├── .gitignore ├── BlazorCodeEditor.sln ├── BlazorCodeEditor ├── App.razor ├── BlazorCodeEditor.csproj ├── Code │ ├── BlazorBootJson.cs │ ├── BlazorResources.cs │ ├── IResourceResolver.cs │ ├── ResourceResolver.cs │ └── WebAssemblyCodeRunner.cs ├── Console │ ├── ConsoleOutput.razor │ ├── ConsoleOutputService.cs │ └── ConsoleOutputViewModel.cs ├── Layout │ ├── MainLayout.razor │ └── MainLayout.razor.css ├── Pages │ └── Home.razor ├── Program.cs ├── Properties │ └── launchSettings.json ├── Webcil │ ├── NT_Structs.cs │ ├── StreamExtensions.cs │ ├── WasmWebcilUnwrapper.cs │ ├── WasmWebcilWrapper.cs │ ├── Webcil.cs │ ├── WebcilContstants.cs │ ├── WebcilConverter.cs │ ├── WebcilConverterUtils.cs │ ├── WebcilSectionHeaderExtensions.cs │ └── WebcilWasmWrapper.cs ├── _Imports.razor └── wwwroot │ ├── app.js │ ├── css │ └── app.css │ ├── favicon.png │ ├── icon-192.png │ ├── index.html │ └── lib │ └── bootstrap │ └── dist │ ├── css │ ├── bootstrap-grid.css │ ├── bootstrap-grid.css.map │ ├── bootstrap-grid.min.css │ ├── bootstrap-grid.min.css.map │ ├── bootstrap-grid.rtl.css │ ├── bootstrap-grid.rtl.css.map │ ├── bootstrap-grid.rtl.min.css │ ├── bootstrap-grid.rtl.min.css.map │ ├── bootstrap-reboot.css │ ├── bootstrap-reboot.css.map │ ├── bootstrap-reboot.min.css │ ├── bootstrap-reboot.min.css.map │ ├── bootstrap-reboot.rtl.css │ ├── bootstrap-reboot.rtl.css.map │ ├── bootstrap-reboot.rtl.min.css │ ├── bootstrap-reboot.rtl.min.css.map │ ├── bootstrap-utilities.css │ ├── bootstrap-utilities.css.map │ ├── bootstrap-utilities.min.css │ ├── bootstrap-utilities.min.css.map │ ├── bootstrap-utilities.rtl.css │ ├── bootstrap-utilities.rtl.css.map │ ├── bootstrap-utilities.rtl.min.css │ ├── bootstrap-utilities.rtl.min.css.map │ ├── bootstrap.css │ ├── bootstrap.css.map │ ├── bootstrap.min.css │ ├── bootstrap.min.css.map │ ├── bootstrap.rtl.css │ ├── bootstrap.rtl.css.map │ ├── bootstrap.rtl.min.css │ └── bootstrap.rtl.min.css.map │ └── js │ ├── bootstrap.bundle.js │ ├── bootstrap.bundle.js.map │ ├── bootstrap.bundle.min.js │ ├── bootstrap.bundle.min.js.map │ ├── bootstrap.esm.js │ ├── bootstrap.esm.js.map │ ├── bootstrap.esm.min.js │ ├── bootstrap.esm.min.js.map │ ├── bootstrap.js │ ├── bootstrap.js.map │ ├── bootstrap.min.js │ └── bootstrap.min.js.map ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Ll]og/ 33 | [Ll]ogs/ 34 | 35 | # Visual Studio 2015/2017 cache/options directory 36 | .vs/ 37 | # Uncomment if you have tasks that create the project's static files in wwwroot 38 | #wwwroot/ 39 | 40 | # Visual Studio 2017 auto generated files 41 | Generated\ Files/ 42 | 43 | # MSTest test Results 44 | [Tt]est[Rr]esult*/ 45 | [Bb]uild[Ll]og.* 46 | 47 | # NUnit 48 | *.VisualState.xml 49 | TestResult.xml 50 | nunit-*.xml 51 | 52 | # Build Results of an ATL Project 53 | [Dd]ebugPS/ 54 | [Rr]eleasePS/ 55 | dlldata.c 56 | 57 | # Benchmark Results 58 | BenchmarkDotNet.Artifacts/ 59 | 60 | # .NET Core 61 | project.lock.json 62 | project.fragment.lock.json 63 | artifacts/ 64 | 65 | # ASP.NET Scaffolding 66 | ScaffoldingReadMe.txt 67 | 68 | # StyleCop 69 | StyleCopReport.xml 70 | 71 | # Files built by Visual Studio 72 | *_i.c 73 | *_p.c 74 | *_h.h 75 | *.ilk 76 | *.meta 77 | *.obj 78 | *.iobj 79 | *.pch 80 | *.pdb 81 | *.ipdb 82 | *.pgc 83 | *.pgd 84 | *.rsp 85 | *.sbr 86 | *.tlb 87 | *.tli 88 | *.tlh 89 | *.tmp 90 | *.tmp_proj 91 | *_wpftmp.csproj 92 | *.log 93 | *.tlog 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio 6 auto-generated project file (contains which files were open etc.) 298 | *.vbp 299 | 300 | # Visual Studio 6 workspace and project file (working project files containing files to include in project) 301 | *.dsw 302 | *.dsp 303 | 304 | # Visual Studio 6 technical files 305 | *.ncb 306 | *.aps 307 | 308 | # Visual Studio LightSwitch build output 309 | **/*.HTMLClient/GeneratedArtifacts 310 | **/*.DesktopClient/GeneratedArtifacts 311 | **/*.DesktopClient/ModelManifest.xml 312 | **/*.Server/GeneratedArtifacts 313 | **/*.Server/ModelManifest.xml 314 | _Pvt_Extensions 315 | 316 | # Paket dependency manager 317 | .paket/paket.exe 318 | paket-files/ 319 | 320 | # FAKE - F# Make 321 | .fake/ 322 | 323 | # CodeRush personal settings 324 | .cr/personal 325 | 326 | # Python Tools for Visual Studio (PTVS) 327 | __pycache__/ 328 | *.pyc 329 | 330 | # Cake - Uncomment if you are using it 331 | # tools/** 332 | # !tools/packages.config 333 | 334 | # Tabs Studio 335 | *.tss 336 | 337 | # Telerik's JustMock configuration file 338 | *.jmconfig 339 | 340 | # BizTalk build output 341 | *.btp.cs 342 | *.btm.cs 343 | *.odx.cs 344 | *.xsd.cs 345 | 346 | # OpenCover UI analysis results 347 | OpenCover/ 348 | 349 | # Azure Stream Analytics local run output 350 | ASALocalRun/ 351 | 352 | # MSBuild Binary and Structured Log 353 | *.binlog 354 | 355 | # NVidia Nsight GPU debugger configuration file 356 | *.nvuser 357 | 358 | # MFractors (Xamarin productivity tool) working folder 359 | .mfractor/ 360 | 361 | # Local History for Visual Studio 362 | .localhistory/ 363 | 364 | # Visual Studio History (VSHistory) files 365 | .vshistory/ 366 | 367 | # BeatPulse healthcheck temp database 368 | healthchecksdb 369 | 370 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 371 | MigrationBackup/ 372 | 373 | # Ionide (cross platform F# VS Code tools) working folder 374 | .ionide/ 375 | 376 | # Fody - auto-generated XML schema 377 | FodyWeavers.xsd 378 | 379 | # VS Code files for those working on multiple tools 380 | .vscode/* 381 | !.vscode/settings.json 382 | !.vscode/tasks.json 383 | !.vscode/launch.json 384 | !.vscode/extensions.json 385 | *.code-workspace 386 | 387 | # Local History for Visual Studio Code 388 | .history/ 389 | 390 | # Windows Installer files from build outputs 391 | *.cab 392 | *.msi 393 | *.msix 394 | *.msm 395 | *.msp 396 | 397 | # JetBrains Rider 398 | *.sln.iml 399 | -------------------------------------------------------------------------------- /BlazorCodeEditor.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorCodeEditor", "BlazorCodeEditor\BlazorCodeEditor.csproj", "{487B46A5-208E-4FB7-8605-0AED9EC5C523}" 4 | EndProject 5 | Global 6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 7 | Debug|Any CPU = Debug|Any CPU 8 | Release|Any CPU = Release|Any CPU 9 | EndGlobalSection 10 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 11 | {487B46A5-208E-4FB7-8605-0AED9EC5C523}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 12 | {487B46A5-208E-4FB7-8605-0AED9EC5C523}.Debug|Any CPU.Build.0 = Debug|Any CPU 13 | {487B46A5-208E-4FB7-8605-0AED9EC5C523}.Release|Any CPU.ActiveCfg = Release|Any CPU 14 | {487B46A5-208E-4FB7-8605-0AED9EC5C523}.Release|Any CPU.Build.0 = Release|Any CPU 15 | EndGlobalSection 16 | EndGlobal 17 | -------------------------------------------------------------------------------- /BlazorCodeEditor/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Not found 8 | 9 |

Sorry, there's nothing at this address.

10 |
11 |
12 |
-------------------------------------------------------------------------------- /BlazorCodeEditor/BlazorCodeEditor.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net9.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | true 11 | 12 | 13 | 14 | false 15 | true 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /BlazorCodeEditor/Code/BlazorBootJson.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace BlazorCodeEditor.Code; 4 | 5 | public class BlazorBootJson 6 | { 7 | public string MainAssemblyName { get; set; } 8 | [JsonPropertyName("resources")] 9 | public BlazorResources Resources { get; set; } 10 | public bool CacheBootResources { get; set; } 11 | public int DebugLevel { get; set; } 12 | public string GlobalizationMode { get; set; } 13 | public Dictionary Extensions { get; set; } 14 | } -------------------------------------------------------------------------------- /BlazorCodeEditor/Code/BlazorResources.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace BlazorCodeEditor.Code; 4 | 5 | public class BlazorResources 6 | { 7 | public string Hash { get; set; } 8 | public Dictionary Assembly { get; set; } 9 | 10 | [JsonPropertyName("fingerprinting")] 11 | public Dictionary Fingerprinting { get; set; } 12 | public Dictionary WasmNative { get; set; } 13 | public Dictionary CoreAssembly { get; set; } 14 | public Dictionary Pdb { get; set; } 15 | public Dictionary> SatelliteResources { get; set; } 16 | public Dictionary JsModuleNative { get; set; } 17 | public Dictionary JsModuleRuntime { get; set; } 18 | public Dictionary LibraryInitializers { get; set; } 19 | public Dictionary ModulesAfterConfigLoaded { get; set; } 20 | } -------------------------------------------------------------------------------- /BlazorCodeEditor/Code/IResourceResolver.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorCodeEditor.Code; 2 | 3 | public interface IResourceResolver 4 | { 5 | public Task ResolveResource(string resource); 6 | } -------------------------------------------------------------------------------- /BlazorCodeEditor/Code/ResourceResolver.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json; 2 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 3 | 4 | namespace BlazorCodeEditor.Code; 5 | 6 | public class ResourceResolver : IResourceResolver 7 | { 8 | private readonly IWebAssemblyHostEnvironment _env; 9 | private readonly HttpClient _httpClient; 10 | private readonly Lazy>> _resourceMappings; 11 | 12 | public ResourceResolver(IWebAssemblyHostEnvironment env) 13 | { 14 | _env = env; 15 | _httpClient = CreateHttpClient(); 16 | _resourceMappings = new Lazy>>(FetchResourcesAsync); 17 | } 18 | 19 | private HttpClient CreateHttpClient() 20 | { 21 | var isDevelopment = _env.IsDevelopment(); 22 | var baseAddress = isDevelopment 23 | ? "https://localhost:7158" 24 | : "https://blazor-code-editor.azurewebsites.net"; 25 | 26 | var httpClient = new HttpClient 27 | { 28 | BaseAddress = new Uri(baseAddress) 29 | }; 30 | 31 | return httpClient; 32 | } 33 | 34 | public async Task ResolveResource(string logicalName) 35 | { 36 | if (string.IsNullOrWhiteSpace(logicalName)) 37 | throw new ArgumentException("Logical name cannot be null or empty.", nameof(logicalName)); 38 | 39 | var resources = await _resourceMappings.Value; 40 | 41 | if (resources.TryGetValue(logicalName, out var hashedName)) 42 | { 43 | return hashedName; 44 | } 45 | 46 | throw new FileNotFoundException($"Resource '{logicalName}' not found in blazor.boot.json."); 47 | } 48 | 49 | private async Task> FetchResourcesAsync() 50 | { 51 | var baseUri = GetBaseUri(); 52 | var bootJsonUrl = $"{baseUri}/_framework/blazor.boot.json"; 53 | var bootJsonContent = await _httpClient.GetStringAsync(bootJsonUrl); 54 | 55 | var bootJson = JsonSerializer.Deserialize(bootJsonContent); 56 | if (bootJson?.Resources?.Fingerprinting == null) 57 | { 58 | throw new InvalidOperationException("Invalid blazor.boot.json structure."); 59 | } 60 | 61 | // Combine all relevant resources into one dictionary for easy lookup 62 | var allResources = new Dictionary(); 63 | 64 | foreach (var resource in bootJson.Resources.Fingerprinting.Where(resource => !allResources.ContainsKey(resource.Value))) 65 | { 66 | allResources.Add(resource.Value, resource.Key); 67 | } 68 | 69 | return allResources; 70 | } 71 | 72 | private string GetBaseUri() 73 | { 74 | return _httpClient.BaseAddress.ToString().TrimEnd('/'); 75 | } 76 | } -------------------------------------------------------------------------------- /BlazorCodeEditor/Code/WebAssemblyCodeRunner.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Reflection; 3 | using BlazorCodeEditor.Console; 4 | using BlazorCodeEditor.Webcil; 5 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 6 | using Microsoft.CodeAnalysis; 7 | using Microsoft.CodeAnalysis.CSharp; 8 | 9 | namespace BlazorCodeEditor.Code; 10 | 11 | public class WebAssemblyCodeRunner : ICodeExecutor 12 | { 13 | private readonly ConsoleOutputService _consoleOutputService; 14 | private readonly IResourceResolver _resourceResolver; 15 | private readonly IWebAssemblyHostEnvironment _env; 16 | 17 | public WebAssemblyCodeRunner(ConsoleOutputService consoleOutputService, IResourceResolver resourceResolver, IWebAssemblyHostEnvironment env) 18 | { 19 | _consoleOutputService = consoleOutputService; 20 | _resourceResolver = resourceResolver; 21 | _env = env; 22 | } 23 | 24 | public async Task ExecuteAsync(string code, CancellationToken cancellationToken = default) 25 | { 26 | var stopwatch = Stopwatch.StartNew(); 27 | 28 | var syntaxTree = CSharpSyntaxTree.ParseText(code); 29 | _consoleOutputService.AddLog("Parsed syntax tree.", ConsoleSeverity.Debug); 30 | 31 | var references = new List 32 | { 33 | await GetMetadataReferenceAsync("System.Private.CoreLib.wasm"), 34 | await GetMetadataReferenceAsync("System.Runtime.wasm"), 35 | await GetMetadataReferenceAsync("System.Console.wasm"), 36 | await GetMetadataReferenceAsync("System.Collections.wasm"), 37 | }; 38 | 39 | stopwatch.Restart(); 40 | var compilation = CSharpCompilation.Create( 41 | "InMemoryAssembly", 42 | new[] { syntaxTree }, 43 | references, 44 | new CSharpCompilationOptions( 45 | OutputKind.ConsoleApplication, 46 | metadataImportOptions: MetadataImportOptions.All, 47 | allowUnsafe: true, 48 | reportSuppressedDiagnostics: true 49 | ) 50 | ); 51 | _consoleOutputService.AddLog($"Compilation completed in {stopwatch.ElapsedMilliseconds} ms.", ConsoleSeverity.Debug); 52 | 53 | foreach (var diagnostic in compilation.GetDiagnostics()) 54 | { 55 | var severity = diagnostic.Severity switch 56 | { 57 | DiagnosticSeverity.Error => ConsoleSeverity.Error, 58 | DiagnosticSeverity.Warning => ConsoleSeverity.Warning, 59 | _ => ConsoleSeverity.Info 60 | }; 61 | _consoleOutputService.AddLog(diagnostic.GetMessage(), severity); 62 | } 63 | 64 | stopwatch.Restart(); 65 | using var memoryStream = new MemoryStream(); 66 | var emitResult = compilation.Emit(memoryStream); 67 | 68 | _consoleOutputService.AddLog($"Emit completed in {stopwatch.ElapsedMilliseconds} ms.", ConsoleSeverity.Debug); 69 | 70 | if (!emitResult.Success) 71 | { 72 | foreach (var diagnostic in emitResult.Diagnostics) 73 | { 74 | var severity = diagnostic.Severity switch 75 | { 76 | DiagnosticSeverity.Error => ConsoleSeverity.Error, 77 | DiagnosticSeverity.Warning => ConsoleSeverity.Warning, 78 | _ => ConsoleSeverity.Info 79 | }; 80 | _consoleOutputService.AddLog(diagnostic.GetMessage(), severity); 81 | } 82 | return; 83 | } 84 | 85 | memoryStream.Seek(0, SeekOrigin.Begin); 86 | var assembly = Assembly.Load(memoryStream.ToArray()); 87 | _consoleOutputService.AddLog($"Assembly loaded: {assembly.FullName}", ConsoleSeverity.Debug); 88 | 89 | var entryPoint = assembly.EntryPoint; 90 | if (entryPoint == null) 91 | { 92 | _consoleOutputService.AddLog("No entry point found in the assembly.", ConsoleSeverity.Error); 93 | return; 94 | } 95 | 96 | try 97 | { 98 | stopwatch.Restart(); 99 | var parameters = entryPoint.GetParameters(); 100 | var invokeArgs = parameters.Length == 1 && parameters[0].ParameterType == typeof(string[]) 101 | ? new object?[] { Array.Empty() } 102 | : null; 103 | 104 | entryPoint.Invoke(null, invokeArgs); 105 | _consoleOutputService.AddLog($"Execution completed in {stopwatch.ElapsedMilliseconds} ms.", ConsoleSeverity.Debug); 106 | } 107 | catch (Exception ex) 108 | { 109 | var exceptionMessage = ex.InnerException != null 110 | ? $"Unhandled Exception: {ex.InnerException.Message}" 111 | : $"Unhandled Exception: {ex.Message}"; 112 | _consoleOutputService.AddLog(exceptionMessage, ConsoleSeverity.Error); 113 | } 114 | } 115 | 116 | private async Task ResolveResourceStreamUri(string resource) 117 | { 118 | var resolved = await _resourceResolver.ResolveResource(resource); 119 | return $"/_framework/{resolved}"; 120 | } 121 | 122 | private async Task GetMetadataReferenceAsync(string wasmModule) 123 | { 124 | var httpClient = CreateHttpClient(); 125 | await using var stream = await httpClient.GetStreamAsync(await ResolveResourceStreamUri(wasmModule)); 126 | var peBytes = WebcilConverterUtil.ConvertFromWebcil(stream); 127 | 128 | using var peStream = new MemoryStream(peBytes); 129 | return MetadataReference.CreateFromStream(peStream); 130 | } 131 | 132 | private HttpClient CreateHttpClient() 133 | { 134 | var isDevelopment = _env.IsDevelopment(); 135 | var baseAddress = isDevelopment 136 | ? "https://localhost:7158" 137 | : "https://blazor-code-editor.azurewebsites.net"; 138 | 139 | var httpClient = new HttpClient 140 | { 141 | BaseAddress = new Uri(baseAddress) 142 | }; 143 | 144 | return httpClient; 145 | } 146 | } 147 | 148 | public interface ICodeExecutor 149 | { 150 | public Task ExecuteAsync(string code, CancellationToken cancellationToken = default); 151 | } -------------------------------------------------------------------------------- /BlazorCodeEditor/Console/ConsoleOutput.razor: -------------------------------------------------------------------------------- 1 | @inject ConsoleOutputService ConsoleOutputService 2 | @implements IDisposable 3 |
4 | 5 |
6 |
7 | 8 |
9 | 10 |
11 |
    12 | @foreach (var log in logs) 13 | { 14 |
  • 15 | [@log.Timestamp.ToString("HH:mm:ss")] @log.Message 16 |
  • 17 | } 18 |
19 |
20 |
21 | @code { 22 | private List logs = new(); 23 | 24 | protected override void OnInitialized() 25 | { 26 | ConsoleOutputService.OnConsoleOutputReceived += HandleConsoleOutputReceived; 27 | ConsoleOutputService.OnConsoleCleared += HandleConsoleCleared; 28 | 29 | logs = ConsoleOutputService.Logs.ToList(); 30 | } 31 | 32 | private void HandleConsoleOutputReceived(ConsoleOutputViewModel log) 33 | { 34 | logs.Add(log); 35 | StateHasChanged(); 36 | } 37 | 38 | private void HandleConsoleCleared() 39 | { 40 | logs.Clear(); 41 | StateHasChanged(); 42 | } 43 | 44 | private async Task ClearLogs() 45 | { 46 | ConsoleOutputService.ClearLogs(); 47 | } 48 | 49 | public void Dispose() 50 | { 51 | ConsoleOutputService.OnConsoleOutputReceived -= HandleConsoleOutputReceived; 52 | ConsoleOutputService.OnConsoleCleared -= HandleConsoleCleared; 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /BlazorCodeEditor/Console/ConsoleOutputService.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.JSInterop; 2 | 3 | namespace BlazorCodeEditor.Console 4 | { 5 | public class ConsoleOutputService : IAsyncDisposable 6 | { 7 | private readonly IJSRuntime _jsRuntime; 8 | private IJSObjectReference? _jsModule; 9 | 10 | private readonly Lazy> moduleTask; 11 | 12 | 13 | public event Action? OnConsoleOutputReceived; 14 | 15 | public event Action? OnConsoleCleared; 16 | 17 | private readonly List _logs = new(); 18 | 19 | public IReadOnlyList Logs => _logs.AsReadOnly(); 20 | 21 | private DotNetObjectReference? _dotNetObjectReference; 22 | 23 | public ConsoleOutputService(IJSRuntime jsRuntime) 24 | { 25 | _jsRuntime = jsRuntime; 26 | _dotNetObjectReference = DotNetObjectReference.Create(this); 27 | 28 | InitializeAsync(); 29 | } 30 | 31 | public async void InitializeAsync() 32 | { 33 | // Load JavaScript module 34 | _jsModule = await _jsRuntime.InvokeAsync("import", "./app.js"); 35 | 36 | // Hook into JavaScript console 37 | await _jsModule.InvokeVoidAsync("captureConsoleOutput", _dotNetObjectReference); 38 | } 39 | 40 | [JSInvokable] 41 | public void OnConsoleLog(string message) 42 | { 43 | AddLog(message, ConsoleSeverity.Info); // Info severity for logs 44 | } 45 | 46 | [JSInvokable] 47 | public void OnConsoleError(string message) 48 | { 49 | AddLog(message, ConsoleSeverity.Error); // Error severity for errors 50 | } 51 | 52 | [JSInvokable] 53 | public void OnConsoleWarn(string message) 54 | { 55 | AddLog(message, ConsoleSeverity.Warning); // Warning severity for warnings 56 | } 57 | 58 | public void AddLog(string message, ConsoleSeverity severity) 59 | { 60 | var logEntry = new ConsoleOutputViewModel 61 | { 62 | Timestamp = DateTimeOffset.Now, 63 | Severity = severity, 64 | Message = message 65 | }; 66 | 67 | _logs.Add(logEntry); 68 | OnConsoleOutputReceived?.Invoke(logEntry); 69 | } 70 | 71 | public void ClearLogs() 72 | { 73 | _logs.Clear(); 74 | OnConsoleCleared?.Invoke(); 75 | } 76 | 77 | public async ValueTask DisposeAsync() 78 | { 79 | if (_jsModule is not null) 80 | { 81 | await _jsModule.DisposeAsync(); 82 | } 83 | } 84 | } 85 | } -------------------------------------------------------------------------------- /BlazorCodeEditor/Console/ConsoleOutputViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorCodeEditor.Console; 2 | 3 | public class ConsoleOutputViewModel 4 | { 5 | /// 6 | /// Time the output was received 7 | /// 8 | public DateTimeOffset Timestamp { get; set; } 9 | 10 | /// 11 | /// Severity of the output 12 | /// 13 | public ConsoleSeverity Severity { get; set; } 14 | 15 | /// 16 | /// Console output 17 | /// 18 | public string Message { get; set; } = string.Empty; 19 | } 20 | 21 | public enum ConsoleSeverity 22 | { 23 | Debug, 24 | Info, 25 | Warning, 26 | Error, 27 | } 28 | -------------------------------------------------------------------------------- /BlazorCodeEditor/Layout/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 |
3 |
4 |
5 | @Body 6 |
7 |
8 |
-------------------------------------------------------------------------------- /BlazorCodeEditor/Layout/MainLayout.razor.css: -------------------------------------------------------------------------------- 1 | .page { 2 | position: relative; 3 | display: flex; 4 | flex-direction: column; 5 | } 6 | 7 | main { 8 | flex: 1; 9 | } 10 | 11 | .sidebar { 12 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 13 | } 14 | 15 | .top-row { 16 | background-color: #f7f7f7; 17 | border-bottom: 1px solid #d6d5d5; 18 | justify-content: flex-end; 19 | height: 3.5rem; 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | .top-row ::deep a, .top-row ::deep .btn-link { 25 | white-space: nowrap; 26 | margin-left: 1.5rem; 27 | text-decoration: none; 28 | } 29 | 30 | .top-row ::deep a:hover, .top-row ::deep .btn-link:hover { 31 | text-decoration: underline; 32 | } 33 | 34 | .top-row ::deep a:first-child { 35 | overflow: hidden; 36 | text-overflow: ellipsis; 37 | } 38 | 39 | @media (max-width: 640.98px) { 40 | .top-row { 41 | justify-content: space-between; 42 | } 43 | 44 | .top-row ::deep a, .top-row ::deep .btn-link { 45 | margin-left: 0; 46 | } 47 | } 48 | 49 | @media (min-width: 641px) { 50 | .page { 51 | flex-direction: row; 52 | } 53 | 54 | .sidebar { 55 | width: 250px; 56 | height: 100vh; 57 | position: sticky; 58 | top: 0; 59 | } 60 | 61 | .top-row { 62 | position: sticky; 63 | top: 0; 64 | z-index: 1; 65 | } 66 | 67 | .top-row.auth ::deep a:first-child { 68 | flex: 1; 69 | text-align: right; 70 | width: 0; 71 | } 72 | 73 | .top-row, article { 74 | padding-left: 2rem !important; 75 | padding-right: 1.5rem !important; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /BlazorCodeEditor/Pages/Home.razor: -------------------------------------------------------------------------------- 1 | @using System.Runtime.InteropServices 2 | @using BlazorCodeEditor.Code 3 | @using BlazorMonaco 4 | @using BlazorCodeEditor.Console 5 | @using BlazorMonaco.Editor 6 | @page "/" 7 | 8 | Editor 9 | 17 | 18 |
19 | 20 |
21 | 22 |
23 | 24 |
25 | 26 | @code { 27 | private StandaloneCodeEditor _editor = default!; 28 | 29 | [Inject] protected ICodeExecutor CodeRunner { get; set; } = default!; 30 | 31 | private StandaloneEditorConstructionOptions _options = new() 32 | { 33 | Language = "csharp", 34 | Value = "using System;\nConsole.WriteLine(\"Hello World!\");" 35 | }; 36 | 37 | private StandaloneEditorConstructionOptions GetOptions(StandaloneCodeEditor editor) => _options; 38 | 39 | protected async Task RunCodeAsync() 40 | { 41 | var text = await _editor.GetValue(); 42 | await CodeRunner.ExecuteAsync(text, CancellationToken.None); 43 | 44 | } 45 | } -------------------------------------------------------------------------------- /BlazorCodeEditor/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components.Web; 2 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 3 | using BlazorCodeEditor; 4 | using BlazorCodeEditor.Code; 5 | using BlazorCodeEditor.Console; 6 | 7 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 8 | builder.RootComponents.Add("#app"); 9 | builder.RootComponents.Add("head::after"); 10 | 11 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); 12 | 13 | builder.Services.AddSingleton (); 14 | builder.Services.AddSingleton(); 15 | builder.Services.AddSingleton(); 16 | 17 | await builder.Build().RunAsync(); -------------------------------------------------------------------------------- /BlazorCodeEditor/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/launchsettings.json", 3 | "profiles": { 4 | "http": { 5 | "commandName": "Project", 6 | "dotnetRunMessages": true, 7 | "launchBrowser": true, 8 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 9 | "applicationUrl": "http://localhost:5245", 10 | "environmentVariables": { 11 | "ASPNETCORE_ENVIRONMENT": "Development" 12 | } 13 | }, 14 | "https": { 15 | "commandName": "Project", 16 | "dotnetRunMessages": true, 17 | "launchBrowser": true, 18 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 19 | "applicationUrl": "https://localhost:7158;http://localhost:5245", 20 | "environmentVariables": { 21 | "ASPNETCORE_ENVIRONMENT": "Development" 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /BlazorCodeEditor/Webcil/NT_Structs.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace BlazorCodeEditor.Webcil; 4 | 5 | internal static class Constants 6 | { 7 | internal const ushort IMAGE_FILE_MACHINE_I386 = 0x014c; 8 | internal const ushort IMAGE_FILE_MACHINE_IA64 = 0x0200; 9 | internal const ushort IMAGE_FILE_MACHINE_AMD64 = 0x8664; 10 | } 11 | 12 | /// 13 | /// https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-image_data_directory 14 | /// 15 | [StructLayout(LayoutKind.Sequential, Pack = 1)] 16 | internal struct IMAGE_DATA_DIRECTORY 17 | { 18 | public uint VirtualAddress; // DWORD VirtualAddress 19 | public uint Size; // DWORD Size 20 | } 21 | 22 | /// 23 | /// https://www.nirsoft.net/kernel_struct/vista/IMAGE_DOS_HEADER.html 24 | /// 25 | [StructLayout(LayoutKind.Sequential, Pack = 1)] 26 | internal struct IMAGE_DOS_HEADER 27 | { 28 | public ushort MagicNumber; // e_magic - Magic number (The value “MZ” are the initials of the PE designer Mark Zbikowski) 29 | public ushort BytesOnLastPageOfFile; // e_cblp - Bytes on last page of file 30 | public ushort PagesInFile; // e_cp - Pages in file 31 | public ushort Relocations; // e_crlc - Relocations 32 | public ushort SizeOfHeaderInParagraphs; // e_cparhdr - Size of header in paragraphs 33 | public ushort MinimumExtraParagraphs; // e_minalloc - Minimum extra paragraphs needed 34 | public ushort MaximumExtraParagraphs; // e_maxalloc - Maximum extra paragraphs needed 35 | public ushort InitialSS; // e_ss - Initial (relative) SS value 36 | public ushort InitialSP; // e_sp - Initial SP value 37 | public ushort Checksum; // e_csum - Checksum 38 | public ushort InitialIP; // e_ip - Initial IP value 39 | public ushort InitialCS; // e_cs - Initial (relative) CS value 40 | public ushort AddressOfRelocationTable; // e_lfarlc - File address of relocation table 41 | public ushort OverlayNumber; // e_ovno - Overlay number 42 | 43 | [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] 44 | public ushort[] ReservedWords1; // e_res - Reserved words 45 | 46 | public ushort OEMIdentifier; // e_oemid - OEM identifier (for e_oeminfo) 47 | public ushort OEMInformation; // e_oeminfo - OEM information; e_oemid specific 48 | 49 | [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] 50 | public ushort[] ReservedWords2; // e_res2 - Reserved words 51 | 52 | public int FileAddressOfNewExeHeader; // e_lfanew - File address of new exe header 53 | } 54 | 55 | /// 56 | /// https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-image_file_header 57 | /// 58 | [StructLayout(LayoutKind.Sequential, Pack = 1)] 59 | internal struct IMAGE_FILE_HEADER 60 | { 61 | /// 62 | /// The architecture type of the computer. 63 | /// An image file can only be run on the specified computer or a system that emulates the specified computer. 64 | /// 65 | public ushort Machine; 66 | 67 | /// 68 | /// The number of sections. 69 | /// This indicates the size of the section table, which immediately follows the headers. 70 | /// Note that the Windows loader limits the number of sections to 96. 71 | /// 72 | public ushort NumberOfSections; 73 | 74 | /// 75 | /// The low 32 bits of the time stamp of the image. 76 | /// This represents the date and time the image was created by the linker. 77 | /// The value is represented in the number of seconds elapsed since midnight (00:00:00), January 1, 1970, Universal Coordinated Time, according to the system clock. 78 | /// 79 | public uint TimeDateStamp; 80 | 81 | public uint PointerToSymbolTable; 82 | 83 | public uint NumberOfSymbols; 84 | 85 | public ushort SizeOfOptionalHeader; 86 | 87 | public ushort Characteristics; 88 | } 89 | 90 | /// 91 | /// https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-image_nt_headers32 92 | /// 93 | [StructLayout(LayoutKind.Sequential, Pack = 1)] 94 | internal struct IMAGE_NT_HEADERS32 95 | { 96 | public uint Signature; // DWORD Signature 97 | public IMAGE_FILE_HEADER FileHeader; // IMAGE_FILE_HEADER FileHeader 98 | public IMAGE_OPTIONAL_HEADER32 OptionalHeader; // IMAGE_OPTIONAL_HEADER32 OptionalHeader 99 | } 100 | 101 | /// 102 | /// https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-image_nt_headers64 103 | /// 104 | [StructLayout(LayoutKind.Sequential, Pack = 1)] 105 | internal struct IMAGE_NT_HEADERS64 106 | { 107 | public uint Signature; // DWORD Signature 108 | public IMAGE_FILE_HEADER FileHeader; // IMAGE_FILE_HEADER FileHeader 109 | public IMAGE_OPTIONAL_HEADER64 OptionalHeader; // IMAGE_OPTIONAL_HEADER32 OptionalHeader 110 | } 111 | 112 | /// 113 | /// https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-image_optional_header32 114 | /// 115 | [StructLayout(LayoutKind.Sequential, Pack = 1)] 116 | internal struct IMAGE_OPTIONAL_HEADER32 117 | { 118 | public ushort Magic; 119 | public byte MajorLinkerVersion; 120 | public byte MinorLinkerVersion; 121 | public uint SizeOfCode; 122 | public uint SizeOfInitializedData; 123 | public uint SizeOfUninitializedData; 124 | 125 | /// 126 | /// A pointer to the entry point function, relative to the image base address. 127 | /// For executable files, this is the starting address. 128 | /// For device drivers, this is the address of the initialization function. 129 | /// The entry point function is optional for DLLs. 130 | /// When no entry point is present, this member is zero. 131 | /// 132 | public uint AddressOfEntryPoint; 133 | 134 | /// 135 | /// A pointer to the beginning of the code section, relative to the image base. 136 | /// 137 | public uint BaseOfCode; 138 | 139 | /// 140 | /// A pointer to the beginning of the data section, relative to the image base. 141 | /// 142 | public uint BaseOfData; 143 | 144 | /// 145 | /// The preferred address of the first byte of the image when it is loaded in memory. 146 | /// This value is a multiple of 64K bytes. 147 | /// The default value for DLLs is 0x10000000. 148 | /// The default value for applications is 0x00400000, except on Windows CE where it is 0x00010000. 149 | /// 150 | public uint ImageBase; 151 | 152 | public uint SectionAlignment; 153 | 154 | public uint FileAlignment; 155 | 156 | public ushort MajorOperatingSystemVersion; 157 | public ushort MinorOperatingSystemVersion; 158 | public ushort MajorImageVersion; 159 | public ushort MinorImageVersion; 160 | public ushort MajorSubsystemVersion; 161 | public ushort MinorSubsystemVersion; 162 | public uint Win32VersionValue; 163 | 164 | /// 165 | /// The size of the image, in bytes, including all headers. Must be a multiple of SectionAlignment. 166 | /// 167 | public uint SizeOfImage; 168 | 169 | /// 170 | /// The combined size of the following items, rounded to a multiple of the value specified in the FileAlignment member. 171 | /// - e_lfanew member of IMAGE_DOS_HEADER 172 | /// - 4 byte signature 173 | /// - size of IMAGE_FILE_HEADER 174 | /// - size of optional header 175 | /// - size of all section headers 176 | /// 177 | public uint SizeOfHeaders; 178 | public uint CheckSum; 179 | public ushort Subsystem; 180 | public ushort DllCharacteristics; 181 | public uint SizeOfStackReserve; 182 | public uint SizeOfStackCommit; 183 | public uint SizeOfHeapReserve; 184 | public uint SizeOfHeapCommit; 185 | public uint LoaderFlags; 186 | 187 | /// 188 | /// The number of directory entries in the remainder of the optional header. Each entry describes a location and size. 189 | /// 190 | public uint NumberOfRvaAndSizes; 191 | 192 | [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x10)] 193 | public IMAGE_DATA_DIRECTORY[] DataDirectory; 194 | } 195 | 196 | /// 197 | /// https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-image_optional_header64 198 | /// 199 | [StructLayout(LayoutKind.Sequential, Pack = 1)] 200 | internal struct IMAGE_OPTIONAL_HEADER64 201 | { 202 | public ushort Magic; 203 | public byte MajorLinkerVersion; 204 | public byte MinorLinkerVersion; 205 | public uint SizeOfCode; 206 | public uint SizeOfInitializedData; 207 | public uint SizeOfUninitializedData; 208 | public uint AddressOfEntryPoint; 209 | public uint BaseOfCode; 210 | public ulong ImageBase; 211 | public uint SectionAlignment; 212 | public uint FileAlignment; 213 | public ushort MajorOperatingSystemVersion; 214 | public ushort MinorOperatingSystemVersion; 215 | public ushort MajorImageVersion; 216 | public ushort MinorImageVersion; 217 | public ushort MajorSubsystemVersion; 218 | public ushort MinorSubsystemVersion; 219 | public uint Win32VersionValue; 220 | public uint SizeOfImage; 221 | public uint SizeOfHeaders; 222 | public uint CheckSum; 223 | public ushort Subsystem; 224 | public ushort DllCharacteristics; 225 | public ulong SizeOfStackReserve; 226 | public ulong SizeOfStackCommit; 227 | public ulong SizeOfHeapReserve; 228 | public ulong SizeOfHeapCommit; 229 | public uint LoaderFlags; 230 | public uint NumberOfRvaAndSizes; 231 | [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x10)] 232 | public IMAGE_DATA_DIRECTORY[] DataDirectory; 233 | } 234 | 235 | /// 236 | /// https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-image_section_header 237 | /// 238 | [StructLayout(LayoutKind.Sequential, Pack = 1)] 239 | internal struct IMAGE_SECTION_HEADER 240 | { 241 | /// 242 | /// An 8-byte, null-padded UTF-8 string. 243 | /// There is no terminating null character if the string is exactly eight characters long. 244 | /// For longer names, this member contains a forward slash (/) followed by an ASCII representation of a decimal number that is an offset into the string table. 245 | /// Executable images do not use a string table and do not support section names longer than eight characters. 246 | /// 247 | [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] 248 | public byte[] Name; 249 | 250 | public UnionType Misc; 251 | 252 | /// 253 | /// The address of the first byte of the section when loaded into memory, relative to the image base. 254 | /// For object files, this is the address of the first byte before relocation is applied. 255 | /// 256 | public uint VirtualAddress; 257 | 258 | /// 259 | /// The size of the initialized data on disk, in bytes. 260 | /// This value must be a multiple of the FileAlignment member of the IMAGE_OPTIONAL_HEADER structure. 261 | /// If this value is less than the VirtualSize member, the remainder of the section is filled with zeroes. 262 | /// If the section contains only uninitialized data, the member is zero. 263 | /// 264 | public uint SizeOfRawData; 265 | 266 | /// 267 | /// A file pointer to the first page within the COFF file. 268 | /// This value must be a multiple of the FileAlignment member of the IMAGE_OPTIONAL_HEADER structure. 269 | /// If a section contains only uninitialized data, set this member is zero. 270 | /// 271 | public uint PointerToRawData; 272 | 273 | public uint PointerToRelocations; 274 | 275 | public uint PointerToLinenumbers; 276 | 277 | public ushort NumberOfRelocations; 278 | 279 | public ushort NumberOfLinenumbers; 280 | 281 | public uint Characteristics; 282 | 283 | [StructLayout(LayoutKind.Explicit)] 284 | public struct UnionType 285 | { 286 | [FieldOffset(0)] 287 | public uint PhysicalAddress; 288 | 289 | /// 290 | /// The total size of the section when loaded into memory, in bytes. If this value is greater than the SizeOfRawData member, the section is filled with zeroes. 291 | /// This field is valid only for executable images and should be set to 0 for object files. 292 | /// 293 | [FieldOffset(0)] 294 | public uint VirtualSize; 295 | } 296 | } -------------------------------------------------------------------------------- /BlazorCodeEditor/Webcil/StreamExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace BlazorCodeEditor.Webcil; 4 | 5 | internal static class StreamExtensions 6 | { 7 | internal static void WriteStruct(this Stream stream, T structData) where T : struct 8 | { 9 | var bytes = StructToBytes(structData); 10 | stream.Write(bytes); 11 | } 12 | 13 | private static byte[] StructToBytes(T structData) where T : struct 14 | { 15 | int size = Marshal.SizeOf(structData); 16 | byte[] byteArray = new byte[size]; 17 | nint ptr = Marshal.AllocHGlobal(size); 18 | 19 | try 20 | { 21 | Marshal.StructureToPtr(structData, ptr, false); 22 | Marshal.Copy(ptr, byteArray, 0, size); 23 | } 24 | finally 25 | { 26 | Marshal.FreeHGlobal(ptr); 27 | } 28 | 29 | return byteArray; 30 | } 31 | } -------------------------------------------------------------------------------- /BlazorCodeEditor/Webcil/WasmWebcilUnwrapper.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorCodeEditor.Webcil; 2 | 3 | internal class WasmWebcilUnwrapper : IDisposable 4 | { 5 | private readonly Stream _wasmStream; 6 | 7 | public WasmWebcilUnwrapper(Stream wasmStream) 8 | { 9 | _wasmStream = wasmStream; 10 | } 11 | 12 | public void WriteUnwrapped(Stream outputStream) 13 | { 14 | ValidateWasmPrefix(); 15 | 16 | using var reader = new BinaryReader(_wasmStream, System.Text.Encoding.UTF8, leaveOpen: true); 17 | var bytes = ReadDataSection(reader); 18 | outputStream.Write(bytes); 19 | } 20 | 21 | private void ValidateWasmPrefix() 22 | { 23 | // Create a byte array matching the length of the prefix. 24 | var prefix = WasmWebcilWrapper.GetPrefix(); 25 | var buffer = new byte[prefix.Length]; 26 | int bytesRead = _wasmStream.Read(buffer, 0, buffer.Length); 27 | if (bytesRead < buffer.Length) 28 | { 29 | throw new InvalidOperationException("Unable to read Wasm prefix."); 30 | } 31 | 32 | // Compare the read prefix with the expected one. 33 | if (!buffer.SequenceEqual(prefix)) 34 | { 35 | throw new InvalidOperationException("Invalid Wasm prefix."); 36 | } 37 | } 38 | 39 | private static void SkipSection(BinaryReader reader) 40 | { 41 | var size = ULEB128Decode(reader); 42 | reader.BaseStream.Seek(size, SeekOrigin.Current); 43 | } 44 | 45 | private static byte[] ReadDataSection(BinaryReader reader) 46 | { 47 | // Skip until we find the data section, which contains the Webcil payload. 48 | byte[] buffer = new byte[1]; 49 | while (true) 50 | { 51 | // Read the Data section 52 | var dataRead = reader.Read(buffer, 0, 1); 53 | if (dataRead == 0) 54 | { 55 | throw new InvalidOperationException("Unable to read Data Section."); 56 | } 57 | 58 | // Check the Data section (ID = 11) 59 | if (buffer[0] == 11) 60 | { 61 | break; 62 | } 63 | 64 | // Skip other sections by reading and ignoring their content. 65 | SkipSection(reader); 66 | } 67 | 68 | // Read and ignore the size of the data section. 69 | ULEB128Decode(reader); 70 | 71 | // Read the number of segments. 72 | int segmentsCount = (int)ULEB128Decode(reader); 73 | int lastSegment = segmentsCount - 1; 74 | for (int segmentIndex = 0; segmentIndex < segmentsCount; segmentIndex++) 75 | { 76 | // Ignore segmentType (1 = passive segment) 77 | var segmentType = reader.Read(buffer, 0, 1); 78 | if (segmentType != 1) 79 | { 80 | throw new InvalidOperationException($"Unexpected segment code for segment {segmentIndex}."); 81 | } 82 | 83 | // Read the segment size. 84 | var segmentSize = ULEB128Decode(reader); 85 | 86 | // The actual Webcil payload is expected to be in the last segment. 87 | if (segmentIndex == lastSegment) 88 | { 89 | return reader.ReadBytes((int)segmentSize); 90 | } 91 | 92 | // Skip other segments. 93 | reader.BaseStream.Seek(segmentSize, SeekOrigin.Current); 94 | } 95 | 96 | throw new Exception("Unable to read DataSection."); 97 | } 98 | 99 | /// 100 | /// Decodes a variable-length quantity (VLQ) encoded as unsigned LEB128. 101 | /// LEB128 (Little Endian Base 128) is used to encode integers in a variable number of bytes. 102 | /// The method reads bytes from the provided binary reader and decodes them into an unsigned integer. 103 | /// 104 | /// The binary reader from which to read the ULEB128 encoded data. 105 | /// The decoded unsigned integer from the ULEB128 encoded data. 106 | private static uint ULEB128Decode(BinaryReader reader) 107 | { 108 | uint result = 0; 109 | int shift = 0; 110 | byte byteValue; 111 | 112 | do 113 | { 114 | byteValue = reader.ReadByte(); 115 | uint byteAsUInt = byteValue & 0x7Fu; 116 | result |= byteAsUInt << shift; 117 | shift += 7; 118 | } while ((byteValue & 0x80) != 0); 119 | 120 | return result; 121 | } 122 | 123 | public void Dispose() 124 | { 125 | _wasmStream.Dispose(); 126 | } 127 | } -------------------------------------------------------------------------------- /BlazorCodeEditor/Webcil/WasmWebcilWrapper.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace BlazorCodeEditor.Webcil; 4 | 5 | public class WasmWebcilWrapper 6 | { 7 | private static readonly FieldInfo FieldInfoPrefix = typeof(WebcilWasmWrapper).GetField("s_wasmWrapperPrefix", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField)!; 8 | 9 | public static byte[] GetPrefix() 10 | { 11 | #if NET7_0_OR_GREATER 12 | return GetPrefixValue>().ToArray(); 13 | #else 14 | return GetPrefixValue(); 15 | #endif 16 | } 17 | 18 | private static T GetPrefixValue() 19 | { 20 | return (T)FieldInfoPrefix.GetValue(null)!; 21 | } 22 | } -------------------------------------------------------------------------------- /BlazorCodeEditor/Webcil/Webcil.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace BlazorCodeEditor.Webcil 4 | { 5 | public class Webcil 6 | { 7 | /// 8 | /// The header of a WebCIL file. 9 | /// 10 | /// 11 | /// 12 | /// The header is a subset of the PE, COFF and CLI headers that are needed by the mono runtime to load managed assemblies. 13 | /// 14 | [StructLayout(LayoutKind.Sequential, Pack = 1)] 15 | public unsafe struct WebcilHeader 16 | { 17 | public fixed byte id[4]; // 'W' 'b' 'I' 'L' 18 | // 4 bytes 19 | public ushort version_major; // 0 20 | public ushort version_minor; // 0 21 | // 8 bytes 22 | 23 | public ushort coff_sections; 24 | public ushort reserved0; // 0 25 | // 12 bytes 26 | public uint pe_cli_header_rva; 27 | public uint pe_cli_header_size; 28 | // 20 bytes 29 | public uint pe_debug_rva; 30 | public uint pe_debug_size; 31 | // 28 bytes 32 | } 33 | 34 | /// 35 | /// This is the Webcil analog of System.Reflection.PortableExecutable.SectionHeader, but with fewer fields 36 | /// 37 | [StructLayout(LayoutKind.Sequential, Pack = 1)] 38 | public readonly struct WebcilSectionHeader 39 | { 40 | public readonly int VirtualSize; 41 | public readonly int VirtualAddress; 42 | public readonly int SizeOfRawData; 43 | public readonly int PointerToRawData; 44 | 45 | public WebcilSectionHeader(int virtualSize, int virtualAddress, int sizeOfRawData, int pointerToRawData) 46 | { 47 | VirtualSize = virtualSize; 48 | VirtualAddress = virtualAddress; 49 | SizeOfRawData = sizeOfRawData; 50 | PointerToRawData = pointerToRawData; 51 | } 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /BlazorCodeEditor/Webcil/WebcilContstants.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorCodeEditor.Webcil 2 | { 3 | internal static unsafe class WebcilConstants 4 | { 5 | public const int WC_VERSION_MAJOR = 0; 6 | public const int WC_VERSION_MINOR = 0; 7 | } 8 | } -------------------------------------------------------------------------------- /BlazorCodeEditor/Webcil/WebcilConverter.cs: -------------------------------------------------------------------------------- 1 | using System.Buffers.Binary; 2 | using System.Collections.Immutable; 3 | using System.Reflection.PortableExecutable; 4 | 5 | namespace BlazorCodeEditor.Webcil 6 | { 7 | /// 8 | /// Reads a .NET assembly in a normal PE COFF file and writes it out as a Webcil file 9 | /// 10 | public class WebcilConverter 11 | { 12 | 13 | // Interesting stuff we've learned about the input PE file 14 | public record PEFileInfo( 15 | // The sections in the PE file 16 | ImmutableArray SectionHeaders, 17 | // The location of the debug directory entries 18 | DirectoryEntry DebugTableDirectory, 19 | // The file offset of the sections, following the section directory 20 | FilePosition SectionStart, 21 | // The debug directory entries 22 | ImmutableArray DebugDirectoryEntries 23 | ); 24 | 25 | // Intersting stuff we know about the webcil file we're writing 26 | public record WCFileInfo( 27 | // The header of the webcil file 28 | Webcil.WebcilHeader Header, 29 | // The section directory of the webcil file 30 | ImmutableArray SectionHeaders, 31 | // The file offset of the sections, following the section directory 32 | FilePosition SectionStart 33 | ); 34 | 35 | private readonly string _inputPath; 36 | private readonly string _outputPath; 37 | 38 | private string InputPath => _inputPath; 39 | 40 | public bool WrapInWebAssembly { get; set; } = true; 41 | 42 | private WebcilConverter(string inputPath, string outputPath) 43 | { 44 | _inputPath = inputPath; 45 | _outputPath = outputPath; 46 | } 47 | 48 | public static WebcilConverter FromPortableExecutable(string inputPath, string outputPath) 49 | => new WebcilConverter(inputPath, outputPath); 50 | 51 | public void ConvertToWebcil() 52 | { 53 | using var inputStream = File.Open(_inputPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); 54 | PEFileInfo peInfo; 55 | WCFileInfo wcInfo; 56 | using (var peReader = new PEReader(inputStream, PEStreamOptions.LeaveOpen)) 57 | { 58 | GatherInfo(peReader, out wcInfo, out peInfo); 59 | } 60 | 61 | using var outputStream = File.Open(_outputPath, FileMode.Create, FileAccess.Write); 62 | if (!WrapInWebAssembly) 63 | { 64 | WriteConversionTo(outputStream, inputStream, peInfo, wcInfo); 65 | } 66 | else 67 | { 68 | // if wrapping in WASM, write the webcil payload to memory because we need to discover the length 69 | 70 | // webcil is about the same size as the PE file 71 | using var memoryStream = new MemoryStream(checked((int)inputStream.Length)); 72 | WriteConversionTo(memoryStream, inputStream, peInfo, wcInfo); 73 | memoryStream.Flush(); 74 | var wrapper = new WebcilWasmWrapper(memoryStream); 75 | memoryStream.Seek(0, SeekOrigin.Begin); 76 | wrapper.WriteWasmWrappedWebcil(outputStream); 77 | } 78 | } 79 | 80 | public void WriteConversionTo(Stream outputStream, FileStream inputStream, PEFileInfo peInfo, WCFileInfo wcInfo) 81 | { 82 | WriteHeader(outputStream, wcInfo.Header); 83 | WriteSectionHeaders(outputStream, wcInfo.SectionHeaders); 84 | CopySections(outputStream, inputStream, peInfo.SectionHeaders); 85 | if (wcInfo.Header.pe_debug_size != 0 && wcInfo.Header.pe_debug_rva != 0) 86 | { 87 | var wcDebugDirectoryEntries = FixupDebugDirectoryEntries(peInfo, wcInfo); 88 | OverwriteDebugDirectoryEntries(outputStream, wcInfo, wcDebugDirectoryEntries); 89 | } 90 | } 91 | 92 | public record struct FilePosition(int Position) 93 | { 94 | public static implicit operator FilePosition(int position) => new(position); 95 | 96 | public static FilePosition operator +(FilePosition left, int right) => new(left.Position + right); 97 | } 98 | 99 | private static unsafe int SizeOfHeader() 100 | { 101 | return sizeof(Webcil.WebcilHeader); 102 | } 103 | 104 | public unsafe void GatherInfo(PEReader peReader, out WCFileInfo wcInfo, out PEFileInfo peInfo) 105 | { 106 | var headers = peReader.PEHeaders; 107 | var peHeader = headers.PEHeader!; 108 | var coffHeader = headers.CoffHeader!; 109 | var sections = headers.SectionHeaders; 110 | Webcil.WebcilHeader header; 111 | header.id[0] = (byte)'W'; 112 | header.id[1] = (byte)'b'; 113 | header.id[2] = (byte)'I'; 114 | header.id[3] = (byte)'L'; 115 | header.version_major = WebcilConstants.WC_VERSION_MAJOR; 116 | header.version_minor = WebcilConstants.WC_VERSION_MINOR; 117 | header.coff_sections = (ushort)coffHeader.NumberOfSections; 118 | header.reserved0 = 0; 119 | header.pe_cli_header_rva = (uint)peHeader.CorHeaderTableDirectory.RelativeVirtualAddress; 120 | header.pe_cli_header_size = (uint)peHeader.CorHeaderTableDirectory.Size; 121 | header.pe_debug_rva = (uint)peHeader.DebugTableDirectory.RelativeVirtualAddress; 122 | header.pe_debug_size = (uint)peHeader.DebugTableDirectory.Size; 123 | 124 | // current logical position in the output file 125 | FilePosition pos = SizeOfHeader(); 126 | // position of the current section in the output file 127 | // initially it's after all the section headers 128 | FilePosition curSectionPos = pos + sizeof(Webcil.WebcilSectionHeader) * coffHeader.NumberOfSections; 129 | // The first WC section is immediately after the section directory 130 | FilePosition firstWCSection = curSectionPos; 131 | 132 | FilePosition firstPESection = 0; 133 | 134 | ImmutableArray.Builder headerBuilder = ImmutableArray.CreateBuilder(coffHeader.NumberOfSections); 135 | foreach (var sectionHeader in sections) 136 | { 137 | // The first section is the one with the lowest file offset 138 | if (firstPESection.Position == 0) 139 | { 140 | firstPESection = sectionHeader.PointerToRawData; 141 | } 142 | else 143 | { 144 | firstPESection = Math.Min(firstPESection.Position, sectionHeader.PointerToRawData); 145 | } 146 | 147 | var newHeader = new Webcil.WebcilSectionHeader 148 | ( 149 | virtualSize: sectionHeader.VirtualSize, 150 | virtualAddress: sectionHeader.VirtualAddress, 151 | sizeOfRawData: sectionHeader.SizeOfRawData, 152 | pointerToRawData: curSectionPos.Position 153 | ); 154 | 155 | pos += sizeof(Webcil.WebcilSectionHeader); 156 | curSectionPos += sectionHeader.SizeOfRawData; 157 | headerBuilder.Add(newHeader); 158 | } 159 | 160 | ImmutableArray debugDirectoryEntries = peReader.ReadDebugDirectory(); 161 | 162 | peInfo = new PEFileInfo(SectionHeaders: sections, 163 | DebugTableDirectory: peHeader.DebugTableDirectory, 164 | SectionStart: firstPESection, 165 | DebugDirectoryEntries: debugDirectoryEntries); 166 | 167 | wcInfo = new WCFileInfo(Header: header, 168 | SectionHeaders: headerBuilder.MoveToImmutable(), 169 | SectionStart: firstWCSection); 170 | } 171 | 172 | private static void WriteHeader(Stream s, Webcil.WebcilHeader webcilHeader) 173 | { 174 | if (!BitConverter.IsLittleEndian) 175 | { 176 | webcilHeader.version_major = BinaryPrimitives.ReverseEndianness(webcilHeader.version_major); 177 | webcilHeader.version_minor = BinaryPrimitives.ReverseEndianness(webcilHeader.version_minor); 178 | webcilHeader.coff_sections = BinaryPrimitives.ReverseEndianness(webcilHeader.coff_sections); 179 | webcilHeader.pe_cli_header_rva = BinaryPrimitives.ReverseEndianness(webcilHeader.pe_cli_header_rva); 180 | webcilHeader.pe_cli_header_size = BinaryPrimitives.ReverseEndianness(webcilHeader.pe_cli_header_size); 181 | webcilHeader.pe_debug_rva = BinaryPrimitives.ReverseEndianness(webcilHeader.pe_debug_rva); 182 | webcilHeader.pe_debug_size = BinaryPrimitives.ReverseEndianness(webcilHeader.pe_debug_size); 183 | } 184 | WriteStructure(s, webcilHeader); 185 | } 186 | 187 | private static void WriteSectionHeaders(Stream s, ImmutableArray sectionsHeaders) 188 | { 189 | foreach (var sectionHeader in sectionsHeaders) 190 | { 191 | WriteSectionHeader(s, sectionHeader); 192 | } 193 | } 194 | 195 | private static void WriteSectionHeader(Stream s, Webcil.WebcilSectionHeader sectionHeader) 196 | { 197 | if (!BitConverter.IsLittleEndian) 198 | { 199 | sectionHeader = new Webcil.WebcilSectionHeader 200 | ( 201 | virtualSize: BinaryPrimitives.ReverseEndianness(sectionHeader.VirtualSize), 202 | virtualAddress: BinaryPrimitives.ReverseEndianness(sectionHeader.VirtualAddress), 203 | sizeOfRawData: BinaryPrimitives.ReverseEndianness(sectionHeader.SizeOfRawData), 204 | pointerToRawData: BinaryPrimitives.ReverseEndianness(sectionHeader.PointerToRawData) 205 | ); 206 | } 207 | WriteStructure(s, sectionHeader); 208 | } 209 | 210 | #if NETCOREAPP2_1_OR_GREATER 211 | private static void WriteStructure(Stream s, T structure) 212 | where T : unmanaged 213 | { 214 | unsafe 215 | { 216 | byte* p = (byte*)&structure; 217 | s.Write(new ReadOnlySpan(p, sizeof(T))); 218 | } 219 | } 220 | #else 221 | private static void WriteStructure(Stream s, T structure) 222 | where T : unmanaged 223 | { 224 | int size = Marshal.SizeOf(); 225 | byte[] buffer = new byte[size]; 226 | IntPtr ptr = IntPtr.Zero; 227 | try 228 | { 229 | ptr = Marshal.AllocHGlobal(size); 230 | Marshal.StructureToPtr(structure, ptr, false); 231 | Marshal.Copy(ptr, buffer, 0, size); 232 | } 233 | finally 234 | { 235 | Marshal.FreeHGlobal(ptr); 236 | } 237 | s.Write(buffer, 0, size); 238 | } 239 | #endif 240 | 241 | private static void CopySections(Stream outStream, FileStream inputStream, ImmutableArray peSections) 242 | { 243 | // endianness: ok, we're just copying from one stream to another 244 | foreach (var peHeader in peSections) 245 | { 246 | var buffer = new byte[peHeader.SizeOfRawData]; 247 | inputStream.Seek(peHeader.PointerToRawData, SeekOrigin.Begin); 248 | ReadExactly(inputStream, buffer); 249 | outStream.Write(buffer, 0, buffer.Length); 250 | } 251 | } 252 | 253 | #if NETCOREAPP2_1_OR_GREATER && !NET6_0 254 | private static void ReadExactly(FileStream s, Span buffer) 255 | { 256 | s.ReadExactly(buffer); 257 | } 258 | #else 259 | private static void ReadExactly(FileStream s, byte[] buffer) 260 | { 261 | int offset = 0; 262 | while (offset < buffer.Length) 263 | { 264 | int read = s.Read(buffer, offset, buffer.Length - offset); 265 | if (read == 0) 266 | throw new EndOfStreamException(); 267 | offset += read; 268 | } 269 | } 270 | #endif 271 | 272 | private static FilePosition GetPositionOfRelativeVirtualAddress(ImmutableArray wcSections, uint relativeVirtualAddress) 273 | { 274 | foreach (var section in wcSections) 275 | { 276 | if (relativeVirtualAddress >= section.VirtualAddress && relativeVirtualAddress < section.VirtualAddress + section.VirtualSize) 277 | { 278 | FilePosition pos = section.PointerToRawData + ((int)relativeVirtualAddress - section.VirtualAddress); 279 | return pos; 280 | } 281 | } 282 | 283 | throw new InvalidOperationException("relative virtual address not in any section"); 284 | } 285 | 286 | // Given a physical file offset, return the section and the offset within the section. 287 | private (Webcil.WebcilSectionHeader section, int offset) GetSectionFromFileOffset(ImmutableArray peSections, FilePosition fileOffset) 288 | { 289 | foreach (var section in peSections) 290 | { 291 | if (fileOffset.Position >= section.PointerToRawData && fileOffset.Position < section.PointerToRawData + section.SizeOfRawData) 292 | { 293 | return (section, fileOffset.Position - section.PointerToRawData); 294 | } 295 | } 296 | 297 | throw new InvalidOperationException($"file offset not in any section (Webcil) for {InputPath}"); 298 | } 299 | 300 | private void GetSectionFromFileOffset(ImmutableArray sections, FilePosition fileOffset) 301 | { 302 | foreach (var section in sections) 303 | { 304 | if (fileOffset.Position >= section.PointerToRawData && fileOffset.Position < section.PointerToRawData + section.SizeOfRawData) 305 | { 306 | return; 307 | } 308 | } 309 | 310 | throw new InvalidOperationException($"file offset {fileOffset.Position} not in any section (PE) for {InputPath}"); 311 | } 312 | 313 | // Make a new set of debug directory entries that 314 | // have their data pointers adjusted to be relative to the start of the webcil file. 315 | // This is necessary because the debug directory entires in the PE file are relative to the start of the PE file, 316 | // and a PE header is bigger than a webcil header. 317 | private ImmutableArray FixupDebugDirectoryEntries(PEFileInfo peInfo, WCFileInfo wcInfo) 318 | { 319 | int dataPointerAdjustment = peInfo.SectionStart.Position - wcInfo.SectionStart.Position; 320 | ImmutableArray entries = peInfo.DebugDirectoryEntries; 321 | ImmutableArray.Builder newEntries = ImmutableArray.CreateBuilder(entries.Length); 322 | foreach (var entry in entries) 323 | { 324 | DebugDirectoryEntry newEntry; 325 | if (entry.Type == DebugDirectoryEntryType.Reproducible || entry.DataPointer == 0 || entry.DataSize == 0) 326 | { 327 | // this entry doesn't have an associated data pointer, so just copy it 328 | newEntry = entry; 329 | } 330 | else 331 | { 332 | // the "DataPointer" field is a file offset in the PE file, adjust the entry wit the corresponding offset in the Webcil file 333 | var newDataPointer = entry.DataPointer - dataPointerAdjustment; 334 | newEntry = new DebugDirectoryEntry(entry.Stamp, entry.MajorVersion, entry.MinorVersion, entry.Type, entry.DataSize, entry.DataRelativeVirtualAddress, newDataPointer); 335 | GetSectionFromFileOffset(peInfo.SectionHeaders, entry.DataPointer); 336 | // validate that the new entry is in some section 337 | GetSectionFromFileOffset(wcInfo.SectionHeaders, newDataPointer); 338 | } 339 | newEntries.Add(newEntry); 340 | } 341 | return newEntries.MoveToImmutable(); 342 | } 343 | 344 | private static void OverwriteDebugDirectoryEntries(Stream s, WCFileInfo wcInfo, ImmutableArray entries) 345 | { 346 | FilePosition debugDirectoryPos = GetPositionOfRelativeVirtualAddress(wcInfo.SectionHeaders, wcInfo.Header.pe_debug_rva); 347 | using var writer = new BinaryWriter(s, System.Text.Encoding.UTF8, leaveOpen: true); 348 | writer.Seek(debugDirectoryPos.Position, SeekOrigin.Begin); 349 | foreach (var entry in entries) 350 | { 351 | WriteDebugDirectoryEntry(writer, entry); 352 | } 353 | // TODO check that we overwrite with the same size as the original 354 | 355 | // restore the stream position 356 | writer.Seek(0, SeekOrigin.End); 357 | } 358 | 359 | private static void WriteDebugDirectoryEntry(BinaryWriter writer, DebugDirectoryEntry entry) 360 | { 361 | writer.Write((uint)0); // Characteristics 362 | writer.Write(entry.Stamp); 363 | writer.Write(entry.MajorVersion); 364 | writer.Write(entry.MinorVersion); 365 | writer.Write((uint)entry.Type); 366 | writer.Write(entry.DataSize); 367 | writer.Write(entry.DataRelativeVirtualAddress); 368 | writer.Write(entry.DataPointer); 369 | } 370 | } 371 | } -------------------------------------------------------------------------------- /BlazorCodeEditor/Webcil/WebcilConverterUtils.cs: -------------------------------------------------------------------------------- 1 | using System.Buffers.Binary; 2 | using System.Collections.Immutable; 3 | using System.Runtime.InteropServices; 4 | using Microsoft.CodeAnalysis; 5 | 6 | namespace BlazorCodeEditor.Webcil; 7 | 8 | internal static class WebcilConverterUtil 9 | { 10 | private static readonly byte[] SectionHeaderText = { 0x2E, 0x74, 0x65, 0x78, 0x74, 0x00, 0x00, 0x00 }; // .text 11 | private static readonly byte[] SectionHeaderRsRc = { 0x2E, 0x72, 0x73, 0x72, 0x63, 0x00, 0x00, 0x00 }; // .rsrc 12 | private static readonly byte[] SectionHeaderReloc = { 0x2E, 0x72, 0x65, 0x6C, 0x6F, 0x63, 0x00, 0x00 }; // .reloc 13 | private static readonly byte[] MSDOS = 14 | { 15 | 0x0E, 0x1F, 0xBA, 0x0E, 0x00, 0xB4, 0x09, 0xCD, 0x21, 0xB8, 0x01, 0x4C, 0xCD, 0x21, 0x54, 0x68, 16 | 0x69, 0x73, 0x20, 0x70, 0x72, 0x6F, 0x67, 0x72, 0x61, 0x6D, 0x20, 0x63, 0x61, 0x6E, 0x6E, 0x6F, 17 | 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6E, 0x20, 0x69, 0x6E, 0x20, 0x44, 0x4F, 0x53, 0x20, 18 | 0x6D, 0x6F, 0x64, 0x65, 0x2E, 0x0D, 0x0D, 0x0A, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 19 | }; 20 | private static readonly ushort[] DOSReservedWords1 = { 0, 0, 0, 0 }; 21 | private static readonly ushort[] DOSReservedWords2 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 22 | private static readonly DateTime Epoch = new(1970, 1, 1); 23 | private static readonly int SizeofDOSHeader = Marshal.SizeOf(); // 64 24 | private static readonly int SizeofFileHeader = Marshal.SizeOf(); 25 | private static readonly int SizeofMSDOS = MSDOS.Length; // 64 26 | private static readonly int SizeofNTHeaders = Marshal.SizeOf(); // 248 27 | private static readonly int SizeofOptionalHeader = Marshal.SizeOf(); 28 | private static readonly int SizeofSectionHeader = Marshal.SizeOf(); // 40 29 | 30 | private const uint FileAlignment = 0x0200; 31 | private const uint SectionAlignment = 0x2000; 32 | 33 | /// 34 | /// Convert a Portable Executable file into a Webcil file. 35 | /// 36 | /// The input path for the PE file. 37 | /// The output path for the Webcil file. 38 | /// The Webcil should be wrapped in Wasm [default value is true]. 39 | public static void ConvertToWebcil(string inputPath, string outputPath, bool wrapInWebAssembly = true) 40 | { 41 | var webcilConverter = WebcilConverter.FromPortableExecutable(inputPath, outputPath); 42 | webcilConverter.WrapInWebAssembly = wrapInWebAssembly; 43 | 44 | webcilConverter.ConvertToWebcil(); 45 | } 46 | 47 | /// 48 | /// Convert a Webcil stream into a Portable Executable which can be used to create a valid . 49 | /// 50 | /// The input sStream. 51 | /// The Webcil is wrapped in Wasm [default value is true]. 52 | /// A byte[] Portable Executable 53 | public static byte[] ConvertFromWebcil(Stream inputStream, bool wrappedInWebAssembly = true) 54 | { 55 | Stream webcilStream; 56 | if (wrappedInWebAssembly) 57 | { 58 | using var unwrapper = new WasmWebcilUnwrapper(inputStream); 59 | webcilStream = new MemoryStream(); 60 | unwrapper.WriteUnwrapped(webcilStream); 61 | 62 | webcilStream.Flush(); 63 | webcilStream.Seek(0, SeekOrigin.Begin); 64 | } 65 | else 66 | { 67 | webcilStream = inputStream; 68 | } 69 | 70 | // These are Webcil variables 71 | var webcilHeader = ReadHeader(webcilStream); 72 | var webcilSectionHeaders = ReadSectionHeaders(webcilStream, webcilHeader.coff_sections); 73 | var webcilSectionHeadersCount = webcilSectionHeaders.Length; 74 | var webcilSectionHeadersSizeOfRawData = (uint)webcilSectionHeaders.Sum(x => x.SizeOfRawData); 75 | 76 | // These are PE (Portable Executable) variables 77 | int sectionStart = SizeofDOSHeader + SizeofMSDOS + SizeofNTHeaders + webcilSectionHeadersCount * SizeofSectionHeader; // 496 78 | int sectionStartRounded = sectionStart.RoundToNearest(); 79 | var extraBytesAfterSections = new byte[sectionStartRounded - sectionStart]; 80 | var pointerToRawDataFirstSectionHeader = webcilSectionHeaders[0].PointerToRawData; 81 | var pointerToRawDataOffsetBetweenWebcilAndPE = sectionStartRounded - pointerToRawDataFirstSectionHeader; 82 | 83 | using var peStream = new MemoryStream(); 84 | 85 | var DOSHeader = new IMAGE_DOS_HEADER 86 | { 87 | MagicNumber = 0x5A4D, 88 | BytesOnLastPageOfFile = 0x90, 89 | PagesInFile = 3, 90 | Relocations = 0, 91 | SizeOfHeaderInParagraphs = 4, 92 | MinimumExtraParagraphs = 0, 93 | MaximumExtraParagraphs = 0xFFFF, 94 | InitialSS = 0, 95 | InitialSP = 0xB8, 96 | Checksum = 0, 97 | InitialIP = 0, 98 | InitialCS = 0, 99 | AddressOfRelocationTable = 0x40, 100 | OverlayNumber = 0, 101 | ReservedWords1 = DOSReservedWords1, 102 | OEMIdentifier = 0, 103 | OEMInformation = 0, 104 | ReservedWords2 = DOSReservedWords2, 105 | FileAddressOfNewExeHeader = 0x80 106 | }; 107 | peStream.WriteStruct(DOSHeader); 108 | 109 | peStream.Write(MSDOS); 110 | 111 | var IMAGE_NT_HEADERS32 = new IMAGE_NT_HEADERS32 112 | { 113 | Signature = 0x4550, // 'PE' 114 | FileHeader = new IMAGE_FILE_HEADER 115 | { 116 | Machine = Constants.IMAGE_FILE_MACHINE_I386, 117 | NumberOfSections = 3, 118 | TimeDateStamp = GetImageTimestamp(), 119 | PointerToSymbolTable = 0, 120 | NumberOfSymbols = 0, 121 | SizeOfOptionalHeader = 0x00E0, 122 | Characteristics = 0x0022 123 | }, 124 | OptionalHeader = new IMAGE_OPTIONAL_HEADER32 125 | { 126 | Magic = 0x010B, // Signature/Magic - Represents PE32 for 32-bit (0x10b) and PE32+ for 64-bit (0x20B) 127 | MajorLinkerVersion = 0x30, 128 | MinorLinkerVersion = 0, 129 | SizeOfCode = (uint)webcilSectionHeaders[0].SizeOfRawData, 130 | SizeOfInitializedData = (uint)(webcilSectionHeaders[1].SizeOfRawData + webcilSectionHeaders[2].SizeOfRawData), 131 | SizeOfUninitializedData = 0, 132 | AddressOfEntryPoint = 0, // This can be set to 0 133 | BaseOfCode = 0x2000, 134 | BaseOfData = 0xA000, 135 | ImageBase = 0x400000, // The default value for applications is 0x00400000 136 | SectionAlignment = SectionAlignment, 137 | FileAlignment = FileAlignment, 138 | MajorOperatingSystemVersion = 4, 139 | MinorOperatingSystemVersion = 0, 140 | MajorImageVersion = 0, 141 | MinorImageVersion = 0, 142 | MajorSubsystemVersion = 4, 143 | MinorSubsystemVersion = 0, 144 | Win32VersionValue = 0, 145 | SizeOfImage = webcilSectionHeadersSizeOfRawData.RoundToNearest(SectionAlignment), 146 | SizeOfHeaders = GetSizeOfHeaders(DOSHeader, webcilSectionHeadersCount), 147 | CheckSum = 0, 148 | Subsystem = 3, // IMAGE_SUBSYSTEM_WINDOWS_CUI 149 | DllCharacteristics = 0x8560, 150 | SizeOfStackReserve = 0x100000, 151 | SizeOfStackCommit = 0x1000, 152 | SizeOfHeapReserve = 0x100000, 153 | SizeOfHeapCommit = 0x1000, 154 | LoaderFlags = 0, 155 | NumberOfRvaAndSizes = 0x10, 156 | DataDirectory = new IMAGE_DATA_DIRECTORY[] 157 | { 158 | new() { Size = 0x0000, VirtualAddress = 0x0000 }, // IMAGE_DIRECTORY_ENTRY_EXPORT 159 | new() { Size = 0x0000, VirtualAddress = 0x0000 }, // IMAGE_DIRECTORY_ENTRY_IMPORT (can be 0) 160 | new() { Size = (uint) webcilSectionHeaders[1].VirtualSize, VirtualAddress = (uint) webcilSectionHeaders[1].VirtualAddress }, // IMAGE_DIRECTORY_ENTRY_RESOURCE 161 | new() { Size = 0x0000, VirtualAddress = 0x0000 }, // IMAGE_DIRECTORY_ENTRY_EXCEPTION 162 | new() { Size = 0x0000, VirtualAddress = 0x0000 }, // IMAGE_DIRECTORY_ENTRY_SECURITY 163 | new() { Size = (uint) webcilSectionHeaders[2].VirtualSize, VirtualAddress = (uint) webcilSectionHeaders[2].VirtualAddress }, // IMAGE_DIRECTORY_ENTRY_BASERELOC 164 | new() { Size = 0x0000, VirtualAddress = 0x0000 }, // IMAGE_DIRECTORY_ENTRY_DEBUG (can be 0) 165 | new() { Size = 0x0000, VirtualAddress = 0x0000 }, // IMAGE_DIRECTORY_ENTRY_ARCHITECTURE 166 | new() { Size = 0x0000, VirtualAddress = 0x0000 }, // IMAGE_DIRECTORY_ENTRY_GLOBALPTR 167 | new() { Size = 0x0000, VirtualAddress = 0x0000 }, // IMAGE_DIRECTORY_ENTRY_TLS 168 | new() { Size = 0x0000, VirtualAddress = 0x0000 }, // IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 169 | new() { Size = 0x0000, VirtualAddress = 0x0000 }, // IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 170 | new() { Size = 0x0008, VirtualAddress = (uint) webcilSectionHeaders[0].VirtualAddress }, // IMAGE_DIRECTORY_ENTRY_IAT 171 | new() { Size = 0x0000, VirtualAddress = 0x0000 }, // IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 172 | new() { Size = 0x0048, VirtualAddress = (uint) webcilSectionHeaders[0].VirtualAddress + 8 }, // TODO ??? IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 173 | new() { Size = 0x0000, VirtualAddress = 0x0000 } // ? 174 | } 175 | } 176 | }; 177 | peStream.WriteStruct(IMAGE_NT_HEADERS32); 178 | 179 | var textSectionHeader = new IMAGE_SECTION_HEADER 180 | { 181 | Name = SectionHeaderText, 182 | Misc = new IMAGE_SECTION_HEADER.UnionType { VirtualSize = (uint)webcilSectionHeaders[0].VirtualSize }, 183 | VirtualAddress = (uint)webcilSectionHeaders[0].VirtualAddress, 184 | SizeOfRawData = (uint)webcilSectionHeaders[0].SizeOfRawData, 185 | PointerToRawData = webcilSectionHeaders[0].GetCorrectedPointerToRawData(pointerToRawDataOffsetBetweenWebcilAndPE), 186 | Characteristics = 0x60000020 187 | }; 188 | peStream.WriteStruct(textSectionHeader); 189 | 190 | var rsrcSectionHeader = new IMAGE_SECTION_HEADER 191 | { 192 | Name = SectionHeaderRsRc, 193 | Misc = new IMAGE_SECTION_HEADER.UnionType { VirtualSize = (uint)webcilSectionHeaders[1].VirtualSize }, 194 | VirtualAddress = (uint)webcilSectionHeaders[1].VirtualAddress, 195 | SizeOfRawData = (uint)webcilSectionHeaders[1].SizeOfRawData, 196 | PointerToRawData = webcilSectionHeaders[1].GetCorrectedPointerToRawData(pointerToRawDataOffsetBetweenWebcilAndPE), 197 | Characteristics = 0x40000040 198 | }; 199 | peStream.WriteStruct(rsrcSectionHeader); 200 | 201 | var relocSectionHeader = new IMAGE_SECTION_HEADER 202 | { 203 | Name = SectionHeaderReloc, 204 | Misc = new IMAGE_SECTION_HEADER.UnionType { VirtualSize = (uint)webcilSectionHeaders[2].VirtualSize }, 205 | VirtualAddress = (uint)webcilSectionHeaders[2].VirtualAddress, 206 | SizeOfRawData = (uint)webcilSectionHeaders[2].SizeOfRawData, 207 | PointerToRawData = webcilSectionHeaders[2].GetCorrectedPointerToRawData(pointerToRawDataOffsetBetweenWebcilAndPE), 208 | Characteristics = 0x42000040 209 | }; 210 | peStream.WriteStruct(relocSectionHeader); 211 | 212 | if (extraBytesAfterSections.Length > 0) 213 | { 214 | peStream.Write(extraBytesAfterSections); 215 | } 216 | 217 | // Just copy all data 218 | foreach (var webcilSectionHeader in webcilSectionHeaders) 219 | { 220 | var buffer = new byte[webcilSectionHeader.SizeOfRawData]; 221 | webcilStream.Seek(webcilSectionHeader.PointerToRawData, SeekOrigin.Begin); 222 | ReadExactly(webcilStream, buffer); 223 | 224 | peStream.Write(buffer, 0, buffer.Length); 225 | } 226 | 227 | peStream.Flush(); 228 | peStream.Seek(0, SeekOrigin.Begin); 229 | 230 | return peStream.ToArray(); 231 | } 232 | 233 | private static Webcil.WebcilHeader ReadHeader(Stream webcilStream) 234 | { 235 | var webcilHeader = ReadStructure(webcilStream); 236 | 237 | if (!BitConverter.IsLittleEndian) 238 | { 239 | webcilHeader.version_major = BinaryPrimitives.ReverseEndianness(webcilHeader.version_major); 240 | webcilHeader.version_minor = BinaryPrimitives.ReverseEndianness(webcilHeader.version_minor); 241 | webcilHeader.coff_sections = BinaryPrimitives.ReverseEndianness(webcilHeader.coff_sections); 242 | webcilHeader.pe_cli_header_rva = BinaryPrimitives.ReverseEndianness(webcilHeader.pe_cli_header_rva); 243 | webcilHeader.pe_cli_header_size = BinaryPrimitives.ReverseEndianness(webcilHeader.pe_cli_header_size); 244 | webcilHeader.pe_debug_rva = BinaryPrimitives.ReverseEndianness(webcilHeader.pe_debug_rva); 245 | webcilHeader.pe_debug_size = BinaryPrimitives.ReverseEndianness(webcilHeader.pe_debug_size); 246 | } 247 | 248 | return webcilHeader; 249 | } 250 | 251 | private static ImmutableArray ReadSectionHeaders(Stream webcilStream, int sectionsHeaders) 252 | { 253 | var result = new List(); 254 | for (int i = 0; i < sectionsHeaders; i++) 255 | { 256 | result.Add(ReadSectionHeader(webcilStream)); 257 | } 258 | 259 | return ImmutableArray.Create(result.ToArray()); 260 | } 261 | 262 | private static Webcil.WebcilSectionHeader ReadSectionHeader(Stream webcilStream) 263 | { 264 | var sectionHeader = ReadStructure(webcilStream); 265 | 266 | if (!BitConverter.IsLittleEndian) 267 | { 268 | sectionHeader = new Webcil.WebcilSectionHeader 269 | ( 270 | virtualSize: BinaryPrimitives.ReverseEndianness(sectionHeader.VirtualSize), 271 | virtualAddress: BinaryPrimitives.ReverseEndianness(sectionHeader.VirtualAddress), 272 | sizeOfRawData: BinaryPrimitives.ReverseEndianness(sectionHeader.SizeOfRawData), 273 | pointerToRawData: BinaryPrimitives.ReverseEndianness(sectionHeader.PointerToRawData) 274 | ); 275 | } 276 | 277 | return sectionHeader; 278 | } 279 | 280 | private static uint GetSizeOfHeaders(IMAGE_DOS_HEADER IMAGE_DOS_HEADER, int numSectionHeaders) 281 | { 282 | var soh = IMAGE_DOS_HEADER.FileAddressOfNewExeHeader + // e_lfanew member of IMAGE_DOS_HEADER 283 | sizeof(uint) + // 4 byte signature 284 | SizeofFileHeader + 285 | SizeofOptionalHeader + // size of optional header 286 | numSectionHeaders * SizeofSectionHeader // size of all section headers 287 | ; 288 | 289 | return (uint)soh.RoundToNearest(); 290 | } 291 | 292 | /// 293 | /// The low 32 bits of the time stamp of the image. 294 | /// This represents the date and time the image was created by the linker. 295 | /// The value is represented in the number of seconds elapsed since midnight (00:00:00), January 1, 1970, Universal Coordinated Time, according to the system clock. 296 | /// 297 | private static uint GetImageTimestamp() 298 | { 299 | // Calculate the total seconds since Unix epoch 300 | var totalSeconds = (DateTime.UtcNow - Epoch).Ticks / TimeSpan.TicksPerSecond; 301 | 302 | // Convert to uint (low 32 bits) 303 | return (uint)totalSeconds; 304 | } 305 | 306 | internal static int RoundToNearest(this int number, int nearest = 512) 307 | { 308 | int remainder = number % nearest; 309 | int halfNearest = nearest / 2; 310 | return remainder >= halfNearest ? number + nearest - remainder : number - remainder; 311 | } 312 | 313 | internal static uint RoundToNearest(this uint number, uint nearest = 512) 314 | { 315 | uint remainder = number % nearest; 316 | uint halfNearest = nearest / 2; 317 | return remainder >= halfNearest ? number + nearest - remainder : number - remainder; 318 | } 319 | 320 | #if NETCOREAPP2_1_OR_GREATER 321 | private static T ReadStructure(Stream s) where T : unmanaged 322 | { 323 | T structure = default; 324 | unsafe 325 | { 326 | byte* p = (byte*)&structure; 327 | Span buffer = new Span(p, sizeof(T)); 328 | int read = s.Read(buffer); 329 | if (read != sizeof(T)) 330 | { 331 | throw new InvalidOperationException("Couldn't read the full structure from the stream."); 332 | } 333 | } 334 | 335 | return structure; 336 | } 337 | #else 338 | private static T ReadStructure(Stream s) where T : unmanaged 339 | { 340 | int size = Marshal.SizeOf(); 341 | byte[] buffer = new byte[size]; 342 | s.Read(buffer, 0, size); 343 | 344 | IntPtr ptr = IntPtr.Zero; 345 | try 346 | { 347 | ptr = Marshal.AllocHGlobal(size); 348 | Marshal.Copy(buffer, 0, ptr, size); 349 | return Marshal.PtrToStructure(ptr); 350 | } 351 | finally 352 | { 353 | Marshal.FreeHGlobal(ptr); 354 | } 355 | } 356 | #endif 357 | 358 | #if NETCOREAPP2_1_OR_GREATER && !NET6_0 359 | private static void ReadExactly(Stream s, Span buffer) 360 | { 361 | s.ReadExactly(buffer); 362 | } 363 | #else 364 | private static void ReadExactly(Stream s, byte[] buffer) 365 | { 366 | int offset = 0; 367 | while (offset < buffer.Length) 368 | { 369 | int read = s.Read(buffer, offset, buffer.Length - offset); 370 | if (read == 0) 371 | { 372 | throw new EndOfStreamException(); 373 | } 374 | 375 | offset += read; 376 | } 377 | } 378 | #endif 379 | } -------------------------------------------------------------------------------- /BlazorCodeEditor/Webcil/WebcilSectionHeaderExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorCodeEditor.Webcil 2 | { 3 | internal static class WebcilSectionHeaderExtensions 4 | { 5 | internal static uint GetCorrectedPointerToRawData(this Webcil.WebcilSectionHeader webcilSectionHeader, int offset) 6 | { 7 | return (uint) (webcilSectionHeader.PointerToRawData + offset); 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /BlazorCodeEditor/Webcil/WebcilWasmWrapper.cs: -------------------------------------------------------------------------------- 1 | // Licensed to the .NET Foundation under one or more agreements. 2 | // The .NET Foundation licenses this file to you under the MIT license. 3 | 4 | 5 | 6 | // 7 | // Emits a simple WebAssembly wrapper module around a given webcil payload. 8 | // 9 | // The entire wasm module is going to be unchanging, except for the data section which has 2 passive 10 | // segments. segment 0 is 4 bytes and contains the length of the webcil payload. segment 1 is of a 11 | // variable size and contains the webcil payload. 12 | // 13 | // The unchanging parts are stored as a "prefix" and "suffix" which contain the bytes for the following 14 | // WAT module, split into the parts that come before the data section, and the bytes that come after: 15 | // 16 | // (module 17 | // (data "\0f\00\00\00") ;; data segment 0: payload size as a 4 byte LE uint32 18 | // (data "webcil Payload\cc") ;; data segment 1: webcil payload 19 | // (memory (import "webcil" "memory") 1) 20 | // (global (export "webcilVersion") i32 (i32.const 0)) 21 | // (func (export "getWebcilSize") (param $destPtr i32) (result) 22 | // local.get $destPtr 23 | // i32.const 0 24 | // i32.const 4 25 | // memory.init 0) 26 | // (func (export "getWebcilPayload") (param $d i32) (param $n i32) (result) 27 | // local.get $d 28 | // i32.const 0 29 | // local.get $n 30 | // memory.init 1)) 31 | namespace BlazorCodeEditor.Webcil 32 | { 33 | public class WebcilWasmWrapper 34 | { 35 | private readonly Stream _webcilPayloadStream; 36 | private readonly uint _webcilPayloadSize; 37 | 38 | public WebcilWasmWrapper(Stream webcilPayloadStream) 39 | { 40 | _webcilPayloadStream = webcilPayloadStream; 41 | long len = webcilPayloadStream.Length; 42 | if (len > (long)uint.MaxValue) 43 | throw new InvalidOperationException("webcil payload too large"); 44 | _webcilPayloadSize = (uint)len; 45 | } 46 | 47 | public void WriteWasmWrappedWebcil(Stream outputStream) 48 | { 49 | WriteWasmHeader(outputStream); 50 | using (var writer = new BinaryWriter(outputStream, System.Text.Encoding.UTF8, leaveOpen: true)) 51 | { 52 | WriteDataSection(writer); 53 | } 54 | WriteWasmSuffix(outputStream); 55 | } 56 | 57 | // 58 | // Everything from the above wat module before the data section 59 | // 60 | // extracted by wasm-reader -s wrapper.wasm 61 | private static 62 | #if NET7_0_OR_GREATER 63 | ReadOnlyMemory 64 | #else 65 | byte[] 66 | #endif 67 | s_wasmWrapperPrefix = new byte[] { 68 | 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x02, 0x60, 0x01, 0x7f, 0x00, 0x60, 0x02, 0x7f, 0x7f, 0x00, 0x02, 0x12, 0x01, 0x06, 0x77, 0x65, 0x62, 0x63, 0x69, 0x6c, 0x06, 0x6d, 69 | 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x02, 0x00, 0x01, 0x03, 0x03, 0x02, 0x00, 0x01, 0x06, 0x0b, 0x02, 0x7f, 0x00, 0x41, 0x00, 0x0b, 0x7f, 0x00, 0x41, 0x00, 0x0b, 0x07, 0x41, 0x04, 0x0d, 0x77, 0x65, 70 | 0x62, 0x63, 0x69, 0x6c, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x03, 0x00, 0x0a, 0x77, 0x65, 0x62, 0x63, 0x69, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x03, 0x01, 0x0d, 0x67, 0x65, 0x74, 0x57, 0x65, 71 | 0x62, 0x63, 0x69, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x00, 0x00, 0x10, 0x67, 0x65, 0x74, 0x57, 0x65, 0x62, 0x63, 0x69, 0x6c, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x00, 0x01, 0x0c, 0x01, 0x02, 72 | 0x0a, 0x1b, 0x02, 0x0c, 0x00, 0x20, 0x00, 0x41, 0x00, 0x41, 0x04, 0xfc, 0x08, 0x00, 0x00, 0x0b, 0x0c, 0x00, 0x20, 0x00, 0x41, 0x00, 0x20, 0x01, 0xfc, 0x08, 0x01, 0x00, 0x0b, 73 | }; 74 | // 75 | // Everything from the above wat module after the data section 76 | // 77 | // extracted by wasm-reader -s wrapper.wasm 78 | private static 79 | #if NET7_0_OR_GREATER 80 | ReadOnlyMemory 81 | #else 82 | byte[] 83 | #endif 84 | s_wasmWrapperSuffix = new byte[] { 85 | 0x00, 0x1b, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x02, 0x14, 0x02, 0x00, 0x01, 0x00, 0x07, 0x64, 0x65, 0x73, 0x74, 0x50, 0x74, 0x72, 0x01, 0x02, 0x00, 0x01, 0x64, 0x01, 0x01, 0x6e, 86 | }; 87 | 88 | private static void WriteWasmHeader(Stream outputStream) 89 | { 90 | #if NET7_0_OR_GREATER 91 | outputStream.Write(s_wasmWrapperPrefix.Span); 92 | #else 93 | outputStream.Write(s_wasmWrapperPrefix, 0, s_wasmWrapperPrefix.Length); 94 | #endif 95 | } 96 | 97 | private static void WriteWasmSuffix(Stream outputStream) 98 | { 99 | #if NET7_0_OR_GREATER 100 | outputStream.Write(s_wasmWrapperSuffix.Span); 101 | #else 102 | outputStream.Write(s_wasmWrapperSuffix, 0, s_wasmWrapperSuffix.Length); 103 | #endif 104 | } 105 | 106 | // 1 byte to encode "passive" data segment 107 | private const uint SegmentCodeSize = 1; 108 | 109 | // Align the payload start to a 4-byte boundary within the wrapper. If the runtime reads the 110 | // payload directly, instead of by instantiatng the wasm module, we don't want the WebAssembly 111 | // prefix to push some of the values inside the image to odd byte offsets as the runtime assumes 112 | // the image will be aligned. 113 | // 114 | // There are requirements in ECMA-335 (Section II.25.4) that fat method headers and method data 115 | // sections be 4-byte aligned. 116 | private const uint WebcilPayloadInternalAlignment = 4; 117 | 118 | private void WriteDataSection(BinaryWriter writer) 119 | { 120 | 121 | uint dataSectionSize = 0; 122 | // uleb128 encoding of number of segments 123 | dataSectionSize += 1; // there's always 2 segments which encodes to 1 byte 124 | // compute the segment 0 size: 125 | // segment 0 has 1 byte segment code, 1 byte of size and at least 4 bytes of payload 126 | uint segment0MinimumSize = SegmentCodeSize + 1 + 4; 127 | dataSectionSize += segment0MinimumSize; 128 | 129 | // encode webcil size as a uleb128 130 | byte[] ulebWebcilPayloadSize = ULEB128Encode(_webcilPayloadSize); 131 | 132 | // compute the segment 1 size: 133 | // segment 1 has 1 byte segment code, a uleb128 encoding of the webcilPayloadSize, and the payload 134 | // don't count the size of the payload yet 135 | checked 136 | { 137 | dataSectionSize += SegmentCodeSize + (uint)ulebWebcilPayloadSize.Length; 138 | } 139 | 140 | // at this point the data section size includes everything except the data section code, the data section size and the webcil payload itself 141 | // and any extra padding that we may want to add to segment 0. 142 | // So we can compute the offset of the payload within the wasm module. 143 | byte[] putativeULEBDataSectionSize = ULEB128Encode(dataSectionSize + _webcilPayloadSize); 144 | uint payloadOffset = (uint)s_wasmWrapperPrefix.Length + 1 + (uint)putativeULEBDataSectionSize.Length + dataSectionSize ; 145 | 146 | uint paddingSize = PadTo(payloadOffset, WebcilPayloadInternalAlignment); 147 | 148 | if (paddingSize > 0) 149 | { 150 | checked 151 | { 152 | dataSectionSize += paddingSize; 153 | } 154 | } 155 | 156 | checked 157 | { 158 | dataSectionSize += _webcilPayloadSize; 159 | } 160 | 161 | byte[] ulebSectionSize = ULEB128Encode(dataSectionSize); 162 | 163 | if (putativeULEBDataSectionSize.Length != ulebSectionSize.Length) 164 | throw new InvalidOperationException ("adding padding would cause data section's encoded length to chane"); // TODO: fixme: there's upto one extra byte to encode the section length - take away a padding byte. 165 | writer.Write((byte)11); // section Data 166 | writer.Write(ulebSectionSize, 0, ulebSectionSize.Length); 167 | 168 | writer.Write((byte)2); // number of segments 169 | 170 | // write segment 0 171 | writer.Write((byte)1); // passive segment 172 | if (paddingSize + 4 > 127) { 173 | throw new InvalidOperationException ("padding would cause segment 0 to need a multi-byte ULEB128 size encoding"); 174 | } 175 | writer.Write((byte)(4 + paddingSize)); // segment size: 4 plus any padding 176 | writer.Write((uint)_webcilPayloadSize); // payload is an unsigned 32 bit number 177 | for (int i = 0; i < paddingSize; i++) 178 | writer.Write((byte)0); 179 | 180 | // write segment 1 181 | writer.Write((byte)1); // passive segment 182 | writer.Write(ulebWebcilPayloadSize, 0, ulebWebcilPayloadSize.Length); // segment size: _webcilPayloadSize 183 | if (writer.BaseStream.Position % WebcilPayloadInternalAlignment != 0) { 184 | throw new Exception ($"predited offset {payloadOffset}, actual position {writer.BaseStream.Position}"); 185 | } 186 | _webcilPayloadStream.CopyTo(writer.BaseStream); // payload is the entire webcil content 187 | } 188 | 189 | private static byte[] ULEB128Encode(uint value) 190 | { 191 | uint n = value; 192 | int len = 0; 193 | do 194 | { 195 | n >>= 7; 196 | len++; 197 | } while (n != 0); 198 | byte[] arr = new byte[len]; 199 | int i = 0; 200 | n = value; 201 | do 202 | { 203 | byte b = (byte)(n & 0x7f); 204 | n >>= 7; 205 | if (n != 0) 206 | b |= 0x80; 207 | arr[i++] = b; 208 | } while (n != 0); 209 | return arr; 210 | } 211 | 212 | private static uint PadTo (uint value, uint align) 213 | { 214 | uint newValue = AlignTo(value, align); 215 | return newValue - value; 216 | } 217 | 218 | private static uint AlignTo (uint value, uint align) 219 | { 220 | return (value + (align - 1)) & ~(align - 1); 221 | } 222 | } 223 | } -------------------------------------------------------------------------------- /BlazorCodeEditor/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | @using BlazorCodeEditor 10 | @using BlazorCodeEditor.Layout -------------------------------------------------------------------------------- /BlazorCodeEditor/wwwroot/app.js: -------------------------------------------------------------------------------- 1 | export function captureConsoleOutput(dotnetHelper) { 2 | // Save the original console methods 3 | const originalLog = console.log; 4 | const originalError = console.error; 5 | const originalWarn = console.warn; 6 | 7 | console.log = function (...args) { 8 | const message = args.map(arg => (typeof arg === 'object' ? JSON.stringify(arg) : arg)).join(' '); 9 | dotnetHelper.invokeMethodAsync("OnConsoleLog", message); 10 | originalLog.apply(console, args); 11 | }; 12 | 13 | console.error = function (...args) { 14 | const message = args.map(arg => (typeof arg === 'object' ? JSON.stringify(arg) : arg)).join(' '); 15 | dotnetHelper.invokeMethodAsync("OnConsoleError", message); 16 | originalError.apply(console, args); 17 | }; 18 | 19 | console.warn = function (...args) { 20 | const message = args.map(arg => (typeof arg === 'object' ? JSON.stringify(arg) : arg)).join(' '); 21 | dotnetHelper.invokeMethodAsync("OnConsoleWarn", message); 22 | originalWarn.apply(console, args); 23 | }; 24 | } -------------------------------------------------------------------------------- /BlazorCodeEditor/wwwroot/css/app.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 3 | } 4 | 5 | h1:focus { 6 | outline: none; 7 | } 8 | 9 | a, .btn-link { 10 | color: #0071c1; 11 | } 12 | 13 | .btn-primary { 14 | color: #fff; 15 | background-color: #1b6ec2; 16 | border-color: #1861ac; 17 | } 18 | 19 | .btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus { 20 | box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb; 21 | } 22 | 23 | .content { 24 | padding-top: 1.1rem; 25 | } 26 | 27 | .valid.modified:not([type=checkbox]) { 28 | outline: 1px solid #26b050; 29 | } 30 | 31 | .invalid { 32 | outline: 1px solid red; 33 | } 34 | 35 | .validation-message { 36 | color: red; 37 | } 38 | 39 | #blazor-error-ui { 40 | color-scheme: light only; 41 | background: lightyellow; 42 | bottom: 0; 43 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 44 | box-sizing: border-box; 45 | display: none; 46 | left: 0; 47 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 48 | position: fixed; 49 | width: 100%; 50 | z-index: 1000; 51 | } 52 | 53 | #blazor-error-ui .dismiss { 54 | cursor: pointer; 55 | position: absolute; 56 | right: 0.75rem; 57 | top: 0.5rem; 58 | } 59 | 60 | .blazor-error-boundary { 61 | background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; 62 | padding: 1rem 1rem 1rem 3.7rem; 63 | color: white; 64 | } 65 | 66 | .blazor-error-boundary::after { 67 | content: "An error has occurred." 68 | } 69 | 70 | .loading-progress { 71 | position: relative; 72 | display: block; 73 | width: 8rem; 74 | height: 8rem; 75 | margin: 20vh auto 1rem auto; 76 | } 77 | 78 | .loading-progress circle { 79 | fill: none; 80 | stroke: #e0e0e0; 81 | stroke-width: 0.6rem; 82 | transform-origin: 50% 50%; 83 | transform: rotate(-90deg); 84 | } 85 | 86 | .loading-progress circle:last-child { 87 | stroke: #1b6ec2; 88 | stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%; 89 | transition: stroke-dasharray 0.05s ease-in-out; 90 | } 91 | 92 | .loading-progress-text { 93 | position: absolute; 94 | text-align: center; 95 | font-weight: bold; 96 | inset: calc(20vh + 3.25rem) 0 auto 0.2rem; 97 | } 98 | 99 | .loading-progress-text:after { 100 | content: var(--blazor-load-percentage-text, "Loading"); 101 | } 102 | 103 | code { 104 | color: #c02d76; 105 | } 106 | 107 | .form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder { 108 | color: var(--bs-secondary-color); 109 | text-align: end; 110 | } 111 | 112 | .form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder { 113 | text-align: start; 114 | } 115 | 116 | .monaco-editor-container { 117 | height:60dvh; 118 | width:100%; 119 | } -------------------------------------------------------------------------------- /BlazorCodeEditor/wwwroot/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thatplatypus/BlazorCodeEditor/82b08c3c71f8d4834ef55236b162311ac2f56bb4/BlazorCodeEditor/wwwroot/favicon.png -------------------------------------------------------------------------------- /BlazorCodeEditor/wwwroot/icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thatplatypus/BlazorCodeEditor/82b08c3c71f8d4834ef55236b162311ac2f56bb4/BlazorCodeEditor/wwwroot/icon-192.png -------------------------------------------------------------------------------- /BlazorCodeEditor/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | BlazorCodeEditor 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 |
22 |
23 | 24 |
25 | An unhandled error has occurred. 26 | Reload 27 | 🗙 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /BlazorCodeEditor/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Reboot v5.3.3 (https://getbootstrap.com/) 3 | * Copyright 2011-2024 The Bootstrap Authors 4 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) 5 | */ 6 | :root, 7 | [data-bs-theme=light] { 8 | --bs-blue: #0d6efd; 9 | --bs-indigo: #6610f2; 10 | --bs-purple: #6f42c1; 11 | --bs-pink: #d63384; 12 | --bs-red: #dc3545; 13 | --bs-orange: #fd7e14; 14 | --bs-yellow: #ffc107; 15 | --bs-green: #198754; 16 | --bs-teal: #20c997; 17 | --bs-cyan: #0dcaf0; 18 | --bs-black: #000; 19 | --bs-white: #fff; 20 | --bs-gray: #6c757d; 21 | --bs-gray-dark: #343a40; 22 | --bs-gray-100: #f8f9fa; 23 | --bs-gray-200: #e9ecef; 24 | --bs-gray-300: #dee2e6; 25 | --bs-gray-400: #ced4da; 26 | --bs-gray-500: #adb5bd; 27 | --bs-gray-600: #6c757d; 28 | --bs-gray-700: #495057; 29 | --bs-gray-800: #343a40; 30 | --bs-gray-900: #212529; 31 | --bs-primary: #0d6efd; 32 | --bs-secondary: #6c757d; 33 | --bs-success: #198754; 34 | --bs-info: #0dcaf0; 35 | --bs-warning: #ffc107; 36 | --bs-danger: #dc3545; 37 | --bs-light: #f8f9fa; 38 | --bs-dark: #212529; 39 | --bs-primary-rgb: 13, 110, 253; 40 | --bs-secondary-rgb: 108, 117, 125; 41 | --bs-success-rgb: 25, 135, 84; 42 | --bs-info-rgb: 13, 202, 240; 43 | --bs-warning-rgb: 255, 193, 7; 44 | --bs-danger-rgb: 220, 53, 69; 45 | --bs-light-rgb: 248, 249, 250; 46 | --bs-dark-rgb: 33, 37, 41; 47 | --bs-primary-text-emphasis: #052c65; 48 | --bs-secondary-text-emphasis: #2b2f32; 49 | --bs-success-text-emphasis: #0a3622; 50 | --bs-info-text-emphasis: #055160; 51 | --bs-warning-text-emphasis: #664d03; 52 | --bs-danger-text-emphasis: #58151c; 53 | --bs-light-text-emphasis: #495057; 54 | --bs-dark-text-emphasis: #495057; 55 | --bs-primary-bg-subtle: #cfe2ff; 56 | --bs-secondary-bg-subtle: #e2e3e5; 57 | --bs-success-bg-subtle: #d1e7dd; 58 | --bs-info-bg-subtle: #cff4fc; 59 | --bs-warning-bg-subtle: #fff3cd; 60 | --bs-danger-bg-subtle: #f8d7da; 61 | --bs-light-bg-subtle: #fcfcfd; 62 | --bs-dark-bg-subtle: #ced4da; 63 | --bs-primary-border-subtle: #9ec5fe; 64 | --bs-secondary-border-subtle: #c4c8cb; 65 | --bs-success-border-subtle: #a3cfbb; 66 | --bs-info-border-subtle: #9eeaf9; 67 | --bs-warning-border-subtle: #ffe69c; 68 | --bs-danger-border-subtle: #f1aeb5; 69 | --bs-light-border-subtle: #e9ecef; 70 | --bs-dark-border-subtle: #adb5bd; 71 | --bs-white-rgb: 255, 255, 255; 72 | --bs-black-rgb: 0, 0, 0; 73 | --bs-font-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; 74 | --bs-font-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; 75 | --bs-gradient: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0)); 76 | --bs-body-font-family: var(--bs-font-sans-serif); 77 | --bs-body-font-size: 1rem; 78 | --bs-body-font-weight: 400; 79 | --bs-body-line-height: 1.5; 80 | --bs-body-color: #212529; 81 | --bs-body-color-rgb: 33, 37, 41; 82 | --bs-body-bg: #fff; 83 | --bs-body-bg-rgb: 255, 255, 255; 84 | --bs-emphasis-color: #000; 85 | --bs-emphasis-color-rgb: 0, 0, 0; 86 | --bs-secondary-color: rgba(33, 37, 41, 0.75); 87 | --bs-secondary-color-rgb: 33, 37, 41; 88 | --bs-secondary-bg: #e9ecef; 89 | --bs-secondary-bg-rgb: 233, 236, 239; 90 | --bs-tertiary-color: rgba(33, 37, 41, 0.5); 91 | --bs-tertiary-color-rgb: 33, 37, 41; 92 | --bs-tertiary-bg: #f8f9fa; 93 | --bs-tertiary-bg-rgb: 248, 249, 250; 94 | --bs-heading-color: inherit; 95 | --bs-link-color: #0d6efd; 96 | --bs-link-color-rgb: 13, 110, 253; 97 | --bs-link-decoration: underline; 98 | --bs-link-hover-color: #0a58ca; 99 | --bs-link-hover-color-rgb: 10, 88, 202; 100 | --bs-code-color: #d63384; 101 | --bs-highlight-color: #212529; 102 | --bs-highlight-bg: #fff3cd; 103 | --bs-border-width: 1px; 104 | --bs-border-style: solid; 105 | --bs-border-color: #dee2e6; 106 | --bs-border-color-translucent: rgba(0, 0, 0, 0.175); 107 | --bs-border-radius: 0.375rem; 108 | --bs-border-radius-sm: 0.25rem; 109 | --bs-border-radius-lg: 0.5rem; 110 | --bs-border-radius-xl: 1rem; 111 | --bs-border-radius-xxl: 2rem; 112 | --bs-border-radius-2xl: var(--bs-border-radius-xxl); 113 | --bs-border-radius-pill: 50rem; 114 | --bs-box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15); 115 | --bs-box-shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075); 116 | --bs-box-shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175); 117 | --bs-box-shadow-inset: inset 0 1px 2px rgba(0, 0, 0, 0.075); 118 | --bs-focus-ring-width: 0.25rem; 119 | --bs-focus-ring-opacity: 0.25; 120 | --bs-focus-ring-color: rgba(13, 110, 253, 0.25); 121 | --bs-form-valid-color: #198754; 122 | --bs-form-valid-border-color: #198754; 123 | --bs-form-invalid-color: #dc3545; 124 | --bs-form-invalid-border-color: #dc3545; 125 | } 126 | 127 | [data-bs-theme=dark] { 128 | color-scheme: dark; 129 | --bs-body-color: #dee2e6; 130 | --bs-body-color-rgb: 222, 226, 230; 131 | --bs-body-bg: #212529; 132 | --bs-body-bg-rgb: 33, 37, 41; 133 | --bs-emphasis-color: #fff; 134 | --bs-emphasis-color-rgb: 255, 255, 255; 135 | --bs-secondary-color: rgba(222, 226, 230, 0.75); 136 | --bs-secondary-color-rgb: 222, 226, 230; 137 | --bs-secondary-bg: #343a40; 138 | --bs-secondary-bg-rgb: 52, 58, 64; 139 | --bs-tertiary-color: rgba(222, 226, 230, 0.5); 140 | --bs-tertiary-color-rgb: 222, 226, 230; 141 | --bs-tertiary-bg: #2b3035; 142 | --bs-tertiary-bg-rgb: 43, 48, 53; 143 | --bs-primary-text-emphasis: #6ea8fe; 144 | --bs-secondary-text-emphasis: #a7acb1; 145 | --bs-success-text-emphasis: #75b798; 146 | --bs-info-text-emphasis: #6edff6; 147 | --bs-warning-text-emphasis: #ffda6a; 148 | --bs-danger-text-emphasis: #ea868f; 149 | --bs-light-text-emphasis: #f8f9fa; 150 | --bs-dark-text-emphasis: #dee2e6; 151 | --bs-primary-bg-subtle: #031633; 152 | --bs-secondary-bg-subtle: #161719; 153 | --bs-success-bg-subtle: #051b11; 154 | --bs-info-bg-subtle: #032830; 155 | --bs-warning-bg-subtle: #332701; 156 | --bs-danger-bg-subtle: #2c0b0e; 157 | --bs-light-bg-subtle: #343a40; 158 | --bs-dark-bg-subtle: #1a1d20; 159 | --bs-primary-border-subtle: #084298; 160 | --bs-secondary-border-subtle: #41464b; 161 | --bs-success-border-subtle: #0f5132; 162 | --bs-info-border-subtle: #087990; 163 | --bs-warning-border-subtle: #997404; 164 | --bs-danger-border-subtle: #842029; 165 | --bs-light-border-subtle: #495057; 166 | --bs-dark-border-subtle: #343a40; 167 | --bs-heading-color: inherit; 168 | --bs-link-color: #6ea8fe; 169 | --bs-link-hover-color: #8bb9fe; 170 | --bs-link-color-rgb: 110, 168, 254; 171 | --bs-link-hover-color-rgb: 139, 185, 254; 172 | --bs-code-color: #e685b5; 173 | --bs-highlight-color: #dee2e6; 174 | --bs-highlight-bg: #664d03; 175 | --bs-border-color: #495057; 176 | --bs-border-color-translucent: rgba(255, 255, 255, 0.15); 177 | --bs-form-valid-color: #75b798; 178 | --bs-form-valid-border-color: #75b798; 179 | --bs-form-invalid-color: #ea868f; 180 | --bs-form-invalid-border-color: #ea868f; 181 | } 182 | 183 | *, 184 | *::before, 185 | *::after { 186 | box-sizing: border-box; 187 | } 188 | 189 | @media (prefers-reduced-motion: no-preference) { 190 | :root { 191 | scroll-behavior: smooth; 192 | } 193 | } 194 | 195 | body { 196 | margin: 0; 197 | font-family: var(--bs-body-font-family); 198 | font-size: var(--bs-body-font-size); 199 | font-weight: var(--bs-body-font-weight); 200 | line-height: var(--bs-body-line-height); 201 | color: var(--bs-body-color); 202 | text-align: var(--bs-body-text-align); 203 | background-color: var(--bs-body-bg); 204 | -webkit-text-size-adjust: 100%; 205 | -webkit-tap-highlight-color: rgba(0, 0, 0, 0); 206 | } 207 | 208 | hr { 209 | margin: 1rem 0; 210 | color: inherit; 211 | border: 0; 212 | border-top: var(--bs-border-width) solid; 213 | opacity: 0.25; 214 | } 215 | 216 | h6, h5, h4, h3, h2, h1 { 217 | margin-top: 0; 218 | margin-bottom: 0.5rem; 219 | font-weight: 500; 220 | line-height: 1.2; 221 | color: var(--bs-heading-color); 222 | } 223 | 224 | h1 { 225 | font-size: calc(1.375rem + 1.5vw); 226 | } 227 | @media (min-width: 1200px) { 228 | h1 { 229 | font-size: 2.5rem; 230 | } 231 | } 232 | 233 | h2 { 234 | font-size: calc(1.325rem + 0.9vw); 235 | } 236 | @media (min-width: 1200px) { 237 | h2 { 238 | font-size: 2rem; 239 | } 240 | } 241 | 242 | h3 { 243 | font-size: calc(1.3rem + 0.6vw); 244 | } 245 | @media (min-width: 1200px) { 246 | h3 { 247 | font-size: 1.75rem; 248 | } 249 | } 250 | 251 | h4 { 252 | font-size: calc(1.275rem + 0.3vw); 253 | } 254 | @media (min-width: 1200px) { 255 | h4 { 256 | font-size: 1.5rem; 257 | } 258 | } 259 | 260 | h5 { 261 | font-size: 1.25rem; 262 | } 263 | 264 | h6 { 265 | font-size: 1rem; 266 | } 267 | 268 | p { 269 | margin-top: 0; 270 | margin-bottom: 1rem; 271 | } 272 | 273 | abbr[title] { 274 | -webkit-text-decoration: underline dotted; 275 | text-decoration: underline dotted; 276 | cursor: help; 277 | -webkit-text-decoration-skip-ink: none; 278 | text-decoration-skip-ink: none; 279 | } 280 | 281 | address { 282 | margin-bottom: 1rem; 283 | font-style: normal; 284 | line-height: inherit; 285 | } 286 | 287 | ol, 288 | ul { 289 | padding-left: 2rem; 290 | } 291 | 292 | ol, 293 | ul, 294 | dl { 295 | margin-top: 0; 296 | margin-bottom: 1rem; 297 | } 298 | 299 | ol ol, 300 | ul ul, 301 | ol ul, 302 | ul ol { 303 | margin-bottom: 0; 304 | } 305 | 306 | dt { 307 | font-weight: 700; 308 | } 309 | 310 | dd { 311 | margin-bottom: 0.5rem; 312 | margin-left: 0; 313 | } 314 | 315 | blockquote { 316 | margin: 0 0 1rem; 317 | } 318 | 319 | b, 320 | strong { 321 | font-weight: bolder; 322 | } 323 | 324 | small { 325 | font-size: 0.875em; 326 | } 327 | 328 | mark { 329 | padding: 0.1875em; 330 | color: var(--bs-highlight-color); 331 | background-color: var(--bs-highlight-bg); 332 | } 333 | 334 | sub, 335 | sup { 336 | position: relative; 337 | font-size: 0.75em; 338 | line-height: 0; 339 | vertical-align: baseline; 340 | } 341 | 342 | sub { 343 | bottom: -0.25em; 344 | } 345 | 346 | sup { 347 | top: -0.5em; 348 | } 349 | 350 | a { 351 | color: rgba(var(--bs-link-color-rgb), var(--bs-link-opacity, 1)); 352 | text-decoration: underline; 353 | } 354 | a:hover { 355 | --bs-link-color-rgb: var(--bs-link-hover-color-rgb); 356 | } 357 | 358 | a:not([href]):not([class]), a:not([href]):not([class]):hover { 359 | color: inherit; 360 | text-decoration: none; 361 | } 362 | 363 | pre, 364 | code, 365 | kbd, 366 | samp { 367 | font-family: var(--bs-font-monospace); 368 | font-size: 1em; 369 | } 370 | 371 | pre { 372 | display: block; 373 | margin-top: 0; 374 | margin-bottom: 1rem; 375 | overflow: auto; 376 | font-size: 0.875em; 377 | } 378 | pre code { 379 | font-size: inherit; 380 | color: inherit; 381 | word-break: normal; 382 | } 383 | 384 | code { 385 | font-size: 0.875em; 386 | color: var(--bs-code-color); 387 | word-wrap: break-word; 388 | } 389 | a > code { 390 | color: inherit; 391 | } 392 | 393 | kbd { 394 | padding: 0.1875rem 0.375rem; 395 | font-size: 0.875em; 396 | color: var(--bs-body-bg); 397 | background-color: var(--bs-body-color); 398 | border-radius: 0.25rem; 399 | } 400 | kbd kbd { 401 | padding: 0; 402 | font-size: 1em; 403 | } 404 | 405 | figure { 406 | margin: 0 0 1rem; 407 | } 408 | 409 | img, 410 | svg { 411 | vertical-align: middle; 412 | } 413 | 414 | table { 415 | caption-side: bottom; 416 | border-collapse: collapse; 417 | } 418 | 419 | caption { 420 | padding-top: 0.5rem; 421 | padding-bottom: 0.5rem; 422 | color: var(--bs-secondary-color); 423 | text-align: left; 424 | } 425 | 426 | th { 427 | text-align: inherit; 428 | text-align: -webkit-match-parent; 429 | } 430 | 431 | thead, 432 | tbody, 433 | tfoot, 434 | tr, 435 | td, 436 | th { 437 | border-color: inherit; 438 | border-style: solid; 439 | border-width: 0; 440 | } 441 | 442 | label { 443 | display: inline-block; 444 | } 445 | 446 | button { 447 | border-radius: 0; 448 | } 449 | 450 | button:focus:not(:focus-visible) { 451 | outline: 0; 452 | } 453 | 454 | input, 455 | button, 456 | select, 457 | optgroup, 458 | textarea { 459 | margin: 0; 460 | font-family: inherit; 461 | font-size: inherit; 462 | line-height: inherit; 463 | } 464 | 465 | button, 466 | select { 467 | text-transform: none; 468 | } 469 | 470 | [role=button] { 471 | cursor: pointer; 472 | } 473 | 474 | select { 475 | word-wrap: normal; 476 | } 477 | select:disabled { 478 | opacity: 1; 479 | } 480 | 481 | [list]:not([type=date]):not([type=datetime-local]):not([type=month]):not([type=week]):not([type=time])::-webkit-calendar-picker-indicator { 482 | display: none !important; 483 | } 484 | 485 | button, 486 | [type=button], 487 | [type=reset], 488 | [type=submit] { 489 | -webkit-appearance: button; 490 | } 491 | button:not(:disabled), 492 | [type=button]:not(:disabled), 493 | [type=reset]:not(:disabled), 494 | [type=submit]:not(:disabled) { 495 | cursor: pointer; 496 | } 497 | 498 | ::-moz-focus-inner { 499 | padding: 0; 500 | border-style: none; 501 | } 502 | 503 | textarea { 504 | resize: vertical; 505 | } 506 | 507 | fieldset { 508 | min-width: 0; 509 | padding: 0; 510 | margin: 0; 511 | border: 0; 512 | } 513 | 514 | legend { 515 | float: left; 516 | width: 100%; 517 | padding: 0; 518 | margin-bottom: 0.5rem; 519 | font-size: calc(1.275rem + 0.3vw); 520 | line-height: inherit; 521 | } 522 | @media (min-width: 1200px) { 523 | legend { 524 | font-size: 1.5rem; 525 | } 526 | } 527 | legend + * { 528 | clear: left; 529 | } 530 | 531 | ::-webkit-datetime-edit-fields-wrapper, 532 | ::-webkit-datetime-edit-text, 533 | ::-webkit-datetime-edit-minute, 534 | ::-webkit-datetime-edit-hour-field, 535 | ::-webkit-datetime-edit-day-field, 536 | ::-webkit-datetime-edit-month-field, 537 | ::-webkit-datetime-edit-year-field { 538 | padding: 0; 539 | } 540 | 541 | ::-webkit-inner-spin-button { 542 | height: auto; 543 | } 544 | 545 | [type=search] { 546 | -webkit-appearance: textfield; 547 | outline-offset: -2px; 548 | } 549 | 550 | /* rtl:raw: 551 | [type="tel"], 552 | [type="url"], 553 | [type="email"], 554 | [type="number"] { 555 | direction: ltr; 556 | } 557 | */ 558 | ::-webkit-search-decoration { 559 | -webkit-appearance: none; 560 | } 561 | 562 | ::-webkit-color-swatch-wrapper { 563 | padding: 0; 564 | } 565 | 566 | ::-webkit-file-upload-button { 567 | font: inherit; 568 | -webkit-appearance: button; 569 | } 570 | 571 | ::file-selector-button { 572 | font: inherit; 573 | -webkit-appearance: button; 574 | } 575 | 576 | output { 577 | display: inline-block; 578 | } 579 | 580 | iframe { 581 | border: 0; 582 | } 583 | 584 | summary { 585 | display: list-item; 586 | cursor: pointer; 587 | } 588 | 589 | progress { 590 | vertical-align: baseline; 591 | } 592 | 593 | [hidden] { 594 | display: none !important; 595 | } 596 | 597 | /*# sourceMappingURL=bootstrap-reboot.css.map */ -------------------------------------------------------------------------------- /BlazorCodeEditor/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Reboot v5.3.3 (https://getbootstrap.com/) 3 | * Copyright 2011-2024 The Bootstrap Authors 4 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) 5 | */:root,[data-bs-theme=light]{--bs-blue:#0d6efd;--bs-indigo:#6610f2;--bs-purple:#6f42c1;--bs-pink:#d63384;--bs-red:#dc3545;--bs-orange:#fd7e14;--bs-yellow:#ffc107;--bs-green:#198754;--bs-teal:#20c997;--bs-cyan:#0dcaf0;--bs-black:#000;--bs-white:#fff;--bs-gray:#6c757d;--bs-gray-dark:#343a40;--bs-gray-100:#f8f9fa;--bs-gray-200:#e9ecef;--bs-gray-300:#dee2e6;--bs-gray-400:#ced4da;--bs-gray-500:#adb5bd;--bs-gray-600:#6c757d;--bs-gray-700:#495057;--bs-gray-800:#343a40;--bs-gray-900:#212529;--bs-primary:#0d6efd;--bs-secondary:#6c757d;--bs-success:#198754;--bs-info:#0dcaf0;--bs-warning:#ffc107;--bs-danger:#dc3545;--bs-light:#f8f9fa;--bs-dark:#212529;--bs-primary-rgb:13,110,253;--bs-secondary-rgb:108,117,125;--bs-success-rgb:25,135,84;--bs-info-rgb:13,202,240;--bs-warning-rgb:255,193,7;--bs-danger-rgb:220,53,69;--bs-light-rgb:248,249,250;--bs-dark-rgb:33,37,41;--bs-primary-text-emphasis:#052c65;--bs-secondary-text-emphasis:#2b2f32;--bs-success-text-emphasis:#0a3622;--bs-info-text-emphasis:#055160;--bs-warning-text-emphasis:#664d03;--bs-danger-text-emphasis:#58151c;--bs-light-text-emphasis:#495057;--bs-dark-text-emphasis:#495057;--bs-primary-bg-subtle:#cfe2ff;--bs-secondary-bg-subtle:#e2e3e5;--bs-success-bg-subtle:#d1e7dd;--bs-info-bg-subtle:#cff4fc;--bs-warning-bg-subtle:#fff3cd;--bs-danger-bg-subtle:#f8d7da;--bs-light-bg-subtle:#fcfcfd;--bs-dark-bg-subtle:#ced4da;--bs-primary-border-subtle:#9ec5fe;--bs-secondary-border-subtle:#c4c8cb;--bs-success-border-subtle:#a3cfbb;--bs-info-border-subtle:#9eeaf9;--bs-warning-border-subtle:#ffe69c;--bs-danger-border-subtle:#f1aeb5;--bs-light-border-subtle:#e9ecef;--bs-dark-border-subtle:#adb5bd;--bs-white-rgb:255,255,255;--bs-black-rgb:0,0,0;--bs-font-sans-serif:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue","Noto Sans","Liberation Sans",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--bs-font-monospace:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--bs-gradient:linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0));--bs-body-font-family:var(--bs-font-sans-serif);--bs-body-font-size:1rem;--bs-body-font-weight:400;--bs-body-line-height:1.5;--bs-body-color:#212529;--bs-body-color-rgb:33,37,41;--bs-body-bg:#fff;--bs-body-bg-rgb:255,255,255;--bs-emphasis-color:#000;--bs-emphasis-color-rgb:0,0,0;--bs-secondary-color:rgba(33, 37, 41, 0.75);--bs-secondary-color-rgb:33,37,41;--bs-secondary-bg:#e9ecef;--bs-secondary-bg-rgb:233,236,239;--bs-tertiary-color:rgba(33, 37, 41, 0.5);--bs-tertiary-color-rgb:33,37,41;--bs-tertiary-bg:#f8f9fa;--bs-tertiary-bg-rgb:248,249,250;--bs-heading-color:inherit;--bs-link-color:#0d6efd;--bs-link-color-rgb:13,110,253;--bs-link-decoration:underline;--bs-link-hover-color:#0a58ca;--bs-link-hover-color-rgb:10,88,202;--bs-code-color:#d63384;--bs-highlight-color:#212529;--bs-highlight-bg:#fff3cd;--bs-border-width:1px;--bs-border-style:solid;--bs-border-color:#dee2e6;--bs-border-color-translucent:rgba(0, 0, 0, 0.175);--bs-border-radius:0.375rem;--bs-border-radius-sm:0.25rem;--bs-border-radius-lg:0.5rem;--bs-border-radius-xl:1rem;--bs-border-radius-xxl:2rem;--bs-border-radius-2xl:var(--bs-border-radius-xxl);--bs-border-radius-pill:50rem;--bs-box-shadow:0 0.5rem 1rem rgba(0, 0, 0, 0.15);--bs-box-shadow-sm:0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);--bs-box-shadow-lg:0 1rem 3rem rgba(0, 0, 0, 0.175);--bs-box-shadow-inset:inset 0 1px 2px rgba(0, 0, 0, 0.075);--bs-focus-ring-width:0.25rem;--bs-focus-ring-opacity:0.25;--bs-focus-ring-color:rgba(13, 110, 253, 0.25);--bs-form-valid-color:#198754;--bs-form-valid-border-color:#198754;--bs-form-invalid-color:#dc3545;--bs-form-invalid-border-color:#dc3545}[data-bs-theme=dark]{color-scheme:dark;--bs-body-color:#dee2e6;--bs-body-color-rgb:222,226,230;--bs-body-bg:#212529;--bs-body-bg-rgb:33,37,41;--bs-emphasis-color:#fff;--bs-emphasis-color-rgb:255,255,255;--bs-secondary-color:rgba(222, 226, 230, 0.75);--bs-secondary-color-rgb:222,226,230;--bs-secondary-bg:#343a40;--bs-secondary-bg-rgb:52,58,64;--bs-tertiary-color:rgba(222, 226, 230, 0.5);--bs-tertiary-color-rgb:222,226,230;--bs-tertiary-bg:#2b3035;--bs-tertiary-bg-rgb:43,48,53;--bs-primary-text-emphasis:#6ea8fe;--bs-secondary-text-emphasis:#a7acb1;--bs-success-text-emphasis:#75b798;--bs-info-text-emphasis:#6edff6;--bs-warning-text-emphasis:#ffda6a;--bs-danger-text-emphasis:#ea868f;--bs-light-text-emphasis:#f8f9fa;--bs-dark-text-emphasis:#dee2e6;--bs-primary-bg-subtle:#031633;--bs-secondary-bg-subtle:#161719;--bs-success-bg-subtle:#051b11;--bs-info-bg-subtle:#032830;--bs-warning-bg-subtle:#332701;--bs-danger-bg-subtle:#2c0b0e;--bs-light-bg-subtle:#343a40;--bs-dark-bg-subtle:#1a1d20;--bs-primary-border-subtle:#084298;--bs-secondary-border-subtle:#41464b;--bs-success-border-subtle:#0f5132;--bs-info-border-subtle:#087990;--bs-warning-border-subtle:#997404;--bs-danger-border-subtle:#842029;--bs-light-border-subtle:#495057;--bs-dark-border-subtle:#343a40;--bs-heading-color:inherit;--bs-link-color:#6ea8fe;--bs-link-hover-color:#8bb9fe;--bs-link-color-rgb:110,168,254;--bs-link-hover-color-rgb:139,185,254;--bs-code-color:#e685b5;--bs-highlight-color:#dee2e6;--bs-highlight-bg:#664d03;--bs-border-color:#495057;--bs-border-color-translucent:rgba(255, 255, 255, 0.15);--bs-form-valid-color:#75b798;--bs-form-valid-border-color:#75b798;--bs-form-invalid-color:#ea868f;--bs-form-invalid-border-color:#ea868f}*,::after,::before{box-sizing:border-box}@media (prefers-reduced-motion:no-preference){:root{scroll-behavior:smooth}}body{margin:0;font-family:var(--bs-body-font-family);font-size:var(--bs-body-font-size);font-weight:var(--bs-body-font-weight);line-height:var(--bs-body-line-height);color:var(--bs-body-color);text-align:var(--bs-body-text-align);background-color:var(--bs-body-bg);-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}hr{margin:1rem 0;color:inherit;border:0;border-top:var(--bs-border-width) solid;opacity:.25}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem;font-weight:500;line-height:1.2;color:var(--bs-heading-color)}h1{font-size:calc(1.375rem + 1.5vw)}@media (min-width:1200px){h1{font-size:2.5rem}}h2{font-size:calc(1.325rem + .9vw)}@media (min-width:1200px){h2{font-size:2rem}}h3{font-size:calc(1.3rem + .6vw)}@media (min-width:1200px){h3{font-size:1.75rem}}h4{font-size:calc(1.275rem + .3vw)}@media (min-width:1200px){h4{font-size:1.5rem}}h5{font-size:1.25rem}h6{font-size:1rem}p{margin-top:0;margin-bottom:1rem}abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}ol,ul{padding-left:2rem}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:.875em}mark{padding:.1875em;color:var(--bs-highlight-color);background-color:var(--bs-highlight-bg)}sub,sup{position:relative;font-size:.75em;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:rgba(var(--bs-link-color-rgb),var(--bs-link-opacity,1));text-decoration:underline}a:hover{--bs-link-color-rgb:var(--bs-link-hover-color-rgb)}a:not([href]):not([class]),a:not([href]):not([class]):hover{color:inherit;text-decoration:none}code,kbd,pre,samp{font-family:var(--bs-font-monospace);font-size:1em}pre{display:block;margin-top:0;margin-bottom:1rem;overflow:auto;font-size:.875em}pre code{font-size:inherit;color:inherit;word-break:normal}code{font-size:.875em;color:var(--bs-code-color);word-wrap:break-word}a>code{color:inherit}kbd{padding:.1875rem .375rem;font-size:.875em;color:var(--bs-body-bg);background-color:var(--bs-body-color);border-radius:.25rem}kbd kbd{padding:0;font-size:1em}figure{margin:0 0 1rem}img,svg{vertical-align:middle}table{caption-side:bottom;border-collapse:collapse}caption{padding-top:.5rem;padding-bottom:.5rem;color:var(--bs-secondary-color);text-align:left}th{text-align:inherit;text-align:-webkit-match-parent}tbody,td,tfoot,th,thead,tr{border-color:inherit;border-style:solid;border-width:0}label{display:inline-block}button{border-radius:0}button:focus:not(:focus-visible){outline:0}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,select{text-transform:none}[role=button]{cursor:pointer}select{word-wrap:normal}select:disabled{opacity:1}[list]:not([type=date]):not([type=datetime-local]):not([type=month]):not([type=week]):not([type=time])::-webkit-calendar-picker-indicator{display:none!important}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}::-moz-focus-inner{padding:0;border-style:none}textarea{resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{float:left;width:100%;padding:0;margin-bottom:.5rem;font-size:calc(1.275rem + .3vw);line-height:inherit}@media (min-width:1200px){legend{font-size:1.5rem}}legend+*{clear:left}::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-fields-wrapper,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-text,::-webkit-datetime-edit-year-field{padding:0}::-webkit-inner-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-color-swatch-wrapper{padding:0}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}::file-selector-button{font:inherit;-webkit-appearance:button}output{display:inline-block}iframe{border:0}summary{display:list-item;cursor:pointer}progress{vertical-align:baseline}[hidden]{display:none!important} 6 | /*# sourceMappingURL=bootstrap-reboot.min.css.map */ -------------------------------------------------------------------------------- /BlazorCodeEditor/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.min.css.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["../../scss/mixins/_banner.scss","../../scss/_root.scss","dist/css/bootstrap-reboot.css","../../scss/vendor/_rfs.scss","../../scss/mixins/_color-mode.scss","../../scss/_reboot.scss","../../scss/mixins/_border-radius.scss"],"names":[],"mappings":"AACE;;;;ACDF,MCMA,sBDGI,UAAA,QAAA,YAAA,QAAA,YAAA,QAAA,UAAA,QAAA,SAAA,QAAA,YAAA,QAAA,YAAA,QAAA,WAAA,QAAA,UAAA,QAAA,UAAA,QAAA,WAAA,KAAA,WAAA,KAAA,UAAA,QAAA,eAAA,QAIA,cAAA,QAAA,cAAA,QAAA,cAAA,QAAA,cAAA,QAAA,cAAA,QAAA,cAAA,QAAA,cAAA,QAAA,cAAA,QAAA,cAAA,QAIA,aAAA,QAAA,eAAA,QAAA,aAAA,QAAA,UAAA,QAAA,aAAA,QAAA,YAAA,QAAA,WAAA,QAAA,UAAA,QAIA,iBAAA,EAAA,CAAA,GAAA,CAAA,IAAA,mBAAA,GAAA,CAAA,GAAA,CAAA,IAAA,iBAAA,EAAA,CAAA,GAAA,CAAA,GAAA,cAAA,EAAA,CAAA,GAAA,CAAA,IAAA,iBAAA,GAAA,CAAA,GAAA,CAAA,EAAA,gBAAA,GAAA,CAAA,EAAA,CAAA,GAAA,eAAA,GAAA,CAAA,GAAA,CAAA,IAAA,cAAA,EAAA,CAAA,EAAA,CAAA,GAIA,2BAAA,QAAA,6BAAA,QAAA,2BAAA,QAAA,wBAAA,QAAA,2BAAA,QAAA,0BAAA,QAAA,yBAAA,QAAA,wBAAA,QAIA,uBAAA,QAAA,yBAAA,QAAA,uBAAA,QAAA,oBAAA,QAAA,uBAAA,QAAA,sBAAA,QAAA,qBAAA,QAAA,oBAAA,QAIA,2BAAA,QAAA,6BAAA,QAAA,2BAAA,QAAA,wBAAA,QAAA,2BAAA,QAAA,0BAAA,QAAA,yBAAA,QAAA,wBAAA,QAGF,eAAA,GAAA,CAAA,GAAA,CAAA,IACA,eAAA,CAAA,CAAA,CAAA,CAAA,EAMA,qBAAA,SAAA,CAAA,aAAA,CAAA,UAAA,CAAA,MAAA,CAAA,gBAAA,CAAA,WAAA,CAAA,iBAAA,CAAA,KAAA,CAAA,UAAA,CAAA,mBAAA,CAAA,gBAAA,CAAA,iBAAA,CAAA,mBACA,oBAAA,cAAA,CAAA,KAAA,CAAA,MAAA,CAAA,QAAA,CAAA,iBAAA,CAAA,aAAA,CAAA,UACA,cAAA,2EAOA,sBAAA,0BE2OI,oBAAA,KFzOJ,sBAAA,IACA,sBAAA,IAKA,gBAAA,QACA,oBAAA,EAAA,CAAA,EAAA,CAAA,GACA,aAAA,KACA,iBAAA,GAAA,CAAA,GAAA,CAAA,IAEA,oBAAA,KACA,wBAAA,CAAA,CAAA,CAAA,CAAA,EAEA,qBAAA,uBACA,yBAAA,EAAA,CAAA,EAAA,CAAA,GACA,kBAAA,QACA,sBAAA,GAAA,CAAA,GAAA,CAAA,IAEA,oBAAA,sBACA,wBAAA,EAAA,CAAA,EAAA,CAAA,GACA,iBAAA,QACA,qBAAA,GAAA,CAAA,GAAA,CAAA,IAGA,mBAAA,QAEA,gBAAA,QACA,oBAAA,EAAA,CAAA,GAAA,CAAA,IACA,qBAAA,UAEA,sBAAA,QACA,0BAAA,EAAA,CAAA,EAAA,CAAA,IAMA,gBAAA,QACA,qBAAA,QACA,kBAAA,QAGA,kBAAA,IACA,kBAAA,MACA,kBAAA,QACA,8BAAA,qBAEA,mBAAA,SACA,sBAAA,QACA,sBAAA,OACA,sBAAA,KACA,uBAAA,KACA,uBAAA,4BACA,wBAAA,MAGA,gBAAA,EAAA,OAAA,KAAA,oBACA,mBAAA,EAAA,SAAA,QAAA,qBACA,mBAAA,EAAA,KAAA,KAAA,qBACA,sBAAA,MAAA,EAAA,IAAA,IAAA,qBAIA,sBAAA,QACA,wBAAA,KACA,sBAAA,yBAIA,sBAAA,QACA,6BAAA,QACA,wBAAA,QACA,+BAAA,QGhHE,qBHsHA,aAAA,KAGA,gBAAA,QACA,oBAAA,GAAA,CAAA,GAAA,CAAA,IACA,aAAA,QACA,iBAAA,EAAA,CAAA,EAAA,CAAA,GAEA,oBAAA,KACA,wBAAA,GAAA,CAAA,GAAA,CAAA,IAEA,qBAAA,0BACA,yBAAA,GAAA,CAAA,GAAA,CAAA,IACA,kBAAA,QACA,sBAAA,EAAA,CAAA,EAAA,CAAA,GAEA,oBAAA,yBACA,wBAAA,GAAA,CAAA,GAAA,CAAA,IACA,iBAAA,QACA,qBAAA,EAAA,CAAA,EAAA,CAAA,GAGE,2BAAA,QAAA,6BAAA,QAAA,2BAAA,QAAA,wBAAA,QAAA,2BAAA,QAAA,0BAAA,QAAA,yBAAA,QAAA,wBAAA,QAIA,uBAAA,QAAA,yBAAA,QAAA,uBAAA,QAAA,oBAAA,QAAA,uBAAA,QAAA,sBAAA,QAAA,qBAAA,QAAA,oBAAA,QAIA,2BAAA,QAAA,6BAAA,QAAA,2BAAA,QAAA,wBAAA,QAAA,2BAAA,QAAA,0BAAA,QAAA,yBAAA,QAAA,wBAAA,QAGF,mBAAA,QAEA,gBAAA,QACA,sBAAA,QACA,oBAAA,GAAA,CAAA,GAAA,CAAA,IACA,0BAAA,GAAA,CAAA,GAAA,CAAA,IAEA,gBAAA,QACA,qBAAA,QACA,kBAAA,QAEA,kBAAA,QACA,8BAAA,0BAEA,sBAAA,QACA,6BAAA,QACA,wBAAA,QACA,+BAAA,QIxKJ,EHyKA,QADA,SGrKE,WAAA,WAeE,8CANJ,MAOM,gBAAA,QAcN,KACE,OAAA,EACA,YAAA,2BF6OI,UAAA,yBE3OJ,YAAA,2BACA,YAAA,2BACA,MAAA,qBACA,WAAA,0BACA,iBAAA,kBACA,yBAAA,KACA,4BAAA,YASF,GACE,OAAA,KAAA,EACA,MAAA,QACA,OAAA,EACA,WAAA,uBAAA,MACA,QAAA,IAUF,GAAA,GAAA,GAAA,GAAA,GAAA,GACE,WAAA,EACA,cAAA,MAGA,YAAA,IACA,YAAA,IACA,MAAA,wBAGF,GFuMQ,UAAA,uBA5JJ,0BE3CJ,GF8MQ,UAAA,QEzMR,GFkMQ,UAAA,sBA5JJ,0BEtCJ,GFyMQ,UAAA,MEpMR,GF6LQ,UAAA,oBA5JJ,0BEjCJ,GFoMQ,UAAA,SE/LR,GFwLQ,UAAA,sBA5JJ,0BE5BJ,GF+LQ,UAAA,QE1LR,GF+KM,UAAA,QE1KN,GF0KM,UAAA,KE/JN,EACE,WAAA,EACA,cAAA,KAUF,YACE,wBAAA,UAAA,OAAA,gBAAA,UAAA,OACA,OAAA,KACA,iCAAA,KAAA,yBAAA,KAMF,QACE,cAAA,KACA,WAAA,OACA,YAAA,QAMF,GHiIA,GG/HE,aAAA,KHqIF,GGlIA,GHiIA,GG9HE,WAAA,EACA,cAAA,KAGF,MHkIA,MACA,MAFA,MG7HE,cAAA,EAGF,GACE,YAAA,IAKF,GACE,cAAA,MACA,YAAA,EAMF,WACE,OAAA,EAAA,EAAA,KAQF,EHuHA,OGrHE,YAAA,OAQF,MF6EM,UAAA,OEtEN,KACE,QAAA,QACA,MAAA,0BACA,iBAAA,uBASF,IHyGA,IGvGE,SAAA,SFwDI,UAAA,MEtDJ,YAAA,EACA,eAAA,SAGF,IAAM,OAAA,OACN,IAAM,IAAA,MAKN,EACE,MAAA,wDACA,gBAAA,UAEA,QACE,oBAAA,+BAWF,2BAAA,iCAEE,MAAA,QACA,gBAAA,KHqGJ,KACA,IG/FA,IHgGA,KG5FE,YAAA,yBFcI,UAAA,IENN,IACE,QAAA,MACA,WAAA,EACA,cAAA,KACA,SAAA,KFEI,UAAA,OEGJ,SFHI,UAAA,QEKF,MAAA,QACA,WAAA,OAIJ,KFVM,UAAA,OEYJ,MAAA,qBACA,UAAA,WAGA,OACE,MAAA,QAIJ,IACE,QAAA,SAAA,QFtBI,UAAA,OEwBJ,MAAA,kBACA,iBAAA,qBCrSE,cAAA,ODwSF,QACE,QAAA,EF7BE,UAAA,IEwCN,OACE,OAAA,EAAA,EAAA,KAMF,IH2EA,IGzEE,eAAA,OAQF,MACE,aAAA,OACA,gBAAA,SAGF,QACE,YAAA,MACA,eAAA,MACA,MAAA,0BACA,WAAA,KAOF,GAEE,WAAA,QACA,WAAA,qBHoEF,MAGA,GAFA,MAGA,GGrEA,MHmEA,GG7DE,aAAA,QACA,aAAA,MACA,aAAA,EAQF,MACE,QAAA,aAMF,OAEE,cAAA,EAQF,iCACE,QAAA,EHsDF,OGjDA,MHmDA,SADA,OAEA,SG/CE,OAAA,EACA,YAAA,QF5HI,UAAA,QE8HJ,YAAA,QAIF,OHgDA,OG9CE,eAAA,KAKF,cACE,OAAA,QAGF,OAGE,UAAA,OAGA,gBACE,QAAA,EAOJ,0IACE,QAAA,eH0CF,cACA,aACA,cGpCA,OAIE,mBAAA,OHoCF,6BACA,4BACA,6BGnCI,sBACE,OAAA,QAON,mBACE,QAAA,EACA,aAAA,KAKF,SACE,OAAA,SAUF,SACE,UAAA,EACA,QAAA,EACA,OAAA,EACA,OAAA,EAQF,OACE,MAAA,KACA,MAAA,KACA,QAAA,EACA,cAAA,MFjNM,UAAA,sBEoNN,YAAA,QFhXE,0BEyWJ,OFtMQ,UAAA,QE+MN,SACE,MAAA,KH4BJ,kCGrBA,uCHoBA,mCADA,+BAGA,oCAJA,6BAKA,mCGhBE,QAAA,EAGF,4BACE,OAAA,KASF,cACE,mBAAA,UACA,eAAA,KAmBF,4BACE,mBAAA,KAKF,+BACE,QAAA,EAOF,6BACE,KAAA,QACA,mBAAA,OAFF,uBACE,KAAA,QACA,mBAAA,OAKF,OACE,QAAA,aAKF,OACE,OAAA,EAOF,QACE,QAAA,UACA,OAAA,QAQF,SACE,eAAA,SAQF,SACE,QAAA","sourcesContent":["@mixin bsBanner($file) {\n /*!\n * Bootstrap #{$file} v5.3.3 (https://getbootstrap.com/)\n * Copyright 2011-2024 The Bootstrap Authors\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n */\n}\n",":root,\n[data-bs-theme=\"light\"] {\n // Note: Custom variable values only support SassScript inside `#{}`.\n\n // Colors\n //\n // Generate palettes for full colors, grays, and theme colors.\n\n @each $color, $value in $colors {\n --#{$prefix}#{$color}: #{$value};\n }\n\n @each $color, $value in $grays {\n --#{$prefix}gray-#{$color}: #{$value};\n }\n\n @each $color, $value in $theme-colors {\n --#{$prefix}#{$color}: #{$value};\n }\n\n @each $color, $value in $theme-colors-rgb {\n --#{$prefix}#{$color}-rgb: #{$value};\n }\n\n @each $color, $value in $theme-colors-text {\n --#{$prefix}#{$color}-text-emphasis: #{$value};\n }\n\n @each $color, $value in $theme-colors-bg-subtle {\n --#{$prefix}#{$color}-bg-subtle: #{$value};\n }\n\n @each $color, $value in $theme-colors-border-subtle {\n --#{$prefix}#{$color}-border-subtle: #{$value};\n }\n\n --#{$prefix}white-rgb: #{to-rgb($white)};\n --#{$prefix}black-rgb: #{to-rgb($black)};\n\n // Fonts\n\n // Note: Use `inspect` for lists so that quoted items keep the quotes.\n // See https://github.com/sass/sass/issues/2383#issuecomment-336349172\n --#{$prefix}font-sans-serif: #{inspect($font-family-sans-serif)};\n --#{$prefix}font-monospace: #{inspect($font-family-monospace)};\n --#{$prefix}gradient: #{$gradient};\n\n // Root and body\n // scss-docs-start root-body-variables\n @if $font-size-root != null {\n --#{$prefix}root-font-size: #{$font-size-root};\n }\n --#{$prefix}body-font-family: #{inspect($font-family-base)};\n @include rfs($font-size-base, --#{$prefix}body-font-size);\n --#{$prefix}body-font-weight: #{$font-weight-base};\n --#{$prefix}body-line-height: #{$line-height-base};\n @if $body-text-align != null {\n --#{$prefix}body-text-align: #{$body-text-align};\n }\n\n --#{$prefix}body-color: #{$body-color};\n --#{$prefix}body-color-rgb: #{to-rgb($body-color)};\n --#{$prefix}body-bg: #{$body-bg};\n --#{$prefix}body-bg-rgb: #{to-rgb($body-bg)};\n\n --#{$prefix}emphasis-color: #{$body-emphasis-color};\n --#{$prefix}emphasis-color-rgb: #{to-rgb($body-emphasis-color)};\n\n --#{$prefix}secondary-color: #{$body-secondary-color};\n --#{$prefix}secondary-color-rgb: #{to-rgb($body-secondary-color)};\n --#{$prefix}secondary-bg: #{$body-secondary-bg};\n --#{$prefix}secondary-bg-rgb: #{to-rgb($body-secondary-bg)};\n\n --#{$prefix}tertiary-color: #{$body-tertiary-color};\n --#{$prefix}tertiary-color-rgb: #{to-rgb($body-tertiary-color)};\n --#{$prefix}tertiary-bg: #{$body-tertiary-bg};\n --#{$prefix}tertiary-bg-rgb: #{to-rgb($body-tertiary-bg)};\n // scss-docs-end root-body-variables\n\n --#{$prefix}heading-color: #{$headings-color};\n\n --#{$prefix}link-color: #{$link-color};\n --#{$prefix}link-color-rgb: #{to-rgb($link-color)};\n --#{$prefix}link-decoration: #{$link-decoration};\n\n --#{$prefix}link-hover-color: #{$link-hover-color};\n --#{$prefix}link-hover-color-rgb: #{to-rgb($link-hover-color)};\n\n @if $link-hover-decoration != null {\n --#{$prefix}link-hover-decoration: #{$link-hover-decoration};\n }\n\n --#{$prefix}code-color: #{$code-color};\n --#{$prefix}highlight-color: #{$mark-color};\n --#{$prefix}highlight-bg: #{$mark-bg};\n\n // scss-docs-start root-border-var\n --#{$prefix}border-width: #{$border-width};\n --#{$prefix}border-style: #{$border-style};\n --#{$prefix}border-color: #{$border-color};\n --#{$prefix}border-color-translucent: #{$border-color-translucent};\n\n --#{$prefix}border-radius: #{$border-radius};\n --#{$prefix}border-radius-sm: #{$border-radius-sm};\n --#{$prefix}border-radius-lg: #{$border-radius-lg};\n --#{$prefix}border-radius-xl: #{$border-radius-xl};\n --#{$prefix}border-radius-xxl: #{$border-radius-xxl};\n --#{$prefix}border-radius-2xl: var(--#{$prefix}border-radius-xxl); // Deprecated in v5.3.0 for consistency\n --#{$prefix}border-radius-pill: #{$border-radius-pill};\n // scss-docs-end root-border-var\n\n --#{$prefix}box-shadow: #{$box-shadow};\n --#{$prefix}box-shadow-sm: #{$box-shadow-sm};\n --#{$prefix}box-shadow-lg: #{$box-shadow-lg};\n --#{$prefix}box-shadow-inset: #{$box-shadow-inset};\n\n // Focus styles\n // scss-docs-start root-focus-variables\n --#{$prefix}focus-ring-width: #{$focus-ring-width};\n --#{$prefix}focus-ring-opacity: #{$focus-ring-opacity};\n --#{$prefix}focus-ring-color: #{$focus-ring-color};\n // scss-docs-end root-focus-variables\n\n // scss-docs-start root-form-validation-variables\n --#{$prefix}form-valid-color: #{$form-valid-color};\n --#{$prefix}form-valid-border-color: #{$form-valid-border-color};\n --#{$prefix}form-invalid-color: #{$form-invalid-color};\n --#{$prefix}form-invalid-border-color: #{$form-invalid-border-color};\n // scss-docs-end root-form-validation-variables\n}\n\n@if $enable-dark-mode {\n @include color-mode(dark, true) {\n color-scheme: dark;\n\n // scss-docs-start root-dark-mode-vars\n --#{$prefix}body-color: #{$body-color-dark};\n --#{$prefix}body-color-rgb: #{to-rgb($body-color-dark)};\n --#{$prefix}body-bg: #{$body-bg-dark};\n --#{$prefix}body-bg-rgb: #{to-rgb($body-bg-dark)};\n\n --#{$prefix}emphasis-color: #{$body-emphasis-color-dark};\n --#{$prefix}emphasis-color-rgb: #{to-rgb($body-emphasis-color-dark)};\n\n --#{$prefix}secondary-color: #{$body-secondary-color-dark};\n --#{$prefix}secondary-color-rgb: #{to-rgb($body-secondary-color-dark)};\n --#{$prefix}secondary-bg: #{$body-secondary-bg-dark};\n --#{$prefix}secondary-bg-rgb: #{to-rgb($body-secondary-bg-dark)};\n\n --#{$prefix}tertiary-color: #{$body-tertiary-color-dark};\n --#{$prefix}tertiary-color-rgb: #{to-rgb($body-tertiary-color-dark)};\n --#{$prefix}tertiary-bg: #{$body-tertiary-bg-dark};\n --#{$prefix}tertiary-bg-rgb: #{to-rgb($body-tertiary-bg-dark)};\n\n @each $color, $value in $theme-colors-text-dark {\n --#{$prefix}#{$color}-text-emphasis: #{$value};\n }\n\n @each $color, $value in $theme-colors-bg-subtle-dark {\n --#{$prefix}#{$color}-bg-subtle: #{$value};\n }\n\n @each $color, $value in $theme-colors-border-subtle-dark {\n --#{$prefix}#{$color}-border-subtle: #{$value};\n }\n\n --#{$prefix}heading-color: #{$headings-color-dark};\n\n --#{$prefix}link-color: #{$link-color-dark};\n --#{$prefix}link-hover-color: #{$link-hover-color-dark};\n --#{$prefix}link-color-rgb: #{to-rgb($link-color-dark)};\n --#{$prefix}link-hover-color-rgb: #{to-rgb($link-hover-color-dark)};\n\n --#{$prefix}code-color: #{$code-color-dark};\n --#{$prefix}highlight-color: #{$mark-color-dark};\n --#{$prefix}highlight-bg: #{$mark-bg-dark};\n\n --#{$prefix}border-color: #{$border-color-dark};\n --#{$prefix}border-color-translucent: #{$border-color-translucent-dark};\n\n --#{$prefix}form-valid-color: #{$form-valid-color-dark};\n --#{$prefix}form-valid-border-color: #{$form-valid-border-color-dark};\n --#{$prefix}form-invalid-color: #{$form-invalid-color-dark};\n --#{$prefix}form-invalid-border-color: #{$form-invalid-border-color-dark};\n // scss-docs-end root-dark-mode-vars\n }\n}\n","/*!\n * Bootstrap Reboot v5.3.3 (https://getbootstrap.com/)\n * Copyright 2011-2024 The Bootstrap Authors\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)\n */\n:root,\n[data-bs-theme=light] {\n --bs-blue: #0d6efd;\n --bs-indigo: #6610f2;\n --bs-purple: #6f42c1;\n --bs-pink: #d63384;\n --bs-red: #dc3545;\n --bs-orange: #fd7e14;\n --bs-yellow: #ffc107;\n --bs-green: #198754;\n --bs-teal: #20c997;\n --bs-cyan: #0dcaf0;\n --bs-black: #000;\n --bs-white: #fff;\n --bs-gray: #6c757d;\n --bs-gray-dark: #343a40;\n --bs-gray-100: #f8f9fa;\n --bs-gray-200: #e9ecef;\n --bs-gray-300: #dee2e6;\n --bs-gray-400: #ced4da;\n --bs-gray-500: #adb5bd;\n --bs-gray-600: #6c757d;\n --bs-gray-700: #495057;\n --bs-gray-800: #343a40;\n --bs-gray-900: #212529;\n --bs-primary: #0d6efd;\n --bs-secondary: #6c757d;\n --bs-success: #198754;\n --bs-info: #0dcaf0;\n --bs-warning: #ffc107;\n --bs-danger: #dc3545;\n --bs-light: #f8f9fa;\n --bs-dark: #212529;\n --bs-primary-rgb: 13, 110, 253;\n --bs-secondary-rgb: 108, 117, 125;\n --bs-success-rgb: 25, 135, 84;\n --bs-info-rgb: 13, 202, 240;\n --bs-warning-rgb: 255, 193, 7;\n --bs-danger-rgb: 220, 53, 69;\n --bs-light-rgb: 248, 249, 250;\n --bs-dark-rgb: 33, 37, 41;\n --bs-primary-text-emphasis: #052c65;\n --bs-secondary-text-emphasis: #2b2f32;\n --bs-success-text-emphasis: #0a3622;\n --bs-info-text-emphasis: #055160;\n --bs-warning-text-emphasis: #664d03;\n --bs-danger-text-emphasis: #58151c;\n --bs-light-text-emphasis: #495057;\n --bs-dark-text-emphasis: #495057;\n --bs-primary-bg-subtle: #cfe2ff;\n --bs-secondary-bg-subtle: #e2e3e5;\n --bs-success-bg-subtle: #d1e7dd;\n --bs-info-bg-subtle: #cff4fc;\n --bs-warning-bg-subtle: #fff3cd;\n --bs-danger-bg-subtle: #f8d7da;\n --bs-light-bg-subtle: #fcfcfd;\n --bs-dark-bg-subtle: #ced4da;\n --bs-primary-border-subtle: #9ec5fe;\n --bs-secondary-border-subtle: #c4c8cb;\n --bs-success-border-subtle: #a3cfbb;\n --bs-info-border-subtle: #9eeaf9;\n --bs-warning-border-subtle: #ffe69c;\n --bs-danger-border-subtle: #f1aeb5;\n --bs-light-border-subtle: #e9ecef;\n --bs-dark-border-subtle: #adb5bd;\n --bs-white-rgb: 255, 255, 255;\n --bs-black-rgb: 0, 0, 0;\n --bs-font-sans-serif: system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", \"Noto Sans\", \"Liberation Sans\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\";\n --bs-font-monospace: SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace;\n --bs-gradient: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0));\n --bs-body-font-family: var(--bs-font-sans-serif);\n --bs-body-font-size: 1rem;\n --bs-body-font-weight: 400;\n --bs-body-line-height: 1.5;\n --bs-body-color: #212529;\n --bs-body-color-rgb: 33, 37, 41;\n --bs-body-bg: #fff;\n --bs-body-bg-rgb: 255, 255, 255;\n --bs-emphasis-color: #000;\n --bs-emphasis-color-rgb: 0, 0, 0;\n --bs-secondary-color: rgba(33, 37, 41, 0.75);\n --bs-secondary-color-rgb: 33, 37, 41;\n --bs-secondary-bg: #e9ecef;\n --bs-secondary-bg-rgb: 233, 236, 239;\n --bs-tertiary-color: rgba(33, 37, 41, 0.5);\n --bs-tertiary-color-rgb: 33, 37, 41;\n --bs-tertiary-bg: #f8f9fa;\n --bs-tertiary-bg-rgb: 248, 249, 250;\n --bs-heading-color: inherit;\n --bs-link-color: #0d6efd;\n --bs-link-color-rgb: 13, 110, 253;\n --bs-link-decoration: underline;\n --bs-link-hover-color: #0a58ca;\n --bs-link-hover-color-rgb: 10, 88, 202;\n --bs-code-color: #d63384;\n --bs-highlight-color: #212529;\n --bs-highlight-bg: #fff3cd;\n --bs-border-width: 1px;\n --bs-border-style: solid;\n --bs-border-color: #dee2e6;\n --bs-border-color-translucent: rgba(0, 0, 0, 0.175);\n --bs-border-radius: 0.375rem;\n --bs-border-radius-sm: 0.25rem;\n --bs-border-radius-lg: 0.5rem;\n --bs-border-radius-xl: 1rem;\n --bs-border-radius-xxl: 2rem;\n --bs-border-radius-2xl: var(--bs-border-radius-xxl);\n --bs-border-radius-pill: 50rem;\n --bs-box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);\n --bs-box-shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);\n --bs-box-shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);\n --bs-box-shadow-inset: inset 0 1px 2px rgba(0, 0, 0, 0.075);\n --bs-focus-ring-width: 0.25rem;\n --bs-focus-ring-opacity: 0.25;\n --bs-focus-ring-color: rgba(13, 110, 253, 0.25);\n --bs-form-valid-color: #198754;\n --bs-form-valid-border-color: #198754;\n --bs-form-invalid-color: #dc3545;\n --bs-form-invalid-border-color: #dc3545;\n}\n\n[data-bs-theme=dark] {\n color-scheme: dark;\n --bs-body-color: #dee2e6;\n --bs-body-color-rgb: 222, 226, 230;\n --bs-body-bg: #212529;\n --bs-body-bg-rgb: 33, 37, 41;\n --bs-emphasis-color: #fff;\n --bs-emphasis-color-rgb: 255, 255, 255;\n --bs-secondary-color: rgba(222, 226, 230, 0.75);\n --bs-secondary-color-rgb: 222, 226, 230;\n --bs-secondary-bg: #343a40;\n --bs-secondary-bg-rgb: 52, 58, 64;\n --bs-tertiary-color: rgba(222, 226, 230, 0.5);\n --bs-tertiary-color-rgb: 222, 226, 230;\n --bs-tertiary-bg: #2b3035;\n --bs-tertiary-bg-rgb: 43, 48, 53;\n --bs-primary-text-emphasis: #6ea8fe;\n --bs-secondary-text-emphasis: #a7acb1;\n --bs-success-text-emphasis: #75b798;\n --bs-info-text-emphasis: #6edff6;\n --bs-warning-text-emphasis: #ffda6a;\n --bs-danger-text-emphasis: #ea868f;\n --bs-light-text-emphasis: #f8f9fa;\n --bs-dark-text-emphasis: #dee2e6;\n --bs-primary-bg-subtle: #031633;\n --bs-secondary-bg-subtle: #161719;\n --bs-success-bg-subtle: #051b11;\n --bs-info-bg-subtle: #032830;\n --bs-warning-bg-subtle: #332701;\n --bs-danger-bg-subtle: #2c0b0e;\n --bs-light-bg-subtle: #343a40;\n --bs-dark-bg-subtle: #1a1d20;\n --bs-primary-border-subtle: #084298;\n --bs-secondary-border-subtle: #41464b;\n --bs-success-border-subtle: #0f5132;\n --bs-info-border-subtle: #087990;\n --bs-warning-border-subtle: #997404;\n --bs-danger-border-subtle: #842029;\n --bs-light-border-subtle: #495057;\n --bs-dark-border-subtle: #343a40;\n --bs-heading-color: inherit;\n --bs-link-color: #6ea8fe;\n --bs-link-hover-color: #8bb9fe;\n --bs-link-color-rgb: 110, 168, 254;\n --bs-link-hover-color-rgb: 139, 185, 254;\n --bs-code-color: #e685b5;\n --bs-highlight-color: #dee2e6;\n --bs-highlight-bg: #664d03;\n --bs-border-color: #495057;\n --bs-border-color-translucent: rgba(255, 255, 255, 0.15);\n --bs-form-valid-color: #75b798;\n --bs-form-valid-border-color: #75b798;\n --bs-form-invalid-color: #ea868f;\n --bs-form-invalid-border-color: #ea868f;\n}\n\n*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\n\n@media (prefers-reduced-motion: no-preference) {\n :root {\n scroll-behavior: smooth;\n }\n}\n\nbody {\n margin: 0;\n font-family: var(--bs-body-font-family);\n font-size: var(--bs-body-font-size);\n font-weight: var(--bs-body-font-weight);\n line-height: var(--bs-body-line-height);\n color: var(--bs-body-color);\n text-align: var(--bs-body-text-align);\n background-color: var(--bs-body-bg);\n -webkit-text-size-adjust: 100%;\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n}\n\nhr {\n margin: 1rem 0;\n color: inherit;\n border: 0;\n border-top: var(--bs-border-width) solid;\n opacity: 0.25;\n}\n\nh6, h5, h4, h3, h2, h1 {\n margin-top: 0;\n margin-bottom: 0.5rem;\n font-weight: 500;\n line-height: 1.2;\n color: var(--bs-heading-color);\n}\n\nh1 {\n font-size: calc(1.375rem + 1.5vw);\n}\n@media (min-width: 1200px) {\n h1 {\n font-size: 2.5rem;\n }\n}\n\nh2 {\n font-size: calc(1.325rem + 0.9vw);\n}\n@media (min-width: 1200px) {\n h2 {\n font-size: 2rem;\n }\n}\n\nh3 {\n font-size: calc(1.3rem + 0.6vw);\n}\n@media (min-width: 1200px) {\n h3 {\n font-size: 1.75rem;\n }\n}\n\nh4 {\n font-size: calc(1.275rem + 0.3vw);\n}\n@media (min-width: 1200px) {\n h4 {\n font-size: 1.5rem;\n }\n}\n\nh5 {\n font-size: 1.25rem;\n}\n\nh6 {\n font-size: 1rem;\n}\n\np {\n margin-top: 0;\n margin-bottom: 1rem;\n}\n\nabbr[title] {\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n cursor: help;\n -webkit-text-decoration-skip-ink: none;\n text-decoration-skip-ink: none;\n}\n\naddress {\n margin-bottom: 1rem;\n font-style: normal;\n line-height: inherit;\n}\n\nol,\nul {\n padding-left: 2rem;\n}\n\nol,\nul,\ndl {\n margin-top: 0;\n margin-bottom: 1rem;\n}\n\nol ol,\nul ul,\nol ul,\nul ol {\n margin-bottom: 0;\n}\n\ndt {\n font-weight: 700;\n}\n\ndd {\n margin-bottom: 0.5rem;\n margin-left: 0;\n}\n\nblockquote {\n margin: 0 0 1rem;\n}\n\nb,\nstrong {\n font-weight: bolder;\n}\n\nsmall {\n font-size: 0.875em;\n}\n\nmark {\n padding: 0.1875em;\n color: var(--bs-highlight-color);\n background-color: var(--bs-highlight-bg);\n}\n\nsub,\nsup {\n position: relative;\n font-size: 0.75em;\n line-height: 0;\n vertical-align: baseline;\n}\n\nsub {\n bottom: -0.25em;\n}\n\nsup {\n top: -0.5em;\n}\n\na {\n color: rgba(var(--bs-link-color-rgb), var(--bs-link-opacity, 1));\n text-decoration: underline;\n}\na:hover {\n --bs-link-color-rgb: var(--bs-link-hover-color-rgb);\n}\n\na:not([href]):not([class]), a:not([href]):not([class]):hover {\n color: inherit;\n text-decoration: none;\n}\n\npre,\ncode,\nkbd,\nsamp {\n font-family: var(--bs-font-monospace);\n font-size: 1em;\n}\n\npre {\n display: block;\n margin-top: 0;\n margin-bottom: 1rem;\n overflow: auto;\n font-size: 0.875em;\n}\npre code {\n font-size: inherit;\n color: inherit;\n word-break: normal;\n}\n\ncode {\n font-size: 0.875em;\n color: var(--bs-code-color);\n word-wrap: break-word;\n}\na > code {\n color: inherit;\n}\n\nkbd {\n padding: 0.1875rem 0.375rem;\n font-size: 0.875em;\n color: var(--bs-body-bg);\n background-color: var(--bs-body-color);\n border-radius: 0.25rem;\n}\nkbd kbd {\n padding: 0;\n font-size: 1em;\n}\n\nfigure {\n margin: 0 0 1rem;\n}\n\nimg,\nsvg {\n vertical-align: middle;\n}\n\ntable {\n caption-side: bottom;\n border-collapse: collapse;\n}\n\ncaption {\n padding-top: 0.5rem;\n padding-bottom: 0.5rem;\n color: var(--bs-secondary-color);\n text-align: left;\n}\n\nth {\n text-align: inherit;\n text-align: -webkit-match-parent;\n}\n\nthead,\ntbody,\ntfoot,\ntr,\ntd,\nth {\n border-color: inherit;\n border-style: solid;\n border-width: 0;\n}\n\nlabel {\n display: inline-block;\n}\n\nbutton {\n border-radius: 0;\n}\n\nbutton:focus:not(:focus-visible) {\n outline: 0;\n}\n\ninput,\nbutton,\nselect,\noptgroup,\ntextarea {\n margin: 0;\n font-family: inherit;\n font-size: inherit;\n line-height: inherit;\n}\n\nbutton,\nselect {\n text-transform: none;\n}\n\n[role=button] {\n cursor: pointer;\n}\n\nselect {\n word-wrap: normal;\n}\nselect:disabled {\n opacity: 1;\n}\n\n[list]:not([type=date]):not([type=datetime-local]):not([type=month]):not([type=week]):not([type=time])::-webkit-calendar-picker-indicator {\n display: none !important;\n}\n\nbutton,\n[type=button],\n[type=reset],\n[type=submit] {\n -webkit-appearance: button;\n}\nbutton:not(:disabled),\n[type=button]:not(:disabled),\n[type=reset]:not(:disabled),\n[type=submit]:not(:disabled) {\n cursor: pointer;\n}\n\n::-moz-focus-inner {\n padding: 0;\n border-style: none;\n}\n\ntextarea {\n resize: vertical;\n}\n\nfieldset {\n min-width: 0;\n padding: 0;\n margin: 0;\n border: 0;\n}\n\nlegend {\n float: left;\n width: 100%;\n padding: 0;\n margin-bottom: 0.5rem;\n font-size: calc(1.275rem + 0.3vw);\n line-height: inherit;\n}\n@media (min-width: 1200px) {\n legend {\n font-size: 1.5rem;\n }\n}\nlegend + * {\n clear: left;\n}\n\n::-webkit-datetime-edit-fields-wrapper,\n::-webkit-datetime-edit-text,\n::-webkit-datetime-edit-minute,\n::-webkit-datetime-edit-hour-field,\n::-webkit-datetime-edit-day-field,\n::-webkit-datetime-edit-month-field,\n::-webkit-datetime-edit-year-field {\n padding: 0;\n}\n\n::-webkit-inner-spin-button {\n height: auto;\n}\n\n[type=search] {\n -webkit-appearance: textfield;\n outline-offset: -2px;\n}\n\n/* rtl:raw:\n[type=\"tel\"],\n[type=\"url\"],\n[type=\"email\"],\n[type=\"number\"] {\n direction: ltr;\n}\n*/\n::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n\n::-webkit-color-swatch-wrapper {\n padding: 0;\n}\n\n::-webkit-file-upload-button {\n font: inherit;\n -webkit-appearance: button;\n}\n\n::file-selector-button {\n font: inherit;\n -webkit-appearance: button;\n}\n\noutput {\n display: inline-block;\n}\n\niframe {\n border: 0;\n}\n\nsummary {\n display: list-item;\n cursor: pointer;\n}\n\nprogress {\n vertical-align: baseline;\n}\n\n[hidden] {\n display: none !important;\n}\n\n/*# sourceMappingURL=bootstrap-reboot.css.map */","// stylelint-disable scss/dimension-no-non-numeric-values\n\n// SCSS RFS mixin\n//\n// Automated responsive values for font sizes, paddings, margins and much more\n//\n// Licensed under MIT (https://github.com/twbs/rfs/blob/main/LICENSE)\n\n// Configuration\n\n// Base value\n$rfs-base-value: 1.25rem !default;\n$rfs-unit: rem !default;\n\n@if $rfs-unit != rem and $rfs-unit != px {\n @error \"`#{$rfs-unit}` is not a valid unit for $rfs-unit. Use `px` or `rem`.\";\n}\n\n// Breakpoint at where values start decreasing if screen width is smaller\n$rfs-breakpoint: 1200px !default;\n$rfs-breakpoint-unit: px !default;\n\n@if $rfs-breakpoint-unit != px and $rfs-breakpoint-unit != em and $rfs-breakpoint-unit != rem {\n @error \"`#{$rfs-breakpoint-unit}` is not a valid unit for $rfs-breakpoint-unit. Use `px`, `em` or `rem`.\";\n}\n\n// Resize values based on screen height and width\n$rfs-two-dimensional: false !default;\n\n// Factor of decrease\n$rfs-factor: 10 !default;\n\n@if type-of($rfs-factor) != number or $rfs-factor <= 1 {\n @error \"`#{$rfs-factor}` is not a valid $rfs-factor, it must be greater than 1.\";\n}\n\n// Mode. Possibilities: \"min-media-query\", \"max-media-query\"\n$rfs-mode: min-media-query !default;\n\n// Generate enable or disable classes. Possibilities: false, \"enable\" or \"disable\"\n$rfs-class: false !default;\n\n// 1 rem = $rfs-rem-value px\n$rfs-rem-value: 16 !default;\n\n// Safari iframe resize bug: https://github.com/twbs/rfs/issues/14\n$rfs-safari-iframe-resize-bug-fix: false !default;\n\n// Disable RFS by setting $enable-rfs to false\n$enable-rfs: true !default;\n\n// Cache $rfs-base-value unit\n$rfs-base-value-unit: unit($rfs-base-value);\n\n@function divide($dividend, $divisor, $precision: 10) {\n $sign: if($dividend > 0 and $divisor > 0 or $dividend < 0 and $divisor < 0, 1, -1);\n $dividend: abs($dividend);\n $divisor: abs($divisor);\n @if $dividend == 0 {\n @return 0;\n }\n @if $divisor == 0 {\n @error \"Cannot divide by 0\";\n }\n $remainder: $dividend;\n $result: 0;\n $factor: 10;\n @while ($remainder > 0 and $precision >= 0) {\n $quotient: 0;\n @while ($remainder >= $divisor) {\n $remainder: $remainder - $divisor;\n $quotient: $quotient + 1;\n }\n $result: $result * 10 + $quotient;\n $factor: $factor * .1;\n $remainder: $remainder * 10;\n $precision: $precision - 1;\n @if ($precision < 0 and $remainder >= $divisor * 5) {\n $result: $result + 1;\n }\n }\n $result: $result * $factor * $sign;\n $dividend-unit: unit($dividend);\n $divisor-unit: unit($divisor);\n $unit-map: (\n \"px\": 1px,\n \"rem\": 1rem,\n \"em\": 1em,\n \"%\": 1%\n );\n @if ($dividend-unit != $divisor-unit and map-has-key($unit-map, $dividend-unit)) {\n $result: $result * map-get($unit-map, $dividend-unit);\n }\n @return $result;\n}\n\n// Remove px-unit from $rfs-base-value for calculations\n@if $rfs-base-value-unit == px {\n $rfs-base-value: divide($rfs-base-value, $rfs-base-value * 0 + 1);\n}\n@else if $rfs-base-value-unit == rem {\n $rfs-base-value: divide($rfs-base-value, divide($rfs-base-value * 0 + 1, $rfs-rem-value));\n}\n\n// Cache $rfs-breakpoint unit to prevent multiple calls\n$rfs-breakpoint-unit-cache: unit($rfs-breakpoint);\n\n// Remove unit from $rfs-breakpoint for calculations\n@if $rfs-breakpoint-unit-cache == px {\n $rfs-breakpoint: divide($rfs-breakpoint, $rfs-breakpoint * 0 + 1);\n}\n@else if $rfs-breakpoint-unit-cache == rem or $rfs-breakpoint-unit-cache == \"em\" {\n $rfs-breakpoint: divide($rfs-breakpoint, divide($rfs-breakpoint * 0 + 1, $rfs-rem-value));\n}\n\n// Calculate the media query value\n$rfs-mq-value: if($rfs-breakpoint-unit == px, #{$rfs-breakpoint}px, #{divide($rfs-breakpoint, $rfs-rem-value)}#{$rfs-breakpoint-unit});\n$rfs-mq-property-width: if($rfs-mode == max-media-query, max-width, min-width);\n$rfs-mq-property-height: if($rfs-mode == max-media-query, max-height, min-height);\n\n// Internal mixin used to determine which media query needs to be used\n@mixin _rfs-media-query {\n @if $rfs-two-dimensional {\n @if $rfs-mode == max-media-query {\n @media (#{$rfs-mq-property-width}: #{$rfs-mq-value}), (#{$rfs-mq-property-height}: #{$rfs-mq-value}) {\n @content;\n }\n }\n @else {\n @media (#{$rfs-mq-property-width}: #{$rfs-mq-value}) and (#{$rfs-mq-property-height}: #{$rfs-mq-value}) {\n @content;\n }\n }\n }\n @else {\n @media (#{$rfs-mq-property-width}: #{$rfs-mq-value}) {\n @content;\n }\n }\n}\n\n// Internal mixin that adds disable classes to the selector if needed.\n@mixin _rfs-rule {\n @if $rfs-class == disable and $rfs-mode == max-media-query {\n // Adding an extra class increases specificity, which prevents the media query to override the property\n &,\n .disable-rfs &,\n &.disable-rfs {\n @content;\n }\n }\n @else if $rfs-class == enable and $rfs-mode == min-media-query {\n .enable-rfs &,\n &.enable-rfs {\n @content;\n }\n } @else {\n @content;\n }\n}\n\n// Internal mixin that adds enable classes to the selector if needed.\n@mixin _rfs-media-query-rule {\n\n @if $rfs-class == enable {\n @if $rfs-mode == min-media-query {\n @content;\n }\n\n @include _rfs-media-query () {\n .enable-rfs &,\n &.enable-rfs {\n @content;\n }\n }\n }\n @else {\n @if $rfs-class == disable and $rfs-mode == min-media-query {\n .disable-rfs &,\n &.disable-rfs {\n @content;\n }\n }\n @include _rfs-media-query () {\n @content;\n }\n }\n}\n\n// Helper function to get the formatted non-responsive value\n@function rfs-value($values) {\n // Convert to list\n $values: if(type-of($values) != list, ($values,), $values);\n\n $val: \"\";\n\n // Loop over each value and calculate value\n @each $value in $values {\n @if $value == 0 {\n $val: $val + \" 0\";\n }\n @else {\n // Cache $value unit\n $unit: if(type-of($value) == \"number\", unit($value), false);\n\n @if $unit == px {\n // Convert to rem if needed\n $val: $val + \" \" + if($rfs-unit == rem, #{divide($value, $value * 0 + $rfs-rem-value)}rem, $value);\n }\n @else if $unit == rem {\n // Convert to px if needed\n $val: $val + \" \" + if($rfs-unit == px, #{divide($value, $value * 0 + 1) * $rfs-rem-value}px, $value);\n } @else {\n // If $value isn't a number (like inherit) or $value has a unit (not px or rem, like 1.5em) or $ is 0, just print the value\n $val: $val + \" \" + $value;\n }\n }\n }\n\n // Remove first space\n @return unquote(str-slice($val, 2));\n}\n\n// Helper function to get the responsive value calculated by RFS\n@function rfs-fluid-value($values) {\n // Convert to list\n $values: if(type-of($values) != list, ($values,), $values);\n\n $val: \"\";\n\n // Loop over each value and calculate value\n @each $value in $values {\n @if $value == 0 {\n $val: $val + \" 0\";\n } @else {\n // Cache $value unit\n $unit: if(type-of($value) == \"number\", unit($value), false);\n\n // If $value isn't a number (like inherit) or $value has a unit (not px or rem, like 1.5em) or $ is 0, just print the value\n @if not $unit or $unit != px and $unit != rem {\n $val: $val + \" \" + $value;\n } @else {\n // Remove unit from $value for calculations\n $value: divide($value, $value * 0 + if($unit == px, 1, divide(1, $rfs-rem-value)));\n\n // Only add the media query if the value is greater than the minimum value\n @if abs($value) <= $rfs-base-value or not $enable-rfs {\n $val: $val + \" \" + if($rfs-unit == rem, #{divide($value, $rfs-rem-value)}rem, #{$value}px);\n }\n @else {\n // Calculate the minimum value\n $value-min: $rfs-base-value + divide(abs($value) - $rfs-base-value, $rfs-factor);\n\n // Calculate difference between $value and the minimum value\n $value-diff: abs($value) - $value-min;\n\n // Base value formatting\n $min-width: if($rfs-unit == rem, #{divide($value-min, $rfs-rem-value)}rem, #{$value-min}px);\n\n // Use negative value if needed\n $min-width: if($value < 0, -$min-width, $min-width);\n\n // Use `vmin` if two-dimensional is enabled\n $variable-unit: if($rfs-two-dimensional, vmin, vw);\n\n // Calculate the variable width between 0 and $rfs-breakpoint\n $variable-width: #{divide($value-diff * 100, $rfs-breakpoint)}#{$variable-unit};\n\n // Return the calculated value\n $val: $val + \" calc(\" + $min-width + if($value < 0, \" - \", \" + \") + $variable-width + \")\";\n }\n }\n }\n }\n\n // Remove first space\n @return unquote(str-slice($val, 2));\n}\n\n// RFS mixin\n@mixin rfs($values, $property: font-size) {\n @if $values != null {\n $val: rfs-value($values);\n $fluid-val: rfs-fluid-value($values);\n\n // Do not print the media query if responsive & non-responsive values are the same\n @if $val == $fluid-val {\n #{$property}: $val;\n }\n @else {\n @include _rfs-rule () {\n #{$property}: if($rfs-mode == max-media-query, $val, $fluid-val);\n\n // Include safari iframe resize fix if needed\n min-width: if($rfs-safari-iframe-resize-bug-fix, (0 * 1vw), null);\n }\n\n @include _rfs-media-query-rule () {\n #{$property}: if($rfs-mode == max-media-query, $fluid-val, $val);\n }\n }\n }\n}\n\n// Shorthand helper mixins\n@mixin font-size($value) {\n @include rfs($value);\n}\n\n@mixin padding($value) {\n @include rfs($value, padding);\n}\n\n@mixin padding-top($value) {\n @include rfs($value, padding-top);\n}\n\n@mixin padding-right($value) {\n @include rfs($value, padding-right);\n}\n\n@mixin padding-bottom($value) {\n @include rfs($value, padding-bottom);\n}\n\n@mixin padding-left($value) {\n @include rfs($value, padding-left);\n}\n\n@mixin margin($value) {\n @include rfs($value, margin);\n}\n\n@mixin margin-top($value) {\n @include rfs($value, margin-top);\n}\n\n@mixin margin-right($value) {\n @include rfs($value, margin-right);\n}\n\n@mixin margin-bottom($value) {\n @include rfs($value, margin-bottom);\n}\n\n@mixin margin-left($value) {\n @include rfs($value, margin-left);\n}\n","// scss-docs-start color-mode-mixin\n@mixin color-mode($mode: light, $root: false) {\n @if $color-mode-type == \"media-query\" {\n @if $root == true {\n @media (prefers-color-scheme: $mode) {\n :root {\n @content;\n }\n }\n } @else {\n @media (prefers-color-scheme: $mode) {\n @content;\n }\n }\n } @else {\n [data-bs-theme=\"#{$mode}\"] {\n @content;\n }\n }\n}\n// scss-docs-end color-mode-mixin\n","// stylelint-disable declaration-no-important, selector-no-qualifying-type, property-no-vendor-prefix\n\n\n// Reboot\n//\n// Normalization of HTML elements, manually forked from Normalize.css to remove\n// styles targeting irrelevant browsers while applying new styles.\n//\n// Normalize is licensed MIT. https://github.com/necolas/normalize.css\n\n\n// Document\n//\n// Change from `box-sizing: content-box` so that `width` is not affected by `padding` or `border`.\n\n*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\n\n\n// Root\n//\n// Ability to the value of the root font sizes, affecting the value of `rem`.\n// null by default, thus nothing is generated.\n\n:root {\n @if $font-size-root != null {\n @include font-size(var(--#{$prefix}root-font-size));\n }\n\n @if $enable-smooth-scroll {\n @media (prefers-reduced-motion: no-preference) {\n scroll-behavior: smooth;\n }\n }\n}\n\n\n// Body\n//\n// 1. Remove the margin in all browsers.\n// 2. As a best practice, apply a default `background-color`.\n// 3. Prevent adjustments of font size after orientation changes in iOS.\n// 4. Change the default tap highlight to be completely transparent in iOS.\n\n// scss-docs-start reboot-body-rules\nbody {\n margin: 0; // 1\n font-family: var(--#{$prefix}body-font-family);\n @include font-size(var(--#{$prefix}body-font-size));\n font-weight: var(--#{$prefix}body-font-weight);\n line-height: var(--#{$prefix}body-line-height);\n color: var(--#{$prefix}body-color);\n text-align: var(--#{$prefix}body-text-align);\n background-color: var(--#{$prefix}body-bg); // 2\n -webkit-text-size-adjust: 100%; // 3\n -webkit-tap-highlight-color: rgba($black, 0); // 4\n}\n// scss-docs-end reboot-body-rules\n\n\n// Content grouping\n//\n// 1. Reset Firefox's gray color\n\nhr {\n margin: $hr-margin-y 0;\n color: $hr-color; // 1\n border: 0;\n border-top: $hr-border-width solid $hr-border-color;\n opacity: $hr-opacity;\n}\n\n\n// Typography\n//\n// 1. Remove top margins from headings\n// By default, `

`-`

` all receive top and bottom margins. We nuke the top\n// margin for easier control within type scales as it avoids margin collapsing.\n\n%heading {\n margin-top: 0; // 1\n margin-bottom: $headings-margin-bottom;\n font-family: $headings-font-family;\n font-style: $headings-font-style;\n font-weight: $headings-font-weight;\n line-height: $headings-line-height;\n color: var(--#{$prefix}heading-color);\n}\n\nh1 {\n @extend %heading;\n @include font-size($h1-font-size);\n}\n\nh2 {\n @extend %heading;\n @include font-size($h2-font-size);\n}\n\nh3 {\n @extend %heading;\n @include font-size($h3-font-size);\n}\n\nh4 {\n @extend %heading;\n @include font-size($h4-font-size);\n}\n\nh5 {\n @extend %heading;\n @include font-size($h5-font-size);\n}\n\nh6 {\n @extend %heading;\n @include font-size($h6-font-size);\n}\n\n\n// Reset margins on paragraphs\n//\n// Similarly, the top margin on `

`s get reset. However, we also reset the\n// bottom margin to use `rem` units instead of `em`.\n\np {\n margin-top: 0;\n margin-bottom: $paragraph-margin-bottom;\n}\n\n\n// Abbreviations\n//\n// 1. Add the correct text decoration in Chrome, Edge, Opera, and Safari.\n// 2. Add explicit cursor to indicate changed behavior.\n// 3. Prevent the text-decoration to be skipped.\n\nabbr[title] {\n text-decoration: underline dotted; // 1\n cursor: help; // 2\n text-decoration-skip-ink: none; // 3\n}\n\n\n// Address\n\naddress {\n margin-bottom: 1rem;\n font-style: normal;\n line-height: inherit;\n}\n\n\n// Lists\n\nol,\nul {\n padding-left: 2rem;\n}\n\nol,\nul,\ndl {\n margin-top: 0;\n margin-bottom: 1rem;\n}\n\nol ol,\nul ul,\nol ul,\nul ol {\n margin-bottom: 0;\n}\n\ndt {\n font-weight: $dt-font-weight;\n}\n\n// 1. Undo browser default\n\ndd {\n margin-bottom: .5rem;\n margin-left: 0; // 1\n}\n\n\n// Blockquote\n\nblockquote {\n margin: 0 0 1rem;\n}\n\n\n// Strong\n//\n// Add the correct font weight in Chrome, Edge, and Safari\n\nb,\nstrong {\n font-weight: $font-weight-bolder;\n}\n\n\n// Small\n//\n// Add the correct font size in all browsers\n\nsmall {\n @include font-size($small-font-size);\n}\n\n\n// Mark\n\nmark {\n padding: $mark-padding;\n color: var(--#{$prefix}highlight-color);\n background-color: var(--#{$prefix}highlight-bg);\n}\n\n\n// Sub and Sup\n//\n// Prevent `sub` and `sup` elements from affecting the line height in\n// all browsers.\n\nsub,\nsup {\n position: relative;\n @include font-size($sub-sup-font-size);\n line-height: 0;\n vertical-align: baseline;\n}\n\nsub { bottom: -.25em; }\nsup { top: -.5em; }\n\n\n// Links\n\na {\n color: rgba(var(--#{$prefix}link-color-rgb), var(--#{$prefix}link-opacity, 1));\n text-decoration: $link-decoration;\n\n &:hover {\n --#{$prefix}link-color-rgb: var(--#{$prefix}link-hover-color-rgb);\n text-decoration: $link-hover-decoration;\n }\n}\n\n// And undo these styles for placeholder links/named anchors (without href).\n// It would be more straightforward to just use a[href] in previous block, but that\n// causes specificity issues in many other styles that are too complex to fix.\n// See https://github.com/twbs/bootstrap/issues/19402\n\na:not([href]):not([class]) {\n &,\n &:hover {\n color: inherit;\n text-decoration: none;\n }\n}\n\n\n// Code\n\npre,\ncode,\nkbd,\nsamp {\n font-family: $font-family-code;\n @include font-size(1em); // Correct the odd `em` font sizing in all browsers.\n}\n\n// 1. Remove browser default top margin\n// 2. Reset browser default of `1em` to use `rem`s\n// 3. Don't allow content to break outside\n\npre {\n display: block;\n margin-top: 0; // 1\n margin-bottom: 1rem; // 2\n overflow: auto; // 3\n @include font-size($code-font-size);\n color: $pre-color;\n\n // Account for some code outputs that place code tags in pre tags\n code {\n @include font-size(inherit);\n color: inherit;\n word-break: normal;\n }\n}\n\ncode {\n @include font-size($code-font-size);\n color: var(--#{$prefix}code-color);\n word-wrap: break-word;\n\n // Streamline the style when inside anchors to avoid broken underline and more\n a > & {\n color: inherit;\n }\n}\n\nkbd {\n padding: $kbd-padding-y $kbd-padding-x;\n @include font-size($kbd-font-size);\n color: $kbd-color;\n background-color: $kbd-bg;\n @include border-radius($border-radius-sm);\n\n kbd {\n padding: 0;\n @include font-size(1em);\n font-weight: $nested-kbd-font-weight;\n }\n}\n\n\n// Figures\n//\n// Apply a consistent margin strategy (matches our type styles).\n\nfigure {\n margin: 0 0 1rem;\n}\n\n\n// Images and content\n\nimg,\nsvg {\n vertical-align: middle;\n}\n\n\n// Tables\n//\n// Prevent double borders\n\ntable {\n caption-side: bottom;\n border-collapse: collapse;\n}\n\ncaption {\n padding-top: $table-cell-padding-y;\n padding-bottom: $table-cell-padding-y;\n color: $table-caption-color;\n text-align: left;\n}\n\n// 1. Removes font-weight bold by inheriting\n// 2. Matches default `` alignment by inheriting `text-align`.\n// 3. Fix alignment for Safari\n\nth {\n font-weight: $table-th-font-weight; // 1\n text-align: inherit; // 2\n text-align: -webkit-match-parent; // 3\n}\n\nthead,\ntbody,\ntfoot,\ntr,\ntd,\nth {\n border-color: inherit;\n border-style: solid;\n border-width: 0;\n}\n\n\n// Forms\n//\n// 1. Allow labels to use `margin` for spacing.\n\nlabel {\n display: inline-block; // 1\n}\n\n// Remove the default `border-radius` that macOS Chrome adds.\n// See https://github.com/twbs/bootstrap/issues/24093\n\nbutton {\n // stylelint-disable-next-line property-disallowed-list\n border-radius: 0;\n}\n\n// Explicitly remove focus outline in Chromium when it shouldn't be\n// visible (e.g. as result of mouse click or touch tap). It already\n// should be doing this automatically, but seems to currently be\n// confused and applies its very visible two-tone outline anyway.\n\nbutton:focus:not(:focus-visible) {\n outline: 0;\n}\n\n// 1. Remove the margin in Firefox and Safari\n\ninput,\nbutton,\nselect,\noptgroup,\ntextarea {\n margin: 0; // 1\n font-family: inherit;\n @include font-size(inherit);\n line-height: inherit;\n}\n\n// Remove the inheritance of text transform in Firefox\nbutton,\nselect {\n text-transform: none;\n}\n// Set the cursor for non-`