Unnamed: 0
int64
0
0
repo_id
stringlengths
5
186
file_path
stringlengths
15
223
content
stringlengths
1
32.8M
0
repos
repos/scafetch/build.zig
const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const exe = b.addExecutable(.{ .name = "scafetch", .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); exe.root_module.addImport("ay-arg", b.dependency("ay-arg", .{ .target = target, .optimize = optimize, }).module("ay-arg")); b.installArtifact(exe); const run_cmd = b.addRunArtifact(exe); if (b.args) |args| { run_cmd.addArgs(args); } const run_step = b.step("run", "Run the app"); run_step.dependOn(&run_cmd.step); }
0
repos/scafetch
repos/scafetch/src/utils.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const builtin = @import("builtin"); pub fn requestGet(allocator: Allocator, url: []const u8) ![]const u8 { const uri = try std.Uri.parse(url); var client = std.http.Client{ .allocator = allocator }; defer client.deinit(); var header_buf: [4096]u8 = undefined; var req = try client.open(.GET, uri, .{ .server_header_buffer = &header_buf }); defer req.deinit(); try req.send(); try req.finish(); try req.wait(); const reader = req.reader(); const body = try reader.readAllAlloc(allocator, std.math.maxInt(usize)); errdefer allocator.free(body); return body; } pub const Color = enum { red, green, yellow, blue, purple, }; const windows = std.os.windows; pub const ConsoleStyle = struct { f: std.fs.File, attrs: AttrType(), fn AttrType() type { return switch (builtin.os.tag) { .windows => windows.WORD, else => void, }; } const Self = @This(); pub fn init(f: std.fs.File) Self { const attrs: AttrType() = blk: { switch (builtin.os.tag) { .windows => { var info: windows.CONSOLE_SCREEN_BUFFER_INFO = undefined; _ = windows.kernel32.GetConsoleScreenBufferInfo(f.handle, &info); _ = windows.kernel32.SetConsoleOutputCP(65001); break :blk info.wAttributes; }, else => break :blk {}, } }; return .{ .f = f, .attrs = attrs, }; } pub fn setColor(self: *const Self, color: Color) !void { if (builtin.os.tag == .windows) { const col: u16 = switch (color) { .red => windows.FOREGROUND_RED, .green => windows.FOREGROUND_GREEN, .blue => windows.FOREGROUND_BLUE, .yellow => windows.FOREGROUND_RED | windows.FOREGROUND_GREEN, .purple => windows.FOREGROUND_RED | windows.FOREGROUND_BLUE, }; try self.setAttrWin(col); } else { const code = switch (color) { .red => "31;1", .green => "32;1", .yellow => "33;1", .blue => "34;1", .purple => "35;1", }; try self.writeCodeAscii(code); } } pub fn setBold(self: *const Self) !void { if (builtin.os.tag == .windows) { try self.setAttrWin(windows.FOREGROUND_INTENSITY); } else { try self.writeCodeAscii("1"); } } pub fn reset(self: *const Self) !void { if (builtin.os.tag == .windows) { try self.setAttrWin(self.attrs); } else { try self.writeCodeAscii("0"); } } fn setAttrWin(self: *const Self, attr: windows.WORD) !void { try windows.SetConsoleTextAttribute(self.f.handle, attr); } fn writeCodeAscii(self: *const Self, code: []const u8) !void { try self.f.writer().print("\x1b[{s}m", .{code}); } };
0
repos/scafetch
repos/scafetch/src/Info.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const utils = @import("utils.zig"); const ConsoleStyle = utils.ConsoleStyle; name: []const u8, is_private: bool, is_fork: bool, is_archived: bool, is_template: bool, description: []const u8, repository: []const u8, language: []const u8, size: u32, stars: u32, watches: u32, forks: u32, license: []const u8, created: []const u8, modified: []const u8, branch: []const u8, const Info = @This(); pub fn free(self: *Info, allocator: Allocator) void { allocator.free(self.name); allocator.free(self.description); allocator.free(self.repository); allocator.free(self.language); allocator.free(self.license); allocator.free(self.created); allocator.free(self.modified); allocator.free(self.branch); } pub fn print(info: *Info, file: std.fs.File) !void { var rand_engine = std.rand.DefaultPrng.init(@as(u64, @intCast(std.time.milliTimestamp()))); const random = rand_engine.random(); const choice = random.enumValue(utils.Color); const writer = file.writer(); const color = ConsoleStyle.init(file); { const id = std.mem.indexOf(u8, info.name, "/").?; try color.setColor(choice); try writer.print(" {s}", .{info.name[0..id]}); try color.reset(); try writer.writeByte('/'); try color.setColor(choice); try writer.print("{s} ", .{info.name[id + 1 ..]}); if (info.is_fork) try writer.writeAll("🔗 "); if (info.is_private) try writer.writeAll("🔒 "); if (info.is_template) try writer.writeAll("🗒; "); if (info.is_archived) try writer.writeAll("📦 "); try writer.writeByte('\n'); try color.reset(); try writer.writeAll(" "); try writer.writeByteNTimes('~', info.name.len); try writer.writeByte('\n'); } { var x: usize = 0; while (x < info.description.len) { const end = blk: { const amount = 60; if (x + amount >= info.description.len) { break :blk info.description.len - x; } else { break :blk amount; } }; const str = std.mem.trimLeft(u8, info.description[x .. x + end], " "); try writer.print("{s}\n", .{str}); x += end; } try writer.writeByte('\n'); } const fields = .{ "repository", "license", "branch", "created", "modified", "language", "size", "stars", "watches", "forks", }; inline for (fields) |f| { const info_fields = std.meta.fields(Info); const field_id: usize = std.meta.fieldIndex(Info, f).?; const field = info_fields[field_id]; const data = @field(info, field.name); if (field.type == []const u8) { if (!std.mem.eql(u8, data, "")) { try writer.writeByte('-'); try color.setColor(choice); try writer.print(" {s}", .{field.name}); try color.reset(); try writer.print(": {s}\n", .{data}); } } else { if (data != 0) { try writer.writeByte('-'); try color.setColor(choice); try writer.print(" {s}", .{field.name}); try color.reset(); try writer.print(": {}\n", .{data}); } } } try writer.writeByte('\n'); }
0
repos/scafetch
repos/scafetch/src/hosts.zig
const std = @import("std"); const json = std.json; const Allocator = std.mem.Allocator; const allocPrint = std.fmt.allocPrint; const utils = @import("utils.zig"); const Info = @import("Info.zig"); pub const Host = enum { github, gitlab, codeberg, default, const hosts_map = std.StaticStringMap(Host).initComptime(.{ .{ "github.com", .github }, .{ "gitlab.com", .gitlab }, .{ "codeberg.org", .codeberg }, .{ "github", .github }, .{ "gitlab", .gitlab }, .{ "codeberg", .codeberg }, .{ "gh", .github }, .{ "gl", .gitlab }, .{ "cb", .codeberg }, }); pub fn match(name: []const u8) ?Host { return Host.hosts_map.get(name); } pub fn getUrl(host: Host, allocator: Allocator, author: []const u8, project: []const u8) ![]const u8 { return switch (host) { .default, .github => try allocPrint(allocator, "https://api.github.com/repos/{s}/{s}", .{ author, project }), .gitlab => try allocPrint(allocator, "https://gitlab.com/api/v4/projects/{s}%2F{s}?license=1", .{ author, project }), .codeberg => try allocPrint(allocator, "https://codeberg.org/api/v1/repos/{s}/{s}", .{ author, project }), }; } pub fn request(host: Host, allocator: Allocator, url: []const u8) !Info { return switch (host) { .github, .default => try Github.request(allocator, url), .codeberg => try Gitea.request(allocator, url), .gitlab => try Gitlab.request(allocator, url), }; } }; const Github = struct { const Query = struct { full_name: []const u8, private: bool, fork: bool, archived: bool, is_template: bool, description: ?[]const u8, html_url: []const u8, language: ?[]const u8, size: u32, stargazers_count: u32, watchers_count: u32, forks_count: u32, license: ?struct { name: []const u8 }, created_at: []const u8, updated_at: []const u8, default_branch: []const u8, pub fn free(self: *@This(), allocator: Allocator) void { allocator.free(self.full_name); if (self.description) |d| allocator.free(d); allocator.free(self.html_url); if (self.language) |l| allocator.free(l); if (self.license) |l| allocator.free(l.name); allocator.free(self.created_at); allocator.free(self.updated_at); allocator.free(self.default_branch); } }; pub fn request(allocator: Allocator, url: []const u8) !Info { const source = try utils.requestGet(allocator, url); defer allocator.free(source); var parsed = try json.parseFromSlice(Query, allocator, source, .{ .ignore_unknown_fields = true, }); defer parsed.deinit(); const query = parsed.value; return Info{ .name = try allocator.dupe(u8, query.full_name), .is_private = query.private, .is_fork = query.fork, .is_archived = query.archived, .is_template = query.is_template, .description = if (query.description) |d| try allocator.dupe(u8, d) else "", .repository = try allocator.dupe(u8, query.html_url), .language = if (query.language) |l| try allocator.dupe(u8, l) else "", .size = query.size, .stars = query.stargazers_count, .watches = query.watchers_count, .forks = query.forks_count, .license = if (query.license) |l| try allocator.dupe(u8, l.name) else "", .created = try allocator.dupe(u8, query.created_at[0..10]), .modified = try allocator.dupe(u8, query.updated_at[0..10]), .branch = try allocator.dupe(u8, query.default_branch), }; } }; const Gitea = struct { const Query = struct { full_name: []const u8, private: bool, fork: bool, archived: bool, template: bool, description: []const u8, html_url: []const u8, size: u32, stars_count: u32, watchers_count: u32, forks_count: u32, created_at: []const u8, updated_at: []const u8, default_branch: []const u8, pub fn free(self: *@This(), allocator: Allocator) void { allocator.free(self.full_name); allocator.free(self.description); allocator.free(self.html_url); allocator.free(self.created_at); allocator.free(self.updated_at); allocator.free(self.default_branch); } }; pub fn request(allocator: Allocator, url: []const u8) !Info { const source = try utils.requestGet(allocator, url); defer allocator.free(source); var parsed = try json.parseFromSlice(Query, allocator, source, .{ .ignore_unknown_fields = true, }); defer parsed.deinit(); const query = parsed.value; return Info{ .name = try allocator.dupe(u8, query.full_name), .is_private = query.private, .is_fork = query.fork, .is_archived = query.archived, .is_template = query.template, .description = try allocator.dupe(u8, query.description), .repository = try allocator.dupe(u8, query.html_url), .language = "", .size = query.size, .stars = query.stars_count, .watches = query.watchers_count, .forks = query.forks_count, .license = "", .created = try allocator.dupe(u8, query.created_at[0..10]), .modified = try allocator.dupe(u8, query.updated_at[0..10]), .branch = try allocator.dupe(u8, query.default_branch), }; } }; const Gitlab = struct { const Query = struct { path_with_namespace: []const u8, description: []const u8, license: ?struct { name: []const u8 }, web_url: []const u8, star_count: u32, forks_count: u32, created_at: []const u8, last_activity_at: []const u8, default_branch: []const u8, pub fn free(self: *@This(), allocator: Allocator) void { allocator.free(self.path_with_namespace); allocator.free(self.description); allocator.free(self.web_url); if (self.license) |l| allocator.free(l.nickname); allocator.free(self.created_at); allocator.free(self.last_activity_at); allocator.free(self.default_branch); } }; pub fn request(allocator: Allocator, url: []const u8) !Info { const source = try utils.requestGet(allocator, url); defer allocator.free(source); var parsed = try json.parseFromSlice(Query, allocator, source, .{ .ignore_unknown_fields = true, }); defer parsed.deinit(); const query = parsed.value; return Info{ .name = try allocator.dupe(u8, query.path_with_namespace), .is_private = false, .is_fork = false, .is_archived = false, .is_template = false, .description = try allocator.dupe(u8, query.description), .repository = try allocator.dupe(u8, query.web_url), .language = "", .size = 0, .stars = query.star_count, .watches = 0, .forks = query.forks_count, .license = if (query.license) |l| try allocator.dupe(u8, l.name) else "", .created = try allocator.dupe(u8, query.created_at[0..10]), .modified = try allocator.dupe(u8, query.last_activity_at[0..10]), .branch = try allocator.dupe(u8, query.default_branch), }; } };
0
repos/scafetch
repos/scafetch/src/main.zig
const std = @import("std"); const json = std.json; const mem = std.mem; const Host = @import("hosts.zig").Host; const Argparse = @import("ay-arg"); pub fn printVersion(writer: anytype) !void { try writer.writeAll("scafetch v0.2\n"); } pub fn printHelp(writer: anytype) !void { try printVersion(writer); try writer.writeAll( \\usage: scafetch <author>/<repository> \\ \\ -o, --host <host> Select the host server, accepted values are \\ github (default), gitlab and codeberg \\ -h, --help Show this help message \\ -v, --version Show the app version \\ \\ ); } pub fn main() anyerror!void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const allocator = gpa.allocator(); defer _ = gpa.deinit(); const stdout_file = std.io.getStdOut(); const stdout = std.io.getStdOut().writer(); const args = try std.process.argsAlloc(allocator); defer std.process.argsFree(allocator, args); const params = &[_]Argparse.ParamDesc{ .{ .long = "host", .short = 'o', .need_value = true }, .{ .long = "version", .short = 'v' }, .{ .long = "help", .short = 'h' }, }; if (args.len < 2) { try printHelp(stdout); std.process.exit(0); } var ap = Argparse.init(allocator, params[0..]); defer ap.deinit(); try ap.parse(args[1..]); if (ap.arguments.get("version")) |_| { try printVersion(stdout); std.process.exit(0); } if (ap.arguments.get("help")) |_| { try printHelp(stdout); std.process.exit(0); } const project = ap.positionals.items[0]; var host_tag: Host = if (ap.arguments.get("host")) |h| std.meta.stringToEnum(Host, h) orelse { try printHelp(stdout); std.log.err("unknown host name: {s}\n", .{h}); std.process.exit(1); } else .default; const url = if (mem.startsWith(u8, project, "http:") or mem.startsWith(u8, project, "https:")) blk: { break :blk try allocator.dupe(u8, project); } else blk: { var tokenizer = std.mem.tokenize(u8, project, "/"); var author_name: []const u8 = undefined; var project_name: []const u8 = undefined; switch (std.mem.count(u8, project, "/")) { 1 => { author_name = tokenizer.next().?; project_name = tokenizer.rest(); }, 2 => { const host_name = tokenizer.next().?; author_name = tokenizer.next().?; project_name = tokenizer.rest(); if (Host.match(host_name)) |host| { if (host_tag != .default and host != host_tag) { try printHelp(stdout); std.log.err("mismatched host name in argument and in url", .{}); std.process.exit(1); } host_tag = host; } }, else => { try printHelp(stdout); std.log.err("malformed url/project name", .{}); std.process.exit(1); }, } break :blk try Host.getUrl(host_tag, allocator, author_name, project_name); }; defer allocator.free(url); var info = try Host.request(host_tag, allocator, url); defer info.free(allocator); try info.print(stdout_file); std.log.info("All your repo stats are belong to us.", .{}); }
0
repos
repos/LoLa/shell.nix
{pkgs ? import <nixpkgs> {}}: pkgs.mkShell { nativeBuildInputs = [ pkgs.zig_master pkgs.llvmPackages_16.bintools pkgs.pkgsCross.avr.buildPackages.gcc ]; }
0
repos
repos/LoLa/README.md
# LoLa Programming Language ![LoLa Logo](design/logo.png) LoLa is a small programming language meant to be embedded into games to be programmed by the players. The compiler and runtime are implemented in Zig and C++. ## Short Example ```js var list = [ "Hello", "World" ]; for(text in list) { Print(text); } ``` You can find more examples in the [examples](examples/lola) folder. ## Why LoLa when there is *X*? LoLa isn't meant to be your next best day-to-day scripting language. Its design is focused on embedding the language in environments where the users want/need/should write some small scripts like games or scriptable applications. In most script languages, you as a script host don't have control over the execution time of the scripts you're executing. LoLa protects you against programming errors like endless loops and such: ### Controlled Execution Environment Every script invocation gets a limit of instructions it might execute. When either this limit is reached or the script yields for other reasons (asynchronous functions), the execution is returned to the host. This means, you can execute the following script "in parallel" to your application main loop without blocking your application *and* without requiring complex multithreading setups: ```js var timer = 0; while(true) { Print("Script running for ", timer, " seconds."); timer += 1; Sleep(1.0); } ``` ### Native Asynchronous Design LoLa features both synchronous and asynchronous host functions. Synchronous host function calls are short-lived and will be executed in-place. Asynchronous functions, in contrast, will be executed multiple times until they yield a value. When they don't yield a value, control will be returned to the script host. This script will not exhaust the instruction limit, but will only increment the counter, then return control back to the host: ```js var counter = 0; while(true) { counter += 1; Yield(); } ``` This behaviour can be utilized to wait for certain events in the host environment, for example to react to key presses, a script could look like this: ```js while(true) { var input = WaitForKey(); if(input == " ") { Print("Space was pressed!"); } } ``` *Note that the current implementation is not thread-safe, but requires to use the limited execution for running scripts in parallel.* ### Native "RPC" Design LoLa also allows executing multiple scripts on the same *environment*, meaning that you can easily create cross-script communications: ```js // script a: var buffer; function Set(val) { buffer = val; } function Get() { return val; } // script b: // GetBuffer() returns a object referencing a environment for "script a" var buffer = GetBuffer(); buffer.Set("Hello, World!"); // script c: // GetBuffer() returns a object referencing a environment for "script a" var buffer = GetBuffer(); Print("Buffer contains: ", buffer.Get()); ``` With a fitting network stack and library, this can even be utilized cross-computer. This example implements a small chat client and server that could work with LoLa RPC capabilities: ```js // Chat client implementation: var server = Connect("lola-rpc://random-projects.net/chat"); if(server == void) { Print("Could not connect to chat server!"); Exit(1); } while(true) { var list = server.GetMessages(GetUser()); for(msg in list) { Print("< ", msg); } Print("> "); var msg = ReadLine(); if(msg == void) break; if(msg == "") continue; server.Send(GetUser(), msg); } ``` ```js // Chat server implementation var messages = CreateDictionary(); function Send(user, msg) { for(other in messages.GetKeys()) { if(other != user) { var log = messages.Get(other); if(log != void) { log = log ++ [ user + ": " + msg ]; } else { log = []; } messages.Set(other, log); } } } function GetMessages(user) { var log = messages.Get(user); if(log != void) { messages.Set(user, []); return log; } else { return []; } } ``` ### Serializable State As LoLa has no reference semantics except for objects, it is easy to understand and learn. It is also simple in its implementation and does not require a complex garbage collector or advanced programming knowledge. Each LoLa value can be serialized/deserialized into a sequence of bytes (only exception are object handles, those require some special attention), so saving the current state of a environment/vm to disk and loading it at a later point is a first-class supported use case. This is especially useful for games where it is favourable to save your script state into a save game as well without having any drawbacks. ### Simple Error Handling LoLa provides little to no in-language error handling, as it's not designed to be robust against user programming errors. Each error is passed to the host as a panic, so it can show the user that there was an error (like `OutOfMemory` or `TypeMismatch`). In-language error handling is based on the dynamic typing: Functions that allow in-language error handling just return `void` instead of a actual return value or `true`/`false` for *success* or *failure*. This allows simple error checking like this: ```js var string = ReadFile("demo.data"); if(string != void) { Print("File contained ", string); } ``` This design decision was made with the idea in mind that most LoLa programmers won't write the next best security critical software, but just do a quick hack in game to reach their next item unlock. ### Smart compiler As LoLa isn't the most complex language, the compiler can support the programmer. Even though the language has fully dynamic typing, the compiler can do some type checking at compile time already: ```js // warning: Possible type mismatch detected: Expected number|string|array, found boolean if(a < true) { } ``` Right now, this is only used for validating expressions, but it is planned to extend this behaviour to annotate variables as well, so even more type errors can be found during compile time. Note that this is a fairly new feature, it does not catch all your type mismatches, but can prevent the obvious ones. ## Starting Points To get familiar with LoLa, you can check out these starting points: - [Documentation](documentation/README.md) - [LoLa Examples](examples/lola/README.md) - [Script Host Examples](examples/host) When you want to contribute to the compiler, check out the following documents: - [Source Code](src/) - [Bison Grammar](src/library/compiler/grammar.yy) - [Flex Tokenizer](src/library/compiler/yy.l) - [Issue List](https://github.com/MasterQ32/LoLa/issues) ## Visual Studio Code Extension If you want syntax highlighting in VSCode, you can install the [`lola-vscode`](https://github.com/MasterQ32/lola-vscode) extension. Right now, it's not published in the gallery, so to install the extension, you have to sideload it. [See the VSCode documentation for this](https://vscode-docs.readthedocs.io/en/stable/extensions/install-extension/). ## Building ### Continous Integration [![Build](https://github.com/MasterQ32/LoLa/actions/workflows/build.yml/badge.svg)](https://github.com/MasterQ32/LoLa/actions/workflows/build.yml) [![Render Website](https://github.com/MasterQ32/LoLa/actions/workflows/website.yml/badge.svg)](https://github.com/MasterQ32/LoLa/actions/workflows/website.yml) ### Requirements - The [Zig Compiler](https://ziglang.org/) (Version 0.12.0-dev.3438+5c628312b or newer) ### Building ```sh zig build ./zig-cache/bin/lola ``` ### Examples To compile the host examples, you can use `zig build examples` to build all provided examples. These will be available in `./zig-cache/bin` then. ### Running the test suite When you change things in the compiler or VM implementation, run the test suite: ```sh zig build test ``` This will execute all zig tests, and also runs a set of predefined tests within the [`src/test/`](src/test/) folder. These tests will verify that the compiler and language runtime behave correctly. ### Building the website The website generator is gated behind `-Denable-website` which removes a lot of dependencies for people not wanting to render a new version of the website. If you still want to update/change the website or documentation, use the following command: ```sh zig build -Denable-website "-Dversion=$(git describe --tags || git rev-parse --short HEAD)" website ``` It will depend on [koino](https://github.com/kivikakk/koino), which is included as a git submodule. Adding new pages to the documentation is done by modifying the `menu_items` array in `src/tools/render-md-page.zig`.
0
repos
repos/LoLa/build.zig.zon
.{ .name = "lola", .version = "0.1.0", .dependencies = .{ .args = .{ .url = "https://github.com/MasterQ32/zig-args/archive/872272205d95bdba33798c94e72c5387a31bc806.tar.gz", .hash = "1220fe6ae56b668cc4a033282b5f227bfbb46a67ede6d84e9f9493fea9de339b5f37", }, .any_pointer = .{ .url = "https://github.com/MasterQ32/any-pointer/archive/33851c78c2dd6bd1921dee2aac17a441b285aec7.tar.gz", .hash = "122068e632c479fa771ed988bf36c10db5bd0b2918b92569b2fa440785e4013055a8", }, }, .paths = .{"."}, }
0
repos
repos/LoLa/build.zig
const std = @import("std"); const builtin = @import("builtin"); const Build = std.Build; fn sdkPath(comptime suffix: []const u8) []const u8 { if (suffix[0] != '/') @compileError("sdkPath requires an absolute path!"); return comptime blk: { const root_dir = std.fs.path.dirname(@src().file) orelse "."; break :blk root_dir ++ suffix; }; } const Example = struct { name: []const u8, path: []const u8, }; const examples = [_]Example{ .{ .name = "minimal-host", .path = "examples/host/minimal-host/main.zig", }, .{ .name = "multi-environment", .path = "examples/host/multi-environment/main.zig", }, .{ .name = "serialization", .path = "examples/host/serialization/main.zig", }, }; pub fn build(b: *Build) !void { const version_tag = b.option([]const u8, "version", "Sets the version displayed in the docs and for `lola version`"); const optimize = b.standardOptimizeOption(.{}); const target = b.standardTargetOptions(.{}); const mod_args = b.dependency("args", .{}).module("args"); // const mod_interface = b.dependency("interface", .{}).module("interface.zig"); const mod_any_pointer = b.dependency("any_pointer", .{}).module("any-pointer"); const mod_lola = b.addModule("lola", .{ .root_source_file = b.path("src/library/main.zig"), .imports = &.{ // .{ .name = "interface", .module = mod_interface }, .{ .name = "any-pointer", .module = mod_any_pointer }, }, }); const build_options = b.addOptions(); build_options.addOption([]const u8, "version", version_tag orelse "development"); const exe = b.addExecutable(.{ .name = "lola", .root_source_file = b.path("src/frontend/main.zig"), .optimize = optimize, .target = target, }); exe.root_module.addImport("lola", mod_lola); exe.root_module.addImport("args", mod_args); exe.root_module.addImport("build_options", build_options.createModule()); b.installArtifact(exe); const benchmark_renderer = b.addExecutable(.{ .name = "benchmark-render", .root_source_file = b.path("src/benchmark/render.zig"), .optimize = optimize, .target = b.graph.host, }); b.installArtifact(benchmark_renderer); { const render_benchmark_step = b.step("render-benchmarks", "Runs the benchmark suite."); const only_render_benchmark = b.addRunArtifact(benchmark_renderer); only_render_benchmark.addDirectoryArg(b.path("benchmarks/data")); only_render_benchmark.addDirectoryArg(b.path("benchmarks/visualization")); render_benchmark_step.dependOn(&only_render_benchmark.step); } const benchmark_modes = [_]std.builtin.Mode{ .ReleaseSafe, .ReleaseFast, .ReleaseSmall, }; const benchmark_step = b.step("benchmark", "Runs the benchmark suite."); const render_benchmark = b.addRunArtifact(benchmark_renderer); render_benchmark.addDirectoryArg(b.path("benchmarks/data")); render_benchmark.addDirectoryArg(b.path("benchmarks/visualization")); benchmark_step.dependOn(&render_benchmark.step); for (benchmark_modes) |benchmark_mode| { const benchmark = b.addExecutable(.{ .name = b.fmt("benchmark-{s}", .{@tagName(benchmark_mode)}), .root_source_file = b.path("src/benchmark/perf.zig"), .optimize = benchmark_mode, .target = b.graph.host, }); benchmark.root_module.addImport("lola", mod_lola); const run_benchmark = b.addRunArtifact(benchmark); run_benchmark.addDirectoryArg(b.path("benchmarks/code")); run_benchmark.addDirectoryArg(b.path("benchmarks/data")); render_benchmark.step.dependOn(&run_benchmark.step); } const wasm_runtime = b.addExecutable(.{ .name = "lola", .root_source_file = b.path("src/wasm-compiler/main.zig"), .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }), .optimize = .ReleaseSafe, }); wasm_runtime.entry = .disabled; wasm_runtime.root_module.addImport("lola", mod_lola); b.installArtifact(wasm_runtime); const examples_step = b.step("examples", "Compiles all examples"); inline for (examples) |example| { const example_exe = b.addExecutable(.{ .name = "example-" ++ example.name, .root_source_file = b.path(example.path), .optimize = optimize, .target = target, }); example_exe.root_module.addImport("lola", mod_lola); examples_step.dependOn(&b.addInstallArtifact(example_exe, .{}).step); } const compiler_lola_mod = b.createModule(.{ .root_source_file = b.path("src/test/compiler.lola"), }); var main_tests = b.addTest(.{ .root_source_file = b.path("src/library/test.zig"), .optimize = optimize, .target = b.graph.host, }); // main_tests.root_module.addImport("interface", mod_interface); main_tests.root_module.addImport("any-pointer", mod_any_pointer); main_tests.root_module.addImport("compiler.lola", compiler_lola_mod); // main_tests.main_pkg_path = b.path("."); const test_step = b.step("test", "Run test suite"); test_step.dependOn(&b.addRunArtifact(main_tests).step); // Run compiler test suites { const prefix = "src/test/"; const behaviour_tests = b.addRunArtifact(exe); behaviour_tests.addArg("run"); behaviour_tests.addArg("--no-stdlib"); // we don't want the behaviour tests to be run with any stdlib functions behaviour_tests.addFileArg(b.path(prefix ++ "behaviour.lola")); behaviour_tests.expectStdOutEqual("Behaviour test suite passed.\n"); test_step.dependOn(&behaviour_tests.step); const stdib_test = b.addRunArtifact(exe); stdib_test.addArg("run"); stdib_test.addFileArg(b.path(prefix ++ "stdlib.lola")); stdib_test.expectStdOutEqual("Standard library test suite passed.\n"); test_step.dependOn(&stdib_test.step); b.cache_root.handle.makeDir("tmp") catch |err| switch (err) { error.PathAlreadyExists => {}, // nice else => |e| return e, }; const runlib_test = b.addRunArtifact(exe); // execute in the .zig-cache directory so we have a "safe" playfield // for file I/O runlib_test.setCwd(.{ .cwd_relative = try b.cache_root.join(b.allocator, &.{"tmp"}) }); // `Exit(123)` is the last call in the runtime suite runlib_test.expectExitCode(123); runlib_test.expectStdOutEqual( \\ \\1 \\1.2 \\[ ] \\[ 1, 2 ] \\truefalse \\hello \\Runtime library test suite passed. \\ ); runlib_test.addArg("run"); runlib_test.addFileArg(b.path(prefix ++ "runtime.lola")); test_step.dependOn(&runlib_test.step); const emptyfile_test = b.addRunArtifact(exe); emptyfile_test.addArg("run"); emptyfile_test.addFileArg(b.path(prefix ++ "empty.lola")); emptyfile_test.expectStdOutEqual(""); test_step.dependOn(&emptyfile_test.step); const globreturn_test = b.addRunArtifact(exe); globreturn_test.addArg("run"); globreturn_test.addFileArg(b.path(prefix ++ "global-return.lola")); globreturn_test.expectStdOutEqual(""); test_step.dependOn(&globreturn_test.step); const extended_behaviour_test = b.addRunArtifact(exe); extended_behaviour_test.addArg("run"); extended_behaviour_test.addFileArg(b.path(prefix ++ "behaviour-with-stdlib.lola")); extended_behaviour_test.expectStdOutEqual("Extended behaviour test suite passed.\n"); test_step.dependOn(&extended_behaviour_test.step); const compiler_test = b.addRunArtifact(exe); compiler_test.addArg("compile"); compiler_test.addArg("--verify"); // verify should not emit a compiled module compiler_test.addFileArg(b.path(prefix ++ "compiler.lola")); compiler_test.expectStdOutEqual(""); test_step.dependOn(&compiler_test.step); } const run_cmd = b.addRunArtifact(exe); run_cmd.step.dependOn(b.getInstallStep()); const run_step = b.step("run", "Run the app"); run_step.dependOn(&run_cmd.step); // TODO: Re-enable website rendering // ///////////////////////////////////////////////////////////////////////// // // Documentation and Website generation: // // this is disabed by-default so we don't depend on any vcpkgs // if (b.option(bool, "enable-website", "Enables website generation.") orelse false) { // // Generates documentation and future files. // const gen_website_step = b.step("website", "Generates the website and all required resources."); // const md_renderer = b.addExecutable(.{ // .name = "markdown-md-page", // .root_source_file = b.path("src/tools/render-md-page.zig"), // }); // md_renderer.addModule("koini", pkgs.koino); // try linkPcre(md_renderer); // const render = b.addRunArtifact(md_renderer); // render.addArg(version_tag orelse "development"); // gen_website_step.dependOn(&render.step); // const copy_wasm_runtime = b.addSystemCommand(&[_][]const u8{ // "cp", // }); // copy_wasm_runtime.addArtifactArg(wasm_runtime); // copy_wasm_runtime.addArg("website/lola.wasm"); // gen_website_step.dependOn(&copy_wasm_runtime.step); // var gen_docs_runner = b.addTest(pkgs.lola.source.path); // // gen_docs_runner.emit_bin = .no_emit; // gen_docs_runner.emit_asm = .no_emit; // gen_docs_runner.emit_bin = .no_emit; // gen_docs_runner.emit_docs = .{ .emit_to = "website/docs" }; // gen_docs_runner.emit_h = false; // gen_docs_runner.emit_llvm_ir = .no_emit; // for (pkgs.lola.dependencies.?) |dep| { // gen_docs_runner.addPackage(dep); // } // gen_docs_runner.setBuildMode(optimize); // gen_docs_runner.setMainPkgPath("."); // gen_website_step.dependOn(&gen_docs_runner.step); // // Only generates documentation // const gen_docs_step = b.step("docs", "Generate the code documentation"); // gen_docs_step.dependOn(&gen_docs_runner.step); // } }
0
repos
repos/LoLa/flake.nix
{ description = "LoLa programming language"; inputs = { nixpkgs.url = "github:nixos/nixpkgs/release-23.11"; flake-utils.url = "github:numtide/flake-utils"; # required for latest zig zig.url = "github:mitchellh/zig-overlay"; # Used for shell.nix flake-compat = { url = github:edolstra/flake-compat; flake = false; }; }; outputs = { self, nixpkgs, flake-utils, ... } @ inputs: let overlays = [ # Other overlays (final: prev: { zigpkgs = inputs.zig.packages.${prev.system}; }) ]; # Our supported systems are the same supported systems as the Zig binaries systems = builtins.attrNames inputs.zig.packages; in flake-utils.lib.eachSystem systems ( system: let pkgs = import nixpkgs {inherit overlays system;}; in rec { devShells.default = pkgs.mkShell { nativeBuildInputs = [ pkgs.zigpkgs."0.13.0" pkgs.pkg-config ]; buildInputs = [ # we need a version of bash capable of being interactive # as opposed to a bash just used for building this flake # in non-interactive mode pkgs.bashInteractive ]; propagatedBuildInputs = []; shellHook = '' export SHELL=${pkgs.bashInteractive}/bin/bash ''; }; # For compatibility with older versions of the `nix` binary devShell = self.devShells.${system}.default; } ); }
0
repos
repos/LoLa/flake.lock
{ "nodes": { "flake-compat": { "flake": false, "locked": { "lastModified": 1696426674, "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", "owner": "edolstra", "repo": "flake-compat", "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", "type": "github" }, "original": { "owner": "edolstra", "repo": "flake-compat", "type": "github" } }, "flake-compat_2": { "flake": false, "locked": { "lastModified": 1696426674, "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", "owner": "edolstra", "repo": "flake-compat", "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", "type": "github" }, "original": { "owner": "edolstra", "repo": "flake-compat", "type": "github" } }, "flake-utils": { "inputs": { "systems": "systems" }, "locked": { "lastModified": 1710146030, "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { "owner": "numtide", "repo": "flake-utils", "type": "github" } }, "flake-utils_2": { "inputs": { "systems": "systems_2" }, "locked": { "lastModified": 1705309234, "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", "owner": "numtide", "repo": "flake-utils", "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", "type": "github" }, "original": { "owner": "numtide", "repo": "flake-utils", "type": "github" } }, "nixpkgs": { "locked": { "lastModified": 1718132686, "narHash": "sha256-JRinkq+FeAkYnrrK8+Bh+jtLHJBN5jDzSimk1ye00EE=", "owner": "nixos", "repo": "nixpkgs", "rev": "96b3dae4f8753c1f5ce0d06b57fe250fb5d9b0e0", "type": "github" }, "original": { "owner": "nixos", "ref": "release-23.11", "repo": "nixpkgs", "type": "github" } }, "nixpkgs_2": { "locked": { "lastModified": 1708161998, "narHash": "sha256-6KnemmUorCvlcAvGziFosAVkrlWZGIc6UNT9GUYr0jQ=", "owner": "NixOS", "repo": "nixpkgs", "rev": "84d981bae8b5e783b3b548de505b22880559515f", "type": "github" }, "original": { "owner": "NixOS", "ref": "nixos-23.11", "repo": "nixpkgs", "type": "github" } }, "root": { "inputs": { "flake-compat": "flake-compat", "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", "zig": "zig" } }, "systems": { "locked": { "lastModified": 1681028828, "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", "owner": "nix-systems", "repo": "default", "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", "type": "github" }, "original": { "owner": "nix-systems", "repo": "default", "type": "github" } }, "systems_2": { "locked": { "lastModified": 1681028828, "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", "owner": "nix-systems", "repo": "default", "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", "type": "github" }, "original": { "owner": "nix-systems", "repo": "default", "type": "github" } }, "zig": { "inputs": { "flake-compat": "flake-compat_2", "flake-utils": "flake-utils_2", "nixpkgs": "nixpkgs_2" }, "locked": { "lastModified": 1718065467, "narHash": "sha256-bRghiY4NGJmyE8Kf5KsPvu3W2AJ7Mf5p+SEWAOPvSOY=", "owner": "mitchellh", "repo": "zig-overlay", "rev": "41966f11eec0ea87f178a857bdfb53c2627f763e", "type": "github" }, "original": { "owner": "mitchellh", "repo": "zig-overlay", "type": "github" } } }, "root": "root", "version": 7 }
0
repos/LoLa
repos/LoLa/src/README.md
# Source Structure The project is structured into two major parts: - [`frontend`](frontend/) is the compiler frontend which implements the command line executable - [`library`](library/) is the implementation of both the runtime as well as the compiler. It is structured into several modules: - [`library/compiler`](library/compiler/) is the compiler which translates LoLa source code into LoLa byte code - [`library/runtime`](library/runtime) is the virtual machine implementation that allows running LoLa byte code - [`library/stdlib`](library/stdlib) is the implementation of the LoLa standard library and builds on the runtime - [`tools`](tools/) contains small tools that are used in this repo, but have no relevance to LoLa itself. One example is the markdown renderer for the website. - [`test`](test/) contains source files that are used to test the compiler and runtime implementation. See `build.zig` and the source files in `library` for the use of those. Each file in this folder has a header that explains its usage.
0
repos/LoLa/src
repos/LoLa/src/wasm-compiler/main.zig
const std = @import("std"); const lola = @import("lola"); // This is our global object pool that is back-referenced // by the runtime library. pub const ObjectPool = lola.runtime.ObjectPool([_]type{ lola.libs.runtime.LoLaList, lola.libs.runtime.LoLaDictionary, }); var gpa = std.heap.GeneralPurposeAllocator(.{}){}; var allocator: std.mem.Allocator = gpa.allocator(); var compile_unit: lola.CompileUnit = undefined; var pool: ObjectPool = undefined; var environment: lola.runtime.Environment = undefined; var vm: lola.runtime.VM = undefined; var is_done: bool = true; pub fn milliTimestamp() usize { return JS.millis(); } const JS = struct { extern fn writeString(data: [*]const u8, len: u32) void; extern fn readString(data: [*]u8, len: usize) usize; extern fn millis() usize; }; const API = struct { fn writeLog(_: void, str: []const u8) !usize { JS.writeString(str.ptr, @as(u32, @intCast(str.len))); return str.len; } var debug_writer = std.io.Writer(void, error{}, writeLog){ .context = {} }; fn writeLogNL(_: void, str: []const u8) !usize { var rest = str; while (std.mem.indexOf(u8, rest, "\n")) |off| { const mid = rest[0..off]; JS.writeString(mid.ptr, @as(u32, @intCast(mid.len))); JS.writeString("\r\n", 2); rest = rest[off + 1 ..]; } JS.writeString(rest.ptr, @as(u32, @intCast(rest.len))); return str.len; } /// debug writer that patches LF into CRLF var debug_writer_lf = std.io.Writer(void, error{}, writeLogNL){ .context = {} }; fn validate(source: []const u8) !void { var diagnostics = lola.compiler.Diagnostics.init(allocator); defer diagnostics.deinit(); // This compiles a piece of source code into a compile unit. // A compile unit is a piece of LoLa IR code with metadata for // all existing functions, debug symbols and so on. It can be loaded into // a environment and be executed. var temp_compile_unit = try lola.compiler.compile(allocator, &diagnostics, "code", source); for (diagnostics.messages.items) |msg| { std.fmt.format(debug_writer_lf, "{}\n", .{msg}) catch unreachable; } if (temp_compile_unit) |*unit| unit.deinit(); } fn initInterpreter(source: []const u8) !void { var diagnostics = lola.compiler.Diagnostics.init(allocator); diagnostics.deinit(); const compile_unit_or_none = try lola.compiler.compile(allocator, &diagnostics, "code", source); for (diagnostics.messages.items) |msg| { std.fmt.format(debug_writer_lf, "{}\n", .{msg}) catch unreachable; } compile_unit = compile_unit_or_none orelse return error.FailedToCompile; errdefer compile_unit.deinit(); pool = ObjectPool.init(allocator); errdefer pool.deinit(); environment = try lola.runtime.Environment.init(allocator, &compile_unit, pool.interface()); errdefer environment.deinit(); try environment.installModule(lola.libs.std, lola.runtime.Context.null_pointer); // try lola.libs.runtime.install(&environment, allocator); try environment.installFunction("Print", lola.runtime.Function.initSimpleUser(struct { fn Print(_environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = _environment; _ = context; // const allocator = context.get(std.mem.Allocator); for (args) |value| { switch (value) { .string => |str| try debug_writer.writeAll(str.contents), else => try debug_writer.print("{}", .{value}), } } try debug_writer.writeAll("\r\n"); return .void; } }.Print)); try environment.installFunction("Write", lola.runtime.Function.initSimpleUser(struct { fn Write(_environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = _environment; _ = context; // const allocator = context.get(std.mem.Allocator); for (args) |value| { switch (value) { .string => |str| try debug_writer.writeAll(str.contents), else => try debug_writer.print("{}", .{value}), } } return .void; } }.Write)); try environment.installFunction("Read", lola.runtime.Function.initSimpleUser(struct { fn Read(_environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = _environment; _ = context; if (args.len != 0) return error.InvalidArgs; var buffer = std.ArrayList(u8).init(allocator); defer buffer.deinit(); while (true) { var temp: [256]u8 = undefined; const len = JS.readString(&temp, temp.len); if (len == 0) break; try buffer.appendSlice(temp[0..len]); } return lola.runtime.Value.fromString(lola.runtime.String.initFromOwned( allocator, try buffer.toOwnedSlice(), )); } }.Read)); vm = try lola.runtime.VM.init(allocator, &environment); errdefer vm.deinit(); is_done = false; } fn deinitInterpreter() void { if (!is_done) { vm.deinit(); environment.deinit(); pool.deinit(); compile_unit.deinit(); } is_done = true; } fn stepInterpreter(steps: u32) !void { if (is_done) return error.InvalidInterpreterState; // Run the virtual machine for up to 150 instructions const result = vm.execute(steps) catch |err| { // When the virtua machine panics, we receive a Zig error try std.fmt.format(debug_writer_lf, "\x1B[91mLoLa Panic: {s}\x1B[m\n", .{@errorName(err)}); try vm.printStackTrace(debug_writer_lf); return error.LoLaPanic; }; // Prepare a garbage collection cycle: pool.clearUsageCounters(); // Mark all objects currently referenced in the environment try pool.walkEnvironment(environment); // Mark all objects currently referenced in the virtual machine try pool.walkVM(vm); // Delete all objects that are not referenced by our system anymore pool.collectGarbage(); switch (result) { // This means that our script execution has ended and // the top-level code has come to an end .completed => { // deinitialize everything, stop execution deinitInterpreter(); return; }, // This means the VM has exhausted its provided instruction quota // and returned control to the host. .exhausted => {}, // This means the virtual machine was suspended via a async function call. .paused => {}, } } }; comptime { _ = exports; } const exports = struct { export fn initialize() void { // nothing to init atm } export fn malloc(len: usize) [*]u8 { const slice = allocator.alloc(u8, len) catch unreachable; return slice.ptr; } export fn free(mem: [*]u8, len: usize) void { allocator.free(mem[0..len]); } const LoLaError = error{ OutOfMemory, FailedToCompile, SyntaxError, InvalidCode, AlreadyDeclared, TooManyVariables, TooManyLabels, LabelAlreadyDefined, Overflow, NotInLoop, VariableNotFound, InvalidStoreTarget, LoLaPanic, AlreadyExists, InvalidObject, InvalidInterpreterState, }; fn mapError(err: LoLaError) u8 { return switch (err) { error.OutOfMemory => 1, error.FailedToCompile => 2, error.SyntaxError => 3, error.InvalidCode => 3, error.AlreadyDeclared => 3, error.TooManyVariables => 3, error.TooManyLabels => 3, error.LabelAlreadyDefined => 3, error.Overflow => 3, error.NotInLoop => 3, error.VariableNotFound => 3, error.InvalidStoreTarget => 3, error.AlreadyExists => 3, error.LoLaPanic => 4, error.InvalidObject => 5, error.InvalidInterpreterState => 6, }; } export fn validate(source: [*]const u8, source_len: usize) u8 { API.validate(source[0..source_len]) catch |err| return mapError(err); return 0; } export fn initInterpreter(source: [*]const u8, source_len: usize) u8 { API.initInterpreter(source[0..source_len]) catch |err| return mapError(err); return 0; } export fn deinitInterpreter() void { API.deinitInterpreter(); } export fn stepInterpreter(steps: u32) u8 { API.stepInterpreter(steps) catch |err| return mapError(err); return 0; } export fn isInterpreterDone() bool { return is_done; } }; pub const std_options = std.Options{ .logFn = log, }; fn log( comptime message_level: std.log.Level, comptime scope: @Type(.EnumLiteral), comptime format: []const u8, args: anytype, ) void { _ = message_level; _ = scope; _ = format; _ = args; }
0
repos/LoLa/src
repos/LoLa/src/library/main.zig
const zig_std = @import("std"); const builtin = @import("builtin"); // Import all runtime namespaces const common = struct { pub usingnamespace @import("common/ir.zig"); pub usingnamespace @import("common/disassembler.zig"); }; pub usingnamespace common; pub const Decoder = @import("common/Decoder.zig"); pub const CompileUnit = @import("common/CompileUnit.zig"); /// Contains functions and structures for executing LoLa code. pub const runtime = struct { pub usingnamespace @import("runtime/value.zig"); pub const Environment = @import("runtime/Environment.zig"); pub const Context = @import("any-pointer").AnyPointer; pub usingnamespace @import("runtime/vm.zig"); pub usingnamespace @import("runtime/objects.zig"); pub const EnvironmentMap = @import("runtime/environmentmap.zig").EnvironmentMap; pub const ScriptFunction = Environment.ScriptFunction; pub const Function = Environment.Function; pub const UserFunctionCall = Environment.UserFunctionCall; pub const UserFunction = Environment.UserFunction; pub const AsyncFunctionCall = Environment.AsyncFunctionCall; pub const AsyncUserFunction = Environment.AsyncUserFunction; pub const AsyncUserFunctionCall = Environment.AsyncUserFunctionCall; }; /// LoLa libraries that provide pre-defined functions and variables. pub const libs = @import("libraries/libs.zig"); /// Contains functions and structures to compile LoLa code. pub const compiler = struct { pub const Diagnostics = @import("compiler/diagnostics.zig").Diagnostics; pub const Location = @import("compiler/location.zig").Location; pub const tokenizer = @import("compiler/tokenizer.zig"); pub const parser = @import("compiler/parser.zig"); pub const ast = @import("compiler/ast.zig"); pub const validate = @import("compiler/analysis.zig").validate; pub const generateIR = @import("compiler/codegen.zig").generateIR; /// Compiles a LoLa source code into a CompileUnit. /// - `allocator` is used to perform all allocations in the compilation process. /// - `diagnostics` will contain all diagnostic messages after compilation. /// - `chunk_name` is the name of the source code piece. This is the name that will be used to refer to chunk in error messages, it is usually the file name. /// - `source_code` is the LoLa source code that should be compiled. /// The function returns either a compile unit when `source_code` is a valid program, otherwise it will return `null`. pub fn compile( allocator: zig_std.mem.Allocator, diagnostics: *Diagnostics, chunk_name: []const u8, source_code: []const u8, ) !?CompileUnit { const seq = try tokenizer.tokenize(allocator, diagnostics, chunk_name, source_code); defer allocator.free(seq); var pgm = try parser.parse(allocator, diagnostics, seq); defer pgm.deinit(); const valid_program = try validate(allocator, diagnostics, pgm); if (!valid_program) return null; return try generateIR(allocator, pgm, chunk_name); } }; comptime { if (builtin.is_test) { // include tests _ = @import("libraries/stdlib.zig"); _ = @import("libraries/runtime.zig"); _ = @import("compiler/diagnostics.zig"); _ = @import("compiler/string-escaping.zig"); _ = @import("compiler/codegen.zig"); _ = @import("compiler/code-writer.zig"); _ = @import("compiler/typeset.zig"); _ = @import("compiler/analysis.zig"); _ = @import("compiler/tokenizer.zig"); _ = @import("compiler/parser.zig"); _ = @import("compiler/location.zig"); _ = @import("compiler/ast.zig"); _ = @import("compiler/scope.zig"); _ = @import("runtime/vm.zig"); _ = @import("runtime/objects.zig"); _ = @import("runtime/Environment.zig"); _ = @import("runtime/environmentmap.zig"); _ = @import("runtime/value.zig"); _ = @import("common/Decoder.zig"); _ = @import("common/disassembler.zig"); _ = @import("common/utility.zig"); _ = @import("common/ir.zig"); _ = @import("common/CompileUnit.zig"); _ = compiler.compile; _ = libs.runtime; _ = libs.std; } }
0
repos/LoLa/src
repos/LoLa/src/library/test.zig
// this path is mainly to provide a neat test environment const lola = @import("main.zig"); comptime { _ = lola; } pub const ObjectPool = lola.runtime.ObjectPool(.{});
0
repos/LoLa/src/library
repos/LoLa/src/library/runtime/Environment.zig
//! An execution environment provides all needed //! data to execute a compiled piece of code. //! It stores its global variables, available functions //! and available features. const std = @import("std"); const iface = @import("interface"); const AnyPointer = @import("any-pointer").AnyPointer; const logger = std.log.scoped(.lola); // Import modules to reduce file size const value_unit = @import("value.zig"); const Value = value_unit.Value; const CompileUnit = @import("../common/CompileUnit.zig"); const vm = @import("vm.zig"); const objects = @import("objects.zig"); const String = value_unit.String; const Array = value_unit.Array; const ObjectPoolInterface = objects.ObjectPoolInterface; const ObjectHandle = objects.ObjectHandle; const Environment = @This(); allocator: std.mem.Allocator, /// The compile unit that provides the executed script. compileUnit: *const CompileUnit, /// Global variables required by the script. scriptGlobals: []Value, /// Object interface to objectPool: ObjectPoolInterface, /// Stores all available global functions. /// Functions will be contained in this unit and will be deinitialized, /// the name must be kept alive until end of the environment. functions: std.StringHashMap(Function), /// This is called when the destroyObject is called. destructor: ?*const fn (self: *Environment) void, pub fn init(allocator: std.mem.Allocator, compileUnit: *const CompileUnit, object_pool: ObjectPoolInterface) !Environment { var self = Environment{ .allocator = allocator, .compileUnit = compileUnit, .objectPool = object_pool, .scriptGlobals = undefined, .functions = undefined, .destructor = null, }; self.scriptGlobals = try allocator.alloc(Value, compileUnit.globalCount); errdefer allocator.free(self.scriptGlobals); for (self.scriptGlobals) |*glob| { glob.* = .void; } self.functions = std.StringHashMap(Function).init(allocator); errdefer self.functions.deinit(); for (compileUnit.functions) |srcfun| { const fun = Function{ .script = ScriptFunction{ .environment = null, // this is a "self-contained" script function .entryPoint = srcfun.entryPoint, .localCount = srcfun.localCount, }, }; _ = try self.functions.put(srcfun.name, fun); } return self; } pub fn deinit(self: *Environment) void { var iter = self.functions.iterator(); while (iter.next()) |fun| { fun.value_ptr.deinit(); } for (self.scriptGlobals) |*glob| { glob.deinit(); } self.functions.deinit(); self.allocator.free(self.scriptGlobals); self.* = undefined; } /// Checks if two function signatures are compatible to each other and if `Queried` can be assigned to a `Destination` type. fn isCompatibleFunctionSignature(comptime Destination: type, comptime Queried: type) bool { const ti_a = @typeInfo(std.meta.Child(Destination)).Fn; const ti_b = @typeInfo(std.meta.Child(Queried)).Fn; if (ti_a.params.len != ti_b.params.len) return false; const rettype_a = ti_a.return_type orelse opaque {}; const rettype_b = ti_b.return_type orelse opaque {}; if (@typeInfo(rettype_a) == .ErrorUnion) { const rti_a = @typeInfo(rettype_a).ErrorUnion.payload; const rti_b = @typeInfo(rettype_b).ErrorUnion.payload; // @compileLog("Compare", rti_a, rti_b); if (rti_a != rti_b) return false; } else if (rettype_a != rettype_b) { return false; } for (ti_a.params, 0..) |arg_a, i| { const arg_b = ti_b.params[i]; const type_a = arg_a.type orelse opaque {}; const type_b = arg_b.type orelse opaque {}; if (type_a != type_b) { if (@typeInfo(type_a) == .Pointer) { const pti_a: std.builtin.Type.Pointer = @typeInfo(type_a).Pointer; const pti_b: std.builtin.Type.Pointer = @typeInfo(type_b).Pointer; if (pti_a.child != pti_b.child) return false; if (pti_a.size != pti_b.size) return false; if (pti_a.is_const and !pti_b.is_const) // if target is const, we cannot allow non-const fn return false; } else { return false; } } } return true; } /// Installs a LoLa module. /// Modules are containers that contain public functions with either a /// `UserFunctionCall` or `AsyncUserFunctionCall` signature. /// Every other function is ignored (and a debug log is generated). pub fn installModule(self: *Environment, comptime Module: type, context: AnyPointer) !void { // Install all functions from the namespace "functions": inline for (comptime std.meta.declarations(Module)) |decl| { const data = @field(Module, decl.name); if (@typeInfo(@TypeOf(data)) == .Fn) { const module_fn = @field(Module, decl.name); const FnType = *const @TypeOf(module_fn); // @compileLog("Install", decl.name, "query", FnType); if (comptime isCompatibleFunctionSignature(UserFunctionCall, FnType)) { // logger.debug("Install synchronous function {s} to environment", .{decl.name}); try self.installFunction(decl.name, Function{ .syncUser = UserFunction{ .context = context, .destructor = null, .call = module_fn, }, }); } else if (comptime isCompatibleFunctionSignature(AsyncUserFunctionCall, FnType)) { // logger.debug("Install asynchronous function {s} to environment", .{decl.name}); try self.installFunction(decl.name, Function{ .asyncUser = AsyncUserFunction{ .context = context, .destructor = null, .call = module_fn, }, }); } else { logger.debug("could not install {s}: unrecognized signature {s}!", .{ decl.name, @typeName(FnType) }); } } } } /// Adds a function to the environment and makes it available for the script. pub fn installFunction(self: *Environment, name: []const u8, function: Function) !void { const result = try self.functions.getOrPut(name); if (result.found_existing) { logger.err("tried to install already existing function '{s}'", .{name}); return error.AlreadyExists; } result.value_ptr.* = function; } // Implementation to make a Environment a valid LoLa object: pub fn getMethod(self: *Environment, name: []const u8) ?Function { if (self.functions.get(name)) |fun| { var mut_fun = fun; if (mut_fun == .script and mut_fun.script.environment == null) mut_fun.script.environment = self; return mut_fun; } else { return null; } } /// This is called when the object is removed from the associated object pool. pub fn destroyObject(self: *Environment) void { if (self.destructor) |dtor| { dtor(self); } } /// Computes a unique signature for this environment based on /// the size and functions stored in the environment. This is used /// for serialization to ensure that Environments are restored into same /// state is it was serialized from previously. fn computeSignature(self: Environment) u64 { var hasher = std.hash.SipHash64(2, 4).init("Environment Seri"); // Hash all function names to create reproducability { var iter = self.functions.iterator(); while (iter.next()) |item| { hasher.update(item.key_ptr.*); } } // safe the length of the script globals as a bad signature for // the comileUnit { var buf: [8]u8 = undefined; std.mem.writeInt(u64, &buf, self.scriptGlobals.len, .little); hasher.update(&buf); } return hasher.finalInt(); } /// Serializes the environment globals in a way that these /// are restorable later. pub fn serialize(self: Environment, stream: anytype) !void { const sig = self.computeSignature(); try stream.writeInt(u64, sig, .little); for (self.scriptGlobals) |glob| { try glob.serialize(stream); } } /// Deserializes the environment globals. This might fail with /// `error.SignatureMismatch` when a environment with a different signature /// is restored. pub fn deserialize(self: *Environment, stream: anytype) !void { const sig_env = self.computeSignature(); const sig_ser = try stream.readInt(u64, .little); if (sig_env != sig_ser) return error.SignatureMismatch; for (self.scriptGlobals) |*glob| { const val = try Value.deserialize(stream, self.allocator); glob.replaceWith(val); } } /// A script function contained in either this or a foreign /// environment. For foreign environments. pub const ScriptFunction = struct { /// This is a reference to the environment for that function. /// If the environment is `null`, the environment is context-sensitive /// and will always be the environment that provided that function. /// This is a "workaround" for not storing a pointer-to-self in Environment for /// embedded script functions. environment: ?*Environment, entryPoint: u32, localCount: u16, }; pub const UserFunctionCall = *const (fn ( environment: *Environment, context: AnyPointer, args: []const Value, ) anyerror!Value); /// A synchronous function that may be called from the script environment pub const UserFunction = struct { const Self = @This(); /// AnyPointer, will be passed to `call`. context: AnyPointer, /// Executes the function, returns a value synchronously. call: UserFunctionCall, /// Optional destructor that may free the memory stored in `context`. /// Is called when the function call is deinitialized. destructor: ?*const (fn (context: AnyPointer) void), pub fn deinit(self: *Self) void { if (self.destructor) |dtor| { dtor(self.context); } self.* = undefined; } }; test "UserFunction (destructor)" { var uf1: UserFunction = .{ .context = AnyPointer.null_pointer, .call = undefined, .destructor = null, }; defer uf1.deinit(); var uf2: UserFunction = .{ .context = AnyPointer.make(*u32, try std.testing.allocator.create(u32)), .call = undefined, .destructor = struct { fn destructor(ctx: AnyPointer) void { std.testing.allocator.destroy(ctx.cast(*u32)); } }.destructor, }; defer uf2.deinit(); } pub const AsyncUserFunctionCall = *const (fn ( environment: *Environment, context: AnyPointer, args: []const Value, ) anyerror!AsyncFunctionCall); /// An asynchronous function that yields execution of the VM /// and can be resumed later. pub const AsyncUserFunction = struct { const Self = @This(); /// AnyPointer, will be passed to `call`. context: AnyPointer, /// Begins execution of this function. /// After the initialization, the return value will be invoked once /// to check if the function can finish synchronously. call: AsyncUserFunctionCall, /// Optional destructor that may free the memory stored in `context`. /// Is called when the function call is deinitialized. destructor: ?*const (fn (context: AnyPointer) void), pub fn deinit(self: *Self) void { if (self.destructor) |dtor| { dtor(self.context); } self.* = undefined; } }; test "AsyncUserFunction (destructor)" { var uf1: AsyncUserFunction = .{ .context = undefined, .call = undefined, .destructor = null, }; defer uf1.deinit(); var uf2: AsyncUserFunction = .{ .context = AnyPointer.make(*u32, try std.testing.allocator.create(u32)), .call = undefined, .destructor = struct { fn destructor(ctx: AnyPointer) void { std.testing.allocator.destroy(ctx.cast(*u32)); } }.destructor, }; defer uf2.deinit(); } /// An asynchronous execution state. pub const AsyncFunctionCall = struct { const Self = @This(); /// The object this call state is associated with. This is required to /// prevent calling functions that operate on dead objects. /// This field is set by the VM and should not be initialized by the creator /// of the call. object: ?ObjectHandle = null, /// The context may be used to to store the state of this function call. /// This may be created with `@sliceToBytes`. context: AnyPointer, /// Executor that will run this function call. /// May return a value (function call completed) or `null` (function call still in progress). execute: *const fn (context: AnyPointer) anyerror!?Value, /// Optional destructor that may free the memory stored in `context`. /// Is called when the function call is deinitialized. destructor: ?*const fn (context: AnyPointer) void, pub fn deinit(self: *Self) void { if (self.destructor) |dtor| { dtor(self.context); } self.* = undefined; } }; test "AsyncFunctionCall.deinit" { const Helper = struct { fn destroy(context: AnyPointer) void { std.testing.allocator.destroy(context.cast(*u32)); } fn exec(context: AnyPointer) anyerror!?Value { _ = context; return error.NotSupported; } }; var callWithDtor = AsyncFunctionCall{ .object = null, .context = AnyPointer.make(*u32, try std.testing.allocator.create(u32)), .execute = Helper.exec, .destructor = Helper.destroy, }; defer callWithDtor.deinit(); var callNoDtor = AsyncFunctionCall{ .object = null, .context = undefined, .execute = Helper.exec, .destructor = null, }; defer callNoDtor.deinit(); } /// A function that can be called by a script. pub const Function = union(enum) { const Self = @This(); /// This is another function of a script. It may be a foreign /// or local script to the environment. script: ScriptFunction, /// A synchronous function like `Sin` that executes in very short time. syncUser: UserFunction, /// An asynchronous function that will yield the VM execution. asyncUser: AsyncUserFunction, pub fn initSimpleUser(fun: *const fn (env: *Environment, context: AnyPointer, args: []const Value) anyerror!Value) Function { return Self{ .syncUser = UserFunction{ .context = AnyPointer.null_pointer, .destructor = null, .call = fun, }, }; } fn convertToZigValue(comptime Target: type, value: Value) !Target { if (Target == Value) { return value; } else { const info = @typeInfo(Target); switch (info) { .Int => return try value.toInteger(Target), .Float => return @as(Target, @floatCast(try value.toNumber())), .Optional => { if (value == .void) return null; return try convertToZigValue(std.meta.Child(Target), value); }, else => return switch (Target) { // Native types void => try value.toVoid(), bool => try value.toBoolean(), []const u8 => value.toString(), // LoLa types ObjectHandle => try value.toObject(), String => if (value == .string) value.string else return error.TypeMismatch, Array => value.toArray(), Value => unreachable, else => @compileError(@typeName(Target) ++ " is not a wrappable type!"), }, } } } fn convertToLoLaValue(allocator: std.mem.Allocator, value: anytype) !Value { const T = @TypeOf(value); const info = @typeInfo(T); if (info == .Int) return Value.initInteger(T, value); if (info == .Float) return Value.initNumber(value); if (info == .Optional) { if (value) |unwrapped| return try convertToLoLaValue(allocator, unwrapped); return .void; } if (info == .ErrorUnion) { return try convertToLoLaValue(allocator, try value); } if (info == .ErrorSet) { return value; } return switch (T) { // Native types void => .void, bool => Value.initBoolean(value), []const u8 => try Value.initString(allocator, value), // LoLa types ObjectHandle => Value.initObject(value), String => Value.fromString(value), Array => Value.fromArray(value), Value => value, else => @compileError(@typeName(T) ++ " is not a wrappable type!"), }; } /// Wraps a native zig function into a LoLa function. /// The function may take any number of arguments of supported types and return one of those as well. /// Supported types are: /// - `lola.runtime.Value` /// - `lola.runtime.String` /// - `lola.runtime.Array` /// - `lola.runtime.ObjectHandle` /// - any integer type /// - any floating point type /// - `bool` /// - `void` /// - `[]const u8` /// Note that when you receive arguments, you don't own them. Do not free or store String or Array values. /// When you return a String or Array, you hand over ownership of that value to the LoLa vm. pub fn wrap(comptime function: anytype) Function { const F = @TypeOf(function); const info = @typeInfo(F); if (info != .Fn) @compileError("Function.wrap expects a function!"); const function_info = info.Fn; if (function_info.is_generic) @compileError("Cannot wrap generic functions!"); if (function_info.is_var_args) @compileError("Cannot wrap functions with variadic arguments!"); const ArgsTuple = std.meta.ArgsTuple(F); const Impl = struct { fn invoke(env: *Environment, context: AnyPointer, args: []const Value) anyerror!Value { _ = context; if (args.len != function_info.params.len) return error.InvalidArgs; var zig_args: ArgsTuple = undefined; comptime var index = 0; inline while (index < function_info.params.len) : (index += 1) { const T = function_info.params[index].type.?; const value = args[index]; if (T == Value) { zig_args[index] = value; } else { zig_args[index] = try convertToZigValue(T, value); } } const ReturnType = function_info.return_type.?; const ActualReturnType = switch (@typeInfo(ReturnType)) { .ErrorUnion => |eu| eu.payload, else => ReturnType, }; const result: ActualReturnType = if (ReturnType != ActualReturnType) try @call(.auto, function, zig_args) else @call(.auto, function, zig_args); return try convertToLoLaValue(env.allocator, result); } }; return initSimpleUser(Impl.invoke); } pub fn wrapWithAnyPointer(comptime function: anytype, context: @typeInfo(@TypeOf(function)).Fn.args[0].type.?) Function { const F = @TypeOf(function); const FunctionAnyPointer = std.meta.Child(@TypeOf(context)); const info = @typeInfo(F); if (info != .Fn) @compileError("Function.wrap expects a function!"); const function_info = info.Fn; if (function_info.is_generic) @compileError("Cannot wrap generic functions!"); if (function_info.is_var_args) @compileError("Cannot wrap functions with variadic arguments!"); const ArgsTuple = std.meta.ArgsTuple(F); const Impl = struct { fn invoke(env: *Environment, wrapped_context: AnyPointer, args: []const Value) anyerror!Value { if (args.len != (function_info.args.len - 1)) return error.InvalidArgs; var zig_args: ArgsTuple = undefined; zig_args[0] = wrapped_context.get(FunctionAnyPointer); comptime var index = 1; inline while (index < function_info.args.len) : (index += 1) { const T = function_info.args[index].type.?; zig_args[index] = try convertToZigValue(T, args[index - 1]); } const ReturnType = function_info.return_type.?; const ActualReturnType = switch (@typeInfo(ReturnType)) { .ErrorUnion => |eu| eu.payload, else => ReturnType, }; const result: ActualReturnType = if (ReturnType != ActualReturnType) try @call(.{}, function, zig_args) else @call(.{}, function, zig_args); return try convertToLoLaValue(env.allocator, result); } }; return Self{ .syncUser = UserFunction{ .context = AnyPointer.init(FunctionAnyPointer, context), .destructor = null, .call = Impl.invoke, }, }; } pub fn deinit(self: *@This()) void { switch (self.*) { .script => {}, .syncUser => |*f| f.deinit(), .asyncUser => |*f| f.deinit(), } } }; test "Environment" { const cu = CompileUnit{ .arena = undefined, .comment = "", .globalCount = 4, .temporaryCount = 0, .code = "", .functions = &[_]CompileUnit.Function{ CompileUnit.Function{ .name = "fun1", .entryPoint = 10, .localCount = 5, }, CompileUnit.Function{ .name = "fun_2", .entryPoint = 21, .localCount = 1, }, CompileUnit.Function{ .name = "fun 3", .entryPoint = 32, .localCount = 3, }, }, .debugSymbols = &[0]CompileUnit.DebugSymbol{}, }; var pool = objects.ObjectPool(.{}).init(std.testing.allocator); defer pool.deinit(); var env = try Environment.init(std.testing.allocator, &cu, pool.interface()); defer env.deinit(); std.debug.assert(env.scriptGlobals.len == 4); std.debug.assert(env.functions.count() == 3); const f1 = env.getMethod("fun1") orelse unreachable; const f2 = env.getMethod("fun_2") orelse unreachable; const f3 = env.getMethod("fun 3") orelse unreachable; try std.testing.expectEqual(@as(usize, 10), f1.script.entryPoint); try std.testing.expectEqual(@as(usize, 5), f1.script.localCount); try std.testing.expectEqual(&env, f1.script.environment.?); try std.testing.expectEqual(@as(usize, 21), f2.script.entryPoint); try std.testing.expectEqual(@as(usize, 1), f2.script.localCount); try std.testing.expectEqual(&env, f2.script.environment.?); try std.testing.expectEqual(@as(usize, 32), f3.script.entryPoint); try std.testing.expectEqual(@as(usize, 3), f3.script.localCount); try std.testing.expectEqual(&env, f3.script.environment.?); } test "Function.wrap" { const Funcs = struct { fn returnVoid() void { unreachable; } fn returnValue() Value { unreachable; } fn returnString() String { unreachable; } fn returnArray() Array { unreachable; } fn returnObjectHandle() ObjectHandle { unreachable; } fn returnInt8() u8 { unreachable; } fn returnInt63() i63 { unreachable; } fn returnF64() f64 { unreachable; } fn returnF16() f16 { unreachable; } fn returnBool() bool { unreachable; } fn returnStringLit() []const u8 { unreachable; } fn takeVoid(value: void) void { _ = value; unreachable; } fn takeValue(value: Value) void { _ = value; unreachable; } fn takeString(value: String) void { _ = value; unreachable; } fn takeArray(value: Array) void { _ = value; unreachable; } fn takeObjectHandle(value: ObjectHandle) void { _ = value; unreachable; } fn takeInt8(value: u8) void { _ = value; unreachable; } fn takeInt63(value: i63) void { _ = value; unreachable; } fn takeF64(value: f64) void { _ = value; unreachable; } fn takeF16(value: f16) void { _ = value; unreachable; } fn takeBool(value: bool) void { _ = value; unreachable; } fn takeStringLit(value: []const u8) void { _ = value; unreachable; } fn takeAll( a0: Value, a1: String, a2: Array, a3: ObjectHandle, a4_1: u7, a4_2: i33, a5_1: f32, a5_2: f16, a6: bool, a7: void, a8: []const u8, ) void { _ = a0; _ = a1; _ = a2; _ = a3; _ = a4_1; _ = a4_2; _ = a5_1; _ = a5_2; _ = a6; _ = a7; _ = a8; unreachable; } }; inline for (comptime std.meta.declarations(Funcs)) |fun| { _ = Function.wrap(@field(Funcs, fun.name)); } }
0
repos/LoLa/src/library
repos/LoLa/src/library/runtime/vm.zig
const std = @import("std"); const lola = @import("../main.zig"); const value_unit = @import("value.zig"); const Value = value_unit.Value; const Decoder = @import("../common/Decoder.zig"); const ir = @import("../common/ir.zig"); const CompileUnit = @import("../common/CompileUnit.zig"); const objects = @import("objects.zig"); const Environment = @import("Environment.zig"); pub const ExecutionResult = enum { /// The vm instruction quota was exhausted and the execution was terminated. exhausted, /// The vm has encountered an asynchronous function call and waits for the completion. paused, /// The vm has completed execution of the program and has no more instructions to /// process. completed, }; /// Executor of a compile unit. This virtual machine will /// execute LoLa instructions. pub const VM = struct { const Self = @This(); const Context = struct { /// Stores the local variables for this call. locals: []Value, /// Provides instruction fetches for the right compile unit decoder: Decoder, /// Stores the stack balance at start of the function call. /// This is used to reset the stack to the right balance at the /// end of a function call. It is also used to check for stack underflows. stackBalance: usize, /// The script function which this context is currently executing environment: *Environment, }; /// Describes a set of statistics for the virtual machine. Can be useful for benchmarking. pub const Statistics = struct { /// Number of instructions executed in total. instructions: usize = 0, /// Number of executions which were stalled by a asynchronous function stalls: usize = 0, }; allocator: std.mem.Allocator, stack: std.ArrayList(Value), calls: std.ArrayList(Context), currentAsynCall: ?Environment.AsyncFunctionCall, objectPool: objects.ObjectPoolInterface, stats: Statistics = Statistics{}, /// Initialize a new virtual machine that will run the given environment. pub fn init(allocator: std.mem.Allocator, environment: *Environment) !Self { var vm = Self{ .allocator = allocator, .stack = std.ArrayList(Value).init(allocator), .calls = std.ArrayList(Context).init(allocator), .currentAsynCall = null, .objectPool = environment.objectPool, }; errdefer vm.stack.deinit(); errdefer vm.calls.deinit(); try vm.stack.ensureTotalCapacity(128); try vm.calls.ensureTotalCapacity(32); // Initialize with special "init context" that runs the script itself // and hosts the global variables. var initFun = try vm.createContext(Environment.ScriptFunction{ .environment = environment, .entryPoint = 0, // start at the very first byte .localCount = environment.compileUnit.temporaryCount, }); errdefer vm.deinitContext(&initFun); try vm.calls.append(initFun); return vm; } pub fn deinit(self: *Self) void { if (self.currentAsynCall) |*asyncCall| { asyncCall.deinit(); } for (self.stack.items) |*v| { v.deinit(); } for (self.calls.items) |*c| { self.deinitContext(c); } self.stack.deinit(); self.calls.deinit(); self.* = undefined; } pub fn deinitContext(self: Self, ctx: *Context) void { for (ctx.locals) |*v| { v.deinit(); } self.allocator.free(ctx.locals); ctx.* = undefined; } /// Creates a new execution context. /// The script function must have a resolved environment which /// uses the same object pool as the main environment. /// It is not possible to mix several object pools. fn createContext(self: *Self, fun: Environment.ScriptFunction) !Context { std.debug.assert(fun.environment != null); std.debug.assert(fun.environment.?.objectPool.self == self.objectPool.self); var ctx = Context{ .decoder = Decoder.init(fun.environment.?.compileUnit.code), .stackBalance = self.stack.items.len, .locals = undefined, .environment = fun.environment.?, }; ctx.decoder.offset = fun.entryPoint; ctx.locals = try self.allocator.alloc(Value, fun.localCount); for (ctx.locals) |*local| { local.* = .void; } return ctx; } /// Pushes the value. Will take ownership of the pushed value. fn push(self: *Self, value: Value) !void { try self.stack.append(value); } /// Peeks at the top of the stack. The returned value is still owned /// by the stack. fn peek(self: Self) !*Value { const slice = self.stack.items; if (slice.len == 0) return error.StackImbalance; return &slice[slice.len - 1]; } /// Pops a value from the stack. The ownership will be transferred to the caller. fn pop(self: *Self) !Value { if (self.calls.items.len > 0) { const ctx = &self.calls.items[self.calls.items.len - 1]; // Assert we did not accidently have a stack underflow std.debug.assert(self.stack.items.len >= ctx.stackBalance); // this pop would produce a stack underrun for the current function call. if (self.stack.items.len == ctx.stackBalance) return error.StackImbalance; } return if (self.stack.popOrNull()) |v| v else return error.StackImbalance; } /// Runs the virtual machine for `quota` instructions. pub fn execute(self: *Self, _quota: ?u32) !ExecutionResult { std.debug.assert(self.calls.items.len > 0); var quota = _quota; while (true) { if (quota) |*q| { // if we have a quota, reduce it til zero. if (q.* == 0) return ExecutionResult.exhausted; q.* -= 1; } if (try self.executeSingle()) |result| { switch (result) { .completed => { // A execution may only be completed if no calls // are active anymore. std.debug.assert(self.calls.items.len == 0); std.debug.assert(self.stack.items.len == 0); return ExecutionResult.completed; }, .yield => return ExecutionResult.paused, } } } } /// Executes a single instruction and returns the state of the machine. fn executeSingle(self: *Self) !?SingleResult { if (self.currentAsynCall) |*asyncCall| { if (asyncCall.object) |obj| { if (!self.objectPool.isObjectValid(obj)) return error.AsyncCallWithInvalidObject; } var res = try asyncCall.execute(asyncCall.context); if (res) |*result| { asyncCall.deinit(); self.currentAsynCall = null; errdefer result.deinit(); try self.push(result.*); } else { // We are not finished, continue later... self.stats.stalls += 1; return .yield; } } const ctx = &self.calls.items[self.calls.items.len - 1]; const environment = ctx.environment; // std.debug.warn("execute 0x{X}…\n", .{ctx.decoder.offset}); const instruction = ctx.decoder.read(ir.Instruction) catch |err| return switch (err) { error.EndOfStream => error.InvalidJump, else => error.InvalidBytecode, }; self.stats.instructions += 1; switch (instruction) { // Auxiliary Section: .nop => {}, .pop => { var value = try self.pop(); value.deinit(); }, // Immediate Section: .push_num => |i| try self.push(Value.initNumber(i.value)), .push_str => |i| { var val = try Value.initString(self.allocator, i.value); errdefer val.deinit(); try self.push(val); }, .push_true => try self.push(Value.initBoolean(true)), .push_false => try self.push(Value.initBoolean(false)), .push_void => try self.push(.void), // Memory Access Section: .store_global_idx => |i| { if (i.value >= environment.scriptGlobals.len) return error.InvalidGlobalVariable; const value = try self.pop(); environment.scriptGlobals[i.value].replaceWith(value); }, .load_global_idx => |i| { if (i.value >= environment.scriptGlobals.len) return error.InvalidGlobalVariable; var value = try environment.scriptGlobals[i.value].clone(); errdefer value.deinit(); try self.push(value); }, .store_local => |i| { if (i.value >= ctx.locals.len) return error.InvalidLocalVariable; const value = try self.pop(); ctx.locals[i.value].replaceWith(value); }, .load_local => |i| { if (i.value >= ctx.locals.len) return error.InvalidLocalVariable; var value = try ctx.locals[i.value].clone(); errdefer value.deinit(); try self.push(value); }, // Array Operations: .array_pack => |i| { var array = try value_unit.Array.init(self.allocator, i.value); errdefer array.deinit(); for (array.contents) |*item| { var value = try self.pop(); errdefer value.deinit(); item.replaceWith(value); } try self.push(Value.fromArray(array)); }, .array_load => { var indexed_val = try self.pop(); defer indexed_val.deinit(); var index_val = try self.pop(); defer index_val.deinit(); const index = try index_val.toInteger(usize); var dupe: Value = switch (indexed_val) { .array => |arr| blk: { if (index >= arr.contents.len) return error.IndexOutOfRange; break :blk try arr.contents[index].clone(); }, .string => |str| blk: { if (index >= str.contents.len) return error.IndexOutOfRange; break :blk Value.initInteger(u8, str.contents[index]); }, else => return error.TypeMismatch, }; errdefer dupe.deinit(); try self.push(dupe); }, .array_store => { var indexed_val = try self.pop(); errdefer indexed_val.deinit(); var index_val = try self.pop(); defer index_val.deinit(); if (indexed_val == .array) { var value = try self.pop(); // only destroy value when we fail to get the array item, // otherwise the value is stored in the array and must not // be deinitialized after that errdefer value.deinit(); const index = try index_val.toInteger(usize); if (index >= indexed_val.array.contents.len) return error.IndexOutOfRange; indexed_val.array.contents[index].replaceWith(value); } else if (indexed_val == .string) { var value = try self.pop(); defer value.deinit(); const string = &indexed_val.string; const byte = try value.toInteger(u8); const index = try index_val.toInteger(usize); if (index >= string.contents.len) return error.IndexOutOfRange; if (string.refcount != null and string.refcount.?.* > 1) { const new_string = try value_unit.String.init(self.allocator, string.contents); string.deinit(); string.* = new_string; } std.debug.assert(string.refcount == null or string.refcount.?.* == 1); const contents = try string.obtainMutableStorage(); contents[index] = byte; } else { return error.TypeMismatch; } try self.push(indexed_val); }, // Iterator Section: .iter_make => { var array_val = try self.pop(); errdefer array_val.deinit(); // is still owned by array_val and will be destroyed in case of array. const array = try array_val.toArray(); try self.push(Value.fromEnumerator(value_unit.Enumerator.initFromOwned(array))); }, .iter_next => { const enumerator_val = try self.peek(); const enumerator = try enumerator_val.getEnumerator(); if (enumerator.next()) |value| { self.push(value) catch |err| { var clone = value; clone.deinit(); return err; }; try self.push(Value.initBoolean(true)); } else { try self.push(Value.initBoolean(false)); } }, // Control Flow Section: .ret => { var call = self.calls.pop(); defer self.deinitContext(&call); // Restore stack balance while (self.stack.items.len > call.stackBalance) { var item = self.stack.pop(); item.deinit(); } // No more context to execute: we have completed execution if (self.calls.items.len == 0) return .completed; try self.push(.void); }, .retval => { var value = try self.pop(); errdefer value.deinit(); var call = self.calls.pop(); defer self.deinitContext(&call); // Restore stack balance while (self.stack.items.len > call.stackBalance) { var item = self.stack.pop(); item.deinit(); } // No more context to execute: we have completed execution if (self.calls.items.len == 0) { // TODO: How to handle returns from the main scrip? value.deinit(); return .completed; } else { try self.push(value); } }, .jmp => |target| { ctx.decoder.offset = target.value; }, .jif, .jnf => |target| { var value = try self.pop(); defer value.deinit(); const boolean = try value.toBoolean(); if (boolean == (instruction == .jnf)) { ctx.decoder.offset = target.value; } }, .call_fn => |call| { const method = environment.getMethod(call.function); if (method == null) return error.FunctionNotFound; if (try self.executeFunctionCall(environment, call, method.?, null)) return .yield; }, .call_obj => |call| { var obj_val = try self.pop(); errdefer obj_val.deinit(); if (obj_val != .object) return error.TypeMismatch; const obj = obj_val.object; if (!self.objectPool.isObjectValid(obj)) return error.InvalidObject; const function_or_null = try self.objectPool.getMethod(obj, call.function); if (function_or_null) |function| { if (try self.executeFunctionCall(environment, call, function, obj)) return .yield; } else { return error.FunctionNotFound; } }, // Logic Section: .bool_and => { var lhs = try self.pop(); defer lhs.deinit(); var rhs = try self.pop(); defer rhs.deinit(); const a = try lhs.toBoolean(); const b = try rhs.toBoolean(); try self.push(Value.initBoolean(a and b)); }, .bool_or => { var lhs = try self.pop(); defer lhs.deinit(); var rhs = try self.pop(); defer rhs.deinit(); const a = try lhs.toBoolean(); const b = try rhs.toBoolean(); try self.push(Value.initBoolean(a or b)); }, .bool_not => { var val = try self.pop(); defer val.deinit(); const a = try val.toBoolean(); try self.push(Value.initBoolean(!a)); }, // Arithmetic Section: .negate => { var value = try self.pop(); defer value.deinit(); const num = try value.toNumber(); try self.push(Value.initNumber(-num)); }, .add => { var rhs = try self.pop(); defer rhs.deinit(); var lhs = try self.pop(); defer lhs.deinit(); if (@as(value_unit.TypeId, lhs) != @as(value_unit.TypeId, rhs)) return error.TypeMismatch; switch (lhs) { .number => { try self.push(Value.initNumber(lhs.number + rhs.number)); }, .string => { const lstr = lhs.string.contents; const rstr = rhs.string.contents; var string = try value_unit.String.initUninitialized(self.allocator, lstr.len + rstr.len); errdefer string.deinit(); const buffer = try string.obtainMutableStorage(); @memcpy(buffer[0..lstr.len], lstr); @memcpy(buffer[lstr.len..buffer.len], rstr); try self.push(Value.fromString(string)); }, .array => { const larr = lhs.array.contents; const rarr = rhs.array.contents; var result = try value_unit.Array.init(self.allocator, larr.len + rarr.len); errdefer result.deinit(); for (larr, 0..) |*item, i| { result.contents[i].exchangeWith(item); } for (rarr, 0..) |*item, i| { result.contents[larr.len + i].exchangeWith(item); } try self.push(Value.fromArray(result)); }, else => return error.TypeMismatch, } }, .sub => { try self.executeNumberArithmetic(struct { fn operator(lhs: f64, rhs: f64) error{DivideByZero}!f64 { return lhs - rhs; } }.operator); }, .mul => { try self.executeNumberArithmetic(struct { fn operator(lhs: f64, rhs: f64) error{DivideByZero}!f64 { return lhs * rhs; } }.operator); }, .div => { try self.executeNumberArithmetic(struct { fn operator(lhs: f64, rhs: f64) error{DivideByZero}!f64 { if (rhs == 0) return error.DivideByZero; return lhs / rhs; } }.operator); }, .mod => { try self.executeNumberArithmetic(struct { fn operator(lhs: f64, rhs: f64) error{DivideByZero}!f64 { if (rhs == 0) return error.DivideByZero; return @mod(lhs, rhs); } }.operator); }, // Comparisons: .eq => { var lhs = try self.pop(); defer lhs.deinit(); var rhs = try self.pop(); defer rhs.deinit(); try self.push(Value.initBoolean(lhs.eql(rhs))); }, .neq => { var lhs = try self.pop(); defer lhs.deinit(); var rhs = try self.pop(); defer rhs.deinit(); try self.push(Value.initBoolean(!lhs.eql(rhs))); }, .less => try self.executeCompareValues(.lt, false), .less_eq => try self.executeCompareValues(.lt, true), .greater => try self.executeCompareValues(.gt, false), .greater_eq => try self.executeCompareValues(.gt, true), // Deperecated Section: .scope_push, .scope_pop, .declare, .store_global_name, .load_global_name, => return error.DeprectedInstruction, } return null; } /// Initiates or executes a function call. /// Returns `true` when the VM execution should suspend after the call, else `false`. fn executeFunctionCall(self: *Self, environment: *Environment, call: anytype, function: Environment.Function, object: ?objects.ObjectHandle) !bool { return switch (function) { .script => |fun| blk: { var context = try self.createContext(fun); errdefer self.deinitContext(&context); try self.readLocals(call, context.locals); // Fixup stack balance after popping all locals context.stackBalance = self.stack.items.len; try self.calls.append(context); break :blk false; }, .syncUser => |fun| blk: { const locals = try self.allocator.alloc(Value, call.argc); for (locals) |*l| { l.* = .void; } defer { for (locals) |*l| { l.deinit(); } self.allocator.free(locals); } try self.readLocals(call, locals); var result = try fun.call(environment, fun.context, locals); errdefer result.deinit(); try self.push(result); break :blk false; }, .asyncUser => |fun| blk: { const locals = try self.allocator.alloc(Value, call.argc); for (locals) |*l| { l.* = .void; } defer { for (locals) |*l| { l.deinit(); } self.allocator.free(locals); } try self.readLocals(call, locals); self.currentAsynCall = try fun.call(environment, fun.context, locals); self.currentAsynCall.?.object = object; break :blk true; }, }; } /// Reads a number of call arguments into a slice. /// If an error happens, all items in `locals` are valid and must be deinitialized. fn readLocals(self: *Self, call: ir.Instruction.CallArg, locals: []Value) !void { var i: usize = 0; while (i < call.argc) : (i += 1) { var value = try self.pop(); if (i < locals.len) { locals[i].replaceWith(value); } else { value.deinit(); // Discard the value } } } fn executeCompareValues(self: *Self, wantedOrder: std.math.Order, allowEql: bool) !void { var rhs = try self.pop(); defer rhs.deinit(); var lhs = try self.pop(); defer lhs.deinit(); if (@as(value_unit.TypeId, lhs) != @as(value_unit.TypeId, rhs)) return error.TypeMismatch; const order = switch (lhs) { .number => |num| std.math.order(num, rhs.number), .string => |str| std.mem.order(u8, str.contents, rhs.string.contents), else => return error.InvalidOperator, }; try self.push(Value.initBoolean( if (order == .eq and allowEql) true else order == wantedOrder, )); } const SingleResult = enum { /// The program has encountered an asynchronous function completed, /// execution and waits for completion. yield, }; fn executeNumberArithmetic(self: *Self, operator: *const fn (f64, f64) error{DivideByZero}!f64) !void { var rhs = try self.pop(); defer rhs.deinit(); var lhs = try self.pop(); defer lhs.deinit(); const n_lhs = try lhs.toNumber(); const n_rhs = try rhs.toNumber(); const result = try operator(n_lhs, n_rhs); try self.push(Value.initNumber(result)); } pub const StackTraceItem = struct { location: ?CompileUnit.DebugSymbol, function: []const u8, compile_unit: *const CompileUnit, }; pub fn getStackTop(self: Self) ?StackTraceItem { if (self.calls.items.len == 0) return null; const call = self.calls.items[self.calls.items.len - 1]; const stack_compile_unit = call.environment.compileUnit; var item = StackTraceItem{ .compile_unit = stack_compile_unit, .location = stack_compile_unit.lookUp(call.decoder.offset), .function = "<main>", }; for (stack_compile_unit.functions) |fun| { if (call.decoder.offset < fun.entryPoint) break; item.function = fun.name; } return item; } /// Prints a stack trace for the current code position into `stream`. pub fn printStackTrace(self: Self, stream: anytype) !void { var i: usize = self.calls.items.len; while (i > 0) { i -= 1; const call = self.calls.items[i]; const stack_compile_unit = call.environment.compileUnit; const location = stack_compile_unit.lookUp(call.decoder.offset); var current_fun: []const u8 = "<main>"; for (stack_compile_unit.functions) |fun| { if (call.decoder.offset < fun.entryPoint) break; current_fun = fun.name; } try stream.print("[{d}] at offset {d} ({s}:{d}:{d}) in function {s}\n", .{ i, call.decoder.offset, stack_compile_unit.comment, if (location) |l| l.sourceLine else 0, if (location) |l| l.sourceColumn else 0, current_fun, }); } } pub fn serialize(self: Self, envmap: *lola.runtime.EnvironmentMap, stream: anytype) !void { if (self.currentAsynCall != null) return error.NotSupportedYet; // we cannot serialize async function that are in-flight atm try stream.writeInt(u64, self.stack.items.len, .little); try stream.writeInt(u64, self.calls.items.len, .little); for (self.stack.items) |item| { try item.serialize(stream); } for (self.calls.items) |item| { try stream.writeInt(u16, @as(u16, @intCast(item.locals.len)), .little); try stream.writeInt(u32, item.decoder.offset, .little); // we don't need to store the CompileUnit of the decoder, as it is implicitly referenced by the environment try stream.writeInt(u32, @as(u32, @intCast(item.stackBalance)), .little); if (envmap.queryByPtr(item.environment)) |env_id| { try stream.writeInt(u32, env_id, .little); } else { return error.UnregisteredEnvironmentPointer; } for (item.locals) |loc| { try loc.serialize(stream); } } } pub fn deserialize(allocator: std.mem.Allocator, envmap: *lola.runtime.EnvironmentMap, stream: anytype) !Self { const stack_size = try stream.readInt(u64, .little); const call_size = try stream.readInt(u64, .little); var vm = Self{ .allocator = allocator, .stack = std.ArrayList(Value).init(allocator), .calls = std.ArrayList(Context).init(allocator), .currentAsynCall = null, .objectPool = undefined, }; errdefer vm.stack.deinit(); errdefer vm.calls.deinit(); try vm.stack.ensureTotalCapacity(@min(stack_size, 128)); try vm.calls.ensureTotalCapacity(@min(call_size, 32)); try vm.stack.resize(stack_size); for (vm.stack.items) |*item| { item.* = .void; } errdefer for (vm.stack.items) |*item| { item.deinit(); }; for (vm.stack.items) |*item| { item.* = try Value.deserialize(stream, allocator); } { var i: usize = 0; while (i < call_size) : (i += 1) { const local_count = try stream.readInt(u16, .little); const offset = try stream.readInt(u32, .little); const stack_balance = try stream.readInt(u32, .little); const env_id = try stream.readInt(u32, .little); const env = envmap.queryById(env_id) orelse return error.UnregisteredEnvironmentPointer; if (i == 0) { // first call defines which environment we use for our // object pool reference: vm.objectPool = env.objectPool; } var ctx = try vm.createContext(Environment.ScriptFunction{ .environment = env, .entryPoint = offset, .localCount = local_count, }); ctx.stackBalance = stack_balance; errdefer vm.deinitContext(&ctx); for (ctx.locals) |*local| { local.* = try Value.deserialize(stream, allocator); } try vm.calls.append(ctx); } } return vm; } }; const TestPool = objects.ObjectPool(.{}); fn runTest(comptime TestRunner: type) !void { var code = TestRunner.code; const cu = CompileUnit{ .arena = undefined, .comment = "", .globalCount = 0, .temporaryCount = 0, .functions = &[_]CompileUnit.Function{}, .debugSymbols = &[0]CompileUnit.DebugSymbol{}, .code = &code, }; var pool = TestPool.init(std.testing.allocator); defer pool.deinit(); var env = try Environment.init(std.testing.allocator, &cu, pool.interface()); defer env.deinit(); var vm = try VM.init(std.testing.allocator, &env); defer vm.deinit(); try TestRunner.verify(&vm); } test "VM basic execution" { try runTest(struct { var code = [_]u8{ @intFromEnum(ir.InstructionName.ret), }; fn verify(vm: *VM) !void { const result = try vm.execute(1); try std.testing.expectEqual(ExecutionResult.completed, result); } }); } test "VM endless loop exhaustion" { try runTest(struct { var code = [_]u8{ @intFromEnum(ir.InstructionName.jmp), 0x00, 0x00, 0x00, 0x00, }; fn verify(vm: *VM) !void { const result = try vm.execute(1000); try std.testing.expectEqual(ExecutionResult.exhausted, result); } }); } test "VM invalid code panic" { try runTest(struct { var code = [_]u8{ @intFromEnum(ir.InstructionName.jmp), 0x00, 0x00, 0x00, }; fn verify(vm: *VM) !void { try std.testing.expectError(error.InvalidBytecode, vm.execute(1000)); } }); } test "VM invalid jump panic" { try runTest(struct { var code = [_]u8{ @intFromEnum(ir.InstructionName.jmp), 0x00, 0x00, 0x00, 0xFF, }; fn verify(vm: *VM) !void { try std.testing.expectError(error.InvalidJump, vm.execute(1000)); } }); }
0
repos/LoLa/src/library
repos/LoLa/src/library/runtime/objects.zig
const std = @import("std"); const builtin = @import("builtin"); const interfaces = @import("../common/interface.zig"); const Environment = @import("Environment.zig"); const vm_unit = @import("vm.zig"); const Value = @import("value.zig").Value; /// Non-owning interface to a abstract LoLa object. /// It is associated with a object handle in the `ObjectPool` and provides /// a way to get methods as well as destroy the object when it's garbage collected. pub const Object = struct { const Interface = interfaces.Interfaces(.{ .getMethod = fn (self: *interfaces.Self, name: []const u8) ?Environment.Function, .destroyObject = fn (self: *interfaces.Self) void, }); const ClassVTable = interfaces.Interfaces(.{ .serializeObject = fn (self: *interfaces.Self, stream: OutputStream) anyerror!void, .deserializeObject = fn (stream: InputStream) anyerror!*interfaces.Self, }); const Self = @This(); ptr: *anyopaque, vtable: *const Interface.VTable, pub fn init(ptr: anytype) Self { return Self{ .ptr = ptr, .vtable = Interface.createVTable(@TypeOf(ptr.*)), }; } pub fn getMethod(self: *const Self, name: []const u8) ?Environment.Function { return self.vtable.getMethod(self.ptr, name); } pub fn destroyObject(self: *Self) void { self.vtable.destroyObject(self.ptr); self.* = undefined; } }; /// A opaque handle to objects. These are used inside the virtual machine and environment and /// will be passed around. They do not hold any memory references and require an object pool to /// resolve to actual objects. pub const ObjectHandle = enum(u64) { const Self = @This(); _, // Just an non-exhaustive handle, no named members }; pub const InputStream = struct { const Self = @This(); pub const ErasedSelf = opaque {}; self: *const ErasedSelf, read: *const fn (self: *const ErasedSelf, buf: []u8) anyerror!usize, fn from(reader_ptr: anytype) Self { const T = std.meta.Child(@TypeOf(reader_ptr)); return Self{ .self = @as(*const ErasedSelf, @ptrCast(reader_ptr)), .read = struct { fn read(self: *const ErasedSelf, buf: []u8) anyerror!usize { return @as(*const T, @ptrCast(@alignCast(self))).read(buf); } }.read, }; } fn readSome(self: Self, buffer: []u8) anyerror!usize { return self.read(self.self, buffer); } fn reader(self: @This()) Reader { return Reader{ .context = self, }; } pub const Reader = std.io.Reader(Self, anyerror, readSome); }; pub const OutputStream = struct { const Self = @This(); pub const ErasedSelf = opaque {}; self: *const ErasedSelf, write: *const fn (self: *const ErasedSelf, buf: []const u8) anyerror!usize, fn from(writer_ptr: anytype) Self { const T = std.meta.Child(@TypeOf(writer_ptr)); return Self{ .self = @as(*const ErasedSelf, @ptrCast(writer_ptr)), .write = struct { fn write(self: *const ErasedSelf, buf: []const u8) anyerror!usize { return @as(*const T, @ptrCast(@alignCast(self))).write(buf); } }.write, }; } fn writeSome(self: Self, buffer: []const u8) anyerror!usize { return self.write(self.self, buffer); } fn writer(self: @This()) Writer { return Writer{ .context = self, }; } pub const Writer = std.io.Writer(Self, anyerror, writeSome); }; const ObjectGetError = error{InvalidObject}; pub const ObjectPoolInterface = struct { const ErasedSelf = opaque {}; self: *ErasedSelf, getMethodFn: *const (fn (self: *ErasedSelf, handle: ObjectHandle, name: []const u8) ObjectGetError!?Environment.Function), destroyObjectFn: *const (fn (self: *ErasedSelf, handle: ObjectHandle) void), isObjectValidFn: *const (fn (self: *ErasedSelf, handle: ObjectHandle) bool), pub fn getMethod(self: @This(), handle: ObjectHandle, name: []const u8) ObjectGetError!?Environment.Function { return self.getMethodFn(self.self, handle, name); } pub fn destroyObject(self: @This(), handle: ObjectHandle) void { return self.destroyObjectFn(self.self, handle); } pub fn isObjectValid(self: @This(), handle: ObjectHandle) bool { return self.isObjectValidFn(self.self, handle); } pub fn castTo(self: *@This(), comptime PoolType: type) *PoolType { return @as(*PoolType, @ptrCast(@alignCast(self.self))); } }; const TypeListInfo = struct { all_can_serialize: bool, hash: u64, }; fn computeTypeListHash(comptime classes: []const type) TypeListInfo { var hasher = std.hash.SipHash64(2, 4).init("OP SER Version 1"); var all_classes_can_serialize = (classes.len > 0); inline for (classes) |class| { const can_serialize = @hasDecl(class, "serializeObject"); if (can_serialize != @hasDecl(class, "deserializeObject")) { @compileError("Each class requires either both serializeObject and deserializeObject to be present or none."); } all_classes_can_serialize = all_classes_can_serialize and can_serialize; // this requires to use a typeHash structure instead of the type name hasher.update(@typeName(class)); } return TypeListInfo{ .hash = hasher.finalInt(), .all_can_serialize = all_classes_can_serialize, }; } /// An object pool is a structure that is used for garbage collecting objects. /// Each object gets a unique number assigned when being put into the pool /// via `createObject`. This handle can then be passed into a VM, used opaquely. /// The VM can also request methods from objects via `getMethod` call. /// To collect garbage, the following procedure should be done: /// 1. Call `clearUsageCounters` to initiate garbage collection /// 2. Call `walkEnvironment`, `walkVM` or `walkValue` to collect all live objects in different elements /// 3. Call `collectGarbage` to delete all objects that have no reference counters set. /// For each object to be deleted, `destroyObject` is invoked and the object is removed from the pool. /// To retain objects by hand in areas not reachable by any of the `walk*` functions, it's possible to /// call `retainObject` to increment the reference counter by 1 and `releaseObject` to reduce it by one. /// Objects marked with this reference counter will not be deleted even when the object is not encountered /// betewen `clearUsageCounters` and `collectGarbage`. pub fn ObjectPool(comptime classes_list: anytype) type { // enforce type safety here const classes: [classes_list.len]type = classes_list; const list_info = comptime computeTypeListHash(&classes); const all_classes_can_serialize = list_info.all_can_serialize; const pool_signature = list_info.hash; const TypeIndex = std.meta.Int( .unsigned, // We need 1 extra value, so 0xFFFF… is never a valid type index // this marks the end of objects in the stream std.mem.alignForward(usize, std.math.log2_int_ceil(usize, classes.len + 1), 8), ); const ClassInfo = struct { name: []const u8, serialize: *const fn (stream: OutputStream, obj: Object) anyerror!void, deserialize: *const fn (allocator: std.mem.Allocator, stream: InputStream) anyerror!Object, }; // Provide a huge-enough branch quota @setEvalBranchQuota(1000 * (classes.len + 1)); const class_lut = comptime if (all_classes_can_serialize) blk: { var lut: [classes.len]ClassInfo = undefined; for (&lut, 0..) |*info, i| { const Class = classes[i]; const Interface = struct { fn serialize(stream: OutputStream, obj: Object) anyerror!void { try Class.serializeObject(stream.writer(), @as(*Class, @ptrCast(@alignCast(obj.ptr)))); } fn deserialize(allocator: std.mem.Allocator, stream: InputStream) anyerror!Object { const ptr = try Class.deserializeObject(allocator, stream.reader()); return Object.init(ptr); } }; info.* = ClassInfo{ .name = @typeName(Class), .serialize = Interface.serialize, .deserialize = Interface.deserialize, }; } break :blk lut; } else {}; return struct { const Self = @This(); const ManagedObject = struct { refcount: usize, manualRefcount: usize, object: Object, class_id: TypeIndex, }; /// Is `true` when all classes in the ObjectPool allow seriaization pub const serializable: bool = all_classes_can_serialize; /// ever-increasing number which is used to allocate new object handles. objectCounter: u64, /// stores all alive objects. Removing elements from this /// requires to call `.object.destroyObject()`! objects: std.AutoHashMap(ObjectHandle, ManagedObject), /// Creates a new object pool, using `allocator` to handle hashmap allocations. pub fn init(allocator: std.mem.Allocator) Self { return Self{ .objectCounter = 0, .objects = std.AutoHashMap(ObjectHandle, ManagedObject).init(allocator), }; } /// Destroys all objects in the pool, then releases all associated memory. /// Do not use the ObjectPool afterwards! pub fn deinit(self: *Self) void { var iter = self.objects.iterator(); while (iter.next()) |obj| { obj.value_ptr.object.destroyObject(); } self.objects.deinit(); self.* = undefined; } // Serialization API /// Serializes the whole object pool into the `stream`. pub fn serialize(self: Self, stream: anytype) !void { if (all_classes_can_serialize) { try stream.writeInt(u64, pool_signature, .little); var iter = self.objects.iterator(); while (iter.next()) |entry| { const obj = entry.value_ptr; var class = class_lut[obj.class_id]; try stream.writeInt(TypeIndex, obj.class_id, .little); try stream.writeInt(u64, @intFromEnum(entry.key_ptr.*), .little); try class.serialize(OutputStream.from(&stream), obj.object); } try stream.writeInt(TypeIndex, std.math.maxInt(TypeIndex), .little); } else { @compileError("This ObjectPool is not serializable!"); } } /// Deserializes a object pool from `steam` and returns it. pub fn deserialize(allocator: std.mem.Allocator, stream: anytype) !Self { if (all_classes_can_serialize) { var pool = init(allocator); errdefer pool.deinit(); const signature = try stream.readInt(u64, .little); if (signature != pool_signature) return error.InvalidStream; while (true) { const type_index = try stream.readInt(TypeIndex, .little); if (type_index == std.math.maxInt(TypeIndex)) break; // end of objects if (type_index >= class_lut.len) return error.InvalidStream; const object_id = try stream.readInt(u64, .little); pool.objectCounter = @max(object_id + 1, pool.objectCounter); const gop = try pool.objects.getOrPut(@as(ObjectHandle, @enumFromInt(object_id))); if (gop.found_existing) return error.InvalidStream; const object = try class_lut[type_index].deserialize(allocator, InputStream.from(&stream)); gop.value_ptr.* = ManagedObject{ .object = object, .refcount = 0, .manualRefcount = 0, .class_id = type_index, }; } return pool; } else { @compileError("This ObjectPool is not serializable!"); } } // Public API /// Inserts a new object into the pool and returns a handle to it. /// `object_ptr` must be a mutable pointer to the object itself. pub fn createObject(self: *Self, object_ptr: anytype) !ObjectHandle { const ObjectTypeInfo = @typeInfo(@TypeOf(object_ptr)).Pointer; if (ObjectTypeInfo.is_const) @compileError("Passing a const pointer to ObjectPool.createObject is not allowed!"); // Calculate the index of the type: const type_index = inline for (classes, 0..) |class, index| { if (class == ObjectTypeInfo.child) break index; } else @compileError("The type " ++ @typeName(ObjectTypeInfo.child) ++ " is not valid for this object pool. Add it to the class list in the type definition to allow creation."); const object = Object.init(object_ptr); self.objectCounter += 1; errdefer self.objectCounter -= 1; const handle = @as(ObjectHandle, @enumFromInt(self.objectCounter)); try self.objects.putNoClobber(handle, ManagedObject{ .object = object, .refcount = 0, .manualRefcount = 0, .class_id = type_index, }); return handle; } /// Keeps the object from beeing garbage collected. /// To allow recollection, call `releaseObject`. pub fn retainObject(self: *Self, object: ObjectHandle) ObjectGetError!void { if (self.objects.getEntry(object)) |obj| { obj.value_ptr.manualRefcount += 1; } else { return error.InvalidObject; } } /// Removes a restrain from `retainObject` to re-allow garbage collection. pub fn releaseObject(self: *Self, object: ObjectHandle) ObjectGetError!void { if (self.objects.getEntry(object)) |obj| { obj.value_ptr.manualRefcount -= 1; } else { return error.InvalidObject; } } /// Destroys an object by external means. This will also invoke the object destructor. pub fn destroyObject(self: *Self, object: ObjectHandle) void { if (self.objects.fetchRemove(object)) |obj| { var copy = obj.value.object; copy.destroyObject(); } } /// Returns if an object handle is still valid. pub fn isObjectValid(self: Self, object: ObjectHandle) bool { return (self.objects.get(object) != null); } /// Gets the method of an object or `null` if the method does not exist. /// The returned `Function` is non-owned. pub fn getMethod(self: Self, object: ObjectHandle, name: []const u8) ObjectGetError!?Environment.Function { if (self.objects.get(object)) |obj| { return obj.object.getMethod(name); } else { return error.InvalidObject; } } // Garbage Collector API /// Sets all usage counters to zero. pub fn clearUsageCounters(self: *Self) void { var iter = self.objects.iterator(); while (iter.next()) |obj| { obj.value_ptr.refcount = 0; } } /// Marks an object handle as used pub fn markUsed(self: *Self, object: ObjectHandle) ObjectGetError!void { if (self.objects.getEntry(object)) |obj| { obj.value_ptr.refcount += 1; } else { return error.InvalidObject; } } /// Walks through the value marks all referenced objects as used. pub fn walkValue(self: *Self, value: Value) ObjectGetError!void { switch (value) { .object => |oid| try self.markUsed(oid), .array => |arr| for (arr.contents) |val| { try self.walkValue(val); }, else => {}, } } /// Walks through all values stored in an environment and marks all referenced objects as used. pub fn walkEnvironment(self: *Self, env: Environment) ObjectGetError!void { for (env.scriptGlobals) |glob| { try self.walkValue(glob); } } /// Walks through all values stored in a virtual machine and marks all referenced objects as used. pub fn walkVM(self: *Self, vm: vm_unit.VM) ObjectGetError!void { for (vm.stack.items) |val| { try self.walkValue(val); } for (vm.calls.items) |call| { for (call.locals) |local| { try self.walkValue(local); } } } /// Removes and destroys all objects that are not marked as used. pub fn collectGarbage(self: *Self) void { // Now this?! var iter = self.objects.iterator(); while (iter.next()) |obj| { if (obj.value_ptr.refcount == 0 and obj.value_ptr.manualRefcount == 0) { if (self.objects.fetchRemove(obj.key_ptr.*)) |kv| { var temp_obj = kv.value.object; temp_obj.destroyObject(); } else { unreachable; } // Hack: Remove modification safety check, // we want to mutate the HashMap! // iter.initial_modification_count = iter.hm.modification_count; } } } // Interface API: /// Returns the non-generic interface for this object pool. /// Pass this to `Environment` or other LoLa components. pub fn interface(self: *Self) ObjectPoolInterface { const Impl = struct { const ErasedSelf = ObjectPoolInterface.ErasedSelf; fn cast(erased_self: *ErasedSelf) *Self { return @as(*Self, @ptrCast(@alignCast(erased_self))); } fn getMethod(erased_self: *ErasedSelf, handle: ObjectHandle, name: []const u8) ObjectGetError!?Environment.Function { return cast(erased_self).getMethod(handle, name); } fn destroyObject(erased_self: *ErasedSelf, handle: ObjectHandle) void { return cast(erased_self).destroyObject(handle); } fn isObjectValid(erased_self: *ErasedSelf, handle: ObjectHandle) bool { return cast(erased_self).isObjectValid(handle); } }; return ObjectPoolInterface{ .self = @as(*ObjectPoolInterface.ErasedSelf, @ptrCast(self)), .destroyObjectFn = Impl.destroyObject, .getMethodFn = Impl.getMethod, .isObjectValidFn = Impl.isObjectValid, }; } }; } const TestObject = struct { const Self = @This(); got_method_query: bool = false, got_destroy_call: bool = false, was_serialized: bool = false, was_deserialized: bool = false, pub fn getMethod(self: *Self, name: []const u8) ?Environment.Function { self.got_method_query = true; _ = name; return null; } pub fn destroyObject(self: *Self) void { self.got_destroy_call = true; } pub fn serializeObject(writer: OutputStream.Writer, object: *Self) !void { try writer.writeAll("test object"); object.was_serialized = true; } var deserialize_instance = Self{}; pub fn deserializeObject(allocator: std.mem.Allocator, reader: InputStream.Reader) !*Self { _ = allocator; var buf: [11]u8 = undefined; try reader.readNoEof(&buf); try std.testing.expectEqualStrings("test object", &buf); deserialize_instance.was_deserialized = true; return &deserialize_instance; } }; const TestPool = ObjectPool([_]type{TestObject}); comptime { if (builtin.is_test) { { if (ObjectPool([_]type{}).serializable != false) @compileError("Empty ObjectPool is required to be unserializable!"); } { if (TestPool.serializable != true) @compileError("TestPool is required to be serializable!"); } { const Unserializable = struct { const Self = @This(); pub fn getMethod(self: *Self, name: []const u8) ?Environment.Function { _ = self; _ = name; unreachable; } pub fn destroyObject(self: *Self) void { _ = self; unreachable; } }; if (ObjectPool([_]type{ TestObject, Unserializable }).serializable != false) @compileError("Unserializable detection doesn't work!"); } } } test "Object" { var test_obj = TestObject{}; var object = Object.init(&test_obj); try std.testing.expectEqual(false, test_obj.got_destroy_call); try std.testing.expectEqual(false, test_obj.got_method_query); _ = object.getMethod("irrelevant"); try std.testing.expectEqual(false, test_obj.got_destroy_call); try std.testing.expectEqual(true, test_obj.got_method_query); object.destroyObject(); try std.testing.expectEqual(true, test_obj.got_destroy_call); try std.testing.expectEqual(true, test_obj.got_method_query); } test "ObjectPool basic object create/destroy cycle" { var pool = TestPool.init(std.testing.allocator); defer pool.deinit(); var test_obj = TestObject{}; const handle = try pool.createObject(&test_obj); try std.testing.expectEqual(false, test_obj.got_destroy_call); try std.testing.expectEqual(false, test_obj.got_method_query); try std.testing.expectEqual(true, pool.isObjectValid(handle)); _ = try pool.getMethod(handle, "irrelevant"); try std.testing.expectEqual(false, test_obj.got_destroy_call); try std.testing.expectEqual(true, test_obj.got_method_query); pool.destroyObject(handle); try std.testing.expectEqual(true, test_obj.got_destroy_call); try std.testing.expectEqual(true, test_obj.got_method_query); try std.testing.expectEqual(false, pool.isObjectValid(handle)); } test "ObjectPool automatic cleanup" { var pool = TestPool.init(std.testing.allocator); errdefer pool.deinit(); var test_obj = TestObject{}; const handle = try pool.createObject(&test_obj); try std.testing.expectEqual(false, test_obj.got_destroy_call); try std.testing.expectEqual(false, test_obj.got_method_query); try std.testing.expectEqual(true, pool.isObjectValid(handle)); pool.deinit(); try std.testing.expectEqual(true, test_obj.got_destroy_call); try std.testing.expectEqual(false, test_obj.got_method_query); } test "ObjectPool garbage collection" { var pool = TestPool.init(std.testing.allocator); defer pool.deinit(); var test_obj = TestObject{}; const handle = try pool.createObject(&test_obj); try std.testing.expectEqual(false, test_obj.got_destroy_call); try std.testing.expectEqual(true, pool.isObjectValid(handle)); // Prevent the object from being collected because it is marked as used pool.clearUsageCounters(); try pool.markUsed(handle); pool.collectGarbage(); try std.testing.expectEqual(false, test_obj.got_destroy_call); try std.testing.expectEqual(true, pool.isObjectValid(handle)); // Prevent the object from being collected because it is marked as referenced try pool.retainObject(handle); pool.clearUsageCounters(); pool.collectGarbage(); try pool.releaseObject(handle); try std.testing.expectEqual(false, test_obj.got_destroy_call); try std.testing.expectEqual(true, pool.isObjectValid(handle)); // Destroy the object by not marking it referenced at last pool.clearUsageCounters(); pool.collectGarbage(); try std.testing.expectEqual(true, test_obj.got_destroy_call); try std.testing.expectEqual(false, pool.isObjectValid(handle)); } // TODO: Write tests for walkEnvironment and walkVM test "ObjectPool serialization" { var backing_buffer: [1024]u8 = undefined; const serialized_id = blk: { var pool = TestPool.init(std.testing.allocator); defer pool.deinit(); var test_obj = TestObject{}; const id = try pool.createObject(&test_obj); try std.testing.expectEqual(false, test_obj.was_serialized); var fbs = std.io.fixedBufferStream(&backing_buffer); try pool.serialize(fbs.writer()); try std.testing.expectEqual(true, test_obj.was_serialized); break :blk id; }; { var fbs = std.io.fixedBufferStream(&backing_buffer); try std.testing.expectEqual(false, TestObject.deserialize_instance.was_deserialized); var pool = try TestPool.deserialize(std.testing.allocator, fbs.reader()); defer pool.deinit(); try std.testing.expectEqual(true, TestObject.deserialize_instance.was_deserialized); try std.testing.expect(pool.isObjectValid(serialized_id)); } }
0
repos/LoLa/src/library
repos/LoLa/src/library/runtime/value.zig
const std = @import("std"); const objects = @import("objects.zig"); const Environment = @import("Environment.zig"); pub const TypeId = enum(u8) { void = 0, number = 1, object = 2, boolean = 3, string = 4, array = 5, enumerator = 6, }; /// A struct that represents any possible LoLa value. pub const Value = union(TypeId) { const Self = @This(); // non-allocating void: void, number: f64, object: objects.ObjectHandle, boolean: bool, // allocating string: String, array: Array, enumerator: Enumerator, pub fn initNumber(val: f64) Self { return Self{ .number = val }; } pub fn initInteger(comptime T: type, val: T) Self { comptime std.debug.assert(@typeInfo(T) == .Int); return Self{ .number = @as(f64, @floatFromInt(val)) }; } pub fn initObject(id: objects.ObjectHandle) Self { return Self{ .object = id }; } pub fn initBoolean(val: bool) Self { return Self{ .boolean = val }; } /// Initializes a new value with string contents. pub fn initString(allocator: std.mem.Allocator, text: []const u8) !Self { return Self{ .string = try String.init(allocator, text) }; } /// Creates a new value that takes ownership of the passed string. /// This string must not be deinited. pub fn fromString(str: String) Self { return Self{ .string = str }; } /// Creates a new value that takes ownership of the passed array. /// This array must not be deinited. pub fn fromArray(array: Array) Self { return Self{ .array = array }; } /// Creates a new value with an enumerator. The array will be cloned /// into the enumerator and will not be owned. pub fn initEnumerator(array: Array) !Self { return Self{ .enumerator = try Enumerator.init(array) }; } /// Creates a new value that takes ownership of the passed enumerator. /// This enumerator must not be deinited. pub fn fromEnumerator(enumerator: Enumerator) Self { return Self{ .enumerator = enumerator }; } /// Duplicate this value. pub fn clone(self: Self) !Self { return switch (self) { .string => |s| Self{ .string = try s.clone() }, .array => |a| Self{ .array = try a.clone() }, .enumerator => |e| Self{ .enumerator = try e.clone() }, .void, .number, .object, .boolean => self, }; } /// Exchanges two values pub fn exchangeWith(self: *Self, other: *Self) void { const temp = self.*; self.* = other.*; other.* = temp; } /// Replaces the current instance with another instance. /// This will move the memory from the other instance into the /// current one. Calling deinit() on `other` after this function /// is an error. pub fn replaceWith(self: *Self, other: Self) void { self.deinit(); self.* = other; } /// Checks if two values are equal. pub fn eql(lhs: Self, rhs: Self) bool { const Tag = std.meta.Tag(Self); if (@as(Tag, lhs) != @as(Tag, rhs)) return false; return switch (lhs) { .void => true, .number => |n| n == rhs.number, .object => |o| o == rhs.object, .boolean => |b| b == rhs.boolean, .string => |s| String.eql(s, rhs.string), .array => |a| Array.eql(a, rhs.array), .enumerator => |e| Enumerator.eql(e, rhs.enumerator), }; } pub fn deinit(self: *Self) void { switch (self.*) { .array => |*a| a.deinit(), .string => |*s| s.deinit(), .enumerator => |*e| e.deinit(), else => {}, } self.* = undefined; } const ConversionError = error{ TypeMismatch, OutOfRange }; pub fn toNumber(self: Self) ConversionError!f64 { if (self != .number) return error.TypeMismatch; return self.number; } pub fn toInteger(self: Self, comptime T: type) ConversionError!T { const num = @floor(try self.toNumber()); if (num < std.math.minInt(T)) return error.OutOfRange; if (num > std.math.maxInt(T)) return error.OutOfRange; return @as(T, @intFromFloat(num)); } pub fn toBoolean(self: Self) ConversionError!bool { if (self != .boolean) return error.TypeMismatch; return self.boolean; } pub fn toVoid(self: Self) ConversionError!void { if (self != .void) return error.TypeMismatch; } pub fn toObject(self: Self) ConversionError!objects.ObjectHandle { if (self != .object) return error.TypeMismatch; return self.object; } pub fn toArray(self: Self) ConversionError!Array { if (self != .array) return error.TypeMismatch; return self.array; } /// Returns either the string contents or errors with TypeMismatch pub fn toString(self: Self) ConversionError![]const u8 { if (self != .string) return error.TypeMismatch; return self.string.contents; } /// Gets the contained array or fails. pub fn getArray(self: *Self) ConversionError!*Array { if (self.* != .array) return error.TypeMismatch; return &self.array; } /// Gets the contained enumerator or fails. pub fn getEnumerator(self: *Self) ConversionError!*Enumerator { if (self.* != .enumerator) return error.TypeMismatch; return &self.enumerator; } fn formatArray(a: Array, stream: anytype) !void { try stream.writeAll("["); for (a.contents, 0..) |item, i| { if (i > 0) try stream.writeAll(","); // Workaround until #???? is fixed: // Print only the type name of the array item. // const itemType = @as(TypeId, item); // try std.fmt.format(context, Errors, output, " {}", .{@tagName(itemType)}); try stream.print(" {}", .{item}); } try stream.writeAll(" ]"); } /// Prints a LoLa value to the given stream. pub fn format(value: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, stream: anytype) !void { _ = fmt; _ = options; return switch (value) { .void => stream.writeAll("void"), .number => |n| stream.print("{d}", .{n}), .object => |o| stream.print("${d}", .{o}), .boolean => |b| if (b) stream.writeAll("true") else stream.writeAll("false"), .string => |s| stream.print("\"{s}\"", .{s.contents}), .array => |a| formatArray(a, stream), .enumerator => |e| stream.print("enumerator({}/{})", .{ e.index, e.array.contents.len }), }; } /// Serializes the value into the given `writer`. /// Note that this does not serialize object values but only references. It is required to serialize the corresponding /// object pool as well to gain restorability of objects. pub fn serialize(self: Self, writer: anytype) (@TypeOf(writer).Error || error{ NotSupported, ObjectTooLarge })!void { try writer.writeByte(@intFromEnum(@as(TypeId, self))); switch (self) { .void => return, // void values are empty \o/ .number => |val| try writer.writeAll(std.mem.asBytes(&val)), .object => |val| try writer.writeInt(u64, @intFromEnum(val), .little), .boolean => |val| try writer.writeByte(if (val) @as(u8, 1) else 0), .string => |val| { try writer.writeInt(u32, std.math.cast(u32, val.contents.len) orelse return error.ObjectTooLarge, .little); try writer.writeAll(val.contents); }, .array => |arr| { try writer.writeInt(u32, std.math.cast(u32, arr.contents.len) orelse return error.ObjectTooLarge, .little); for (arr.contents) |item| { try item.serialize(writer); } }, .enumerator => |e| { try writer.writeInt(u32, std.math.cast(u32, e.array.contents.len) orelse return error.ObjectTooLarge, .little); try writer.writeInt(u32, std.math.cast(u32, e.index) orelse return error.ObjectTooLarge, .little); for (e.array.contents) |item| { try item.serialize(writer); } }, } } /// Deserializes a value from the `reader`, using `allocator` to allocate memory. /// Note that if objects are deserialized you need to also deserialize the corresponding object pool pub fn deserialize(reader: anytype, allocator: std.mem.Allocator) (@TypeOf(reader).Error || error{ OutOfMemory, InvalidEnumTag, EndOfStream, NotSupported })!Self { const type_id_src = try reader.readByte(); const type_id = try std.meta.intToEnum(TypeId, type_id_src); return switch (type_id) { .void => .void, .number => blk: { var buffer: [@sizeOf(f64)]u8 align(@alignOf(f64)) = undefined; try reader.readNoEof(&buffer); break :blk initNumber(@as(f64, @bitCast(buffer))); }, .object => initObject(@as(objects.ObjectHandle, @enumFromInt(try reader.readInt(std.meta.Tag(objects.ObjectHandle), .little)))), .boolean => initBoolean((try reader.readByte()) != 0), .string => blk: { const size = try reader.readInt(u32, .little); const buffer = try allocator.alloc(u8, size); errdefer allocator.free(buffer); try reader.readNoEof(buffer); break :blk fromString(String.initFromOwned(allocator, buffer)); }, .array => blk: { const size = try reader.readInt(u32, .little); var array = try Array.init(allocator, size); errdefer array.deinit(); for (array.contents) |*item| { item.* = try deserialize(reader, allocator); } break :blk fromArray(array); }, .enumerator => blk: { const size = try reader.readInt(u32, .little); const index = try reader.readInt(u32, .little); var array = try Array.init(allocator, size); errdefer array.deinit(); for (array.contents) |*item| { item.* = try deserialize(reader, allocator); } break :blk fromEnumerator(Enumerator{ .array = array, .index = index, }); }, }; } }; test "Value.void" { var voidVal = Value{ .void = {} }; defer voidVal.deinit(); std.debug.assert(voidVal == .void); } test "Value.number" { var value = Value{ .number = 3.14 }; defer value.deinit(); std.debug.assert(value == .number); std.debug.assert(value.number == 3.14); } test "Value.boolean" { var value = Value{ .boolean = true }; defer value.deinit(); std.debug.assert(value == .boolean); std.debug.assert(value.boolean == true); } test "Value.object" { var value = Value{ .object = @as(objects.ObjectHandle, @enumFromInt(2394)) }; defer value.deinit(); std.debug.assert(value == .object); std.debug.assert(value.object == @as(objects.ObjectHandle, @enumFromInt(2394))); } test "Value.string (move)" { var value = Value.fromString(try String.init(std.testing.allocator, "Hello")); defer value.deinit(); std.debug.assert(value == .string); std.debug.assert(std.mem.eql(u8, value.string.contents, "Hello")); } test "Value.string (init)" { var value = try Value.initString(std.testing.allocator, "Malloc'd"); defer value.deinit(); std.debug.assert(value == .string); std.debug.assert(std.mem.eql(u8, value.string.contents, "Malloc'd")); } test "Value.eql (void)" { const v1: Value = .void; const v2: Value = .void; std.debug.assert(v1.eql(v2)); } test "Value.eql (boolean)" { const v1 = Value.initBoolean(true); const v2 = Value.initBoolean(true); const v3 = Value.initBoolean(false); std.debug.assert(v1.eql(v2)); std.debug.assert(v2.eql(v1)); std.debug.assert(v1.eql(v3) == false); std.debug.assert(v2.eql(v3) == false); } test "Value.eql (number)" { const v1 = Value.initNumber(1.3); const v2 = Value.initNumber(1.3); const v3 = Value.initNumber(2.3); std.debug.assert(v1.eql(v2)); std.debug.assert(v2.eql(v1)); std.debug.assert(v1.eql(v3) == false); std.debug.assert(v2.eql(v3) == false); } test "Value.eql (object)" { const v1 = Value.initObject(@as(objects.ObjectHandle, @enumFromInt(1))); const v2 = Value.initObject(@as(objects.ObjectHandle, @enumFromInt(1))); const v3 = Value.initObject(@as(objects.ObjectHandle, @enumFromInt(2))); std.debug.assert(v1.eql(v2)); std.debug.assert(v2.eql(v1)); std.debug.assert(v1.eql(v3) == false); std.debug.assert(v2.eql(v3) == false); } test "Value.eql (string)" { var v1 = try Value.initString(std.testing.allocator, "a"); defer v1.deinit(); var v2 = try Value.initString(std.testing.allocator, "a"); defer v2.deinit(); var v3 = try Value.initString(std.testing.allocator, "b"); defer v3.deinit(); std.debug.assert(v1.eql(v2)); std.debug.assert(v2.eql(v1)); std.debug.assert(v1.eql(v3) == false); std.debug.assert(v2.eql(v3) == false); } /// Immutable string type. /// Both pub const String = struct { const Self = @This(); allocator: std.mem.Allocator, contents: []const u8, refcount: ?*usize, /// Creates a new, uninitialized string pub fn initUninitialized(allocator: std.mem.Allocator, length: usize) !Self { const alignment = @alignOf(usize); const ptr_offset = std.mem.alignForward(usize, length, alignment); const buffer = try allocator.alignedAlloc( u8, alignment, ptr_offset + @sizeOf(usize), ); std.mem.writeInt(usize, buffer[ptr_offset..][0..@sizeOf(usize)], 1, .little); return Self{ .allocator = allocator, .contents = buffer[0..length], .refcount = @ptrCast(@alignCast(buffer.ptr + ptr_offset)), }; } /// Clones `text` with the given parameter and stores the /// duplicated value. pub fn init(allocator: std.mem.Allocator, text: []const u8) !Self { var string = try initUninitialized(allocator, text.len); @memcpy( string.obtainMutableStorage() catch unreachable, text, ); return string; } /// Returns a string that will take ownership of the passed `text` and /// will free that with `allocator`. pub fn initFromOwned(allocator: std.mem.Allocator, text: []const u8) Self { return Self{ .allocator = allocator, .contents = text, .refcount = null, }; } /// Returns a muable slice of the string elements. /// This may fail with `error.Forbidden` when the string is referenced more than once. pub fn obtainMutableStorage(self: *Self) error{Forbidden}![]u8 { if (self.refcount) |rc| { std.debug.assert(rc.* > 0); if (rc.* > 1) return error.Forbidden; } // this is safe as we allocated the memory, so it is actually mutable return @as([*]u8, @ptrFromInt(@intFromPtr(self.contents.ptr)))[0..self.contents.len]; } pub fn clone(self: Self) error{OutOfMemory}!Self { if (self.refcount) |rc| { // we can just increase reference count here rc.* += 1; return self; } else { // otherwise, return a new copy which is now reference-counted // -> performance opt-in return try init(self.allocator, self.contents); } } pub fn eql(lhs: Self, rhs: Self) bool { return std.mem.eql(u8, lhs.contents, rhs.contents); } pub fn deinit(self: *Self) void { if (self.refcount) |rc| { std.debug.assert(rc.* > 0); rc.* -= 1; if (rc.* > 0) return; // patch-up the old length so the allocator will know what happened self.contents.len = std.mem.alignForward(usize, self.contents.len, @alignOf(usize)) + @sizeOf(usize); self.allocator.free(@as([]align(@alignOf(usize)) const u8, @alignCast(self.contents))); } else { self.allocator.free(self.contents); } self.* = undefined; } }; test "String" { var text = try String.init(std.testing.allocator, "Hello, World!"); std.debug.assert(std.mem.eql(u8, text.contents, "Hello, World!")); var text2 = try text.clone(); text.deinit(); std.debug.assert(std.mem.eql(u8, text2.contents, "Hello, World!")); text2.deinit(); } test "String.eql" { var str1 = try String.init(std.testing.allocator, "Hello, World!"); defer str1.deinit(); var str2 = try String.init(std.testing.allocator, "Hello, World!"); defer str2.deinit(); var str3 = try String.init(std.testing.allocator, "World, Hello!"); defer str3.deinit(); std.debug.assert(str1.eql(str2)); std.debug.assert(str2.eql(str1)); std.debug.assert(str1.eql(str3) == false); std.debug.assert(str2.eql(str3) == false); } pub const Array = struct { const Self = @This(); allocator: std.mem.Allocator, contents: []Value, pub fn init(allocator: std.mem.Allocator, size: usize) !Self { const arr = Self{ .allocator = allocator, .contents = try allocator.alloc(Value, size), }; for (arr.contents) |*item| { item.* = Value{ .void = {} }; } return arr; } pub fn clone(self: Self) error{OutOfMemory}!Self { var arr = Self{ .allocator = self.allocator, .contents = try self.allocator.alloc(Value, self.contents.len), }; errdefer arr.allocator.free(arr.contents); var index: usize = 0; // Cleanup all successfully cloned items errdefer { var i: usize = 0; while (i < index) : (i += 1) { arr.contents[i].deinit(); } } while (index < arr.contents.len) : (index += 1) { arr.contents[index] = try self.contents[index].clone(); } return arr; } pub fn eql(lhs: Self, rhs: Self) bool { if (lhs.contents.len != rhs.contents.len) return false; for (lhs.contents, 0..) |v, i| { if (!Value.eql(v, rhs.contents[i])) return false; } return true; } pub fn deinit(self: *Self) void { for (self.contents) |*item| { item.deinit(); } self.allocator.free(self.contents); self.* = undefined; } }; test "Array" { var array = try Array.init(std.testing.allocator, 3); defer array.deinit(); std.debug.assert(array.contents.len == 3); std.debug.assert(array.contents[0] == .void); std.debug.assert(array.contents[1] == .void); std.debug.assert(array.contents[2] == .void); array.contents[0].replaceWith(Value.initBoolean(true)); array.contents[1].replaceWith(try Value.initString(std.testing.allocator, "Hello")); array.contents[2].replaceWith(Value.initNumber(45.0)); std.debug.assert(array.contents[0] == .boolean); std.debug.assert(array.contents[1] == .string); std.debug.assert(array.contents[2] == .number); } test "Array.eql" { var array1 = try Array.init(std.testing.allocator, 2); defer array1.deinit(); array1.contents[0] = Value.initBoolean(true); array1.contents[1] = Value.initNumber(42); var array2 = try Array.init(std.testing.allocator, 2); defer array2.deinit(); array2.contents[0] = Value.initBoolean(true); array2.contents[1] = Value.initNumber(42); var array3 = try Array.init(std.testing.allocator, 2); defer array3.deinit(); array3.contents[0] = Value.initBoolean(true); array3.contents[1] = Value.initNumber(43); var array4 = try Array.init(std.testing.allocator, 3); defer array4.deinit(); std.debug.assert(array1.eql(array2)); std.debug.assert(array2.eql(array1)); std.debug.assert(array1.eql(array3) == false); std.debug.assert(array2.eql(array3) == false); std.debug.assert(array1.eql(array4) == false); std.debug.assert(array2.eql(array4) == false); std.debug.assert(array3.eql(array4) == false); } pub const Enumerator = struct { const Self = @This(); array: Array, index: usize, /// Creates a new enumerator that will clone the contained value. pub fn init(array: Array) !Self { return Self{ .array = try array.clone(), .index = 0, }; } /// Creates a new enumerator that will own the passed value. pub fn initFromOwned(array: Array) Self { return Self{ .array = array, .index = 0, }; } /// Checks if the enumerator has a next item. pub fn hasNext(self: Self) bool { return self.index < self.array.contents.len; } /// Returns either a owned value or nothing. /// Will replace the returned value in the enumerator array with `void`. /// As the enumerator can only yield values from the array and does not "store" /// them for later use, this prevents unnecessary clones. pub fn next(self: *Self) ?Value { if (self.index >= self.array.contents.len) return null; var result: Value = .void; self.array.contents[self.index].exchangeWith(&result); self.index += 1; return result; } pub fn clone(self: Self) !Self { return Self{ .array = try self.array.clone(), .index = self.index, }; } // Enumerators are never equal to each other. pub fn eql(lhs: Self, rhs: Self) bool { _ = lhs; _ = rhs; return false; } pub fn deinit(self: *Self) void { self.array.deinit(); self.* = undefined; } }; test "Enumerator" { var array = try Array.init(std.testing.allocator, 3); array.contents[0] = try Value.initString(std.testing.allocator, "a"); array.contents[1] = try Value.initString(std.testing.allocator, "b"); array.contents[2] = try Value.initString(std.testing.allocator, "c"); var enumerator = Enumerator.initFromOwned(array); defer enumerator.deinit(); std.debug.assert(enumerator.hasNext()); var a = enumerator.next() orelse return error.NotEnoughItems; defer a.deinit(); var b = enumerator.next() orelse return error.NotEnoughItems; defer b.deinit(); var c = enumerator.next() orelse return error.NotEnoughItems; defer c.deinit(); std.debug.assert(enumerator.next() == null); std.debug.assert(a == .string); std.debug.assert(b == .string); std.debug.assert(c == .string); std.debug.assert(std.mem.eql(u8, a.string.contents, "a")); std.debug.assert(std.mem.eql(u8, b.string.contents, "b")); std.debug.assert(std.mem.eql(u8, c.string.contents, "c")); } test "Enumerator.eql" { var array = try Array.init(std.testing.allocator, 0); defer array.deinit(); var enumerator1 = try Enumerator.init(array); defer enumerator1.deinit(); var enumerator2 = try Enumerator.init(array); defer enumerator2.deinit(); std.debug.assert(enumerator1.eql(enumerator2) == false); }
0
repos/LoLa/src/library
repos/LoLa/src/library/runtime/environmentmap.zig
const std = @import("std"); const lola = @import("../main.zig"); /// This map is required by the VM serialization to identify environment pointers /// and allow serialization/deserialization of the correct references. pub const EnvironmentMap = struct { const Self = @This(); const Entry = struct { env: *lola.runtime.Environment, id: u32, }; items: std.ArrayList(Entry), pub fn init(allocator: std.mem.Allocator) Self { return Self{ .items = std.ArrayList(Entry).init(allocator), }; } pub fn deinit(self: *Self) void { self.items.deinit(); self.* = undefined; } /// Adds a new environment-id-pair to the map. /// Will return `error.IdAlreadyMapped` if a environment with this ID already exists, /// will return `error.EnvironmentAlreadyMapped` if the given environment is already in the map. /// Will return `error.OutOfMemory` when the internal storage cannot be resized. pub fn add(self: *Self, id: u32, env: *lola.runtime.Environment) !void { for (self.items.items) |item| { if (item.id == id) return error.IdAlreadyMapped; if (item.env == env) return error.EnvironmentAlreadyMapped; } try self.items.append(Entry{ .id = id, .env = env, }); } /// Returns the ID for the given environment or `null` if the environment was not registered. pub fn queryByPtr(self: Self, env: *lola.runtime.Environment) ?u32 { return for (self.items.items) |item| { if (item.env == env) break item.id; } else null; } /// Returns the Environment for the given id or `null` if the environment was not registered. pub fn queryById(self: Self, id: u32) ?*lola.runtime.Environment { return for (self.items.items) |item| { if (item.id == id) break item.env; } else null; } }; test "EnvironmentMap" { // three storage locations var env_1: lola.runtime.Environment = undefined; var env_2: lola.runtime.Environment = undefined; var env_3: lola.runtime.Environment = undefined; var map = EnvironmentMap.init(std.testing.allocator); defer map.deinit(); try map.add(1, &env_1); try map.add(2, &env_2); try std.testing.expectEqual(@as(?*lola.runtime.Environment, &env_1), map.queryById(1)); try std.testing.expectEqual(@as(?*lola.runtime.Environment, &env_2), map.queryById(2)); try std.testing.expectEqual(@as(?*lola.runtime.Environment, null), map.queryById(3)); try std.testing.expectEqual(@as(?u32, 1), map.queryByPtr(&env_1)); try std.testing.expectEqual(@as(?u32, 2), map.queryByPtr(&env_2)); try std.testing.expectEqual(@as(?u32, null), map.queryByPtr(&env_3)); }
0
repos/LoLa/src/library
repos/LoLa/src/library/common/disassembler.zig
const std = @import("std"); const CompileUnit = @import("CompileUnit.zig"); const Decoder = @import("Decoder.zig"); const ir = @import("ir.zig"); pub const DisassemblerOptions = struct { /// Prefix each line of the disassembly with the hexadecimal address. addressPrefix: bool = false, /// If set, a hexdump with both hex- and ascii display will be emitted. /// Each line of text will contain `hexwidth` number of bytes. hexwidth: ?usize = null, /// If set to `true`, the output will contain a line with the /// name of function that starts at this offset. This option /// is set by default. labelOutput: bool = true, /// If set to `true`, the disassembled instruction will be emitted. /// This is set by default. instructionOutput: bool = true, }; /// Disassembles a given compile unit into a text stream. /// The output of the disassembler is adjustable to different formats. /// If all output is disabled in the config, this function can also be used /// to verify that a compile unit can be parsed completly without any problems. pub fn disassemble(stream: anytype, cu: CompileUnit, options: DisassemblerOptions) !void { var decoder = Decoder.init(cu.code); const anyOutput = options.addressPrefix or options.labelOutput or options.instructionOutput or (options.hexwidth != null); if (options.addressPrefix) try stream.print("{X:0>6}\t", .{decoder.offset}); if (options.labelOutput) try stream.writeAll("<main>:\n"); while (!decoder.isEof()) { if (options.labelOutput) { for (cu.functions) |fun| { if (fun.entryPoint == decoder.offset) { if (options.addressPrefix) try stream.print("{X:0>6}\t", .{decoder.offset}); try stream.print("{s}:\n", .{fun.name}); } } } if (options.addressPrefix) try stream.print("{X:0>6}\t", .{decoder.offset}); const start = decoder.offset; const instr = try decoder.read(ir.Instruction); const end = decoder.offset; if (options.hexwidth) |hw| { try writeHexDump(stream, decoder.data, start, end, hw); } if (options.instructionOutput) { try stream.writeAll("\t"); try stream.writeAll(@tagName(@as(ir.InstructionName, instr))); inline for (std.meta.fields(ir.Instruction)) |fld| { const instr_name = @field(ir.InstructionName, fld.name); if (instr == instr_name) { if (fld.type == ir.Instruction.Deprecated) { // no-op } else if (fld.type == ir.Instruction.NoArg) { // no-op } else if (fld.type == ir.Instruction.CallArg) { const args = @field(instr, fld.name); try stream.print(" {s} {d}", .{ args.function, args.argc }); } else { if (@TypeOf(@field(instr, fld.name).value) == f64) { try stream.print(" {d}", .{@field(instr, fld.name).value}); } else if (instr_name == .jif or instr_name == .jmp or instr_name == .jnf) { try stream.print(" 0x{X}", .{@field(instr, fld.name).value}); } else { try stream.print(" {any}", .{@field(instr, fld.name).value}); } } } } } if (anyOutput) try stream.writeAll("\n"); if (options.hexwidth) |hw| { var cursor = start + hw; var paddedEnd = start + 2 * hw; while (paddedEnd < end + hw) : (paddedEnd += hw) { if (options.addressPrefix) try stream.print("{X:0>6}\t", .{cursor}); try writeHexDump(stream, decoder.data, cursor, end, hw); cursor += hw; try stream.writeAll("\n"); } } } } fn writeHexDump(stream: anytype, data: []const u8, begin: usize, end: usize, width: usize) !void { var offset_hex = begin; while (offset_hex < begin + width) : (offset_hex += 1) { if (offset_hex < end) { try stream.print("{X:0>2} ", .{data[offset_hex]}); } else { try stream.writeAll(" "); } } try stream.writeAll("|"); var offset_bin = begin; while (offset_bin < begin + width) : (offset_bin += 1) { if (offset_bin < end) { if (std.ascii.isPrint(data[offset_bin])) { try stream.print("{c}", .{data[offset_bin]}); } else { try stream.writeAll("."); } } else { try stream.writeAll(" "); } } try stream.writeAll("|"); } test "disassemble" { // dummy test _ = disassemble; }
0
repos/LoLa/src/library
repos/LoLa/src/library/common/interface.zig
const std = @import("std"); const Struct = std.builtin.Type.Struct; const StructField = std.builtin.Type.StructField; pub const Self = struct {}; fn MapSelfType(comptime T: type, comptime NewSelf: type) type { return if (T == Self) @compileError("Cannot use Self without pointer") else if (T == *Self) return *NewSelf else if (T == *const Self) return *const NewSelf else T; } fn GeneralizedFunc(comptime F: type) type { const f_in = @typeInfo(F).Fn; var f_out = f_in; f_out.params = &.{}; for (f_in.params) |pi| { var po = pi; po.type = MapSelfType( pi.type orelse @compileError("No support for generic parameters!"), anyopaque, ); f_out.params = f_out.params ++ [_]std.builtin.Type.Fn.Param{po}; } return @Type(.{ .Fn = f_out }); } pub fn Interfaces(comptime spec: anytype) type { const Parameter = struct { source_type: type, generic_type: type, is_mapped: bool, }; const Function = struct { name: [:0]const u8, spec_type: type, generic_type: type, spec_return: type, generic_return: type, return_is_mapped: bool, params: []const Parameter, }; const spec_fields = comptime std.meta.fields(@TypeOf(spec)); const functions = comptime blk: { var funcs: [spec_fields.len]Function = undefined; for (&funcs, spec_fields) |*fun, *sf| { const info = @typeInfo(@field(spec, sf.name)).Fn; fun.* = Function{ .name = sf.name, .spec_type = @field(spec, sf.name), .generic_type = GeneralizedFunc(@field(spec, sf.name)), .spec_return = info.return_type.?, .generic_return = MapSelfType(info.return_type.?, anyopaque), .params = &.{}, .return_is_mapped = (info.return_type.? != MapSelfType(info.return_type.?, anyopaque)), }; for (@typeInfo(fun.spec_type).Fn.params, @typeInfo(fun.generic_type).Fn.params) |sfn, gfn| { const param: Parameter = .{ .source_type = sfn.type.?, .generic_type = gfn.type.?, .is_mapped = (sfn.type.? != gfn.type.?), }; fun.params = fun.params ++ [1]Parameter{param}; } } break :blk funcs; }; return struct { const Intf = @This(); pub const VTable: type = blk: { var vti = Struct{ .backing_integer = null, .decls = &.{}, .fields = &.{}, .is_tuple = false, .layout = .auto, }; for (functions) |func| { vti.fields = vti.fields ++ &[_]StructField{ StructField{ .name = func.name, .type = *const func.generic_type, .default_value = null, .is_comptime = false, .alignment = @alignOf(*const func.generic_type), }, }; } break :blk @Type(.{ .Struct = vti, }); }; pub fn createVTable(comptime T: type) *const VTable { const Buffer = struct { const vtable: VTable = blk: { var vt: VTable = undefined; for (functions) |func| { const src_func = @field(T, func.name); const F = struct { fn MappedArg(comptime i: comptime_int) type { // @compileLog(func.name, i, func.params[i].generic_type, func.params[i].is_mapped); return if (func.params[i].is_mapped) MapSelfType(func.params[i].source_type, anyopaque) else func.params[i].generic_type; } fn mapArg(comptime i: comptime_int, value: MappedArg(i)) MapSelfType(func.params[i].source_type, T) { return if (func.params[i].is_mapped) @ptrCast(@alignCast(value)) else return value; } fn mapResult(value: MapSelfType(func.spec_return, anyopaque)) MapSelfType(func.spec_return, T) { return if (func.return_is_mapped) @ptrCast(@alignCast(value)) else return value; } const invoke = CallTranslator( src_func, MappedArg, mapArg, MapSelfType(func.spec_return, T), mapResult, ).invoke; }; @field(vt, func.name) = F.invoke; } break :blk vt; }; }; return &Buffer.vtable; } }; } fn CallTranslator( comptime target_func: anytype, comptime MappedArg: anytype, comptime mapArg: anytype, comptime MappedResult: type, comptime mapResult: anytype, ) type { const fi = @typeInfo(@TypeOf(target_func)).Fn; return switch (fi.params.len) { 0 => struct { pub fn invoke() MappedResult { return mapResult(target_func()); } }, 1 => struct { pub fn invoke(a0: MappedArg(0)) MappedResult { return mapResult(target_func(mapArg(0, a0))); } }, 2 => struct { pub fn invoke(a0: MappedArg(0), a1: MappedArg(1)) MappedResult { return mapResult(target_func(mapArg(0, a0), mapArg(1, a1))); } }, 3 => struct { pub fn invoke(a0: MappedArg(0), a1: MappedArg(1), a2: MappedArg(2)) MappedResult { return mapResult(target_func(mapArg(0, a0), mapArg(1, a1), mapArg(2, a2))); } }, 4 => struct { pub fn invoke(a0: MappedArg(0), a1: MappedArg(1), a2: MappedArg(2), a3: MappedArg(3)) MappedResult { return mapResult(target_func(mapArg(0, a0), mapArg(1, a1), mapArg(2, a2), mapArg(3, a3))); } }, 5 => struct { pub fn invoke(a0: MappedArg(0), a1: MappedArg(1), a2: MappedArg(2), a3: MappedArg(3), a4: MappedArg(4)) MappedResult { return mapResult(target_func(mapArg(0, a0), mapArg(1, a1), mapArg(2, a2), mapArg(3, a3), mapArg(4, a4))); } }, 6 => struct { pub fn invoke(a0: MappedArg(0), a1: MappedArg(1), a2: MappedArg(2), a3: MappedArg(3), a4: MappedArg(4), a5: MappedArg(5)) MappedResult { return mapResult(target_func(mapArg(0, a0), mapArg(1, a1), mapArg(2, a2), mapArg(3, a3), mapArg(4, a4), mapArg(5, a5))); } }, 7 => struct { pub fn invoke(a0: MappedArg(0), a1: MappedArg(1), a2: MappedArg(2), a3: MappedArg(3), a4: MappedArg(4), a5: MappedArg(5), a6: MappedArg(6)) MappedResult { return mapResult(target_func(mapArg(0, a0), mapArg(1, a1), mapArg(2, a2), mapArg(3, a3), mapArg(4, a4), mapArg(5, a5), mapArg(6, a6))); } }, 8 => struct { pub fn invoke(a0: MappedArg(0), a1: MappedArg(1), a2: MappedArg(2), a3: MappedArg(3), a4: MappedArg(4), a5: MappedArg(5), a6: MappedArg(6), a7: MappedArg(7)) MappedResult { return mapResult(target_func(mapArg(0, a0), mapArg(1, a1), mapArg(2, a2), mapArg(3, a3), mapArg(4, a4), mapArg(5, a5), mapArg(6, a6), mapArg(7, a7))); } }, 9 => struct { pub fn invoke(a0: MappedArg(0), a1: MappedArg(1), a2: MappedArg(2), a3: MappedArg(3), a4: MappedArg(4), a5: MappedArg(5), a6: MappedArg(6), a7: MappedArg(7), a8: MappedArg(8)) MappedResult { return mapResult(target_func(mapArg(0, a0), mapArg(1, a1), mapArg(2, a2), mapArg(3, a3), mapArg(4, a4), mapArg(5, a5), mapArg(6, a6), mapArg(7, a7), mapArg(8, a8))); } }, 10 => struct { pub fn invoke(a0: MappedArg(0), a1: MappedArg(1), a2: MappedArg(2), a3: MappedArg(3), a4: MappedArg(4), a5: MappedArg(5), a6: MappedArg(6), a7: MappedArg(7), a8: MappedArg(8), a9: MappedArg(9)) MappedResult { return mapResult(target_func(mapArg(0, a0), mapArg(1, a1), mapArg(2, a2), mapArg(3, a3), mapArg(4, a4), mapArg(5, a5), mapArg(6, a6), mapArg(7, a7), mapArg(8, a8), mapArg(9, a9))); } }, else => @compileError("Functions with more than {} args aren't supported yet!"), }; }
0
repos/LoLa/src/library
repos/LoLa/src/library/common/Decoder.zig
const std = @import("std"); const utility = @import("utility.zig"); // Import modules to reduce file size const ir = @import("ir.zig"); const CompileUnit = @import("CompileUnit.zig"); /// A struct that allows decoding data from LoLa IR code. pub const Decoder = @This(); data: []const u8, // we are restricted to 4GB code size in the binary format, the decoder itself can use the same restriction offset: u32, pub fn init(source: []const u8) Decoder { return Decoder{ .data = source, .offset = 0, }; } pub fn isEof(self: Decoder) bool { return self.offset >= self.data.len; } pub fn readRaw(self: *Decoder, dest: []u8) !void { if (self.offset == self.data.len) return error.EndOfStream; if (self.offset + dest.len > self.data.len) return error.NotEnoughData; @memcpy(dest, self.data[self.offset .. self.offset + dest.len]); self.offset += @as(u32, @intCast(dest.len)); } pub fn readBytes(self: *Decoder, comptime count: comptime_int) ![count]u8 { var data: [count]u8 = undefined; try self.readRaw(&data); return data; } /// Reads a value of the given type from the data stream. /// Allowed types are `u8`, `u16`, `u32`, `f64`, `Instruction`. pub fn read(self: *Decoder, comptime T: type) !T { if (T == ir.Instruction) { return readInstruction(self); } const data = try self.readBytes(@sizeOf(T)); switch (T) { u8, u16, u32 => return std.mem.readInt(T, &data, .little), f64 => return @as(f64, @bitCast(data)), ir.InstructionName => return try std.meta.intToEnum(ir.InstructionName, data[0]), else => @compileError("Unsupported type " ++ @typeName(T) ++ " for Decoder.read!"), } } /// Reads a variable-length string from the data stream. /// Note that the returned handle is only valid as long as Decoder.data is valid. pub fn readVarString(self: *Decoder) ![]const u8 { const len = try self.read(u16); if (self.offset + len > self.data.len) return error.NotEnoughData; // this is when a string tells you it's longer than the actual data storage. const string = self.data[self.offset .. self.offset + len]; self.offset += len; return string; } /// Reads a fixed-length string from the data. The string may either be 0-terminated /// or use the available length completly. /// Note that the returned handle is only valid as long as Decoder.data is valid. pub fn readFixedString(self: *Decoder, comptime len: comptime_int) ![]const u8 { if (self.offset == self.data.len) return error.EndOfStream; if (self.offset + len > self.data.len) return error.NotEnoughData; const fullMem = self.data[self.offset .. self.offset + len]; self.offset += len; return utility.clampFixedString(fullMem); } /// Reads a a full instruction from the source. /// This will provide full decoding and error checking. fn readInstruction(self: *Decoder) !ir.Instruction { if (self.isEof()) return error.EndOfStream; const instr = try self.read(ir.InstructionName); inline for (std.meta.fields(ir.Instruction)) |fld| { if (instr == @field(ir.InstructionName, fld.name)) { if (fld.type == ir.Instruction.Deprecated) { return error.DeprecatedInstruction; } else if (fld.type == ir.Instruction.NoArg) { return @unionInit(ir.Instruction, fld.name, .{}); } else if (fld.type == ir.Instruction.CallArg) { const fun = self.readVarString() catch |err| return mapEndOfStreamToNotEnoughData(err); const argc = self.read(u8) catch |err| return mapEndOfStreamToNotEnoughData(err); return @unionInit(ir.Instruction, fld.name, ir.Instruction.CallArg{ .function = fun, .argc = argc, }); } else { const ValType = std.meta.fieldInfo(fld.type, .value).type; if (ValType == []const u8) { return @unionInit(ir.Instruction, fld.name, fld.type{ .value = self.readVarString() catch |err| return mapEndOfStreamToNotEnoughData(err), }); } else { return @unionInit(ir.Instruction, fld.name, fld.type{ .value = self.read(ValType) catch |err| return mapEndOfStreamToNotEnoughData(err), }); } } } } return error.InvalidInstruction; } fn mapEndOfStreamToNotEnoughData(err: anytype) @TypeOf(err) { return switch (err) { error.EndOfStream => error.NotEnoughData, else => err, }; } // zig fmt: off const decoderTestBlob = [_]u8{ 1,2,3, // "[3]u8" 8, // u8, 16, 0, // u16 32, 0, 0, 0, // u32 12, // Instruction "add" 5, 0, 'H', 'e', 'l', 'l', 'o', // String(*) "Hello" 0x1F, 0x85, 0xEB, 0x51, 0xB8, 0x1E, 0x09, 0x40, // f64 = 3.14000000000000012434 == 0x40091EB851EB851F 'B', 'y', 'e', 0, 0, 0, 0, 0, // String(8) "Bye" }; // zig fmt: on test "Decoder" { var decoder = Decoder.init(&decoderTestBlob); std.debug.assert(std.mem.eql(u8, &(try decoder.readBytes(3)), &[3]u8{ 1, 2, 3 })); std.debug.assert((try decoder.read(u8)) == 8); std.debug.assert((try decoder.read(u16)) == 16); std.debug.assert((try decoder.read(u32)) == 32); std.debug.assert((try decoder.read(ir.InstructionName)) == .add); std.debug.assert(std.mem.eql(u8, try decoder.readVarString(), "Hello")); std.debug.assert((try decoder.read(f64)) == 3.14000000000000012434); std.debug.assert(std.mem.eql(u8, try decoder.readFixedString(8), "Bye")); if (decoder.readBytes(1)) |_| { std.debug.assert(false); } else |err| { std.debug.assert(err == error.EndOfStream); } } test "Decoder.NotEnoughData" { const blob = [_]u8{1}; var decoder = Decoder.init(&blob); if (decoder.read(u16)) |_| { std.debug.assert(false); } else |err| { std.debug.assert(err == error.NotEnoughData); } } test "Decoder.NotEnoughData (string)" { const blob = [_]u8{ 1, 0 }; var decoder = Decoder.init(&blob); if (decoder.readVarString()) |_| { std.debug.assert(false); } else |err| { std.debug.assert(err == error.NotEnoughData); } } test "Decoder.read(Instruction)" { const Pattern = struct { const ResultType = @typeInfo(@TypeOf(Decoder.readInstruction)).Fn.return_type orelse unreachable; text: []const u8, instr: ResultType, fn isMatch(self: @This(), testee: ResultType) bool { if (self.instr) |a_p| { if (testee) |b_p| return eql(a_p, b_p) else |_| return false; } else |a_e| { if (testee) |_| return false else |b_e| return a_e == b_e; } } fn eql(a: ir.Instruction, b: ir.Instruction) bool { @setEvalBranchQuota(5000); const activeField = @as(ir.InstructionName, a); if (activeField != @as(ir.InstructionName, b)) return false; inline for (std.meta.fields(ir.InstructionName)) |fld| { if (activeField == @field(ir.InstructionName, fld.name)) { const FieldType = @TypeOf(@field(a, fld.name)); const lhs = @field(a, fld.name); const rhs = @field(b, fld.name); if ((FieldType == ir.Instruction.Deprecated) or (FieldType == ir.Instruction.NoArg)) { return true; } else if (FieldType == ir.Instruction.CallArg) { return lhs.argc == rhs.argc and std.mem.eql(u8, lhs.function, rhs.function); } else { const ValType = std.meta.fieldInfo(FieldType, .value).type; if (ValType == []const u8) { return std.mem.eql(u8, lhs.value, rhs.value); } else { return lhs.value == rhs.value; } } } } unreachable; } }; const Instruction = ir.Instruction; const patterns = [_]Pattern{ .{ .text = "\x00", .instr = Instruction{ .nop = .{} } }, .{ .text = "\x01", .instr = error.DeprecatedInstruction }, .{ .text = "\x02", .instr = error.DeprecatedInstruction }, .{ .text = "\x03", .instr = error.DeprecatedInstruction }, .{ .text = "\x06\x03\x00ABC", .instr = Instruction{ .push_str = .{ .value = "ABC" } } }, .{ .text = "\x07\x00\x00\x00\x00\x00\x00\x00\x00", .instr = Instruction{ .push_num = .{ .value = 0 } } }, .{ .text = "\x08\x00\x10", .instr = Instruction{ .array_pack = .{ .value = 0x1000 } } }, .{ .text = "\x09\x01\x00x\x01", .instr = Instruction{ .call_fn = .{ .function = "x", .argc = 1 } } }, .{ .text = "\x0A\x02\x00yz\x03", .instr = Instruction{ .call_obj = .{ .function = "yz", .argc = 3 } } }, .{ .text = "\x0B", .instr = Instruction{ .pop = .{} } }, .{ .text = "\x0C", .instr = Instruction{ .add = .{} } }, .{ .text = "\x0D", .instr = Instruction{ .sub = .{} } }, .{ .text = "\x0E", .instr = Instruction{ .mul = .{} } }, .{ .text = "\x0F", .instr = Instruction{ .div = .{} } }, .{ .text = "\x10", .instr = Instruction{ .mod = .{} } }, .{ .text = "\x11", .instr = Instruction{ .bool_and = .{} } }, .{ .text = "\x12", .instr = Instruction{ .bool_or = .{} } }, .{ .text = "\x13", .instr = Instruction{ .bool_not = .{} } }, .{ .text = "\x14", .instr = Instruction{ .negate = .{} } }, .{ .text = "\x15", .instr = Instruction{ .eq = .{} } }, .{ .text = "\x16", .instr = Instruction{ .neq = .{} } }, .{ .text = "\x17", .instr = Instruction{ .less_eq = .{} } }, .{ .text = "\x18", .instr = Instruction{ .greater_eq = .{} } }, .{ .text = "\x19", .instr = Instruction{ .less = .{} } }, .{ .text = "\x1A", .instr = Instruction{ .greater = .{} } }, .{ .text = "\x1B\x00\x11\x22\x33", .instr = Instruction{ .jmp = .{ .value = 0x33221100 } } }, .{ .text = "\x1C\x44\x33\x22\x11", .instr = Instruction{ .jnf = .{ .value = 0x11223344 } } }, .{ .text = "\x1D", .instr = Instruction{ .iter_make = .{} } }, .{ .text = "\x1E", .instr = Instruction{ .iter_next = .{} } }, .{ .text = "\x1F", .instr = Instruction{ .array_store = .{} } }, .{ .text = "\x20", .instr = Instruction{ .array_load = .{} } }, .{ .text = "\x21", .instr = Instruction{ .ret = .{} } }, .{ .text = "\x22\xDE\xBA", .instr = Instruction{ .store_local = .{ .value = 0xBADE } } }, .{ .text = "\x23\xFE\xAF", .instr = Instruction{ .load_local = .{ .value = 0xAFFE } } }, .{ .text = "\x25", .instr = Instruction{ .retval = .{} } }, .{ .text = "\x26\x00\x12\x34\x56", .instr = Instruction{ .jif = .{ .value = 0x56341200 } } }, .{ .text = "\x27\x34\x12", .instr = Instruction{ .store_global_idx = .{ .value = 0x1234 } } }, .{ .text = "\x28\x21\x43", .instr = Instruction{ .load_global_idx = .{ .value = 0x4321 } } }, .{ .text = "\x29", .instr = Instruction{ .push_true = .{} } }, .{ .text = "\x2A", .instr = Instruction{ .push_false = .{} } }, .{ .text = "\x2B", .instr = Instruction{ .push_void = .{} } }, .{ .text = "", .instr = error.EndOfStream }, .{ .text = "\x26", .instr = error.NotEnoughData }, .{ .text = "\x09\xFF", .instr = error.NotEnoughData }, .{ .text = "\x26\x00\x00", .instr = error.NotEnoughData }, .{ .text = "\x09\xFF\xFF", .instr = error.NotEnoughData }, }; for (patterns) |pattern| { var decoder = Decoder.init(pattern.text); const instruction = decoder.read(Instruction); if (!pattern.isMatch(instruction)) { std.log.err("expected {!}, got {!}\n", .{ pattern.instr, instruction }); return error.UnexpectedToken; } } }
0
repos/LoLa/src/library
repos/LoLa/src/library/common/utility.zig
const std = @import("std"); pub fn clampFixedString(str: []const u8) []const u8 { if (std.mem.indexOfScalar(u8, str, 0)) |off| { return str[0..off]; } else { return str; } }
0
repos/LoLa/src/library
repos/LoLa/src/library/common/ir.zig
/// This enumeration contains all possible instructions and assigns each a value. pub const InstructionName = enum(u8) { nop = 0, scope_push = 1, // deprecated scope_pop = 2, // deprecated declare = 3, // deprecated store_global_name = 4, // deprecated load_global_name = 5, // deprecated push_str = 6, push_num = 7, array_pack = 8, call_fn = 9, call_obj = 10, pop = 11, add = 12, sub = 13, mul = 14, div = 15, mod = 16, bool_and = 17, bool_or = 18, bool_not = 19, negate = 20, eq = 21, neq = 22, less_eq = 23, greater_eq = 24, less = 25, greater = 26, jmp = 27, jnf = 28, iter_make = 29, iter_next = 30, array_store = 31, array_load = 32, ret = 33, store_local = 34, load_local = 35, // HERE BE HOLE retval = 37, jif = 38, store_global_idx = 39, load_global_idx = 40, push_true = 41, push_false = 42, push_void = 43, }; /// This union contains each possible instruction with its (optional) arguments already encoded. /// Each instruction type is either `NoArg`, `SingleArg`, `CallArg` or `Deprecated`, defining how /// each instruction is encoded. /// This information can be used to encode/decode the instructions based on their meta-information. pub const Instruction = union(InstructionName) { pub const Deprecated = struct {}; pub const NoArg = struct {}; fn SingleArg(comptime T: type) type { return struct { value: T }; } pub const CallArg = struct { function: []const u8, argc: u8, }; nop: NoArg, scope_push: Deprecated, scope_pop: Deprecated, declare: Deprecated, store_global_name: Deprecated, load_global_name: Deprecated, push_str: SingleArg([]const u8), push_num: SingleArg(f64), array_pack: SingleArg(u16), call_fn: CallArg, call_obj: CallArg, pop: NoArg, add: NoArg, sub: NoArg, mul: NoArg, div: NoArg, mod: NoArg, bool_and: NoArg, bool_or: NoArg, bool_not: NoArg, negate: NoArg, eq: NoArg, neq: NoArg, less_eq: NoArg, greater_eq: NoArg, less: NoArg, greater: NoArg, jmp: SingleArg(u32), jnf: SingleArg(u32), iter_make: NoArg, iter_next: NoArg, array_store: NoArg, array_load: NoArg, ret: NoArg, store_local: SingleArg(u16), load_local: SingleArg(u16), retval: NoArg, jif: SingleArg(u32), store_global_idx: SingleArg(u16), load_global_idx: SingleArg(u16), push_true: NoArg, push_false: NoArg, push_void: NoArg, };
0
repos/LoLa/src/library
repos/LoLa/src/library/common/CompileUnit.zig
const std = @import("std"); const utility = @import("utility.zig"); // Import modules to reduce file size // usingnamespace @import("value.zig"); /// A compiled piece of code, provides the building blocks for /// an environment. Note that a compile unit must be instantiated /// into an environment to be executed. pub const CompileUnit = @This(); /// Description of a script function. pub const Function = struct { name: []const u8, entryPoint: u32, localCount: u16, }; /// A mapping of which code portion belongs to which /// line in the source code. /// Lines are valid from offset until the next available symbol. pub const DebugSymbol = struct { /// Offset of the symbol from the start of the compiled code. offset: u32, /// The line number, starting at 1. sourceLine: u32, /// The offset into the line, starting at 1. sourceColumn: u16, }; arena: std.heap.ArenaAllocator, /// Freeform file structure comment. This usually contains the file name of the compile file. comment: []const u8, /// Number of global (persistent) variables stored in the environment globalCount: u16, /// Number of temporary (local) variables in the global scope. temporaryCount: u16, /// The compiled binary code. code: []u8, /// Array of function definitions functions: []const Function, /// Sorted array of debug symbols debugSymbols: []const DebugSymbol, /// Loads a compile unit from a data stream. pub fn loadFromStream(allocator: std.mem.Allocator, stream: anytype) !CompileUnit { // var inStream = file.getInStream(); // var stream = &inStream.stream; var header: [8]u8 = undefined; stream.readNoEof(&header) catch |err| switch (err) { error.EndOfStream => return error.InvalidFormat, // file is too short! else => return err, }; if (!std.mem.eql(u8, &header, "LoLa\xB9\x40\x80\x5A")) return error.InvalidFormat; const version = try stream.readInt(u32, .little); if (version != 1) return error.UnsupportedVersion; var comment: [256]u8 = undefined; try stream.readNoEof(&comment); var unit = CompileUnit{ .arena = std.heap.ArenaAllocator.init(allocator), .globalCount = undefined, .temporaryCount = undefined, .code = undefined, .functions = undefined, .debugSymbols = undefined, .comment = undefined, }; errdefer unit.arena.deinit(); unit.comment = try unit.arena.allocator().dupe(u8, utility.clampFixedString(&comment)); unit.globalCount = try stream.readInt(u16, .little); unit.temporaryCount = try stream.readInt(u16, .little); const functionCount = try stream.readInt(u16, .little); const codeSize = try stream.readInt(u32, .little); const numSymbols = try stream.readInt(u32, .little); if (functionCount > codeSize or numSymbols > codeSize) { // It is not reasonable to have multiple functions per // byte of code. // The same is valid for debug symbols. return error.CorruptedData; } const functions = try unit.arena.allocator().alloc(Function, functionCount); const code = try unit.arena.allocator().alloc(u8, codeSize); const debugSymbols = try unit.arena.allocator().alloc(DebugSymbol, numSymbols); for (functions) |*fun| { var name: [128]u8 = undefined; try stream.readNoEof(&name); const entryPoint = try stream.readInt(u32, .little); const localCount = try stream.readInt(u16, .little); fun.* = Function{ .name = try unit.arena.allocator().dupe(u8, utility.clampFixedString(&name)), .entryPoint = entryPoint, .localCount = localCount, }; } unit.functions = functions; try stream.readNoEof(code); unit.code = code; for (debugSymbols) |*sym| { const offset = try stream.readInt(u32, .little); const sourceLine = try stream.readInt(u32, .little); const sourceColumn = try stream.readInt(u16, .little); sym.* = DebugSymbol{ .offset = offset, .sourceLine = sourceLine, .sourceColumn = sourceColumn, }; } std.sort.block(DebugSymbol, debugSymbols, {}, struct { fn lessThan(context: void, lhs: DebugSymbol, rhs: DebugSymbol) bool { _ = context; return lhs.offset < rhs.offset; } }.lessThan); unit.debugSymbols = debugSymbols; return unit; } /// Saves a compile unit to a data stream. pub fn saveToStream(self: CompileUnit, stream: anytype) !void { try stream.writeAll("LoLa\xB9\x40\x80\x5A"); try stream.writeInt(u32, 1, .little); try stream.writeAll(self.comment); try stream.writeByteNTimes(0, 256 - self.comment.len); try stream.writeInt(u16, self.globalCount, .little); try stream.writeInt(u16, self.temporaryCount, .little); try stream.writeInt(u16, @as(u16, @intCast(self.functions.len)), .little); try stream.writeInt(u32, @as(u32, @intCast(self.code.len)), .little); try stream.writeInt(u32, @as(u32, @intCast(self.debugSymbols.len)), .little); for (self.functions) |fun| { try stream.writeAll(fun.name); try stream.writeByteNTimes(0, 128 - fun.name.len); try stream.writeInt(u32, fun.entryPoint, .little); try stream.writeInt(u16, fun.localCount, .little); } try stream.writeAll(self.code); for (self.debugSymbols) |sym| { try stream.writeInt(u32, sym.offset, .little); try stream.writeInt(u32, sym.sourceLine, .little); try stream.writeInt(u16, sym.sourceColumn, .little); } } /// Searches for a debug symbol that preceeds the given address. /// Function assumes that CompileUnit.debugSymbols is sorted /// front-to-back by offset. pub fn lookUp(self: CompileUnit, offset: u32) ?DebugSymbol { if (offset >= self.code.len) return null; var result: ?DebugSymbol = null; for (self.debugSymbols) |sym| { if (sym.offset > offset) break; result = sym; } return result; } pub fn deinit(self: CompileUnit) void { self.arena.deinit(); } const serializedCompileUnit = "" // SoT ++ "LoLa\xB9\x40\x80\x5A" // Header ++ "\x01\x00\x00\x00" // Version ++ "Made with NativeLola.zig!" ++ ("\x00" ** (256 - 25)) // Comment ++ "\x03\x00" // globalCount ++ "\x55\x11" // temporaryCount ++ "\x02\x00" // functionCount ++ "\x05\x00\x00\x00" // codeSize ++ "\x03\x00\x00\x00" // numSymbols ++ "Function1" ++ ("\x00" ** (128 - 9)) // Name ++ "\x00\x00\x00\x00" // entryPoint ++ "\x01\x00" // localCount ++ "Function2" ++ ("\x00" ** (128 - 9)) // Name ++ "\x10\x10\x00\x00" // entryPoint ++ "\x02\x00" // localCount ++ "Hello" // code ++ "\x01\x00\x00\x00" ++ "\x01\x00\x00\x00" ++ "\x01\x00" // dbgSym1 ++ "\x02\x00\x00\x00" ++ "\x02\x00\x00\x00" ++ "\x04\x00" // dbgSym2 ++ "\x04\x00\x00\x00" ++ "\x03\x00\x00\x00" ++ "\x08\x00" // dbgSym3 ; test "CompileUnit I/O" { var sliceInStream = std.io.fixedBufferStream(serializedCompileUnit); const cu = try CompileUnit.loadFromStream(std.testing.allocator, sliceInStream.reader()); defer cu.deinit(); std.debug.assert(std.mem.eql(u8, cu.comment, "Made with NativeLola.zig!")); std.debug.assert(cu.globalCount == 3); std.debug.assert(cu.temporaryCount == 0x1155); std.debug.assert(std.mem.eql(u8, cu.code, "Hello")); std.debug.assert(cu.functions.len == 2); std.debug.assert(cu.debugSymbols.len == 3); std.debug.assert(std.mem.eql(u8, cu.functions[0].name, "Function1")); std.debug.assert(cu.functions[0].entryPoint == 0x00000000); std.debug.assert(cu.functions[0].localCount == 1); std.debug.assert(std.mem.eql(u8, cu.functions[1].name, "Function2")); std.debug.assert(cu.functions[1].entryPoint == 0x00001010); std.debug.assert(cu.functions[1].localCount == 2); std.debug.assert(cu.debugSymbols[0].offset == 1); std.debug.assert(cu.debugSymbols[0].sourceLine == 1); std.debug.assert(cu.debugSymbols[0].sourceColumn == 1); std.debug.assert(cu.debugSymbols[1].offset == 2); std.debug.assert(cu.debugSymbols[1].sourceLine == 2); std.debug.assert(cu.debugSymbols[1].sourceColumn == 4); std.debug.assert(cu.debugSymbols[2].offset == 4); std.debug.assert(cu.debugSymbols[2].sourceLine == 3); std.debug.assert(cu.debugSymbols[2].sourceColumn == 8); var storage: [serializedCompileUnit.len]u8 = undefined; var sliceOutStream = std.io.fixedBufferStream(&storage); try cu.saveToStream(sliceOutStream.writer()); std.debug.assert(sliceOutStream.getWritten().len == serializedCompileUnit.len); std.debug.assert(std.mem.eql(u8, sliceOutStream.getWritten(), serializedCompileUnit)); } test "CompileUnit.lookUp" { var sliceInStream = std.io.fixedBufferStream(serializedCompileUnit); const cu = try CompileUnit.loadFromStream(std.testing.allocator, sliceInStream.reader()); defer cu.deinit(); std.debug.assert(cu.lookUp(0) == null); // no debug symbol before 1 std.debug.assert(cu.lookUp(1).?.sourceLine == 1); std.debug.assert(cu.lookUp(2).?.sourceLine == 2); std.debug.assert(cu.lookUp(3).?.sourceLine == 2); std.debug.assert(cu.lookUp(4).?.sourceLine == 3); std.debug.assert(cu.lookUp(5) == null); // no debug symbol after end-of-code }
0
repos/LoLa/src/library
repos/LoLa/src/library/compiler/location.zig
const std = @import("std"); /// A location in a chunk of text. Can be used to locate tokens and AST structures. pub const Location = struct { /// the name of the file/chunk this location is relative to chunk: []const u8, /// source line, starting at 1 line: u32, /// source column, starting at 1 column: u32, /// Offset to the start of the location offset_start: usize, /// Offset to the end of the location offset_end: usize, pub fn getLength(self: @This()) usize { return self.offset_end - self.offset_start; } pub fn format(self: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { _ = fmt; _ = options; try writer.print("{s}:{d}:{d}", .{ self.chunk, self.line, self.column }); } pub fn merge(a: Location, b: Location) Location { // Should emitted from the same chunk std.debug.assert(a.chunk.ptr == b.chunk.ptr); const min = if (a.offset_start < b.offset_start) a else b; return Location{ .chunk = a.chunk, .line = min.line, .column = min.column, .offset_start = @min(a.offset_start, b.offset_start), .offset_end = @max(a.offset_end, b.offset_end), }; } };
0
repos/LoLa/src/library
repos/LoLa/src/library/compiler/string-escaping.zig
const std = @import("std"); pub const EscapedStringIterator = struct { slice: []const u8, position: usize, pub fn init(slice: []const u8) @This() { return @This(){ .slice = slice, .position = 0, }; } pub fn next(self: *@This()) error{IncompleteEscapeSequence}!?u8 { if (self.position >= self.slice.len) return null; switch (self.slice[self.position]) { '\\' => { self.position += 1; if (self.position == self.slice.len) return error.IncompleteEscapeSequence; const c = self.slice[self.position]; self.position += 1; return switch (c) { 'a' => 7, 'b' => 8, 't' => 9, 'n' => 10, 'r' => 13, 'e' => 27, '\"' => 34, '\'' => 39, 'x' => blk: { if (self.position + 2 > self.slice.len) return error.IncompleteEscapeSequence; const str = self.slice[self.position..][0..2]; self.position += 2; break :blk std.fmt.parseInt(u8, str, 16) catch return error.IncompleteEscapeSequence; }, else => c, }; }, else => { self.position += 1; return self.slice[self.position - 1]; }, } } }; /// Applies all known string escape codes to the given input string, /// returning a freshly allocated string. pub fn escapeString(allocator: std.mem.Allocator, input: []const u8) ![]u8 { var iterator = EscapedStringIterator{ .slice = input, .position = 0, }; var len: usize = 0; while (try iterator.next()) |_| { len += 1; } iterator.position = 0; const result = try allocator.alloc(u8, len); var i: usize = 0; while (iterator.next() catch unreachable) |c| { result[i] = c; i += 1; } std.debug.assert(i == len); return result; } test "escape empty string" { const str = try escapeString(std.testing.allocator, ""); defer std.testing.allocator.free(str); try std.testing.expectEqualStrings("", str); } test "escape string without escape codes" { const str = try escapeString(std.testing.allocator, "ixtAOy9UbcIsIijUi42mtzOSwTiNolZAajBeS9W2PCgkyt7fDbuSQcjqKVRoBhalPBwThIkcVRa6W6tK2go1m7V2WoIrQNxuPzpf"); defer std.testing.allocator.free(str); try std.testing.expectEqualStrings("ixtAOy9UbcIsIijUi42mtzOSwTiNolZAajBeS9W2PCgkyt7fDbuSQcjqKVRoBhalPBwThIkcVRa6W6tK2go1m7V2WoIrQNxuPzpf", str); } // \a 7 Alert / Bell // \b 8 Backspace // \t 9 Horizontal Tab // \n 10 Line Feed // \r 13 Carriage Return // \e 27 Escape // \" 34 Double Quotes // \' 39 Single Quote test "escape string with predefined escape sequences" { const str = try escapeString(std.testing.allocator, " \\a \\b \\t \\n \\r \\e \\\" \\' "); defer std.testing.allocator.free(str); try std.testing.expectEqualStrings(" \x07 \x08 \x09 \x0A \x0D \x1B \" \' ", str); } test "escape string with hexadecimal escape sequences" { const str = try escapeString(std.testing.allocator, " \\xcA \\x84 \\x2d \\x75 \\xb7 \\xF1 \\xf3 \\x9e "); defer std.testing.allocator.free(str); try std.testing.expectEqualStrings(" \xca \x84 \x2d \x75 \xb7 \xf1 \xf3 \x9e ", str); } test "incomplete normal escape sequence" { try std.testing.expectError(error.IncompleteEscapeSequence, escapeString(std.testing.allocator, "\\")); } test "incomplete normal hex sequence" { try std.testing.expectError(error.IncompleteEscapeSequence, escapeString(std.testing.allocator, "\\x")); try std.testing.expectError(error.IncompleteEscapeSequence, escapeString(std.testing.allocator, "\\xA")); } test "invalid hex sequence" { try std.testing.expectError(error.IncompleteEscapeSequence, escapeString(std.testing.allocator, "\\xXX")); } test "escape string with tight predefined escape sequence" { const str = try escapeString(std.testing.allocator, "\\a"); defer std.testing.allocator.free(str); try std.testing.expectEqualStrings("\x07", str); } test "escape string with tight hexadecimal escape sequence" { const str = try escapeString(std.testing.allocator, "\\xca"); defer std.testing.allocator.free(str); try std.testing.expectEqualStrings("\xca", str); }
0
repos/LoLa/src/library
repos/LoLa/src/library/compiler/typeset.zig
const std = @import("std"); pub const Type = enum { void, number, string, boolean, array, object, pub fn format(value: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { _ = fmt; _ = options; try writer.writerAll(@tagName(value)); } }; pub const TypeSet = struct { const Self = @This(); pub const empty = Self{ .void = false, .number = false, .string = false, .boolean = false, .array = false, .object = false, }; pub const any = Self{ .void = true, .number = true, .string = true, .boolean = true, .array = true, .object = true, }; void: bool, number: bool, string: bool, boolean: bool, array: bool, object: bool, pub fn from(value_type: Type) Self { return Self{ .void = (value_type == .void), .number = (value_type == .number), .string = (value_type == .string), .boolean = (value_type == .boolean), .array = (value_type == .array), .object = (value_type == .object), }; } pub fn init(list: anytype) Self { var set = TypeSet.empty; inline for (list) |item| { set = set.@"union"(from(item)); } return set; } pub fn contains(self: Self, item: Type) bool { return switch (item) { .void => self.void, .number => self.number, .string => self.string, .boolean => self.boolean, .array => self.array, .object => self.object, }; } /// Returns a type set that only contains all types that are contained in both parameters. pub fn intersection(a: Self, b: Self) Self { var result: Self = undefined; inline for (std.meta.fields(Self)) |fld| { @field(result, fld.name) = @field(a, fld.name) and @field(b, fld.name); } return result; } /// Returns a type set that contains all types that are contained in any of the parameters. pub fn @"union"(a: Self, b: Self) Self { var result: Self = undefined; inline for (std.meta.fields(Self)) |fld| { @field(result, fld.name) = @field(a, fld.name) or @field(b, fld.name); } return result; } pub fn isEmpty(self: Self) bool { inline for (std.meta.fields(Self)) |fld| { if (@field(self, fld.name)) return false; } return true; } pub fn isAny(self: Self) bool { inline for (std.meta.fields(Self)) |fld| { if (!@field(self, fld.name)) return false; } return true; } /// Tests if the type set contains at least one common type. pub fn areCompatible(a: Self, b: Self) bool { return !intersection(a, b).isEmpty(); } pub fn format(value: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { _ = fmt; _ = options; if (value.isEmpty()) { try writer.writeAll("none"); } else if (value.isAny()) { try writer.writeAll("any"); } else { var separate = false; inline for (std.meta.fields(Self)) |fld| { if (@field(value, fld.name)) { if (separate) { try writer.writeAll("|"); } separate = true; try writer.writeAll(fld.name); } } } } };
0
repos/LoLa/src/library
repos/LoLa/src/library/compiler/parser.zig
const std = @import("std"); const lexer = @import("tokenizer.zig"); const ast = @import("ast.zig"); const diag = @import("diagnostics.zig"); const Location = @import("location.zig").Location; const EscapedStringIterator = @import("string-escaping.zig").EscapedStringIterator; /// Parses a sequence of tokens into an abstract syntax tree. /// Returns either a successfully parsed tree or puts all found /// syntax errors into `diagnostics`. pub fn parse( allocator: std.mem.Allocator, diagnostics: *diag.Diagnostics, sequence: []const lexer.Token, ) !ast.Program { var arena = std.heap.ArenaAllocator.init(allocator); errdefer arena.deinit(); var root_script = std.ArrayList(ast.Statement).init(arena.allocator()); defer root_script.deinit(); var functions = std.ArrayList(ast.Function).init(arena.allocator()); defer functions.deinit(); const Parser = struct { const Self = @This(); const Predicate = *const (fn (lexer.Token) bool); const AcceptError = error{SyntaxError}; const ParseError = std.mem.Allocator.Error || AcceptError; const SavedState = struct { index: usize, }; allocator: std.mem.Allocator, sequence: []const lexer.Token, index: usize = 0, diagnostics: *diag.Diagnostics, fn emitDiagnostics(self: *Self, comptime fmt: []const u8, args: anytype) error{ OutOfMemory, SyntaxError } { try self.diagnostics.emit(.@"error", self.getCurrentLocation(), fmt, args); return error.SyntaxError; } fn getCurrentLocation(self: Self) Location { return self.sequence[self.index].location; } /// Applies all known string escape codes fn escapeString(self: Self, input: []const u8) ![]u8 { var iterator = EscapedStringIterator.init(input); var len: usize = 0; while (try iterator.next()) |_| { len += 1; } iterator = EscapedStringIterator.init(input); const result = try self.allocator.alloc(u8, len); var i: usize = 0; while (iterator.next() catch unreachable) |c| { result[i] = c; i += 1; } std.debug.assert(i == len); return result; } /// Create a save state that allows rewinding the parser process. /// This should be used when a parsing function calls accept mulitple /// times and may emit a syntax error. /// The state should be restored in a errdefer. fn saveState(self: Self) SavedState { return SavedState{ .index = self.index, }; } /// Restores a previously created save state. fn restoreState(self: *Self, state: SavedState) void { self.index = state.index; } fn moveToHeap(self: *Self, value: anytype) !*@TypeOf(value) { const T = @TypeOf(value); std.debug.assert(@typeInfo(T) != .Pointer); const ptr = try self.allocator.create(T); ptr.* = value; std.debug.assert(std.meta.eql(ptr.*, value)); return ptr; } fn any(token: lexer.Token) bool { _ = token; return true; } fn is(comptime kind: lexer.TokenType) Predicate { return struct { fn pred(token: lexer.Token) bool { return token.type == kind; } }.pred; } fn oneOf(comptime kinds: anytype) Predicate { return struct { fn pred(token: lexer.Token) bool { return inline for (kinds) |k| { if (token.type == k) break true; } else false; } }.pred; } fn peek(self: Self) AcceptError!lexer.Token { if (self.index >= self.sequence.len) return error.SyntaxError; return self.sequence[self.index]; } fn accept(self: *Self, predicate: Predicate) AcceptError!lexer.Token { if (self.index >= self.sequence.len) return error.SyntaxError; const tok = self.sequence[self.index]; if (predicate(tok)) { self.index += 1; return tok; } else { // std.debug.print("cannot accept {} here!\n", .{tok}); return error.SyntaxError; } } fn acceptFunction(self: *Self) ParseError!ast.Function { const state = self.saveState(); errdefer self.restoreState(state); const initial_pos = try self.accept(is(.function)); const name = try self.accept(is(.identifier)); _ = try self.accept(is(.@"(")); var args = std.ArrayList([]const u8).init(self.allocator); defer args.deinit(); while (true) { const arg_or_end = try self.accept(oneOf(.{ .identifier, .@")" })); switch (arg_or_end.type) { .@")" => break, .identifier => { try args.append(arg_or_end.text); const delimit = try self.accept(oneOf(.{ .@",", .@")" })); if (delimit.type == .@")") break; }, else => unreachable, } } const block = try self.acceptBlock(); return ast.Function{ .location = initial_pos.location, .name = name.text, .parameters = try args.toOwnedSlice(), .body = block, }; } fn acceptBlock(self: *Self) ParseError!ast.Statement { const state = self.saveState(); errdefer self.restoreState(state); const begin = try self.accept(is(.@"{")); var body = std.ArrayList(ast.Statement).init(self.allocator); defer body.deinit(); while (true) { const stmt = self.acceptStatement() catch break; try body.append(stmt); } _ = try self.accept(is(.@"}")); return ast.Statement{ .location = begin.location, .type = .{ .block = try body.toOwnedSlice(), }, }; } fn acceptStatement(self: *Self) ParseError!ast.Statement { const state = self.saveState(); errdefer self.restoreState(state); const start = try self.peek(); switch (start.type) { .@";" => { _ = try self.accept(is(.@";")); return ast.Statement{ .location = start.location, .type = .empty, }; }, .@"break" => { _ = try self.accept(is(.@"break")); _ = try self.accept(is(.@";")); return ast.Statement{ .location = start.location, .type = .@"break", }; }, .@"continue" => { _ = try self.accept(is(.@"continue")); _ = try self.accept(is(.@";")); return ast.Statement{ .location = start.location, .type = .@"continue", }; }, .@"{" => { return try self.acceptBlock(); }, .@"while" => { _ = try self.accept(is(.@"while")); _ = try self.accept(is(.@"(")); const condition = try self.acceptExpression(); _ = try self.accept(is(.@")")); const body = try self.acceptBlock(); return ast.Statement{ .location = start.location, .type = .{ .while_loop = .{ .condition = condition, .body = try self.moveToHeap(body), }, }, }; }, .@"if" => { _ = try self.accept(is(.@"if")); _ = try self.accept(is(.@"(")); const condition = try self.acceptExpression(); _ = try self.accept(is(.@")")); const true_body = try self.acceptStatement(); if (self.accept(is(.@"else"))) |_| { const false_body = try self.acceptStatement(); return ast.Statement{ .location = start.location, .type = .{ .if_statement = .{ .condition = condition, .true_body = try self.moveToHeap(true_body), .false_body = try self.moveToHeap(false_body), }, }, }; } else |_| { return ast.Statement{ .location = start.location, .type = .{ .if_statement = .{ .condition = condition, .true_body = try self.moveToHeap(true_body), .false_body = null, }, }, }; } }, .@"for" => { _ = try self.accept(is(.@"for")); _ = try self.accept(is(.@"(")); const name = try self.accept(is(.identifier)); _ = try self.accept(is(.in)); const source = try self.acceptExpression(); _ = try self.accept(is(.@")")); const body = try self.acceptBlock(); return ast.Statement{ .location = start.location, .type = .{ .for_loop = .{ .variable = name.text, .source = source, .body = try self.moveToHeap(body), }, }, }; }, .@"return" => { _ = try self.accept(is(.@"return")); if (self.accept(is(.@";"))) |_| { return ast.Statement{ .location = start.location, .type = .return_void, }; } else |_| { const value = try self.acceptExpression(); _ = try self.accept(is(.@";")); return ast.Statement{ .location = start.location, .type = .{ .return_expr = value, }, }; } }, .@"var", .@"const" => { const decl_type = try self.accept(oneOf(.{ .@"var", .@"const" })); const name = try self.accept(is(.identifier)); const decider = try self.accept(oneOf(.{ .@";", .@"=" })); var stmt = ast.Statement{ .location = start.location.merge(name.location), .type = .{ .declaration = .{ .variable = name.text, .initial_value = null, .is_const = (decl_type.type == .@"const"), }, }, }; if (decider.type == .@"=") { const value = try self.acceptExpression(); _ = try self.accept(is(.@";")); stmt.type.declaration.initial_value = value; } return stmt; }, else => { const expr = try self.acceptExpression(); if ((expr.type == .function_call) or (expr.type == .method_call)) { _ = try self.accept(is(.@";")); return ast.Statement{ .location = expr.location, .type = .{ .discard_value = expr, }, }; } else { const mode = try self.accept(oneOf(.{ .@"=", .@"+=", .@"-=", .@"*=", .@"/=", .@"%=", })); const value = try self.acceptExpression(); _ = try self.accept(is(.@";")); return switch (mode.type) { .@"+=", .@"-=", .@"*=", .@"/=", .@"%=" => ast.Statement{ .location = expr.location, .type = .{ .assignment = .{ .target = expr, .value = ast.Expression{ .location = expr.location, .type = .{ .binary_operator = .{ .operator = switch (mode.type) { .@"+=" => .add, .@"-=" => .subtract, .@"*=" => .multiply, .@"/=" => .divide, .@"%=" => .modulus, else => unreachable, }, .lhs = try self.moveToHeap(expr), .rhs = try self.moveToHeap(value), }, }, }, }, }, }, .@"=" => ast.Statement{ .location = expr.location, .type = .{ .assignment = .{ .target = expr, .value = value, }, }, }, else => unreachable, }; } }, } } fn acceptExpression(self: *Self) ParseError!ast.Expression { const state = self.saveState(); errdefer self.restoreState(state); return try self.acceptLogicCombinatorExpression(); } fn acceptLogicCombinatorExpression(self: *Self) ParseError!ast.Expression { const state = self.saveState(); errdefer self.restoreState(state); var expr = try self.acceptComparisonExpression(); while (true) { const and_or = self.accept(oneOf(.{ .@"and", .@"or" })) catch break; const rhs = try self.acceptComparisonExpression(); const new_expr = ast.Expression{ .location = expr.location.merge(and_or.location).merge(rhs.location), .type = .{ .binary_operator = .{ .operator = switch (and_or.type) { .@"and" => .boolean_and, .@"or" => .boolean_or, else => unreachable, }, .lhs = try self.moveToHeap(expr), .rhs = try self.moveToHeap(rhs), }, }, }; expr = new_expr; } return expr; } fn acceptComparisonExpression(self: *Self) ParseError!ast.Expression { const state = self.saveState(); errdefer self.restoreState(state); var expr = try self.acceptSumExpression(); while (true) { const and_or = self.accept(oneOf(.{ .@"<=", .@">=", .@">", .@"<", .@"==", .@"!=", })) catch break; const rhs = try self.acceptSumExpression(); const new_expr = ast.Expression{ .location = expr.location.merge(and_or.location).merge(rhs.location), .type = .{ .binary_operator = .{ .operator = switch (and_or.type) { .@"<=" => .less_or_equal_than, .@">=" => .greater_or_equal_than, .@">" => .greater_than, .@"<" => .less_than, .@"==" => .equal, .@"!=" => .different, else => unreachable, }, .lhs = try self.moveToHeap(expr), .rhs = try self.moveToHeap(rhs), }, }, }; expr = new_expr; } return expr; } fn acceptSumExpression(self: *Self) ParseError!ast.Expression { const state = self.saveState(); errdefer self.restoreState(state); var expr = try self.acceptMulExpression(); while (true) { const and_or = self.accept(oneOf(.{ .@"+", .@"-", })) catch break; const rhs = try self.acceptMulExpression(); const new_expr = ast.Expression{ .location = expr.location.merge(and_or.location).merge(rhs.location), .type = .{ .binary_operator = .{ .operator = switch (and_or.type) { .@"+" => .add, .@"-" => .subtract, else => unreachable, }, .lhs = try self.moveToHeap(expr), .rhs = try self.moveToHeap(rhs), }, }, }; expr = new_expr; } return expr; } fn acceptMulExpression(self: *Self) ParseError!ast.Expression { const state = self.saveState(); errdefer self.restoreState(state); var expr = try self.acceptUnaryPrefixOperatorExpression(); while (true) { const and_or = self.accept(oneOf(.{ .@"*", .@"/", .@"%", })) catch break; const rhs = try self.acceptUnaryPrefixOperatorExpression(); const new_expr = ast.Expression{ .location = expr.location.merge(and_or.location).merge(rhs.location), .type = .{ .binary_operator = .{ .operator = switch (and_or.type) { .@"*" => .multiply, .@"/" => .divide, .@"%" => .modulus, else => unreachable, }, .lhs = try self.moveToHeap(expr), .rhs = try self.moveToHeap(rhs), }, }, }; expr = new_expr; } return expr; } fn acceptUnaryPrefixOperatorExpression(self: *Self) ParseError!ast.Expression { const state = self.saveState(); errdefer self.restoreState(state); if (self.accept(oneOf(.{ .not, .@"-" }))) |prefix| { // this must directly recurse as we can write `not not x` const value = try self.acceptUnaryPrefixOperatorExpression(); return ast.Expression{ .location = prefix.location.merge(value.location), .type = .{ .unary_operator = .{ .operator = switch (prefix.type) { .not => .boolean_not, .@"-" => .negate, else => unreachable, }, .value = try self.moveToHeap(value), }, }, }; } else |_| { return try self.acceptIndexingExpression(); } } fn acceptIndexingExpression(self: *Self) ParseError!ast.Expression { const state = self.saveState(); errdefer self.restoreState(state); var value = try self.acceptCallExpression(); while (self.accept(is(.@"["))) |_| { const index = try self.acceptExpression(); _ = try self.accept(is(.@"]")); const new_value = ast.Expression{ .location = value.location.merge(index.location), .type = .{ .array_indexer = .{ .value = try self.moveToHeap(value), .index = try self.moveToHeap(index), }, }, }; value = new_value; } else |_| {} return value; } fn acceptCallExpression(self: *Self) ParseError!ast.Expression { const state = self.saveState(); errdefer self.restoreState(state); var value = try self.acceptValueExpression(); while (self.accept(oneOf(.{ .@"(", .@"." }))) |sym| { const new_value = switch (sym.type) { // call .@"(" => blk: { var args = std.ArrayList(ast.Expression).init(self.allocator); defer args.deinit(); var loc = value.location; if (self.accept(is(.@")"))) |_| { // this is the end of the argument list } else |_| { while (true) { const arg = try self.acceptExpression(); try args.append(arg); const terminator = try self.accept(oneOf(.{ .@")", .@"," })); loc = terminator.location.merge(loc); if (terminator.type == .@")") break; } } break :blk ast.Expression{ .location = loc, .type = .{ .function_call = .{ .function = try self.moveToHeap(value), .arguments = try args.toOwnedSlice(), }, }, }; }, // method call .@"." => blk: { const method_name = try self.accept(is(.identifier)); _ = try self.accept(is(.@"(")); var args = std.ArrayList(ast.Expression).init(self.allocator); defer args.deinit(); var loc = value.location; if (self.accept(is(.@")"))) |_| { // this is the end of the argument list } else |_| { while (true) { const arg = try self.acceptExpression(); try args.append(arg); const terminator = try self.accept(oneOf(.{ .@")", .@"," })); loc = terminator.location.merge(loc); if (terminator.type == .@")") break; } } break :blk ast.Expression{ .location = loc, .type = .{ .method_call = .{ .object = try self.moveToHeap(value), .name = method_name.text, .arguments = try args.toOwnedSlice(), }, }, }; }, else => unreachable, }; value = new_value; } else |_| {} return value; } fn acceptValueExpression(self: *Self) ParseError!ast.Expression { const state = self.saveState(); errdefer self.restoreState(state); const token = try self.accept(oneOf(.{ .@"(", .@"[", .number_literal, .string_literal, .character_literal, .identifier, })); switch (token.type) { .@"(" => { const value = try self.acceptExpression(); _ = try self.accept(is(.@")")); return value; }, .@"[" => { var array = std.ArrayList(ast.Expression).init(self.allocator); defer array.deinit(); while (true) { if (self.accept(is(.@"]"))) |_| { break; } else |_| { const item = try self.acceptExpression(); try array.append(item); const delimit = try self.accept(oneOf(.{ .@",", .@"]" })); if (delimit.type == .@"]") break; } } return ast.Expression{ .location = token.location, .type = .{ .array_literal = try array.toOwnedSlice(), }, }; }, .number_literal => { const val = if (std.mem.startsWith(u8, token.text, "0x")) @as(f64, @floatFromInt(std.fmt.parseInt(i54, token.text[2..], 16) catch return self.emitDiagnostics("`{s}` is not a valid hexadecimal number!", .{token.text}))) else std.fmt.parseFloat(f64, token.text) catch return self.emitDiagnostics("`{s}` is not a valid number!", .{token.text}); return ast.Expression{ .location = token.location, .type = .{ .number_literal = val, }, }; }, .string_literal => { std.debug.assert(token.text.len >= 2); return ast.Expression{ .location = token.location, .type = .{ .string_literal = self.escapeString(token.text[1 .. token.text.len - 1]) catch return self.emitDiagnostics("Invalid escape sequence in {s}!", .{token.text}), }, }; }, .character_literal => { std.debug.assert(token.text.len >= 2); const escaped_text = self.escapeString(token.text[1 .. token.text.len - 1]) catch return self.emitDiagnostics("Invalid escape sequence in {s}!", .{token.text}); var value: u21 = undefined; if (escaped_text.len == 0) { return error.SyntaxError; } else if (escaped_text.len == 1) { // this is a shortcut for non-utf8 encoded files. // it's not a perfect heuristic, but it's okay. value = escaped_text[0]; } else { const utf8_len = std.unicode.utf8ByteSequenceLength(escaped_text[0]) catch return self.emitDiagnostics("Invalid utf8 sequence: `{s}`!", .{escaped_text}); if (escaped_text.len != utf8_len) return error.SyntaxError; value = std.unicode.utf8Decode(escaped_text[0..utf8_len]) catch return self.emitDiagnostics("Invalid utf8 sequence: `{s}`!", .{escaped_text}); } return ast.Expression{ .location = token.location, .type = .{ .number_literal = @as(f64, @floatFromInt(value)), }, }; }, .identifier => return ast.Expression{ .location = token.location, .type = .{ .variable_expr = token.text, }, }, else => unreachable, } } }; var parser = Parser{ .allocator = arena.allocator(), .sequence = sequence, .diagnostics = diagnostics, }; while (parser.index < parser.sequence.len) { const state = parser.saveState(); // look-ahead one token and try accepting a "function" keyword, // use that to select between parsing a function or a statement. if (parser.accept(Parser.is(.function))) |_| { // we need to unaccept the function token parser.restoreState(state); const fun = try parser.acceptFunction(); try functions.append(fun); } else |_| { // no need to unaccept here as we didn't accept in the first place const stmt = parser.acceptStatement() catch |err| switch (err) { error.SyntaxError => { // Do some recovery here: try diagnostics.emit(.@"error", parser.getCurrentLocation(), "syntax error!", .{}); while (parser.index < parser.sequence.len) { const recovery_state = parser.saveState(); const tok = try parser.accept(Parser.any); if (tok.type == .@";") break; // We want to be able to parse the next function properly // even if we have syntax errors. if (tok.type == .function) { parser.restoreState(recovery_state); break; } } continue; }, else => |e| return e, }; try root_script.append(stmt); } } return ast.Program{ .arena = arena, .root_script = try root_script.toOwnedSlice(), .functions = try functions.toOwnedSlice(), }; } fn testTokenize(str: []const u8) ![]lexer.Token { var result = std.ArrayList(lexer.Token).init(std.testing.allocator); var tokenizer = lexer.Tokenizer.init("testsrc", str); while (true) { switch (tokenizer.next()) { .end_of_file => return result.toOwnedSlice(), .invalid_sequence => unreachable, // we don't do that here .token => |token| try result.append(token), } } } fn expectEqual(expected: anytype, actual: anytype) !void { const T = @TypeOf(expected); return try std.testing.expectEqual(expected, @as(T, actual)); } const expectEqualStrings = std.testing.expectEqualStrings; test "empty file parsing" { var diagnostics = diag.Diagnostics.init(std.testing.allocator); defer diagnostics.deinit(); var pgm = try parse(std.testing.allocator, &diagnostics, &[_]lexer.Token{}); defer pgm.deinit(); // assert that an empty file results in a empty AST try expectEqual(@as(usize, 0), pgm.root_script.len); try expectEqual(@as(usize, 0), pgm.functions.len); // assert that we didn't encounter syntax errors try expectEqual(@as(usize, 0), diagnostics.messages.items.len); } fn parseTest(string: []const u8) !ast.Program { const seq = try testTokenize(string); defer std.testing.allocator.free(seq); var diagnostics = diag.Diagnostics.init(std.testing.allocator); defer diagnostics.deinit(); return try parse(std.testing.allocator, &diagnostics, seq); } test "parse single top level statement" { // test with the simplest of all statements: // the empty one var pgm = try parseTest(";"); defer pgm.deinit(); try expectEqual(@as(usize, 0), pgm.functions.len); try expectEqual(@as(usize, 1), pgm.root_script.len); try expectEqual(ast.Statement.Type.empty, pgm.root_script[0].type); } test "parse single empty function" { // 0 params { var pgm = try parseTest("function empty(){}"); defer pgm.deinit(); try expectEqual(@as(usize, 1), pgm.functions.len); try expectEqual(@as(usize, 0), pgm.root_script.len); const fun = pgm.functions[0]; try std.testing.expectEqualStrings("empty", fun.name); try expectEqual(ast.Statement.Type.block, fun.body.type); try expectEqual(@as(usize, 0), fun.body.type.block.len); try expectEqual(@as(usize, 0), fun.parameters.len); } // 1 param { var pgm = try parseTest("function empty(p0){}"); defer pgm.deinit(); try expectEqual(@as(usize, 1), pgm.functions.len); try expectEqual(@as(usize, 0), pgm.root_script.len); const fun = pgm.functions[0]; try std.testing.expectEqualStrings("empty", fun.name); try expectEqual(ast.Statement.Type.block, fun.body.type); try expectEqual(@as(usize, 0), fun.body.type.block.len); try expectEqual(@as(usize, 1), fun.parameters.len); try std.testing.expectEqualStrings("p0", fun.parameters[0]); } // 3 param { var pgm = try parseTest("function empty(p0,p1,p2){}"); defer pgm.deinit(); try expectEqual(@as(usize, 1), pgm.functions.len); try expectEqual(@as(usize, 0), pgm.root_script.len); const fun = pgm.functions[0]; try std.testing.expectEqualStrings("empty", fun.name); try expectEqual(ast.Statement.Type.block, fun.body.type); try expectEqual(@as(usize, 0), fun.body.type.block.len); try expectEqual(@as(usize, 3), fun.parameters.len); try std.testing.expectEqualStrings("p0", fun.parameters[0]); try std.testing.expectEqualStrings("p1", fun.parameters[1]); try std.testing.expectEqualStrings("p2", fun.parameters[2]); } } test "parse multiple top level statements" { // test with the simplest of all statements: // the empty one var pgm = try parseTest(";;;"); defer pgm.deinit(); try expectEqual(@as(usize, 0), pgm.functions.len); try expectEqual(@as(usize, 3), pgm.root_script.len); try expectEqual(ast.Statement.Type.empty, pgm.root_script[0].type); try expectEqual(ast.Statement.Type.empty, pgm.root_script[1].type); try expectEqual(ast.Statement.Type.empty, pgm.root_script[2].type); } test "parse mixed function and top level statement" { var pgm = try parseTest(";function n(){};"); defer pgm.deinit(); try expectEqual(@as(usize, 1), pgm.functions.len); try expectEqual(@as(usize, 2), pgm.root_script.len); try expectEqual(ast.Statement.Type.empty, pgm.root_script[0].type); try expectEqual(ast.Statement.Type.empty, pgm.root_script[1].type); const fun = pgm.functions[0]; try std.testing.expectEqualStrings("n", fun.name); try expectEqual(ast.Statement.Type.block, fun.body.type); try expectEqual(@as(usize, 0), fun.body.type.block.len); try expectEqual(@as(usize, 0), fun.parameters.len); } test "nested blocks" { var pgm = try parseTest( \\{ } \\{ \\ { ; } \\ { ; ; } \\ ; \\} \\{ } ); defer pgm.deinit(); try expectEqual(@as(usize, 0), pgm.functions.len); try expectEqual(@as(usize, 3), pgm.root_script.len); try expectEqual(ast.Statement.Type.block, pgm.root_script[0].type); try expectEqual(ast.Statement.Type.block, pgm.root_script[1].type); try expectEqual(ast.Statement.Type.block, pgm.root_script[2].type); try expectEqual(@as(usize, 0), pgm.root_script[0].type.block.len); try expectEqual(@as(usize, 3), pgm.root_script[1].type.block.len); try expectEqual(@as(usize, 0), pgm.root_script[2].type.block.len); try expectEqual(ast.Statement.Type.block, pgm.root_script[1].type.block[0].type); try expectEqual(ast.Statement.Type.block, pgm.root_script[1].type.block[1].type); try expectEqual(ast.Statement.Type.empty, pgm.root_script[1].type.block[2].type); try expectEqual(@as(usize, 1), pgm.root_script[1].type.block[0].type.block.len); try expectEqual(@as(usize, 2), pgm.root_script[1].type.block[1].type.block.len); try expectEqual(ast.Statement.Type.empty, pgm.root_script[1].type.block[1].type.block[0].type); try expectEqual(ast.Statement.Type.empty, pgm.root_script[1].type.block[1].type.block[0].type); } test "nested blocks in functions" { var pgm = try parseTest( \\function foo() { \\ { } \\ { \\ { ; } \\ { ; ; } \\ ; \\ } \\ { } \\} ); defer pgm.deinit(); try expectEqual(@as(usize, 1), pgm.functions.len); try expectEqual(@as(usize, 0), pgm.root_script.len); const fun = pgm.functions[0]; try expectEqual(ast.Statement.Type.block, fun.body.type); const items = fun.body.type.block; try expectEqual(ast.Statement.Type.block, items[0].type); try expectEqual(ast.Statement.Type.block, items[1].type); try expectEqual(ast.Statement.Type.block, items[2].type); try expectEqual(@as(usize, 0), items[0].type.block.len); try expectEqual(@as(usize, 3), items[1].type.block.len); try expectEqual(@as(usize, 0), items[2].type.block.len); try expectEqual(ast.Statement.Type.block, items[1].type.block[0].type); try expectEqual(ast.Statement.Type.block, items[1].type.block[1].type); try expectEqual(ast.Statement.Type.empty, items[1].type.block[2].type); try expectEqual(@as(usize, 1), items[1].type.block[0].type.block.len); try expectEqual(@as(usize, 2), items[1].type.block[1].type.block.len); try expectEqual(ast.Statement.Type.empty, items[1].type.block[1].type.block[0].type); try expectEqual(ast.Statement.Type.empty, items[1].type.block[1].type.block[0].type); } test "parsing break" { var pgm = try parseTest("break;"); defer pgm.deinit(); try expectEqual(@as(usize, 0), pgm.functions.len); try expectEqual(@as(usize, 1), pgm.root_script.len); try expectEqual(ast.Statement.Type.@"break", pgm.root_script[0].type); } test "parsing continue" { var pgm = try parseTest("continue;"); defer pgm.deinit(); try expectEqual(@as(usize, 0), pgm.functions.len); try expectEqual(@as(usize, 1), pgm.root_script.len); try expectEqual(ast.Statement.Type.@"continue", pgm.root_script[0].type); } test "parsing while" { var pgm = try parseTest("while(1) { }"); defer pgm.deinit(); try expectEqual(@as(usize, 0), pgm.functions.len); try expectEqual(@as(usize, 1), pgm.root_script.len); try expectEqual(ast.Statement.Type.while_loop, pgm.root_script[0].type); try expectEqual(ast.Statement.Type.block, pgm.root_script[0].type.while_loop.body.type); try expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.while_loop.condition.type); } test "parsing for" { var pgm = try parseTest("for(name in 1) { }"); defer pgm.deinit(); try expectEqual(@as(usize, 0), pgm.functions.len); try expectEqual(@as(usize, 1), pgm.root_script.len); try expectEqual(ast.Statement.Type.for_loop, pgm.root_script[0].type); try expectEqualStrings("name", pgm.root_script[0].type.for_loop.variable); try expectEqual(ast.Statement.Type.block, pgm.root_script[0].type.for_loop.body.type); try expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.for_loop.source.type); } test "parsing single if" { var pgm = try parseTest("if(1) { }"); defer pgm.deinit(); try expectEqual(@as(usize, 0), pgm.functions.len); try expectEqual(@as(usize, 1), pgm.root_script.len); try expectEqual(ast.Statement.Type.if_statement, pgm.root_script[0].type); try expectEqual(ast.Statement.Type.block, pgm.root_script[0].type.if_statement.true_body.type); try expectEqual(@as(?*ast.Statement, null), pgm.root_script[0].type.if_statement.false_body); try expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.if_statement.condition.type); } test "parsing if-else" { var pgm = try parseTest("if(1) { } else ;"); defer pgm.deinit(); try expectEqual(@as(usize, 0), pgm.functions.len); try expectEqual(@as(usize, 1), pgm.root_script.len); try expectEqual(ast.Statement.Type.if_statement, pgm.root_script[0].type); try expectEqual(ast.Statement.Type.block, pgm.root_script[0].type.if_statement.true_body.type); try expectEqual(ast.Statement.Type.empty, pgm.root_script[0].type.if_statement.false_body.?.type); try expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.if_statement.condition.type); } test "parsing return (void)" { var pgm = try parseTest("return;"); defer pgm.deinit(); try expectEqual(@as(usize, 0), pgm.functions.len); try expectEqual(@as(usize, 1), pgm.root_script.len); try expectEqual(ast.Statement.Type.return_void, pgm.root_script[0].type); } test "parsing return (value)" { var pgm = try parseTest("return 1;"); defer pgm.deinit(); try expectEqual(@as(usize, 0), pgm.functions.len); try expectEqual(@as(usize, 1), pgm.root_script.len); try expectEqual(ast.Statement.Type.return_expr, pgm.root_script[0].type); try expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.return_expr.type); } test "parsing var declaration (no value)" { var pgm = try parseTest("var name;"); defer pgm.deinit(); try expectEqual(@as(usize, 0), pgm.functions.len); try expectEqual(@as(usize, 1), pgm.root_script.len); try expectEqual(ast.Statement.Type.declaration, pgm.root_script[0].type); try expectEqualStrings("name", pgm.root_script[0].type.declaration.variable); try expectEqual(false, pgm.root_script[0].type.declaration.is_const); try expectEqual(@as(?ast.Expression, null), pgm.root_script[0].type.declaration.initial_value); } test "parsing var declaration (initial value)" { var pgm = try parseTest("var name = 1;"); defer pgm.deinit(); try expectEqual(@as(usize, 0), pgm.functions.len); try expectEqual(@as(usize, 1), pgm.root_script.len); try expectEqual(ast.Statement.Type.declaration, pgm.root_script[0].type); try expectEqualStrings("name", pgm.root_script[0].type.declaration.variable); try expectEqual(false, pgm.root_script[0].type.declaration.is_const); try expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.declaration.initial_value.?.type); } test "parsing const declaration (no value)" { var pgm = try parseTest("const name;"); defer pgm.deinit(); try expectEqual(@as(usize, 0), pgm.functions.len); try expectEqual(@as(usize, 1), pgm.root_script.len); try expectEqual(ast.Statement.Type.declaration, pgm.root_script[0].type); try expectEqualStrings("name", pgm.root_script[0].type.declaration.variable); try expectEqual(true, pgm.root_script[0].type.declaration.is_const); try expectEqual(@as(?ast.Expression, null), pgm.root_script[0].type.declaration.initial_value); } test "parsing const declaration (initial value)" { var pgm = try parseTest("const name = 1;"); defer pgm.deinit(); try expectEqual(@as(usize, 0), pgm.functions.len); try expectEqual(@as(usize, 1), pgm.root_script.len); try expectEqual(ast.Statement.Type.declaration, pgm.root_script[0].type); try expectEqualStrings("name", pgm.root_script[0].type.declaration.variable); try expectEqual(true, pgm.root_script[0].type.declaration.is_const); try expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.declaration.initial_value.?.type); } test "parsing assignment" { var pgm = try parseTest("1 = 1;"); defer pgm.deinit(); try expectEqual(@as(usize, 0), pgm.functions.len); try expectEqual(@as(usize, 1), pgm.root_script.len); try expectEqual(ast.Statement.Type.assignment, pgm.root_script[0].type); try expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.assignment.target.type); try expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.assignment.value.type); } test "parsing operator-assignment addition" { var pgm = try parseTest("1 += 1;"); defer pgm.deinit(); try expectEqual(@as(usize, 0), pgm.functions.len); try expectEqual(@as(usize, 1), pgm.root_script.len); try expectEqual(ast.Statement.Type.assignment, pgm.root_script[0].type); try expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.assignment.target.type); try expectEqual(ast.Expression.Type.binary_operator, pgm.root_script[0].type.assignment.value.type); try expectEqual(ast.BinaryOperator.add, pgm.root_script[0].type.assignment.value.type.binary_operator.operator); } test "parsing operator-assignment subtraction" { var pgm = try parseTest("1 -= 1;"); defer pgm.deinit(); try expectEqual(@as(usize, 0), pgm.functions.len); try expectEqual(@as(usize, 1), pgm.root_script.len); try expectEqual(ast.Statement.Type.assignment, pgm.root_script[0].type); try expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.assignment.target.type); try expectEqual(ast.Expression.Type.binary_operator, pgm.root_script[0].type.assignment.value.type); try expectEqual(ast.BinaryOperator.subtract, pgm.root_script[0].type.assignment.value.type.binary_operator.operator); } test "parsing operator-assignment multiplication" { var pgm = try parseTest("1 *= 1;"); defer pgm.deinit(); try expectEqual(@as(usize, 0), pgm.functions.len); try expectEqual(@as(usize, 1), pgm.root_script.len); try expectEqual(ast.Statement.Type.assignment, pgm.root_script[0].type); try expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.assignment.target.type); try expectEqual(ast.Expression.Type.binary_operator, pgm.root_script[0].type.assignment.value.type); try expectEqual(ast.BinaryOperator.multiply, pgm.root_script[0].type.assignment.value.type.binary_operator.operator); } test "parsing operator-assignment division" { var pgm = try parseTest("1 /= 1;"); defer pgm.deinit(); try expectEqual(@as(usize, 0), pgm.functions.len); try expectEqual(@as(usize, 1), pgm.root_script.len); try expectEqual(ast.Statement.Type.assignment, pgm.root_script[0].type); try expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.assignment.target.type); try expectEqual(ast.Expression.Type.binary_operator, pgm.root_script[0].type.assignment.value.type); try expectEqual(ast.BinaryOperator.divide, pgm.root_script[0].type.assignment.value.type.binary_operator.operator); } test "parsing operator-assignment modulus" { var pgm = try parseTest("1 %= 1;"); defer pgm.deinit(); try expectEqual(@as(usize, 0), pgm.functions.len); try expectEqual(@as(usize, 1), pgm.root_script.len); try expectEqual(ast.Statement.Type.assignment, pgm.root_script[0].type); try expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.assignment.target.type); try expectEqual(ast.Expression.Type.binary_operator, pgm.root_script[0].type.assignment.value.type); try expectEqual(ast.BinaryOperator.modulus, pgm.root_script[0].type.assignment.value.type.binary_operator.operator); } /// Parse a program with `1 = $(EXPR)`, will return `$(EXPR)` fn getTestExpr(pgm: ast.Program) !ast.Expression { try expectEqual(@as(usize, 0), pgm.functions.len); try expectEqual(@as(usize, 1), pgm.root_script.len); try expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.assignment.target.type); const expr = pgm.root_script[0].type.assignment.value; return expr; } test "integer literal" { var pgm = try parseTest("1 = 1;"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.number_literal, expr.type); try std.testing.expectApproxEqAbs(@as(f64, 1), expr.type.number_literal, 0.000001); } test "decimal literal" { var pgm = try parseTest("1 = 1.0;"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.number_literal, expr.type); try std.testing.expectApproxEqAbs(@as(f64, 1), expr.type.number_literal, 0.000001); } test "hexadecimal literal" { var pgm = try parseTest("1 = 0x1;"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.number_literal, expr.type); try std.testing.expectApproxEqAbs(@as(f64, 1), expr.type.number_literal, 0.000001); } test "string literal" { var pgm = try parseTest("1 = \"string content\";"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.string_literal, expr.type); try expectEqualStrings("string content", expr.type.string_literal); } test "escaped string literal" { var pgm = try parseTest("1 = \"\\\"content\\\"\";"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.string_literal, expr.type); try expectEqualStrings("\"content\"", expr.type.string_literal); } test "character literal" { var pgm = try parseTest("1 = ' ';"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.number_literal, expr.type); try expectEqual(@as(f64, ' '), expr.type.number_literal); } test "variable reference" { var pgm = try parseTest("1 = variable_name;"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.variable_expr, expr.type); try expectEqualStrings("variable_name", expr.type.variable_expr); } test "addition expression" { var pgm = try parseTest("1 = 1 + 1;"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.binary_operator, expr.type); try expectEqual(ast.BinaryOperator.add, expr.type.binary_operator.operator); } test "subtraction expression" { var pgm = try parseTest("1 = 1 - 1;"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.binary_operator, expr.type); try expectEqual(ast.BinaryOperator.subtract, expr.type.binary_operator.operator); } test "multiplication expression" { var pgm = try parseTest("1 = 1 * 1;"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.binary_operator, expr.type); try expectEqual(ast.BinaryOperator.multiply, expr.type.binary_operator.operator); } test "division expression" { var pgm = try parseTest("1 = 1 / 1;"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.binary_operator, expr.type); try expectEqual(ast.BinaryOperator.divide, expr.type.binary_operator.operator); } test "modulus expression" { var pgm = try parseTest("1 = 1 % 1;"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.binary_operator, expr.type); try expectEqual(ast.BinaryOperator.modulus, expr.type.binary_operator.operator); } test "boolean or expression" { var pgm = try parseTest("1 = 1 or 1;"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.binary_operator, expr.type); try expectEqual(ast.BinaryOperator.boolean_or, expr.type.binary_operator.operator); } test "boolean and expression" { var pgm = try parseTest("1 = 1 and 1;"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.binary_operator, expr.type); try expectEqual(ast.BinaryOperator.boolean_and, expr.type.binary_operator.operator); } test "greater than expression" { var pgm = try parseTest("1 = 1 > 1;"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.binary_operator, expr.type); try expectEqual(ast.BinaryOperator.greater_than, expr.type.binary_operator.operator); } test "less than expression" { var pgm = try parseTest("1 = 1 < 1;"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.binary_operator, expr.type); try expectEqual(ast.BinaryOperator.less_than, expr.type.binary_operator.operator); } test "greater or equal than expression" { var pgm = try parseTest("1 = 1 >= 1;"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.binary_operator, expr.type); try expectEqual(ast.BinaryOperator.greater_or_equal_than, expr.type.binary_operator.operator); } test "less or equal than expression" { var pgm = try parseTest("1 = 1 <= 1;"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.binary_operator, expr.type); try expectEqual(ast.BinaryOperator.less_or_equal_than, expr.type.binary_operator.operator); } test "equal expression" { var pgm = try parseTest("1 = 1 == 1;"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.binary_operator, expr.type); try expectEqual(ast.BinaryOperator.equal, expr.type.binary_operator.operator); } test "different expression" { var pgm = try parseTest("1 = 1 != 1;"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.binary_operator, expr.type); try expectEqual(ast.BinaryOperator.different, expr.type.binary_operator.operator); } test "operator precedence (binaries)" { var pgm = try parseTest("1 = 1 + 1 * 1;"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.binary_operator, expr.type); try expectEqual(ast.BinaryOperator.add, expr.type.binary_operator.operator); try expectEqual(ast.Expression.Type.binary_operator, expr.type.binary_operator.rhs.type); try expectEqual(ast.BinaryOperator.multiply, expr.type.binary_operator.rhs.type.binary_operator.operator); } test "operator precedence (unary and binary mixed)" { var pgm = try parseTest("1 = -1 * 1;"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.binary_operator, expr.type); try expectEqual(ast.BinaryOperator.multiply, expr.type.binary_operator.operator); try expectEqual(ast.Expression.Type.unary_operator, expr.type.binary_operator.lhs.type); try expectEqual(ast.UnaryOperator.negate, expr.type.binary_operator.lhs.type.unary_operator.operator); } test "invers operator precedence with parens" { var pgm = try parseTest("1 = 1 * (1 + 1);"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.binary_operator, expr.type); try expectEqual(ast.BinaryOperator.multiply, expr.type.binary_operator.operator); try expectEqual(ast.Expression.Type.binary_operator, expr.type.binary_operator.rhs.type); try expectEqual(ast.BinaryOperator.add, expr.type.binary_operator.rhs.type.binary_operator.operator); } test "unary minus expression" { var pgm = try parseTest("1 = -1;"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.unary_operator, expr.type); try expectEqual(ast.UnaryOperator.negate, expr.type.unary_operator.operator); } test "unary not expression" { var pgm = try parseTest("1 = not 1;"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.unary_operator, expr.type); try expectEqual(ast.UnaryOperator.boolean_not, expr.type.unary_operator.operator); } test "single array indexing expression" { var pgm = try parseTest("1 = 1[\"\"];"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.array_indexer, expr.type); try expectEqual(ast.Expression.Type.number_literal, expr.type.array_indexer.value.type); try expectEqual(ast.Expression.Type.string_literal, expr.type.array_indexer.index.type); } test "multiple array indexing expressions" { var pgm = try parseTest("1 = a[b][c];"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.array_indexer, expr.type); try expectEqual(ast.Expression.Type.array_indexer, expr.type.array_indexer.value.type); try expectEqual(ast.Expression.Type.variable_expr, expr.type.array_indexer.index.type); try expectEqualStrings("c", expr.type.array_indexer.index.type.variable_expr); try expectEqual(ast.Expression.Type.variable_expr, expr.type.array_indexer.value.type.array_indexer.value.type); try expectEqual(ast.Expression.Type.variable_expr, expr.type.array_indexer.value.type.array_indexer.index.type); try expectEqualStrings("a", expr.type.array_indexer.value.type.array_indexer.value.type.variable_expr); try expectEqualStrings("b", expr.type.array_indexer.value.type.array_indexer.index.type.variable_expr); } test "zero parameter function call expression" { var pgm = try parseTest("1 = foo();"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.function_call, expr.type); try expectEqual(ast.Expression.Type.variable_expr, expr.type.function_call.function.type); try expectEqual(@as(usize, 0), expr.type.function_call.arguments.len); } test "one parameter function call expression" { var pgm = try parseTest("1 = foo(a);"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.function_call, expr.type); try expectEqual(ast.Expression.Type.variable_expr, expr.type.function_call.function.type); try expectEqual(@as(usize, 1), expr.type.function_call.arguments.len); try expectEqualStrings("a", expr.type.function_call.arguments[0].type.variable_expr); } test "4 parameter function call expression" { var pgm = try parseTest("1 = foo(a,b,c,d);"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.function_call, expr.type); try expectEqual(ast.Expression.Type.variable_expr, expr.type.function_call.function.type); try expectEqual(@as(usize, 4), expr.type.function_call.arguments.len); try expectEqualStrings("a", expr.type.function_call.arguments[0].type.variable_expr); try expectEqualStrings("b", expr.type.function_call.arguments[1].type.variable_expr); try expectEqualStrings("c", expr.type.function_call.arguments[2].type.variable_expr); try expectEqualStrings("d", expr.type.function_call.arguments[3].type.variable_expr); } test "zero parameter method call expression" { var pgm = try parseTest("1 = a.foo();"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.method_call, expr.type); try expectEqualStrings("foo", expr.type.method_call.name); try expectEqual(ast.Expression.Type.variable_expr, expr.type.method_call.object.type); try expectEqual(@as(usize, 0), expr.type.method_call.arguments.len); } test "one parameter method call expression" { var pgm = try parseTest("1 = a.foo(a);"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.method_call, expr.type); try expectEqualStrings("foo", expr.type.method_call.name); try expectEqual(ast.Expression.Type.variable_expr, expr.type.method_call.object.type); try expectEqual(@as(usize, 1), expr.type.method_call.arguments.len); try expectEqualStrings("a", expr.type.method_call.arguments[0].type.variable_expr); } test "4 parameter method call expression" { var pgm = try parseTest("1 = a.foo(a,b,c,d);"); defer pgm.deinit(); const expr = try getTestExpr(pgm); try expectEqual(ast.Expression.Type.method_call, expr.type); try expectEqualStrings("foo", expr.type.method_call.name); try expectEqual(ast.Expression.Type.variable_expr, expr.type.method_call.object.type); try expectEqual(@as(usize, 4), expr.type.method_call.arguments.len); try expectEqualStrings("a", expr.type.method_call.arguments[0].type.variable_expr); try expectEqualStrings("b", expr.type.method_call.arguments[1].type.variable_expr); try expectEqualStrings("c", expr.type.method_call.arguments[2].type.variable_expr); try expectEqualStrings("d", expr.type.method_call.arguments[3].type.variable_expr); } test "full suite parsing" { const seq = try testTokenize(@embedFile("../../test/compiler.lola")); defer std.testing.allocator.free(seq); var diagnostics = diag.Diagnostics.init(std.testing.allocator); defer diagnostics.deinit(); var pgm = try parse(std.testing.allocator, &diagnostics, seq); defer pgm.deinit(); for (diagnostics.messages.items) |msg| { std.log.err("{}", .{msg}); } // assert that we don't have an empty AST try std.testing.expect(pgm.root_script.len > 0); try std.testing.expect(pgm.functions.len > 0); // assert that we didn't encounter syntax errors try expectEqual(@as(usize, 0), diagnostics.messages.items.len); }
0
repos/LoLa/src/library
repos/LoLa/src/library/compiler/code-writer.zig
const std = @import("std"); const Instruction = @import("../common/ir.zig").Instruction; const InstructionName = @import("../common/ir.zig").InstructionName; /// A handle to a location in source code. /// This handle is created by a `CodeWriter` and only that code writer /// knows where this label is located in memory (or if it is yet to be defined). pub const Label = enum(u32) { _ }; /// A append-only data structure that allows emission of data and instructions to create /// LoLa byte code. pub const CodeWriter = struct { const Self = @This(); const Loop = struct { breakLabel: Label, continueLabel: Label }; const Patch = struct { label: Label, offset: u32 }; /// The bytecode that was already emitted. code: std.ArrayList(u8), /// Used as a stack of loops. Each loop has a break position and a continue position, /// which can be emitted by calling emitBreak or emitContinue. This allows nesting loops /// and emitting the right loop targets without passing the context around in code generation. loops: std.ArrayList(Loop), /// Stores a list of forward references for labels. This is required /// when a call to `emitLabel` happens before `defineLabel` is called. /// This list is empty when all emitted label references are well-defined. patches: std.ArrayList(Patch), /// Stores the offset for every defined label. labels: std.AutoHashMap(Label, u32), next_label: u32 = 0, pub fn init(allocator: std.mem.Allocator) Self { return Self{ .code = std.ArrayList(u8).init(allocator), .loops = std.ArrayList(Loop).init(allocator), .patches = std.ArrayList(Patch).init(allocator), .labels = std.AutoHashMap(Label, u32).init(allocator), }; } pub fn deinit(self: *Self) void { self.code.deinit(); self.loops.deinit(); self.patches.deinit(); self.labels.deinit(); self.* = undefined; } /// Finalizes the code generation process and returns the generated code. /// The returned memory is owned by the caller and was allocated with the allocator passed into `init`. pub fn finalize(self: *Self) ![]u8 { if (self.loops.items.len != 0) return error.InvalidCode; if (self.patches.items.len != 0) return error.InvalidCode; self.loops.shrinkAndFree(0); self.patches.shrinkAndFree(0); self.labels.clearAndFree(); return self.code.toOwnedSlice(); } /// Creates a new label identifier. This only returns a new handle, it does /// not emit any code or modify data structures. pub fn createLabel(self: *Self) !Label { if (self.next_label == std.math.maxInt(u32)) return error.TooManyLabels; const id = @as(Label, @enumFromInt(self.next_label)); self.next_label += 1; return id; } /// Defines the location a label references. This must be called exactly once for a label. /// Calling it more than once is a error, the same as calling it never. /// Defining a label will patch all forward references in the `code`, removing the need to /// store patches for later. pub fn defineLabel(self: *Self, lbl: Label) !void { const item = try self.labels.getOrPut(lbl); if (item.found_existing) return error.LabelAlreadyDefined; item.value_ptr.* = @as(u32, @intCast(self.code.items.len)); // resolve all forward references to this label, so we // have a empty patch list when every referenced label was also defined. var i: usize = 0; while (i < self.patches.items.len) { const patch = self.patches.items[i]; if (patch.label == lbl) { std.mem.writeInt(u32, self.code.items[patch.offset..][0..4], item.value_ptr.*, .little); _ = self.patches.swapRemove(i); } else { i += 1; } } } /// Combination of createLabel and defineLabel, is provided as a convenience function. pub fn createAndDefineLabel(self: *Self) !Label { const lbl = try self.createLabel(); try self.defineLabel(lbl); return lbl; } /// Pushes a new loop construct. /// `breakLabel` is a label that is jumped to when a `break` instruction is emitted. This is usually the end of the loop. /// `continueLabel` is a label that is jumped to when a `continue` instruction is emitted. This is usually the start of the loop. pub fn pushLoop(self: *Self, breakLabel: Label, continueLabel: Label) !void { try self.loops.append(Loop{ .breakLabel = breakLabel, .continueLabel = continueLabel, }); } /// Pops a loop from the stack. pub fn popLoop(self: *Self) void { std.debug.assert(self.loops.items.len > 0); _ = self.loops.pop(); } /// emits raw data pub fn emitRaw(self: *Self, data: []const u8) !void { if (self.code.items.len + data.len > std.math.maxInt(u32)) return error.OutOfMemory; try self.code.writer().writeAll(data); } /// Emits a label and marks a patch position if necessary pub fn emitLabel(self: *Self, label: Label) !void { if (self.labels.get(label)) |offset| { try self.emitU32(offset); } else { try self.patches.append(Patch{ .label = label, .offset = @as(u32, @intCast(self.code.items.len)), }); try self.emitU32(0xFFFFFFFF); } } /// Emits a raw instruction name without the corresponding instruction arguments. pub fn emitInstructionName(self: *Self, name: InstructionName) !void { try self.emitU8(@intFromEnum(name)); } pub fn emitInstruction(self: *Self, instr: Instruction) !void { try self.emitInstructionName(instr); inline for (std.meta.fields(Instruction)) |fld| { if (instr == @field(InstructionName, fld.name)) { const value = @field(instr, fld.name); if (fld.type == Instruction.Deprecated) { @panic("called emitInstruction with a deprecated instruction!"); // this is a API violation } else if (fld.type == Instruction.NoArg) { // It's enough to emit the instruction name return; } else if (fld.type == Instruction.CallArg) { try self.emitString(value.function); try self.emitU8(value.argc); return; } else { const ValType = std.meta.fieldInfo(fld.type, .value).type; switch (ValType) { []const u8 => try self.emitString(value.value), u8 => try self.emitU8(value.value), u16 => try self.emitU16(value.value), u32 => try self.emitU32(value.value), f64 => try self.emitNumber(value.value), else => @compileError("Unsupported encoding: " ++ @typeName(ValType)), } return; } } } unreachable; } fn emitNumber(self: *Self, val: f64) !void { try self.emitRaw(std.mem.asBytes(&val)); } /// Encodes a variable-length string with a max. length of 0 … 65535 characters. pub fn emitString(self: *Self, val: []const u8) !void { try self.emitU16(std.math.cast(u16, val.len) orelse return error.Overflow); try self.emitRaw(val); } fn emitInteger(self: *Self, comptime T: type, val: T) !void { var buf: [@sizeOf(T)]u8 = undefined; std.mem.writeInt(T, &buf, val, .little); try self.emitRaw(&buf); } /// Emits a unsigned 32 bit integer, encoded little endian. pub fn emitU8(self: *Self, val: u8) !void { try self.emitInteger(u8, val); } /// Emits a unsigned 32 bit integer, encoded little endian. pub fn emitU16(self: *Self, val: u16) !void { try self.emitInteger(u16, val); } /// Emits a unsigned 32 bit integer, encoded little endian. pub fn emitU32(self: *Self, val: u32) !void { try self.emitInteger(u32, val); } pub fn emitBreak(self: *Self) !void { if (self.loops.items.len > 0) { const loop = self.loops.items[self.loops.items.len - 1]; try self.emitInstructionName(.jmp); try self.emitLabel(loop.breakLabel); } else { return error.NotInLoop; } } pub fn emitContinue(self: *Self) !void { if (self.loops.items.len > 0) { const loop = self.loops.items[self.loops.items.len - 1]; try self.emitInstructionName(.jmp); try self.emitLabel(loop.continueLabel); } else { return error.NotInLoop; } } }; test "empty code generation" { var writer = CodeWriter.init(std.testing.allocator); defer writer.deinit(); const mem = try writer.finalize(); defer std.testing.allocator.free(mem); try std.testing.expectEqualSlices(u8, "", mem); } test "emitting primitive values" { var writer = CodeWriter.init(std.testing.allocator); defer writer.deinit(); try writer.emitU32(0x44332211); try writer.emitU16(0x6655); try writer.emitU8(0x77); try writer.emitInstructionName(.jmp); const mem = try writer.finalize(); defer std.testing.allocator.free(mem); try std.testing.expectEqualSlices(u8, "\x11\x22\x33\x44\x55\x66\x77\x1B", mem); } test "emitting variable-width strings" { var writer = CodeWriter.init(std.testing.allocator); defer writer.deinit(); try writer.emitString("Hello"); const mem = try writer.finalize(); defer std.testing.allocator.free(mem); try std.testing.expectEqualSlices(u8, "\x05\x00Hello", mem); } test "label handling" { var writer = CodeWriter.init(std.testing.allocator); defer writer.deinit(); const label = try writer.createLabel(); try writer.emitLabel(label); // tests the patch path try writer.defineLabel(label); // tests label insertion try writer.emitLabel(label); // tests the fast-forward path const mem = try writer.finalize(); defer std.testing.allocator.free(mem); try std.testing.expectEqualSlices(u8, "\x04\x00\x00\x00\x04\x00\x00\x00", mem); } test "label creation" { var writer = CodeWriter.init(std.testing.allocator); defer writer.deinit(); const label1 = try writer.createLabel(); const label2 = try writer.createLabel(); const label3 = try writer.createLabel(); try std.testing.expect(label1 != label2); try std.testing.expect(label1 != label3); try std.testing.expect(label2 != label3); } test "loop creation, break and continue emission" { var writer = CodeWriter.init(std.testing.allocator); defer writer.deinit(); const label_start = try writer.createLabel(); const label_end = try writer.createLabel(); try std.testing.expectError(error.NotInLoop, writer.emitBreak()); try std.testing.expectError(error.NotInLoop, writer.emitContinue()); try writer.emitRaw("A"); try writer.pushLoop(label_end, label_start); try writer.emitRaw("B"); try writer.defineLabel(label_start); try writer.emitRaw("C"); try writer.emitBreak(); try writer.emitRaw("D"); try writer.emitContinue(); try writer.emitRaw("E"); try writer.defineLabel(label_end); try writer.emitRaw("F"); writer.popLoop(); try std.testing.expectError(error.NotInLoop, writer.emitBreak()); try std.testing.expectError(error.NotInLoop, writer.emitContinue()); const mem = try writer.finalize(); defer std.testing.allocator.free(mem); try std.testing.expectEqualSlices(u8, "ABC\x1B\x0F\x00\x00\x00D\x1B\x02\x00\x00\x00EF", mem); } test "emitting numeric value" { var writer = CodeWriter.init(std.testing.allocator); defer writer.deinit(); try writer.emitNumber(0.0); const mem = try writer.finalize(); defer std.testing.allocator.free(mem); try std.testing.expectEqualSlices(u8, "\x00\x00\x00\x00\x00\x00\x00\x00", mem); } test "instruction emission" { var writer = CodeWriter.init(std.testing.allocator); defer writer.deinit(); // tests a NoArg instruction try writer.emitInstruction(Instruction{ .push_void = .{}, }); // tests a SingleArg([]const u8) instruction try writer.emitInstruction(Instruction{ .push_str = .{ .value = "abc" }, }); // tests a SingleArg(f64) instruction try writer.emitInstruction(Instruction{ .push_num = .{ .value = 0.0000 }, }); // tests a SingleArg(u32) instruction try writer.emitInstruction(Instruction{ .jmp = .{ .value = 0x44332211 }, }); // tests a SingleArg(u16) instruction try writer.emitInstruction(Instruction{ .store_local = .{ .value = 0xBEEF }, }); const mem = try writer.finalize(); defer std.testing.allocator.free(mem); try std.testing.expectEqualSlices( u8, "\x2B" ++ "\x06\x03\x00abc" ++ "\x07\x00\x00\x00\x00\x00\x00\x00\x00" ++ "\x1B\x11\x22\x33\x44" ++ "\x22\xEF\xBE", mem, ); }
0
repos/LoLa/src/library
repos/LoLa/src/library/compiler/codegen.zig
const std = @import("std"); const ast = @import("ast.zig"); const Location = @import("location.zig").Location; const Scope = @import("scope.zig").Scope; const Diagnostics = @import("diagnostics.zig").Diagnostics; const CompileUnit = @import("../common/CompileUnit.zig"); const CodeWriter = @import("code-writer.zig").CodeWriter; const Instruction = @import("../common/ir.zig").Instruction; const CodeGenError = error{ OutOfMemory, AlreadyDeclared, TooManyVariables, TooManyLabels, LabelAlreadyDefined, Overflow, NotInLoop, VariableNotFound, InvalidStoreTarget, }; /// Helper structure to emit debug symbols const DebugSyms = struct { const Self = @This(); writer: *CodeWriter, symbols: std.ArrayList(CompileUnit.DebugSymbol), fn push(self: *Self, location: Location) !void { try self.symbols.append(CompileUnit.DebugSymbol{ .offset = @as(u32, @intCast(self.writer.code.items.len)), .sourceLine = location.line, .sourceColumn = @as(u16, @intCast(location.column)), }); } }; fn emitStore(debug_symbols: *DebugSyms, scope: *Scope, writer: *CodeWriter, expression: ast.Expression) CodeGenError!void { try debug_symbols.push(expression.location); std.debug.assert(expression.isAssignable()); switch (expression.type) { .array_indexer => |indexer| { try emitExpression(debug_symbols, scope, writer, indexer.index.*); // load the index on the stack try emitExpression(debug_symbols, scope, writer, indexer.value.*); // load the array on the stack try writer.emitInstructionName(.array_store); try emitStore(debug_symbols, scope, writer, indexer.value.*); // now store back the value on the stack }, .variable_expr => |variable_name| { if (std.mem.eql(u8, variable_name, "true")) { return error.InvalidStoreTarget; } else if (std.mem.eql(u8, variable_name, "false")) { return error.InvalidStoreTarget; } else if (std.mem.eql(u8, variable_name, "void")) { return error.InvalidStoreTarget; } else { const v = scope.get(variable_name) orelse return error.VariableNotFound; switch (v.type) { .global => try writer.emitInstruction(Instruction{ .store_global_idx = .{ .value = v.storage_slot }, }), .local => try writer.emitInstruction(Instruction{ .store_local = .{ .value = v.storage_slot }, }), } } }, else => unreachable, } } fn emitExpression(debug_symbols: *DebugSyms, scope: *Scope, writer: *CodeWriter, expression: ast.Expression) CodeGenError!void { try debug_symbols.push(expression.location); switch (expression.type) { .array_indexer => |indexer| { try emitExpression(debug_symbols, scope, writer, indexer.index.*); try emitExpression(debug_symbols, scope, writer, indexer.value.*); try writer.emitInstructionName(.array_load); }, .variable_expr => |variable_name| { if (std.mem.eql(u8, variable_name, "true")) { try writer.emitInstruction(Instruction{ .push_true = .{}, }); } else if (std.mem.eql(u8, variable_name, "false")) { try writer.emitInstruction(Instruction{ .push_false = .{}, }); } else if (std.mem.eql(u8, variable_name, "void")) { try writer.emitInstruction(Instruction{ .push_void = .{}, }); } else { const v = scope.get(variable_name) orelse return error.VariableNotFound; switch (v.type) { .global => try writer.emitInstruction(Instruction{ .load_global_idx = .{ .value = v.storage_slot }, }), .local => try writer.emitInstruction(Instruction{ .load_local = .{ .value = v.storage_slot }, }), } } }, .array_literal => |array| { var i: usize = array.len; while (i > 0) { i -= 1; try emitExpression(debug_symbols, scope, writer, array[i]); } try writer.emitInstruction(Instruction{ .array_pack = .{ .value = @as(u16, @intCast(array.len)) }, }); }, .function_call => |call| { var i: usize = call.arguments.len; while (i > 0) { i -= 1; try emitExpression(debug_symbols, scope, writer, call.arguments[i]); } try writer.emitInstruction(Instruction{ .call_fn = .{ .function = call.function.type.variable_expr, .argc = @as(u8, @intCast(call.arguments.len)), }, }); }, .method_call => |call| { // TODO: Write code in compiler.lola that covers this path. var i: usize = call.arguments.len; while (i > 0) { i -= 1; try emitExpression(debug_symbols, scope, writer, call.arguments[i]); } try emitExpression(debug_symbols, scope, writer, call.object.*); try writer.emitInstruction(Instruction{ .call_obj = .{ .function = call.name, .argc = @as(u8, @intCast(call.arguments.len)), }, }); }, .number_literal => |literal| { try writer.emitInstruction(Instruction{ .push_num = .{ .value = literal }, }); }, .string_literal => |literal| { try writer.emitInstruction(Instruction{ .push_str = .{ .value = literal }, }); }, .unary_operator => |expr| { try emitExpression(debug_symbols, scope, writer, expr.value.*); try writer.emitInstructionName(switch (expr.operator) { .negate => .negate, .boolean_not => .bool_not, }); }, .binary_operator => |expr| { try emitExpression(debug_symbols, scope, writer, expr.lhs.*); try emitExpression(debug_symbols, scope, writer, expr.rhs.*); try writer.emitInstructionName(switch (expr.operator) { .add => .add, .subtract => .sub, .multiply => .mul, .divide => .div, .modulus => .mod, .boolean_or => .bool_or, .boolean_and => .bool_and, .less_than => .less, .greater_than => .greater, .greater_or_equal_than => .greater_eq, .less_or_equal_than => .less_eq, .equal => .eq, .different => .neq, }); }, } } fn emitStatement(debug_symbols: *DebugSyms, scope: *Scope, writer: *CodeWriter, stmt: ast.Statement) CodeGenError!void { try debug_symbols.push(stmt.location); switch (stmt.type) { .empty => { // trivial: do nothing! }, .assignment => |ass| { try emitExpression(debug_symbols, scope, writer, ass.value); try emitStore(debug_symbols, scope, writer, ass.target); }, .discard_value => |expr| { try emitExpression(debug_symbols, scope, writer, expr); try writer.emitInstruction(Instruction{ .pop = .{}, }); }, .return_void => { try writer.emitInstruction(Instruction{ .ret = .{}, }); }, .return_expr => |expr| { try emitExpression(debug_symbols, scope, writer, expr); try writer.emitInstruction(Instruction{ .retval = .{}, }); }, .while_loop => |loop| { const cont_lbl = try writer.createAndDefineLabel(); const break_lbl = try writer.createLabel(); try writer.pushLoop(break_lbl, cont_lbl); try emitExpression(debug_symbols, scope, writer, loop.condition); try writer.emitInstructionName(.jif); try writer.emitLabel(break_lbl); try emitStatement(debug_symbols, scope, writer, loop.body.*); try writer.emitInstructionName(.jmp); try writer.emitLabel(cont_lbl); try writer.defineLabel(break_lbl); writer.popLoop(); }, .for_loop => |loop| { try scope.enter(); try emitExpression(debug_symbols, scope, writer, loop.source); try writer.emitInstructionName(.iter_make); // Loop variable is a constant! try scope.declare(loop.variable, true); const loopvar = scope.get(loop.variable) orelse unreachable; std.debug.assert(loopvar.type == .local); const loop_start = try writer.createAndDefineLabel(); const loop_end = try writer.createLabel(); try writer.pushLoop(loop_end, loop_start); try writer.emitInstructionName(.iter_next); try writer.emitInstructionName(.jif); try writer.emitLabel(loop_end); try writer.emitInstruction(Instruction{ .store_local = .{ .value = loopvar.storage_slot, }, }); try emitStatement(debug_symbols, scope, writer, loop.body.*); try writer.emitInstructionName(.jmp); try writer.emitLabel(loop_start); try writer.defineLabel(loop_end); writer.popLoop(); // // erase the iterator from the stack try writer.emitInstructionName(.pop); try scope.leave(); }, .if_statement => |conditional| { const end_if = try writer.createLabel(); try emitExpression(debug_symbols, scope, writer, conditional.condition); if (conditional.false_body) |false_body| { const false_lbl = try writer.createLabel(); try writer.emitInstructionName(.jif); try writer.emitLabel(false_lbl); try emitStatement(debug_symbols, scope, writer, conditional.true_body.*); try writer.emitInstructionName(.jmp); try writer.emitLabel(end_if); try writer.defineLabel(false_lbl); try emitStatement(debug_symbols, scope, writer, false_body.*); } else { try writer.emitInstructionName(.jif); try writer.emitLabel(end_if); try emitStatement(debug_symbols, scope, writer, conditional.true_body.*); } try writer.defineLabel(end_if); }, .declaration => |decl| { try scope.declare(decl.variable, decl.is_const); if (decl.initial_value) |value| { try emitExpression(debug_symbols, scope, writer, value); const v = scope.get(decl.variable) orelse unreachable; switch (v.type) { .local => try writer.emitInstruction(Instruction{ .store_local = .{ .value = v.storage_slot, }, }), .global => try writer.emitInstruction(Instruction{ .store_global_idx = .{ .value = v.storage_slot, }, }), } } }, .block => |blk| { try scope.enter(); for (blk) |s| { try emitStatement(debug_symbols, scope, writer, s); } try scope.leave(); }, .@"break" => { try writer.emitBreak(); }, .@"continue" => { try writer.emitContinue(); }, } } /// Generates code for a given program. The program is assumed to be sane and checked with /// code analysis already. pub fn generateIR( allocator: std.mem.Allocator, program: ast.Program, comment: []const u8, ) !CompileUnit { var arena = std.heap.ArenaAllocator.init(allocator); errdefer arena.deinit(); var writer = CodeWriter.init(allocator); defer writer.deinit(); var functions = std.ArrayList(CompileUnit.Function).init(allocator); defer functions.deinit(); var debug_symbols = DebugSyms{ .writer = &writer, .symbols = std.ArrayList(CompileUnit.DebugSymbol).init(allocator), }; defer debug_symbols.symbols.deinit(); var global_scope = Scope.init(allocator, null, true); defer global_scope.deinit(); for (program.root_script) |stmt| { try emitStatement(&debug_symbols, &global_scope, &writer, stmt); } // each script ends with a return try writer.emitInstruction(Instruction{ .ret = .{}, }); std.debug.assert(global_scope.return_point.items.len == 0); for (program.functions) |function| { const entry_point = @as(u32, @intCast(writer.code.items.len)); var local_scope = Scope.init(allocator, &global_scope, false); defer local_scope.deinit(); for (function.parameters) |param| { try local_scope.declare(param, true); } try emitStatement(&debug_symbols, &local_scope, &writer, function.body); // when no explicit return is given, we implicitly return void try writer.emitInstruction(Instruction{ .ret = .{}, }); try functions.append(CompileUnit.Function{ .name = try arena.allocator().dupe(u8, function.name), .entryPoint = entry_point, .localCount = @as(u16, @intCast(local_scope.max_locals)), }); } const code = try writer.finalize(); defer allocator.free(code); std.sort.block(CompileUnit.DebugSymbol, debug_symbols.symbols.items, {}, struct { fn lessThan(v: void, lhs: CompileUnit.DebugSymbol, rhs: CompileUnit.DebugSymbol) bool { _ = v; return lhs.offset < rhs.offset; } }.lessThan); var cu = CompileUnit{ .comment = try arena.allocator().dupe(u8, comment), .globalCount = @as(u16, @intCast(global_scope.global_variables.items.len)), .temporaryCount = @as(u16, @intCast(global_scope.max_locals)), .code = try arena.allocator().dupe(u8, code), .functions = try arena.allocator().dupe(CompileUnit.Function, functions.items), .debugSymbols = try arena.allocator().dupe(CompileUnit.DebugSymbol, debug_symbols.symbols.items), .arena = undefined, }; // this prevents miscompilation of undefined evaluation order in init statement. // we need to use the arena for allocation above, so we change it. cu.arena = arena; return cu; } test "code generation" { // For lack of a better idea: // Just run the analysis against the compiler test suite var diagnostics = Diagnostics.init(std.testing.allocator); defer diagnostics.deinit(); const seq = try @import("tokenizer.zig").tokenize(std.testing.allocator, &diagnostics, "src/test/compiler.lola", @embedFile("compiler.lola")); defer std.testing.allocator.free(seq); var pgm = try @import("parser.zig").parse(std.testing.allocator, &diagnostics, seq); defer pgm.deinit(); var compile_unit = try generateIR(std.testing.allocator, pgm, "test unit"); defer compile_unit.deinit(); try std.testing.expectEqual(@as(usize, 0), diagnostics.messages.items.len); try std.testing.expectEqualStrings("test unit", compile_unit.comment); }
0
repos/LoLa/src/library
repos/LoLa/src/library/compiler/analysis.zig
const std = @import("std"); const ast = @import("ast.zig"); const Location = @import("location.zig").Location; const Scope = @import("scope.zig").Scope; const Diagnostics = @import("diagnostics.zig").Diagnostics; const Type = @import("typeset.zig").Type; const TypeSet = @import("typeset.zig").TypeSet; const AnalysisState = struct { /// Depth of nested loops (while, for) loop_nesting: usize, /// Depth of nested conditionally executed scopes (if, while, for) conditional_scope_depth: usize, /// Only `true` when not analyzing a function is_root_script: bool, }; const ValidationError = error{OutOfMemory}; const array_or_string = TypeSet.init(.{ .array, .string }); fn expressionTypeToString(src: ast.Expression.Type) []const u8 { return switch (src) { .array_indexer => "array indexer", .variable_expr => "variable", .array_literal => "array literal", .function_call => "function call", .method_call => "method call", .number_literal => "number literal", .string_literal => "string literal", .unary_operator => "unary operator application", .binary_operator => "binary operator application", }; } fn emitTooManyVariables(diagnostics: *Diagnostics, location: Location) !void { try diagnostics.emit(.@"error", location, "Too many variables declared! The maximum allowed number of variables is 35535.", .{}); } fn performTypeCheck(diagnostics: *Diagnostics, location: Location, expected: TypeSet, actual: TypeSet) !void { if (expected.intersection(actual).isEmpty()) { try diagnostics.emit(.warning, location, "Possible type mismatch detected: Expected {}, found {}", .{ expected, actual, }); } } /// Validates a expression and returns a set of possible result types. fn validateExpression(state: *AnalysisState, diagnostics: *Diagnostics, scope: *Scope, expression: ast.Expression) ValidationError!TypeSet { // we're happy for now with expressions... switch (expression.type) { .array_indexer => |indexer| { const array_type = try validateExpression(state, diagnostics, scope, indexer.value.*); const index_type = try validateExpression(state, diagnostics, scope, indexer.index.*); try performTypeCheck(diagnostics, indexer.value.location, array_or_string, array_type); try performTypeCheck(diagnostics, indexer.index.location, TypeSet.from(.number), index_type); if (array_type.contains(.array)) { // when we're possibly indexing an array, // we return a value of type `any` return TypeSet.any; } else if (array_type.contains(.string)) { // when we are not an array, but a string, // we can only return a number. return TypeSet.from(.number); } else { return TypeSet.empty; } }, .variable_expr => |variable_name| { // Check reserved names if (std.mem.eql(u8, variable_name, "true")) { return TypeSet.from(.boolean); } else if (std.mem.eql(u8, variable_name, "false")) { return TypeSet.from(.boolean); } else if (std.mem.eql(u8, variable_name, "void")) { return TypeSet.from(.void); } const variable = scope.get(variable_name) orelse { try diagnostics.emit(.@"error", expression.location, "Use of undeclared variable {s}", .{ variable_name, }); return TypeSet.any; }; return variable.possible_types; }, .array_literal => |array| { for (array) |item| { _ = try validateExpression(state, diagnostics, scope, item); } return TypeSet.from(.array); }, .function_call => |call| { if (call.function.type != .variable_expr) { try diagnostics.emit(.@"error", expression.location, "Function name expected", .{}); } if (call.arguments.len >= 256) { try diagnostics.emit(.@"error", expression.location, "Function argument list exceeds 255 arguments!", .{}); } for (call.arguments) |item| { _ = try validateExpression(state, diagnostics, scope, item); } return TypeSet.any; }, .method_call => |call| { _ = try validateExpression(state, diagnostics, scope, call.object.*); for (call.arguments) |item| { _ = try validateExpression(state, diagnostics, scope, item); } return TypeSet.any; }, .number_literal => { // these are always ok return TypeSet.from(.number); }, .string_literal => { return TypeSet.from(.string); }, .unary_operator => |expr| { const result = try validateExpression(state, diagnostics, scope, expr.value.*); const expected = switch (expr.operator) { .negate => Type.number, .boolean_not => Type.boolean, }; try performTypeCheck(diagnostics, expression.location, TypeSet.from(expected), result); return result; }, .binary_operator => |expr| { const lhs = try validateExpression(state, diagnostics, scope, expr.lhs.*); const rhs = try validateExpression(state, diagnostics, scope, expr.rhs.*); const accepted_set = switch (expr.operator) { .add => TypeSet.init(.{ .string, .number, .array }), .subtract, .multiply, .divide, .modulus => TypeSet.from(.number), .boolean_or, .boolean_and => TypeSet.from(.boolean), .equal, .different => TypeSet.any, .less_than, .greater_than, .greater_or_equal_than, .less_or_equal_than => TypeSet.init(.{ .string, .number, .array }), }; try performTypeCheck(diagnostics, expr.lhs.location, accepted_set, lhs); try performTypeCheck(diagnostics, expr.rhs.location, accepted_set, rhs); if (!TypeSet.areCompatible(lhs, rhs)) { try diagnostics.emit(.warning, expression.location, "Possible type mismatch detected. {} and {} are not compatible.\n", .{ lhs, rhs, }); return TypeSet.empty; } return switch (expr.operator) { .add => TypeSet.intersection(lhs, rhs), .subtract, .multiply, .divide, .modulus => TypeSet.from(.number), .boolean_or, .boolean_and => TypeSet.from(.boolean), .less_than, .greater_than, .greater_or_equal_than, .less_or_equal_than, .equal, .different => TypeSet.from(.boolean), }; }, } return .void; } fn validateStore(state: *AnalysisState, diagnostics: *Diagnostics, scope: *Scope, expression: ast.Expression, type_hint: TypeSet) ValidationError!void { if (!expression.isAssignable()) { try diagnostics.emit(.@"error", expression.location, "Expected array indexer or a variable, got {s}", .{ expressionTypeToString(expression.type), }); return; } switch (expression.type) { .array_indexer => |indexer| { const array_val = try validateExpression(state, diagnostics, scope, indexer.value.*); const index_val = try validateExpression(state, diagnostics, scope, indexer.index.*); try performTypeCheck(diagnostics, indexer.value.location, array_or_string, array_val); try performTypeCheck(diagnostics, indexer.index.location, TypeSet.from(.number), index_val); if (array_val.contains(.string) and !array_val.contains(.array)) { // when we are sure we write into a string, but definitly not an array // check if we're writing a number. try performTypeCheck(diagnostics, expression.location, TypeSet.from(.number), type_hint); } // now propagate the store validation back to the lvalue. // Note that we can assume that the lvalue _is_ a array, as it would be a type mismatch otherwise. try validateStore(state, diagnostics, scope, indexer.value.*, array_or_string.intersection(array_val)); }, .variable_expr => |variable_name| { if (std.mem.eql(u8, variable_name, "true") or std.mem.eql(u8, variable_name, "false") or std.mem.eql(u8, variable_name, "void")) { try diagnostics.emit(.@"error", expression.location, "Expected array indexer or a variable, got {s}", .{ variable_name, }); } else if (scope.get(variable_name)) |variable| { if (variable.is_const) { try diagnostics.emit(.@"error", expression.location, "Assignment to constant {s} not allowed.", .{ variable_name, }); } if (state.conditional_scope_depth > 0) { variable.possible_types = variable.possible_types.@"union"(type_hint); } else { variable.possible_types = type_hint; } } }, else => unreachable, } } fn validateStatement(state: *AnalysisState, diagnostics: *Diagnostics, scope: *Scope, stmt: ast.Statement) ValidationError!void { switch (stmt.type) { .empty => { // trivial: do nothing! }, .assignment => |ass| { const value_type = try validateExpression(state, diagnostics, scope, ass.value); if (ass.target.isAssignable()) { try validateStore(state, diagnostics, scope, ass.target, value_type); } else { try diagnostics.emit(.@"error", ass.target.location, "Expected either a array indexer or a variable, got {s}", .{ @tagName(@as(ast.Expression.Type, ass.target.type)), }); } }, .discard_value => |expr| { _ = try validateExpression(state, diagnostics, scope, expr); }, .return_void => { // this is always ok }, .return_expr => |expr| { // this is ok when the expr is ok _ = try validateExpression(state, diagnostics, scope, expr); // and when we are not on the root script. if (state.is_root_script) { try diagnostics.emit(.@"error", stmt.location, "Returning a value from global scope is not allowed.", .{}); } }, .while_loop => |loop| { state.loop_nesting += 1; defer state.loop_nesting -= 1; state.conditional_scope_depth += 1; defer state.conditional_scope_depth -= 1; const condition_type = try validateExpression(state, diagnostics, scope, loop.condition); try validateStatement(state, diagnostics, scope, loop.body.*); try performTypeCheck(diagnostics, stmt.location, TypeSet.from(.boolean), condition_type); }, .for_loop => |loop| { state.loop_nesting += 1; defer state.loop_nesting -= 1; state.conditional_scope_depth += 1; defer state.conditional_scope_depth -= 1; try scope.enter(); scope.declare(loop.variable, true) catch |err| switch (err) { error.AlreadyDeclared => unreachable, // not possible for locals error.TooManyVariables => try emitTooManyVariables(diagnostics, stmt.location), else => |e| return e, }; const array_type = try validateExpression(state, diagnostics, scope, loop.source); try validateStatement(state, diagnostics, scope, loop.body.*); try performTypeCheck(diagnostics, stmt.location, TypeSet.from(.array), array_type); try scope.leave(); }, .if_statement => |conditional| { state.conditional_scope_depth += 1; defer state.conditional_scope_depth -= 1; const conditional_type = try validateExpression(state, diagnostics, scope, conditional.condition); try validateStatement(state, diagnostics, scope, conditional.true_body.*); if (conditional.false_body) |body| { try validateStatement(state, diagnostics, scope, body.*); } try performTypeCheck(diagnostics, stmt.location, TypeSet.from(.boolean), conditional_type); }, .declaration => |decl| { // evaluate expression before so we can safely reference up-variables: // var a = a * 2; const initial_value = if (decl.initial_value) |init_val| try validateExpression(state, diagnostics, scope, init_val) else null; scope.declare(decl.variable, decl.is_const) catch |err| switch (err) { error.AlreadyDeclared => try diagnostics.emit(.@"error", stmt.location, "Global variable {s} is already declared!", .{decl.variable}), error.TooManyVariables => try emitTooManyVariables(diagnostics, stmt.location), else => |e| return e, }; if (initial_value) |init_val| scope.get(decl.variable).?.possible_types = init_val; if (decl.is_const and decl.initial_value == null) { try diagnostics.emit(.@"error", stmt.location, "Constant {s} must be initialized!", .{ decl.variable, }); } }, .block => |blk| { try scope.enter(); for (blk) |sub_stmt| { try validateStatement(state, diagnostics, scope, sub_stmt); } try scope.leave(); }, .@"break" => { if (state.loop_nesting == 0) { try diagnostics.emit(.@"error", stmt.location, "break outside of loop!", .{}); } }, .@"continue" => { if (state.loop_nesting == 0) { try diagnostics.emit(.@"error", stmt.location, "continue outside of loop!", .{}); } }, } } fn getErrorCount(diagnostics: *const Diagnostics) usize { var res: usize = 0; for (diagnostics.messages.items) |msg| { if (msg.kind == .@"error") res += 1; } return res; } /// Validates the `program` against programming mistakes and filles `diagnostics` with the findings. /// Note that the function will always succeed when no `OutOfMemory` happens. To see if the program /// is semantically sound, check `diagnostics` for error messages. pub fn validate(allocator: std.mem.Allocator, diagnostics: *Diagnostics, program: ast.Program) ValidationError!bool { var global_scope = Scope.init(allocator, null, true); defer global_scope.deinit(); const initial_errc = getErrorCount(diagnostics); for (program.root_script) |stmt| { var state = AnalysisState{ .loop_nesting = 0, .is_root_script = true, .conditional_scope_depth = 0, }; try validateStatement(&state, diagnostics, &global_scope, stmt); } std.debug.assert(global_scope.return_point.items.len == 0); for (program.functions, 0..) |function, i| { for (program.functions[0..i]) |other_fn| { if (std.mem.eql(u8, function.name, other_fn.name)) { try diagnostics.emit(.@"error", function.location, "A function with the name {s} was already declared!", .{function.name}); break; } } var local_scope = Scope.init(allocator, &global_scope, false); defer local_scope.deinit(); for (function.parameters) |param| { local_scope.declare(param, true) catch |err| switch (err) { error.AlreadyDeclared => try diagnostics.emit(.@"error", function.location, "A parameter {s} is already declared!", .{param}), error.TooManyVariables => try emitTooManyVariables(diagnostics, function.location), else => |e| return e, }; } var state = AnalysisState{ .loop_nesting = 0, .is_root_script = false, .conditional_scope_depth = 0, }; try validateStatement(&state, diagnostics, &local_scope, function.body); } return (getErrorCount(diagnostics) == initial_errc); } test "validate correct program" { // For lack of a better idea: // Just run the analysis against the compiler test suite var diagnostics = Diagnostics.init(std.testing.allocator); defer diagnostics.deinit(); const seq = try @import("tokenizer.zig").tokenize(std.testing.allocator, &diagnostics, "src/test/compiler.lola", @embedFile("compiler.lola")); defer std.testing.allocator.free(seq); var pgm = try @import("parser.zig").parse(std.testing.allocator, &diagnostics, seq); defer pgm.deinit(); try std.testing.expectEqual(true, try validate(std.testing.allocator, &diagnostics, pgm)); for (diagnostics.messages.items) |msg| { std.debug.print("{s}\n", .{msg}); } try std.testing.expectEqual(@as(usize, 0), diagnostics.messages.items.len); } fn expectAnalysisErrors(source: []const u8, expected_messages: []const []const u8) !void { // For lack of a better idea: // Just run the analysis against the compiler test suite var diagnostics = Diagnostics.init(std.testing.allocator); defer diagnostics.deinit(); const seq = try @import("tokenizer.zig").tokenize(std.testing.allocator, &diagnostics, "", source); defer std.testing.allocator.free(seq); var pgm = try @import("parser.zig").parse(std.testing.allocator, &diagnostics, seq); defer pgm.deinit(); try std.testing.expectEqual(false, try validate(std.testing.allocator, &diagnostics, pgm)); try std.testing.expectEqual(expected_messages.len, diagnostics.messages.items.len); for (expected_messages, 0..) |expected, i| { try std.testing.expectEqualStrings(expected, diagnostics.messages.items[i].message); } } test "detect return from root script" { try expectAnalysisErrors("return 10;", &[_][]const u8{ "Returning a value from global scope is not allowed.", }); } test "detect const without init" { try expectAnalysisErrors("const a;", &[_][]const u8{ "Constant a must be initialized!", }); } test "detect assignment to const" { try expectAnalysisErrors("const a = 5; a = 10;", &[_][]const u8{ "Assignment to constant a not allowed.", }); } test "detect doubly-declared global variables" { try expectAnalysisErrors("var a; var a;", &[_][]const u8{ "Global variable a is already declared!", }); } test "detect assignment to const parameter" { try expectAnalysisErrors("function f(x) { x = void; }", &[_][]const u8{ "Assignment to constant x not allowed.", }); }
0
repos/LoLa/src/library
repos/LoLa/src/library/compiler/tokenizer.zig
const std = @import("std"); const Diagnostics = @import("diagnostics.zig").Diagnostics; pub const TokenType = enum { const Self = @This(); number_literal, string_literal, character_literal, identifier, comment, whitespace, @"{", @"}", @"(", @")", @"]", @"[", @"var", @"const", @"for", @"while", @"if", @"else", function, in, @"break", @"continue", @"return", @"and", @"or", not, @"+=", @"-=", @"*=", @"/=", @"%=", @"<=", @">=", @"<", @">", @"!=", @"==", @"=", @".", @",", @";", @"+", @"-", @"*", @"/", @"%", /// Returns `true` when the token type is emitted from the tokenizer, /// otherwise `false`. pub fn isEmitted(self: Self) bool { return switch (self) { .comment, .whitespace => false, else => true, }; } }; const keywords = [_][]const u8{ "var", "for", "while", "if", "else", "function", "in", "break", "continue", "return", "and", "or", "not", "const", }; pub const Location = @import("location.zig").Location; /// A single, recognized piece of text in the source file. pub const Token = struct { /// the text that was recognized text: []const u8, /// the position in the source file location: Location, /// the type (and parsed value) of the token type: TokenType, }; pub const Tokenizer = struct { const Self = @This(); /// Result from a tokenization process const Result = union(enum) { token: Token, end_of_file: void, invalid_sequence: []const u8, }; source: []const u8, offset: usize, current_location: Location, pub fn init(chunk_name: []const u8, source: []const u8) Self { return Self{ .source = source, .offset = 0, .current_location = Location{ .line = 1, .column = 1, .chunk = chunk_name, .offset_start = undefined, .offset_end = undefined, }, }; } pub fn next(self: *Self) Result { while (true) { const start = self.offset; if (start >= self.source.len) return .end_of_file; if (nextInternal(self)) |token_type| { const end = self.offset; std.debug.assert(end > start); // tokens may never be empty! var token = Token{ .type = token_type, .location = self.current_location, .text = self.source[start..end], }; // std.debug.print("token: `{}`\n", .{token.text}); if (token.type == .identifier) { inline for (keywords) |kwd| { if (std.mem.eql(u8, token.text, kwd)) { token.type = @field(TokenType, kwd); break; } } } token.location.offset_start = start; token.location.offset_end = end; for (token.text) |c| { if (c == '\n') { self.current_location.line += 1; self.current_location.column = 1; } else { self.current_location.column += 1; } } if (token.type.isEmitted()) return Result{ .token = token }; } else { while (self.accept(invalid_char_class)) {} const end = self.offset; self.current_location.offset_start = start; self.current_location.offset_end = end; return Result{ .invalid_sequence = self.source[start..end] }; } } } const Predicate = fn (u8) bool; fn accept(self: *Self, predicate: *const fn (u8) bool) bool { if (self.offset >= self.source.len) return false; const c = self.source[self.offset]; const accepted = predicate(c); // std.debug.print("{c} → {}\n", .{ // c, accepted, // }); if (accepted) { self.offset += 1; return true; } else { return false; } } fn any(c: u8) bool { _ = c; return true; } fn anyOf(comptime chars: []const u8) Predicate { return struct { fn pred(c: u8) bool { return inline for (chars) |o| { if (c == o) break true; } else false; } }.pred; } fn noneOf(comptime chars: []const u8) Predicate { return struct { fn pred(c: u8) bool { return inline for (chars) |o| { if (c == o) break false; } else true; } }.pred; } const invalid_char_class = noneOf(" \r\n\tABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789+-*/%={}()[]<>\"\'.,;!"); const whitespace_class = anyOf(" \r\n\t"); const comment_class = noneOf("\n"); const identifier_class = anyOf("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789"); const digit_class = anyOf("0123456789"); const hexdigit_class = anyOf("0123456789abcdefABCDEF"); const string_char_class = noneOf("\"\\"); const character_char_class = noneOf("\'\\"); fn nextInternal(self: *Self) ?TokenType { std.debug.assert(self.offset < self.source.len); // copy for shorter code const source = self.source; if (self.accept(whitespace_class)) { while (self.accept(whitespace_class)) {} return .whitespace; } const current_char = source[self.offset]; self.offset += 1; switch (current_char) { '=' => return if (self.accept(anyOf("="))) .@"==" else .@"=", '!' => return if (self.accept(anyOf("="))) .@"!=" else null, '.' => return .@".", ',' => return .@",", ';' => return .@";", '{' => return .@"{", '}' => return .@"}", '(' => return .@"(", ')' => return .@")", ']' => return .@"]", '[' => return .@"[", '+' => return if (self.accept(anyOf("="))) .@"+=" else .@"+", '-' => return if (self.accept(anyOf("="))) .@"-=" else .@"-", '*' => return if (self.accept(anyOf("="))) .@"*=" else .@"*", '/' => { if (self.accept(anyOf("/"))) { while (self.accept(comment_class)) {} return .comment; } else if (self.accept(anyOf("="))) { return .@"/="; } else { return .@"/"; } }, '%' => return if (self.accept(anyOf("="))) .@"%=" else .@"%", '<' => return if (self.accept(anyOf("="))) .@"<=" else .@"<", '>' => return if (self.accept(anyOf("="))) .@">=" else .@">", // parse numbers '0'...'9' => { while (self.accept(digit_class)) {} if (self.accept(anyOf("xX"))) { while (self.accept(hexdigit_class)) {} return .number_literal; } else if (self.accept(anyOf("."))) { while (self.accept(digit_class)) {} return .number_literal; } return .number_literal; }, // parse identifiers 'a'...'z', 'A'...'Z', '_' => { while (self.accept(identifier_class)) {} return .identifier; }, // parse strings '"' => { while (true) { while (self.accept(string_char_class)) {} if (self.accept(anyOf("\""))) { return .string_literal; } else if (self.accept(anyOf("\\"))) { if (self.accept(anyOf("x"))) { // hex literal if (!self.accept(hexdigit_class)) return null; if (!self.accept(hexdigit_class)) return null; } else { if (!self.accept(any)) return null; } } else { return null; } } }, // parse character literals '\'' => { while (true) { while (self.accept(character_char_class)) {} if (self.accept(anyOf("\'"))) { return .character_literal; } else if (self.accept(anyOf("\\"))) { if (self.accept(anyOf("x"))) { // hex literal if (!self.accept(hexdigit_class)) return null; if (!self.accept(hexdigit_class)) return null; } else { if (!self.accept(any)) return null; } } else { return null; } } }, else => return null, } } }; pub fn tokenize(allocator: std.mem.Allocator, diagnostics: *Diagnostics, chunk_name: []const u8, source: []const u8) ![]Token { var result = std.ArrayList(Token).init(allocator); var tokenizer = Tokenizer.init(chunk_name, source); while (true) { switch (tokenizer.next()) { .end_of_file => return result.toOwnedSlice(), .invalid_sequence => |seq| { try diagnostics.emit(.@"error", tokenizer.current_location, "invalid byte sequence: {}", .{ std.fmt.fmtSliceHexUpper(seq), }); }, .token => |token| try result.append(token), } } } fn expectEqual(expected: anytype, actual: anytype) !void { const T = @TypeOf(expected); return try std.testing.expectEqual(expected, @as(T, actual)); } const expectEqualStrings = std.testing.expectEqualStrings; test "Tokenizer empty string" { var tokenizer = Tokenizer.init("??", ""); try expectEqual(std.meta.Tag(Tokenizer.Result).end_of_file, tokenizer.next()); } test "Tokenizer invalid bytes" { var tokenizer = Tokenizer.init("??", "\\``?`a##§"); { const item = tokenizer.next(); try expectEqual(std.meta.Tag(Tokenizer.Result).invalid_sequence, item); try expectEqualStrings("\\``?`", item.invalid_sequence); } { const item = tokenizer.next(); try expectEqual(std.meta.Tag(Tokenizer.Result).token, item); try expectEqualStrings("a", item.token.text); } { const item = tokenizer.next(); try expectEqual(std.meta.Tag(Tokenizer.Result).invalid_sequence, item); try expectEqualStrings("##§", item.invalid_sequence); } } test "Tokenizer (tokenize compiler test suite)" { var tokenizer = Tokenizer.init("src/test/compiler.lola", @embedFile("../../test/compiler.lola")); while (true) { switch (tokenizer.next()) { .token => { // Use this for manual validation: // std.debug.print("token: {}\n", .{tok}); }, .end_of_file => break, .invalid_sequence => |seq| { std.debug.print("failed to parse test file at `{s}`!\n", .{ seq, }); // this test should never reach this state, as the test file // is validated by hand unreachable; }, } } } test "tokenize" { // TODO: Implement meaningful test _ = tokenize; }
0
repos/LoLa/src/library
repos/LoLa/src/library/compiler/diagnostics.zig
const std = @import("std"); const Location = @import("location.zig").Location; pub const Diagnostics = struct { const Self = @This(); pub const MessageKind = enum { @"error", warning, notice }; pub const Message = struct { kind: MessageKind, location: Location, message: []const u8, pub fn format(value: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { _ = fmt; _ = options; try writer.print("{}: {s}: {s}", .{ value.location, @tagName(value.kind), value.message, }); } }; arena: std.heap.ArenaAllocator, messages: std.ArrayList(Message), pub fn init(allocator: std.mem.Allocator) Self { return Self{ .arena = std.heap.ArenaAllocator.init(allocator), .messages = std.ArrayList(Message).init(allocator), }; } pub fn deinit(self: *Self) void { self.messages.deinit(); self.arena.deinit(); } /// Emits a new diagnostic message and appends that to the current output. pub fn emit(self: *Self, kind: MessageKind, location: Location, comptime fmt: []const u8, args: anytype) !void { const msg_string = try std.fmt.allocPrint(self.arena.allocator(), fmt, args); errdefer self.arena.allocator().free(msg_string); const arena_pos = try self.arena.allocator().dupe(u8, location.chunk); errdefer self.arena.allocator().free(arena_pos); try self.messages.append(Message{ .kind = kind, .location = Location{ .chunk = arena_pos, .line = location.line, .column = location.column, .offset_start = location.offset_start, .offset_end = location.offset_end, }, .message = msg_string, }); } /// returns true when the collection has any critical messages. pub fn hasErrors(self: Self) bool { return for (self.messages.items) |msg| { if (msg.kind == .@"error") break true; } else false; } }; test "diagnostic list" { const loc = Location{ .chunk = "demo", .line = 1, .column = 2, .offset_end = undefined, .offset_start = undefined, }; var diagnostics = Diagnostics.init(std.testing.allocator); defer diagnostics.deinit(); try std.testing.expectEqual(false, diagnostics.hasErrors()); try std.testing.expectEqual(@as(usize, 0), diagnostics.messages.items.len); try diagnostics.emit(.warning, loc, "{s}", .{"this is a warning!"}); try std.testing.expectEqual(false, diagnostics.hasErrors()); try std.testing.expectEqual(@as(usize, 1), diagnostics.messages.items.len); try diagnostics.emit(.notice, loc, "{s}", .{"this is a notice!"}); try std.testing.expectEqual(false, diagnostics.hasErrors()); try std.testing.expectEqual(@as(usize, 2), diagnostics.messages.items.len); try diagnostics.emit(.@"error", loc, "{s}", .{"this is a error!"}); try std.testing.expectEqual(true, diagnostics.hasErrors()); try std.testing.expectEqual(@as(usize, 3), diagnostics.messages.items.len); try std.testing.expectEqualStrings("this is a warning!", diagnostics.messages.items[0].message); try std.testing.expectEqualStrings("this is a notice!", diagnostics.messages.items[1].message); try std.testing.expectEqualStrings("this is a error!", diagnostics.messages.items[2].message); }
0
repos/LoLa/src/library
repos/LoLa/src/library/compiler/scope.zig
const std = @import("std"); const Type = @import("typeset.zig").Type; const TypeSet = @import("typeset.zig").TypeSet; /// A scope structure that can be used to manage variable /// allocation with different scopes (global, local). pub const Scope = struct { const Self = @This(); const Variable = struct { /// This is the offset of the variables name: []const u8, storage_slot: u16, type: enum { local, global }, possible_types: TypeSet = TypeSet.any, is_const: bool, }; arena: std.heap.ArenaAllocator, local_variables: std.ArrayList(Variable), global_variables: std.ArrayList(Variable), return_point: std.ArrayList(usize), /// When this is true, the scope will declare /// top-level variables as `global`, otherwise as `local`. is_global: bool, /// When this is non-null, the scope will use this as a fallback /// in `get` and will pass the query to this value. /// Note: It is not allowed that `global_scope` will return a `local` variable then! global_scope: ?*Self, /// The highest number of local variables that were declared at a point in this scope. max_locals: usize = 0, /// Creates a new scope. /// `global_scope` is a reference towards a scope that will provide references to a encasing scope. /// This scope must only provide `global` variables. pub fn init(allocator: std.mem.Allocator, global_scope: ?*Self, is_global: bool) Self { return Self{ .arena = std.heap.ArenaAllocator.init(allocator), .local_variables = std.ArrayList(Variable).init(allocator), .global_variables = std.ArrayList(Variable).init(allocator), .return_point = std.ArrayList(usize).init(allocator), .is_global = is_global, .global_scope = global_scope, }; } pub fn deinit(self: *Self) void { self.local_variables.deinit(); self.global_variables.deinit(); self.return_point.deinit(); self.arena.deinit(); self.* = undefined; } /// Enters a sub-scope. This is usually called at the start of a block. /// Sub-scopes are a set of variables that are only valid in a smaller /// portion of the code. /// This will push a return point to which later must be returned by /// calling `leave`. pub fn enter(self: *Self) !void { try self.return_point.append(self.local_variables.items.len); } /// Leaves a sub-scope. This is usually called at the end of a block. pub fn leave(self: *Self) !void { self.local_variables.shrinkRetainingCapacity(self.return_point.pop()); } /// Declares are new variable. pub fn declare(self: *Self, name: []const u8, is_const: bool) !void { if (self.is_global and (self.return_point.items.len == 0)) { // a variable is only global when the scope is a global scope and // we don't have any sub-scopes open (which would create temporary variables) for (self.global_variables.items) |variable| { if (std.mem.eql(u8, variable.name, name)) { // Global variables are not allowed to return error.AlreadyDeclared; } } if (self.global_variables.items.len == std.math.maxInt(u16)) return error.TooManyVariables; try self.global_variables.append(Variable{ .storage_slot = @as(u16, @intCast(self.global_variables.items.len)), .name = try self.arena.allocator().dupe(u8, name), .type = .global, .is_const = is_const, }); } else { if (self.local_variables.items.len == std.math.maxInt(u16)) return error.TooManyVariables; try self.local_variables.append(Variable{ .storage_slot = @as(u16, @intCast(self.local_variables.items.len)), .name = try self.arena.allocator().dupe(u8, name), .type = .local, .is_const = is_const, }); self.max_locals = @max(self.max_locals, self.local_variables.items.len); } } /// Tries to return a variable named `name`. This will first search in the /// local variables, then in the global ones. /// Will return `null` when a variable is not found. pub fn get(self: Self, name: []const u8) ?*Variable { var i: usize = undefined; // First, search all local variables back-to-front: // This allows trivial shadowing as variables will be searched // in reverse declaration order. i = self.local_variables.items.len; while (i > 0) { i -= 1; const variable = &self.local_variables.items[i]; if (std.mem.eql(u8, variable.name, name)) return variable; } if (self.is_global) { // The same goes for global variables i = self.global_variables.items.len; while (i > 0) { i -= 1; const variable = &self.global_variables.items[i]; if (std.mem.eql(u8, variable.name, name)) return variable; } } if (self.global_scope) |globals| { const global = globals.get(name); // The global scope is not allowed to supply local variables to us. If this happens, // a programming error was done. std.debug.assert(global == null or global.?.type != .local); return global; } return null; } }; test "scope init/deinit" { var scope = Scope.init(std.testing.allocator, null, false); defer scope.deinit(); } test "scope declare/get" { var scope = Scope.init(std.testing.allocator, null, true); defer scope.deinit(); try scope.declare("foo", true); try std.testing.expectError(error.AlreadyDeclared, scope.declare("foo", true)); try scope.enter(); try scope.declare("bar", true); try std.testing.expect(scope.get("foo").?.type == .global); try std.testing.expect(scope.get("bar").?.type == .local); try std.testing.expect(scope.get("bam") == null); try scope.leave(); try std.testing.expect(scope.get("foo").?.type == .global); try std.testing.expect(scope.get("bar") == null); try std.testing.expect(scope.get("bam") == null); } test "variable allocation" { var scope = Scope.init(std.testing.allocator, null, true); defer scope.deinit(); try scope.declare("foo", true); try scope.declare("bar", true); try scope.declare("bam", true); try std.testing.expect(scope.get("foo").?.storage_slot == 0); try std.testing.expect(scope.get("bar").?.storage_slot == 1); try std.testing.expect(scope.get("bam").?.storage_slot == 2); try scope.enter(); try scope.declare("foo", true); try scope.enter(); try scope.declare("bar", true); try scope.declare("bam", true); try std.testing.expect(scope.get("foo").?.storage_slot == 0); try std.testing.expect(scope.get("bar").?.storage_slot == 1); try std.testing.expect(scope.get("bam").?.storage_slot == 2); try std.testing.expect(scope.get("foo").?.type == .local); try std.testing.expect(scope.get("bar").?.type == .local); try std.testing.expect(scope.get("bam").?.type == .local); try scope.leave(); try std.testing.expect(scope.get("foo").?.type == .local); try std.testing.expect(scope.get("bar").?.type == .global); try std.testing.expect(scope.get("bam").?.type == .global); try scope.leave(); try std.testing.expect(scope.get("foo").?.type == .global); try std.testing.expect(scope.get("bar").?.type == .global); try std.testing.expect(scope.get("bam").?.type == .global); }
0
repos/LoLa/src/library
repos/LoLa/src/library/compiler/ast.zig
const std = @import("std"); const Location = @import("location.zig").Location; pub const UnaryOperator = enum { negate, boolean_not, }; pub const BinaryOperator = enum { add, subtract, multiply, divide, modulus, boolean_or, boolean_and, less_than, greater_than, greater_or_equal_than, less_or_equal_than, equal, different, }; pub const Expression = struct { const Self = @This(); pub const Type = std.meta.Tag(ExprValue); /// Starting location of the statement location: Location, /// kind of the expression as well as associated child nodes. /// child expressions memory is stored in the `Program` structure. type: ExprValue, /// Returns true when the expression allows an assignment similar to /// Cs `lvalue`. pub fn isAssignable(self: Self) bool { return switch (self.type) { .array_indexer, .variable_expr => true, else => false, }; } const ExprValue = union(enum) { array_indexer: struct { value: *Expression, index: *Expression, }, variable_expr: []const u8, array_literal: []Expression, function_call: struct { // this must be a expression of type `variable_expr` function: *Expression, arguments: []Expression, }, method_call: struct { object: *Expression, name: []const u8, arguments: []Expression, }, number_literal: f64, string_literal: []const u8, unary_operator: struct { operator: UnaryOperator, value: *Expression, }, binary_operator: struct { operator: BinaryOperator, lhs: *Expression, rhs: *Expression, }, }; }; pub const Statement = struct { const Self = @This(); pub const Type = std.meta.Tag(StmtValue); /// Starting location of the statement location: Location, /// kind of the statement as well as associated child nodes. /// child statements and expressions memory is stored in the /// `Program` structure. type: StmtValue, const StmtValue = union(enum) { empty: void, // Just a single, flat ';' /// Top level assignment as in `lvalue = value`. assignment: struct { target: Expression, value: Expression, }, /// Top-level function call like `Foo()` discard_value: Expression, return_void: void, return_expr: Expression, while_loop: struct { condition: Expression, body: *Statement, }, for_loop: struct { variable: []const u8, source: Expression, body: *Statement, }, if_statement: struct { condition: Expression, true_body: *Statement, false_body: ?*Statement, }, declaration: struct { variable: []const u8, initial_value: ?Expression, is_const: bool, }, block: []Statement, @"break": void, @"continue": void, }; }; pub const Function = struct { /// Starting location of the function location: Location, name: []const u8, parameters: [][]const u8, body: Statement, }; /// Root node of the abstract syntax tree, /// contains a whole LoLa file. pub const Program = struct { const Self = @This(); /// Arena storing all associated memory with the AST. /// Each node, string or array is stored here. arena: std.heap.ArenaAllocator, /// The sequence of statements that are not contained in functions. root_script: []Statement, /// All declared functions in the script. functions: []Function, /// Releases all resources associated with this syntax tree. pub fn deinit(self: *Self) void { self.arena.deinit(); self.* = undefined; } }; pub fn dumpExpression(writer: anytype, expr: Expression) @TypeOf(writer).Error!void { switch (expr.type) { .array_indexer => |val| { try dumpExpression(writer, val.value.*); try writer.writeAll("["); try dumpExpression(writer, val.index.*); try writer.writeAll("]"); }, .variable_expr => |val| try writer.writeAll(val), .array_literal => |val| { try writer.writeAll("[ "); for (val, 0..) |item, index| { if (index > 0) { try writer.writeAll(", "); } try dumpExpression(writer, item); } try writer.writeAll("]"); }, .function_call => unreachable, .method_call => unreachable, .number_literal => |val| try writer.print("{d}", .{val}), .string_literal => |val| try writer.print("\"{}\"", .{val}), .unary_operator => |val| { try writer.writeAll(switch (val.operator) { .negate => "-", .boolean_not => "not", }); try dumpExpression(writer, val.value.*); }, .binary_operator => |val| { try writer.writeAll("("); try dumpExpression(writer, val.lhs.*); try writer.writeAll(" "); try writer.writeAll(switch (val.operator) { .add => "+", .subtract => "-", .multiply => "*", .divide => "/", .modulus => "%", .boolean_or => "or", .boolean_and => "and", .less_than => "<", .greater_than => ">", .greater_or_equal_than => ">=", .less_or_equal_than => "<=", .equal => "==", .different => "!=", }); try writer.writeAll(" "); try dumpExpression(writer, val.rhs.*); try writer.writeAll(")"); }, } }
0
repos/LoLa/src/library
repos/LoLa/src/library/libraries/libs.zig
/// Provides the LoLa standard library. pub const std = @import("stdlib.zig"); /// Provides the LoLa runtime library. pub const runtime = @import("runtime.zig");
0
repos/LoLa/src/library
repos/LoLa/src/library/libraries/stdlib.zig
// This file implements the LoLa standard library const std = @import("std"); const builtin = @import("builtin"); const lola = @import("../main.zig"); const whitespace = [_]u8{ 0x09, // horizontal tab 0x0A, // line feed 0x0B, // vertical tab 0x0C, // form feed 0x0D, // carriage return 0x20, // space }; const root = @import("root"); const milliTimestamp = if (builtin.os.tag == .freestanding) if (@hasDecl(root, "milliTimestamp")) root.milliTimestamp else @compileError("Please provide milliTimestamp in the root file for freestanding targets!") else std.time.milliTimestamp; /// empty compile unit for testing purposes const empty_compile_unit = lola.CompileUnit{ .arena = std.heap.ArenaAllocator.init(std.testing.failing_allocator), .comment = "empty compile unit", .globalCount = 0, .temporaryCount = 0, .code = "", .functions = &[0]lola.CompileUnit.Function{}, .debugSymbols = &[0]lola.CompileUnit.DebugSymbol{}, }; test "stdlib.install" { var pool = lola.runtime.ObjectPool([_]type{}).init(std.testing.allocator); defer pool.deinit(); var env = try lola.runtime.Environment.init(std.testing.allocator, &empty_compile_unit, pool.interface()); defer env.deinit(); // TODO: Reinsert this try env.installModule(@This(), lola.runtime.Context.null_pointer); } pub fn Sleep(env: *lola.runtime.Environment, call_context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.AsyncFunctionCall { _ = call_context; if (args.len != 1) return error.InvalidArgs; const seconds = try args[0].toNumber(); const Context = struct { allocator: std.mem.Allocator, end_time: f64, }; const ptr = try env.allocator.create(Context); ptr.* = Context{ .allocator = env.allocator, .end_time = @as(f64, @floatFromInt(milliTimestamp())) + 1000.0 * seconds, }; return lola.runtime.AsyncFunctionCall{ .context = lola.runtime.Context.make(*Context, ptr), .destructor = struct { fn dtor(exec_context: lola.runtime.Context) void { const ctx = exec_context.cast(*Context); ctx.allocator.destroy(ctx); } }.dtor, .execute = struct { fn execute(exec_context: lola.runtime.Context) anyerror!?lola.runtime.Value { const ctx = exec_context.cast(*Context); if (ctx.end_time < @as(f64, @floatFromInt(milliTimestamp()))) { return .void; } else { return null; } } }.execute, }; } pub fn Yield(env: *lola.runtime.Environment, call_context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.AsyncFunctionCall { _ = call_context; if (args.len != 0) return error.InvalidArgs; const Context = struct { allocator: std.mem.Allocator, end: bool, }; const ptr = try env.allocator.create(Context); ptr.* = Context{ .allocator = env.allocator, .end = false, }; return lola.runtime.AsyncFunctionCall{ .context = lola.runtime.Context.make(*Context, ptr), .destructor = struct { fn dtor(exec_context: lola.runtime.Context) void { const ctx = exec_context.cast(*Context); ctx.allocator.destroy(ctx); } }.dtor, .execute = struct { fn execute(exec_context: lola.runtime.Context) anyerror!?lola.runtime.Value { const ctx = exec_context.cast(*Context); if (ctx.end) { return .void; } else { ctx.end = true; return null; } } }.execute, }; } pub fn Length(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = env; _ = context; if (args.len != 1) return error.InvalidArgs; return switch (args[0]) { .string => |str| lola.runtime.Value.initNumber(@as(f64, @floatFromInt(str.contents.len))), .array => |arr| lola.runtime.Value.initNumber(@as(f64, @floatFromInt(arr.contents.len))), else => error.TypeMismatch, }; } pub fn SubString(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = context; if (args.len < 2 or args.len > 3) return error.InvalidArgs; if (args[0] != .string) return error.TypeMismatch; if (args[1] != .number) return error.TypeMismatch; if (args.len == 3 and args[2] != .number) return error.TypeMismatch; const str = args[0].string; const start = try args[1].toInteger(usize); if (start >= str.contents.len) return lola.runtime.Value.initString(env.allocator, ""); const sliced = if (args.len == 3) str.contents[start..][0..@min(str.contents.len - start, try args[2].toInteger(usize))] else str.contents[start..]; return try lola.runtime.Value.initString(env.allocator, sliced); } pub fn Trim(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = context; if (args.len != 1) return error.InvalidArgs; if (args[0] != .string) return error.TypeMismatch; const str = args[0].string; return try lola.runtime.Value.initString( env.allocator, std.mem.trim(u8, str.contents, &whitespace), ); } pub fn TrimLeft(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = context; if (args.len != 1) return error.InvalidArgs; if (args[0] != .string) return error.TypeMismatch; const str = args[0].string; return try lola.runtime.Value.initString( env.allocator, std.mem.trimLeft(u8, str.contents, &whitespace), ); } pub fn TrimRight(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = context; if (args.len != 1) return error.InvalidArgs; if (args[0] != .string) return error.TypeMismatch; const str = args[0].string; return try lola.runtime.Value.initString( env.allocator, std.mem.trimRight(u8, str.contents, &whitespace), ); } pub fn IndexOf(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = env; _ = context; if (args.len != 2) return error.InvalidArgs; if (args[0] == .string) { if (args[1] != .string) return error.TypeMismatch; const haystack = args[0].string.contents; const needle = args[1].string.contents; return if (std.mem.indexOf(u8, haystack, needle)) |index| lola.runtime.Value.initNumber(@as(f64, @floatFromInt(index))) else .void; } else if (args[0] == .array) { const haystack = args[0].array.contents; for (haystack, 0..) |val, i| { if (val.eql(args[1])) return lola.runtime.Value.initNumber(@as(f64, @floatFromInt(i))); } return .void; } else { return error.TypeMismatch; } } pub fn LastIndexOf(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = env; _ = context; if (args.len != 2) return error.InvalidArgs; if (args[0] == .string) { if (args[1] != .string) return error.TypeMismatch; const haystack = args[0].string.contents; const needle = args[1].string.contents; return if (std.mem.lastIndexOf(u8, haystack, needle)) |index| lola.runtime.Value.initNumber(@as(f64, @floatFromInt(index))) else .void; } else if (args[0] == .array) { const haystack = args[0].array.contents; var i: usize = haystack.len; while (i > 0) { i -= 1; if (haystack[i].eql(args[1])) return lola.runtime.Value.initNumber(@as(f64, @floatFromInt(i))); } return .void; } else { return error.TypeMismatch; } } pub fn Byte(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = env; _ = context; if (args.len != 1) return error.InvalidArgs; if (args[0] != .string) return error.TypeMismatch; const value = args[0].string.contents; if (value.len > 0) return lola.runtime.Value.initNumber(@as(f64, @floatFromInt(value[0]))) else return .void; } pub fn Chr(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = context; if (args.len != 1) return error.InvalidArgs; const val = try args[0].toInteger(u8); return try lola.runtime.Value.initString( env.allocator, &[_]u8{val}, ); } pub fn NumToString(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = context; if (args.len < 1 or args.len > 2) return error.InvalidArgs; var buffer: [256]u8 = undefined; const slice = if (args.len == 2) blk: { const base = try args[1].toInteger(u8); const val = try args[0].toInteger(isize); const len = std.fmt.formatIntBuf(&buffer, val, base, .upper, std.fmt.FormatOptions{}); break :blk buffer[0..len]; } else blk: { var stream = std.io.fixedBufferStream(&buffer); const val = try args[0].toNumber(); try stream.writer().print("{d}", .{val}); break :blk stream.getWritten(); }; return try lola.runtime.Value.initString(env.allocator, slice); } pub fn StringToNum(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = env; _ = context; if (args.len < 1 or args.len > 2) return error.InvalidArgs; const str = try args[0].toString(); if (args.len == 2) { const base = try args[1].toInteger(u8); const text = if (base == 16) blk: { var tmp = str; if (std.mem.startsWith(u8, tmp, "0x")) tmp = tmp[2..]; if (std.mem.endsWith(u8, tmp, "h")) tmp = tmp[0 .. tmp.len - 1]; break :blk tmp; } else str; const val = try std.fmt.parseInt(isize, text, base); // return .void; return lola.runtime.Value.initNumber(@as(f64, @floatFromInt(val))); } else { const val = std.fmt.parseFloat(f64, str) catch return .void; return lola.runtime.Value.initNumber(val); } } pub fn Split(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = context; if (args.len < 2 or args.len > 3) return error.InvalidArgs; const input = try args[0].toString(); const separator = try args[1].toString(); const removeEmpty = if (args.len == 3) try args[2].toBoolean() else false; var items = std.ArrayList(lola.runtime.Value).init(env.allocator); defer { for (items.items) |*i| { i.deinit(); } items.deinit(); } var iter = std.mem.splitAny(u8, input, separator); while (iter.next()) |slice| { if (!removeEmpty or slice.len > 0) { var val = try lola.runtime.Value.initString(env.allocator, slice); errdefer val.deinit(); try items.append(val); } } return lola.runtime.Value.fromArray(lola.runtime.Array{ .allocator = env.allocator, .contents = try items.toOwnedSlice(), }); } pub fn Join(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = context; if (args.len < 1 or args.len > 2) return error.InvalidArgs; const array = try args[0].toArray(); const separator = if (args.len == 2) try args[1].toString() else ""; for (array.contents) |item| { if (item != .string) return error.TypeMismatch; } var result = std.ArrayList(u8).init(env.allocator); defer result.deinit(); for (array.contents, 0..) |item, i| { if (i > 0) { try result.appendSlice(separator); } try result.appendSlice(try item.toString()); } return lola.runtime.Value.fromString(lola.runtime.String.initFromOwned( env.allocator, try result.toOwnedSlice(), )); } pub fn Array(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = context; if (args.len < 1 or args.len > 2) return error.InvalidArgs; const length = try args[0].toInteger(usize); const init_val = if (args.len > 1) args[1] else .void; const arr = try lola.runtime.Array.init(env.allocator, length); for (arr.contents) |*item| { item.* = try init_val.clone(); } return lola.runtime.Value.fromArray(arr); } pub fn Range(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = context; if (args.len < 1 or args.len > 2) return error.InvalidArgs; if (args.len == 2) { const start = try args[0].toInteger(usize); const length = try args[1].toInteger(usize); const arr = try lola.runtime.Array.init(env.allocator, length); for (arr.contents, 0..) |*item, i| { item.* = lola.runtime.Value.initNumber(@as(f64, @floatFromInt(start + i))); } return lola.runtime.Value.fromArray(arr); } else { const length = try args[0].toInteger(usize); const arr = try lola.runtime.Array.init(env.allocator, length); for (arr.contents, 0..) |*item, i| { item.* = lola.runtime.Value.initNumber(@as(f64, @floatFromInt(i))); } return lola.runtime.Value.fromArray(arr); } } pub fn Slice(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = context; if (args.len != 3) return error.InvalidArgs; const array = try args[0].toArray(); const start = try args[1].toInteger(usize); const length = try args[2].toInteger(usize); // Out of bounds if (start >= array.contents.len) return lola.runtime.Value.fromArray(try lola.runtime.Array.init(env.allocator, 0)); const actual_length = @min(length, array.contents.len - start); var arr = try lola.runtime.Array.init(env.allocator, actual_length); errdefer arr.deinit(); for (arr.contents, 0..) |*item, i| { item.* = try array.contents[start + i].clone(); } return lola.runtime.Value.fromArray(arr); } pub fn DeltaEqual(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = env; _ = context; if (args.len != 3) return error.InvalidArgs; const a = try args[0].toNumber(); const b = try args[1].toNumber(); const delta = try args[2].toNumber(); return lola.runtime.Value.initBoolean(@abs(a - b) < delta); } pub fn Floor(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = env; _ = context; if (args.len != 1) return error.InvalidArgs; return lola.runtime.Value.initNumber(@floor(try args[0].toNumber())); } pub fn Ceiling(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = env; _ = context; if (args.len != 1) return error.InvalidArgs; return lola.runtime.Value.initNumber(@ceil(try args[0].toNumber())); } pub fn Round(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = env; _ = context; if (args.len != 1) return error.InvalidArgs; return lola.runtime.Value.initNumber(@round(try args[0].toNumber())); } pub fn Sin(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = env; _ = context; if (args.len != 1) return error.InvalidArgs; return lola.runtime.Value.initNumber(@sin(try args[0].toNumber())); } pub fn Cos(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = env; _ = context; if (args.len != 1) return error.InvalidArgs; return lola.runtime.Value.initNumber(@cos(try args[0].toNumber())); } pub fn Tan(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = env; _ = context; if (args.len != 1) return error.InvalidArgs; return lola.runtime.Value.initNumber(@tan(try args[0].toNumber())); } pub fn Atan(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = env; _ = context; if (args.len == 1) { return lola.runtime.Value.initNumber( std.math.atan(try args[0].toNumber()), ); } else if (args.len == 2) { return lola.runtime.Value.initNumber(std.math.atan2( try args[0].toNumber(), try args[1].toNumber(), )); } else { return error.InvalidArgs; } } pub fn Sqrt(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = env; _ = context; if (args.len != 1) return error.InvalidArgs; return lola.runtime.Value.initNumber(std.math.sqrt(try args[0].toNumber())); } pub fn Pow(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = env; _ = context; if (args.len != 2) return error.InvalidArgs; return lola.runtime.Value.initNumber(std.math.pow( f64, try args[0].toNumber(), try args[1].toNumber(), )); } pub fn Log(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = env; _ = context; if (args.len == 1) { return lola.runtime.Value.initNumber( std.math.log10(try args[0].toNumber()), ); } else if (args.len == 2) { return lola.runtime.Value.initNumber(std.math.log( f64, try args[1].toNumber(), try args[0].toNumber(), )); } else { return error.InvalidArgs; } } pub fn Exp(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = env; _ = context; if (args.len != 1) return error.InvalidArgs; return lola.runtime.Value.initNumber(@exp(try args[0].toNumber())); } pub fn Timestamp(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = env; _ = context; if (args.len != 0) return error.InvalidArgs; return lola.runtime.Value.initNumber(@as(f64, @floatFromInt(milliTimestamp())) / 1000.0); } pub fn TypeOf(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = context; if (args.len != 1) return error.InvalidArgs; return lola.runtime.Value.initString(env.allocator, switch (args[0]) { .void => "void", .boolean => "boolean", .string => "string", .number => "number", .object => "object", .array => "array", .enumerator => "enumerator", }); } pub fn ToString(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = context; if (args.len != 1) return error.InvalidArgs; const str = try std.fmt.allocPrint(env.allocator, "{}", .{args[0]}); return lola.runtime.Value.fromString(lola.runtime.String.initFromOwned(env.allocator, str)); } pub fn HasFunction(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = context; switch (args.len) { 1 => { const name = try args[0].toString(); return lola.runtime.Value.initBoolean(env.functions.get(name) != null); }, 2 => { const obj = try args[0].toObject(); const name = try args[1].toString(); const maybe_method = try env.objectPool.getMethod(obj, name); return lola.runtime.Value.initBoolean(maybe_method != null); }, else => return error.InvalidArgs, } } pub fn Serialize(env: *lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = context; if (args.len != 1) return error.InvalidArgs; const value = args[0]; var string_buffer = std.ArrayList(u8).init(env.allocator); defer string_buffer.deinit(); try value.serialize(string_buffer.writer()); return lola.runtime.Value.fromString(lola.runtime.String.initFromOwned(env.allocator, try string_buffer.toOwnedSlice())); } pub fn Deserialize(env: *lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = context; if (args.len != 1) return error.InvalidArgs; const serialized_string = try args[0].toString(); var stream = std.io.fixedBufferStream(serialized_string); return try lola.runtime.Value.deserialize(stream.reader(), env.allocator); } pub fn Random(env: *lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = context; _ = env; var lower: f64 = 0; var upper: f64 = 1; switch (args.len) { 0 => {}, 1 => upper = try args[0].toNumber(), 2 => { lower = try args[0].toNumber(); upper = try args[1].toNumber(); }, else => return error.InvalidArgs, } var result: f64 = undefined; { random_mutex.lock(); defer random_mutex.unlock(); if (random == null) { random = std.Random.DefaultPrng.init(@as(u64, @bitCast(@as(f64, @floatFromInt(milliTimestamp()))))); } result = lower + (upper - lower) * random.?.random().float(f64); } return lola.runtime.Value.initNumber(result); } pub fn RandomInt(env: *lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value { _ = context; _ = env; var lower: i32 = 0; var upper: i32 = std.math.maxInt(i32); switch (args.len) { 0 => {}, 1 => upper = try args[0].toInteger(i32), 2 => { lower = try args[0].toInteger(i32); upper = try args[1].toInteger(i32); }, else => return error.InvalidArgs, } var result: i32 = undefined; { random_mutex.lock(); defer random_mutex.unlock(); if (random == null) { random = std.Random.DefaultPrng.init(@as(u64, @bitCast(@as(f64, @floatFromInt(milliTimestamp()))))); } result = random.?.random().intRangeLessThan(i32, lower, upper); } return lola.runtime.Value.initInteger(i32, result); } var random_mutex = std.Thread.Mutex{}; var random: ?std.Random.DefaultPrng = null;
0
repos/LoLa/src/library
repos/LoLa/src/library/libraries/runtime.zig
// This file implements the LoLa Runtime Library. const std = @import("std"); const builtin = @import("builtin"); const lola = @import("../main.zig"); const root = @import("root"); const GlobalObjectPool = if (builtin.is_test) // we need to do a workaround here for testing purposes lola.runtime.ObjectPool([_]type{ LoLaList, LoLaDictionary, }) else if (@hasDecl(root, "ObjectPool")) root.ObjectPool else @compileError("Please define and use a global ObjectPool type to use the runtime classes."); comptime { if (builtin.is_test) { const T = lola.runtime.ObjectPool([_]type{ LoLaList, LoLaDictionary, }); if (!T.serializable) @compileError("Both LoLaList and LoLaDictionary must be serializable!"); } } /// empty compile unit for testing purposes const empty_compile_unit = lola.CompileUnit{ .arena = std.heap.ArenaAllocator.init(std.testing.failing_allocator), .comment = "empty compile unit", .globalCount = 0, .temporaryCount = 0, .code = "", .functions = &[0]lola.CompileUnit.Function{}, .debugSymbols = &[0]lola.CompileUnit.DebugSymbol{}, }; test "runtime.install" { var pool = GlobalObjectPool.init(std.testing.allocator); defer pool.deinit(); var env = try lola.runtime.Environment.init(std.testing.allocator, &empty_compile_unit, pool.interface()); defer env.deinit(); try env.installModule(@This(), lola.runtime.Context.null_pointer); } // fn Sleep(call_context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.AsyncFunctionCall { // const allocator = call_context.get(std.mem.Allocator); // if (args.len != 1) // return error.InvalidArgs; // const seconds = try args[0].toNumber(); // const Context = struct { // allocator: std.mem.Allocator, // end_time: f64, // }; // const ptr = try allocator.create(Context); // ptr.* = Context{ // .allocator = allocator, // .end_time = @intToFloat(f64, std.time.milliTimestamp()) + 1000.0 * seconds, // }; // return lola.runtime.AsyncFunctionCall{ // .context = lola.runtime.Context.init(Context, ptr), // .destructor = struct { // fn dtor(exec_context: lola.runtime.Context) void { // const ctx = exec_context.get(Context); // ctx.allocator.destroy(ctx); // } // }.dtor, // .execute = struct { // fn execute(exec_context: lola.runtime.Context) anyerror!?lola.runtime.Value { // const ctx = exec_context.get(Context); // if (ctx.end_time < @intToFloat(f64, std.time.milliTimestamp())) { // return .void; // } else { // return null; // } // } // }.execute, // }; // } pub fn Print(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = environment; _ = context; var stdout = std.io.getStdOut().writer(); for (args) |value| { switch (value) { .string => |str| try stdout.writeAll(str.contents), else => try stdout.print("{}", .{value}), } } try stdout.writeAll("\n"); return .void; } pub fn Exit(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = environment; _ = context; if (args.len != 1) return error.InvalidArgs; const status = try args[0].toInteger(u8); std.process.exit(status); } pub fn ReadFile(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = context; if (args.len != 1) return error.InvalidArgs; const path = try args[0].toString(); var file = std.fs.cwd().openFile(path, .{ .mode = .read_only }) catch return .void; defer file.close(); // 2 GB const contents = try file.readToEndAlloc(environment.allocator, 2 << 30); return lola.runtime.Value.fromString(lola.runtime.String.initFromOwned(environment.allocator, contents)); } pub fn FileExists(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = environment; _ = context; if (args.len != 1) return error.InvalidArgs; const path = try args[0].toString(); var file = std.fs.cwd().openFile(path, .{ .mode = .read_only }) catch return lola.runtime.Value.initBoolean(false); file.close(); return lola.runtime.Value.initBoolean(true); } pub fn WriteFile(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = environment; _ = context; if (args.len != 2) return error.InvalidArgs; const path = try args[0].toString(); const value = try args[1].toString(); var file = try std.fs.cwd().createFile(path, .{}); defer file.close(); try file.writeAll(value); return .void; } pub fn CreateList(environment: *lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = context; if (args.len > 1) return error.InvalidArgs; if (args.len > 0) _ = try args[0].toArray(); const list = try environment.allocator.create(LoLaList); errdefer environment.allocator.destroy(list); list.* = LoLaList{ .allocator = environment.allocator, .data = std.ArrayList(lola.runtime.Value).init(environment.allocator), }; if (args.len > 0) { const array = args[0].toArray() catch unreachable; errdefer list.data.deinit(); try list.data.resize(array.contents.len); for (list.data.items) |*item| { item.* = .void; } errdefer for (list.data.items) |*item| { item.deinit(); }; for (list.data.items, 0..) |*item, index| { item.* = try array.contents[index].clone(); } } return lola.runtime.Value.initObject( try environment.objectPool.castTo(GlobalObjectPool).createObject(list), ); } pub fn CreateDictionary(environment: *lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = context; if (args.len != 0) return error.InvalidArgs; const list = try environment.allocator.create(LoLaDictionary); errdefer environment.allocator.destroy(list); list.* = LoLaDictionary{ .allocator = environment.allocator, .data = std.ArrayList(LoLaDictionary.KV).init(environment.allocator), }; return lola.runtime.Value.initObject( try environment.objectPool.castTo(GlobalObjectPool).createObject(list), ); } pub const LoLaList = struct { const Self = @This(); allocator: std.mem.Allocator, data: std.ArrayList(lola.runtime.Value), pub fn getMethod(self: *Self, name: []const u8) ?lola.runtime.Function { inline for (comptime std.meta.declarations(funcs)) |decl| { if (std.mem.eql(u8, name, decl.name)) { return lola.runtime.Function{ .syncUser = .{ .context = lola.runtime.Context.make(*Self, self), .call = @field(funcs, decl.name), .destructor = null, }, }; } } return null; } pub fn destroyObject(self: *Self) void { for (self.data.items) |*item| { item.deinit(); } self.data.deinit(); self.allocator.destroy(self); } pub fn serializeObject(writer: lola.runtime.OutputStream.Writer, object: *Self) !void { try writer.writeInt(u32, @as(u32, @intCast(object.data.items.len)), .little); for (object.data.items) |item| { try item.serialize(writer); } } pub fn deserializeObject(allocator: std.mem.Allocator, reader: lola.runtime.InputStream.Reader) !*Self { const item_count = try reader.readInt(u32, .little); var list = try allocator.create(Self); list.* = Self{ .allocator = allocator, .data = std.ArrayList(lola.runtime.Value).init(allocator), }; errdefer list.destroyObject(); // this will also free memory! try list.data.resize(item_count); // sane init to make destroyObject not explode // (deinit a void value is a no-op) for (list.data.items) |*item| { item.* = .void; } for (list.data.items) |*item| { item.* = try lola.runtime.Value.deserialize(reader, allocator); } return list; } const funcs = struct { pub fn Add(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = environment; const list = context.cast(*Self); if (args.len != 1) return error.InvalidArgs; var cloned = try args[0].clone(); errdefer cloned.deinit(); try list.data.append(cloned); return .void; } pub fn Remove(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = environment; const list = context.cast(*Self); if (args.len != 1) return error.InvalidArgs; const value = args[0]; var src_index: usize = 0; var dst_index: usize = 0; while (src_index < list.data.items.len) : (src_index += 1) { const eql = list.data.items[src_index].eql(value); if (eql) { // When the element is equal, we destroy and remove it. // std.debug.print("deinit {} ({})\n", .{ // src_index, // list.data.items[src_index], // }); list.data.items[src_index].deinit(); } else { // Otherwise, we move the object to the front of the list skipping // the already removed elements. // std.debug.print("move {} ({}) → {} ({})\n", .{ // src_index, // list.data.items[src_index], // dst_index, // list.data.items[dst_index], // }); if (src_index > dst_index) { list.data.items[dst_index] = list.data.items[src_index]; } dst_index += 1; } } // note: // we don't need to deinit() excess values here as we moved them // above, so they are "twice" in the list. list.data.shrinkRetainingCapacity(dst_index); return .void; } pub fn RemoveAt(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = environment; const list = context.cast(*Self); if (args.len != 1) return error.InvalidArgs; const index = try args[0].toInteger(usize); if (index < list.data.items.len) { list.data.items[index].deinit(); std.mem.copyForwards( lola.runtime.Value, list.data.items[index..], list.data.items[index + 1 ..], ); list.data.shrinkRetainingCapacity(list.data.items.len - 1); } return .void; } pub fn GetCount(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = environment; const list = context.cast(*Self); if (args.len != 0) return error.InvalidArgs; return lola.runtime.Value.initInteger(usize, list.data.items.len); } pub fn GetItem(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = environment; const list = context.cast(*Self); if (args.len != 1) return error.InvalidArgs; const index = try args[0].toInteger(usize); if (index >= list.data.items.len) return error.OutOfRange; return try list.data.items[index].clone(); } pub fn SetItem(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = environment; const list = context.cast(*Self); if (args.len != 2) return error.InvalidArgs; const index = try args[0].toInteger(usize); if (index >= list.data.items.len) return error.OutOfRange; const cloned = try args[1].clone(); list.data.items[index].replaceWith(cloned); return .void; } pub fn ToArray(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = environment; const list = context.cast(*Self); if (args.len != 0) return error.InvalidArgs; var array = try lola.runtime.Array.init(list.allocator, list.data.items.len); errdefer array.deinit(); for (array.contents, 0..) |*item, index| { item.* = try list.data.items[index].clone(); } return lola.runtime.Value.fromArray(array); } pub fn IndexOf(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = environment; const list = context.cast(*Self); if (args.len != 1) return error.InvalidArgs; for (list.data.items, 0..) |item, index| { if (item.eql(args[0])) return lola.runtime.Value.initInteger(usize, index); } return .void; } pub fn Resize(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = environment; const list = context.cast(*Self); if (args.len != 1) return error.InvalidArgs; const new_size = try args[0].toInteger(usize); const old_size = list.data.items.len; if (old_size > new_size) { for (list.data.items[new_size..]) |*item| { item.deinit(); } list.data.shrinkAndFree(new_size); } else if (new_size > old_size) { try list.data.resize(new_size); for (list.data.items[old_size..]) |*item| { item.* = .void; } } return .void; } pub fn Clear(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = environment; const list = context.cast(*Self); if (args.len != 0) return error.InvalidArgs; for (list.data.items) |*item| { item.deinit(); } list.data.shrinkAndFree(0); return .void; } }; }; pub const LoLaDictionary = struct { const Self = @This(); const KV = struct { key: lola.runtime.Value, value: lola.runtime.Value, fn deinit(self: *KV) void { self.key.deinit(); self.value.deinit(); self.* = undefined; } }; allocator: std.mem.Allocator, data: std.ArrayList(KV), pub fn getMethod(self: *Self, name: []const u8) ?lola.runtime.Function { inline for (comptime std.meta.declarations(funcs)) |decl| { if (std.mem.eql(u8, name, decl.name)) { return lola.runtime.Function{ .syncUser = .{ .context = lola.runtime.Context.make(*Self, self), .call = @field(funcs, decl.name), .destructor = null, }, }; } } return null; } pub fn destroyObject(self: *Self) void { for (self.data.items) |*item| { item.deinit(); } self.data.deinit(); self.allocator.destroy(self); } pub fn serializeObject(writer: lola.runtime.OutputStream.Writer, object: *Self) !void { try writer.writeInt(u32, @as(u32, @intCast(object.data.items.len)), .little); for (object.data.items) |item| { try item.key.serialize(writer); try item.value.serialize(writer); } } pub fn deserializeObject(allocator: std.mem.Allocator, reader: lola.runtime.InputStream.Reader) !*Self { const item_count = try reader.readInt(u32, .little); var list = try allocator.create(Self); list.* = Self{ .allocator = allocator, .data = std.ArrayList(KV).init(allocator), }; errdefer list.destroyObject(); // this will also free memory! try list.data.resize(item_count); // sane init to make destroyObject not explode // (deinit a void value is a no-op) for (list.data.items) |*item| { item.* = KV{ .key = .void, .value = .void, }; } for (list.data.items) |*item| { item.key = try lola.runtime.Value.deserialize(reader, allocator); item.value = try lola.runtime.Value.deserialize(reader, allocator); } return list; } const funcs = struct { pub fn Set(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { const dict = context.cast(*Self); if (args.len != 2) return error.InvalidArgs; if (args[1] == .void) { // short-circuit a argument `void` to a call to `Remove(key)` var result = try Remove(environment, context, args[0..1]); result.deinit(); return .void; } var value = try args[1].clone(); errdefer value.deinit(); for (dict.data.items) |*item| { if (item.key.eql(args[0])) { item.value.replaceWith(value); return .void; } } var key = try args[0].clone(); errdefer key.deinit(); try dict.data.append(KV{ .key = key, .value = value, }); return .void; } pub fn Get(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = environment; const dict = context.cast(*Self); if (args.len != 1) return error.InvalidArgs; for (dict.data.items) |item| { if (item.key.eql(args[0])) { return try item.value.clone(); } } return .void; } pub fn Contains(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = environment; const dict = context.cast(*Self); if (args.len != 1) return error.InvalidArgs; for (dict.data.items) |item| { if (item.key.eql(args[0])) { return lola.runtime.Value.initBoolean(true); } } return lola.runtime.Value.initBoolean(false); } pub fn Remove(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = environment; const dict = context.cast(*Self); if (args.len != 1) return error.InvalidArgs; for (dict.data.items, 0..) |*item, index| { if (item.key.eql(args[0])) { // use a fast swap-remove here item.deinit(); const last_index = dict.data.items.len - 1; dict.data.items[index] = dict.data.items[last_index]; dict.data.shrinkRetainingCapacity(last_index); return lola.runtime.Value.initBoolean(true); } } return lola.runtime.Value.initBoolean(false); } pub fn Clear(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = environment; const dict = context.cast(*Self); if (args.len != 0) return error.InvalidArgs; for (dict.data.items) |*item| { item.deinit(); } dict.data.shrinkAndFree(0); return .void; } pub fn GetCount(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = environment; const dict = context.cast(*Self); if (args.len != 0) return error.InvalidArgs; return lola.runtime.Value.initInteger(usize, dict.data.items.len); } pub fn GetKeys(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = environment; const dict = context.cast(*Self); if (args.len != 0) return error.InvalidArgs; var arr = try lola.runtime.Array.init(dict.allocator, dict.data.items.len); errdefer arr.deinit(); for (dict.data.items, 0..) |item, index| { arr.contents[index].replaceWith(try item.key.clone()); } return lola.runtime.Value.fromArray(arr); } pub fn GetValues(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = environment; const dict = context.cast(*Self); if (args.len != 0) return error.InvalidArgs; var arr = try lola.runtime.Array.init(dict.allocator, dict.data.items.len); errdefer arr.deinit(); for (dict.data.items, 0..) |item, index| { arr.contents[index].replaceWith(try item.value.clone()); } return lola.runtime.Value.fromArray(arr); } }; };
0
repos/LoLa/src
repos/LoLa/src/benchmark/perf.zig
//! This tool measures LoLa performance by running a set of different benchmark files const std = @import("std"); const builtin = @import("builtin"); const lola = @import("lola"); // This is required for the runtime library to be able to provide // object implementations. pub const ObjectPool = lola.runtime.ObjectPool([_]type{ lola.libs.runtime.LoLaDictionary, lola.libs.runtime.LoLaList, }); pub fn main() !u8 { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); const argv = try std.process.argsAlloc(gpa.allocator()); defer std.process.argsFree(gpa.allocator(), argv); if (argv.len != 3) { return 1; } const date_time = std.time.epoch.EpochSeconds{ .secs = @as(u64, @intCast(std.time.timestamp())), }; const time = date_time.getDaySeconds(); const date = date_time.getEpochDay(); const year_day = date.calculateYearDay(); const month_day = year_day.calculateMonthDay(); var files = std.ArrayList(Benchmark).init(gpa.allocator()); defer files.deinit(); var string_arena = std.heap.ArenaAllocator.init(gpa.allocator()); defer string_arena.deinit(); const date_string = try std.fmt.allocPrint(string_arena.allocator(), "{d:0>4}-{d:0>2}-{d:0>2} {d:0>2}:{d:0>2}:{d:0>2}", .{ year_day.year, month_day.month.numeric(), month_day.day_index, time.getHoursIntoDay(), time.getMinutesIntoHour(), time.getSecondsIntoMinute(), }); { var dir = try std.fs.cwd().openDir(argv[1], .{ .iterate = true }); defer dir.close(); var iterator = dir.iterate(); while (try iterator.next()) |entry| { const name = try string_arena.allocator().dupe(u8, entry.name); const source = try dir.readFileAlloc(string_arena.allocator(), entry.name, size(1.5, .MeBi)); // 1 MB source const target_file = try std.fmt.allocPrint(string_arena.allocator(), "{s}-{s}.csv", .{ name[0 .. name.len - std.fs.path.extension(name).len], @tagName(builtin.mode), }); try files.append(.{ .file_name = name, .source_code = source, .target_file = target_file, }); } } var output_dir = try std.fs.cwd().openDir(argv[2], .{}); defer output_dir.close(); for (files.items) |benchmark| { const result = benchmark.run(gpa.allocator()) catch |err| { std.log.warn("failed to run benchmark {s}: {s}", .{ benchmark.file_name, @errorName(err), }); continue; }; var file: std.fs.File = if (output_dir.openFile(benchmark.target_file, .{ .mode = .write_only })) |file| file else |_| blk: { var file = try output_dir.createFile(benchmark.target_file, .{}); try file.writeAll("time;compile;setup;run\n"); break :blk file; }; defer file.close(); try file.seekFromEnd(0); try file.writer().print("{s};{d};{d};{d}\n", .{ date_string, result.compile_time, result.setup_time, result.run_time }); } return 0; } pub const Unit = enum(u64) { base = 1, kilo = 1000, KiBi = 1024, mega = 1000 * 1000, MeBi = 1024 * 1024, giga = 1000 * 1000 * 1000, GiBi = 1024 * 1024 * 1024, tera = 1000 * 1000 * 1000 * 1000, TeBi = 1024 * 1024 * 1024 * 1024, }; pub fn size(comptime val: comptime_float, comptime unit: Unit) usize { return @as(usize, @intFromFloat(std.math.floor(@as(f64, @as(comptime_int, @intFromEnum(unit)) * val)))); } pub const BenchmarkResult = struct { build_mode: std.builtin.Mode = builtin.mode, compile_time: u128, setup_time: u128, run_time: u128, }; const Benchmark = struct { file_name: []const u8, source_code: []const u8, target_file: []const u8, pub fn run(self: Benchmark, allocator: std.mem.Allocator) !BenchmarkResult { std.log.info("Running benchmark {s}...", .{self.file_name}); var result = BenchmarkResult{ .compile_time = undefined, .setup_time = undefined, .run_time = undefined, }; const compile_start = std.time.nanoTimestamp(); var diagnostics = lola.compiler.Diagnostics.init(allocator); defer { for (diagnostics.messages.items) |msg| { std.debug.print("{}\n", .{msg}); } diagnostics.deinit(); } // This compiles a piece of source code into a compile unit. // A compile unit is a piece of LoLa IR code with metadata for // all existing functions, debug symbols and so on. It can be loaded into // a environment and be executed. var compile_unit = (try lola.compiler.compile(allocator, &diagnostics, self.file_name, self.source_code)) orelse return error.SyntaxError; defer compile_unit.deinit(); const setup_start = std.time.nanoTimestamp(); result.compile_time = @as(u128, @intCast(setup_start - compile_start)); var pool = ObjectPool.init(allocator); defer pool.deinit(); var env = try lola.runtime.Environment.init(allocator, &compile_unit, pool.interface()); defer env.deinit(); try env.installModule(lola.libs.std, lola.runtime.Context.null_pointer); try env.installModule(lola.libs.runtime, lola.runtime.Context.null_pointer); var vm = try lola.runtime.VM.init(allocator, &env); defer vm.deinit(); const runtime_start = std.time.nanoTimestamp(); result.setup_time = @as(u128, @intCast(runtime_start - setup_start)); while (true) { const res = try vm.execute(1_000_000); pool.clearUsageCounters(); try pool.walkEnvironment(env); try pool.walkVM(vm); pool.collectGarbage(); if (res == .completed) break; } result.run_time = @as(u128, @intCast(std.time.nanoTimestamp() - runtime_start)); return result; } };
0
repos/LoLa/src
repos/LoLa/src/benchmark/render.zig
const std = @import("std"); pub fn main() !u8 { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const argv = try std.process.argsAlloc(gpa.allocator()); defer std.process.argsFree(gpa.allocator(), argv); if (argv.len != 3) { return 1; } var src_dir = try std.fs.cwd().openDir(argv[1], .{ .iterate = true }); defer src_dir.close(); var dst_dir = try std.fs.cwd().openDir(argv[2], .{}); defer dst_dir.close(); var data = std.ArrayList(Series).init(gpa.allocator()); { var iter = src_dir.iterate(); while (try iter.next()) |entry| { if (!std.mem.eql(u8, std.fs.path.extension(entry.name), ".csv")) continue; const name_no_ext = entry.name[0 .. entry.name.len - 4]; const idx = std.mem.lastIndexOfScalar(u8, name_no_ext, '-') orelse continue; var series = Series{ .benchmark = try gpa.allocator().dupe(u8, name_no_ext[0..idx]), .mode = std.meta.stringToEnum(std.builtin.Mode, name_no_ext[idx + 1 ..]) orelse @panic("unexpected name"), .data = undefined, }; var file = try src_dir.openFile(entry.name, .{ .mode = .read_only }); defer file.close(); series.data = try loadSeries(gpa.allocator(), file); std.sort.block(DataPoint, series.data, {}, orderDataPoint); try data.append(series); } } try renderSeriesSet(dst_dir, "compile-ReleaseSafe.svg", data.items, "compile_time", filterReleaseSafe); try renderSeriesSet(dst_dir, "setup-ReleaseSafe.svg", data.items, "setup_time", filterReleaseSafe); try renderSeriesSet(dst_dir, "run-ReleaseSafe.svg", data.items, "run_time", filterReleaseSafe); try renderSeriesSet(dst_dir, "compile-ReleaseSmall.svg", data.items, "compile_time", filterReleaseSmall); try renderSeriesSet(dst_dir, "setup-ReleaseSmall.svg", data.items, "setup_time", filterReleaseSmall); try renderSeriesSet(dst_dir, "run-ReleaseSmall.svg", data.items, "run_time", filterReleaseSmall); try renderSeriesSet(dst_dir, "compile-ReleaseFast.svg", data.items, "compile_time", filterReleaseFast); try renderSeriesSet(dst_dir, "setup-ReleaseFast.svg", data.items, "setup_time", filterReleaseFast); try renderSeriesSet(dst_dir, "run-ReleaseFast.svg", data.items, "run_time", filterReleaseFast); return 0; } pub fn renderSeriesSet(dst_dir: std.fs.Dir, file_name: []const u8, all_series: []Series, comptime field: []const u8, comptime filter: fn (series: Series) bool) !void { var file = try dst_dir.createFile(file_name, .{}); defer file.close(); const writer = file.writer(); var start_time: u128 = std.math.maxInt(u128); var end_time: u128 = 0; var high: f32 = 0; const scale_base = 5; for (all_series) |series| { if (filter(series)) { start_time = @min(start_time, series.data[0].date.getLinearSortVal()); end_time = @max(end_time, series.data[series.data.len - 1].date.getLinearSortVal()); for (series.data) |dp| { high = @max(high, @as(f32, @floatFromInt(@field(dp, field)))); } } } high = std.math.pow(f32, scale_base, @ceil(std.math.log(f32, scale_base, 1.3 * high))); const time_range = end_time - start_time; const size_x: f32 = 350; const size_y: f32 = 200; const legend_size: f32 = 50; const viewport_size: f32 = size_x - legend_size; try writer.print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", .{}); try writer.print("<svg version=\"1.1\" viewBox=\"0 0 {d} {d}\" xmlns=\"http://www.w3.org/2000/svg\">\n", .{ size_x, size_y, }); const color_palette = [_][]const u8{ "#442434", "#30346d", "#4e4a4e", "#854c30", "#346524", "#d04648", "#757161", "#597dce", "#d27d2c", "#8595a1", "#6daa2c", "#d2aa99", "#6dc2ca", "#dad45e", }; var index: u32 = 0; for (all_series) |series| { if (filter(series)) { const color = color_palette[index % color_palette.len]; try writer.print( \\ <text x="{d:.3}" y="{d:.3}" fill="{s}" font-family="sans-serif" font-size="5" xml:space="preserve">{s}</text> \\ , .{ viewport_size + 5, 10 + 7 * index, color, series.benchmark, }); try writer.print(" <path d=\"M", .{}); for (series.data) |dp| { const dx = viewport_size * @as(f32, @floatFromInt(dp.date.getLinearSortVal() - start_time)) / @as(f32, @floatFromInt(time_range)); const dy = size_y * (1.0 - @as(f32, @floatFromInt(@field(dp, field))) / high); try writer.print(" {d:.4} {d:.4}", .{ dx, dy }); } try writer.print("\" fill=\"none\" stroke=\"{s}\" stroke-width=\"1.00\" />\n", .{ color, }); index += 1; } } try writer.print("</svg>\n", .{}); } fn filterReleaseSafe(series: Series) bool { return (series.mode == .ReleaseSafe); } fn filterReleaseSmall(series: Series) bool { return (series.mode == .ReleaseSmall); } fn filterReleaseFast(series: Series) bool { return (series.mode == .ReleaseFast); } fn orderDataPoint(_: void, lhs: DataPoint, rhs: DataPoint) bool { return lhs.date.getLinearSortVal() < rhs.date.getLinearSortVal(); } pub const Date = struct { year: u32, day: u8, month: u8, hour: u8, minute: u8, second: u8, pub fn getLinearSortVal(date: Date) u64 { return 1 * @as(u64, date.second) + 1_00 * @as(u64, date.minute) + 1_00_00 * @as(u64, date.hour) + 1_00_00_00 * @as(u64, date.month) + 1_00_00_00_00 * @as(u64, date.day) + 1_00_00_00_000 * @as(u64, date.year); } }; pub const DataPoint = struct { date: Date, compile_time: u64, setup_time: u64, run_time: u64, }; pub const Series = struct { benchmark: []const u8, mode: std.builtin.Mode, data: []DataPoint, }; pub fn loadSeries(allocator: std.mem.Allocator, file: std.fs.File) ![]DataPoint { const reader = file.reader(); var line_buffer: [4096]u8 = undefined; const first_line = (try reader.readUntilDelimiterOrEof(&line_buffer, '\n')) orelse return error.UnexpectedData; if (!std.mem.eql(u8, first_line, "time;compile;setup;run")) return error.UnexpectedData; var data_set = std.ArrayList(DataPoint).init(allocator); defer data_set.deinit(); while (true) { const line_or_eof = try reader.readUntilDelimiterOrEof(&line_buffer, '\n'); if (line_or_eof) |line| { if (line.len == 0) continue; var iter = std.mem.splitScalar(u8, line, ';'); const time_str = iter.next() orelse return error.UnexpectedData; const compile_str = try std.fmt.parseInt(u64, iter.next() orelse return error.UnexpectedData, 10); const setup_str = try std.fmt.parseInt(u64, iter.next() orelse return error.UnexpectedData, 10); const run_str = try std.fmt.parseInt(u64, iter.next() orelse return error.UnexpectedData, 10); if (time_str.len != 19) return error.UnexpectedData; try data_set.append(DataPoint{ .date = Date{ // 2022-03-14 14:25:56 .year = try std.fmt.parseInt(u32, time_str[0..4], 10), .day = try std.fmt.parseInt(u8, time_str[5..7], 10), .month = try std.fmt.parseInt(u8, time_str[8..10], 10), .hour = try std.fmt.parseInt(u8, time_str[11..13], 10), .minute = try std.fmt.parseInt(u8, time_str[14..16], 10), .second = try std.fmt.parseInt(u8, time_str[17..19], 10), }, .compile_time = compile_str, .setup_time = setup_str, .run_time = run_str, }); } else { break; } } return data_set.toOwnedSlice(); }
0
repos/LoLa/src
repos/LoLa/src/tools/render-md-page.zig
const std = @import("std"); const assert = std.debug.assert; const koino = @import("koino"); const MenuItem = struct { input_file_name: []const u8, output_file_name: []const u8, header: []const u8, }; const menu_items = [_]MenuItem{ MenuItem{ .input_file_name = "documentation/README.md", .output_file_name = "website/docs/language.htm", .header = "Language Reference", }, MenuItem{ .input_file_name = "documentation/standard-library.md", .output_file_name = "website/docs/standard-library.htm", .header = "Standard Library", }, MenuItem{ .input_file_name = "documentation/runtime-library.md", .output_file_name = "website/docs/runtime-library.htm", .header = "Runtime Library", }, MenuItem{ .input_file_name = "documentation/ir.md", .output_file_name = "website/docs/intermediate-language.htm", .header = "IR", }, MenuItem{ .input_file_name = "documentation/modules.md", .output_file_name = "website/docs/module-binary.htm", .header = "Module Format", }, }; pub fn main() !u8 { @setEvalBranchQuota(1500); var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); const allocator = gpa.allocator(); var args = try std.process.argsWithAllocator(allocator); args.deinit(); _ = args.next() orelse return 1; // exe name const version_name = args.next(); for (menu_items, 0..) |current_file, current_index| { const options = koino.Options{ .extensions = .{ .table = true, .autolink = true, .strikethrough = true, }, }; var infile = try std.fs.cwd().openFile(current_file.input_file_name, .{}); defer infile.close(); var markdown = try infile.reader().readAllAlloc(allocator, 1024 * 1024 * 1024); defer allocator.free(markdown); var output = try markdownToHtml(allocator, options, markdown); defer allocator.free(output); var outfile = try std.fs.cwd().createFile(current_file.output_file_name, .{}); defer outfile.close(); try outfile.writeAll( \\<!DOCTYPE html> \\<html lang="en"> \\ \\<head> \\ <meta charset="utf-8"> \\ <meta name="viewport" content="width=device-width, initial-scale=1"> \\ <title>LoLa Documentation</title> \\ <link rel="icon" \\ href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAgklEQVR4AWMYWuD7EllJIM4G4g4g5oIJ/odhOJ8wToOxSTXgNxDHoeiBMfA4+wGShjyYOCkG/IGqWQziEzYAoUAeiF9D5U+DxEg14DRU7jWIT5IBIOdCxf+A+CQZAAoopEB7QJwBCBwHiip8UYmRdrAlDpIMgApwQZNnNii5Dq0MBgCxxycBnwEd+wAAAABJRU5ErkJggg=="> \\ <link rel="stylesheet" href="../documentation.css" /> \\</head> \\ \\<body class="canvas"> \\ <div class="flex-main"> \\ <div class="flex-filler"></div> \\ <div class="flex-left sidebar"> \\ <nav> \\ <div class="logo"> \\ <img src="../img/logo.png" /> \\ </div> \\ <div id="sectPkgs" class=""> \\ <h2><span>Documents</span></h2> \\ <ul id="listPkgs" class="packages"> ); for (menu_items, 0..) |menu, i| { var is_current = (current_index == i); var current_class = if (is_current) @as([]const u8, "class=\"active\"") else ""; try outfile.writer().print( \\<li><a href="{s}" {s}>{s}</a></li> \\ , .{ std.fs.path.basename(menu.output_file_name), current_class, menu.header, }); } var version_name_str = @as(?[]const u8, version_name) orelse @as([]const u8, "development"); try outfile.writer().print( \\ </ul> \\ </div> \\ <div id="sectInfo" class=""> \\ <h2><span>LoLa Version</span></h2> \\ <p class="str" id="tdZigVer">{s}</p> \\ </div> \\ </nav> \\ </div> \\ <div class="flex-right"> \\ <div class="wrap"> \\ <section class="docs"> , .{ version_name_str, }); try outfile.writer().writeAll(output); try outfile.writeAll( \\ </section> \\ </div> \\ <div class="flex-filler"></div> \\ </div> \\ </div> \\</body> \\ \\</html> \\ ); } return 0; } fn markdownToHtmlInternal(resultAllocator: std.mem.Allocator, internalAllocator: std.mem.Allocator, options: koino.Options, markdown: []const u8) ![]u8 { var p = try koino.parser.Parser.init(internalAllocator, options); try p.feed(markdown); var doc = try p.finish(); p.deinit(); defer doc.deinit(); var buffer = std.ArrayList(u8).init(resultAllocator); defer buffer.deinit(); try koino.html.print(buffer.writer(), internalAllocator, p.options, doc); return buffer.toOwnedSlice(); } pub fn markdownToHtml(allocator: std.mem.Allocator, options: koino.Options, markdown: []const u8) ![]u8 { var arena = std.heap.ArenaAllocator.init(allocator); defer arena.deinit(); return markdownToHtmlInternal(allocator, arena.allocator(), options, markdown); }
0
repos/LoLa/src
repos/LoLa/src/frontend/main.zig
const std = @import("std"); const builtin = @import("builtin"); const lola = @import("lola"); const args_parser = @import("args"); const build_options = @import("build_options"); var gpa_state = std.heap.GeneralPurposeAllocator(.{}){}; const gpa = gpa_state.allocator(); // This is our global object pool that is back-referenced // by the runtime library. pub const ObjectPool = lola.runtime.ObjectPool([_]type{ lola.libs.runtime.LoLaList, lola.libs.runtime.LoLaDictionary, }); pub fn main() !u8 { defer _ = gpa_state.deinit(); var cli = args_parser.parseWithVerbForCurrentProcess(struct {}, CliVerb, gpa, .print) catch return 1; defer cli.deinit(); const verb = cli.verb orelse { try print_usage(); return 1; }; switch (verb) { .compile => |options| return try compile(options, cli.positionals), .dump => |options| return try disassemble(options, cli.positionals), .run => |options| return try run(options, cli.positionals), .help => { try print_usage(); return 0; }, .version => { try std.io.getStdOut().writeAll(build_options.version ++ "\n"); return 0; }, } return 0; } pub fn print_usage() !void { const usage_msg = \\Usage: lola [command] [options] \\ \\Commands: \\ compile [source] Compiles the given source file into a module. \\ dump [module] Disassembles the given module. \\ run [file] Runs the given file. Both modules and source files are allowed. \\ version Prints version number and exits. \\ \\General Options: \\ -o [output file] Defines the output file for the action. \\ \\Compile Options: \\ --verify, -v Does not emit the output file, but only runs in-memory checks. \\ This can be used to do syntax checks of the code. \\ \\Disassemble Options: \\ --with-offset, -O Adds offsets to the disassembly. \\ --with-hexdump, -b Adds the hex dump in the disassembly. \\ --metadata Dumps information about the module itself. \\ \\Run Options: \\ --limit [n] Limits execution to [n] instructions, then halts. \\ --mode [autodetect|source|module] Determines if run should interpret the file as a source file, \\ a precompiled module or if it should autodetect the file type. \\ --no-stdlib Removes the standard library from the environment. \\ --no-runtime Removes the system runtime from the environment. \\ --benchmark Runs the script 100 times, measuring the duration of each run and \\ will print a benchmark result in the end. \\ ; // \\ -S Intermixes the disassembly with the original source code if possible. try std.io.getStdErr().writer().writeAll(usage_msg); } const CliVerb = union(enum) { compile: CompileCLI, dump: DisassemblerCLI, run: RunCLI, help: struct {}, version: struct {}, }; const DisassemblerCLI = struct { output: ?[]const u8 = null, metadata: bool = false, @"with-offset": bool = false, @"with-hexdump": bool = false, // @"intermix-source": bool = false, pub const shorthands = .{ // .S = "intermix-source", .b = "with-hexdump", .O = "with-offset", .o = "output", .m = "metadata", }; }; fn disassemble(options: DisassemblerCLI, files: []const []const u8) !u8 { var stream = std.io.getStdOut().writer(); if (files.len == 0) { try print_usage(); return 1; } var logfile: ?std.fs.File = null; defer if (logfile) |f| f.close(); if (options.output) |outfile| { logfile = try std.fs.cwd().createFile(outfile, .{ .read = false, .truncate = true, .exclusive = false, }); stream = logfile.?.writer(); } for (files) |arg| { if (files.len != 1) { try stream.print("Disassembly for {s}:\n", .{arg}); } var arena = std.heap.ArenaAllocator.init(gpa); defer arena.deinit(); const allocator = arena.allocator(); var cu = blk: { var file = try std.fs.cwd().openFile(arg, .{ .mode = .read_only }); defer file.close(); break :blk try lola.CompileUnit.loadFromStream(allocator, file.reader()); }; defer cu.deinit(); if (options.metadata) { try stream.writeAll("metadata:\n"); try stream.print("\tcomment: {s}\n", .{cu.comment}); try stream.print("\tcode size: {d} bytes\n", .{cu.code.len}); try stream.print("\tnum globals: {d}\n", .{cu.globalCount}); try stream.print("\tnum temporaries: {d}\n", .{cu.temporaryCount}); try stream.print("\tnum functions: {d}\n", .{cu.functions.len}); for (cu.functions) |fun| { try stream.print("\t\tep={X:0>4} lc={: >3} {s}\n", .{ fun.entryPoint, fun.localCount, fun.name, }); } try stream.print("\tnum debug syms: {d}\n", .{cu.debugSymbols.len}); try stream.writeAll("disassembly:\n"); } try lola.disassemble(stream, cu, lola.DisassemblerOptions{ .addressPrefix = options.@"with-offset", .hexwidth = if (options.@"with-hexdump") 8 else null, .labelOutput = true, .instructionOutput = true, }); } return 0; } const CompileCLI = struct { output: ?[]const u8 = null, verify: bool = false, pub const shorthands = .{ .o = "output", .v = "verify", }; }; const ModuleBuffer = extern struct { data: [*]u8, length: usize, }; fn compile(options: CompileCLI, files: []const []const u8) !u8 { if (files.len != 1) { try print_usage(); return 1; } const allocator = gpa; const inname = files[0]; const outname = if (options.output) |name| name else blk: { var name = try allocator.alloc(u8, inname.len + 3); @memcpy(name[0..inname.len], inname); @memcpy(name[inname.len..], ".lm"); break :blk name; }; defer if (options.output == null) allocator.free(outname); const cu = compileFileToUnit(allocator, inname) catch |err| switch (err) { error.CompileError => return 1, else => |e| return e, }; defer cu.deinit(); if (!options.verify) { var file = try std.fs.cwd().createFile(outname, .{ .truncate = true, .read = false, .exclusive = false }); defer file.close(); try cu.saveToStream(file.writer()); } return 0; } const RunCLI = struct { limit: ?u32 = null, mode: enum { autodetect, source, module } = .autodetect, @"no-stdlib": bool = false, @"no-runtime": bool = false, benchmark: bool = false, }; fn autoLoadModule(allocator: std.mem.Allocator, options: RunCLI, file: []const u8) !lola.CompileUnit { return switch (options.mode) { .autodetect => loadModuleFromFile(allocator, file) catch |err| if (err == error.InvalidFormat) try compileFileToUnit(allocator, file) else return err, .module => try loadModuleFromFile(allocator, file), .source => try compileFileToUnit(allocator, file), }; } fn run(options: RunCLI, files: []const []const u8) !u8 { if (files.len != 1) { try print_usage(); return 1; } const allocator = gpa; var cu = autoLoadModule(allocator, options, files[0]) catch |err| { const stderr = std.io.getStdErr().writer(); if (err == error.FileNotFound) { try stderr.print("Could not find '{s}'. Are you sure you passed the right file?\n", .{files[0]}); return 1; } try stderr.writeAll(switch (options.mode) { .autodetect => "Failed to run file: File seems not to be a compiled module or source file!\n", .module => "Failed to run file: File seems not to be a compiled module.\n", .source => return 1, // We already have the diagnostic output of the compiler anyways }); if (err != error.InvalidFormat and err != error.CompileError) { try stderr.print("The following error happened: {s}\n", .{ @errorName(err), }); } return 1; }; defer cu.deinit(); var pool = ObjectPool.init(allocator); defer pool.deinit(); var env = try lola.runtime.Environment.init(allocator, &cu, pool.interface()); defer env.deinit(); if (!options.@"no-stdlib") { try env.installModule(lola.libs.std, lola.runtime.Context.null_pointer); } if (!options.@"no-runtime") { try env.installModule(lola.libs.runtime, lola.runtime.Context.null_pointer); // Move these two to a test runner try env.installFunction("Expect", lola.runtime.Function.initSimpleUser(struct { fn call(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = environment; _ = context; if (args.len != 1) return error.InvalidArgs; const assertion = try args[0].toBoolean(); if (!assertion) return error.AssertionFailed; return .void; } }.call)); try env.installFunction("ExpectEqual", lola.runtime.Function.initSimpleUser(struct { fn call(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value { _ = environment; _ = context; if (args.len != 2) return error.InvalidArgs; if (!args[0].eql(args[1])) { std.log.err("Expected {}, got {}\n", .{ args[1], args[0] }); return error.AssertionFailed; } return .void; } }.call)); } if (options.benchmark == false) { var vm = try lola.runtime.VM.init(allocator, &env); defer vm.deinit(); while (true) { const result = vm.execute(options.limit) catch |err| { var stderr = std.io.getStdErr().writer(); if (builtin.mode == .Debug) { if (@errorReturnTrace()) |err_trace| { std.debug.dumpStackTrace(err_trace.*); } else { try stderr.print("Panic during execution: {s}\n", .{@errorName(err)}); } } else { try stderr.print("Panic during execution: {s}\n", .{@errorName(err)}); } try stderr.print("Call stack:\n", .{}); try vm.printStackTrace(stderr); return 1; }; pool.clearUsageCounters(); try pool.walkEnvironment(env); try pool.walkVM(vm); pool.collectGarbage(); switch (result) { .completed => return 0, .exhausted => { try std.io.getStdErr().writer().print("Execution exhausted after {?d} instructions!\n", .{ options.limit, }); return 1; }, .paused => { // continue execution here std.time.sleep(100); // sleep at least 100 ns and return control to scheduler }, } } } else { var cycle: usize = 0; var stats = lola.runtime.VM.Statistics{}; var total_time: u64 = 0; var total_timer = try std.time.Timer.start(); // Run at least one second while ((cycle < 100) or (total_timer.read() < std.time.ns_per_s)) : (cycle += 1) { var vm = try lola.runtime.VM.init(allocator, &env); defer vm.deinit(); var timer = try std.time.Timer.start(); emulation: while (true) { const result = vm.execute(options.limit) catch |err| { const stderr = std.io.getStdErr().writer(); try stderr.print("Panic during execution: {s}\n", .{@errorName(err)}); try stderr.print("Call stack:\n", .{}); try vm.printStackTrace(stderr); return 1; }; pool.clearUsageCounters(); try pool.walkEnvironment(env); try pool.walkVM(vm); pool.collectGarbage(); switch (result) { .completed => break :emulation, .exhausted => { try std.io.getStdErr().writer().print("Execution exhausted after {?d} instructions!\n", .{ options.limit, }); return 1; }, .paused => {}, } } total_time += timer.lap(); stats.instructions += vm.stats.instructions; stats.stalls += vm.stats.stalls; } try std.io.getStdErr().writer().print( \\Benchmark result: \\ Number of runs: {d} \\ Mean time: {d} µs \\ Mean #instructions: {d} \\ Mean #stalls: {d} \\ Mean instruction/s: {d} \\ , .{ cycle, (@as(f64, @floatFromInt(total_time)) / @as(f64, @floatFromInt(cycle))) / std.time.ns_per_us, @as(f64, @floatFromInt(stats.instructions)) / @as(f64, @floatFromInt(cycle)), @as(f64, @floatFromInt(stats.stalls)) / @as(f64, @floatFromInt(cycle)), std.time.ns_per_s * @as(f64, @floatFromInt(stats.instructions)) / @as(f64, @floatFromInt(total_time)), }); } return 0; } fn compileFileToUnit(allocator: std.mem.Allocator, fileName: []const u8) !lola.CompileUnit { const maxLength = 1 << 20; // 1 MB const source = blk: { var file = try std.fs.cwd().openFile(fileName, .{ .mode = .read_only }); defer file.close(); break :blk try file.reader().readAllAlloc(gpa, maxLength); }; defer gpa.free(source); var diag = lola.compiler.Diagnostics.init(allocator); defer { for (diag.messages.items) |msg| { std.debug.print("{}\n", .{msg}); } diag.deinit(); } const seq = try lola.compiler.tokenizer.tokenize(allocator, &diag, fileName, source); defer allocator.free(seq); var pgm = try lola.compiler.parser.parse(allocator, &diag, seq); defer pgm.deinit(); const successful = try lola.compiler.validate(allocator, &diag, pgm); if (!successful) return error.CompileError; const compile_unit = try lola.compiler.generateIR(allocator, pgm, fileName); errdefer compile_unit; return compile_unit; } fn loadModuleFromFile(allocator: std.mem.Allocator, fileName: []const u8) !lola.CompileUnit { var file = try std.fs.cwd().openFile(fileName, .{ .mode = .read_only }); defer file.close(); return try lola.CompileUnit.loadFromStream(allocator, file.reader()); }
0
repos/LoLa/examples/host
repos/LoLa/examples/host/multi-environment/main.zig
const std = @import("std"); const lola = @import("lola"); //// // Multi-environment communication example: // In this example, we have three scripts: // server.lola: Exporting a simple key-value store // client-a.lola: Writes "Hello, World!" into the store in server // client-b.lola: Reads the message from the server and prints it // // Real world application: // This shows the inter-environment communication capabilities of LoLa, // which is useful for games with interactive computer systems that need // to interact with each other in a user-scriptable way. // // Each computer is its own environment, providing a simple script. // Computers/Environments can communicate via a object interface, exposing // other computers as a LoLa object and allowing those environments to // communicate with each other. // pub const ObjectPool = lola.runtime.ObjectPool([_]type{ lola.libs.runtime.LoLaDictionary, lola.libs.runtime.LoLaList, // Environment is a non-serializable object. If you need to serialize a whole VM state with cross-references, // provide your own wrapper implementation lola.runtime.Environment, }); pub fn main() anyerror!u8 { var gpa_state = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa_state.deinit(); const allocator = gpa_state.allocator(); var diagnostics = lola.compiler.Diagnostics.init(allocator); defer { for (diagnostics.messages.items) |msg| { std.debug.print("{}\n", .{msg}); } diagnostics.deinit(); } var server_unit = (try lola.compiler.compile(allocator, &diagnostics, "server.lola", @embedFile("server.lola"))) orelse return 1; defer server_unit.deinit(); var client_a_unit = (try lola.compiler.compile(allocator, &diagnostics, "client-a.lola", @embedFile("client-a.lola"))) orelse return 1; defer client_a_unit.deinit(); var client_b_unit = (try lola.compiler.compile(allocator, &diagnostics, "client-b.lola", @embedFile("client-b.lola"))) orelse return 1; defer client_b_unit.deinit(); var pool = ObjectPool.init(allocator); defer pool.deinit(); var server_env = try lola.runtime.Environment.init(allocator, &server_unit, pool.interface()); defer server_env.deinit(); var client_a_env = try lola.runtime.Environment.init(allocator, &client_a_unit, pool.interface()); defer client_a_env.deinit(); var client_b_env = try lola.runtime.Environment.init(allocator, &client_b_unit, pool.interface()); defer client_b_env.deinit(); for ([_]*lola.runtime.Environment{ &server_env, &client_a_env, &client_b_env }) |env| { try env.installModule(lola.libs.std, lola.runtime.Context.null_pointer); try env.installModule(lola.libs.runtime, lola.runtime.Context.null_pointer); } var server_obj_handle = try pool.createObject(&server_env); // Important: The environment is stored in the ObjectPool, // but will be destroyed earlier by us, so we have to remove it // from the pool before we destroy `server_env`! defer pool.destroyObject(server_obj_handle); const getServerFunction = lola.runtime.Function{ .syncUser = .{ .context = lola.runtime.Context.make(*lola.runtime.ObjectHandle, &server_obj_handle), .call = struct { fn call( environment: *lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value, ) anyerror!lola.runtime.Value { _ = environment; _ = args; return lola.runtime.Value.initObject(context.cast(*lola.runtime.ObjectHandle).*); } }.call, .destructor = null, }, }; try client_a_env.installFunction("GetServer", getServerFunction); try client_b_env.installFunction("GetServer", getServerFunction); // First, initialize the server and let it initialize `storage`. { var vm = try lola.runtime.VM.init(allocator, &server_env); defer vm.deinit(); const result = try vm.execute(null); if (result != .completed) return error.CouldNotCompleteCode; } // Then, let Client A execute { var vm = try lola.runtime.VM.init(allocator, &client_a_env); defer vm.deinit(); const result = try vm.execute(null); if (result != .completed) return error.CouldNotCompleteCode; } // Then, let Client B execute { var vm = try lola.runtime.VM.init(allocator, &client_b_env); defer vm.deinit(); const result = try vm.execute(null); if (result != .completed) return error.CouldNotCompleteCode; } return 0; }
0
repos/LoLa/examples/host
repos/LoLa/examples/host/minimal-host/main.zig
const std = @import("std"); const lola = @import("lola"); //// // Minimal API example: // This example shows how to get started with the LoLa library. // Compiles and runs the Hello-World program. // const example_source = \\Print("Hello, World!"); \\ ; // This is required for the runtime library to be able to provide // object implementations. pub const ObjectPool = lola.runtime.ObjectPool([_]type{ lola.libs.runtime.LoLaDictionary, lola.libs.runtime.LoLaList, }); pub fn main() anyerror!u8 { var gpa_state = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa_state.deinit(); const allocator = gpa_state.allocator(); // Step 1: Compile the source code into a compile unit // This stores the error messages and warnings, we // just keep it and print all messages on exit (if any). var diagnostics = lola.compiler.Diagnostics.init(allocator); defer { for (diagnostics.messages.items) |msg| { std.debug.print("{}\n", .{msg}); } diagnostics.deinit(); } // This compiles a piece of source code into a compile unit. // A compile unit is a piece of LoLa IR code with metadata for // all existing functions, debug symbols and so on. It can be loaded into // a environment and be executed. var compile_unit = (try lola.compiler.compile(allocator, &diagnostics, "example_source", example_source)) orelse { std.debug.print("failed to compile example_source!\n", .{}); return 1; }; defer compile_unit.deinit(); // A object pool is required for garabge collecting object handles // stored in several LoLa environments and virtual machines. var pool = ObjectPool.init(allocator); defer pool.deinit(); // A environment stores global variables and provides functions // to the virtual machines. It is also a possible LoLa object that // can be passed into virtual machines. var env = try lola.runtime.Environment.init(allocator, &compile_unit, pool.interface()); defer env.deinit(); // Install both standard and runtime library into // our environment. You can see how to implement custom // functions if you check out the implementation of both // libraries! try env.installModule(lola.libs.std, lola.runtime.Context.null_pointer); try env.installModule(lola.libs.runtime, lola.runtime.Context.null_pointer); // Create a virtual machine that is used to execute LoLa bytecode. // Using `.init` will always run the top-level code. var vm = try lola.runtime.VM.init(allocator, &env); defer vm.deinit(); // The main interpreter loop: while (true) { // Run the virtual machine for up to 150 instructions const result = vm.execute(150) catch |err| { // When the virtua machine panics, we receive a Zig error std.debug.print("LoLa panic: {s}\n", .{@errorName(err)}); return 1; }; // Prepare a garbage collection cycle: pool.clearUsageCounters(); // Mark all objects currently referenced in the environment try pool.walkEnvironment(env); // Mark all objects currently referenced in the virtual machine try pool.walkVM(vm); // Delete all objects that are not referenced by our system anymore pool.collectGarbage(); switch (result) { // This means that our script execution has ended and // the top-level code has come to an end .completed => break, // This means the VM has exhausted its provided instruction quota // and returned control to the host. .exhausted => { std.debug.print("Execution exhausted after 150 instructions!\n", .{}); }, // This means the virtual machine was suspended via a async function call. .paused => std.time.sleep(100), } } return 0; }
0
repos/LoLa/examples/host
repos/LoLa/examples/host/serialization/main.zig
const std = @import("std"); const lola = @import("lola"); //// // Serialization API example: // This example shows how to save a whole-program state into a buffer // and restore that later to continue execution. // // NOTE: This example is work-in-progress! const example_source = \\for(i in Range(1, 100)) { \\ Print("Round ", i); \\} ; pub const ObjectPool = lola.runtime.ObjectPool([_]type{ lola.libs.runtime.LoLaDictionary, lola.libs.runtime.LoLaList, }); pub fn main() anyerror!void { // this will store our intermediate data var serialization_buffer: [4096]u8 = undefined; { var gpa_state = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa_state.deinit(); try run_serialization( gpa_state.allocator(), &serialization_buffer, ); } { var stdout = std.io.getStdOut().writer(); try stdout.writeAll("\n"); try stdout.writeAll("-----------------------------------\n"); try stdout.writeAll("\n"); } { var gpa_state = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa_state.deinit(); try run_deserialization( gpa_state.allocator(), &serialization_buffer, ); } } fn run_serialization(allocator: std.mem.Allocator, serialization_buffer: []u8) !void { var diagnostics = lola.compiler.Diagnostics.init(allocator); defer { for (diagnostics.messages.items) |msg| { std.debug.print("{}\n", .{msg}); } diagnostics.deinit(); } var compile_unit = (try lola.compiler.compile(allocator, &diagnostics, "example_source", example_source)) orelse return error.FailedToCompile; defer compile_unit.deinit(); var pool = ObjectPool.init(allocator); defer pool.deinit(); var env = try lola.runtime.Environment.init(allocator, &compile_unit, pool.interface()); defer env.deinit(); try env.installModule(lola.libs.std, lola.runtime.Context.null_pointer); try env.installModule(lola.libs.runtime, lola.runtime.Context.null_pointer); var vm = try lola.runtime.VM.init(allocator, &env); defer vm.deinit(); const result = try vm.execute(405); std.debug.assert(result == .exhausted); // we didn't finish running our nice example const stdout = std.io.getStdOut().writer(); try stdout.writeAll("Suspend at\n"); try vm.printStackTrace(stdout); { var stream = std.io.fixedBufferStream(serialization_buffer); const writer = stream.writer(); try compile_unit.saveToStream(writer); // This saves all objects associated with their handles. // This will only work when all object classes are serializable though. try pool.serialize(writer); // this saves all global variables saved in the environment try env.serialize(writer); var registry = lola.runtime.EnvironmentMap.init(allocator); defer registry.deinit(); try registry.add(1234, &env); // This saves the current virtual machine state try vm.serialize(&registry, writer); try stdout.print("saved state to {} bytes!\n", .{ stream.getWritten().len, }); } } fn run_deserialization(allocator: std.mem.Allocator, serialization_buffer: []u8) !void { var stream = std.io.fixedBufferStream(serialization_buffer); const reader = stream.reader(); // Trivial deserialization: // Just load the compile unit from disk again var compile_unit = try lola.CompileUnit.loadFromStream(allocator, reader); defer compile_unit.deinit(); // This is the reason we need to specialize lola.runtime.ObjectPool() on // a type list: // We need a way to do generic deserialization (arbitrary types) and it requires // a way to get a runtime type-handle and turn it back into a deserialization function. // this is done by storing the type indices per created object which can then be turned back // into a real lola.runtime.Object. var object_pool = try ObjectPool.deserialize(allocator, reader); defer object_pool.deinit(); // Environments cannot be deserialized directly from a stream: // Each environment contains function pointers and references its compile unit. // Both of these things cannot be done by a pure stream serialization. // Thus, we need to restore the constant part of the environment by hand and // install all functions as well: var env = try lola.runtime.Environment.init(allocator, &compile_unit, object_pool.interface()); defer env.deinit(); // Installs the functions back into the environment. try env.installModule(lola.libs.std, lola.runtime.Context.null_pointer); try env.installModule(lola.libs.runtime, lola.runtime.Context.null_pointer); // This will restore the whole environment state back to how it was at serialization // time. All globals will be restored here. try env.deserialize(reader); // This is needed for deserialization: // We need means to have a unique Environment <-> ID mapping // which is persistent over the serialization process. var registry = lola.runtime.EnvironmentMap.init(allocator); defer registry.deinit(); // Here we need to add all environments that were previously serialized with // the same IDs as before. try registry.add(1234, &env); // Restore the virtual machine with all function calls. var vm = try lola.runtime.VM.deserialize(allocator, &registry, reader); defer vm.deinit(); var stdout = std.io.getStdOut().writer(); try stdout.print("restored state with {} bytes!\n", .{ stream.getWritten().len, }); try stdout.writeAll("Resume at\n"); try vm.printStackTrace(stdout); // let the program finish _ = try vm.execute(null); }
0
repos/LoLa/examples
repos/LoLa/examples/lola/README.md
# LoLa Examples - [Hello World](hello-world.lola) - [Iterative Fibonacci Numbers](fib-iterative.lola) - [Summing up an array](sum-of-array.lola) - [Reverse Array](reverse-array.lola) - [Bubble Sort](bubble-sort.lola) - [Global Variable Usage](global-setter.lola)
0
repos/LoLa
repos/LoLa/design/README.md
# LoLa Design The logo is not licenced under MIT licence! Do not use this in anywhere without previous agreement with Felix Queißner ([email protected])! Logo design by [https://www.artbyluphalia.com/](www.artbyluphalia.com). Give her a visit!
0
repos/LoLa
repos/LoLa/website/style.css
@font-face { font-family: 'PT Sans'; font-style: normal; font-weight: 400; font-display: swap; src: local('PT Sans'), local('PTSans-Regular'), url(fonts/PT_Sans/PTSans-Regular.ttf) format('truetype'); } @font-face { font-family: 'Source Code Pro'; font-style: normal; font-weight: 400; font-display: swap; src: local('Source Code Pro Regular'), local('SourceCodePro-Regular'), url(fonts/Source_Code_Pro/SourceCodePro-Regular.ttf) format('truetype'); } * { box-sizing: border-box; } html { margin: 0; padding: 0; font-family: 'PT Sans', sans-serif; } body { margin: 0; padding: 0; max-width: 60em; margin-left: auto; margin-right: auto; } a.anchor { display: block; position: relative; top: -9em; visibility: hidden; } nav { position: sticky; top: 0; background-color: #ffffff; padding: 0; margin: 0; display: flex; flex-wrap: wrap; justify-content: center; box-shadow: 0px 0.4vw 1vw -.1vw rgba(0, 0, 54, 0.2); border-radius: .0vw .0vw .4vw .4vw; } nav a { text-decoration: none; color: black; } a { transition: text-shadow 0.2s linear; text-shadow: 0vw 0vw 0vw rgba(0,0,0,0); } a:hover { text-decoration: underline; text-shadow: 0.01vw 0.2vw 0.5vw rgba(0,0,0,0.2); } nav h1 { display: inline-block; margin: 0; padding: 1em; align-self: center; } nav ul { display: inline-block; list-style: none; padding: 0; margin: 0; align-self: center; } nav ul li { display: inline-block; padding-left: 0.25em; padding-right: 0.25em; height: 100%; } .teaser, .features, .content { padding-left: 2em; padding-right: 2em; } .teaser { background: linear-gradient(to bottom, rgba(75,75,232,0.3) 0%, rgba(32,124,229,0.3) 100%); font-size: 1.2em; padding-top: 1.5em; padding-bottom: 1.5em; display: flex; flex-wrap: wrap-reverse; justify-content: center; box-shadow: 0px 0.6vw 1vw -.1vw rgba(0, 0, 54, 0.2) inset; border-radius: .3vw .3vw .3vw .3vw; margin-top: 0.75vw; } .teaser .text { flex: 1; } a { color: blueviolet; font-weight: bold; } .teaser .logo { width: 10em; height: 10em; border-radius: .3vw .3vw .3vw .3vw; } .features { padding-top: 1em; padding-bottom: 1em; } .features .group { display: flex; flex-wrap: wrap; justify-content: center; } .features .group:nth-of-type(even) { flex-wrap: wrap-reverse; } .features h3 { margin: 0; margin-bottom: 0.5em; } .features p img { vertical-align: bottom; height: 1em; } .features .group .text, .features .group .preview { margin: 0.5em; } .features .group .text { flex: 1; max-width: 50em; } .features .group .preview { display: block; width: 30%; min-width: 20em; padding: 0.5em; background-color: rgba(32,124,229,0.2); color: rgb(0, 0, 0); font-family: 'Source Code Pro', monospace; font-size: 1.3em; display: inline-table; box-shadow: 0px 0.2vw 1vw -.1vw rgba(0, 0, 54, 0.2) inset; border-radius: .3vw .3vw .3vw .3vw; } .features .preview pre { margin: 0; padding: 1% 1% 1% 1%; } .features .float-left { float: left; margin-right: 1em; } .features .float-right { float: right; margin-left: 1em; } .features hr { clear: both; margin-top: 0.1em; margin-bottom: 0.1em; visibility: hidden; } .content p { margin-left: 1em; } .content ul li { line-height: 1.4em; } code .kw { color: #a52fff; } code .string { color: #ff6ba1; } code .comment { color: rgb(255, 91, 159); }
0
repos/LoLa
repos/LoLa/website/documentation.css
:root { font-size: 1em; --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; --mono: "Source Code Pro", monospace; --tx-color: #141414; --bg-color: #ffffff; --link-color: #2A6286; --sidebar-sh-color: rgba(0, 0, 0, 0.09); --sidebar-pkg-bg-color: #f1f1f1; --sidebar-pkglnk-tx-color: #141414; --sidebar-pkglnk-tx-color-hover: #fff; --sidebar-pkglnk-tx-color-active: #000; --sidebar-pkglnk-bg-color: transparent; --sidebar-pkglnk-bg-color-hover: #555; --sidebar-pkglnk-bg-color-active: #FFBB4D; --search-bg-color: #f3f3f3; --search-bg-color-focus: #ffffff; --search-sh-color: rgba(0, 0, 0, 0.18); --help-sh-color: rgba(0, 0, 0, 0.75); } html, body { margin: 0; padding: 0; height: 100%; } a { text-decoration: none; } a:hover { text-decoration: underline; } .hidden { display: none; } /* layout */ .canvas { width: 100vw; height: 100vh; overflow: hidden; margin: 0; padding: 0; font-family: var(--ui); color: var(--tx-color); background-color: var(--bg-color); } .flex-main { display: flex; width: 100%; height: 100%; justify-content: center; z-index: 100; } .flex-filler { flex-grow: 1; flex-shrink: 1; } .flex-left { width: 12rem; max-width: 15vw; min-width: 9.5rem; overflow: auto; -webkit-overflow-scrolling: touch; overflow-wrap: break-word; flex-shrink: 0; flex-grow: 0; z-index: 300; } .flex-right { display: flex; overflow: auto; -webkit-overflow-scrolling: touch; flex-grow: 1; flex-shrink: 1; z-index: 200; } .flex-right>.wrap { width: 60rem; max-width: 85vw; flex-shrink: 1; } .help-modal { z-index: 400; } /* sidebar */ .sidebar { font-size: 1rem; background-color: var(--bg-color); box-shadow: 0 0 1rem var(--sidebar-sh-color); } .sidebar .logo { padding: 1rem 0.35rem 0.35rem 0.35rem; } .sidebar .logo>svg, .sidebar .logo>img { display: block; overflow: visible; } .sidebar .logo>img { width: 100%; } .sidebar h2 { margin: 0.5rem; padding: 0; font-size: 1.2rem; } .sidebar h2>span { border-bottom: 0.125rem dotted var(--tx-color); } .sidebar .packages { list-style-type: none; margin: 0; padding: 0; background-color: var(--sidebar-pkg-bg-color); } .sidebar .packages>li>a { display: block; padding: 0.5rem 1rem; color: var(--sidebar-pkglnk-tx-color); background-color: var(--sidebar-pkglnk-bg-color); text-decoration: none; } .sidebar .packages>li>a:hover { color: var(--sidebar-pkglnk-tx-color-hover); background-color: var(--sidebar-pkglnk-bg-color-hover); } .sidebar .packages>li>a.active { color: var(--sidebar-pkglnk-tx-color-active); background-color: var(--sidebar-pkglnk-bg-color-active); } .sidebar p.str { margin: 0.5rem; font-family: var(--mono); } /* docs section */ .docs { padding: 1rem 0.7rem 2.4rem 1.4rem; font-size: 1rem; background-color: var(--bg-color); overflow-wrap: break-word; } .docs .search { width: 100%; margin-bottom: 0.8rem; padding: 0.5rem; font-size: 1rem; font-family: var(--ui); color: var(--tx-color); background-color: var(--search-bg-color); border-top: 0; border-left: 0; border-right: 0; border-bottom-width: 0.125rem; border-bottom-style: solid; border-bottom-color: var(--tx-color); outline: none; transition: border-bottom-color 0.35s, background 0.35s, box-shadow 0.35s; border-radius: 0; -webkit-appearance: none; } .docs .search:focus { background-color: var(--search-bg-color-focus); border-bottom-color: #ffbb4d; box-shadow: 0 0.3em 1em 0.125em var(--search-sh-color); } .docs .search::placeholder { font-size: 1rem; font-family: var(--ui); color: var(--tx-color); opacity: 0.5; } .docs a { color: var(--link-color); } .docs p { margin: 0.8rem 0; } .docs pre { font-family: var(--mono); font-size: 1em; background-color: #F5F5F5; padding: 1em; overflow-x: auto; } .docs code { font-family: var(--mono); font-size: 1em; } .docs h1 { font-size: 1.4em; margin: 0.8em 0; padding: 0; border-bottom: 0.0625rem dashed; } .docs h2 { font-size: 1.3em; margin: 0.5em 0; padding: 0; border-bottom: 0.0625rem solid; } #listNav { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #f1f1f1; } #listNav li { float: left; } #listNav li a { display: block; color: #000; text-align: center; padding: .5em .8em; text-decoration: none; } #listNav li a:hover { background-color: #555; color: #fff; } #listNav li a.active { background-color: #FFBB4D; color: #000; } #listSearchResults li.selected { background-color: #93e196; } #tableFnErrors dt { font-weight: bold; } .examples { list-style-type: none; margin: 0; padding: 0; } .examples li { padding: 0.5em 0; white-space: nowrap; overflow-x: auto; } .docs td { margin: 0; padding: 0.5em; max-width: 27em; text-overflow: ellipsis; overflow-x: hidden; } /* help dialog */ .help-modal { display: flex; width: 100%; height: 100%; position: fixed; top: 0; left: 0; justify-content: center; align-items: center; background-color: rgba(0, 0, 0, 0.15); backdrop-filter: blur(0.3em); } .help-modal>.dialog { max-width: 97vw; max-height: 97vh; overflow: auto; font-size: 1rem; color: #fff; background-color: #333; border: 0.125rem solid #000; box-shadow: 0 0.5rem 2.5rem 0.3rem var(--help-sh-color); } .help-modal h1 { margin: 0.75em 2.5em 1em 2.5em; font-size: 1.5em; text-align: center; } .help-modal dt, .help-modal dd { display: inline; margin: 0 0.2em; } .help-modal dl { margin-left: 0.5em; margin-right: 0.5em; } .help-modal kbd { display: inline-block; padding: 0.3em 0.2em; font-size: 1.2em; font-size: var(--mono); line-height: 0.8em; vertical-align: middle; color: #000; background-color: #fafbfc; border-color: #d1d5da; border-bottom-color: #c6cbd1; border: solid 0.0625em; border-radius: 0.1875em; box-shadow: inset 0 -0.0625em 0 #c6cbd1; cursor: default; } /* tokens */ .tok-kw { color: #333; font-weight: bold; } .tok-str { color: #d14; } .tok-builtin { color: #0086b3; } .tok-comment { color: #777; font-style: italic; } .tok-fn { color: #900; font-weight: bold; } .tok-null { color: #008080; } .tok-number { color: #008080; } .tok-type { color: #458; font-weight: bold; } /* dark mode */ @media (prefers-color-scheme: dark) { :root { --tx-color: #bbb; --bg-color: #111; --link-color: #88f; --sidebar-sh-color: rgba(128, 128, 128, 0.09); --sidebar-pkg-bg-color: #333; --sidebar-pkglnk-tx-color: #fff; --sidebar-pkglnk-tx-color-hover: #fff; --sidebar-pkglnk-tx-color-active: #000; --sidebar-pkglnk-bg-color: transparent; --sidebar-pkglnk-bg-color-hover: #555; --sidebar-pkglnk-bg-color-active: #FFBB4D; --search-bg-color: #3c3c3c; --search-bg-color-focus: #000; --search-sh-color: rgba(255, 255, 255, 0.28); --help-sh-color: rgba(142, 142, 142, 0.5); } .docs pre { background-color: #2A2A2A; } #listNav { background-color: #333; } #listNav li a { color: #fff; } #listNav li a:hover { background-color: #555; color: #fff; } #listNav li a.active { background-color: #FFBB4D; color: #000; } #listSearchResults li.selected { background-color: #000; } #listSearchResults li.selected a { color: #fff; } .tok-kw { color: #eee; } .tok-str { color: #2e5; } .tok-builtin { color: #ff894c; } .tok-comment { color: #aa7; } .tok-fn { color: #e33; } .tok-null { color: #ff8080; } .tok-number { color: #ff8080; } .tok-type { color: #68f; } } @media only screen and (max-width: 750px) { .canvas { overflow: auto; } .flex-main { flex-direction: column; display: block; } .sidebar { min-width: calc(100vw - 2.8rem); padding-left: 1.4rem; padding-right: 1.4rem; } .logo { max-width: 6.5rem; } .flex-main>.flex-filler { display: none; } .flex-main>.flex-right>.flex-filler { display: none; } .flex-main>.flex-right>.wrap { max-width: 100vw; } .flex-main>.flex-right>.wrap>.docs { padding-right: 1.4rem; background: transparent; } .packages { display: flex; flex-wrap: wrap; } .table-container table { display: flex; flex-direction: column; } .table-container tr { display: flex; flex-direction: column; } .examples { overflow-x: scroll; -webkit-overflow-scrolling: touch; max-width: 100vw; margin-left: -1.4rem; margin-right: -1.4rem; } .examples li { width: max-content; padding-left: 1.4rem; padding-right: 1.4rem; } .mobile-scroll-container { overflow-x: scroll; -webkit-overflow-scrolling: touch; margin-left: -1.4rem; margin-right: -1.4rem; max-width: 100vw; } .mobile-scroll-container>.scroll-item { margin-left: 1.4rem; margin-right: 1.4rem; box-sizing: border-box; width: max-content; display: inline-block; min-width: calc(100% - 2.8rem); } }
0
repos/LoLa
repos/LoLa/website/playground.css
* { box-sizing: border-box; } #toolbar { position: fixed; top: 0; left: 0; right: 0; height: 3rem; padding: 0; display: flex; background: linear-gradient(0deg, #EEE, #FFF); border-bottom: 1px solid #DDD; } #toolbar img { height: 100%; } #toolbar span, #toolbar button, #toolbar select { margin: 0.5rem; } #toolbar button.hidden { display: none; } #toolbar span { align-items: center; display: inline-flex; font-family: sans-serif; font-size: 1.5rem; font-weight: bold; } #toolbar .spanner { flex: 1; } #editor { position: fixed; top: 3rem; left: 0; right: 0; bottom: 20rem; font-size: 1.0rem; } #output { position: fixed; left: 0; right: 0; bottom: 0; height: 20rem; border-top: 1px solid #DDD; } a.button { -webkit-appearance: button; -moz-appearance: button; appearance: button; text-decoration: none; color: initial; } #output { font-family: monospace; overflow-y: hidden; overflow-x: hidden; padding: 0.5rem; background-color: black; }
0
repos/LoLa
repos/LoLa/website/playground.js
const templates = [ { name: 'Hello, World!', text: `// Enter LoLa code here and press [Run] above to compile & execute the code! Print("Hello, World!"); `, }, ]; var terminal; var editor; var concatArrayBuffers = function(buffer1, buffer2) { var tmp = new Uint8Array(buffer1.length + buffer2.length); tmp.set(buffer1, 0); tmp.set(buffer2, buffer1.length); return tmp; }; function loadTemplate(id) { editor.session.setValue(templates[id].text); } const utf8_enc = new TextEncoder('utf-8'); const utf8_dec = new TextDecoder('utf-8'); function validateCode() { const code = editor.session.getValue(); var encoded_text = utf8_enc.encode(code); const string_ptr = wasmContext.instance.exports.malloc(encoded_text.length); let byteView = new Uint8Array( wasmContext.instance.exports.memory.buffer, string_ptr, encoded_text.length); let i = 0; while (i < encoded_text.length) { byteView[i] = encoded_text[i]; i += 1; } const result = wasmContext.instance.exports.validate(string_ptr, encoded_text.length); wasmContext.instance.exports.free(string_ptr, encoded_text.length); if (result != 0) console.log('failed to validate code!'); } function stopCode() { wasmContext.instance.exports.deinitInterpreter(); document.getElementById('stopButton').classList.add('hidden'); } function runCode() { const code = editor.session.getValue(); var encoded_text = utf8_enc.encode(code); const string_ptr = wasmContext.instance.exports.malloc(encoded_text.length); let byteView = new Uint8Array( wasmContext.instance.exports.memory.buffer, string_ptr, encoded_text.length); let i = 0; while (i < encoded_text.length) { byteView[i] = encoded_text[i]; i += 1; } if (!wasmContext.instance.exports.isInterpreterDone()) { stopCode(); } const result = wasmContext.instance.exports.initInterpreter( string_ptr, encoded_text.length); wasmContext.instance.exports.free(string_ptr, encoded_text.length); if (result != 0) { console.log('failed to compile code!'); } else { // kick off interpreter loop terminal.clear(); wasmContext.start_time = Date.now(); wasmContext.input_buffer = new Uint8Array(); document.getElementById('stopButton').classList.remove('hidden'); window.requestAnimationFrame(stepRuntime); terminal.focus(); } } function showHelp() { window.open('docs/language.htm', '_blank'); } // run this when the site is fully loaded window.addEventListener('DOMContentLoaded', (ev) => { // Initialize editor editor = ace.edit('editor'); // editor.setTheme("ace/theme/vibrant_ink"); editor.session.setMode('ace/mode/javascript'); // Initialize terminal { terminal = new Terminal(); const fitAddon = new FitAddon.FitAddon(); terminal.loadAddon(fitAddon); terminal.open(document.getElementById('output')); fitAddon.fit(); } terminal.write(`Your program output will appear here!\r\n`); terminal.onData(data => { if (!wasmContext.instance.exports.isInterpreterDone()) { wasmContext.input_buffer = concatArrayBuffers( wasmContext.input_buffer, utf8_enc.encode(data), ); } }); // Initialize samples dropdown { const examples = document.getElementById('examples'); examples.options.length = 0; for (const index in templates) { examples.options.add(new Option(templates[index].name, String(index))); } } editor.session.setValue( `// Enter LoLa code here and press [Run] above to compile & execute the code! Print("Hello, World!"); while(true) { var str = Read(); if(str != "") Write("[", str, "]"); } // Available functions are: // - All of the standard library (see [Help]) // - "Print(…): void" Prints all arguments, then writes a new line // - "Write(…): void" Prints all arguments without appending a new line // - "Read(): string" Reads all available text from the terminal. `); }); var wasmContext = { instance: null, input_buffer: new Uint8Array(), start_time: 0, }; const wasmImports = { env: { readString: (data, len) => { let target_buffer = new Uint8Array( wasmContext.instance.exports.memory.buffer, data, len, ); let actual_len = Math.min(wasmContext.input_buffer.length, len); for (var i = 0; i < actual_len; i++) { target_buffer[i] = wasmContext.input_buffer[i]; } wasmContext.input_buffer = wasmContext.input_buffer.slice(actual_len); return i; }, writeString: (data, len) => { let source_buffer = new Uint8Array( wasmContext.instance.exports.memory.buffer, data, len, ); let s = utf8_dec.decode(source_buffer); terminal.write(s); }, millis: () => { return Date.now() - wasmContext.start_time; }, } }; function translateEmulatorError(ind) { switch (ind) { case 0: return 'success'; case 1: return 'out of memory'; case 2: return 'compilation error'; case 3: return 'compilation error'; case 4: return 'panic'; case 5: return 'invalid object'; case 6: return 'invalid interpreter state'; default: return 'unknown'; } } function stepRuntime(time) { if (!wasmContext.instance.exports.isInterpreterDone()) { const success = wasmContext.instance.exports.stepInterpreter(1000); if (wasmContext.instance.exports.isInterpreterDone()) { document.getElementById('stopButton').classList.add('hidden'); } if (success == 0) { // continue window.requestAnimationFrame(stepRuntime); } else if (success == 4) { // that's a panic, we just use the message printed from within the VM } else { console.log(success); alert('emulator failed: ' + translateEmulatorError(success)); } } } // Load and initialize the wasm runtime fetch('lola.wasm') .then(response => response.arrayBuffer()) .then(bytes => WebAssembly.instantiate(bytes, wasmImports)) .then(results => { wasmContext.instance = results.instance; // this initialize the allocator and such results.instance.exports.initialize(); }); templates.push({ name: 'Bubblesort', text: `function BubbleSort(const_arr) { var arr = const_arr; var len = Length(arr); var n = len; while(n > 1) { var i = 0; while(i < n - 1) { if (arr[i] > arr[i+1]) { var tmp = arr[i]; arr[i] = arr[i+1]; arr[i+1] = tmp; } i += 1; } n -= 1; } return arr; } // Sorting works on numbers Print(BubbleSort([ 7, 8, 9, 3, 2, 1 ])); // as well as strings Print(BubbleSort([ "scorn", "by nature", "Agave cantala", "solvophobic", "outpost", "ovotestis", "weather", "ablation", "boresighting", "postfix" ]));`, }); templates.push({ name: 'Simple Timer', text: `while(true) { Print(Timestamp()); Yield(); }` }); templates.push({ name: 'Stack Trace', text: `function Nested() { Boom(); } function Deeply() { Nested(); } function Within() { Deeply(); } Within();` });
0
repos/LoLa/website/fonts
repos/LoLa/website/fonts/PT_Sans/OFL.txt
Copyright (c) 2010, ParaType Ltd. (http://www.paratype.com/public), with Reserved Font Names "PT Sans" and "ParaType". This Font Software is licensed under the SIL Open Font License, Version 1.1. This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL ----------------------------------------------------------- SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 ----------------------------------------------------------- PREAMBLE The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others. The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives. DEFINITIONS "Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation. "Reserved Font Name" refers to any names specified as such after the copyright statement(s). "Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s). "Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment. "Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software. PERMISSION & CONDITIONS Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions: 1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself. 2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user. 3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users. 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission. 5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software. TERMINATION This license becomes null and void if any of the above conditions are not met. DISCLAIMER THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
0
repos/LoLa/website/fonts
repos/LoLa/website/fonts/Source_Code_Pro/OFL.txt
Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe Systems Incorporated in the United States and/or other countries. This Font Software is licensed under the SIL Open Font License, Version 1.1. This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL ----------------------------------------------------------- SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 ----------------------------------------------------------- PREAMBLE The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others. The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives. DEFINITIONS "Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation. "Reserved Font Name" refers to any names specified as such after the copyright statement(s). "Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s). "Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment. "Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software. PERMISSION & CONDITIONS Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions: 1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself. 2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user. 3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users. 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission. 5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software. TERMINATION This license becomes null and void if any of the above conditions are not met. DISCLAIMER THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
0
repos/LoLa/website
repos/LoLa/website/libs/xterm.css
/** * Copyright (c) 2014 The xterm.js authors. All rights reserved. * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) * https://github.com/chjj/term.js * @license MIT * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * Originally forked from (with the author's permission): * Fabrice Bellard's javascript vt100 for jslinux: * http://bellard.org/jslinux/ * Copyright (c) 2011 Fabrice Bellard * The original design remains. The terminal itself * has been extended to include xterm CSI codes, among * other features. */ /** * Default styles for xterm.js */ .xterm { font-feature-settings: "liga" 0; position: relative; user-select: none; -ms-user-select: none; -webkit-user-select: none; } .xterm.focus, .xterm:focus { outline: none; } .xterm .xterm-helpers { position: absolute; top: 0; /** * The z-index of the helpers must be higher than the canvases in order for * IMEs to appear on top. */ z-index: 5; } .xterm .xterm-helper-textarea { /* * HACK: to fix IE's blinking cursor * Move textarea out of the screen to the far left, so that the cursor is not visible. */ position: absolute; opacity: 0; left: -9999em; top: 0; width: 0; height: 0; z-index: -5; /** Prevent wrapping so the IME appears against the textarea at the correct position */ white-space: nowrap; overflow: hidden; resize: none; } .xterm .composition-view { /* TODO: Composition position got messed up somewhere */ background: #000; color: #FFF; display: none; position: absolute; white-space: nowrap; z-index: 1; } .xterm .composition-view.active { display: block; } .xterm .xterm-viewport { /* On OS X this is required in order for the scroll bar to appear fully opaque */ background-color: #000; overflow-y: scroll; cursor: default; position: absolute; right: 0; left: 0; top: 0; bottom: 0; } .xterm .xterm-screen { position: relative; } .xterm .xterm-screen canvas { position: absolute; left: 0; top: 0; } .xterm .xterm-scroll-area { visibility: hidden; } .xterm-char-measure-element { display: inline-block; visibility: hidden; position: absolute; top: 0; left: -9999em; line-height: normal; } .xterm { cursor: text; } .xterm.enable-mouse-events { /* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */ cursor: default; } .xterm.xterm-cursor-pointer { cursor: pointer; } .xterm.column-select.focus { /* Column selection mode */ cursor: crosshair; } .xterm .xterm-accessibility, .xterm .xterm-message { position: absolute; left: 0; top: 0; bottom: 0; right: 0; z-index: 10; color: transparent; } .xterm .live-region { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; } .xterm-dim { opacity: 0.5; } .xterm-underline { text-decoration: underline; }
0
repos/LoLa/website
repos/LoLa/website/libs/theme-vibrant_ink.js
ace.define("ace/theme/vibrant_ink",["require","exports","module","ace/lib/dom"],function(e,t,n){t.isDark=!0,t.cssClass="ace-vibrant-ink",t.cssText=".ace-vibrant-ink .ace_gutter {background: #1a1a1a;color: #BEBEBE}.ace-vibrant-ink .ace_print-margin {width: 1px;background: #1a1a1a}.ace-vibrant-ink {background-color: #0F0F0F;color: #FFFFFF}.ace-vibrant-ink .ace_cursor {color: #FFFFFF}.ace-vibrant-ink .ace_marker-layer .ace_selection {background: #6699CC}.ace-vibrant-ink.ace_multiselect .ace_selection.ace_start {box-shadow: 0 0 3px 0px #0F0F0F;}.ace-vibrant-ink .ace_marker-layer .ace_step {background: rgb(102, 82, 0)}.ace-vibrant-ink .ace_marker-layer .ace_bracket {margin: -1px 0 0 -1px;border: 1px solid #404040}.ace-vibrant-ink .ace_marker-layer .ace_active-line {background: #333333}.ace-vibrant-ink .ace_gutter-active-line {background-color: #333333}.ace-vibrant-ink .ace_marker-layer .ace_selected-word {border: 1px solid #6699CC}.ace-vibrant-ink .ace_invisible {color: #404040}.ace-vibrant-ink .ace_keyword,.ace-vibrant-ink .ace_meta {color: #FF6600}.ace-vibrant-ink .ace_constant,.ace-vibrant-ink .ace_constant.ace_character,.ace-vibrant-ink .ace_constant.ace_character.ace_escape,.ace-vibrant-ink .ace_constant.ace_other {color: #339999}.ace-vibrant-ink .ace_constant.ace_numeric {color: #99CC99}.ace-vibrant-ink .ace_invalid,.ace-vibrant-ink .ace_invalid.ace_deprecated {color: #CCFF33;background-color: #000000}.ace-vibrant-ink .ace_fold {background-color: #FFCC00;border-color: #FFFFFF}.ace-vibrant-ink .ace_entity.ace_name.ace_function,.ace-vibrant-ink .ace_support.ace_function,.ace-vibrant-ink .ace_variable {color: #FFCC00}.ace-vibrant-ink .ace_variable.ace_parameter {font-style: italic}.ace-vibrant-ink .ace_string {color: #66FF00}.ace-vibrant-ink .ace_string.ace_regexp {color: #44B4CC}.ace-vibrant-ink .ace_comment {color: #9933CC}.ace-vibrant-ink .ace_entity.ace_other.ace_attribute-name {font-style: italic;color: #99CC99}.ace-vibrant-ink .ace_indent-guide {background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWNgYGBgYNDTc/oPAALPAZ7hxlbYAAAAAElFTkSuQmCC) right repeat-y}";var r=e("../lib/dom");r.importCssString(t.cssText,t.cssClass)}); (function() { ace.require(["ace/theme/vibrant_ink"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; } }); })();
0
repos/LoLa/website
repos/LoLa/website/libs/ace.js
(function(){function o(n){var i=e;n&&(e[n]||(e[n]={}),i=e[n]);if(!i.define||!i.define.packaged)t.original=i.define,i.define=t,i.define.packaged=!0;if(!i.require||!i.require.packaged)r.original=i.require,i.require=r,i.require.packaged=!0}var ACE_NAMESPACE = "ace",e=function(){return this}();!e&&typeof window!="undefined"&&(e=window);if(!ACE_NAMESPACE&&typeof requirejs!="undefined")return;var t=function(e,n,r){if(typeof e!="string"){t.original?t.original.apply(this,arguments):(console.error("dropping module because define wasn't a string."),console.trace());return}arguments.length==2&&(r=n),t.modules[e]||(t.payloads[e]=r,t.modules[e]=null)};t.modules={},t.payloads={};var n=function(e,t,n){if(typeof t=="string"){var i=s(e,t);if(i!=undefined)return n&&n(),i}else if(Object.prototype.toString.call(t)==="[object Array]"){var o=[];for(var u=0,a=t.length;u<a;++u){var f=s(e,t[u]);if(f==undefined&&r.original)return;o.push(f)}return n&&n.apply(null,o)||!0}},r=function(e,t){var i=n("",e,t);return i==undefined&&r.original?r.original.apply(this,arguments):i},i=function(e,t){if(t.indexOf("!")!==-1){var n=t.split("!");return i(e,n[0])+"!"+i(e,n[1])}if(t.charAt(0)=="."){var r=e.split("/").slice(0,-1).join("/");t=r+"/"+t;while(t.indexOf(".")!==-1&&s!=t){var s=t;t=t.replace(/\/\.\//,"/").replace(/[^\/]+\/\.\.\//,"")}}return t},s=function(e,r){r=i(e,r);var s=t.modules[r];if(!s){s=t.payloads[r];if(typeof s=="function"){var o={},u={id:r,uri:"",exports:o,packaged:!0},a=function(e,t){return n(r,e,t)},f=s(a,o,u);o=f||u.exports,t.modules[r]=o,delete t.payloads[r]}s=t.modules[r]=o||s}return s};o(ACE_NAMESPACE)})(),ace.define("ace/lib/fixoldbrowsers",["require","exports","module"],function(e,t,n){"use strict";typeof Element!="undefined"&&!Element.prototype.remove&&Object.defineProperty(Element.prototype,"remove",{enumerable:!1,writable:!0,configurable:!0,value:function(){this.parentNode&&this.parentNode.removeChild(this)}})}),ace.define("ace/lib/useragent",["require","exports","module"],function(e,t,n){"use strict";t.OS={LINUX:"LINUX",MAC:"MAC",WINDOWS:"WINDOWS"},t.getOS=function(){return t.isMac?t.OS.MAC:t.isLinux?t.OS.LINUX:t.OS.WINDOWS};var r=typeof navigator=="object"?navigator:{},i=(/mac|win|linux/i.exec(r.platform)||["other"])[0].toLowerCase(),s=r.userAgent||"",o=r.appName||"";t.isWin=i=="win",t.isMac=i=="mac",t.isLinux=i=="linux",t.isIE=o=="Microsoft Internet Explorer"||o.indexOf("MSAppHost")>=0?parseFloat((s.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]):parseFloat((s.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]),t.isOldIE=t.isIE&&t.isIE<9,t.isGecko=t.isMozilla=s.match(/ Gecko\/\d+/),t.isOpera=typeof opera=="object"&&Object.prototype.toString.call(window.opera)=="[object Opera]",t.isWebKit=parseFloat(s.split("WebKit/")[1])||undefined,t.isChrome=parseFloat(s.split(" Chrome/")[1])||undefined,t.isEdge=parseFloat(s.split(" Edge/")[1])||undefined,t.isAIR=s.indexOf("AdobeAIR")>=0,t.isAndroid=s.indexOf("Android")>=0,t.isChromeOS=s.indexOf(" CrOS ")>=0,t.isIOS=/iPad|iPhone|iPod/.test(s)&&!window.MSStream,t.isIOS&&(t.isMac=!0),t.isMobile=t.isIOS||t.isAndroid}),ace.define("ace/lib/dom",["require","exports","module","ace/lib/useragent"],function(e,t,n){"use strict";var r=e("./useragent"),i="http://www.w3.org/1999/xhtml";t.buildDom=function o(e,t,n){if(typeof e=="string"&&e){var r=document.createTextNode(e);return t&&t.appendChild(r),r}if(!Array.isArray(e))return e&&e.appendChild&&t&&t.appendChild(e),e;if(typeof e[0]!="string"||!e[0]){var i=[];for(var s=0;s<e.length;s++){var u=o(e[s],t,n);u&&i.push(u)}return i}var a=document.createElement(e[0]),f=e[1],l=1;f&&typeof f=="object"&&!Array.isArray(f)&&(l=2);for(var s=l;s<e.length;s++)o(e[s],a,n);return l==2&&Object.keys(f).forEach(function(e){var t=f[e];e==="class"?a.className=Array.isArray(t)?t.join(" "):t:typeof t=="function"||e=="value"||e[0]=="$"?a[e]=t:e==="ref"?n&&(n[t]=a):t!=null&&a.setAttribute(e,t)}),t&&t.appendChild(a),a},t.getDocumentHead=function(e){return e||(e=document),e.head||e.getElementsByTagName("head")[0]||e.documentElement},t.createElement=function(e,t){return document.createElementNS?document.createElementNS(t||i,e):document.createElement(e)},t.removeChildren=function(e){e.innerHTML=""},t.createTextNode=function(e,t){var n=t?t.ownerDocument:document;return n.createTextNode(e)},t.createFragment=function(e){var t=e?e.ownerDocument:document;return t.createDocumentFragment()},t.hasCssClass=function(e,t){var n=(e.className+"").split(/\s+/g);return n.indexOf(t)!==-1},t.addCssClass=function(e,n){t.hasCssClass(e,n)||(e.className+=" "+n)},t.removeCssClass=function(e,t){var n=e.className.split(/\s+/g);for(;;){var r=n.indexOf(t);if(r==-1)break;n.splice(r,1)}e.className=n.join(" ")},t.toggleCssClass=function(e,t){var n=e.className.split(/\s+/g),r=!0;for(;;){var i=n.indexOf(t);if(i==-1)break;r=!1,n.splice(i,1)}return r&&n.push(t),e.className=n.join(" "),r},t.setCssClass=function(e,n,r){r?t.addCssClass(e,n):t.removeCssClass(e,n)},t.hasCssString=function(e,t){var n=0,r;t=t||document;if(r=t.querySelectorAll("style"))while(n<r.length)if(r[n++].id===e)return!0},t.importCssString=function(n,r,i){var s=i;if(!i||!i.getRootNode)s=document;else{s=i.getRootNode();if(!s||s==i)s=document}var o=s.ownerDocument||s;if(r&&t.hasCssString(r,s))return null;r&&(n+="\n/*# sourceURL=ace/css/"+r+" */");var u=t.createElement("style");u.appendChild(o.createTextNode(n)),r&&(u.id=r),s==o&&(s=t.getDocumentHead(o)),s.insertBefore(u,s.firstChild)},t.importCssStylsheet=function(e,n){t.buildDom(["link",{rel:"stylesheet",href:e}],t.getDocumentHead(n))},t.scrollbarWidth=function(e){var n=t.createElement("ace_inner");n.style.width="100%",n.style.minWidth="0px",n.style.height="200px",n.style.display="block";var r=t.createElement("ace_outer"),i=r.style;i.position="absolute",i.left="-10000px",i.overflow="hidden",i.width="200px",i.minWidth="0px",i.height="150px",i.display="block",r.appendChild(n);var s=e.documentElement;s.appendChild(r);var o=n.offsetWidth;i.overflow="scroll";var u=n.offsetWidth;return o==u&&(u=r.clientWidth),s.removeChild(r),o-u},typeof document=="undefined"&&(t.importCssString=function(){}),t.computedStyle=function(e,t){return window.getComputedStyle(e,"")||{}},t.setStyle=function(e,t,n){e[t]!==n&&(e[t]=n)},t.HAS_CSS_ANIMATION=!1,t.HAS_CSS_TRANSFORMS=!1,t.HI_DPI=r.isWin?typeof window!="undefined"&&window.devicePixelRatio>=1.5:!0;if(typeof document!="undefined"){var s=document.createElement("div");t.HI_DPI&&s.style.transform!==undefined&&(t.HAS_CSS_TRANSFORMS=!0),!r.isEdge&&typeof s.style.animationName!="undefined"&&(t.HAS_CSS_ANIMATION=!0),s=null}t.HAS_CSS_TRANSFORMS?t.translate=function(e,t,n){e.style.transform="translate("+Math.round(t)+"px, "+Math.round(n)+"px)"}:t.translate=function(e,t,n){e.style.top=Math.round(n)+"px",e.style.left=Math.round(t)+"px"}}),ace.define("ace/lib/oop",["require","exports","module"],function(e,t,n){"use strict";t.inherits=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})},t.mixin=function(e,t){for(var n in t)e[n]=t[n];return e},t.implement=function(e,n){t.mixin(e,n)}}),ace.define("ace/lib/keys",["require","exports","module","ace/lib/oop"],function(e,t,n){"use strict";var r=e("./oop"),i=function(){var e={MODIFIER_KEYS:{16:"Shift",17:"Ctrl",18:"Alt",224:"Meta",91:"MetaLeft",92:"MetaRight",93:"ContextMenu"},KEY_MODS:{ctrl:1,alt:2,option:2,shift:4,"super":8,meta:8,command:8,cmd:8,control:1},FUNCTION_KEYS:{8:"Backspace",9:"Tab",13:"Return",19:"Pause",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"Print",45:"Insert",46:"Delete",96:"Numpad0",97:"Numpad1",98:"Numpad2",99:"Numpad3",100:"Numpad4",101:"Numpad5",102:"Numpad6",103:"Numpad7",104:"Numpad8",105:"Numpad9","-13":"NumpadEnter",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"Numlock",145:"Scrolllock"},PRINTABLE_KEYS:{32:" ",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",59:";",61:"=",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",107:"+",109:"-",110:".",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",111:"/",106:"*"}},t,n;for(n in e.FUNCTION_KEYS)t=e.FUNCTION_KEYS[n].toLowerCase(),e[t]=parseInt(n,10);for(n in e.PRINTABLE_KEYS)t=e.PRINTABLE_KEYS[n].toLowerCase(),e[t]=parseInt(n,10);return r.mixin(e,e.MODIFIER_KEYS),r.mixin(e,e.PRINTABLE_KEYS),r.mixin(e,e.FUNCTION_KEYS),e.enter=e["return"],e.escape=e.esc,e.del=e["delete"],e[173]="-",function(){var t=["cmd","ctrl","alt","shift"];for(var n=Math.pow(2,t.length);n--;)e.KEY_MODS[n]=t.filter(function(t){return n&e.KEY_MODS[t]}).join("-")+"-"}(),e.KEY_MODS[0]="",e.KEY_MODS[-1]="input-",e}();r.mixin(t,i),t.keyCodeToString=function(e){var t=i[e];return typeof t!="string"&&(t=String.fromCharCode(e)),t.toLowerCase()}}),ace.define("ace/lib/event",["require","exports","module","ace/lib/keys","ace/lib/useragent"],function(e,t,n){"use strict";function a(){u=!1;try{document.createComment("").addEventListener("test",function(){},{get passive(){u={passive:!1}}})}catch(e){}}function f(){return u==undefined&&a(),u}function l(e,t,n){this.elem=e,this.type=t,this.callback=n}function d(e,t,n){var u=p(t);if(!i.isMac&&s){t.getModifierState&&(t.getModifierState("OS")||t.getModifierState("Win"))&&(u|=8);if(s.altGr){if((3&u)==3)return;s.altGr=0}if(n===18||n===17){var a="location"in t?t.location:t.keyLocation;if(n===17&&a===1)s[n]==1&&(o=t.timeStamp);else if(n===18&&u===3&&a===2){var f=t.timeStamp-o;f<50&&(s.altGr=!0)}}}n in r.MODIFIER_KEYS&&(n=-1);if(!u&&n===13){var a="location"in t?t.location:t.keyLocation;if(a===3){e(t,u,-n);if(t.defaultPrevented)return}}if(i.isChromeOS&&u&8){e(t,u,n);if(t.defaultPrevented)return;u&=-9}return!!u||n in r.FUNCTION_KEYS||n in r.PRINTABLE_KEYS?e(t,u,n):!1}function v(){s=Object.create(null)}var r=e("./keys"),i=e("./useragent"),s=null,o=0,u;l.prototype.destroy=function(){h(this.elem,this.type,this.callback),this.elem=this.type=this.callback=undefined};var c=t.addListener=function(e,t,n,r){e.addEventListener(t,n,f()),r&&r.$toDestroy.push(new l(e,t,n))},h=t.removeListener=function(e,t,n){e.removeEventListener(t,n,f())};t.stopEvent=function(e){return t.stopPropagation(e),t.preventDefault(e),!1},t.stopPropagation=function(e){e.stopPropagation&&e.stopPropagation()},t.preventDefault=function(e){e.preventDefault&&e.preventDefault()},t.getButton=function(e){return e.type=="dblclick"?0:e.type=="contextmenu"||i.isMac&&e.ctrlKey&&!e.altKey&&!e.shiftKey?2:e.button},t.capture=function(e,t,n){function i(e){t&&t(e),n&&n(e),h(r,"mousemove",t),h(r,"mouseup",i),h(r,"dragstart",i)}var r=e&&e.ownerDocument||document;return c(r,"mousemove",t),c(r,"mouseup",i),c(r,"dragstart",i),i},t.addMouseWheelListener=function(e,t,n){"onmousewheel"in e?c(e,"mousewheel",function(e){var n=8;e.wheelDeltaX!==undefined?(e.wheelX=-e.wheelDeltaX/n,e.wheelY=-e.wheelDeltaY/n):(e.wheelX=0,e.wheelY=-e.wheelDelta/n),t(e)},n):"onwheel"in e?c(e,"wheel",function(e){var n=.35;switch(e.deltaMode){case e.DOM_DELTA_PIXEL:e.wheelX=e.deltaX*n||0,e.wheelY=e.deltaY*n||0;break;case e.DOM_DELTA_LINE:case e.DOM_DELTA_PAGE:e.wheelX=(e.deltaX||0)*5,e.wheelY=(e.deltaY||0)*5}t(e)},n):c(e,"DOMMouseScroll",function(e){e.axis&&e.axis==e.HORIZONTAL_AXIS?(e.wheelX=(e.detail||0)*5,e.wheelY=0):(e.wheelX=0,e.wheelY=(e.detail||0)*5),t(e)},n)},t.addMultiMouseDownListener=function(e,n,r,s,o){function p(e){t.getButton(e)!==0?u=0:e.detail>1?(u++,u>4&&(u=1)):u=1;if(i.isIE){var o=Math.abs(e.clientX-a)>5||Math.abs(e.clientY-f)>5;if(!l||o)u=1;l&&clearTimeout(l),l=setTimeout(function(){l=null},n[u-1]||600),u==1&&(a=e.clientX,f=e.clientY)}e._clicks=u,r[s]("mousedown",e);if(u>4)u=0;else if(u>1)return r[s](h[u],e)}var u=0,a,f,l,h={2:"dblclick",3:"tripleclick",4:"quadclick"};Array.isArray(e)||(e=[e]),e.forEach(function(e){c(e,"mousedown",p,o)})};var p=function(e){return 0|(e.ctrlKey?1:0)|(e.altKey?2:0)|(e.shiftKey?4:0)|(e.metaKey?8:0)};t.getModifierString=function(e){return r.KEY_MODS[p(e)]},t.addCommandKeyListener=function(e,n,r){if(i.isOldGecko||i.isOpera&&!("KeyboardEvent"in window)){var o=null;c(e,"keydown",function(e){o=e.keyCode},r),c(e,"keypress",function(e){return d(n,e,o)},r)}else{var u=null;c(e,"keydown",function(e){s[e.keyCode]=(s[e.keyCode]||0)+1;var t=d(n,e,e.keyCode);return u=e.defaultPrevented,t},r),c(e,"keypress",function(e){u&&(e.ctrlKey||e.altKey||e.shiftKey||e.metaKey)&&(t.stopEvent(e),u=null)},r),c(e,"keyup",function(e){s[e.keyCode]=null},r),s||(v(),c(window,"focus",v))}};if(typeof window=="object"&&window.postMessage&&!i.isOldIE){var m=1;t.nextTick=function(e,n){n=n||window;var r="zero-timeout-message-"+m++,i=function(s){s.data==r&&(t.stopPropagation(s),h(n,"message",i),e())};c(n,"message",i),n.postMessage(r,"*")}}t.$idleBlocked=!1,t.onIdle=function(e,n){return setTimeout(function r(){t.$idleBlocked?setTimeout(r,100):e()},n)},t.$idleBlockId=null,t.blockIdle=function(e){t.$idleBlockId&&clearTimeout(t.$idleBlockId),t.$idleBlocked=!0,t.$idleBlockId=setTimeout(function(){t.$idleBlocked=!1},e||100)},t.nextFrame=typeof window=="object"&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame),t.nextFrame?t.nextFrame=t.nextFrame.bind(window):t.nextFrame=function(e){setTimeout(e,17)}}),ace.define("ace/range",["require","exports","module"],function(e,t,n){"use strict";var r=function(e,t){return e.row-t.row||e.column-t.column},i=function(e,t,n,r){this.start={row:e,column:t},this.end={row:n,column:r}};(function(){this.isEqual=function(e){return this.start.row===e.start.row&&this.end.row===e.end.row&&this.start.column===e.start.column&&this.end.column===e.end.column},this.toString=function(){return"Range: ["+this.start.row+"/"+this.start.column+"] -> ["+this.end.row+"/"+this.end.column+"]"},this.contains=function(e,t){return this.compare(e,t)==0},this.compareRange=function(e){var t,n=e.end,r=e.start;return t=this.compare(n.row,n.column),t==1?(t=this.compare(r.row,r.column),t==1?2:t==0?1:0):t==-1?-2:(t=this.compare(r.row,r.column),t==-1?-1:t==1?42:0)},this.comparePoint=function(e){return this.compare(e.row,e.column)},this.containsRange=function(e){return this.comparePoint(e.start)==0&&this.comparePoint(e.end)==0},this.intersects=function(e){var t=this.compareRange(e);return t==-1||t==0||t==1},this.isEnd=function(e,t){return this.end.row==e&&this.end.column==t},this.isStart=function(e,t){return this.start.row==e&&this.start.column==t},this.setStart=function(e,t){typeof e=="object"?(this.start.column=e.column,this.start.row=e.row):(this.start.row=e,this.start.column=t)},this.setEnd=function(e,t){typeof e=="object"?(this.end.column=e.column,this.end.row=e.row):(this.end.row=e,this.end.column=t)},this.inside=function(e,t){return this.compare(e,t)==0?this.isEnd(e,t)||this.isStart(e,t)?!1:!0:!1},this.insideStart=function(e,t){return this.compare(e,t)==0?this.isEnd(e,t)?!1:!0:!1},this.insideEnd=function(e,t){return this.compare(e,t)==0?this.isStart(e,t)?!1:!0:!1},this.compare=function(e,t){return!this.isMultiLine()&&e===this.start.row?t<this.start.column?-1:t>this.end.column?1:0:e<this.start.row?-1:e>this.end.row?1:this.start.row===e?t>=this.start.column?0:-1:this.end.row===e?t<=this.end.column?0:1:0},this.compareStart=function(e,t){return this.start.row==e&&this.start.column==t?-1:this.compare(e,t)},this.compareEnd=function(e,t){return this.end.row==e&&this.end.column==t?1:this.compare(e,t)},this.compareInside=function(e,t){return this.end.row==e&&this.end.column==t?1:this.start.row==e&&this.start.column==t?-1:this.compare(e,t)},this.clipRows=function(e,t){if(this.end.row>t)var n={row:t+1,column:0};else if(this.end.row<e)var n={row:e,column:0};if(this.start.row>t)var r={row:t+1,column:0};else if(this.start.row<e)var r={row:e,column:0};return i.fromPoints(r||this.start,n||this.end)},this.extend=function(e,t){var n=this.compare(e,t);if(n==0)return this;if(n==-1)var r={row:e,column:t};else var s={row:e,column:t};return i.fromPoints(r||this.start,s||this.end)},this.isEmpty=function(){return this.start.row===this.end.row&&this.start.column===this.end.column},this.isMultiLine=function(){return this.start.row!==this.end.row},this.clone=function(){return i.fromPoints(this.start,this.end)},this.collapseRows=function(){return this.end.column==0?new i(this.start.row,0,Math.max(this.start.row,this.end.row-1),0):new i(this.start.row,0,this.end.row,0)},this.toScreenRange=function(e){var t=e.documentToScreenPosition(this.start),n=e.documentToScreenPosition(this.end);return new i(t.row,t.column,n.row,n.column)},this.moveBy=function(e,t){this.start.row+=e,this.start.column+=t,this.end.row+=e,this.end.column+=t}}).call(i.prototype),i.fromPoints=function(e,t){return new i(e.row,e.column,t.row,t.column)},i.comparePoints=r,i.comparePoints=function(e,t){return e.row-t.row||e.column-t.column},t.Range=i}),ace.define("ace/lib/lang",["require","exports","module"],function(e,t,n){"use strict";t.last=function(e){return e[e.length-1]},t.stringReverse=function(e){return e.split("").reverse().join("")},t.stringRepeat=function(e,t){var n="";while(t>0){t&1&&(n+=e);if(t>>=1)e+=e}return n};var r=/^\s\s*/,i=/\s\s*$/;t.stringTrimLeft=function(e){return e.replace(r,"")},t.stringTrimRight=function(e){return e.replace(i,"")},t.copyObject=function(e){var t={};for(var n in e)t[n]=e[n];return t},t.copyArray=function(e){var t=[];for(var n=0,r=e.length;n<r;n++)e[n]&&typeof e[n]=="object"?t[n]=this.copyObject(e[n]):t[n]=e[n];return t},t.deepCopy=function s(e){if(typeof e!="object"||!e)return e;var t;if(Array.isArray(e)){t=[];for(var n=0;n<e.length;n++)t[n]=s(e[n]);return t}if(Object.prototype.toString.call(e)!=="[object Object]")return e;t={};for(var n in e)t[n]=s(e[n]);return t},t.arrayToMap=function(e){var t={};for(var n=0;n<e.length;n++)t[e[n]]=1;return t},t.createMap=function(e){var t=Object.create(null);for(var n in e)t[n]=e[n];return t},t.arrayRemove=function(e,t){for(var n=0;n<=e.length;n++)t===e[n]&&e.splice(n,1)},t.escapeRegExp=function(e){return e.replace(/([.*+?^${}()|[\]\/\\])/g,"\\$1")},t.escapeHTML=function(e){return(""+e).replace(/&/g,"&#38;").replace(/"/g,"&#34;").replace(/'/g,"&#39;").replace(/</g,"&#60;")},t.getMatchOffsets=function(e,t){var n=[];return e.replace(t,function(e){n.push({offset:arguments[arguments.length-2],length:e.length})}),n},t.deferredCall=function(e){var t=null,n=function(){t=null,e()},r=function(e){return r.cancel(),t=setTimeout(n,e||0),r};return r.schedule=r,r.call=function(){return this.cancel(),e(),r},r.cancel=function(){return clearTimeout(t),t=null,r},r.isPending=function(){return t},r},t.delayedCall=function(e,t){var n=null,r=function(){n=null,e()},i=function(e){n==null&&(n=setTimeout(r,e||t))};return i.delay=function(e){n&&clearTimeout(n),n=setTimeout(r,e||t)},i.schedule=i,i.call=function(){this.cancel(),e()},i.cancel=function(){n&&clearTimeout(n),n=null},i.isPending=function(){return n},i}}),ace.define("ace/clipboard",["require","exports","module"],function(e,t,n){"use strict";var r;n.exports={lineMode:!1,pasteCancelled:function(){return r&&r>Date.now()-50?!0:r=!1},cancel:function(){r=Date.now()}}}),ace.define("ace/keyboard/textinput",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/lib/dom","ace/lib/lang","ace/clipboard","ace/lib/keys"],function(e,t,n){"use strict";var r=e("../lib/event"),i=e("../lib/useragent"),s=e("../lib/dom"),o=e("../lib/lang"),u=e("../clipboard"),a=i.isChrome<18,f=i.isIE,l=i.isChrome>63,c=400,h=e("../lib/keys"),p=h.KEY_MODS,d=i.isIOS,v=d?/\s/:/\n/,m=i.isMobile,g=function(e,t){function X(){x=!0,n.blur(),n.focus(),x=!1}function $(e){e.keyCode==27&&n.value.length<n.selectionStart&&(b||(T=n.value),N=C=-1,O()),V()}function K(){clearTimeout(J),J=setTimeout(function(){E&&(n.style.cssText=E,E=""),t.renderer.$isMousePressed=!1,t.renderer.$keepTextAreaAtCursor&&t.renderer.$moveTextAreaToCursor()},0)}function G(e,t,n){var r=null,i=!1;n.addEventListener("keydown",function(e){r&&clearTimeout(r),i=!0},!0),n.addEventListener("keyup",function(e){r=setTimeout(function(){i=!1},100)},!0);var s=function(e){if(document.activeElement!==n)return;if(i||b||t.$mouseHandler.isMousePressed)return;if(g)return;var r=n.selectionStart,s=n.selectionEnd,o=null,u=0;if(r==0)o=h.up;else if(r==1)o=h.home;else if(s>C&&T[s]=="\n")o=h.end;else if(r<N&&T[r-1]==" ")o=h.left,u=p.option;else if(r<N||r==N&&C!=N&&r==s)o=h.left;else if(s>C&&T.slice(0,s).split("\n").length>2)o=h.down;else if(s>C&&T[s-1]==" ")o=h.right,u=p.option;else if(s>C||s==C&&C!=N&&r==s)o=h.right;r!==s&&(u|=p.shift);if(o){var a=t.onCommandKey({},u,o);if(!a&&t.commands){o=h.keyCodeToString(o);var f=t.commands.findKeyCommand(u,o);f&&t.execCommand(f)}N=r,C=s,O("")}};document.addEventListener("selectionchange",s),t.on("destroy",function(){document.removeEventListener("selectionchange",s)})}var n=s.createElement("textarea");n.className="ace_text-input",n.setAttribute("wrap","off"),n.setAttribute("autocorrect","off"),n.setAttribute("autocapitalize","off"),n.setAttribute("spellcheck",!1),n.style.opacity="0",e.insertBefore(n,e.firstChild);var g=!1,y=!1,b=!1,w=!1,E="";m||(n.style.fontSize="1px");var S=!1,x=!1,T="",N=0,C=0,k=0;try{var L=document.activeElement===n}catch(A){}r.addListener(n,"blur",function(e){if(x)return;t.onBlur(e),L=!1},t),r.addListener(n,"focus",function(e){if(x)return;L=!0;if(i.isEdge)try{if(!document.hasFocus())return}catch(e){}t.onFocus(e),i.isEdge?setTimeout(O):O()},t),this.$focusScroll=!1,this.focus=function(){if(E||l||this.$focusScroll=="browser")return n.focus({preventScroll:!0});var e=n.style.top;n.style.position="fixed",n.style.top="0px";try{var t=n.getBoundingClientRect().top!=0}catch(r){return}var i=[];if(t){var s=n.parentElement;while(s&&s.nodeType==1)i.push(s),s.setAttribute("ace_nocontext",!0),!s.parentElement&&s.getRootNode?s=s.getRootNode().host:s=s.parentElement}n.focus({preventScroll:!0}),t&&i.forEach(function(e){e.removeAttribute("ace_nocontext")}),setTimeout(function(){n.style.position="",n.style.top=="0px"&&(n.style.top=e)},0)},this.blur=function(){n.blur()},this.isFocused=function(){return L},t.on("beforeEndOperation",function(){var e=t.curOp,r=e&&e.command&&e.command.name;if(r=="insertstring")return;var i=r&&(e.docChanged||e.selectionChanged);b&&i&&(T=n.value="",W()),O()});var O=d?function(e){if(!L||g&&!e||w)return;e||(e="");var r="\n ab"+e+"cde fg\n";r!=n.value&&(n.value=T=r);var i=4,s=4+(e.length||(t.selection.isEmpty()?0:1));(N!=i||C!=s)&&n.setSelectionRange(i,s),N=i,C=s}:function(){if(b||w)return;if(!L&&!P)return;b=!0;var e=0,r=0,i="";if(t.session){var s=t.selection,o=s.getRange(),u=s.cursor.row;e=o.start.column,r=o.end.column,i=t.session.getLine(u);if(o.start.row!=u){var a=t.session.getLine(u-1);e=o.start.row<u-1?0:e,r+=a.length+1,i=a+"\n"+i}else if(o.end.row!=u){var f=t.session.getLine(u+1);r=o.end.row>u+1?f.length:r,r+=i.length+1,i=i+"\n"+f}else m&&u>0&&(i="\n"+i,r+=1,e+=1);i.length>c&&(e<c&&r<c?i=i.slice(0,c):(i="\n",e==r?e=r=0:(e=0,r=1)))}var l=i+"\n\n";l!=T&&(n.value=T=l,N=C=l.length),P&&(N=n.selectionStart,C=n.selectionEnd);if(C!=r||N!=e||n.selectionEnd!=C)try{n.setSelectionRange(e,r),N=e,C=r}catch(h){}b=!1};this.resetSelection=O,L&&t.onFocus();var M=function(e){return e.selectionStart===0&&e.selectionEnd>=T.length&&e.value===T&&T&&e.selectionEnd!==C},_=function(e){if(b)return;g?g=!1:M(n)?(t.selectAll(),O()):m&&n.selectionStart!=N&&O()},D=null;this.setInputHandler=function(e){D=e},this.getInputHandler=function(){return D};var P=!1,H=function(e,r){P&&(P=!1);if(y)return O(),e&&t.onPaste(e),y=!1,"";var s=n.selectionStart,o=n.selectionEnd,u=N,a=T.length-C,f=e,l=e.length-s,c=e.length-o,h=0;while(u>0&&T[h]==e[h])h++,u--;f=f.slice(h),h=1;while(a>0&&T.length-h>N-1&&T[T.length-h]==e[e.length-h])h++,a--;l-=h-1,c-=h-1;var p=f.length-h+1;p<0&&(u=-p,p=0),f=f.slice(0,p);if(!r&&!f&&!l&&!u&&!a&&!c)return"";w=!0;var d=!1;return i.isAndroid&&f==". "&&(f=" ",d=!0),f&&!u&&!a&&!l&&!c||S?t.onTextInput(f):t.onTextInput(f,{extendLeft:u,extendRight:a,restoreStart:l,restoreEnd:c}),w=!1,T=e,N=s,C=o,k=c,d?"\n":f},B=function(e){if(b)return z();if(e&&e.inputType){if(e.inputType=="historyUndo")return t.execCommand("undo");if(e.inputType=="historyRedo")return t.execCommand("redo")}var r=n.value,i=H(r,!0);(r.length>c+100||v.test(i)||m&&N<1&&N==C)&&O()},j=function(e,t,n){var r=e.clipboardData||window.clipboardData;if(!r||a)return;var i=f||n?"Text":"text/plain";try{return t?r.setData(i,t)!==!1:r.getData(i)}catch(e){if(!n)return j(e,t,!0)}},F=function(e,i){var s=t.getCopyText();if(!s)return r.preventDefault(e);j(e,s)?(d&&(O(s),g=s,setTimeout(function(){g=!1},10)),i?t.onCut():t.onCopy(),r.preventDefault(e)):(g=!0,n.value=s,n.select(),setTimeout(function(){g=!1,O(),i?t.onCut():t.onCopy()}))},I=function(e){F(e,!0)},q=function(e){F(e,!1)},R=function(e){var s=j(e);if(u.pasteCancelled())return;typeof s=="string"?(s&&t.onPaste(s,e),i.isIE&&setTimeout(O),r.preventDefault(e)):(n.value="",y=!0)};r.addCommandKeyListener(n,t.onCommandKey.bind(t),t),r.addListener(n,"select",_,t),r.addListener(n,"input",B,t),r.addListener(n,"cut",I,t),r.addListener(n,"copy",q,t),r.addListener(n,"paste",R,t),(!("oncut"in n)||!("oncopy"in n)||!("onpaste"in n))&&r.addListener(e,"keydown",function(e){if(i.isMac&&!e.metaKey||!e.ctrlKey)return;switch(e.keyCode){case 67:q(e);break;case 86:R(e);break;case 88:I(e)}},t);var U=function(e){if(b||!t.onCompositionStart||t.$readOnly)return;b={};if(S)return;e.data&&(b.useTextareaForIME=!1),setTimeout(z,0),t._signal("compositionStart"),t.on("mousedown",X);var r=t.getSelectionRange();r.end.row=r.start.row,r.end.column=r.start.column,b.markerRange=r,b.selectionStart=N,t.onCompositionStart(b),b.useTextareaForIME?(T=n.value="",N=0,C=0):(n.msGetInputContext&&(b.context=n.msGetInputContext()),n.getInputContext&&(b.context=n.getInputContext()))},z=function(){if(!b||!t.onCompositionUpdate||t.$readOnly)return;if(S)return X();if(b.useTextareaForIME)t.onCompositionUpdate(n.value);else{var e=n.value;H(e),b.markerRange&&(b.context&&(b.markerRange.start.column=b.selectionStart=b.context.compositionStartOffset),b.markerRange.end.column=b.markerRange.start.column+C-b.selectionStart+k)}},W=function(e){if(!t.onCompositionEnd||t.$readOnly)return;b=!1,t.onCompositionEnd(),t.off("mousedown",X),e&&B()},V=o.delayedCall(z,50).schedule.bind(null,null);r.addListener(n,"compositionstart",U,t),r.addListener(n,"compositionupdate",z,t),r.addListener(n,"keyup",$,t),r.addListener(n,"keydown",V,t),r.addListener(n,"compositionend",W,t),this.getElement=function(){return n},this.setCommandMode=function(e){S=e,n.readOnly=!1},this.setReadOnly=function(e){S||(n.readOnly=e)},this.setCopyWithEmptySelection=function(e){},this.onContextMenu=function(e){P=!0,O(),t._emit("nativecontextmenu",{target:t,domEvent:e}),this.moveToMouse(e,!0)},this.moveToMouse=function(e,o){E||(E=n.style.cssText),n.style.cssText=(o?"z-index:100000;":"")+(i.isIE?"opacity:0.1;":"")+"text-indent: -"+(N+C)*t.renderer.characterWidth*.5+"px;";var u=t.container.getBoundingClientRect(),a=s.computedStyle(t.container),f=u.top+(parseInt(a.borderTopWidth)||0),l=u.left+(parseInt(u.borderLeftWidth)||0),c=u.bottom-f-n.clientHeight-2,h=function(e){s.translate(n,e.clientX-l-2,Math.min(e.clientY-f-2,c))};h(e);if(e.type!="mousedown")return;t.renderer.$isMousePressed=!0,clearTimeout(J),i.isWin&&r.capture(t.container,h,K)},this.onContextMenuClose=K;var J,Q=function(e){t.textInput.onContextMenu(e),K()};r.addListener(n,"mouseup",Q,t),r.addListener(n,"mousedown",function(e){e.preventDefault(),K()},t),r.addListener(t.renderer.scroller,"contextmenu",Q,t),r.addListener(n,"contextmenu",Q,t),d&&G(e,t,n)};t.TextInput=g,t.$setUserAgentForTests=function(e,t){m=e,d=t}}),ace.define("ace/mouse/default_handlers",["require","exports","module","ace/lib/useragent"],function(e,t,n){"use strict";function o(e){e.$clickSelection=null;var t=e.editor;t.setDefaultHandler("mousedown",this.onMouseDown.bind(e)),t.setDefaultHandler("dblclick",this.onDoubleClick.bind(e)),t.setDefaultHandler("tripleclick",this.onTripleClick.bind(e)),t.setDefaultHandler("quadclick",this.onQuadClick.bind(e)),t.setDefaultHandler("mousewheel",this.onMouseWheel.bind(e));var n=["select","startSelect","selectEnd","selectAllEnd","selectByWordsEnd","selectByLinesEnd","dragWait","dragWaitEnd","focusWait"];n.forEach(function(t){e[t]=this[t]},this),e.selectByLines=this.extendSelectionBy.bind(e,"getLineRange"),e.selectByWords=this.extendSelectionBy.bind(e,"getWordRange")}function u(e,t,n,r){return Math.sqrt(Math.pow(n-e,2)+Math.pow(r-t,2))}function a(e,t){if(e.start.row==e.end.row)var n=2*t.column-e.start.column-e.end.column;else if(e.start.row==e.end.row-1&&!e.start.column&&!e.end.column)var n=t.column-4;else var n=2*t.row-e.start.row-e.end.row;return n<0?{cursor:e.start,anchor:e.end}:{cursor:e.end,anchor:e.start}}var r=e("../lib/useragent"),i=0,s=550;(function(){this.onMouseDown=function(e){var t=e.inSelection(),n=e.getDocumentPosition();this.mousedownEvent=e;var i=this.editor,s=e.getButton();if(s!==0){var o=i.getSelectionRange(),u=o.isEmpty();(u||s==1)&&i.selection.moveToPosition(n),s==2&&(i.textInput.onContextMenu(e.domEvent),r.isMozilla||e.preventDefault());return}this.mousedownEvent.time=Date.now();if(t&&!i.isFocused()){i.focus();if(this.$focusTimeout&&!this.$clickSelection&&!i.inMultiSelectMode){this.setState("focusWait"),this.captureMouse(e);return}}return this.captureMouse(e),this.startSelect(n,e.domEvent._clicks>1),e.preventDefault()},this.startSelect=function(e,t){e=e||this.editor.renderer.screenToTextCoordinates(this.x,this.y);var n=this.editor;if(!this.mousedownEvent)return;this.mousedownEvent.getShiftKey()?n.selection.selectToPosition(e):t||n.selection.moveToPosition(e),t||this.select(),n.renderer.scroller.setCapture&&n.renderer.scroller.setCapture(),n.setStyle("ace_selecting"),this.setState("select")},this.select=function(){var e,t=this.editor,n=t.renderer.screenToTextCoordinates(this.x,this.y);if(this.$clickSelection){var r=this.$clickSelection.comparePoint(n);if(r==-1)e=this.$clickSelection.end;else if(r==1)e=this.$clickSelection.start;else{var i=a(this.$clickSelection,n);n=i.cursor,e=i.anchor}t.selection.setSelectionAnchor(e.row,e.column)}t.selection.selectToPosition(n),t.renderer.scrollCursorIntoView()},this.extendSelectionBy=function(e){var t,n=this.editor,r=n.renderer.screenToTextCoordinates(this.x,this.y),i=n.selection[e](r.row,r.column);if(this.$clickSelection){var s=this.$clickSelection.comparePoint(i.start),o=this.$clickSelection.comparePoint(i.end);if(s==-1&&o<=0){t=this.$clickSelection.end;if(i.end.row!=r.row||i.end.column!=r.column)r=i.start}else if(o==1&&s>=0){t=this.$clickSelection.start;if(i.start.row!=r.row||i.start.column!=r.column)r=i.end}else if(s==-1&&o==1)r=i.end,t=i.start;else{var u=a(this.$clickSelection,r);r=u.cursor,t=u.anchor}n.selection.setSelectionAnchor(t.row,t.column)}n.selection.selectToPosition(r),n.renderer.scrollCursorIntoView()},this.selectEnd=this.selectAllEnd=this.selectByWordsEnd=this.selectByLinesEnd=function(){this.$clickSelection=null,this.editor.unsetStyle("ace_selecting"),this.editor.renderer.scroller.releaseCapture&&this.editor.renderer.scroller.releaseCapture()},this.focusWait=function(){var e=u(this.mousedownEvent.x,this.mousedownEvent.y,this.x,this.y),t=Date.now();(e>i||t-this.mousedownEvent.time>this.$focusTimeout)&&this.startSelect(this.mousedownEvent.getDocumentPosition())},this.onDoubleClick=function(e){var t=e.getDocumentPosition(),n=this.editor,r=n.session,i=r.getBracketRange(t);i?(i.isEmpty()&&(i.start.column--,i.end.column++),this.setState("select")):(i=n.selection.getWordRange(t.row,t.column),this.setState("selectByWords")),this.$clickSelection=i,this.select()},this.onTripleClick=function(e){var t=e.getDocumentPosition(),n=this.editor;this.setState("selectByLines");var r=n.getSelectionRange();r.isMultiLine()&&r.contains(t.row,t.column)?(this.$clickSelection=n.selection.getLineRange(r.start.row),this.$clickSelection.end=n.selection.getLineRange(r.end.row).end):this.$clickSelection=n.selection.getLineRange(t.row),this.select()},this.onQuadClick=function(e){var t=this.editor;t.selectAll(),this.$clickSelection=t.getSelectionRange(),this.setState("selectAll")},this.onMouseWheel=function(e){if(e.getAccelKey())return;e.getShiftKey()&&e.wheelY&&!e.wheelX&&(e.wheelX=e.wheelY,e.wheelY=0);var t=this.editor;this.$lastScroll||(this.$lastScroll={t:0,vx:0,vy:0,allowed:0});var n=this.$lastScroll,r=e.domEvent.timeStamp,i=r-n.t,o=i?e.wheelX/i:n.vx,u=i?e.wheelY/i:n.vy;i<s&&(o=(o+n.vx)/2,u=(u+n.vy)/2);var a=Math.abs(o/u),f=!1;a>=1&&t.renderer.isScrollableBy(e.wheelX*e.speed,0)&&(f=!0),a<=1&&t.renderer.isScrollableBy(0,e.wheelY*e.speed)&&(f=!0);if(f)n.allowed=r;else if(r-n.allowed<s){var l=Math.abs(o)<=1.5*Math.abs(n.vx)&&Math.abs(u)<=1.5*Math.abs(n.vy);l?(f=!0,n.allowed=r):n.allowed=0}n.t=r,n.vx=o,n.vy=u;if(f)return t.renderer.scrollBy(e.wheelX*e.speed,e.wheelY*e.speed),e.stop()}}).call(o.prototype),t.DefaultHandlers=o}),ace.define("ace/tooltip",["require","exports","module","ace/lib/oop","ace/lib/dom"],function(e,t,n){"use strict";function s(e){this.isOpen=!1,this.$element=null,this.$parentNode=e}var r=e("./lib/oop"),i=e("./lib/dom");(function(){this.$init=function(){return this.$element=i.createElement("div"),this.$element.className="ace_tooltip",this.$element.style.display="none",this.$parentNode.appendChild(this.$element),this.$element},this.getElement=function(){return this.$element||this.$init()},this.setText=function(e){this.getElement().textContent=e},this.setHtml=function(e){this.getElement().innerHTML=e},this.setPosition=function(e,t){this.getElement().style.left=e+"px",this.getElement().style.top=t+"px"},this.setClassName=function(e){i.addCssClass(this.getElement(),e)},this.show=function(e,t,n){e!=null&&this.setText(e),t!=null&&n!=null&&this.setPosition(t,n),this.isOpen||(this.getElement().style.display="block",this.isOpen=!0)},this.hide=function(){this.isOpen&&(this.getElement().style.display="none",this.isOpen=!1)},this.getHeight=function(){return this.getElement().offsetHeight},this.getWidth=function(){return this.getElement().offsetWidth},this.destroy=function(){this.isOpen=!1,this.$element&&this.$element.parentNode&&this.$element.parentNode.removeChild(this.$element)}}).call(s.prototype),t.Tooltip=s}),ace.define("ace/mouse/default_gutter_handler",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event","ace/tooltip"],function(e,t,n){"use strict";function u(e){function l(){var r=u.getDocumentPosition().row,s=n.$annotations[r];if(!s)return c();var o=t.session.getLength();if(r==o){var a=t.renderer.pixelToScreenCoordinates(0,u.y).row,l=u.$pos;if(a>t.session.documentToScreenRow(l.row,l.column))return c()}if(f==s)return;f=s.text.join("<br/>"),i.setHtml(f),i.show(),t._signal("showGutterTooltip",i),t.on("mousewheel",c);if(e.$tooltipFollowsMouse)h(u);else{var p=u.domEvent.target,d=p.getBoundingClientRect(),v=i.getElement().style;v.left=d.right+"px",v.top=d.bottom+"px"}}function c(){o&&(o=clearTimeout(o)),f&&(i.hide(),f=null,t._signal("hideGutterTooltip",i),t.off("mousewheel",c))}function h(e){i.setPosition(e.x,e.y)}var t=e.editor,n=t.renderer.$gutterLayer,i=new a(t.container);e.editor.setDefaultHandler("guttermousedown",function(r){if(!t.isFocused()||r.getButton()!=0)return;var i=n.getRegion(r);if(i=="foldWidgets")return;var s=r.getDocumentPosition().row,o=t.session.selection;if(r.getShiftKey())o.selectTo(s,0);else{if(r.domEvent.detail==2)return t.selectAll(),r.preventDefault();e.$clickSelection=t.selection.getLineRange(s)}return e.setState("selectByLines"),e.captureMouse(r),r.preventDefault()});var o,u,f;e.editor.setDefaultHandler("guttermousemove",function(t){var n=t.domEvent.target||t.domEvent.srcElement;if(r.hasCssClass(n,"ace_fold-widget"))return c();f&&e.$tooltipFollowsMouse&&h(t),u=t;if(o)return;o=setTimeout(function(){o=null,u&&!e.isMousePressed?l():c()},50)}),s.addListener(t.renderer.$gutter,"mouseout",function(e){u=null;if(!f||o)return;o=setTimeout(function(){o=null,c()},50)},t),t.on("changeSession",c)}function a(e){o.call(this,e)}var r=e("../lib/dom"),i=e("../lib/oop"),s=e("../lib/event"),o=e("../tooltip").Tooltip;i.inherits(a,o),function(){this.setPosition=function(e,t){var n=window.innerWidth||document.documentElement.clientWidth,r=window.innerHeight||document.documentElement.clientHeight,i=this.getWidth(),s=this.getHeight();e+=15,t+=15,e+i>n&&(e-=e+i-n),t+s>r&&(t-=20+s),o.prototype.setPosition.call(this,e,t)}}.call(a.prototype),t.GutterHandler=u}),ace.define("ace/mouse/mouse_event",["require","exports","module","ace/lib/event","ace/lib/useragent"],function(e,t,n){"use strict";var r=e("../lib/event"),i=e("../lib/useragent"),s=t.MouseEvent=function(e,t){this.domEvent=e,this.editor=t,this.x=this.clientX=e.clientX,this.y=this.clientY=e.clientY,this.$pos=null,this.$inSelection=null,this.propagationStopped=!1,this.defaultPrevented=!1};(function(){this.stopPropagation=function(){r.stopPropagation(this.domEvent),this.propagationStopped=!0},this.preventDefault=function(){r.preventDefault(this.domEvent),this.defaultPrevented=!0},this.stop=function(){this.stopPropagation(),this.preventDefault()},this.getDocumentPosition=function(){return this.$pos?this.$pos:(this.$pos=this.editor.renderer.screenToTextCoordinates(this.clientX,this.clientY),this.$pos)},this.inSelection=function(){if(this.$inSelection!==null)return this.$inSelection;var e=this.editor,t=e.getSelectionRange();if(t.isEmpty())this.$inSelection=!1;else{var n=this.getDocumentPosition();this.$inSelection=t.contains(n.row,n.column)}return this.$inSelection},this.getButton=function(){return r.getButton(this.domEvent)},this.getShiftKey=function(){return this.domEvent.shiftKey},this.getAccelKey=i.isMac?function(){return this.domEvent.metaKey}:function(){return this.domEvent.ctrlKey}}).call(s.prototype)}),ace.define("ace/mouse/dragdrop_handler",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"],function(e,t,n){"use strict";function f(e){function T(e,n){var r=Date.now(),i=!n||e.row!=n.row,s=!n||e.column!=n.column;if(!S||i||s)t.moveCursorToPosition(e),S=r,x={x:p,y:d};else{var o=l(x.x,x.y,p,d);o>a?S=null:r-S>=u&&(t.renderer.scrollCursorIntoView(),S=null)}}function N(e,n){var r=Date.now(),i=t.renderer.layerConfig.lineHeight,s=t.renderer.layerConfig.characterWidth,u=t.renderer.scroller.getBoundingClientRect(),a={x:{left:p-u.left,right:u.right-p},y:{top:d-u.top,bottom:u.bottom-d}},f=Math.min(a.x.left,a.x.right),l=Math.min(a.y.top,a.y.bottom),c={row:e.row,column:e.column};f/s<=2&&(c.column+=a.x.left<a.x.right?-3:2),l/i<=1&&(c.row+=a.y.top<a.y.bottom?-1:1);var h=e.row!=c.row,v=e.column!=c.column,m=!n||e.row!=n.row;h||v&&!m?E?r-E>=o&&t.renderer.scrollCursorIntoView(c):E=r:E=null}function C(){var e=g;g=t.renderer.screenToTextCoordinates(p,d),T(g,e),N(g,e)}function k(){m=t.selection.toOrientedRange(),h=t.session.addMarker(m,"ace_selection",t.getSelectionStyle()),t.clearSelection(),t.isFocused()&&t.renderer.$cursorLayer.setBlinking(!1),clearInterval(v),C(),v=setInterval(C,20),y=0,i.addListener(document,"mousemove",O)}function L(){clearInterval(v),t.session.removeMarker(h),h=null,t.selection.fromOrientedRange(m),t.isFocused()&&!w&&t.$resetCursorStyle(),m=null,g=null,y=0,E=null,S=null,i.removeListener(document,"mousemove",O)}function O(){A==null&&(A=setTimeout(function(){A!=null&&h&&L()},20))}function M(e){var t=e.types;return!t||Array.prototype.some.call(t,function(e){return e=="text/plain"||e=="Text"})}function _(e){var t=["copy","copymove","all","uninitialized"],n=["move","copymove","linkmove","all","uninitialized"],r=s.isMac?e.altKey:e.ctrlKey,i="uninitialized";try{i=e.dataTransfer.effectAllowed.toLowerCase()}catch(e){}var o="none";return r&&t.indexOf(i)>=0?o="copy":n.indexOf(i)>=0?o="move":t.indexOf(i)>=0&&(o="copy"),o}var t=e.editor,n=r.createElement("img");n.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",s.isOpera&&(n.style.cssText="width:1px;height:1px;position:fixed;top:0;left:0;z-index:2147483647;opacity:0;");var f=["dragWait","dragWaitEnd","startDrag","dragReadyEnd","onMouseDrag"];f.forEach(function(t){e[t]=this[t]},this),t.on("mousedown",this.onMouseDown.bind(e));var c=t.container,h,p,d,v,m,g,y=0,b,w,E,S,x;this.onDragStart=function(e){if(this.cancelDrag||!c.draggable){var r=this;return setTimeout(function(){r.startSelect(),r.captureMouse(e)},0),e.preventDefault()}m=t.getSelectionRange();var i=e.dataTransfer;i.effectAllowed=t.getReadOnly()?"copy":"copyMove",s.isOpera&&(t.container.appendChild(n),n.scrollTop=0),i.setDragImage&&i.setDragImage(n,0,0),s.isOpera&&t.container.removeChild(n),i.clearData(),i.setData("Text",t.session.getTextRange()),w=!0,this.setState("drag")},this.onDragEnd=function(e){c.draggable=!1,w=!1,this.setState(null);if(!t.getReadOnly()){var n=e.dataTransfer.dropEffect;!b&&n=="move"&&t.session.remove(t.getSelectionRange()),t.$resetCursorStyle()}this.editor.unsetStyle("ace_dragging"),this.editor.renderer.setCursorStyle("")},this.onDragEnter=function(e){if(t.getReadOnly()||!M(e.dataTransfer))return;return p=e.clientX,d=e.clientY,h||k(),y++,e.dataTransfer.dropEffect=b=_(e),i.preventDefault(e)},this.onDragOver=function(e){if(t.getReadOnly()||!M(e.dataTransfer))return;return p=e.clientX,d=e.clientY,h||(k(),y++),A!==null&&(A=null),e.dataTransfer.dropEffect=b=_(e),i.preventDefault(e)},this.onDragLeave=function(e){y--;if(y<=0&&h)return L(),b=null,i.preventDefault(e)},this.onDrop=function(e){if(!g)return;var n=e.dataTransfer;if(w)switch(b){case"move":m.contains(g.row,g.column)?m={start:g,end:g}:m=t.moveText(m,g);break;case"copy":m=t.moveText(m,g,!0)}else{var r=n.getData("Text");m={start:g,end:t.session.insert(g,r)},t.focus(),b=null}return L(),i.preventDefault(e)},i.addListener(c,"dragstart",this.onDragStart.bind(e),t),i.addListener(c,"dragend",this.onDragEnd.bind(e),t),i.addListener(c,"dragenter",this.onDragEnter.bind(e),t),i.addListener(c,"dragover",this.onDragOver.bind(e),t),i.addListener(c,"dragleave",this.onDragLeave.bind(e),t),i.addListener(c,"drop",this.onDrop.bind(e),t);var A=null}function l(e,t,n,r){return Math.sqrt(Math.pow(n-e,2)+Math.pow(r-t,2))}var r=e("../lib/dom"),i=e("../lib/event"),s=e("../lib/useragent"),o=200,u=200,a=5;(function(){this.dragWait=function(){var e=Date.now()-this.mousedownEvent.time;e>this.editor.getDragDelay()&&this.startDrag()},this.dragWaitEnd=function(){var e=this.editor.container;e.draggable=!1,this.startSelect(this.mousedownEvent.getDocumentPosition()),this.selectEnd()},this.dragReadyEnd=function(e){this.editor.$resetCursorStyle(),this.editor.unsetStyle("ace_dragging"),this.editor.renderer.setCursorStyle(""),this.dragWaitEnd()},this.startDrag=function(){this.cancelDrag=!1;var e=this.editor,t=e.container;t.draggable=!0,e.renderer.$cursorLayer.setBlinking(!1),e.setStyle("ace_dragging");var n=s.isWin?"default":"move";e.renderer.setCursorStyle(n),this.setState("dragReady")},this.onMouseDrag=function(e){var t=this.editor.container;if(s.isIE&&this.state=="dragReady"){var n=l(this.mousedownEvent.x,this.mousedownEvent.y,this.x,this.y);n>3&&t.dragDrop()}if(this.state==="dragWait"){var n=l(this.mousedownEvent.x,this.mousedownEvent.y,this.x,this.y);n>0&&(t.draggable=!1,this.startSelect(this.mousedownEvent.getDocumentPosition()))}},this.onMouseDown=function(e){if(!this.$dragEnabled)return;this.mousedownEvent=e;var t=this.editor,n=e.inSelection(),r=e.getButton(),i=e.domEvent.detail||1;if(i===1&&r===0&&n){if(e.editor.inMultiSelectMode&&(e.getAccelKey()||e.getShiftKey()))return;this.mousedownEvent.time=Date.now();var o=e.domEvent.target||e.domEvent.srcElement;"unselectable"in o&&(o.unselectable="on");if(t.getDragDelay()){if(s.isWebKit){this.cancelDrag=!0;var u=t.container;u.draggable=!0}this.setState("dragWait")}else this.startDrag();this.captureMouse(e,this.onMouseDrag.bind(this)),e.defaultPrevented=!0}}}).call(f.prototype),t.DragdropHandler=f}),ace.define("ace/mouse/touch_handler",["require","exports","module","ace/mouse/mouse_event","ace/lib/event","ace/lib/dom"],function(e,t,n){"use strict";var r=e("./mouse_event").MouseEvent,i=e("../lib/event"),s=e("../lib/dom");t.addTouchListeners=function(e,t){function b(){var e=window.navigator&&window.navigator.clipboard,r=!1,i=function(){var n=t.getCopyText(),i=t.session.getUndoManager().hasUndo();y.replaceChild(s.buildDom(r?["span",!n&&["span",{"class":"ace_mobile-button",action:"selectall"},"Select All"],n&&["span",{"class":"ace_mobile-button",action:"copy"},"Copy"],n&&["span",{"class":"ace_mobile-button",action:"cut"},"Cut"],e&&["span",{"class":"ace_mobile-button",action:"paste"},"Paste"],i&&["span",{"class":"ace_mobile-button",action:"undo"},"Undo"],["span",{"class":"ace_mobile-button",action:"find"},"Find"],["span",{"class":"ace_mobile-button",action:"openCommandPallete"},"Pallete"]]:["span"]),y.firstChild)},o=function(n){var s=n.target.getAttribute("action");if(s=="more"||!r)return r=!r,i();if(s=="paste")e.readText().then(function(e){t.execCommand(s,e)});else if(s){if(s=="cut"||s=="copy")e?e.writeText(t.getCopyText()):document.execCommand("copy");t.execCommand(s)}y.firstChild.style.display="none",r=!1,s!="openCommandPallete"&&t.focus()};y=s.buildDom(["div",{"class":"ace_mobile-menu",ontouchstart:function(e){n="menu",e.stopPropagation(),e.preventDefault(),t.textInput.focus()},ontouchend:function(e){e.stopPropagation(),e.preventDefault(),o(e)},onclick:o},["span"],["span",{"class":"ace_mobile-button",action:"more"},"..."]],t.container)}function w(){y||b();var e=t.selection.cursor,n=t.renderer.textToScreenCoordinates(e.row,e.column),r=t.renderer.textToScreenCoordinates(0,0).pageX,i=t.renderer.scrollLeft,s=t.container.getBoundingClientRect();y.style.top=n.pageY-s.top-3+"px",n.pageX-s.left<s.width-70?(y.style.left="",y.style.right="10px"):(y.style.right="",y.style.left=r+i-s.left+"px"),y.style.display="",y.firstChild.style.display="none",t.on("input",E)}function E(e){y&&(y.style.display="none"),t.off("input",E)}function S(){l=null,clearTimeout(l);var e=t.selection.getRange(),r=e.contains(p.row,p.column);if(e.isEmpty()||!r)t.selection.moveToPosition(p),t.selection.selectWord();n="wait",w()}function x(){l=null,clearTimeout(l),t.selection.moveToPosition(p);var e=d>=2?t.selection.getLineRange(p.row):t.session.getBracketRange(p);e&&!e.isEmpty()?t.selection.setRange(e):t.selection.selectWord(),n="wait"}function T(){h+=60,c=setInterval(function(){h--<=0&&(clearInterval(c),c=null),Math.abs(v)<.01&&(v=0),Math.abs(m)<.01&&(m=0),h<20&&(v=.9*v),h<20&&(m=.9*m);var e=t.session.getScrollTop();t.renderer.scrollBy(10*v,10*m),e==t.session.getScrollTop()&&(h=0)},10)}var n="scroll",o,u,a,f,l,c,h=0,p,d=0,v=0,m=0,g,y;i.addListener(e,"contextmenu",function(e){if(!g)return;var n=t.textInput.getElement();n.focus()},t),i.addListener(e,"touchstart",function(e){var i=e.touches;if(l||i.length>1){clearTimeout(l),l=null,a=-1,n="zoom";return}g=t.$mouseHandler.isMousePressed=!0;var s=t.renderer.layerConfig.lineHeight,c=t.renderer.layerConfig.lineHeight,y=e.timeStamp;f=y;var b=i[0],w=b.clientX,E=b.clientY;Math.abs(o-w)+Math.abs(u-E)>s&&(a=-1),o=e.clientX=w,u=e.clientY=E,v=m=0;var T=new r(e,t);p=T.getDocumentPosition();if(y-a<500&&i.length==1&&!h)d++,e.preventDefault(),e.button=0,x();else{d=0;var N=t.selection.cursor,C=t.selection.isEmpty()?N:t.selection.anchor,k=t.renderer.$cursorLayer.getPixelPosition(N,!0),L=t.renderer.$cursorLayer.getPixelPosition(C,!0),A=t.renderer.scroller.getBoundingClientRect(),O=t.renderer.layerConfig.offset,M=t.renderer.scrollLeft,_=function(e,t){return e/=c,t=t/s-.75,e*e+t*t};if(e.clientX<A.left){n="zoom";return}var D=_(e.clientX-A.left-k.left+M,e.clientY-A.top-k.top+O),P=_(e.clientX-A.left-L.left+M,e.clientY-A.top-L.top+O);D<3.5&&P<3.5&&(n=D>P?"cursor":"anchor"),P<3.5?n="anchor":D<3.5?n="cursor":n="scroll",l=setTimeout(S,450)}a=y},t),i.addListener(e,"touchend",function(e){g=t.$mouseHandler.isMousePressed=!1,c&&clearInterval(c),n=="zoom"?(n="",h=0):l?(t.selection.moveToPosition(p),h=0,w()):n=="scroll"?(T(),E()):w(),clearTimeout(l),l=null},t),i.addListener(e,"touchmove",function(e){l&&(clearTimeout(l),l=null);var i=e.touches;if(i.length>1||n=="zoom")return;var s=i[0],a=o-s.clientX,c=u-s.clientY;if(n=="wait"){if(!(a*a+c*c>4))return e.preventDefault();n="cursor"}o=s.clientX,u=s.clientY,e.clientX=s.clientX,e.clientY=s.clientY;var h=e.timeStamp,p=h-f;f=h;if(n=="scroll"){var d=new r(e,t);d.speed=1,d.wheelX=a,d.wheelY=c,10*Math.abs(a)<Math.abs(c)&&(a=0),10*Math.abs(c)<Math.abs(a)&&(c=0),p!=0&&(v=a/p,m=c/p),t._emit("mousewheel",d),d.propagationStopped||(v=m=0)}else{var g=new r(e,t),y=g.getDocumentPosition();n=="cursor"?t.selection.moveCursorToPosition(y):n=="anchor"&&t.selection.setSelectionAnchor(y.row,y.column),t.renderer.scrollCursorIntoView(y),e.preventDefault()}},t)}}),ace.define("ace/lib/net",["require","exports","module","ace/lib/dom"],function(e,t,n){"use strict";var r=e("./dom");t.get=function(e,t){var n=new XMLHttpRequest;n.open("GET",e,!0),n.onreadystatechange=function(){n.readyState===4&&t(n.responseText)},n.send(null)},t.loadScript=function(e,t){var n=r.getDocumentHead(),i=document.createElement("script");i.src=e,n.appendChild(i),i.onload=i.onreadystatechange=function(e,n){if(n||!i.readyState||i.readyState=="loaded"||i.readyState=="complete")i=i.onload=i.onreadystatechange=null,n||t()}},t.qualifyURL=function(e){var t=document.createElement("a");return t.href=e,t.href}}),ace.define("ace/lib/event_emitter",["require","exports","module"],function(e,t,n){"use strict";var r={},i=function(){this.propagationStopped=!0},s=function(){this.defaultPrevented=!0};r._emit=r._dispatchEvent=function(e,t){this._eventRegistry||(this._eventRegistry={}),this._defaultHandlers||(this._defaultHandlers={});var n=this._eventRegistry[e]||[],r=this._defaultHandlers[e];if(!n.length&&!r)return;if(typeof t!="object"||!t)t={};t.type||(t.type=e),t.stopPropagation||(t.stopPropagation=i),t.preventDefault||(t.preventDefault=s),n=n.slice();for(var o=0;o<n.length;o++){n[o](t,this);if(t.propagationStopped)break}if(r&&!t.defaultPrevented)return r(t,this)},r._signal=function(e,t){var n=(this._eventRegistry||{})[e];if(!n)return;n=n.slice();for(var r=0;r<n.length;r++)n[r](t,this)},r.once=function(e,t){var n=this;this.on(e,function r(){n.off(e,r),t.apply(null,arguments)});if(!t)return new Promise(function(e){t=e})},r.setDefaultHandler=function(e,t){var n=this._defaultHandlers;n||(n=this._defaultHandlers={_disabled_:{}});if(n[e]){var r=n[e],i=n._disabled_[e];i||(n._disabled_[e]=i=[]),i.push(r);var s=i.indexOf(t);s!=-1&&i.splice(s,1)}n[e]=t},r.removeDefaultHandler=function(e,t){var n=this._defaultHandlers;if(!n)return;var r=n._disabled_[e];if(n[e]==t)r&&this.setDefaultHandler(e,r.pop());else if(r){var i=r.indexOf(t);i!=-1&&r.splice(i,1)}},r.on=r.addEventListener=function(e,t,n){this._eventRegistry=this._eventRegistry||{};var r=this._eventRegistry[e];return r||(r=this._eventRegistry[e]=[]),r.indexOf(t)==-1&&r[n?"unshift":"push"](t),t},r.off=r.removeListener=r.removeEventListener=function(e,t){this._eventRegistry=this._eventRegistry||{};var n=this._eventRegistry[e];if(!n)return;var r=n.indexOf(t);r!==-1&&n.splice(r,1)},r.removeAllListeners=function(e){e||(this._eventRegistry=this._defaultHandlers=undefined),this._eventRegistry&&(this._eventRegistry[e]=undefined),this._defaultHandlers&&(this._defaultHandlers[e]=undefined)},t.EventEmitter=r}),ace.define("ace/lib/app_config",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"],function(e,t,n){"no use strict";function o(e){typeof console!="undefined"&&console.warn&&console.warn.apply(console,arguments)}function u(e,t){var n=new Error(e);n.data=t,typeof console=="object"&&console.error&&console.error(n),setTimeout(function(){throw n})}var r=e("./oop"),i=e("./event_emitter").EventEmitter,s={setOptions:function(e){Object.keys(e).forEach(function(t){this.setOption(t,e[t])},this)},getOptions:function(e){var t={};if(!e){var n=this.$options;e=Object.keys(n).filter(function(e){return!n[e].hidden})}else Array.isArray(e)||(t=e,e=Object.keys(t));return e.forEach(function(e){t[e]=this.getOption(e)},this),t},setOption:function(e,t){if(this["$"+e]===t)return;var n=this.$options[e];if(!n)return o('misspelled option "'+e+'"');if(n.forwardTo)return this[n.forwardTo]&&this[n.forwardTo].setOption(e,t);n.handlesSet||(this["$"+e]=t),n&&n.set&&n.set.call(this,t)},getOption:function(e){var t=this.$options[e];return t?t.forwardTo?this[t.forwardTo]&&this[t.forwardTo].getOption(e):t&&t.get?t.get.call(this):this["$"+e]:o('misspelled option "'+e+'"')}},a=function(){this.$defaultOptions={}};(function(){r.implement(this,i),this.defineOptions=function(e,t,n){return e.$options||(this.$defaultOptions[t]=e.$options={}),Object.keys(n).forEach(function(t){var r=n[t];typeof r=="string"&&(r={forwardTo:r}),r.name||(r.name=t),e.$options[r.name]=r,"initialValue"in r&&(e["$"+r.name]=r.initialValue)}),r.implement(e,s),this},this.resetOptions=function(e){Object.keys(e.$options).forEach(function(t){var n=e.$options[t];"value"in n&&e.setOption(t,n.value)})},this.setDefaultValue=function(e,t,n){if(!e){for(e in this.$defaultOptions)if(this.$defaultOptions[e][t])break;if(!this.$defaultOptions[e][t])return!1}var r=this.$defaultOptions[e]||(this.$defaultOptions[e]={});r[t]&&(r.forwardTo?this.setDefaultValue(r.forwardTo,t,n):r[t].value=n)},this.setDefaultValues=function(e,t){Object.keys(t).forEach(function(n){this.setDefaultValue(e,n,t[n])},this)},this.warn=o,this.reportError=u}).call(a.prototype),t.AppConfig=a}),ace.define("ace/config",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/lib/net","ace/lib/app_config"],function(e,t,n){"no use strict";function l(r){if(!u||!u.document)return;a.packaged=r||e.packaged||n.packaged||u.define&&define.packaged;var i={},s="",o=document.currentScript||document._currentScript,f=o&&o.ownerDocument||document,l=f.getElementsByTagName("script");for(var h=0;h<l.length;h++){var p=l[h],d=p.src||p.getAttribute("src");if(!d)continue;var v=p.attributes;for(var m=0,g=v.length;m<g;m++){var y=v[m];y.name.indexOf("data-ace-")===0&&(i[c(y.name.replace(/^data-ace-/,""))]=y.value)}var b=d.match(/^(.*)\/ace(\-\w+)?\.js(\?|$)/);b&&(s=b[1])}s&&(i.base=i.base||s,i.packaged=!0),i.basePath=i.base,i.workerPath=i.workerPath||i.base,i.modePath=i.modePath||i.base,i.themePath=i.themePath||i.base,delete i.base;for(var w in i)typeof i[w]!="undefined"&&t.set(w,i[w])}function c(e){return e.replace(/-(.)/g,function(e,t){return t.toUpperCase()})}var r=e("./lib/lang"),i=e("./lib/oop"),s=e("./lib/net"),o=e("./lib/app_config").AppConfig;n.exports=t=new o;var u=function(){return this||typeof window!="undefined"&&window}(),a={packaged:!1,workerPath:null,modePath:null,themePath:null,basePath:"",suffix:".js",$moduleUrls:{},loadWorkerFromBlob:!0,sharedPopups:!1};t.get=function(e){if(!a.hasOwnProperty(e))throw new Error("Unknown config key: "+e);return a[e]},t.set=function(e,t){if(a.hasOwnProperty(e))a[e]=t;else if(this.setDefaultValue("",e,t)==0)throw new Error("Unknown config key: "+e)},t.all=function(){return r.copyObject(a)},t.$modes={},t.moduleUrl=function(e,t){if(a.$moduleUrls[e])return a.$moduleUrls[e];var n=e.split("/");t=t||n[n.length-2]||"";var r=t=="snippets"?"/":"-",i=n[n.length-1];if(t=="worker"&&r=="-"){var s=new RegExp("^"+t+"[\\-_]|[\\-_]"+t+"$","g");i=i.replace(s,"")}(!i||i==t)&&n.length>1&&(i=n[n.length-2]);var o=a[t+"Path"];return o==null?o=a.basePath:r=="/"&&(t=r=""),o&&o.slice(-1)!="/"&&(o+="/"),o+t+r+i+this.get("suffix")},t.setModuleUrl=function(e,t){return a.$moduleUrls[e]=t},t.$loading={},t.loadModule=function(n,r){var i,o;Array.isArray(n)&&(o=n[0],n=n[1]);try{i=e(n)}catch(u){}if(i&&!t.$loading[n])return r&&r(i);t.$loading[n]||(t.$loading[n]=[]),t.$loading[n].push(r);if(t.$loading[n].length>1)return;var a=function(){e([n],function(e){t._emit("load.module",{name:n,module:e});var r=t.$loading[n];t.$loading[n]=null,r.forEach(function(t){t&&t(e)})})};if(!t.get("packaged"))return a();s.loadScript(t.moduleUrl(n,o),a),f()};var f=function(){!a.basePath&&!a.workerPath&&!a.modePath&&!a.themePath&&!Object.keys(a.$moduleUrls).length&&(console.error("Unable to infer path to ace from script src,","use ace.config.set('basePath', 'path') to enable dynamic loading of modes and themes","or with webpack use ace/webpack-resolver"),f=function(){})};t.init=l,t.version="1.4.12"}),ace.define("ace/mouse/mouse_handler",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/mouse/default_handlers","ace/mouse/default_gutter_handler","ace/mouse/mouse_event","ace/mouse/dragdrop_handler","ace/mouse/touch_handler","ace/config"],function(e,t,n){"use strict";var r=e("../lib/event"),i=e("../lib/useragent"),s=e("./default_handlers").DefaultHandlers,o=e("./default_gutter_handler").GutterHandler,u=e("./mouse_event").MouseEvent,a=e("./dragdrop_handler").DragdropHandler,f=e("./touch_handler").addTouchListeners,l=e("../config"),c=function(e){var t=this;this.editor=e,new s(this),new o(this),new a(this);var n=function(t){var n=!document.hasFocus||!document.hasFocus()||!e.isFocused()&&document.activeElement==(e.textInput&&e.textInput.getElement());n&&window.focus(),e.focus()},u=e.renderer.getMouseEventTarget();r.addListener(u,"click",this.onMouseEvent.bind(this,"click"),e),r.addListener(u,"mousemove",this.onMouseMove.bind(this,"mousemove"),e),r.addMultiMouseDownListener([u,e.renderer.scrollBarV&&e.renderer.scrollBarV.inner,e.renderer.scrollBarH&&e.renderer.scrollBarH.inner,e.textInput&&e.textInput.getElement()].filter(Boolean),[400,300,250],this,"onMouseEvent",e),r.addMouseWheelListener(e.container,this.onMouseWheel.bind(this,"mousewheel"),e),f(e.container,e);var l=e.renderer.$gutter;r.addListener(l,"mousedown",this.onMouseEvent.bind(this,"guttermousedown"),e),r.addListener(l,"click",this.onMouseEvent.bind(this,"gutterclick"),e),r.addListener(l,"dblclick",this.onMouseEvent.bind(this,"gutterdblclick"),e),r.addListener(l,"mousemove",this.onMouseEvent.bind(this,"guttermousemove"),e),r.addListener(u,"mousedown",n,e),r.addListener(l,"mousedown",n,e),i.isIE&&e.renderer.scrollBarV&&(r.addListener(e.renderer.scrollBarV.element,"mousedown",n,e),r.addListener(e.renderer.scrollBarH.element,"mousedown",n,e)),e.on("mousemove",function(n){if(t.state||t.$dragDelay||!t.$dragEnabled)return;var r=e.renderer.screenToTextCoordinates(n.x,n.y),i=e.session.selection.getRange(),s=e.renderer;!i.isEmpty()&&i.insideStart(r.row,r.column)?s.setCursorStyle("default"):s.setCursorStyle("")},e)};(function(){this.onMouseEvent=function(e,t){this.editor._emit(e,new u(t,this.editor))},this.onMouseMove=function(e,t){var n=this.editor._eventRegistry&&this.editor._eventRegistry.mousemove;if(!n||!n.length)return;this.editor._emit(e,new u(t,this.editor))},this.onMouseWheel=function(e,t){var n=new u(t,this.editor);n.speed=this.$scrollSpeed*2,n.wheelX=t.wheelX,n.wheelY=t.wheelY,this.editor._emit(e,n)},this.setState=function(e){this.state=e},this.captureMouse=function(e,t){this.x=e.x,this.y=e.y,this.isMousePressed=!0;var n=this.editor,s=this.editor.renderer;s.$isMousePressed=!0;var o=this,a=function(e){if(!e)return;if(i.isWebKit&&!e.which&&o.releaseMouse)return o.releaseMouse();o.x=e.clientX,o.y=e.clientY,t&&t(e),o.mouseEvent=new u(e,o.editor),o.$mouseMoved=!0},f=function(e){n.off("beforeEndOperation",c),clearInterval(h),l(),o[o.state+"End"]&&o[o.state+"End"](e),o.state="",o.isMousePressed=s.$isMousePressed=!1,s.$keepTextAreaAtCursor&&s.$moveTextAreaToCursor(),o.$onCaptureMouseMove=o.releaseMouse=null,e&&o.onMouseEvent("mouseup",e),n.endOperation()},l=function(){o[o.state]&&o[o.state](),o.$mouseMoved=!1};if(i.isOldIE&&e.domEvent.type=="dblclick")return setTimeout(function(){f(e)});var c=function(e){if(!o.releaseMouse)return;n.curOp.command.name&&n.curOp.selectionChanged&&(o[o.state+"End"]&&o[o.state+"End"](),o.state="",o.releaseMouse())};n.on("beforeEndOperation",c),n.startOperation({command:{name:"mouse"}}),o.$onCaptureMouseMove=a,o.releaseMouse=r.capture(this.editor.container,a,f);var h=setInterval(l,20)},this.releaseMouse=null,this.cancelContextMenu=function(){var e=function(t){if(t&&t.domEvent&&t.domEvent.type!="contextmenu")return;this.editor.off("nativecontextmenu",e),t&&t.domEvent&&r.stopEvent(t.domEvent)}.bind(this);setTimeout(e,10),this.editor.on("nativecontextmenu",e)},this.destroy=function(){this.releaseMouse&&this.releaseMouse()}}).call(c.prototype),l.defineOptions(c.prototype,"mouseHandler",{scrollSpeed:{initialValue:2},dragDelay:{initialValue:i.isMac?150:0},dragEnabled:{initialValue:!0},focusTimeout:{initialValue:0},tooltipFollowsMouse:{initialValue:!0}}),t.MouseHandler=c}),ace.define("ace/mouse/fold_handler",["require","exports","module","ace/lib/dom"],function(e,t,n){"use strict";function i(e){e.on("click",function(t){var n=t.getDocumentPosition(),i=e.session,s=i.getFoldAt(n.row,n.column,1);s&&(t.getAccelKey()?i.removeFold(s):i.expandFold(s),t.stop());var o=t.domEvent&&t.domEvent.target;o&&r.hasCssClass(o,"ace_inline_button")&&r.hasCssClass(o,"ace_toggle_wrap")&&(i.setOption("wrap",!i.getUseWrapMode()),e.renderer.scrollCursorIntoView())}),e.on("gutterclick",function(t){var n=e.renderer.$gutterLayer.getRegion(t);if(n=="foldWidgets"){var r=t.getDocumentPosition().row,i=e.session;i.foldWidgets&&i.foldWidgets[r]&&e.session.onFoldWidgetClick(r,t),e.isFocused()||e.focus(),t.stop()}}),e.on("gutterdblclick",function(t){var n=e.renderer.$gutterLayer.getRegion(t);if(n=="foldWidgets"){var r=t.getDocumentPosition().row,i=e.session,s=i.getParentFoldRangeData(r,!0),o=s.range||s.firstRange;if(o){r=o.start.row;var u=i.getFoldAt(r,i.getLine(r).length,1);u?i.removeFold(u):(i.addFold("...",o),e.renderer.scrollCursorIntoView({row:o.start.row,column:0}))}t.stop()}})}var r=e("../lib/dom");t.FoldHandler=i}),ace.define("ace/keyboard/keybinding",["require","exports","module","ace/lib/keys","ace/lib/event"],function(e,t,n){"use strict";var r=e("../lib/keys"),i=e("../lib/event"),s=function(e){this.$editor=e,this.$data={editor:e},this.$handlers=[],this.setDefaultHandler(e.commands)};(function(){this.setDefaultHandler=function(e){this.removeKeyboardHandler(this.$defaultHandler),this.$defaultHandler=e,this.addKeyboardHandler(e,0)},this.setKeyboardHandler=function(e){var t=this.$handlers;if(t[t.length-1]==e)return;while(t[t.length-1]&&t[t.length-1]!=this.$defaultHandler)this.removeKeyboardHandler(t[t.length-1]);this.addKeyboardHandler(e,1)},this.addKeyboardHandler=function(e,t){if(!e)return;typeof e=="function"&&!e.handleKeyboard&&(e.handleKeyboard=e);var n=this.$handlers.indexOf(e);n!=-1&&this.$handlers.splice(n,1),t==undefined?this.$handlers.push(e):this.$handlers.splice(t,0,e),n==-1&&e.attach&&e.attach(this.$editor)},this.removeKeyboardHandler=function(e){var t=this.$handlers.indexOf(e);return t==-1?!1:(this.$handlers.splice(t,1),e.detach&&e.detach(this.$editor),!0)},this.getKeyboardHandler=function(){return this.$handlers[this.$handlers.length-1]},this.getStatusText=function(){var e=this.$data,t=e.editor;return this.$handlers.map(function(n){return n.getStatusText&&n.getStatusText(t,e)||""}).filter(Boolean).join(" ")},this.$callKeyboardHandlers=function(e,t,n,r){var s,o=!1,u=this.$editor.commands;for(var a=this.$handlers.length;a--;){s=this.$handlers[a].handleKeyboard(this.$data,e,t,n,r);if(!s||!s.command)continue;s.command=="null"?o=!0:o=u.exec(s.command,this.$editor,s.args,r),o&&r&&e!=-1&&s.passEvent!=1&&s.command.passEvent!=1&&i.stopEvent(r);if(o)break}return!o&&e==-1&&(s={command:"insertstring"},o=u.exec("insertstring",this.$editor,t)),o&&this.$editor._signal&&this.$editor._signal("keyboardActivity",s),o},this.onCommandKey=function(e,t,n){var i=r.keyCodeToString(n);return this.$callKeyboardHandlers(t,i,n,e)},this.onTextInput=function(e){return this.$callKeyboardHandlers(-1,e)}}).call(s.prototype),t.KeyBinding=s}),ace.define("ace/lib/bidiutil",["require","exports","module"],function(e,t,n){"use strict";function F(e,t,n,r){var i=s?d:p,c=null,h=null,v=null,m=0,g=null,y=null,b=-1,w=null,E=null,T=[];if(!r)for(w=0,r=[];w<n;w++)r[w]=R(e[w]);o=s,u=!1,a=!1,f=!1,l=!1;for(E=0;E<n;E++){c=m,T[E]=h=q(e,r,T,E),m=i[c][h],g=m&240,m&=15,t[E]=v=i[m][5];if(g>0)if(g==16){for(w=b;w<E;w++)t[w]=1;b=-1}else b=-1;y=i[m][6];if(y)b==-1&&(b=E);else if(b>-1){for(w=b;w<E;w++)t[w]=v;b=-1}r[E]==S&&(t[E]=0),o|=v}if(l)for(w=0;w<n;w++)if(r[w]==x){t[w]=s;for(var C=w-1;C>=0;C--){if(r[C]!=N)break;t[C]=s}}}function I(e,t,n){if(o<e)return;if(e==1&&s==m&&!f){n.reverse();return}var r=n.length,i=0,u,a,l,c;while(i<r){if(t[i]>=e){u=i+1;while(u<r&&t[u]>=e)u++;for(a=i,l=u-1;a<l;a++,l--)c=n[a],n[a]=n[l],n[l]=c;i=u}i++}}function q(e,t,n,r){var i=t[r],o,c,h,p;switch(i){case g:case y:u=!1;case E:case w:return i;case b:return u?w:b;case T:return u=!0,a=!0,y;case N:return E;case C:if(r<1||r+1>=t.length||(o=n[r-1])!=b&&o!=w||(c=t[r+1])!=b&&c!=w)return E;return u&&(c=w),c==o?c:E;case k:o=r>0?n[r-1]:S;if(o==b&&r+1<t.length&&t[r+1]==b)return b;return E;case L:if(r>0&&n[r-1]==b)return b;if(u)return E;p=r+1,h=t.length;while(p<h&&t[p]==L)p++;if(p<h&&t[p]==b)return b;return E;case A:h=t.length,p=r+1;while(p<h&&t[p]==A)p++;if(p<h){var d=e[r],v=d>=1425&&d<=2303||d==64286;o=t[p];if(v&&(o==y||o==T))return y}if(r<1||(o=t[r-1])==S)return E;return n[r-1];case S:return u=!1,f=!0,s;case x:return l=!0,E;case O:case M:case D:case P:case _:u=!1;case H:return E}}function R(e){var t=e.charCodeAt(0),n=t>>8;return n==0?t>191?g:B[t]:n==5?/[\u0591-\u05f4]/.test(e)?y:g:n==6?/[\u0610-\u061a\u064b-\u065f\u06d6-\u06e4\u06e7-\u06ed]/.test(e)?A:/[\u0660-\u0669\u066b-\u066c]/.test(e)?w:t==1642?L:/[\u06f0-\u06f9]/.test(e)?b:T:n==32&&t<=8287?j[t&255]:n==254?t>=65136?T:E:E}function U(e){return e>="\u064b"&&e<="\u0655"}var r=["\u0621","\u0641"],i=["\u063a","\u064a"],s=0,o=0,u=!1,a=!1,f=!1,l=!1,c=!1,h=!1,p=[[0,3,0,1,0,0,0],[0,3,0,1,2,2,0],[0,3,0,17,2,0,1],[0,3,5,5,4,1,0],[0,3,21,21,4,0,1],[0,3,5,5,4,2,0]],d=[[2,0,1,1,0,1,0],[2,0,1,1,0,2,0],[2,0,2,1,3,2,0],[2,0,2,33,3,1,1]],v=0,m=1,g=0,y=1,b=2,w=3,E=4,S=5,x=6,T=7,N=8,C=9,k=10,L=11,A=12,O=13,M=14,_=15,D=16,P=17,H=18,B=[H,H,H,H,H,H,H,H,H,x,S,x,N,S,H,H,H,H,H,H,H,H,H,H,H,H,H,H,S,S,S,x,N,E,E,L,L,L,E,E,E,E,E,k,C,k,C,C,b,b,b,b,b,b,b,b,b,b,C,E,E,E,E,E,E,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,E,E,E,E,E,E,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,E,E,E,E,H,H,H,H,H,H,S,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,H,C,E,L,L,L,L,E,E,E,E,g,E,E,H,E,E,L,L,b,b,E,g,E,E,E,b,g,E,E,E,E,E],j=[N,N,N,N,N,N,N,N,N,N,N,H,H,H,g,y,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,N,S,O,M,_,D,P,C,L,L,L,L,L,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,C,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,N];t.L=g,t.R=y,t.EN=b,t.ON_R=3,t.AN=4,t.R_H=5,t.B=6,t.RLE=7,t.DOT="\u00b7",t.doBidiReorder=function(e,n,r){if(e.length<2)return{};var i=e.split(""),o=new Array(i.length),u=new Array(i.length),a=[];s=r?m:v,F(i,a,i.length,n);for(var f=0;f<o.length;o[f]=f,f++);I(2,a,o),I(1,a,o);for(var f=0;f<o.length-1;f++)n[f]===w?a[f]=t.AN:a[f]===y&&(n[f]>T&&n[f]<O||n[f]===E||n[f]===H)?a[f]=t.ON_R:f>0&&i[f-1]==="\u0644"&&/\u0622|\u0623|\u0625|\u0627/.test(i[f])&&(a[f-1]=a[f]=t.R_H,f++);i[i.length-1]===t.DOT&&(a[i.length-1]=t.B),i[0]==="\u202b"&&(a[0]=t.RLE);for(var f=0;f<o.length;f++)u[f]=a[o[f]];return{logicalFromVisual:o,bidiLevels:u}},t.hasBidiCharacters=function(e,t){var n=!1;for(var r=0;r<e.length;r++)t[r]=R(e.charAt(r)),!n&&(t[r]==y||t[r]==T||t[r]==w)&&(n=!0);return n},t.getVisualFromLogicalIdx=function(e,t){for(var n=0;n<t.logicalFromVisual.length;n++)if(t.logicalFromVisual[n]==e)return n;return 0}}),ace.define("ace/bidihandler",["require","exports","module","ace/lib/bidiutil","ace/lib/lang"],function(e,t,n){"use strict";var r=e("./lib/bidiutil"),i=e("./lib/lang"),s=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\u202B]/,o=function(e){this.session=e,this.bidiMap={},this.currentRow=null,this.bidiUtil=r,this.charWidths=[],this.EOL="\u00ac",this.showInvisibles=!0,this.isRtlDir=!1,this.$isRtl=!1,this.line="",this.wrapIndent=0,this.EOF="\u00b6",this.RLE="\u202b",this.contentWidth=0,this.fontMetrics=null,this.rtlLineOffset=0,this.wrapOffset=0,this.isMoveLeftOperation=!1,this.seenBidi=s.test(e.getValue())};(function(){this.isBidiRow=function(e,t,n){return this.seenBidi?(e!==this.currentRow&&(this.currentRow=e,this.updateRowLine(t,n),this.updateBidiMap()),this.bidiMap.bidiLevels):!1},this.onChange=function(e){this.seenBidi?this.currentRow=null:e.action=="insert"&&s.test(e.lines.join("\n"))&&(this.seenBidi=!0,this.currentRow=null)},this.getDocumentRow=function(){var e=0,t=this.session.$screenRowCache;if(t.length){var n=this.session.$getRowCacheIndex(t,this.currentRow);n>=0&&(e=this.session.$docRowCache[n])}return e},this.getSplitIndex=function(){var e=0,t=this.session.$screenRowCache;if(t.length){var n,r=this.session.$getRowCacheIndex(t,this.currentRow);while(this.currentRow-e>0){n=this.session.$getRowCacheIndex(t,this.currentRow-e-1);if(n!==r)break;r=n,e++}}else e=this.currentRow;return e},this.updateRowLine=function(e,t){e===undefined&&(e=this.getDocumentRow());var n=e===this.session.getLength()-1,s=n?this.EOF:this.EOL;this.wrapIndent=0,this.line=this.session.getLine(e),this.isRtlDir=this.$isRtl||this.line.charAt(0)===this.RLE;if(this.session.$useWrapMode){var o=this.session.$wrapData[e];o&&(t===undefined&&(t=this.getSplitIndex()),t>0&&o.length?(this.wrapIndent=o.indent,this.wrapOffset=this.wrapIndent*this.charWidths[r.L],this.line=t<o.length?this.line.substring(o[t-1],o[t]):this.line.substring(o[o.length-1])):this.line=this.line.substring(0,o[t])),t==o.length&&(this.line+=this.showInvisibles?s:r.DOT)}else this.line+=this.showInvisibles?s:r.DOT;var u=this.session,a=0,f;this.line=this.line.replace(/\t|[\u1100-\u2029, \u202F-\uFFE6]/g,function(e,t){return e===" "||u.isFullWidth(e.charCodeAt(0))?(f=e===" "?u.getScreenTabSize(t+a):2,a+=f-1,i.stringRepeat(r.DOT,f)):e}),this.isRtlDir&&(this.fontMetrics.$main.textContent=this.line.charAt(this.line.length-1)==r.DOT?this.line.substr(0,this.line.length-1):this.line,this.rtlLineOffset=this.contentWidth-this.fontMetrics.$main.getBoundingClientRect().width)},this.updateBidiMap=function(){var e=[];r.hasBidiCharacters(this.line,e)||this.isRtlDir?this.bidiMap=r.doBidiReorder(this.line,e,this.isRtlDir):this.bidiMap={}},this.markAsDirty=function(){this.currentRow=null},this.updateCharacterWidths=function(e){if(this.characterWidth===e.$characterSize.width)return;this.fontMetrics=e;var t=this.characterWidth=e.$characterSize.width,n=e.$measureCharWidth("\u05d4");this.charWidths[r.L]=this.charWidths[r.EN]=this.charWidths[r.ON_R]=t,this.charWidths[r.R]=this.charWidths[r.AN]=n,this.charWidths[r.R_H]=n*.45,this.charWidths[r.B]=this.charWidths[r.RLE]=0,this.currentRow=null},this.setShowInvisibles=function(e){this.showInvisibles=e,this.currentRow=null},this.setEolChar=function(e){this.EOL=e},this.setContentWidth=function(e){this.contentWidth=e},this.isRtlLine=function(e){return this.$isRtl?!0:e!=undefined?this.session.getLine(e).charAt(0)==this.RLE:this.isRtlDir},this.setRtlDirection=function(e,t){var n=e.getCursorPosition();for(var r=e.selection.getSelectionAnchor().row;r<=n.row;r++)!t&&e.session.getLine(r).charAt(0)===e.session.$bidiHandler.RLE?e.session.doc.removeInLine(r,0,1):t&&e.session.getLine(r).charAt(0)!==e.session.$bidiHandler.RLE&&e.session.doc.insert({column:0,row:r},e.session.$bidiHandler.RLE)},this.getPosLeft=function(e){e-=this.wrapIndent;var t=this.line.charAt(0)===this.RLE?1:0,n=e>t?this.session.getOverwrite()?e:e-1:t,i=r.getVisualFromLogicalIdx(n,this.bidiMap),s=this.bidiMap.bidiLevels,o=0;!this.session.getOverwrite()&&e<=t&&s[i]%2!==0&&i++;for(var u=0;u<i;u++)o+=this.charWidths[s[u]];return!this.session.getOverwrite()&&e>t&&s[i]%2===0&&(o+=this.charWidths[s[i]]),this.wrapIndent&&(o+=this.isRtlDir?-1*this.wrapOffset:this.wrapOffset),this.isRtlDir&&(o+=this.rtlLineOffset),o},this.getSelections=function(e,t){var n=this.bidiMap,r=n.bidiLevels,i,s=[],o=0,u=Math.min(e,t)-this.wrapIndent,a=Math.max(e,t)-this.wrapIndent,f=!1,l=!1,c=0;this.wrapIndent&&(o+=this.isRtlDir?-1*this.wrapOffset:this.wrapOffset);for(var h,p=0;p<r.length;p++)h=n.logicalFromVisual[p],i=r[p],f=h>=u&&h<a,f&&!l?c=o:!f&&l&&s.push({left:c,width:o-c}),o+=this.charWidths[i],l=f;f&&p===r.length&&s.push({left:c,width:o-c});if(this.isRtlDir)for(var d=0;d<s.length;d++)s[d].left+=this.rtlLineOffset;return s},this.offsetToCol=function(e){this.isRtlDir&&(e-=this.rtlLineOffset);var t=0,e=Math.max(e,0),n=0,r=0,i=this.bidiMap.bidiLevels,s=this.charWidths[i[r]];this.wrapIndent&&(e-=this.isRtlDir?-1*this.wrapOffset:this.wrapOffset);while(e>n+s/2){n+=s;if(r===i.length-1){s=0;break}s=this.charWidths[i[++r]]}return r>0&&i[r-1]%2!==0&&i[r]%2===0?(e<n&&r--,t=this.bidiMap.logicalFromVisual[r]):r>0&&i[r-1]%2===0&&i[r]%2!==0?t=1+(e>n?this.bidiMap.logicalFromVisual[r]:this.bidiMap.logicalFromVisual[r-1]):this.isRtlDir&&r===i.length-1&&s===0&&i[r-1]%2===0||!this.isRtlDir&&r===0&&i[r]%2!==0?t=1+this.bidiMap.logicalFromVisual[r]:(r>0&&i[r-1]%2!==0&&s!==0&&r--,t=this.bidiMap.logicalFromVisual[r]),t===0&&this.isRtlDir&&t++,t+this.wrapIndent}}).call(o.prototype),t.BidiHandler=o}),ace.define("ace/selection",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/range"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./lib/lang"),s=e("./lib/event_emitter").EventEmitter,o=e("./range").Range,u=function(e){this.session=e,this.doc=e.getDocument(),this.clearSelection(),this.cursor=this.lead=this.doc.createAnchor(0,0),this.anchor=this.doc.createAnchor(0,0),this.$silent=!1;var t=this;this.cursor.on("change",function(e){t.$cursorChanged=!0,t.$silent||t._emit("changeCursor"),!t.$isEmpty&&!t.$silent&&t._emit("changeSelection"),!t.$keepDesiredColumnOnChange&&e.old.column!=e.value.column&&(t.$desiredColumn=null)}),this.anchor.on("change",function(){t.$anchorChanged=!0,!t.$isEmpty&&!t.$silent&&t._emit("changeSelection")})};(function(){r.implement(this,s),this.isEmpty=function(){return this.$isEmpty||this.anchor.row==this.lead.row&&this.anchor.column==this.lead.column},this.isMultiLine=function(){return!this.$isEmpty&&this.anchor.row!=this.cursor.row},this.getCursor=function(){return this.lead.getPosition()},this.setSelectionAnchor=function(e,t){this.$isEmpty=!1,this.anchor.setPosition(e,t)},this.getAnchor=this.getSelectionAnchor=function(){return this.$isEmpty?this.getSelectionLead():this.anchor.getPosition()},this.getSelectionLead=function(){return this.lead.getPosition()},this.isBackwards=function(){var e=this.anchor,t=this.lead;return e.row>t.row||e.row==t.row&&e.column>t.column},this.getRange=function(){var e=this.anchor,t=this.lead;return this.$isEmpty?o.fromPoints(t,t):this.isBackwards()?o.fromPoints(t,e):o.fromPoints(e,t)},this.clearSelection=function(){this.$isEmpty||(this.$isEmpty=!0,this._emit("changeSelection"))},this.selectAll=function(){this.$setSelection(0,0,Number.MAX_VALUE,Number.MAX_VALUE)},this.setRange=this.setSelectionRange=function(e,t){var n=t?e.end:e.start,r=t?e.start:e.end;this.$setSelection(n.row,n.column,r.row,r.column)},this.$setSelection=function(e,t,n,r){if(this.$silent)return;var i=this.$isEmpty,s=this.inMultiSelectMode;this.$silent=!0,this.$cursorChanged=this.$anchorChanged=!1,this.anchor.setPosition(e,t),this.cursor.setPosition(n,r),this.$isEmpty=!o.comparePoints(this.anchor,this.cursor),this.$silent=!1,this.$cursorChanged&&this._emit("changeCursor"),(this.$cursorChanged||this.$anchorChanged||i!=this.$isEmpty||s)&&this._emit("changeSelection")},this.$moveSelection=function(e){var t=this.lead;this.$isEmpty&&this.setSelectionAnchor(t.row,t.column),e.call(this)},this.selectTo=function(e,t){this.$moveSelection(function(){this.moveCursorTo(e,t)})},this.selectToPosition=function(e){this.$moveSelection(function(){this.moveCursorToPosition(e)})},this.moveTo=function(e,t){this.clearSelection(),this.moveCursorTo(e,t)},this.moveToPosition=function(e){this.clearSelection(),this.moveCursorToPosition(e)},this.selectUp=function(){this.$moveSelection(this.moveCursorUp)},this.selectDown=function(){this.$moveSelection(this.moveCursorDown)},this.selectRight=function(){this.$moveSelection(this.moveCursorRight)},this.selectLeft=function(){this.$moveSelection(this.moveCursorLeft)},this.selectLineStart=function(){this.$moveSelection(this.moveCursorLineStart)},this.selectLineEnd=function(){this.$moveSelection(this.moveCursorLineEnd)},this.selectFileEnd=function(){this.$moveSelection(this.moveCursorFileEnd)},this.selectFileStart=function(){this.$moveSelection(this.moveCursorFileStart)},this.selectWordRight=function(){this.$moveSelection(this.moveCursorWordRight)},this.selectWordLeft=function(){this.$moveSelection(this.moveCursorWordLeft)},this.getWordRange=function(e,t){if(typeof t=="undefined"){var n=e||this.lead;e=n.row,t=n.column}return this.session.getWordRange(e,t)},this.selectWord=function(){this.setSelectionRange(this.getWordRange())},this.selectAWord=function(){var e=this.getCursor(),t=this.session.getAWordRange(e.row,e.column);this.setSelectionRange(t)},this.getLineRange=function(e,t){var n=typeof e=="number"?e:this.lead.row,r,i=this.session.getFoldLine(n);return i?(n=i.start.row,r=i.end.row):r=n,t===!0?new o(n,0,r,this.session.getLine(r).length):new o(n,0,r+1,0)},this.selectLine=function(){this.setSelectionRange(this.getLineRange())},this.moveCursorUp=function(){this.moveCursorBy(-1,0)},this.moveCursorDown=function(){this.moveCursorBy(1,0)},this.wouldMoveIntoSoftTab=function(e,t,n){var r=e.column,i=e.column+t;return n<0&&(r=e.column-t,i=e.column),this.session.isTabStop(e)&&this.doc.getLine(e.row).slice(r,i).split(" ").length-1==t},this.moveCursorLeft=function(){var e=this.lead.getPosition(),t;if(t=this.session.getFoldAt(e.row,e.column,-1))this.moveCursorTo(t.start.row,t.start.column);else if(e.column===0)e.row>0&&this.moveCursorTo(e.row-1,this.doc.getLine(e.row-1).length);else{var n=this.session.getTabSize();this.wouldMoveIntoSoftTab(e,n,-1)&&!this.session.getNavigateWithinSoftTabs()?this.moveCursorBy(0,-n):this.moveCursorBy(0,-1)}},this.moveCursorRight=function(){var e=this.lead.getPosition(),t;if(t=this.session.getFoldAt(e.row,e.column,1))this.moveCursorTo(t.end.row,t.end.column);else if(this.lead.column==this.doc.getLine(this.lead.row).length)this.lead.row<this.doc.getLength()-1&&this.moveCursorTo(this.lead.row+1,0);else{var n=this.session.getTabSize(),e=this.lead;this.wouldMoveIntoSoftTab(e,n,1)&&!this.session.getNavigateWithinSoftTabs()?this.moveCursorBy(0,n):this.moveCursorBy(0,1)}},this.moveCursorLineStart=function(){var e=this.lead.row,t=this.lead.column,n=this.session.documentToScreenRow(e,t),r=this.session.screenToDocumentPosition(n,0),i=this.session.getDisplayLine(e,null,r.row,r.column),s=i.match(/^\s*/);s[0].length!=t&&!this.session.$useEmacsStyleLineStart&&(r.column+=s[0].length),this.moveCursorToPosition(r)},this.moveCursorLineEnd=function(){var e=this.lead,t=this.session.getDocumentLastRowColumnPosition(e.row,e.column);if(this.lead.column==t.column){var n=this.session.getLine(t.row);if(t.column==n.length){var r=n.search(/\s+$/);r>0&&(t.column=r)}}this.moveCursorTo(t.row,t.column)},this.moveCursorFileEnd=function(){var e=this.doc.getLength()-1,t=this.doc.getLine(e).length;this.moveCursorTo(e,t)},this.moveCursorFileStart=function(){this.moveCursorTo(0,0)},this.moveCursorLongWordRight=function(){var e=this.lead.row,t=this.lead.column,n=this.doc.getLine(e),r=n.substring(t);this.session.nonTokenRe.lastIndex=0,this.session.tokenRe.lastIndex=0;var i=this.session.getFoldAt(e,t,1);if(i){this.moveCursorTo(i.end.row,i.end.column);return}this.session.nonTokenRe.exec(r)&&(t+=this.session.nonTokenRe.lastIndex,this.session.nonTokenRe.lastIndex=0,r=n.substring(t));if(t>=n.length){this.moveCursorTo(e,n.length),this.moveCursorRight(),e<this.doc.getLength()-1&&this.moveCursorWordRight();return}this.session.tokenRe.exec(r)&&(t+=this.session.tokenRe.lastIndex,this.session.tokenRe.lastIndex=0),this.moveCursorTo(e,t)},this.moveCursorLongWordLeft=function(){var e=this.lead.row,t=this.lead.column,n;if(n=this.session.getFoldAt(e,t,-1)){this.moveCursorTo(n.start.row,n.start.column);return}var r=this.session.getFoldStringAt(e,t,-1);r==null&&(r=this.doc.getLine(e).substring(0,t));var s=i.stringReverse(r);this.session.nonTokenRe.lastIndex=0,this.session.tokenRe.lastIndex=0,this.session.nonTokenRe.exec(s)&&(t-=this.session.nonTokenRe.lastIndex,s=s.slice(this.session.nonTokenRe.lastIndex),this.session.nonTokenRe.lastIndex=0);if(t<=0){this.moveCursorTo(e,0),this.moveCursorLeft(),e>0&&this.moveCursorWordLeft();return}this.session.tokenRe.exec(s)&&(t-=this.session.tokenRe.lastIndex,this.session.tokenRe.lastIndex=0),this.moveCursorTo(e,t)},this.$shortWordEndIndex=function(e){var t=0,n,r=/\s/,i=this.session.tokenRe;i.lastIndex=0;if(this.session.tokenRe.exec(e))t=this.session.tokenRe.lastIndex;else{while((n=e[t])&&r.test(n))t++;if(t<1){i.lastIndex=0;while((n=e[t])&&!i.test(n)){i.lastIndex=0,t++;if(r.test(n)){if(t>2){t--;break}while((n=e[t])&&r.test(n))t++;if(t>2)break}}}}return i.lastIndex=0,t},this.moveCursorShortWordRight=function(){var e=this.lead.row,t=this.lead.column,n=this.doc.getLine(e),r=n.substring(t),i=this.session.getFoldAt(e,t,1);if(i)return this.moveCursorTo(i.end.row,i.end.column);if(t==n.length){var s=this.doc.getLength();do e++,r=this.doc.getLine(e);while(e<s&&/^\s*$/.test(r));/^\s+/.test(r)||(r=""),t=0}var o=this.$shortWordEndIndex(r);this.moveCursorTo(e,t+o)},this.moveCursorShortWordLeft=function(){var e=this.lead.row,t=this.lead.column,n;if(n=this.session.getFoldAt(e,t,-1))return this.moveCursorTo(n.start.row,n.start.column);var r=this.session.getLine(e).substring(0,t);if(t===0){do e--,r=this.doc.getLine(e);while(e>0&&/^\s*$/.test(r));t=r.length,/\s+$/.test(r)||(r="")}var s=i.stringReverse(r),o=this.$shortWordEndIndex(s);return this.moveCursorTo(e,t-o)},this.moveCursorWordRight=function(){this.session.$selectLongWords?this.moveCursorLongWordRight():this.moveCursorShortWordRight()},this.moveCursorWordLeft=function(){this.session.$selectLongWords?this.moveCursorLongWordLeft():this.moveCursorShortWordLeft()},this.moveCursorBy=function(e,t){var n=this.session.documentToScreenPosition(this.lead.row,this.lead.column),r;t===0&&(e!==0&&(this.session.$bidiHandler.isBidiRow(n.row,this.lead.row)?(r=this.session.$bidiHandler.getPosLeft(n.column),n.column=Math.round(r/this.session.$bidiHandler.charWidths[0])):r=n.column*this.session.$bidiHandler.charWidths[0]),this.$desiredColumn?n.column=this.$desiredColumn:this.$desiredColumn=n.column);if(e!=0&&this.session.lineWidgets&&this.session.lineWidgets[this.lead.row]){var i=this.session.lineWidgets[this.lead.row];e<0?e-=i.rowsAbove||0:e>0&&(e+=i.rowCount-(i.rowsAbove||0))}var s=this.session.screenToDocumentPosition(n.row+e,n.column,r);e!==0&&t===0&&s.row===this.lead.row&&s.column===this.lead.column,this.moveCursorTo(s.row,s.column+t,t===0)},this.moveCursorToPosition=function(e){this.moveCursorTo(e.row,e.column)},this.moveCursorTo=function(e,t,n){var r=this.session.getFoldAt(e,t,1);r&&(e=r.start.row,t=r.start.column),this.$keepDesiredColumnOnChange=!0;var i=this.session.getLine(e);/[\uDC00-\uDFFF]/.test(i.charAt(t))&&i.charAt(t-1)&&(this.lead.row==e&&this.lead.column==t+1?t-=1:t+=1),this.lead.setPosition(e,t),this.$keepDesiredColumnOnChange=!1,n||(this.$desiredColumn=null)},this.moveCursorToScreen=function(e,t,n){var r=this.session.screenToDocumentPosition(e,t);this.moveCursorTo(r.row,r.column,n)},this.detach=function(){this.lead.detach(),this.anchor.detach(),this.session=this.doc=null},this.fromOrientedRange=function(e){this.setSelectionRange(e,e.cursor==e.start),this.$desiredColumn=e.desiredColumn||this.$desiredColumn},this.toOrientedRange=function(e){var t=this.getRange();return e?(e.start.column=t.start.column,e.start.row=t.start.row,e.end.column=t.end.column,e.end.row=t.end.row):e=t,e.cursor=this.isBackwards()?e.start:e.end,e.desiredColumn=this.$desiredColumn,e},this.getRangeOfMovements=function(e){var t=this.getCursor();try{e(this);var n=this.getCursor();return o.fromPoints(t,n)}catch(r){return o.fromPoints(t,t)}finally{this.moveCursorToPosition(t)}},this.toJSON=function(){if(this.rangeCount)var e=this.ranges.map(function(e){var t=e.clone();return t.isBackwards=e.cursor==e.start,t});else{var e=this.getRange();e.isBackwards=this.isBackwards()}return e},this.fromJSON=function(e){if(e.start==undefined){if(this.rangeList&&e.length>1){this.toSingleRange(e[0]);for(var t=e.length;t--;){var n=o.fromPoints(e[t].start,e[t].end);e[t].isBackwards&&(n.cursor=n.start),this.addRange(n,!0)}return}e=e[0]}this.rangeList&&this.toSingleRange(e),this.setSelectionRange(e,e.isBackwards)},this.isEqual=function(e){if((e.length||this.rangeCount)&&e.length!=this.rangeCount)return!1;if(!e.length||!this.ranges)return this.getRange().isEqual(e);for(var t=this.ranges.length;t--;)if(!this.ranges[t].isEqual(e[t]))return!1;return!0}}).call(u.prototype),t.Selection=u}),ace.define("ace/tokenizer",["require","exports","module","ace/config"],function(e,t,n){"use strict";var r=e("./config"),i=2e3,s=function(e){this.states=e,this.regExps={},this.matchMappings={};for(var t in this.states){var n=this.states[t],r=[],i=0,s=this.matchMappings[t]={defaultToken:"text"},o="g",u=[];for(var a=0;a<n.length;a++){var f=n[a];f.defaultToken&&(s.defaultToken=f.defaultToken),f.caseInsensitive&&(o="gi");if(f.regex==null)continue;f.regex instanceof RegExp&&(f.regex=f.regex.toString().slice(1,-1));var l=f.regex,c=(new RegExp("(?:("+l+")|(.))")).exec("a").length-2;Array.isArray(f.token)?f.token.length==1||c==1?f.token=f.token[0]:c-1!=f.token.length?(this.reportError("number of classes and regexp groups doesn't match",{rule:f,groupCount:c-1}),f.token=f.token[0]):(f.tokenArray=f.token,f.token=null,f.onMatch=this.$arrayTokens):typeof f.token=="function"&&!f.onMatch&&(c>1?f.onMatch=this.$applyToken:f.onMatch=f.token),c>1&&(/\\\d/.test(f.regex)?l=f.regex.replace(/\\([0-9]+)/g,function(e,t){return"\\"+(parseInt(t,10)+i+1)}):(c=1,l=this.removeCapturingGroups(f.regex)),!f.splitRegex&&typeof f.token!="string"&&u.push(f)),s[i]=a,i+=c,r.push(l),f.onMatch||(f.onMatch=null)}r.length||(s[0]=0,r.push("$")),u.forEach(function(e){e.splitRegex=this.createSplitterRegexp(e.regex,o)},this),this.regExps[t]=new RegExp("("+r.join(")|(")+")|($)",o)}};(function(){this.$setMaxTokenCount=function(e){i=e|0},this.$applyToken=function(e){var t=this.splitRegex.exec(e).slice(1),n=this.token.apply(this,t);if(typeof n=="string")return[{type:n,value:e}];var r=[];for(var i=0,s=n.length;i<s;i++)t[i]&&(r[r.length]={type:n[i],value:t[i]});return r},this.$arrayTokens=function(e){if(!e)return[];var t=this.splitRegex.exec(e);if(!t)return"text";var n=[],r=this.tokenArray;for(var i=0,s=r.length;i<s;i++)t[i+1]&&(n[n.length]={type:r[i],value:t[i+1]});return n},this.removeCapturingGroups=function(e){var t=e.replace(/\\.|\[(?:\\.|[^\\\]])*|\(\?[:=!]|(\()/g,function(e,t){return t?"(?:":e});return t},this.createSplitterRegexp=function(e,t){if(e.indexOf("(?=")!=-1){var n=0,r=!1,i={};e.replace(/(\\.)|(\((?:\?[=!])?)|(\))|([\[\]])/g,function(e,t,s,o,u,a){return r?r=u!="]":u?r=!0:o?(n==i.stack&&(i.end=a+1,i.stack=-1),n--):s&&(n++,s.length!=1&&(i.stack=n,i.start=a)),e}),i.end!=null&&/^\)*$/.test(e.substr(i.end))&&(e=e.substring(0,i.start)+e.substr(i.end))}return e.charAt(0)!="^"&&(e="^"+e),e.charAt(e.length-1)!="$"&&(e+="$"),new RegExp(e,(t||"").replace("g",""))},this.getLineTokens=function(e,t){if(t&&typeof t!="string"){var n=t.slice(0);t=n[0],t==="#tmp"&&(n.shift(),t=n.shift())}else var n=[];var r=t||"start",s=this.states[r];s||(r="start",s=this.states[r]);var o=this.matchMappings[r],u=this.regExps[r];u.lastIndex=0;var a,f=[],l=0,c=0,h={type:null,value:""};while(a=u.exec(e)){var p=o.defaultToken,d=null,v=a[0],m=u.lastIndex;if(m-v.length>l){var g=e.substring(l,m-v.length);h.type==p?h.value+=g:(h.type&&f.push(h),h={type:p,value:g})}for(var y=0;y<a.length-2;y++){if(a[y+1]===undefined)continue;d=s[o[y]],d.onMatch?p=d.onMatch(v,r,n,e):p=d.token,d.next&&(typeof d.next=="string"?r=d.next:r=d.next(r,n),s=this.states[r],s||(this.reportError("state doesn't exist",r),r="start",s=this.states[r]),o=this.matchMappings[r],l=m,u=this.regExps[r],u.lastIndex=m),d.consumeLineEnd&&(l=m);break}if(v)if(typeof p=="string")!!d&&d.merge===!1||h.type!==p?(h.type&&f.push(h),h={type:p,value:v}):h.value+=v;else if(p){h.type&&f.push(h),h={type:null,value:""};for(var y=0;y<p.length;y++)f.push(p[y])}if(l==e.length)break;l=m;if(c++>i){c>2*e.length&&this.reportError("infinite loop with in ace tokenizer",{startState:t,line:e});while(l<e.length)h.type&&f.push(h),h={value:e.substring(l,l+=500),type:"overflow"};r="start",n=[];break}}return h.type&&f.push(h),n.length>1&&n[0]!==r&&n.unshift("#tmp",r),{tokens:f,state:n.length?n:r}},this.reportError=r.reportError}).call(s.prototype),t.Tokenizer=s}),ace.define("ace/mode/text_highlight_rules",["require","exports","module","ace/lib/lang"],function(e,t,n){"use strict";var r=e("../lib/lang"),i=function(){this.$rules={start:[{token:"empty_line",regex:"^$"},{defaultToken:"text"}]}};(function(){this.addRules=function(e,t){if(!t){for(var n in e)this.$rules[n]=e[n];return}for(var n in e){var r=e[n];for(var i=0;i<r.length;i++){var s=r[i];if(s.next||s.onMatch)typeof s.next=="string"&&s.next.indexOf(t)!==0&&(s.next=t+s.next),s.nextState&&s.nextState.indexOf(t)!==0&&(s.nextState=t+s.nextState)}this.$rules[t+n]=r}},this.getRules=function(){return this.$rules},this.embedRules=function(e,t,n,i,s){var o=typeof e=="function"?(new e).getRules():e;if(i)for(var u=0;u<i.length;u++)i[u]=t+i[u];else{i=[];for(var a in o)i.push(t+a)}this.addRules(o,t);if(n){var f=Array.prototype[s?"push":"unshift"];for(var u=0;u<i.length;u++)f.apply(this.$rules[i[u]],r.deepCopy(n))}this.$embeds||(this.$embeds=[]),this.$embeds.push(t)},this.getEmbeds=function(){return this.$embeds};var e=function(e,t){return(e!="start"||t.length)&&t.unshift(this.nextState,e),this.nextState},t=function(e,t){return t.shift(),t.shift()||"start"};this.normalizeRules=function(){function i(s){var o=r[s];o.processed=!0;for(var u=0;u<o.length;u++){var a=o[u],f=null;Array.isArray(a)&&(f=a,a={}),!a.regex&&a.start&&(a.regex=a.start,a.next||(a.next=[]),a.next.push({defaultToken:a.token},{token:a.token+".end",regex:a.end||a.start,next:"pop"}),a.token=a.token+".start",a.push=!0);var l=a.next||a.push;if(l&&Array.isArray(l)){var c=a.stateName;c||(c=a.token,typeof c!="string"&&(c=c[0]||""),r[c]&&(c+=n++)),r[c]=l,a.next=c,i(c)}else l=="pop"&&(a.next=t);a.push&&(a.nextState=a.next||a.push,a.next=e,delete a.push);if(a.rules)for(var h in a.rules)r[h]?r[h].push&&r[h].push.apply(r[h],a.rules[h]):r[h]=a.rules[h];var p=typeof a=="string"?a:a.include;p&&(Array.isArray(p)?f=p.map(function(e){return r[e]}):f=r[p]);if(f){var d=[u,1].concat(f);a.noEscape&&(d=d.filter(function(e){return!e.next})),o.splice.apply(o,d),u--}a.keywordMap&&(a.token=this.createKeywordMapper(a.keywordMap,a.defaultToken||"text",a.caseInsensitive),delete a.defaultToken)}}var n=0,r=this.$rules;Object.keys(r).forEach(i,this)},this.createKeywordMapper=function(e,t,n,r){var i=Object.create(null);return this.$keywordList=[],Object.keys(e).forEach(function(t){var s=e[t],o=s.split(r||"|");for(var u=o.length;u--;){var a=o[u];this.$keywordList.push(a),n&&(a=a.toLowerCase()),i[a]=t}},this),e=null,n?function(e){return i[e.toLowerCase()]||t}:function(e){return i[e]||t}},this.getKeywords=function(){return this.$keywords}}).call(i.prototype),t.TextHighlightRules=i}),ace.define("ace/mode/behaviour",["require","exports","module"],function(e,t,n){"use strict";var r=function(){this.$behaviours={}};(function(){this.add=function(e,t,n){switch(undefined){case this.$behaviours:this.$behaviours={};case this.$behaviours[e]:this.$behaviours[e]={}}this.$behaviours[e][t]=n},this.addBehaviours=function(e){for(var t in e)for(var n in e[t])this.add(t,n,e[t][n])},this.remove=function(e){this.$behaviours&&this.$behaviours[e]&&delete this.$behaviours[e]},this.inherit=function(e,t){if(typeof e=="function")var n=(new e).getBehaviours(t);else var n=e.getBehaviours(t);this.addBehaviours(n)},this.getBehaviours=function(e){if(!e)return this.$behaviours;var t={};for(var n=0;n<e.length;n++)this.$behaviours[e[n]]&&(t[e[n]]=this.$behaviours[e[n]]);return t}}).call(r.prototype),t.Behaviour=r}),ace.define("ace/token_iterator",["require","exports","module","ace/range"],function(e,t,n){"use strict";var r=e("./range").Range,i=function(e,t,n){this.$session=e,this.$row=t,this.$rowTokens=e.getTokens(t);var r=e.getTokenAt(t,n);this.$tokenIndex=r?r.index:-1};(function(){this.stepBackward=function(){this.$tokenIndex-=1;while(this.$tokenIndex<0){this.$row-=1;if(this.$row<0)return this.$row=0,null;this.$rowTokens=this.$session.getTokens(this.$row),this.$tokenIndex=this.$rowTokens.length-1}return this.$rowTokens[this.$tokenIndex]},this.stepForward=function(){this.$tokenIndex+=1;var e;while(this.$tokenIndex>=this.$rowTokens.length){this.$row+=1,e||(e=this.$session.getLength());if(this.$row>=e)return this.$row=e-1,null;this.$rowTokens=this.$session.getTokens(this.$row),this.$tokenIndex=0}return this.$rowTokens[this.$tokenIndex]},this.getCurrentToken=function(){return this.$rowTokens[this.$tokenIndex]},this.getCurrentTokenRow=function(){return this.$row},this.getCurrentTokenColumn=function(){var e=this.$rowTokens,t=this.$tokenIndex,n=e[t].start;if(n!==undefined)return n;n=0;while(t>0)t-=1,n+=e[t].value.length;return n},this.getCurrentTokenPosition=function(){return{row:this.$row,column:this.getCurrentTokenColumn()}},this.getCurrentTokenRange=function(){var e=this.$rowTokens[this.$tokenIndex],t=this.getCurrentTokenColumn();return new r(this.$row,t,this.$row,t+e.value.length)}}).call(i.prototype),t.TokenIterator=i}),ace.define("ace/mode/behaviour/cstyle",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"],function(e,t,n){"use strict";var r=e("../../lib/oop"),i=e("../behaviour").Behaviour,s=e("../../token_iterator").TokenIterator,o=e("../../lib/lang"),u=["text","paren.rparen","rparen","paren","punctuation.operator"],a=["text","paren.rparen","rparen","paren","punctuation.operator","comment"],f,l={},c={'"':'"',"'":"'"},h=function(e){var t=-1;e.multiSelect&&(t=e.selection.index,l.rangeCount!=e.multiSelect.rangeCount&&(l={rangeCount:e.multiSelect.rangeCount}));if(l[t])return f=l[t];f=l[t]={autoInsertedBrackets:0,autoInsertedRow:-1,autoInsertedLineEnd:"",maybeInsertedBrackets:0,maybeInsertedRow:-1,maybeInsertedLineStart:"",maybeInsertedLineEnd:""}},p=function(e,t,n,r){var i=e.end.row-e.start.row;return{text:n+t+r,selection:[0,e.start.column+1,i,e.end.column+(i?0:1)]}},d=function(e){this.add("braces","insertion",function(t,n,r,i,s){var u=r.getCursorPosition(),a=i.doc.getLine(u.row);if(s=="{"){h(r);var l=r.getSelectionRange(),c=i.doc.getTextRange(l);if(c!==""&&c!=="{"&&r.getWrapBehavioursEnabled())return p(l,c,"{","}");if(d.isSaneInsertion(r,i))return/[\]\}\)]/.test(a[u.column])||r.inMultiSelectMode||e&&e.braces?(d.recordAutoInsert(r,i,"}"),{text:"{}",selection:[1,1]}):(d.recordMaybeInsert(r,i,"{"),{text:"{",selection:[1,1]})}else if(s=="}"){h(r);var v=a.substring(u.column,u.column+1);if(v=="}"){var m=i.$findOpeningBracket("}",{column:u.column+1,row:u.row});if(m!==null&&d.isAutoInsertedClosing(u,a,s))return d.popAutoInsertedClosing(),{text:"",selection:[1,1]}}}else{if(s=="\n"||s=="\r\n"){h(r);var g="";d.isMaybeInsertedClosing(u,a)&&(g=o.stringRepeat("}",f.maybeInsertedBrackets),d.clearMaybeInsertedClosing());var v=a.substring(u.column,u.column+1);if(v==="}"){var y=i.findMatchingBracket({row:u.row,column:u.column+1},"}");if(!y)return null;var b=this.$getIndent(i.getLine(y.row))}else{if(!g){d.clearMaybeInsertedClosing();return}var b=this.$getIndent(a)}var w=b+i.getTabString();return{text:"\n"+w+"\n"+b+g,selection:[1,w.length,1,w.length]}}d.clearMaybeInsertedClosing()}}),this.add("braces","deletion",function(e,t,n,r,i){var s=r.doc.getTextRange(i);if(!i.isMultiLine()&&s=="{"){h(n);var o=r.doc.getLine(i.start.row),u=o.substring(i.end.column,i.end.column+1);if(u=="}")return i.end.column++,i;f.maybeInsertedBrackets--}}),this.add("parens","insertion",function(e,t,n,r,i){if(i=="("){h(n);var s=n.getSelectionRange(),o=r.doc.getTextRange(s);if(o!==""&&n.getWrapBehavioursEnabled())return p(s,o,"(",")");if(d.isSaneInsertion(n,r))return d.recordAutoInsert(n,r,")"),{text:"()",selection:[1,1]}}else if(i==")"){h(n);var u=n.getCursorPosition(),a=r.doc.getLine(u.row),f=a.substring(u.column,u.column+1);if(f==")"){var l=r.$findOpeningBracket(")",{column:u.column+1,row:u.row});if(l!==null&&d.isAutoInsertedClosing(u,a,i))return d.popAutoInsertedClosing(),{text:"",selection:[1,1]}}}}),this.add("parens","deletion",function(e,t,n,r,i){var s=r.doc.getTextRange(i);if(!i.isMultiLine()&&s=="("){h(n);var o=r.doc.getLine(i.start.row),u=o.substring(i.start.column+1,i.start.column+2);if(u==")")return i.end.column++,i}}),this.add("brackets","insertion",function(e,t,n,r,i){if(i=="["){h(n);var s=n.getSelectionRange(),o=r.doc.getTextRange(s);if(o!==""&&n.getWrapBehavioursEnabled())return p(s,o,"[","]");if(d.isSaneInsertion(n,r))return d.recordAutoInsert(n,r,"]"),{text:"[]",selection:[1,1]}}else if(i=="]"){h(n);var u=n.getCursorPosition(),a=r.doc.getLine(u.row),f=a.substring(u.column,u.column+1);if(f=="]"){var l=r.$findOpeningBracket("]",{column:u.column+1,row:u.row});if(l!==null&&d.isAutoInsertedClosing(u,a,i))return d.popAutoInsertedClosing(),{text:"",selection:[1,1]}}}}),this.add("brackets","deletion",function(e,t,n,r,i){var s=r.doc.getTextRange(i);if(!i.isMultiLine()&&s=="["){h(n);var o=r.doc.getLine(i.start.row),u=o.substring(i.start.column+1,i.start.column+2);if(u=="]")return i.end.column++,i}}),this.add("string_dquotes","insertion",function(e,t,n,r,i){var s=r.$mode.$quotes||c;if(i.length==1&&s[i]){if(this.lineCommentStart&&this.lineCommentStart.indexOf(i)!=-1)return;h(n);var o=i,u=n.getSelectionRange(),a=r.doc.getTextRange(u);if(a!==""&&(a.length!=1||!s[a])&&n.getWrapBehavioursEnabled())return p(u,a,o,o);if(!a){var f=n.getCursorPosition(),l=r.doc.getLine(f.row),d=l.substring(f.column-1,f.column),v=l.substring(f.column,f.column+1),m=r.getTokenAt(f.row,f.column),g=r.getTokenAt(f.row,f.column+1);if(d=="\\"&&m&&/escape/.test(m.type))return null;var y=m&&/string|escape/.test(m.type),b=!g||/string|escape/.test(g.type),w;if(v==o)w=y!==b,w&&/string\.end/.test(g.type)&&(w=!1);else{if(y&&!b)return null;if(y&&b)return null;var E=r.$mode.tokenRe;E.lastIndex=0;var S=E.test(d);E.lastIndex=0;var x=E.test(d);if(S||x)return null;if(v&&!/[\s;,.})\]\\]/.test(v))return null;var T=l[f.column-2];if(!(d!=o||T!=o&&!E.test(T)))return null;w=!0}return{text:w?o+o:"",selection:[1,1]}}}}),this.add("string_dquotes","deletion",function(e,t,n,r,i){var s=r.$mode.$quotes||c,o=r.doc.getTextRange(i);if(!i.isMultiLine()&&s.hasOwnProperty(o)){h(n);var u=r.doc.getLine(i.start.row),a=u.substring(i.start.column+1,i.start.column+2);if(a==o)return i.end.column++,i}})};d.isSaneInsertion=function(e,t){var n=e.getCursorPosition(),r=new s(t,n.row,n.column);if(!this.$matchTokenType(r.getCurrentToken()||"text",u)){if(/[)}\]]/.test(e.session.getLine(n.row)[n.column]))return!0;var i=new s(t,n.row,n.column+1);if(!this.$matchTokenType(i.getCurrentToken()||"text",u))return!1}return r.stepForward(),r.getCurrentTokenRow()!==n.row||this.$matchTokenType(r.getCurrentToken()||"text",a)},d.$matchTokenType=function(e,t){return t.indexOf(e.type||e)>-1},d.recordAutoInsert=function(e,t,n){var r=e.getCursorPosition(),i=t.doc.getLine(r.row);this.isAutoInsertedClosing(r,i,f.autoInsertedLineEnd[0])||(f.autoInsertedBrackets=0),f.autoInsertedRow=r.row,f.autoInsertedLineEnd=n+i.substr(r.column),f.autoInsertedBrackets++},d.recordMaybeInsert=function(e,t,n){var r=e.getCursorPosition(),i=t.doc.getLine(r.row);this.isMaybeInsertedClosing(r,i)||(f.maybeInsertedBrackets=0),f.maybeInsertedRow=r.row,f.maybeInsertedLineStart=i.substr(0,r.column)+n,f.maybeInsertedLineEnd=i.substr(r.column),f.maybeInsertedBrackets++},d.isAutoInsertedClosing=function(e,t,n){return f.autoInsertedBrackets>0&&e.row===f.autoInsertedRow&&n===f.autoInsertedLineEnd[0]&&t.substr(e.column)===f.autoInsertedLineEnd},d.isMaybeInsertedClosing=function(e,t){return f.maybeInsertedBrackets>0&&e.row===f.maybeInsertedRow&&t.substr(e.column)===f.maybeInsertedLineEnd&&t.substr(0,e.column)==f.maybeInsertedLineStart},d.popAutoInsertedClosing=function(){f.autoInsertedLineEnd=f.autoInsertedLineEnd.substr(1),f.autoInsertedBrackets--},d.clearMaybeInsertedClosing=function(){f&&(f.maybeInsertedBrackets=0,f.maybeInsertedRow=-1)},r.inherits(d,i),t.CstyleBehaviour=d}),ace.define("ace/unicode",["require","exports","module"],function(e,t,n){"use strict";var r=[48,9,8,25,5,0,2,25,48,0,11,0,5,0,6,22,2,30,2,457,5,11,15,4,8,0,2,0,18,116,2,1,3,3,9,0,2,2,2,0,2,19,2,82,2,138,2,4,3,155,12,37,3,0,8,38,10,44,2,0,2,1,2,1,2,0,9,26,6,2,30,10,7,61,2,9,5,101,2,7,3,9,2,18,3,0,17,58,3,100,15,53,5,0,6,45,211,57,3,18,2,5,3,11,3,9,2,1,7,6,2,2,2,7,3,1,3,21,2,6,2,0,4,3,3,8,3,1,3,3,9,0,5,1,2,4,3,11,16,2,2,5,5,1,3,21,2,6,2,1,2,1,2,1,3,0,2,4,5,1,3,2,4,0,8,3,2,0,8,15,12,2,2,8,2,2,2,21,2,6,2,1,2,4,3,9,2,2,2,2,3,0,16,3,3,9,18,2,2,7,3,1,3,21,2,6,2,1,2,4,3,8,3,1,3,2,9,1,5,1,2,4,3,9,2,0,17,1,2,5,4,2,2,3,4,1,2,0,2,1,4,1,4,2,4,11,5,4,4,2,2,3,3,0,7,0,15,9,18,2,2,7,2,2,2,22,2,9,2,4,4,7,2,2,2,3,8,1,2,1,7,3,3,9,19,1,2,7,2,2,2,22,2,9,2,4,3,8,2,2,2,3,8,1,8,0,2,3,3,9,19,1,2,7,2,2,2,22,2,15,4,7,2,2,2,3,10,0,9,3,3,9,11,5,3,1,2,17,4,23,2,8,2,0,3,6,4,0,5,5,2,0,2,7,19,1,14,57,6,14,2,9,40,1,2,0,3,1,2,0,3,0,7,3,2,6,2,2,2,0,2,0,3,1,2,12,2,2,3,4,2,0,2,5,3,9,3,1,35,0,24,1,7,9,12,0,2,0,2,0,5,9,2,35,5,19,2,5,5,7,2,35,10,0,58,73,7,77,3,37,11,42,2,0,4,328,2,3,3,6,2,0,2,3,3,40,2,3,3,32,2,3,3,6,2,0,2,3,3,14,2,56,2,3,3,66,5,0,33,15,17,84,13,619,3,16,2,25,6,74,22,12,2,6,12,20,12,19,13,12,2,2,2,1,13,51,3,29,4,0,5,1,3,9,34,2,3,9,7,87,9,42,6,69,11,28,4,11,5,11,11,39,3,4,12,43,5,25,7,10,38,27,5,62,2,28,3,10,7,9,14,0,89,75,5,9,18,8,13,42,4,11,71,55,9,9,4,48,83,2,2,30,14,230,23,280,3,5,3,37,3,5,3,7,2,0,2,0,2,0,2,30,3,52,2,6,2,0,4,2,2,6,4,3,3,5,5,12,6,2,2,6,67,1,20,0,29,0,14,0,17,4,60,12,5,0,4,11,18,0,5,0,3,9,2,0,4,4,7,0,2,0,2,0,2,3,2,10,3,3,6,4,5,0,53,1,2684,46,2,46,2,132,7,6,15,37,11,53,10,0,17,22,10,6,2,6,2,6,2,6,2,6,2,6,2,6,2,6,2,31,48,0,470,1,36,5,2,4,6,1,5,85,3,1,3,2,2,89,2,3,6,40,4,93,18,23,57,15,513,6581,75,20939,53,1164,68,45,3,268,4,27,21,31,3,13,13,1,2,24,9,69,11,1,38,8,3,102,3,1,111,44,25,51,13,68,12,9,7,23,4,0,5,45,3,35,13,28,4,64,15,10,39,54,10,13,3,9,7,22,4,1,5,66,25,2,227,42,2,1,3,9,7,11171,13,22,5,48,8453,301,3,61,3,105,39,6,13,4,6,11,2,12,2,4,2,0,2,1,2,1,2,107,34,362,19,63,3,53,41,11,5,15,17,6,13,1,25,2,33,4,2,134,20,9,8,25,5,0,2,25,12,88,4,5,3,5,3,5,3,2],i=0,s=[];for(var o=0;o<r.length;o+=2)s.push(i+=r[o]),r[o+1]&&s.push(45,i+=r[o+1]);t.wordChars=String.fromCharCode.apply(null,s)}),ace.define("ace/mode/text",["require","exports","module","ace/config","ace/tokenizer","ace/mode/text_highlight_rules","ace/mode/behaviour/cstyle","ace/unicode","ace/lib/lang","ace/token_iterator","ace/range"],function(e,t,n){"use strict";var r=e("../config"),i=e("../tokenizer").Tokenizer,s=e("./text_highlight_rules").TextHighlightRules,o=e("./behaviour/cstyle").CstyleBehaviour,u=e("../unicode"),a=e("../lib/lang"),f=e("../token_iterator").TokenIterator,l=e("../range").Range,c=function(){this.HighlightRules=s};(function(){this.$defaultBehaviour=new o,this.tokenRe=new RegExp("^["+u.wordChars+"\\$_]+","g"),this.nonTokenRe=new RegExp("^(?:[^"+u.wordChars+"\\$_]|\\s])+","g"),this.getTokenizer=function(){return this.$tokenizer||(this.$highlightRules=this.$highlightRules||new this.HighlightRules(this.$highlightRuleConfig),this.$tokenizer=new i(this.$highlightRules.getRules())),this.$tokenizer},this.lineCommentStart="",this.blockComment="",this.toggleCommentLines=function(e,t,n,r){function w(e){for(var t=n;t<=r;t++)e(i.getLine(t),t)}var i=t.doc,s=!0,o=!0,u=Infinity,f=t.getTabSize(),l=!1;if(!this.lineCommentStart){if(!this.blockComment)return!1;var c=this.blockComment.start,h=this.blockComment.end,p=new RegExp("^(\\s*)(?:"+a.escapeRegExp(c)+")"),d=new RegExp("(?:"+a.escapeRegExp(h)+")\\s*$"),v=function(e,t){if(g(e,t))return;if(!s||/\S/.test(e))i.insertInLine({row:t,column:e.length},h),i.insertInLine({row:t,column:u},c)},m=function(e,t){var n;(n=e.match(d))&&i.removeInLine(t,e.length-n[0].length,e.length),(n=e.match(p))&&i.removeInLine(t,n[1].length,n[0].length)},g=function(e,n){if(p.test(e))return!0;var r=t.getTokens(n);for(var i=0;i<r.length;i++)if(r[i].type==="comment")return!0}}else{if(Array.isArray(this.lineCommentStart))var p=this.lineCommentStart.map(a.escapeRegExp).join("|"),c=this.lineCommentStart[0];else var p=a.escapeRegExp(this.lineCommentStart),c=this.lineCommentStart;p=new RegExp("^(\\s*)(?:"+p+") ?"),l=t.getUseSoftTabs();var m=function(e,t){var n=e.match(p);if(!n)return;var r=n[1].length,s=n[0].length;!b(e,r,s)&&n[0][s-1]==" "&&s--,i.removeInLine(t,r,s)},y=c+" ",v=function(e,t){if(!s||/\S/.test(e))b(e,u,u)?i.insertInLine({row:t,column:u},y):i.insertInLine({row:t,column:u},c)},g=function(e,t){return p.test(e)},b=function(e,t,n){var r=0;while(t--&&e.charAt(t)==" ")r++;if(r%f!=0)return!1;var r=0;while(e.charAt(n++)==" ")r++;return f>2?r%f!=f-1:r%f==0}}var E=Infinity;w(function(e,t){var n=e.search(/\S/);n!==-1?(n<u&&(u=n),o&&!g(e,t)&&(o=!1)):E>e.length&&(E=e.length)}),u==Infinity&&(u=E,s=!1,o=!1),l&&u%f!=0&&(u=Math.floor(u/f)*f),w(o?m:v)},this.toggleBlockComment=function(e,t,n,r){var i=this.blockComment;if(!i)return;!i.start&&i[0]&&(i=i[0]);var s=new f(t,r.row,r.column),o=s.getCurrentToken(),u=t.selection,a=t.selection.toOrientedRange(),c,h;if(o&&/comment/.test(o.type)){var p,d;while(o&&/comment/.test(o.type)){var v=o.value.indexOf(i.start);if(v!=-1){var m=s.getCurrentTokenRow(),g=s.getCurrentTokenColumn()+v;p=new l(m,g,m,g+i.start.length);break}o=s.stepBackward()}var s=new f(t,r.row,r.column),o=s.getCurrentToken();while(o&&/comment/.test(o.type)){var v=o.value.indexOf(i.end);if(v!=-1){var m=s.getCurrentTokenRow(),g=s.getCurrentTokenColumn()+v;d=new l(m,g,m,g+i.end.length);break}o=s.stepForward()}d&&t.remove(d),p&&(t.remove(p),c=p.start.row,h=-i.start.length)}else h=i.start.length,c=n.start.row,t.insert(n.end,i.end),t.insert(n.start,i.start);a.start.row==c&&(a.start.column+=h),a.end.row==c&&(a.end.column+=h),t.selection.fromOrientedRange(a)},this.getNextLineIndent=function(e,t,n){return this.$getIndent(t)},this.checkOutdent=function(e,t,n){return!1},this.autoOutdent=function(e,t,n){},this.$getIndent=function(e){return e.match(/^\s*/)[0]},this.createWorker=function(e){return null},this.createModeDelegates=function(e){this.$embeds=[],this.$modes={};for(var t in e)if(e[t]){var n=e[t],i=n.prototype.$id,s=r.$modes[i];s||(r.$modes[i]=s=new n),r.$modes[t]||(r.$modes[t]=s),this.$embeds.push(t),this.$modes[t]=s}var o=["toggleBlockComment","toggleCommentLines","getNextLineIndent","checkOutdent","autoOutdent","transformAction","getCompletions"];for(var t=0;t<o.length;t++)(function(e){var n=o[t],r=e[n];e[o[t]]=function(){return this.$delegator(n,arguments,r)}})(this)},this.$delegator=function(e,t,n){var r=t[0]||"start";if(typeof r!="string"){if(Array.isArray(r[2])){var i=r[2][r[2].length-1],s=this.$modes[i];if(s)return s[e].apply(s,[r[1]].concat([].slice.call(t,1)))}r=r[0]||"start"}for(var o=0;o<this.$embeds.length;o++){if(!this.$modes[this.$embeds[o]])continue;var u=r.split(this.$embeds[o]);if(!u[0]&&u[1]){t[0]=u[1];var s=this.$modes[this.$embeds[o]];return s[e].apply(s,t)}}var a=n.apply(this,t);return n?a:undefined},this.transformAction=function(e,t,n,r,i){if(this.$behaviour){var s=this.$behaviour.getBehaviours();for(var o in s)if(s[o][t]){var u=s[o][t].apply(this,arguments);if(u)return u}}},this.getKeywords=function(e){if(!this.completionKeywords){var t=this.$tokenizer.rules,n=[];for(var r in t){var i=t[r];for(var s=0,o=i.length;s<o;s++)if(typeof i[s].token=="string")/keyword|support|storage/.test(i[s].token)&&n.push(i[s].regex);else if(typeof i[s].token=="object")for(var u=0,a=i[s].token.length;u<a;u++)if(/keyword|support|storage/.test(i[s].token[u])){var r=i[s].regex.match(/\(.+?\)/g)[u];n.push(r.substr(1,r.length-2))}}this.completionKeywords=n}return e?n.concat(this.$keywordList||[]):this.$keywordList},this.$createKeywordList=function(){return this.$highlightRules||this.getTokenizer(),this.$keywordList=this.$highlightRules.$keywordList||[]},this.getCompletions=function(e,t,n,r){var i=this.$keywordList||this.$createKeywordList();return i.map(function(e){return{name:e,value:e,score:0,meta:"keyword"}})},this.$id="ace/mode/text"}).call(c.prototype),t.Mode=c}),ace.define("ace/apply_delta",["require","exports","module"],function(e,t,n){"use strict";function r(e,t){throw console.log("Invalid Delta:",e),"Invalid Delta: "+t}function i(e,t){return t.row>=0&&t.row<e.length&&t.column>=0&&t.column<=e[t.row].length}function s(e,t){t.action!="insert"&&t.action!="remove"&&r(t,"delta.action must be 'insert' or 'remove'"),t.lines instanceof Array||r(t,"delta.lines must be an Array"),(!t.start||!t.end)&&r(t,"delta.start/end must be an present");var n=t.start;i(e,t.start)||r(t,"delta.start must be contained in document");var s=t.end;t.action=="remove"&&!i(e,s)&&r(t,"delta.end must contained in document for 'remove' actions");var o=s.row-n.row,u=s.column-(o==0?n.column:0);(o!=t.lines.length-1||t.lines[o].length!=u)&&r(t,"delta.range must match delta lines")}t.applyDelta=function(e,t,n){var r=t.start.row,i=t.start.column,s=e[r]||"";switch(t.action){case"insert":var o=t.lines;if(o.length===1)e[r]=s.substring(0,i)+t.lines[0]+s.substring(i);else{var u=[r,1].concat(t.lines);e.splice.apply(e,u),e[r]=s.substring(0,i)+e[r],e[r+t.lines.length-1]+=s.substring(i)}break;case"remove":var a=t.end.column,f=t.end.row;r===f?e[r]=s.substring(0,i)+s.substring(a):e.splice(r,f-r+1,s.substring(0,i)+e[f].substring(a))}}}),ace.define("ace/anchor",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./lib/event_emitter").EventEmitter,s=t.Anchor=function(e,t,n){this.$onChange=this.onChange.bind(this),this.attach(e),typeof n=="undefined"?this.setPosition(t.row,t.column):this.setPosition(t,n)};(function(){function e(e,t,n){var r=n?e.column<=t.column:e.column<t.column;return e.row<t.row||e.row==t.row&&r}function t(t,n,r){var i=t.action=="insert",s=(i?1:-1)*(t.end.row-t.start.row),o=(i?1:-1)*(t.end.column-t.start.column),u=t.start,a=i?u:t.end;return e(n,u,r)?{row:n.row,column:n.column}:e(a,n,!r)?{row:n.row+s,column:n.column+(n.row==a.row?o:0)}:{row:u.row,column:u.column}}r.implement(this,i),this.getPosition=function(){return this.$clipPositionToDocument(this.row,this.column)},this.getDocument=function(){return this.document},this.$insertRight=!1,this.onChange=function(e){if(e.start.row==e.end.row&&e.start.row!=this.row)return;if(e.start.row>this.row)return;var n=t(e,{row:this.row,column:this.column},this.$insertRight);this.setPosition(n.row,n.column,!0)},this.setPosition=function(e,t,n){var r;n?r={row:e,column:t}:r=this.$clipPositionToDocument(e,t);if(this.row==r.row&&this.column==r.column)return;var i={row:this.row,column:this.column};this.row=r.row,this.column=r.column,this._signal("change",{old:i,value:r})},this.detach=function(){this.document.off("change",this.$onChange)},this.attach=function(e){this.document=e||this.document,this.document.on("change",this.$onChange)},this.$clipPositionToDocument=function(e,t){var n={};return e>=this.document.getLength()?(n.row=Math.max(0,this.document.getLength()-1),n.column=this.document.getLine(n.row).length):e<0?(n.row=0,n.column=0):(n.row=e,n.column=Math.min(this.document.getLine(n.row).length,Math.max(0,t))),t<0&&(n.column=0),n}}).call(s.prototype)}),ace.define("ace/document",["require","exports","module","ace/lib/oop","ace/apply_delta","ace/lib/event_emitter","ace/range","ace/anchor"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./apply_delta").applyDelta,s=e("./lib/event_emitter").EventEmitter,o=e("./range").Range,u=e("./anchor").Anchor,a=function(e){this.$lines=[""],e.length===0?this.$lines=[""]:Array.isArray(e)?this.insertMergedLines({row:0,column:0},e):this.insert({row:0,column:0},e)};(function(){r.implement(this,s),this.setValue=function(e){var t=this.getLength()-1;this.remove(new o(0,0,t,this.getLine(t).length)),this.insert({row:0,column:0},e)},this.getValue=function(){return this.getAllLines().join(this.getNewLineCharacter())},this.createAnchor=function(e,t){return new u(this,e,t)},"aaa".split(/a/).length===0?this.$split=function(e){return e.replace(/\r\n|\r/g,"\n").split("\n")}:this.$split=function(e){return e.split(/\r\n|\r|\n/)},this.$detectNewLine=function(e){var t=e.match(/^.*?(\r\n|\r|\n)/m);this.$autoNewLine=t?t[1]:"\n",this._signal("changeNewLineMode")},this.getNewLineCharacter=function(){switch(this.$newLineMode){case"windows":return"\r\n";case"unix":return"\n";default:return this.$autoNewLine||"\n"}},this.$autoNewLine="",this.$newLineMode="auto",this.setNewLineMode=function(e){if(this.$newLineMode===e)return;this.$newLineMode=e,this._signal("changeNewLineMode")},this.getNewLineMode=function(){return this.$newLineMode},this.isNewLine=function(e){return e=="\r\n"||e=="\r"||e=="\n"},this.getLine=function(e){return this.$lines[e]||""},this.getLines=function(e,t){return this.$lines.slice(e,t+1)},this.getAllLines=function(){return this.getLines(0,this.getLength())},this.getLength=function(){return this.$lines.length},this.getTextRange=function(e){return this.getLinesForRange(e).join(this.getNewLineCharacter())},this.getLinesForRange=function(e){var t;if(e.start.row===e.end.row)t=[this.getLine(e.start.row).substring(e.start.column,e.end.column)];else{t=this.getLines(e.start.row,e.end.row),t[0]=(t[0]||"").substring(e.start.column);var n=t.length-1;e.end.row-e.start.row==n&&(t[n]=t[n].substring(0,e.end.column))}return t},this.insertLines=function(e,t){return console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead."),this.insertFullLines(e,t)},this.removeLines=function(e,t){return console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead."),this.removeFullLines(e,t)},this.insertNewLine=function(e){return console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead."),this.insertMergedLines(e,["",""])},this.insert=function(e,t){return this.getLength()<=1&&this.$detectNewLine(t),this.insertMergedLines(e,this.$split(t))},this.insertInLine=function(e,t){var n=this.clippedPos(e.row,e.column),r=this.pos(e.row,e.column+t.length);return this.applyDelta({start:n,end:r,action:"insert",lines:[t]},!0),this.clonePos(r)},this.clippedPos=function(e,t){var n=this.getLength();e===undefined?e=n:e<0?e=0:e>=n&&(e=n-1,t=undefined);var r=this.getLine(e);return t==undefined&&(t=r.length),t=Math.min(Math.max(t,0),r.length),{row:e,column:t}},this.clonePos=function(e){return{row:e.row,column:e.column}},this.pos=function(e,t){return{row:e,column:t}},this.$clipPosition=function(e){var t=this.getLength();return e.row>=t?(e.row=Math.max(0,t-1),e.column=this.getLine(t-1).length):(e.row=Math.max(0,e.row),e.column=Math.min(Math.max(e.column,0),this.getLine(e.row).length)),e},this.insertFullLines=function(e,t){e=Math.min(Math.max(e,0),this.getLength());var n=0;e<this.getLength()?(t=t.concat([""]),n=0):(t=[""].concat(t),e--,n=this.$lines[e].length),this.insertMergedLines({row:e,column:n},t)},this.insertMergedLines=function(e,t){var n=this.clippedPos(e.row,e.column),r={row:n.row+t.length-1,column:(t.length==1?n.column:0)+t[t.length-1].length};return this.applyDelta({start:n,end:r,action:"insert",lines:t}),this.clonePos(r)},this.remove=function(e){var t=this.clippedPos(e.start.row,e.start.column),n=this.clippedPos(e.end.row,e.end.column);return this.applyDelta({start:t,end:n,action:"remove",lines:this.getLinesForRange({start:t,end:n})}),this.clonePos(t)},this.removeInLine=function(e,t,n){var r=this.clippedPos(e,t),i=this.clippedPos(e,n);return this.applyDelta({start:r,end:i,action:"remove",lines:this.getLinesForRange({start:r,end:i})},!0),this.clonePos(r)},this.removeFullLines=function(e,t){e=Math.min(Math.max(0,e),this.getLength()-1),t=Math.min(Math.max(0,t),this.getLength()-1);var n=t==this.getLength()-1&&e>0,r=t<this.getLength()-1,i=n?e-1:e,s=n?this.getLine(i).length:0,u=r?t+1:t,a=r?0:this.getLine(u).length,f=new o(i,s,u,a),l=this.$lines.slice(e,t+1);return this.applyDelta({start:f.start,end:f.end,action:"remove",lines:this.getLinesForRange(f)}),l},this.removeNewLine=function(e){e<this.getLength()-1&&e>=0&&this.applyDelta({start:this.pos(e,this.getLine(e).length),end:this.pos(e+1,0),action:"remove",lines:["",""]})},this.replace=function(e,t){e instanceof o||(e=o.fromPoints(e.start,e.end));if(t.length===0&&e.isEmpty())return e.start;if(t==this.getTextRange(e))return e.end;this.remove(e);var n;return t?n=this.insert(e.start,t):n=e.start,n},this.applyDeltas=function(e){for(var t=0;t<e.length;t++)this.applyDelta(e[t])},this.revertDeltas=function(e){for(var t=e.length-1;t>=0;t--)this.revertDelta(e[t])},this.applyDelta=function(e,t){var n=e.action=="insert";if(n?e.lines.length<=1&&!e.lines[0]:!o.comparePoints(e.start,e.end))return;n&&e.lines.length>2e4?this.$splitAndapplyLargeDelta(e,2e4):(i(this.$lines,e,t),this._signal("change",e))},this.$safeApplyDelta=function(e){var t=this.$lines.length;(e.action=="remove"&&e.start.row<t&&e.end.row<t||e.action=="insert"&&e.start.row<=t)&&this.applyDelta(e)},this.$splitAndapplyLargeDelta=function(e,t){var n=e.lines,r=n.length-t+1,i=e.start.row,s=e.start.column;for(var o=0,u=0;o<r;o=u){u+=t-1;var a=n.slice(o,u);a.push(""),this.applyDelta({start:this.pos(i+o,s),end:this.pos(i+u,s=0),action:e.action,lines:a},!0)}e.lines=n.slice(o),e.start.row=i+o,e.start.column=s,this.applyDelta(e,!0)},this.revertDelta=function(e){this.$safeApplyDelta({start:this.clonePos(e.start),end:this.clonePos(e.end),action:e.action=="insert"?"remove":"insert",lines:e.lines.slice()})},this.indexToPosition=function(e,t){var n=this.$lines||this.getAllLines(),r=this.getNewLineCharacter().length;for(var i=t||0,s=n.length;i<s;i++){e-=n[i].length+r;if(e<0)return{row:i,column:e+n[i].length+r}}return{row:s-1,column:e+n[s-1].length+r}},this.positionToIndex=function(e,t){var n=this.$lines||this.getAllLines(),r=this.getNewLineCharacter().length,i=0,s=Math.min(e.row,n.length);for(var o=t||0;o<s;++o)i+=n[o].length+r;return i+e.column}}).call(a.prototype),t.Document=a}),ace.define("ace/background_tokenizer",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./lib/event_emitter").EventEmitter,s=function(e,t){this.running=!1,this.lines=[],this.states=[],this.currentLine=0,this.tokenizer=e;var n=this;this.$worker=function(){if(!n.running)return;var e=new Date,t=n.currentLine,r=-1,i=n.doc,s=t;while(n.lines[t])t++;var o=i.getLength(),u=0;n.running=!1;while(t<o){n.$tokenizeRow(t),r=t;do t++;while(n.lines[t]);u++;if(u%5===0&&new Date-e>20){n.running=setTimeout(n.$worker,20);break}}n.currentLine=t,r==-1&&(r=t),s<=r&&n.fireUpdateEvent(s,r)}};(function(){r.implement(this,i),this.setTokenizer=function(e){this.tokenizer=e,this.lines=[],this.states=[],this.start(0)},this.setDocument=function(e){this.doc=e,this.lines=[],this.states=[],this.stop()},this.fireUpdateEvent=function(e,t){var n={first:e,last:t};this._signal("update",{data:n})},this.start=function(e){this.currentLine=Math.min(e||0,this.currentLine,this.doc.getLength()),this.lines.splice(this.currentLine,this.lines.length),this.states.splice(this.currentLine,this.states.length),this.stop(),this.running=setTimeout(this.$worker,700)},this.scheduleStart=function(){this.running||(this.running=setTimeout(this.$worker,700))},this.$updateOnChange=function(e){var t=e.start.row,n=e.end.row-t;if(n===0)this.lines[t]=null;else if(e.action=="remove")this.lines.splice(t,n+1,null),this.states.splice(t,n+1,null);else{var r=Array(n+1);r.unshift(t,1),this.lines.splice.apply(this.lines,r),this.states.splice.apply(this.states,r)}this.currentLine=Math.min(t,this.currentLine,this.doc.getLength()),this.stop()},this.stop=function(){this.running&&clearTimeout(this.running),this.running=!1},this.getTokens=function(e){return this.lines[e]||this.$tokenizeRow(e)},this.getState=function(e){return this.currentLine==e&&this.$tokenizeRow(e),this.states[e]||"start"},this.$tokenizeRow=function(e){var t=this.doc.getLine(e),n=this.states[e-1],r=this.tokenizer.getLineTokens(t,n,e);return this.states[e]+""!=r.state+""?(this.states[e]=r.state,this.lines[e+1]=null,this.currentLine>e+1&&(this.currentLine=e+1)):this.currentLine==e&&(this.currentLine=e+1),this.lines[e]=r.tokens}}).call(s.prototype),t.BackgroundTokenizer=s}),ace.define("ace/search_highlight",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"],function(e,t,n){"use strict";var r=e("./lib/lang"),i=e("./lib/oop"),s=e("./range").Range,o=function(e,t,n){this.setRegexp(e),this.clazz=t,this.type=n||"text"};(function(){this.MAX_RANGES=500,this.setRegexp=function(e){if(this.regExp+""==e+"")return;this.regExp=e,this.cache=[]},this.update=function(e,t,n,i){if(!this.regExp)return;var o=i.firstRow,u=i.lastRow;for(var a=o;a<=u;a++){var f=this.cache[a];f==null&&(f=r.getMatchOffsets(n.getLine(a),this.regExp),f.length>this.MAX_RANGES&&(f=f.slice(0,this.MAX_RANGES)),f=f.map(function(e){return new s(a,e.offset,a,e.offset+e.length)}),this.cache[a]=f.length?f:"");for(var l=f.length;l--;)t.drawSingleLineMarker(e,f[l].toScreenRange(n),this.clazz,i)}}}).call(o.prototype),t.SearchHighlight=o}),ace.define("ace/edit_session/fold_line",["require","exports","module","ace/range"],function(e,t,n){"use strict";function i(e,t){this.foldData=e,Array.isArray(t)?this.folds=t:t=this.folds=[t];var n=t[t.length-1];this.range=new r(t[0].start.row,t[0].start.column,n.end.row,n.end.column),this.start=this.range.start,this.end=this.range.end,this.folds.forEach(function(e){e.setFoldLine(this)},this)}var r=e("../range").Range;(function(){this.shiftRow=function(e){this.start.row+=e,this.end.row+=e,this.folds.forEach(function(t){t.start.row+=e,t.end.row+=e})},this.addFold=function(e){if(e.sameRow){if(e.start.row<this.startRow||e.endRow>this.endRow)throw new Error("Can't add a fold to this FoldLine as it has no connection");this.folds.push(e),this.folds.sort(function(e,t){return-e.range.compareEnd(t.start.row,t.start.column)}),this.range.compareEnd(e.start.row,e.start.column)>0?(this.end.row=e.end.row,this.end.column=e.end.column):this.range.compareStart(e.end.row,e.end.column)<0&&(this.start.row=e.start.row,this.start.column=e.start.column)}else if(e.start.row==this.end.row)this.folds.push(e),this.end.row=e.end.row,this.end.column=e.end.column;else{if(e.end.row!=this.start.row)throw new Error("Trying to add fold to FoldRow that doesn't have a matching row");this.folds.unshift(e),this.start.row=e.start.row,this.start.column=e.start.column}e.foldLine=this},this.containsRow=function(e){return e>=this.start.row&&e<=this.end.row},this.walk=function(e,t,n){var r=0,i=this.folds,s,o,u,a=!0;t==null&&(t=this.end.row,n=this.end.column);for(var f=0;f<i.length;f++){s=i[f],o=s.range.compareStart(t,n);if(o==-1){e(null,t,n,r,a);return}u=e(null,s.start.row,s.start.column,r,a),u=!u&&e(s.placeholder,s.start.row,s.start.column,r);if(u||o===0)return;a=!s.sameRow,r=s.end.column}e(null,t,n,r,a)},this.getNextFoldTo=function(e,t){var n,r;for(var i=0;i<this.folds.length;i++){n=this.folds[i],r=n.range.compareEnd(e,t);if(r==-1)return{fold:n,kind:"after"};if(r===0)return{fold:n,kind:"inside"}}return null},this.addRemoveChars=function(e,t,n){var r=this.getNextFoldTo(e,t),i,s;if(r){i=r.fold;if(r.kind=="inside"&&i.start.column!=t&&i.start.row!=e)window.console&&window.console.log(e,t,i);else if(i.start.row==e){s=this.folds;var o=s.indexOf(i);o===0&&(this.start.column+=n);for(o;o<s.length;o++){i=s[o],i.start.column+=n;if(!i.sameRow)return;i.end.column+=n}this.end.column+=n}}},this.split=function(e,t){var n=this.getNextFoldTo(e,t);if(!n||n.kind=="inside")return null;var r=n.fold,s=this.folds,o=this.foldData,u=s.indexOf(r),a=s[u-1];this.end.row=a.end.row,this.end.column=a.end.column,s=s.splice(u,s.length-u);var f=new i(o,s);return o.splice(o.indexOf(this)+1,0,f),f},this.merge=function(e){var t=e.folds;for(var n=0;n<t.length;n++)this.addFold(t[n]);var r=this.foldData;r.splice(r.indexOf(e),1)},this.toString=function(){var e=[this.range.toString()+": ["];return this.folds.forEach(function(t){e.push(" "+t.toString())}),e.push("]"),e.join("\n")},this.idxToPosition=function(e){var t=0;for(var n=0;n<this.folds.length;n++){var r=this.folds[n];e-=r.start.column-t;if(e<0)return{row:r.start.row,column:r.start.column+e};e-=r.placeholder.length;if(e<0)return r.start;t=r.end.column}return{row:this.end.row,column:this.end.column+e}}}).call(i.prototype),t.FoldLine=i}),ace.define("ace/range_list",["require","exports","module","ace/range"],function(e,t,n){"use strict";var r=e("./range").Range,i=r.comparePoints,s=function(){this.ranges=[],this.$bias=1};(function(){this.comparePoints=i,this.pointIndex=function(e,t,n){var r=this.ranges;for(var s=n||0;s<r.length;s++){var o=r[s],u=i(e,o.end);if(u>0)continue;var a=i(e,o.start);return u===0?t&&a!==0?-s-2:s:a>0||a===0&&!t?s:-s-1}return-s-1},this.add=function(e){var t=!e.isEmpty(),n=this.pointIndex(e.start,t);n<0&&(n=-n-1);var r=this.pointIndex(e.end,t,n);return r<0?r=-r-1:r++,this.ranges.splice(n,r-n,e)},this.addList=function(e){var t=[];for(var n=e.length;n--;)t.push.apply(t,this.add(e[n]));return t},this.substractPoint=function(e){var t=this.pointIndex(e);if(t>=0)return this.ranges.splice(t,1)},this.merge=function(){var e=[],t=this.ranges;t=t.sort(function(e,t){return i(e.start,t.start)});var n=t[0],r;for(var s=1;s<t.length;s++){r=n,n=t[s];var o=i(r.end,n.start);if(o<0)continue;if(o==0&&!r.isEmpty()&&!n.isEmpty())continue;i(r.end,n.end)<0&&(r.end.row=n.end.row,r.end.column=n.end.column),t.splice(s,1),e.push(n),n=r,s--}return this.ranges=t,e},this.contains=function(e,t){return this.pointIndex({row:e,column:t})>=0},this.containsPoint=function(e){return this.pointIndex(e)>=0},this.rangeAtPoint=function(e){var t=this.pointIndex(e);if(t>=0)return this.ranges[t]},this.clipRows=function(e,t){var n=this.ranges;if(n[0].start.row>t||n[n.length-1].start.row<e)return[];var r=this.pointIndex({row:e,column:0});r<0&&(r=-r-1);var i=this.pointIndex({row:t,column:0},r);i<0&&(i=-i-1);var s=[];for(var o=r;o<i;o++)s.push(n[o]);return s},this.removeAll=function(){return this.ranges.splice(0,this.ranges.length)},this.attach=function(e){this.session&&this.detach(),this.session=e,this.onChange=this.$onChange.bind(this),this.session.on("change",this.onChange)},this.detach=function(){if(!this.session)return;this.session.removeListener("change",this.onChange),this.session=null},this.$onChange=function(e){var t=e.start,n=e.end,r=t.row,i=n.row,s=this.ranges;for(var o=0,u=s.length;o<u;o++){var a=s[o];if(a.end.row>=r)break}if(e.action=="insert"){var f=i-r,l=-t.column+n.column;for(;o<u;o++){var a=s[o];if(a.start.row>r)break;a.start.row==r&&a.start.column>=t.column&&(a.start.column==t.column&&this.$bias<=0||(a.start.column+=l,a.start.row+=f));if(a.end.row==r&&a.end.column>=t.column){if(a.end.column==t.column&&this.$bias<0)continue;a.end.column==t.column&&l>0&&o<u-1&&a.end.column>a.start.column&&a.end.column==s[o+1].start.column&&(a.end.column-=l),a.end.column+=l,a.end.row+=f}}}else{var f=r-i,l=t.column-n.column;for(;o<u;o++){var a=s[o];if(a.start.row>i)break;if(a.end.row<i&&(r<a.end.row||r==a.end.row&&t.column<a.end.column))a.end.row=r,a.end.column=t.column;else if(a.end.row==i)if(a.end.column<=n.column){if(f||a.end.column>t.column)a.end.column=t.column,a.end.row=t.row}else a.end.column+=l,a.end.row+=f;else a.end.row>i&&(a.end.row+=f);if(a.start.row<i&&(r<a.start.row||r==a.start.row&&t.column<a.start.column))a.start.row=r,a.start.column=t.column;else if(a.start.row==i)if(a.start.column<=n.column){if(f||a.start.column>t.column)a.start.column=t.column,a.start.row=t.row}else a.start.column+=l,a.start.row+=f;else a.start.row>i&&(a.start.row+=f)}}if(f!=0&&o<u)for(;o<u;o++){var a=s[o];a.start.row+=f,a.end.row+=f}}}).call(s.prototype),t.RangeList=s}),ace.define("ace/edit_session/fold",["require","exports","module","ace/range_list","ace/lib/oop"],function(e,t,n){"use strict";function o(e,t){e.row-=t.row,e.row==0&&(e.column-=t.column)}function u(e,t){o(e.start,t),o(e.end,t)}function a(e,t){e.row==0&&(e.column+=t.column),e.row+=t.row}function f(e,t){a(e.start,t),a(e.end,t)}var r=e("../range_list").RangeList,i=e("../lib/oop"),s=t.Fold=function(e,t){this.foldLine=null,this.placeholder=t,this.range=e,this.start=e.start,this.end=e.end,this.sameRow=e.start.row==e.end.row,this.subFolds=this.ranges=[]};i.inherits(s,r),function(){this.toString=function(){return'"'+this.placeholder+'" '+this.range.toString()},this.setFoldLine=function(e){this.foldLine=e,this.subFolds.forEach(function(t){t.setFoldLine(e)})},this.clone=function(){var e=this.range.clone(),t=new s(e,this.placeholder);return this.subFolds.forEach(function(e){t.subFolds.push(e.clone())}),t.collapseChildren=this.collapseChildren,t},this.addSubFold=function(e){if(this.range.isEqual(e))return;u(e,this.start);var t=e.start.row,n=e.start.column;for(var r=0,i=-1;r<this.subFolds.length;r++){i=this.subFolds[r].range.compare(t,n);if(i!=1)break}var s=this.subFolds[r],o=0;if(i==0){if(s.range.containsRange(e))return s.addSubFold(e);o=1}var t=e.range.end.row,n=e.range.end.column;for(var a=r,i=-1;a<this.subFolds.length;a++){i=this.subFolds[a].range.compare(t,n);if(i!=1)break}i==0&&a++;var f=this.subFolds.splice(r,a-r,e),l=i==0?f.length-1:f.length;for(var c=o;c<l;c++)e.addSubFold(f[c]);return e.setFoldLine(this.foldLine),e},this.restoreRange=function(e){return f(e,this.start)}}.call(s.prototype)}),ace.define("ace/edit_session/folding",["require","exports","module","ace/range","ace/edit_session/fold_line","ace/edit_session/fold","ace/token_iterator"],function(e,t,n){"use strict";function u(){this.getFoldAt=function(e,t,n){var r=this.getFoldLine(e);if(!r)return null;var i=r.folds;for(var s=0;s<i.length;s++){var o=i[s].range;if(o.contains(e,t)){if(n==1&&o.isEnd(e,t)&&!o.isEmpty())continue;if(n==-1&&o.isStart(e,t)&&!o.isEmpty())continue;return i[s]}}},this.getFoldsInRange=function(e){var t=e.start,n=e.end,r=this.$foldData,i=[];t.column+=1,n.column-=1;for(var s=0;s<r.length;s++){var o=r[s].range.compareRange(e);if(o==2)continue;if(o==-2)break;var u=r[s].folds;for(var a=0;a<u.length;a++){var f=u[a];o=f.range.compareRange(e);if(o==-2)break;if(o==2)continue;if(o==42)break;i.push(f)}}return t.column-=1,n.column+=1,i},this.getFoldsInRangeList=function(e){if(Array.isArray(e)){var t=[];e.forEach(function(e){t=t.concat(this.getFoldsInRange(e))},this)}else var t=this.getFoldsInRange(e);return t},this.getAllFolds=function(){var e=[],t=this.$foldData;for(var n=0;n<t.length;n++)for(var r=0;r<t[n].folds.length;r++)e.push(t[n].folds[r]);return e},this.getFoldStringAt=function(e,t,n,r){r=r||this.getFoldLine(e);if(!r)return null;var i={end:{column:0}},s,o;for(var u=0;u<r.folds.length;u++){o=r.folds[u];var a=o.range.compareEnd(e,t);if(a==-1){s=this.getLine(o.start.row).substring(i.end.column,o.start.column);break}if(a===0)return null;i=o}return s||(s=this.getLine(o.start.row).substring(i.end.column)),n==-1?s.substring(0,t-i.end.column):n==1?s.substring(t-i.end.column):s},this.getFoldLine=function(e,t){var n=this.$foldData,r=0;t&&(r=n.indexOf(t)),r==-1&&(r=0);for(r;r<n.length;r++){var i=n[r];if(i.start.row<=e&&i.end.row>=e)return i;if(i.end.row>e)return null}return null},this.getNextFoldLine=function(e,t){var n=this.$foldData,r=0;t&&(r=n.indexOf(t)),r==-1&&(r=0);for(r;r<n.length;r++){var i=n[r];if(i.end.row>=e)return i}return null},this.getFoldedRowCount=function(e,t){var n=this.$foldData,r=t-e+1;for(var i=0;i<n.length;i++){var s=n[i],o=s.end.row,u=s.start.row;if(o>=t){u<t&&(u>=e?r-=t-u:r=0);break}o>=e&&(u>=e?r-=o-u:r-=o-e+1)}return r},this.$addFoldLine=function(e){return this.$foldData.push(e),this.$foldData.sort(function(e,t){return e.start.row-t.start.row}),e},this.addFold=function(e,t){var n=this.$foldData,r=!1,o;e instanceof s?o=e:(o=new s(t,e),o.collapseChildren=t.collapseChildren),this.$clipRangeToDocument(o.range);var u=o.start.row,a=o.start.column,f=o.end.row,l=o.end.column,c=this.getFoldAt(u,a,1),h=this.getFoldAt(f,l,-1);if(c&&h==c)return c.addSubFold(o);c&&!c.range.isStart(u,a)&&this.removeFold(c),h&&!h.range.isEnd(f,l)&&this.removeFold(h);var p=this.getFoldsInRange(o.range);p.length>0&&(this.removeFolds(p),o.collapseChildren||p.forEach(function(e){o.addSubFold(e)}));for(var d=0;d<n.length;d++){var v=n[d];if(f==v.start.row){v.addFold(o),r=!0;break}if(u==v.end.row){v.addFold(o),r=!0;if(!o.sameRow){var m=n[d+1];if(m&&m.start.row==f){v.merge(m);break}}break}if(f<=v.start.row)break}return r||(v=this.$addFoldLine(new i(this.$foldData,o))),this.$useWrapMode?this.$updateWrapData(v.start.row,v.start.row):this.$updateRowLengthCache(v.start.row,v.start.row),this.$modified=!0,this._signal("changeFold",{data:o,action:"add"}),o},this.addFolds=function(e){e.forEach(function(e){this.addFold(e)},this)},this.removeFold=function(e){var t=e.foldLine,n=t.start.row,r=t.end.row,i=this.$foldData,s=t.folds;if(s.length==1)i.splice(i.indexOf(t),1);else if(t.range.isEnd(e.end.row,e.end.column))s.pop(),t.end.row=s[s.length-1].end.row,t.end.column=s[s.length-1].end.column;else if(t.range.isStart(e.start.row,e.start.column))s.shift(),t.start.row=s[0].start.row,t.start.column=s[0].start.column;else if(e.sameRow)s.splice(s.indexOf(e),1);else{var o=t.split(e.start.row,e.start.column);s=o.folds,s.shift(),o.start.row=s[0].start.row,o.start.column=s[0].start.column}this.$updating||(this.$useWrapMode?this.$updateWrapData(n,r):this.$updateRowLengthCache(n,r)),this.$modified=!0,this._signal("changeFold",{data:e,action:"remove"})},this.removeFolds=function(e){var t=[];for(var n=0;n<e.length;n++)t.push(e[n]);t.forEach(function(e){this.removeFold(e)},this),this.$modified=!0},this.expandFold=function(e){this.removeFold(e),e.subFolds.forEach(function(t){e.restoreRange(t),this.addFold(t)},this),e.collapseChildren>0&&this.foldAll(e.start.row+1,e.end.row,e.collapseChildren-1),e.subFolds=[]},this.expandFolds=function(e){e.forEach(function(e){this.expandFold(e)},this)},this.unfold=function(e,t){var n,i;e==null?(n=new r(0,0,this.getLength(),0),t==null&&(t=!0)):typeof e=="number"?n=new r(e,0,e,this.getLine(e).length):"row"in e?n=r.fromPoints(e,e):n=e,i=this.getFoldsInRangeList(n),t!=0?this.removeFolds(i):this.expandFolds(i);if(i.length)return i},this.isRowFolded=function(e,t){return!!this.getFoldLine(e,t)},this.getRowFoldEnd=function(e,t){var n=this.getFoldLine(e,t);return n?n.end.row:e},this.getRowFoldStart=function(e,t){var n=this.getFoldLine(e,t);return n?n.start.row:e},this.getFoldDisplayLine=function(e,t,n,r,i){r==null&&(r=e.start.row),i==null&&(i=0),t==null&&(t=e.end.row),n==null&&(n=this.getLine(t).length);var s=this.doc,o="";return e.walk(function(e,t,n,u){if(t<r)return;if(t==r){if(n<i)return;u=Math.max(i,u)}e!=null?o+=e:o+=s.getLine(t).substring(u,n)},t,n),o},this.getDisplayLine=function(e,t,n,r){var i=this.getFoldLine(e);if(!i){var s;return s=this.doc.getLine(e),s.substring(r||0,t||s.length)}return this.getFoldDisplayLine(i,e,t,n,r)},this.$cloneFoldData=function(){var e=[];return e=this.$foldData.map(function(t){var n=t.folds.map(function(e){return e.clone()});return new i(e,n)}),e},this.toggleFold=function(e){var t=this.selection,n=t.getRange(),r,i;if(n.isEmpty()){var s=n.start;r=this.getFoldAt(s.row,s.column);if(r){this.expandFold(r);return}(i=this.findMatchingBracket(s))?n.comparePoint(i)==1?n.end=i:(n.start=i,n.start.column++,n.end.column--):(i=this.findMatchingBracket({row:s.row,column:s.column+1}))?(n.comparePoint(i)==1?n.end=i:n.start=i,n.start.column++):n=this.getCommentFoldRange(s.row,s.column)||n}else{var o=this.getFoldsInRange(n);if(e&&o.length){this.expandFolds(o);return}o.length==1&&(r=o[0])}r||(r=this.getFoldAt(n.start.row,n.start.column));if(r&&r.range.toString()==n.toString()){this.expandFold(r);return}var u="...";if(!n.isMultiLine()){u=this.getTextRange(n);if(u.length<4)return;u=u.trim().substring(0,2)+".."}this.addFold(u,n)},this.getCommentFoldRange=function(e,t,n){var i=new o(this,e,t),s=i.getCurrentToken(),u=s&&s.type;if(s&&/^comment|string/.test(u)){u=u.match(/comment|string/)[0],u=="comment"&&(u+="|doc-start");var a=new RegExp(u),f=new r;if(n!=1){do s=i.stepBackward();while(s&&a.test(s.type));i.stepForward()}f.start.row=i.getCurrentTokenRow(),f.start.column=i.getCurrentTokenColumn()+2,i=new o(this,e,t);if(n!=-1){var l=-1;do{s=i.stepForward();if(l==-1){var c=this.getState(i.$row);a.test(c)||(l=i.$row)}else if(i.$row>l)break}while(s&&a.test(s.type));s=i.stepBackward()}else s=i.getCurrentToken();return f.end.row=i.getCurrentTokenRow(),f.end.column=i.getCurrentTokenColumn()+s.value.length-2,f}},this.foldAll=function(e,t,n,r){n==undefined&&(n=1e5);var i=this.foldWidgets;if(!i)return;t=t||this.getLength(),e=e||0;for(var s=e;s<t;s++){i[s]==null&&(i[s]=this.getFoldWidget(s));if(i[s]!="start")continue;if(r&&!r(s))continue;var o=this.getFoldWidgetRange(s);o&&o.isMultiLine()&&o.end.row<=t&&o.start.row>=e&&(s=o.end.row,o.collapseChildren=n,this.addFold("...",o))}},this.foldToLevel=function(e){this.foldAll();while(e-->0)this.unfold(null,!1)},this.foldAllComments=function(){var e=this;this.foldAll(null,null,null,function(t){var n=e.getTokens(t);for(var r=0;r<n.length;r++){var i=n[r];if(i.type=="text"&&/^\s+$/.test(i.value))continue;return/comment/.test(i.type)?!0:!1}})},this.$foldStyles={manual:1,markbegin:1,markbeginend:1},this.$foldStyle="markbegin",this.setFoldStyle=function(e){if(!this.$foldStyles[e])throw new Error("invalid fold style: "+e+"["+Object.keys(this.$foldStyles).join(", ")+"]");if(this.$foldStyle==e)return;this.$foldStyle=e,e=="manual"&&this.unfold();var t=this.$foldMode;this.$setFolding(null),this.$setFolding(t)},this.$setFolding=function(e){if(this.$foldMode==e)return;this.$foldMode=e,this.off("change",this.$updateFoldWidgets),this.off("tokenizerUpdate",this.$tokenizerUpdateFoldWidgets),this._signal("changeAnnotation");if(!e||this.$foldStyle=="manual"){this.foldWidgets=null;return}this.foldWidgets=[],this.getFoldWidget=e.getFoldWidget.bind(e,this,this.$foldStyle),this.getFoldWidgetRange=e.getFoldWidgetRange.bind(e,this,this.$foldStyle),this.$updateFoldWidgets=this.updateFoldWidgets.bind(this),this.$tokenizerUpdateFoldWidgets=this.tokenizerUpdateFoldWidgets.bind(this),this.on("change",this.$updateFoldWidgets),this.on("tokenizerUpdate",this.$tokenizerUpdateFoldWidgets)},this.getParentFoldRangeData=function(e,t){var n=this.foldWidgets;if(!n||t&&n[e])return{};var r=e-1,i;while(r>=0){var s=n[r];s==null&&(s=n[r]=this.getFoldWidget(r));if(s=="start"){var o=this.getFoldWidgetRange(r);i||(i=o);if(o&&o.end.row>=e)break}r--}return{range:r!==-1&&o,firstRange:i}},this.onFoldWidgetClick=function(e,t){t=t.domEvent;var n={children:t.shiftKey,all:t.ctrlKey||t.metaKey,siblings:t.altKey},r=this.$toggleFoldWidget(e,n);if(!r){var i=t.target||t.srcElement;i&&/ace_fold-widget/.test(i.className)&&(i.className+=" ace_invalid")}},this.$toggleFoldWidget=function(e,t){if(!this.getFoldWidget)return;var n=this.getFoldWidget(e),r=this.getLine(e),i=n==="end"?-1:1,s=this.getFoldAt(e,i===-1?0:r.length,i);if(s)return t.children||t.all?this.removeFold(s):this.expandFold(s),s;var o=this.getFoldWidgetRange(e,!0);if(o&&!o.isMultiLine()){s=this.getFoldAt(o.start.row,o.start.column,1);if(s&&o.isEqual(s.range))return this.removeFold(s),s}if(t.siblings){var u=this.getParentFoldRangeData(e);if(u.range)var a=u.range.start.row+1,f=u.range.end.row;this.foldAll(a,f,t.all?1e4:0)}else t.children?(f=o?o.end.row:this.getLength(),this.foldAll(e+1,f,t.all?1e4:0)):o&&(t.all&&(o.collapseChildren=1e4),this.addFold("...",o));return o},this.toggleFoldWidget=function(e){var t=this.selection.getCursor().row;t=this.getRowFoldStart(t);var n=this.$toggleFoldWidget(t,{});if(n)return;var r=this.getParentFoldRangeData(t,!0);n=r.range||r.firstRange;if(n){t=n.start.row;var i=this.getFoldAt(t,this.getLine(t).length,1);i?this.removeFold(i):this.addFold("...",n)}},this.updateFoldWidgets=function(e){var t=e.start.row,n=e.end.row-t;if(n===0)this.foldWidgets[t]=null;else if(e.action=="remove")this.foldWidgets.splice(t,n+1,null);else{var r=Array(n+1);r.unshift(t,1),this.foldWidgets.splice.apply(this.foldWidgets,r)}},this.tokenizerUpdateFoldWidgets=function(e){var t=e.data;t.first!=t.last&&this.foldWidgets.length>t.first&&this.foldWidgets.splice(t.first,this.foldWidgets.length)}}var r=e("../range").Range,i=e("./fold_line").FoldLine,s=e("./fold").Fold,o=e("../token_iterator").TokenIterator;t.Folding=u}),ace.define("ace/edit_session/bracket_match",["require","exports","module","ace/token_iterator","ace/range"],function(e,t,n){"use strict";function s(){this.findMatchingBracket=function(e,t){if(e.column==0)return null;var n=t||this.getLine(e.row).charAt(e.column-1);if(n=="")return null;var r=n.match(/([\(\[\{])|([\)\]\}])/);return r?r[1]?this.$findClosingBracket(r[1],e):this.$findOpeningBracket(r[2],e):null},this.getBracketRange=function(e){var t=this.getLine(e.row),n=!0,r,s=t.charAt(e.column-1),o=s&&s.match(/([\(\[\{])|([\)\]\}])/);o||(s=t.charAt(e.column),e={row:e.row,column:e.column+1},o=s&&s.match(/([\(\[\{])|([\)\]\}])/),n=!1);if(!o)return null;if(o[1]){var u=this.$findClosingBracket(o[1],e);if(!u)return null;r=i.fromPoints(e,u),n||(r.end.column++,r.start.column--),r.cursor=r.end}else{var u=this.$findOpeningBracket(o[2],e);if(!u)return null;r=i.fromPoints(u,e),n||(r.start.column++,r.end.column--),r.cursor=r.start}return r},this.getMatchingBracketRanges=function(e){var t=this.getLine(e.row),n=t.charAt(e.column-1),r=n&&n.match(/([\(\[\{])|([\)\]\}])/);r||(n=t.charAt(e.column),e={row:e.row,column:e.column+1},r=n&&n.match(/([\(\[\{])|([\)\]\}])/));if(!r)return null;var s=new i(e.row,e.column-1,e.row,e.column),o=r[1]?this.$findClosingBracket(r[1],e):this.$findOpeningBracket(r[2],e);if(!o)return[s];var u=new i(o.row,o.column,o.row,o.column+1);return[s,u]},this.$brackets={")":"(","(":")","]":"[","[":"]","{":"}","}":"{","<":">",">":"<"},this.$findOpeningBracket=function(e,t,n){var i=this.$brackets[e],s=1,o=new r(this,t.row,t.column),u=o.getCurrentToken();u||(u=o.stepForward());if(!u)return;n||(n=new RegExp("(\\.?"+u.type.replace(".","\\.").replace("rparen",".paren").replace(/\b(?:end)\b/,"(?:start|begin|end)")+")+"));var a=t.column-o.getCurrentTokenColumn()-2,f=u.value;for(;;){while(a>=0){var l=f.charAt(a);if(l==i){s-=1;if(s==0)return{row:o.getCurrentTokenRow(),column:a+o.getCurrentTokenColumn()}}else l==e&&(s+=1);a-=1}do u=o.stepBackward();while(u&&!n.test(u.type));if(u==null)break;f=u.value,a=f.length-1}return null},this.$findClosingBracket=function(e,t,n){var i=this.$brackets[e],s=1,o=new r(this,t.row,t.column),u=o.getCurrentToken();u||(u=o.stepForward());if(!u)return;n||(n=new RegExp("(\\.?"+u.type.replace(".","\\.").replace("lparen",".paren").replace(/\b(?:start|begin)\b/,"(?:start|begin|end)")+")+"));var a=t.column-o.getCurrentTokenColumn();for(;;){var f=u.value,l=f.length;while(a<l){var c=f.charAt(a);if(c==i){s-=1;if(s==0)return{row:o.getCurrentTokenRow(),column:a+o.getCurrentTokenColumn()}}else c==e&&(s+=1);a+=1}do u=o.stepForward();while(u&&!n.test(u.type));if(u==null)break;a=0}return null}}var r=e("../token_iterator").TokenIterator,i=e("../range").Range;t.BracketMatch=s}),ace.define("ace/edit_session",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/bidihandler","ace/config","ace/lib/event_emitter","ace/selection","ace/mode/text","ace/range","ace/document","ace/background_tokenizer","ace/search_highlight","ace/edit_session/folding","ace/edit_session/bracket_match"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./lib/lang"),s=e("./bidihandler").BidiHandler,o=e("./config"),u=e("./lib/event_emitter").EventEmitter,a=e("./selection").Selection,f=e("./mode/text").Mode,l=e("./range").Range,c=e("./document").Document,h=e("./background_tokenizer").BackgroundTokenizer,p=e("./search_highlight").SearchHighlight,d=function(e,t){this.$breakpoints=[],this.$decorations=[],this.$frontMarkers={},this.$backMarkers={},this.$markerId=1,this.$undoSelect=!0,this.$foldData=[],this.id="session"+ ++d.$uid,this.$foldData.toString=function(){return this.join("\n")},this.on("changeFold",this.onChangeFold.bind(this)),this.$onChange=this.onChange.bind(this);if(typeof e!="object"||!e.getLine)e=new c(e);this.setDocument(e),this.selection=new a(this),this.$bidiHandler=new s(this),o.resetOptions(this),this.setMode(t),o._signal("session",this)};d.$uid=0,function(){function m(e){return e<4352?!1:e>=4352&&e<=4447||e>=4515&&e<=4519||e>=4602&&e<=4607||e>=9001&&e<=9002||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12283||e>=12288&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12589||e>=12593&&e<=12686||e>=12688&&e<=12730||e>=12736&&e<=12771||e>=12784&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=13054||e>=13056&&e<=19903||e>=19968&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=55216&&e<=55238||e>=55243&&e<=55291||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=65281&&e<=65376||e>=65504&&e<=65510}r.implement(this,u),this.setDocument=function(e){this.doc&&this.doc.removeListener("change",this.$onChange),this.doc=e,e.on("change",this.$onChange),this.bgTokenizer&&this.bgTokenizer.setDocument(this.getDocument()),this.resetCaches()},this.getDocument=function(){return this.doc},this.$resetRowCache=function(e){if(!e){this.$docRowCache=[],this.$screenRowCache=[];return}var t=this.$docRowCache.length,n=this.$getRowCacheIndex(this.$docRowCache,e)+1;t>n&&(this.$docRowCache.splice(n,t),this.$screenRowCache.splice(n,t))},this.$getRowCacheIndex=function(e,t){var n=0,r=e.length-1;while(n<=r){var i=n+r>>1,s=e[i];if(t>s)n=i+1;else{if(!(t<s))return i;r=i-1}}return n-1},this.resetCaches=function(){this.$modified=!0,this.$wrapData=[],this.$rowLengthCache=[],this.$resetRowCache(0),this.bgTokenizer&&this.bgTokenizer.start(0)},this.onChangeFold=function(e){var t=e.data;this.$resetRowCache(t.start.row)},this.onChange=function(e){this.$modified=!0,this.$bidiHandler.onChange(e),this.$resetRowCache(e.start.row);var t=this.$updateInternalDataOnChange(e);!this.$fromUndo&&this.$undoManager&&(t&&t.length&&(this.$undoManager.add({action:"removeFolds",folds:t},this.mergeUndoDeltas),this.mergeUndoDeltas=!0),this.$undoManager.add(e,this.mergeUndoDeltas),this.mergeUndoDeltas=!0,this.$informUndoManager.schedule()),this.bgTokenizer&&this.bgTokenizer.$updateOnChange(e),this._signal("change",e)},this.setValue=function(e){this.doc.setValue(e),this.selection.moveTo(0,0),this.$resetRowCache(0),this.setUndoManager(this.$undoManager),this.getUndoManager().reset()},this.getValue=this.toString=function(){return this.doc.getValue()},this.getSelection=function(){return this.selection},this.getState=function(e){return this.bgTokenizer.getState(e)},this.getTokens=function(e){return this.bgTokenizer.getTokens(e)},this.getTokenAt=function(e,t){var n=this.bgTokenizer.getTokens(e),r,i=0;if(t==null){var s=n.length-1;i=this.getLine(e).length}else for(var s=0;s<n.length;s++){i+=n[s].value.length;if(i>=t)break}return r=n[s],r?(r.index=s,r.start=i-r.value.length,r):null},this.setUndoManager=function(e){this.$undoManager=e,this.$informUndoManager&&this.$informUndoManager.cancel();if(e){var t=this;e.addSession(this),this.$syncInformUndoManager=function(){t.$informUndoManager.cancel(),t.mergeUndoDeltas=!1},this.$informUndoManager=i.delayedCall(this.$syncInformUndoManager)}else this.$syncInformUndoManager=function(){}},this.markUndoGroup=function(){this.$syncInformUndoManager&&this.$syncInformUndoManager()},this.$defaultUndoManager={undo:function(){},redo:function(){},hasUndo:function(){},hasRedo:function(){},reset:function(){},add:function(){},addSelection:function(){},startNewGroup:function(){},addSession:function(){}},this.getUndoManager=function(){return this.$undoManager||this.$defaultUndoManager},this.getTabString=function(){return this.getUseSoftTabs()?i.stringRepeat(" ",this.getTabSize()):" "},this.setUseSoftTabs=function(e){this.setOption("useSoftTabs",e)},this.getUseSoftTabs=function(){return this.$useSoftTabs&&!this.$mode.$indentWithTabs},this.setTabSize=function(e){this.setOption("tabSize",e)},this.getTabSize=function(){return this.$tabSize},this.isTabStop=function(e){return this.$useSoftTabs&&e.column%this.$tabSize===0},this.setNavigateWithinSoftTabs=function(e){this.setOption("navigateWithinSoftTabs",e)},this.getNavigateWithinSoftTabs=function(){return this.$navigateWithinSoftTabs},this.$overwrite=!1,this.setOverwrite=function(e){this.setOption("overwrite",e)},this.getOverwrite=function(){return this.$overwrite},this.toggleOverwrite=function(){this.setOverwrite(!this.$overwrite)},this.addGutterDecoration=function(e,t){this.$decorations[e]||(this.$decorations[e]=""),this.$decorations[e]+=" "+t,this._signal("changeBreakpoint",{})},this.removeGutterDecoration=function(e,t){this.$decorations[e]=(this.$decorations[e]||"").replace(" "+t,""),this._signal("changeBreakpoint",{})},this.getBreakpoints=function(){return this.$breakpoints},this.setBreakpoints=function(e){this.$breakpoints=[];for(var t=0;t<e.length;t++)this.$breakpoints[e[t]]="ace_breakpoint";this._signal("changeBreakpoint",{})},this.clearBreakpoints=function(){this.$breakpoints=[],this._signal("changeBreakpoint",{})},this.setBreakpoint=function(e,t){t===undefined&&(t="ace_breakpoint"),t?this.$breakpoints[e]=t:delete this.$breakpoints[e],this._signal("changeBreakpoint",{})},this.clearBreakpoint=function(e){delete this.$breakpoints[e],this._signal("changeBreakpoint",{})},this.addMarker=function(e,t,n,r){var i=this.$markerId++,s={range:e,type:n||"line",renderer:typeof n=="function"?n:null,clazz:t,inFront:!!r,id:i};return r?(this.$frontMarkers[i]=s,this._signal("changeFrontMarker")):(this.$backMarkers[i]=s,this._signal("changeBackMarker")),i},this.addDynamicMarker=function(e,t){if(!e.update)return;var n=this.$markerId++;return e.id=n,e.inFront=!!t,t?(this.$frontMarkers[n]=e,this._signal("changeFrontMarker")):(this.$backMarkers[n]=e,this._signal("changeBackMarker")),e},this.removeMarker=function(e){var t=this.$frontMarkers[e]||this.$backMarkers[e];if(!t)return;var n=t.inFront?this.$frontMarkers:this.$backMarkers;delete n[e],this._signal(t.inFront?"changeFrontMarker":"changeBackMarker")},this.getMarkers=function(e){return e?this.$frontMarkers:this.$backMarkers},this.highlight=function(e){if(!this.$searchHighlight){var t=new p(null,"ace_selected-word","text");this.$searchHighlight=this.addDynamicMarker(t)}this.$searchHighlight.setRegexp(e)},this.highlightLines=function(e,t,n,r){typeof t!="number"&&(n=t,t=e),n||(n="ace_step");var i=new l(e,0,t,Infinity);return i.id=this.addMarker(i,n,"fullLine",r),i},this.setAnnotations=function(e){this.$annotations=e,this._signal("changeAnnotation",{})},this.getAnnotations=function(){return this.$annotations||[]},this.clearAnnotations=function(){this.setAnnotations([])},this.$detectNewLine=function(e){var t=e.match(/^.*?(\r?\n)/m);t?this.$autoNewLine=t[1]:this.$autoNewLine="\n"},this.getWordRange=function(e,t){var n=this.getLine(e),r=!1;t>0&&(r=!!n.charAt(t-1).match(this.tokenRe)),r||(r=!!n.charAt(t).match(this.tokenRe));if(r)var i=this.tokenRe;else if(/^\s+$/.test(n.slice(t-1,t+1)))var i=/\s/;else var i=this.nonTokenRe;var s=t;if(s>0){do s--;while(s>=0&&n.charAt(s).match(i));s++}var o=t;while(o<n.length&&n.charAt(o).match(i))o++;return new l(e,s,e,o)},this.getAWordRange=function(e,t){var n=this.getWordRange(e,t),r=this.getLine(n.end.row);while(r.charAt(n.end.column).match(/[ \t]/))n.end.column+=1;return n},this.setNewLineMode=function(e){this.doc.setNewLineMode(e)},this.getNewLineMode=function(){return this.doc.getNewLineMode()},this.setUseWorker=function(e){this.setOption("useWorker",e)},this.getUseWorker=function(){return this.$useWorker},this.onReloadTokenizer=function(e){var t=e.data;this.bgTokenizer.start(t.first),this._signal("tokenizerUpdate",e)},this.$modes=o.$modes,this.$mode=null,this.$modeId=null,this.setMode=function(e,t){if(e&&typeof e=="object"){if(e.getTokenizer)return this.$onChangeMode(e);var n=e,r=n.path}else r=e||"ace/mode/text";this.$modes["ace/mode/text"]||(this.$modes["ace/mode/text"]=new f);if(this.$modes[r]&&!n){this.$onChangeMode(this.$modes[r]),t&&t();return}this.$modeId=r,o.loadModule(["mode",r],function(e){if(this.$modeId!==r)return t&&t();this.$modes[r]&&!n?this.$onChangeMode(this.$modes[r]):e&&e.Mode&&(e=new e.Mode(n),n||(this.$modes[r]=e,e.$id=r),this.$onChangeMode(e)),t&&t()}.bind(this)),this.$mode||this.$onChangeMode(this.$modes["ace/mode/text"],!0)},this.$onChangeMode=function(e,t){t||(this.$modeId=e.$id);if(this.$mode===e)return;var n=this.$mode;this.$mode=e,this.$stopWorker(),this.$useWorker&&this.$startWorker();var r=e.getTokenizer();if(r.on!==undefined){var i=this.onReloadTokenizer.bind(this);r.on("update",i)}if(!this.bgTokenizer){this.bgTokenizer=new h(r);var s=this;this.bgTokenizer.on("update",function(e){s._signal("tokenizerUpdate",e)})}else this.bgTokenizer.setTokenizer(r);this.bgTokenizer.setDocument(this.getDocument()),this.tokenRe=e.tokenRe,this.nonTokenRe=e.nonTokenRe,t||(e.attachToSession&&e.attachToSession(this),this.$options.wrapMethod.set.call(this,this.$wrapMethod),this.$setFolding(e.foldingRules),this.bgTokenizer.start(0),this._emit("changeMode",{oldMode:n,mode:e}))},this.$stopWorker=function(){this.$worker&&(this.$worker.terminate(),this.$worker=null)},this.$startWorker=function(){try{this.$worker=this.$mode.createWorker(this)}catch(e){o.warn("Could not load worker",e),this.$worker=null}},this.getMode=function(){return this.$mode},this.$scrollTop=0,this.setScrollTop=function(e){if(this.$scrollTop===e||isNaN(e))return;this.$scrollTop=e,this._signal("changeScrollTop",e)},this.getScrollTop=function(){return this.$scrollTop},this.$scrollLeft=0,this.setScrollLeft=function(e){if(this.$scrollLeft===e||isNaN(e))return;this.$scrollLeft=e,this._signal("changeScrollLeft",e)},this.getScrollLeft=function(){return this.$scrollLeft},this.getScreenWidth=function(){return this.$computeWidth(),this.lineWidgets?Math.max(this.getLineWidgetMaxWidth(),this.screenWidth):this.screenWidth},this.getLineWidgetMaxWidth=function(){if(this.lineWidgetsWidth!=null)return this.lineWidgetsWidth;var e=0;return this.lineWidgets.forEach(function(t){t&&t.screenWidth>e&&(e=t.screenWidth)}),this.lineWidgetWidth=e},this.$computeWidth=function(e){if(this.$modified||e){this.$modified=!1;if(this.$useWrapMode)return this.screenWidth=this.$wrapLimit;var t=this.doc.getAllLines(),n=this.$rowLengthCache,r=0,i=0,s=this.$foldData[i],o=s?s.start.row:Infinity,u=t.length;for(var a=0;a<u;a++){if(a>o){a=s.end.row+1;if(a>=u)break;s=this.$foldData[i++],o=s?s.start.row:Infinity}n[a]==null&&(n[a]=this.$getStringScreenWidth(t[a])[0]),n[a]>r&&(r=n[a])}this.screenWidth=r}},this.getLine=function(e){return this.doc.getLine(e)},this.getLines=function(e,t){return this.doc.getLines(e,t)},this.getLength=function(){return this.doc.getLength()},this.getTextRange=function(e){return this.doc.getTextRange(e||this.selection.getRange())},this.insert=function(e,t){return this.doc.insert(e,t)},this.remove=function(e){return this.doc.remove(e)},this.removeFullLines=function(e,t){return this.doc.removeFullLines(e,t)},this.undoChanges=function(e,t){if(!e.length)return;this.$fromUndo=!0;for(var n=e.length-1;n!=-1;n--){var r=e[n];r.action=="insert"||r.action=="remove"?this.doc.revertDelta(r):r.folds&&this.addFolds(r.folds)}!t&&this.$undoSelect&&(e.selectionBefore?this.selection.fromJSON(e.selectionBefore):this.selection.setRange(this.$getUndoSelection(e,!0))),this.$fromUndo=!1},this.redoChanges=function(e,t){if(!e.length)return;this.$fromUndo=!0;for(var n=0;n<e.length;n++){var r=e[n];(r.action=="insert"||r.action=="remove")&&this.doc.$safeApplyDelta(r)}!t&&this.$undoSelect&&(e.selectionAfter?this.selection.fromJSON(e.selectionAfter):this.selection.setRange(this.$getUndoSelection(e,!1))),this.$fromUndo=!1},this.setUndoSelect=function(e){this.$undoSelect=e},this.$getUndoSelection=function(e,t){function n(e){return t?e.action!=="insert":e.action==="insert"}var r,i;for(var s=0;s<e.length;s++){var o=e[s];if(!o.start)continue;if(!r){n(o)?r=l.fromPoints(o.start,o.end):r=l.fromPoints(o.start,o.start);continue}n(o)?(i=o.start,r.compare(i.row,i.column)==-1&&r.setStart(i),i=o.end,r.compare(i.row,i.column)==1&&r.setEnd(i)):(i=o.start,r.compare(i.row,i.column)==-1&&(r=l.fromPoints(o.start,o.start)))}return r},this.replace=function(e,t){return this.doc.replace(e,t)},this.moveText=function(e,t,n){var r=this.getTextRange(e),i=this.getFoldsInRange(e),s=l.fromPoints(t,t);if(!n){this.remove(e);var o=e.start.row-e.end.row,u=o?-e.end.column:e.start.column-e.end.column;u&&(s.start.row==e.end.row&&s.start.column>e.end.column&&(s.start.column+=u),s.end.row==e.end.row&&s.end.column>e.end.column&&(s.end.column+=u)),o&&s.start.row>=e.end.row&&(s.start.row+=o,s.end.row+=o)}s.end=this.insert(s.start,r);if(i.length){var a=e.start,f=s.start,o=f.row-a.row,u=f.column-a.column;this.addFolds(i.map(function(e){return e=e.clone(),e.start.row==a.row&&(e.start.column+=u),e.end.row==a.row&&(e.end.column+=u),e.start.row+=o,e.end.row+=o,e}))}return s},this.indentRows=function(e,t,n){n=n.replace(/\t/g,this.getTabString());for(var r=e;r<=t;r++)this.doc.insertInLine({row:r,column:0},n)},this.outdentRows=function(e){var t=e.collapseRows(),n=new l(0,0,0,0),r=this.getTabSize();for(var i=t.start.row;i<=t.end.row;++i){var s=this.getLine(i);n.start.row=i,n.end.row=i;for(var o=0;o<r;++o)if(s.charAt(o)!=" ")break;o<r&&s.charAt(o)==" "?(n.start.column=o,n.end.column=o+1):(n.start.column=0,n.end.column=o),this.remove(n)}},this.$moveLines=function(e,t,n){e=this.getRowFoldStart(e),t=this.getRowFoldEnd(t);if(n<0){var r=this.getRowFoldStart(e+n);if(r<0)return 0;var i=r-e}else if(n>0){var r=this.getRowFoldEnd(t+n);if(r>this.doc.getLength()-1)return 0;var i=r-t}else{e=this.$clipRowToDocument(e),t=this.$clipRowToDocument(t);var i=t-e+1}var s=new l(e,0,t,Number.MAX_VALUE),o=this.getFoldsInRange(s).map(function(e){return e=e.clone(),e.start.row+=i,e.end.row+=i,e}),u=n==0?this.doc.getLines(e,t):this.doc.removeFullLines(e,t);return this.doc.insertFullLines(e+i,u),o.length&&this.addFolds(o),i},this.moveLinesUp=function(e,t){return this.$moveLines(e,t,-1)},this.moveLinesDown=function(e,t){return this.$moveLines(e,t,1)},this.duplicateLines=function(e,t){return this.$moveLines(e,t,0)},this.$clipRowToDocument=function(e){return Math.max(0,Math.min(e,this.doc.getLength()-1))},this.$clipColumnToRow=function(e,t){return t<0?0:Math.min(this.doc.getLine(e).length,t)},this.$clipPositionToDocument=function(e,t){t=Math.max(0,t);if(e<0)e=0,t=0;else{var n=this.doc.getLength();e>=n?(e=n-1,t=this.doc.getLine(n-1).length):t=Math.min(this.doc.getLine(e).length,t)}return{row:e,column:t}},this.$clipRangeToDocument=function(e){e.start.row<0?(e.start.row=0,e.start.column=0):e.start.column=this.$clipColumnToRow(e.start.row,e.start.column);var t=this.doc.getLength()-1;return e.end.row>t?(e.end.row=t,e.end.column=this.doc.getLine(t).length):e.end.column=this.$clipColumnToRow(e.end.row,e.end.column),e},this.$wrapLimit=80,this.$useWrapMode=!1,this.$wrapLimitRange={min:null,max:null},this.setUseWrapMode=function(e){if(e!=this.$useWrapMode){this.$useWrapMode=e,this.$modified=!0,this.$resetRowCache(0);if(e){var t=this.getLength();this.$wrapData=Array(t),this.$updateWrapData(0,t-1)}this._signal("changeWrapMode")}},this.getUseWrapMode=function(){return this.$useWrapMode},this.setWrapLimitRange=function(e,t){if(this.$wrapLimitRange.min!==e||this.$wrapLimitRange.max!==t)this.$wrapLimitRange={min:e,max:t},this.$modified=!0,this.$bidiHandler.markAsDirty(),this.$useWrapMode&&this._signal("changeWrapMode")},this.adjustWrapLimit=function(e,t){var n=this.$wrapLimitRange;n.max<0&&(n={min:t,max:t});var r=this.$constrainWrapLimit(e,n.min,n.max);return r!=this.$wrapLimit&&r>1?(this.$wrapLimit=r,this.$modified=!0,this.$useWrapMode&&(this.$updateWrapData(0,this.getLength()-1),this.$resetRowCache(0),this._signal("changeWrapLimit")),!0):!1},this.$constrainWrapLimit=function(e,t,n){return t&&(e=Math.max(t,e)),n&&(e=Math.min(n,e)),e},this.getWrapLimit=function(){return this.$wrapLimit},this.setWrapLimit=function(e){this.setWrapLimitRange(e,e)},this.getWrapLimitRange=function(){return{min:this.$wrapLimitRange.min,max:this.$wrapLimitRange.max}},this.$updateInternalDataOnChange=function(e){var t=this.$useWrapMode,n=e.action,r=e.start,i=e.end,s=r.row,o=i.row,u=o-s,a=null;this.$updating=!0;if(u!=0)if(n==="remove"){this[t?"$wrapData":"$rowLengthCache"].splice(s,u);var f=this.$foldData;a=this.getFoldsInRange(e),this.removeFolds(a);var l=this.getFoldLine(i.row),c=0;if(l){l.addRemoveChars(i.row,i.column,r.column-i.column),l.shiftRow(-u);var h=this.getFoldLine(s);h&&h!==l&&(h.merge(l),l=h),c=f.indexOf(l)+1}for(c;c<f.length;c++){var l=f[c];l.start.row>=i.row&&l.shiftRow(-u)}o=s}else{var p=Array(u);p.unshift(s,0);var d=t?this.$wrapData:this.$rowLengthCache;d.splice.apply(d,p);var f=this.$foldData,l=this.getFoldLine(s),c=0;if(l){var v=l.range.compareInside(r.row,r.column);v==0?(l=l.split(r.row,r.column),l&&(l.shiftRow(u),l.addRemoveChars(o,0,i.column-r.column))):v==-1&&(l.addRemoveChars(s,0,i.column-r.column),l.shiftRow(u)),c=f.indexOf(l)+1}for(c;c<f.length;c++){var l=f[c];l.start.row>=s&&l.shiftRow(u)}}else{u=Math.abs(e.start.column-e.end.column),n==="remove"&&(a=this.getFoldsInRange(e),this.removeFolds(a),u=-u);var l=this.getFoldLine(s);l&&l.addRemoveChars(s,r.column,u)}return t&&this.$wrapData.length!=this.doc.getLength()&&console.error("doc.getLength() and $wrapData.length have to be the same!"),this.$updating=!1,t?this.$updateWrapData(s,o):this.$updateRowLengthCache(s,o),a},this.$updateRowLengthCache=function(e,t,n){this.$rowLengthCache[e]=null,this.$rowLengthCache[t]=null},this.$updateWrapData=function(e,t){var r=this.doc.getAllLines(),i=this.getTabSize(),o=this.$wrapData,u=this.$wrapLimit,a,f,l=e;t=Math.min(t,r.length-1);while(l<=t)f=this.getFoldLine(l,f),f?(a=[],f.walk(function(e,t,i,o){var u;if(e!=null){u=this.$getDisplayTokens(e,a.length),u[0]=n;for(var f=1;f<u.length;f++)u[f]=s}else u=this.$getDisplayTokens(r[t].substring(o,i),a.length);a=a.concat(u)}.bind(this),f.end.row,r[f.end.row].length+1),o[f.start.row]=this.$computeWrapSplits(a,u,i),l=f.end.row+1):(a=this.$getDisplayTokens(r[l]),o[l]=this.$computeWrapSplits(a,u,i),l++)};var e=1,t=2,n=3,s=4,a=9,c=10,d=11,v=12;this.$computeWrapSplits=function(e,r,i){function g(){var t=0;if(m===0)return t;if(p)for(var n=0;n<e.length;n++){var r=e[n];if(r==c)t+=1;else{if(r!=d){if(r==v)continue;break}t+=i}}return h&&p!==!1&&(t+=i),Math.min(t,m)}function y(t){var n=t-f;for(var r=f;r<t;r++){var i=e[r];if(i===12||i===2)n-=1}o.length||(b=g(),o.indent=b),l+=n,o.push(l),f=t}if(e.length==0)return[];var o=[],u=e.length,f=0,l=0,h=this.$wrapAsCode,p=this.$indentedSoftWrap,m=r<=Math.max(2*i,8)||p===!1?0:Math.floor(r/2),b=0;while(u-f>r-b){var w=f+r-b;if(e[w-1]>=c&&e[w]>=c){y(w);continue}if(e[w]==n||e[w]==s){for(w;w!=f-1;w--)if(e[w]==n)break;if(w>f){y(w);continue}w=f+r;for(w;w<e.length;w++)if(e[w]!=s)break;if(w==e.length)break;y(w);continue}var E=Math.max(w-(r-(r>>2)),f-1);while(w>E&&e[w]<n)w--;if(h){while(w>E&&e[w]<n)w--;while(w>E&&e[w]==a)w--}else while(w>E&&e[w]<c)w--;if(w>E){y(++w);continue}w=f+r,e[w]==t&&w--,y(w-b)}return o},this.$getDisplayTokens=function(n,r){var i=[],s;r=r||0;for(var o=0;o<n.length;o++){var u=n.charCodeAt(o);if(u==9){s=this.getScreenTabSize(i.length+r),i.push(d);for(var f=1;f<s;f++)i.push(v)}else u==32?i.push(c):u>39&&u<48||u>57&&u<64?i.push(a):u>=4352&&m(u)?i.push(e,t):i.push(e)}return i},this.$getStringScreenWidth=function(e,t,n){if(t==0)return[0,0];t==null&&(t=Infinity),n=n||0;var r,i;for(i=0;i<e.length;i++){r=e.charCodeAt(i),r==9?n+=this.getScreenTabSize(n):r>=4352&&m(r)?n+=2:n+=1;if(n>t)break}return[n,i]},this.lineWidgets=null,this.getRowLength=function(e){var t=1;return this.lineWidgets&&(t+=this.lineWidgets[e]&&this.lineWidgets[e].rowCount||0),!this.$useWrapMode||!this.$wrapData[e]?t:this.$wrapData[e].length+t},this.getRowLineCount=function(e){return!this.$useWrapMode||!this.$wrapData[e]?1:this.$wrapData[e].length+1},this.getRowWrapIndent=function(e){if(this.$useWrapMode){var t=this.screenToDocumentPosition(e,Number.MAX_VALUE),n=this.$wrapData[t.row];return n.length&&n[0]<t.column?n.indent:0}return 0},this.getScreenLastRowColumn=function(e){var t=this.screenToDocumentPosition(e,Number.MAX_VALUE);return this.documentToScreenColumn(t.row,t.column)},this.getDocumentLastRowColumn=function(e,t){var n=this.documentToScreenRow(e,t);return this.getScreenLastRowColumn(n)},this.getDocumentLastRowColumnPosition=function(e,t){var n=this.documentToScreenRow(e,t);return this.screenToDocumentPosition(n,Number.MAX_VALUE/10)},this.getRowSplitData=function(e){return this.$useWrapMode?this.$wrapData[e]:undefined},this.getScreenTabSize=function(e){return this.$tabSize-(e%this.$tabSize|0)},this.screenToDocumentRow=function(e,t){return this.screenToDocumentPosition(e,t).row},this.screenToDocumentColumn=function(e,t){return this.screenToDocumentPosition(e,t).column},this.screenToDocumentPosition=function(e,t,n){if(e<0)return{row:0,column:0};var r,i=0,s=0,o,u=0,a=0,f=this.$screenRowCache,l=this.$getRowCacheIndex(f,e),c=f.length;if(c&&l>=0)var u=f[l],i=this.$docRowCache[l],h=e>f[c-1];else var h=!c;var p=this.getLength()-1,d=this.getNextFoldLine(i),v=d?d.start.row:Infinity;while(u<=e){a=this.getRowLength(i);if(u+a>e||i>=p)break;u+=a,i++,i>v&&(i=d.end.row+1,d=this.getNextFoldLine(i,d),v=d?d.start.row:Infinity),h&&(this.$docRowCache.push(i),this.$screenRowCache.push(u))}if(d&&d.start.row<=i)r=this.getFoldDisplayLine(d),i=d.start.row;else{if(u+a<=e||i>p)return{row:p,column:this.getLine(p).length};r=this.getLine(i),d=null}var m=0,g=Math.floor(e-u);if(this.$useWrapMode){var y=this.$wrapData[i];y&&(o=y[g],g>0&&y.length&&(m=y.indent,s=y[g-1]||y[y.length-1],r=r.substring(s)))}return n!==undefined&&this.$bidiHandler.isBidiRow(u+g,i,g)&&(t=this.$bidiHandler.offsetToCol(n)),s+=this.$getStringScreenWidth(r,t-m)[1],this.$useWrapMode&&s>=o&&(s=o-1),d?d.idxToPosition(s):{row:i,column:s}},this.documentToScreenPosition=function(e,t){if(typeof t=="undefined")var n=this.$clipPositionToDocument(e.row,e.column);else n=this.$clipPositionToDocument(e,t);e=n.row,t=n.column;var r=0,i=null,s=null;s=this.getFoldAt(e,t,1),s&&(e=s.start.row,t=s.start.column);var o,u=0,a=this.$docRowCache,f=this.$getRowCacheIndex(a,e),l=a.length;if(l&&f>=0)var u=a[f],r=this.$screenRowCache[f],c=e>a[l-1];else var c=!l;var h=this.getNextFoldLine(u),p=h?h.start.row:Infinity;while(u<e){if(u>=p){o=h.end.row+1;if(o>e)break;h=this.getNextFoldLine(o,h),p=h?h.start.row:Infinity}else o=u+1;r+=this.getRowLength(u),u=o,c&&(this.$docRowCache.push(u),this.$screenRowCache.push(r))}var d="";h&&u>=p?(d=this.getFoldDisplayLine(h,e,t),i=h.start.row):(d=this.getLine(e).substring(0,t),i=e);var v=0;if(this.$useWrapMode){var m=this.$wrapData[i];if(m){var g=0;while(d.length>=m[g])r++,g++;d=d.substring(m[g-1]||0,d.length),v=g>0?m.indent:0}}return this.lineWidgets&&this.lineWidgets[u]&&this.lineWidgets[u].rowsAbove&&(r+=this.lineWidgets[u].rowsAbove),{row:r,column:v+this.$getStringScreenWidth(d)[0]}},this.documentToScreenColumn=function(e,t){return this.documentToScreenPosition(e,t).column},this.documentToScreenRow=function(e,t){return this.documentToScreenPosition(e,t).row},this.getScreenLength=function(){var e=0,t=null;if(!this.$useWrapMode){e=this.getLength();var n=this.$foldData;for(var r=0;r<n.length;r++)t=n[r],e-=t.end.row-t.start.row}else{var i=this.$wrapData.length,s=0,r=0,t=this.$foldData[r++],o=t?t.start.row:Infinity;while(s<i){var u=this.$wrapData[s];e+=u?u.length+1:1,s++,s>o&&(s=t.end.row+1,t=this.$foldData[r++],o=t?t.start.row:Infinity)}}return this.lineWidgets&&(e+=this.$getWidgetScreenLength()),e},this.$setFontMetrics=function(e){if(!this.$enableVarChar)return;this.$getStringScreenWidth=function(t,n,r){if(n===0)return[0,0];n||(n=Infinity),r=r||0;var i,s;for(s=0;s<t.length;s++){i=t.charAt(s),i===" "?r+=this.getScreenTabSize(r):r+=e.getCharacterWidth(i);if(r>n)break}return[r,s]}},this.destroy=function(){this.bgTokenizer&&(this.bgTokenizer.setDocument(null),this.bgTokenizer=null),this.$stopWorker(),this.removeAllListeners(),this.selection.detach()},this.isFullWidth=m}.call(d.prototype),e("./edit_session/folding").Folding.call(d.prototype),e("./edit_session/bracket_match").BracketMatch.call(d.prototype),o.defineOptions(d.prototype,"session",{wrap:{set:function(e){!e||e=="off"?e=!1:e=="free"?e=!0:e=="printMargin"?e=-1:typeof e=="string"&&(e=parseInt(e,10)||!1);if(this.$wrap==e)return;this.$wrap=e;if(!e)this.setUseWrapMode(!1);else{var t=typeof e=="number"?e:null;this.setWrapLimitRange(t,t),this.setUseWrapMode(!0)}},get:function(){return this.getUseWrapMode()?this.$wrap==-1?"printMargin":this.getWrapLimitRange().min?this.$wrap:"free":"off"},handlesSet:!0},wrapMethod:{set:function(e){e=e=="auto"?this.$mode.type!="text":e!="text",e!=this.$wrapAsCode&&(this.$wrapAsCode=e,this.$useWrapMode&&(this.$useWrapMode=!1,this.setUseWrapMode(!0)))},initialValue:"auto"},indentedSoftWrap:{set:function(){this.$useWrapMode&&(this.$useWrapMode=!1,this.setUseWrapMode(!0))},initialValue:!0},firstLineNumber:{set:function(){this._signal("changeBreakpoint")},initialValue:1},useWorker:{set:function(e){this.$useWorker=e,this.$stopWorker(),e&&this.$startWorker()},initialValue:!0},useSoftTabs:{initialValue:!0},tabSize:{set:function(e){e=parseInt(e),e>0&&this.$tabSize!==e&&(this.$modified=!0,this.$rowLengthCache=[],this.$tabSize=e,this._signal("changeTabSize"))},initialValue:4,handlesSet:!0},navigateWithinSoftTabs:{initialValue:!1},foldStyle:{set:function(e){this.setFoldStyle(e)},handlesSet:!0},overwrite:{set:function(e){this._signal("changeOverwrite")},initialValue:!1},newLineMode:{set:function(e){this.doc.setNewLineMode(e)},get:function(){return this.doc.getNewLineMode()},handlesSet:!0},mode:{set:function(e){this.setMode(e)},get:function(){return this.$modeId},handlesSet:!0}}),t.EditSession=d}),ace.define("ace/search",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"],function(e,t,n){"use strict";function u(e,t){function n(e){return/\w/.test(e)||t.regExp?"\\b":""}return n(e[0])+e+n(e[e.length-1])}var r=e("./lib/lang"),i=e("./lib/oop"),s=e("./range").Range,o=function(){this.$options={}};(function(){this.set=function(e){return i.mixin(this.$options,e),this},this.getOptions=function(){return r.copyObject(this.$options)},this.setOptions=function(e){this.$options=e},this.find=function(e){var t=this.$options,n=this.$matchIterator(e,t);if(!n)return!1;var r=null;return n.forEach(function(e,n,i,o){return r=new s(e,n,i,o),n==o&&t.start&&t.start.start&&t.skipCurrent!=0&&r.isEqual(t.start)?(r=null,!1):!0}),r},this.findAll=function(e){var t=this.$options;if(!t.needle)return[];this.$assembleRegExp(t);var n=t.range,i=n?e.getLines(n.start.row,n.end.row):e.doc.getAllLines(),o=[],u=t.re;if(t.$isMultiLine){var a=u.length,f=i.length-a,l;e:for(var c=u.offset||0;c<=f;c++){for(var h=0;h<a;h++)if(i[c+h].search(u[h])==-1)continue e;var p=i[c],d=i[c+a-1],v=p.length-p.match(u[0])[0].length,m=d.match(u[a-1])[0].length;if(l&&l.end.row===c&&l.end.column>v)continue;o.push(l=new s(c,v,c+a-1,m)),a>2&&(c=c+a-2)}}else for(var g=0;g<i.length;g++){var y=r.getMatchOffsets(i[g],u);for(var h=0;h<y.length;h++){var b=y[h];o.push(new s(g,b.offset,g,b.offset+b.length))}}if(n){var w=n.start.column,E=n.start.column,g=0,h=o.length-1;while(g<h&&o[g].start.column<w&&o[g].start.row==n.start.row)g++;while(g<h&&o[h].end.column>E&&o[h].end.row==n.end.row)h--;o=o.slice(g,h+1);for(g=0,h=o.length;g<h;g++)o[g].start.row+=n.start.row,o[g].end.row+=n.start.row}return o},this.replace=function(e,t){var n=this.$options,r=this.$assembleRegExp(n);if(n.$isMultiLine)return t;if(!r)return;var i=r.exec(e);if(!i||i[0].length!=e.length)return null;t=e.replace(r,t);if(n.preserveCase){t=t.split("");for(var s=Math.min(e.length,e.length);s--;){var o=e[s];o&&o.toLowerCase()!=o?t[s]=t[s].toUpperCase():t[s]=t[s].toLowerCase()}t=t.join("")}return t},this.$assembleRegExp=function(e,t){if(e.needle instanceof RegExp)return e.re=e.needle;var n=e.needle;if(!e.needle)return e.re=!1;e.regExp||(n=r.escapeRegExp(n)),e.wholeWord&&(n=u(n,e));var i=e.caseSensitive?"gm":"gmi";e.$isMultiLine=!t&&/[\n\r]/.test(n);if(e.$isMultiLine)return e.re=this.$assembleMultilineRegExp(n,i);try{var s=new RegExp(n,i)}catch(o){s=!1}return e.re=s},this.$assembleMultilineRegExp=function(e,t){var n=e.replace(/\r\n|\r|\n/g,"$\n^").split("\n"),r=[];for(var i=0;i<n.length;i++)try{r.push(new RegExp(n[i],t))}catch(s){return!1}return r},this.$matchIterator=function(e,t){var n=this.$assembleRegExp(t);if(!n)return!1;var r=t.backwards==1,i=t.skipCurrent!=0,s=t.range,o=t.start;o||(o=s?s[r?"end":"start"]:e.selection.getRange()),o.start&&(o=o[i!=r?"end":"start"]);var u=s?s.start.row:0,a=s?s.end.row:e.getLength()-1;if(r)var f=function(e){var n=o.row;if(c(n,o.column,e))return;for(n--;n>=u;n--)if(c(n,Number.MAX_VALUE,e))return;if(t.wrap==0)return;for(n=a,u=o.row;n>=u;n--)if(c(n,Number.MAX_VALUE,e))return};else var f=function(e){var n=o.row;if(c(n,o.column,e))return;for(n+=1;n<=a;n++)if(c(n,0,e))return;if(t.wrap==0)return;for(n=u,a=o.row;n<=a;n++)if(c(n,0,e))return};if(t.$isMultiLine)var l=n.length,c=function(t,i,s){var o=r?t-l+1:t;if(o<0)return;var u=e.getLine(o),a=u.search(n[0]);if(!r&&a<i||a===-1)return;for(var f=1;f<l;f++){u=e.getLine(o+f);if(u.search(n[f])==-1)return}var c=u.match(n[l-1])[0].length;if(r&&c>i)return;if(s(o,a,o+l-1,c))return!0};else if(r)var c=function(t,r,i){var s=e.getLine(t),o=[],u,a=0;n.lastIndex=0;while(u=n.exec(s)){var f=u[0].length;a=u.index;if(!f){if(a>=s.length)break;n.lastIndex=a+=1}if(u.index+f>r)break;o.push(u.index,f)}for(var l=o.length-1;l>=0;l-=2){var c=o[l-1],f=o[l];if(i(t,c,t,c+f))return!0}};else var c=function(t,r,i){var s=e.getLine(t),o,u;n.lastIndex=r;while(u=n.exec(s)){var a=u[0].length;o=u.index;if(i(t,o,t,o+a))return!0;if(!a){n.lastIndex=o+=1;if(o>=s.length)return!1}}};return{forEach:f}}}).call(o.prototype),t.Search=o}),ace.define("ace/keyboard/hash_handler",["require","exports","module","ace/lib/keys","ace/lib/useragent"],function(e,t,n){"use strict";function o(e,t){this.platform=t||(i.isMac?"mac":"win"),this.commands={},this.commandKeyBinding={},this.addCommands(e),this.$singleCommand=!0}function u(e,t){o.call(this,e,t),this.$singleCommand=!1}var r=e("../lib/keys"),i=e("../lib/useragent"),s=r.KEY_MODS;u.prototype=o.prototype,function(){function e(e){return typeof e=="object"&&e.bindKey&&e.bindKey.position||(e.isDefault?-100:0)}this.addCommand=function(e){this.commands[e.name]&&this.removeCommand(e),this.commands[e.name]=e,e.bindKey&&this._buildKeyHash(e)},this.removeCommand=function(e,t){var n=e&&(typeof e=="string"?e:e.name);e=this.commands[n],t||delete this.commands[n];var r=this.commandKeyBinding;for(var i in r){var s=r[i];if(s==e)delete r[i];else if(Array.isArray(s)){var o=s.indexOf(e);o!=-1&&(s.splice(o,1),s.length==1&&(r[i]=s[0]))}}},this.bindKey=function(e,t,n){typeof e=="object"&&e&&(n==undefined&&(n=e.position),e=e[this.platform]);if(!e)return;if(typeof t=="function")return this.addCommand({exec:t,bindKey:e,name:t.name||e});e.split("|").forEach(function(e){var r="";if(e.indexOf(" ")!=-1){var i=e.split(/\s+/);e=i.pop(),i.forEach(function(e){var t=this.parseKeys(e),n=s[t.hashId]+t.key;r+=(r?" ":"")+n,this._addCommandToBinding(r,"chainKeys")},this),r+=" "}var o=this.parseKeys(e),u=s[o.hashId]+o.key;this._addCommandToBinding(r+u,t,n)},this)},this._addCommandToBinding=function(t,n,r){var i=this.commandKeyBinding,s;if(!n)delete i[t];else if(!i[t]||this.$singleCommand)i[t]=n;else{Array.isArray(i[t])?(s=i[t].indexOf(n))!=-1&&i[t].splice(s,1):i[t]=[i[t]],typeof r!="number"&&(r=e(n));var o=i[t];for(s=0;s<o.length;s++){var u=o[s],a=e(u);if(a>r)break}o.splice(s,0,n)}},this.addCommands=function(e){e&&Object.keys(e).forEach(function(t){var n=e[t];if(!n)return;if(typeof n=="string")return this.bindKey(n,t);typeof n=="function"&&(n={exec:n});if(typeof n!="object")return;n.name||(n.name=t),this.addCommand(n)},this)},this.removeCommands=function(e){Object.keys(e).forEach(function(t){this.removeCommand(e[t])},this)},this.bindKeys=function(e){Object.keys(e).forEach(function(t){this.bindKey(t,e[t])},this)},this._buildKeyHash=function(e){this.bindKey(e.bindKey,e)},this.parseKeys=function(e){var t=e.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(e){return e}),n=t.pop(),i=r[n];if(r.FUNCTION_KEYS[i])n=r.FUNCTION_KEYS[i].toLowerCase();else{if(!t.length)return{key:n,hashId:-1};if(t.length==1&&t[0]=="shift")return{key:n.toUpperCase(),hashId:-1}}var s=0;for(var o=t.length;o--;){var u=r.KEY_MODS[t[o]];if(u==null)return typeof console!="undefined"&&console.error("invalid modifier "+t[o]+" in "+e),!1;s|=u}return{key:n,hashId:s}},this.findKeyCommand=function(t,n){var r=s[t]+n;return this.commandKeyBinding[r]},this.handleKeyboard=function(e,t,n,r){if(r<0)return;var i=s[t]+n,o=this.commandKeyBinding[i];e.$keyChain&&(e.$keyChain+=" "+i,o=this.commandKeyBinding[e.$keyChain]||o);if(o)if(o=="chainKeys"||o[o.length-1]=="chainKeys")return e.$keyChain=e.$keyChain||i,{command:"null"};if(e.$keyChain)if(!!t&&t!=4||n.length!=1){if(t==-1||r>0)e.$keyChain=""}else e.$keyChain=e.$keyChain.slice(0,-i.length-1);return{command:o}},this.getStatusText=function(e,t){return t.$keyChain||""}}.call(o.prototype),t.HashHandler=o,t.MultiHashHandler=u}),ace.define("ace/commands/command_manager",["require","exports","module","ace/lib/oop","ace/keyboard/hash_handler","ace/lib/event_emitter"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("../keyboard/hash_handler").MultiHashHandler,s=e("../lib/event_emitter").EventEmitter,o=function(e,t){i.call(this,t,e),this.byName=this.commands,this.setDefaultHandler("exec",function(e){return e.command.exec(e.editor,e.args||{})})};r.inherits(o,i),function(){r.implement(this,s),this.exec=function(e,t,n){if(Array.isArray(e)){for(var r=e.length;r--;)if(this.exec(e[r],t,n))return!0;return!1}typeof e=="string"&&(e=this.commands[e]);if(!e)return!1;if(t&&t.$readOnly&&!e.readOnly)return!1;if(this.$checkCommandState!=0&&e.isAvailable&&!e.isAvailable(t))return!1;var i={editor:t,command:e,args:n};return i.returnValue=this._emit("exec",i),this._signal("afterExec",i),i.returnValue===!1?!1:!0},this.toggleRecording=function(e){if(this.$inReplay)return;return e&&e._emit("changeStatus"),this.recording?(this.macro.pop(),this.off("exec",this.$addCommandToMacro),this.macro.length||(this.macro=this.oldMacro),this.recording=!1):(this.$addCommandToMacro||(this.$addCommandToMacro=function(e){this.macro.push([e.command,e.args])}.bind(this)),this.oldMacro=this.macro,this.macro=[],this.on("exec",this.$addCommandToMacro),this.recording=!0)},this.replay=function(e){if(this.$inReplay||!this.macro)return;if(this.recording)return this.toggleRecording(e);try{this.$inReplay=!0,this.macro.forEach(function(t){typeof t=="string"?this.exec(t,e):this.exec(t[0],e,t[1])},this)}finally{this.$inReplay=!1}},this.trimMacro=function(e){return e.map(function(e){return typeof e[0]!="string"&&(e[0]=e[0].name),e[1]||(e=e[0]),e})}}.call(o.prototype),t.CommandManager=o}),ace.define("ace/commands/default_commands",["require","exports","module","ace/lib/lang","ace/config","ace/range"],function(e,t,n){"use strict";function o(e,t){return{win:e,mac:t}}var r=e("../lib/lang"),i=e("../config"),s=e("../range").Range;t.commands=[{name:"showSettingsMenu",bindKey:o("Ctrl-,","Command-,"),exec:function(e){i.loadModule("ace/ext/settings_menu",function(t){t.init(e),e.showSettingsMenu()})},readOnly:!0},{name:"goToNextError",bindKey:o("Alt-E","F4"),exec:function(e){i.loadModule("./ext/error_marker",function(t){t.showErrorMarker(e,1)})},scrollIntoView:"animate",readOnly:!0},{name:"goToPreviousError",bindKey:o("Alt-Shift-E","Shift-F4"),exec:function(e){i.loadModule("./ext/error_marker",function(t){t.showErrorMarker(e,-1)})},scrollIntoView:"animate",readOnly:!0},{name:"selectall",description:"Select all",bindKey:o("Ctrl-A","Command-A"),exec:function(e){e.selectAll()},readOnly:!0},{name:"centerselection",description:"Center selection",bindKey:o(null,"Ctrl-L"),exec:function(e){e.centerSelection()},readOnly:!0},{name:"gotoline",description:"Go to line...",bindKey:o("Ctrl-L","Command-L"),exec:function(e,t){typeof t=="number"&&!isNaN(t)&&e.gotoLine(t),e.prompt({$type:"gotoLine"})},readOnly:!0},{name:"fold",bindKey:o("Alt-L|Ctrl-F1","Command-Alt-L|Command-F1"),exec:function(e){e.session.toggleFold(!1)},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"unfold",bindKey:o("Alt-Shift-L|Ctrl-Shift-F1","Command-Alt-Shift-L|Command-Shift-F1"),exec:function(e){e.session.toggleFold(!0)},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"toggleFoldWidget",bindKey:o("F2","F2"),exec:function(e){e.session.toggleFoldWidget()},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"toggleParentFoldWidget",bindKey:o("Alt-F2","Alt-F2"),exec:function(e){e.session.toggleFoldWidget(!0)},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"foldall",description:"Fold all",bindKey:o(null,"Ctrl-Command-Option-0"),exec:function(e){e.session.foldAll()},scrollIntoView:"center",readOnly:!0},{name:"foldAllComments",description:"Fold all comments",bindKey:o(null,"Ctrl-Command-Option-0"),exec:function(e){e.session.foldAllComments()},scrollIntoView:"center",readOnly:!0},{name:"foldOther",description:"Fold other",bindKey:o("Alt-0","Command-Option-0"),exec:function(e){e.session.foldAll(),e.session.unfold(e.selection.getAllRanges())},scrollIntoView:"center",readOnly:!0},{name:"unfoldall",description:"Unfold all",bindKey:o("Alt-Shift-0","Command-Option-Shift-0"),exec:function(e){e.session.unfold()},scrollIntoView:"center",readOnly:!0},{name:"findnext",description:"Find next",bindKey:o("Ctrl-K","Command-G"),exec:function(e){e.findNext()},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"findprevious",description:"Find previous",bindKey:o("Ctrl-Shift-K","Command-Shift-G"),exec:function(e){e.findPrevious()},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"selectOrFindNext",description:"Select or find next",bindKey:o("Alt-K","Ctrl-G"),exec:function(e){e.selection.isEmpty()?e.selection.selectWord():e.findNext()},readOnly:!0},{name:"selectOrFindPrevious",description:"Select or find previous",bindKey:o("Alt-Shift-K","Ctrl-Shift-G"),exec:function(e){e.selection.isEmpty()?e.selection.selectWord():e.findPrevious()},readOnly:!0},{name:"find",description:"Find",bindKey:o("Ctrl-F","Command-F"),exec:function(e){i.loadModule("ace/ext/searchbox",function(t){t.Search(e)})},readOnly:!0},{name:"overwrite",description:"Overwrite",bindKey:"Insert",exec:function(e){e.toggleOverwrite()},readOnly:!0},{name:"selecttostart",description:"Select to start",bindKey:o("Ctrl-Shift-Home","Command-Shift-Home|Command-Shift-Up"),exec:function(e){e.getSelection().selectFileStart()},multiSelectAction:"forEach",readOnly:!0,scrollIntoView:"animate",aceCommandGroup:"fileJump"},{name:"gotostart",description:"Go to start",bindKey:o("Ctrl-Home","Command-Home|Command-Up"),exec:function(e){e.navigateFileStart()},multiSelectAction:"forEach",readOnly:!0,scrollIntoView:"animate",aceCommandGroup:"fileJump"},{name:"selectup",description:"Select up",bindKey:o("Shift-Up","Shift-Up|Ctrl-Shift-P"),exec:function(e){e.getSelection().selectUp()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"golineup",description:"Go line up",bindKey:o("Up","Up|Ctrl-P"),exec:function(e,t){e.navigateUp(t.times)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selecttoend",description:"Select to end",bindKey:o("Ctrl-Shift-End","Command-Shift-End|Command-Shift-Down"),exec:function(e){e.getSelection().selectFileEnd()},multiSelectAction:"forEach",readOnly:!0,scrollIntoView:"animate",aceCommandGroup:"fileJump"},{name:"gotoend",description:"Go to end",bindKey:o("Ctrl-End","Command-End|Command-Down"),exec:function(e){e.navigateFileEnd()},multiSelectAction:"forEach",readOnly:!0,scrollIntoView:"animate",aceCommandGroup:"fileJump"},{name:"selectdown",description:"Select down",bindKey:o("Shift-Down","Shift-Down|Ctrl-Shift-N"),exec:function(e){e.getSelection().selectDown()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"golinedown",description:"Go line down",bindKey:o("Down","Down|Ctrl-N"),exec:function(e,t){e.navigateDown(t.times)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectwordleft",description:"Select word left",bindKey:o("Ctrl-Shift-Left","Option-Shift-Left"),exec:function(e){e.getSelection().selectWordLeft()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotowordleft",description:"Go to word left",bindKey:o("Ctrl-Left","Option-Left"),exec:function(e){e.navigateWordLeft()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selecttolinestart",description:"Select to line start",bindKey:o("Alt-Shift-Left","Command-Shift-Left|Ctrl-Shift-A"),exec:function(e){e.getSelection().selectLineStart()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotolinestart",description:"Go to line start",bindKey:o("Alt-Left|Home","Command-Left|Home|Ctrl-A"),exec:function(e){e.navigateLineStart()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectleft",description:"Select left",bindKey:o("Shift-Left","Shift-Left|Ctrl-Shift-B"),exec:function(e){e.getSelection().selectLeft()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotoleft",description:"Go to left",bindKey:o("Left","Left|Ctrl-B"),exec:function(e,t){e.navigateLeft(t.times)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectwordright",description:"Select word right",bindKey:o("Ctrl-Shift-Right","Option-Shift-Right"),exec:function(e){e.getSelection().selectWordRight()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotowordright",description:"Go to word right",bindKey:o("Ctrl-Right","Option-Right"),exec:function(e){e.navigateWordRight()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selecttolineend",description:"Select to line end",bindKey:o("Alt-Shift-Right","Command-Shift-Right|Shift-End|Ctrl-Shift-E"),exec:function(e){e.getSelection().selectLineEnd()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotolineend",description:"Go to line end",bindKey:o("Alt-Right|End","Command-Right|End|Ctrl-E"),exec:function(e){e.navigateLineEnd()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectright",description:"Select right",bindKey:o("Shift-Right","Shift-Right"),exec:function(e){e.getSelection().selectRight()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotoright",description:"Go to right",bindKey:o("Right","Right|Ctrl-F"),exec:function(e,t){e.navigateRight(t.times)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectpagedown",description:"Select page down",bindKey:"Shift-PageDown",exec:function(e){e.selectPageDown()},readOnly:!0},{name:"pagedown",description:"Page down",bindKey:o(null,"Option-PageDown"),exec:function(e){e.scrollPageDown()},readOnly:!0},{name:"gotopagedown",description:"Go to page down",bindKey:o("PageDown","PageDown|Ctrl-V"),exec:function(e){e.gotoPageDown()},readOnly:!0},{name:"selectpageup",description:"Select page up",bindKey:"Shift-PageUp",exec:function(e){e.selectPageUp()},readOnly:!0},{name:"pageup",description:"Page up",bindKey:o(null,"Option-PageUp"),exec:function(e){e.scrollPageUp()},readOnly:!0},{name:"gotopageup",description:"Go to page up",bindKey:"PageUp",exec:function(e){e.gotoPageUp()},readOnly:!0},{name:"scrollup",description:"Scroll up",bindKey:o("Ctrl-Up",null),exec:function(e){e.renderer.scrollBy(0,-2*e.renderer.layerConfig.lineHeight)},readOnly:!0},{name:"scrolldown",description:"Scroll down",bindKey:o("Ctrl-Down",null),exec:function(e){e.renderer.scrollBy(0,2*e.renderer.layerConfig.lineHeight)},readOnly:!0},{name:"selectlinestart",description:"Select line start",bindKey:"Shift-Home",exec:function(e){e.getSelection().selectLineStart()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectlineend",description:"Select line end",bindKey:"Shift-End",exec:function(e){e.getSelection().selectLineEnd()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"togglerecording",description:"Toggle recording",bindKey:o("Ctrl-Alt-E","Command-Option-E"),exec:function(e){e.commands.toggleRecording(e)},readOnly:!0},{name:"replaymacro",description:"Replay macro",bindKey:o("Ctrl-Shift-E","Command-Shift-E"),exec:function(e){e.commands.replay(e)},readOnly:!0},{name:"jumptomatching",description:"Jump to matching",bindKey:o("Ctrl-\\|Ctrl-P","Command-\\"),exec:function(e){e.jumpToMatching()},multiSelectAction:"forEach",scrollIntoView:"animate",readOnly:!0},{name:"selecttomatching",description:"Select to matching",bindKey:o("Ctrl-Shift-\\|Ctrl-Shift-P","Command-Shift-\\"),exec:function(e){e.jumpToMatching(!0)},multiSelectAction:"forEach",scrollIntoView:"animate",readOnly:!0},{name:"expandToMatching",description:"Expand to matching",bindKey:o("Ctrl-Shift-M","Ctrl-Shift-M"),exec:function(e){e.jumpToMatching(!0,!0)},multiSelectAction:"forEach",scrollIntoView:"animate",readOnly:!0},{name:"passKeysToBrowser",description:"Pass keys to browser",bindKey:o(null,null),exec:function(){},passEvent:!0,readOnly:!0},{name:"copy",description:"Copy",exec:function(e){},readOnly:!0},{name:"cut",description:"Cut",exec:function(e){var t=e.$copyWithEmptySelection&&e.selection.isEmpty(),n=t?e.selection.getLineRange():e.selection.getRange();e._emit("cut",n),n.isEmpty()||e.session.remove(n),e.clearSelection()},scrollIntoView:"cursor",multiSelectAction:"forEach"},{name:"paste",description:"Paste",exec:function(e,t){e.$handlePaste(t)},scrollIntoView:"cursor"},{name:"removeline",description:"Remove line",bindKey:o("Ctrl-D","Command-D"),exec:function(e){e.removeLines()},scrollIntoView:"cursor",multiSelectAction:"forEachLine"},{name:"duplicateSelection",description:"Duplicate selection",bindKey:o("Ctrl-Shift-D","Command-Shift-D"),exec:function(e){e.duplicateSelection()},scrollIntoView:"cursor",multiSelectAction:"forEach"},{name:"sortlines",description:"Sort lines",bindKey:o("Ctrl-Alt-S","Command-Alt-S"),exec:function(e){e.sortLines()},scrollIntoView:"selection",multiSelectAction:"forEachLine"},{name:"togglecomment",description:"Toggle comment",bindKey:o("Ctrl-/","Command-/"),exec:function(e){e.toggleCommentLines()},multiSelectAction:"forEachLine",scrollIntoView:"selectionPart"},{name:"toggleBlockComment",description:"Toggle block comment",bindKey:o("Ctrl-Shift-/","Command-Shift-/"),exec:function(e){e.toggleBlockComment()},multiSelectAction:"forEach",scrollIntoView:"selectionPart"},{name:"modifyNumberUp",description:"Modify number up",bindKey:o("Ctrl-Shift-Up","Alt-Shift-Up"),exec:function(e){e.modifyNumber(1)},scrollIntoView:"cursor",multiSelectAction:"forEach"},{name:"modifyNumberDown",description:"Modify number down",bindKey:o("Ctrl-Shift-Down","Alt-Shift-Down"),exec:function(e){e.modifyNumber(-1)},scrollIntoView:"cursor",multiSelectAction:"forEach"},{name:"replace",description:"Replace",bindKey:o("Ctrl-H","Command-Option-F"),exec:function(e){i.loadModule("ace/ext/searchbox",function(t){t.Search(e,!0)})}},{name:"undo",description:"Undo",bindKey:o("Ctrl-Z","Command-Z"),exec:function(e){e.undo()}},{name:"redo",description:"Redo",bindKey:o("Ctrl-Shift-Z|Ctrl-Y","Command-Shift-Z|Command-Y"),exec:function(e){e.redo()}},{name:"copylinesup",description:"Copy lines up",bindKey:o("Alt-Shift-Up","Command-Option-Up"),exec:function(e){e.copyLinesUp()},scrollIntoView:"cursor"},{name:"movelinesup",description:"Move lines up",bindKey:o("Alt-Up","Option-Up"),exec:function(e){e.moveLinesUp()},scrollIntoView:"cursor"},{name:"copylinesdown",description:"Copy lines down",bindKey:o("Alt-Shift-Down","Command-Option-Down"),exec:function(e){e.copyLinesDown()},scrollIntoView:"cursor"},{name:"movelinesdown",description:"Move lines down",bindKey:o("Alt-Down","Option-Down"),exec:function(e){e.moveLinesDown()},scrollIntoView:"cursor"},{name:"del",description:"Delete",bindKey:o("Delete","Delete|Ctrl-D|Shift-Delete"),exec:function(e){e.remove("right")},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"backspace",description:"Backspace",bindKey:o("Shift-Backspace|Backspace","Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H"),exec:function(e){e.remove("left")},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"cut_or_delete",description:"Cut or delete",bindKey:o("Shift-Delete",null),exec:function(e){if(!e.selection.isEmpty())return!1;e.remove("left")},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removetolinestart",description:"Remove to line start",bindKey:o("Alt-Backspace","Command-Backspace"),exec:function(e){e.removeToLineStart()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removetolineend",description:"Remove to line end",bindKey:o("Alt-Delete","Ctrl-K|Command-Delete"),exec:function(e){e.removeToLineEnd()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removetolinestarthard",description:"Remove to line start hard",bindKey:o("Ctrl-Shift-Backspace",null),exec:function(e){var t=e.selection.getRange();t.start.column=0,e.session.remove(t)},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removetolineendhard",description:"Remove to line end hard",bindKey:o("Ctrl-Shift-Delete",null),exec:function(e){var t=e.selection.getRange();t.end.column=Number.MAX_VALUE,e.session.remove(t)},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removewordleft",description:"Remove word left",bindKey:o("Ctrl-Backspace","Alt-Backspace|Ctrl-Alt-Backspace"),exec:function(e){e.removeWordLeft()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removewordright",description:"Remove word right",bindKey:o("Ctrl-Delete","Alt-Delete"),exec:function(e){e.removeWordRight()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"outdent",description:"Outdent",bindKey:o("Shift-Tab","Shift-Tab"),exec:function(e){e.blockOutdent()},multiSelectAction:"forEach",scrollIntoView:"selectionPart"},{name:"indent",description:"Indent",bindKey:o("Tab","Tab"),exec:function(e){e.indent()},multiSelectAction:"forEach",scrollIntoView:"selectionPart"},{name:"blockoutdent",description:"Block outdent",bindKey:o("Ctrl-[","Ctrl-["),exec:function(e){e.blockOutdent()},multiSelectAction:"forEachLine",scrollIntoView:"selectionPart"},{name:"blockindent",description:"Block indent",bindKey:o("Ctrl-]","Ctrl-]"),exec:function(e){e.blockIndent()},multiSelectAction:"forEachLine",scrollIntoView:"selectionPart"},{name:"insertstring",description:"Insert string",exec:function(e,t){e.insert(t)},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"inserttext",description:"Insert text",exec:function(e,t){e.insert(r.stringRepeat(t.text||"",t.times||1))},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"splitline",description:"Split line",bindKey:o(null,"Ctrl-O"),exec:function(e){e.splitLine()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"transposeletters",description:"Transpose letters",bindKey:o("Alt-Shift-X","Ctrl-T"),exec:function(e){e.transposeLetters()},multiSelectAction:function(e){e.transposeSelections(1)},scrollIntoView:"cursor"},{name:"touppercase",description:"To uppercase",bindKey:o("Ctrl-U","Ctrl-U"),exec:function(e){e.toUpperCase()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"tolowercase",description:"To lowercase",bindKey:o("Ctrl-Shift-U","Ctrl-Shift-U"),exec:function(e){e.toLowerCase()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"autoindent",description:"Auto Indent",bindKey:o(null,null),exec:function(e){e.autoIndent()},multiSelectAction:"forEachLine",scrollIntoView:"animate"},{name:"expandtoline",description:"Expand to line",bindKey:o("Ctrl-Shift-L","Command-Shift-L"),exec:function(e){var t=e.selection.getRange();t.start.column=t.end.column=0,t.end.row++,e.selection.setRange(t,!1)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"joinlines",description:"Join lines",bindKey:o(null,null),exec:function(e){var t=e.selection.isBackwards(),n=t?e.selection.getSelectionLead():e.selection.getSelectionAnchor(),i=t?e.selection.getSelectionAnchor():e.selection.getSelectionLead(),o=e.session.doc.getLine(n.row).length,u=e.session.doc.getTextRange(e.selection.getRange()),a=u.replace(/\n\s*/," ").length,f=e.session.doc.getLine(n.row);for(var l=n.row+1;l<=i.row+1;l++){var c=r.stringTrimLeft(r.stringTrimRight(e.session.doc.getLine(l)));c.length!==0&&(c=" "+c),f+=c}i.row+1<e.session.doc.getLength()-1&&(f+=e.session.doc.getNewLineCharacter()),e.clearSelection(),e.session.doc.replace(new s(n.row,0,i.row+2,0),f),a>0?(e.selection.moveCursorTo(n.row,n.column),e.selection.selectTo(n.row,n.column+a)):(o=e.session.doc.getLine(n.row).length>o?o+1:o,e.selection.moveCursorTo(n.row,o))},multiSelectAction:"forEach",readOnly:!0},{name:"invertSelection",description:"Invert selection",bindKey:o(null,null),exec:function(e){var t=e.session.doc.getLength()-1,n=e.session.doc.getLine(t).length,r=e.selection.rangeList.ranges,i=[];r.length<1&&(r=[e.selection.getRange()]);for(var o=0;o<r.length;o++)o==r.length-1&&(r[o].end.row!==t||r[o].end.column!==n)&&i.push(new s(r[o].end.row,r[o].end.column,t,n)),o===0?(r[o].start.row!==0||r[o].start.column!==0)&&i.push(new s(0,0,r[o].start.row,r[o].start.column)):i.push(new s(r[o-1].end.row,r[o-1].end.column,r[o].start.row,r[o].start.column));e.exitMultiSelectMode(),e.clearSelection();for(var o=0;o<i.length;o++)e.selection.addRange(i[o],!1)},readOnly:!0,scrollIntoView:"none"},{name:"addLineAfter",exec:function(e){e.selection.clearSelection(),e.navigateLineEnd(),e.insert("\n")},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"addLineBefore",exec:function(e){e.selection.clearSelection();var t=e.getCursorPosition();e.selection.moveTo(t.row-1,Number.MAX_VALUE),e.insert("\n"),t.row===0&&e.navigateUp()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"openCommandPallete",description:"Open command pallete",bindKey:o("F1","F1"),exec:function(e){e.prompt({$type:"commands"})},readOnly:!0},{name:"modeSelect",description:"Change language mode...",bindKey:o(null,null),exec:function(e){e.prompt({$type:"modes"})},readOnly:!0}];for(var u=1;u<9;u++)t.commands.push({name:"foldToLevel"+u,description:"Fold To Level "+u,level:u,exec:function(e){e.session.foldToLevel(this.level)},scrollIntoView:"center",readOnly:!0})}),ace.define("ace/editor",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/keyboard/textinput","ace/mouse/mouse_handler","ace/mouse/fold_handler","ace/keyboard/keybinding","ace/edit_session","ace/search","ace/range","ace/lib/event_emitter","ace/commands/command_manager","ace/commands/default_commands","ace/config","ace/token_iterator","ace/clipboard"],function(e,t,n){"use strict";e("./lib/fixoldbrowsers");var r=e("./lib/oop"),i=e("./lib/dom"),s=e("./lib/lang"),o=e("./lib/useragent"),u=e("./keyboard/textinput").TextInput,a=e("./mouse/mouse_handler").MouseHandler,f=e("./mouse/fold_handler").FoldHandler,l=e("./keyboard/keybinding").KeyBinding,c=e("./edit_session").EditSession,h=e("./search").Search,p=e("./range").Range,d=e("./lib/event_emitter").EventEmitter,v=e("./commands/command_manager").CommandManager,m=e("./commands/default_commands").commands,g=e("./config"),y=e("./token_iterator").TokenIterator,b=e("./clipboard"),w=function(e,t,n){this.$toDestroy=[];var r=e.getContainerElement();this.container=r,this.renderer=e,this.id="editor"+ ++w.$uid,this.commands=new v(o.isMac?"mac":"win",m),typeof document=="object"&&(this.textInput=new u(e.getTextAreaContainer(),this),this.renderer.textarea=this.textInput.getElement(),this.$mouseHandler=new a(this),new f(this)),this.keyBinding=new l(this),this.$search=(new h).set({wrap:!0}),this.$historyTracker=this.$historyTracker.bind(this),this.commands.on("exec",this.$historyTracker),this.$initOperationListeners(),this._$emitInputEvent=s.delayedCall(function(){this._signal("input",{}),this.session&&this.session.bgTokenizer&&this.session.bgTokenizer.scheduleStart()}.bind(this)),this.on("change",function(e,t){t._$emitInputEvent.schedule(31)}),this.setSession(t||n&&n.session||new c("")),g.resetOptions(this),n&&this.setOptions(n),g._signal("editor",this)};w.$uid=0,function(){r.implement(this,d),this.$initOperationListeners=function(){this.commands.on("exec",this.startOperation.bind(this),!0),this.commands.on("afterExec",this.endOperation.bind(this),!0),this.$opResetTimer=s.delayedCall(this.endOperation.bind(this,!0)),this.on("change",function(){this.curOp||(this.startOperation(),this.curOp.selectionBefore=this.$lastSel),this.curOp.docChanged=!0}.bind(this),!0),this.on("changeSelection",function(){this.curOp||(this.startOperation(),this.curOp.selectionBefore=this.$lastSel),this.curOp.selectionChanged=!0}.bind(this),!0)},this.curOp=null,this.prevOp={},this.startOperation=function(e){if(this.curOp){if(!e||this.curOp.command)return;this.prevOp=this.curOp}e||(this.previousCommand=null,e={}),this.$opResetTimer.schedule(),this.curOp=this.session.curOp={command:e.command||{},args:e.args,scrollTop:this.renderer.scrollTop},this.curOp.selectionBefore=this.selection.toJSON()},this.endOperation=function(e){if(this.curOp&&this.session){if(e&&e.returnValue===!1||!this.session)return this.curOp=null;if(e==1&&this.curOp.command&&this.curOp.command.name=="mouse")return;this._signal("beforeEndOperation");if(!this.curOp)return;var t=this.curOp.command,n=t&&t.scrollIntoView;if(n){switch(n){case"center-animate":n="animate";case"center":this.renderer.scrollCursorIntoView(null,.5);break;case"animate":case"cursor":this.renderer.scrollCursorIntoView();break;case"selectionPart":var r=this.selection.getRange(),i=this.renderer.layerConfig;(r.start.row>=i.lastRow||r.end.row<=i.firstRow)&&this.renderer.scrollSelectionIntoView(this.selection.anchor,this.selection.lead);break;default:}n=="animate"&&this.renderer.animateScrolling(this.curOp.scrollTop)}var s=this.selection.toJSON();this.curOp.selectionAfter=s,this.$lastSel=this.selection.toJSON(),this.session.getUndoManager().addSelection(s),this.prevOp=this.curOp,this.curOp=null}},this.$mergeableCommands=["backspace","del","insertstring"],this.$historyTracker=function(e){if(!this.$mergeUndoDeltas)return;var t=this.prevOp,n=this.$mergeableCommands,r=t.command&&e.command.name==t.command.name;if(e.command.name=="insertstring"){var i=e.args;this.mergeNextCommand===undefined&&(this.mergeNextCommand=!0),r=r&&this.mergeNextCommand&&(!/\s/.test(i)||/\s/.test(t.args)),this.mergeNextCommand=!0}else r=r&&n.indexOf(e.command.name)!==-1;this.$mergeUndoDeltas!="always"&&Date.now()-this.sequenceStartTime>2e3&&(r=!1),r?this.session.mergeUndoDeltas=!0:n.indexOf(e.command.name)!==-1&&(this.sequenceStartTime=Date.now())},this.setKeyboardHandler=function(e,t){if(e&&typeof e=="string"&&e!="ace"){this.$keybindingId=e;var n=this;g.loadModule(["keybinding",e],function(r){n.$keybindingId==e&&n.keyBinding.setKeyboardHandler(r&&r.handler),t&&t()})}else this.$keybindingId=null,this.keyBinding.setKeyboardHandler(e),t&&t()},this.getKeyboardHandler=function(){return this.keyBinding.getKeyboardHandler()},this.setSession=function(e){if(this.session==e)return;this.curOp&&this.endOperation(),this.curOp={};var t=this.session;if(t){this.session.off("change",this.$onDocumentChange),this.session.off("changeMode",this.$onChangeMode),this.session.off("tokenizerUpdate",this.$onTokenizerUpdate),this.session.off("changeTabSize",this.$onChangeTabSize),this.session.off("changeWrapLimit",this.$onChangeWrapLimit),this.session.off("changeWrapMode",this.$onChangeWrapMode),this.session.off("changeFold",this.$onChangeFold),this.session.off("changeFrontMarker",this.$onChangeFrontMarker),this.session.off("changeBackMarker",this.$onChangeBackMarker),this.session.off("changeBreakpoint",this.$onChangeBreakpoint),this.session.off("changeAnnotation",this.$onChangeAnnotation),this.session.off("changeOverwrite",this.$onCursorChange),this.session.off("changeScrollTop",this.$onScrollTopChange),this.session.off("changeScrollLeft",this.$onScrollLeftChange);var n=this.session.getSelection();n.off("changeCursor",this.$onCursorChange),n.off("changeSelection",this.$onSelectionChange)}this.session=e,e?(this.$onDocumentChange=this.onDocumentChange.bind(this),e.on("change",this.$onDocumentChange),this.renderer.setSession(e),this.$onChangeMode=this.onChangeMode.bind(this),e.on("changeMode",this.$onChangeMode),this.$onTokenizerUpdate=this.onTokenizerUpdate.bind(this),e.on("tokenizerUpdate",this.$onTokenizerUpdate),this.$onChangeTabSize=this.renderer.onChangeTabSize.bind(this.renderer),e.on("changeTabSize",this.$onChangeTabSize),this.$onChangeWrapLimit=this.onChangeWrapLimit.bind(this),e.on("changeWrapLimit",this.$onChangeWrapLimit),this.$onChangeWrapMode=this.onChangeWrapMode.bind(this),e.on("changeWrapMode",this.$onChangeWrapMode),this.$onChangeFold=this.onChangeFold.bind(this),e.on("changeFold",this.$onChangeFold),this.$onChangeFrontMarker=this.onChangeFrontMarker.bind(this),this.session.on("changeFrontMarker",this.$onChangeFrontMarker),this.$onChangeBackMarker=this.onChangeBackMarker.bind(this),this.session.on("changeBackMarker",this.$onChangeBackMarker),this.$onChangeBreakpoint=this.onChangeBreakpoint.bind(this),this.session.on("changeBreakpoint",this.$onChangeBreakpoint),this.$onChangeAnnotation=this.onChangeAnnotation.bind(this),this.session.on("changeAnnotation",this.$onChangeAnnotation),this.$onCursorChange=this.onCursorChange.bind(this),this.session.on("changeOverwrite",this.$onCursorChange),this.$onScrollTopChange=this.onScrollTopChange.bind(this),this.session.on("changeScrollTop",this.$onScrollTopChange),this.$onScrollLeftChange=this.onScrollLeftChange.bind(this),this.session.on("changeScrollLeft",this.$onScrollLeftChange),this.selection=e.getSelection(),this.selection.on("changeCursor",this.$onCursorChange),this.$onSelectionChange=this.onSelectionChange.bind(this),this.selection.on("changeSelection",this.$onSelectionChange),this.onChangeMode(),this.onCursorChange(),this.onScrollTopChange(),this.onScrollLeftChange(),this.onSelectionChange(),this.onChangeFrontMarker(),this.onChangeBackMarker(),this.onChangeBreakpoint(),this.onChangeAnnotation(),this.session.getUseWrapMode()&&this.renderer.adjustWrapLimit(),this.renderer.updateFull()):(this.selection=null,this.renderer.setSession(e)),this._signal("changeSession",{session:e,oldSession:t}),this.curOp=null,t&&t._signal("changeEditor",{oldEditor:this}),e&&e._signal("changeEditor",{editor:this}),e&&e.bgTokenizer&&e.bgTokenizer.scheduleStart()},this.getSession=function(){return this.session},this.setValue=function(e,t){return this.session.doc.setValue(e),t?t==1?this.navigateFileEnd():t==-1&&this.navigateFileStart():this.selectAll(),e},this.getValue=function(){return this.session.getValue()},this.getSelection=function(){return this.selection},this.resize=function(e){this.renderer.onResize(e)},this.setTheme=function(e,t){this.renderer.setTheme(e,t)},this.getTheme=function(){return this.renderer.getTheme()},this.setStyle=function(e){this.renderer.setStyle(e)},this.unsetStyle=function(e){this.renderer.unsetStyle(e)},this.getFontSize=function(){return this.getOption("fontSize")||i.computedStyle(this.container).fontSize},this.setFontSize=function(e){this.setOption("fontSize",e)},this.$highlightBrackets=function(){if(this.$highlightPending)return;var e=this;this.$highlightPending=!0,setTimeout(function(){e.$highlightPending=!1;var t=e.session;if(!t||!t.bgTokenizer)return;t.$bracketHighlight&&(t.$bracketHighlight.markerIds.forEach(function(e){t.removeMarker(e)}),t.$bracketHighlight=null);var n=t.getMatchingBracketRanges(e.getCursorPosition());!n&&t.$mode.getMatching&&(n=t.$mode.getMatching(e.session));if(!n)return;var r="ace_bracket";Array.isArray(n)?n.length==1&&(r="ace_error_bracket"):n=[n],n.length==2&&(p.comparePoints(n[0].end,n[1].start)==0?n=[p.fromPoints(n[0].start,n[1].end)]:p.comparePoints(n[0].start,n[1].end)==0&&(n=[p.fromPoints(n[1].start,n[0].end)])),t.$bracketHighlight={ranges:n,markerIds:n.map(function(e){return t.addMarker(e,r,"text")})}},50)},this.$highlightTags=function(){if(this.$highlightTagPending)return;var e=this;this.$highlightTagPending=!0,setTimeout(function(){e.$highlightTagPending=!1;var t=e.session;if(!t||!t.bgTokenizer)return;var n=e.getCursorPosition(),r=new y(e.session,n.row,n.column),i=r.getCurrentToken();if(!i||!/\b(?:tag-open|tag-name)/.test(i.type)){t.removeMarker(t.$tagHighlight),t.$tagHighlight=null;return}if(i.type.indexOf("tag-open")!==-1){i=r.stepForward();if(!i)return}var s=i.value,o=i.value,u=0,a=r.stepBackward();if(a.value==="<"){do a=i,i=r.stepForward(),i&&(i.type.indexOf("tag-name")!==-1?(o=i.value,s===o&&(a.value==="<"?u++:a.value==="</"&&u--)):s===o&&i.value==="/>"&&u--);while(i&&u>=0)}else{do{i=a,a=r.stepBackward();if(i)if(i.type.indexOf("tag-name")!==-1)s===i.value&&(a.value==="<"?u++:a.value==="</"&&u--);else if(i.value==="/>"){var f=0,l=a;while(l){if(l.type.indexOf("tag-name")!==-1&&l.value===s){u--;break}if(l.value==="<")break;l=r.stepBackward(),f++}for(var c=0;c<f;c++)r.stepForward()}}while(a&&u<=0);r.stepForward()}if(!i){t.removeMarker(t.$tagHighlight),t.$tagHighlight=null;return}var h=r.getCurrentTokenRow(),d=r.getCurrentTokenColumn(),v=new p(h,d,h,d+i.value.length),m=t.$backMarkers[t.$tagHighlight];t.$tagHighlight&&m!=undefined&&v.compareRange(m.range)!==0&&(t.removeMarker(t.$tagHighlight),t.$tagHighlight=null),t.$tagHighlight||(t.$tagHighlight=t.addMarker(v,"ace_bracket","text"))},50)},this.focus=function(){var e=this;setTimeout(function(){e.isFocused()||e.textInput.focus()}),this.textInput.focus()},this.isFocused=function(){return this.textInput.isFocused()},this.blur=function(){this.textInput.blur()},this.onFocus=function(e){if(this.$isFocused)return;this.$isFocused=!0,this.renderer.showCursor(),this.renderer.visualizeFocus(),this._emit("focus",e)},this.onBlur=function(e){if(!this.$isFocused)return;this.$isFocused=!1,this.renderer.hideCursor(),this.renderer.visualizeBlur(),this._emit("blur",e)},this.$cursorChange=function(){this.renderer.updateCursor(),this.$highlightBrackets(),this.$highlightTags(),this.$updateHighlightActiveLine()},this.onDocumentChange=function(e){var t=this.session.$useWrapMode,n=e.start.row==e.end.row?e.end.row:Infinity;this.renderer.updateLines(e.start.row,n,t),this._signal("change",e),this.$cursorChange()},this.onTokenizerUpdate=function(e){var t=e.data;this.renderer.updateLines(t.first,t.last)},this.onScrollTopChange=function(){this.renderer.scrollToY(this.session.getScrollTop())},this.onScrollLeftChange=function(){this.renderer.scrollToX(this.session.getScrollLeft())},this.onCursorChange=function(){this.$cursorChange(),this._signal("changeSelection")},this.$updateHighlightActiveLine=function(){var e=this.getSession(),t;if(this.$highlightActiveLine){if(this.$selectionStyle!="line"||!this.selection.isMultiLine())t=this.getCursorPosition();this.renderer.theme&&this.renderer.theme.$selectionColorConflict&&!this.selection.isEmpty()&&(t=!1),this.renderer.$maxLines&&this.session.getLength()===1&&!(this.renderer.$minLines>1)&&(t=!1)}if(e.$highlightLineMarker&&!t)e.removeMarker(e.$highlightLineMarker.id),e.$highlightLineMarker=null;else if(!e.$highlightLineMarker&&t){var n=new p(t.row,t.column,t.row,Infinity);n.id=e.addMarker(n,"ace_active-line","screenLine"),e.$highlightLineMarker=n}else t&&(e.$highlightLineMarker.start.row=t.row,e.$highlightLineMarker.end.row=t.row,e.$highlightLineMarker.start.column=t.column,e._signal("changeBackMarker"))},this.onSelectionChange=function(e){var t=this.session;t.$selectionMarker&&t.removeMarker(t.$selectionMarker),t.$selectionMarker=null;if(!this.selection.isEmpty()){var n=this.selection.getRange(),r=this.getSelectionStyle();t.$selectionMarker=t.addMarker(n,"ace_selection",r)}else this.$updateHighlightActiveLine();var i=this.$highlightSelectedWord&&this.$getSelectionHighLightRegexp();this.session.highlight(i),this._signal("changeSelection")},this.$getSelectionHighLightRegexp=function(){var e=this.session,t=this.getSelectionRange();if(t.isEmpty()||t.isMultiLine())return;var n=t.start.column,r=t.end.column,i=e.getLine(t.start.row),s=i.substring(n,r);if(s.length>5e3||!/[\w\d]/.test(s))return;var o=this.$search.$assembleRegExp({wholeWord:!0,caseSensitive:!0,needle:s}),u=i.substring(n-1,r+1);if(!o.test(u))return;return o},this.onChangeFrontMarker=function(){this.renderer.updateFrontMarkers()},this.onChangeBackMarker=function(){this.renderer.updateBackMarkers()},this.onChangeBreakpoint=function(){this.renderer.updateBreakpoints()},this.onChangeAnnotation=function(){this.renderer.setAnnotations(this.session.getAnnotations())},this.onChangeMode=function(e){this.renderer.updateText(),this._emit("changeMode",e)},this.onChangeWrapLimit=function(){this.renderer.updateFull()},this.onChangeWrapMode=function(){this.renderer.onResize(!0)},this.onChangeFold=function(){this.$updateHighlightActiveLine(),this.renderer.updateFull()},this.getSelectedText=function(){return this.session.getTextRange(this.getSelectionRange())},this.getCopyText=function(){var e=this.getSelectedText(),t=this.session.doc.getNewLineCharacter(),n=!1;if(!e&&this.$copyWithEmptySelection){n=!0;var r=this.selection.getAllRanges();for(var i=0;i<r.length;i++){var s=r[i];if(i&&r[i-1].start.row==s.start.row)continue;e+=this.session.getLine(s.start.row)+t}}var o={text:e};return this._signal("copy",o),b.lineMode=n?o.text:"",o.text},this.onCopy=function(){this.commands.exec("copy",this)},this.onCut=function(){this.commands.exec("cut",this)},this.onPaste=function(e,t){var n={text:e,event:t};this.commands.exec("paste",this,n)},this.$handlePaste=function(e){typeof e=="string"&&(e={text:e}),this._signal("paste",e);var t=e.text,n=t==b.lineMode,r=this.session;if(!this.inMultiSelectMode||this.inVirtualSelectionMode)n?r.insert({row:this.selection.lead.row,column:0},t):this.insert(t);else if(n)this.selection.rangeList.ranges.forEach(function(e){r.insert({row:e.start.row,column:0},t)});else{var i=t.split(/\r\n|\r|\n/),s=this.selection.rangeList.ranges,o=i.length==2&&(!i[0]||!i[1]);if(i.length!=s.length||o)return this.commands.exec("insertstring",this,t);for(var u=s.length;u--;){var a=s[u];a.isEmpty()||r.remove(a),r.insert(a.start,i[u])}}},this.execCommand=function(e,t){return this.commands.exec(e,this,t)},this.insert=function(e,t){var n=this.session,r=n.getMode(),i=this.getCursorPosition();if(this.getBehavioursEnabled()&&!t){var s=r.transformAction(n.getState(i.row),"insertion",this,n,e);s&&(e!==s.text&&(this.inVirtualSelectionMode||(this.session.mergeUndoDeltas=!1,this.mergeNextCommand=!1)),e=s.text)}e==" "&&(e=this.session.getTabString());if(!this.selection.isEmpty()){var o=this.getSelectionRange();i=this.session.remove(o),this.clearSelection()}else if(this.session.getOverwrite()&&e.indexOf("\n")==-1){var o=new p.fromPoints(i,i);o.end.column+=e.length,this.session.remove(o)}if(e=="\n"||e=="\r\n"){var u=n.getLine(i.row);if(i.column>u.search(/\S|$/)){var a=u.substr(i.column).search(/\S|$/);n.doc.removeInLine(i.row,i.column,i.column+a)}}this.clearSelection();var f=i.column,l=n.getState(i.row),u=n.getLine(i.row),c=r.checkOutdent(l,u,e);n.insert(i,e),s&&s.selection&&(s.selection.length==2?this.selection.setSelectionRange(new p(i.row,f+s.selection[0],i.row,f+s.selection[1])):this.selection.setSelectionRange(new p(i.row+s.selection[0],s.selection[1],i.row+s.selection[2],s.selection[3])));if(this.$enableAutoIndent){if(n.getDocument().isNewLine(e)){var h=r.getNextLineIndent(l,u.slice(0,i.column),n.getTabString());n.insert({row:i.row+1,column:0},h)}c&&r.autoOutdent(l,n,i.row)}},this.autoIndent=function(){var e=this.session,t=e.getMode(),n,r;if(this.selection.isEmpty())n=0,r=e.doc.getLength()-1;else{var i=this.getSelectionRange();n=i.start.row,r=i.end.row}var s="",o="",u="",a,f,l,c=e.getTabString();for(var h=n;h<=r;h++)h>0&&(s=e.getState(h-1),o=e.getLine(h-1),u=t.getNextLineIndent(s,o,c)),a=e.getLine(h),f=t.$getIndent(a),u!==f&&(f.length>0&&(l=new p(h,0,h,f.length),e.remove(l)),u.length>0&&e.insert({row:h,column:0},u)),t.autoOutdent(s,e,h)},this.onTextInput=function(e,t){if(!t)return this.keyBinding.onTextInput(e);this.startOperation({command:{name:"insertstring"}});var n=this.applyComposition.bind(this,e,t);this.selection.rangeCount?this.forEachSelection(n):n(),this.endOperation()},this.applyComposition=function(e,t){if(t.extendLeft||t.extendRight){var n=this.selection.getRange();n.start.column-=t.extendLeft,n.end.column+=t.extendRight,n.start.column<0&&(n.start.row--,n.start.column+=this.session.getLine(n.start.row).length+1),this.selection.setRange(n),!e&&!n.isEmpty()&&this.remove()}(e||!this.selection.isEmpty())&&this.insert(e,!0);if(t.restoreStart||t.restoreEnd){var n=this.selection.getRange();n.start.column-=t.restoreStart,n.end.column-=t.restoreEnd,this.selection.setRange(n)}},this.onCommandKey=function(e,t,n){return this.keyBinding.onCommandKey(e,t,n)},this.setOverwrite=function(e){this.session.setOverwrite(e)},this.getOverwrite=function(){return this.session.getOverwrite()},this.toggleOverwrite=function(){this.session.toggleOverwrite()},this.setScrollSpeed=function(e){this.setOption("scrollSpeed",e)},this.getScrollSpeed=function(){return this.getOption("scrollSpeed")},this.setDragDelay=function(e){this.setOption("dragDelay",e)},this.getDragDelay=function(){return this.getOption("dragDelay")},this.setSelectionStyle=function(e){this.setOption("selectionStyle",e)},this.getSelectionStyle=function(){return this.getOption("selectionStyle")},this.setHighlightActiveLine=function(e){this.setOption("highlightActiveLine",e)},this.getHighlightActiveLine=function(){return this.getOption("highlightActiveLine")},this.setHighlightGutterLine=function(e){this.setOption("highlightGutterLine",e)},this.getHighlightGutterLine=function(){return this.getOption("highlightGutterLine")},this.setHighlightSelectedWord=function(e){this.setOption("highlightSelectedWord",e)},this.getHighlightSelectedWord=function(){return this.$highlightSelectedWord},this.setAnimatedScroll=function(e){this.renderer.setAnimatedScroll(e)},this.getAnimatedScroll=function(){return this.renderer.getAnimatedScroll()},this.setShowInvisibles=function(e){this.renderer.setShowInvisibles(e)},this.getShowInvisibles=function(){return this.renderer.getShowInvisibles()},this.setDisplayIndentGuides=function(e){this.renderer.setDisplayIndentGuides(e)},this.getDisplayIndentGuides=function(){return this.renderer.getDisplayIndentGuides()},this.setShowPrintMargin=function(e){this.renderer.setShowPrintMargin(e)},this.getShowPrintMargin=function(){return this.renderer.getShowPrintMargin()},this.setPrintMarginColumn=function(e){this.renderer.setPrintMarginColumn(e)},this.getPrintMarginColumn=function(){return this.renderer.getPrintMarginColumn()},this.setReadOnly=function(e){this.setOption("readOnly",e)},this.getReadOnly=function(){return this.getOption("readOnly")},this.setBehavioursEnabled=function(e){this.setOption("behavioursEnabled",e)},this.getBehavioursEnabled=function(){return this.getOption("behavioursEnabled")},this.setWrapBehavioursEnabled=function(e){this.setOption("wrapBehavioursEnabled",e)},this.getWrapBehavioursEnabled=function(){return this.getOption("wrapBehavioursEnabled")},this.setShowFoldWidgets=function(e){this.setOption("showFoldWidgets",e)},this.getShowFoldWidgets=function(){return this.getOption("showFoldWidgets")},this.setFadeFoldWidgets=function(e){this.setOption("fadeFoldWidgets",e)},this.getFadeFoldWidgets=function(){return this.getOption("fadeFoldWidgets")},this.remove=function(e){this.selection.isEmpty()&&(e=="left"?this.selection.selectLeft():this.selection.selectRight());var t=this.getSelectionRange();if(this.getBehavioursEnabled()){var n=this.session,r=n.getState(t.start.row),i=n.getMode().transformAction(r,"deletion",this,n,t);if(t.end.column===0){var s=n.getTextRange(t);if(s[s.length-1]=="\n"){var o=n.getLine(t.end.row);/^\s+$/.test(o)&&(t.end.column=o.length)}}i&&(t=i)}this.session.remove(t),this.clearSelection()},this.removeWordRight=function(){this.selection.isEmpty()&&this.selection.selectWordRight(),this.session.remove(this.getSelectionRange()),this.clearSelection()},this.removeWordLeft=function(){this.selection.isEmpty()&&this.selection.selectWordLeft(),this.session.remove(this.getSelectionRange()),this.clearSelection()},this.removeToLineStart=function(){this.selection.isEmpty()&&this.selection.selectLineStart(),this.selection.isEmpty()&&this.selection.selectLeft(),this.session.remove(this.getSelectionRange()),this.clearSelection()},this.removeToLineEnd=function(){this.selection.isEmpty()&&this.selection.selectLineEnd();var e=this.getSelectionRange();e.start.column==e.end.column&&e.start.row==e.end.row&&(e.end.column=0,e.end.row++),this.session.remove(e),this.clearSelection()},this.splitLine=function(){this.selection.isEmpty()||(this.session.remove(this.getSelectionRange()),this.clearSelection());var e=this.getCursorPosition();this.insert("\n"),this.moveCursorToPosition(e)},this.transposeLetters=function(){if(!this.selection.isEmpty())return;var e=this.getCursorPosition(),t=e.column;if(t===0)return;var n=this.session.getLine(e.row),r,i;t<n.length?(r=n.charAt(t)+n.charAt(t-1),i=new p(e.row,t-1,e.row,t+1)):(r=n.charAt(t-1)+n.charAt(t-2),i=new p(e.row,t-2,e.row,t)),this.session.replace(i,r),this.session.selection.moveToPosition(i.end)},this.toLowerCase=function(){var e=this.getSelectionRange();this.selection.isEmpty()&&this.selection.selectWord();var t=this.getSelectionRange(),n=this.session.getTextRange(t);this.session.replace(t,n.toLowerCase()),this.selection.setSelectionRange(e)},this.toUpperCase=function(){var e=this.getSelectionRange();this.selection.isEmpty()&&this.selection.selectWord();var t=this.getSelectionRange(),n=this.session.getTextRange(t);this.session.replace(t,n.toUpperCase()),this.selection.setSelectionRange(e)},this.indent=function(){var e=this.session,t=this.getSelectionRange();if(t.start.row<t.end.row){var n=this.$getSelectedRows();e.indentRows(n.first,n.last," ");return}if(t.start.column<t.end.column){var r=e.getTextRange(t);if(!/^\s+$/.test(r)){var n=this.$getSelectedRows();e.indentRows(n.first,n.last," ");return}}var i=e.getLine(t.start.row),o=t.start,u=e.getTabSize(),a=e.documentToScreenColumn(o.row,o.column);if(this.session.getUseSoftTabs())var f=u-a%u,l=s.stringRepeat(" ",f);else{var f=a%u;while(i[t.start.column-1]==" "&&f)t.start.column--,f--;this.selection.setSelectionRange(t),l=" "}return this.insert(l)},this.blockIndent=function(){var e=this.$getSelectedRows();this.session.indentRows(e.first,e.last," ")},this.blockOutdent=function(){var e=this.session.getSelection();this.session.outdentRows(e.getRange())},this.sortLines=function(){var e=this.$getSelectedRows(),t=this.session,n=[];for(var r=e.first;r<=e.last;r++)n.push(t.getLine(r));n.sort(function(e,t){return e.toLowerCase()<t.toLowerCase()?-1:e.toLowerCase()>t.toLowerCase()?1:0});var i=new p(0,0,0,0);for(var r=e.first;r<=e.last;r++){var s=t.getLine(r);i.start.row=r,i.end.row=r,i.end.column=s.length,t.replace(i,n[r-e.first])}},this.toggleCommentLines=function(){var e=this.session.getState(this.getCursorPosition().row),t=this.$getSelectedRows();this.session.getMode().toggleCommentLines(e,this.session,t.first,t.last)},this.toggleBlockComment=function(){var e=this.getCursorPosition(),t=this.session.getState(e.row),n=this.getSelectionRange();this.session.getMode().toggleBlockComment(t,this.session,n,e)},this.getNumberAt=function(e,t){var n=/[\-]?[0-9]+(?:\.[0-9]+)?/g;n.lastIndex=0;var r=this.session.getLine(e);while(n.lastIndex<t){var i=n.exec(r);if(i.index<=t&&i.index+i[0].length>=t){var s={value:i[0],start:i.index,end:i.index+i[0].length};return s}}return null},this.modifyNumber=function(e){var t=this.selection.getCursor().row,n=this.selection.getCursor().column,r=new p(t,n-1,t,n),i=this.session.getTextRange(r);if(!isNaN(parseFloat(i))&&isFinite(i)){var s=this.getNumberAt(t,n);if(s){var o=s.value.indexOf(".")>=0?s.start+s.value.indexOf(".")+1:s.end,u=s.start+s.value.length-o,a=parseFloat(s.value);a*=Math.pow(10,u),o!==s.end&&n<o?e*=Math.pow(10,s.end-n-1):e*=Math.pow(10,s.end-n),a+=e,a/=Math.pow(10,u);var f=a.toFixed(u),l=new p(t,s.start,t,s.end);this.session.replace(l,f),this.moveCursorTo(t,Math.max(s.start+1,n+f.length-s.value.length))}}else this.toggleWord()},this.$toggleWordPairs=[["first","last"],["true","false"],["yes","no"],["width","height"],["top","bottom"],["right","left"],["on","off"],["x","y"],["get","set"],["max","min"],["horizontal","vertical"],["show","hide"],["add","remove"],["up","down"],["before","after"],["even","odd"],["in","out"],["inside","outside"],["next","previous"],["increase","decrease"],["attach","detach"],["&&","||"],["==","!="]],this.toggleWord=function(){var e=this.selection.getCursor().row,t=this.selection.getCursor().column;this.selection.selectWord();var n=this.getSelectedText(),r=this.selection.getWordRange().start.column,i=n.replace(/([a-z]+|[A-Z]+)(?=[A-Z_]|$)/g,"$1 ").split(/\s/),o=t-r-1;o<0&&(o=0);var u=0,a=0,f=this;n.match(/[A-Za-z0-9_]+/)&&i.forEach(function(t,i){a=u+t.length,o>=u&&o<=a&&(n=t,f.selection.clearSelection(),f.moveCursorTo(e,u+r),f.selection.selectTo(e,a+r)),u=a});var l=this.$toggleWordPairs,c;for(var h=0;h<l.length;h++){var p=l[h];for(var d=0;d<=1;d++){var v=+!d,m=n.match(new RegExp("^\\s?_?("+s.escapeRegExp(p[d])+")\\s?$","i"));if(m){var g=n.match(new RegExp("([_]|^|\\s)("+s.escapeRegExp(m[1])+")($|\\s)","g"));g&&(c=n.replace(new RegExp(s.escapeRegExp(p[d]),"i"),function(e){var t=p[v];return e.toUpperCase()==e?t=t.toUpperCase():e.charAt(0).toUpperCase()==e.charAt(0)&&(t=t.substr(0,0)+p[v].charAt(0).toUpperCase()+t.substr(1)),t}),this.insert(c),c="")}}}},this.removeLines=function(){var e=this.$getSelectedRows();this.session.removeFullLines(e.first,e.last),this.clearSelection()},this.duplicateSelection=function(){var e=this.selection,t=this.session,n=e.getRange(),r=e.isBackwards();if(n.isEmpty()){var i=n.start.row;t.duplicateLines(i,i)}else{var s=r?n.start:n.end,o=t.insert(s,t.getTextRange(n),!1);n.start=s,n.end=o,e.setSelectionRange(n,r)}},this.moveLinesDown=function(){this.$moveLines(1,!1)},this.moveLinesUp=function(){this.$moveLines(-1,!1)},this.moveText=function(e,t,n){return this.session.moveText(e,t,n)},this.copyLinesUp=function(){this.$moveLines(-1,!0)},this.copyLinesDown=function(){this.$moveLines(1,!0)},this.$moveLines=function(e,t){var n,r,i=this.selection;if(!i.inMultiSelectMode||this.inVirtualSelectionMode){var s=i.toOrientedRange();n=this.$getSelectedRows(s),r=this.session.$moveLines(n.first,n.last,t?0:e),t&&e==-1&&(r=0),s.moveBy(r,0),i.fromOrientedRange(s)}else{var o=i.rangeList.ranges;i.rangeList.detach(this.session),this.inVirtualSelectionMode=!0;var u=0,a=0,f=o.length;for(var l=0;l<f;l++){var c=l;o[l].moveBy(u,0),n=this.$getSelectedRows(o[l]);var h=n.first,p=n.last;while(++l<f){a&&o[l].moveBy(a,0);var d=this.$getSelectedRows(o[l]);if(t&&d.first!=p)break;if(!t&&d.first>p+1)break;p=d.last}l--,u=this.session.$moveLines(h,p,t?0:e),t&&e==-1&&(c=l+1);while(c<=l)o[c].moveBy(u,0),c++;t||(u=0),a+=u}i.fromOrientedRange(i.ranges[0]),i.rangeList.attach(this.session),this.inVirtualSelectionMode=!1}},this.$getSelectedRows=function(e){return e=(e||this.getSelectionRange()).collapseRows(),{first:this.session.getRowFoldStart(e.start.row),last:this.session.getRowFoldEnd(e.end.row)}},this.onCompositionStart=function(e){this.renderer.showComposition(e)},this.onCompositionUpdate=function(e){this.renderer.setCompositionText(e)},this.onCompositionEnd=function(){this.renderer.hideComposition()},this.getFirstVisibleRow=function(){return this.renderer.getFirstVisibleRow()},this.getLastVisibleRow=function(){return this.renderer.getLastVisibleRow()},this.isRowVisible=function(e){return e>=this.getFirstVisibleRow()&&e<=this.getLastVisibleRow()},this.isRowFullyVisible=function(e){return e>=this.renderer.getFirstFullyVisibleRow()&&e<=this.renderer.getLastFullyVisibleRow()},this.$getVisibleRowCount=function(){return this.renderer.getScrollBottomRow()-this.renderer.getScrollTopRow()+1},this.$moveByPage=function(e,t){var n=this.renderer,r=this.renderer.layerConfig,i=e*Math.floor(r.height/r.lineHeight);t===!0?this.selection.$moveSelection(function(){this.moveCursorBy(i,0)}):t===!1&&(this.selection.moveCursorBy(i,0),this.selection.clearSelection());var s=n.scrollTop;n.scrollBy(0,i*r.lineHeight),t!=null&&n.scrollCursorIntoView(null,.5),n.animateScrolling(s)},this.selectPageDown=function(){this.$moveByPage(1,!0)},this.selectPageUp=function(){this.$moveByPage(-1,!0)},this.gotoPageDown=function(){this.$moveByPage(1,!1)},this.gotoPageUp=function(){this.$moveByPage(-1,!1)},this.scrollPageDown=function(){this.$moveByPage(1)},this.scrollPageUp=function(){this.$moveByPage(-1)},this.scrollToRow=function(e){this.renderer.scrollToRow(e)},this.scrollToLine=function(e,t,n,r){this.renderer.scrollToLine(e,t,n,r)},this.centerSelection=function(){var e=this.getSelectionRange(),t={row:Math.floor(e.start.row+(e.end.row-e.start.row)/2),column:Math.floor(e.start.column+(e.end.column-e.start.column)/2)};this.renderer.alignCursor(t,.5)},this.getCursorPosition=function(){return this.selection.getCursor()},this.getCursorPositionScreen=function(){return this.session.documentToScreenPosition(this.getCursorPosition())},this.getSelectionRange=function(){return this.selection.getRange()},this.selectAll=function(){this.selection.selectAll()},this.clearSelection=function(){this.selection.clearSelection()},this.moveCursorTo=function(e,t){this.selection.moveCursorTo(e,t)},this.moveCursorToPosition=function(e){this.selection.moveCursorToPosition(e)},this.jumpToMatching=function(e,t){var n=this.getCursorPosition(),r=new y(this.session,n.row,n.column),i=r.getCurrentToken(),s=i||r.stepForward();if(!s)return;var o,u=!1,a={},f=n.column-s.start,l,c={")":"(","(":"(","]":"[","[":"[","{":"{","}":"{"};do{if(s.value.match(/[{}()\[\]]/g))for(;f<s.value.length&&!u;f++){if(!c[s.value[f]])continue;l=c[s.value[f]]+"."+s.type.replace("rparen","lparen"),isNaN(a[l])&&(a[l]=0);switch(s.value[f]){case"(":case"[":case"{":a[l]++;break;case")":case"]":case"}":a[l]--,a[l]===-1&&(o="bracket",u=!0)}}else s.type.indexOf("tag-name")!==-1&&(isNaN(a[s.value])&&(a[s.value]=0),i.value==="<"?a[s.value]++:i.value==="</"&&a[s.value]--,a[s.value]===-1&&(o="tag",u=!0));u||(i=s,s=r.stepForward(),f=0)}while(s&&!u);if(!o)return;var h,d;if(o==="bracket"){h=this.session.getBracketRange(n);if(!h){h=new p(r.getCurrentTokenRow(),r.getCurrentTokenColumn()+f-1,r.getCurrentTokenRow(),r.getCurrentTokenColumn()+f-1),d=h.start;if(t||d.row===n.row&&Math.abs(d.column-n.column)<2)h=this.session.getBracketRange(d)}}else if(o==="tag"){if(!s||s.type.indexOf("tag-name")===-1)return;var v=s.value;h=new p(r.getCurrentTokenRow(),r.getCurrentTokenColumn()-2,r.getCurrentTokenRow(),r.getCurrentTokenColumn()-2);if(h.compare(n.row,n.column)===0){u=!1;do s=i,i=r.stepBackward(),i&&(i.type.indexOf("tag-close")!==-1&&h.setEnd(r.getCurrentTokenRow(),r.getCurrentTokenColumn()+1),s.value===v&&s.type.indexOf("tag-name")!==-1&&(i.value==="<"?a[v]++:i.value==="</"&&a[v]--,a[v]===0&&(u=!0)));while(i&&!u)}s&&s.type.indexOf("tag-name")&&(d=h.start,d.row==n.row&&Math.abs(d.column-n.column)<2&&(d=h.end))}d=h&&h.cursor||d,d&&(e?h&&t?this.selection.setRange(h):h&&h.isEqual(this.getSelectionRange())?this.clearSelection():this.selection.selectTo(d.row,d.column):this.selection.moveTo(d.row,d.column))},this.gotoLine=function(e,t,n){this.selection.clearSelection(),this.session.unfold({row:e-1,column:t||0}),this.exitMultiSelectMode&&this.exitMultiSelectMode(),this.moveCursorTo(e-1,t||0),this.isRowFullyVisible(e-1)||this.scrollToLine(e-1,!0,n)},this.navigateTo=function(e,t){this.selection.moveTo(e,t)},this.navigateUp=function(e){if(this.selection.isMultiLine()&&!this.selection.isBackwards()){var t=this.selection.anchor.getPosition();return this.moveCursorToPosition(t)}this.selection.clearSelection(),this.selection.moveCursorBy(-e||-1,0)},this.navigateDown=function(e){if(this.selection.isMultiLine()&&this.selection.isBackwards()){var t=this.selection.anchor.getPosition();return this.moveCursorToPosition(t)}this.selection.clearSelection(),this.selection.moveCursorBy(e||1,0)},this.navigateLeft=function(e){if(!this.selection.isEmpty()){var t=this.getSelectionRange().start;this.moveCursorToPosition(t)}else{e=e||1;while(e--)this.selection.moveCursorLeft()}this.clearSelection()},this.navigateRight=function(e){if(!this.selection.isEmpty()){var t=this.getSelectionRange().end;this.moveCursorToPosition(t)}else{e=e||1;while(e--)this.selection.moveCursorRight()}this.clearSelection()},this.navigateLineStart=function(){this.selection.moveCursorLineStart(),this.clearSelection()},this.navigateLineEnd=function(){this.selection.moveCursorLineEnd(),this.clearSelection()},this.navigateFileEnd=function(){this.selection.moveCursorFileEnd(),this.clearSelection()},this.navigateFileStart=function(){this.selection.moveCursorFileStart(),this.clearSelection()},this.navigateWordRight=function(){this.selection.moveCursorWordRight(),this.clearSelection()},this.navigateWordLeft=function(){this.selection.moveCursorWordLeft(),this.clearSelection()},this.replace=function(e,t){t&&this.$search.set(t);var n=this.$search.find(this.session),r=0;return n?(this.$tryReplace(n,e)&&(r=1),this.selection.setSelectionRange(n),this.renderer.scrollSelectionIntoView(n.start,n.end),r):r},this.replaceAll=function(e,t){t&&this.$search.set(t);var n=this.$search.findAll(this.session),r=0;if(!n.length)return r;var i=this.getSelectionRange();this.selection.moveTo(0,0);for(var s=n.length-1;s>=0;--s)this.$tryReplace(n[s],e)&&r++;return this.selection.setSelectionRange(i),r},this.$tryReplace=function(e,t){var n=this.session.getTextRange(e);return t=this.$search.replace(n,t),t!==null?(e.end=this.session.replace(e,t),e):null},this.getLastSearchOptions=function(){return this.$search.getOptions()},this.find=function(e,t,n){t||(t={}),typeof e=="string"||e instanceof RegExp?t.needle=e:typeof e=="object"&&r.mixin(t,e);var i=this.selection.getRange();t.needle==null&&(e=this.session.getTextRange(i)||this.$search.$options.needle,e||(i=this.session.getWordRange(i.start.row,i.start.column),e=this.session.getTextRange(i)),this.$search.set({needle:e})),this.$search.set(t),t.start||this.$search.set({start:i});var s=this.$search.find(this.session);if(t.preventScroll)return s;if(s)return this.revealRange(s,n),s;t.backwards?i.start=i.end:i.end=i.start,this.selection.setRange(i)},this.findNext=function(e,t){this.find({skipCurrent:!0,backwards:!1},e,t)},this.findPrevious=function(e,t){this.find(e,{skipCurrent:!0,backwards:!0},t)},this.revealRange=function(e,t){this.session.unfold(e),this.selection.setSelectionRange(e);var n=this.renderer.scrollTop;this.renderer.scrollSelectionIntoView(e.start,e.end,.5),t!==!1&&this.renderer.animateScrolling(n)},this.undo=function(){this.session.getUndoManager().undo(this.session),this.renderer.scrollCursorIntoView(null,.5)},this.redo=function(){this.session.getUndoManager().redo(this.session),this.renderer.scrollCursorIntoView(null,.5)},this.destroy=function(){this.$toDestroy&&(this.$toDestroy.forEach(function(e){e.destroy()}),this.$toDestroy=null),this.$mouseHandler&&this.$mouseHandler.destroy(),this.renderer.destroy(),this._signal("destroy",this),this.session&&this.session.destroy(),this._$emitInputEvent&&this._$emitInputEvent.cancel(),this.removeAllListeners()},this.setAutoScrollEditorIntoView=function(e){if(!e)return;var t,n=this,r=!1;this.$scrollAnchor||(this.$scrollAnchor=document.createElement("div"));var i=this.$scrollAnchor;i.style.cssText="position:absolute",this.container.insertBefore(i,this.container.firstChild);var s=this.on("changeSelection",function(){r=!0}),o=this.renderer.on("beforeRender",function(){r&&(t=n.renderer.container.getBoundingClientRect())}),u=this.renderer.on("afterRender",function(){if(r&&t&&(n.isFocused()||n.searchBox&&n.searchBox.isFocused())){var e=n.renderer,s=e.$cursorLayer.$pixelPos,o=e.layerConfig,u=s.top-o.offset;s.top>=0&&u+t.top<0?r=!0:s.top<o.height&&s.top+t.top+o.lineHeight>window.innerHeight?r=!1:r=null,r!=null&&(i.style.top=u+"px",i.style.left=s.left+"px",i.style.height=o.lineHeight+"px",i.scrollIntoView(r)),r=t=null}});this.setAutoScrollEditorIntoView=function(e){if(e)return;delete this.setAutoScrollEditorIntoView,this.off("changeSelection",s),this.renderer.off("afterRender",u),this.renderer.off("beforeRender",o)}},this.$resetCursorStyle=function(){var e=this.$cursorStyle||"ace",t=this.renderer.$cursorLayer;if(!t)return;t.setSmoothBlinking(/smooth/.test(e)),t.isBlinking=!this.$readOnly&&e!="wide",i.setCssClass(t.element,"ace_slim-cursors",/slim/.test(e))},this.prompt=function(e,t,n){var r=this;g.loadModule("./ext/prompt",function(i){i.prompt(r,e,t,n)})}}.call(w.prototype),g.defineOptions(w.prototype,"editor",{selectionStyle:{set:function(e){this.onSelectionChange(),this._signal("changeSelectionStyle",{data:e})},initialValue:"line"},highlightActiveLine:{set:function(){this.$updateHighlightActiveLine()},initialValue:!0},highlightSelectedWord:{set:function(e){this.$onSelectionChange()},initialValue:!0},readOnly:{set:function(e){this.textInput.setReadOnly(e),this.$resetCursorStyle()},initialValue:!1},copyWithEmptySelection:{set:function(e){this.textInput.setCopyWithEmptySelection(e)},initialValue:!1},cursorStyle:{set:function(e){this.$resetCursorStyle()},values:["ace","slim","smooth","wide"],initialValue:"ace"},mergeUndoDeltas:{values:[!1,!0,"always"],initialValue:!0},behavioursEnabled:{initialValue:!0},wrapBehavioursEnabled:{initialValue:!0},enableAutoIndent:{initialValue:!0},autoScrollEditorIntoView:{set:function(e){this.setAutoScrollEditorIntoView(e)}},keyboardHandler:{set:function(e){this.setKeyboardHandler(e)},get:function(){return this.$keybindingId},handlesSet:!0},value:{set:function(e){this.session.setValue(e)},get:function(){return this.getValue()},handlesSet:!0,hidden:!0},session:{set:function(e){this.setSession(e)},get:function(){return this.session},handlesSet:!0,hidden:!0},showLineNumbers:{set:function(e){this.renderer.$gutterLayer.setShowLineNumbers(e),this.renderer.$loop.schedule(this.renderer.CHANGE_GUTTER),e&&this.$relativeLineNumbers?E.attach(this):E.detach(this)},initialValue:!0},relativeLineNumbers:{set:function(e){this.$showLineNumbers&&e?E.attach(this):E.detach(this)}},placeholder:{set:function(e){this.$updatePlaceholder||(this.$updatePlaceholder=function(){var e=this.session&&(this.renderer.$composition||this.getValue());if(e&&this.renderer.placeholderNode)this.renderer.off("afterRender",this.$updatePlaceholder),i.removeCssClass(this.container,"ace_hasPlaceholder"),this.renderer.placeholderNode.remove(),this.renderer.placeholderNode=null;else if(!e&&!this.renderer.placeholderNode){this.renderer.on("afterRender",this.$updatePlaceholder),i.addCssClass(this.container,"ace_hasPlaceholder");var t=i.createElement("div");t.className="ace_placeholder",t.textContent=this.$placeholder||"",this.renderer.placeholderNode=t,this.renderer.content.appendChild(this.renderer.placeholderNode)}else!e&&this.renderer.placeholderNode&&(this.renderer.placeholderNode.textContent=this.$placeholder||"")}.bind(this),this.on("input",this.$updatePlaceholder)),this.$updatePlaceholder()}},hScrollBarAlwaysVisible:"renderer",vScrollBarAlwaysVisible:"renderer",highlightGutterLine:"renderer",animatedScroll:"renderer",showInvisibles:"renderer",showPrintMargin:"renderer",printMarginColumn:"renderer",printMargin:"renderer",fadeFoldWidgets:"renderer",showFoldWidgets:"renderer",displayIndentGuides:"renderer",showGutter:"renderer",fontSize:"renderer",fontFamily:"renderer",maxLines:"renderer",minLines:"renderer",scrollPastEnd:"renderer",fixedWidthGutter:"renderer",theme:"renderer",hasCssTransforms:"renderer",maxPixelHeight:"renderer",useTextareaForIME:"renderer",scrollSpeed:"$mouseHandler",dragDelay:"$mouseHandler",dragEnabled:"$mouseHandler",focusTimeout:"$mouseHandler",tooltipFollowsMouse:"$mouseHandler",firstLineNumber:"session",overwrite:"session",newLineMode:"session",useWorker:"session",useSoftTabs:"session",navigateWithinSoftTabs:"session",tabSize:"session",wrap:"session",indentedSoftWrap:"session",foldStyle:"session",mode:"session"});var E={getText:function(e,t){return(Math.abs(e.selection.lead.row-t)||t+1+(t<9?"\u00b7":""))+""},getWidth:function(e,t,n){return Math.max(t.toString().length,(n.lastRow+1).toString().length,2)*n.characterWidth},update:function(e,t){t.renderer.$loop.schedule(t.renderer.CHANGE_GUTTER)},attach:function(e){e.renderer.$gutterLayer.$renderer=this,e.on("changeSelection",this.update),this.update(null,e)},detach:function(e){e.renderer.$gutterLayer.$renderer==this&&(e.renderer.$gutterLayer.$renderer=null),e.off("changeSelection",this.update),this.update(null,e)}};t.Editor=w}),ace.define("ace/undomanager",["require","exports","module","ace/range"],function(e,t,n){"use strict";function i(e,t){for(var n=t;n--;){var r=e[n];if(r&&!r[0].ignore){while(n<t-1){var i=d(e[n],e[n+1]);e[n]=i[0],e[n+1]=i[1],n++}return!0}}}function a(e){var t=e.action=="insert",n=e.start,r=e.end,i=(r.row-n.row)*(t?1:-1),s=(r.column-n.column)*(t?1:-1);t&&(r=n);for(var o in this.marks){var a=this.marks[o],f=u(a,n);if(f<0)continue;if(f===0&&t){if(a.bias!=1){a.bias==-1;continue}f=1}var l=t?f:u(a,r);if(l>0){a.row+=i,a.column+=a.row==r.row?s:0;continue}!t&&l<=0&&(a.row=n.row,a.column=n.column,l===0&&(a.bias=1))}}function f(e){return{row:e.row,column:e.column}}function l(e){return{start:f(e.start),end:f(e.end),action:e.action,lines:e.lines.slice()}}function c(e){e=e||this;if(Array.isArray(e))return e.map(c).join("\n");var t="";e.action?(t=e.action=="insert"?"+":"-",t+="["+e.lines+"]"):e.value&&(Array.isArray(e.value)?t=e.value.map(h).join("\n"):t=h(e.value)),e.start&&(t+=h(e));if(e.id||e.rev)t+=" ("+(e.id||e.rev)+")";return t}function h(e){return e.start.row+":"+e.start.column+"=>"+e.end.row+":"+e.end.column}function p(e,t){var n=e.action=="insert",r=t.action=="insert";if(n&&r)if(o(t.start,e.end)>=0)m(t,e,-1);else{if(!(o(t.start,e.start)<=0))return null;m(e,t,1)}else if(n&&!r)if(o(t.start,e.end)>=0)m(t,e,-1);else{if(!(o(t.end,e.start)<=0))return null;m(e,t,-1)}else if(!n&&r)if(o(t.start,e.start)>=0)m(t,e,1);else{if(!(o(t.start,e.start)<=0))return null;m(e,t,1)}else if(!n&&!r)if(o(t.start,e.start)>=0)m(t,e,1);else{if(!(o(t.end,e.start)<=0))return null;m(e,t,-1)}return[t,e]}function d(e,t){for(var n=e.length;n--;)for(var r=0;r<t.length;r++)if(!p(e[n],t[r])){while(n<e.length){while(r--)p(t[r],e[n]);r=t.length,n++}return[e,t]}return e.selectionBefore=t.selectionBefore=e.selectionAfter=t.selectionAfter=null,[t,e]}function v(e,t){var n=e.action=="insert",r=t.action=="insert";if(n&&r)o(e.start,t.start)<0?m(t,e,1):m(e,t,1);else if(n&&!r)o(e.start,t.end)>=0?m(e,t,-1):o(e.start,t.start)<=0?m(t,e,1):(m(e,s.fromPoints(t.start,e.start),-1),m(t,e,1));else if(!n&&r)o(t.start,e.end)>=0?m(t,e,-1):o(t.start,e.start)<=0?m(e,t,1):(m(t,s.fromPoints(e.start,t.start),-1),m(e,t,1));else if(!n&&!r)if(o(t.start,e.end)>=0)m(t,e,-1);else{if(!(o(t.end,e.start)<=0)){var i,u;return o(e.start,t.start)<0&&(i=e,e=y(e,t.start)),o(e.end,t.end)>0&&(u=y(e,t.end)),g(t.end,e.start,e.end,-1),u&&!i&&(e.lines=u.lines,e.start=u.start,e.end=u.end,u=e),[t,i,u].filter(Boolean)}m(e,t,-1)}return[t,e]}function m(e,t,n){g(e.start,t.start,t.end,n),g(e.end,t.start,t.end,n)}function g(e,t,n,r){e.row==(r==1?t:n).row&&(e.column+=r*(n.column-t.column)),e.row+=r*(n.row-t.row)}function y(e,t){var n=e.lines,r=e.end;e.end=f(t);var i=e.end.row-e.start.row,s=n.splice(i,n.length),o=i?t.column:t.column-e.start.column;n.push(s[0].substring(0,o)),s[0]=s[0].substr(o);var u={start:f(t),end:r,lines:s,action:e.action};return u}function b(e,t){t=l(t);for(var n=e.length;n--;){var r=e[n];for(var i=0;i<r.length;i++){var s=r[i],o=v(s,t);t=o[0],o.length!=2&&(o[2]?(r.splice(i+1,1,o[1],o[2]),i++):o[1]||(r.splice(i,1),i--))}r.length||e.splice(n,1)}return e}function w(e,t){for(var n=0;n<t.length;n++){var r=t[n];for(var i=0;i<r.length;i++)b(e,r[i])}}var r=function(){this.$maxRev=0,this.$fromUndo=!1,this.reset()};(function(){this.addSession=function(e){this.$session=e},this.add=function(e,t,n){if(this.$fromUndo)return;if(e==this.$lastDelta)return;this.$keepRedoStack||(this.$redoStack.length=0);if(t===!1||!this.lastDeltas)this.lastDeltas=[],this.$undoStack.push(this.lastDeltas),e.id=this.$rev=++this.$maxRev;if(e.action=="remove"||e.action=="insert")this.$lastDelta=e;this.lastDeltas.push(e)},this.addSelection=function(e,t){this.selections.push({value:e,rev:t||this.$rev})},this.startNewGroup=function(){return this.lastDeltas=null,this.$rev},this.markIgnored=function(e,t){t==null&&(t=this.$rev+1);var n=this.$undoStack;for(var r=n.length;r--;){var i=n[r][0];if(i.id<=e)break;i.id<t&&(i.ignore=!0)}this.lastDeltas=null},this.getSelection=function(e,t){var n=this.selections;for(var r=n.length;r--;){var i=n[r];if(i.rev<e)return t&&(i=n[r+1]),i}},this.getRevision=function(){return this.$rev},this.getDeltas=function(e,t){t==null&&(t=this.$rev+1);var n=this.$undoStack,r=null,i=0;for(var s=n.length;s--;){var o=n[s][0];o.id<t&&!r&&(r=s+1);if(o.id<=e){i=s+1;break}}return n.slice(i,r)},this.getChangedRanges=function(e,t){t==null&&(t=this.$rev+1)},this.getChangedLines=function(e,t){t==null&&(t=this.$rev+1)},this.undo=function(e,t){this.lastDeltas=null;var n=this.$undoStack;if(!i(n,n.length))return;e||(e=this.$session),this.$redoStackBaseRev!==this.$rev&&this.$redoStack.length&&(this.$redoStack=[]),this.$fromUndo=!0;var r=n.pop(),s=null;return r&&(s=e.undoChanges(r,t),this.$redoStack.push(r),this.$syncRev()),this.$fromUndo=!1,s},this.redo=function(e,t){this.lastDeltas=null,e||(e=this.$session),this.$fromUndo=!0;if(this.$redoStackBaseRev!=this.$rev){var n=this.getDeltas(this.$redoStackBaseRev,this.$rev+1);w(this.$redoStack,n),this.$redoStackBaseRev=this.$rev,this.$redoStack.forEach(function(e){e[0].id=++this.$maxRev},this)}var r=this.$redoStack.pop(),i=null;return r&&(i=e.redoChanges(r,t),this.$undoStack.push(r),this.$syncRev()),this.$fromUndo=!1,i},this.$syncRev=function(){var e=this.$undoStack,t=e[e.length-1],n=t&&t[0].id||0;this.$redoStackBaseRev=n,this.$rev=n},this.reset=function(){this.lastDeltas=null,this.$lastDelta=null,this.$undoStack=[],this.$redoStack=[],this.$rev=0,this.mark=0,this.$redoStackBaseRev=this.$rev,this.selections=[]},this.canUndo=function(){return this.$undoStack.length>0},this.canRedo=function(){return this.$redoStack.length>0},this.bookmark=function(e){e==undefined&&(e=this.$rev),this.mark=e},this.isAtBookmark=function(){return this.$rev===this.mark},this.toJSON=function(){},this.fromJSON=function(){},this.hasUndo=this.canUndo,this.hasRedo=this.canRedo,this.isClean=this.isAtBookmark,this.markClean=this.bookmark,this.$prettyPrint=function(e){return e?c(e):c(this.$undoStack)+"\n---\n"+c(this.$redoStack)}}).call(r.prototype);var s=e("./range").Range,o=s.comparePoints,u=s.comparePoints;t.UndoManager=r}),ace.define("ace/layer/lines",["require","exports","module","ace/lib/dom"],function(e,t,n){"use strict";var r=e("../lib/dom"),i=function(e,t){this.element=e,this.canvasHeight=t||5e5,this.element.style.height=this.canvasHeight*2+"px",this.cells=[],this.cellCache=[],this.$offsetCoefficient=0};(function(){this.moveContainer=function(e){r.translate(this.element,0,-(e.firstRowScreen*e.lineHeight%this.canvasHeight)-e.offset*this.$offsetCoefficient)},this.pageChanged=function(e,t){return Math.floor(e.firstRowScreen*e.lineHeight/this.canvasHeight)!==Math.floor(t.firstRowScreen*t.lineHeight/this.canvasHeight)},this.computeLineTop=function(e,t,n){var r=t.firstRowScreen*t.lineHeight,i=Math.floor(r/this.canvasHeight),s=n.documentToScreenRow(e,0)*t.lineHeight;return s-i*this.canvasHeight},this.computeLineHeight=function(e,t,n){return t.lineHeight*n.getRowLineCount(e)},this.getLength=function(){return this.cells.length},this.get=function(e){return this.cells[e]},this.shift=function(){this.$cacheCell(this.cells.shift())},this.pop=function(){this.$cacheCell(this.cells.pop())},this.push=function(e){if(Array.isArray(e)){this.cells.push.apply(this.cells,e);var t=r.createFragment(this.element);for(var n=0;n<e.length;n++)t.appendChild(e[n].element);this.element.appendChild(t)}else this.cells.push(e),this.element.appendChild(e.element)},this.unshift=function(e){if(Array.isArray(e)){this.cells.unshift.apply(this.cells,e);var t=r.createFragment(this.element);for(var n=0;n<e.length;n++)t.appendChild(e[n].element);this.element.firstChild?this.element.insertBefore(t,this.element.firstChild):this.element.appendChild(t)}else this.cells.unshift(e),this.element.insertAdjacentElement("afterbegin",e.element)},this.last=function(){return this.cells.length?this.cells[this.cells.length-1]:null},this.$cacheCell=function(e){if(!e)return;e.element.remove(),this.cellCache.push(e)},this.createCell=function(e,t,n,i){var s=this.cellCache.pop();if(!s){var o=r.createElement("div");i&&i(o),this.element.appendChild(o),s={element:o,text:"",row:e}}return s.row=e,s}}).call(i.prototype),t.Lines=i}),ace.define("ace/layer/gutter",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/layer/lines"],function(e,t,n){"use strict";function f(e){var t=document.createTextNode("");e.appendChild(t);var n=r.createElement("span");return e.appendChild(n),e}var r=e("../lib/dom"),i=e("../lib/oop"),s=e("../lib/lang"),o=e("../lib/event_emitter").EventEmitter,u=e("./lines").Lines,a=function(e){this.element=r.createElement("div"),this.element.className="ace_layer ace_gutter-layer",e.appendChild(this.element),this.setShowFoldWidgets(this.$showFoldWidgets),this.gutterWidth=0,this.$annotations=[],this.$updateAnnotations=this.$updateAnnotations.bind(this),this.$lines=new u(this.element),this.$lines.$offsetCoefficient=1};(function(){i.implement(this,o),this.setSession=function(e){this.session&&this.session.off("change",this.$updateAnnotations),this.session=e,e&&e.on("change",this.$updateAnnotations)},this.addGutterDecoration=function(e,t){window.console&&console.warn&&console.warn("deprecated use session.addGutterDecoration"),this.session.addGutterDecoration(e,t)},this.removeGutterDecoration=function(e,t){window.console&&console.warn&&console.warn("deprecated use session.removeGutterDecoration"),this.session.removeGutterDecoration(e,t)},this.setAnnotations=function(e){this.$annotations=[];for(var t=0;t<e.length;t++){var n=e[t],r=n.row,i=this.$annotations[r];i||(i=this.$annotations[r]={text:[]});var o=n.text;o=o?s.escapeHTML(o):n.html||"",i.text.indexOf(o)===-1&&i.text.push(o);var u=n.type;u=="error"?i.className=" ace_error":u=="warning"&&i.className!=" ace_error"?i.className=" ace_warning":u=="info"&&!i.className&&(i.className=" ace_info")}},this.$updateAnnotations=function(e){if(!this.$annotations.length)return;var t=e.start.row,n=e.end.row-t;if(n!==0)if(e.action=="remove")this.$annotations.splice(t,n+1,null);else{var r=new Array(n+1);r.unshift(t,1),this.$annotations.splice.apply(this.$annotations,r)}},this.update=function(e){this.config=e;var t=this.session,n=e.firstRow,r=Math.min(e.lastRow+e.gutterOffset,t.getLength()-1);this.oldLastRow=r,this.config=e,this.$lines.moveContainer(e),this.$updateCursorRow();var i=t.getNextFoldLine(n),s=i?i.start.row:Infinity,o=null,u=-1,a=n;for(;;){a>s&&(a=i.end.row+1,i=t.getNextFoldLine(a,i),s=i?i.start.row:Infinity);if(a>r){while(this.$lines.getLength()>u+1)this.$lines.pop();break}o=this.$lines.get(++u),o?o.row=a:(o=this.$lines.createCell(a,e,this.session,f),this.$lines.push(o)),this.$renderCell(o,e,i,a),a++}this._signal("afterRender"),this.$updateGutterWidth(e)},this.$updateGutterWidth=function(e){var t=this.session,n=t.gutterRenderer||this.$renderer,r=t.$firstLineNumber,i=this.$lines.last()?this.$lines.last().text:"";if(this.$fixedWidth||t.$useWrapMode)i=t.getLength()+r-1;var s=n?n.getWidth(t,i,e):i.toString().length*e.characterWidth,o=this.$padding||this.$computePadding();s+=o.left+o.right,s!==this.gutterWidth&&!isNaN(s)&&(this.gutterWidth=s,this.element.parentNode.style.width=this.element.style.width=Math.ceil(this.gutterWidth)+"px",this._signal("changeGutterWidth",s))},this.$updateCursorRow=function(){if(!this.$highlightGutterLine)return;var e=this.session.selection.getCursor();if(this.$cursorRow===e.row)return;this.$cursorRow=e.row},this.updateLineHighlight=function(){if(!this.$highlightGutterLine)return;var e=this.session.selection.cursor.row;this.$cursorRow=e;if(this.$cursorCell&&this.$cursorCell.row==e)return;this.$cursorCell&&(this.$cursorCell.element.className=this.$cursorCell.element.className.replace("ace_gutter-active-line ",""));var t=this.$lines.cells;this.$cursorCell=null;for(var n=0;n<t.length;n++){var r=t[n];if(r.row>=this.$cursorRow){if(r.row>this.$cursorRow){var i=this.session.getFoldLine(this.$cursorRow);if(!(n>0&&i&&i.start.row==t[n-1].row))break;r=t[n-1]}r.element.className="ace_gutter-active-line "+r.element.className,this.$cursorCell=r;break}}},this.scrollLines=function(e){var t=this.config;this.config=e,this.$updateCursorRow();if(this.$lines.pageChanged(t,e))return this.update(e);this.$lines.moveContainer(e);var n=Math.min(e.lastRow+e.gutterOffset,this.session.getLength()-1),r=this.oldLastRow;this.oldLastRow=n;if(!t||r<e.firstRow)return this.update(e);if(n<t.firstRow)return this.update(e);if(t.firstRow<e.firstRow)for(var i=this.session.getFoldedRowCount(t.firstRow,e.firstRow-1);i>0;i--)this.$lines.shift();if(r>n)for(var i=this.session.getFoldedRowCount(n+1,r);i>0;i--)this.$lines.pop();e.firstRow<t.firstRow&&this.$lines.unshift(this.$renderLines(e,e.firstRow,t.firstRow-1)),n>r&&this.$lines.push(this.$renderLines(e,r+1,n)),this.updateLineHighlight(),this._signal("afterRender"),this.$updateGutterWidth(e)},this.$renderLines=function(e,t,n){var r=[],i=t,s=this.session.getNextFoldLine(i),o=s?s.start.row:Infinity;for(;;){i>o&&(i=s.end.row+1,s=this.session.getNextFoldLine(i,s),o=s?s.start.row:Infinity);if(i>n)break;var u=this.$lines.createCell(i,e,this.session,f);this.$renderCell(u,e,s,i),r.push(u),i++}return r},this.$renderCell=function(e,t,n,i){var s=e.element,o=this.session,u=s.childNodes[0],a=s.childNodes[1],f=o.$firstLineNumber,l=o.$breakpoints,c=o.$decorations,h=o.gutterRenderer||this.$renderer,p=this.$showFoldWidgets&&o.foldWidgets,d=n?n.start.row:Number.MAX_VALUE,v="ace_gutter-cell ";this.$highlightGutterLine&&(i==this.$cursorRow||n&&i<this.$cursorRow&&i>=d&&this.$cursorRow<=n.end.row)&&(v+="ace_gutter-active-line ",this.$cursorCell!=e&&(this.$cursorCell&&(this.$cursorCell.element.className=this.$cursorCell.element.className.replace("ace_gutter-active-line ","")),this.$cursorCell=e)),l[i]&&(v+=l[i]),c[i]&&(v+=c[i]),this.$annotations[i]&&(v+=this.$annotations[i].className),s.className!=v&&(s.className=v);if(p){var m=p[i];m==null&&(m=p[i]=o.getFoldWidget(i))}if(m){var v="ace_fold-widget ace_"+m;m=="start"&&i==d&&i<n.end.row?v+=" ace_closed":v+=" ace_open",a.className!=v&&(a.className=v);var g=t.lineHeight+"px";r.setStyle(a.style,"height",g),r.setStyle(a.style,"display","inline-block")}else a&&r.setStyle(a.style,"display","none");var y=(h?h.getText(o,i):i+f).toString();return y!==u.data&&(u.data=y),r.setStyle(e.element.style,"height",this.$lines.computeLineHeight(i,t,o)+"px"),r.setStyle(e.element.style,"top",this.$lines.computeLineTop(i,t,o)+"px"),e.text=y,e},this.$fixedWidth=!1,this.$highlightGutterLine=!0,this.$renderer="",this.setHighlightGutterLine=function(e){this.$highlightGutterLine=e},this.$showLineNumbers=!0,this.$renderer="",this.setShowLineNumbers=function(e){this.$renderer=!e&&{getWidth:function(){return 0},getText:function(){return""}}},this.getShowLineNumbers=function(){return this.$showLineNumbers},this.$showFoldWidgets=!0,this.setShowFoldWidgets=function(e){e?r.addCssClass(this.element,"ace_folding-enabled"):r.removeCssClass(this.element,"ace_folding-enabled"),this.$showFoldWidgets=e,this.$padding=null},this.getShowFoldWidgets=function(){return this.$showFoldWidgets},this.$computePadding=function(){if(!this.element.firstChild)return{left:0,right:0};var e=r.computedStyle(this.element.firstChild);return this.$padding={},this.$padding.left=(parseInt(e.borderLeftWidth)||0)+(parseInt(e.paddingLeft)||0)+1,this.$padding.right=(parseInt(e.borderRightWidth)||0)+(parseInt(e.paddingRight)||0),this.$padding},this.getRegion=function(e){var t=this.$padding||this.$computePadding(),n=this.element.getBoundingClientRect();if(e.x<t.left+n.left)return"markers";if(this.$showFoldWidgets&&e.x>n.right-t.right)return"foldWidgets"}}).call(a.prototype),t.Gutter=a}),ace.define("ace/layer/marker",["require","exports","module","ace/range","ace/lib/dom"],function(e,t,n){"use strict";var r=e("../range").Range,i=e("../lib/dom"),s=function(e){this.element=i.createElement("div"),this.element.className="ace_layer ace_marker-layer",e.appendChild(this.element)};(function(){function e(e,t,n,r){return(e?1:0)|(t?2:0)|(n?4:0)|(r?8:0)}this.$padding=0,this.setPadding=function(e){this.$padding=e},this.setSession=function(e){this.session=e},this.setMarkers=function(e){this.markers=e},this.elt=function(e,t){var n=this.i!=-1&&this.element.childNodes[this.i];n?this.i++:(n=document.createElement("div"),this.element.appendChild(n),this.i=-1),n.style.cssText=t,n.className=e},this.update=function(e){if(!e)return;this.config=e,this.i=0;var t;for(var n in this.markers){var r=this.markers[n];if(!r.range){r.update(t,this,this.session,e);continue}var i=r.range.clipRows(e.firstRow,e.lastRow);if(i.isEmpty())continue;i=i.toScreenRange(this.session);if(r.renderer){var s=this.$getTop(i.start.row,e),o=this.$padding+i.start.column*e.characterWidth;r.renderer(t,i,o,s,e)}else r.type=="fullLine"?this.drawFullLineMarker(t,i,r.clazz,e):r.type=="screenLine"?this.drawScreenLineMarker(t,i,r.clazz,e):i.isMultiLine()?r.type=="text"?this.drawTextMarker(t,i,r.clazz,e):this.drawMultiLineMarker(t,i,r.clazz,e):this.drawSingleLineMarker(t,i,r.clazz+" ace_start"+" ace_br15",e)}if(this.i!=-1)while(this.i<this.element.childElementCount)this.element.removeChild(this.element.lastChild)},this.$getTop=function(e,t){return(e-t.firstRowScreen)*t.lineHeight},this.drawTextMarker=function(t,n,i,s,o){var u=this.session,a=n.start.row,f=n.end.row,l=a,c=0,h=0,p=u.getScreenLastRowColumn(l),d=new r(l,n.start.column,l,h);for(;l<=f;l++)d.start.row=d.end.row=l,d.start.column=l==a?n.start.column:u.getRowWrapIndent(l),d.end.column=p,c=h,h=p,p=l+1<f?u.getScreenLastRowColumn(l+1):l==f?0:n.end.column,this.drawSingleLineMarker(t,d,i+(l==a?" ace_start":"")+" ace_br"+e(l==a||l==a+1&&n.start.column,c<h,h>p,l==f),s,l==f?0:1,o)},this.drawMultiLineMarker=function(e,t,n,r,i){var s=this.$padding,o=r.lineHeight,u=this.$getTop(t.start.row,r),a=s+t.start.column*r.characterWidth;i=i||"";if(this.session.$bidiHandler.isBidiRow(t.start.row)){var f=t.clone();f.end.row=f.start.row,f.end.column=this.session.getLine(f.start.row).length,this.drawBidiSingleLineMarker(e,f,n+" ace_br1 ace_start",r,null,i)}else this.elt(n+" ace_br1 ace_start","height:"+o+"px;"+"right:0;"+"top:"+u+"px;left:"+a+"px;"+(i||""));if(this.session.$bidiHandler.isBidiRow(t.end.row)){var f=t.clone();f.start.row=f.end.row,f.start.column=0,this.drawBidiSingleLineMarker(e,f,n+" ace_br12",r,null,i)}else{u=this.$getTop(t.end.row,r);var l=t.end.column*r.characterWidth;this.elt(n+" ace_br12","height:"+o+"px;"+"width:"+l+"px;"+"top:"+u+"px;"+"left:"+s+"px;"+(i||""))}o=(t.end.row-t.start.row-1)*r.lineHeight;if(o<=0)return;u=this.$getTop(t.start.row+1,r);var c=(t.start.column?1:0)|(t.end.column?0:8);this.elt(n+(c?" ace_br"+c:""),"height:"+o+"px;"+"right:0;"+"top:"+u+"px;"+"left:"+s+"px;"+(i||""))},this.drawSingleLineMarker=function(e,t,n,r,i,s){if(this.session.$bidiHandler.isBidiRow(t.start.row))return this.drawBidiSingleLineMarker(e,t,n,r,i,s);var o=r.lineHeight,u=(t.end.column+(i||0)-t.start.column)*r.characterWidth,a=this.$getTop(t.start.row,r),f=this.$padding+t.start.column*r.characterWidth;this.elt(n,"height:"+o+"px;"+"width:"+u+"px;"+"top:"+a+"px;"+"left:"+f+"px;"+(s||""))},this.drawBidiSingleLineMarker=function(e,t,n,r,i,s){var o=r.lineHeight,u=this.$getTop(t.start.row,r),a=this.$padding,f=this.session.$bidiHandler.getSelections(t.start.column,t.end.column);f.forEach(function(e){this.elt(n,"height:"+o+"px;"+"width:"+e.width+(i||0)+"px;"+"top:"+u+"px;"+"left:"+(a+e.left)+"px;"+(s||""))},this)},this.drawFullLineMarker=function(e,t,n,r,i){var s=this.$getTop(t.start.row,r),o=r.lineHeight;t.start.row!=t.end.row&&(o+=this.$getTop(t.end.row,r)-s),this.elt(n,"height:"+o+"px;"+"top:"+s+"px;"+"left:0;right:0;"+(i||""))},this.drawScreenLineMarker=function(e,t,n,r,i){var s=this.$getTop(t.start.row,r),o=r.lineHeight;this.elt(n,"height:"+o+"px;"+"top:"+s+"px;"+"left:0;right:0;"+(i||""))}}).call(s.prototype),t.Marker=s}),ace.define("ace/layer/text",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/layer/lines","ace/lib/event_emitter"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("../lib/dom"),s=e("../lib/lang"),o=e("./lines").Lines,u=e("../lib/event_emitter").EventEmitter,a=function(e){this.dom=i,this.element=this.dom.createElement("div"),this.element.className="ace_layer ace_text-layer",e.appendChild(this.element),this.$updateEolChar=this.$updateEolChar.bind(this),this.$lines=new o(this.element)};(function(){r.implement(this,u),this.EOF_CHAR="\u00b6",this.EOL_CHAR_LF="\u00ac",this.EOL_CHAR_CRLF="\u00a4",this.EOL_CHAR=this.EOL_CHAR_LF,this.TAB_CHAR="\u2014",this.SPACE_CHAR="\u00b7",this.$padding=0,this.MAX_LINE_LENGTH=1e4,this.$updateEolChar=function(){var e=this.session.doc,t=e.getNewLineCharacter()=="\n"&&e.getNewLineMode()!="windows",n=t?this.EOL_CHAR_LF:this.EOL_CHAR_CRLF;if(this.EOL_CHAR!=n)return this.EOL_CHAR=n,!0},this.setPadding=function(e){this.$padding=e,this.element.style.margin="0 "+e+"px"},this.getLineHeight=function(){return this.$fontMetrics.$characterSize.height||0},this.getCharacterWidth=function(){return this.$fontMetrics.$characterSize.width||0},this.$setFontMetrics=function(e){this.$fontMetrics=e,this.$fontMetrics.on("changeCharacterSize",function(e){this._signal("changeCharacterSize",e)}.bind(this)),this.$pollSizeChanges()},this.checkForSizeChanges=function(){this.$fontMetrics.checkForSizeChanges()},this.$pollSizeChanges=function(){return this.$pollSizeChangesTimer=this.$fontMetrics.$pollSizeChanges()},this.setSession=function(e){this.session=e,e&&this.$computeTabString()},this.showInvisibles=!1,this.showSpaces=!1,this.showTabs=!1,this.showEOL=!1,this.setShowInvisibles=function(e){return this.showInvisibles==e?!1:(this.showInvisibles=e,typeof e=="string"?(this.showSpaces=/tab/i.test(e),this.showTabs=/space/i.test(e),this.showEOL=/eol/i.test(e)):this.showSpaces=this.showTabs=this.showEOL=e,this.$computeTabString(),!0)},this.displayIndentGuides=!0,this.setDisplayIndentGuides=function(e){return this.displayIndentGuides==e?!1:(this.displayIndentGuides=e,this.$computeTabString(),!0)},this.$tabStrings=[],this.onChangeTabSize=this.$computeTabString=function(){var e=this.session.getTabSize();this.tabSize=e;var t=this.$tabStrings=[0];for(var n=1;n<e+1;n++)if(this.showTabs){var r=this.dom.createElement("span");r.className="ace_invisible ace_invisible_tab",r.textContent=s.stringRepeat(this.TAB_CHAR,n),t.push(r)}else t.push(this.dom.createTextNode(s.stringRepeat(" ",n),this.element));if(this.displayIndentGuides){this.$indentGuideRe=/\s\S| \t|\t |\s$/;var i="ace_indent-guide",o=this.showSpaces?" ace_invisible ace_invisible_space":"",u=this.showSpaces?s.stringRepeat(this.SPACE_CHAR,this.tabSize):s.stringRepeat(" ",this.tabSize),a=this.showTabs?" ace_invisible ace_invisible_tab":"",f=this.showTabs?s.stringRepeat(this.TAB_CHAR,this.tabSize):u,r=this.dom.createElement("span");r.className=i+o,r.textContent=u,this.$tabStrings[" "]=r;var r=this.dom.createElement("span");r.className=i+a,r.textContent=f,this.$tabStrings[" "]=r}},this.updateLines=function(e,t,n){if(this.config.lastRow!=e.lastRow||this.config.firstRow!=e.firstRow)return this.update(e);this.config=e;var r=Math.max(t,e.firstRow),i=Math.min(n,e.lastRow),s=this.element.childNodes,o=0;for(var u=e.firstRow;u<r;u++){var a=this.session.getFoldLine(u);if(a){if(a.containsRow(r)){r=a.start.row;break}u=a.end.row}o++}var f=!1,u=r,a=this.session.getNextFoldLine(u),l=a?a.start.row:Infinity;for(;;){u>l&&(u=a.end.row+1,a=this.session.getNextFoldLine(u,a),l=a?a.start.row:Infinity);if(u>i)break;var c=s[o++];if(c){this.dom.removeChildren(c),this.$renderLine(c,u,u==l?a:!1),f&&(c.style.top=this.$lines.computeLineTop(u,e,this.session)+"px");var h=e.lineHeight*this.session.getRowLength(u)+"px";c.style.height!=h&&(f=!0,c.style.height=h)}u++}if(f)while(o<this.$lines.cells.length){var p=this.$lines.cells[o++];p.element.style.top=this.$lines.computeLineTop(p.row,e,this.session)+"px"}},this.scrollLines=function(e){var t=this.config;this.config=e;if(this.$lines.pageChanged(t,e))return this.update(e);this.$lines.moveContainer(e);var n=e.lastRow,r=t?t.lastRow:-1;if(!t||r<e.firstRow)return this.update(e);if(n<t.firstRow)return this.update(e);if(!t||t.lastRow<e.firstRow)return this.update(e);if(e.lastRow<t.firstRow)return this.update(e);if(t.firstRow<e.firstRow)for(var i=this.session.getFoldedRowCount(t.firstRow,e.firstRow-1);i>0;i--)this.$lines.shift();if(t.lastRow>e.lastRow)for(var i=this.session.getFoldedRowCount(e.lastRow+1,t.lastRow);i>0;i--)this.$lines.pop();e.firstRow<t.firstRow&&this.$lines.unshift(this.$renderLinesFragment(e,e.firstRow,t.firstRow-1)),e.lastRow>t.lastRow&&this.$lines.push(this.$renderLinesFragment(e,t.lastRow+1,e.lastRow))},this.$renderLinesFragment=function(e,t,n){var r=[],s=t,o=this.session.getNextFoldLine(s),u=o?o.start.row:Infinity;for(;;){s>u&&(s=o.end.row+1,o=this.session.getNextFoldLine(s,o),u=o?o.start.row:Infinity);if(s>n)break;var a=this.$lines.createCell(s,e,this.session),f=a.element;this.dom.removeChildren(f),i.setStyle(f.style,"height",this.$lines.computeLineHeight(s,e,this.session)+"px"),i.setStyle(f.style,"top",this.$lines.computeLineTop(s,e,this.session)+"px"),this.$renderLine(f,s,s==u?o:!1),this.$useLineGroups()?f.className="ace_line_group":f.className="ace_line",r.push(a),s++}return r},this.update=function(e){this.$lines.moveContainer(e),this.config=e;var t=e.firstRow,n=e.lastRow,r=this.$lines;while(r.getLength())r.pop();r.push(this.$renderLinesFragment(e,t,n))},this.$textToken={text:!0,rparen:!0,lparen:!0},this.$renderToken=function(e,t,n,r){var i=this,o=/(\t)|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\uFEFF\uFFF9-\uFFFC]+)|(\u3000)|([\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3001-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]|[\uD800-\uDBFF][\uDC00-\uDFFF])/g,u=this.dom.createFragment(this.element),a,f=0;while(a=o.exec(r)){var l=a[1],c=a[2],h=a[3],p=a[4],d=a[5];if(!i.showSpaces&&c)continue;var v=f!=a.index?r.slice(f,a.index):"";f=a.index+a[0].length,v&&u.appendChild(this.dom.createTextNode(v,this.element));if(l){var m=i.session.getScreenTabSize(t+a.index);u.appendChild(i.$tabStrings[m].cloneNode(!0)),t+=m-1}else if(c)if(i.showSpaces){var g=this.dom.createElement("span");g.className="ace_invisible ace_invisible_space",g.textContent=s.stringRepeat(i.SPACE_CHAR,c.length),u.appendChild(g)}else u.appendChild(this.com.createTextNode(c,this.element));else if(h){var g=this.dom.createElement("span");g.className="ace_invisible ace_invisible_space ace_invalid",g.textContent=s.stringRepeat(i.SPACE_CHAR,h.length),u.appendChild(g)}else if(p){t+=1;var g=this.dom.createElement("span");g.style.width=i.config.characterWidth*2+"px",g.className=i.showSpaces?"ace_cjk ace_invisible ace_invisible_space":"ace_cjk",g.textContent=i.showSpaces?i.SPACE_CHAR:p,u.appendChild(g)}else if(d){t+=1;var g=this.dom.createElement("span");g.style.width=i.config.characterWidth*2+"px",g.className="ace_cjk",g.textContent=d,u.appendChild(g)}}u.appendChild(this.dom.createTextNode(f?r.slice(f):r,this.element));if(!this.$textToken[n.type]){var y="ace_"+n.type.replace(/\./g," ace_"),g=this.dom.createElement("span");n.type=="fold"&&(g.style.width=n.value.length*this.config.characterWidth+"px"),g.className=y,g.appendChild(u),e.appendChild(g)}else e.appendChild(u);return t+r.length},this.renderIndentGuide=function(e,t,n){var r=t.search(this.$indentGuideRe);if(r<=0||r>=n)return t;if(t[0]==" "){r-=r%this.tabSize;var i=r/this.tabSize;for(var s=0;s<i;s++)e.appendChild(this.$tabStrings[" "].cloneNode(!0));return t.substr(r)}if(t[0]==" "){for(var s=0;s<r;s++)e.appendChild(this.$tabStrings[" "].cloneNode(!0));return t.substr(r)}return t},this.$createLineElement=function(e){var t=this.dom.createElement("div");return t.className="ace_line",t.style.height=this.config.lineHeight+"px",t},this.$renderWrappedLine=function(e,t,n){var r=0,i=0,o=n[0],u=0,a=this.$createLineElement();e.appendChild(a);for(var f=0;f<t.length;f++){var l=t[f],c=l.value;if(f==0&&this.displayIndentGuides){r=c.length,c=this.renderIndentGuide(a,c,o);if(!c)continue;r-=c.length}if(r+c.length<o)u=this.$renderToken(a,u,l,c),r+=c.length;else{while(r+c.length>=o)u=this.$renderToken(a,u,l,c.substring(0,o-r)),c=c.substring(o-r),r=o,a=this.$createLineElement(),e.appendChild(a),a.appendChild(this.dom.createTextNode(s.stringRepeat("\u00a0",n.indent),this.element)),i++,u=0,o=n[i]||Number.MAX_VALUE;c.length!=0&&(r+=c.length,u=this.$renderToken(a,u,l,c))}}n[n.length-1]>this.MAX_LINE_LENGTH&&this.$renderOverflowMessage(a,u,null,"",!0)},this.$renderSimpleLine=function(e,t){var n=0,r=t[0],i=r.value;this.displayIndentGuides&&(i=this.renderIndentGuide(e,i)),i&&(n=this.$renderToken(e,n,r,i));for(var s=1;s<t.length;s++){r=t[s],i=r.value;if(n+i.length>this.MAX_LINE_LENGTH)return this.$renderOverflowMessage(e,n,r,i);n=this.$renderToken(e,n,r,i)}},this.$renderOverflowMessage=function(e,t,n,r,i){n&&this.$renderToken(e,t,n,r.slice(0,this.MAX_LINE_LENGTH-t));var s=this.dom.createElement("span");s.className="ace_inline_button ace_keyword ace_toggle_wrap",s.textContent=i?"<hide>":"<click to see more...>",e.appendChild(s)},this.$renderLine=function(e,t,n){!n&&n!=0&&(n=this.session.getFoldLine(t));if(n)var r=this.$getFoldLineTokens(t,n);else var r=this.session.getTokens(t);var i=e;if(r.length){var s=this.session.getRowSplitData(t);if(s&&s.length){this.$renderWrappedLine(e,r,s);var i=e.lastChild}else{var i=e;this.$useLineGroups()&&(i=this.$createLineElement(),e.appendChild(i)),this.$renderSimpleLine(i,r)}}else this.$useLineGroups()&&(i=this.$createLineElement(),e.appendChild(i));if(this.showEOL&&i){n&&(t=n.end.row);var o=this.dom.createElement("span");o.className="ace_invisible ace_invisible_eol",o.textContent=t==this.session.getLength()-1?this.EOF_CHAR:this.EOL_CHAR,i.appendChild(o)}},this.$getFoldLineTokens=function(e,t){function i(e,t,n){var i=0,s=0;while(s+e[i].value.length<t){s+=e[i].value.length,i++;if(i==e.length)return}if(s!=t){var o=e[i].value.substring(t-s);o.length>n-t&&(o=o.substring(0,n-t)),r.push({type:e[i].type,value:o}),s=t+o.length,i+=1}while(s<n&&i<e.length){var o=e[i].value;o.length+s>n?r.push({type:e[i].type,value:o.substring(0,n-s)}):r.push(e[i]),s+=o.length,i+=1}}var n=this.session,r=[],s=n.getTokens(e);return t.walk(function(e,t,o,u,a){e!=null?r.push({type:"fold",value:e}):(a&&(s=n.getTokens(t)),s.length&&i(s,u,o))},t.end.row,this.session.getLine(t.end.row).length),r},this.$useLineGroups=function(){return this.session.getUseWrapMode()},this.destroy=function(){}}).call(a.prototype),t.Text=a}),ace.define("ace/layer/cursor",["require","exports","module","ace/lib/dom"],function(e,t,n){"use strict";var r=e("../lib/dom"),i=function(e){this.element=r.createElement("div"),this.element.className="ace_layer ace_cursor-layer",e.appendChild(this.element),this.isVisible=!1,this.isBlinking=!0,this.blinkInterval=1e3,this.smoothBlinking=!1,this.cursors=[],this.cursor=this.addCursor(),r.addCssClass(this.element,"ace_hidden-cursors"),this.$updateCursors=this.$updateOpacity.bind(this)};(function(){this.$updateOpacity=function(e){var t=this.cursors;for(var n=t.length;n--;)r.setStyle(t[n].style,"opacity",e?"":"0")},this.$startCssAnimation=function(){var e=this.cursors;for(var t=e.length;t--;)e[t].style.animationDuration=this.blinkInterval+"ms";setTimeout(function(){r.addCssClass(this.element,"ace_animate-blinking")}.bind(this))},this.$stopCssAnimation=function(){r.removeCssClass(this.element,"ace_animate-blinking")},this.$padding=0,this.setPadding=function(e){this.$padding=e},this.setSession=function(e){this.session=e},this.setBlinking=function(e){e!=this.isBlinking&&(this.isBlinking=e,this.restartTimer())},this.setBlinkInterval=function(e){e!=this.blinkInterval&&(this.blinkInterval=e,this.restartTimer())},this.setSmoothBlinking=function(e){e!=this.smoothBlinking&&(this.smoothBlinking=e,r.setCssClass(this.element,"ace_smooth-blinking",e),this.$updateCursors(!0),this.restartTimer())},this.addCursor=function(){var e=r.createElement("div");return e.className="ace_cursor",this.element.appendChild(e),this.cursors.push(e),e},this.removeCursor=function(){if(this.cursors.length>1){var e=this.cursors.pop();return e.parentNode.removeChild(e),e}},this.hideCursor=function(){this.isVisible=!1,r.addCssClass(this.element,"ace_hidden-cursors"),this.restartTimer()},this.showCursor=function(){this.isVisible=!0,r.removeCssClass(this.element,"ace_hidden-cursors"),this.restartTimer()},this.restartTimer=function(){var e=this.$updateCursors;clearInterval(this.intervalId),clearTimeout(this.timeoutId),this.$stopCssAnimation(),this.smoothBlinking&&r.removeCssClass(this.element,"ace_smooth-blinking"),e(!0);if(!this.isBlinking||!this.blinkInterval||!this.isVisible){this.$stopCssAnimation();return}this.smoothBlinking&&setTimeout(function(){r.addCssClass(this.element,"ace_smooth-blinking")}.bind(this));if(r.HAS_CSS_ANIMATION)this.$startCssAnimation();else{var t=function(){this.timeoutId=setTimeout(function(){e(!1)},.6*this.blinkInterval)}.bind(this);this.intervalId=setInterval(function(){e(!0),t()},this.blinkInterval),t()}},this.getPixelPosition=function(e,t){if(!this.config||!this.session)return{left:0,top:0};e||(e=this.session.selection.getCursor());var n=this.session.documentToScreenPosition(e),r=this.$padding+(this.session.$bidiHandler.isBidiRow(n.row,e.row)?this.session.$bidiHandler.getPosLeft(n.column):n.column*this.config.characterWidth),i=(n.row-(t?this.config.firstRowScreen:0))*this.config.lineHeight;return{left:r,top:i}},this.isCursorInView=function(e,t){return e.top>=0&&e.top<t.maxHeight},this.update=function(e){this.config=e;var t=this.session.$selectionMarkers,n=0,i=0;if(t===undefined||t.length===0)t=[{cursor:null}];for(var n=0,s=t.length;n<s;n++){var o=this.getPixelPosition(t[n].cursor,!0);if((o.top>e.height+e.offset||o.top<0)&&n>1)continue;var u=this.cursors[i++]||this.addCursor(),a=u.style;this.drawCursor?this.drawCursor(u,o,e,t[n],this.session):this.isCursorInView(o,e)?(r.setStyle(a,"display","block"),r.translate(u,o.left,o.top),r.setStyle(a,"width",Math.round(e.characterWidth)+"px"),r.setStyle(a,"height",e.lineHeight+"px")):r.setStyle(a,"display","none")}while(this.cursors.length>i)this.removeCursor();var f=this.session.getOverwrite();this.$setOverwrite(f),this.$pixelPos=o,this.restartTimer()},this.drawCursor=null,this.$setOverwrite=function(e){e!=this.overwrite&&(this.overwrite=e,e?r.addCssClass(this.element,"ace_overwrite-cursors"):r.removeCssClass(this.element,"ace_overwrite-cursors"))},this.destroy=function(){clearInterval(this.intervalId),clearTimeout(this.timeoutId)}}).call(i.prototype),t.Cursor=i}),ace.define("ace/scrollbar",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/event","ace/lib/event_emitter"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./lib/dom"),s=e("./lib/event"),o=e("./lib/event_emitter").EventEmitter,u=32768,a=function(e){this.element=i.createElement("div"),this.element.className="ace_scrollbar ace_scrollbar"+this.classSuffix,this.inner=i.createElement("div"),this.inner.className="ace_scrollbar-inner",this.inner.textContent="\u00a0",this.element.appendChild(this.inner),e.appendChild(this.element),this.setVisible(!1),this.skipEvent=!1,s.addListener(this.element,"scroll",this.onScroll.bind(this)),s.addListener(this.element,"mousedown",s.preventDefault)};(function(){r.implement(this,o),this.setVisible=function(e){this.element.style.display=e?"":"none",this.isVisible=e,this.coeff=1}}).call(a.prototype);var f=function(e,t){a.call(this,e),this.scrollTop=0,this.scrollHeight=0,t.$scrollbarWidth=this.width=i.scrollbarWidth(e.ownerDocument),this.inner.style.width=this.element.style.width=(this.width||15)+5+"px",this.$minWidth=0};r.inherits(f,a),function(){this.classSuffix="-v",this.onScroll=function(){if(!this.skipEvent){this.scrollTop=this.element.scrollTop;if(this.coeff!=1){var e=this.element.clientHeight/this.scrollHeight;this.scrollTop=this.scrollTop*(1-e)/(this.coeff-e)}this._emit("scroll",{data:this.scrollTop})}this.skipEvent=!1},this.getWidth=function(){return Math.max(this.isVisible?this.width:0,this.$minWidth||0)},this.setHeight=function(e){this.element.style.height=e+"px"},this.setInnerHeight=this.setScrollHeight=function(e){this.scrollHeight=e,e>u?(this.coeff=u/e,e=u):this.coeff!=1&&(this.coeff=1),this.inner.style.height=e+"px"},this.setScrollTop=function(e){this.scrollTop!=e&&(this.skipEvent=!0,this.scrollTop=e,this.element.scrollTop=e*this.coeff)}}.call(f.prototype);var l=function(e,t){a.call(this,e),this.scrollLeft=0,this.height=t.$scrollbarWidth,this.inner.style.height=this.element.style.height=(this.height||15)+5+"px"};r.inherits(l,a),function(){this.classSuffix="-h",this.onScroll=function(){this.skipEvent||(this.scrollLeft=this.element.scrollLeft,this._emit("scroll",{data:this.scrollLeft})),this.skipEvent=!1},this.getHeight=function(){return this.isVisible?this.height:0},this.setWidth=function(e){this.element.style.width=e+"px"},this.setInnerWidth=function(e){this.inner.style.width=e+"px"},this.setScrollWidth=function(e){this.inner.style.width=e+"px"},this.setScrollLeft=function(e){this.scrollLeft!=e&&(this.skipEvent=!0,this.scrollLeft=this.element.scrollLeft=e)}}.call(l.prototype),t.ScrollBar=f,t.ScrollBarV=f,t.ScrollBarH=l,t.VScrollBar=f,t.HScrollBar=l}),ace.define("ace/renderloop",["require","exports","module","ace/lib/event"],function(e,t,n){"use strict";var r=e("./lib/event"),i=function(e,t){this.onRender=e,this.pending=!1,this.changes=0,this.$recursionLimit=2,this.window=t||window;var n=this;this._flush=function(e){n.pending=!1;var t=n.changes;t&&(r.blockIdle(100),n.changes=0,n.onRender(t));if(n.changes){if(n.$recursionLimit--<0)return;n.schedule()}else n.$recursionLimit=2}};(function(){this.schedule=function(e){this.changes=this.changes|e,this.changes&&!this.pending&&(r.nextFrame(this._flush),this.pending=!0)},this.clear=function(e){var t=this.changes;return this.changes=0,t}}).call(i.prototype),t.RenderLoop=i}),ace.define("ace/layer/font_metrics",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/event","ace/lib/useragent","ace/lib/event_emitter"],function(e,t,n){var r=e("../lib/oop"),i=e("../lib/dom"),s=e("../lib/lang"),o=e("../lib/event"),u=e("../lib/useragent"),a=e("../lib/event_emitter").EventEmitter,f=256,l=typeof ResizeObserver=="function",c=200,h=t.FontMetrics=function(e){this.el=i.createElement("div"),this.$setMeasureNodeStyles(this.el.style,!0),this.$main=i.createElement("div"),this.$setMeasureNodeStyles(this.$main.style),this.$measureNode=i.createElement("div"),this.$setMeasureNodeStyles(this.$measureNode.style),this.el.appendChild(this.$main),this.el.appendChild(this.$measureNode),e.appendChild(this.el),this.$measureNode.textContent=s.stringRepeat("X",f),this.$characterSize={width:0,height:0},l?this.$addObserver():this.checkForSizeChanges()};(function(){r.implement(this,a),this.$characterSize={width:0,height:0},this.$setMeasureNodeStyles=function(e,t){e.width=e.height="auto",e.left=e.top="0px",e.visibility="hidden",e.position="absolute",e.whiteSpace="pre",u.isIE<8?e["font-family"]="inherit":e.font="inherit",e.overflow=t?"hidden":"visible"},this.checkForSizeChanges=function(e){e===undefined&&(e=this.$measureSizes());if(e&&(this.$characterSize.width!==e.width||this.$characterSize.height!==e.height)){this.$measureNode.style.fontWeight="bold";var t=this.$measureSizes();this.$measureNode.style.fontWeight="",this.$characterSize=e,this.charSizes=Object.create(null),this.allowBoldFonts=t&&t.width===e.width&&t.height===e.height,this._emit("changeCharacterSize",{data:e})}},this.$addObserver=function(){var e=this;this.$observer=new window.ResizeObserver(function(t){e.checkForSizeChanges()}),this.$observer.observe(this.$measureNode)},this.$pollSizeChanges=function(){if(this.$pollSizeChangesTimer||this.$observer)return this.$pollSizeChangesTimer;var e=this;return this.$pollSizeChangesTimer=o.onIdle(function t(){e.checkForSizeChanges(),o.onIdle(t,500)},500)},this.setPolling=function(e){e?this.$pollSizeChanges():this.$pollSizeChangesTimer&&(clearInterval(this.$pollSizeChangesTimer),this.$pollSizeChangesTimer=0)},this.$measureSizes=function(e){var t={height:(e||this.$measureNode).clientHeight,width:(e||this.$measureNode).clientWidth/f};return t.width===0||t.height===0?null:t},this.$measureCharWidth=function(e){this.$main.textContent=s.stringRepeat(e,f);var t=this.$main.getBoundingClientRect();return t.width/f},this.getCharacterWidth=function(e){var t=this.charSizes[e];return t===undefined&&(t=this.charSizes[e]=this.$measureCharWidth(e)/this.$characterSize.width),t},this.destroy=function(){clearInterval(this.$pollSizeChangesTimer),this.$observer&&this.$observer.disconnect(),this.el&&this.el.parentNode&&this.el.parentNode.removeChild(this.el)},this.$getZoom=function e(t){return!t||!t.parentElement?1:(window.getComputedStyle(t).zoom||1)*e(t.parentElement)},this.$initTransformMeasureNodes=function(){var e=function(e,t){return["div",{style:"position: absolute;top:"+e+"px;left:"+t+"px;"}]};this.els=i.buildDom([e(0,0),e(c,0),e(0,c),e(c,c)],this.el)},this.transformCoordinates=function(e,t){function r(e,t,n){var r=e[1]*t[0]-e[0]*t[1];return[(-t[1]*n[0]+t[0]*n[1])/r,(+e[1]*n[0]-e[0]*n[1])/r]}function i(e,t){return[e[0]-t[0],e[1]-t[1]]}function s(e,t){return[e[0]+t[0],e[1]+t[1]]}function o(e,t){return[e*t[0],e*t[1]]}function u(e){var t=e.getBoundingClientRect();return[t.left,t.top]}if(e){var n=this.$getZoom(this.el);e=o(1/n,e)}this.els||this.$initTransformMeasureNodes();var a=u(this.els[0]),f=u(this.els[1]),l=u(this.els[2]),h=u(this.els[3]),p=r(i(h,f),i(h,l),i(s(f,l),s(h,a))),d=o(1+p[0],i(f,a)),v=o(1+p[1],i(l,a));if(t){var m=t,g=p[0]*m[0]/c+p[1]*m[1]/c+1,y=s(o(m[0],d),o(m[1],v));return s(o(1/g/c,y),a)}var b=i(e,a),w=r(i(d,o(p[0],b)),i(v,o(p[1],b)),b);return o(c,w)}}).call(h.prototype)}),ace.define("ace/virtual_renderer",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/config","ace/layer/gutter","ace/layer/marker","ace/layer/text","ace/layer/cursor","ace/scrollbar","ace/scrollbar","ace/renderloop","ace/layer/font_metrics","ace/lib/event_emitter","ace/lib/useragent"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./lib/dom"),s=e("./config"),o=e("./layer/gutter").Gutter,u=e("./layer/marker").Marker,a=e("./layer/text").Text,f=e("./layer/cursor").Cursor,l=e("./scrollbar").HScrollBar,c=e("./scrollbar").VScrollBar,h=e("./renderloop").RenderLoop,p=e("./layer/font_metrics").FontMetrics,d=e("./lib/event_emitter").EventEmitter,v='.ace_br1 {border-top-left-radius : 3px;}.ace_br2 {border-top-right-radius : 3px;}.ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}.ace_br4 {border-bottom-right-radius: 3px;}.ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}.ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}.ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}.ace_br8 {border-bottom-left-radius : 3px;}.ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}.ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}.ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}.ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}.ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}.ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}.ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}.ace_editor {position: relative;overflow: hidden;padding: 0;font: 12px/normal \'Monaco\', \'Menlo\', \'Ubuntu Mono\', \'Consolas\', \'source-code-pro\', monospace;direction: ltr;text-align: left;-webkit-tap-highlight-color: rgba(0, 0, 0, 0);}.ace_scroller {position: absolute;overflow: hidden;top: 0;bottom: 0;background-color: inherit;-ms-user-select: none;-moz-user-select: none;-webkit-user-select: none;user-select: none;cursor: text;}.ace_content {position: absolute;box-sizing: border-box;min-width: 100%;contain: style size layout;font-variant-ligatures: no-common-ligatures;}.ace_dragging .ace_scroller:before{position: absolute;top: 0;left: 0;right: 0;bottom: 0;content: \'\';background: rgba(250, 250, 250, 0.01);z-index: 1000;}.ace_dragging.ace_dark .ace_scroller:before{background: rgba(0, 0, 0, 0.01);}.ace_selecting, .ace_selecting * {cursor: text !important;}.ace_gutter {position: absolute;overflow : hidden;width: auto;top: 0;bottom: 0;left: 0;cursor: default;z-index: 4;-ms-user-select: none;-moz-user-select: none;-webkit-user-select: none;user-select: none;contain: style size layout;}.ace_gutter-active-line {position: absolute;left: 0;right: 0;}.ace_scroller.ace_scroll-left {box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;}.ace_gutter-cell {position: absolute;top: 0;left: 0;right: 0;padding-left: 19px;padding-right: 6px;background-repeat: no-repeat;}.ace_gutter-cell.ace_error {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAABOFBMVEX/////////QRswFAb/Ui4wFAYwFAYwFAaWGAfDRymzOSH/PxswFAb/SiUwFAYwFAbUPRvjQiDllog5HhHdRybsTi3/Tyv9Tir+Syj/UC3////XurebMBIwFAb/RSHbPx/gUzfdwL3kzMivKBAwFAbbvbnhPx66NhowFAYwFAaZJg8wFAaxKBDZurf/RB6mMxb/SCMwFAYwFAbxQB3+RB4wFAb/Qhy4Oh+4QifbNRcwFAYwFAYwFAb/QRzdNhgwFAYwFAbav7v/Uy7oaE68MBK5LxLewr/r2NXewLswFAaxJw4wFAbkPRy2PyYwFAaxKhLm1tMwFAazPiQwFAaUGAb/QBrfOx3bvrv/VC/maE4wFAbRPBq6MRO8Qynew8Dp2tjfwb0wFAbx6eju5+by6uns4uH9/f36+vr/GkHjAAAAYnRSTlMAGt+64rnWu/bo8eAA4InH3+DwoN7j4eLi4xP99Nfg4+b+/u9B/eDs1MD1mO7+4PHg2MXa347g7vDizMLN4eG+Pv7i5evs/v79yu7S3/DV7/498Yv24eH+4ufQ3Ozu/v7+y13sRqwAAADLSURBVHjaZc/XDsFgGIBhtDrshlitmk2IrbHFqL2pvXf/+78DPokj7+Fz9qpU/9UXJIlhmPaTaQ6QPaz0mm+5gwkgovcV6GZzd5JtCQwgsxoHOvJO15kleRLAnMgHFIESUEPmawB9ngmelTtipwwfASilxOLyiV5UVUyVAfbG0cCPHig+GBkzAENHS0AstVF6bacZIOzgLmxsHbt2OecNgJC83JERmePUYq8ARGkJx6XtFsdddBQgZE2nPR6CICZhawjA4Fb/chv+399kfR+MMMDGOQAAAABJRU5ErkJggg==");background-repeat: no-repeat;background-position: 2px center;}.ace_gutter-cell.ace_warning {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAmVBMVEX///8AAAD///8AAAAAAABPSzb/5sAAAAB/blH/73z/ulkAAAAAAAD85pkAAAAAAAACAgP/vGz/rkDerGbGrV7/pkQICAf////e0IsAAAD/oED/qTvhrnUAAAD/yHD/njcAAADuv2r/nz//oTj/p064oGf/zHAAAAA9Nir/tFIAAAD/tlTiuWf/tkIAAACynXEAAAAAAAAtIRW7zBpBAAAAM3RSTlMAABR1m7RXO8Ln31Z36zT+neXe5OzooRDfn+TZ4p3h2hTf4t3k3ucyrN1K5+Xaks52Sfs9CXgrAAAAjklEQVR42o3PbQ+CIBQFYEwboPhSYgoYunIqqLn6/z8uYdH8Vmdnu9vz4WwXgN/xTPRD2+sgOcZjsge/whXZgUaYYvT8QnuJaUrjrHUQreGczuEafQCO/SJTufTbroWsPgsllVhq3wJEk2jUSzX3CUEDJC84707djRc5MTAQxoLgupWRwW6UB5fS++NV8AbOZgnsC7BpEAAAAABJRU5ErkJggg==");background-position: 2px center;}.ace_gutter-cell.ace_info {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII=");background-position: 2px center;}.ace_dark .ace_gutter-cell.ace_info {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC");}.ace_scrollbar {contain: strict;position: absolute;right: 0;bottom: 0;z-index: 6;}.ace_scrollbar-inner {position: absolute;cursor: text;left: 0;top: 0;}.ace_scrollbar-v{overflow-x: hidden;overflow-y: scroll;top: 0;}.ace_scrollbar-h {overflow-x: scroll;overflow-y: hidden;left: 0;}.ace_print-margin {position: absolute;height: 100%;}.ace_text-input {position: absolute;z-index: 0;width: 0.5em;height: 1em;opacity: 0;background: transparent;-moz-appearance: none;appearance: none;border: none;resize: none;outline: none;overflow: hidden;font: inherit;padding: 0 1px;margin: 0 -1px;contain: strict;-ms-user-select: text;-moz-user-select: text;-webkit-user-select: text;user-select: text;white-space: pre!important;}.ace_text-input.ace_composition {background: transparent;color: inherit;z-index: 1000;opacity: 1;}.ace_composition_placeholder { color: transparent }.ace_composition_marker { border-bottom: 1px solid;position: absolute;border-radius: 0;margin-top: 1px;}[ace_nocontext=true] {transform: none!important;filter: none!important;clip-path: none!important;mask : none!important;contain: none!important;perspective: none!important;mix-blend-mode: initial!important;z-index: auto;}.ace_layer {z-index: 1;position: absolute;overflow: hidden;word-wrap: normal;white-space: pre;height: 100%;width: 100%;box-sizing: border-box;pointer-events: none;}.ace_gutter-layer {position: relative;width: auto;text-align: right;pointer-events: auto;height: 1000000px;contain: style size layout;}.ace_text-layer {font: inherit !important;position: absolute;height: 1000000px;width: 1000000px;contain: style size layout;}.ace_text-layer > .ace_line, .ace_text-layer > .ace_line_group {contain: style size layout;position: absolute;top: 0;left: 0;right: 0;}.ace_hidpi .ace_text-layer,.ace_hidpi .ace_gutter-layer,.ace_hidpi .ace_content,.ace_hidpi .ace_gutter {contain: strict;will-change: transform;}.ace_hidpi .ace_text-layer > .ace_line, .ace_hidpi .ace_text-layer > .ace_line_group {contain: strict;}.ace_cjk {display: inline-block;text-align: center;}.ace_cursor-layer {z-index: 4;}.ace_cursor {z-index: 4;position: absolute;box-sizing: border-box;border-left: 2px solid;transform: translatez(0);}.ace_multiselect .ace_cursor {border-left-width: 1px;}.ace_slim-cursors .ace_cursor {border-left-width: 1px;}.ace_overwrite-cursors .ace_cursor {border-left-width: 0;border-bottom: 1px solid;}.ace_hidden-cursors .ace_cursor {opacity: 0.2;}.ace_hasPlaceholder .ace_hidden-cursors .ace_cursor {opacity: 0;}.ace_smooth-blinking .ace_cursor {transition: opacity 0.18s;}.ace_animate-blinking .ace_cursor {animation-duration: 1000ms;animation-timing-function: step-end;animation-name: blink-ace-animate;animation-iteration-count: infinite;}.ace_animate-blinking.ace_smooth-blinking .ace_cursor {animation-duration: 1000ms;animation-timing-function: ease-in-out;animation-name: blink-ace-animate-smooth;}@keyframes blink-ace-animate {from, to { opacity: 1; }60% { opacity: 0; }}@keyframes blink-ace-animate-smooth {from, to { opacity: 1; }45% { opacity: 1; }60% { opacity: 0; }85% { opacity: 0; }}.ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {position: absolute;z-index: 3;}.ace_marker-layer .ace_selection {position: absolute;z-index: 5;}.ace_marker-layer .ace_bracket {position: absolute;z-index: 6;}.ace_marker-layer .ace_error_bracket {position: absolute;border-bottom: 1px solid #DE5555;border-radius: 0;}.ace_marker-layer .ace_active-line {position: absolute;z-index: 2;}.ace_marker-layer .ace_selected-word {position: absolute;z-index: 4;box-sizing: border-box;}.ace_line .ace_fold {box-sizing: border-box;display: inline-block;height: 11px;margin-top: -2px;vertical-align: middle;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII="),url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII=");background-repeat: no-repeat, repeat-x;background-position: center center, top left;color: transparent;border: 1px solid black;border-radius: 2px;cursor: pointer;pointer-events: auto;}.ace_dark .ace_fold {}.ace_fold:hover{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII="),url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC");}.ace_tooltip {background-color: #FFF;background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));border: 1px solid gray;border-radius: 1px;box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);color: black;max-width: 100%;padding: 3px 4px;position: fixed;z-index: 999999;box-sizing: border-box;cursor: default;white-space: pre;word-wrap: break-word;line-height: normal;font-style: normal;font-weight: normal;letter-spacing: normal;pointer-events: none;}.ace_folding-enabled > .ace_gutter-cell {padding-right: 13px;}.ace_fold-widget {box-sizing: border-box;margin: 0 -12px 0 1px;display: none;width: 11px;vertical-align: top;background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg==");background-repeat: no-repeat;background-position: center;border-radius: 3px;border: 1px solid transparent;cursor: pointer;}.ace_folding-enabled .ace_fold-widget {display: inline-block; }.ace_fold-widget.ace_end {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg==");}.ace_fold-widget.ace_closed {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA==");}.ace_fold-widget:hover {border: 1px solid rgba(0, 0, 0, 0.3);background-color: rgba(255, 255, 255, 0.2);box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);}.ace_fold-widget:active {border: 1px solid rgba(0, 0, 0, 0.4);background-color: rgba(0, 0, 0, 0.05);box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);}.ace_dark .ace_fold-widget {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC");}.ace_dark .ace_fold-widget.ace_end {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==");}.ace_dark .ace_fold-widget.ace_closed {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==");}.ace_dark .ace_fold-widget:hover {box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);background-color: rgba(255, 255, 255, 0.1);}.ace_dark .ace_fold-widget:active {box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);}.ace_inline_button {border: 1px solid lightgray;display: inline-block;margin: -1px 8px;padding: 0 5px;pointer-events: auto;cursor: pointer;}.ace_inline_button:hover {border-color: gray;background: rgba(200,200,200,0.2);display: inline-block;pointer-events: auto;}.ace_fold-widget.ace_invalid {background-color: #FFB4B4;border-color: #DE5555;}.ace_fade-fold-widgets .ace_fold-widget {transition: opacity 0.4s ease 0.05s;opacity: 0;}.ace_fade-fold-widgets:hover .ace_fold-widget {transition: opacity 0.05s ease 0.05s;opacity:1;}.ace_underline {text-decoration: underline;}.ace_bold {font-weight: bold;}.ace_nobold .ace_bold {font-weight: normal;}.ace_italic {font-style: italic;}.ace_error-marker {background-color: rgba(255, 0, 0,0.2);position: absolute;z-index: 9;}.ace_highlight-marker {background-color: rgba(255, 255, 0,0.2);position: absolute;z-index: 8;}.ace_mobile-menu {position: absolute;line-height: 1.5;border-radius: 4px;-ms-user-select: none;-moz-user-select: none;-webkit-user-select: none;user-select: none;background: white;box-shadow: 1px 3px 2px grey;border: 1px solid #dcdcdc;color: black;}.ace_dark > .ace_mobile-menu {background: #333;color: #ccc;box-shadow: 1px 3px 2px grey;border: 1px solid #444;}.ace_mobile-button {padding: 2px;cursor: pointer;overflow: hidden;}.ace_mobile-button:hover {background-color: #eee;opacity:1;}.ace_mobile-button:active {background-color: #ddd;}.ace_placeholder {font-family: arial;transform: scale(0.9);transform-origin: left;white-space: pre;opacity: 0.7;margin: 0 10px;}',m=e("./lib/useragent"),g=m.isIE;i.importCssString(v,"ace_editor.css");var y=function(e,t){var n=this;this.container=e||i.createElement("div"),i.addCssClass(this.container,"ace_editor"),i.HI_DPI&&i.addCssClass(this.container,"ace_hidpi"),this.setTheme(t),this.$gutter=i.createElement("div"),this.$gutter.className="ace_gutter",this.container.appendChild(this.$gutter),this.$gutter.setAttribute("aria-hidden",!0),this.scroller=i.createElement("div"),this.scroller.className="ace_scroller",this.container.appendChild(this.scroller),this.content=i.createElement("div"),this.content.className="ace_content",this.scroller.appendChild(this.content),this.$gutterLayer=new o(this.$gutter),this.$gutterLayer.on("changeGutterWidth",this.onGutterResize.bind(this)),this.$markerBack=new u(this.content);var r=this.$textLayer=new a(this.content);this.canvas=r.element,this.$markerFront=new u(this.content),this.$cursorLayer=new f(this.content),this.$horizScroll=!1,this.$vScroll=!1,this.scrollBar=this.scrollBarV=new c(this.container,this),this.scrollBarH=new l(this.container,this),this.scrollBarV.on("scroll",function(e){n.$scrollAnimation||n.session.setScrollTop(e.data-n.scrollMargin.top)}),this.scrollBarH.on("scroll",function(e){n.$scrollAnimation||n.session.setScrollLeft(e.data-n.scrollMargin.left)}),this.scrollTop=0,this.scrollLeft=0,this.cursorPos={row:0,column:0},this.$fontMetrics=new p(this.container),this.$textLayer.$setFontMetrics(this.$fontMetrics),this.$textLayer.on("changeCharacterSize",function(e){n.updateCharacterSize(),n.onResize(!0,n.gutterWidth,n.$size.width,n.$size.height),n._signal("changeCharacterSize",e)}),this.$size={width:0,height:0,scrollerHeight:0,scrollerWidth:0,$dirty:!0},this.layerConfig={width:1,padding:0,firstRow:0,firstRowScreen:0,lastRow:0,lineHeight:0,characterWidth:0,minHeight:1,maxHeight:1,offset:0,height:1,gutterOffset:1},this.scrollMargin={left:0,right:0,top:0,bottom:0,v:0,h:0},this.margin={left:0,right:0,top:0,bottom:0,v:0,h:0},this.$keepTextAreaAtCursor=!m.isIOS,this.$loop=new h(this.$renderChanges.bind(this),this.container.ownerDocument.defaultView),this.$loop.schedule(this.CHANGE_FULL),this.updateCharacterSize(),this.setPadding(4),s.resetOptions(this),s._signal("renderer",this)};(function(){this.CHANGE_CURSOR=1,this.CHANGE_MARKER=2,this.CHANGE_GUTTER=4,this.CHANGE_SCROLL=8,this.CHANGE_LINES=16,this.CHANGE_TEXT=32,this.CHANGE_SIZE=64,this.CHANGE_MARKER_BACK=128,this.CHANGE_MARKER_FRONT=256,this.CHANGE_FULL=512,this.CHANGE_H_SCROLL=1024,r.implement(this,d),this.updateCharacterSize=function(){this.$textLayer.allowBoldFonts!=this.$allowBoldFonts&&(this.$allowBoldFonts=this.$textLayer.allowBoldFonts,this.setStyle("ace_nobold",!this.$allowBoldFonts)),this.layerConfig.characterWidth=this.characterWidth=this.$textLayer.getCharacterWidth(),this.layerConfig.lineHeight=this.lineHeight=this.$textLayer.getLineHeight(),this.$updatePrintMargin(),i.setStyle(this.scroller.style,"line-height",this.lineHeight+"px")},this.setSession=function(e){this.session&&this.session.doc.off("changeNewLineMode",this.onChangeNewLineMode),this.session=e,e&&this.scrollMargin.top&&e.getScrollTop()<=0&&e.setScrollTop(-this.scrollMargin.top),this.$cursorLayer.setSession(e),this.$markerBack.setSession(e),this.$markerFront.setSession(e),this.$gutterLayer.setSession(e),this.$textLayer.setSession(e);if(!e)return;this.$loop.schedule(this.CHANGE_FULL),this.session.$setFontMetrics(this.$fontMetrics),this.scrollBarH.scrollLeft=this.scrollBarV.scrollTop=null,this.onChangeNewLineMode=this.onChangeNewLineMode.bind(this),this.onChangeNewLineMode(),this.session.doc.on("changeNewLineMode",this.onChangeNewLineMode)},this.updateLines=function(e,t,n){t===undefined&&(t=Infinity),this.$changedLines?(this.$changedLines.firstRow>e&&(this.$changedLines.firstRow=e),this.$changedLines.lastRow<t&&(this.$changedLines.lastRow=t)):this.$changedLines={firstRow:e,lastRow:t};if(this.$changedLines.lastRow<this.layerConfig.firstRow){if(!n)return;this.$changedLines.lastRow=this.layerConfig.lastRow}if(this.$changedLines.firstRow>this.layerConfig.lastRow)return;this.$loop.schedule(this.CHANGE_LINES)},this.onChangeNewLineMode=function(){this.$loop.schedule(this.CHANGE_TEXT),this.$textLayer.$updateEolChar(),this.session.$bidiHandler.setEolChar(this.$textLayer.EOL_CHAR)},this.onChangeTabSize=function(){this.$loop.schedule(this.CHANGE_TEXT|this.CHANGE_MARKER),this.$textLayer.onChangeTabSize()},this.updateText=function(){this.$loop.schedule(this.CHANGE_TEXT)},this.updateFull=function(e){e?this.$renderChanges(this.CHANGE_FULL,!0):this.$loop.schedule(this.CHANGE_FULL)},this.updateFontSize=function(){this.$textLayer.checkForSizeChanges()},this.$changes=0,this.$updateSizeAsync=function(){this.$loop.pending?this.$size.$dirty=!0:this.onResize()},this.onResize=function(e,t,n,r){if(this.resizing>2)return;this.resizing>0?this.resizing++:this.resizing=e?1:0;var i=this.container;r||(r=i.clientHeight||i.scrollHeight),n||(n=i.clientWidth||i.scrollWidth);var s=this.$updateCachedSize(e,t,n,r);if(!this.$size.scrollerHeight||!n&&!r)return this.resizing=0;e&&(this.$gutterLayer.$padding=null),e?this.$renderChanges(s|this.$changes,!0):this.$loop.schedule(s|this.$changes),this.resizing&&(this.resizing=0),this.scrollBarV.scrollLeft=this.scrollBarV.scrollTop=null},this.$updateCachedSize=function(e,t,n,r){r-=this.$extraHeight||0;var s=0,o=this.$size,u={width:o.width,height:o.height,scrollerHeight:o.scrollerHeight,scrollerWidth:o.scrollerWidth};r&&(e||o.height!=r)&&(o.height=r,s|=this.CHANGE_SIZE,o.scrollerHeight=o.height,this.$horizScroll&&(o.scrollerHeight-=this.scrollBarH.getHeight()),this.scrollBarV.element.style.bottom=this.scrollBarH.getHeight()+"px",s|=this.CHANGE_SCROLL);if(n&&(e||o.width!=n)){s|=this.CHANGE_SIZE,o.width=n,t==null&&(t=this.$showGutter?this.$gutter.offsetWidth:0),this.gutterWidth=t,i.setStyle(this.scrollBarH.element.style,"left",t+"px"),i.setStyle(this.scroller.style,"left",t+this.margin.left+"px"),o.scrollerWidth=Math.max(0,n-t-this.scrollBarV.getWidth()-this.margin.h),i.setStyle(this.$gutter.style,"left",this.margin.left+"px");var a=this.scrollBarV.getWidth()+"px";i.setStyle(this.scrollBarH.element.style,"right",a),i.setStyle(this.scroller.style,"right",a),i.setStyle(this.scroller.style,"bottom",this.scrollBarH.getHeight());if(this.session&&this.session.getUseWrapMode()&&this.adjustWrapLimit()||e)s|=this.CHANGE_FULL}return o.$dirty=!n||!r,s&&this._signal("resize",u),s},this.onGutterResize=function(e){var t=this.$showGutter?e:0;t!=this.gutterWidth&&(this.$changes|=this.$updateCachedSize(!0,t,this.$size.width,this.$size.height)),this.session.getUseWrapMode()&&this.adjustWrapLimit()?this.$loop.schedule(this.CHANGE_FULL):this.$size.$dirty?this.$loop.schedule(this.CHANGE_FULL):this.$computeLayerConfig()},this.adjustWrapLimit=function(){var e=this.$size.scrollerWidth-this.$padding*2,t=Math.floor(e/this.characterWidth);return this.session.adjustWrapLimit(t,this.$showPrintMargin&&this.$printMarginColumn)},this.setAnimatedScroll=function(e){this.setOption("animatedScroll",e)},this.getAnimatedScroll=function(){return this.$animatedScroll},this.setShowInvisibles=function(e){this.setOption("showInvisibles",e),this.session.$bidiHandler.setShowInvisibles(e)},this.getShowInvisibles=function(){return this.getOption("showInvisibles")},this.getDisplayIndentGuides=function(){return this.getOption("displayIndentGuides")},this.setDisplayIndentGuides=function(e){this.setOption("displayIndentGuides",e)},this.setShowPrintMargin=function(e){this.setOption("showPrintMargin",e)},this.getShowPrintMargin=function(){return this.getOption("showPrintMargin")},this.setPrintMarginColumn=function(e){this.setOption("printMarginColumn",e)},this.getPrintMarginColumn=function(){return this.getOption("printMarginColumn")},this.getShowGutter=function(){return this.getOption("showGutter")},this.setShowGutter=function(e){return this.setOption("showGutter",e)},this.getFadeFoldWidgets=function(){return this.getOption("fadeFoldWidgets")},this.setFadeFoldWidgets=function(e){this.setOption("fadeFoldWidgets",e)},this.setHighlightGutterLine=function(e){this.setOption("highlightGutterLine",e)},this.getHighlightGutterLine=function(){return this.getOption("highlightGutterLine")},this.$updatePrintMargin=function(){if(!this.$showPrintMargin&&!this.$printMarginEl)return;if(!this.$printMarginEl){var e=i.createElement("div");e.className="ace_layer ace_print-margin-layer",this.$printMarginEl=i.createElement("div"),this.$printMarginEl.className="ace_print-margin",e.appendChild(this.$printMarginEl),this.content.insertBefore(e,this.content.firstChild)}var t=this.$printMarginEl.style;t.left=Math.round(this.characterWidth*this.$printMarginColumn+this.$padding)+"px",t.visibility=this.$showPrintMargin?"visible":"hidden",this.session&&this.session.$wrap==-1&&this.adjustWrapLimit()},this.getContainerElement=function(){return this.container},this.getMouseEventTarget=function(){return this.scroller},this.getTextAreaContainer=function(){return this.container},this.$moveTextAreaToCursor=function(){if(this.$isMousePressed)return;var e=this.textarea.style,t=this.$composition;if(!this.$keepTextAreaAtCursor&&!t){i.translate(this.textarea,-100,0);return}var n=this.$cursorLayer.$pixelPos;if(!n)return;t&&t.markerRange&&(n=this.$cursorLayer.getPixelPosition(t.markerRange.start,!0));var r=this.layerConfig,s=n.top,o=n.left;s-=r.offset;var u=t&&t.useTextareaForIME?this.lineHeight:g?0:1;if(s<0||s>r.height-u){i.translate(this.textarea,0,0);return}var a=1,f=this.$size.height-u;if(!t)s+=this.lineHeight;else if(t.useTextareaForIME){var l=this.textarea.value;a=this.characterWidth*this.session.$getStringScreenWidth(l)[0]}else s+=this.lineHeight+2;o-=this.scrollLeft,o>this.$size.scrollerWidth-a&&(o=this.$size.scrollerWidth-a),o+=this.gutterWidth+this.margin.left,i.setStyle(e,"height",u+"px"),i.setStyle(e,"width",a+"px"),i.translate(this.textarea,Math.min(o,this.$size.scrollerWidth-a),Math.min(s,f))},this.getFirstVisibleRow=function(){return this.layerConfig.firstRow},this.getFirstFullyVisibleRow=function(){return this.layerConfig.firstRow+(this.layerConfig.offset===0?0:1)},this.getLastFullyVisibleRow=function(){var e=this.layerConfig,t=e.lastRow,n=this.session.documentToScreenRow(t,0)*e.lineHeight;return n-this.session.getScrollTop()>e.height-e.lineHeight?t-1:t},this.getLastVisibleRow=function(){return this.layerConfig.lastRow},this.$padding=null,this.setPadding=function(e){this.$padding=e,this.$textLayer.setPadding(e),this.$cursorLayer.setPadding(e),this.$markerFront.setPadding(e),this.$markerBack.setPadding(e),this.$loop.schedule(this.CHANGE_FULL),this.$updatePrintMargin()},this.setScrollMargin=function(e,t,n,r){var i=this.scrollMargin;i.top=e|0,i.bottom=t|0,i.right=r|0,i.left=n|0,i.v=i.top+i.bottom,i.h=i.left+i.right,i.top&&this.scrollTop<=0&&this.session&&this.session.setScrollTop(-i.top),this.updateFull()},this.setMargin=function(e,t,n,r){var i=this.margin;i.top=e|0,i.bottom=t|0,i.right=r|0,i.left=n|0,i.v=i.top+i.bottom,i.h=i.left+i.right,this.$updateCachedSize(!0,this.gutterWidth,this.$size.width,this.$size.height),this.updateFull()},this.getHScrollBarAlwaysVisible=function(){return this.$hScrollBarAlwaysVisible},this.setHScrollBarAlwaysVisible=function(e){this.setOption("hScrollBarAlwaysVisible",e)},this.getVScrollBarAlwaysVisible=function(){return this.$vScrollBarAlwaysVisible},this.setVScrollBarAlwaysVisible=function(e){this.setOption("vScrollBarAlwaysVisible",e)},this.$updateScrollBarV=function(){var e=this.layerConfig.maxHeight,t=this.$size.scrollerHeight;!this.$maxLines&&this.$scrollPastEnd&&(e-=(t-this.lineHeight)*this.$scrollPastEnd,this.scrollTop>e-t&&(e=this.scrollTop+t,this.scrollBarV.scrollTop=null)),this.scrollBarV.setScrollHeight(e+this.scrollMargin.v),this.scrollBarV.setScrollTop(this.scrollTop+this.scrollMargin.top)},this.$updateScrollBarH=function(){this.scrollBarH.setScrollWidth(this.layerConfig.width+2*this.$padding+this.scrollMargin.h),this.scrollBarH.setScrollLeft(this.scrollLeft+this.scrollMargin.left)},this.$frozen=!1,this.freeze=function(){this.$frozen=!0},this.unfreeze=function(){this.$frozen=!1},this.$renderChanges=function(e,t){this.$changes&&(e|=this.$changes,this.$changes=0);if(!this.session||!this.container.offsetWidth||this.$frozen||!e&&!t){this.$changes|=e;return}if(this.$size.$dirty)return this.$changes|=e,this.onResize(!0);this.lineHeight||this.$textLayer.checkForSizeChanges(),this._signal("beforeRender",e),this.session&&this.session.$bidiHandler&&this.session.$bidiHandler.updateCharacterWidths(this.$fontMetrics);var n=this.layerConfig;if(e&this.CHANGE_FULL||e&this.CHANGE_SIZE||e&this.CHANGE_TEXT||e&this.CHANGE_LINES||e&this.CHANGE_SCROLL||e&this.CHANGE_H_SCROLL){e|=this.$computeLayerConfig()|this.$loop.clear();if(n.firstRow!=this.layerConfig.firstRow&&n.firstRowScreen==this.layerConfig.firstRowScreen){var r=this.scrollTop+(n.firstRow-this.layerConfig.firstRow)*this.lineHeight;r>0&&(this.scrollTop=r,e|=this.CHANGE_SCROLL,e|=this.$computeLayerConfig()|this.$loop.clear())}n=this.layerConfig,this.$updateScrollBarV(),e&this.CHANGE_H_SCROLL&&this.$updateScrollBarH(),i.translate(this.content,-this.scrollLeft,-n.offset);var s=n.width+2*this.$padding+"px",o=n.minHeight+"px";i.setStyle(this.content.style,"width",s),i.setStyle(this.content.style,"height",o)}e&this.CHANGE_H_SCROLL&&(i.translate(this.content,-this.scrollLeft,-n.offset),this.scroller.className=this.scrollLeft<=0?"ace_scroller":"ace_scroller ace_scroll-left");if(e&this.CHANGE_FULL){this.$changedLines=null,this.$textLayer.update(n),this.$showGutter&&this.$gutterLayer.update(n),this.$markerBack.update(n),this.$markerFront.update(n),this.$cursorLayer.update(n),this.$moveTextAreaToCursor(),this._signal("afterRender",e);return}if(e&this.CHANGE_SCROLL){this.$changedLines=null,e&this.CHANGE_TEXT||e&this.CHANGE_LINES?this.$textLayer.update(n):this.$textLayer.scrollLines(n),this.$showGutter&&(e&this.CHANGE_GUTTER||e&this.CHANGE_LINES?this.$gutterLayer.update(n):this.$gutterLayer.scrollLines(n)),this.$markerBack.update(n),this.$markerFront.update(n),this.$cursorLayer.update(n),this.$moveTextAreaToCursor(),this._signal("afterRender",e);return}e&this.CHANGE_TEXT?(this.$changedLines=null,this.$textLayer.update(n),this.$showGutter&&this.$gutterLayer.update(n)):e&this.CHANGE_LINES?(this.$updateLines()||e&this.CHANGE_GUTTER&&this.$showGutter)&&this.$gutterLayer.update(n):e&this.CHANGE_TEXT||e&this.CHANGE_GUTTER?this.$showGutter&&this.$gutterLayer.update(n):e&this.CHANGE_CURSOR&&this.$highlightGutterLine&&this.$gutterLayer.updateLineHighlight(n),e&this.CHANGE_CURSOR&&(this.$cursorLayer.update(n),this.$moveTextAreaToCursor()),e&(this.CHANGE_MARKER|this.CHANGE_MARKER_FRONT)&&this.$markerFront.update(n),e&(this.CHANGE_MARKER|this.CHANGE_MARKER_BACK)&&this.$markerBack.update(n),this._signal("afterRender",e)},this.$autosize=function(){var e=this.session.getScreenLength()*this.lineHeight,t=this.$maxLines*this.lineHeight,n=Math.min(t,Math.max((this.$minLines||1)*this.lineHeight,e))+this.scrollMargin.v+(this.$extraHeight||0);this.$horizScroll&&(n+=this.scrollBarH.getHeight()),this.$maxPixelHeight&&n>this.$maxPixelHeight&&(n=this.$maxPixelHeight);var r=n<=2*this.lineHeight,i=!r&&e>t;if(n!=this.desiredHeight||this.$size.height!=this.desiredHeight||i!=this.$vScroll){i!=this.$vScroll&&(this.$vScroll=i,this.scrollBarV.setVisible(i));var s=this.container.clientWidth;this.container.style.height=n+"px",this.$updateCachedSize(!0,this.$gutterWidth,s,n),this.desiredHeight=n,this._signal("autosize")}},this.$computeLayerConfig=function(){var e=this.session,t=this.$size,n=t.height<=2*this.lineHeight,r=this.session.getScreenLength(),i=r*this.lineHeight,s=this.$getLongestLine(),o=!n&&(this.$hScrollBarAlwaysVisible||t.scrollerWidth-s-2*this.$padding<0),u=this.$horizScroll!==o;u&&(this.$horizScroll=o,this.scrollBarH.setVisible(o));var a=this.$vScroll;this.$maxLines&&this.lineHeight>1&&this.$autosize();var f=t.scrollerHeight+this.lineHeight,l=!this.$maxLines&&this.$scrollPastEnd?(t.scrollerHeight-this.lineHeight)*this.$scrollPastEnd:0;i+=l;var c=this.scrollMargin;this.session.setScrollTop(Math.max(-c.top,Math.min(this.scrollTop,i-t.scrollerHeight+c.bottom))),this.session.setScrollLeft(Math.max(-c.left,Math.min(this.scrollLeft,s+2*this.$padding-t.scrollerWidth+c.right)));var h=!n&&(this.$vScrollBarAlwaysVisible||t.scrollerHeight-i+l<0||this.scrollTop>c.top),p=a!==h;p&&(this.$vScroll=h,this.scrollBarV.setVisible(h));var d=this.scrollTop%this.lineHeight,v=Math.ceil(f/this.lineHeight)-1,m=Math.max(0,Math.round((this.scrollTop-d)/this.lineHeight)),g=m+v,y,b,w=this.lineHeight;m=e.screenToDocumentRow(m,0);var E=e.getFoldLine(m);E&&(m=E.start.row),y=e.documentToScreenRow(m,0),b=e.getRowLength(m)*w,g=Math.min(e.screenToDocumentRow(g,0),e.getLength()-1),f=t.scrollerHeight+e.getRowLength(g)*w+b,d=this.scrollTop-y*w;var S=0;if(this.layerConfig.width!=s||u)S=this.CHANGE_H_SCROLL;if(u||p)S|=this.$updateCachedSize(!0,this.gutterWidth,t.width,t.height),this._signal("scrollbarVisibilityChanged"),p&&(s=this.$getLongestLine());return this.layerConfig={width:s,padding:this.$padding,firstRow:m,firstRowScreen:y,lastRow:g,lineHeight:w,characterWidth:this.characterWidth,minHeight:f,maxHeight:i,offset:d,gutterOffset:w?Math.max(0,Math.ceil((d+t.height-t.scrollerHeight)/w)):0,height:this.$size.scrollerHeight},this.session.$bidiHandler&&this.session.$bidiHandler.setContentWidth(s-this.$padding),S},this.$updateLines=function(){if(!this.$changedLines)return;var e=this.$changedLines.firstRow,t=this.$changedLines.lastRow;this.$changedLines=null;var n=this.layerConfig;if(e>n.lastRow+1)return;if(t<n.firstRow)return;if(t===Infinity){this.$showGutter&&this.$gutterLayer.update(n),this.$textLayer.update(n);return}return this.$textLayer.updateLines(n,e,t),!0},this.$getLongestLine=function(){var e=this.session.getScreenWidth();return this.showInvisibles&&!this.session.$useWrapMode&&(e+=1),this.$textLayer&&e>this.$textLayer.MAX_LINE_LENGTH&&(e=this.$textLayer.MAX_LINE_LENGTH+30),Math.max(this.$size.scrollerWidth-2*this.$padding,Math.round(e*this.characterWidth))},this.updateFrontMarkers=function(){this.$markerFront.setMarkers(this.session.getMarkers(!0)),this.$loop.schedule(this.CHANGE_MARKER_FRONT)},this.updateBackMarkers=function(){this.$markerBack.setMarkers(this.session.getMarkers()),this.$loop.schedule(this.CHANGE_MARKER_BACK)},this.addGutterDecoration=function(e,t){this.$gutterLayer.addGutterDecoration(e,t)},this.removeGutterDecoration=function(e,t){this.$gutterLayer.removeGutterDecoration(e,t)},this.updateBreakpoints=function(e){this.$loop.schedule(this.CHANGE_GUTTER)},this.setAnnotations=function(e){this.$gutterLayer.setAnnotations(e),this.$loop.schedule(this.CHANGE_GUTTER)},this.updateCursor=function(){this.$loop.schedule(this.CHANGE_CURSOR)},this.hideCursor=function(){this.$cursorLayer.hideCursor()},this.showCursor=function(){this.$cursorLayer.showCursor()},this.scrollSelectionIntoView=function(e,t,n){this.scrollCursorIntoView(e,n),this.scrollCursorIntoView(t,n)},this.scrollCursorIntoView=function(e,t,n){if(this.$size.scrollerHeight===0)return;var r=this.$cursorLayer.getPixelPosition(e),i=r.left,s=r.top,o=n&&n.top||0,u=n&&n.bottom||0,a=this.$scrollAnimation?this.session.getScrollTop():this.scrollTop;a+o>s?(t&&a+o>s+this.lineHeight&&(s-=t*this.$size.scrollerHeight),s===0&&(s=-this.scrollMargin.top),this.session.setScrollTop(s)):a+this.$size.scrollerHeight-u<s+this.lineHeight&&(t&&a+this.$size.scrollerHeight-u<s-this.lineHeight&&(s+=t*this.$size.scrollerHeight),this.session.setScrollTop(s+this.lineHeight+u-this.$size.scrollerHeight));var f=this.scrollLeft;f>i?(i<this.$padding+2*this.layerConfig.characterWidth&&(i=-this.scrollMargin.left),this.session.setScrollLeft(i)):f+this.$size.scrollerWidth<i+this.characterWidth?this.session.setScrollLeft(Math.round(i+this.characterWidth-this.$size.scrollerWidth)):f<=this.$padding&&i-f<this.characterWidth&&this.session.setScrollLeft(0)},this.getScrollTop=function(){return this.session.getScrollTop()},this.getScrollLeft=function(){return this.session.getScrollLeft()},this.getScrollTopRow=function(){return this.scrollTop/this.lineHeight},this.getScrollBottomRow=function(){return Math.max(0,Math.floor((this.scrollTop+this.$size.scrollerHeight)/this.lineHeight)-1)},this.scrollToRow=function(e){this.session.setScrollTop(e*this.lineHeight)},this.alignCursor=function(e,t){typeof e=="number"&&(e={row:e,column:0});var n=this.$cursorLayer.getPixelPosition(e),r=this.$size.scrollerHeight-this.lineHeight,i=n.top-r*(t||0);return this.session.setScrollTop(i),i},this.STEPS=8,this.$calcSteps=function(e,t){var n=0,r=this.STEPS,i=[],s=function(e,t,n){return n*(Math.pow(e-1,3)+1)+t};for(n=0;n<r;++n)i.push(s(n/this.STEPS,e,t-e));return i},this.scrollToLine=function(e,t,n,r){var i=this.$cursorLayer.getPixelPosition({row:e,column:0}),s=i.top;t&&(s-=this.$size.scrollerHeight/2);var o=this.scrollTop;this.session.setScrollTop(s),n!==!1&&this.animateScrolling(o,r)},this.animateScrolling=function(e,t){var n=this.scrollTop;if(!this.$animatedScroll)return;var r=this;if(e==n)return;if(this.$scrollAnimation){var i=this.$scrollAnimation.steps;if(i.length){e=i[0];if(e==n)return}}var s=r.$calcSteps(e,n);this.$scrollAnimation={from:e,to:n,steps:s},clearInterval(this.$timer),r.session.setScrollTop(s.shift()),r.session.$scrollTop=n,this.$timer=setInterval(function(){if(!r.session)return clearInterval(r.$timer);s.length?(r.session.setScrollTop(s.shift()),r.session.$scrollTop=n):n!=null?(r.session.$scrollTop=-1,r.session.setScrollTop(n),n=null):(r.$timer=clearInterval(r.$timer),r.$scrollAnimation=null,t&&t())},10)},this.scrollToY=function(e){this.scrollTop!==e&&(this.$loop.schedule(this.CHANGE_SCROLL),this.scrollTop=e)},this.scrollToX=function(e){this.scrollLeft!==e&&(this.scrollLeft=e),this.$loop.schedule(this.CHANGE_H_SCROLL)},this.scrollTo=function(e,t){this.session.setScrollTop(t),this.session.setScrollLeft(t)},this.scrollBy=function(e,t){t&&this.session.setScrollTop(this.session.getScrollTop()+t),e&&this.session.setScrollLeft(this.session.getScrollLeft()+e)},this.isScrollableBy=function(e,t){if(t<0&&this.session.getScrollTop()>=1-this.scrollMargin.top)return!0;if(t>0&&this.session.getScrollTop()+this.$size.scrollerHeight-this.layerConfig.maxHeight<-1+this.scrollMargin.bottom)return!0;if(e<0&&this.session.getScrollLeft()>=1-this.scrollMargin.left)return!0;if(e>0&&this.session.getScrollLeft()+this.$size.scrollerWidth-this.layerConfig.width<-1+this.scrollMargin.right)return!0},this.pixelToScreenCoordinates=function(e,t){var n;if(this.$hasCssTransforms){n={top:0,left:0};var r=this.$fontMetrics.transformCoordinates([e,t]);e=r[1]-this.gutterWidth-this.margin.left,t=r[0]}else n=this.scroller.getBoundingClientRect();var i=e+this.scrollLeft-n.left-this.$padding,s=i/this.characterWidth,o=Math.floor((t+this.scrollTop-n.top)/this.lineHeight),u=this.$blockCursor?Math.floor(s):Math.round(s);return{row:o,column:u,side:s-u>0?1:-1,offsetX:i}},this.screenToTextCoordinates=function(e,t){var n;if(this.$hasCssTransforms){n={top:0,left:0};var r=this.$fontMetrics.transformCoordinates([e,t]);e=r[1]-this.gutterWidth-this.margin.left,t=r[0]}else n=this.scroller.getBoundingClientRect();var i=e+this.scrollLeft-n.left-this.$padding,s=i/this.characterWidth,o=this.$blockCursor?Math.floor(s):Math.round(s),u=Math.floor((t+this.scrollTop-n.top)/this.lineHeight);return this.session.screenToDocumentPosition(u,Math.max(o,0),i)},this.textToScreenCoordinates=function(e,t){var n=this.scroller.getBoundingClientRect(),r=this.session.documentToScreenPosition(e,t),i=this.$padding+(this.session.$bidiHandler.isBidiRow(r.row,e)?this.session.$bidiHandler.getPosLeft(r.column):Math.round(r.column*this.characterWidth)),s=r.row*this.lineHeight;return{pageX:n.left+i-this.scrollLeft,pageY:n.top+s-this.scrollTop}},this.visualizeFocus=function(){i.addCssClass(this.container,"ace_focus")},this.visualizeBlur=function(){i.removeCssClass(this.container,"ace_focus")},this.showComposition=function(e){this.$composition=e,e.cssText||(e.cssText=this.textarea.style.cssText),e.useTextareaForIME==undefined&&(e.useTextareaForIME=this.$useTextareaForIME),this.$useTextareaForIME?(i.addCssClass(this.textarea,"ace_composition"),this.textarea.style.cssText="",this.$moveTextAreaToCursor(),this.$cursorLayer.element.style.display="none"):e.markerId=this.session.addMarker(e.markerRange,"ace_composition_marker","text")},this.setCompositionText=function(e){var t=this.session.selection.cursor;this.addToken(e,"composition_placeholder",t.row,t.column),this.$moveTextAreaToCursor()},this.hideComposition=function(){if(!this.$composition)return;this.$composition.markerId&&this.session.removeMarker(this.$composition.markerId),i.removeCssClass(this.textarea,"ace_composition"),this.textarea.style.cssText=this.$composition.cssText;var e=this.session.selection.cursor;this.removeExtraToken(e.row,e.column),this.$composition=null,this.$cursorLayer.element.style.display=""},this.addToken=function(e,t,n,r){var i=this.session;i.bgTokenizer.lines[n]=null;var s={type:t,value:e},o=i.getTokens(n);if(r==null)o.push(s);else{var u=0;for(var a=0;a<o.length;a++){var f=o[a];u+=f.value.length;if(r<=u){var l=f.value.length-(u-r),c=f.value.slice(0,l),h=f.value.slice(l);o.splice(a,1,{type:f.type,value:c},s,{type:f.type,value:h});break}}}this.updateLines(n,n)},this.removeExtraToken=function(e,t){this.updateLines(e,e)},this.setTheme=function(e,t){function o(r){if(n.$themeId!=e)return t&&t();if(!r||!r.cssClass)throw new Error("couldn't load module "+e+" or it didn't call define");r.$id&&(n.$themeId=r.$id),i.importCssString(r.cssText,r.cssClass,n.container),n.theme&&i.removeCssClass(n.container,n.theme.cssClass);var s="padding"in r?r.padding:"padding"in(n.theme||{})?4:n.$padding;n.$padding&&s!=n.$padding&&n.setPadding(s),n.$theme=r.cssClass,n.theme=r,i.addCssClass(n.container,r.cssClass),i.setCssClass(n.container,"ace_dark",r.isDark),n.$size&&(n.$size.width=0,n.$updateSizeAsync()),n._dispatchEvent("themeLoaded",{theme:r}),t&&t()}var n=this;this.$themeId=e,n._dispatchEvent("themeChange",{theme:e});if(!e||typeof e=="string"){var r=e||this.$options.theme.initialValue;s.loadModule(["theme",r],o)}else o(e)},this.getTheme=function(){return this.$themeId},this.setStyle=function(e,t){i.setCssClass(this.container,e,t!==!1)},this.unsetStyle=function(e){i.removeCssClass(this.container,e)},this.setCursorStyle=function(e){i.setStyle(this.scroller.style,"cursor",e)},this.setMouseCursor=function(e){i.setStyle(this.scroller.style,"cursor",e)},this.attachToShadowRoot=function(){i.importCssString(v,"ace_editor.css",this.container)},this.destroy=function(){this.freeze(),this.$fontMetrics.destroy(),this.$cursorLayer.destroy(),this.removeAllListeners(),this.container.textContent=""}}).call(y.prototype),s.defineOptions(y.prototype,"renderer",{animatedScroll:{initialValue:!1},showInvisibles:{set:function(e){this.$textLayer.setShowInvisibles(e)&&this.$loop.schedule(this.CHANGE_TEXT)},initialValue:!1},showPrintMargin:{set:function(){this.$updatePrintMargin()},initialValue:!0},printMarginColumn:{set:function(){this.$updatePrintMargin()},initialValue:80},printMargin:{set:function(e){typeof e=="number"&&(this.$printMarginColumn=e),this.$showPrintMargin=!!e,this.$updatePrintMargin()},get:function(){return this.$showPrintMargin&&this.$printMarginColumn}},showGutter:{set:function(e){this.$gutter.style.display=e?"block":"none",this.$loop.schedule(this.CHANGE_FULL),this.onGutterResize()},initialValue:!0},fadeFoldWidgets:{set:function(e){i.setCssClass(this.$gutter,"ace_fade-fold-widgets",e)},initialValue:!1},showFoldWidgets:{set:function(e){this.$gutterLayer.setShowFoldWidgets(e),this.$loop.schedule(this.CHANGE_GUTTER)},initialValue:!0},displayIndentGuides:{set:function(e){this.$textLayer.setDisplayIndentGuides(e)&&this.$loop.schedule(this.CHANGE_TEXT)},initialValue:!0},highlightGutterLine:{set:function(e){this.$gutterLayer.setHighlightGutterLine(e),this.$loop.schedule(this.CHANGE_GUTTER)},initialValue:!0},hScrollBarAlwaysVisible:{set:function(e){(!this.$hScrollBarAlwaysVisible||!this.$horizScroll)&&this.$loop.schedule(this.CHANGE_SCROLL)},initialValue:!1},vScrollBarAlwaysVisible:{set:function(e){(!this.$vScrollBarAlwaysVisible||!this.$vScroll)&&this.$loop.schedule(this.CHANGE_SCROLL)},initialValue:!1},fontSize:{set:function(e){typeof e=="number"&&(e+="px"),this.container.style.fontSize=e,this.updateFontSize()},initialValue:12},fontFamily:{set:function(e){this.container.style.fontFamily=e,this.updateFontSize()}},maxLines:{set:function(e){this.updateFull()}},minLines:{set:function(e){this.$minLines<562949953421311||(this.$minLines=0),this.updateFull()}},maxPixelHeight:{set:function(e){this.updateFull()},initialValue:0},scrollPastEnd:{set:function(e){e=+e||0;if(this.$scrollPastEnd==e)return;this.$scrollPastEnd=e,this.$loop.schedule(this.CHANGE_SCROLL)},initialValue:0,handlesSet:!0},fixedWidthGutter:{set:function(e){this.$gutterLayer.$fixedWidth=!!e,this.$loop.schedule(this.CHANGE_GUTTER)}},theme:{set:function(e){this.setTheme(e)},get:function(){return this.$themeId||this.theme},initialValue:"./theme/textmate",handlesSet:!0},hasCssTransforms:{},useTextareaForIME:{initialValue:!m.isMobile&&!m.isIE}}),t.VirtualRenderer=y}),ace.define("ace/worker/worker_client",["require","exports","module","ace/lib/oop","ace/lib/net","ace/lib/event_emitter","ace/config"],function(e,t,n){"use strict";function u(e){var t="importScripts('"+i.qualifyURL(e)+"');";try{return new Blob([t],{type:"application/javascript"})}catch(n){var r=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder,s=new r;return s.append(t),s.getBlob("application/javascript")}}function a(e){if(typeof Worker=="undefined")return{postMessage:function(){},terminate:function(){}};if(o.get("loadWorkerFromBlob")){var t=u(e),n=window.URL||window.webkitURL,r=n.createObjectURL(t);return new Worker(r)}return new Worker(e)}var r=e("../lib/oop"),i=e("../lib/net"),s=e("../lib/event_emitter").EventEmitter,o=e("../config"),f=function(e){e.postMessage||(e=this.$createWorkerFromOldConfig.apply(this,arguments)),this.$worker=e,this.$sendDeltaQueue=this.$sendDeltaQueue.bind(this),this.changeListener=this.changeListener.bind(this),this.onMessage=this.onMessage.bind(this),this.callbackId=1,this.callbacks={},this.$worker.onmessage=this.onMessage};(function(){r.implement(this,s),this.$createWorkerFromOldConfig=function(t,n,r,i,s){e.nameToUrl&&!e.toUrl&&(e.toUrl=e.nameToUrl);if(o.get("packaged")||!e.toUrl)i=i||o.moduleUrl(n,"worker");else{var u=this.$normalizePath;i=i||u(e.toUrl("ace/worker/worker.js",null,"_"));var f={};t.forEach(function(t){f[t]=u(e.toUrl(t,null,"_").replace(/(\.js)?(\?.*)?$/,""))})}return this.$worker=a(i),s&&this.send("importScripts",s),this.$worker.postMessage({init:!0,tlns:f,module:n,classname:r}),this.$worker},this.onMessage=function(e){var t=e.data;switch(t.type){case"event":this._signal(t.name,{data:t.data});break;case"call":var n=this.callbacks[t.id];n&&(n(t.data),delete this.callbacks[t.id]);break;case"error":this.reportError(t.data);break;case"log":window.console&&console.log&&console.log.apply(console,t.data)}},this.reportError=function(e){window.console&&console.error&&console.error(e)},this.$normalizePath=function(e){return i.qualifyURL(e)},this.terminate=function(){this._signal("terminate",{}),this.deltaQueue=null,this.$worker.terminate(),this.$worker=null,this.$doc&&this.$doc.off("change",this.changeListener),this.$doc=null},this.send=function(e,t){this.$worker.postMessage({command:e,args:t})},this.call=function(e,t,n){if(n){var r=this.callbackId++;this.callbacks[r]=n,t.push(r)}this.send(e,t)},this.emit=function(e,t){try{t.data&&t.data.err&&(t.data.err={message:t.data.err.message,stack:t.data.err.stack,code:t.data.err.code}),this.$worker.postMessage({event:e,data:{data:t.data}})}catch(n){console.error(n.stack)}},this.attachToDocument=function(e){this.$doc&&this.terminate(),this.$doc=e,this.call("setValue",[e.getValue()]),e.on("change",this.changeListener)},this.changeListener=function(e){this.deltaQueue||(this.deltaQueue=[],setTimeout(this.$sendDeltaQueue,0)),e.action=="insert"?this.deltaQueue.push(e.start,e.lines):this.deltaQueue.push(e.start,e.end)},this.$sendDeltaQueue=function(){var e=this.deltaQueue;if(!e)return;this.deltaQueue=null,e.length>50&&e.length>this.$doc.getLength()>>1?this.call("setValue",[this.$doc.getValue()]):this.emit("change",{data:e})}}).call(f.prototype);var l=function(e,t,n){var r=null,i=!1,u=Object.create(s),a=[],l=new f({messageBuffer:a,terminate:function(){},postMessage:function(e){a.push(e);if(!r)return;i?setTimeout(c):c()}});l.setEmitSync=function(e){i=e};var c=function(){var e=a.shift();e.command?r[e.command].apply(r,e.args):e.event&&u._signal(e.event,e.data)};return u.postMessage=function(e){l.onMessage({data:e})},u.callback=function(e,t){this.postMessage({type:"call",id:t,data:e})},u.emit=function(e,t){this.postMessage({type:"event",name:e,data:t})},o.loadModule(["worker",t],function(e){r=new e[n](u);while(a.length)c()}),l};t.UIWorkerClient=l,t.WorkerClient=f,t.createWorker=a}),ace.define("ace/placeholder",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/oop"],function(e,t,n){"use strict";var r=e("./range").Range,i=e("./lib/event_emitter").EventEmitter,s=e("./lib/oop"),o=function(e,t,n,r,i,s){var o=this;this.length=t,this.session=e,this.doc=e.getDocument(),this.mainClass=i,this.othersClass=s,this.$onUpdate=this.onUpdate.bind(this),this.doc.on("change",this.$onUpdate),this.$others=r,this.$onCursorChange=function(){setTimeout(function(){o.onCursorChange()})},this.$pos=n;var u=e.getUndoManager().$undoStack||e.getUndoManager().$undostack||{length:-1};this.$undoStackDepth=u.length,this.setup(),e.selection.on("changeCursor",this.$onCursorChange)};(function(){s.implement(this,i),this.setup=function(){var e=this,t=this.doc,n=this.session;this.selectionBefore=n.selection.toJSON(),n.selection.inMultiSelectMode&&n.selection.toSingleRange(),this.pos=t.createAnchor(this.$pos.row,this.$pos.column);var i=this.pos;i.$insertRight=!0,i.detach(),i.markerId=n.addMarker(new r(i.row,i.column,i.row,i.column+this.length),this.mainClass,null,!1),this.others=[],this.$others.forEach(function(n){var r=t.createAnchor(n.row,n.column);r.$insertRight=!0,r.detach(),e.others.push(r)}),n.setUndoSelect(!1)},this.showOtherMarkers=function(){if(this.othersActive)return;var e=this.session,t=this;this.othersActive=!0,this.others.forEach(function(n){n.markerId=e.addMarker(new r(n.row,n.column,n.row,n.column+t.length),t.othersClass,null,!1)})},this.hideOtherMarkers=function(){if(!this.othersActive)return;this.othersActive=!1;for(var e=0;e<this.others.length;e++)this.session.removeMarker(this.others[e].markerId)},this.onUpdate=function(e){if(this.$updating)return this.updateAnchors(e);var t=e;if(t.start.row!==t.end.row)return;if(t.start.row!==this.pos.row)return;this.$updating=!0;var n=e.action==="insert"?t.end.column-t.start.column:t.start.column-t.end.column,i=t.start.column>=this.pos.column&&t.start.column<=this.pos.column+this.length+1,s=t.start.column-this.pos.column;this.updateAnchors(e),i&&(this.length+=n);if(i&&!this.session.$fromUndo)if(e.action==="insert")for(var o=this.others.length-1;o>=0;o--){var u=this.others[o],a={row:u.row,column:u.column+s};this.doc.insertMergedLines(a,e.lines)}else if(e.action==="remove")for(var o=this.others.length-1;o>=0;o--){var u=this.others[o],a={row:u.row,column:u.column+s};this.doc.remove(new r(a.row,a.column,a.row,a.column-n))}this.$updating=!1,this.updateMarkers()},this.updateAnchors=function(e){this.pos.onChange(e);for(var t=this.others.length;t--;)this.others[t].onChange(e);this.updateMarkers()},this.updateMarkers=function(){if(this.$updating)return;var e=this,t=this.session,n=function(n,i){t.removeMarker(n.markerId),n.markerId=t.addMarker(new r(n.row,n.column,n.row,n.column+e.length),i,null,!1)};n(this.pos,this.mainClass);for(var i=this.others.length;i--;)n(this.others[i],this.othersClass)},this.onCursorChange=function(e){if(this.$updating||!this.session)return;var t=this.session.selection.getCursor();t.row===this.pos.row&&t.column>=this.pos.column&&t.column<=this.pos.column+this.length?(this.showOtherMarkers(),this._emit("cursorEnter",e)):(this.hideOtherMarkers(),this._emit("cursorLeave",e))},this.detach=function(){this.session.removeMarker(this.pos&&this.pos.markerId),this.hideOtherMarkers(),this.doc.off("change",this.$onUpdate),this.session.selection.off("changeCursor",this.$onCursorChange),this.session.setUndoSelect(!0),this.session=null},this.cancel=function(){if(this.$undoStackDepth===-1)return;var e=this.session.getUndoManager(),t=(e.$undoStack||e.$undostack).length-this.$undoStackDepth;for(var n=0;n<t;n++)e.undo(this.session,!0);this.selectionBefore&&this.session.selection.fromJSON(this.selectionBefore)}}).call(o.prototype),t.PlaceHolder=o}),ace.define("ace/mouse/multi_select_handler",["require","exports","module","ace/lib/event","ace/lib/useragent"],function(e,t,n){function s(e,t){return e.row==t.row&&e.column==t.column}function o(e){var t=e.domEvent,n=t.altKey,o=t.shiftKey,u=t.ctrlKey,a=e.getAccelKey(),f=e.getButton();u&&i.isMac&&(f=t.button);if(e.editor.inMultiSelectMode&&f==2){e.editor.textInput.onContextMenu(e.domEvent);return}if(!u&&!n&&!a){f===0&&e.editor.inMultiSelectMode&&e.editor.exitMultiSelectMode();return}if(f!==0)return;var l=e.editor,c=l.selection,h=l.inMultiSelectMode,p=e.getDocumentPosition(),d=c.getCursor(),v=e.inSelection()||c.isEmpty()&&s(p,d),m=e.x,g=e.y,y=function(e){m=e.clientX,g=e.clientY},b=l.session,w=l.renderer.pixelToScreenCoordinates(m,g),E=w,S;if(l.$mouseHandler.$enableJumpToDef)u&&n||a&&n?S=o?"block":"add":n&&l.$blockSelectEnabled&&(S="block");else if(a&&!n){S="add";if(!h&&o)return}else n&&l.$blockSelectEnabled&&(S="block");S&&i.isMac&&t.ctrlKey&&l.$mouseHandler.cancelContextMenu();if(S=="add"){if(!h&&v)return;if(!h){var x=c.toOrientedRange();l.addSelectionMarker(x)}var T=c.rangeList.rangeAtPoint(p);l.inVirtualSelectionMode=!0,o&&(T=null,x=c.ranges[0]||x,l.removeSelectionMarker(x)),l.once("mouseup",function(){var e=c.toOrientedRange();T&&e.isEmpty()&&s(T.cursor,e.cursor)?c.substractPoint(e.cursor):(o?c.substractPoint(x.cursor):x&&(l.removeSelectionMarker(x),c.addRange(x)),c.addRange(e)),l.inVirtualSelectionMode=!1})}else if(S=="block"){e.stop(),l.inVirtualSelectionMode=!0;var N,C=[],k=function(){var e=l.renderer.pixelToScreenCoordinates(m,g),t=b.screenToDocumentPosition(e.row,e.column,e.offsetX);if(s(E,e)&&s(t,c.lead))return;E=e,l.selection.moveToPosition(t),l.renderer.scrollCursorIntoView(),l.removeSelectionMarkers(C),C=c.rectangularRangeBlock(E,w),l.$mouseHandler.$clickSelection&&C.length==1&&C[0].isEmpty()&&(C[0]=l.$mouseHandler.$clickSelection.clone()),C.forEach(l.addSelectionMarker,l),l.updateSelectionMarkers()};h&&!a?c.toSingleRange():!h&&a&&(N=c.toOrientedRange(),l.addSelectionMarker(N)),o?w=b.documentToScreenPosition(c.lead):c.moveToPosition(p),E={row:-1,column:-1};var L=function(e){k(),clearInterval(O),l.removeSelectionMarkers(C),C.length||(C=[c.toOrientedRange()]),N&&(l.removeSelectionMarker(N),c.toSingleRange(N));for(var t=0;t<C.length;t++)c.addRange(C[t]);l.inVirtualSelectionMode=!1,l.$mouseHandler.$clickSelection=null},A=k;r.capture(l.container,y,L);var O=setInterval(function(){A()},20);return e.preventDefault()}}var r=e("../lib/event"),i=e("../lib/useragent");t.onMouseDown=o}),ace.define("ace/commands/multi_select_commands",["require","exports","module","ace/keyboard/hash_handler"],function(e,t,n){t.defaultCommands=[{name:"addCursorAbove",description:"Add cursor above",exec:function(e){e.selectMoreLines(-1)},bindKey:{win:"Ctrl-Alt-Up",mac:"Ctrl-Alt-Up"},scrollIntoView:"cursor",readOnly:!0},{name:"addCursorBelow",description:"Add cursor below",exec:function(e){e.selectMoreLines(1)},bindKey:{win:"Ctrl-Alt-Down",mac:"Ctrl-Alt-Down"},scrollIntoView:"cursor",readOnly:!0},{name:"addCursorAboveSkipCurrent",description:"Add cursor above (skip current)",exec:function(e){e.selectMoreLines(-1,!0)},bindKey:{win:"Ctrl-Alt-Shift-Up",mac:"Ctrl-Alt-Shift-Up"},scrollIntoView:"cursor",readOnly:!0},{name:"addCursorBelowSkipCurrent",description:"Add cursor below (skip current)",exec:function(e){e.selectMoreLines(1,!0)},bindKey:{win:"Ctrl-Alt-Shift-Down",mac:"Ctrl-Alt-Shift-Down"},scrollIntoView:"cursor",readOnly:!0},{name:"selectMoreBefore",description:"Select more before",exec:function(e){e.selectMore(-1)},bindKey:{win:"Ctrl-Alt-Left",mac:"Ctrl-Alt-Left"},scrollIntoView:"cursor",readOnly:!0},{name:"selectMoreAfter",description:"Select more after",exec:function(e){e.selectMore(1)},bindKey:{win:"Ctrl-Alt-Right",mac:"Ctrl-Alt-Right"},scrollIntoView:"cursor",readOnly:!0},{name:"selectNextBefore",description:"Select next before",exec:function(e){e.selectMore(-1,!0)},bindKey:{win:"Ctrl-Alt-Shift-Left",mac:"Ctrl-Alt-Shift-Left"},scrollIntoView:"cursor",readOnly:!0},{name:"selectNextAfter",description:"Select next after",exec:function(e){e.selectMore(1,!0)},bindKey:{win:"Ctrl-Alt-Shift-Right",mac:"Ctrl-Alt-Shift-Right"},scrollIntoView:"cursor",readOnly:!0},{name:"toggleSplitSelectionIntoLines",description:"Split into lines",exec:function(e){e.multiSelect.rangeCount>1?e.multiSelect.joinSelections():e.multiSelect.splitIntoLines()},bindKey:{win:"Ctrl-Alt-L",mac:"Ctrl-Alt-L"},readOnly:!0},{name:"splitSelectionIntoLines",description:"Split into lines",exec:function(e){e.multiSelect.splitIntoLines()},readOnly:!0},{name:"alignCursors",description:"Align cursors",exec:function(e){e.alignCursors()},bindKey:{win:"Ctrl-Alt-A",mac:"Ctrl-Alt-A"},scrollIntoView:"cursor"},{name:"findAll",description:"Find all",exec:function(e){e.findAll()},bindKey:{win:"Ctrl-Alt-K",mac:"Ctrl-Alt-G"},scrollIntoView:"cursor",readOnly:!0}],t.multiSelectCommands=[{name:"singleSelection",description:"Single selection",bindKey:"esc",exec:function(e){e.exitMultiSelectMode()},scrollIntoView:"cursor",readOnly:!0,isAvailable:function(e){return e&&e.inMultiSelectMode}}];var r=e("../keyboard/hash_handler").HashHandler;t.keyboardHandler=new r(t.multiSelectCommands)}),ace.define("ace/multi_select",["require","exports","module","ace/range_list","ace/range","ace/selection","ace/mouse/multi_select_handler","ace/lib/event","ace/lib/lang","ace/commands/multi_select_commands","ace/search","ace/edit_session","ace/editor","ace/config"],function(e,t,n){function h(e,t,n){return c.$options.wrap=!0,c.$options.needle=t,c.$options.backwards=n==-1,c.find(e)}function v(e,t){return e.row==t.row&&e.column==t.column}function m(e){if(e.$multiselectOnSessionChange)return;e.$onAddRange=e.$onAddRange.bind(e),e.$onRemoveRange=e.$onRemoveRange.bind(e),e.$onMultiSelect=e.$onMultiSelect.bind(e),e.$onSingleSelect=e.$onSingleSelect.bind(e),e.$multiselectOnSessionChange=t.onSessionChange.bind(e),e.$checkMultiselectChange=e.$checkMultiselectChange.bind(e),e.$multiselectOnSessionChange(e),e.on("changeSession",e.$multiselectOnSessionChange),e.on("mousedown",o),e.commands.addCommands(f.defaultCommands),g(e)}function g(e){function r(t){n&&(e.renderer.setMouseCursor(""),n=!1)}if(!e.textInput)return;var t=e.textInput.getElement(),n=!1;u.addListener(t,"keydown",function(t){var i=t.keyCode==18&&!(t.ctrlKey||t.shiftKey||t.metaKey);e.$blockSelectEnabled&&i?n||(e.renderer.setMouseCursor("crosshair"),n=!0):n&&r()},e),u.addListener(t,"keyup",r,e),u.addListener(t,"blur",r,e)}var r=e("./range_list").RangeList,i=e("./range").Range,s=e("./selection").Selection,o=e("./mouse/multi_select_handler").onMouseDown,u=e("./lib/event"),a=e("./lib/lang"),f=e("./commands/multi_select_commands");t.commands=f.defaultCommands.concat(f.multiSelectCommands);var l=e("./search").Search,c=new l,p=e("./edit_session").EditSession;(function(){this.getSelectionMarkers=function(){return this.$selectionMarkers}}).call(p.prototype),function(){this.ranges=null,this.rangeList=null,this.addRange=function(e,t){if(!e)return;if(!this.inMultiSelectMode&&this.rangeCount===0){var n=this.toOrientedRange();this.rangeList.add(n),this.rangeList.add(e);if(this.rangeList.ranges.length!=2)return this.rangeList.removeAll(),t||this.fromOrientedRange(e);this.rangeList.removeAll(),this.rangeList.add(n),this.$onAddRange(n)}e.cursor||(e.cursor=e.end);var r=this.rangeList.add(e);return this.$onAddRange(e),r.length&&this.$onRemoveRange(r),this.rangeCount>1&&!this.inMultiSelectMode&&(this._signal("multiSelect"),this.inMultiSelectMode=!0,this.session.$undoSelect=!1,this.rangeList.attach(this.session)),t||this.fromOrientedRange(e)},this.toSingleRange=function(e){e=e||this.ranges[0];var t=this.rangeList.removeAll();t.length&&this.$onRemoveRange(t),e&&this.fromOrientedRange(e)},this.substractPoint=function(e){var t=this.rangeList.substractPoint(e);if(t)return this.$onRemoveRange(t),t[0]},this.mergeOverlappingRanges=function(){var e=this.rangeList.merge();e.length&&this.$onRemoveRange(e)},this.$onAddRange=function(e){this.rangeCount=this.rangeList.ranges.length,this.ranges.unshift(e),this._signal("addRange",{range:e})},this.$onRemoveRange=function(e){this.rangeCount=this.rangeList.ranges.length;if(this.rangeCount==1&&this.inMultiSelectMode){var t=this.rangeList.ranges.pop();e.push(t),this.rangeCount=0}for(var n=e.length;n--;){var r=this.ranges.indexOf(e[n]);this.ranges.splice(r,1)}this._signal("removeRange",{ranges:e}),this.rangeCount===0&&this.inMultiSelectMode&&(this.inMultiSelectMode=!1,this._signal("singleSelect"),this.session.$undoSelect=!0,this.rangeList.detach(this.session)),t=t||this.ranges[0],t&&!t.isEqual(this.getRange())&&this.fromOrientedRange(t)},this.$initRangeList=function(){if(this.rangeList)return;this.rangeList=new r,this.ranges=[],this.rangeCount=0},this.getAllRanges=function(){return this.rangeCount?this.rangeList.ranges.concat():[this.getRange()]},this.splitIntoLines=function(){var e=this.ranges.length?this.ranges:[this.getRange()],t=[];for(var n=0;n<e.length;n++){var r=e[n],s=r.start.row,o=r.end.row;if(s===o)t.push(r.clone());else{t.push(new i(s,r.start.column,s,this.session.getLine(s).length));while(++s<o)t.push(this.getLineRange(s,!0));t.push(new i(o,0,o,r.end.column))}n==0&&!this.isBackwards()&&(t=t.reverse())}this.toSingleRange();for(var n=t.length;n--;)this.addRange(t[n])},this.joinSelections=function(){var e=this.rangeList.ranges,t=e[e.length-1],n=i.fromPoints(e[0].start,t.end);this.toSingleRange(),this.setSelectionRange(n,t.cursor==t.start)},this.toggleBlockSelection=function(){if(this.rangeCount>1){var e=this.rangeList.ranges,t=e[e.length-1],n=i.fromPoints(e[0].start,t.end);this.toSingleRange(),this.setSelectionRange(n,t.cursor==t.start)}else{var r=this.session.documentToScreenPosition(this.cursor),s=this.session.documentToScreenPosition(this.anchor),o=this.rectangularRangeBlock(r,s);o.forEach(this.addRange,this)}},this.rectangularRangeBlock=function(e,t,n){var r=[],s=e.column<t.column;if(s)var o=e.column,u=t.column,a=e.offsetX,f=t.offsetX;else var o=t.column,u=e.column,a=t.offsetX,f=e.offsetX;var l=e.row<t.row;if(l)var c=e.row,h=t.row;else var c=t.row,h=e.row;o<0&&(o=0),c<0&&(c=0),c==h&&(n=!0);var p;for(var d=c;d<=h;d++){var m=i.fromPoints(this.session.screenToDocumentPosition(d,o,a),this.session.screenToDocumentPosition(d,u,f));if(m.isEmpty()){if(p&&v(m.end,p))break;p=m.end}m.cursor=s?m.start:m.end,r.push(m)}l&&r.reverse();if(!n){var g=r.length-1;while(r[g].isEmpty()&&g>0)g--;if(g>0){var y=0;while(r[y].isEmpty())y++}for(var b=g;b>=y;b--)r[b].isEmpty()&&r.splice(b,1)}return r}}.call(s.prototype);var d=e("./editor").Editor;(function(){this.updateSelectionMarkers=function(){this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.addSelectionMarker=function(e){e.cursor||(e.cursor=e.end);var t=this.getSelectionStyle();return e.marker=this.session.addMarker(e,"ace_selection",t),this.session.$selectionMarkers.push(e),this.session.selectionMarkerCount=this.session.$selectionMarkers.length,e},this.removeSelectionMarker=function(e){if(!e.marker)return;this.session.removeMarker(e.marker);var t=this.session.$selectionMarkers.indexOf(e);t!=-1&&this.session.$selectionMarkers.splice(t,1),this.session.selectionMarkerCount=this.session.$selectionMarkers.length},this.removeSelectionMarkers=function(e){var t=this.session.$selectionMarkers;for(var n=e.length;n--;){var r=e[n];if(!r.marker)continue;this.session.removeMarker(r.marker);var i=t.indexOf(r);i!=-1&&t.splice(i,1)}this.session.selectionMarkerCount=t.length},this.$onAddRange=function(e){this.addSelectionMarker(e.range),this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.$onRemoveRange=function(e){this.removeSelectionMarkers(e.ranges),this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.$onMultiSelect=function(e){if(this.inMultiSelectMode)return;this.inMultiSelectMode=!0,this.setStyle("ace_multiselect"),this.keyBinding.addKeyboardHandler(f.keyboardHandler),this.commands.setDefaultHandler("exec",this.$onMultiSelectExec),this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.$onSingleSelect=function(e){if(this.session.multiSelect.inVirtualMode)return;this.inMultiSelectMode=!1,this.unsetStyle("ace_multiselect"),this.keyBinding.removeKeyboardHandler(f.keyboardHandler),this.commands.removeDefaultHandler("exec",this.$onMultiSelectExec),this.renderer.updateCursor(),this.renderer.updateBackMarkers(),this._emit("changeSelection")},this.$onMultiSelectExec=function(e){var t=e.command,n=e.editor;if(!n.multiSelect)return;if(!t.multiSelectAction){var r=t.exec(n,e.args||{});n.multiSelect.addRange(n.multiSelect.toOrientedRange()),n.multiSelect.mergeOverlappingRanges()}else t.multiSelectAction=="forEach"?r=n.forEachSelection(t,e.args):t.multiSelectAction=="forEachLine"?r=n.forEachSelection(t,e.args,!0):t.multiSelectAction=="single"?(n.exitMultiSelectMode(),r=t.exec(n,e.args||{})):r=t.multiSelectAction(n,e.args||{});return r},this.forEachSelection=function(e,t,n){if(this.inVirtualSelectionMode)return;var r=n&&n.keepOrder,i=n==1||n&&n.$byLines,o=this.session,u=this.selection,a=u.rangeList,f=(r?u:a).ranges,l;if(!f.length)return e.exec?e.exec(this,t||{}):e(this,t||{});var c=u._eventRegistry;u._eventRegistry={};var h=new s(o);this.inVirtualSelectionMode=!0;for(var p=f.length;p--;){if(i)while(p>0&&f[p].start.row==f[p-1].end.row)p--;h.fromOrientedRange(f[p]),h.index=p,this.selection=o.selection=h;var d=e.exec?e.exec(this,t||{}):e(this,t||{});!l&&d!==undefined&&(l=d),h.toOrientedRange(f[p])}h.detach(),this.selection=o.selection=u,this.inVirtualSelectionMode=!1,u._eventRegistry=c,u.mergeOverlappingRanges(),u.ranges[0]&&u.fromOrientedRange(u.ranges[0]);var v=this.renderer.$scrollAnimation;return this.onCursorChange(),this.onSelectionChange(),v&&v.from==v.to&&this.renderer.animateScrolling(v.from),l},this.exitMultiSelectMode=function(){if(!this.inMultiSelectMode||this.inVirtualSelectionMode)return;this.multiSelect.toSingleRange()},this.getSelectedText=function(){var e="";if(this.inMultiSelectMode&&!this.inVirtualSelectionMode){var t=this.multiSelect.rangeList.ranges,n=[];for(var r=0;r<t.length;r++)n.push(this.session.getTextRange(t[r]));var i=this.session.getDocument().getNewLineCharacter();e=n.join(i),e.length==(n.length-1)*i.length&&(e="")}else this.selection.isEmpty()||(e=this.session.getTextRange(this.getSelectionRange()));return e},this.$checkMultiselectChange=function(e,t){if(this.inMultiSelectMode&&!this.inVirtualSelectionMode){var n=this.multiSelect.ranges[0];if(this.multiSelect.isEmpty()&&t==this.multiSelect.anchor)return;var r=t==this.multiSelect.anchor?n.cursor==n.start?n.end:n.start:n.cursor;r.row!=t.row||this.session.$clipPositionToDocument(r.row,r.column).column!=t.column?this.multiSelect.toSingleRange(this.multiSelect.toOrientedRange()):this.multiSelect.mergeOverlappingRanges()}},this.findAll=function(e,t,n){t=t||{},t.needle=e||t.needle;if(t.needle==undefined){var r=this.selection.isEmpty()?this.selection.getWordRange():this.selection.getRange();t.needle=this.session.getTextRange(r)}this.$search.set(t);var i=this.$search.findAll(this.session);if(!i.length)return 0;var s=this.multiSelect;n||s.toSingleRange(i[0]);for(var o=i.length;o--;)s.addRange(i[o],!0);return r&&s.rangeList.rangeAtPoint(r.start)&&s.addRange(r,!0),i.length},this.selectMoreLines=function(e,t){var n=this.selection.toOrientedRange(),r=n.cursor==n.end,s=this.session.documentToScreenPosition(n.cursor);this.selection.$desiredColumn&&(s.column=this.selection.$desiredColumn);var o=this.session.screenToDocumentPosition(s.row+e,s.column);if(!n.isEmpty())var u=this.session.documentToScreenPosition(r?n.end:n.start),a=this.session.screenToDocumentPosition(u.row+e,u.column);else var a=o;if(r){var f=i.fromPoints(o,a);f.cursor=f.start}else{var f=i.fromPoints(a,o);f.cursor=f.end}f.desiredColumn=s.column;if(!this.selection.inMultiSelectMode)this.selection.addRange(n);else if(t)var l=n.cursor;this.selection.addRange(f),l&&this.selection.substractPoint(l)},this.transposeSelections=function(e){var t=this.session,n=t.multiSelect,r=n.ranges;for(var i=r.length;i--;){var s=r[i];if(s.isEmpty()){var o=t.getWordRange(s.start.row,s.start.column);s.start.row=o.start.row,s.start.column=o.start.column,s.end.row=o.end.row,s.end.column=o.end.column}}n.mergeOverlappingRanges();var u=[];for(var i=r.length;i--;){var s=r[i];u.unshift(t.getTextRange(s))}e<0?u.unshift(u.pop()):u.push(u.shift());for(var i=r.length;i--;){var s=r[i],o=s.clone();t.replace(s,u[i]),s.start.row=o.start.row,s.start.column=o.start.column}n.fromOrientedRange(n.ranges[0])},this.selectMore=function(e,t,n){var r=this.session,i=r.multiSelect,s=i.toOrientedRange();if(s.isEmpty()){s=r.getWordRange(s.start.row,s.start.column),s.cursor=e==-1?s.start:s.end,this.multiSelect.addRange(s);if(n)return}var o=r.getTextRange(s),u=h(r,o,e);u&&(u.cursor=e==-1?u.start:u.end,this.session.unfold(u),this.multiSelect.addRange(u),this.renderer.scrollCursorIntoView(null,.5)),t&&this.multiSelect.substractPoint(s.cursor)},this.alignCursors=function(){var e=this.session,t=e.multiSelect,n=t.ranges,r=-1,s=n.filter(function(e){if(e.cursor.row==r)return!0;r=e.cursor.row});if(!n.length||s.length==n.length-1){var o=this.selection.getRange(),u=o.start.row,f=o.end.row,l=u==f;if(l){var c=this.session.getLength(),h;do h=this.session.getLine(f);while(/[=:]/.test(h)&&++f<c);do h=this.session.getLine(u);while(/[=:]/.test(h)&&--u>0);u<0&&(u=0),f>=c&&(f=c-1)}var p=this.session.removeFullLines(u,f);p=this.$reAlignText(p,l),this.session.insert({row:u,column:0},p.join("\n")+"\n"),l||(o.start.column=0,o.end.column=p[p.length-1].length),this.selection.setRange(o)}else{s.forEach(function(e){t.substractPoint(e.cursor)});var d=0,v=Infinity,m=n.map(function(t){var n=t.cursor,r=e.getLine(n.row),i=r.substr(n.column).search(/\S/g);return i==-1&&(i=0),n.column>d&&(d=n.column),i<v&&(v=i),i});n.forEach(function(t,n){var r=t.cursor,s=d-r.column,o=m[n]-v;s>o?e.insert(r,a.stringRepeat(" ",s-o)):e.remove(new i(r.row,r.column,r.row,r.column-s+o)),t.start.column=t.end.column=d,t.start.row=t.end.row=r.row,t.cursor=t.end}),t.fromOrientedRange(n[0]),this.renderer.updateCursor(),this.renderer.updateBackMarkers()}},this.$reAlignText=function(e,t){function u(e){return a.stringRepeat(" ",e)}function f(e){return e[2]?u(i)+e[2]+u(s-e[2].length+o)+e[4].replace(/^([=:])\s+/,"$1 "):e[0]}function l(e){return e[2]?u(i+s-e[2].length)+e[2]+u(o)+e[4].replace(/^([=:])\s+/,"$1 "):e[0]}function c(e){return e[2]?u(i)+e[2]+u(o)+e[4].replace(/^([=:])\s+/,"$1 "):e[0]}var n=!0,r=!0,i,s,o;return e.map(function(e){var t=e.match(/(\s*)(.*?)(\s*)([=:].*)/);return t?i==null?(i=t[1].length,s=t[2].length,o=t[3].length,t):(i+s+o!=t[1].length+t[2].length+t[3].length&&(r=!1),i!=t[1].length&&(n=!1),i>t[1].length&&(i=t[1].length),s<t[2].length&&(s=t[2].length),o>t[3].length&&(o=t[3].length),t):[e]}).map(t?f:n?r?l:f:c)}}).call(d.prototype),t.onSessionChange=function(e){var t=e.session;t&&!t.multiSelect&&(t.$selectionMarkers=[],t.selection.$initRangeList(),t.multiSelect=t.selection),this.multiSelect=t&&t.multiSelect;var n=e.oldSession;n&&(n.multiSelect.off("addRange",this.$onAddRange),n.multiSelect.off("removeRange",this.$onRemoveRange),n.multiSelect.off("multiSelect",this.$onMultiSelect),n.multiSelect.off("singleSelect",this.$onSingleSelect),n.multiSelect.lead.off("change",this.$checkMultiselectChange),n.multiSelect.anchor.off("change",this.$checkMultiselectChange)),t&&(t.multiSelect.on("addRange",this.$onAddRange),t.multiSelect.on("removeRange",this.$onRemoveRange),t.multiSelect.on("multiSelect",this.$onMultiSelect),t.multiSelect.on("singleSelect",this.$onSingleSelect),t.multiSelect.lead.on("change",this.$checkMultiselectChange),t.multiSelect.anchor.on("change",this.$checkMultiselectChange)),t&&this.inMultiSelectMode!=t.selection.inMultiSelectMode&&(t.selection.inMultiSelectMode?this.$onMultiSelect():this.$onSingleSelect())},t.MultiSelect=m,e("./config").defineOptions(d.prototype,"editor",{enableMultiselect:{set:function(e){m(this),e?(this.on("changeSession",this.$multiselectOnSessionChange),this.on("mousedown",o)):(this.off("changeSession",this.$multiselectOnSessionChange),this.off("mousedown",o))},value:!0},enableBlockSelect:{set:function(e){this.$blockSelectEnabled=e},value:!0}})}),ace.define("ace/mode/folding/fold_mode",["require","exports","module","ace/range"],function(e,t,n){"use strict";var r=e("../../range").Range,i=t.FoldMode=function(){};(function(){this.foldingStartMarker=null,this.foldingStopMarker=null,this.getFoldWidget=function(e,t,n){var r=e.getLine(n);return this.foldingStartMarker.test(r)?"start":t=="markbeginend"&&this.foldingStopMarker&&this.foldingStopMarker.test(r)?"end":""},this.getFoldWidgetRange=function(e,t,n){return null},this.indentationBlock=function(e,t,n){var i=/\S/,s=e.getLine(t),o=s.search(i);if(o==-1)return;var u=n||s.length,a=e.getLength(),f=t,l=t;while(++t<a){var c=e.getLine(t).search(i);if(c==-1)continue;if(c<=o){var h=e.getTokenAt(t,0);if(!h||h.type!=="string")break}l=t}if(l>f){var p=e.getLine(l).length;return new r(f,u,l,p)}},this.openingBracketBlock=function(e,t,n,i,s){var o={row:n,column:i+1},u=e.$findClosingBracket(t,o,s);if(!u)return;var a=e.foldWidgets[u.row];return a==null&&(a=e.getFoldWidget(u.row)),a=="start"&&u.row>o.row&&(u.row--,u.column=e.getLine(u.row).length),r.fromPoints(o,u)},this.closingBracketBlock=function(e,t,n,i,s){var o={row:n,column:i},u=e.$findOpeningBracket(t,o);if(!u)return;return u.column++,o.column--,r.fromPoints(u,o)}}).call(i.prototype)}),ace.define("ace/theme/textmate",["require","exports","module","ace/lib/dom"],function(e,t,n){"use strict";t.isDark=!1,t.cssClass="ace-tm",t.cssText='.ace-tm .ace_gutter {background: #f0f0f0;color: #333;}.ace-tm .ace_print-margin {width: 1px;background: #e8e8e8;}.ace-tm .ace_fold {background-color: #6B72E6;}.ace-tm {background-color: #FFFFFF;color: black;}.ace-tm .ace_cursor {color: black;}.ace-tm .ace_invisible {color: rgb(191, 191, 191);}.ace-tm .ace_storage,.ace-tm .ace_keyword {color: blue;}.ace-tm .ace_constant {color: rgb(197, 6, 11);}.ace-tm .ace_constant.ace_buildin {color: rgb(88, 72, 246);}.ace-tm .ace_constant.ace_language {color: rgb(88, 92, 246);}.ace-tm .ace_constant.ace_library {color: rgb(6, 150, 14);}.ace-tm .ace_invalid {background-color: rgba(255, 0, 0, 0.1);color: red;}.ace-tm .ace_support.ace_function {color: rgb(60, 76, 114);}.ace-tm .ace_support.ace_constant {color: rgb(6, 150, 14);}.ace-tm .ace_support.ace_type,.ace-tm .ace_support.ace_class {color: rgb(109, 121, 222);}.ace-tm .ace_keyword.ace_operator {color: rgb(104, 118, 135);}.ace-tm .ace_string {color: rgb(3, 106, 7);}.ace-tm .ace_comment {color: rgb(76, 136, 107);}.ace-tm .ace_comment.ace_doc {color: rgb(0, 102, 255);}.ace-tm .ace_comment.ace_doc.ace_tag {color: rgb(128, 159, 191);}.ace-tm .ace_constant.ace_numeric {color: rgb(0, 0, 205);}.ace-tm .ace_variable {color: rgb(49, 132, 149);}.ace-tm .ace_xml-pe {color: rgb(104, 104, 91);}.ace-tm .ace_entity.ace_name.ace_function {color: #0000A2;}.ace-tm .ace_heading {color: rgb(12, 7, 255);}.ace-tm .ace_list {color:rgb(185, 6, 144);}.ace-tm .ace_meta.ace_tag {color:rgb(0, 22, 142);}.ace-tm .ace_string.ace_regex {color: rgb(255, 0, 0)}.ace-tm .ace_marker-layer .ace_selection {background: rgb(181, 213, 255);}.ace-tm.ace_multiselect .ace_selection.ace_start {box-shadow: 0 0 3px 0px white;}.ace-tm .ace_marker-layer .ace_step {background: rgb(252, 255, 0);}.ace-tm .ace_marker-layer .ace_stack {background: rgb(164, 229, 101);}.ace-tm .ace_marker-layer .ace_bracket {margin: -1px 0 0 -1px;border: 1px solid rgb(192, 192, 192);}.ace-tm .ace_marker-layer .ace_active-line {background: rgba(0, 0, 0, 0.07);}.ace-tm .ace_gutter-active-line {background-color : #dcdcdc;}.ace-tm .ace_marker-layer .ace_selected-word {background: rgb(250, 250, 255);border: 1px solid rgb(200, 200, 250);}.ace-tm .ace_indent-guide {background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==") right repeat-y;}',t.$id="ace/theme/textmate";var r=e("../lib/dom");r.importCssString(t.cssText,t.cssClass)}),ace.define("ace/line_widgets",["require","exports","module","ace/lib/dom"],function(e,t,n){"use strict";function i(e){this.session=e,this.session.widgetManager=this,this.session.getRowLength=this.getRowLength,this.session.$getWidgetScreenLength=this.$getWidgetScreenLength,this.updateOnChange=this.updateOnChange.bind(this),this.renderWidgets=this.renderWidgets.bind(this),this.measureWidgets=this.measureWidgets.bind(this),this.session._changedWidgets=[],this.$onChangeEditor=this.$onChangeEditor.bind(this),this.session.on("change",this.updateOnChange),this.session.on("changeFold",this.updateOnFold),this.session.on("changeEditor",this.$onChangeEditor)}var r=e("./lib/dom");(function(){this.getRowLength=function(e){var t;return this.lineWidgets?t=this.lineWidgets[e]&&this.lineWidgets[e].rowCount||0:t=0,!this.$useWrapMode||!this.$wrapData[e]?1+t:this.$wrapData[e].length+1+t},this.$getWidgetScreenLength=function(){var e=0;return this.lineWidgets.forEach(function(t){t&&t.rowCount&&!t.hidden&&(e+=t.rowCount)}),e},this.$onChangeEditor=function(e){this.attach(e.editor)},this.attach=function(e){e&&e.widgetManager&&e.widgetManager!=this&&e.widgetManager.detach();if(this.editor==e)return;this.detach(),this.editor=e,e&&(e.widgetManager=this,e.renderer.on("beforeRender",this.measureWidgets),e.renderer.on("afterRender",this.renderWidgets))},this.detach=function(e){var t=this.editor;if(!t)return;this.editor=null,t.widgetManager=null,t.renderer.off("beforeRender",this.measureWidgets),t.renderer.off("afterRender",this.renderWidgets);var n=this.session.lineWidgets;n&&n.forEach(function(e){e&&e.el&&e.el.parentNode&&(e._inDocument=!1,e.el.parentNode.removeChild(e.el))})},this.updateOnFold=function(e,t){var n=t.lineWidgets;if(!n||!e.action)return;var r=e.data,i=r.start.row,s=r.end.row,o=e.action=="add";for(var u=i+1;u<s;u++)n[u]&&(n[u].hidden=o);n[s]&&(o?n[i]?n[s].hidden=o:n[i]=n[s]:(n[i]==n[s]&&(n[i]=undefined),n[s].hidden=o))},this.updateOnChange=function(e){var t=this.session.lineWidgets;if(!t)return;var n=e.start.row,r=e.end.row-n;if(r!==0)if(e.action=="remove"){var i=t.splice(n+1,r);!t[n]&&i[i.length-1]&&(t[n]=i.pop()),i.forEach(function(e){e&&this.removeLineWidget(e)},this),this.$updateRows()}else{var s=new Array(r);t[n]&&t[n].column!=null&&e.start.column>t[n].column&&n++,s.unshift(n,0),t.splice.apply(t,s),this.$updateRows()}},this.$updateRows=function(){var e=this.session.lineWidgets;if(!e)return;var t=!0;e.forEach(function(e,n){if(e){t=!1,e.row=n;while(e.$oldWidget)e.$oldWidget.row=n,e=e.$oldWidget}}),t&&(this.session.lineWidgets=null)},this.$registerLineWidget=function(e){this.session.lineWidgets||(this.session.lineWidgets=new Array(this.session.getLength()));var t=this.session.lineWidgets[e.row];return t&&(e.$oldWidget=t,t.el&&t.el.parentNode&&(t.el.parentNode.removeChild(t.el),t._inDocument=!1)),this.session.lineWidgets[e.row]=e,e},this.addLineWidget=function(e){this.$registerLineWidget(e),e.session=this.session;if(!this.editor)return e;var t=this.editor.renderer;e.html&&!e.el&&(e.el=r.createElement("div"),e.el.innerHTML=e.html),e.el&&(r.addCssClass(e.el,"ace_lineWidgetContainer"),e.el.style.position="absolute",e.el.style.zIndex=5,t.container.appendChild(e.el),e._inDocument=!0,e.coverGutter||(e.el.style.zIndex=3),e.pixelHeight==null&&(e.pixelHeight=e.el.offsetHeight)),e.rowCount==null&&(e.rowCount=e.pixelHeight/t.layerConfig.lineHeight);var n=this.session.getFoldAt(e.row,0);e.$fold=n;if(n){var i=this.session.lineWidgets;e.row==n.end.row&&!i[n.start.row]?i[n.start.row]=e:e.hidden=!0}return this.session._emit("changeFold",{data:{start:{row:e.row}}}),this.$updateRows(),this.renderWidgets(null,t),this.onWidgetChanged(e),e},this.removeLineWidget=function(e){e._inDocument=!1,e.session=null,e.el&&e.el.parentNode&&e.el.parentNode.removeChild(e.el);if(e.editor&&e.editor.destroy)try{e.editor.destroy()}catch(t){}if(this.session.lineWidgets){var n=this.session.lineWidgets[e.row];if(n==e)this.session.lineWidgets[e.row]=e.$oldWidget,e.$oldWidget&&this.onWidgetChanged(e.$oldWidget);else while(n){if(n.$oldWidget==e){n.$oldWidget=e.$oldWidget;break}n=n.$oldWidget}}this.session._emit("changeFold",{data:{start:{row:e.row}}}),this.$updateRows()},this.getWidgetsAtRow=function(e){var t=this.session.lineWidgets,n=t&&t[e],r=[];while(n)r.push(n),n=n.$oldWidget;return r},this.onWidgetChanged=function(e){this.session._changedWidgets.push(e),this.editor&&this.editor.renderer.updateFull()},this.measureWidgets=function(e,t){var n=this.session._changedWidgets,r=t.layerConfig;if(!n||!n.length)return;var i=Infinity;for(var s=0;s<n.length;s++){var o=n[s];if(!o||!o.el)continue;if(o.session!=this.session)continue;if(!o._inDocument){if(this.session.lineWidgets[o.row]!=o)continue;o._inDocument=!0,t.container.appendChild(o.el)}o.h=o.el.offsetHeight,o.fixedWidth||(o.w=o.el.offsetWidth,o.screenWidth=Math.ceil(o.w/r.characterWidth));var u=o.h/r.lineHeight;o.coverLine&&(u-=this.session.getRowLineCount(o.row),u<0&&(u=0)),o.rowCount!=u&&(o.rowCount=u,o.row<i&&(i=o.row))}i!=Infinity&&(this.session._emit("changeFold",{data:{start:{row:i}}}),this.session.lineWidgetWidth=null),this.session._changedWidgets=[]},this.renderWidgets=function(e,t){var n=t.layerConfig,r=this.session.lineWidgets;if(!r)return;var i=Math.min(this.firstRow,n.firstRow),s=Math.max(this.lastRow,n.lastRow,r.length);while(i>0&&!r[i])i--;this.firstRow=n.firstRow,this.lastRow=n.lastRow,t.$cursorLayer.config=n;for(var o=i;o<=s;o++){var u=r[o];if(!u||!u.el)continue;if(u.hidden){u.el.style.top=-100-(u.pixelHeight||0)+"px";continue}u._inDocument||(u._inDocument=!0,t.container.appendChild(u.el));var a=t.$cursorLayer.getPixelPosition({row:o,column:0},!0).top;u.coverLine||(a+=n.lineHeight*this.session.getRowLineCount(u.row)),u.el.style.top=a-n.offset+"px";var f=u.coverGutter?0:t.gutterWidth;u.fixedWidth||(f-=t.scrollLeft),u.el.style.left=f+"px",u.fullWidth&&u.screenWidth&&(u.el.style.minWidth=n.width+2*n.padding+"px"),u.fixedWidth?u.el.style.right=t.scrollBar.getWidth()+"px":u.el.style.right=""}}}).call(i.prototype),t.LineWidgets=i}),ace.define("ace/ext/error_marker",["require","exports","module","ace/line_widgets","ace/lib/dom","ace/range"],function(e,t,n){"use strict";function o(e,t,n){var r=0,i=e.length-1;while(r<=i){var s=r+i>>1,o=n(t,e[s]);if(o>0)r=s+1;else{if(!(o<0))return s;i=s-1}}return-(r+1)}function u(e,t,n){var r=e.getAnnotations().sort(s.comparePoints);if(!r.length)return;var i=o(r,{row:t,column:-1},s.comparePoints);i<0&&(i=-i-1),i>=r.length?i=n>0?0:r.length-1:i===0&&n<0&&(i=r.length-1);var u=r[i];if(!u||!n)return;if(u.row===t){do u=r[i+=n];while(u&&u.row===t);if(!u)return r.slice()}var a=[];t=u.row;do a[n<0?"unshift":"push"](u),u=r[i+=n];while(u&&u.row==t);return a.length&&a}var r=e("../line_widgets").LineWidgets,i=e("../lib/dom"),s=e("../range").Range;t.showErrorMarker=function(e,t){var n=e.session;n.widgetManager||(n.widgetManager=new r(n),n.widgetManager.attach(e));var s=e.getCursorPosition(),o=s.row,a=n.widgetManager.getWidgetsAtRow(o).filter(function(e){return e.type=="errorMarker"})[0];a?a.destroy():o-=t;var f=u(n,o,t),l;if(f){var c=f[0];s.column=(c.pos&&typeof c.column!="number"?c.pos.sc:c.column)||0,s.row=c.row,l=e.renderer.$gutterLayer.$annotations[s.row]}else{if(a)return;l={text:["Looks good!"],className:"ace_ok"}}e.session.unfold(s.row),e.selection.moveToPosition(s);var h={row:s.row,fixedWidth:!0,coverGutter:!0,el:i.createElement("div"),type:"errorMarker"},p=h.el.appendChild(i.createElement("div")),d=h.el.appendChild(i.createElement("div"));d.className="error_widget_arrow "+l.className;var v=e.renderer.$cursorLayer.getPixelPosition(s).left;d.style.left=v+e.renderer.gutterWidth-5+"px",h.el.className="error_widget_wrapper",p.className="error_widget "+l.className,p.innerHTML=l.text.join("<br>"),p.appendChild(i.createElement("div"));var m=function(e,t,n){if(t===0&&(n==="esc"||n==="return"))return h.destroy(),{command:"null"}};h.destroy=function(){if(e.$mouseHandler.isMousePressed)return;e.keyBinding.removeKeyboardHandler(m),n.widgetManager.removeLineWidget(h),e.off("changeSelection",h.destroy),e.off("changeSession",h.destroy),e.off("mouseup",h.destroy),e.off("change",h.destroy)},e.keyBinding.addKeyboardHandler(m),e.on("changeSelection",h.destroy),e.on("changeSession",h.destroy),e.on("mouseup",h.destroy),e.on("change",h.destroy),e.session.widgetManager.addLineWidget(h),h.el.onmousedown=e.focus.bind(e),e.renderer.scrollCursorIntoView(null,.5,{bottom:h.el.offsetHeight})},i.importCssString(" .error_widget_wrapper { background: inherit; color: inherit; border:none } .error_widget { border-top: solid 2px; border-bottom: solid 2px; margin: 5px 0; padding: 10px 40px; white-space: pre-wrap; } .error_widget.ace_error, .error_widget_arrow.ace_error{ border-color: #ff5a5a } .error_widget.ace_warning, .error_widget_arrow.ace_warning{ border-color: #F1D817 } .error_widget.ace_info, .error_widget_arrow.ace_info{ border-color: #5a5a5a } .error_widget.ace_ok, .error_widget_arrow.ace_ok{ border-color: #5aaa5a } .error_widget_arrow { position: absolute; border: solid 5px; border-top-color: transparent!important; border-right-color: transparent!important; border-left-color: transparent!important; top: -5px; }","")}),ace.define("ace/ace",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/dom","ace/lib/event","ace/range","ace/editor","ace/edit_session","ace/undomanager","ace/virtual_renderer","ace/worker/worker_client","ace/keyboard/hash_handler","ace/placeholder","ace/multi_select","ace/mode/folding/fold_mode","ace/theme/textmate","ace/ext/error_marker","ace/config"],function(e,t,n){"use strict";e("./lib/fixoldbrowsers");var r=e("./lib/dom"),i=e("./lib/event"),s=e("./range").Range,o=e("./editor").Editor,u=e("./edit_session").EditSession,a=e("./undomanager").UndoManager,f=e("./virtual_renderer").VirtualRenderer;e("./worker/worker_client"),e("./keyboard/hash_handler"),e("./placeholder"),e("./multi_select"),e("./mode/folding/fold_mode"),e("./theme/textmate"),e("./ext/error_marker"),t.config=e("./config"),t.require=e,typeof define=="function"&&(t.define=define),t.edit=function(e,n){if(typeof e=="string"){var s=e;e=document.getElementById(s);if(!e)throw new Error("ace.edit can't find div #"+s)}if(e&&e.env&&e.env.editor instanceof o)return e.env.editor;var u="";if(e&&/input|textarea/i.test(e.tagName)){var a=e;u=a.value,e=r.createElement("pre"),a.parentNode.replaceChild(e,a)}else e&&(u=e.textContent,e.innerHTML="");var l=t.createEditSession(u),c=new o(new f(e),l,n),h={document:l,editor:c,onResize:c.resize.bind(c,null)};return a&&(h.textarea=a),i.addListener(window,"resize",h.onResize),c.on("destroy",function(){i.removeListener(window,"resize",h.onResize),h.editor.container.env=null}),c.container.env=c.env=h,c},t.createEditSession=function(e,t){var n=new u(e,t);return n.setUndoManager(new a),n},t.Range=s,t.Editor=o,t.EditSession=u,t.UndoManager=a,t.VirtualRenderer=f,t.version=t.config.version}); (function() { ace.require(["ace/ace"], function(a) { if (a) { a.config.init(true); a.define = ace.define; } if (!window.ace) window.ace = a; for (var key in a) if (a.hasOwnProperty(key)) window.ace[key] = a[key]; window.ace["default"] = window.ace; if (typeof module == "object" && typeof exports == "object" && module) { module.exports = window.ace; } }); })();
0
repos/LoLa/website
repos/LoLa/website/libs/xterm-addon-fit.js
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FitAddon=t():e.FitAddon=t()}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FitAddon=void 0;var n=function(){function e(){}return e.prototype.activate=function(e){this._terminal=e},e.prototype.dispose=function(){},e.prototype.fit=function(){var e=this.proposeDimensions();if(e&&this._terminal){var t=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}},e.prototype.proposeDimensions=function(){if(this._terminal&&this._terminal.element&&this._terminal.element.parentElement){var e=this._terminal._core,t=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(t.getPropertyValue("height")),n=Math.max(0,parseInt(t.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),i=r-(parseInt(o.getPropertyValue("padding-top"))+parseInt(o.getPropertyValue("padding-bottom"))),a=n-(parseInt(o.getPropertyValue("padding-right"))+parseInt(o.getPropertyValue("padding-left")))-e.viewport.scrollBarWidth;return{cols:Math.max(2,Math.floor(a/e._renderService.dimensions.actualCellWidth)),rows:Math.max(1,Math.floor(i/e._renderService.dimensions.actualCellHeight))}}},e}();t.FitAddon=n}])})); //# sourceMappingURL=xterm-addon-fit.js.map
0
repos/LoLa/website
repos/LoLa/website/libs/worker-javascript.js
"no use strict";!function(e){function t(e,t){var n=e,r="";while(n){var i=t[n];if(typeof i=="string")return i+r;if(i)return i.location.replace(/\/*$/,"/")+(r||i.main||i.name);if(i===!1)return"";var s=n.lastIndexOf("/");if(s===-1)break;r=n.substr(s)+r,n=n.slice(0,s)}return e}if(typeof e.window!="undefined"&&e.document)return;if(e.require&&e.define)return;e.console||(e.console=function(){var e=Array.prototype.slice.call(arguments,0);postMessage({type:"log",data:e})},e.console.error=e.console.warn=e.console.log=e.console.trace=e.console),e.window=e,e.ace=e,e.onerror=function(e,t,n,r,i){postMessage({type:"error",data:{message:e,data:i.data,file:t,line:n,col:r,stack:i.stack}})},e.normalizeModule=function(t,n){if(n.indexOf("!")!==-1){var r=n.split("!");return e.normalizeModule(t,r[0])+"!"+e.normalizeModule(t,r[1])}if(n.charAt(0)=="."){var i=t.split("/").slice(0,-1).join("/");n=(i?i+"/":"")+n;while(n.indexOf(".")!==-1&&s!=n){var s=n;n=n.replace(/^\.\//,"").replace(/\/\.\//,"/").replace(/[^\/]+\/\.\.\//,"")}}return n},e.require=function(r,i){i||(i=r,r=null);if(!i.charAt)throw new Error("worker.js require() accepts only (parentId, id) as arguments");i=e.normalizeModule(r,i);var s=e.require.modules[i];if(s)return s.initialized||(s.initialized=!0,s.exports=s.factory().exports),s.exports;if(!e.require.tlns)return console.log("unable to load "+i);var o=t(i,e.require.tlns);return o.slice(-3)!=".js"&&(o+=".js"),e.require.id=i,e.require.modules[i]={},importScripts(o),e.require(r,i)},e.require.modules={},e.require.tlns={},e.define=function(t,n,r){arguments.length==2?(r=n,typeof t!="string"&&(n=t,t=e.require.id)):arguments.length==1&&(r=t,n=[],t=e.require.id);if(typeof r!="function"){e.require.modules[t]={exports:r,initialized:!0};return}n.length||(n=["require","exports","module"]);var i=function(n){return e.require(t,n)};e.require.modules[t]={exports:{},factory:function(){var e=this,t=r.apply(this,n.slice(0,r.length).map(function(t){switch(t){case"require":return i;case"exports":return e.exports;case"module":return e;default:return i(t)}}));return t&&(e.exports=t),e}}},e.define.amd={},require.tlns={},e.initBaseUrls=function(t){for(var n in t)require.tlns[n]=t[n]},e.initSender=function(){var n=e.require("ace/lib/event_emitter").EventEmitter,r=e.require("ace/lib/oop"),i=function(){};return function(){r.implement(this,n),this.callback=function(e,t){postMessage({type:"call",id:t,data:e})},this.emit=function(e,t){postMessage({type:"event",name:e,data:t})}}.call(i.prototype),new i};var n=e.main=null,r=e.sender=null;e.onmessage=function(t){var i=t.data;if(i.event&&r)r._signal(i.event,i.data);else if(i.command)if(n[i.command])n[i.command].apply(n,i.args);else{if(!e[i.command])throw new Error("Unknown command:"+i.command);e[i.command].apply(e,i.args)}else if(i.init){e.initBaseUrls(i.tlns),r=e.sender=e.initSender();var s=require(i.module)[i.classname];n=e.main=new s(r)}}}(this),ace.define("ace/lib/oop",[],function(e,t,n){"use strict";t.inherits=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})},t.mixin=function(e,t){for(var n in t)e[n]=t[n];return e},t.implement=function(e,n){t.mixin(e,n)}}),ace.define("ace/range",[],function(e,t,n){"use strict";var r=function(e,t){return e.row-t.row||e.column-t.column},i=function(e,t,n,r){this.start={row:e,column:t},this.end={row:n,column:r}};(function(){this.isEqual=function(e){return this.start.row===e.start.row&&this.end.row===e.end.row&&this.start.column===e.start.column&&this.end.column===e.end.column},this.toString=function(){return"Range: ["+this.start.row+"/"+this.start.column+"] -> ["+this.end.row+"/"+this.end.column+"]"},this.contains=function(e,t){return this.compare(e,t)==0},this.compareRange=function(e){var t,n=e.end,r=e.start;return t=this.compare(n.row,n.column),t==1?(t=this.compare(r.row,r.column),t==1?2:t==0?1:0):t==-1?-2:(t=this.compare(r.row,r.column),t==-1?-1:t==1?42:0)},this.comparePoint=function(e){return this.compare(e.row,e.column)},this.containsRange=function(e){return this.comparePoint(e.start)==0&&this.comparePoint(e.end)==0},this.intersects=function(e){var t=this.compareRange(e);return t==-1||t==0||t==1},this.isEnd=function(e,t){return this.end.row==e&&this.end.column==t},this.isStart=function(e,t){return this.start.row==e&&this.start.column==t},this.setStart=function(e,t){typeof e=="object"?(this.start.column=e.column,this.start.row=e.row):(this.start.row=e,this.start.column=t)},this.setEnd=function(e,t){typeof e=="object"?(this.end.column=e.column,this.end.row=e.row):(this.end.row=e,this.end.column=t)},this.inside=function(e,t){return this.compare(e,t)==0?this.isEnd(e,t)||this.isStart(e,t)?!1:!0:!1},this.insideStart=function(e,t){return this.compare(e,t)==0?this.isEnd(e,t)?!1:!0:!1},this.insideEnd=function(e,t){return this.compare(e,t)==0?this.isStart(e,t)?!1:!0:!1},this.compare=function(e,t){return!this.isMultiLine()&&e===this.start.row?t<this.start.column?-1:t>this.end.column?1:0:e<this.start.row?-1:e>this.end.row?1:this.start.row===e?t>=this.start.column?0:-1:this.end.row===e?t<=this.end.column?0:1:0},this.compareStart=function(e,t){return this.start.row==e&&this.start.column==t?-1:this.compare(e,t)},this.compareEnd=function(e,t){return this.end.row==e&&this.end.column==t?1:this.compare(e,t)},this.compareInside=function(e,t){return this.end.row==e&&this.end.column==t?1:this.start.row==e&&this.start.column==t?-1:this.compare(e,t)},this.clipRows=function(e,t){if(this.end.row>t)var n={row:t+1,column:0};else if(this.end.row<e)var n={row:e,column:0};if(this.start.row>t)var r={row:t+1,column:0};else if(this.start.row<e)var r={row:e,column:0};return i.fromPoints(r||this.start,n||this.end)},this.extend=function(e,t){var n=this.compare(e,t);if(n==0)return this;if(n==-1)var r={row:e,column:t};else var s={row:e,column:t};return i.fromPoints(r||this.start,s||this.end)},this.isEmpty=function(){return this.start.row===this.end.row&&this.start.column===this.end.column},this.isMultiLine=function(){return this.start.row!==this.end.row},this.clone=function(){return i.fromPoints(this.start,this.end)},this.collapseRows=function(){return this.end.column==0?new i(this.start.row,0,Math.max(this.start.row,this.end.row-1),0):new i(this.start.row,0,this.end.row,0)},this.toScreenRange=function(e){var t=e.documentToScreenPosition(this.start),n=e.documentToScreenPosition(this.end);return new i(t.row,t.column,n.row,n.column)},this.moveBy=function(e,t){this.start.row+=e,this.start.column+=t,this.end.row+=e,this.end.column+=t}}).call(i.prototype),i.fromPoints=function(e,t){return new i(e.row,e.column,t.row,t.column)},i.comparePoints=r,i.comparePoints=function(e,t){return e.row-t.row||e.column-t.column},t.Range=i}),ace.define("ace/apply_delta",[],function(e,t,n){"use strict";function r(e,t){throw console.log("Invalid Delta:",e),"Invalid Delta: "+t}function i(e,t){return t.row>=0&&t.row<e.length&&t.column>=0&&t.column<=e[t.row].length}function s(e,t){t.action!="insert"&&t.action!="remove"&&r(t,"delta.action must be 'insert' or 'remove'"),t.lines instanceof Array||r(t,"delta.lines must be an Array"),(!t.start||!t.end)&&r(t,"delta.start/end must be an present");var n=t.start;i(e,t.start)||r(t,"delta.start must be contained in document");var s=t.end;t.action=="remove"&&!i(e,s)&&r(t,"delta.end must contained in document for 'remove' actions");var o=s.row-n.row,u=s.column-(o==0?n.column:0);(o!=t.lines.length-1||t.lines[o].length!=u)&&r(t,"delta.range must match delta lines")}t.applyDelta=function(e,t,n){var r=t.start.row,i=t.start.column,s=e[r]||"";switch(t.action){case"insert":var o=t.lines;if(o.length===1)e[r]=s.substring(0,i)+t.lines[0]+s.substring(i);else{var u=[r,1].concat(t.lines);e.splice.apply(e,u),e[r]=s.substring(0,i)+e[r],e[r+t.lines.length-1]+=s.substring(i)}break;case"remove":var a=t.end.column,f=t.end.row;r===f?e[r]=s.substring(0,i)+s.substring(a):e.splice(r,f-r+1,s.substring(0,i)+e[f].substring(a))}}}),ace.define("ace/lib/event_emitter",[],function(e,t,n){"use strict";var r={},i=function(){this.propagationStopped=!0},s=function(){this.defaultPrevented=!0};r._emit=r._dispatchEvent=function(e,t){this._eventRegistry||(this._eventRegistry={}),this._defaultHandlers||(this._defaultHandlers={});var n=this._eventRegistry[e]||[],r=this._defaultHandlers[e];if(!n.length&&!r)return;if(typeof t!="object"||!t)t={};t.type||(t.type=e),t.stopPropagation||(t.stopPropagation=i),t.preventDefault||(t.preventDefault=s),n=n.slice();for(var o=0;o<n.length;o++){n[o](t,this);if(t.propagationStopped)break}if(r&&!t.defaultPrevented)return r(t,this)},r._signal=function(e,t){var n=(this._eventRegistry||{})[e];if(!n)return;n=n.slice();for(var r=0;r<n.length;r++)n[r](t,this)},r.once=function(e,t){var n=this;this.on(e,function r(){n.off(e,r),t.apply(null,arguments)});if(!t)return new Promise(function(e){t=e})},r.setDefaultHandler=function(e,t){var n=this._defaultHandlers;n||(n=this._defaultHandlers={_disabled_:{}});if(n[e]){var r=n[e],i=n._disabled_[e];i||(n._disabled_[e]=i=[]),i.push(r);var s=i.indexOf(t);s!=-1&&i.splice(s,1)}n[e]=t},r.removeDefaultHandler=function(e,t){var n=this._defaultHandlers;if(!n)return;var r=n._disabled_[e];if(n[e]==t)r&&this.setDefaultHandler(e,r.pop());else if(r){var i=r.indexOf(t);i!=-1&&r.splice(i,1)}},r.on=r.addEventListener=function(e,t,n){this._eventRegistry=this._eventRegistry||{};var r=this._eventRegistry[e];return r||(r=this._eventRegistry[e]=[]),r.indexOf(t)==-1&&r[n?"unshift":"push"](t),t},r.off=r.removeListener=r.removeEventListener=function(e,t){this._eventRegistry=this._eventRegistry||{};var n=this._eventRegistry[e];if(!n)return;var r=n.indexOf(t);r!==-1&&n.splice(r,1)},r.removeAllListeners=function(e){e||(this._eventRegistry=this._defaultHandlers=undefined),this._eventRegistry&&(this._eventRegistry[e]=undefined),this._defaultHandlers&&(this._defaultHandlers[e]=undefined)},t.EventEmitter=r}),ace.define("ace/anchor",[],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./lib/event_emitter").EventEmitter,s=t.Anchor=function(e,t,n){this.$onChange=this.onChange.bind(this),this.attach(e),typeof n=="undefined"?this.setPosition(t.row,t.column):this.setPosition(t,n)};(function(){function e(e,t,n){var r=n?e.column<=t.column:e.column<t.column;return e.row<t.row||e.row==t.row&&r}function t(t,n,r){var i=t.action=="insert",s=(i?1:-1)*(t.end.row-t.start.row),o=(i?1:-1)*(t.end.column-t.start.column),u=t.start,a=i?u:t.end;return e(n,u,r)?{row:n.row,column:n.column}:e(a,n,!r)?{row:n.row+s,column:n.column+(n.row==a.row?o:0)}:{row:u.row,column:u.column}}r.implement(this,i),this.getPosition=function(){return this.$clipPositionToDocument(this.row,this.column)},this.getDocument=function(){return this.document},this.$insertRight=!1,this.onChange=function(e){if(e.start.row==e.end.row&&e.start.row!=this.row)return;if(e.start.row>this.row)return;var n=t(e,{row:this.row,column:this.column},this.$insertRight);this.setPosition(n.row,n.column,!0)},this.setPosition=function(e,t,n){var r;n?r={row:e,column:t}:r=this.$clipPositionToDocument(e,t);if(this.row==r.row&&this.column==r.column)return;var i={row:this.row,column:this.column};this.row=r.row,this.column=r.column,this._signal("change",{old:i,value:r})},this.detach=function(){this.document.off("change",this.$onChange)},this.attach=function(e){this.document=e||this.document,this.document.on("change",this.$onChange)},this.$clipPositionToDocument=function(e,t){var n={};return e>=this.document.getLength()?(n.row=Math.max(0,this.document.getLength()-1),n.column=this.document.getLine(n.row).length):e<0?(n.row=0,n.column=0):(n.row=e,n.column=Math.min(this.document.getLine(n.row).length,Math.max(0,t))),t<0&&(n.column=0),n}}).call(s.prototype)}),ace.define("ace/document",[],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./apply_delta").applyDelta,s=e("./lib/event_emitter").EventEmitter,o=e("./range").Range,u=e("./anchor").Anchor,a=function(e){this.$lines=[""],e.length===0?this.$lines=[""]:Array.isArray(e)?this.insertMergedLines({row:0,column:0},e):this.insert({row:0,column:0},e)};(function(){r.implement(this,s),this.setValue=function(e){var t=this.getLength()-1;this.remove(new o(0,0,t,this.getLine(t).length)),this.insert({row:0,column:0},e)},this.getValue=function(){return this.getAllLines().join(this.getNewLineCharacter())},this.createAnchor=function(e,t){return new u(this,e,t)},"aaa".split(/a/).length===0?this.$split=function(e){return e.replace(/\r\n|\r/g,"\n").split("\n")}:this.$split=function(e){return e.split(/\r\n|\r|\n/)},this.$detectNewLine=function(e){var t=e.match(/^.*?(\r\n|\r|\n)/m);this.$autoNewLine=t?t[1]:"\n",this._signal("changeNewLineMode")},this.getNewLineCharacter=function(){switch(this.$newLineMode){case"windows":return"\r\n";case"unix":return"\n";default:return this.$autoNewLine||"\n"}},this.$autoNewLine="",this.$newLineMode="auto",this.setNewLineMode=function(e){if(this.$newLineMode===e)return;this.$newLineMode=e,this._signal("changeNewLineMode")},this.getNewLineMode=function(){return this.$newLineMode},this.isNewLine=function(e){return e=="\r\n"||e=="\r"||e=="\n"},this.getLine=function(e){return this.$lines[e]||""},this.getLines=function(e,t){return this.$lines.slice(e,t+1)},this.getAllLines=function(){return this.getLines(0,this.getLength())},this.getLength=function(){return this.$lines.length},this.getTextRange=function(e){return this.getLinesForRange(e).join(this.getNewLineCharacter())},this.getLinesForRange=function(e){var t;if(e.start.row===e.end.row)t=[this.getLine(e.start.row).substring(e.start.column,e.end.column)];else{t=this.getLines(e.start.row,e.end.row),t[0]=(t[0]||"").substring(e.start.column);var n=t.length-1;e.end.row-e.start.row==n&&(t[n]=t[n].substring(0,e.end.column))}return t},this.insertLines=function(e,t){return console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead."),this.insertFullLines(e,t)},this.removeLines=function(e,t){return console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead."),this.removeFullLines(e,t)},this.insertNewLine=function(e){return console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead."),this.insertMergedLines(e,["",""])},this.insert=function(e,t){return this.getLength()<=1&&this.$detectNewLine(t),this.insertMergedLines(e,this.$split(t))},this.insertInLine=function(e,t){var n=this.clippedPos(e.row,e.column),r=this.pos(e.row,e.column+t.length);return this.applyDelta({start:n,end:r,action:"insert",lines:[t]},!0),this.clonePos(r)},this.clippedPos=function(e,t){var n=this.getLength();e===undefined?e=n:e<0?e=0:e>=n&&(e=n-1,t=undefined);var r=this.getLine(e);return t==undefined&&(t=r.length),t=Math.min(Math.max(t,0),r.length),{row:e,column:t}},this.clonePos=function(e){return{row:e.row,column:e.column}},this.pos=function(e,t){return{row:e,column:t}},this.$clipPosition=function(e){var t=this.getLength();return e.row>=t?(e.row=Math.max(0,t-1),e.column=this.getLine(t-1).length):(e.row=Math.max(0,e.row),e.column=Math.min(Math.max(e.column,0),this.getLine(e.row).length)),e},this.insertFullLines=function(e,t){e=Math.min(Math.max(e,0),this.getLength());var n=0;e<this.getLength()?(t=t.concat([""]),n=0):(t=[""].concat(t),e--,n=this.$lines[e].length),this.insertMergedLines({row:e,column:n},t)},this.insertMergedLines=function(e,t){var n=this.clippedPos(e.row,e.column),r={row:n.row+t.length-1,column:(t.length==1?n.column:0)+t[t.length-1].length};return this.applyDelta({start:n,end:r,action:"insert",lines:t}),this.clonePos(r)},this.remove=function(e){var t=this.clippedPos(e.start.row,e.start.column),n=this.clippedPos(e.end.row,e.end.column);return this.applyDelta({start:t,end:n,action:"remove",lines:this.getLinesForRange({start:t,end:n})}),this.clonePos(t)},this.removeInLine=function(e,t,n){var r=this.clippedPos(e,t),i=this.clippedPos(e,n);return this.applyDelta({start:r,end:i,action:"remove",lines:this.getLinesForRange({start:r,end:i})},!0),this.clonePos(r)},this.removeFullLines=function(e,t){e=Math.min(Math.max(0,e),this.getLength()-1),t=Math.min(Math.max(0,t),this.getLength()-1);var n=t==this.getLength()-1&&e>0,r=t<this.getLength()-1,i=n?e-1:e,s=n?this.getLine(i).length:0,u=r?t+1:t,a=r?0:this.getLine(u).length,f=new o(i,s,u,a),l=this.$lines.slice(e,t+1);return this.applyDelta({start:f.start,end:f.end,action:"remove",lines:this.getLinesForRange(f)}),l},this.removeNewLine=function(e){e<this.getLength()-1&&e>=0&&this.applyDelta({start:this.pos(e,this.getLine(e).length),end:this.pos(e+1,0),action:"remove",lines:["",""]})},this.replace=function(e,t){e instanceof o||(e=o.fromPoints(e.start,e.end));if(t.length===0&&e.isEmpty())return e.start;if(t==this.getTextRange(e))return e.end;this.remove(e);var n;return t?n=this.insert(e.start,t):n=e.start,n},this.applyDeltas=function(e){for(var t=0;t<e.length;t++)this.applyDelta(e[t])},this.revertDeltas=function(e){for(var t=e.length-1;t>=0;t--)this.revertDelta(e[t])},this.applyDelta=function(e,t){var n=e.action=="insert";if(n?e.lines.length<=1&&!e.lines[0]:!o.comparePoints(e.start,e.end))return;n&&e.lines.length>2e4?this.$splitAndapplyLargeDelta(e,2e4):(i(this.$lines,e,t),this._signal("change",e))},this.$safeApplyDelta=function(e){var t=this.$lines.length;(e.action=="remove"&&e.start.row<t&&e.end.row<t||e.action=="insert"&&e.start.row<=t)&&this.applyDelta(e)},this.$splitAndapplyLargeDelta=function(e,t){var n=e.lines,r=n.length-t+1,i=e.start.row,s=e.start.column;for(var o=0,u=0;o<r;o=u){u+=t-1;var a=n.slice(o,u);a.push(""),this.applyDelta({start:this.pos(i+o,s),end:this.pos(i+u,s=0),action:e.action,lines:a},!0)}e.lines=n.slice(o),e.start.row=i+o,e.start.column=s,this.applyDelta(e,!0)},this.revertDelta=function(e){this.$safeApplyDelta({start:this.clonePos(e.start),end:this.clonePos(e.end),action:e.action=="insert"?"remove":"insert",lines:e.lines.slice()})},this.indexToPosition=function(e,t){var n=this.$lines||this.getAllLines(),r=this.getNewLineCharacter().length;for(var i=t||0,s=n.length;i<s;i++){e-=n[i].length+r;if(e<0)return{row:i,column:e+n[i].length+r}}return{row:s-1,column:e+n[s-1].length+r}},this.positionToIndex=function(e,t){var n=this.$lines||this.getAllLines(),r=this.getNewLineCharacter().length,i=0,s=Math.min(e.row,n.length);for(var o=t||0;o<s;++o)i+=n[o].length+r;return i+e.column}}).call(a.prototype),t.Document=a}),ace.define("ace/lib/lang",[],function(e,t,n){"use strict";t.last=function(e){return e[e.length-1]},t.stringReverse=function(e){return e.split("").reverse().join("")},t.stringRepeat=function(e,t){var n="";while(t>0){t&1&&(n+=e);if(t>>=1)e+=e}return n};var r=/^\s\s*/,i=/\s\s*$/;t.stringTrimLeft=function(e){return e.replace(r,"")},t.stringTrimRight=function(e){return e.replace(i,"")},t.copyObject=function(e){var t={};for(var n in e)t[n]=e[n];return t},t.copyArray=function(e){var t=[];for(var n=0,r=e.length;n<r;n++)e[n]&&typeof e[n]=="object"?t[n]=this.copyObject(e[n]):t[n]=e[n];return t},t.deepCopy=function s(e){if(typeof e!="object"||!e)return e;var t;if(Array.isArray(e)){t=[];for(var n=0;n<e.length;n++)t[n]=s(e[n]);return t}if(Object.prototype.toString.call(e)!=="[object Object]")return e;t={};for(var n in e)t[n]=s(e[n]);return t},t.arrayToMap=function(e){var t={};for(var n=0;n<e.length;n++)t[e[n]]=1;return t},t.createMap=function(e){var t=Object.create(null);for(var n in e)t[n]=e[n];return t},t.arrayRemove=function(e,t){for(var n=0;n<=e.length;n++)t===e[n]&&e.splice(n,1)},t.escapeRegExp=function(e){return e.replace(/([.*+?^${}()|[\]\/\\])/g,"\\$1")},t.escapeHTML=function(e){return(""+e).replace(/&/g,"&#38;").replace(/"/g,"&#34;").replace(/'/g,"&#39;").replace(/</g,"&#60;")},t.getMatchOffsets=function(e,t){var n=[];return e.replace(t,function(e){n.push({offset:arguments[arguments.length-2],length:e.length})}),n},t.deferredCall=function(e){var t=null,n=function(){t=null,e()},r=function(e){return r.cancel(),t=setTimeout(n,e||0),r};return r.schedule=r,r.call=function(){return this.cancel(),e(),r},r.cancel=function(){return clearTimeout(t),t=null,r},r.isPending=function(){return t},r},t.delayedCall=function(e,t){var n=null,r=function(){n=null,e()},i=function(e){n==null&&(n=setTimeout(r,e||t))};return i.delay=function(e){n&&clearTimeout(n),n=setTimeout(r,e||t)},i.schedule=i,i.call=function(){this.cancel(),e()},i.cancel=function(){n&&clearTimeout(n),n=null},i.isPending=function(){return n},i}}),ace.define("ace/worker/mirror",[],function(e,t,n){"use strict";var r=e("../range").Range,i=e("../document").Document,s=e("../lib/lang"),o=t.Mirror=function(e){this.sender=e;var t=this.doc=new i(""),n=this.deferredUpdate=s.delayedCall(this.onUpdate.bind(this)),r=this;e.on("change",function(e){var i=e.data;if(i[0].start)t.applyDeltas(i);else for(var s=0;s<i.length;s+=2){if(Array.isArray(i[s+1]))var o={action:"insert",start:i[s],lines:i[s+1]};else var o={action:"remove",start:i[s],end:i[s+1]};t.applyDelta(o,!0)}if(r.$timeout)return n.schedule(r.$timeout);r.onUpdate()})};(function(){this.$timeout=500,this.setTimeout=function(e){this.$timeout=e},this.setValue=function(e){this.doc.setValue(e),this.deferredUpdate.schedule(this.$timeout)},this.getValue=function(e){this.sender.callback(this.doc.getValue(),e)},this.onUpdate=function(){},this.isPending=function(){return this.deferredUpdate.isPending()}}).call(o.prototype)}),ace.define("ace/mode/javascript/jshint",[],function(e,t,n){n.exports=function(){function t(n,r,i){function o(u,a){if(!r[u]){if(!n[u]){var f=typeof e=="function"&&e;if(!a&&f)return f(u,!0);if(s)return s(u,!0);var l=new Error("Cannot find module '"+u+"'");throw l.code="MODULE_NOT_FOUND",l}var c=r[u]={exports:{}};n[u][0].call(c.exports,function(e){var t=n[u][1][e];return o(t?t:e)},c,c.exports,t,n,r,i)}return r[u].exports}var s=typeof e=="function"&&e;for(var u=0;u<i.length;u++)o(i[u]);return o(i[0])}return t}()({"/../../jshint/data/ascii-identifier-data.js":[function(e,t,n){var r=[];for(var i=0;i<128;i++)r[i]=i===36||i>=65&&i<=90||i===95||i>=97&&i<=122;var s=[];for(var i=0;i<128;i++)s[i]=r[i]||i>=48&&i<=57;t.exports={asciiIdentifierStartTable:r,asciiIdentifierPartTable:s}},{}],"/../../jshint/data/es5-identifier-names.js":[function(e,t,n){t.exports=/^(?:[\$A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0525\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0621-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971\u0972\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D28\u0D2A-\u0D39\u0D3D\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC\u0EDD\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8B\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10D0-\u10FA\u10FC\u1100-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u2094\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2D00-\u2D25\u2D30-\u2D65\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31B7\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCB\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA65F\uA662-\uA66E\uA67F-\uA697\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B\uA78C\uA7FB-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA2D\uFA30-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC])(?:[\$0-9A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u0525\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0621-\u065E\u0660-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0900-\u0939\u093C-\u094E\u0950-\u0955\u0958-\u0963\u0966-\u096F\u0971\u0972\u0979-\u097F\u0981-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C01-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C82\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0D02\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D28\u0D2A-\u0D39\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC\u0EDD\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F8B\u0F90-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10D0-\u10FA\u10FC\u1100-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17B3\u17B6-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191C\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BAA\u1BAE-\u1BB9\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF2\u1D00-\u1DE6\u1DFD-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u2094\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF1\u2D00-\u2D25\u2D30-\u2D65\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31B7\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCB\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA65F\uA662-\uA66F\uA67C\uA67D\uA67F-\uA697\uA6A0-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B\uA78C\uA7FB-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7B\uAA80-\uAAC2\uAADB-\uAADD\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA2D\uFA30-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE26\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC])*$/},{}],"/../../jshint/data/non-ascii-identifier-part-only.js":[function(e,t,n){var r="183,768,769,770,771,772,773,774,775,776,777,778,779,780,781,782,783,784,785,786,787,788,789,790,791,792,793,794,795,796,797,798,799,800,801,802,803,804,805,806,807,808,809,810,811,812,813,814,815,816,817,818,819,820,821,822,823,824,825,826,827,828,829,830,831,832,833,834,835,836,837,838,839,840,841,842,843,844,845,846,847,848,849,850,851,852,853,854,855,856,857,858,859,860,861,862,863,864,865,866,867,868,869,870,871,872,873,874,875,876,877,878,879,903,1155,1156,1157,1158,1159,1425,1426,1427,1428,1429,1430,1431,1432,1433,1434,1435,1436,1437,1438,1439,1440,1441,1442,1443,1444,1445,1446,1447,1448,1449,1450,1451,1452,1453,1454,1455,1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,1466,1467,1468,1469,1471,1473,1474,1476,1477,1479,1552,1553,1554,1555,1556,1557,1558,1559,1560,1561,1562,1611,1612,1613,1614,1615,1616,1617,1618,1619,1620,1621,1622,1623,1624,1625,1626,1627,1628,1629,1630,1631,1632,1633,1634,1635,1636,1637,1638,1639,1640,1641,1648,1750,1751,1752,1753,1754,1755,1756,1759,1760,1761,1762,1763,1764,1767,1768,1770,1771,1772,1773,1776,1777,1778,1779,1780,1781,1782,1783,1784,1785,1809,1840,1841,1842,1843,1844,1845,1846,1847,1848,1849,1850,1851,1852,1853,1854,1855,1856,1857,1858,1859,1860,1861,1862,1863,1864,1865,1866,1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,2027,2028,2029,2030,2031,2032,2033,2034,2035,2045,2070,2071,2072,2073,2075,2076,2077,2078,2079,2080,2081,2082,2083,2085,2086,2087,2089,2090,2091,2092,2093,2137,2138,2139,2259,2260,2261,2262,2263,2264,2265,2266,2267,2268,2269,2270,2271,2272,2273,2275,2276,2277,2278,2279,2280,2281,2282,2283,2284,2285,2286,2287,2288,2289,2290,2291,2292,2293,2294,2295,2296,2297,2298,2299,2300,2301,2302,2303,2304,2305,2306,2307,2362,2363,2364,2366,2367,2368,2369,2370,2371,2372,2373,2374,2375,2376,2377,2378,2379,2380,2381,2382,2383,2385,2386,2387,2388,2389,2390,2391,2402,2403,2406,2407,2408,2409,2410,2411,2412,2413,2414,2415,2433,2434,2435,2492,2494,2495,2496,2497,2498,2499,2500,2503,2504,2507,2508,2509,2519,2530,2531,2534,2535,2536,2537,2538,2539,2540,2541,2542,2543,2558,2561,2562,2563,2620,2622,2623,2624,2625,2626,2631,2632,2635,2636,2637,2641,2662,2663,2664,2665,2666,2667,2668,2669,2670,2671,2672,2673,2677,2689,2690,2691,2748,2750,2751,2752,2753,2754,2755,2756,2757,2759,2760,2761,2763,2764,2765,2786,2787,2790,2791,2792,2793,2794,2795,2796,2797,2798,2799,2810,2811,2812,2813,2814,2815,2817,2818,2819,2876,2878,2879,2880,2881,2882,2883,2884,2887,2888,2891,2892,2893,2902,2903,2914,2915,2918,2919,2920,2921,2922,2923,2924,2925,2926,2927,2946,3006,3007,3008,3009,3010,3014,3015,3016,3018,3019,3020,3021,3031,3046,3047,3048,3049,3050,3051,3052,3053,3054,3055,3072,3073,3074,3075,3076,3134,3135,3136,3137,3138,3139,3140,3142,3143,3144,3146,3147,3148,3149,3157,3158,3170,3171,3174,3175,3176,3177,3178,3179,3180,3181,3182,3183,3201,3202,3203,3260,3262,3263,3264,3265,3266,3267,3268,3270,3271,3272,3274,3275,3276,3277,3285,3286,3298,3299,3302,3303,3304,3305,3306,3307,3308,3309,3310,3311,3328,3329,3330,3331,3387,3388,3390,3391,3392,3393,3394,3395,3396,3398,3399,3400,3402,3403,3404,3405,3415,3426,3427,3430,3431,3432,3433,3434,3435,3436,3437,3438,3439,3458,3459,3530,3535,3536,3537,3538,3539,3540,3542,3544,3545,3546,3547,3548,3549,3550,3551,3558,3559,3560,3561,3562,3563,3564,3565,3566,3567,3570,3571,3633,3636,3637,3638,3639,3640,3641,3642,3655,3656,3657,3658,3659,3660,3661,3662,3664,3665,3666,3667,3668,3669,3670,3671,3672,3673,3761,3764,3765,3766,3767,3768,3769,3771,3772,3784,3785,3786,3787,3788,3789,3792,3793,3794,3795,3796,3797,3798,3799,3800,3801,3864,3865,3872,3873,3874,3875,3876,3877,3878,3879,3880,3881,3893,3895,3897,3902,3903,3953,3954,3955,3956,3957,3958,3959,3960,3961,3962,3963,3964,3965,3966,3967,3968,3969,3970,3971,3972,3974,3975,3981,3982,3983,3984,3985,3986,3987,3988,3989,3990,3991,3993,3994,3995,3996,3997,3998,3999,4000,4001,4002,4003,4004,4005,4006,4007,4008,4009,4010,4011,4012,4013,4014,4015,4016,4017,4018,4019,4020,4021,4022,4023,4024,4025,4026,4027,4028,4038,4139,4140,4141,4142,4143,4144,4145,4146,4147,4148,4149,4150,4151,4152,4153,4154,4155,4156,4157,4158,4160,4161,4162,4163,4164,4165,4166,4167,4168,4169,4182,4183,4184,4185,4190,4191,4192,4194,4195,4196,4199,4200,4201,4202,4203,4204,4205,4209,4210,4211,4212,4226,4227,4228,4229,4230,4231,4232,4233,4234,4235,4236,4237,4239,4240,4241,4242,4243,4244,4245,4246,4247,4248,4249,4250,4251,4252,4253,4957,4958,4959,4969,4970,4971,4972,4973,4974,4975,4976,4977,5906,5907,5908,5938,5939,5940,5970,5971,6002,6003,6068,6069,6070,6071,6072,6073,6074,6075,6076,6077,6078,6079,6080,6081,6082,6083,6084,6085,6086,6087,6088,6089,6090,6091,6092,6093,6094,6095,6096,6097,6098,6099,6109,6112,6113,6114,6115,6116,6117,6118,6119,6120,6121,6155,6156,6157,6160,6161,6162,6163,6164,6165,6166,6167,6168,6169,6313,6432,6433,6434,6435,6436,6437,6438,6439,6440,6441,6442,6443,6448,6449,6450,6451,6452,6453,6454,6455,6456,6457,6458,6459,6470,6471,6472,6473,6474,6475,6476,6477,6478,6479,6608,6609,6610,6611,6612,6613,6614,6615,6616,6617,6618,6679,6680,6681,6682,6683,6741,6742,6743,6744,6745,6746,6747,6748,6749,6750,6752,6753,6754,6755,6756,6757,6758,6759,6760,6761,6762,6763,6764,6765,6766,6767,6768,6769,6770,6771,6772,6773,6774,6775,6776,6777,6778,6779,6780,6783,6784,6785,6786,6787,6788,6789,6790,6791,6792,6793,6800,6801,6802,6803,6804,6805,6806,6807,6808,6809,6832,6833,6834,6835,6836,6837,6838,6839,6840,6841,6842,6843,6844,6845,6912,6913,6914,6915,6916,6964,6965,6966,6967,6968,6969,6970,6971,6972,6973,6974,6975,6976,6977,6978,6979,6980,6992,6993,6994,6995,6996,6997,6998,6999,7000,7001,7019,7020,7021,7022,7023,7024,7025,7026,7027,7040,7041,7042,7073,7074,7075,7076,7077,7078,7079,7080,7081,7082,7083,7084,7085,7088,7089,7090,7091,7092,7093,7094,7095,7096,7097,7142,7143,7144,7145,7146,7147,7148,7149,7150,7151,7152,7153,7154,7155,7204,7205,7206,7207,7208,7209,7210,7211,7212,7213,7214,7215,7216,7217,7218,7219,7220,7221,7222,7223,7232,7233,7234,7235,7236,7237,7238,7239,7240,7241,7248,7249,7250,7251,7252,7253,7254,7255,7256,7257,7376,7377,7378,7380,7381,7382,7383,7384,7385,7386,7387,7388,7389,7390,7391,7392,7393,7394,7395,7396,7397,7398,7399,7400,7405,7410,7411,7412,7415,7416,7417,7616,7617,7618,7619,7620,7621,7622,7623,7624,7625,7626,7627,7628,7629,7630,7631,7632,7633,7634,7635,7636,7637,7638,7639,7640,7641,7642,7643,7644,7645,7646,7647,7648,7649,7650,7651,7652,7653,7654,7655,7656,7657,7658,7659,7660,7661,7662,7663,7664,7665,7666,7667,7668,7669,7670,7671,7672,7673,7675,7676,7677,7678,7679,8204,8205,8255,8256,8276,8400,8401,8402,8403,8404,8405,8406,8407,8408,8409,8410,8411,8412,8417,8421,8422,8423,8424,8425,8426,8427,8428,8429,8430,8431,8432,11503,11504,11505,11647,11744,11745,11746,11747,11748,11749,11750,11751,11752,11753,11754,11755,11756,11757,11758,11759,11760,11761,11762,11763,11764,11765,11766,11767,11768,11769,11770,11771,11772,11773,11774,11775,12330,12331,12332,12333,12334,12335,12441,12442,42528,42529,42530,42531,42532,42533,42534,42535,42536,42537,42607,42612,42613,42614,42615,42616,42617,42618,42619,42620,42621,42654,42655,42736,42737,43010,43014,43019,43043,43044,43045,43046,43047,43136,43137,43188,43189,43190,43191,43192,43193,43194,43195,43196,43197,43198,43199,43200,43201,43202,43203,43204,43205,43216,43217,43218,43219,43220,43221,43222,43223,43224,43225,43232,43233,43234,43235,43236,43237,43238,43239,43240,43241,43242,43243,43244,43245,43246,43247,43248,43249,43263,43264,43265,43266,43267,43268,43269,43270,43271,43272,43273,43302,43303,43304,43305,43306,43307,43308,43309,43335,43336,43337,43338,43339,43340,43341,43342,43343,43344,43345,43346,43347,43392,43393,43394,43395,43443,43444,43445,43446,43447,43448,43449,43450,43451,43452,43453,43454,43455,43456,43472,43473,43474,43475,43476,43477,43478,43479,43480,43481,43493,43504,43505,43506,43507,43508,43509,43510,43511,43512,43513,43561,43562,43563,43564,43565,43566,43567,43568,43569,43570,43571,43572,43573,43574,43587,43596,43597,43600,43601,43602,43603,43604,43605,43606,43607,43608,43609,43643,43644,43645,43696,43698,43699,43700,43703,43704,43710,43711,43713,43755,43756,43757,43758,43759,43765,43766,44003,44004,44005,44006,44007,44008,44009,44010,44012,44013,44016,44017,44018,44019,44020,44021,44022,44023,44024,44025,64286,65024,65025,65026,65027,65028,65029,65030,65031,65032,65033,65034,65035,65036,65037,65038,65039,65056,65057,65058,65059,65060,65061,65062,65063,65064,65065,65066,65067,65068,65069,65070,65071,65075,65076,65101,65102,65103,65296,65297,65298,65299,65300,65301,65302,65303,65304,65305,65343",i=r.split(",").map(function(e){return parseInt(e,10)});t.exports=i},{}],"/../../jshint/data/non-ascii-identifier-start.js":[function(e,t,n){var r="170,181,186,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,493,494,495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,520,521,522,523,524,525,526,527,528,529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557,558,559,560,561,562,563,564,565,566,567,568,569,570,571,572,573,574,575,576,577,578,579,580,581,582,583,584,585,586,587,588,589,590,591,592,593,594,595,596,597,598,599,600,601,602,603,604,605,606,607,608,609,610,611,612,613,614,615,616,617,618,619,620,621,622,623,624,625,626,627,628,629,630,631,632,633,634,635,636,637,638,639,640,641,642,643,644,645,646,647,648,649,650,651,652,653,654,655,656,657,658,659,660,661,662,663,664,665,666,667,668,669,670,671,672,673,674,675,676,677,678,679,680,681,682,683,684,685,686,687,688,689,690,691,692,693,694,695,696,697,698,699,700,701,702,703,704,705,710,711,712,713,714,715,716,717,718,719,720,721,736,737,738,739,740,748,750,880,881,882,883,884,886,887,890,891,892,893,895,902,904,905,906,908,910,911,912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,931,932,933,934,935,936,937,938,939,940,941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980,981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000,1001,1002,1003,1004,1005,1006,1007,1008,1009,1010,1011,1012,1013,1015,1016,1017,1018,1019,1020,1021,1022,1023,1024,1025,1026,1027,1028,1029,1030,1031,1032,1033,1034,1035,1036,1037,1038,1039,1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,1104,1105,1106,1107,1108,1109,1110,1111,1112,1113,1114,1115,1116,1117,1118,1119,1120,1121,1122,1123,1124,1125,1126,1127,1128,1129,1130,1131,1132,1133,1134,1135,1136,1137,1138,1139,1140,1141,1142,1143,1144,1145,1146,1147,1148,1149,1150,1151,1152,1153,1162,1163,1164,1165,1166,1167,1168,1169,1170,1171,1172,1173,1174,1175,1176,1177,1178,1179,1180,1181,1182,1183,1184,1185,1186,1187,1188,1189,1190,1191,1192,1193,1194,1195,1196,1197,1198,1199,1200,1201,1202,1203,1204,1205,1206,1207,1208,1209,1210,1211,1212,1213,1214,1215,1216,1217,1218,1219,1220,1221,1222,1223,1224,1225,1226,1227,1228,1229,1230,1231,1232,1233,1234,1235,1236,1237,1238,1239,1240,1241,1242,1243,1244,1245,1246,1247,1248,1249,1250,1251,1252,1253,1254,1255,1256,1257,1258,1259,1260,1261,1262,1263,1264,1265,1266,1267,1268,1269,1270,1271,1272,1273,1274,1275,1276,1277,1278,1279,1280,1281,1282,1283,1284,1285,1286,1287,1288,1289,1290,1291,1292,1293,1294,1295,1296,1297,1298,1299,1300,1301,1302,1303,1304,1305,1306,1307,1308,1309,1310,1311,1312,1313,1314,1315,1316,1317,1318,1319,1320,1321,1322,1323,1324,1325,1326,1327,1329,1330,1331,1332,1333,1334,1335,1336,1337,1338,1339,1340,1341,1342,1343,1344,1345,1346,1347,1348,1349,1350,1351,1352,1353,1354,1355,1356,1357,1358,1359,1360,1361,1362,1363,1364,1365,1366,1369,1376,1377,1378,1379,1380,1381,1382,1383,1384,1385,1386,1387,1388,1389,1390,1391,1392,1393,1394,1395,1396,1397,1398,1399,1400,1401,1402,1403,1404,1405,1406,1407,1408,1409,1410,1411,1412,1413,1414,1415,1416,1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,1519,1520,1521,1522,1568,1569,1570,1571,1572,1573,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583,1584,1585,1586,1587,1588,1589,1590,1591,1592,1593,1594,1595,1596,1597,1598,1599,1600,1601,1602,1603,1604,1605,1606,1607,1608,1609,1610,1646,1647,1649,1650,1651,1652,1653,1654,1655,1656,1657,1658,1659,1660,1661,1662,1663,1664,1665,1666,1667,1668,1669,1670,1671,1672,1673,1674,1675,1676,1677,1678,1679,1680,1681,1682,1683,1684,1685,1686,1687,1688,1689,1690,1691,1692,1693,1694,1695,1696,1697,1698,1699,1700,1701,1702,1703,1704,1705,1706,1707,1708,1709,1710,1711,1712,1713,1714,1715,1716,1717,1718,1719,1720,1721,1722,1723,1724,1725,1726,1727,1728,1729,1730,1731,1732,1733,1734,1735,1736,1737,1738,1739,1740,1741,1742,1743,1744,1745,1746,1747,1749,1765,1766,1774,1775,1786,1787,1788,1791,1808,1810,1811,1812,1813,1814,1815,1816,1817,1818,1819,1820,1821,1822,1823,1824,1825,1826,1827,1828,1829,1830,1831,1832,1833,1834,1835,1836,1837,1838,1839,1869,1870,1871,1872,1873,1874,1875,1876,1877,1878,1879,1880,1881,1882,1883,1884,1885,1886,1887,1888,1889,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913,1914,1915,1916,1917,1918,1919,1920,1921,1922,1923,1924,1925,1926,1927,1928,1929,1930,1931,1932,1933,1934,1935,1936,1937,1938,1939,1940,1941,1942,1943,1944,1945,1946,1947,1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1969,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2036,2037,2042,2048,2049,2050,2051,2052,2053,2054,2055,2056,2057,2058,2059,2060,2061,2062,2063,2064,2065,2066,2067,2068,2069,2074,2084,2088,2112,2113,2114,2115,2116,2117,2118,2119,2120,2121,2122,2123,2124,2125,2126,2127,2128,2129,2130,2131,2132,2133,2134,2135,2136,2144,2145,2146,2147,2148,2149,2150,2151,2152,2153,2154,2208,2209,2210,2211,2212,2213,2214,2215,2216,2217,2218,2219,2220,2221,2222,2223,2224,2225,2226,2227,2228,2230,2231,2232,2233,2234,2235,2236,2237,2308,2309,2310,2311,2312,2313,2314,2315,2316,2317,2318,2319,2320,2321,2322,2323,2324,2325,2326,2327,2328,2329,2330,2331,2332,2333,2334,2335,2336,2337,2338,2339,2340,2341,2342,2343,2344,2345,2346,2347,2348,2349,2350,2351,2352,2353,2354,2355,2356,2357,2358,2359,2360,2361,2365,2384,2392,2393,2394,2395,2396,2397,2398,2399,2400,2401,2417,2418,2419,2420,2421,2422,2423,2424,2425,2426,2427,2428,2429,2430,2431,2432,2437,2438,2439,2440,2441,2442,2443,2444,2447,2448,2451,2452,2453,2454,2455,2456,2457,2458,2459,2460,2461,2462,2463,2464,2465,2466,2467,2468,2469,2470,2471,2472,2474,2475,2476,2477,2478,2479,2480,2482,2486,2487,2488,2489,2493,2510,2524,2525,2527,2528,2529,2544,2545,2556,2565,2566,2567,2568,2569,2570,2575,2576,2579,2580,2581,2582,2583,2584,2585,2586,2587,2588,2589,2590,2591,2592,2593,2594,2595,2596,2597,2598,2599,2600,2602,2603,2604,2605,2606,2607,2608,2610,2611,2613,2614,2616,2617,2649,2650,2651,2652,2654,2674,2675,2676,2693,2694,2695,2696,2697,2698,2699,2700,2701,2703,2704,2705,2707,2708,2709,2710,2711,2712,2713,2714,2715,2716,2717,2718,2719,2720,2721,2722,2723,2724,2725,2726,2727,2728,2730,2731,2732,2733,2734,2735,2736,2738,2739,2741,2742,2743,2744,2745,2749,2768,2784,2785,2809,2821,2822,2823,2824,2825,2826,2827,2828,2831,2832,2835,2836,2837,2838,2839,2840,2841,2842,2843,2844,2845,2846,2847,2848,2849,2850,2851,2852,2853,2854,2855,2856,2858,2859,2860,2861,2862,2863,2864,2866,2867,2869,2870,2871,2872,2873,2877,2908,2909,2911,2912,2913,2929,2947,2949,2950,2951,2952,2953,2954,2958,2959,2960,2962,2963,2964,2965,2969,2970,2972,2974,2975,2979,2980,2984,2985,2986,2990,2991,2992,2993,2994,2995,2996,2997,2998,2999,3000,3001,3024,3077,3078,3079,3080,3081,3082,3083,3084,3086,3087,3088,3090,3091,3092,3093,3094,3095,3096,3097,3098,3099,3100,3101,3102,3103,3104,3105,3106,3107,3108,3109,3110,3111,3112,3114,3115,3116,3117,3118,3119,3120,3121,3122,3123,3124,3125,3126,3127,3128,3129,3133,3160,3161,3162,3168,3169,3200,3205,3206,3207,3208,3209,3210,3211,3212,3214,3215,3216,3218,3219,3220,3221,3222,3223,3224,3225,3226,3227,3228,3229,3230,3231,3232,3233,3234,3235,3236,3237,3238,3239,3240,3242,3243,3244,3245,3246,3247,3248,3249,3250,3251,3253,3254,3255,3256,3257,3261,3294,3296,3297,3313,3314,3333,3334,3335,3336,3337,3338,3339,3340,3342,3343,3344,3346,3347,3348,3349,3350,3351,3352,3353,3354,3355,3356,3357,3358,3359,3360,3361,3362,3363,3364,3365,3366,3367,3368,3369,3370,3371,3372,3373,3374,3375,3376,3377,3378,3379,3380,3381,3382,3383,3384,3385,3386,3389,3406,3412,3413,3414,3423,3424,3425,3450,3451,3452,3453,3454,3455,3461,3462,3463,3464,3465,3466,3467,3468,3469,3470,3471,3472,3473,3474,3475,3476,3477,3478,3482,3483,3484,3485,3486,3487,3488,3489,3490,3491,3492,3493,3494,3495,3496,3497,3498,3499,3500,3501,3502,3503,3504,3505,3507,3508,3509,3510,3511,3512,3513,3514,3515,3517,3520,3521,3522,3523,3524,3525,3526,3585,3586,3587,3588,3589,3590,3591,3592,3593,3594,3595,3596,3597,3598,3599,3600,3601,3602,3603,3604,3605,3606,3607,3608,3609,3610,3611,3612,3613,3614,3615,3616,3617,3618,3619,3620,3621,3622,3623,3624,3625,3626,3627,3628,3629,3630,3631,3632,3634,3635,3648,3649,3650,3651,3652,3653,3654,3713,3714,3716,3719,3720,3722,3725,3732,3733,3734,3735,3737,3738,3739,3740,3741,3742,3743,3745,3746,3747,3749,3751,3754,3755,3757,3758,3759,3760,3762,3763,3773,3776,3777,3778,3779,3780,3782,3804,3805,3806,3807,3840,3904,3905,3906,3907,3908,3909,3910,3911,3913,3914,3915,3916,3917,3918,3919,3920,3921,3922,3923,3924,3925,3926,3927,3928,3929,3930,3931,3932,3933,3934,3935,3936,3937,3938,3939,3940,3941,3942,3943,3944,3945,3946,3947,3948,3976,3977,3978,3979,3980,4096,4097,4098,4099,4100,4101,4102,4103,4104,4105,4106,4107,4108,4109,4110,4111,4112,4113,4114,4115,4116,4117,4118,4119,4120,4121,4122,4123,4124,4125,4126,4127,4128,4129,4130,4131,4132,4133,4134,4135,4136,4137,4138,4159,4176,4177,4178,4179,4180,4181,4186,4187,4188,4189,4193,4197,4198,4206,4207,4208,4213,4214,4215,4216,4217,4218,4219,4220,4221,4222,4223,4224,4225,4238,4256,4257,4258,4259,4260,4261,4262,4263,4264,4265,4266,4267,4268,4269,4270,4271,4272,4273,4274,4275,4276,4277,4278,4279,4280,4281,4282,4283,4284,4285,4286,4287,4288,4289,4290,4291,4292,4293,4295,4301,4304,4305,4306,4307,4308,4309,4310,4311,4312,4313,4314,4315,4316,4317,4318,4319,4320,4321,4322,4323,4324,4325,4326,4327,4328,4329,4330,4331,4332,4333,4334,4335,4336,4337,4338,4339,4340,4341,4342,4343,4344,4345,4346,4348,4349,4350,4351,4352,4353,4354,4355,4356,4357,4358,4359,4360,4361,4362,4363,4364,4365,4366,4367,4368,4369,4370,4371,4372,4373,4374,4375,4376,4377,4378,4379,4380,4381,4382,4383,4384,4385,4386,4387,4388,4389,4390,4391,4392,4393,4394,4395,4396,4397,4398,4399,4400,4401,4402,4403,4404,4405,4406,4407,4408,4409,4410,4411,4412,4413,4414,4415,4416,4417,4418,4419,4420,4421,4422,4423,4424,4425,4426,4427,4428,4429,4430,4431,4432,4433,4434,4435,4436,4437,4438,4439,4440,4441,4442,4443,4444,4445,4446,4447,4448,4449,4450,4451,4452,4453,4454,4455,4456,4457,4458,4459,4460,4461,4462,4463,4464,4465,4466,4467,4468,4469,4470,4471,4472,4473,4474,4475,4476,4477,4478,4479,4480,4481,4482,4483,4484,4485,4486,4487,4488,4489,4490,4491,4492,4493,4494,4495,4496,4497,4498,4499,4500,4501,4502,4503,4504,4505,4506,4507,4508,4509,4510,4511,4512,4513,4514,4515,4516,4517,4518,4519,4520,4521,4522,4523,4524,4525,4526,4527,4528,4529,4530,4531,4532,4533,4534,4535,4536,4537,4538,4539,4540,4541,4542,4543,4544,4545,4546,4547,4548,4549,4550,4551,4552,4553,4554,4555,4556,4557,4558,4559,4560,4561,4562,4563,4564,4565,4566,4567,4568,4569,4570,4571,4572,4573,4574,4575,4576,4577,4578,4579,4580,4581,4582,4583,4584,4585,4586,4587,4588,4589,4590,4591,4592,4593,4594,4595,4596,4597,4598,4599,4600,4601,4602,4603,4604,4605,4606,4607,4608,4609,4610,4611,4612,4613,4614,4615,4616,4617,4618,4619,4620,4621,4622,4623,4624,4625,4626,4627,4628,4629,4630,4631,4632,4633,4634,4635,4636,4637,4638,4639,4640,4641,4642,4643,4644,4645,4646,4647,4648,4649,4650,4651,4652,4653,4654,4655,4656,4657,4658,4659,4660,4661,4662,4663,4664,4665,4666,4667,4668,4669,4670,4671,4672,4673,4674,4675,4676,4677,4678,4679,4680,4682,4683,4684,4685,4688,4689,4690,4691,4692,4693,4694,4696,4698,4699,4700,4701,4704,4705,4706,4707,4708,4709,4710,4711,4712,4713,4714,4715,4716,4717,4718,4719,4720,4721,4722,4723,4724,4725,4726,4727,4728,4729,4730,4731,4732,4733,4734,4735,4736,4737,4738,4739,4740,4741,4742,4743,4744,4746,4747,4748,4749,4752,4753,4754,4755,4756,4757,4758,4759,4760,4761,4762,4763,4764,4765,4766,4767,4768,4769,4770,4771,4772,4773,4774,4775,4776,4777,4778,4779,4780,4781,4782,4783,4784,4786,4787,4788,4789,4792,4793,4794,4795,4796,4797,4798,4800,4802,4803,4804,4805,4808,4809,4810,4811,4812,4813,4814,4815,4816,4817,4818,4819,4820,4821,4822,4824,4825,4826,4827,4828,4829,4830,4831,4832,4833,4834,4835,4836,4837,4838,4839,4840,4841,4842,4843,4844,4845,4846,4847,4848,4849,4850,4851,4852,4853,4854,4855,4856,4857,4858,4859,4860,4861,4862,4863,4864,4865,4866,4867,4868,4869,4870,4871,4872,4873,4874,4875,4876,4877,4878,4879,4880,4882,4883,4884,4885,4888,4889,4890,4891,4892,4893,4894,4895,4896,4897,4898,4899,4900,4901,4902,4903,4904,4905,4906,4907,4908,4909,4910,4911,4912,4913,4914,4915,4916,4917,4918,4919,4920,4921,4922,4923,4924,4925,4926,4927,4928,4929,4930,4931,4932,4933,4934,4935,4936,4937,4938,4939,4940,4941,4942,4943,4944,4945,4946,4947,4948,4949,4950,4951,4952,4953,4954,4992,4993,4994,4995,4996,4997,4998,4999,5000,5001,5002,5003,5004,5005,5006,5007,5024,5025,5026,5027,5028,5029,5030,5031,5032,5033,5034,5035,5036,5037,5038,5039,5040,5041,5042,5043,5044,5045,5046,5047,5048,5049,5050,5051,5052,5053,5054,5055,5056,5057,5058,5059,5060,5061,5062,5063,5064,5065,5066,5067,5068,5069,5070,5071,5072,5073,5074,5075,5076,5077,5078,5079,5080,5081,5082,5083,5084,5085,5086,5087,5088,5089,5090,5091,5092,5093,5094,5095,5096,5097,5098,5099,5100,5101,5102,5103,5104,5105,5106,5107,5108,5109,5112,5113,5114,5115,5116,5117,5121,5122,5123,5124,5125,5126,5127,5128,5129,5130,5131,5132,5133,5134,5135,5136,5137,5138,5139,5140,5141,5142,5143,5144,5145,5146,5147,5148,5149,5150,5151,5152,5153,5154,5155,5156,5157,5158,5159,5160,5161,5162,5163,5164,5165,5166,5167,5168,5169,5170,5171,5172,5173,5174,5175,5176,5177,5178,5179,5180,5181,5182,5183,5184,5185,5186,5187,5188,5189,5190,5191,5192,5193,5194,5195,5196,5197,5198,5199,5200,5201,5202,5203,5204,5205,5206,5207,5208,5209,5210,5211,5212,5213,5214,5215,5216,5217,5218,5219,5220,5221,5222,5223,5224,5225,5226,5227,5228,5229,5230,5231,5232,5233,5234,5235,5236,5237,5238,5239,5240,5241,5242,5243,5244,5245,5246,5247,5248,5249,5250,5251,5252,5253,5254,5255,5256,5257,5258,5259,5260,5261,5262,5263,5264,5265,5266,5267,5268,5269,5270,5271,5272,5273,5274,5275,5276,5277,5278,5279,5280,5281,5282,5283,5284,5285,5286,5287,5288,5289,5290,5291,5292,5293,5294,5295,5296,5297,5298,5299,5300,5301,5302,5303,5304,5305,5306,5307,5308,5309,5310,5311,5312,5313,5314,5315,5316,5317,5318,5319,5320,5321,5322,5323,5324,5325,5326,5327,5328,5329,5330,5331,5332,5333,5334,5335,5336,5337,5338,5339,5340,5341,5342,5343,5344,5345,5346,5347,5348,5349,5350,5351,5352,5353,5354,5355,5356,5357,5358,5359,5360,5361,5362,5363,5364,5365,5366,5367,5368,5369,5370,5371,5372,5373,5374,5375,5376,5377,5378,5379,5380,5381,5382,5383,5384,5385,5386,5387,5388,5389,5390,5391,5392,5393,5394,5395,5396,5397,5398,5399,5400,5401,5402,5403,5404,5405,5406,5407,5408,5409,5410,5411,5412,5413,5414,5415,5416,5417,5418,5419,5420,5421,5422,5423,5424,5425,5426,5427,5428,5429,5430,5431,5432,5433,5434,5435,5436,5437,5438,5439,5440,5441,5442,5443,5444,5445,5446,5447,5448,5449,5450,5451,5452,5453,5454,5455,5456,5457,5458,5459,5460,5461,5462,5463,5464,5465,5466,5467,5468,5469,5470,5471,5472,5473,5474,5475,5476,5477,5478,5479,5480,5481,5482,5483,5484,5485,5486,5487,5488,5489,5490,5491,5492,5493,5494,5495,5496,5497,5498,5499,5500,5501,5502,5503,5504,5505,5506,5507,5508,5509,5510,5511,5512,5513,5514,5515,5516,5517,5518,5519,5520,5521,5522,5523,5524,5525,5526,5527,5528,5529,5530,5531,5532,5533,5534,5535,5536,5537,5538,5539,5540,5541,5542,5543,5544,5545,5546,5547,5548,5549,5550,5551,5552,5553,5554,5555,5556,5557,5558,5559,5560,5561,5562,5563,5564,5565,5566,5567,5568,5569,5570,5571,5572,5573,5574,5575,5576,5577,5578,5579,5580,5581,5582,5583,5584,5585,5586,5587,5588,5589,5590,5591,5592,5593,5594,5595,5596,5597,5598,5599,5600,5601,5602,5603,5604,5605,5606,5607,5608,5609,5610,5611,5612,5613,5614,5615,5616,5617,5618,5619,5620,5621,5622,5623,5624,5625,5626,5627,5628,5629,5630,5631,5632,5633,5634,5635,5636,5637,5638,5639,5640,5641,5642,5643,5644,5645,5646,5647,5648,5649,5650,5651,5652,5653,5654,5655,5656,5657,5658,5659,5660,5661,5662,5663,5664,5665,5666,5667,5668,5669,5670,5671,5672,5673,5674,5675,5676,5677,5678,5679,5680,5681,5682,5683,5684,5685,5686,5687,5688,5689,5690,5691,5692,5693,5694,5695,5696,5697,5698,5699,5700,5701,5702,5703,5704,5705,5706,5707,5708,5709,5710,5711,5712,5713,5714,5715,5716,5717,5718,5719,5720,5721,5722,5723,5724,5725,5726,5727,5728,5729,5730,5731,5732,5733,5734,5735,5736,5737,5738,5739,5740,5743,5744,5745,5746,5747,5748,5749,5750,5751,5752,5753,5754,5755,5756,5757,5758,5759,5761,5762,5763,5764,5765,5766,5767,5768,5769,5770,5771,5772,5773,5774,5775,5776,5777,5778,5779,5780,5781,5782,5783,5784,5785,5786,5792,5793,5794,5795,5796,5797,5798,5799,5800,5801,5802,5803,5804,5805,5806,5807,5808,5809,5810,5811,5812,5813,5814,5815,5816,5817,5818,5819,5820,5821,5822,5823,5824,5825,5826,5827,5828,5829,5830,5831,5832,5833,5834,5835,5836,5837,5838,5839,5840,5841,5842,5843,5844,5845,5846,5847,5848,5849,5850,5851,5852,5853,5854,5855,5856,5857,5858,5859,5860,5861,5862,5863,5864,5865,5866,5870,5871,5872,5873,5874,5875,5876,5877,5878,5879,5880,5888,5889,5890,5891,5892,5893,5894,5895,5896,5897,5898,5899,5900,5902,5903,5904,5905,5920,5921,5922,5923,5924,5925,5926,5927,5928,5929,5930,5931,5932,5933,5934,5935,5936,5937,5952,5953,5954,5955,5956,5957,5958,5959,5960,5961,5962,5963,5964,5965,5966,5967,5968,5969,5984,5985,5986,5987,5988,5989,5990,5991,5992,5993,5994,5995,5996,5998,5999,6000,6016,6017,6018,6019,6020,6021,6022,6023,6024,6025,6026,6027,6028,6029,6030,6031,6032,6033,6034,6035,6036,6037,6038,6039,6040,6041,6042,6043,6044,6045,6046,6047,6048,6049,6050,6051,6052,6053,6054,6055,6056,6057,6058,6059,6060,6061,6062,6063,6064,6065,6066,6067,6103,6108,6176,6177,6178,6179,6180,6181,6182,6183,6184,6185,6186,6187,6188,6189,6190,6191,6192,6193,6194,6195,6196,6197,6198,6199,6200,6201,6202,6203,6204,6205,6206,6207,6208,6209,6210,6211,6212,6213,6214,6215,6216,6217,6218,6219,6220,6221,6222,6223,6224,6225,6226,6227,6228,6229,6230,6231,6232,6233,6234,6235,6236,6237,6238,6239,6240,6241,6242,6243,6244,6245,6246,6247,6248,6249,6250,6251,6252,6253,6254,6255,6256,6257,6258,6259,6260,6261,6262,6263,6264,6272,6273,6274,6275,6276,6277,6278,6279,6280,6281,6282,6283,6284,6285,6286,6287,6288,6289,6290,6291,6292,6293,6294,6295,6296,6297,6298,6299,6300,6301,6302,6303,6304,6305,6306,6307,6308,6309,6310,6311,6312,6314,6320,6321,6322,6323,6324,6325,6326,6327,6328,6329,6330,6331,6332,6333,6334,6335,6336,6337,6338,6339,6340,6341,6342,6343,6344,6345,6346,6347,6348,6349,6350,6351,6352,6353,6354,6355,6356,6357,6358,6359,6360,6361,6362,6363,6364,6365,6366,6367,6368,6369,6370,6371,6372,6373,6374,6375,6376,6377,6378,6379,6380,6381,6382,6383,6384,6385,6386,6387,6388,6389,6400,6401,6402,6403,6404,6405,6406,6407,6408,6409,6410,6411,6412,6413,6414,6415,6416,6417,6418,6419,6420,6421,6422,6423,6424,6425,6426,6427,6428,6429,6430,6480,6481,6482,6483,6484,6485,6486,6487,6488,6489,6490,6491,6492,6493,6494,6495,6496,6497,6498,6499,6500,6501,6502,6503,6504,6505,6506,6507,6508,6509,6512,6513,6514,6515,6516,6528,6529,6530,6531,6532,6533,6534,6535,6536,6537,6538,6539,6540,6541,6542,6543,6544,6545,6546,6547,6548,6549,6550,6551,6552,6553,6554,6555,6556,6557,6558,6559,6560,6561,6562,6563,6564,6565,6566,6567,6568,6569,6570,6571,6576,6577,6578,6579,6580,6581,6582,6583,6584,6585,6586,6587,6588,6589,6590,6591,6592,6593,6594,6595,6596,6597,6598,6599,6600,6601,6656,6657,6658,6659,6660,6661,6662,6663,6664,6665,6666,6667,6668,6669,6670,6671,6672,6673,6674,6675,6676,6677,6678,6688,6689,6690,6691,6692,6693,6694,6695,6696,6697,6698,6699,6700,6701,6702,6703,6704,6705,6706,6707,6708,6709,6710,6711,6712,6713,6714,6715,6716,6717,6718,6719,6720,6721,6722,6723,6724,6725,6726,6727,6728,6729,6730,6731,6732,6733,6734,6735,6736,6737,6738,6739,6740,6823,6917,6918,6919,6920,6921,6922,6923,6924,6925,6926,6927,6928,6929,6930,6931,6932,6933,6934,6935,6936,6937,6938,6939,6940,6941,6942,6943,6944,6945,6946,6947,6948,6949,6950,6951,6952,6953,6954,6955,6956,6957,6958,6959,6960,6961,6962,6963,6981,6982,6983,6984,6985,6986,6987,7043,7044,7045,7046,7047,7048,7049,7050,7051,7052,7053,7054,7055,7056,7057,7058,7059,7060,7061,7062,7063,7064,7065,7066,7067,7068,7069,7070,7071,7072,7086,7087,7098,7099,7100,7101,7102,7103,7104,7105,7106,7107,7108,7109,7110,7111,7112,7113,7114,7115,7116,7117,7118,7119,7120,7121,7122,7123,7124,7125,7126,7127,7128,7129,7130,7131,7132,7133,7134,7135,7136,7137,7138,7139,7140,7141,7168,7169,7170,7171,7172,7173,7174,7175,7176,7177,7178,7179,7180,7181,7182,7183,7184,7185,7186,7187,7188,7189,7190,7191,7192,7193,7194,7195,7196,7197,7198,7199,7200,7201,7202,7203,7245,7246,7247,7258,7259,7260,7261,7262,7263,7264,7265,7266,7267,7268,7269,7270,7271,7272,7273,7274,7275,7276,7277,7278,7279,7280,7281,7282,7283,7284,7285,7286,7287,7288,7289,7290,7291,7292,7293,7296,7297,7298,7299,7300,7301,7302,7303,7304,7312,7313,7314,7315,7316,7317,7318,7319,7320,7321,7322,7323,7324,7325,7326,7327,7328,7329,7330,7331,7332,7333,7334,7335,7336,7337,7338,7339,7340,7341,7342,7343,7344,7345,7346,7347,7348,7349,7350,7351,7352,7353,7354,7357,7358,7359,7401,7402,7403,7404,7406,7407,7408,7409,7413,7414,7424,7425,7426,7427,7428,7429,7430,7431,7432,7433,7434,7435,7436,7437,7438,7439,7440,7441,7442,7443,7444,7445,7446,7447,7448,7449,7450,7451,7452,7453,7454,7455,7456,7457,7458,7459,7460,7461,7462,7463,7464,7465,7466,7467,7468,7469,7470,7471,7472,7473,7474,7475,7476,7477,7478,7479,7480,7481,7482,7483,7484,7485,7486,7487,7488,7489,7490,7491,7492,7493,7494,7495,7496,7497,7498,7499,7500,7501,7502,7503,7504,7505,7506,7507,7508,7509,7510,7511,7512,7513,7514,7515,7516,7517,7518,7519,7520,7521,7522,7523,7524,7525,7526,7527,7528,7529,7530,7531,7532,7533,7534,7535,7536,7537,7538,7539,7540,7541,7542,7543,7544,7545,7546,7547,7548,7549,7550,7551,7552,7553,7554,7555,7556,7557,7558,7559,7560,7561,7562,7563,7564,7565,7566,7567,7568,7569,7570,7571,7572,7573,7574,7575,7576,7577,7578,7579,7580,7581,7582,7583,7584,7585,7586,7587,7588,7589,7590,7591,7592,7593,7594,7595,7596,7597,7598,7599,7600,7601,7602,7603,7604,7605,7606,7607,7608,7609,7610,7611,7612,7613,7614,7615,7680,7681,7682,7683,7684,7685,7686,7687,7688,7689,7690,7691,7692,7693,7694,7695,7696,7697,7698,7699,7700,7701,7702,7703,7704,7705,7706,7707,7708,7709,7710,7711,7712,7713,7714,7715,7716,7717,7718,7719,7720,7721,7722,7723,7724,7725,7726,7727,7728,7729,7730,7731,7732,7733,7734,7735,7736,7737,7738,7739,7740,7741,7742,7743,7744,7745,7746,7747,7748,7749,7750,7751,7752,7753,7754,7755,7756,7757,7758,7759,7760,7761,7762,7763,7764,7765,7766,7767,7768,7769,7770,7771,7772,7773,7774,7775,7776,7777,7778,7779,7780,7781,7782,7783,7784,7785,7786,7787,7788,7789,7790,7791,7792,7793,7794,7795,7796,7797,7798,7799,7800,7801,7802,7803,7804,7805,7806,7807,7808,7809,7810,7811,7812,7813,7814,7815,7816,7817,7818,7819,7820,7821,7822,7823,7824,7825,7826,7827,7828,7829,7830,7831,7832,7833,7834,7835,7836,7837,7838,7839,7840,7841,7842,7843,7844,7845,7846,7847,7848,7849,7850,7851,7852,7853,7854,7855,7856,7857,7858,7859,7860,7861,7862,7863,7864,7865,7866,7867,7868,7869,7870,7871,7872,7873,7874,7875,7876,7877,7878,7879,7880,7881,7882,7883,7884,7885,7886,7887,7888,7889,7890,7891,7892,7893,7894,7895,7896,7897,7898,7899,7900,7901,7902,7903,7904,7905,7906,7907,7908,7909,7910,7911,7912,7913,7914,7915,7916,7917,7918,7919,7920,7921,7922,7923,7924,7925,7926,7927,7928,7929,7930,7931,7932,7933,7934,7935,7936,7937,7938,7939,7940,7941,7942,7943,7944,7945,7946,7947,7948,7949,7950,7951,7952,7953,7954,7955,7956,7957,7960,7961,7962,7963,7964,7965,7968,7969,7970,7971,7972,7973,7974,7975,7976,7977,7978,7979,7980,7981,7982,7983,7984,7985,7986,7987,7988,7989,7990,7991,7992,7993,7994,7995,7996,7997,7998,7999,8000,8001,8002,8003,8004,8005,8008,8009,8010,8011,8012,8013,8016,8017,8018,8019,8020,8021,8022,8023,8025,8027,8029,8031,8032,8033,8034,8035,8036,8037,8038,8039,8040,8041,8042,8043,8044,8045,8046,8047,8048,8049,8050,8051,8052,8053,8054,8055,8056,8057,8058,8059,8060,8061,8064,8065,8066,8067,8068,8069,8070,8071,8072,8073,8074,8075,8076,8077,8078,8079,8080,8081,8082,8083,8084,8085,8086,8087,8088,8089,8090,8091,8092,8093,8094,8095,8096,8097,8098,8099,8100,8101,8102,8103,8104,8105,8106,8107,8108,8109,8110,8111,8112,8113,8114,8115,8116,8118,8119,8120,8121,8122,8123,8124,8126,8130,8131,8132,8134,8135,8136,8137,8138,8139,8140,8144,8145,8146,8147,8150,8151,8152,8153,8154,8155,8160,8161,8162,8163,8164,8165,8166,8167,8168,8169,8170,8171,8172,8178,8179,8180,8182,8183,8184,8185,8186,8187,8188,8305,8319,8336,8337,8338,8339,8340,8341,8342,8343,8344,8345,8346,8347,8348,8450,8455,8458,8459,8460,8461,8462,8463,8464,8465,8466,8467,8469,8472,8473,8474,8475,8476,8477,8484,8486,8488,8490,8491,8492,8493,8494,8495,8496,8497,8498,8499,8500,8501,8502,8503,8504,8505,8508,8509,8510,8511,8517,8518,8519,8520,8521,8526,8544,8545,8546,8547,8548,8549,8550,8551,8552,8553,8554,8555,8556,8557,8558,8559,8560,8561,8562,8563,8564,8565,8566,8567,8568,8569,8570,8571,8572,8573,8574,8575,8576,8577,8578,8579,8580,8581,8582,8583,8584,11264,11265,11266,11267,11268,11269,11270,11271,11272,11273,11274,11275,11276,11277,11278,11279,11280,11281,11282,11283,11284,11285,11286,11287,11288,11289,11290,11291,11292,11293,11294,11295,11296,11297,11298,11299,11300,11301,11302,11303,11304,11305,11306,11307,11308,11309,11310,11312,11313,11314,11315,11316,11317,11318,11319,11320,11321,11322,11323,11324,11325,11326,11327,11328,11329,11330,11331,11332,11333,11334,11335,11336,11337,11338,11339,11340,11341,11342,11343,11344,11345,11346,11347,11348,11349,11350,11351,11352,11353,11354,11355,11356,11357,11358,11360,11361,11362,11363,11364,11365,11366,11367,11368,11369,11370,11371,11372,11373,11374,11375,11376,11377,11378,11379,11380,11381,11382,11383,11384,11385,11386,11387,11388,11389,11390,11391,11392,11393,11394,11395,11396,11397,11398,11399,11400,11401,11402,11403,11404,11405,11406,11407,11408,11409,11410,11411,11412,11413,11414,11415,11416,11417,11418,11419,11420,11421,11422,11423,11424,11425,11426,11427,11428,11429,11430,11431,11432,11433,11434,11435,11436,11437,11438,11439,11440,11441,11442,11443,11444,11445,11446,11447,11448,11449,11450,11451,11452,11453,11454,11455,11456,11457,11458,11459,11460,11461,11462,11463,11464,11465,11466,11467,11468,11469,11470,11471,11472,11473,11474,11475,11476,11477,11478,11479,11480,11481,11482,11483,11484,11485,11486,11487,11488,11489,11490,11491,11492,11499,11500,11501,11502,11506,11507,11520,11521,11522,11523,11524,11525,11526,11527,11528,11529,11530,11531,11532,11533,11534,11535,11536,11537,11538,11539,11540,11541,11542,11543,11544,11545,11546,11547,11548,11549,11550,11551,11552,11553,11554,11555,11556,11557,11559,11565,11568,11569,11570,11571,11572,11573,11574,11575,11576,11577,11578,11579,11580,11581,11582,11583,11584,11585,11586,11587,11588,11589,11590,11591,11592,11593,11594,11595,11596,11597,11598,11599,11600,11601,11602,11603,11604,11605,11606,11607,11608,11609,11610,11611,11612,11613,11614,11615,11616,11617,11618,11619,11620,11621,11622,11623,11631,11648,11649,11650,11651,11652,11653,11654,11655,11656,11657,11658,11659,11660,11661,11662,11663,11664,11665,11666,11667,11668,11669,11670,11680,11681,11682,11683,11684,11685,11686,11688,11689,11690,11691,11692,11693,11694,11696,11697,11698,11699,11700,11701,11702,11704,11705,11706,11707,11708,11709,11710,11712,11713,11714,11715,11716,11717,11718,11720,11721,11722,11723,11724,11725,11726,11728,11729,11730,11731,11732,11733,11734,11736,11737,11738,11739,11740,11741,11742,12293,12294,12295,12321,12322,12323,12324,12325,12326,12327,12328,12329,12337,12338,12339,12340,12341,12344,12345,12346,12347,12348,12353,12354,12355,12356,12357,12358,12359,12360,12361,12362,12363,12364,12365,12366,12367,12368,12369,12370,12371,12372,12373,12374,12375,12376,12377,12378,12379,12380,12381,12382,12383,12384,12385,12386,12387,12388,12389,12390,12391,12392,12393,12394,12395,12396,12397,12398,12399,12400,12401,12402,12403,12404,12405,12406,12407,12408,12409,12410,12411,12412,12413,12414,12415,12416,12417,12418,12419,12420,12421,12422,12423,12424,12425,12426,12427,12428,12429,12430,12431,12432,12433,12434,12435,12436,12437,12438,12443,12444,12445,12446,12447,12449,12450,12451,12452,12453,12454,12455,12456,12457,12458,12459,12460,12461,12462,12463,12464,12465,12466,12467,12468,12469,12470,12471,12472,12473,12474,12475,12476,12477,12478,12479,12480,12481,12482,12483,12484,12485,12486,12487,12488,12489,12490,12491,12492,12493,12494,12495,12496,12497,12498,12499,12500,12501,12502,12503,12504,12505,12506,12507,12508,12509,12510,12511,12512,12513,12514,12515,12516,12517,12518,12519,12520,12521,12522,12523,12524,12525,12526,12527,12528,12529,12530,12531,12532,12533,12534,12535,12536,12537,12538,12540,12541,12542,12543,12549,12550,12551,12552,12553,12554,12555,12556,12557,12558,12559,12560,12561,12562,12563,12564,12565,12566,12567,12568,12569,12570,12571,12572,12573,12574,12575,12576,12577,12578,12579,12580,12581,12582,12583,12584,12585,12586,12587,12588,12589,12590,12591,12593,12594,12595,12596,12597,12598,12599,12600,12601,12602,12603,12604,12605,12606,12607,12608,12609,12610,12611,12612,12613,12614,12615,12616,12617,12618,12619,12620,12621,12622,12623,12624,12625,12626,12627,12628,12629,12630,12631,12632,12633,12634,12635,12636,12637,12638,12639,12640,12641,12642,12643,12644,12645,12646,12647,12648,12649,12650,12651,12652,12653,12654,12655,12656,12657,12658,12659,12660,12661,12662,12663,12664,12665,12666,12667,12668,12669,12670,12671,12672,12673,12674,12675,12676,12677,12678,12679,12680,12681,12682,12683,12684,12685,12686,12704,12705,12706,12707,12708,12709,12710,12711,12712,12713,12714,12715,12716,12717,12718,12719,12720,12721,12722,12723,12724,12725,12726,12727,12728,12729,12730,12784,12785,12786,12787,12788,12789,12790,12791,12792,12793,12794,12795,12796,12797,12798,12799,13312,13313,13314,13315,13316,13317,13318,13319,13320,13321,13322,13323,13324,13325,13326,13327,13328,13329,13330,13331,13332,13333,13334,13335,13336,13337,13338,13339,13340,13341,13342,13343,13344,13345,13346,13347,13348,13349,13350,13351,13352,13353,13354,13355,13356,13357,13358,13359,13360,13361,13362,13363,13364,13365,13366,13367,13368,13369,13370,13371,13372,13373,13374,13375,13376,13377,13378,13379,13380,13381,13382,13383,13384,13385,13386,13387,13388,13389,13390,13391,13392,13393,13394,13395,13396,13397,13398,13399,13400,13401,13402,13403,13404,13405,13406,13407,13408,13409,13410,13411,13412,13413,13414,13415,13416,13417,13418,13419,13420,13421,13422,13423,13424,13425,13426,13427,13428,13429,13430,13431,13432,13433,13434,13435,13436,13437,13438,13439,13440,13441,13442,13443,13444,13445,13446,13447,13448,13449,13450,13451,13452,13453,13454,13455,13456,13457,13458,13459,13460,13461,13462,13463,13464,13465,13466,13467,13468,13469,13470,13471,13472,13473,13474,13475,13476,13477,13478,13479,13480,13481,13482,13483,13484,13485,13486,13487,13488,13489,13490,13491,13492,13493,13494,13495,13496,13497,13498,13499,13500,13501,13502,13503,13504,13505,13506,13507,13508,13509,13510,13511,13512,13513,13514,13515,13516,13517,13518,13519,13520,13521,13522,13523,13524,13525,13526,13527,13528,13529,13530,13531,13532,13533,13534,13535,13536,13537,13538,13539,13540,13541,13542,13543,13544,13545,13546,13547,13548,13549,13550,13551,13552,13553,13554,13555,13556,13557,13558,13559,13560,13561,13562,13563,13564,13565,13566,13567,13568,13569,13570,13571,13572,13573,13574,13575,13576,13577,13578,13579,13580,13581,13582,13583,13584,13585,13586,13587,13588,13589,13590,13591,13592,13593,13594,13595,13596,13597,13598,13599,13600,13601,13602,13603,13604,13605,13606,13607,13608,13609,13610,13611,13612,13613,13614,13615,13616,13617,13618,13619,13620,13621,13622,13623,13624,13625,13626,13627,13628,13629,13630,13631,13632,13633,13634,13635,13636,13637,13638,13639,13640,13641,13642,13643,13644,13645,13646,13647,13648,13649,13650,13651,13652,13653,13654,13655,13656,13657,13658,13659,13660,13661,13662,13663,13664,13665,13666,13667,13668,13669,13670,13671,13672,13673,13674,13675,13676,13677,13678,13679,13680,13681,13682,13683,13684,13685,13686,13687,13688,13689,13690,13691,13692,13693,13694,13695,13696,13697,13698,13699,13700,13701,13702,13703,13704,13705,13706,13707,13708,13709,13710,13711,13712,13713,13714,13715,13716,13717,13718,13719,13720,13721,13722,13723,13724,13725,13726,13727,13728,13729,13730,13731,13732,13733,13734,13735,13736,13737,13738,13739,13740,13741,13742,13743,13744,13745,13746,13747,13748,13749,13750,13751,13752,13753,13754,13755,13756,13757,13758,13759,13760,13761,13762,13763,13764,13765,13766,13767,13768,13769,13770,13771,13772,13773,13774,13775,13776,13777,13778,13779,13780,13781,13782,13783,13784,13785,13786,13787,13788,13789,13790,13791,13792,13793,13794,13795,13796,13797,13798,13799,13800,13801,13802,13803,13804,13805,13806,13807,13808,13809,13810,13811,13812,13813,13814,13815,13816,13817,13818,13819,13820,13821,13822,13823,13824,13825,13826,13827,13828,13829,13830,13831,13832,13833,13834,13835,13836,13837,13838,13839,13840,13841,13842,13843,13844,13845,13846,13847,13848,13849,13850,13851,13852,13853,13854,13855,13856,13857,13858,13859,13860,13861,13862,13863,13864,13865,13866,13867,13868,13869,13870,13871,13872,13873,13874,13875,13876,13877,13878,13879,13880,13881,13882,13883,13884,13885,13886,13887,13888,13889,13890,13891,13892,13893,13894,13895,13896,13897,13898,13899,13900,13901,13902,13903,13904,13905,13906,13907,13908,13909,13910,13911,13912,13913,13914,13915,13916,13917,13918,13919,13920,13921,13922,13923,13924,13925,13926,13927,13928,13929,13930,13931,13932,13933,13934,13935,13936,13937,13938,13939,13940,13941,13942,13943,13944,13945,13946,13947,13948,13949,13950,13951,13952,13953,13954,13955,13956,13957,13958,13959,13960,13961,13962,13963,13964,13965,13966,13967,13968,13969,13970,13971,13972,13973,13974,13975,13976,13977,13978,13979,13980,13981,13982,13983,13984,13985,13986,13987,13988,13989,13990,13991,13992,13993,13994,13995,13996,13997,13998,13999,14000,14001,14002,14003,14004,14005,14006,14007,14008,14009,14010,14011,14012,14013,14014,14015,14016,14017,14018,14019,14020,14021,14022,14023,14024,14025,14026,14027,14028,14029,14030,14031,14032,14033,14034,14035,14036,14037,14038,14039,14040,14041,14042,14043,14044,14045,14046,14047,14048,14049,14050,14051,14052,14053,14054,14055,14056,14057,14058,14059,14060,14061,14062,14063,14064,14065,14066,14067,14068,14069,14070,14071,14072,14073,14074,14075,14076,14077,14078,14079,14080,14081,14082,14083,14084,14085,14086,14087,14088,14089,14090,14091,14092,14093,14094,14095,14096,14097,14098,14099,14100,14101,14102,14103,14104,14105,14106,14107,14108,14109,14110,14111,14112,14113,14114,14115,14116,14117,14118,14119,14120,14121,14122,14123,14124,14125,14126,14127,14128,14129,14130,14131,14132,14133,14134,14135,14136,14137,14138,14139,14140,14141,14142,14143,14144,14145,14146,14147,14148,14149,14150,14151,14152,14153,14154,14155,14156,14157,14158,14159,14160,14161,14162,14163,14164,14165,14166,14167,14168,14169,14170,14171,14172,14173,14174,14175,14176,14177,14178,14179,14180,14181,14182,14183,14184,14185,14186,14187,14188,14189,14190,14191,14192,14193,14194,14195,14196,14197,14198,14199,14200,14201,14202,14203,14204,14205,14206,14207,14208,14209,14210,14211,14212,14213,14214,14215,14216,14217,14218,14219,14220,14221,14222,14223,14224,14225,14226,14227,14228,14229,14230,14231,14232,14233,14234,14235,14236,14237,14238,14239,14240,14241,14242,14243,14244,14245,14246,14247,14248,14249,14250,14251,14252,14253,14254,14255,14256,14257,14258,14259,14260,14261,14262,14263,14264,14265,14266,14267,14268,14269,14270,14271,14272,14273,14274,14275,14276,14277,14278,14279,14280,14281,14282,14283,14284,14285,14286,14287,14288,14289,14290,14291,14292,14293,14294,14295,14296,14297,14298,14299,14300,14301,14302,14303,14304,14305,14306,14307,14308,14309,14310,14311,14312,14313,14314,14315,14316,14317,14318,14319,14320,14321,14322,14323,14324,14325,14326,14327,14328,14329,14330,14331,14332,14333,14334,14335,14336,14337,14338,14339,14340,14341,14342,14343,14344,14345,14346,14347,14348,14349,14350,14351,14352,14353,14354,14355,14356,14357,14358,14359,14360,14361,14362,14363,14364,14365,14366,14367,14368,14369,14370,14371,14372,14373,14374,14375,14376,14377,14378,14379,14380,14381,14382,14383,14384,14385,14386,14387,14388,14389,14390,14391,14392,14393,14394,14395,14396,14397,14398,14399,14400,14401,14402,14403,14404,14405,14406,14407,14408,14409,14410,14411,14412,14413,14414,14415,14416,14417,14418,14419,14420,14421,14422,14423,14424,14425,14426,14427,14428,14429,14430,14431,14432,14433,14434,14435,14436,14437,14438,14439,14440,14441,14442,14443,14444,14445,14446,14447,14448,14449,14450,14451,14452,14453,14454,14455,14456,14457,14458,14459,14460,14461,14462,14463,14464,14465,14466,14467,14468,14469,14470,14471,14472,14473,14474,14475,14476,14477,14478,14479,14480,14481,14482,14483,14484,14485,14486,14487,14488,14489,14490,14491,14492,14493,14494,14495,14496,14497,14498,14499,14500,14501,14502,14503,14504,14505,14506,14507,14508,14509,14510,14511,14512,14513,14514,14515,14516,14517,14518,14519,14520,14521,14522,14523,14524,14525,14526,14527,14528,14529,14530,14531,14532,14533,14534,14535,14536,14537,14538,14539,14540,14541,14542,14543,14544,14545,14546,14547,14548,14549,14550,14551,14552,14553,14554,14555,14556,14557,14558,14559,14560,14561,14562,14563,14564,14565,14566,14567,14568,14569,14570,14571,14572,14573,14574,14575,14576,14577,14578,14579,14580,14581,14582,14583,14584,14585,14586,14587,14588,14589,14590,14591,14592,14593,14594,14595,14596,14597,14598,14599,14600,14601,14602,14603,14604,14605,14606,14607,14608,14609,14610,14611,14612,14613,14614,14615,14616,14617,14618,14619,14620,14621,14622,14623,14624,14625,14626,14627,14628,14629,14630,14631,14632,14633,14634,14635,14636,14637,14638,14639,14640,14641,14642,14643,14644,14645,14646,14647,14648,14649,14650,14651,14652,14653,14654,14655,14656,14657,14658,14659,14660,14661,14662,14663,14664,14665,14666,14667,14668,14669,14670,14671,14672,14673,14674,14675,14676,14677,14678,14679,14680,14681,14682,14683,14684,14685,14686,14687,14688,14689,14690,14691,14692,14693,14694,14695,14696,14697,14698,14699,14700,14701,14702,14703,14704,14705,14706,14707,14708,14709,14710,14711,14712,14713,14714,14715,14716,14717,14718,14719,14720,14721,14722,14723,14724,14725,14726,14727,14728,14729,14730,14731,14732,14733,14734,14735,14736,14737,14738,14739,14740,14741,14742,14743,14744,14745,14746,14747,14748,14749,14750,14751,14752,14753,14754,14755,14756,14757,14758,14759,14760,14761,14762,14763,14764,14765,14766,14767,14768,14769,14770,14771,14772,14773,14774,14775,14776,14777,14778,14779,14780,14781,14782,14783,14784,14785,14786,14787,14788,14789,14790,14791,14792,14793,14794,14795,14796,14797,14798,14799,14800,14801,14802,14803,14804,14805,14806,14807,14808,14809,14810,14811,14812,14813,14814,14815,14816,14817,14818,14819,14820,14821,14822,14823,14824,14825,14826,14827,14828,14829,14830,14831,14832,14833,14834,14835,14836,14837,14838,14839,14840,14841,14842,14843,14844,14845,14846,14847,14848,14849,14850,14851,14852,14853,14854,14855,14856,14857,14858,14859,14860,14861,14862,14863,14864,14865,14866,14867,14868,14869,14870,14871,14872,14873,14874,14875,14876,14877,14878,14879,14880,14881,14882,14883,14884,14885,14886,14887,14888,14889,14890,14891,14892,14893,14894,14895,14896,14897,14898,14899,14900,14901,14902,14903,14904,14905,14906,14907,14908,14909,14910,14911,14912,14913,14914,14915,14916,14917,14918,14919,14920,14921,14922,14923,14924,14925,14926,14927,14928,14929,14930,14931,14932,14933,14934,14935,14936,14937,14938,14939,14940,14941,14942,14943,14944,14945,14946,14947,14948,14949,14950,14951,14952,14953,14954,14955,14956,14957,14958,14959,14960,14961,14962,14963,14964,14965,14966,14967,14968,14969,14970,14971,14972,14973,14974,14975,14976,14977,14978,14979,14980,14981,14982,14983,14984,14985,14986,14987,14988,14989,14990,14991,14992,14993,14994,14995,14996,14997,14998,14999,15000,15001,15002,15003,15004,15005,15006,15007,15008,15009,15010,15011,15012,15013,15014,15015,15016,15017,15018,15019,15020,15021,15022,15023,15024,15025,15026,15027,15028,15029,15030,15031,15032,15033,15034,15035,15036,15037,15038,15039,15040,15041,15042,15043,15044,15045,15046,15047,15048,15049,15050,15051,15052,15053,15054,15055,15056,15057,15058,15059,15060,15061,15062,15063,15064,15065,15066,15067,15068,15069,15070,15071,15072,15073,15074,15075,15076,15077,15078,15079,15080,15081,15082,15083,15084,15085,15086,15087,15088,15089,15090,15091,15092,15093,15094,15095,15096,15097,15098,15099,15100,15101,15102,15103,15104,15105,15106,15107,15108,15109,15110,15111,15112,15113,15114,15115,15116,15117,15118,15119,15120,15121,15122,15123,15124,15125,15126,15127,15128,15129,15130,15131,15132,15133,15134,15135,15136,15137,15138,15139,15140,15141,15142,15143,15144,15145,15146,15147,15148,15149,15150,15151,15152,15153,15154,15155,15156,15157,15158,15159,15160,15161,15162,15163,15164,15165,15166,15167,15168,15169,15170,15171,15172,15173,15174,15175,15176,15177,15178,15179,15180,15181,15182,15183,15184,15185,15186,15187,15188,15189,15190,15191,15192,15193,15194,15195,15196,15197,15198,15199,15200,15201,15202,15203,15204,15205,15206,15207,15208,15209,15210,15211,15212,15213,15214,15215,15216,15217,15218,15219,15220,15221,15222,15223,15224,15225,15226,15227,15228,15229,15230,15231,15232,15233,15234,15235,15236,15237,15238,15239,15240,15241,15242,15243,15244,15245,15246,15247,15248,15249,15250,15251,15252,15253,15254,15255,15256,15257,15258,15259,15260,15261,15262,15263,15264,15265,15266,15267,15268,15269,15270,15271,15272,15273,15274,15275,15276,15277,15278,15279,15280,15281,15282,15283,15284,15285,15286,15287,15288,15289,15290,15291,15292,15293,15294,15295,15296,15297,15298,15299,15300,15301,15302,15303,15304,15305,15306,15307,15308,15309,15310,15311,15312,15313,15314,15315,15316,15317,15318,15319,15320,15321,15322,15323,15324,15325,15326,15327,15328,15329,15330,15331,15332,15333,15334,15335,15336,15337,15338,15339,15340,15341,15342,15343,15344,15345,15346,15347,15348,15349,15350,15351,15352,15353,15354,15355,15356,15357,15358,15359,15360,15361,15362,15363,15364,15365,15366,15367,15368,15369,15370,15371,15372,15373,15374,15375,15376,15377,15378,15379,15380,15381,15382,15383,15384,15385,15386,15387,15388,15389,15390,15391,15392,15393,15394,15395,15396,15397,15398,15399,15400,15401,15402,15403,15404,15405,15406,15407,15408,15409,15410,15411,15412,15413,15414,15415,15416,15417,15418,15419,15420,15421,15422,15423,15424,15425,15426,15427,15428,15429,15430,15431,15432,15433,15434,15435,15436,15437,15438,15439,15440,15441,15442,15443,15444,15445,15446,15447,15448,15449,15450,15451,15452,15453,15454,15455,15456,15457,15458,15459,15460,15461,15462,15463,15464,15465,15466,15467,15468,15469,15470,15471,15472,15473,15474,15475,15476,15477,15478,15479,15480,15481,15482,15483,15484,15485,15486,15487,15488,15489,15490,15491,15492,15493,15494,15495,15496,15497,15498,15499,15500,15501,15502,15503,15504,15505,15506,15507,15508,15509,15510,15511,15512,15513,15514,15515,15516,15517,15518,15519,15520,15521,15522,15523,15524,15525,15526,15527,15528,15529,15530,15531,15532,15533,15534,15535,15536,15537,15538,15539,15540,15541,15542,15543,15544,15545,15546,15547,15548,15549,15550,15551,15552,15553,15554,15555,15556,15557,15558,15559,15560,15561,15562,15563,15564,15565,15566,15567,15568,15569,15570,15571,15572,15573,15574,15575,15576,15577,15578,15579,15580,15581,15582,15583,15584,15585,15586,15587,15588,15589,15590,15591,15592,15593,15594,15595,15596,15597,15598,15599,15600,15601,15602,15603,15604,15605,15606,15607,15608,15609,15610,15611,15612,15613,15614,15615,15616,15617,15618,15619,15620,15621,15622,15623,15624,15625,15626,15627,15628,15629,15630,15631,15632,15633,15634,15635,15636,15637,15638,15639,15640,15641,15642,15643,15644,15645,15646,15647,15648,15649,15650,15651,15652,15653,15654,15655,15656,15657,15658,15659,15660,15661,15662,15663,15664,15665,15666,15667,15668,15669,15670,15671,15672,15673,15674,15675,15676,15677,15678,15679,15680,15681,15682,15683,15684,15685,15686,15687,15688,15689,15690,15691,15692,15693,15694,15695,15696,15697,15698,15699,15700,15701,15702,15703,15704,15705,15706,15707,15708,15709,15710,15711,15712,15713,15714,15715,15716,15717,15718,15719,15720,15721,15722,15723,15724,15725,15726,15727,15728,15729,15730,15731,15732,15733,15734,15735,15736,15737,15738,15739,15740,15741,15742,15743,15744,15745,15746,15747,15748,15749,15750,15751,15752,15753,15754,15755,15756,15757,15758,15759,15760,15761,15762,15763,15764,15765,15766,15767,15768,15769,15770,15771,15772,15773,15774,15775,15776,15777,15778,15779,15780,15781,15782,15783,15784,15785,15786,15787,15788,15789,15790,15791,15792,15793,15794,15795,15796,15797,15798,15799,15800,15801,15802,15803,15804,15805,15806,15807,15808,15809,15810,15811,15812,15813,15814,15815,15816,15817,15818,15819,15820,15821,15822,15823,15824,15825,15826,15827,15828,15829,15830,15831,15832,15833,15834,15835,15836,15837,15838,15839,15840,15841,15842,15843,15844,15845,15846,15847,15848,15849,15850,15851,15852,15853,15854,15855,15856,15857,15858,15859,15860,15861,15862,15863,15864,15865,15866,15867,15868,15869,15870,15871,15872,15873,15874,15875,15876,15877,15878,15879,15880,15881,15882,15883,15884,15885,15886,15887,15888,15889,15890,15891,15892,15893,15894,15895,15896,15897,15898,15899,15900,15901,15902,15903,15904,15905,15906,15907,15908,15909,15910,15911,15912,15913,15914,15915,15916,15917,15918,15919,15920,15921,15922,15923,15924,15925,15926,15927,15928,15929,15930,15931,15932,15933,15934,15935,15936,15937,15938,15939,15940,15941,15942,15943,15944,15945,15946,15947,15948,15949,15950,15951,15952,15953,15954,15955,15956,15957,15958,15959,15960,15961,15962,15963,15964,15965,15966,15967,15968,15969,15970,15971,15972,15973,15974,15975,15976,15977,15978,15979,15980,15981,15982,15983,15984,15985,15986,15987,15988,15989,15990,15991,15992,15993,15994,15995,15996,15997,15998,15999,16000,16001,16002,16003,16004,16005,16006,16007,16008,16009,16010,16011,16012,16013,16014,16015,16016,16017,16018,16019,16020,16021,16022,16023,16024,16025,16026,16027,16028,16029,16030,16031,16032,16033,16034,16035,16036,16037,16038,16039,16040,16041,16042,16043,16044,16045,16046,16047,16048,16049,16050,16051,16052,16053,16054,16055,16056,16057,16058,16059,16060,16061,16062,16063,16064,16065,16066,16067,16068,16069,16070,16071,16072,16073,16074,16075,16076,16077,16078,16079,16080,16081,16082,16083,16084,16085,16086,16087,16088,16089,16090,16091,16092,16093,16094,16095,16096,16097,16098,16099,16100,16101,16102,16103,16104,16105,16106,16107,16108,16109,16110,16111,16112,16113,16114,16115,16116,16117,16118,16119,16120,16121,16122,16123,16124,16125,16126,16127,16128,16129,16130,16131,16132,16133,16134,16135,16136,16137,16138,16139,16140,16141,16142,16143,16144,16145,16146,16147,16148,16149,16150,16151,16152,16153,16154,16155,16156,16157,16158,16159,16160,16161,16162,16163,16164,16165,16166,16167,16168,16169,16170,16171,16172,16173,16174,16175,16176,16177,16178,16179,16180,16181,16182,16183,16184,16185,16186,16187,16188,16189,16190,16191,16192,16193,16194,16195,16196,16197,16198,16199,16200,16201,16202,16203,16204,16205,16206,16207,16208,16209,16210,16211,16212,16213,16214,16215,16216,16217,16218,16219,16220,16221,16222,16223,16224,16225,16226,16227,16228,16229,16230,16231,16232,16233,16234,16235,16236,16237,16238,16239,16240,16241,16242,16243,16244,16245,16246,16247,16248,16249,16250,16251,16252,16253,16254,16255,16256,16257,16258,16259,16260,16261,16262,16263,16264,16265,16266,16267,16268,16269,16270,16271,16272,16273,16274,16275,16276,16277,16278,16279,16280,16281,16282,16283,16284,16285,16286,16287,16288,16289,16290,16291,16292,16293,16294,16295,16296,16297,16298,16299,16300,16301,16302,16303,16304,16305,16306,16307,16308,16309,16310,16311,16312,16313,16314,16315,16316,16317,16318,16319,16320,16321,16322,16323,16324,16325,16326,16327,16328,16329,16330,16331,16332,16333,16334,16335,16336,16337,16338,16339,16340,16341,16342,16343,16344,16345,16346,16347,16348,16349,16350,16351,16352,16353,16354,16355,16356,16357,16358,16359,16360,16361,16362,16363,16364,16365,16366,16367,16368,16369,16370,16371,16372,16373,16374,16375,16376,16377,16378,16379,16380,16381,16382,16383,16384,16385,16386,16387,16388,16389,16390,16391,16392,16393,16394,16395,16396,16397,16398,16399,16400,16401,16402,16403,16404,16405,16406,16407,16408,16409,16410,16411,16412,16413,16414,16415,16416,16417,16418,16419,16420,16421,16422,16423,16424,16425,16426,16427,16428,16429,16430,16431,16432,16433,16434,16435,16436,16437,16438,16439,16440,16441,16442,16443,16444,16445,16446,16447,16448,16449,16450,16451,16452,16453,16454,16455,16456,16457,16458,16459,16460,16461,16462,16463,16464,16465,16466,16467,16468,16469,16470,16471,16472,16473,16474,16475,16476,16477,16478,16479,16480,16481,16482,16483,16484,16485,16486,16487,16488,16489,16490,16491,16492,16493,16494,16495,16496,16497,16498,16499,16500,16501,16502,16503,16504,16505,16506,16507,16508,16509,16510,16511,16512,16513,16514,16515,16516,16517,16518,16519,16520,16521,16522,16523,16524,16525,16526,16527,16528,16529,16530,16531,16532,16533,16534,16535,16536,16537,16538,16539,16540,16541,16542,16543,16544,16545,16546,16547,16548,16549,16550,16551,16552,16553,16554,16555,16556,16557,16558,16559,16560,16561,16562,16563,16564,16565,16566,16567,16568,16569,16570,16571,16572,16573,16574,16575,16576,16577,16578,16579,16580,16581,16582,16583,16584,16585,16586,16587,16588,16589,16590,16591,16592,16593,16594,16595,16596,16597,16598,16599,16600,16601,16602,16603,16604,16605,16606,16607,16608,16609,16610,16611,16612,16613,16614,16615,16616,16617,16618,16619,16620,16621,16622,16623,16624,16625,16626,16627,16628,16629,16630,16631,16632,16633,16634,16635,16636,16637,16638,16639,16640,16641,16642,16643,16644,16645,16646,16647,16648,16649,16650,16651,16652,16653,16654,16655,16656,16657,16658,16659,16660,16661,16662,16663,16664,16665,16666,16667,16668,16669,16670,16671,16672,16673,16674,16675,16676,16677,16678,16679,16680,16681,16682,16683,16684,16685,16686,16687,16688,16689,16690,16691,16692,16693,16694,16695,16696,16697,16698,16699,16700,16701,16702,16703,16704,16705,16706,16707,16708,16709,16710,16711,16712,16713,16714,16715,16716,16717,16718,16719,16720,16721,16722,16723,16724,16725,16726,16727,16728,16729,16730,16731,16732,16733,16734,16735,16736,16737,16738,16739,16740,16741,16742,16743,16744,16745,16746,16747,16748,16749,16750,16751,16752,16753,16754,16755,16756,16757,16758,16759,16760,16761,16762,16763,16764,16765,16766,16767,16768,16769,16770,16771,16772,16773,16774,16775,16776,16777,16778,16779,16780,16781,16782,16783,16784,16785,16786,16787,16788,16789,16790,16791,16792,16793,16794,16795,16796,16797,16798,16799,16800,16801,16802,16803,16804,16805,16806,16807,16808,16809,16810,16811,16812,16813,16814,16815,16816,16817,16818,16819,16820,16821,16822,16823,16824,16825,16826,16827,16828,16829,16830,16831,16832,16833,16834,16835,16836,16837,16838,16839,16840,16841,16842,16843,16844,16845,16846,16847,16848,16849,16850,16851,16852,16853,16854,16855,16856,16857,16858,16859,16860,16861,16862,16863,16864,16865,16866,16867,16868,16869,16870,16871,16872,16873,16874,16875,16876,16877,16878,16879,16880,16881,16882,16883,16884,16885,16886,16887,16888,16889,16890,16891,16892,16893,16894,16895,16896,16897,16898,16899,16900,16901,16902,16903,16904,16905,16906,16907,16908,16909,16910,16911,16912,16913,16914,16915,16916,16917,16918,16919,16920,16921,16922,16923,16924,16925,16926,16927,16928,16929,16930,16931,16932,16933,16934,16935,16936,16937,16938,16939,16940,16941,16942,16943,16944,16945,16946,16947,16948,16949,16950,16951,16952,16953,16954,16955,16956,16957,16958,16959,16960,16961,16962,16963,16964,16965,16966,16967,16968,16969,16970,16971,16972,16973,16974,16975,16976,16977,16978,16979,16980,16981,16982,16983,16984,16985,16986,16987,16988,16989,16990,16991,16992,16993,16994,16995,16996,16997,16998,16999,17000,17001,17002,17003,17004,17005,17006,17007,17008,17009,17010,17011,17012,17013,17014,17015,17016,17017,17018,17019,17020,17021,17022,17023,17024,17025,17026,17027,17028,17029,17030,17031,17032,17033,17034,17035,17036,17037,17038,17039,17040,17041,17042,17043,17044,17045,17046,17047,17048,17049,17050,17051,17052,17053,17054,17055,17056,17057,17058,17059,17060,17061,17062,17063,17064,17065,17066,17067,17068,17069,17070,17071,17072,17073,17074,17075,17076,17077,17078,17079,17080,17081,17082,17083,17084,17085,17086,17087,17088,17089,17090,17091,17092,17093,17094,17095,17096,17097,17098,17099,17100,17101,17102,17103,17104,17105,17106,17107,17108,17109,17110,17111,17112,17113,17114,17115,17116,17117,17118,17119,17120,17121,17122,17123,17124,17125,17126,17127,17128,17129,17130,17131,17132,17133,17134,17135,17136,17137,17138,17139,17140,17141,17142,17143,17144,17145,17146,17147,17148,17149,17150,17151,17152,17153,17154,17155,17156,17157,17158,17159,17160,17161,17162,17163,17164,17165,17166,17167,17168,17169,17170,17171,17172,17173,17174,17175,17176,17177,17178,17179,17180,17181,17182,17183,17184,17185,17186,17187,17188,17189,17190,17191,17192,17193,17194,17195,17196,17197,17198,17199,17200,17201,17202,17203,17204,17205,17206,17207,17208,17209,17210,17211,17212,17213,17214,17215,17216,17217,17218,17219,17220,17221,17222,17223,17224,17225,17226,17227,17228,17229,17230,17231,17232,17233,17234,17235,17236,17237,17238,17239,17240,17241,17242,17243,17244,17245,17246,17247,17248,17249,17250,17251,17252,17253,17254,17255,17256,17257,17258,17259,17260,17261,17262,17263,17264,17265,17266,17267,17268,17269,17270,17271,17272,17273,17274,17275,17276,17277,17278,17279,17280,17281,17282,17283,17284,17285,17286,17287,17288,17289,17290,17291,17292,17293,17294,17295,17296,17297,17298,17299,17300,17301,17302,17303,17304,17305,17306,17307,17308,17309,17310,17311,17312,17313,17314,17315,17316,17317,17318,17319,17320,17321,17322,17323,17324,17325,17326,17327,17328,17329,17330,17331,17332,17333,17334,17335,17336,17337,17338,17339,17340,17341,17342,17343,17344,17345,17346,17347,17348,17349,17350,17351,17352,17353,17354,17355,17356,17357,17358,17359,17360,17361,17362,17363,17364,17365,17366,17367,17368,17369,17370,17371,17372,17373,17374,17375,17376,17377,17378,17379,17380,17381,17382,17383,17384,17385,17386,17387,17388,17389,17390,17391,17392,17393,17394,17395,17396,17397,17398,17399,17400,17401,17402,17403,17404,17405,17406,17407,17408,17409,17410,17411,17412,17413,17414,17415,17416,17417,17418,17419,17420,17421,17422,17423,17424,17425,17426,17427,17428,17429,17430,17431,17432,17433,17434,17435,17436,17437,17438,17439,17440,17441,17442,17443,17444,17445,17446,17447,17448,17449,17450,17451,17452,17453,17454,17455,17456,17457,17458,17459,17460,17461,17462,17463,17464,17465,17466,17467,17468,17469,17470,17471,17472,17473,17474,17475,17476,17477,17478,17479,17480,17481,17482,17483,17484,17485,17486,17487,17488,17489,17490,17491,17492,17493,17494,17495,17496,17497,17498,17499,17500,17501,17502,17503,17504,17505,17506,17507,17508,17509,17510,17511,17512,17513,17514,17515,17516,17517,17518,17519,17520,17521,17522,17523,17524,17525,17526,17527,17528,17529,17530,17531,17532,17533,17534,17535,17536,17537,17538,17539,17540,17541,17542,17543,17544,17545,17546,17547,17548,17549,17550,17551,17552,17553,17554,17555,17556,17557,17558,17559,17560,17561,17562,17563,17564,17565,17566,17567,17568,17569,17570,17571,17572,17573,17574,17575,17576,17577,17578,17579,17580,17581,17582,17583,17584,17585,17586,17587,17588,17589,17590,17591,17592,17593,17594,17595,17596,17597,17598,17599,17600,17601,17602,17603,17604,17605,17606,17607,17608,17609,17610,17611,17612,17613,17614,17615,17616,17617,17618,17619,17620,17621,17622,17623,17624,17625,17626,17627,17628,17629,17630,17631,17632,17633,17634,17635,17636,17637,17638,17639,17640,17641,17642,17643,17644,17645,17646,17647,17648,17649,17650,17651,17652,17653,17654,17655,17656,17657,17658,17659,17660,17661,17662,17663,17664,17665,17666,17667,17668,17669,17670,17671,17672,17673,17674,17675,17676,17677,17678,17679,17680,17681,17682,17683,17684,17685,17686,17687,17688,17689,17690,17691,17692,17693,17694,17695,17696,17697,17698,17699,17700,17701,17702,17703,17704,17705,17706,17707,17708,17709,17710,17711,17712,17713,17714,17715,17716,17717,17718,17719,17720,17721,17722,17723,17724,17725,17726,17727,17728,17729,17730,17731,17732,17733,17734,17735,17736,17737,17738,17739,17740,17741,17742,17743,17744,17745,17746,17747,17748,17749,17750,17751,17752,17753,17754,17755,17756,17757,17758,17759,17760,17761,17762,17763,17764,17765,17766,17767,17768,17769,17770,17771,17772,17773,17774,17775,17776,17777,17778,17779,17780,17781,17782,17783,17784,17785,17786,17787,17788,17789,17790,17791,17792,17793,17794,17795,17796,17797,17798,17799,17800,17801,17802,17803,17804,17805,17806,17807,17808,17809,17810,17811,17812,17813,17814,17815,17816,17817,17818,17819,17820,17821,17822,17823,17824,17825,17826,17827,17828,17829,17830,17831,17832,17833,17834,17835,17836,17837,17838,17839,17840,17841,17842,17843,17844,17845,17846,17847,17848,17849,17850,17851,17852,17853,17854,17855,17856,17857,17858,17859,17860,17861,17862,17863,17864,17865,17866,17867,17868,17869,17870,17871,17872,17873,17874,17875,17876,17877,17878,17879,17880,17881,17882,17883,17884,17885,17886,17887,17888,17889,17890,17891,17892,17893,17894,17895,17896,17897,17898,17899,17900,17901,17902,17903,17904,17905,17906,17907,17908,17909,17910,17911,17912,17913,17914,17915,17916,17917,17918,17919,17920,17921,17922,17923,17924,17925,17926,17927,17928,17929,17930,17931,17932,17933,17934,17935,17936,17937,17938,17939,17940,17941,17942,17943,17944,17945,17946,17947,17948,17949,17950,17951,17952,17953,17954,17955,17956,17957,17958,17959,17960,17961,17962,17963,17964,17965,17966,17967,17968,17969,17970,17971,17972,17973,17974,17975,17976,17977,17978,17979,17980,17981,17982,17983,17984,17985,17986,17987,17988,17989,17990,17991,17992,17993,17994,17995,17996,17997,17998,17999,18000,18001,18002,18003,18004,18005,18006,18007,18008,18009,18010,18011,18012,18013,18014,18015,18016,18017,18018,18019,18020,18021,18022,18023,18024,18025,18026,18027,18028,18029,18030,18031,18032,18033,18034,18035,18036,18037,18038,18039,18040,18041,18042,18043,18044,18045,18046,18047,18048,18049,18050,18051,18052,18053,18054,18055,18056,18057,18058,18059,18060,18061,18062,18063,18064,18065,18066,18067,18068,18069,18070,18071,18072,18073,18074,18075,18076,18077,18078,18079,18080,18081,18082,18083,18084,18085,18086,18087,18088,18089,18090,18091,18092,18093,18094,18095,18096,18097,18098,18099,18100,18101,18102,18103,18104,18105,18106,18107,18108,18109,18110,18111,18112,18113,18114,18115,18116,18117,18118,18119,18120,18121,18122,18123,18124,18125,18126,18127,18128,18129,18130,18131,18132,18133,18134,18135,18136,18137,18138,18139,18140,18141,18142,18143,18144,18145,18146,18147,18148,18149,18150,18151,18152,18153,18154,18155,18156,18157,18158,18159,18160,18161,18162,18163,18164,18165,18166,18167,18168,18169,18170,18171,18172,18173,18174,18175,18176,18177,18178,18179,18180,18181,18182,18183,18184,18185,18186,18187,18188,18189,18190,18191,18192,18193,18194,18195,18196,18197,18198,18199,18200,18201,18202,18203,18204,18205,18206,18207,18208,18209,18210,18211,18212,18213,18214,18215,18216,18217,18218,18219,18220,18221,18222,18223,18224,18225,18226,18227,18228,18229,18230,18231,18232,18233,18234,18235,18236,18237,18238,18239,18240,18241,18242,18243,18244,18245,18246,18247,18248,18249,18250,18251,18252,18253,18254,18255,18256,18257,18258,18259,18260,18261,18262,18263,18264,18265,18266,18267,18268,18269,18270,18271,18272,18273,18274,18275,18276,18277,18278,18279,18280,18281,18282,18283,18284,18285,18286,18287,18288,18289,18290,18291,18292,18293,18294,18295,18296,18297,18298,18299,18300,18301,18302,18303,18304,18305,18306,18307,18308,18309,18310,18311,18312,18313,18314,18315,18316,18317,18318,18319,18320,18321,18322,18323,18324,18325,18326,18327,18328,18329,18330,18331,18332,18333,18334,18335,18336,18337,18338,18339,18340,18341,18342,18343,18344,18345,18346,18347,18348,18349,18350,18351,18352,18353,18354,18355,18356,18357,18358,18359,18360,18361,18362,18363,18364,18365,18366,18367,18368,18369,18370,18371,18372,18373,18374,18375,18376,18377,18378,18379,18380,18381,18382,18383,18384,18385,18386,18387,18388,18389,18390,18391,18392,18393,18394,18395,18396,18397,18398,18399,18400,18401,18402,18403,18404,18405,18406,18407,18408,18409,18410,18411,18412,18413,18414,18415,18416,18417,18418,18419,18420,18421,18422,18423,18424,18425,18426,18427,18428,18429,18430,18431,18432,18433,18434,18435,18436,18437,18438,18439,18440,18441,18442,18443,18444,18445,18446,18447,18448,18449,18450,18451,18452,18453,18454,18455,18456,18457,18458,18459,18460,18461,18462,18463,18464,18465,18466,18467,18468,18469,18470,18471,18472,18473,18474,18475,18476,18477,18478,18479,18480,18481,18482,18483,18484,18485,18486,18487,18488,18489,18490,18491,18492,18493,18494,18495,18496,18497,18498,18499,18500,18501,18502,18503,18504,18505,18506,18507,18508,18509,18510,18511,18512,18513,18514,18515,18516,18517,18518,18519,18520,18521,18522,18523,18524,18525,18526,18527,18528,18529,18530,18531,18532,18533,18534,18535,18536,18537,18538,18539,18540,18541,18542,18543,18544,18545,18546,18547,18548,18549,18550,18551,18552,18553,18554,18555,18556,18557,18558,18559,18560,18561,18562,18563,18564,18565,18566,18567,18568,18569,18570,18571,18572,18573,18574,18575,18576,18577,18578,18579,18580,18581,18582,18583,18584,18585,18586,18587,18588,18589,18590,18591,18592,18593,18594,18595,18596,18597,18598,18599,18600,18601,18602,18603,18604,18605,18606,18607,18608,18609,18610,18611,18612,18613,18614,18615,18616,18617,18618,18619,18620,18621,18622,18623,18624,18625,18626,18627,18628,18629,18630,18631,18632,18633,18634,18635,18636,18637,18638,18639,18640,18641,18642,18643,18644,18645,18646,18647,18648,18649,18650,18651,18652,18653,18654,18655,18656,18657,18658,18659,18660,18661,18662,18663,18664,18665,18666,18667,18668,18669,18670,18671,18672,18673,18674,18675,18676,18677,18678,18679,18680,18681,18682,18683,18684,18685,18686,18687,18688,18689,18690,18691,18692,18693,18694,18695,18696,18697,18698,18699,18700,18701,18702,18703,18704,18705,18706,18707,18708,18709,18710,18711,18712,18713,18714,18715,18716,18717,18718,18719,18720,18721,18722,18723,18724,18725,18726,18727,18728,18729,18730,18731,18732,18733,18734,18735,18736,18737,18738,18739,18740,18741,18742,18743,18744,18745,18746,18747,18748,18749,18750,18751,18752,18753,18754,18755,18756,18757,18758,18759,18760,18761,18762,18763,18764,18765,18766,18767,18768,18769,18770,18771,18772,18773,18774,18775,18776,18777,18778,18779,18780,18781,18782,18783,18784,18785,18786,18787,18788,18789,18790,18791,18792,18793,18794,18795,18796,18797,18798,18799,18800,18801,18802,18803,18804,18805,18806,18807,18808,18809,18810,18811,18812,18813,18814,18815,18816,18817,18818,18819,18820,18821,18822,18823,18824,18825,18826,18827,18828,18829,18830,18831,18832,18833,18834,18835,18836,18837,18838,18839,18840,18841,18842,18843,18844,18845,18846,18847,18848,18849,18850,18851,18852,18853,18854,18855,18856,18857,18858,18859,18860,18861,18862,18863,18864,18865,18866,18867,18868,18869,18870,18871,18872,18873,18874,18875,18876,18877,18878,18879,18880,18881,18882,18883,18884,18885,18886,18887,18888,18889,18890,18891,18892,18893,18894,18895,18896,18897,18898,18899,18900,18901,18902,18903,18904,18905,18906,18907,18908,18909,18910,18911,18912,18913,18914,18915,18916,18917,18918,18919,18920,18921,18922,18923,18924,18925,18926,18927,18928,18929,18930,18931,18932,18933,18934,18935,18936,18937,18938,18939,18940,18941,18942,18943,18944,18945,18946,18947,18948,18949,18950,18951,18952,18953,18954,18955,18956,18957,18958,18959,18960,18961,18962,18963,18964,18965,18966,18967,18968,18969,18970,18971,18972,18973,18974,18975,18976,18977,18978,18979,18980,18981,18982,18983,18984,18985,18986,18987,18988,18989,18990,18991,18992,18993,18994,18995,18996,18997,18998,18999,19000,19001,19002,19003,19004,19005,19006,19007,19008,19009,19010,19011,19012,19013,19014,19015,19016,19017,19018,19019,19020,19021,19022,19023,19024,19025,19026,19027,19028,19029,19030,19031,19032,19033,19034,19035,19036,19037,19038,19039,19040,19041,19042,19043,19044,19045,19046,19047,19048,19049,19050,19051,19052,19053,19054,19055,19056,19057,19058,19059,19060,19061,19062,19063,19064,19065,19066,19067,19068,19069,19070,19071,19072,19073,19074,19075,19076,19077,19078,19079,19080,19081,19082,19083,19084,19085,19086,19087,19088,19089,19090,19091,19092,19093,19094,19095,19096,19097,19098,19099,19100,19101,19102,19103,19104,19105,19106,19107,19108,19109,19110,19111,19112,19113,19114,19115,19116,19117,19118,19119,19120,19121,19122,19123,19124,19125,19126,19127,19128,19129,19130,19131,19132,19133,19134,19135,19136,19137,19138,19139,19140,19141,19142,19143,19144,19145,19146,19147,19148,19149,19150,19151,19152,19153,19154,19155,19156,19157,19158,19159,19160,19161,19162,19163,19164,19165,19166,19167,19168,19169,19170,19171,19172,19173,19174,19175,19176,19177,19178,19179,19180,19181,19182,19183,19184,19185,19186,19187,19188,19189,19190,19191,19192,19193,19194,19195,19196,19197,19198,19199,19200,19201,19202,19203,19204,19205,19206,19207,19208,19209,19210,19211,19212,19213,19214,19215,19216,19217,19218,19219,19220,19221,19222,19223,19224,19225,19226,19227,19228,19229,19230,19231,19232,19233,19234,19235,19236,19237,19238,19239,19240,19241,19242,19243,19244,19245,19246,19247,19248,19249,19250,19251,19252,19253,19254,19255,19256,19257,19258,19259,19260,19261,19262,19263,19264,19265,19266,19267,19268,19269,19270,19271,19272,19273,19274,19275,19276,19277,19278,19279,19280,19281,19282,19283,19284,19285,19286,19287,19288,19289,19290,19291,19292,19293,19294,19295,19296,19297,19298,19299,19300,19301,19302,19303,19304,19305,19306,19307,19308,19309,19310,19311,19312,19313,19314,19315,19316,19317,19318,19319,19320,19321,19322,19323,19324,19325,19326,19327,19328,19329,19330,19331,19332,19333,19334,19335,19336,19337,19338,19339,19340,19341,19342,19343,19344,19345,19346,19347,19348,19349,19350,19351,19352,19353,19354,19355,19356,19357,19358,19359,19360,19361,19362,19363,19364,19365,19366,19367,19368,19369,19370,19371,19372,19373,19374,19375,19376,19377,19378,19379,19380,19381,19382,19383,19384,19385,19386,19387,19388,19389,19390,19391,19392,19393,19394,19395,19396,19397,19398,19399,19400,19401,19402,19403,19404,19405,19406,19407,19408,19409,19410,19411,19412,19413,19414,19415,19416,19417,19418,19419,19420,19421,19422,19423,19424,19425,19426,19427,19428,19429,19430,19431,19432,19433,19434,19435,19436,19437,19438,19439,19440,19441,19442,19443,19444,19445,19446,19447,19448,19449,19450,19451,19452,19453,19454,19455,19456,19457,19458,19459,19460,19461,19462,19463,19464,19465,19466,19467,19468,19469,19470,19471,19472,19473,19474,19475,19476,19477,19478,19479,19480,19481,19482,19483,19484,19485,19486,19487,19488,19489,19490,19491,19492,19493,19494,19495,19496,19497,19498,19499,19500,19501,19502,19503,19504,19505,19506,19507,19508,19509,19510,19511,19512,19513,19514,19515,19516,19517,19518,19519,19520,19521,19522,19523,19524,19525,19526,19527,19528,19529,19530,19531,19532,19533,19534,19535,19536,19537,19538,19539,19540,19541,19542,19543,19544,19545,19546,19547,19548,19549,19550,19551,19552,19553,19554,19555,19556,19557,19558,19559,19560,19561,19562,19563,19564,19565,19566,19567,19568,19569,19570,19571,19572,19573,19574,19575,19576,19577,19578,19579,19580,19581,19582,19583,19584,19585,19586,19587,19588,19589,19590,19591,19592,19593,19594,19595,19596,19597,19598,19599,19600,19601,19602,19603,19604,19605,19606,19607,19608,19609,19610,19611,19612,19613,19614,19615,19616,19617,19618,19619,19620,19621,19622,19623,19624,19625,19626,19627,19628,19629,19630,19631,19632,19633,19634,19635,19636,19637,19638,19639,19640,19641,19642,19643,19644,19645,19646,19647,19648,19649,19650,19651,19652,19653,19654,19655,19656,19657,19658,19659,19660,19661,19662,19663,19664,19665,19666,19667,19668,19669,19670,19671,19672,19673,19674,19675,19676,19677,19678,19679,19680,19681,19682,19683,19684,19685,19686,19687,19688,19689,19690,19691,19692,19693,19694,19695,19696,19697,19698,19699,19700,19701,19702,19703,19704,19705,19706,19707,19708,19709,19710,19711,19712,19713,19714,19715,19716,19717,19718,19719,19720,19721,19722,19723,19724,19725,19726,19727,19728,19729,19730,19731,19732,19733,19734,19735,19736,19737,19738,19739,19740,19741,19742,19743,19744,19745,19746,19747,19748,19749,19750,19751,19752,19753,19754,19755,19756,19757,19758,19759,19760,19761,19762,19763,19764,19765,19766,19767,19768,19769,19770,19771,19772,19773,19774,19775,19776,19777,19778,19779,19780,19781,19782,19783,19784,19785,19786,19787,19788,19789,19790,19791,19792,19793,19794,19795,19796,19797,19798,19799,19800,19801,19802,19803,19804,19805,19806,19807,19808,19809,19810,19811,19812,19813,19814,19815,19816,19817,19818,19819,19820,19821,19822,19823,19824,19825,19826,19827,19828,19829,19830,19831,19832,19833,19834,19835,19836,19837,19838,19839,19840,19841,19842,19843,19844,19845,19846,19847,19848,19849,19850,19851,19852,19853,19854,19855,19856,19857,19858,19859,19860,19861,19862,19863,19864,19865,19866,19867,19868,19869,19870,19871,19872,19873,19874,19875,19876,19877,19878,19879,19880,19881,19882,19883,19884,19885,19886,19887,19888,19889,19890,19891,19892,19893,19968,19969,19970,19971,19972,19973,19974,19975,19976,19977,19978,19979,19980,19981,19982,19983,19984,19985,19986,19987,19988,19989,19990,19991,19992,19993,19994,19995,19996,19997,19998,19999,20000,20001,20002,20003,20004,20005,20006,20007,20008,20009,20010,20011,20012,20013,20014,20015,20016,20017,20018,20019,20020,20021,20022,20023,20024,20025,20026,20027,20028,20029,20030,20031,20032,20033,20034,20035,20036,20037,20038,20039,20040,20041,20042,20043,20044,20045,20046,20047,20048,20049,20050,20051,20052,20053,20054,20055,20056,20057,20058,20059,20060,20061,20062,20063,20064,20065,20066,20067,20068,20069,20070,20071,20072,20073,20074,20075,20076,20077,20078,20079,20080,20081,20082,20083,20084,20085,20086,20087,20088,20089,20090,20091,20092,20093,20094,20095,20096,20097,20098,20099,20100,20101,20102,20103,20104,20105,20106,20107,20108,20109,20110,20111,20112,20113,20114,20115,20116,20117,20118,20119,20120,20121,20122,20123,20124,20125,20126,20127,20128,20129,20130,20131,20132,20133,20134,20135,20136,20137,20138,20139,20140,20141,20142,20143,20144,20145,20146,20147,20148,20149,20150,20151,20152,20153,20154,20155,20156,20157,20158,20159,20160,20161,20162,20163,20164,20165,20166,20167,20168,20169,20170,20171,20172,20173,20174,20175,20176,20177,20178,20179,20180,20181,20182,20183,20184,20185,20186,20187,20188,20189,20190,20191,20192,20193,20194,20195,20196,20197,20198,20199,20200,20201,20202,20203,20204,20205,20206,20207,20208,20209,20210,20211,20212,20213,20214,20215,20216,20217,20218,20219,20220,20221,20222,20223,20224,20225,20226,20227,20228,20229,20230,20231,20232,20233,20234,20235,20236,20237,20238,20239,20240,20241,20242,20243,20244,20245,20246,20247,20248,20249,20250,20251,20252,20253,20254,20255,20256,20257,20258,20259,20260,20261,20262,20263,20264,20265,20266,20267,20268,20269,20270,20271,20272,20273,20274,20275,20276,20277,20278,20279,20280,20281,20282,20283,20284,20285,20286,20287,20288,20289,20290,20291,20292,20293,20294,20295,20296,20297,20298,20299,20300,20301,20302,20303,20304,20305,20306,20307,20308,20309,20310,20311,20312,20313,20314,20315,20316,20317,20318,20319,20320,20321,20322,20323,20324,20325,20326,20327,20328,20329,20330,20331,20332,20333,20334,20335,20336,20337,20338,20339,20340,20341,20342,20343,20344,20345,20346,20347,20348,20349,20350,20351,20352,20353,20354,20355,20356,20357,20358,20359,20360,20361,20362,20363,20364,20365,20366,20367,20368,20369,20370,20371,20372,20373,20374,20375,20376,20377,20378,20379,20380,20381,20382,20383,20384,20385,20386,20387,20388,20389,20390,20391,20392,20393,20394,20395,20396,20397,20398,20399,20400,20401,20402,20403,20404,20405,20406,20407,20408,20409,20410,20411,20412,20413,20414,20415,20416,20417,20418,20419,20420,20421,20422,20423,20424,20425,20426,20427,20428,20429,20430,20431,20432,20433,20434,20435,20436,20437,20438,20439,20440,20441,20442,20443,20444,20445,20446,20447,20448,20449,20450,20451,20452,20453,20454,20455,20456,20457,20458,20459,20460,20461,20462,20463,20464,20465,20466,20467,20468,20469,20470,20471,20472,20473,20474,20475,20476,20477,20478,20479,20480,20481,20482,20483,20484,20485,20486,20487,20488,20489,20490,20491,20492,20493,20494,20495,20496,20497,20498,20499,20500,20501,20502,20503,20504,20505,20506,20507,20508,20509,20510,20511,20512,20513,20514,20515,20516,20517,20518,20519,20520,20521,20522,20523,20524,20525,20526,20527,20528,20529,20530,20531,20532,20533,20534,20535,20536,20537,20538,20539,20540,20541,20542,20543,20544,20545,20546,20547,20548,20549,20550,20551,20552,20553,20554,20555,20556,20557,20558,20559,20560,20561,20562,20563,20564,20565,20566,20567,20568,20569,20570,20571,20572,20573,20574,20575,20576,20577,20578,20579,20580,20581,20582,20583,20584,20585,20586,20587,20588,20589,20590,20591,20592,20593,20594,20595,20596,20597,20598,20599,20600,20601,20602,20603,20604,20605,20606,20607,20608,20609,20610,20611,20612,20613,20614,20615,20616,20617,20618,20619,20620,20621,20622,20623,20624,20625,20626,20627,20628,20629,20630,20631,20632,20633,20634,20635,20636,20637,20638,20639,20640,20641,20642,20643,20644,20645,20646,20647,20648,20649,20650,20651,20652,20653,20654,20655,20656,20657,20658,20659,20660,20661,20662,20663,20664,20665,20666,20667,20668,20669,20670,20671,20672,20673,20674,20675,20676,20677,20678,20679,20680,20681,20682,20683,20684,20685,20686,20687,20688,20689,20690,20691,20692,20693,20694,20695,20696,20697,20698,20699,20700,20701,20702,20703,20704,20705,20706,20707,20708,20709,20710,20711,20712,20713,20714,20715,20716,20717,20718,20719,20720,20721,20722,20723,20724,20725,20726,20727,20728,20729,20730,20731,20732,20733,20734,20735,20736,20737,20738,20739,20740,20741,20742,20743,20744,20745,20746,20747,20748,20749,20750,20751,20752,20753,20754,20755,20756,20757,20758,20759,20760,20761,20762,20763,20764,20765,20766,20767,20768,20769,20770,20771,20772,20773,20774,20775,20776,20777,20778,20779,20780,20781,20782,20783,20784,20785,20786,20787,20788,20789,20790,20791,20792,20793,20794,20795,20796,20797,20798,20799,20800,20801,20802,20803,20804,20805,20806,20807,20808,20809,20810,20811,20812,20813,20814,20815,20816,20817,20818,20819,20820,20821,20822,20823,20824,20825,20826,20827,20828,20829,20830,20831,20832,20833,20834,20835,20836,20837,20838,20839,20840,20841,20842,20843,20844,20845,20846,20847,20848,20849,20850,20851,20852,20853,20854,20855,20856,20857,20858,20859,20860,20861,20862,20863,20864,20865,20866,20867,20868,20869,20870,20871,20872,20873,20874,20875,20876,20877,20878,20879,20880,20881,20882,20883,20884,20885,20886,20887,20888,20889,20890,20891,20892,20893,20894,20895,20896,20897,20898,20899,20900,20901,20902,20903,20904,20905,20906,20907,20908,20909,20910,20911,20912,20913,20914,20915,20916,20917,20918,20919,20920,20921,20922,20923,20924,20925,20926,20927,20928,20929,20930,20931,20932,20933,20934,20935,20936,20937,20938,20939,20940,20941,20942,20943,20944,20945,20946,20947,20948,20949,20950,20951,20952,20953,20954,20955,20956,20957,20958,20959,20960,20961,20962,20963,20964,20965,20966,20967,20968,20969,20970,20971,20972,20973,20974,20975,20976,20977,20978,20979,20980,20981,20982,20983,20984,20985,20986,20987,20988,20989,20990,20991,20992,20993,20994,20995,20996,20997,20998,20999,21000,21001,21002,21003,21004,21005,21006,21007,21008,21009,21010,21011,21012,21013,21014,21015,21016,21017,21018,21019,21020,21021,21022,21023,21024,21025,21026,21027,21028,21029,21030,21031,21032,21033,21034,21035,21036,21037,21038,21039,21040,21041,21042,21043,21044,21045,21046,21047,21048,21049,21050,21051,21052,21053,21054,21055,21056,21057,21058,21059,21060,21061,21062,21063,21064,21065,21066,21067,21068,21069,21070,21071,21072,21073,21074,21075,21076,21077,21078,21079,21080,21081,21082,21083,21084,21085,21086,21087,21088,21089,21090,21091,21092,21093,21094,21095,21096,21097,21098,21099,21100,21101,21102,21103,21104,21105,21106,21107,21108,21109,21110,21111,21112,21113,21114,21115,21116,21117,21118,21119,21120,21121,21122,21123,21124,21125,21126,21127,21128,21129,21130,21131,21132,21133,21134,21135,21136,21137,21138,21139,21140,21141,21142,21143,21144,21145,21146,21147,21148,21149,21150,21151,21152,21153,21154,21155,21156,21157,21158,21159,21160,21161,21162,21163,21164,21165,21166,21167,21168,21169,21170,21171,21172,21173,21174,21175,21176,21177,21178,21179,21180,21181,21182,21183,21184,21185,21186,21187,21188,21189,21190,21191,21192,21193,21194,21195,21196,21197,21198,21199,21200,21201,21202,21203,21204,21205,21206,21207,21208,21209,21210,21211,21212,21213,21214,21215,21216,21217,21218,21219,21220,21221,21222,21223,21224,21225,21226,21227,21228,21229,21230,21231,21232,21233,21234,21235,21236,21237,21238,21239,21240,21241,21242,21243,21244,21245,21246,21247,21248,21249,21250,21251,21252,21253,21254,21255,21256,21257,21258,21259,21260,21261,21262,21263,21264,21265,21266,21267,21268,21269,21270,21271,21272,21273,21274,21275,21276,21277,21278,21279,21280,21281,21282,21283,21284,21285,21286,21287,21288,21289,21290,21291,21292,21293,21294,21295,21296,21297,21298,21299,21300,21301,21302,21303,21304,21305,21306,21307,21308,21309,21310,21311,21312,21313,21314,21315,21316,21317,21318,21319,21320,21321,21322,21323,21324,21325,21326,21327,21328,21329,21330,21331,21332,21333,21334,21335,21336,21337,21338,21339,21340,21341,21342,21343,21344,21345,21346,21347,21348,21349,21350,21351,21352,21353,21354,21355,21356,21357,21358,21359,21360,21361,21362,21363,21364,21365,21366,21367,21368,21369,21370,21371,21372,21373,21374,21375,21376,21377,21378,21379,21380,21381,21382,21383,21384,21385,21386,21387,21388,21389,21390,21391,21392,21393,21394,21395,21396,21397,21398,21399,21400,21401,21402,21403,21404,21405,21406,21407,21408,21409,21410,21411,21412,21413,21414,21415,21416,21417,21418,21419,21420,21421,21422,21423,21424,21425,21426,21427,21428,21429,21430,21431,21432,21433,21434,21435,21436,21437,21438,21439,21440,21441,21442,21443,21444,21445,21446,21447,21448,21449,21450,21451,21452,21453,21454,21455,21456,21457,21458,21459,21460,21461,21462,21463,21464,21465,21466,21467,21468,21469,21470,21471,21472,21473,21474,21475,21476,21477,21478,21479,21480,21481,21482,21483,21484,21485,21486,21487,21488,21489,21490,21491,21492,21493,21494,21495,21496,21497,21498,21499,21500,21501,21502,21503,21504,21505,21506,21507,21508,21509,21510,21511,21512,21513,21514,21515,21516,21517,21518,21519,21520,21521,21522,21523,21524,21525,21526,21527,21528,21529,21530,21531,21532,21533,21534,21535,21536,21537,21538,21539,21540,21541,21542,21543,21544,21545,21546,21547,21548,21549,21550,21551,21552,21553,21554,21555,21556,21557,21558,21559,21560,21561,21562,21563,21564,21565,21566,21567,21568,21569,21570,21571,21572,21573,21574,21575,21576,21577,21578,21579,21580,21581,21582,21583,21584,21585,21586,21587,21588,21589,21590,21591,21592,21593,21594,21595,21596,21597,21598,21599,21600,21601,21602,21603,21604,21605,21606,21607,21608,21609,21610,21611,21612,21613,21614,21615,21616,21617,21618,21619,21620,21621,21622,21623,21624,21625,21626,21627,21628,21629,21630,21631,21632,21633,21634,21635,21636,21637,21638,21639,21640,21641,21642,21643,21644,21645,21646,21647,21648,21649,21650,21651,21652,21653,21654,21655,21656,21657,21658,21659,21660,21661,21662,21663,21664,21665,21666,21667,21668,21669,21670,21671,21672,21673,21674,21675,21676,21677,21678,21679,21680,21681,21682,21683,21684,21685,21686,21687,21688,21689,21690,21691,21692,21693,21694,21695,21696,21697,21698,21699,21700,21701,21702,21703,21704,21705,21706,21707,21708,21709,21710,21711,21712,21713,21714,21715,21716,21717,21718,21719,21720,21721,21722,21723,21724,21725,21726,21727,21728,21729,21730,21731,21732,21733,21734,21735,21736,21737,21738,21739,21740,21741,21742,21743,21744,21745,21746,21747,21748,21749,21750,21751,21752,21753,21754,21755,21756,21757,21758,21759,21760,21761,21762,21763,21764,21765,21766,21767,21768,21769,21770,21771,21772,21773,21774,21775,21776,21777,21778,21779,21780,21781,21782,21783,21784,21785,21786,21787,21788,21789,21790,21791,21792,21793,21794,21795,21796,21797,21798,21799,21800,21801,21802,21803,21804,21805,21806,21807,21808,21809,21810,21811,21812,21813,21814,21815,21816,21817,21818,21819,21820,21821,21822,21823,21824,21825,21826,21827,21828,21829,21830,21831,21832,21833,21834,21835,21836,21837,21838,21839,21840,21841,21842,21843,21844,21845,21846,21847,21848,21849,21850,21851,21852,21853,21854,21855,21856,21857,21858,21859,21860,21861,21862,21863,21864,21865,21866,21867,21868,21869,21870,21871,21872,21873,21874,21875,21876,21877,21878,21879,21880,21881,21882,21883,21884,21885,21886,21887,21888,21889,21890,21891,21892,21893,21894,21895,21896,21897,21898,21899,21900,21901,21902,21903,21904,21905,21906,21907,21908,21909,21910,21911,21912,21913,21914,21915,21916,21917,21918,21919,21920,21921,21922,21923,21924,21925,21926,21927,21928,21929,21930,21931,21932,21933,21934,21935,21936,21937,21938,21939,21940,21941,21942,21943,21944,21945,21946,21947,21948,21949,21950,21951,21952,21953,21954,21955,21956,21957,21958,21959,21960,21961,21962,21963,21964,21965,21966,21967,21968,21969,21970,21971,21972,21973,21974,21975,21976,21977,21978,21979,21980,21981,21982,21983,21984,21985,21986,21987,21988,21989,21990,21991,21992,21993,21994,21995,21996,21997,21998,21999,22000,22001,22002,22003,22004,22005,22006,22007,22008,22009,22010,22011,22012,22013,22014,22015,22016,22017,22018,22019,22020,22021,22022,22023,22024,22025,22026,22027,22028,22029,22030,22031,22032,22033,22034,22035,22036,22037,22038,22039,22040,22041,22042,22043,22044,22045,22046,22047,22048,22049,22050,22051,22052,22053,22054,22055,22056,22057,22058,22059,22060,22061,22062,22063,22064,22065,22066,22067,22068,22069,22070,22071,22072,22073,22074,22075,22076,22077,22078,22079,22080,22081,22082,22083,22084,22085,22086,22087,22088,22089,22090,22091,22092,22093,22094,22095,22096,22097,22098,22099,22100,22101,22102,22103,22104,22105,22106,22107,22108,22109,22110,22111,22112,22113,22114,22115,22116,22117,22118,22119,22120,22121,22122,22123,22124,22125,22126,22127,22128,22129,22130,22131,22132,22133,22134,22135,22136,22137,22138,22139,22140,22141,22142,22143,22144,22145,22146,22147,22148,22149,22150,22151,22152,22153,22154,22155,22156,22157,22158,22159,22160,22161,22162,22163,22164,22165,22166,22167,22168,22169,22170,22171,22172,22173,22174,22175,22176,22177,22178,22179,22180,22181,22182,22183,22184,22185,22186,22187,22188,22189,22190,22191,22192,22193,22194,22195,22196,22197,22198,22199,22200,22201,22202,22203,22204,22205,22206,22207,22208,22209,22210,22211,22212,22213,22214,22215,22216,22217,22218,22219,22220,22221,22222,22223,22224,22225,22226,22227,22228,22229,22230,22231,22232,22233,22234,22235,22236,22237,22238,22239,22240,22241,22242,22243,22244,22245,22246,22247,22248,22249,22250,22251,22252,22253,22254,22255,22256,22257,22258,22259,22260,22261,22262,22263,22264,22265,22266,22267,22268,22269,22270,22271,22272,22273,22274,22275,22276,22277,22278,22279,22280,22281,22282,22283,22284,22285,22286,22287,22288,22289,22290,22291,22292,22293,22294,22295,22296,22297,22298,22299,22300,22301,22302,22303,22304,22305,22306,22307,22308,22309,22310,22311,22312,22313,22314,22315,22316,22317,22318,22319,22320,22321,22322,22323,22324,22325,22326,22327,22328,22329,22330,22331,22332,22333,22334,22335,22336,22337,22338,22339,22340,22341,22342,22343,22344,22345,22346,22347,22348,22349,22350,22351,22352,22353,22354,22355,22356,22357,22358,22359,22360,22361,22362,22363,22364,22365,22366,22367,22368,22369,22370,22371,22372,22373,22374,22375,22376,22377,22378,22379,22380,22381,22382,22383,22384,22385,22386,22387,22388,22389,22390,22391,22392,22393,22394,22395,22396,22397,22398,22399,22400,22401,22402,22403,22404,22405,22406,22407,22408,22409,22410,22411,22412,22413,22414,22415,22416,22417,22418,22419,22420,22421,22422,22423,22424,22425,22426,22427,22428,22429,22430,22431,22432,22433,22434,22435,22436,22437,22438,22439,22440,22441,22442,22443,22444,22445,22446,22447,22448,22449,22450,22451,22452,22453,22454,22455,22456,22457,22458,22459,22460,22461,22462,22463,22464,22465,22466,22467,22468,22469,22470,22471,22472,22473,22474,22475,22476,22477,22478,22479,22480,22481,22482,22483,22484,22485,22486,22487,22488,22489,22490,22491,22492,22493,22494,22495,22496,22497,22498,22499,22500,22501,22502,22503,22504,22505,22506,22507,22508,22509,22510,22511,22512,22513,22514,22515,22516,22517,22518,22519,22520,22521,22522,22523,22524,22525,22526,22527,22528,22529,22530,22531,22532,22533,22534,22535,22536,22537,22538,22539,22540,22541,22542,22543,22544,22545,22546,22547,22548,22549,22550,22551,22552,22553,22554,22555,22556,22557,22558,22559,22560,22561,22562,22563,22564,22565,22566,22567,22568,22569,22570,22571,22572,22573,22574,22575,22576,22577,22578,22579,22580,22581,22582,22583,22584,22585,22586,22587,22588,22589,22590,22591,22592,22593,22594,22595,22596,22597,22598,22599,22600,22601,22602,22603,22604,22605,22606,22607,22608,22609,22610,22611,22612,22613,22614,22615,22616,22617,22618,22619,22620,22621,22622,22623,22624,22625,22626,22627,22628,22629,22630,22631,22632,22633,22634,22635,22636,22637,22638,22639,22640,22641,22642,22643,22644,22645,22646,22647,22648,22649,22650,22651,22652,22653,22654,22655,22656,22657,22658,22659,22660,22661,22662,22663,22664,22665,22666,22667,22668,22669,22670,22671,22672,22673,22674,22675,22676,22677,22678,22679,22680,22681,22682,22683,22684,22685,22686,22687,22688,22689,22690,22691,22692,22693,22694,22695,22696,22697,22698,22699,22700,22701,22702,22703,22704,22705,22706,22707,22708,22709,22710,22711,22712,22713,22714,22715,22716,22717,22718,22719,22720,22721,22722,22723,22724,22725,22726,22727,22728,22729,22730,22731,22732,22733,22734,22735,22736,22737,22738,22739,22740,22741,22742,22743,22744,22745,22746,22747,22748,22749,22750,22751,22752,22753,22754,22755,22756,22757,22758,22759,22760,22761,22762,22763,22764,22765,22766,22767,22768,22769,22770,22771,22772,22773,22774,22775,22776,22777,22778,22779,22780,22781,22782,22783,22784,22785,22786,22787,22788,22789,22790,22791,22792,22793,22794,22795,22796,22797,22798,22799,22800,22801,22802,22803,22804,22805,22806,22807,22808,22809,22810,22811,22812,22813,22814,22815,22816,22817,22818,22819,22820,22821,22822,22823,22824,22825,22826,22827,22828,22829,22830,22831,22832,22833,22834,22835,22836,22837,22838,22839,22840,22841,22842,22843,22844,22845,22846,22847,22848,22849,22850,22851,22852,22853,22854,22855,22856,22857,22858,22859,22860,22861,22862,22863,22864,22865,22866,22867,22868,22869,22870,22871,22872,22873,22874,22875,22876,22877,22878,22879,22880,22881,22882,22883,22884,22885,22886,22887,22888,22889,22890,22891,22892,22893,22894,22895,22896,22897,22898,22899,22900,22901,22902,22903,22904,22905,22906,22907,22908,22909,22910,22911,22912,22913,22914,22915,22916,22917,22918,22919,22920,22921,22922,22923,22924,22925,22926,22927,22928,22929,22930,22931,22932,22933,22934,22935,22936,22937,22938,22939,22940,22941,22942,22943,22944,22945,22946,22947,22948,22949,22950,22951,22952,22953,22954,22955,22956,22957,22958,22959,22960,22961,22962,22963,22964,22965,22966,22967,22968,22969,22970,22971,22972,22973,22974,22975,22976,22977,22978,22979,22980,22981,22982,22983,22984,22985,22986,22987,22988,22989,22990,22991,22992,22993,22994,22995,22996,22997,22998,22999,23000,23001,23002,23003,23004,23005,23006,23007,23008,23009,23010,23011,23012,23013,23014,23015,23016,23017,23018,23019,23020,23021,23022,23023,23024,23025,23026,23027,23028,23029,23030,23031,23032,23033,23034,23035,23036,23037,23038,23039,23040,23041,23042,23043,23044,23045,23046,23047,23048,23049,23050,23051,23052,23053,23054,23055,23056,23057,23058,23059,23060,23061,23062,23063,23064,23065,23066,23067,23068,23069,23070,23071,23072,23073,23074,23075,23076,23077,23078,23079,23080,23081,23082,23083,23084,23085,23086,23087,23088,23089,23090,23091,23092,23093,23094,23095,23096,23097,23098,23099,23100,23101,23102,23103,23104,23105,23106,23107,23108,23109,23110,23111,23112,23113,23114,23115,23116,23117,23118,23119,23120,23121,23122,23123,23124,23125,23126,23127,23128,23129,23130,23131,23132,23133,23134,23135,23136,23137,23138,23139,23140,23141,23142,23143,23144,23145,23146,23147,23148,23149,23150,23151,23152,23153,23154,23155,23156,23157,23158,23159,23160,23161,23162,23163,23164,23165,23166,23167,23168,23169,23170,23171,23172,23173,23174,23175,23176,23177,23178,23179,23180,23181,23182,23183,23184,23185,23186,23187,23188,23189,23190,23191,23192,23193,23194,23195,23196,23197,23198,23199,23200,23201,23202,23203,23204,23205,23206,23207,23208,23209,23210,23211,23212,23213,23214,23215,23216,23217,23218,23219,23220,23221,23222,23223,23224,23225,23226,23227,23228,23229,23230,23231,23232,23233,23234,23235,23236,23237,23238,23239,23240,23241,23242,23243,23244,23245,23246,23247,23248,23249,23250,23251,23252,23253,23254,23255,23256,23257,23258,23259,23260,23261,23262,23263,23264,23265,23266,23267,23268,23269,23270,23271,23272,23273,23274,23275,23276,23277,23278,23279,23280,23281,23282,23283,23284,23285,23286,23287,23288,23289,23290,23291,23292,23293,23294,23295,23296,23297,23298,23299,23300,23301,23302,23303,23304,23305,23306,23307,23308,23309,23310,23311,23312,23313,23314,23315,23316,23317,23318,23319,23320,23321,23322,23323,23324,23325,23326,23327,23328,23329,23330,23331,23332,23333,23334,23335,23336,23337,23338,23339,23340,23341,23342,23343,23344,23345,23346,23347,23348,23349,23350,23351,23352,23353,23354,23355,23356,23357,23358,23359,23360,23361,23362,23363,23364,23365,23366,23367,23368,23369,23370,23371,23372,23373,23374,23375,23376,23377,23378,23379,23380,23381,23382,23383,23384,23385,23386,23387,23388,23389,23390,23391,23392,23393,23394,23395,23396,23397,23398,23399,23400,23401,23402,23403,23404,23405,23406,23407,23408,23409,23410,23411,23412,23413,23414,23415,23416,23417,23418,23419,23420,23421,23422,23423,23424,23425,23426,23427,23428,23429,23430,23431,23432,23433,23434,23435,23436,23437,23438,23439,23440,23441,23442,23443,23444,23445,23446,23447,23448,23449,23450,23451,23452,23453,23454,23455,23456,23457,23458,23459,23460,23461,23462,23463,23464,23465,23466,23467,23468,23469,23470,23471,23472,23473,23474,23475,23476,23477,23478,23479,23480,23481,23482,23483,23484,23485,23486,23487,23488,23489,23490,23491,23492,23493,23494,23495,23496,23497,23498,23499,23500,23501,23502,23503,23504,23505,23506,23507,23508,23509,23510,23511,23512,23513,23514,23515,23516,23517,23518,23519,23520,23521,23522,23523,23524,23525,23526,23527,23528,23529,23530,23531,23532,23533,23534,23535,23536,23537,23538,23539,23540,23541,23542,23543,23544,23545,23546,23547,23548,23549,23550,23551,23552,23553,23554,23555,23556,23557,23558,23559,23560,23561,23562,23563,23564,23565,23566,23567,23568,23569,23570,23571,23572,23573,23574,23575,23576,23577,23578,23579,23580,23581,23582,23583,23584,23585,23586,23587,23588,23589,23590,23591,23592,23593,23594,23595,23596,23597,23598,23599,23600,23601,23602,23603,23604,23605,23606,23607,23608,23609,23610,23611,23612,23613,23614,23615,23616,23617,23618,23619,23620,23621,23622,23623,23624,23625,23626,23627,23628,23629,23630,23631,23632,23633,23634,23635,23636,23637,23638,23639,23640,23641,23642,23643,23644,23645,23646,23647,23648,23649,23650,23651,23652,23653,23654,23655,23656,23657,23658,23659,23660,23661,23662,23663,23664,23665,23666,23667,23668,23669,23670,23671,23672,23673,23674,23675,23676,23677,23678,23679,23680,23681,23682,23683,23684,23685,23686,23687,23688,23689,23690,23691,23692,23693,23694,23695,23696,23697,23698,23699,23700,23701,23702,23703,23704,23705,23706,23707,23708,23709,23710,23711,23712,23713,23714,23715,23716,23717,23718,23719,23720,23721,23722,23723,23724,23725,23726,23727,23728,23729,23730,23731,23732,23733,23734,23735,23736,23737,23738,23739,23740,23741,23742,23743,23744,23745,23746,23747,23748,23749,23750,23751,23752,23753,23754,23755,23756,23757,23758,23759,23760,23761,23762,23763,23764,23765,23766,23767,23768,23769,23770,23771,23772,23773,23774,23775,23776,23777,23778,23779,23780,23781,23782,23783,23784,23785,23786,23787,23788,23789,23790,23791,23792,23793,23794,23795,23796,23797,23798,23799,23800,23801,23802,23803,23804,23805,23806,23807,23808,23809,23810,23811,23812,23813,23814,23815,23816,23817,23818,23819,23820,23821,23822,23823,23824,23825,23826,23827,23828,23829,23830,23831,23832,23833,23834,23835,23836,23837,23838,23839,23840,23841,23842,23843,23844,23845,23846,23847,23848,23849,23850,23851,23852,23853,23854,23855,23856,23857,23858,23859,23860,23861,23862,23863,23864,23865,23866,23867,23868,23869,23870,23871,23872,23873,23874,23875,23876,23877,23878,23879,23880,23881,23882,23883,23884,23885,23886,23887,23888,23889,23890,23891,23892,23893,23894,23895,23896,23897,23898,23899,23900,23901,23902,23903,23904,23905,23906,23907,23908,23909,23910,23911,23912,23913,23914,23915,23916,23917,23918,23919,23920,23921,23922,23923,23924,23925,23926,23927,23928,23929,23930,23931,23932,23933,23934,23935,23936,23937,23938,23939,23940,23941,23942,23943,23944,23945,23946,23947,23948,23949,23950,23951,23952,23953,23954,23955,23956,23957,23958,23959,23960,23961,23962,23963,23964,23965,23966,23967,23968,23969,23970,23971,23972,23973,23974,23975,23976,23977,23978,23979,23980,23981,23982,23983,23984,23985,23986,23987,23988,23989,23990,23991,23992,23993,23994,23995,23996,23997,23998,23999,24000,24001,24002,24003,24004,24005,24006,24007,24008,24009,24010,24011,24012,24013,24014,24015,24016,24017,24018,24019,24020,24021,24022,24023,24024,24025,24026,24027,24028,24029,24030,24031,24032,24033,24034,24035,24036,24037,24038,24039,24040,24041,24042,24043,24044,24045,24046,24047,24048,24049,24050,24051,24052,24053,24054,24055,24056,24057,24058,24059,24060,24061,24062,24063,24064,24065,24066,24067,24068,24069,24070,24071,24072,24073,24074,24075,24076,24077,24078,24079,24080,24081,24082,24083,24084,24085,24086,24087,24088,24089,24090,24091,24092,24093,24094,24095,24096,24097,24098,24099,24100,24101,24102,24103,24104,24105,24106,24107,24108,24109,24110,24111,24112,24113,24114,24115,24116,24117,24118,24119,24120,24121,24122,24123,24124,24125,24126,24127,24128,24129,24130,24131,24132,24133,24134,24135,24136,24137,24138,24139,24140,24141,24142,24143,24144,24145,24146,24147,24148,24149,24150,24151,24152,24153,24154,24155,24156,24157,24158,24159,24160,24161,24162,24163,24164,24165,24166,24167,24168,24169,24170,24171,24172,24173,24174,24175,24176,24177,24178,24179,24180,24181,24182,24183,24184,24185,24186,24187,24188,24189,24190,24191,24192,24193,24194,24195,24196,24197,24198,24199,24200,24201,24202,24203,24204,24205,24206,24207,24208,24209,24210,24211,24212,24213,24214,24215,24216,24217,24218,24219,24220,24221,24222,24223,24224,24225,24226,24227,24228,24229,24230,24231,24232,24233,24234,24235,24236,24237,24238,24239,24240,24241,24242,24243,24244,24245,24246,24247,24248,24249,24250,24251,24252,24253,24254,24255,24256,24257,24258,24259,24260,24261,24262,24263,24264,24265,24266,24267,24268,24269,24270,24271,24272,24273,24274,24275,24276,24277,24278,24279,24280,24281,24282,24283,24284,24285,24286,24287,24288,24289,24290,24291,24292,24293,24294,24295,24296,24297,24298,24299,24300,24301,24302,24303,24304,24305,24306,24307,24308,24309,24310,24311,24312,24313,24314,24315,24316,24317,24318,24319,24320,24321,24322,24323,24324,24325,24326,24327,24328,24329,24330,24331,24332,24333,24334,24335,24336,24337,24338,24339,24340,24341,24342,24343,24344,24345,24346,24347,24348,24349,24350,24351,24352,24353,24354,24355,24356,24357,24358,24359,24360,24361,24362,24363,24364,24365,24366,24367,24368,24369,24370,24371,24372,24373,24374,24375,24376,24377,24378,24379,24380,24381,24382,24383,24384,24385,24386,24387,24388,24389,24390,24391,24392,24393,24394,24395,24396,24397,24398,24399,24400,24401,24402,24403,24404,24405,24406,24407,24408,24409,24410,24411,24412,24413,24414,24415,24416,24417,24418,24419,24420,24421,24422,24423,24424,24425,24426,24427,24428,24429,24430,24431,24432,24433,24434,24435,24436,24437,24438,24439,24440,24441,24442,24443,24444,24445,24446,24447,24448,24449,24450,24451,24452,24453,24454,24455,24456,24457,24458,24459,24460,24461,24462,24463,24464,24465,24466,24467,24468,24469,24470,24471,24472,24473,24474,24475,24476,24477,24478,24479,24480,24481,24482,24483,24484,24485,24486,24487,24488,24489,24490,24491,24492,24493,24494,24495,24496,24497,24498,24499,24500,24501,24502,24503,24504,24505,24506,24507,24508,24509,24510,24511,24512,24513,24514,24515,24516,24517,24518,24519,24520,24521,24522,24523,24524,24525,24526,24527,24528,24529,24530,24531,24532,24533,24534,24535,24536,24537,24538,24539,24540,24541,24542,24543,24544,24545,24546,24547,24548,24549,24550,24551,24552,24553,24554,24555,24556,24557,24558,24559,24560,24561,24562,24563,24564,24565,24566,24567,24568,24569,24570,24571,24572,24573,24574,24575,24576,24577,24578,24579,24580,24581,24582,24583,24584,24585,24586,24587,24588,24589,24590,24591,24592,24593,24594,24595,24596,24597,24598,24599,24600,24601,24602,24603,24604,24605,24606,24607,24608,24609,24610,24611,24612,24613,24614,24615,24616,24617,24618,24619,24620,24621,24622,24623,24624,24625,24626,24627,24628,24629,24630,24631,24632,24633,24634,24635,24636,24637,24638,24639,24640,24641,24642,24643,24644,24645,24646,24647,24648,24649,24650,24651,24652,24653,24654,24655,24656,24657,24658,24659,24660,24661,24662,24663,24664,24665,24666,24667,24668,24669,24670,24671,24672,24673,24674,24675,24676,24677,24678,24679,24680,24681,24682,24683,24684,24685,24686,24687,24688,24689,24690,24691,24692,24693,24694,24695,24696,24697,24698,24699,24700,24701,24702,24703,24704,24705,24706,24707,24708,24709,24710,24711,24712,24713,24714,24715,24716,24717,24718,24719,24720,24721,24722,24723,24724,24725,24726,24727,24728,24729,24730,24731,24732,24733,24734,24735,24736,24737,24738,24739,24740,24741,24742,24743,24744,24745,24746,24747,24748,24749,24750,24751,24752,24753,24754,24755,24756,24757,24758,24759,24760,24761,24762,24763,24764,24765,24766,24767,24768,24769,24770,24771,24772,24773,24774,24775,24776,24777,24778,24779,24780,24781,24782,24783,24784,24785,24786,24787,24788,24789,24790,24791,24792,24793,24794,24795,24796,24797,24798,24799,24800,24801,24802,24803,24804,24805,24806,24807,24808,24809,24810,24811,24812,24813,24814,24815,24816,24817,24818,24819,24820,24821,24822,24823,24824,24825,24826,24827,24828,24829,24830,24831,24832,24833,24834,24835,24836,24837,24838,24839,24840,24841,24842,24843,24844,24845,24846,24847,24848,24849,24850,24851,24852,24853,24854,24855,24856,24857,24858,24859,24860,24861,24862,24863,24864,24865,24866,24867,24868,24869,24870,24871,24872,24873,24874,24875,24876,24877,24878,24879,24880,24881,24882,24883,24884,24885,24886,24887,24888,24889,24890,24891,24892,24893,24894,24895,24896,24897,24898,24899,24900,24901,24902,24903,24904,24905,24906,24907,24908,24909,24910,24911,24912,24913,24914,24915,24916,24917,24918,24919,24920,24921,24922,24923,24924,24925,24926,24927,24928,24929,24930,24931,24932,24933,24934,24935,24936,24937,24938,24939,24940,24941,24942,24943,24944,24945,24946,24947,24948,24949,24950,24951,24952,24953,24954,24955,24956,24957,24958,24959,24960,24961,24962,24963,24964,24965,24966,24967,24968,24969,24970,24971,24972,24973,24974,24975,24976,24977,24978,24979,24980,24981,24982,24983,24984,24985,24986,24987,24988,24989,24990,24991,24992,24993,24994,24995,24996,24997,24998,24999,25000,25001,25002,25003,25004,25005,25006,25007,25008,25009,25010,25011,25012,25013,25014,25015,25016,25017,25018,25019,25020,25021,25022,25023,25024,25025,25026,25027,25028,25029,25030,25031,25032,25033,25034,25035,25036,25037,25038,25039,25040,25041,25042,25043,25044,25045,25046,25047,25048,25049,25050,25051,25052,25053,25054,25055,25056,25057,25058,25059,25060,25061,25062,25063,25064,25065,25066,25067,25068,25069,25070,25071,25072,25073,25074,25075,25076,25077,25078,25079,25080,25081,25082,25083,25084,25085,25086,25087,25088,25089,25090,25091,25092,25093,25094,25095,25096,25097,25098,25099,25100,25101,25102,25103,25104,25105,25106,25107,25108,25109,25110,25111,25112,25113,25114,25115,25116,25117,25118,25119,25120,25121,25122,25123,25124,25125,25126,25127,25128,25129,25130,25131,25132,25133,25134,25135,25136,25137,25138,25139,25140,25141,25142,25143,25144,25145,25146,25147,25148,25149,25150,25151,25152,25153,25154,25155,25156,25157,25158,25159,25160,25161,25162,25163,25164,25165,25166,25167,25168,25169,25170,25171,25172,25173,25174,25175,25176,25177,25178,25179,25180,25181,25182,25183,25184,25185,25186,25187,25188,25189,25190,25191,25192,25193,25194,25195,25196,25197,25198,25199,25200,25201,25202,25203,25204,25205,25206,25207,25208,25209,25210,25211,25212,25213,25214,25215,25216,25217,25218,25219,25220,25221,25222,25223,25224,25225,25226,25227,25228,25229,25230,25231,25232,25233,25234,25235,25236,25237,25238,25239,25240,25241,25242,25243,25244,25245,25246,25247,25248,25249,25250,25251,25252,25253,25254,25255,25256,25257,25258,25259,25260,25261,25262,25263,25264,25265,25266,25267,25268,25269,25270,25271,25272,25273,25274,25275,25276,25277,25278,25279,25280,25281,25282,25283,25284,25285,25286,25287,25288,25289,25290,25291,25292,25293,25294,25295,25296,25297,25298,25299,25300,25301,25302,25303,25304,25305,25306,25307,25308,25309,25310,25311,25312,25313,25314,25315,25316,25317,25318,25319,25320,25321,25322,25323,25324,25325,25326,25327,25328,25329,25330,25331,25332,25333,25334,25335,25336,25337,25338,25339,25340,25341,25342,25343,25344,25345,25346,25347,25348,25349,25350,25351,25352,25353,25354,25355,25356,25357,25358,25359,25360,25361,25362,25363,25364,25365,25366,25367,25368,25369,25370,25371,25372,25373,25374,25375,25376,25377,25378,25379,25380,25381,25382,25383,25384,25385,25386,25387,25388,25389,25390,25391,25392,25393,25394,25395,25396,25397,25398,25399,25400,25401,25402,25403,25404,25405,25406,25407,25408,25409,25410,25411,25412,25413,25414,25415,25416,25417,25418,25419,25420,25421,25422,25423,25424,25425,25426,25427,25428,25429,25430,25431,25432,25433,25434,25435,25436,25437,25438,25439,25440,25441,25442,25443,25444,25445,25446,25447,25448,25449,25450,25451,25452,25453,25454,25455,25456,25457,25458,25459,25460,25461,25462,25463,25464,25465,25466,25467,25468,25469,25470,25471,25472,25473,25474,25475,25476,25477,25478,25479,25480,25481,25482,25483,25484,25485,25486,25487,25488,25489,25490,25491,25492,25493,25494,25495,25496,25497,25498,25499,25500,25501,25502,25503,25504,25505,25506,25507,25508,25509,25510,25511,25512,25513,25514,25515,25516,25517,25518,25519,25520,25521,25522,25523,25524,25525,25526,25527,25528,25529,25530,25531,25532,25533,25534,25535,25536,25537,25538,25539,25540,25541,25542,25543,25544,25545,25546,25547,25548,25549,25550,25551,25552,25553,25554,25555,25556,25557,25558,25559,25560,25561,25562,25563,25564,25565,25566,25567,25568,25569,25570,25571,25572,25573,25574,25575,25576,25577,25578,25579,25580,25581,25582,25583,25584,25585,25586,25587,25588,25589,25590,25591,25592,25593,25594,25595,25596,25597,25598,25599,25600,25601,25602,25603,25604,25605,25606,25607,25608,25609,25610,25611,25612,25613,25614,25615,25616,25617,25618,25619,25620,25621,25622,25623,25624,25625,25626,25627,25628,25629,25630,25631,25632,25633,25634,25635,25636,25637,25638,25639,25640,25641,25642,25643,25644,25645,25646,25647,25648,25649,25650,25651,25652,25653,25654,25655,25656,25657,25658,25659,25660,25661,25662,25663,25664,25665,25666,25667,25668,25669,25670,25671,25672,25673,25674,25675,25676,25677,25678,25679,25680,25681,25682,25683,25684,25685,25686,25687,25688,25689,25690,25691,25692,25693,25694,25695,25696,25697,25698,25699,25700,25701,25702,25703,25704,25705,25706,25707,25708,25709,25710,25711,25712,25713,25714,25715,25716,25717,25718,25719,25720,25721,25722,25723,25724,25725,25726,25727,25728,25729,25730,25731,25732,25733,25734,25735,25736,25737,25738,25739,25740,25741,25742,25743,25744,25745,25746,25747,25748,25749,25750,25751,25752,25753,25754,25755,25756,25757,25758,25759,25760,25761,25762,25763,25764,25765,25766,25767,25768,25769,25770,25771,25772,25773,25774,25775,25776,25777,25778,25779,25780,25781,25782,25783,25784,25785,25786,25787,25788,25789,25790,25791,25792,25793,25794,25795,25796,25797,25798,25799,25800,25801,25802,25803,25804,25805,25806,25807,25808,25809,25810,25811,25812,25813,25814,25815,25816,25817,25818,25819,25820,25821,25822,25823,25824,25825,25826,25827,25828,25829,25830,25831,25832,25833,25834,25835,25836,25837,25838,25839,25840,25841,25842,25843,25844,25845,25846,25847,25848,25849,25850,25851,25852,25853,25854,25855,25856,25857,25858,25859,25860,25861,25862,25863,25864,25865,25866,25867,25868,25869,25870,25871,25872,25873,25874,25875,25876,25877,25878,25879,25880,25881,25882,25883,25884,25885,25886,25887,25888,25889,25890,25891,25892,25893,25894,25895,25896,25897,25898,25899,25900,25901,25902,25903,25904,25905,25906,25907,25908,25909,25910,25911,25912,25913,25914,25915,25916,25917,25918,25919,25920,25921,25922,25923,25924,25925,25926,25927,25928,25929,25930,25931,25932,25933,25934,25935,25936,25937,25938,25939,25940,25941,25942,25943,25944,25945,25946,25947,25948,25949,25950,25951,25952,25953,25954,25955,25956,25957,25958,25959,25960,25961,25962,25963,25964,25965,25966,25967,25968,25969,25970,25971,25972,25973,25974,25975,25976,25977,25978,25979,25980,25981,25982,25983,25984,25985,25986,25987,25988,25989,25990,25991,25992,25993,25994,25995,25996,25997,25998,25999,26000,26001,26002,26003,26004,26005,26006,26007,26008,26009,26010,26011,26012,26013,26014,26015,26016,26017,26018,26019,26020,26021,26022,26023,26024,26025,26026,26027,26028,26029,26030,26031,26032,26033,26034,26035,26036,26037,26038,26039,26040,26041,26042,26043,26044,26045,26046,26047,26048,26049,26050,26051,26052,26053,26054,26055,26056,26057,26058,26059,26060,26061,26062,26063,26064,26065,26066,26067,26068,26069,26070,26071,26072,26073,26074,26075,26076,26077,26078,26079,26080,26081,26082,26083,26084,26085,26086,26087,26088,26089,26090,26091,26092,26093,26094,26095,26096,26097,26098,26099,26100,26101,26102,26103,26104,26105,26106,26107,26108,26109,26110,26111,26112,26113,26114,26115,26116,26117,26118,26119,26120,26121,26122,26123,26124,26125,26126,26127,26128,26129,26130,26131,26132,26133,26134,26135,26136,26137,26138,26139,26140,26141,26142,26143,26144,26145,26146,26147,26148,26149,26150,26151,26152,26153,26154,26155,26156,26157,26158,26159,26160,26161,26162,26163,26164,26165,26166,26167,26168,26169,26170,26171,26172,26173,26174,26175,26176,26177,26178,26179,26180,26181,26182,26183,26184,26185,26186,26187,26188,26189,26190,26191,26192,26193,26194,26195,26196,26197,26198,26199,26200,26201,26202,26203,26204,26205,26206,26207,26208,26209,26210,26211,26212,26213,26214,26215,26216,26217,26218,26219,26220,26221,26222,26223,26224,26225,26226,26227,26228,26229,26230,26231,26232,26233,26234,26235,26236,26237,26238,26239,26240,26241,26242,26243,26244,26245,26246,26247,26248,26249,26250,26251,26252,26253,26254,26255,26256,26257,26258,26259,26260,26261,26262,26263,26264,26265,26266,26267,26268,26269,26270,26271,26272,26273,26274,26275,26276,26277,26278,26279,26280,26281,26282,26283,26284,26285,26286,26287,26288,26289,26290,26291,26292,26293,26294,26295,26296,26297,26298,26299,26300,26301,26302,26303,26304,26305,26306,26307,26308,26309,26310,26311,26312,26313,26314,26315,26316,26317,26318,26319,26320,26321,26322,26323,26324,26325,26326,26327,26328,26329,26330,26331,26332,26333,26334,26335,26336,26337,26338,26339,26340,26341,26342,26343,26344,26345,26346,26347,26348,26349,26350,26351,26352,26353,26354,26355,26356,26357,26358,26359,26360,26361,26362,26363,26364,26365,26366,26367,26368,26369,26370,26371,26372,26373,26374,26375,26376,26377,26378,26379,26380,26381,26382,26383,26384,26385,26386,26387,26388,26389,26390,26391,26392,26393,26394,26395,26396,26397,26398,26399,26400,26401,26402,26403,26404,26405,26406,26407,26408,26409,26410,26411,26412,26413,26414,26415,26416,26417,26418,26419,26420,26421,26422,26423,26424,26425,26426,26427,26428,26429,26430,26431,26432,26433,26434,26435,26436,26437,26438,26439,26440,26441,26442,26443,26444,26445,26446,26447,26448,26449,26450,26451,26452,26453,26454,26455,26456,26457,26458,26459,26460,26461,26462,26463,26464,26465,26466,26467,26468,26469,26470,26471,26472,26473,26474,26475,26476,26477,26478,26479,26480,26481,26482,26483,26484,26485,26486,26487,26488,26489,26490,26491,26492,26493,26494,26495,26496,26497,26498,26499,26500,26501,26502,26503,26504,26505,26506,26507,26508,26509,26510,26511,26512,26513,26514,26515,26516,26517,26518,26519,26520,26521,26522,26523,26524,26525,26526,26527,26528,26529,26530,26531,26532,26533,26534,26535,26536,26537,26538,26539,26540,26541,26542,26543,26544,26545,26546,26547,26548,26549,26550,26551,26552,26553,26554,26555,26556,26557,26558,26559,26560,26561,26562,26563,26564,26565,26566,26567,26568,26569,26570,26571,26572,26573,26574,26575,26576,26577,26578,26579,26580,26581,26582,26583,26584,26585,26586,26587,26588,26589,26590,26591,26592,26593,26594,26595,26596,26597,26598,26599,26600,26601,26602,26603,26604,26605,26606,26607,26608,26609,26610,26611,26612,26613,26614,26615,26616,26617,26618,26619,26620,26621,26622,26623,26624,26625,26626,26627,26628,26629,26630,26631,26632,26633,26634,26635,26636,26637,26638,26639,26640,26641,26642,26643,26644,26645,26646,26647,26648,26649,26650,26651,26652,26653,26654,26655,26656,26657,26658,26659,26660,26661,26662,26663,26664,26665,26666,26667,26668,26669,26670,26671,26672,26673,26674,26675,26676,26677,26678,26679,26680,26681,26682,26683,26684,26685,26686,26687,26688,26689,26690,26691,26692,26693,26694,26695,26696,26697,26698,26699,26700,26701,26702,26703,26704,26705,26706,26707,26708,26709,26710,26711,26712,26713,26714,26715,26716,26717,26718,26719,26720,26721,26722,26723,26724,26725,26726,26727,26728,26729,26730,26731,26732,26733,26734,26735,26736,26737,26738,26739,26740,26741,26742,26743,26744,26745,26746,26747,26748,26749,26750,26751,26752,26753,26754,26755,26756,26757,26758,26759,26760,26761,26762,26763,26764,26765,26766,26767,26768,26769,26770,26771,26772,26773,26774,26775,26776,26777,26778,26779,26780,26781,26782,26783,26784,26785,26786,26787,26788,26789,26790,26791,26792,26793,26794,26795,26796,26797,26798,26799,26800,26801,26802,26803,26804,26805,26806,26807,26808,26809,26810,26811,26812,26813,26814,26815,26816,26817,26818,26819,26820,26821,26822,26823,26824,26825,26826,26827,26828,26829,26830,26831,26832,26833,26834,26835,26836,26837,26838,26839,26840,26841,26842,26843,26844,26845,26846,26847,26848,26849,26850,26851,26852,26853,26854,26855,26856,26857,26858,26859,26860,26861,26862,26863,26864,26865,26866,26867,26868,26869,26870,26871,26872,26873,26874,26875,26876,26877,26878,26879,26880,26881,26882,26883,26884,26885,26886,26887,26888,26889,26890,26891,26892,26893,26894,26895,26896,26897,26898,26899,26900,26901,26902,26903,26904,26905,26906,26907,26908,26909,26910,26911,26912,26913,26914,26915,26916,26917,26918,26919,26920,26921,26922,26923,26924,26925,26926,26927,26928,26929,26930,26931,26932,26933,26934,26935,26936,26937,26938,26939,26940,26941,26942,26943,26944,26945,26946,26947,26948,26949,26950,26951,26952,26953,26954,26955,26956,26957,26958,26959,26960,26961,26962,26963,26964,26965,26966,26967,26968,26969,26970,26971,26972,26973,26974,26975,26976,26977,26978,26979,26980,26981,26982,26983,26984,26985,26986,26987,26988,26989,26990,26991,26992,26993,26994,26995,26996,26997,26998,26999,27000,27001,27002,27003,27004,27005,27006,27007,27008,27009,27010,27011,27012,27013,27014,27015,27016,27017,27018,27019,27020,27021,27022,27023,27024,27025,27026,27027,27028,27029,27030,27031,27032,27033,27034,27035,27036,27037,27038,27039,27040,27041,27042,27043,27044,27045,27046,27047,27048,27049,27050,27051,27052,27053,27054,27055,27056,27057,27058,27059,27060,27061,27062,27063,27064,27065,27066,27067,27068,27069,27070,27071,27072,27073,27074,27075,27076,27077,27078,27079,27080,27081,27082,27083,27084,27085,27086,27087,27088,27089,27090,27091,27092,27093,27094,27095,27096,27097,27098,27099,27100,27101,27102,27103,27104,27105,27106,27107,27108,27109,27110,27111,27112,27113,27114,27115,27116,27117,27118,27119,27120,27121,27122,27123,27124,27125,27126,27127,27128,27129,27130,27131,27132,27133,27134,27135,27136,27137,27138,27139,27140,27141,27142,27143,27144,27145,27146,27147,27148,27149,27150,27151,27152,27153,27154,27155,27156,27157,27158,27159,27160,27161,27162,27163,27164,27165,27166,27167,27168,27169,27170,27171,27172,27173,27174,27175,27176,27177,27178,27179,27180,27181,27182,27183,27184,27185,27186,27187,27188,27189,27190,27191,27192,27193,27194,27195,27196,27197,27198,27199,27200,27201,27202,27203,27204,27205,27206,27207,27208,27209,27210,27211,27212,27213,27214,27215,27216,27217,27218,27219,27220,27221,27222,27223,27224,27225,27226,27227,27228,27229,27230,27231,27232,27233,27234,27235,27236,27237,27238,27239,27240,27241,27242,27243,27244,27245,27246,27247,27248,27249,27250,27251,27252,27253,27254,27255,27256,27257,27258,27259,27260,27261,27262,27263,27264,27265,27266,27267,27268,27269,27270,27271,27272,27273,27274,27275,27276,27277,27278,27279,27280,27281,27282,27283,27284,27285,27286,27287,27288,27289,27290,27291,27292,27293,27294,27295,27296,27297,27298,27299,27300,27301,27302,27303,27304,27305,27306,27307,27308,27309,27310,27311,27312,27313,27314,27315,27316,27317,27318,27319,27320,27321,27322,27323,27324,27325,27326,27327,27328,27329,27330,27331,27332,27333,27334,27335,27336,27337,27338,27339,27340,27341,27342,27343,27344,27345,27346,27347,27348,27349,27350,27351,27352,27353,27354,27355,27356,27357,27358,27359,27360,27361,27362,27363,27364,27365,27366,27367,27368,27369,27370,27371,27372,27373,27374,27375,27376,27377,27378,27379,27380,27381,27382,27383,27384,27385,27386,27387,27388,27389,27390,27391,27392,27393,27394,27395,27396,27397,27398,27399,27400,27401,27402,27403,27404,27405,27406,27407,27408,27409,27410,27411,27412,27413,27414,27415,27416,27417,27418,27419,27420,27421,27422,27423,27424,27425,27426,27427,27428,27429,27430,27431,27432,27433,27434,27435,27436,27437,27438,27439,27440,27441,27442,27443,27444,27445,27446,27447,27448,27449,27450,27451,27452,27453,27454,27455,27456,27457,27458,27459,27460,27461,27462,27463,27464,27465,27466,27467,27468,27469,27470,27471,27472,27473,27474,27475,27476,27477,27478,27479,27480,27481,27482,27483,27484,27485,27486,27487,27488,27489,27490,27491,27492,27493,27494,27495,27496,27497,27498,27499,27500,27501,27502,27503,27504,27505,27506,27507,27508,27509,27510,27511,27512,27513,27514,27515,27516,27517,27518,27519,27520,27521,27522,27523,27524,27525,27526,27527,27528,27529,27530,27531,27532,27533,27534,27535,27536,27537,27538,27539,27540,27541,27542,27543,27544,27545,27546,27547,27548,27549,27550,27551,27552,27553,27554,27555,27556,27557,27558,27559,27560,27561,27562,27563,27564,27565,27566,27567,27568,27569,27570,27571,27572,27573,27574,27575,27576,27577,27578,27579,27580,27581,27582,27583,27584,27585,27586,27587,27588,27589,27590,27591,27592,27593,27594,27595,27596,27597,27598,27599,27600,27601,27602,27603,27604,27605,27606,27607,27608,27609,27610,27611,27612,27613,27614,27615,27616,27617,27618,27619,27620,27621,27622,27623,27624,27625,27626,27627,27628,27629,27630,27631,27632,27633,27634,27635,27636,27637,27638,27639,27640,27641,27642,27643,27644,27645,27646,27647,27648,27649,27650,27651,27652,27653,27654,27655,27656,27657,27658,27659,27660,27661,27662,27663,27664,27665,27666,27667,27668,27669,27670,27671,27672,27673,27674,27675,27676,27677,27678,27679,27680,27681,27682,27683,27684,27685,27686,27687,27688,27689,27690,27691,27692,27693,27694,27695,27696,27697,27698,27699,27700,27701,27702,27703,27704,27705,27706,27707,27708,27709,27710,27711,27712,27713,27714,27715,27716,27717,27718,27719,27720,27721,27722,27723,27724,27725,27726,27727,27728,27729,27730,27731,27732,27733,27734,27735,27736,27737,27738,27739,27740,27741,27742,27743,27744,27745,27746,27747,27748,27749,27750,27751,27752,27753,27754,27755,27756,27757,27758,27759,27760,27761,27762,27763,27764,27765,27766,27767,27768,27769,27770,27771,27772,27773,27774,27775,27776,27777,27778,27779,27780,27781,27782,27783,27784,27785,27786,27787,27788,27789,27790,27791,27792,27793,27794,27795,27796,27797,27798,27799,27800,27801,27802,27803,27804,27805,27806,27807,27808,27809,27810,27811,27812,27813,27814,27815,27816,27817,27818,27819,27820,27821,27822,27823,27824,27825,27826,27827,27828,27829,27830,27831,27832,27833,27834,27835,27836,27837,27838,27839,27840,27841,27842,27843,27844,27845,27846,27847,27848,27849,27850,27851,27852,27853,27854,27855,27856,27857,27858,27859,27860,27861,27862,27863,27864,27865,27866,27867,27868,27869,27870,27871,27872,27873,27874,27875,27876,27877,27878,27879,27880,27881,27882,27883,27884,27885,27886,27887,27888,27889,27890,27891,27892,27893,27894,27895,27896,27897,27898,27899,27900,27901,27902,27903,27904,27905,27906,27907,27908,27909,27910,27911,27912,27913,27914,27915,27916,27917,27918,27919,27920,27921,27922,27923,27924,27925,27926,27927,27928,27929,27930,27931,27932,27933,27934,27935,27936,27937,27938,27939,27940,27941,27942,27943,27944,27945,27946,27947,27948,27949,27950,27951,27952,27953,27954,27955,27956,27957,27958,27959,27960,27961,27962,27963,27964,27965,27966,27967,27968,27969,27970,27971,27972,27973,27974,27975,27976,27977,27978,27979,27980,27981,27982,27983,27984,27985,27986,27987,27988,27989,27990,27991,27992,27993,27994,27995,27996,27997,27998,27999,28000,28001,28002,28003,28004,28005,28006,28007,28008,28009,28010,28011,28012,28013,28014,28015,28016,28017,28018,28019,28020,28021,28022,28023,28024,28025,28026,28027,28028,28029,28030,28031,28032,28033,28034,28035,28036,28037,28038,28039,28040,28041,28042,28043,28044,28045,28046,28047,28048,28049,28050,28051,28052,28053,28054,28055,28056,28057,28058,28059,28060,28061,28062,28063,28064,28065,28066,28067,28068,28069,28070,28071,28072,28073,28074,28075,28076,28077,28078,28079,28080,28081,28082,28083,28084,28085,28086,28087,28088,28089,28090,28091,28092,28093,28094,28095,28096,28097,28098,28099,28100,28101,28102,28103,28104,28105,28106,28107,28108,28109,28110,28111,28112,28113,28114,28115,28116,28117,28118,28119,28120,28121,28122,28123,28124,28125,28126,28127,28128,28129,28130,28131,28132,28133,28134,28135,28136,28137,28138,28139,28140,28141,28142,28143,28144,28145,28146,28147,28148,28149,28150,28151,28152,28153,28154,28155,28156,28157,28158,28159,28160,28161,28162,28163,28164,28165,28166,28167,28168,28169,28170,28171,28172,28173,28174,28175,28176,28177,28178,28179,28180,28181,28182,28183,28184,28185,28186,28187,28188,28189,28190,28191,28192,28193,28194,28195,28196,28197,28198,28199,28200,28201,28202,28203,28204,28205,28206,28207,28208,28209,28210,28211,28212,28213,28214,28215,28216,28217,28218,28219,28220,28221,28222,28223,28224,28225,28226,28227,28228,28229,28230,28231,28232,28233,28234,28235,28236,28237,28238,28239,28240,28241,28242,28243,28244,28245,28246,28247,28248,28249,28250,28251,28252,28253,28254,28255,28256,28257,28258,28259,28260,28261,28262,28263,28264,28265,28266,28267,28268,28269,28270,28271,28272,28273,28274,28275,28276,28277,28278,28279,28280,28281,28282,28283,28284,28285,28286,28287,28288,28289,28290,28291,28292,28293,28294,28295,28296,28297,28298,28299,28300,28301,28302,28303,28304,28305,28306,28307,28308,28309,28310,28311,28312,28313,28314,28315,28316,28317,28318,28319,28320,28321,28322,28323,28324,28325,28326,28327,28328,28329,28330,28331,28332,28333,28334,28335,28336,28337,28338,28339,28340,28341,28342,28343,28344,28345,28346,28347,28348,28349,28350,28351,28352,28353,28354,28355,28356,28357,28358,28359,28360,28361,28362,28363,28364,28365,28366,28367,28368,28369,28370,28371,28372,28373,28374,28375,28376,28377,28378,28379,28380,28381,28382,28383,28384,28385,28386,28387,28388,28389,28390,28391,28392,28393,28394,28395,28396,28397,28398,28399,28400,28401,28402,28403,28404,28405,28406,28407,28408,28409,28410,28411,28412,28413,28414,28415,28416,28417,28418,28419,28420,28421,28422,28423,28424,28425,28426,28427,28428,28429,28430,28431,28432,28433,28434,28435,28436,28437,28438,28439,28440,28441,28442,28443,28444,28445,28446,28447,28448,28449,28450,28451,28452,28453,28454,28455,28456,28457,28458,28459,28460,28461,28462,28463,28464,28465,28466,28467,28468,28469,28470,28471,28472,28473,28474,28475,28476,28477,28478,28479,28480,28481,28482,28483,28484,28485,28486,28487,28488,28489,28490,28491,28492,28493,28494,28495,28496,28497,28498,28499,28500,28501,28502,28503,28504,28505,28506,28507,28508,28509,28510,28511,28512,28513,28514,28515,28516,28517,28518,28519,28520,28521,28522,28523,28524,28525,28526,28527,28528,28529,28530,28531,28532,28533,28534,28535,28536,28537,28538,28539,28540,28541,28542,28543,28544,28545,28546,28547,28548,28549,28550,28551,28552,28553,28554,28555,28556,28557,28558,28559,28560,28561,28562,28563,28564,28565,28566,28567,28568,28569,28570,28571,28572,28573,28574,28575,28576,28577,28578,28579,28580,28581,28582,28583,28584,28585,28586,28587,28588,28589,28590,28591,28592,28593,28594,28595,28596,28597,28598,28599,28600,28601,28602,28603,28604,28605,28606,28607,28608,28609,28610,28611,28612,28613,28614,28615,28616,28617,28618,28619,28620,28621,28622,28623,28624,28625,28626,28627,28628,28629,28630,28631,28632,28633,28634,28635,28636,28637,28638,28639,28640,28641,28642,28643,28644,28645,28646,28647,28648,28649,28650,28651,28652,28653,28654,28655,28656,28657,28658,28659,28660,28661,28662,28663,28664,28665,28666,28667,28668,28669,28670,28671,28672,28673,28674,28675,28676,28677,28678,28679,28680,28681,28682,28683,28684,28685,28686,28687,28688,28689,28690,28691,28692,28693,28694,28695,28696,28697,28698,28699,28700,28701,28702,28703,28704,28705,28706,28707,28708,28709,28710,28711,28712,28713,28714,28715,28716,28717,28718,28719,28720,28721,28722,28723,28724,28725,28726,28727,28728,28729,28730,28731,28732,28733,28734,28735,28736,28737,28738,28739,28740,28741,28742,28743,28744,28745,28746,28747,28748,28749,28750,28751,28752,28753,28754,28755,28756,28757,28758,28759,28760,28761,28762,28763,28764,28765,28766,28767,28768,28769,28770,28771,28772,28773,28774,28775,28776,28777,28778,28779,28780,28781,28782,28783,28784,28785,28786,28787,28788,28789,28790,28791,28792,28793,28794,28795,28796,28797,28798,28799,28800,28801,28802,28803,28804,28805,28806,28807,28808,28809,28810,28811,28812,28813,28814,28815,28816,28817,28818,28819,28820,28821,28822,28823,28824,28825,28826,28827,28828,28829,28830,28831,28832,28833,28834,28835,28836,28837,28838,28839,28840,28841,28842,28843,28844,28845,28846,28847,28848,28849,28850,28851,28852,28853,28854,28855,28856,28857,28858,28859,28860,28861,28862,28863,28864,28865,28866,28867,28868,28869,28870,28871,28872,28873,28874,28875,28876,28877,28878,28879,28880,28881,28882,28883,28884,28885,28886,28887,28888,28889,28890,28891,28892,28893,28894,28895,28896,28897,28898,28899,28900,28901,28902,28903,28904,28905,28906,28907,28908,28909,28910,28911,28912,28913,28914,28915,28916,28917,28918,28919,28920,28921,28922,28923,28924,28925,28926,28927,28928,28929,28930,28931,28932,28933,28934,28935,28936,28937,28938,28939,28940,28941,28942,28943,28944,28945,28946,28947,28948,28949,28950,28951,28952,28953,28954,28955,28956,28957,28958,28959,28960,28961,28962,28963,28964,28965,28966,28967,28968,28969,28970,28971,28972,28973,28974,28975,28976,28977,28978,28979,28980,28981,28982,28983,28984,28985,28986,28987,28988,28989,28990,28991,28992,28993,28994,28995,28996,28997,28998,28999,29000,29001,29002,29003,29004,29005,29006,29007,29008,29009,29010,29011,29012,29013,29014,29015,29016,29017,29018,29019,29020,29021,29022,29023,29024,29025,29026,29027,29028,29029,29030,29031,29032,29033,29034,29035,29036,29037,29038,29039,29040,29041,29042,29043,29044,29045,29046,29047,29048,29049,29050,29051,29052,29053,29054,29055,29056,29057,29058,29059,29060,29061,29062,29063,29064,29065,29066,29067,29068,29069,29070,29071,29072,29073,29074,29075,29076,29077,29078,29079,29080,29081,29082,29083,29084,29085,29086,29087,29088,29089,29090,29091,29092,29093,29094,29095,29096,29097,29098,29099,29100,29101,29102,29103,29104,29105,29106,29107,29108,29109,29110,29111,29112,29113,29114,29115,29116,29117,29118,29119,29120,29121,29122,29123,29124,29125,29126,29127,29128,29129,29130,29131,29132,29133,29134,29135,29136,29137,29138,29139,29140,29141,29142,29143,29144,29145,29146,29147,29148,29149,29150,29151,29152,29153,29154,29155,29156,29157,29158,29159,29160,29161,29162,29163,29164,29165,29166,29167,29168,29169,29170,29171,29172,29173,29174,29175,29176,29177,29178,29179,29180,29181,29182,29183,29184,29185,29186,29187,29188,29189,29190,29191,29192,29193,29194,29195,29196,29197,29198,29199,29200,29201,29202,29203,29204,29205,29206,29207,29208,29209,29210,29211,29212,29213,29214,29215,29216,29217,29218,29219,29220,29221,29222,29223,29224,29225,29226,29227,29228,29229,29230,29231,29232,29233,29234,29235,29236,29237,29238,29239,29240,29241,29242,29243,29244,29245,29246,29247,29248,29249,29250,29251,29252,29253,29254,29255,29256,29257,29258,29259,29260,29261,29262,29263,29264,29265,29266,29267,29268,29269,29270,29271,29272,29273,29274,29275,29276,29277,29278,29279,29280,29281,29282,29283,29284,29285,29286,29287,29288,29289,29290,29291,29292,29293,29294,29295,29296,29297,29298,29299,29300,29301,29302,29303,29304,29305,29306,29307,29308,29309,29310,29311,29312,29313,29314,29315,29316,29317,29318,29319,29320,29321,29322,29323,29324,29325,29326,29327,29328,29329,29330,29331,29332,29333,29334,29335,29336,29337,29338,29339,29340,29341,29342,29343,29344,29345,29346,29347,29348,29349,29350,29351,29352,29353,29354,29355,29356,29357,29358,29359,29360,29361,29362,29363,29364,29365,29366,29367,29368,29369,29370,29371,29372,29373,29374,29375,29376,29377,29378,29379,29380,29381,29382,29383,29384,29385,29386,29387,29388,29389,29390,29391,29392,29393,29394,29395,29396,29397,29398,29399,29400,29401,29402,29403,29404,29405,29406,29407,29408,29409,29410,29411,29412,29413,29414,29415,29416,29417,29418,29419,29420,29421,29422,29423,29424,29425,29426,29427,29428,29429,29430,29431,29432,29433,29434,29435,29436,29437,29438,29439,29440,29441,29442,29443,29444,29445,29446,29447,29448,29449,29450,29451,29452,29453,29454,29455,29456,29457,29458,29459,29460,29461,29462,29463,29464,29465,29466,29467,29468,29469,29470,29471,29472,29473,29474,29475,29476,29477,29478,29479,29480,29481,29482,29483,29484,29485,29486,29487,29488,29489,29490,29491,29492,29493,29494,29495,29496,29497,29498,29499,29500,29501,29502,29503,29504,29505,29506,29507,29508,29509,29510,29511,29512,29513,29514,29515,29516,29517,29518,29519,29520,29521,29522,29523,29524,29525,29526,29527,29528,29529,29530,29531,29532,29533,29534,29535,29536,29537,29538,29539,29540,29541,29542,29543,29544,29545,29546,29547,29548,29549,29550,29551,29552,29553,29554,29555,29556,29557,29558,29559,29560,29561,29562,29563,29564,29565,29566,29567,29568,29569,29570,29571,29572,29573,29574,29575,29576,29577,29578,29579,29580,29581,29582,29583,29584,29585,29586,29587,29588,29589,29590,29591,29592,29593,29594,29595,29596,29597,29598,29599,29600,29601,29602,29603,29604,29605,29606,29607,29608,29609,29610,29611,29612,29613,29614,29615,29616,29617,29618,29619,29620,29621,29622,29623,29624,29625,29626,29627,29628,29629,29630,29631,29632,29633,29634,29635,29636,29637,29638,29639,29640,29641,29642,29643,29644,29645,29646,29647,29648,29649,29650,29651,29652,29653,29654,29655,29656,29657,29658,29659,29660,29661,29662,29663,29664,29665,29666,29667,29668,29669,29670,29671,29672,29673,29674,29675,29676,29677,29678,29679,29680,29681,29682,29683,29684,29685,29686,29687,29688,29689,29690,29691,29692,29693,29694,29695,29696,29697,29698,29699,29700,29701,29702,29703,29704,29705,29706,29707,29708,29709,29710,29711,29712,29713,29714,29715,29716,29717,29718,29719,29720,29721,29722,29723,29724,29725,29726,29727,29728,29729,29730,29731,29732,29733,29734,29735,29736,29737,29738,29739,29740,29741,29742,29743,29744,29745,29746,29747,29748,29749,29750,29751,29752,29753,29754,29755,29756,29757,29758,29759,29760,29761,29762,29763,29764,29765,29766,29767,29768,29769,29770,29771,29772,29773,29774,29775,29776,29777,29778,29779,29780,29781,29782,29783,29784,29785,29786,29787,29788,29789,29790,29791,29792,29793,29794,29795,29796,29797,29798,29799,29800,29801,29802,29803,29804,29805,29806,29807,29808,29809,29810,29811,29812,29813,29814,29815,29816,29817,29818,29819,29820,29821,29822,29823,29824,29825,29826,29827,29828,29829,29830,29831,29832,29833,29834,29835,29836,29837,29838,29839,29840,29841,29842,29843,29844,29845,29846,29847,29848,29849,29850,29851,29852,29853,29854,29855,29856,29857,29858,29859,29860,29861,29862,29863,29864,29865,29866,29867,29868,29869,29870,29871,29872,29873,29874,29875,29876,29877,29878,29879,29880,29881,29882,29883,29884,29885,29886,29887,29888,29889,29890,29891,29892,29893,29894,29895,29896,29897,29898,29899,29900,29901,29902,29903,29904,29905,29906,29907,29908,29909,29910,29911,29912,29913,29914,29915,29916,29917,29918,29919,29920,29921,29922,29923,29924,29925,29926,29927,29928,29929,29930,29931,29932,29933,29934,29935,29936,29937,29938,29939,29940,29941,29942,29943,29944,29945,29946,29947,29948,29949,29950,29951,29952,29953,29954,29955,29956,29957,29958,29959,29960,29961,29962,29963,29964,29965,29966,29967,29968,29969,29970,29971,29972,29973,29974,29975,29976,29977,29978,29979,29980,29981,29982,29983,29984,29985,29986,29987,29988,29989,29990,29991,29992,29993,29994,29995,29996,29997,29998,29999,30000,30001,30002,30003,30004,30005,30006,30007,30008,30009,30010,30011,30012,30013,30014,30015,30016,30017,30018,30019,30020,30021,30022,30023,30024,30025,30026,30027,30028,30029,30030,30031,30032,30033,30034,30035,30036,30037,30038,30039,30040,30041,30042,30043,30044,30045,30046,30047,30048,30049,30050,30051,30052,30053,30054,30055,30056,30057,30058,30059,30060,30061,30062,30063,30064,30065,30066,30067,30068,30069,30070,30071,30072,30073,30074,30075,30076,30077,30078,30079,30080,30081,30082,30083,30084,30085,30086,30087,30088,30089,30090,30091,30092,30093,30094,30095,30096,30097,30098,30099,30100,30101,30102,30103,30104,30105,30106,30107,30108,30109,30110,30111,30112,30113,30114,30115,30116,30117,30118,30119,30120,30121,30122,30123,30124,30125,30126,30127,30128,30129,30130,30131,30132,30133,30134,30135,30136,30137,30138,30139,30140,30141,30142,30143,30144,30145,30146,30147,30148,30149,30150,30151,30152,30153,30154,30155,30156,30157,30158,30159,30160,30161,30162,30163,30164,30165,30166,30167,30168,30169,30170,30171,30172,30173,30174,30175,30176,30177,30178,30179,30180,30181,30182,30183,30184,30185,30186,30187,30188,30189,30190,30191,30192,30193,30194,30195,30196,30197,30198,30199,30200,30201,30202,30203,30204,30205,30206,30207,30208,30209,30210,30211,30212,30213,30214,30215,30216,30217,30218,30219,30220,30221,30222,30223,30224,30225,30226,30227,30228,30229,30230,30231,30232,30233,30234,30235,30236,30237,30238,30239,30240,30241,30242,30243,30244,30245,30246,30247,30248,30249,30250,30251,30252,30253,30254,30255,30256,30257,30258,30259,30260,30261,30262,30263,30264,30265,30266,30267,30268,30269,30270,30271,30272,30273,30274,30275,30276,30277,30278,30279,30280,30281,30282,30283,30284,30285,30286,30287,30288,30289,30290,30291,30292,30293,30294,30295,30296,30297,30298,30299,30300,30301,30302,30303,30304,30305,30306,30307,30308,30309,30310,30311,30312,30313,30314,30315,30316,30317,30318,30319,30320,30321,30322,30323,30324,30325,30326,30327,30328,30329,30330,30331,30332,30333,30334,30335,30336,30337,30338,30339,30340,30341,30342,30343,30344,30345,30346,30347,30348,30349,30350,30351,30352,30353,30354,30355,30356,30357,30358,30359,30360,30361,30362,30363,30364,30365,30366,30367,30368,30369,30370,30371,30372,30373,30374,30375,30376,30377,30378,30379,30380,30381,30382,30383,30384,30385,30386,30387,30388,30389,30390,30391,30392,30393,30394,30395,30396,30397,30398,30399,30400,30401,30402,30403,30404,30405,30406,30407,30408,30409,30410,30411,30412,30413,30414,30415,30416,30417,30418,30419,30420,30421,30422,30423,30424,30425,30426,30427,30428,30429,30430,30431,30432,30433,30434,30435,30436,30437,30438,30439,30440,30441,30442,30443,30444,30445,30446,30447,30448,30449,30450,30451,30452,30453,30454,30455,30456,30457,30458,30459,30460,30461,30462,30463,30464,30465,30466,30467,30468,30469,30470,30471,30472,30473,30474,30475,30476,30477,30478,30479,30480,30481,30482,30483,30484,30485,30486,30487,30488,30489,30490,30491,30492,30493,30494,30495,30496,30497,30498,30499,30500,30501,30502,30503,30504,30505,30506,30507,30508,30509,30510,30511,30512,30513,30514,30515,30516,30517,30518,30519,30520,30521,30522,30523,30524,30525,30526,30527,30528,30529,30530,30531,30532,30533,30534,30535,30536,30537,30538,30539,30540,30541,30542,30543,30544,30545,30546,30547,30548,30549,30550,30551,30552,30553,30554,30555,30556,30557,30558,30559,30560,30561,30562,30563,30564,30565,30566,30567,30568,30569,30570,30571,30572,30573,30574,30575,30576,30577,30578,30579,30580,30581,30582,30583,30584,30585,30586,30587,30588,30589,30590,30591,30592,30593,30594,30595,30596,30597,30598,30599,30600,30601,30602,30603,30604,30605,30606,30607,30608,30609,30610,30611,30612,30613,30614,30615,30616,30617,30618,30619,30620,30621,30622,30623,30624,30625,30626,30627,30628,30629,30630,30631,30632,30633,30634,30635,30636,30637,30638,30639,30640,30641,30642,30643,30644,30645,30646,30647,30648,30649,30650,30651,30652,30653,30654,30655,30656,30657,30658,30659,30660,30661,30662,30663,30664,30665,30666,30667,30668,30669,30670,30671,30672,30673,30674,30675,30676,30677,30678,30679,30680,30681,30682,30683,30684,30685,30686,30687,30688,30689,30690,30691,30692,30693,30694,30695,30696,30697,30698,30699,30700,30701,30702,30703,30704,30705,30706,30707,30708,30709,30710,30711,30712,30713,30714,30715,30716,30717,30718,30719,30720,30721,30722,30723,30724,30725,30726,30727,30728,30729,30730,30731,30732,30733,30734,30735,30736,30737,30738,30739,30740,30741,30742,30743,30744,30745,30746,30747,30748,30749,30750,30751,30752,30753,30754,30755,30756,30757,30758,30759,30760,30761,30762,30763,30764,30765,30766,30767,30768,30769,30770,30771,30772,30773,30774,30775,30776,30777,30778,30779,30780,30781,30782,30783,30784,30785,30786,30787,30788,30789,30790,30791,30792,30793,30794,30795,30796,30797,30798,30799,30800,30801,30802,30803,30804,30805,30806,30807,30808,30809,30810,30811,30812,30813,30814,30815,30816,30817,30818,30819,30820,30821,30822,30823,30824,30825,30826,30827,30828,30829,30830,30831,30832,30833,30834,30835,30836,30837,30838,30839,30840,30841,30842,30843,30844,30845,30846,30847,30848,30849,30850,30851,30852,30853,30854,30855,30856,30857,30858,30859,30860,30861,30862,30863,30864,30865,30866,30867,30868,30869,30870,30871,30872,30873,30874,30875,30876,30877,30878,30879,30880,30881,30882,30883,30884,30885,30886,30887,30888,30889,30890,30891,30892,30893,30894,30895,30896,30897,30898,30899,30900,30901,30902,30903,30904,30905,30906,30907,30908,30909,30910,30911,30912,30913,30914,30915,30916,30917,30918,30919,30920,30921,30922,30923,30924,30925,30926,30927,30928,30929,30930,30931,30932,30933,30934,30935,30936,30937,30938,30939,30940,30941,30942,30943,30944,30945,30946,30947,30948,30949,30950,30951,30952,30953,30954,30955,30956,30957,30958,30959,30960,30961,30962,30963,30964,30965,30966,30967,30968,30969,30970,30971,30972,30973,30974,30975,30976,30977,30978,30979,30980,30981,30982,30983,30984,30985,30986,30987,30988,30989,30990,30991,30992,30993,30994,30995,30996,30997,30998,30999,31000,31001,31002,31003,31004,31005,31006,31007,31008,31009,31010,31011,31012,31013,31014,31015,31016,31017,31018,31019,31020,31021,31022,31023,31024,31025,31026,31027,31028,31029,31030,31031,31032,31033,31034,31035,31036,31037,31038,31039,31040,31041,31042,31043,31044,31045,31046,31047,31048,31049,31050,31051,31052,31053,31054,31055,31056,31057,31058,31059,31060,31061,31062,31063,31064,31065,31066,31067,31068,31069,31070,31071,31072,31073,31074,31075,31076,31077,31078,31079,31080,31081,31082,31083,31084,31085,31086,31087,31088,31089,31090,31091,31092,31093,31094,31095,31096,31097,31098,31099,31100,31101,31102,31103,31104,31105,31106,31107,31108,31109,31110,31111,31112,31113,31114,31115,31116,31117,31118,31119,31120,31121,31122,31123,31124,31125,31126,31127,31128,31129,31130,31131,31132,31133,31134,31135,31136,31137,31138,31139,31140,31141,31142,31143,31144,31145,31146,31147,31148,31149,31150,31151,31152,31153,31154,31155,31156,31157,31158,31159,31160,31161,31162,31163,31164,31165,31166,31167,31168,31169,31170,31171,31172,31173,31174,31175,31176,31177,31178,31179,31180,31181,31182,31183,31184,31185,31186,31187,31188,31189,31190,31191,31192,31193,31194,31195,31196,31197,31198,31199,31200,31201,31202,31203,31204,31205,31206,31207,31208,31209,31210,31211,31212,31213,31214,31215,31216,31217,31218,31219,31220,31221,31222,31223,31224,31225,31226,31227,31228,31229,31230,31231,31232,31233,31234,31235,31236,31237,31238,31239,31240,31241,31242,31243,31244,31245,31246,31247,31248,31249,31250,31251,31252,31253,31254,31255,31256,31257,31258,31259,31260,31261,31262,31263,31264,31265,31266,31267,31268,31269,31270,31271,31272,31273,31274,31275,31276,31277,31278,31279,31280,31281,31282,31283,31284,31285,31286,31287,31288,31289,31290,31291,31292,31293,31294,31295,31296,31297,31298,31299,31300,31301,31302,31303,31304,31305,31306,31307,31308,31309,31310,31311,31312,31313,31314,31315,31316,31317,31318,31319,31320,31321,31322,31323,31324,31325,31326,31327,31328,31329,31330,31331,31332,31333,31334,31335,31336,31337,31338,31339,31340,31341,31342,31343,31344,31345,31346,31347,31348,31349,31350,31351,31352,31353,31354,31355,31356,31357,31358,31359,31360,31361,31362,31363,31364,31365,31366,31367,31368,31369,31370,31371,31372,31373,31374,31375,31376,31377,31378,31379,31380,31381,31382,31383,31384,31385,31386,31387,31388,31389,31390,31391,31392,31393,31394,31395,31396,31397,31398,31399,31400,31401,31402,31403,31404,31405,31406,31407,31408,31409,31410,31411,31412,31413,31414,31415,31416,31417,31418,31419,31420,31421,31422,31423,31424,31425,31426,31427,31428,31429,31430,31431,31432,31433,31434,31435,31436,31437,31438,31439,31440,31441,31442,31443,31444,31445,31446,31447,31448,31449,31450,31451,31452,31453,31454,31455,31456,31457,31458,31459,31460,31461,31462,31463,31464,31465,31466,31467,31468,31469,31470,31471,31472,31473,31474,31475,31476,31477,31478,31479,31480,31481,31482,31483,31484,31485,31486,31487,31488,31489,31490,31491,31492,31493,31494,31495,31496,31497,31498,31499,31500,31501,31502,31503,31504,31505,31506,31507,31508,31509,31510,31511,31512,31513,31514,31515,31516,31517,31518,31519,31520,31521,31522,31523,31524,31525,31526,31527,31528,31529,31530,31531,31532,31533,31534,31535,31536,31537,31538,31539,31540,31541,31542,31543,31544,31545,31546,31547,31548,31549,31550,31551,31552,31553,31554,31555,31556,31557,31558,31559,31560,31561,31562,31563,31564,31565,31566,31567,31568,31569,31570,31571,31572,31573,31574,31575,31576,31577,31578,31579,31580,31581,31582,31583,31584,31585,31586,31587,31588,31589,31590,31591,31592,31593,31594,31595,31596,31597,31598,31599,31600,31601,31602,31603,31604,31605,31606,31607,31608,31609,31610,31611,31612,31613,31614,31615,31616,31617,31618,31619,31620,31621,31622,31623,31624,31625,31626,31627,31628,31629,31630,31631,31632,31633,31634,31635,31636,31637,31638,31639,31640,31641,31642,31643,31644,31645,31646,31647,31648,31649,31650,31651,31652,31653,31654,31655,31656,31657,31658,31659,31660,31661,31662,31663,31664,31665,31666,31667,31668,31669,31670,31671,31672,31673,31674,31675,31676,31677,31678,31679,31680,31681,31682,31683,31684,31685,31686,31687,31688,31689,31690,31691,31692,31693,31694,31695,31696,31697,31698,31699,31700,31701,31702,31703,31704,31705,31706,31707,31708,31709,31710,31711,31712,31713,31714,31715,31716,31717,31718,31719,31720,31721,31722,31723,31724,31725,31726,31727,31728,31729,31730,31731,31732,31733,31734,31735,31736,31737,31738,31739,31740,31741,31742,31743,31744,31745,31746,31747,31748,31749,31750,31751,31752,31753,31754,31755,31756,31757,31758,31759,31760,31761,31762,31763,31764,31765,31766,31767,31768,31769,31770,31771,31772,31773,31774,31775,31776,31777,31778,31779,31780,31781,31782,31783,31784,31785,31786,31787,31788,31789,31790,31791,31792,31793,31794,31795,31796,31797,31798,31799,31800,31801,31802,31803,31804,31805,31806,31807,31808,31809,31810,31811,31812,31813,31814,31815,31816,31817,31818,31819,31820,31821,31822,31823,31824,31825,31826,31827,31828,31829,31830,31831,31832,31833,31834,31835,31836,31837,31838,31839,31840,31841,31842,31843,31844,31845,31846,31847,31848,31849,31850,31851,31852,31853,31854,31855,31856,31857,31858,31859,31860,31861,31862,31863,31864,31865,31866,31867,31868,31869,31870,31871,31872,31873,31874,31875,31876,31877,31878,31879,31880,31881,31882,31883,31884,31885,31886,31887,31888,31889,31890,31891,31892,31893,31894,31895,31896,31897,31898,31899,31900,31901,31902,31903,31904,31905,31906,31907,31908,31909,31910,31911,31912,31913,31914,31915,31916,31917,31918,31919,31920,31921,31922,31923,31924,31925,31926,31927,31928,31929,31930,31931,31932,31933,31934,31935,31936,31937,31938,31939,31940,31941,31942,31943,31944,31945,31946,31947,31948,31949,31950,31951,31952,31953,31954,31955,31956,31957,31958,31959,31960,31961,31962,31963,31964,31965,31966,31967,31968,31969,31970,31971,31972,31973,31974,31975,31976,31977,31978,31979,31980,31981,31982,31983,31984,31985,31986,31987,31988,31989,31990,31991,31992,31993,31994,31995,31996,31997,31998,31999,32000,32001,32002,32003,32004,32005,32006,32007,32008,32009,32010,32011,32012,32013,32014,32015,32016,32017,32018,32019,32020,32021,32022,32023,32024,32025,32026,32027,32028,32029,32030,32031,32032,32033,32034,32035,32036,32037,32038,32039,32040,32041,32042,32043,32044,32045,32046,32047,32048,32049,32050,32051,32052,32053,32054,32055,32056,32057,32058,32059,32060,32061,32062,32063,32064,32065,32066,32067,32068,32069,32070,32071,32072,32073,32074,32075,32076,32077,32078,32079,32080,32081,32082,32083,32084,32085,32086,32087,32088,32089,32090,32091,32092,32093,32094,32095,32096,32097,32098,32099,32100,32101,32102,32103,32104,32105,32106,32107,32108,32109,32110,32111,32112,32113,32114,32115,32116,32117,32118,32119,32120,32121,32122,32123,32124,32125,32126,32127,32128,32129,32130,32131,32132,32133,32134,32135,32136,32137,32138,32139,32140,32141,32142,32143,32144,32145,32146,32147,32148,32149,32150,32151,32152,32153,32154,32155,32156,32157,32158,32159,32160,32161,32162,32163,32164,32165,32166,32167,32168,32169,32170,32171,32172,32173,32174,32175,32176,32177,32178,32179,32180,32181,32182,32183,32184,32185,32186,32187,32188,32189,32190,32191,32192,32193,32194,32195,32196,32197,32198,32199,32200,32201,32202,32203,32204,32205,32206,32207,32208,32209,32210,32211,32212,32213,32214,32215,32216,32217,32218,32219,32220,32221,32222,32223,32224,32225,32226,32227,32228,32229,32230,32231,32232,32233,32234,32235,32236,32237,32238,32239,32240,32241,32242,32243,32244,32245,32246,32247,32248,32249,32250,32251,32252,32253,32254,32255,32256,32257,32258,32259,32260,32261,32262,32263,32264,32265,32266,32267,32268,32269,32270,32271,32272,32273,32274,32275,32276,32277,32278,32279,32280,32281,32282,32283,32284,32285,32286,32287,32288,32289,32290,32291,32292,32293,32294,32295,32296,32297,32298,32299,32300,32301,32302,32303,32304,32305,32306,32307,32308,32309,32310,32311,32312,32313,32314,32315,32316,32317,32318,32319,32320,32321,32322,32323,32324,32325,32326,32327,32328,32329,32330,32331,32332,32333,32334,32335,32336,32337,32338,32339,32340,32341,32342,32343,32344,32345,32346,32347,32348,32349,32350,32351,32352,32353,32354,32355,32356,32357,32358,32359,32360,32361,32362,32363,32364,32365,32366,32367,32368,32369,32370,32371,32372,32373,32374,32375,32376,32377,32378,32379,32380,32381,32382,32383,32384,32385,32386,32387,32388,32389,32390,32391,32392,32393,32394,32395,32396,32397,32398,32399,32400,32401,32402,32403,32404,32405,32406,32407,32408,32409,32410,32411,32412,32413,32414,32415,32416,32417,32418,32419,32420,32421,32422,32423,32424,32425,32426,32427,32428,32429,32430,32431,32432,32433,32434,32435,32436,32437,32438,32439,32440,32441,32442,32443,32444,32445,32446,32447,32448,32449,32450,32451,32452,32453,32454,32455,32456,32457,32458,32459,32460,32461,32462,32463,32464,32465,32466,32467,32468,32469,32470,32471,32472,32473,32474,32475,32476,32477,32478,32479,32480,32481,32482,32483,32484,32485,32486,32487,32488,32489,32490,32491,32492,32493,32494,32495,32496,32497,32498,32499,32500,32501,32502,32503,32504,32505,32506,32507,32508,32509,32510,32511,32512,32513,32514,32515,32516,32517,32518,32519,32520,32521,32522,32523,32524,32525,32526,32527,32528,32529,32530,32531,32532,32533,32534,32535,32536,32537,32538,32539,32540,32541,32542,32543,32544,32545,32546,32547,32548,32549,32550,32551,32552,32553,32554,32555,32556,32557,32558,32559,32560,32561,32562,32563,32564,32565,32566,32567,32568,32569,32570,32571,32572,32573,32574,32575,32576,32577,32578,32579,32580,32581,32582,32583,32584,32585,32586,32587,32588,32589,32590,32591,32592,32593,32594,32595,32596,32597,32598,32599,32600,32601,32602,32603,32604,32605,32606,32607,32608,32609,32610,32611,32612,32613,32614,32615,32616,32617,32618,32619,32620,32621,32622,32623,32624,32625,32626,32627,32628,32629,32630,32631,32632,32633,32634,32635,32636,32637,32638,32639,32640,32641,32642,32643,32644,32645,32646,32647,32648,32649,32650,32651,32652,32653,32654,32655,32656,32657,32658,32659,32660,32661,32662,32663,32664,32665,32666,32667,32668,32669,32670,32671,32672,32673,32674,32675,32676,32677,32678,32679,32680,32681,32682,32683,32684,32685,32686,32687,32688,32689,32690,32691,32692,32693,32694,32695,32696,32697,32698,32699,32700,32701,32702,32703,32704,32705,32706,32707,32708,32709,32710,32711,32712,32713,32714,32715,32716,32717,32718,32719,32720,32721,32722,32723,32724,32725,32726,32727,32728,32729,32730,32731,32732,32733,32734,32735,32736,32737,32738,32739,32740,32741,32742,32743,32744,32745,32746,32747,32748,32749,32750,32751,32752,32753,32754,32755,32756,32757,32758,32759,32760,32761,32762,32763,32764,32765,32766,32767,32768,32769,32770,32771,32772,32773,32774,32775,32776,32777,32778,32779,32780,32781,32782,32783,32784,32785,32786,32787,32788,32789,32790,32791,32792,32793,32794,32795,32796,32797,32798,32799,32800,32801,32802,32803,32804,32805,32806,32807,32808,32809,32810,32811,32812,32813,32814,32815,32816,32817,32818,32819,32820,32821,32822,32823,32824,32825,32826,32827,32828,32829,32830,32831,32832,32833,32834,32835,32836,32837,32838,32839,32840,32841,32842,32843,32844,32845,32846,32847,32848,32849,32850,32851,32852,32853,32854,32855,32856,32857,32858,32859,32860,32861,32862,32863,32864,32865,32866,32867,32868,32869,32870,32871,32872,32873,32874,32875,32876,32877,32878,32879,32880,32881,32882,32883,32884,32885,32886,32887,32888,32889,32890,32891,32892,32893,32894,32895,32896,32897,32898,32899,32900,32901,32902,32903,32904,32905,32906,32907,32908,32909,32910,32911,32912,32913,32914,32915,32916,32917,32918,32919,32920,32921,32922,32923,32924,32925,32926,32927,32928,32929,32930,32931,32932,32933,32934,32935,32936,32937,32938,32939,32940,32941,32942,32943,32944,32945,32946,32947,32948,32949,32950,32951,32952,32953,32954,32955,32956,32957,32958,32959,32960,32961,32962,32963,32964,32965,32966,32967,32968,32969,32970,32971,32972,32973,32974,32975,32976,32977,32978,32979,32980,32981,32982,32983,32984,32985,32986,32987,32988,32989,32990,32991,32992,32993,32994,32995,32996,32997,32998,32999,33000,33001,33002,33003,33004,33005,33006,33007,33008,33009,33010,33011,33012,33013,33014,33015,33016,33017,33018,33019,33020,33021,33022,33023,33024,33025,33026,33027,33028,33029,33030,33031,33032,33033,33034,33035,33036,33037,33038,33039,33040,33041,33042,33043,33044,33045,33046,33047,33048,33049,33050,33051,33052,33053,33054,33055,33056,33057,33058,33059,33060,33061,33062,33063,33064,33065,33066,33067,33068,33069,33070,33071,33072,33073,33074,33075,33076,33077,33078,33079,33080,33081,33082,33083,33084,33085,33086,33087,33088,33089,33090,33091,33092,33093,33094,33095,33096,33097,33098,33099,33100,33101,33102,33103,33104,33105,33106,33107,33108,33109,33110,33111,33112,33113,33114,33115,33116,33117,33118,33119,33120,33121,33122,33123,33124,33125,33126,33127,33128,33129,33130,33131,33132,33133,33134,33135,33136,33137,33138,33139,33140,33141,33142,33143,33144,33145,33146,33147,33148,33149,33150,33151,33152,33153,33154,33155,33156,33157,33158,33159,33160,33161,33162,33163,33164,33165,33166,33167,33168,33169,33170,33171,33172,33173,33174,33175,33176,33177,33178,33179,33180,33181,33182,33183,33184,33185,33186,33187,33188,33189,33190,33191,33192,33193,33194,33195,33196,33197,33198,33199,33200,33201,33202,33203,33204,33205,33206,33207,33208,33209,33210,33211,33212,33213,33214,33215,33216,33217,33218,33219,33220,33221,33222,33223,33224,33225,33226,33227,33228,33229,33230,33231,33232,33233,33234,33235,33236,33237,33238,33239,33240,33241,33242,33243,33244,33245,33246,33247,33248,33249,33250,33251,33252,33253,33254,33255,33256,33257,33258,33259,33260,33261,33262,33263,33264,33265,33266,33267,33268,33269,33270,33271,33272,33273,33274,33275,33276,33277,33278,33279,33280,33281,33282,33283,33284,33285,33286,33287,33288,33289,33290,33291,33292,33293,33294,33295,33296,33297,33298,33299,33300,33301,33302,33303,33304,33305,33306,33307,33308,33309,33310,33311,33312,33313,33314,33315,33316,33317,33318,33319,33320,33321,33322,33323,33324,33325,33326,33327,33328,33329,33330,33331,33332,33333,33334,33335,33336,33337,33338,33339,33340,33341,33342,33343,33344,33345,33346,33347,33348,33349,33350,33351,33352,33353,33354,33355,33356,33357,33358,33359,33360,33361,33362,33363,33364,33365,33366,33367,33368,33369,33370,33371,33372,33373,33374,33375,33376,33377,33378,33379,33380,33381,33382,33383,33384,33385,33386,33387,33388,33389,33390,33391,33392,33393,33394,33395,33396,33397,33398,33399,33400,33401,33402,33403,33404,33405,33406,33407,33408,33409,33410,33411,33412,33413,33414,33415,33416,33417,33418,33419,33420,33421,33422,33423,33424,33425,33426,33427,33428,33429,33430,33431,33432,33433,33434,33435,33436,33437,33438,33439,33440,33441,33442,33443,33444,33445,33446,33447,33448,33449,33450,33451,33452,33453,33454,33455,33456,33457,33458,33459,33460,33461,33462,33463,33464,33465,33466,33467,33468,33469,33470,33471,33472,33473,33474,33475,33476,33477,33478,33479,33480,33481,33482,33483,33484,33485,33486,33487,33488,33489,33490,33491,33492,33493,33494,33495,33496,33497,33498,33499,33500,33501,33502,33503,33504,33505,33506,33507,33508,33509,33510,33511,33512,33513,33514,33515,33516,33517,33518,33519,33520,33521,33522,33523,33524,33525,33526,33527,33528,33529,33530,33531,33532,33533,33534,33535,33536,33537,33538,33539,33540,33541,33542,33543,33544,33545,33546,33547,33548,33549,33550,33551,33552,33553,33554,33555,33556,33557,33558,33559,33560,33561,33562,33563,33564,33565,33566,33567,33568,33569,33570,33571,33572,33573,33574,33575,33576,33577,33578,33579,33580,33581,33582,33583,33584,33585,33586,33587,33588,33589,33590,33591,33592,33593,33594,33595,33596,33597,33598,33599,33600,33601,33602,33603,33604,33605,33606,33607,33608,33609,33610,33611,33612,33613,33614,33615,33616,33617,33618,33619,33620,33621,33622,33623,33624,33625,33626,33627,33628,33629,33630,33631,33632,33633,33634,33635,33636,33637,33638,33639,33640,33641,33642,33643,33644,33645,33646,33647,33648,33649,33650,33651,33652,33653,33654,33655,33656,33657,33658,33659,33660,33661,33662,33663,33664,33665,33666,33667,33668,33669,33670,33671,33672,33673,33674,33675,33676,33677,33678,33679,33680,33681,33682,33683,33684,33685,33686,33687,33688,33689,33690,33691,33692,33693,33694,33695,33696,33697,33698,33699,33700,33701,33702,33703,33704,33705,33706,33707,33708,33709,33710,33711,33712,33713,33714,33715,33716,33717,33718,33719,33720,33721,33722,33723,33724,33725,33726,33727,33728,33729,33730,33731,33732,33733,33734,33735,33736,33737,33738,33739,33740,33741,33742,33743,33744,33745,33746,33747,33748,33749,33750,33751,33752,33753,33754,33755,33756,33757,33758,33759,33760,33761,33762,33763,33764,33765,33766,33767,33768,33769,33770,33771,33772,33773,33774,33775,33776,33777,33778,33779,33780,33781,33782,33783,33784,33785,33786,33787,33788,33789,33790,33791,33792,33793,33794,33795,33796,33797,33798,33799,33800,33801,33802,33803,33804,33805,33806,33807,33808,33809,33810,33811,33812,33813,33814,33815,33816,33817,33818,33819,33820,33821,33822,33823,33824,33825,33826,33827,33828,33829,33830,33831,33832,33833,33834,33835,33836,33837,33838,33839,33840,33841,33842,33843,33844,33845,33846,33847,33848,33849,33850,33851,33852,33853,33854,33855,33856,33857,33858,33859,33860,33861,33862,33863,33864,33865,33866,33867,33868,33869,33870,33871,33872,33873,33874,33875,33876,33877,33878,33879,33880,33881,33882,33883,33884,33885,33886,33887,33888,33889,33890,33891,33892,33893,33894,33895,33896,33897,33898,33899,33900,33901,33902,33903,33904,33905,33906,33907,33908,33909,33910,33911,33912,33913,33914,33915,33916,33917,33918,33919,33920,33921,33922,33923,33924,33925,33926,33927,33928,33929,33930,33931,33932,33933,33934,33935,33936,33937,33938,33939,33940,33941,33942,33943,33944,33945,33946,33947,33948,33949,33950,33951,33952,33953,33954,33955,33956,33957,33958,33959,33960,33961,33962,33963,33964,33965,33966,33967,33968,33969,33970,33971,33972,33973,33974,33975,33976,33977,33978,33979,33980,33981,33982,33983,33984,33985,33986,33987,33988,33989,33990,33991,33992,33993,33994,33995,33996,33997,33998,33999,34000,34001,34002,34003,34004,34005,34006,34007,34008,34009,34010,34011,34012,34013,34014,34015,34016,34017,34018,34019,34020,34021,34022,34023,34024,34025,34026,34027,34028,34029,34030,34031,34032,34033,34034,34035,34036,34037,34038,34039,34040,34041,34042,34043,34044,34045,34046,34047,34048,34049,34050,34051,34052,34053,34054,34055,34056,34057,34058,34059,34060,34061,34062,34063,34064,34065,34066,34067,34068,34069,34070,34071,34072,34073,34074,34075,34076,34077,34078,34079,34080,34081,34082,34083,34084,34085,34086,34087,34088,34089,34090,34091,34092,34093,34094,34095,34096,34097,34098,34099,34100,34101,34102,34103,34104,34105,34106,34107,34108,34109,34110,34111,34112,34113,34114,34115,34116,34117,34118,34119,34120,34121,34122,34123,34124,34125,34126,34127,34128,34129,34130,34131,34132,34133,34134,34135,34136,34137,34138,34139,34140,34141,34142,34143,34144,34145,34146,34147,34148,34149,34150,34151,34152,34153,34154,34155,34156,34157,34158,34159,34160,34161,34162,34163,34164,34165,34166,34167,34168,34169,34170,34171,34172,34173,34174,34175,34176,34177,34178,34179,34180,34181,34182,34183,34184,34185,34186,34187,34188,34189,34190,34191,34192,34193,34194,34195,34196,34197,34198,34199,34200,34201,34202,34203,34204,34205,34206,34207,34208,34209,34210,34211,34212,34213,34214,34215,34216,34217,34218,34219,34220,34221,34222,34223,34224,34225,34226,34227,34228,34229,34230,34231,34232,34233,34234,34235,34236,34237,34238,34239,34240,34241,34242,34243,34244,34245,34246,34247,34248,34249,34250,34251,34252,34253,34254,34255,34256,34257,34258,34259,34260,34261,34262,34263,34264,34265,34266,34267,34268,34269,34270,34271,34272,34273,34274,34275,34276,34277,34278,34279,34280,34281,34282,34283,34284,34285,34286,34287,34288,34289,34290,34291,34292,34293,34294,34295,34296,34297,34298,34299,34300,34301,34302,34303,34304,34305,34306,34307,34308,34309,34310,34311,34312,34313,34314,34315,34316,34317,34318,34319,34320,34321,34322,34323,34324,34325,34326,34327,34328,34329,34330,34331,34332,34333,34334,34335,34336,34337,34338,34339,34340,34341,34342,34343,34344,34345,34346,34347,34348,34349,34350,34351,34352,34353,34354,34355,34356,34357,34358,34359,34360,34361,34362,34363,34364,34365,34366,34367,34368,34369,34370,34371,34372,34373,34374,34375,34376,34377,34378,34379,34380,34381,34382,34383,34384,34385,34386,34387,34388,34389,34390,34391,34392,34393,34394,34395,34396,34397,34398,34399,34400,34401,34402,34403,34404,34405,34406,34407,34408,34409,34410,34411,34412,34413,34414,34415,34416,34417,34418,34419,34420,34421,34422,34423,34424,34425,34426,34427,34428,34429,34430,34431,34432,34433,34434,34435,34436,34437,34438,34439,34440,34441,34442,34443,34444,34445,34446,34447,34448,34449,34450,34451,34452,34453,34454,34455,34456,34457,34458,34459,34460,34461,34462,34463,34464,34465,34466,34467,34468,34469,34470,34471,34472,34473,34474,34475,34476,34477,34478,34479,34480,34481,34482,34483,34484,34485,34486,34487,34488,34489,34490,34491,34492,34493,34494,34495,34496,34497,34498,34499,34500,34501,34502,34503,34504,34505,34506,34507,34508,34509,34510,34511,34512,34513,34514,34515,34516,34517,34518,34519,34520,34521,34522,34523,34524,34525,34526,34527,34528,34529,34530,34531,34532,34533,34534,34535,34536,34537,34538,34539,34540,34541,34542,34543,34544,34545,34546,34547,34548,34549,34550,34551,34552,34553,34554,34555,34556,34557,34558,34559,34560,34561,34562,34563,34564,34565,34566,34567,34568,34569,34570,34571,34572,34573,34574,34575,34576,34577,34578,34579,34580,34581,34582,34583,34584,34585,34586,34587,34588,34589,34590,34591,34592,34593,34594,34595,34596,34597,34598,34599,34600,34601,34602,34603,34604,34605,34606,34607,34608,34609,34610,34611,34612,34613,34614,34615,34616,34617,34618,34619,34620,34621,34622,34623,34624,34625,34626,34627,34628,34629,34630,34631,34632,34633,34634,34635,34636,34637,34638,34639,34640,34641,34642,34643,34644,34645,34646,34647,34648,34649,34650,34651,34652,34653,34654,34655,34656,34657,34658,34659,34660,34661,34662,34663,34664,34665,34666,34667,34668,34669,34670,34671,34672,34673,34674,34675,34676,34677,34678,34679,34680,34681,34682,34683,34684,34685,34686,34687,34688,34689,34690,34691,34692,34693,34694,34695,34696,34697,34698,34699,34700,34701,34702,34703,34704,34705,34706,34707,34708,34709,34710,34711,34712,34713,34714,34715,34716,34717,34718,34719,34720,34721,34722,34723,34724,34725,34726,34727,34728,34729,34730,34731,34732,34733,34734,34735,34736,34737,34738,34739,34740,34741,34742,34743,34744,34745,34746,34747,34748,34749,34750,34751,34752,34753,34754,34755,34756,34757,34758,34759,34760,34761,34762,34763,34764,34765,34766,34767,34768,34769,34770,34771,34772,34773,34774,34775,34776,34777,34778,34779,34780,34781,34782,34783,34784,34785,34786,34787,34788,34789,34790,34791,34792,34793,34794,34795,34796,34797,34798,34799,34800,34801,34802,34803,34804,34805,34806,34807,34808,34809,34810,34811,34812,34813,34814,34815,34816,34817,34818,34819,34820,34821,34822,34823,34824,34825,34826,34827,34828,34829,34830,34831,34832,34833,34834,34835,34836,34837,34838,34839,34840,34841,34842,34843,34844,34845,34846,34847,34848,34849,34850,34851,34852,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,34869,34870,34871,34872,34873,34874,34875,34876,34877,34878,34879,34880,34881,34882,34883,34884,34885,34886,34887,34888,34889,34890,34891,34892,34893,34894,34895,34896,34897,34898,34899,34900,34901,34902,34903,34904,34905,34906,34907,34908,34909,34910,34911,34912,34913,34914,34915,34916,34917,34918,34919,34920,34921,34922,34923,34924,34925,34926,34927,34928,34929,34930,34931,34932,34933,34934,34935,34936,34937,34938,34939,34940,34941,34942,34943,34944,34945,34946,34947,34948,34949,34950,34951,34952,34953,34954,34955,34956,34957,34958,34959,34960,34961,34962,34963,34964,34965,34966,34967,34968,34969,34970,34971,34972,34973,34974,34975,34976,34977,34978,34979,34980,34981,34982,34983,34984,34985,34986,34987,34988,34989,34990,34991,34992,34993,34994,34995,34996,34997,34998,34999,35000,35001,35002,35003,35004,35005,35006,35007,35008,35009,35010,35011,35012,35013,35014,35015,35016,35017,35018,35019,35020,35021,35022,35023,35024,35025,35026,35027,35028,35029,35030,35031,35032,35033,35034,35035,35036,35037,35038,35039,35040,35041,35042,35043,35044,35045,35046,35047,35048,35049,35050,35051,35052,35053,35054,35055,35056,35057,35058,35059,35060,35061,35062,35063,35064,35065,35066,35067,35068,35069,35070,35071,35072,35073,35074,35075,35076,35077,35078,35079,35080,35081,35082,35083,35084,35085,35086,35087,35088,35089,35090,35091,35092,35093,35094,35095,35096,35097,35098,35099,35100,35101,35102,35103,35104,35105,35106,35107,35108,35109,35110,35111,35112,35113,35114,35115,35116,35117,35118,35119,35120,35121,35122,35123,35124,35125,35126,35127,35128,35129,35130,35131,35132,35133,35134,35135,35136,35137,35138,35139,35140,35141,35142,35143,35144,35145,35146,35147,35148,35149,35150,35151,35152,35153,35154,35155,35156,35157,35158,35159,35160,35161,35162,35163,35164,35165,35166,35167,35168,35169,35170,35171,35172,35173,35174,35175,35176,35177,35178,35179,35180,35181,35182,35183,35184,35185,35186,35187,35188,35189,35190,35191,35192,35193,35194,35195,35196,35197,35198,35199,35200,35201,35202,35203,35204,35205,35206,35207,35208,35209,35210,35211,35212,35213,35214,35215,35216,35217,35218,35219,35220,35221,35222,35223,35224,35225,35226,35227,35228,35229,35230,35231,35232,35233,35234,35235,35236,35237,35238,35239,35240,35241,35242,35243,35244,35245,35246,35247,35248,35249,35250,35251,35252,35253,35254,35255,35256,35257,35258,35259,35260,35261,35262,35263,35264,35265,35266,35267,35268,35269,35270,35271,35272,35273,35274,35275,35276,35277,35278,35279,35280,35281,35282,35283,35284,35285,35286,35287,35288,35289,35290,35291,35292,35293,35294,35295,35296,35297,35298,35299,35300,35301,35302,35303,35304,35305,35306,35307,35308,35309,35310,35311,35312,35313,35314,35315,35316,35317,35318,35319,35320,35321,35322,35323,35324,35325,35326,35327,35328,35329,35330,35331,35332,35333,35334,35335,35336,35337,35338,35339,35340,35341,35342,35343,35344,35345,35346,35347,35348,35349,35350,35351,35352,35353,35354,35355,35356,35357,35358,35359,35360,35361,35362,35363,35364,35365,35366,35367,35368,35369,35370,35371,35372,35373,35374,35375,35376,35377,35378,35379,35380,35381,35382,35383,35384,35385,35386,35387,35388,35389,35390,35391,35392,35393,35394,35395,35396,35397,35398,35399,35400,35401,35402,35403,35404,35405,35406,35407,35408,35409,35410,35411,35412,35413,35414,35415,35416,35417,35418,35419,35420,35421,35422,35423,35424,35425,35426,35427,35428,35429,35430,35431,35432,35433,35434,35435,35436,35437,35438,35439,35440,35441,35442,35443,35444,35445,35446,35447,35448,35449,35450,35451,35452,35453,35454,35455,35456,35457,35458,35459,35460,35461,35462,35463,35464,35465,35466,35467,35468,35469,35470,35471,35472,35473,35474,35475,35476,35477,35478,35479,35480,35481,35482,35483,35484,35485,35486,35487,35488,35489,35490,35491,35492,35493,35494,35495,35496,35497,35498,35499,35500,35501,35502,35503,35504,35505,35506,35507,35508,35509,35510,35511,35512,35513,35514,35515,35516,35517,35518,35519,35520,35521,35522,35523,35524,35525,35526,35527,35528,35529,35530,35531,35532,35533,35534,35535,35536,35537,35538,35539,35540,35541,35542,35543,35544,35545,35546,35547,35548,35549,35550,35551,35552,35553,35554,35555,35556,35557,35558,35559,35560,35561,35562,35563,35564,35565,35566,35567,35568,35569,35570,35571,35572,35573,35574,35575,35576,35577,35578,35579,35580,35581,35582,35583,35584,35585,35586,35587,35588,35589,35590,35591,35592,35593,35594,35595,35596,35597,35598,35599,35600,35601,35602,35603,35604,35605,35606,35607,35608,35609,35610,35611,35612,35613,35614,35615,35616,35617,35618,35619,35620,35621,35622,35623,35624,35625,35626,35627,35628,35629,35630,35631,35632,35633,35634,35635,35636,35637,35638,35639,35640,35641,35642,35643,35644,35645,35646,35647,35648,35649,35650,35651,35652,35653,35654,35655,35656,35657,35658,35659,35660,35661,35662,35663,35664,35665,35666,35667,35668,35669,35670,35671,35672,35673,35674,35675,35676,35677,35678,35679,35680,35681,35682,35683,35684,35685,35686,35687,35688,35689,35690,35691,35692,35693,35694,35695,35696,35697,35698,35699,35700,35701,35702,35703,35704,35705,35706,35707,35708,35709,35710,35711,35712,35713,35714,35715,35716,35717,35718,35719,35720,35721,35722,35723,35724,35725,35726,35727,35728,35729,35730,35731,35732,35733,35734,35735,35736,35737,35738,35739,35740,35741,35742,35743,35744,35745,35746,35747,35748,35749,35750,35751,35752,35753,35754,35755,35756,35757,35758,35759,35760,35761,35762,35763,35764,35765,35766,35767,35768,35769,35770,35771,35772,35773,35774,35775,35776,35777,35778,35779,35780,35781,35782,35783,35784,35785,35786,35787,35788,35789,35790,35791,35792,35793,35794,35795,35796,35797,35798,35799,35800,35801,35802,35803,35804,35805,35806,35807,35808,35809,35810,35811,35812,35813,35814,35815,35816,35817,35818,35819,35820,35821,35822,35823,35824,35825,35826,35827,35828,35829,35830,35831,35832,35833,35834,35835,35836,35837,35838,35839,35840,35841,35842,35843,35844,35845,35846,35847,35848,35849,35850,35851,35852,35853,35854,35855,35856,35857,35858,35859,35860,35861,35862,35863,35864,35865,35866,35867,35868,35869,35870,35871,35872,35873,35874,35875,35876,35877,35878,35879,35880,35881,35882,35883,35884,35885,35886,35887,35888,35889,35890,35891,35892,35893,35894,35895,35896,35897,35898,35899,35900,35901,35902,35903,35904,35905,35906,35907,35908,35909,35910,35911,35912,35913,35914,35915,35916,35917,35918,35919,35920,35921,35922,35923,35924,35925,35926,35927,35928,35929,35930,35931,35932,35933,35934,35935,35936,35937,35938,35939,35940,35941,35942,35943,35944,35945,35946,35947,35948,35949,35950,35951,35952,35953,35954,35955,35956,35957,35958,35959,35960,35961,35962,35963,35964,35965,35966,35967,35968,35969,35970,35971,35972,35973,35974,35975,35976,35977,35978,35979,35980,35981,35982,35983,35984,35985,35986,35987,35988,35989,35990,35991,35992,35993,35994,35995,35996,35997,35998,35999,36000,36001,36002,36003,36004,36005,36006,36007,36008,36009,36010,36011,36012,36013,36014,36015,36016,36017,36018,36019,36020,36021,36022,36023,36024,36025,36026,36027,36028,36029,36030,36031,36032,36033,36034,36035,36036,36037,36038,36039,36040,36041,36042,36043,36044,36045,36046,36047,36048,36049,36050,36051,36052,36053,36054,36055,36056,36057,36058,36059,36060,36061,36062,36063,36064,36065,36066,36067,36068,36069,36070,36071,36072,36073,36074,36075,36076,36077,36078,36079,36080,36081,36082,36083,36084,36085,36086,36087,36088,36089,36090,36091,36092,36093,36094,36095,36096,36097,36098,36099,36100,36101,36102,36103,36104,36105,36106,36107,36108,36109,36110,36111,36112,36113,36114,36115,36116,36117,36118,36119,36120,36121,36122,36123,36124,36125,36126,36127,36128,36129,36130,36131,36132,36133,36134,36135,36136,36137,36138,36139,36140,36141,36142,36143,36144,36145,36146,36147,36148,36149,36150,36151,36152,36153,36154,36155,36156,36157,36158,36159,36160,36161,36162,36163,36164,36165,36166,36167,36168,36169,36170,36171,36172,36173,36174,36175,36176,36177,36178,36179,36180,36181,36182,36183,36184,36185,36186,36187,36188,36189,36190,36191,36192,36193,36194,36195,36196,36197,36198,36199,36200,36201,36202,36203,36204,36205,36206,36207,36208,36209,36210,36211,36212,36213,36214,36215,36216,36217,36218,36219,36220,36221,36222,36223,36224,36225,36226,36227,36228,36229,36230,36231,36232,36233,36234,36235,36236,36237,36238,36239,36240,36241,36242,36243,36244,36245,36246,36247,36248,36249,36250,36251,36252,36253,36254,36255,36256,36257,36258,36259,36260,36261,36262,36263,36264,36265,36266,36267,36268,36269,36270,36271,36272,36273,36274,36275,36276,36277,36278,36279,36280,36281,36282,36283,36284,36285,36286,36287,36288,36289,36290,36291,36292,36293,36294,36295,36296,36297,36298,36299,36300,36301,36302,36303,36304,36305,36306,36307,36308,36309,36310,36311,36312,36313,36314,36315,36316,36317,36318,36319,36320,36321,36322,36323,36324,36325,36326,36327,36328,36329,36330,36331,36332,36333,36334,36335,36336,36337,36338,36339,36340,36341,36342,36343,36344,36345,36346,36347,36348,36349,36350,36351,36352,36353,36354,36355,36356,36357,36358,36359,36360,36361,36362,36363,36364,36365,36366,36367,36368,36369,36370,36371,36372,36373,36374,36375,36376,36377,36378,36379,36380,36381,36382,36383,36384,36385,36386,36387,36388,36389,36390,36391,36392,36393,36394,36395,36396,36397,36398,36399,36400,36401,36402,36403,36404,36405,36406,36407,36408,36409,36410,36411,36412,36413,36414,36415,36416,36417,36418,36419,36420,36421,36422,36423,36424,36425,36426,36427,36428,36429,36430,36431,36432,36433,36434,36435,36436,36437,36438,36439,36440,36441,36442,36443,36444,36445,36446,36447,36448,36449,36450,36451,36452,36453,36454,36455,36456,36457,36458,36459,36460,36461,36462,36463,36464,36465,36466,36467,36468,36469,36470,36471,36472,36473,36474,36475,36476,36477,36478,36479,36480,36481,36482,36483,36484,36485,36486,36487,36488,36489,36490,36491,36492,36493,36494,36495,36496,36497,36498,36499,36500,36501,36502,36503,36504,36505,36506,36507,36508,36509,36510,36511,36512,36513,36514,36515,36516,36517,36518,36519,36520,36521,36522,36523,36524,36525,36526,36527,36528,36529,36530,36531,36532,36533,36534,36535,36536,36537,36538,36539,36540,36541,36542,36543,36544,36545,36546,36547,36548,36549,36550,36551,36552,36553,36554,36555,36556,36557,36558,36559,36560,36561,36562,36563,36564,36565,36566,36567,36568,36569,36570,36571,36572,36573,36574,36575,36576,36577,36578,36579,36580,36581,36582,36583,36584,36585,36586,36587,36588,36589,36590,36591,36592,36593,36594,36595,36596,36597,36598,36599,36600,36601,36602,36603,36604,36605,36606,36607,36608,36609,36610,36611,36612,36613,36614,36615,36616,36617,36618,36619,36620,36621,36622,36623,36624,36625,36626,36627,36628,36629,36630,36631,36632,36633,36634,36635,36636,36637,36638,36639,36640,36641,36642,36643,36644,36645,36646,36647,36648,36649,36650,36651,36652,36653,36654,36655,36656,36657,36658,36659,36660,36661,36662,36663,36664,36665,36666,36667,36668,36669,36670,36671,36672,36673,36674,36675,36676,36677,36678,36679,36680,36681,36682,36683,36684,36685,36686,36687,36688,36689,36690,36691,36692,36693,36694,36695,36696,36697,36698,36699,36700,36701,36702,36703,36704,36705,36706,36707,36708,36709,36710,36711,36712,36713,36714,36715,36716,36717,36718,36719,36720,36721,36722,36723,36724,36725,36726,36727,36728,36729,36730,36731,36732,36733,36734,36735,36736,36737,36738,36739,36740,36741,36742,36743,36744,36745,36746,36747,36748,36749,36750,36751,36752,36753,36754,36755,36756,36757,36758,36759,36760,36761,36762,36763,36764,36765,36766,36767,36768,36769,36770,36771,36772,36773,36774,36775,36776,36777,36778,36779,36780,36781,36782,36783,36784,36785,36786,36787,36788,36789,36790,36791,36792,36793,36794,36795,36796,36797,36798,36799,36800,36801,36802,36803,36804,36805,36806,36807,36808,36809,36810,36811,36812,36813,36814,36815,36816,36817,36818,36819,36820,36821,36822,36823,36824,36825,36826,36827,36828,36829,36830,36831,36832,36833,36834,36835,36836,36837,36838,36839,36840,36841,36842,36843,36844,36845,36846,36847,36848,36849,36850,36851,36852,36853,36854,36855,36856,36857,36858,36859,36860,36861,36862,36863,36864,36865,36866,36867,36868,36869,36870,36871,36872,36873,36874,36875,36876,36877,36878,36879,36880,36881,36882,36883,36884,36885,36886,36887,36888,36889,36890,36891,36892,36893,36894,36895,36896,36897,36898,36899,36900,36901,36902,36903,36904,36905,36906,36907,36908,36909,36910,36911,36912,36913,36914,36915,36916,36917,36918,36919,36920,36921,36922,36923,36924,36925,36926,36927,36928,36929,36930,36931,36932,36933,36934,36935,36936,36937,36938,36939,36940,36941,36942,36943,36944,36945,36946,36947,36948,36949,36950,36951,36952,36953,36954,36955,36956,36957,36958,36959,36960,36961,36962,36963,36964,36965,36966,36967,36968,36969,36970,36971,36972,36973,36974,36975,36976,36977,36978,36979,36980,36981,36982,36983,36984,36985,36986,36987,36988,36989,36990,36991,36992,36993,36994,36995,36996,36997,36998,36999,37000,37001,37002,37003,37004,37005,37006,37007,37008,37009,37010,37011,37012,37013,37014,37015,37016,37017,37018,37019,37020,37021,37022,37023,37024,37025,37026,37027,37028,37029,37030,37031,37032,37033,37034,37035,37036,37037,37038,37039,37040,37041,37042,37043,37044,37045,37046,37047,37048,37049,37050,37051,37052,37053,37054,37055,37056,37057,37058,37059,37060,37061,37062,37063,37064,37065,37066,37067,37068,37069,37070,37071,37072,37073,37074,37075,37076,37077,37078,37079,37080,37081,37082,37083,37084,37085,37086,37087,37088,37089,37090,37091,37092,37093,37094,37095,37096,37097,37098,37099,37100,37101,37102,37103,37104,37105,37106,37107,37108,37109,37110,37111,37112,37113,37114,37115,37116,37117,37118,37119,37120,37121,37122,37123,37124,37125,37126,37127,37128,37129,37130,37131,37132,37133,37134,37135,37136,37137,37138,37139,37140,37141,37142,37143,37144,37145,37146,37147,37148,37149,37150,37151,37152,37153,37154,37155,37156,37157,37158,37159,37160,37161,37162,37163,37164,37165,37166,37167,37168,37169,37170,37171,37172,37173,37174,37175,37176,37177,37178,37179,37180,37181,37182,37183,37184,37185,37186,37187,37188,37189,37190,37191,37192,37193,37194,37195,37196,37197,37198,37199,37200,37201,37202,37203,37204,37205,37206,37207,37208,37209,37210,37211,37212,37213,37214,37215,37216,37217,37218,37219,37220,37221,37222,37223,37224,37225,37226,37227,37228,37229,37230,37231,37232,37233,37234,37235,37236,37237,37238,37239,37240,37241,37242,37243,37244,37245,37246,37247,37248,37249,37250,37251,37252,37253,37254,37255,37256,37257,37258,37259,37260,37261,37262,37263,37264,37265,37266,37267,37268,37269,37270,37271,37272,37273,37274,37275,37276,37277,37278,37279,37280,37281,37282,37283,37284,37285,37286,37287,37288,37289,37290,37291,37292,37293,37294,37295,37296,37297,37298,37299,37300,37301,37302,37303,37304,37305,37306,37307,37308,37309,37310,37311,37312,37313,37314,37315,37316,37317,37318,37319,37320,37321,37322,37323,37324,37325,37326,37327,37328,37329,37330,37331,37332,37333,37334,37335,37336,37337,37338,37339,37340,37341,37342,37343,37344,37345,37346,37347,37348,37349,37350,37351,37352,37353,37354,37355,37356,37357,37358,37359,37360,37361,37362,37363,37364,37365,37366,37367,37368,37369,37370,37371,37372,37373,37374,37375,37376,37377,37378,37379,37380,37381,37382,37383,37384,37385,37386,37387,37388,37389,37390,37391,37392,37393,37394,37395,37396,37397,37398,37399,37400,37401,37402,37403,37404,37405,37406,37407,37408,37409,37410,37411,37412,37413,37414,37415,37416,37417,37418,37419,37420,37421,37422,37423,37424,37425,37426,37427,37428,37429,37430,37431,37432,37433,37434,37435,37436,37437,37438,37439,37440,37441,37442,37443,37444,37445,37446,37447,37448,37449,37450,37451,37452,37453,37454,37455,37456,37457,37458,37459,37460,37461,37462,37463,37464,37465,37466,37467,37468,37469,37470,37471,37472,37473,37474,37475,37476,37477,37478,37479,37480,37481,37482,37483,37484,37485,37486,37487,37488,37489,37490,37491,37492,37493,37494,37495,37496,37497,37498,37499,37500,37501,37502,37503,37504,37505,37506,37507,37508,37509,37510,37511,37512,37513,37514,37515,37516,37517,37518,37519,37520,37521,37522,37523,37524,37525,37526,37527,37528,37529,37530,37531,37532,37533,37534,37535,37536,37537,37538,37539,37540,37541,37542,37543,37544,37545,37546,37547,37548,37549,37550,37551,37552,37553,37554,37555,37556,37557,37558,37559,37560,37561,37562,37563,37564,37565,37566,37567,37568,37569,37570,37571,37572,37573,37574,37575,37576,37577,37578,37579,37580,37581,37582,37583,37584,37585,37586,37587,37588,37589,37590,37591,37592,37593,37594,37595,37596,37597,37598,37599,37600,37601,37602,37603,37604,37605,37606,37607,37608,37609,37610,37611,37612,37613,37614,37615,37616,37617,37618,37619,37620,37621,37622,37623,37624,37625,37626,37627,37628,37629,37630,37631,37632,37633,37634,37635,37636,37637,37638,37639,37640,37641,37642,37643,37644,37645,37646,37647,37648,37649,37650,37651,37652,37653,37654,37655,37656,37657,37658,37659,37660,37661,37662,37663,37664,37665,37666,37667,37668,37669,37670,37671,37672,37673,37674,37675,37676,37677,37678,37679,37680,37681,37682,37683,37684,37685,37686,37687,37688,37689,37690,37691,37692,37693,37694,37695,37696,37697,37698,37699,37700,37701,37702,37703,37704,37705,37706,37707,37708,37709,37710,37711,37712,37713,37714,37715,37716,37717,37718,37719,37720,37721,37722,37723,37724,37725,37726,37727,37728,37729,37730,37731,37732,37733,37734,37735,37736,37737,37738,37739,37740,37741,37742,37743,37744,37745,37746,37747,37748,37749,37750,37751,37752,37753,37754,37755,37756,37757,37758,37759,37760,37761,37762,37763,37764,37765,37766,37767,37768,37769,37770,37771,37772,37773,37774,37775,37776,37777,37778,37779,37780,37781,37782,37783,37784,37785,37786,37787,37788,37789,37790,37791,37792,37793,37794,37795,37796,37797,37798,37799,37800,37801,37802,37803,37804,37805,37806,37807,37808,37809,37810,37811,37812,37813,37814,37815,37816,37817,37818,37819,37820,37821,37822,37823,37824,37825,37826,37827,37828,37829,37830,37831,37832,37833,37834,37835,37836,37837,37838,37839,37840,37841,37842,37843,37844,37845,37846,37847,37848,37849,37850,37851,37852,37853,37854,37855,37856,37857,37858,37859,37860,37861,37862,37863,37864,37865,37866,37867,37868,37869,37870,37871,37872,37873,37874,37875,37876,37877,37878,37879,37880,37881,37882,37883,37884,37885,37886,37887,37888,37889,37890,37891,37892,37893,37894,37895,37896,37897,37898,37899,37900,37901,37902,37903,37904,37905,37906,37907,37908,37909,37910,37911,37912,37913,37914,37915,37916,37917,37918,37919,37920,37921,37922,37923,37924,37925,37926,37927,37928,37929,37930,37931,37932,37933,37934,37935,37936,37937,37938,37939,37940,37941,37942,37943,37944,37945,37946,37947,37948,37949,37950,37951,37952,37953,37954,37955,37956,37957,37958,37959,37960,37961,37962,37963,37964,37965,37966,37967,37968,37969,37970,37971,37972,37973,37974,37975,37976,37977,37978,37979,37980,37981,37982,37983,37984,37985,37986,37987,37988,37989,37990,37991,37992,37993,37994,37995,37996,37997,37998,37999,38000,38001,38002,38003,38004,38005,38006,38007,38008,38009,38010,38011,38012,38013,38014,38015,38016,38017,38018,38019,38020,38021,38022,38023,38024,38025,38026,38027,38028,38029,38030,38031,38032,38033,38034,38035,38036,38037,38038,38039,38040,38041,38042,38043,38044,38045,38046,38047,38048,38049,38050,38051,38052,38053,38054,38055,38056,38057,38058,38059,38060,38061,38062,38063,38064,38065,38066,38067,38068,38069,38070,38071,38072,38073,38074,38075,38076,38077,38078,38079,38080,38081,38082,38083,38084,38085,38086,38087,38088,38089,38090,38091,38092,38093,38094,38095,38096,38097,38098,38099,38100,38101,38102,38103,38104,38105,38106,38107,38108,38109,38110,38111,38112,38113,38114,38115,38116,38117,38118,38119,38120,38121,38122,38123,38124,38125,38126,38127,38128,38129,38130,38131,38132,38133,38134,38135,38136,38137,38138,38139,38140,38141,38142,38143,38144,38145,38146,38147,38148,38149,38150,38151,38152,38153,38154,38155,38156,38157,38158,38159,38160,38161,38162,38163,38164,38165,38166,38167,38168,38169,38170,38171,38172,38173,38174,38175,38176,38177,38178,38179,38180,38181,38182,38183,38184,38185,38186,38187,38188,38189,38190,38191,38192,38193,38194,38195,38196,38197,38198,38199,38200,38201,38202,38203,38204,38205,38206,38207,38208,38209,38210,38211,38212,38213,38214,38215,38216,38217,38218,38219,38220,38221,38222,38223,38224,38225,38226,38227,38228,38229,38230,38231,38232,38233,38234,38235,38236,38237,38238,38239,38240,38241,38242,38243,38244,38245,38246,38247,38248,38249,38250,38251,38252,38253,38254,38255,38256,38257,38258,38259,38260,38261,38262,38263,38264,38265,38266,38267,38268,38269,38270,38271,38272,38273,38274,38275,38276,38277,38278,38279,38280,38281,38282,38283,38284,38285,38286,38287,38288,38289,38290,38291,38292,38293,38294,38295,38296,38297,38298,38299,38300,38301,38302,38303,38304,38305,38306,38307,38308,38309,38310,38311,38312,38313,38314,38315,38316,38317,38318,38319,38320,38321,38322,38323,38324,38325,38326,38327,38328,38329,38330,38331,38332,38333,38334,38335,38336,38337,38338,38339,38340,38341,38342,38343,38344,38345,38346,38347,38348,38349,38350,38351,38352,38353,38354,38355,38356,38357,38358,38359,38360,38361,38362,38363,38364,38365,38366,38367,38368,38369,38370,38371,38372,38373,38374,38375,38376,38377,38378,38379,38380,38381,38382,38383,38384,38385,38386,38387,38388,38389,38390,38391,38392,38393,38394,38395,38396,38397,38398,38399,38400,38401,38402,38403,38404,38405,38406,38407,38408,38409,38410,38411,38412,38413,38414,38415,38416,38417,38418,38419,38420,38421,38422,38423,38424,38425,38426,38427,38428,38429,38430,38431,38432,38433,38434,38435,38436,38437,38438,38439,38440,38441,38442,38443,38444,38445,38446,38447,38448,38449,38450,38451,38452,38453,38454,38455,38456,38457,38458,38459,38460,38461,38462,38463,38464,38465,38466,38467,38468,38469,38470,38471,38472,38473,38474,38475,38476,38477,38478,38479,38480,38481,38482,38483,38484,38485,38486,38487,38488,38489,38490,38491,38492,38493,38494,38495,38496,38497,38498,38499,38500,38501,38502,38503,38504,38505,38506,38507,38508,38509,38510,38511,38512,38513,38514,38515,38516,38517,38518,38519,38520,38521,38522,38523,38524,38525,38526,38527,38528,38529,38530,38531,38532,38533,38534,38535,38536,38537,38538,38539,38540,38541,38542,38543,38544,38545,38546,38547,38548,38549,38550,38551,38552,38553,38554,38555,38556,38557,38558,38559,38560,38561,38562,38563,38564,38565,38566,38567,38568,38569,38570,38571,38572,38573,38574,38575,38576,38577,38578,38579,38580,38581,38582,38583,38584,38585,38586,38587,38588,38589,38590,38591,38592,38593,38594,38595,38596,38597,38598,38599,38600,38601,38602,38603,38604,38605,38606,38607,38608,38609,38610,38611,38612,38613,38614,38615,38616,38617,38618,38619,38620,38621,38622,38623,38624,38625,38626,38627,38628,38629,38630,38631,38632,38633,38634,38635,38636,38637,38638,38639,38640,38641,38642,38643,38644,38645,38646,38647,38648,38649,38650,38651,38652,38653,38654,38655,38656,38657,38658,38659,38660,38661,38662,38663,38664,38665,38666,38667,38668,38669,38670,38671,38672,38673,38674,38675,38676,38677,38678,38679,38680,38681,38682,38683,38684,38685,38686,38687,38688,38689,38690,38691,38692,38693,38694,38695,38696,38697,38698,38699,38700,38701,38702,38703,38704,38705,38706,38707,38708,38709,38710,38711,38712,38713,38714,38715,38716,38717,38718,38719,38720,38721,38722,38723,38724,38725,38726,38727,38728,38729,38730,38731,38732,38733,38734,38735,38736,38737,38738,38739,38740,38741,38742,38743,38744,38745,38746,38747,38748,38749,38750,38751,38752,38753,38754,38755,38756,38757,38758,38759,38760,38761,38762,38763,38764,38765,38766,38767,38768,38769,38770,38771,38772,38773,38774,38775,38776,38777,38778,38779,38780,38781,38782,38783,38784,38785,38786,38787,38788,38789,38790,38791,38792,38793,38794,38795,38796,38797,38798,38799,38800,38801,38802,38803,38804,38805,38806,38807,38808,38809,38810,38811,38812,38813,38814,38815,38816,38817,38818,38819,38820,38821,38822,38823,38824,38825,38826,38827,38828,38829,38830,38831,38832,38833,38834,38835,38836,38837,38838,38839,38840,38841,38842,38843,38844,38845,38846,38847,38848,38849,38850,38851,38852,38853,38854,38855,38856,38857,38858,38859,38860,38861,38862,38863,38864,38865,38866,38867,38868,38869,38870,38871,38872,38873,38874,38875,38876,38877,38878,38879,38880,38881,38882,38883,38884,38885,38886,38887,38888,38889,38890,38891,38892,38893,38894,38895,38896,38897,38898,38899,38900,38901,38902,38903,38904,38905,38906,38907,38908,38909,38910,38911,38912,38913,38914,38915,38916,38917,38918,38919,38920,38921,38922,38923,38924,38925,38926,38927,38928,38929,38930,38931,38932,38933,38934,38935,38936,38937,38938,38939,38940,38941,38942,38943,38944,38945,38946,38947,38948,38949,38950,38951,38952,38953,38954,38955,38956,38957,38958,38959,38960,38961,38962,38963,38964,38965,38966,38967,38968,38969,38970,38971,38972,38973,38974,38975,38976,38977,38978,38979,38980,38981,38982,38983,38984,38985,38986,38987,38988,38989,38990,38991,38992,38993,38994,38995,38996,38997,38998,38999,39000,39001,39002,39003,39004,39005,39006,39007,39008,39009,39010,39011,39012,39013,39014,39015,39016,39017,39018,39019,39020,39021,39022,39023,39024,39025,39026,39027,39028,39029,39030,39031,39032,39033,39034,39035,39036,39037,39038,39039,39040,39041,39042,39043,39044,39045,39046,39047,39048,39049,39050,39051,39052,39053,39054,39055,39056,39057,39058,39059,39060,39061,39062,39063,39064,39065,39066,39067,39068,39069,39070,39071,39072,39073,39074,39075,39076,39077,39078,39079,39080,39081,39082,39083,39084,39085,39086,39087,39088,39089,39090,39091,39092,39093,39094,39095,39096,39097,39098,39099,39100,39101,39102,39103,39104,39105,39106,39107,39108,39109,39110,39111,39112,39113,39114,39115,39116,39117,39118,39119,39120,39121,39122,39123,39124,39125,39126,39127,39128,39129,39130,39131,39132,39133,39134,39135,39136,39137,39138,39139,39140,39141,39142,39143,39144,39145,39146,39147,39148,39149,39150,39151,39152,39153,39154,39155,39156,39157,39158,39159,39160,39161,39162,39163,39164,39165,39166,39167,39168,39169,39170,39171,39172,39173,39174,39175,39176,39177,39178,39179,39180,39181,39182,39183,39184,39185,39186,39187,39188,39189,39190,39191,39192,39193,39194,39195,39196,39197,39198,39199,39200,39201,39202,39203,39204,39205,39206,39207,39208,39209,39210,39211,39212,39213,39214,39215,39216,39217,39218,39219,39220,39221,39222,39223,39224,39225,39226,39227,39228,39229,39230,39231,39232,39233,39234,39235,39236,39237,39238,39239,39240,39241,39242,39243,39244,39245,39246,39247,39248,39249,39250,39251,39252,39253,39254,39255,39256,39257,39258,39259,39260,39261,39262,39263,39264,39265,39266,39267,39268,39269,39270,39271,39272,39273,39274,39275,39276,39277,39278,39279,39280,39281,39282,39283,39284,39285,39286,39287,39288,39289,39290,39291,39292,39293,39294,39295,39296,39297,39298,39299,39300,39301,39302,39303,39304,39305,39306,39307,39308,39309,39310,39311,39312,39313,39314,39315,39316,39317,39318,39319,39320,39321,39322,39323,39324,39325,39326,39327,39328,39329,39330,39331,39332,39333,39334,39335,39336,39337,39338,39339,39340,39341,39342,39343,39344,39345,39346,39347,39348,39349,39350,39351,39352,39353,39354,39355,39356,39357,39358,39359,39360,39361,39362,39363,39364,39365,39366,39367,39368,39369,39370,39371,39372,39373,39374,39375,39376,39377,39378,39379,39380,39381,39382,39383,39384,39385,39386,39387,39388,39389,39390,39391,39392,39393,39394,39395,39396,39397,39398,39399,39400,39401,39402,39403,39404,39405,39406,39407,39408,39409,39410,39411,39412,39413,39414,39415,39416,39417,39418,39419,39420,39421,39422,39423,39424,39425,39426,39427,39428,39429,39430,39431,39432,39433,39434,39435,39436,39437,39438,39439,39440,39441,39442,39443,39444,39445,39446,39447,39448,39449,39450,39451,39452,39453,39454,39455,39456,39457,39458,39459,39460,39461,39462,39463,39464,39465,39466,39467,39468,39469,39470,39471,39472,39473,39474,39475,39476,39477,39478,39479,39480,39481,39482,39483,39484,39485,39486,39487,39488,39489,39490,39491,39492,39493,39494,39495,39496,39497,39498,39499,39500,39501,39502,39503,39504,39505,39506,39507,39508,39509,39510,39511,39512,39513,39514,39515,39516,39517,39518,39519,39520,39521,39522,39523,39524,39525,39526,39527,39528,39529,39530,39531,39532,39533,39534,39535,39536,39537,39538,39539,39540,39541,39542,39543,39544,39545,39546,39547,39548,39549,39550,39551,39552,39553,39554,39555,39556,39557,39558,39559,39560,39561,39562,39563,39564,39565,39566,39567,39568,39569,39570,39571,39572,39573,39574,39575,39576,39577,39578,39579,39580,39581,39582,39583,39584,39585,39586,39587,39588,39589,39590,39591,39592,39593,39594,39595,39596,39597,39598,39599,39600,39601,39602,39603,39604,39605,39606,39607,39608,39609,39610,39611,39612,39613,39614,39615,39616,39617,39618,39619,39620,39621,39622,39623,39624,39625,39626,39627,39628,39629,39630,39631,39632,39633,39634,39635,39636,39637,39638,39639,39640,39641,39642,39643,39644,39645,39646,39647,39648,39649,39650,39651,39652,39653,39654,39655,39656,39657,39658,39659,39660,39661,39662,39663,39664,39665,39666,39667,39668,39669,39670,39671,39672,39673,39674,39675,39676,39677,39678,39679,39680,39681,39682,39683,39684,39685,39686,39687,39688,39689,39690,39691,39692,39693,39694,39695,39696,39697,39698,39699,39700,39701,39702,39703,39704,39705,39706,39707,39708,39709,39710,39711,39712,39713,39714,39715,39716,39717,39718,39719,39720,39721,39722,39723,39724,39725,39726,39727,39728,39729,39730,39731,39732,39733,39734,39735,39736,39737,39738,39739,39740,39741,39742,39743,39744,39745,39746,39747,39748,39749,39750,39751,39752,39753,39754,39755,39756,39757,39758,39759,39760,39761,39762,39763,39764,39765,39766,39767,39768,39769,39770,39771,39772,39773,39774,39775,39776,39777,39778,39779,39780,39781,39782,39783,39784,39785,39786,39787,39788,39789,39790,39791,39792,39793,39794,39795,39796,39797,39798,39799,39800,39801,39802,39803,39804,39805,39806,39807,39808,39809,39810,39811,39812,39813,39814,39815,39816,39817,39818,39819,39820,39821,39822,39823,39824,39825,39826,39827,39828,39829,39830,39831,39832,39833,39834,39835,39836,39837,39838,39839,39840,39841,39842,39843,39844,39845,39846,39847,39848,39849,39850,39851,39852,39853,39854,39855,39856,39857,39858,39859,39860,39861,39862,39863,39864,39865,39866,39867,39868,39869,39870,39871,39872,39873,39874,39875,39876,39877,39878,39879,39880,39881,39882,39883,39884,39885,39886,39887,39888,39889,39890,39891,39892,39893,39894,39895,39896,39897,39898,39899,39900,39901,39902,39903,39904,39905,39906,39907,39908,39909,39910,39911,39912,39913,39914,39915,39916,39917,39918,39919,39920,39921,39922,39923,39924,39925,39926,39927,39928,39929,39930,39931,39932,39933,39934,39935,39936,39937,39938,39939,39940,39941,39942,39943,39944,39945,39946,39947,39948,39949,39950,39951,39952,39953,39954,39955,39956,39957,39958,39959,39960,39961,39962,39963,39964,39965,39966,39967,39968,39969,39970,39971,39972,39973,39974,39975,39976,39977,39978,39979,39980,39981,39982,39983,39984,39985,39986,39987,39988,39989,39990,39991,39992,39993,39994,39995,39996,39997,39998,39999,40000,40001,40002,40003,40004,40005,40006,40007,40008,40009,40010,40011,40012,40013,40014,40015,40016,40017,40018,40019,40020,40021,40022,40023,40024,40025,40026,40027,40028,40029,40030,40031,40032,40033,40034,40035,40036,40037,40038,40039,40040,40041,40042,40043,40044,40045,40046,40047,40048,40049,40050,40051,40052,40053,40054,40055,40056,40057,40058,40059,40060,40061,40062,40063,40064,40065,40066,40067,40068,40069,40070,40071,40072,40073,40074,40075,40076,40077,40078,40079,40080,40081,40082,40083,40084,40085,40086,40087,40088,40089,40090,40091,40092,40093,40094,40095,40096,40097,40098,40099,40100,40101,40102,40103,40104,40105,40106,40107,40108,40109,40110,40111,40112,40113,40114,40115,40116,40117,40118,40119,40120,40121,40122,40123,40124,40125,40126,40127,40128,40129,40130,40131,40132,40133,40134,40135,40136,40137,40138,40139,40140,40141,40142,40143,40144,40145,40146,40147,40148,40149,40150,40151,40152,40153,40154,40155,40156,40157,40158,40159,40160,40161,40162,40163,40164,40165,40166,40167,40168,40169,40170,40171,40172,40173,40174,40175,40176,40177,40178,40179,40180,40181,40182,40183,40184,40185,40186,40187,40188,40189,40190,40191,40192,40193,40194,40195,40196,40197,40198,40199,40200,40201,40202,40203,40204,40205,40206,40207,40208,40209,40210,40211,40212,40213,40214,40215,40216,40217,40218,40219,40220,40221,40222,40223,40224,40225,40226,40227,40228,40229,40230,40231,40232,40233,40234,40235,40236,40237,40238,40239,40240,40241,40242,40243,40244,40245,40246,40247,40248,40249,40250,40251,40252,40253,40254,40255,40256,40257,40258,40259,40260,40261,40262,40263,40264,40265,40266,40267,40268,40269,40270,40271,40272,40273,40274,40275,40276,40277,40278,40279,40280,40281,40282,40283,40284,40285,40286,40287,40288,40289,40290,40291,40292,40293,40294,40295,40296,40297,40298,40299,40300,40301,40302,40303,40304,40305,40306,40307,40308,40309,40310,40311,40312,40313,40314,40315,40316,40317,40318,40319,40320,40321,40322,40323,40324,40325,40326,40327,40328,40329,40330,40331,40332,40333,40334,40335,40336,40337,40338,40339,40340,40341,40342,40343,40344,40345,40346,40347,40348,40349,40350,40351,40352,40353,40354,40355,40356,40357,40358,40359,40360,40361,40362,40363,40364,40365,40366,40367,40368,40369,40370,40371,40372,40373,40374,40375,40376,40377,40378,40379,40380,40381,40382,40383,40384,40385,40386,40387,40388,40389,40390,40391,40392,40393,40394,40395,40396,40397,40398,40399,40400,40401,40402,40403,40404,40405,40406,40407,40408,40409,40410,40411,40412,40413,40414,40415,40416,40417,40418,40419,40420,40421,40422,40423,40424,40425,40426,40427,40428,40429,40430,40431,40432,40433,40434,40435,40436,40437,40438,40439,40440,40441,40442,40443,40444,40445,40446,40447,40448,40449,40450,40451,40452,40453,40454,40455,40456,40457,40458,40459,40460,40461,40462,40463,40464,40465,40466,40467,40468,40469,40470,40471,40472,40473,40474,40475,40476,40477,40478,40479,40480,40481,40482,40483,40484,40485,40486,40487,40488,40489,40490,40491,40492,40493,40494,40495,40496,40497,40498,40499,40500,40501,40502,40503,40504,40505,40506,40507,40508,40509,40510,40511,40512,40513,40514,40515,40516,40517,40518,40519,40520,40521,40522,40523,40524,40525,40526,40527,40528,40529,40530,40531,40532,40533,40534,40535,40536,40537,40538,40539,40540,40541,40542,40543,40544,40545,40546,40547,40548,40549,40550,40551,40552,40553,40554,40555,40556,40557,40558,40559,40560,40561,40562,40563,40564,40565,40566,40567,40568,40569,40570,40571,40572,40573,40574,40575,40576,40577,40578,40579,40580,40581,40582,40583,40584,40585,40586,40587,40588,40589,40590,40591,40592,40593,40594,40595,40596,40597,40598,40599,40600,40601,40602,40603,40604,40605,40606,40607,40608,40609,40610,40611,40612,40613,40614,40615,40616,40617,40618,40619,40620,40621,40622,40623,40624,40625,40626,40627,40628,40629,40630,40631,40632,40633,40634,40635,40636,40637,40638,40639,40640,40641,40642,40643,40644,40645,40646,40647,40648,40649,40650,40651,40652,40653,40654,40655,40656,40657,40658,40659,40660,40661,40662,40663,40664,40665,40666,40667,40668,40669,40670,40671,40672,40673,40674,40675,40676,40677,40678,40679,40680,40681,40682,40683,40684,40685,40686,40687,40688,40689,40690,40691,40692,40693,40694,40695,40696,40697,40698,40699,40700,40701,40702,40703,40704,40705,40706,40707,40708,40709,40710,40711,40712,40713,40714,40715,40716,40717,40718,40719,40720,40721,40722,40723,40724,40725,40726,40727,40728,40729,40730,40731,40732,40733,40734,40735,40736,40737,40738,40739,40740,40741,40742,40743,40744,40745,40746,40747,40748,40749,40750,40751,40752,40753,40754,40755,40756,40757,40758,40759,40760,40761,40762,40763,40764,40765,40766,40767,40768,40769,40770,40771,40772,40773,40774,40775,40776,40777,40778,40779,40780,40781,40782,40783,40784,40785,40786,40787,40788,40789,40790,40791,40792,40793,40794,40795,40796,40797,40798,40799,40800,40801,40802,40803,40804,40805,40806,40807,40808,40809,40810,40811,40812,40813,40814,40815,40816,40817,40818,40819,40820,40821,40822,40823,40824,40825,40826,40827,40828,40829,40830,40831,40832,40833,40834,40835,40836,40837,40838,40839,40840,40841,40842,40843,40844,40845,40846,40847,40848,40849,40850,40851,40852,40853,40854,40855,40856,40857,40858,40859,40860,40861,40862,40863,40864,40865,40866,40867,40868,40869,40870,40871,40872,40873,40874,40875,40876,40877,40878,40879,40880,40881,40882,40883,40884,40885,40886,40887,40888,40889,40890,40891,40892,40893,40894,40895,40896,40897,40898,40899,40900,40901,40902,40903,40904,40905,40906,40907,40908,40909,40910,40911,40912,40913,40914,40915,40916,40917,40918,40919,40920,40921,40922,40923,40924,40925,40926,40927,40928,40929,40930,40931,40932,40933,40934,40935,40936,40937,40938,40939,40940,40941,40942,40943,40960,40961,40962,40963,40964,40965,40966,40967,40968,40969,40970,40971,40972,40973,40974,40975,40976,40977,40978,40979,40980,40981,40982,40983,40984,40985,40986,40987,40988,40989,40990,40991,40992,40993,40994,40995,40996,40997,40998,40999,41000,41001,41002,41003,41004,41005,41006,41007,41008,41009,41010,41011,41012,41013,41014,41015,41016,41017,41018,41019,41020,41021,41022,41023,41024,41025,41026,41027,41028,41029,41030,41031,41032,41033,41034,41035,41036,41037,41038,41039,41040,41041,41042,41043,41044,41045,41046,41047,41048,41049,41050,41051,41052,41053,41054,41055,41056,41057,41058,41059,41060,41061,41062,41063,41064,41065,41066,41067,41068,41069,41070,41071,41072,41073,41074,41075,41076,41077,41078,41079,41080,41081,41082,41083,41084,41085,41086,41087,41088,41089,41090,41091,41092,41093,41094,41095,41096,41097,41098,41099,41100,41101,41102,41103,41104,41105,41106,41107,41108,41109,41110,41111,41112,41113,41114,41115,41116,41117,41118,41119,41120,41121,41122,41123,41124,41125,41126,41127,41128,41129,41130,41131,41132,41133,41134,41135,41136,41137,41138,41139,41140,41141,41142,41143,41144,41145,41146,41147,41148,41149,41150,41151,41152,41153,41154,41155,41156,41157,41158,41159,41160,41161,41162,41163,41164,41165,41166,41167,41168,41169,41170,41171,41172,41173,41174,41175,41176,41177,41178,41179,41180,41181,41182,41183,41184,41185,41186,41187,41188,41189,41190,41191,41192,41193,41194,41195,41196,41197,41198,41199,41200,41201,41202,41203,41204,41205,41206,41207,41208,41209,41210,41211,41212,41213,41214,41215,41216,41217,41218,41219,41220,41221,41222,41223,41224,41225,41226,41227,41228,41229,41230,41231,41232,41233,41234,41235,41236,41237,41238,41239,41240,41241,41242,41243,41244,41245,41246,41247,41248,41249,41250,41251,41252,41253,41254,41255,41256,41257,41258,41259,41260,41261,41262,41263,41264,41265,41266,41267,41268,41269,41270,41271,41272,41273,41274,41275,41276,41277,41278,41279,41280,41281,41282,41283,41284,41285,41286,41287,41288,41289,41290,41291,41292,41293,41294,41295,41296,41297,41298,41299,41300,41301,41302,41303,41304,41305,41306,41307,41308,41309,41310,41311,41312,41313,41314,41315,41316,41317,41318,41319,41320,41321,41322,41323,41324,41325,41326,41327,41328,41329,41330,41331,41332,41333,41334,41335,41336,41337,41338,41339,41340,41341,41342,41343,41344,41345,41346,41347,41348,41349,41350,41351,41352,41353,41354,41355,41356,41357,41358,41359,41360,41361,41362,41363,41364,41365,41366,41367,41368,41369,41370,41371,41372,41373,41374,41375,41376,41377,41378,41379,41380,41381,41382,41383,41384,41385,41386,41387,41388,41389,41390,41391,41392,41393,41394,41395,41396,41397,41398,41399,41400,41401,41402,41403,41404,41405,41406,41407,41408,41409,41410,41411,41412,41413,41414,41415,41416,41417,41418,41419,41420,41421,41422,41423,41424,41425,41426,41427,41428,41429,41430,41431,41432,41433,41434,41435,41436,41437,41438,41439,41440,41441,41442,41443,41444,41445,41446,41447,41448,41449,41450,41451,41452,41453,41454,41455,41456,41457,41458,41459,41460,41461,41462,41463,41464,41465,41466,41467,41468,41469,41470,41471,41472,41473,41474,41475,41476,41477,41478,41479,41480,41481,41482,41483,41484,41485,41486,41487,41488,41489,41490,41491,41492,41493,41494,41495,41496,41497,41498,41499,41500,41501,41502,41503,41504,41505,41506,41507,41508,41509,41510,41511,41512,41513,41514,41515,41516,41517,41518,41519,41520,41521,41522,41523,41524,41525,41526,41527,41528,41529,41530,41531,41532,41533,41534,41535,41536,41537,41538,41539,41540,41541,41542,41543,41544,41545,41546,41547,41548,41549,41550,41551,41552,41553,41554,41555,41556,41557,41558,41559,41560,41561,41562,41563,41564,41565,41566,41567,41568,41569,41570,41571,41572,41573,41574,41575,41576,41577,41578,41579,41580,41581,41582,41583,41584,41585,41586,41587,41588,41589,41590,41591,41592,41593,41594,41595,41596,41597,41598,41599,41600,41601,41602,41603,41604,41605,41606,41607,41608,41609,41610,41611,41612,41613,41614,41615,41616,41617,41618,41619,41620,41621,41622,41623,41624,41625,41626,41627,41628,41629,41630,41631,41632,41633,41634,41635,41636,41637,41638,41639,41640,41641,41642,41643,41644,41645,41646,41647,41648,41649,41650,41651,41652,41653,41654,41655,41656,41657,41658,41659,41660,41661,41662,41663,41664,41665,41666,41667,41668,41669,41670,41671,41672,41673,41674,41675,41676,41677,41678,41679,41680,41681,41682,41683,41684,41685,41686,41687,41688,41689,41690,41691,41692,41693,41694,41695,41696,41697,41698,41699,41700,41701,41702,41703,41704,41705,41706,41707,41708,41709,41710,41711,41712,41713,41714,41715,41716,41717,41718,41719,41720,41721,41722,41723,41724,41725,41726,41727,41728,41729,41730,41731,41732,41733,41734,41735,41736,41737,41738,41739,41740,41741,41742,41743,41744,41745,41746,41747,41748,41749,41750,41751,41752,41753,41754,41755,41756,41757,41758,41759,41760,41761,41762,41763,41764,41765,41766,41767,41768,41769,41770,41771,41772,41773,41774,41775,41776,41777,41778,41779,41780,41781,41782,41783,41784,41785,41786,41787,41788,41789,41790,41791,41792,41793,41794,41795,41796,41797,41798,41799,41800,41801,41802,41803,41804,41805,41806,41807,41808,41809,41810,41811,41812,41813,41814,41815,41816,41817,41818,41819,41820,41821,41822,41823,41824,41825,41826,41827,41828,41829,41830,41831,41832,41833,41834,41835,41836,41837,41838,41839,41840,41841,41842,41843,41844,41845,41846,41847,41848,41849,41850,41851,41852,41853,41854,41855,41856,41857,41858,41859,41860,41861,41862,41863,41864,41865,41866,41867,41868,41869,41870,41871,41872,41873,41874,41875,41876,41877,41878,41879,41880,41881,41882,41883,41884,41885,41886,41887,41888,41889,41890,41891,41892,41893,41894,41895,41896,41897,41898,41899,41900,41901,41902,41903,41904,41905,41906,41907,41908,41909,41910,41911,41912,41913,41914,41915,41916,41917,41918,41919,41920,41921,41922,41923,41924,41925,41926,41927,41928,41929,41930,41931,41932,41933,41934,41935,41936,41937,41938,41939,41940,41941,41942,41943,41944,41945,41946,41947,41948,41949,41950,41951,41952,41953,41954,41955,41956,41957,41958,41959,41960,41961,41962,41963,41964,41965,41966,41967,41968,41969,41970,41971,41972,41973,41974,41975,41976,41977,41978,41979,41980,41981,41982,41983,41984,41985,41986,41987,41988,41989,41990,41991,41992,41993,41994,41995,41996,41997,41998,41999,42000,42001,42002,42003,42004,42005,42006,42007,42008,42009,42010,42011,42012,42013,42014,42015,42016,42017,42018,42019,42020,42021,42022,42023,42024,42025,42026,42027,42028,42029,42030,42031,42032,42033,42034,42035,42036,42037,42038,42039,42040,42041,42042,42043,42044,42045,42046,42047,42048,42049,42050,42051,42052,42053,42054,42055,42056,42057,42058,42059,42060,42061,42062,42063,42064,42065,42066,42067,42068,42069,42070,42071,42072,42073,42074,42075,42076,42077,42078,42079,42080,42081,42082,42083,42084,42085,42086,42087,42088,42089,42090,42091,42092,42093,42094,42095,42096,42097,42098,42099,42100,42101,42102,42103,42104,42105,42106,42107,42108,42109,42110,42111,42112,42113,42114,42115,42116,42117,42118,42119,42120,42121,42122,42123,42124,42192,42193,42194,42195,42196,42197,42198,42199,42200,42201,42202,42203,42204,42205,42206,42207,42208,42209,42210,42211,42212,42213,42214,42215,42216,42217,42218,42219,42220,42221,42222,42223,42224,42225,42226,42227,42228,42229,42230,42231,42232,42233,42234,42235,42236,42237,42240,42241,42242,42243,42244,42245,42246,42247,42248,42249,42250,42251,42252,42253,42254,42255,42256,42257,42258,42259,42260,42261,42262,42263,42264,42265,42266,42267,42268,42269,42270,42271,42272,42273,42274,42275,42276,42277,42278,42279,42280,42281,42282,42283,42284,42285,42286,42287,42288,42289,42290,42291,42292,42293,42294,42295,42296,42297,42298,42299,42300,42301,42302,42303,42304,42305,42306,42307,42308,42309,42310,42311,42312,42313,42314,42315,42316,42317,42318,42319,42320,42321,42322,42323,42324,42325,42326,42327,42328,42329,42330,42331,42332,42333,42334,42335,42336,42337,42338,42339,42340,42341,42342,42343,42344,42345,42346,42347,42348,42349,42350,42351,42352,42353,42354,42355,42356,42357,42358,42359,42360,42361,42362,42363,42364,42365,42366,42367,42368,42369,42370,42371,42372,42373,42374,42375,42376,42377,42378,42379,42380,42381,42382,42383,42384,42385,42386,42387,42388,42389,42390,42391,42392,42393,42394,42395,42396,42397,42398,42399,42400,42401,42402,42403,42404,42405,42406,42407,42408,42409,42410,42411,42412,42413,42414,42415,42416,42417,42418,42419,42420,42421,42422,42423,42424,42425,42426,42427,42428,42429,42430,42431,42432,42433,42434,42435,42436,42437,42438,42439,42440,42441,42442,42443,42444,42445,42446,42447,42448,42449,42450,42451,42452,42453,42454,42455,42456,42457,42458,42459,42460,42461,42462,42463,42464,42465,42466,42467,42468,42469,42470,42471,42472,42473,42474,42475,42476,42477,42478,42479,42480,42481,42482,42483,42484,42485,42486,42487,42488,42489,42490,42491,42492,42493,42494,42495,42496,42497,42498,42499,42500,42501,42502,42503,42504,42505,42506,42507,42508,42512,42513,42514,42515,42516,42517,42518,42519,42520,42521,42522,42523,42524,42525,42526,42527,42538,42539,42560,42561,42562,42563,42564,42565,42566,42567,42568,42569,42570,42571,42572,42573,42574,42575,42576,42577,42578,42579,42580,42581,42582,42583,42584,42585,42586,42587,42588,42589,42590,42591,42592,42593,42594,42595,42596,42597,42598,42599,42600,42601,42602,42603,42604,42605,42606,42623,42624,42625,42626,42627,42628,42629,42630,42631,42632,42633,42634,42635,42636,42637,42638,42639,42640,42641,42642,42643,42644,42645,42646,42647,42648,42649,42650,42651,42652,42653,42656,42657,42658,42659,42660,42661,42662,42663,42664,42665,42666,42667,42668,42669,42670,42671,42672,42673,42674,42675,42676,42677,42678,42679,42680,42681,42682,42683,42684,42685,42686,42687,42688,42689,42690,42691,42692,42693,42694,42695,42696,42697,42698,42699,42700,42701,42702,42703,42704,42705,42706,42707,42708,42709,42710,42711,42712,42713,42714,42715,42716,42717,42718,42719,42720,42721,42722,42723,42724,42725,42726,42727,42728,42729,42730,42731,42732,42733,42734,42735,42775,42776,42777,42778,42779,42780,42781,42782,42783,42786,42787,42788,42789,42790,42791,42792,42793,42794,42795,42796,42797,42798,42799,42800,42801,42802,42803,42804,42805,42806,42807,42808,42809,42810,42811,42812,42813,42814,42815,42816,42817,42818,42819,42820,42821,42822,42823,42824,42825,42826,42827,42828,42829,42830,42831,42832,42833,42834,42835,42836,42837,42838,42839,42840,42841,42842,42843,42844,42845,42846,42847,42848,42849,42850,42851,42852,42853,42854,42855,42856,42857,42858,42859,42860,42861,42862,42863,42864,42865,42866,42867,42868,42869,42870,42871,42872,42873,42874,42875,42876,42877,42878,42879,42880,42881,42882,42883,42884,42885,42886,42887,42888,42891,42892,42893,42894,42895,42896,42897,42898,42899,42900,42901,42902,42903,42904,42905,42906,42907,42908,42909,42910,42911,42912,42913,42914,42915,42916,42917,42918,42919,42920,42921,42922,42923,42924,42925,42926,42927,42928,42929,42930,42931,42932,42933,42934,42935,42936,42937,42999,43000,43001,43002,43003,43004,43005,43006,43007,43008,43009,43011,43012,43013,43015,43016,43017,43018,43020,43021,43022,43023,43024,43025,43026,43027,43028,43029,43030,43031,43032,43033,43034,43035,43036,43037,43038,43039,43040,43041,43042,43072,43073,43074,43075,43076,43077,43078,43079,43080,43081,43082,43083,43084,43085,43086,43087,43088,43089,43090,43091,43092,43093,43094,43095,43096,43097,43098,43099,43100,43101,43102,43103,43104,43105,43106,43107,43108,43109,43110,43111,43112,43113,43114,43115,43116,43117,43118,43119,43120,43121,43122,43123,43138,43139,43140,43141,43142,43143,43144,43145,43146,43147,43148,43149,43150,43151,43152,43153,43154,43155,43156,43157,43158,43159,43160,43161,43162,43163,43164,43165,43166,43167,43168,43169,43170,43171,43172,43173,43174,43175,43176,43177,43178,43179,43180,43181,43182,43183,43184,43185,43186,43187,43250,43251,43252,43253,43254,43255,43259,43261,43262,43274,43275,43276,43277,43278,43279,43280,43281,43282,43283,43284,43285,43286,43287,43288,43289,43290,43291,43292,43293,43294,43295,43296,43297,43298,43299,43300,43301,43312,43313,43314,43315,43316,43317,43318,43319,43320,43321,43322,43323,43324,43325,43326,43327,43328,43329,43330,43331,43332,43333,43334,43360,43361,43362,43363,43364,43365,43366,43367,43368,43369,43370,43371,43372,43373,43374,43375,43376,43377,43378,43379,43380,43381,43382,43383,43384,43385,43386,43387,43388,43396,43397,43398,43399,43400,43401,43402,43403,43404,43405,43406,43407,43408,43409,43410,43411,43412,43413,43414,43415,43416,43417,43418,43419,43420,43421,43422,43423,43424,43425,43426,43427,43428,43429,43430,43431,43432,43433,43434,43435,43436,43437,43438,43439,43440,43441,43442,43471,43488,43489,43490,43491,43492,43494,43495,43496,43497,43498,43499,43500,43501,43502,43503,43514,43515,43516,43517,43518,43520,43521,43522,43523,43524,43525,43526,43527,43528,43529,43530,43531,43532,43533,43534,43535,43536,43537,43538,43539,43540,43541,43542,43543,43544,43545,43546,43547,43548,43549,43550,43551,43552,43553,43554,43555,43556,43557,43558,43559,43560,43584,43585,43586,43588,43589,43590,43591,43592,43593,43594,43595,43616,43617,43618,43619,43620,43621,43622,43623,43624,43625,43626,43627,43628,43629,43630,43631,43632,43633,43634,43635,43636,43637,43638,43642,43646,43647,43648,43649,43650,43651,43652,43653,43654,43655,43656,43657,43658,43659,43660,43661,43662,43663,43664,43665,43666,43667,43668,43669,43670,43671,43672,43673,43674,43675,43676,43677,43678,43679,43680,43681,43682,43683,43684,43685,43686,43687,43688,43689,43690,43691,43692,43693,43694,43695,43697,43701,43702,43705,43706,43707,43708,43709,43712,43714,43739,43740,43741,43744,43745,43746,43747,43748,43749,43750,43751,43752,43753,43754,43762,43763,43764,43777,43778,43779,43780,43781,43782,43785,43786,43787,43788,43789,43790,43793,43794,43795,43796,43797,43798,43808,43809,43810,43811,43812,43813,43814,43816,43817,43818,43819,43820,43821,43822,43824,43825,43826,43827,43828,43829,43830,43831,43832,43833,43834,43835,43836,43837,43838,43839,43840,43841,43842,43843,43844,43845,43846,43847,43848,43849,43850,43851,43852,43853,43854,43855,43856,43857,43858,43859,43860,43861,43862,43863,43864,43865,43866,43868,43869,43870,43871,43872,43873,43874,43875,43876,43877,43888,43889,43890,43891,43892,43893,43894,43895,43896,43897,43898,43899,43900,43901,43902,43903,43904,43905,43906,43907,43908,43909,43910,43911,43912,43913,43914,43915,43916,43917,43918,43919,43920,43921,43922,43923,43924,43925,43926,43927,43928,43929,43930,43931,43932,43933,43934,43935,43936,43937,43938,43939,43940,43941,43942,43943,43944,43945,43946,43947,43948,43949,43950,43951,43952,43953,43954,43955,43956,43957,43958,43959,43960,43961,43962,43963,43964,43965,43966,43967,43968,43969,43970,43971,43972,43973,43974,43975,43976,43977,43978,43979,43980,43981,43982,43983,43984,43985,43986,43987,43988,43989,43990,43991,43992,43993,43994,43995,43996,43997,43998,43999,44000,44001,44002,44032,44033,44034,44035,44036,44037,44038,44039,44040,44041,44042,44043,44044,44045,44046,44047,44048,44049,44050,44051,44052,44053,44054,44055,44056,44057,44058,44059,44060,44061,44062,44063,44064,44065,44066,44067,44068,44069,44070,44071,44072,44073,44074,44075,44076,44077,44078,44079,44080,44081,44082,44083,44084,44085,44086,44087,44088,44089,44090,44091,44092,44093,44094,44095,44096,44097,44098,44099,44100,44101,44102,44103,44104,44105,44106,44107,44108,44109,44110,44111,44112,44113,44114,44115,44116,44117,44118,44119,44120,44121,44122,44123,44124,44125,44126,44127,44128,44129,44130,44131,44132,44133,44134,44135,44136,44137,44138,44139,44140,44141,44142,44143,44144,44145,44146,44147,44148,44149,44150,44151,44152,44153,44154,44155,44156,44157,44158,44159,44160,44161,44162,44163,44164,44165,44166,44167,44168,44169,44170,44171,44172,44173,44174,44175,44176,44177,44178,44179,44180,44181,44182,44183,44184,44185,44186,44187,44188,44189,44190,44191,44192,44193,44194,44195,44196,44197,44198,44199,44200,44201,44202,44203,44204,44205,44206,44207,44208,44209,44210,44211,44212,44213,44214,44215,44216,44217,44218,44219,44220,44221,44222,44223,44224,44225,44226,44227,44228,44229,44230,44231,44232,44233,44234,44235,44236,44237,44238,44239,44240,44241,44242,44243,44244,44245,44246,44247,44248,44249,44250,44251,44252,44253,44254,44255,44256,44257,44258,44259,44260,44261,44262,44263,44264,44265,44266,44267,44268,44269,44270,44271,44272,44273,44274,44275,44276,44277,44278,44279,44280,44281,44282,44283,44284,44285,44286,44287,44288,44289,44290,44291,44292,44293,44294,44295,44296,44297,44298,44299,44300,44301,44302,44303,44304,44305,44306,44307,44308,44309,44310,44311,44312,44313,44314,44315,44316,44317,44318,44319,44320,44321,44322,44323,44324,44325,44326,44327,44328,44329,44330,44331,44332,44333,44334,44335,44336,44337,44338,44339,44340,44341,44342,44343,44344,44345,44346,44347,44348,44349,44350,44351,44352,44353,44354,44355,44356,44357,44358,44359,44360,44361,44362,44363,44364,44365,44366,44367,44368,44369,44370,44371,44372,44373,44374,44375,44376,44377,44378,44379,44380,44381,44382,44383,44384,44385,44386,44387,44388,44389,44390,44391,44392,44393,44394,44395,44396,44397,44398,44399,44400,44401,44402,44403,44404,44405,44406,44407,44408,44409,44410,44411,44412,44413,44414,44415,44416,44417,44418,44419,44420,44421,44422,44423,44424,44425,44426,44427,44428,44429,44430,44431,44432,44433,44434,44435,44436,44437,44438,44439,44440,44441,44442,44443,44444,44445,44446,44447,44448,44449,44450,44451,44452,44453,44454,44455,44456,44457,44458,44459,44460,44461,44462,44463,44464,44465,44466,44467,44468,44469,44470,44471,44472,44473,44474,44475,44476,44477,44478,44479,44480,44481,44482,44483,44484,44485,44486,44487,44488,44489,44490,44491,44492,44493,44494,44495,44496,44497,44498,44499,44500,44501,44502,44503,44504,44505,44506,44507,44508,44509,44510,44511,44512,44513,44514,44515,44516,44517,44518,44519,44520,44521,44522,44523,44524,44525,44526,44527,44528,44529,44530,44531,44532,44533,44534,44535,44536,44537,44538,44539,44540,44541,44542,44543,44544,44545,44546,44547,44548,44549,44550,44551,44552,44553,44554,44555,44556,44557,44558,44559,44560,44561,44562,44563,44564,44565,44566,44567,44568,44569,44570,44571,44572,44573,44574,44575,44576,44577,44578,44579,44580,44581,44582,44583,44584,44585,44586,44587,44588,44589,44590,44591,44592,44593,44594,44595,44596,44597,44598,44599,44600,44601,44602,44603,44604,44605,44606,44607,44608,44609,44610,44611,44612,44613,44614,44615,44616,44617,44618,44619,44620,44621,44622,44623,44624,44625,44626,44627,44628,44629,44630,44631,44632,44633,44634,44635,44636,44637,44638,44639,44640,44641,44642,44643,44644,44645,44646,44647,44648,44649,44650,44651,44652,44653,44654,44655,44656,44657,44658,44659,44660,44661,44662,44663,44664,44665,44666,44667,44668,44669,44670,44671,44672,44673,44674,44675,44676,44677,44678,44679,44680,44681,44682,44683,44684,44685,44686,44687,44688,44689,44690,44691,44692,44693,44694,44695,44696,44697,44698,44699,44700,44701,44702,44703,44704,44705,44706,44707,44708,44709,44710,44711,44712,44713,44714,44715,44716,44717,44718,44719,44720,44721,44722,44723,44724,44725,44726,44727,44728,44729,44730,44731,44732,44733,44734,44735,44736,44737,44738,44739,44740,44741,44742,44743,44744,44745,44746,44747,44748,44749,44750,44751,44752,44753,44754,44755,44756,44757,44758,44759,44760,44761,44762,44763,44764,44765,44766,44767,44768,44769,44770,44771,44772,44773,44774,44775,44776,44777,44778,44779,44780,44781,44782,44783,44784,44785,44786,44787,44788,44789,44790,44791,44792,44793,44794,44795,44796,44797,44798,44799,44800,44801,44802,44803,44804,44805,44806,44807,44808,44809,44810,44811,44812,44813,44814,44815,44816,44817,44818,44819,44820,44821,44822,44823,44824,44825,44826,44827,44828,44829,44830,44831,44832,44833,44834,44835,44836,44837,44838,44839,44840,44841,44842,44843,44844,44845,44846,44847,44848,44849,44850,44851,44852,44853,44854,44855,44856,44857,44858,44859,44860,44861,44862,44863,44864,44865,44866,44867,44868,44869,44870,44871,44872,44873,44874,44875,44876,44877,44878,44879,44880,44881,44882,44883,44884,44885,44886,44887,44888,44889,44890,44891,44892,44893,44894,44895,44896,44897,44898,44899,44900,44901,44902,44903,44904,44905,44906,44907,44908,44909,44910,44911,44912,44913,44914,44915,44916,44917,44918,44919,44920,44921,44922,44923,44924,44925,44926,44927,44928,44929,44930,44931,44932,44933,44934,44935,44936,44937,44938,44939,44940,44941,44942,44943,44944,44945,44946,44947,44948,44949,44950,44951,44952,44953,44954,44955,44956,44957,44958,44959,44960,44961,44962,44963,44964,44965,44966,44967,44968,44969,44970,44971,44972,44973,44974,44975,44976,44977,44978,44979,44980,44981,44982,44983,44984,44985,44986,44987,44988,44989,44990,44991,44992,44993,44994,44995,44996,44997,44998,44999,45000,45001,45002,45003,45004,45005,45006,45007,45008,45009,45010,45011,45012,45013,45014,45015,45016,45017,45018,45019,45020,45021,45022,45023,45024,45025,45026,45027,45028,45029,45030,45031,45032,45033,45034,45035,45036,45037,45038,45039,45040,45041,45042,45043,45044,45045,45046,45047,45048,45049,45050,45051,45052,45053,45054,45055,45056,45057,45058,45059,45060,45061,45062,45063,45064,45065,45066,45067,45068,45069,45070,45071,45072,45073,45074,45075,45076,45077,45078,45079,45080,45081,45082,45083,45084,45085,45086,45087,45088,45089,45090,45091,45092,45093,45094,45095,45096,45097,45098,45099,45100,45101,45102,45103,45104,45105,45106,45107,45108,45109,45110,45111,45112,45113,45114,45115,45116,45117,45118,45119,45120,45121,45122,45123,45124,45125,45126,45127,45128,45129,45130,45131,45132,45133,45134,45135,45136,45137,45138,45139,45140,45141,45142,45143,45144,45145,45146,45147,45148,45149,45150,45151,45152,45153,45154,45155,45156,45157,45158,45159,45160,45161,45162,45163,45164,45165,45166,45167,45168,45169,45170,45171,45172,45173,45174,45175,45176,45177,45178,45179,45180,45181,45182,45183,45184,45185,45186,45187,45188,45189,45190,45191,45192,45193,45194,45195,45196,45197,45198,45199,45200,45201,45202,45203,45204,45205,45206,45207,45208,45209,45210,45211,45212,45213,45214,45215,45216,45217,45218,45219,45220,45221,45222,45223,45224,45225,45226,45227,45228,45229,45230,45231,45232,45233,45234,45235,45236,45237,45238,45239,45240,45241,45242,45243,45244,45245,45246,45247,45248,45249,45250,45251,45252,45253,45254,45255,45256,45257,45258,45259,45260,45261,45262,45263,45264,45265,45266,45267,45268,45269,45270,45271,45272,45273,45274,45275,45276,45277,45278,45279,45280,45281,45282,45283,45284,45285,45286,45287,45288,45289,45290,45291,45292,45293,45294,45295,45296,45297,45298,45299,45300,45301,45302,45303,45304,45305,45306,45307,45308,45309,45310,45311,45312,45313,45314,45315,45316,45317,45318,45319,45320,45321,45322,45323,45324,45325,45326,45327,45328,45329,45330,45331,45332,45333,45334,45335,45336,45337,45338,45339,45340,45341,45342,45343,45344,45345,45346,45347,45348,45349,45350,45351,45352,45353,45354,45355,45356,45357,45358,45359,45360,45361,45362,45363,45364,45365,45366,45367,45368,45369,45370,45371,45372,45373,45374,45375,45376,45377,45378,45379,45380,45381,45382,45383,45384,45385,45386,45387,45388,45389,45390,45391,45392,45393,45394,45395,45396,45397,45398,45399,45400,45401,45402,45403,45404,45405,45406,45407,45408,45409,45410,45411,45412,45413,45414,45415,45416,45417,45418,45419,45420,45421,45422,45423,45424,45425,45426,45427,45428,45429,45430,45431,45432,45433,45434,45435,45436,45437,45438,45439,45440,45441,45442,45443,45444,45445,45446,45447,45448,45449,45450,45451,45452,45453,45454,45455,45456,45457,45458,45459,45460,45461,45462,45463,45464,45465,45466,45467,45468,45469,45470,45471,45472,45473,45474,45475,45476,45477,45478,45479,45480,45481,45482,45483,45484,45485,45486,45487,45488,45489,45490,45491,45492,45493,45494,45495,45496,45497,45498,45499,45500,45501,45502,45503,45504,45505,45506,45507,45508,45509,45510,45511,45512,45513,45514,45515,45516,45517,45518,45519,45520,45521,45522,45523,45524,45525,45526,45527,45528,45529,45530,45531,45532,45533,45534,45535,45536,45537,45538,45539,45540,45541,45542,45543,45544,45545,45546,45547,45548,45549,45550,45551,45552,45553,45554,45555,45556,45557,45558,45559,45560,45561,45562,45563,45564,45565,45566,45567,45568,45569,45570,45571,45572,45573,45574,45575,45576,45577,45578,45579,45580,45581,45582,45583,45584,45585,45586,45587,45588,45589,45590,45591,45592,45593,45594,45595,45596,45597,45598,45599,45600,45601,45602,45603,45604,45605,45606,45607,45608,45609,45610,45611,45612,45613,45614,45615,45616,45617,45618,45619,45620,45621,45622,45623,45624,45625,45626,45627,45628,45629,45630,45631,45632,45633,45634,45635,45636,45637,45638,45639,45640,45641,45642,45643,45644,45645,45646,45647,45648,45649,45650,45651,45652,45653,45654,45655,45656,45657,45658,45659,45660,45661,45662,45663,45664,45665,45666,45667,45668,45669,45670,45671,45672,45673,45674,45675,45676,45677,45678,45679,45680,45681,45682,45683,45684,45685,45686,45687,45688,45689,45690,45691,45692,45693,45694,45695,45696,45697,45698,45699,45700,45701,45702,45703,45704,45705,45706,45707,45708,45709,45710,45711,45712,45713,45714,45715,45716,45717,45718,45719,45720,45721,45722,45723,45724,45725,45726,45727,45728,45729,45730,45731,45732,45733,45734,45735,45736,45737,45738,45739,45740,45741,45742,45743,45744,45745,45746,45747,45748,45749,45750,45751,45752,45753,45754,45755,45756,45757,45758,45759,45760,45761,45762,45763,45764,45765,45766,45767,45768,45769,45770,45771,45772,45773,45774,45775,45776,45777,45778,45779,45780,45781,45782,45783,45784,45785,45786,45787,45788,45789,45790,45791,45792,45793,45794,45795,45796,45797,45798,45799,45800,45801,45802,45803,45804,45805,45806,45807,45808,45809,45810,45811,45812,45813,45814,45815,45816,45817,45818,45819,45820,45821,45822,45823,45824,45825,45826,45827,45828,45829,45830,45831,45832,45833,45834,45835,45836,45837,45838,45839,45840,45841,45842,45843,45844,45845,45846,45847,45848,45849,45850,45851,45852,45853,45854,45855,45856,45857,45858,45859,45860,45861,45862,45863,45864,45865,45866,45867,45868,45869,45870,45871,45872,45873,45874,45875,45876,45877,45878,45879,45880,45881,45882,45883,45884,45885,45886,45887,45888,45889,45890,45891,45892,45893,45894,45895,45896,45897,45898,45899,45900,45901,45902,45903,45904,45905,45906,45907,45908,45909,45910,45911,45912,45913,45914,45915,45916,45917,45918,45919,45920,45921,45922,45923,45924,45925,45926,45927,45928,45929,45930,45931,45932,45933,45934,45935,45936,45937,45938,45939,45940,45941,45942,45943,45944,45945,45946,45947,45948,45949,45950,45951,45952,45953,45954,45955,45956,45957,45958,45959,45960,45961,45962,45963,45964,45965,45966,45967,45968,45969,45970,45971,45972,45973,45974,45975,45976,45977,45978,45979,45980,45981,45982,45983,45984,45985,45986,45987,45988,45989,45990,45991,45992,45993,45994,45995,45996,45997,45998,45999,46000,46001,46002,46003,46004,46005,46006,46007,46008,46009,46010,46011,46012,46013,46014,46015,46016,46017,46018,46019,46020,46021,46022,46023,46024,46025,46026,46027,46028,46029,46030,46031,46032,46033,46034,46035,46036,46037,46038,46039,46040,46041,46042,46043,46044,46045,46046,46047,46048,46049,46050,46051,46052,46053,46054,46055,46056,46057,46058,46059,46060,46061,46062,46063,46064,46065,46066,46067,46068,46069,46070,46071,46072,46073,46074,46075,46076,46077,46078,46079,46080,46081,46082,46083,46084,46085,46086,46087,46088,46089,46090,46091,46092,46093,46094,46095,46096,46097,46098,46099,46100,46101,46102,46103,46104,46105,46106,46107,46108,46109,46110,46111,46112,46113,46114,46115,46116,46117,46118,46119,46120,46121,46122,46123,46124,46125,46126,46127,46128,46129,46130,46131,46132,46133,46134,46135,46136,46137,46138,46139,46140,46141,46142,46143,46144,46145,46146,46147,46148,46149,46150,46151,46152,46153,46154,46155,46156,46157,46158,46159,46160,46161,46162,46163,46164,46165,46166,46167,46168,46169,46170,46171,46172,46173,46174,46175,46176,46177,46178,46179,46180,46181,46182,46183,46184,46185,46186,46187,46188,46189,46190,46191,46192,46193,46194,46195,46196,46197,46198,46199,46200,46201,46202,46203,46204,46205,46206,46207,46208,46209,46210,46211,46212,46213,46214,46215,46216,46217,46218,46219,46220,46221,46222,46223,46224,46225,46226,46227,46228,46229,46230,46231,46232,46233,46234,46235,46236,46237,46238,46239,46240,46241,46242,46243,46244,46245,46246,46247,46248,46249,46250,46251,46252,46253,46254,46255,46256,46257,46258,46259,46260,46261,46262,46263,46264,46265,46266,46267,46268,46269,46270,46271,46272,46273,46274,46275,46276,46277,46278,46279,46280,46281,46282,46283,46284,46285,46286,46287,46288,46289,46290,46291,46292,46293,46294,46295,46296,46297,46298,46299,46300,46301,46302,46303,46304,46305,46306,46307,46308,46309,46310,46311,46312,46313,46314,46315,46316,46317,46318,46319,46320,46321,46322,46323,46324,46325,46326,46327,46328,46329,46330,46331,46332,46333,46334,46335,46336,46337,46338,46339,46340,46341,46342,46343,46344,46345,46346,46347,46348,46349,46350,46351,46352,46353,46354,46355,46356,46357,46358,46359,46360,46361,46362,46363,46364,46365,46366,46367,46368,46369,46370,46371,46372,46373,46374,46375,46376,46377,46378,46379,46380,46381,46382,46383,46384,46385,46386,46387,46388,46389,46390,46391,46392,46393,46394,46395,46396,46397,46398,46399,46400,46401,46402,46403,46404,46405,46406,46407,46408,46409,46410,46411,46412,46413,46414,46415,46416,46417,46418,46419,46420,46421,46422,46423,46424,46425,46426,46427,46428,46429,46430,46431,46432,46433,46434,46435,46436,46437,46438,46439,46440,46441,46442,46443,46444,46445,46446,46447,46448,46449,46450,46451,46452,46453,46454,46455,46456,46457,46458,46459,46460,46461,46462,46463,46464,46465,46466,46467,46468,46469,46470,46471,46472,46473,46474,46475,46476,46477,46478,46479,46480,46481,46482,46483,46484,46485,46486,46487,46488,46489,46490,46491,46492,46493,46494,46495,46496,46497,46498,46499,46500,46501,46502,46503,46504,46505,46506,46507,46508,46509,46510,46511,46512,46513,46514,46515,46516,46517,46518,46519,46520,46521,46522,46523,46524,46525,46526,46527,46528,46529,46530,46531,46532,46533,46534,46535,46536,46537,46538,46539,46540,46541,46542,46543,46544,46545,46546,46547,46548,46549,46550,46551,46552,46553,46554,46555,46556,46557,46558,46559,46560,46561,46562,46563,46564,46565,46566,46567,46568,46569,46570,46571,46572,46573,46574,46575,46576,46577,46578,46579,46580,46581,46582,46583,46584,46585,46586,46587,46588,46589,46590,46591,46592,46593,46594,46595,46596,46597,46598,46599,46600,46601,46602,46603,46604,46605,46606,46607,46608,46609,46610,46611,46612,46613,46614,46615,46616,46617,46618,46619,46620,46621,46622,46623,46624,46625,46626,46627,46628,46629,46630,46631,46632,46633,46634,46635,46636,46637,46638,46639,46640,46641,46642,46643,46644,46645,46646,46647,46648,46649,46650,46651,46652,46653,46654,46655,46656,46657,46658,46659,46660,46661,46662,46663,46664,46665,46666,46667,46668,46669,46670,46671,46672,46673,46674,46675,46676,46677,46678,46679,46680,46681,46682,46683,46684,46685,46686,46687,46688,46689,46690,46691,46692,46693,46694,46695,46696,46697,46698,46699,46700,46701,46702,46703,46704,46705,46706,46707,46708,46709,46710,46711,46712,46713,46714,46715,46716,46717,46718,46719,46720,46721,46722,46723,46724,46725,46726,46727,46728,46729,46730,46731,46732,46733,46734,46735,46736,46737,46738,46739,46740,46741,46742,46743,46744,46745,46746,46747,46748,46749,46750,46751,46752,46753,46754,46755,46756,46757,46758,46759,46760,46761,46762,46763,46764,46765,46766,46767,46768,46769,46770,46771,46772,46773,46774,46775,46776,46777,46778,46779,46780,46781,46782,46783,46784,46785,46786,46787,46788,46789,46790,46791,46792,46793,46794,46795,46796,46797,46798,46799,46800,46801,46802,46803,46804,46805,46806,46807,46808,46809,46810,46811,46812,46813,46814,46815,46816,46817,46818,46819,46820,46821,46822,46823,46824,46825,46826,46827,46828,46829,46830,46831,46832,46833,46834,46835,46836,46837,46838,46839,46840,46841,46842,46843,46844,46845,46846,46847,46848,46849,46850,46851,46852,46853,46854,46855,46856,46857,46858,46859,46860,46861,46862,46863,46864,46865,46866,46867,46868,46869,46870,46871,46872,46873,46874,46875,46876,46877,46878,46879,46880,46881,46882,46883,46884,46885,46886,46887,46888,46889,46890,46891,46892,46893,46894,46895,46896,46897,46898,46899,46900,46901,46902,46903,46904,46905,46906,46907,46908,46909,46910,46911,46912,46913,46914,46915,46916,46917,46918,46919,46920,46921,46922,46923,46924,46925,46926,46927,46928,46929,46930,46931,46932,46933,46934,46935,46936,46937,46938,46939,46940,46941,46942,46943,46944,46945,46946,46947,46948,46949,46950,46951,46952,46953,46954,46955,46956,46957,46958,46959,46960,46961,46962,46963,46964,46965,46966,46967,46968,46969,46970,46971,46972,46973,46974,46975,46976,46977,46978,46979,46980,46981,46982,46983,46984,46985,46986,46987,46988,46989,46990,46991,46992,46993,46994,46995,46996,46997,46998,46999,47000,47001,47002,47003,47004,47005,47006,47007,47008,47009,47010,47011,47012,47013,47014,47015,47016,47017,47018,47019,47020,47021,47022,47023,47024,47025,47026,47027,47028,47029,47030,47031,47032,47033,47034,47035,47036,47037,47038,47039,47040,47041,47042,47043,47044,47045,47046,47047,47048,47049,47050,47051,47052,47053,47054,47055,47056,47057,47058,47059,47060,47061,47062,47063,47064,47065,47066,47067,47068,47069,47070,47071,47072,47073,47074,47075,47076,47077,47078,47079,47080,47081,47082,47083,47084,47085,47086,47087,47088,47089,47090,47091,47092,47093,47094,47095,47096,47097,47098,47099,47100,47101,47102,47103,47104,47105,47106,47107,47108,47109,47110,47111,47112,47113,47114,47115,47116,47117,47118,47119,47120,47121,47122,47123,47124,47125,47126,47127,47128,47129,47130,47131,47132,47133,47134,47135,47136,47137,47138,47139,47140,47141,47142,47143,47144,47145,47146,47147,47148,47149,47150,47151,47152,47153,47154,47155,47156,47157,47158,47159,47160,47161,47162,47163,47164,47165,47166,47167,47168,47169,47170,47171,47172,47173,47174,47175,47176,47177,47178,47179,47180,47181,47182,47183,47184,47185,47186,47187,47188,47189,47190,47191,47192,47193,47194,47195,47196,47197,47198,47199,47200,47201,47202,47203,47204,47205,47206,47207,47208,47209,47210,47211,47212,47213,47214,47215,47216,47217,47218,47219,47220,47221,47222,47223,47224,47225,47226,47227,47228,47229,47230,47231,47232,47233,47234,47235,47236,47237,47238,47239,47240,47241,47242,47243,47244,47245,47246,47247,47248,47249,47250,47251,47252,47253,47254,47255,47256,47257,47258,47259,47260,47261,47262,47263,47264,47265,47266,47267,47268,47269,47270,47271,47272,47273,47274,47275,47276,47277,47278,47279,47280,47281,47282,47283,47284,47285,47286,47287,47288,47289,47290,47291,47292,47293,47294,47295,47296,47297,47298,47299,47300,47301,47302,47303,47304,47305,47306,47307,47308,47309,47310,47311,47312,47313,47314,47315,47316,47317,47318,47319,47320,47321,47322,47323,47324,47325,47326,47327,47328,47329,47330,47331,47332,47333,47334,47335,47336,47337,47338,47339,47340,47341,47342,47343,47344,47345,47346,47347,47348,47349,47350,47351,47352,47353,47354,47355,47356,47357,47358,47359,47360,47361,47362,47363,47364,47365,47366,47367,47368,47369,47370,47371,47372,47373,47374,47375,47376,47377,47378,47379,47380,47381,47382,47383,47384,47385,47386,47387,47388,47389,47390,47391,47392,47393,47394,47395,47396,47397,47398,47399,47400,47401,47402,47403,47404,47405,47406,47407,47408,47409,47410,47411,47412,47413,47414,47415,47416,47417,47418,47419,47420,47421,47422,47423,47424,47425,47426,47427,47428,47429,47430,47431,47432,47433,47434,47435,47436,47437,47438,47439,47440,47441,47442,47443,47444,47445,47446,47447,47448,47449,47450,47451,47452,47453,47454,47455,47456,47457,47458,47459,47460,47461,47462,47463,47464,47465,47466,47467,47468,47469,47470,47471,47472,47473,47474,47475,47476,47477,47478,47479,47480,47481,47482,47483,47484,47485,47486,47487,47488,47489,47490,47491,47492,47493,47494,47495,47496,47497,47498,47499,47500,47501,47502,47503,47504,47505,47506,47507,47508,47509,47510,47511,47512,47513,47514,47515,47516,47517,47518,47519,47520,47521,47522,47523,47524,47525,47526,47527,47528,47529,47530,47531,47532,47533,47534,47535,47536,47537,47538,47539,47540,47541,47542,47543,47544,47545,47546,47547,47548,47549,47550,47551,47552,47553,47554,47555,47556,47557,47558,47559,47560,47561,47562,47563,47564,47565,47566,47567,47568,47569,47570,47571,47572,47573,47574,47575,47576,47577,47578,47579,47580,47581,47582,47583,47584,47585,47586,47587,47588,47589,47590,47591,47592,47593,47594,47595,47596,47597,47598,47599,47600,47601,47602,47603,47604,47605,47606,47607,47608,47609,47610,47611,47612,47613,47614,47615,47616,47617,47618,47619,47620,47621,47622,47623,47624,47625,47626,47627,47628,47629,47630,47631,47632,47633,47634,47635,47636,47637,47638,47639,47640,47641,47642,47643,47644,47645,47646,47647,47648,47649,47650,47651,47652,47653,47654,47655,47656,47657,47658,47659,47660,47661,47662,47663,47664,47665,47666,47667,47668,47669,47670,47671,47672,47673,47674,47675,47676,47677,47678,47679,47680,47681,47682,47683,47684,47685,47686,47687,47688,47689,47690,47691,47692,47693,47694,47695,47696,47697,47698,47699,47700,47701,47702,47703,47704,47705,47706,47707,47708,47709,47710,47711,47712,47713,47714,47715,47716,47717,47718,47719,47720,47721,47722,47723,47724,47725,47726,47727,47728,47729,47730,47731,47732,47733,47734,47735,47736,47737,47738,47739,47740,47741,47742,47743,47744,47745,47746,47747,47748,47749,47750,47751,47752,47753,47754,47755,47756,47757,47758,47759,47760,47761,47762,47763,47764,47765,47766,47767,47768,47769,47770,47771,47772,47773,47774,47775,47776,47777,47778,47779,47780,47781,47782,47783,47784,47785,47786,47787,47788,47789,47790,47791,47792,47793,47794,47795,47796,47797,47798,47799,47800,47801,47802,47803,47804,47805,47806,47807,47808,47809,47810,47811,47812,47813,47814,47815,47816,47817,47818,47819,47820,47821,47822,47823,47824,47825,47826,47827,47828,47829,47830,47831,47832,47833,47834,47835,47836,47837,47838,47839,47840,47841,47842,47843,47844,47845,47846,47847,47848,47849,47850,47851,47852,47853,47854,47855,47856,47857,47858,47859,47860,47861,47862,47863,47864,47865,47866,47867,47868,47869,47870,47871,47872,47873,47874,47875,47876,47877,47878,47879,47880,47881,47882,47883,47884,47885,47886,47887,47888,47889,47890,47891,47892,47893,47894,47895,47896,47897,47898,47899,47900,47901,47902,47903,47904,47905,47906,47907,47908,47909,47910,47911,47912,47913,47914,47915,47916,47917,47918,47919,47920,47921,47922,47923,47924,47925,47926,47927,47928,47929,47930,47931,47932,47933,47934,47935,47936,47937,47938,47939,47940,47941,47942,47943,47944,47945,47946,47947,47948,47949,47950,47951,47952,47953,47954,47955,47956,47957,47958,47959,47960,47961,47962,47963,47964,47965,47966,47967,47968,47969,47970,47971,47972,47973,47974,47975,47976,47977,47978,47979,47980,47981,47982,47983,47984,47985,47986,47987,47988,47989,47990,47991,47992,47993,47994,47995,47996,47997,47998,47999,48000,48001,48002,48003,48004,48005,48006,48007,48008,48009,48010,48011,48012,48013,48014,48015,48016,48017,48018,48019,48020,48021,48022,48023,48024,48025,48026,48027,48028,48029,48030,48031,48032,48033,48034,48035,48036,48037,48038,48039,48040,48041,48042,48043,48044,48045,48046,48047,48048,48049,48050,48051,48052,48053,48054,48055,48056,48057,48058,48059,48060,48061,48062,48063,48064,48065,48066,48067,48068,48069,48070,48071,48072,48073,48074,48075,48076,48077,48078,48079,48080,48081,48082,48083,48084,48085,48086,48087,48088,48089,48090,48091,48092,48093,48094,48095,48096,48097,48098,48099,48100,48101,48102,48103,48104,48105,48106,48107,48108,48109,48110,48111,48112,48113,48114,48115,48116,48117,48118,48119,48120,48121,48122,48123,48124,48125,48126,48127,48128,48129,48130,48131,48132,48133,48134,48135,48136,48137,48138,48139,48140,48141,48142,48143,48144,48145,48146,48147,48148,48149,48150,48151,48152,48153,48154,48155,48156,48157,48158,48159,48160,48161,48162,48163,48164,48165,48166,48167,48168,48169,48170,48171,48172,48173,48174,48175,48176,48177,48178,48179,48180,48181,48182,48183,48184,48185,48186,48187,48188,48189,48190,48191,48192,48193,48194,48195,48196,48197,48198,48199,48200,48201,48202,48203,48204,48205,48206,48207,48208,48209,48210,48211,48212,48213,48214,48215,48216,48217,48218,48219,48220,48221,48222,48223,48224,48225,48226,48227,48228,48229,48230,48231,48232,48233,48234,48235,48236,48237,48238,48239,48240,48241,48242,48243,48244,48245,48246,48247,48248,48249,48250,48251,48252,48253,48254,48255,48256,48257,48258,48259,48260,48261,48262,48263,48264,48265,48266,48267,48268,48269,48270,48271,48272,48273,48274,48275,48276,48277,48278,48279,48280,48281,48282,48283,48284,48285,48286,48287,48288,48289,48290,48291,48292,48293,48294,48295,48296,48297,48298,48299,48300,48301,48302,48303,48304,48305,48306,48307,48308,48309,48310,48311,48312,48313,48314,48315,48316,48317,48318,48319,48320,48321,48322,48323,48324,48325,48326,48327,48328,48329,48330,48331,48332,48333,48334,48335,48336,48337,48338,48339,48340,48341,48342,48343,48344,48345,48346,48347,48348,48349,48350,48351,48352,48353,48354,48355,48356,48357,48358,48359,48360,48361,48362,48363,48364,48365,48366,48367,48368,48369,48370,48371,48372,48373,48374,48375,48376,48377,48378,48379,48380,48381,48382,48383,48384,48385,48386,48387,48388,48389,48390,48391,48392,48393,48394,48395,48396,48397,48398,48399,48400,48401,48402,48403,48404,48405,48406,48407,48408,48409,48410,48411,48412,48413,48414,48415,48416,48417,48418,48419,48420,48421,48422,48423,48424,48425,48426,48427,48428,48429,48430,48431,48432,48433,48434,48435,48436,48437,48438,48439,48440,48441,48442,48443,48444,48445,48446,48447,48448,48449,48450,48451,48452,48453,48454,48455,48456,48457,48458,48459,48460,48461,48462,48463,48464,48465,48466,48467,48468,48469,48470,48471,48472,48473,48474,48475,48476,48477,48478,48479,48480,48481,48482,48483,48484,48485,48486,48487,48488,48489,48490,48491,48492,48493,48494,48495,48496,48497,48498,48499,48500,48501,48502,48503,48504,48505,48506,48507,48508,48509,48510,48511,48512,48513,48514,48515,48516,48517,48518,48519,48520,48521,48522,48523,48524,48525,48526,48527,48528,48529,48530,48531,48532,48533,48534,48535,48536,48537,48538,48539,48540,48541,48542,48543,48544,48545,48546,48547,48548,48549,48550,48551,48552,48553,48554,48555,48556,48557,48558,48559,48560,48561,48562,48563,48564,48565,48566,48567,48568,48569,48570,48571,48572,48573,48574,48575,48576,48577,48578,48579,48580,48581,48582,48583,48584,48585,48586,48587,48588,48589,48590,48591,48592,48593,48594,48595,48596,48597,48598,48599,48600,48601,48602,48603,48604,48605,48606,48607,48608,48609,48610,48611,48612,48613,48614,48615,48616,48617,48618,48619,48620,48621,48622,48623,48624,48625,48626,48627,48628,48629,48630,48631,48632,48633,48634,48635,48636,48637,48638,48639,48640,48641,48642,48643,48644,48645,48646,48647,48648,48649,48650,48651,48652,48653,48654,48655,48656,48657,48658,48659,48660,48661,48662,48663,48664,48665,48666,48667,48668,48669,48670,48671,48672,48673,48674,48675,48676,48677,48678,48679,48680,48681,48682,48683,48684,48685,48686,48687,48688,48689,48690,48691,48692,48693,48694,48695,48696,48697,48698,48699,48700,48701,48702,48703,48704,48705,48706,48707,48708,48709,48710,48711,48712,48713,48714,48715,48716,48717,48718,48719,48720,48721,48722,48723,48724,48725,48726,48727,48728,48729,48730,48731,48732,48733,48734,48735,48736,48737,48738,48739,48740,48741,48742,48743,48744,48745,48746,48747,48748,48749,48750,48751,48752,48753,48754,48755,48756,48757,48758,48759,48760,48761,48762,48763,48764,48765,48766,48767,48768,48769,48770,48771,48772,48773,48774,48775,48776,48777,48778,48779,48780,48781,48782,48783,48784,48785,48786,48787,48788,48789,48790,48791,48792,48793,48794,48795,48796,48797,48798,48799,48800,48801,48802,48803,48804,48805,48806,48807,48808,48809,48810,48811,48812,48813,48814,48815,48816,48817,48818,48819,48820,48821,48822,48823,48824,48825,48826,48827,48828,48829,48830,48831,48832,48833,48834,48835,48836,48837,48838,48839,48840,48841,48842,48843,48844,48845,48846,48847,48848,48849,48850,48851,48852,48853,48854,48855,48856,48857,48858,48859,48860,48861,48862,48863,48864,48865,48866,48867,48868,48869,48870,48871,48872,48873,48874,48875,48876,48877,48878,48879,48880,48881,48882,48883,48884,48885,48886,48887,48888,48889,48890,48891,48892,48893,48894,48895,48896,48897,48898,48899,48900,48901,48902,48903,48904,48905,48906,48907,48908,48909,48910,48911,48912,48913,48914,48915,48916,48917,48918,48919,48920,48921,48922,48923,48924,48925,48926,48927,48928,48929,48930,48931,48932,48933,48934,48935,48936,48937,48938,48939,48940,48941,48942,48943,48944,48945,48946,48947,48948,48949,48950,48951,48952,48953,48954,48955,48956,48957,48958,48959,48960,48961,48962,48963,48964,48965,48966,48967,48968,48969,48970,48971,48972,48973,48974,48975,48976,48977,48978,48979,48980,48981,48982,48983,48984,48985,48986,48987,48988,48989,48990,48991,48992,48993,48994,48995,48996,48997,48998,48999,49000,49001,49002,49003,49004,49005,49006,49007,49008,49009,49010,49011,49012,49013,49014,49015,49016,49017,49018,49019,49020,49021,49022,49023,49024,49025,49026,49027,49028,49029,49030,49031,49032,49033,49034,49035,49036,49037,49038,49039,49040,49041,49042,49043,49044,49045,49046,49047,49048,49049,49050,49051,49052,49053,49054,49055,49056,49057,49058,49059,49060,49061,49062,49063,49064,49065,49066,49067,49068,49069,49070,49071,49072,49073,49074,49075,49076,49077,49078,49079,49080,49081,49082,49083,49084,49085,49086,49087,49088,49089,49090,49091,49092,49093,49094,49095,49096,49097,49098,49099,49100,49101,49102,49103,49104,49105,49106,49107,49108,49109,49110,49111,49112,49113,49114,49115,49116,49117,49118,49119,49120,49121,49122,49123,49124,49125,49126,49127,49128,49129,49130,49131,49132,49133,49134,49135,49136,49137,49138,49139,49140,49141,49142,49143,49144,49145,49146,49147,49148,49149,49150,49151,49152,49153,49154,49155,49156,49157,49158,49159,49160,49161,49162,49163,49164,49165,49166,49167,49168,49169,49170,49171,49172,49173,49174,49175,49176,49177,49178,49179,49180,49181,49182,49183,49184,49185,49186,49187,49188,49189,49190,49191,49192,49193,49194,49195,49196,49197,49198,49199,49200,49201,49202,49203,49204,49205,49206,49207,49208,49209,49210,49211,49212,49213,49214,49215,49216,49217,49218,49219,49220,49221,49222,49223,49224,49225,49226,49227,49228,49229,49230,49231,49232,49233,49234,49235,49236,49237,49238,49239,49240,49241,49242,49243,49244,49245,49246,49247,49248,49249,49250,49251,49252,49253,49254,49255,49256,49257,49258,49259,49260,49261,49262,49263,49264,49265,49266,49267,49268,49269,49270,49271,49272,49273,49274,49275,49276,49277,49278,49279,49280,49281,49282,49283,49284,49285,49286,49287,49288,49289,49290,49291,49292,49293,49294,49295,49296,49297,49298,49299,49300,49301,49302,49303,49304,49305,49306,49307,49308,49309,49310,49311,49312,49313,49314,49315,49316,49317,49318,49319,49320,49321,49322,49323,49324,49325,49326,49327,49328,49329,49330,49331,49332,49333,49334,49335,49336,49337,49338,49339,49340,49341,49342,49343,49344,49345,49346,49347,49348,49349,49350,49351,49352,49353,49354,49355,49356,49357,49358,49359,49360,49361,49362,49363,49364,49365,49366,49367,49368,49369,49370,49371,49372,49373,49374,49375,49376,49377,49378,49379,49380,49381,49382,49383,49384,49385,49386,49387,49388,49389,49390,49391,49392,49393,49394,49395,49396,49397,49398,49399,49400,49401,49402,49403,49404,49405,49406,49407,49408,49409,49410,49411,49412,49413,49414,49415,49416,49417,49418,49419,49420,49421,49422,49423,49424,49425,49426,49427,49428,49429,49430,49431,49432,49433,49434,49435,49436,49437,49438,49439,49440,49441,49442,49443,49444,49445,49446,49447,49448,49449,49450,49451,49452,49453,49454,49455,49456,49457,49458,49459,49460,49461,49462,49463,49464,49465,49466,49467,49468,49469,49470,49471,49472,49473,49474,49475,49476,49477,49478,49479,49480,49481,49482,49483,49484,49485,49486,49487,49488,49489,49490,49491,49492,49493,49494,49495,49496,49497,49498,49499,49500,49501,49502,49503,49504,49505,49506,49507,49508,49509,49510,49511,49512,49513,49514,49515,49516,49517,49518,49519,49520,49521,49522,49523,49524,49525,49526,49527,49528,49529,49530,49531,49532,49533,49534,49535,49536,49537,49538,49539,49540,49541,49542,49543,49544,49545,49546,49547,49548,49549,49550,49551,49552,49553,49554,49555,49556,49557,49558,49559,49560,49561,49562,49563,49564,49565,49566,49567,49568,49569,49570,49571,49572,49573,49574,49575,49576,49577,49578,49579,49580,49581,49582,49583,49584,49585,49586,49587,49588,49589,49590,49591,49592,49593,49594,49595,49596,49597,49598,49599,49600,49601,49602,49603,49604,49605,49606,49607,49608,49609,49610,49611,49612,49613,49614,49615,49616,49617,49618,49619,49620,49621,49622,49623,49624,49625,49626,49627,49628,49629,49630,49631,49632,49633,49634,49635,49636,49637,49638,49639,49640,49641,49642,49643,49644,49645,49646,49647,49648,49649,49650,49651,49652,49653,49654,49655,49656,49657,49658,49659,49660,49661,49662,49663,49664,49665,49666,49667,49668,49669,49670,49671,49672,49673,49674,49675,49676,49677,49678,49679,49680,49681,49682,49683,49684,49685,49686,49687,49688,49689,49690,49691,49692,49693,49694,49695,49696,49697,49698,49699,49700,49701,49702,49703,49704,49705,49706,49707,49708,49709,49710,49711,49712,49713,49714,49715,49716,49717,49718,49719,49720,49721,49722,49723,49724,49725,49726,49727,49728,49729,49730,49731,49732,49733,49734,49735,49736,49737,49738,49739,49740,49741,49742,49743,49744,49745,49746,49747,49748,49749,49750,49751,49752,49753,49754,49755,49756,49757,49758,49759,49760,49761,49762,49763,49764,49765,49766,49767,49768,49769,49770,49771,49772,49773,49774,49775,49776,49777,49778,49779,49780,49781,49782,49783,49784,49785,49786,49787,49788,49789,49790,49791,49792,49793,49794,49795,49796,49797,49798,49799,49800,49801,49802,49803,49804,49805,49806,49807,49808,49809,49810,49811,49812,49813,49814,49815,49816,49817,49818,49819,49820,49821,49822,49823,49824,49825,49826,49827,49828,49829,49830,49831,49832,49833,49834,49835,49836,49837,49838,49839,49840,49841,49842,49843,49844,49845,49846,49847,49848,49849,49850,49851,49852,49853,49854,49855,49856,49857,49858,49859,49860,49861,49862,49863,49864,49865,49866,49867,49868,49869,49870,49871,49872,49873,49874,49875,49876,49877,49878,49879,49880,49881,49882,49883,49884,49885,49886,49887,49888,49889,49890,49891,49892,49893,49894,49895,49896,49897,49898,49899,49900,49901,49902,49903,49904,49905,49906,49907,49908,49909,49910,49911,49912,49913,49914,49915,49916,49917,49918,49919,49920,49921,49922,49923,49924,49925,49926,49927,49928,49929,49930,49931,49932,49933,49934,49935,49936,49937,49938,49939,49940,49941,49942,49943,49944,49945,49946,49947,49948,49949,49950,49951,49952,49953,49954,49955,49956,49957,49958,49959,49960,49961,49962,49963,49964,49965,49966,49967,49968,49969,49970,49971,49972,49973,49974,49975,49976,49977,49978,49979,49980,49981,49982,49983,49984,49985,49986,49987,49988,49989,49990,49991,49992,49993,49994,49995,49996,49997,49998,49999,50000,50001,50002,50003,50004,50005,50006,50007,50008,50009,50010,50011,50012,50013,50014,50015,50016,50017,50018,50019,50020,50021,50022,50023,50024,50025,50026,50027,50028,50029,50030,50031,50032,50033,50034,50035,50036,50037,50038,50039,50040,50041,50042,50043,50044,50045,50046,50047,50048,50049,50050,50051,50052,50053,50054,50055,50056,50057,50058,50059,50060,50061,50062,50063,50064,50065,50066,50067,50068,50069,50070,50071,50072,50073,50074,50075,50076,50077,50078,50079,50080,50081,50082,50083,50084,50085,50086,50087,50088,50089,50090,50091,50092,50093,50094,50095,50096,50097,50098,50099,50100,50101,50102,50103,50104,50105,50106,50107,50108,50109,50110,50111,50112,50113,50114,50115,50116,50117,50118,50119,50120,50121,50122,50123,50124,50125,50126,50127,50128,50129,50130,50131,50132,50133,50134,50135,50136,50137,50138,50139,50140,50141,50142,50143,50144,50145,50146,50147,50148,50149,50150,50151,50152,50153,50154,50155,50156,50157,50158,50159,50160,50161,50162,50163,50164,50165,50166,50167,50168,50169,50170,50171,50172,50173,50174,50175,50176,50177,50178,50179,50180,50181,50182,50183,50184,50185,50186,50187,50188,50189,50190,50191,50192,50193,50194,50195,50196,50197,50198,50199,50200,50201,50202,50203,50204,50205,50206,50207,50208,50209,50210,50211,50212,50213,50214,50215,50216,50217,50218,50219,50220,50221,50222,50223,50224,50225,50226,50227,50228,50229,50230,50231,50232,50233,50234,50235,50236,50237,50238,50239,50240,50241,50242,50243,50244,50245,50246,50247,50248,50249,50250,50251,50252,50253,50254,50255,50256,50257,50258,50259,50260,50261,50262,50263,50264,50265,50266,50267,50268,50269,50270,50271,50272,50273,50274,50275,50276,50277,50278,50279,50280,50281,50282,50283,50284,50285,50286,50287,50288,50289,50290,50291,50292,50293,50294,50295,50296,50297,50298,50299,50300,50301,50302,50303,50304,50305,50306,50307,50308,50309,50310,50311,50312,50313,50314,50315,50316,50317,50318,50319,50320,50321,50322,50323,50324,50325,50326,50327,50328,50329,50330,50331,50332,50333,50334,50335,50336,50337,50338,50339,50340,50341,50342,50343,50344,50345,50346,50347,50348,50349,50350,50351,50352,50353,50354,50355,50356,50357,50358,50359,50360,50361,50362,50363,50364,50365,50366,50367,50368,50369,50370,50371,50372,50373,50374,50375,50376,50377,50378,50379,50380,50381,50382,50383,50384,50385,50386,50387,50388,50389,50390,50391,50392,50393,50394,50395,50396,50397,50398,50399,50400,50401,50402,50403,50404,50405,50406,50407,50408,50409,50410,50411,50412,50413,50414,50415,50416,50417,50418,50419,50420,50421,50422,50423,50424,50425,50426,50427,50428,50429,50430,50431,50432,50433,50434,50435,50436,50437,50438,50439,50440,50441,50442,50443,50444,50445,50446,50447,50448,50449,50450,50451,50452,50453,50454,50455,50456,50457,50458,50459,50460,50461,50462,50463,50464,50465,50466,50467,50468,50469,50470,50471,50472,50473,50474,50475,50476,50477,50478,50479,50480,50481,50482,50483,50484,50485,50486,50487,50488,50489,50490,50491,50492,50493,50494,50495,50496,50497,50498,50499,50500,50501,50502,50503,50504,50505,50506,50507,50508,50509,50510,50511,50512,50513,50514,50515,50516,50517,50518,50519,50520,50521,50522,50523,50524,50525,50526,50527,50528,50529,50530,50531,50532,50533,50534,50535,50536,50537,50538,50539,50540,50541,50542,50543,50544,50545,50546,50547,50548,50549,50550,50551,50552,50553,50554,50555,50556,50557,50558,50559,50560,50561,50562,50563,50564,50565,50566,50567,50568,50569,50570,50571,50572,50573,50574,50575,50576,50577,50578,50579,50580,50581,50582,50583,50584,50585,50586,50587,50588,50589,50590,50591,50592,50593,50594,50595,50596,50597,50598,50599,50600,50601,50602,50603,50604,50605,50606,50607,50608,50609,50610,50611,50612,50613,50614,50615,50616,50617,50618,50619,50620,50621,50622,50623,50624,50625,50626,50627,50628,50629,50630,50631,50632,50633,50634,50635,50636,50637,50638,50639,50640,50641,50642,50643,50644,50645,50646,50647,50648,50649,50650,50651,50652,50653,50654,50655,50656,50657,50658,50659,50660,50661,50662,50663,50664,50665,50666,50667,50668,50669,50670,50671,50672,50673,50674,50675,50676,50677,50678,50679,50680,50681,50682,50683,50684,50685,50686,50687,50688,50689,50690,50691,50692,50693,50694,50695,50696,50697,50698,50699,50700,50701,50702,50703,50704,50705,50706,50707,50708,50709,50710,50711,50712,50713,50714,50715,50716,50717,50718,50719,50720,50721,50722,50723,50724,50725,50726,50727,50728,50729,50730,50731,50732,50733,50734,50735,50736,50737,50738,50739,50740,50741,50742,50743,50744,50745,50746,50747,50748,50749,50750,50751,50752,50753,50754,50755,50756,50757,50758,50759,50760,50761,50762,50763,50764,50765,50766,50767,50768,50769,50770,50771,50772,50773,50774,50775,50776,50777,50778,50779,50780,50781,50782,50783,50784,50785,50786,50787,50788,50789,50790,50791,50792,50793,50794,50795,50796,50797,50798,50799,50800,50801,50802,50803,50804,50805,50806,50807,50808,50809,50810,50811,50812,50813,50814,50815,50816,50817,50818,50819,50820,50821,50822,50823,50824,50825,50826,50827,50828,50829,50830,50831,50832,50833,50834,50835,50836,50837,50838,50839,50840,50841,50842,50843,50844,50845,50846,50847,50848,50849,50850,50851,50852,50853,50854,50855,50856,50857,50858,50859,50860,50861,50862,50863,50864,50865,50866,50867,50868,50869,50870,50871,50872,50873,50874,50875,50876,50877,50878,50879,50880,50881,50882,50883,50884,50885,50886,50887,50888,50889,50890,50891,50892,50893,50894,50895,50896,50897,50898,50899,50900,50901,50902,50903,50904,50905,50906,50907,50908,50909,50910,50911,50912,50913,50914,50915,50916,50917,50918,50919,50920,50921,50922,50923,50924,50925,50926,50927,50928,50929,50930,50931,50932,50933,50934,50935,50936,50937,50938,50939,50940,50941,50942,50943,50944,50945,50946,50947,50948,50949,50950,50951,50952,50953,50954,50955,50956,50957,50958,50959,50960,50961,50962,50963,50964,50965,50966,50967,50968,50969,50970,50971,50972,50973,50974,50975,50976,50977,50978,50979,50980,50981,50982,50983,50984,50985,50986,50987,50988,50989,50990,50991,50992,50993,50994,50995,50996,50997,50998,50999,51000,51001,51002,51003,51004,51005,51006,51007,51008,51009,51010,51011,51012,51013,51014,51015,51016,51017,51018,51019,51020,51021,51022,51023,51024,51025,51026,51027,51028,51029,51030,51031,51032,51033,51034,51035,51036,51037,51038,51039,51040,51041,51042,51043,51044,51045,51046,51047,51048,51049,51050,51051,51052,51053,51054,51055,51056,51057,51058,51059,51060,51061,51062,51063,51064,51065,51066,51067,51068,51069,51070,51071,51072,51073,51074,51075,51076,51077,51078,51079,51080,51081,51082,51083,51084,51085,51086,51087,51088,51089,51090,51091,51092,51093,51094,51095,51096,51097,51098,51099,51100,51101,51102,51103,51104,51105,51106,51107,51108,51109,51110,51111,51112,51113,51114,51115,51116,51117,51118,51119,51120,51121,51122,51123,51124,51125,51126,51127,51128,51129,51130,51131,51132,51133,51134,51135,51136,51137,51138,51139,51140,51141,51142,51143,51144,51145,51146,51147,51148,51149,51150,51151,51152,51153,51154,51155,51156,51157,51158,51159,51160,51161,51162,51163,51164,51165,51166,51167,51168,51169,51170,51171,51172,51173,51174,51175,51176,51177,51178,51179,51180,51181,51182,51183,51184,51185,51186,51187,51188,51189,51190,51191,51192,51193,51194,51195,51196,51197,51198,51199,51200,51201,51202,51203,51204,51205,51206,51207,51208,51209,51210,51211,51212,51213,51214,51215,51216,51217,51218,51219,51220,51221,51222,51223,51224,51225,51226,51227,51228,51229,51230,51231,51232,51233,51234,51235,51236,51237,51238,51239,51240,51241,51242,51243,51244,51245,51246,51247,51248,51249,51250,51251,51252,51253,51254,51255,51256,51257,51258,51259,51260,51261,51262,51263,51264,51265,51266,51267,51268,51269,51270,51271,51272,51273,51274,51275,51276,51277,51278,51279,51280,51281,51282,51283,51284,51285,51286,51287,51288,51289,51290,51291,51292,51293,51294,51295,51296,51297,51298,51299,51300,51301,51302,51303,51304,51305,51306,51307,51308,51309,51310,51311,51312,51313,51314,51315,51316,51317,51318,51319,51320,51321,51322,51323,51324,51325,51326,51327,51328,51329,51330,51331,51332,51333,51334,51335,51336,51337,51338,51339,51340,51341,51342,51343,51344,51345,51346,51347,51348,51349,51350,51351,51352,51353,51354,51355,51356,51357,51358,51359,51360,51361,51362,51363,51364,51365,51366,51367,51368,51369,51370,51371,51372,51373,51374,51375,51376,51377,51378,51379,51380,51381,51382,51383,51384,51385,51386,51387,51388,51389,51390,51391,51392,51393,51394,51395,51396,51397,51398,51399,51400,51401,51402,51403,51404,51405,51406,51407,51408,51409,51410,51411,51412,51413,51414,51415,51416,51417,51418,51419,51420,51421,51422,51423,51424,51425,51426,51427,51428,51429,51430,51431,51432,51433,51434,51435,51436,51437,51438,51439,51440,51441,51442,51443,51444,51445,51446,51447,51448,51449,51450,51451,51452,51453,51454,51455,51456,51457,51458,51459,51460,51461,51462,51463,51464,51465,51466,51467,51468,51469,51470,51471,51472,51473,51474,51475,51476,51477,51478,51479,51480,51481,51482,51483,51484,51485,51486,51487,51488,51489,51490,51491,51492,51493,51494,51495,51496,51497,51498,51499,51500,51501,51502,51503,51504,51505,51506,51507,51508,51509,51510,51511,51512,51513,51514,51515,51516,51517,51518,51519,51520,51521,51522,51523,51524,51525,51526,51527,51528,51529,51530,51531,51532,51533,51534,51535,51536,51537,51538,51539,51540,51541,51542,51543,51544,51545,51546,51547,51548,51549,51550,51551,51552,51553,51554,51555,51556,51557,51558,51559,51560,51561,51562,51563,51564,51565,51566,51567,51568,51569,51570,51571,51572,51573,51574,51575,51576,51577,51578,51579,51580,51581,51582,51583,51584,51585,51586,51587,51588,51589,51590,51591,51592,51593,51594,51595,51596,51597,51598,51599,51600,51601,51602,51603,51604,51605,51606,51607,51608,51609,51610,51611,51612,51613,51614,51615,51616,51617,51618,51619,51620,51621,51622,51623,51624,51625,51626,51627,51628,51629,51630,51631,51632,51633,51634,51635,51636,51637,51638,51639,51640,51641,51642,51643,51644,51645,51646,51647,51648,51649,51650,51651,51652,51653,51654,51655,51656,51657,51658,51659,51660,51661,51662,51663,51664,51665,51666,51667,51668,51669,51670,51671,51672,51673,51674,51675,51676,51677,51678,51679,51680,51681,51682,51683,51684,51685,51686,51687,51688,51689,51690,51691,51692,51693,51694,51695,51696,51697,51698,51699,51700,51701,51702,51703,51704,51705,51706,51707,51708,51709,51710,51711,51712,51713,51714,51715,51716,51717,51718,51719,51720,51721,51722,51723,51724,51725,51726,51727,51728,51729,51730,51731,51732,51733,51734,51735,51736,51737,51738,51739,51740,51741,51742,51743,51744,51745,51746,51747,51748,51749,51750,51751,51752,51753,51754,51755,51756,51757,51758,51759,51760,51761,51762,51763,51764,51765,51766,51767,51768,51769,51770,51771,51772,51773,51774,51775,51776,51777,51778,51779,51780,51781,51782,51783,51784,51785,51786,51787,51788,51789,51790,51791,51792,51793,51794,51795,51796,51797,51798,51799,51800,51801,51802,51803,51804,51805,51806,51807,51808,51809,51810,51811,51812,51813,51814,51815,51816,51817,51818,51819,51820,51821,51822,51823,51824,51825,51826,51827,51828,51829,51830,51831,51832,51833,51834,51835,51836,51837,51838,51839,51840,51841,51842,51843,51844,51845,51846,51847,51848,51849,51850,51851,51852,51853,51854,51855,51856,51857,51858,51859,51860,51861,51862,51863,51864,51865,51866,51867,51868,51869,51870,51871,51872,51873,51874,51875,51876,51877,51878,51879,51880,51881,51882,51883,51884,51885,51886,51887,51888,51889,51890,51891,51892,51893,51894,51895,51896,51897,51898,51899,51900,51901,51902,51903,51904,51905,51906,51907,51908,51909,51910,51911,51912,51913,51914,51915,51916,51917,51918,51919,51920,51921,51922,51923,51924,51925,51926,51927,51928,51929,51930,51931,51932,51933,51934,51935,51936,51937,51938,51939,51940,51941,51942,51943,51944,51945,51946,51947,51948,51949,51950,51951,51952,51953,51954,51955,51956,51957,51958,51959,51960,51961,51962,51963,51964,51965,51966,51967,51968,51969,51970,51971,51972,51973,51974,51975,51976,51977,51978,51979,51980,51981,51982,51983,51984,51985,51986,51987,51988,51989,51990,51991,51992,51993,51994,51995,51996,51997,51998,51999,52000,52001,52002,52003,52004,52005,52006,52007,52008,52009,52010,52011,52012,52013,52014,52015,52016,52017,52018,52019,52020,52021,52022,52023,52024,52025,52026,52027,52028,52029,52030,52031,52032,52033,52034,52035,52036,52037,52038,52039,52040,52041,52042,52043,52044,52045,52046,52047,52048,52049,52050,52051,52052,52053,52054,52055,52056,52057,52058,52059,52060,52061,52062,52063,52064,52065,52066,52067,52068,52069,52070,52071,52072,52073,52074,52075,52076,52077,52078,52079,52080,52081,52082,52083,52084,52085,52086,52087,52088,52089,52090,52091,52092,52093,52094,52095,52096,52097,52098,52099,52100,52101,52102,52103,52104,52105,52106,52107,52108,52109,52110,52111,52112,52113,52114,52115,52116,52117,52118,52119,52120,52121,52122,52123,52124,52125,52126,52127,52128,52129,52130,52131,52132,52133,52134,52135,52136,52137,52138,52139,52140,52141,52142,52143,52144,52145,52146,52147,52148,52149,52150,52151,52152,52153,52154,52155,52156,52157,52158,52159,52160,52161,52162,52163,52164,52165,52166,52167,52168,52169,52170,52171,52172,52173,52174,52175,52176,52177,52178,52179,52180,52181,52182,52183,52184,52185,52186,52187,52188,52189,52190,52191,52192,52193,52194,52195,52196,52197,52198,52199,52200,52201,52202,52203,52204,52205,52206,52207,52208,52209,52210,52211,52212,52213,52214,52215,52216,52217,52218,52219,52220,52221,52222,52223,52224,52225,52226,52227,52228,52229,52230,52231,52232,52233,52234,52235,52236,52237,52238,52239,52240,52241,52242,52243,52244,52245,52246,52247,52248,52249,52250,52251,52252,52253,52254,52255,52256,52257,52258,52259,52260,52261,52262,52263,52264,52265,52266,52267,52268,52269,52270,52271,52272,52273,52274,52275,52276,52277,52278,52279,52280,52281,52282,52283,52284,52285,52286,52287,52288,52289,52290,52291,52292,52293,52294,52295,52296,52297,52298,52299,52300,52301,52302,52303,52304,52305,52306,52307,52308,52309,52310,52311,52312,52313,52314,52315,52316,52317,52318,52319,52320,52321,52322,52323,52324,52325,52326,52327,52328,52329,52330,52331,52332,52333,52334,52335,52336,52337,52338,52339,52340,52341,52342,52343,52344,52345,52346,52347,52348,52349,52350,52351,52352,52353,52354,52355,52356,52357,52358,52359,52360,52361,52362,52363,52364,52365,52366,52367,52368,52369,52370,52371,52372,52373,52374,52375,52376,52377,52378,52379,52380,52381,52382,52383,52384,52385,52386,52387,52388,52389,52390,52391,52392,52393,52394,52395,52396,52397,52398,52399,52400,52401,52402,52403,52404,52405,52406,52407,52408,52409,52410,52411,52412,52413,52414,52415,52416,52417,52418,52419,52420,52421,52422,52423,52424,52425,52426,52427,52428,52429,52430,52431,52432,52433,52434,52435,52436,52437,52438,52439,52440,52441,52442,52443,52444,52445,52446,52447,52448,52449,52450,52451,52452,52453,52454,52455,52456,52457,52458,52459,52460,52461,52462,52463,52464,52465,52466,52467,52468,52469,52470,52471,52472,52473,52474,52475,52476,52477,52478,52479,52480,52481,52482,52483,52484,52485,52486,52487,52488,52489,52490,52491,52492,52493,52494,52495,52496,52497,52498,52499,52500,52501,52502,52503,52504,52505,52506,52507,52508,52509,52510,52511,52512,52513,52514,52515,52516,52517,52518,52519,52520,52521,52522,52523,52524,52525,52526,52527,52528,52529,52530,52531,52532,52533,52534,52535,52536,52537,52538,52539,52540,52541,52542,52543,52544,52545,52546,52547,52548,52549,52550,52551,52552,52553,52554,52555,52556,52557,52558,52559,52560,52561,52562,52563,52564,52565,52566,52567,52568,52569,52570,52571,52572,52573,52574,52575,52576,52577,52578,52579,52580,52581,52582,52583,52584,52585,52586,52587,52588,52589,52590,52591,52592,52593,52594,52595,52596,52597,52598,52599,52600,52601,52602,52603,52604,52605,52606,52607,52608,52609,52610,52611,52612,52613,52614,52615,52616,52617,52618,52619,52620,52621,52622,52623,52624,52625,52626,52627,52628,52629,52630,52631,52632,52633,52634,52635,52636,52637,52638,52639,52640,52641,52642,52643,52644,52645,52646,52647,52648,52649,52650,52651,52652,52653,52654,52655,52656,52657,52658,52659,52660,52661,52662,52663,52664,52665,52666,52667,52668,52669,52670,52671,52672,52673,52674,52675,52676,52677,52678,52679,52680,52681,52682,52683,52684,52685,52686,52687,52688,52689,52690,52691,52692,52693,52694,52695,52696,52697,52698,52699,52700,52701,52702,52703,52704,52705,52706,52707,52708,52709,52710,52711,52712,52713,52714,52715,52716,52717,52718,52719,52720,52721,52722,52723,52724,52725,52726,52727,52728,52729,52730,52731,52732,52733,52734,52735,52736,52737,52738,52739,52740,52741,52742,52743,52744,52745,52746,52747,52748,52749,52750,52751,52752,52753,52754,52755,52756,52757,52758,52759,52760,52761,52762,52763,52764,52765,52766,52767,52768,52769,52770,52771,52772,52773,52774,52775,52776,52777,52778,52779,52780,52781,52782,52783,52784,52785,52786,52787,52788,52789,52790,52791,52792,52793,52794,52795,52796,52797,52798,52799,52800,52801,52802,52803,52804,52805,52806,52807,52808,52809,52810,52811,52812,52813,52814,52815,52816,52817,52818,52819,52820,52821,52822,52823,52824,52825,52826,52827,52828,52829,52830,52831,52832,52833,52834,52835,52836,52837,52838,52839,52840,52841,52842,52843,52844,52845,52846,52847,52848,52849,52850,52851,52852,52853,52854,52855,52856,52857,52858,52859,52860,52861,52862,52863,52864,52865,52866,52867,52868,52869,52870,52871,52872,52873,52874,52875,52876,52877,52878,52879,52880,52881,52882,52883,52884,52885,52886,52887,52888,52889,52890,52891,52892,52893,52894,52895,52896,52897,52898,52899,52900,52901,52902,52903,52904,52905,52906,52907,52908,52909,52910,52911,52912,52913,52914,52915,52916,52917,52918,52919,52920,52921,52922,52923,52924,52925,52926,52927,52928,52929,52930,52931,52932,52933,52934,52935,52936,52937,52938,52939,52940,52941,52942,52943,52944,52945,52946,52947,52948,52949,52950,52951,52952,52953,52954,52955,52956,52957,52958,52959,52960,52961,52962,52963,52964,52965,52966,52967,52968,52969,52970,52971,52972,52973,52974,52975,52976,52977,52978,52979,52980,52981,52982,52983,52984,52985,52986,52987,52988,52989,52990,52991,52992,52993,52994,52995,52996,52997,52998,52999,53000,53001,53002,53003,53004,53005,53006,53007,53008,53009,53010,53011,53012,53013,53014,53015,53016,53017,53018,53019,53020,53021,53022,53023,53024,53025,53026,53027,53028,53029,53030,53031,53032,53033,53034,53035,53036,53037,53038,53039,53040,53041,53042,53043,53044,53045,53046,53047,53048,53049,53050,53051,53052,53053,53054,53055,53056,53057,53058,53059,53060,53061,53062,53063,53064,53065,53066,53067,53068,53069,53070,53071,53072,53073,53074,53075,53076,53077,53078,53079,53080,53081,53082,53083,53084,53085,53086,53087,53088,53089,53090,53091,53092,53093,53094,53095,53096,53097,53098,53099,53100,53101,53102,53103,53104,53105,53106,53107,53108,53109,53110,53111,53112,53113,53114,53115,53116,53117,53118,53119,53120,53121,53122,53123,53124,53125,53126,53127,53128,53129,53130,53131,53132,53133,53134,53135,53136,53137,53138,53139,53140,53141,53142,53143,53144,53145,53146,53147,53148,53149,53150,53151,53152,53153,53154,53155,53156,53157,53158,53159,53160,53161,53162,53163,53164,53165,53166,53167,53168,53169,53170,53171,53172,53173,53174,53175,53176,53177,53178,53179,53180,53181,53182,53183,53184,53185,53186,53187,53188,53189,53190,53191,53192,53193,53194,53195,53196,53197,53198,53199,53200,53201,53202,53203,53204,53205,53206,53207,53208,53209,53210,53211,53212,53213,53214,53215,53216,53217,53218,53219,53220,53221,53222,53223,53224,53225,53226,53227,53228,53229,53230,53231,53232,53233,53234,53235,53236,53237,53238,53239,53240,53241,53242,53243,53244,53245,53246,53247,53248,53249,53250,53251,53252,53253,53254,53255,53256,53257,53258,53259,53260,53261,53262,53263,53264,53265,53266,53267,53268,53269,53270,53271,53272,53273,53274,53275,53276,53277,53278,53279,53280,53281,53282,53283,53284,53285,53286,53287,53288,53289,53290,53291,53292,53293,53294,53295,53296,53297,53298,53299,53300,53301,53302,53303,53304,53305,53306,53307,53308,53309,53310,53311,53312,53313,53314,53315,53316,53317,53318,53319,53320,53321,53322,53323,53324,53325,53326,53327,53328,53329,53330,53331,53332,53333,53334,53335,53336,53337,53338,53339,53340,53341,53342,53343,53344,53345,53346,53347,53348,53349,53350,53351,53352,53353,53354,53355,53356,53357,53358,53359,53360,53361,53362,53363,53364,53365,53366,53367,53368,53369,53370,53371,53372,53373,53374,53375,53376,53377,53378,53379,53380,53381,53382,53383,53384,53385,53386,53387,53388,53389,53390,53391,53392,53393,53394,53395,53396,53397,53398,53399,53400,53401,53402,53403,53404,53405,53406,53407,53408,53409,53410,53411,53412,53413,53414,53415,53416,53417,53418,53419,53420,53421,53422,53423,53424,53425,53426,53427,53428,53429,53430,53431,53432,53433,53434,53435,53436,53437,53438,53439,53440,53441,53442,53443,53444,53445,53446,53447,53448,53449,53450,53451,53452,53453,53454,53455,53456,53457,53458,53459,53460,53461,53462,53463,53464,53465,53466,53467,53468,53469,53470,53471,53472,53473,53474,53475,53476,53477,53478,53479,53480,53481,53482,53483,53484,53485,53486,53487,53488,53489,53490,53491,53492,53493,53494,53495,53496,53497,53498,53499,53500,53501,53502,53503,53504,53505,53506,53507,53508,53509,53510,53511,53512,53513,53514,53515,53516,53517,53518,53519,53520,53521,53522,53523,53524,53525,53526,53527,53528,53529,53530,53531,53532,53533,53534,53535,53536,53537,53538,53539,53540,53541,53542,53543,53544,53545,53546,53547,53548,53549,53550,53551,53552,53553,53554,53555,53556,53557,53558,53559,53560,53561,53562,53563,53564,53565,53566,53567,53568,53569,53570,53571,53572,53573,53574,53575,53576,53577,53578,53579,53580,53581,53582,53583,53584,53585,53586,53587,53588,53589,53590,53591,53592,53593,53594,53595,53596,53597,53598,53599,53600,53601,53602,53603,53604,53605,53606,53607,53608,53609,53610,53611,53612,53613,53614,53615,53616,53617,53618,53619,53620,53621,53622,53623,53624,53625,53626,53627,53628,53629,53630,53631,53632,53633,53634,53635,53636,53637,53638,53639,53640,53641,53642,53643,53644,53645,53646,53647,53648,53649,53650,53651,53652,53653,53654,53655,53656,53657,53658,53659,53660,53661,53662,53663,53664,53665,53666,53667,53668,53669,53670,53671,53672,53673,53674,53675,53676,53677,53678,53679,53680,53681,53682,53683,53684,53685,53686,53687,53688,53689,53690,53691,53692,53693,53694,53695,53696,53697,53698,53699,53700,53701,53702,53703,53704,53705,53706,53707,53708,53709,53710,53711,53712,53713,53714,53715,53716,53717,53718,53719,53720,53721,53722,53723,53724,53725,53726,53727,53728,53729,53730,53731,53732,53733,53734,53735,53736,53737,53738,53739,53740,53741,53742,53743,53744,53745,53746,53747,53748,53749,53750,53751,53752,53753,53754,53755,53756,53757,53758,53759,53760,53761,53762,53763,53764,53765,53766,53767,53768,53769,53770,53771,53772,53773,53774,53775,53776,53777,53778,53779,53780,53781,53782,53783,53784,53785,53786,53787,53788,53789,53790,53791,53792,53793,53794,53795,53796,53797,53798,53799,53800,53801,53802,53803,53804,53805,53806,53807,53808,53809,53810,53811,53812,53813,53814,53815,53816,53817,53818,53819,53820,53821,53822,53823,53824,53825,53826,53827,53828,53829,53830,53831,53832,53833,53834,53835,53836,53837,53838,53839,53840,53841,53842,53843,53844,53845,53846,53847,53848,53849,53850,53851,53852,53853,53854,53855,53856,53857,53858,53859,53860,53861,53862,53863,53864,53865,53866,53867,53868,53869,53870,53871,53872,53873,53874,53875,53876,53877,53878,53879,53880,53881,53882,53883,53884,53885,53886,53887,53888,53889,53890,53891,53892,53893,53894,53895,53896,53897,53898,53899,53900,53901,53902,53903,53904,53905,53906,53907,53908,53909,53910,53911,53912,53913,53914,53915,53916,53917,53918,53919,53920,53921,53922,53923,53924,53925,53926,53927,53928,53929,53930,53931,53932,53933,53934,53935,53936,53937,53938,53939,53940,53941,53942,53943,53944,53945,53946,53947,53948,53949,53950,53951,53952,53953,53954,53955,53956,53957,53958,53959,53960,53961,53962,53963,53964,53965,53966,53967,53968,53969,53970,53971,53972,53973,53974,53975,53976,53977,53978,53979,53980,53981,53982,53983,53984,53985,53986,53987,53988,53989,53990,53991,53992,53993,53994,53995,53996,53997,53998,53999,54000,54001,54002,54003,54004,54005,54006,54007,54008,54009,54010,54011,54012,54013,54014,54015,54016,54017,54018,54019,54020,54021,54022,54023,54024,54025,54026,54027,54028,54029,54030,54031,54032,54033,54034,54035,54036,54037,54038,54039,54040,54041,54042,54043,54044,54045,54046,54047,54048,54049,54050,54051,54052,54053,54054,54055,54056,54057,54058,54059,54060,54061,54062,54063,54064,54065,54066,54067,54068,54069,54070,54071,54072,54073,54074,54075,54076,54077,54078,54079,54080,54081,54082,54083,54084,54085,54086,54087,54088,54089,54090,54091,54092,54093,54094,54095,54096,54097,54098,54099,54100,54101,54102,54103,54104,54105,54106,54107,54108,54109,54110,54111,54112,54113,54114,54115,54116,54117,54118,54119,54120,54121,54122,54123,54124,54125,54126,54127,54128,54129,54130,54131,54132,54133,54134,54135,54136,54137,54138,54139,54140,54141,54142,54143,54144,54145,54146,54147,54148,54149,54150,54151,54152,54153,54154,54155,54156,54157,54158,54159,54160,54161,54162,54163,54164,54165,54166,54167,54168,54169,54170,54171,54172,54173,54174,54175,54176,54177,54178,54179,54180,54181,54182,54183,54184,54185,54186,54187,54188,54189,54190,54191,54192,54193,54194,54195,54196,54197,54198,54199,54200,54201,54202,54203,54204,54205,54206,54207,54208,54209,54210,54211,54212,54213,54214,54215,54216,54217,54218,54219,54220,54221,54222,54223,54224,54225,54226,54227,54228,54229,54230,54231,54232,54233,54234,54235,54236,54237,54238,54239,54240,54241,54242,54243,54244,54245,54246,54247,54248,54249,54250,54251,54252,54253,54254,54255,54256,54257,54258,54259,54260,54261,54262,54263,54264,54265,54266,54267,54268,54269,54270,54271,54272,54273,54274,54275,54276,54277,54278,54279,54280,54281,54282,54283,54284,54285,54286,54287,54288,54289,54290,54291,54292,54293,54294,54295,54296,54297,54298,54299,54300,54301,54302,54303,54304,54305,54306,54307,54308,54309,54310,54311,54312,54313,54314,54315,54316,54317,54318,54319,54320,54321,54322,54323,54324,54325,54326,54327,54328,54329,54330,54331,54332,54333,54334,54335,54336,54337,54338,54339,54340,54341,54342,54343,54344,54345,54346,54347,54348,54349,54350,54351,54352,54353,54354,54355,54356,54357,54358,54359,54360,54361,54362,54363,54364,54365,54366,54367,54368,54369,54370,54371,54372,54373,54374,54375,54376,54377,54378,54379,54380,54381,54382,54383,54384,54385,54386,54387,54388,54389,54390,54391,54392,54393,54394,54395,54396,54397,54398,54399,54400,54401,54402,54403,54404,54405,54406,54407,54408,54409,54410,54411,54412,54413,54414,54415,54416,54417,54418,54419,54420,54421,54422,54423,54424,54425,54426,54427,54428,54429,54430,54431,54432,54433,54434,54435,54436,54437,54438,54439,54440,54441,54442,54443,54444,54445,54446,54447,54448,54449,54450,54451,54452,54453,54454,54455,54456,54457,54458,54459,54460,54461,54462,54463,54464,54465,54466,54467,54468,54469,54470,54471,54472,54473,54474,54475,54476,54477,54478,54479,54480,54481,54482,54483,54484,54485,54486,54487,54488,54489,54490,54491,54492,54493,54494,54495,54496,54497,54498,54499,54500,54501,54502,54503,54504,54505,54506,54507,54508,54509,54510,54511,54512,54513,54514,54515,54516,54517,54518,54519,54520,54521,54522,54523,54524,54525,54526,54527,54528,54529,54530,54531,54532,54533,54534,54535,54536,54537,54538,54539,54540,54541,54542,54543,54544,54545,54546,54547,54548,54549,54550,54551,54552,54553,54554,54555,54556,54557,54558,54559,54560,54561,54562,54563,54564,54565,54566,54567,54568,54569,54570,54571,54572,54573,54574,54575,54576,54577,54578,54579,54580,54581,54582,54583,54584,54585,54586,54587,54588,54589,54590,54591,54592,54593,54594,54595,54596,54597,54598,54599,54600,54601,54602,54603,54604,54605,54606,54607,54608,54609,54610,54611,54612,54613,54614,54615,54616,54617,54618,54619,54620,54621,54622,54623,54624,54625,54626,54627,54628,54629,54630,54631,54632,54633,54634,54635,54636,54637,54638,54639,54640,54641,54642,54643,54644,54645,54646,54647,54648,54649,54650,54651,54652,54653,54654,54655,54656,54657,54658,54659,54660,54661,54662,54663,54664,54665,54666,54667,54668,54669,54670,54671,54672,54673,54674,54675,54676,54677,54678,54679,54680,54681,54682,54683,54684,54685,54686,54687,54688,54689,54690,54691,54692,54693,54694,54695,54696,54697,54698,54699,54700,54701,54702,54703,54704,54705,54706,54707,54708,54709,54710,54711,54712,54713,54714,54715,54716,54717,54718,54719,54720,54721,54722,54723,54724,54725,54726,54727,54728,54729,54730,54731,54732,54733,54734,54735,54736,54737,54738,54739,54740,54741,54742,54743,54744,54745,54746,54747,54748,54749,54750,54751,54752,54753,54754,54755,54756,54757,54758,54759,54760,54761,54762,54763,54764,54765,54766,54767,54768,54769,54770,54771,54772,54773,54774,54775,54776,54777,54778,54779,54780,54781,54782,54783,54784,54785,54786,54787,54788,54789,54790,54791,54792,54793,54794,54795,54796,54797,54798,54799,54800,54801,54802,54803,54804,54805,54806,54807,54808,54809,54810,54811,54812,54813,54814,54815,54816,54817,54818,54819,54820,54821,54822,54823,54824,54825,54826,54827,54828,54829,54830,54831,54832,54833,54834,54835,54836,54837,54838,54839,54840,54841,54842,54843,54844,54845,54846,54847,54848,54849,54850,54851,54852,54853,54854,54855,54856,54857,54858,54859,54860,54861,54862,54863,54864,54865,54866,54867,54868,54869,54870,54871,54872,54873,54874,54875,54876,54877,54878,54879,54880,54881,54882,54883,54884,54885,54886,54887,54888,54889,54890,54891,54892,54893,54894,54895,54896,54897,54898,54899,54900,54901,54902,54903,54904,54905,54906,54907,54908,54909,54910,54911,54912,54913,54914,54915,54916,54917,54918,54919,54920,54921,54922,54923,54924,54925,54926,54927,54928,54929,54930,54931,54932,54933,54934,54935,54936,54937,54938,54939,54940,54941,54942,54943,54944,54945,54946,54947,54948,54949,54950,54951,54952,54953,54954,54955,54956,54957,54958,54959,54960,54961,54962,54963,54964,54965,54966,54967,54968,54969,54970,54971,54972,54973,54974,54975,54976,54977,54978,54979,54980,54981,54982,54983,54984,54985,54986,54987,54988,54989,54990,54991,54992,54993,54994,54995,54996,54997,54998,54999,55000,55001,55002,55003,55004,55005,55006,55007,55008,55009,55010,55011,55012,55013,55014,55015,55016,55017,55018,55019,55020,55021,55022,55023,55024,55025,55026,55027,55028,55029,55030,55031,55032,55033,55034,55035,55036,55037,55038,55039,55040,55041,55042,55043,55044,55045,55046,55047,55048,55049,55050,55051,55052,55053,55054,55055,55056,55057,55058,55059,55060,55061,55062,55063,55064,55065,55066,55067,55068,55069,55070,55071,55072,55073,55074,55075,55076,55077,55078,55079,55080,55081,55082,55083,55084,55085,55086,55087,55088,55089,55090,55091,55092,55093,55094,55095,55096,55097,55098,55099,55100,55101,55102,55103,55104,55105,55106,55107,55108,55109,55110,55111,55112,55113,55114,55115,55116,55117,55118,55119,55120,55121,55122,55123,55124,55125,55126,55127,55128,55129,55130,55131,55132,55133,55134,55135,55136,55137,55138,55139,55140,55141,55142,55143,55144,55145,55146,55147,55148,55149,55150,55151,55152,55153,55154,55155,55156,55157,55158,55159,55160,55161,55162,55163,55164,55165,55166,55167,55168,55169,55170,55171,55172,55173,55174,55175,55176,55177,55178,55179,55180,55181,55182,55183,55184,55185,55186,55187,55188,55189,55190,55191,55192,55193,55194,55195,55196,55197,55198,55199,55200,55201,55202,55203,55216,55217,55218,55219,55220,55221,55222,55223,55224,55225,55226,55227,55228,55229,55230,55231,55232,55233,55234,55235,55236,55237,55238,55243,55244,55245,55246,55247,55248,55249,55250,55251,55252,55253,55254,55255,55256,55257,55258,55259,55260,55261,55262,55263,55264,55265,55266,55267,55268,55269,55270,55271,55272,55273,55274,55275,55276,55277,55278,55279,55280,55281,55282,55283,55284,55285,55286,55287,55288,55289,55290,55291,63744,63745,63746,63747,63748,63749,63750,63751,63752,63753,63754,63755,63756,63757,63758,63759,63760,63761,63762,63763,63764,63765,63766,63767,63768,63769,63770,63771,63772,63773,63774,63775,63776,63777,63778,63779,63780,63781,63782,63783,63784,63785,63786,63787,63788,63789,63790,63791,63792,63793,63794,63795,63796,63797,63798,63799,63800,63801,63802,63803,63804,63805,63806,63807,63808,63809,63810,63811,63812,63813,63814,63815,63816,63817,63818,63819,63820,63821,63822,63823,63824,63825,63826,63827,63828,63829,63830,63831,63832,63833,63834,63835,63836,63837,63838,63839,63840,63841,63842,63843,63844,63845,63846,63847,63848,63849,63850,63851,63852,63853,63854,63855,63856,63857,63858,63859,63860,63861,63862,63863,63864,63865,63866,63867,63868,63869,63870,63871,63872,63873,63874,63875,63876,63877,63878,63879,63880,63881,63882,63883,63884,63885,63886,63887,63888,63889,63890,63891,63892,63893,63894,63895,63896,63897,63898,63899,63900,63901,63902,63903,63904,63905,63906,63907,63908,63909,63910,63911,63912,63913,63914,63915,63916,63917,63918,63919,63920,63921,63922,63923,63924,63925,63926,63927,63928,63929,63930,63931,63932,63933,63934,63935,63936,63937,63938,63939,63940,63941,63942,63943,63944,63945,63946,63947,63948,63949,63950,63951,63952,63953,63954,63955,63956,63957,63958,63959,63960,63961,63962,63963,63964,63965,63966,63967,63968,63969,63970,63971,63972,63973,63974,63975,63976,63977,63978,63979,63980,63981,63982,63983,63984,63985,63986,63987,63988,63989,63990,63991,63992,63993,63994,63995,63996,63997,63998,63999,64000,64001,64002,64003,64004,64005,64006,64007,64008,64009,64010,64011,64012,64013,64014,64015,64016,64017,64018,64019,64020,64021,64022,64023,64024,64025,64026,64027,64028,64029,64030,64031,64032,64033,64034,64035,64036,64037,64038,64039,64040,64041,64042,64043,64044,64045,64046,64047,64048,64049,64050,64051,64052,64053,64054,64055,64056,64057,64058,64059,64060,64061,64062,64063,64064,64065,64066,64067,64068,64069,64070,64071,64072,64073,64074,64075,64076,64077,64078,64079,64080,64081,64082,64083,64084,64085,64086,64087,64088,64089,64090,64091,64092,64093,64094,64095,64096,64097,64098,64099,64100,64101,64102,64103,64104,64105,64106,64107,64108,64109,64112,64113,64114,64115,64116,64117,64118,64119,64120,64121,64122,64123,64124,64125,64126,64127,64128,64129,64130,64131,64132,64133,64134,64135,64136,64137,64138,64139,64140,64141,64142,64143,64144,64145,64146,64147,64148,64149,64150,64151,64152,64153,64154,64155,64156,64157,64158,64159,64160,64161,64162,64163,64164,64165,64166,64167,64168,64169,64170,64171,64172,64173,64174,64175,64176,64177,64178,64179,64180,64181,64182,64183,64184,64185,64186,64187,64188,64189,64190,64191,64192,64193,64194,64195,64196,64197,64198,64199,64200,64201,64202,64203,64204,64205,64206,64207,64208,64209,64210,64211,64212,64213,64214,64215,64216,64217,64256,64257,64258,64259,64260,64261,64262,64275,64276,64277,64278,64279,64285,64287,64288,64289,64290,64291,64292,64293,64294,64295,64296,64298,64299,64300,64301,64302,64303,64304,64305,64306,64307,64308,64309,64310,64312,64313,64314,64315,64316,64318,64320,64321,64323,64324,64326,64327,64328,64329,64330,64331,64332,64333,64334,64335,64336,64337,64338,64339,64340,64341,64342,64343,64344,64345,64346,64347,64348,64349,64350,64351,64352,64353,64354,64355,64356,64357,64358,64359,64360,64361,64362,64363,64364,64365,64366,64367,64368,64369,64370,64371,64372,64373,64374,64375,64376,64377,64378,64379,64380,64381,64382,64383,64384,64385,64386,64387,64388,64389,64390,64391,64392,64393,64394,64395,64396,64397,64398,64399,64400,64401,64402,64403,64404,64405,64406,64407,64408,64409,64410,64411,64412,64413,64414,64415,64416,64417,64418,64419,64420,64421,64422,64423,64424,64425,64426,64427,64428,64429,64430,64431,64432,64433,64467,64468,64469,64470,64471,64472,64473,64474,64475,64476,64477,64478,64479,64480,64481,64482,64483,64484,64485,64486,64487,64488,64489,64490,64491,64492,64493,64494,64495,64496,64497,64498,64499,64500,64501,64502,64503,64504,64505,64506,64507,64508,64509,64510,64511,64512,64513,64514,64515,64516,64517,64518,64519,64520,64521,64522,64523,64524,64525,64526,64527,64528,64529,64530,64531,64532,64533,64534,64535,64536,64537,64538,64539,64540,64541,64542,64543,64544,64545,64546,64547,64548,64549,64550,64551,64552,64553,64554,64555,64556,64557,64558,64559,64560,64561,64562,64563,64564,64565,64566,64567,64568,64569,64570,64571,64572,64573,64574,64575,64576,64577,64578,64579,64580,64581,64582,64583,64584,64585,64586,64587,64588,64589,64590,64591,64592,64593,64594,64595,64596,64597,64598,64599,64600,64601,64602,64603,64604,64605,64606,64607,64608,64609,64610,64611,64612,64613,64614,64615,64616,64617,64618,64619,64620,64621,64622,64623,64624,64625,64626,64627,64628,64629,64630,64631,64632,64633,64634,64635,64636,64637,64638,64639,64640,64641,64642,64643,64644,64645,64646,64647,64648,64649,64650,64651,64652,64653,64654,64655,64656,64657,64658,64659,64660,64661,64662,64663,64664,64665,64666,64667,64668,64669,64670,64671,64672,64673,64674,64675,64676,64677,64678,64679,64680,64681,64682,64683,64684,64685,64686,64687,64688,64689,64690,64691,64692,64693,64694,64695,64696,64697,64698,64699,64700,64701,64702,64703,64704,64705,64706,64707,64708,64709,64710,64711,64712,64713,64714,64715,64716,64717,64718,64719,64720,64721,64722,64723,64724,64725,64726,64727,64728,64729,64730,64731,64732,64733,64734,64735,64736,64737,64738,64739,64740,64741,64742,64743,64744,64745,64746,64747,64748,64749,64750,64751,64752,64753,64754,64755,64756,64757,64758,64759,64760,64761,64762,64763,64764,64765,64766,64767,64768,64769,64770,64771,64772,64773,64774,64775,64776,64777,64778,64779,64780,64781,64782,64783,64784,64785,64786,64787,64788,64789,64790,64791,64792,64793,64794,64795,64796,64797,64798,64799,64800,64801,64802,64803,64804,64805,64806,64807,64808,64809,64810,64811,64812,64813,64814,64815,64816,64817,64818,64819,64820,64821,64822,64823,64824,64825,64826,64827,64828,64829,64848,64849,64850,64851,64852,64853,64854,64855,64856,64857,64858,64859,64860,64861,64862,64863,64864,64865,64866,64867,64868,64869,64870,64871,64872,64873,64874,64875,64876,64877,64878,64879,64880,64881,64882,64883,64884,64885,64886,64887,64888,64889,64890,64891,64892,64893,64894,64895,64896,64897,64898,64899,64900,64901,64902,64903,64904,64905,64906,64907,64908,64909,64910,64911,64914,64915,64916,64917,64918,64919,64920,64921,64922,64923,64924,64925,64926,64927,64928,64929,64930,64931,64932,64933,64934,64935,64936,64937,64938,64939,64940,64941,64942,64943,64944,64945,64946,64947,64948,64949,64950,64951,64952,64953,64954,64955,64956,64957,64958,64959,64960,64961,64962,64963,64964,64965,64966,64967,65008,65009,65010,65011,65012,65013,65014,65015,65016,65017,65018,65019,65136,65137,65138,65139,65140,65142,65143,65144,65145,65146,65147,65148,65149,65150,65151,65152,65153,65154,65155,65156,65157,65158,65159,65160,65161,65162,65163,65164,65165,65166,65167,65168,65169,65170,65171,65172,65173,65174,65175,65176,65177,65178,65179,65180,65181,65182,65183,65184,65185,65186,65187,65188,65189,65190,65191,65192,65193,65194,65195,65196,65197,65198,65199,65200,65201,65202,65203,65204,65205,65206,65207,65208,65209,65210,65211,65212,65213,65214,65215,65216,65217,65218,65219,65220,65221,65222,65223,65224,65225,65226,65227,65228,65229,65230,65231,65232,65233,65234,65235,65236,65237,65238,65239,65240,65241,65242,65243,65244,65245,65246,65247,65248,65249,65250,65251,65252,65253,65254,65255,65256,65257,65258,65259,65260,65261,65262,65263,65264,65265,65266,65267,65268,65269,65270,65271,65272,65273,65274,65275,65276,65313,65314,65315,65316,65317,65318,65319,65320,65321,65322,65323,65324,65325,65326,65327,65328,65329,65330,65331,65332,65333,65334,65335,65336,65337,65338,65345,65346,65347,65348,65349,65350,65351,65352,65353,65354,65355,65356,65357,65358,65359,65360,65361,65362,65363,65364,65365,65366,65367,65368,65369,65370,65382,65383,65384,65385,65386,65387,65388,65389,65390,65391,65392,65393,65394,65395,65396,65397,65398,65399,65400,65401,65402,65403,65404,65405,65406,65407,65408,65409,65410,65411,65412,65413,65414,65415,65416,65417,65418,65419,65420,65421,65422,65423,65424,65425,65426,65427,65428,65429,65430,65431,65432,65433,65434,65435,65436,65437,65438,65439,65440,65441,65442,65443,65444,65445,65446,65447,65448,65449,65450,65451,65452,65453,65454,65455,65456,65457,65458,65459,65460,65461,65462,65463,65464,65465,65466,65467,65468,65469,65470,65474,65475,65476,65477,65478,65479,65482,65483,65484,65485,65486,65487,65490,65491,65492,65493,65494,65495,65498,65499,65500",i=r.split(",").map(function(e){return parseInt(e,10)});t.exports=i},{}],"/../../jshint/node_modules/console-browserify/index.js":[function(e,t,n){(function(n){function d(){}function v(){u.log.apply(u,arguments)}function m(){u.log.apply(u,arguments)}function g(){u.warn.apply(u,arguments)}function y(e){a[e]=s()}function b(e){var t=a[e];if(!t)throw new Error("No such label: "+e);var n=s()-t;u.log(e+": "+n+"ms")}function w(){var e=new Error;e.name="Trace",e.message=r.format.apply(null,arguments),u.error(e.stack)}function E(e){u.log(r.inspect(e)+"\n")}function S(e){if(!e){var t=o.call(arguments,1);i.ok(!1,r.format.apply(null,t))}}var r=e("util"),i=e("assert"),s=e("date-now"),o=Array.prototype.slice,u,a={};typeof n!="undefined"&&n.console?u=n.console:typeof window!="undefined"&&window.console?u=window.console:u={};var f=[[d,"log"],[v,"info"],[m,"warn"],[g,"error"],[y,"time"],[b,"timeEnd"],[w,"trace"],[E,"dir"],[S,"assert"]];for(var l=0;l<f.length;l++){var c=f[l],h=c[0],p=c[1];u[p]||(u[p]=h)}t.exports=u}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{assert:"/../node_modules/assert/assert.js","date-now":"/../../jshint/node_modules/date-now/index.js",util:"/../node_modules/util/util.js"}],"/../../jshint/node_modules/date-now/index.js":[function(e,t,n){function r(){return(new Date).getTime()}t.exports=r},{}],"/../../jshint/node_modules/lodash.clone/index.js":[function(e,t,n){(function(e){function W(e,t){return e.set(t[0],t[1]),e}function X(e,t){return e.add(t),e}function V(e,t){var n=-1,r=e?e.length:0;while(++n<r)if(t(e[n],n,e)===!1)break;return e}function $(e,t){var n=-1,r=t.length,i=e.length;while(++n<r)e[i+n]=t[n];return e}function J(e,t,n,r){var i=-1,s=e?e.length:0;r&&s&&(n=e[++i]);while(++i<s)n=t(n,e[i],i,e);return n}function K(e,t){var n=-1,r=Array(e);while(++n<e)r[n]=t(n);return r}function Q(e,t){return e==null?undefined:e[t]}function G(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch(n){}return t}function Y(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function Z(e,t){return function(n){return e(t(n))}}function et(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}function Dt(e){var t=-1,n=e?e.length:0;this.clear();while(++t<n){var r=e[t];this.set(r[0],r[1])}}function Pt(){this.__data__=Nt?Nt(null):{}}function Ht(e){return this.has(e)&&delete this.__data__[e]}function Bt(e){var t=this.__data__;if(Nt){var n=t[e];return n===i?undefined:n}return ut.call(t,e)?t[e]:undefined}function jt(e){var t=this.__data__;return Nt?t[e]!==undefined:ut.call(t,e)}function Ft(e,t){var n=this.__data__;return n[e]=Nt&&t===undefined?i:t,this}function It(e){var t=-1,n=e?e.length:0;this.clear();while(++t<n){var r=e[t];this.set(r[0],r[1])}}function qt(){this.__data__=[]}function Rt(e){var t=this.__data__,n=on(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():mt.call(t,n,1),!0}function Ut(e){var t=this.__data__,n=on(t,e);return n<0?undefined:t[n][1]}function zt(e){return on(this.__data__,e)>-1}function Wt(e,t){var n=this.__data__,r=on(n,e);return r<0?n.push([e,t]):n[r][1]=t,this}function Xt(e){var t=-1,n=e?e.length:0;this.clear();while(++t<n){var r=e[t];this.set(r[0],r[1])}}function Vt(){this.__data__={hash:new Dt,map:new(Et||It),string:new Dt}}function $t(e){return Cn(this,e)["delete"](e)}function Jt(e){return Cn(this,e).get(e)}function Kt(e){return Cn(this,e).has(e)}function Qt(e,t){return Cn(this,e).set(e,t),this}function Gt(e){this.__data__=new It(e)}function Yt(){this.__data__=new It}function Zt(e){return this.__data__["delete"](e)}function en(e){return this.__data__.get(e)}function tn(e){return this.__data__.has(e)}function nn(e,t){var n=this.__data__;if(n instanceof It){var i=n.__data__;if(!Et||i.length<r-1)return i.push([e,t]),this;n=this.__data__=new Xt(i)}return n.set(e,t),this}function rn(e,t){var n=Rn(e)||qn(e)?K(e.length,String):[],r=n.length,i=!!r;for(var s in e)(t||ut.call(e,s))&&(!i||s!="length"&&!Dn(s,r))&&n.push(s);return n}function sn(e,t,n){var r=e[t];if(!ut.call(e,t)||!In(r,n)||n===undefined&&!(t in e))e[t]=n}function on(e,t){var n=e.length;while(n--)if(In(e[n][0],t))return n;return-1}function un(e,t){return e&&xn(t,Kn(t),e)}function an(e,t,n,r,i,s,u){var a;r&&(a=s?r(e,i,s,u):r(e));if(a!==undefined)return a;if(!$n(e))return e;var f=Rn(e);if(f){a=On(e);if(!t)return Sn(e,a)}else{var l=An(e),p=l==c||l==h;if(Wn(e))return dn(e,t);if(l==v||l==o||p&&!s){if(G(e))return s?e:{};a=Mn(p?{}:e);if(!t)return Tn(e,un(a,e))}else{if(!j[l])return s?e:{};a=_n(e,l,an,t)}}u||(u=new Gt);var d=u.get(e);if(d)return d;u.set(e,a);if(!f)var m=n?Nn(e):Kn(e);return V(m||e,function(i,s){m&&(s=i,i=e[s]),sn(a,s,an(i,t,n,r,s,e,u))}),a}function fn(e){return $n(e)?dt(e):{}}function ln(e,t,n){var r=t(e);return Rn(e)?r:$(r,n(e))}function cn(e){return at.call(e)}function hn(e){if(!$n(e)||Hn(e))return!1;var t=Xn(e)||G(e)?ft:H;return t.test(jn(e))}function pn(e){if(!Bn(e))return bt(e);var t=[];for(var n in Object(e))ut.call(e,n)&&n!="constructor"&&t.push(n);return t}function dn(e,t){if(t)return e.slice();var n=new e.constructor(e.length);return e.copy(n),n}function vn(e){var t=new e.constructor(e.byteLength);return(new ht(t)).set(new ht(e)),t}function mn(e,t){var n=t?vn(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function gn(e,t,n){var r=t?n(Y(e),!0):Y(e);return J(r,W,new e.constructor)}function yn(e){var t=new e.constructor(e.source,P.exec(e));return t.lastIndex=e.lastIndex,t}function bn(e,t,n){var r=t?n(et(e),!0):et(e);return J(r,X,new e.constructor)}function wn(e){return _t?Object(_t.call(e)):{}}function En(e,t){var n=t?vn(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Sn(e,t){var n=-1,r=e.length;t||(t=Array(r));while(++n<r)t[n]=e[n];return t}function xn(e,t,n,r){n||(n={});var i=-1,s=t.length;while(++i<s){var o=t[i],u=r?r(n[o],e[o],o,n,e):undefined;sn(n,o,u===undefined?e[o]:u)}return n}function Tn(e,t){return xn(e,Ln(e),t)}function Nn(e){return ln(e,Kn,Ln)}function Cn(e,t){var n=e.__data__;return Pn(t)?n[typeof t=="string"?"string":"hash"]:n.map}function kn(e,t){var n=Q(e,t);return hn(n)?n:undefined}function On(e){var t=e.length,n=e.constructor(t);return t&&typeof e[0]=="string"&&ut.call(e,"index")&&(n.index=e.index,n.input=e.input),n}function Mn(e){return typeof e.constructor=="function"&&!Bn(e)?fn(pt(e)):{}}function _n(e,t,n,r){var i=e.constructor;switch(t){case S:return vn(e);case a:case f:return new i(+e);case x:return mn(e,r);case T:case N:case C:case k:case L:case A:case O:case M:case _:return En(e,r);case p:return gn(e,r,n);case d:case b:return new i(e);case g:return yn(e);case y:return bn(e,r,n);case w:return wn(e)}}function Dn(e,t){return t=t==null?s:t,!!t&&(typeof e=="number"||B.test(e))&&e>-1&&e%1==0&&e<t}function Pn(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Hn(e){return!!st&&st in e}function Bn(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||rt;return e===n}function jn(e){if(e!=null){try{return ot.call(e)}catch(t){}try{return e+""}catch(t){}}return""}function Fn(e){return an(e,!1,!0)}function In(e,t){return e===t||e!==e&&t!==t}function qn(e){return zn(e)&&ut.call(e,"callee")&&(!vt.call(e,"callee")||at.call(e)==o)}function Un(e){return e!=null&&Vn(e.length)&&!Xn(e)}function zn(e){return Jn(e)&&Un(e)}function Xn(e){var t=$n(e)?at.call(e):"";return t==c||t==h}function Vn(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=s}function $n(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function Jn(e){return!!e&&typeof e=="object"}function Kn(e){return Un(e)?rn(e):pn(e)}function Qn(){return[]}function Gn(){return!1}var r=200,i="__lodash_hash_undefined__",s=9007199254740991,o="[object Arguments]",u="[object Array]",a="[object Boolean]",f="[object Date]",l="[object Error]",c="[object Function]",h="[object GeneratorFunction]",p="[object Map]",d="[object Number]",v="[object Object]",m="[object Promise]",g="[object RegExp]",y="[object Set]",b="[object String]",w="[object Symbol]",E="[object WeakMap]",S="[object ArrayBuffer]",x="[object DataView]",T="[object Float32Array]",N="[object Float64Array]",C="[object Int8Array]",k="[object Int16Array]",L="[object Int32Array]",A="[object Uint8Array]",O="[object Uint8ClampedArray]",M="[object Uint16Array]",_="[object Uint32Array]",D=/[\\^$.*+?()[\]{}|]/g,P=/\w*$/,H=/^\[object .+?Constructor\]$/,B=/^(?:0|[1-9]\d*)$/,j={};j[o]=j[u]=j[S]=j[x]=j[a]=j[f]=j[T]=j[N]=j[C]=j[k]=j[L]=j[p]=j[d]=j[v]=j[g]=j[y]=j[b]=j[w]=j[A]=j[O]=j[M]=j[_]=!0,j[l]=j[c]=j[E]=!1;var F=typeof e=="object"&&e&&e.Object===Object&&e,I=typeof self=="object"&&self&&self.Object===Object&&self,q=F||I||Function("return this")(),R=typeof n=="object"&&n&&!n.nodeType&&n,U=R&&typeof t=="object"&&t&&!t.nodeType&&t,z=U&&U.exports===R,tt=Array.prototype,nt=Function.prototype,rt=Object.prototype,it=q["__core-js_shared__"],st=function(){var e=/[^.]+$/.exec(it&&it.keys&&it.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),ot=nt.toString,ut=rt.hasOwnProperty,at=rt.toString,ft=RegExp("^"+ot.call(ut).replace(D,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),lt=z?q.Buffer:undefined,ct=q.Symbol,ht=q.Uint8Array,pt=Z(Object.getPrototypeOf,Object),dt=Object.create,vt=rt.propertyIsEnumerable,mt=tt.splice,gt=Object.getOwnPropertySymbols,yt=lt?lt.isBuffer:undefined,bt=Z(Object.keys,Object),wt=kn(q,"DataView"),Et=kn(q,"Map"),St=kn(q,"Promise"),xt=kn(q,"Set"),Tt=kn(q,"WeakMap"),Nt=kn(Object,"create"),Ct=jn(wt),kt=jn(Et),Lt=jn(St),At=jn(xt),Ot=jn(Tt),Mt=ct?ct.prototype:undefined,_t=Mt?Mt.valueOf:undefined;Dt.prototype.clear=Pt,Dt.prototype["delete"]=Ht,Dt.prototype.get=Bt,Dt.prototype.has=jt,Dt.prototype.set=Ft,It.prototype.clear=qt,It.prototype["delete"]=Rt,It.prototype.get=Ut,It.prototype.has=zt,It.prototype.set=Wt,Xt.prototype.clear=Vt,Xt.prototype["delete"]=$t,Xt.prototype.get=Jt,Xt.prototype.has=Kt,Xt.prototype.set=Qt,Gt.prototype.clear=Yt,Gt.prototype["delete"]=Zt,Gt.prototype.get=en,Gt.prototype.has=tn,Gt.prototype.set=nn;var Ln=gt?Z(gt,Object):Qn,An=cn;if(wt&&An(new wt(new ArrayBuffer(1)))!=x||Et&&An(new Et)!=p||St&&An(St.resolve())!=m||xt&&An(new xt)!=y||Tt&&An(new Tt)!=E)An=function(e){var t=at.call(e),n=t==v?e.constructor:undefined,r=n?jn(n):undefined;if(r)switch(r){case Ct:return x;case kt:return p;case Lt:return m;case At:return y;case Ot:return E}return t};var Rn=Array.isArray,Wn=yt||Gn;t.exports=Fn}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{}],"/../../jshint/node_modules/lodash.slice/index.js":[function(e,t,n){function y(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),n=n>i?i:n,n<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;var s=Array(i);while(++r<i)s[r]=e[r+t];return s}function b(e,t){return t=t==null?i:t,!!t&&(typeof e=="number"||d.test(e))&&e>-1&&e%1==0&&e<t}function w(e,t,n){if(!C(n))return!1;var r=typeof t;return(r=="number"?x(n)&&b(t,n.length):r=="string"&&t in n)?S(n[t],e):!1}function E(e,t,n){var r=e?e.length:0;return r?(n&&typeof n!="number"&&w(e,t,n)?(t=0,n=r):(t=t==null?0:O(t),n=n===undefined?r:O(n)),y(e,t,n)):[]}function S(e,t){return e===t||e!==e&&t!==t}function x(e){return e!=null&&N(e.length)&&!T(e)}function T(e){var t=C(e)?g.call(e):"";return t==u||t==a}function N(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=i}function C(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function k(e){return!!e&&typeof e=="object"}function L(e){return typeof e=="symbol"||k(e)&&g.call(e)==f}function A(e){if(!e)return e===0?e:0;e=M(e);if(e===r||e===-r){var t=e<0?-1:1;return t*s}return e===e?e:0}function O(e){var t=A(e),n=t%1;return t===t?n?t-n:t:0}function M(e){if(typeof e=="number")return e;if(L(e))return o;if(C(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=C(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=e.replace(l,"");var n=h.test(e);return n||p.test(e)?v(e.slice(2),n?2:8):c.test(e)?o:+e}var r=1/0,i=9007199254740991,s=1.7976931348623157e308,o=0/0,u="[object Function]",a="[object GeneratorFunction]",f="[object Symbol]",l=/^\s+|\s+$/g,c=/^[-+]0x[0-9a-f]+$/i,h=/^0b[01]+$/i,p=/^0o[0-7]+$/i,d=/^(?:0|[1-9]\d*)$/,v=parseInt,m=Object.prototype,g=m.toString;t.exports=E},{}],"/../../jshint/node_modules/underscore/underscore.js":[function(e,t,n){(function(e){(function(e,r){typeof n=="object"&&typeof t!="undefined"?t.exports=r():typeof define=="function"&&define.amd?define("underscore",r):function(){var t=e._,n=r();e._=n,n.noConflict=function(){return e._=t,n}}()})(this,function(){function v(e){if(e instanceof v)return e;if(!(this instanceof v))return new v(e);this._wrapped=e}function g(e,t,n){if(t===void 0)return e;switch(n==null?3:n){case 1:return function(n){return e.call(t,n)};case 3:return function(n,r,i){return e.call(t,n,r,i)};case 4:return function(n,r,i,s){return e.call(t,n,r,i,s)}}return function(){return e.apply(t,arguments)}}function y(e,t,n){return e==null?Fn:wn(e)?g(e,t,n):yn(e)&&!gn(e)?zn(e):Rn(e)}function b(e,t){return y(e,t,Infinity)}function w(e,t,n){return v.iteratee!==b?v.iteratee(e,t):y(e,t,n)}function E(e,t){return t=t==null?e.length-1:+t,function(){var n=Math.max(arguments.length-t,0),r=Array(n),i=0;for(;i<n;i++)r[i]=arguments[i+t];switch(t){case 0:return e.call(this,r);case 1:return e.call(this,arguments[0],r);case 2:return e.call(this,arguments[0],arguments[1],r)}var s=Array(t+1);for(i=0;i<t;i++)s[i]=arguments[i];return s[t]=r,e.apply(this,s)}}function S(e){if(!yn(e))return{};if(c)return c(e);d.prototype=e;var t=new d;return d.prototype=null,t}function x(e){return function(t){return t==null?void 0:t[e]}}function T(e,t){return e!=null&&a.call(e,t)}function N(e,t){var n=t.length;for(var r=0;r<n;r++){if(e==null)return void 0;e=e[t[r]]}return n?e:void 0}function L(e){var t=k(e);return typeof t=="number"&&t>=0&&t<=C}function A(e,t,n){t=g(t,n);var r,i;if(L(e))for(r=0,i=e.length;r<i;r++)t(e[r],r,e);else{var s=Xt(e);for(r=0,i=s.length;r<i;r++)t(e[s[r]],s[r],e)}return e}function O(e,t,n){t=w(t,n);var r=!L(e)&&Xt(e),i=(r||e).length,s=Array(i);for(var o=0;o<i;o++){var u=r?r[o]:o;s[o]=t(e[u],u,e)}return s}function M(e){var t=function(t,n,r,i){var s=!L(t)&&Xt(t),o=(s||t).length,u=e>0?0:o-1;i||(r=t[s?s[u]:u],u+=e);for(;u>=0&&u<o;u+=e){var a=s?s[u]:u;r=n(r,t[a],a,t)}return r};return function(e,n,r,i){var s=arguments.length>=3;return t(e,g(n,i,4),r,s)}}function P(e,t,n){var r=L(e)?bt:tn,i=r(e,t,n);if(i!==void 0&&i!==-1)return e[i]}function H(e,t,n){var r=[];return t=w(t,n),A(e,function(e,n,i){t(e,n,i)&&r.push(e)}),r}function B(e,t,n){return H(e,jt(w(t)),n)}function j(e,t,n){t=w(t,n);var r=!L(e)&&Xt(e),i=(r||e).length;for(var s=0;s<i;s++){var o=r?r[s]:s;if(!t(e[o],o,e))return!1}return!0}function F(e,t,n){t=w(t,n);var r=!L(e)&&Xt(e),i=(r||e).length;for(var s=0;s<i;s++){var o=r?r[s]:s;if(t(e[o],o,e))return!0}return!1}function I(e,t,n,r){L(e)||(e=$t(e));if(typeof n!="number"||r)n=0;return xt(e,t,n)>=0}function R(e,t){return O(e,Rn(t))}function U(e,t){return H(e,zn(t))}function z(e,t){return P(e,zn(t))}function W(e,t,n){var r=-Infinity,i=-Infinity,s,o;if(t==null||typeof t=="number"&&typeof e[0]!="object"&&e!=null){e=L(e)?e:$t(e);for(var u=0,a=e.length;u<a;u++)s=e[u],s!=null&&s>r&&(r=s)}else t=w(t,n),A(e,function(e,n,s){o=t(e,n,s);if(o>i||o===-Infinity&&r===-Infinity)r=e,i=o});return r}function X(e,t,n){var r=Infinity,i=Infinity,s,o;if(t==null||typeof t=="number"&&typeof e[0]!="object"&&e!=null){e=L(e)?e:$t(e);for(var u=0,a=e.length;u<a;u++)s=e[u],s!=null&&s<r&&(r=s)}else t=w(t,n),A(e,function(e,n,s){o=t(e,n,s);if(o<i||o===Infinity&&r===Infinity)r=e,i=o});return r}function V(e){return $(e,Infinity)}function $(e,t,n){if(t==null||n)return L(e)||(e=$t(e)),e[Xn(e.length-1)];var r=L(e)?an(e):$t(e),i=k(r);t=Math.max(Math.min(t,i),0);var s=i-1;for(var o=0;o<t;o++){var u=Xn(o,s),a=r[o];r[o]=r[u],r[u]=a}return r.slice(0,t)}function J(e,t,n){var r=0;return t=w(t,n),R(O(e,function(e,n,i){return{value:e,index:r++,criteria:t(e,n,i)}}).sort(function(e,t){var n=e.criteria,r=t.criteria;if(n!==r){if(n>r||n===void 0)return 1;if(n<r||r===void 0)return-1}return e.index-t.index}),"value")}function K(e,t){return function(n,r,i){var s=t?[[],[]]:{};return r=w(r,i),A(n,function(t,i){var o=r(t,i,n);e(s,t,o)}),s}}function et(e){return e?gn(e)?o.call(e):En(e)?e.match(Z):L(e)?O(e,Fn):$t(e):[]}function tt(e){return e==null?0:L(e)?e.length:Xt(e).length}function rt(e,t,n){return e==null||e.length<1?t==null?void 0:[]:t==null||n?e[0]:it(e,e.length-t)}function it(e,t,n){return o.call(e,0,Math.max(0,e.length-(t==null||n?1:t)))}function st(e,t,n){return e==null||e.length<1?t==null?void 0:[]:t==null||n?e[e.length-1]:ot(e,Math.max(0,e.length-t))}function ot(e,t,n){return o.call(e,t==null||n?1:t)}function ut(e){return H(e,Boolean)}function at(e,t,n,r){r=r||[];var i=r.length;for(var s=0,o=k(e);s<o;s++){var u=e[s];if(L(u)&&(gn(u)||bn(u)))if(t){var a=0,f=u.length;while(a<f)r[i++]=u[a++]}else at(u,t,n,r),i=r.length;else n||(r[i++]=u)}return r}function ft(e,t){return at(e,t,!1)}function ct(e,t,n,r){Pn(t)||(r=n,n=t,t=!1),n!=null&&(n=w(n,r));var i=[],s=[];for(var o=0,u=k(e);o<u;o++){var a=e[o],f=n?n(a,o,e):a;t&&!n?((!o||s!==f)&&i.push(a),s=f):n?I(s,f)||(s.push(f),i.push(a)):I(i,a)||i.push(a)}return i}function pt(e){var t=[],n=arguments.length;for(var r=0,i=k(e);r<i;r++){var s=e[r];if(I(t,s))continue;var o;for(o=1;o<n;o++)if(!I(arguments[o],s))break;o===n&&t.push(s)}return t}function vt(e){var t=e&&W(e,k).length||0,n=Array(t);for(var r=0;r<t;r++)n[r]=R(e,r);return n}function gt(e,t){var n={};for(var r=0,i=k(e);r<i;r++)t?n[e[r]]=t[r]:n[e[r][0]]=e[r][1];return n}function yt(e){return function(t,n,r){n=w(n,r);var i=k(t),s=e>0?0:i-1;for(;s>=0&&s<i;s+=e)if(n(t[s],s,t))return s;return-1}}function Et(e,t,n,r){n=w(n,r,1);var i=n(t),s=0,o=k(e);while(s<o){var u=Math.floor((s+o)/2);n(e[u])<i?s=u+1:o=u}return s}function St(e,t,n){return function(r,i,s){var u=0,a=k(r);if(typeof s=="number")e>0?u=s>=0?s:Math.max(s+a,u):a=s>=0?Math.min(s+1,a):s+a+1;else if(n&&s&&a)return s=n(r,i),r[s]===i?s:-1;if(i!==i)return s=t(o.call(r,u,a),Dn),s>=0?s+u:-1;for(s=e>0?u:a-1;s>=0&&s<a;s+=e)if(r[s]===i)return s;return-1}}function Nt(e,t,n){t==null&&(t=e||0,e=0),n||(n=t<e?-1:1);var r=Math.max(Math.ceil((t-e)/n),0),i=Array(r);for(var s=0;s<r;s++,e+=n)i[s]=e;return i}function Ct(e,t){if(t==null||t<1)return[];var n=[],r=0,i=e.length;while(r<i)n.push(o.call(e,r,r+=t));return n}function kt(e,t,n,r,i){if(r instanceof t){var s=S(e.prototype),o=e.apply(s,i);return yn(o)?o:s}return e.apply(n,i)}function Mt(e,t){var n=function(r){var i=n.cache,s=""+(t?t.apply(this,arguments):r);return T(i,s)||(i[s]=e.apply(this,arguments)),i[s]};return n.cache={},n}function Pt(e,t,n){var r,i,s,o,u=0;n||(n={});var a=function(){u=n.leading===!1?0:Vn(),r=null,o=e.apply(i,s),r||(i=s=null)},f=function(){var f=Vn();!u&&n.leading===!1&&(u=f);var l=t-(f-u);return i=this,s=arguments,l<=0||l>t?(r&&(clearTimeout(r),r=null),u=f,o=e.apply(i,s),r||(i=s=null)):!r&&n.trailing!==!1&&(r=setTimeout(a,l)),o};return f.cancel=function(){clearTimeout(r),u=0,r=i=s=null},f}function Ht(e,t,n){var r,i,s=function(t,n){r=null,n&&(i=e.apply(t,n))},o=E(function(o){r&&clearTimeout(r);if(n){var u=!r;r=setTimeout(s,t),u&&(i=e.apply(this,o))}else r=_t(s,t,this,o);return i});return o.cancel=function(){clearTimeout(r),r=null},o}function Bt(e,t){return At(t,e)}function jt(e){return function(){return!e.apply(this,arguments)}}function Ft(){var e=arguments,t=e.length-1;return function(){var n=t,r=e[t].apply(this,arguments);while(n--)r=e[n].call(this,r);return r}}function It(e,t){return function(){if(--e<1)return t.apply(this,arguments)}}function qt(e,t){var n;return function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=null),n}}function Wt(e,t){var n=zt.length,i=e.constructor,s=wn(i)&&i.prototype||r,o="constructor";T(e,o)&&!I(t,o)&&t.push(o);while(n--)o=zt[n],o in e&&e[o]!==s[o]&&!I(t,o)&&t.push(o)}function Xt(e){if(!yn(e))return[];if(l)return l(e);var t=[];for(var n in e)T(e,n)&&t.push(n);return Ut&&Wt(e,t),t}function Vt(e){if(!yn(e))return[];var t=[];for(var n in e)t.push(n);return Ut&&Wt(e,t),t}function $t(e){var t=Xt(e),n=t.length,r=Array(n);for(var i=0;i<n;i++)r[i]=e[t[i]];return r}function Jt(e,t,n){t=w(t,n);var r=Xt(e),i=r.length,s={};for(var o=0;o<i;o++){var u=r[o];s[u]=t(e[u],u,e)}return s}function Kt(e){var t=Xt(e),n=t.length,r=Array(n);for(var i=0;i<n;i++)r[i]=[t[i],e[t[i]]];return r}function Qt(e){var t={},n=Xt(e);for(var r=0,i=n.length;r<i;r++)t[e[n[r]]]=n[r];return t}function Gt(e){var t=[];for(var n in e)wn(e[n])&&t.push(n);return t.sort()}function Yt(e,t){return function(n){var r=arguments.length;t&&(n=Object(n));if(r<2||n==null)return n;for(var i=1;i<r;i++){var s=arguments[i],o=e(s),u=o.length;for(var a=0;a<u;a++){var f=o[a];if(!t||n[f]===void 0)n[f]=s[f]}}return n}}function tn(e,t,n){t=w(t,n);var r=Xt(e),i;for(var s=0,o=r.length;s<o;s++){i=r[s];if(t(e[i],i,e))return i}}function nn(e,t,n){return t in n}function un(e,t){var n=S(e);return t&&en(n,t),n}function an(e){return yn(e)?gn(e)?e.slice():Zt({},e):e}function fn(e,t){return t(e),e}function ln(e,t){var n=Xt(t),r=n.length;if(e==null)return!r;var i=Object(e);for(var s=0;s<r;s++){var o=n[s];if(t[o]!==i[o]||!(o in i))return!1}return!0}function cn(e,t,n,r){if(e===t)return e!==0||1/e===1/t;if(e==null||t==null)return!1;if(e!==e)return t!==t;var i=typeof e;return i!=="function"&&i!=="object"&&typeof t!="object"?!1:hn(e,t,n,r)}function hn(e,t,n,r){e instanceof v&&(e=e._wrapped),t instanceof v&&(t=t._wrapped);var s=u.call(e);if(s!==u.call(t))return!1;switch(s){case"[object RegExp]":case"[object String]":return""+e==""+t;case"[object Number]":if(+e!==+e)return+t!==+t;return+e===0?1/+e===1/t:+e===+t;case"[object Date]":case"[object Boolean]":return+e===+t;case"[object Symbol]":return i.valueOf.call(e)===i.valueOf.call(t)}var o=s==="[object Array]";if(!o){if(typeof e!="object"||typeof t!="object")return!1;var a=e.constructor,f=t.constructor;if(a!==f&&!(wn(a)&&a instanceof a&&wn(f)&&f instanceof f)&&"constructor"in e&&"constructor"in t)return!1}n=n||[],r=r||[];var l=n.length;while(l--)if(n[l]===e)return r[l]===t;n.push(e),r.push(t);if(o){l=e.length;if(l!==t.length)return!1;while(l--)if(!cn(e[l],t[l],n,r))return!1}else{var c=Xt(e),h;l=c.length;if(Xt(t).length!==l)return!1;while(l--){h=c[l];if(!T(t,h)||!cn(e[h],t[h],n,r))return!1}}return n.pop(),r.pop(),!0}function pn(e,t){return cn(e,t)}function dn(e){return e==null?!0:L(e)&&(gn(e)||En(e)||bn(e))?e.length===0:Xt(e).length===0}function vn(e){return!!e&&e.nodeType===1}function mn(e){return function(t){return u.call(t)==="[object "+e+"]"}}function yn(e){var t=typeof e;return t==="function"||t==="object"&&!!e}function _n(e){return!Cn(e)&&p(e)&&!h(parseFloat(e))}function Dn(e){return Sn(e)&&h(e)}function Pn(e){return e===!0||e===!1||u.call(e)==="[object Boolean]"}function Hn(e){return e===null}function Bn(e){return e===void 0}function jn(e,t){if(!gn(t))return T(e,t);var n=t.length;for(var r=0;r<n;r++){var i=t[r];if(e==null||!a.call(e,i))return!1;e=e[i]}return!!n}function Fn(e){return e}function In(e){return function(){return e}}function qn(){}function Rn(e){return gn(e)?function(t){return N(t,e)}:x(e)}function Un(e){return e==null?function(){}:function(t){return gn(t)?N(e,t):e[t]}}function zn(e){return e=en({},e),function(t){return ln(t,e)}}function Wn(e,t,n){var r=Array(Math.max(0,e));t=g(t,n,1);for(var i=0;i<e;i++)r[i]=t(i);return r}function Xn(e,t){return t==null&&(t=e,e=0),e+Math.floor(Math.random()*(t-e+1))}function Kn(e){var t=function(t){return e[t]},n="(?:"+Xt(e).join("|")+")",r=RegExp(n),i=RegExp(n,"g");return function(e){return e=e==null?"":""+e,r.test(e)?e.replace(i,t):e}}function Yn(e,t,n){gn(t)||(t=[t]);var r=t.length;if(!r)return wn(n)?n.call(e):n;for(var i=0;i<r;i++){var s=e==null?void 0:e[t[i]];s===void 0&&(s=n,i=r),e=wn(s)?s.call(e):s}return e}function er(e){var t=++Zn+"";return e?e+t:t}function or(e,t,n){!t&&n&&(t=n),t=on({},t,v.templateSettings);var r=RegExp([(t.escape||nr).source,(t.interpolate||nr).source,(t.evaluate||nr).source].join("|")+"|$","g"),i=0,s="__p+='";e.replace(r,function(t,n,r,o,u){return s+=e.slice(i,u).replace(ir,sr),i=u+t.length,n?s+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'":r?s+="'+\n((__t=("+r+"))==null?'':__t)+\n'":o&&(s+="';\n"+o+"\n__p+='"),t}),s+="';\n",t.variable||(s="with(obj||{}){\n"+s+"}\n"),s="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+s+"return __p;\n";var o;try{o=new Function(t.variable||"obj","_",s)}catch(u){throw u.source=s,u}var a=function(e){return o.call(this,e,v)},f=t.variable||"obj";return a.source="function("+f+"){\n"+s+"}",a}function ur(e){var t=v(e);return t._chain=!0,t}function ar(e,t){return e._chain?v(t).chain():t}function fr(e){return A(Gt(e),function(t){var n=v[t]=e[t];v.prototype[t]=function(){var e=[this._wrapped];return s.apply(e,arguments),ar(this,n.apply(v,e))}}),v}var t=typeof self=="object"&&self.self===self&&self||typeof e=="object"&&e.global===e&&e||Function("return this")()||{},n=Array.prototype,r=Object.prototype,i=typeof Symbol!="undefined"?Symbol.prototype:null,s=n.push,o=n.slice,u=r.toString,a=r.hasOwnProperty,f=Array.isArray,l=Object.keys,c=Object.create,h=t.isNaN,p=t.isFinite,d=function(){},m=v.VERSION="1.10.2";v.iteratee=b;var C=Math.pow(2,53)-1,k=x("length"),_=M(1),D=M(-1),q=E(function(e,t,n){var r,i;return wn(t)?i=t:gn(t)&&(r=t.slice(0,-1),t=t[t.length-1]),O(e,function(e){var s=i;if(!s){r&&r.length&&(e=N(e,r));if(e==null)return void 0;s=e[t]}return s==null?s:s.apply(e,n)})}),Q=K(function(e,t,n){T(e,n)?e[n].push(t):e[n]=[t]}),G=K(function(e,t,n){e[n]=t}),Y=K(function(e,t,n){T(e,n)?e[n]++:e[n]=1}),Z=/[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g,nt=K(function(e,t,n){e[n?0:1].push(t)},!0),lt=E(function(e,t){return dt(e,t)}),ht=E(function(e){return ct(at(e,!0,!0))}),dt=E(function(e,t){return t=at(t,!0,!0),H(e,function(e){return!I(t,e)})}),mt=E(vt),bt=yt(1),wt=yt(-1),xt=St(1,bt,Et),Tt=St(-1,wt),Lt=E(function(e,t,n){if(!wn(e))throw new TypeError("Bind must be called on a function");var r=E(function(i){return kt(e,r,t,this,n.concat(i))});return r}),At=E(function(e,t){var n=At.placeholder,r=function(){var i=0,s=t.length,o=Array(s);for(var u=0;u<s;u++)o[u]=t[u]===n?arguments[i++]:t[u];while(i<arguments.length)o.push(arguments[i++]);return kt(e,r,this,this,o)};return r});At.placeholder=v;var Ot=E(function(e,t){t=at(t,!1,!1);var n=t.length;if(n<1)throw new Error("bindAll must be passed function names");while(n--){var r=t[n];e[r]=Lt(e[r],e)}}),_t=E(function(e,t,n){return setTimeout(function(){return e.apply(null,n)},t)}),Dt=At(_t,v,1),Rt=At(qt,2),Ut=!{toString:null}.propertyIsEnumerable("toString"),zt=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],Zt=Yt(Vt),en=Yt(Xt),rn=E(function(e,t){var n={},r=t[0];if(e==null)return n;wn(r)?(t.length>1&&(r=g(r,t[1])),t=Vt(e)):(r=nn,t=at(t,!1,!1),e=Object(e));for(var i=0,s=t.length;i<s;i++){var o=t[i],u=e[o];r(u,o,e)&&(n[o]=u)}return n}),sn=E(function(e,t){var n=t[0],r;return wn(n)?(n=jt(n),t.length>1&&(r=t[1])):(t=O(at(t,!1,!1),String),n=function(e,n){return!I(t,n)}),rn(e,n,r)}),on=Yt(Vt,!0),gn=f||mn("Array"),bn=mn("Arguments"),wn=mn("Function"),En=mn("String"),Sn=mn("Number"),xn=mn("Date"),Tn=mn("RegExp"),Nn=mn("Error"),Cn=mn("Symbol"),kn=mn("Map"),Ln=mn("WeakMap"),An=mn("Set"),On=mn("WeakSet");(function(){bn(arguments)||(bn=function(e){return T(e,"callee")})})();var Mn=t.document&&t.document.childNodes;typeof /./!="function"&&typeof Int8Array!="object"&&typeof Mn!="function"&&(wn=function(e){return typeof e=="function"||!1});var Vn=Date.now||function(){return(new Date).getTime()},$n={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},Jn=Qt($n),Qn=Kn($n),Gn=Kn(Jn),Zn=0,tr=v.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},nr=/(.)^/,rr={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},ir=/\\|'|\r|\n|\u2028|\u2029/g,sr=function(e){return"\\"+rr[e]};A(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=n[e];v.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),(e==="shift"||e==="splice")&&n.length===0&&delete n[0],ar(this,n)}}),A(["concat","join","slice"],function(e){var t=n[e];v.prototype[e]=function(){return ar(this,t.apply(this._wrapped,arguments))}}),v.prototype.value=function(){return this._wrapped},v.prototype.valueOf=v.prototype.toJSON=v.prototype.value,v.prototype.toString=function(){return String(this._wrapped)};var lr={"default":v,VERSION:m,iteratee:b,restArguments:E,each:A,forEach:A,map:O,collect:O,reduce:_,foldl:_,inject:_,reduceRight:D,foldr:D,find:P,detect:P,filter:H,select:H,reject:B,every:j,all:j,some:F,any:F,contains:I,includes:I,include:I,invoke:q,pluck:R,where:U,findWhere:z,max:W,min:X,shuffle:V,sample:$,sortBy:J,groupBy:Q,indexBy:G,countBy:Y,toArray:et,size:tt,partition:nt,first:rt,head:rt,take:rt,initial:it,last:st,rest:ot,tail:ot,drop:ot,compact:ut,flatten:ft,without:lt,uniq:ct,unique:ct,union:ht,intersection:pt,difference:dt,unzip:vt,zip:mt,object:gt,findIndex:bt,findLastIndex:wt,sortedIndex:Et,indexOf:xt,lastIndexOf:Tt,range:Nt,chunk:Ct,bind:Lt,partial:At,bindAll:Ot,memoize:Mt,delay:_t,defer:Dt,throttle:Pt,debounce:Ht,wrap:Bt,negate:jt,compose:Ft,after:It,before:qt,once:Rt,keys:Xt,allKeys:Vt,values:$t,mapObject:Jt,pairs:Kt,invert:Qt,functions:Gt,methods:Gt,extend:Zt,extendOwn:en,assign:en,findKey:tn,pick:rn,omit:sn,defaults:on,create:un,clone:an,tap:fn,isMatch:ln,isEqual:pn,isEmpty:dn,isElement:vn,isArray:gn,isObject:yn,isArguments:bn,isFunction:wn,isString:En,isNumber:Sn,isDate:xn,isRegExp:Tn,isError:Nn,isSymbol:Cn,isMap:kn,isWeakMap:Ln,isSet:An,isWeakSet:On,isFinite:_n,isNaN:Dn,isBoolean:Pn,isNull:Hn,isUndefined:Bn,has:jn,identity:Fn,constant:In,noop:qn,property:Rn,propertyOf:Un,matcher:zn,matches:zn,times:Wn,random:Xn,now:Vn,escape:Qn,unescape:Gn,result:Yn,uniqueId:er,templateSettings:tr,template:or,chain:ur,mixin:fr},cr=fr(lr);return cr._=cr,cr})}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{}],"/../../jshint/src/jshint.js":[function(e,t,n){var r=e("underscore");r.clone=e("lodash.clone");var i=e("events"),s=e("./vars.js"),o=e("./messages.js"),u=e("./lex.js").Lexer,a=e("./reg.js"),f=e("./state.js").state,l=e("./style.js"),c=e("./options.js"),h=e("./scope-manager.js"),p=e("./prod-params.js"),d=e("console-browserify"),v=function(){"use strict";function N(e,t,n){var i,s;return t?(i="",s=c.validNames):(i="unstable ",s=c.unstableNames),e=e.trim(),/^[+-]W\d{3}$/g.test(e)?!0:s.indexOf(e)===-1&&n.type!=="jslint"&&!r.has(c.removed,e)?(F("E001",n,i,e),!1):!0}function C(e){return Object.prototype.toString.call(e)==="[object String]"}function k(e,t){return e?!e.identifier||e.value!==t?!1:!0:!1}function L(e,t){if(!t.reserved)return!1;var n=t.meta;if(n&&n.isFutureReservedWord){if(f.inES5()){if(!n.es5)return!1;if(t.isProperty)return!1}}else if(n&&n.es5&&!f.inES5())return!1;return n&&n.strictOnly&&f.inES5()&&!f.option.strict&&!f.isStrict()?!1:t.id==="await"&&!(e&p.async)&&!f.option.module?!1:t.id==="yield"&&!(e&p.yield)?f.isStrict():!0}function A(e,t){return e.replace(/\{([^{}]*)\}/g,function(e,n){var r=t[n];return typeof r=="string"||typeof r=="number"?r:e})}function O(e,t){Object.keys(t).forEach(function(n){if(r.has(v.blacklist,n))return;e[n]=t[n]})}function M(){if(f.option.enforceall){for(var e in c.bool.enforcing)f.option[e]===undefined&&!c.noenforceall[e]&&(f.option[e]=!0);for(var t in c.bool.relaxing)f.option[t]===undefined&&(f.option[t]=!1)}}function D(){var e=null;M(),e=f.inferEsVersion(),e&&P("E059",f.tokens.next,"esversion",e),f.inES5()&&O(S,s.ecmaIdentifiers[5]),f.inES6()&&O(S,s.ecmaIdentifiers[6]),f.inES8()&&O(S,s.ecmaIdentifiers[8]),f.option.strict==="global"&&"globalstrict"in f.option&&P("E059",f.tokens.next,"strict","globalstrict"),f.option.module&&(f.inES6()||B("W134",f.tokens.next,"module",6)),f.option.regexpu&&(f.inES6()||B("W134",f.tokens.next,"regexpu",6)),f.option.couch&&O(S,s.couch),f.option.qunit&&O(S,s.qunit),f.option.rhino&&O(S,s.rhino),f.option.shelljs&&(O(S,s.shelljs),O(S,s.node)),f.option.typed&&O(S,s.typed),f.option.phantom&&O(S,s.phantom),f.option.prototypejs&&O(S,s.prototypejs),f.option.node&&(O(S,s.node),O(S,s.typed)),f.option.devel&&O(S,s.devel),f.option.dojo&&O(S,s.dojo),f.option.browser&&(O(S,s.browser),O(S,s.typed)),f.option.browserify&&(O(S,s.browser),O(S,s.typed),O(S,s.browserify)),f.option.nonstandard&&O(S,s.nonstandard),f.option.jasmine&&O(S,s.jasmine),f.option.jquery&&O(S,s.jquery),f.option.mootools&&O(S,s.mootools),f.option.worker&&O(S,s.worker),f.option.wsh&&O(S,s.wsh),f.option.yui&&O(S,s.yui),f.option.mocha&&O(S,s.mocha)}function P(e,t,n,r){var i=Math.floor(t.line/f.lines.length*100),s=o.errors[e].desc,u={name:"JSHintError",line:t.line,character:t.from,message:s+" ("+i+"% scanned).",raw:s,code:e,a:n,b:r};throw u.reason=A(s,u)+" ("+i+"% scanned).",u}function H(){var e=f.ignoredLines;if(r.isEmpty(e))return;v.errors=r.reject(v.errors,function(t){return e[t.line]})}function B(e,t,n,r,i,s){var u,a,l,c;if(/^W\d{3}$/.test(e)){if(f.ignored[e])return;c=o.warnings[e]}else/E\d{3}/.test(e)?c=o.errors[e]:/I\d{3}/.test(e)&&(c=o.info[e]);return t=t||f.tokens.next||{},t.id==="(end)"&&(t=f.tokens.curr),a=t.line,u=t.from,l={id:"(error)",raw:c.desc,code:c.code,evidence:f.lines[a-1]||"",line:a,character:u,scope:v.scope,a:n,b:r,c:i,d:s},l.reason=A(c.desc,l),v.errors.push(l),H(),v.errors.length>=f.option.maxerr&&P("E043",t),l}function j(e,t,n,r,i,s,o){return B(e,{line:t,from:n},r,i,s,o)}function F(e,t,n,r,i,s){B(e,t,n,r,i,s)}function I(e,t,n,r,i,s,o){return F(e,{line:t,from:n},r,i,s,o)}function q(e,t){v.internals.push({id:"(internal)",elem:e,token:t,code:t.value.replace(/([^\\])(\\*)\2\\n/g,"$1\n")})}function R(e,t){var i=e.body.split(",").map(function(e){return e.trim()}),s={};if(e.type==="falls through"){t.caseFallsThrough=!0;return}if(e.type==="globals"){i.forEach(function(t,n){var r=t.split(":"),o=r[0].trim();if(o==="-"||!o.length){if(n>0&&n===i.length-1)return;F("E002",e);return}o.charAt(0)==="-"?(o=o.slice(1),v.blacklist[o]=o,delete S[o]):s[o]=r.length>1&&r[1].trim()==="true"}),O(S,s);for(var o in s)r.has(s,o)&&(n[o]=e)}e.type==="exported"&&i.forEach(function(t,n){if(!t.length){if(n>0&&n===i.length-1)return;F("E002",e);return}f.funct["(scope)"].addExported(t)}),e.type==="members"&&(E=E||{},i.forEach(function(e){var t=e.charAt(0),n=e.charAt(e.length-1);t===n&&(t==='"'||t==="'")&&(e=e.substr(1,e.length-2).replace('\\"','"')),E[e]=!1}));var u=["maxstatements","maxparams","maxdepth","maxcomplexity","maxerr","maxlen","indent"];if(e.type==="jshint"||e.type==="jslint"||e.type==="jshint.unstable")i.forEach(function(t){var n=t.split(":"),r=n[0].trim(),i=n.length>1?n[1].trim():"",s;if(!N(r,e.type!=="jshint.unstable",e))return;if(u.indexOf(r)>=0){if(i!=="false"){s=+i;if(typeof s!="number"||!isFinite(s)||s<=0||Math.floor(s)!==s){F("E032",e,i);return}f.option[r]=s}else f.option[r]=r==="indent"?4:!1;return}if(r==="validthis"){if(f.funct["(global)"])return void F("E009");if(i!=="true"&&i!=="false")return void F("E002",e);f.option.validthis=i==="true";return}if(r==="quotmark"){switch(i){case"true":case"false":f.option.quotmark=i==="true";break;case"double":case"single":f.option.quotmark=i;break;default:F("E002",e)}return}if(r==="shadow"){switch(i){case"true":f.option.shadow=!0;break;case"outer":f.option.shadow="outer";break;case"false":case"inner":f.option.shadow="inner";break;default:F("E002",e)}return}if(r==="unused"){switch(i){case"true":f.option.unused=!0;break;case"false":f.option.unused=!1;break;case"vars":case"strict":f.option.unused=i;break;default:F("E002",e)}return}if(r==="latedef"){switch(i){case"true":f.option.latedef=!0;break;case"false":f.option.latedef=!1;break;case"nofunc":f.option.latedef="nofunc";break;default:F("E002",e)}return}if(r==="ignore"){switch(i){case"line":f.ignoredLines[e.line]=!0,H();break;default:F("E002",e)}return}if(r==="strict"){switch(i){case"true":f.option.strict=!0;break;case"false":f.option.strict=!1;break;case"global":case"implied":f.option.strict=i;break;default:F("E002",e)}return}r==="module"&&(qt(f.funct)||F("E055",e,"module"));if(r==="esversion"){switch(i){case"3":case"5":case"6":case"7":case"8":case"9":case"10":f.option.moz=!1,f.option.esversion=+i;break;case"2015":case"2016":case"2017":case"2018":case"2019":f.option.moz=!1,f.option.esversion=+i-2009;break;default:F("E002",e)}qt(f.funct)||F("E055",e,"esversion");return}var o=/^([+-])(W\d{3})$/g.exec(r);if(o){f.ignored[o[2]]=o[1]==="-";return}var a;if(i==="true"||i==="false"){e.type==="jslint"?(a=c.renamed[r]||r,f.option[a]=i==="true",c.inverted[a]!==undefined&&(f.option[a]=!f.option[a])):e.type==="jshint.unstable"?f.option.unstable[r]=i==="true":f.option[r]=i==="true";return}F("E002",e)}),D()}function U(e){var t=e||0,n=y.length,r;if(t<n)return y[t];while(n<=t){r=b.token();if(!r)return y.length?y[n-1]:f.tokens.next;y[n]=r,n+=1}return r}function z(){var e=0,t;do t=U(e++);while(t.id==="(endline)");return t}function W(e,t){var n=f.tokens.next;e&&n.id!==e&&(t?n.id==="(end)"?F("E019",t,t.id):F("E020",n,e,t.id,t.line,n.value):(n.type!=="(identifier)"||n.value!==e)&&F("E021",n,e,n.value)),f.tokens.prev=f.tokens.curr,f.tokens.curr=f.tokens.next;for(;;){f.tokens.next=y.shift()||b.token(),f.tokens.next||P("E041",f.tokens.curr);if(f.tokens.next.id==="(end)"||f.tokens.next.id==="(error)")return;f.tokens.next.check&&f.tokens.next.check();if(f.tokens.next.isSpecial)R(f.tokens.next,f.tokens.curr);else if(f.tokens.next.id!=="(endline)")break}}function X(e){return e.first||e.right||e.left||e.id==="yield"||e.id==="await"}function V(e,t,n){return arguments.length<=1&&(t=f.tokens.curr,n=f.tokens.next),n.id==="in"&&e&p.noin?!0:n.id===";"||n.id==="}"||n.id===":"?!0:n.infix===t.infix||t.id==="yield"&&t.rbp<n.rbp?!J(t,n):!1}function $(e,t){var n,r=!1,i=!1,s=e&p.initial,o;e&=~p.initial,f.nameStack.push(),f.tokens.next.id==="(end)"&&F("E006",f.tokens.curr),W(),s&&(f.funct["(verb)"]=f.tokens.curr.value,f.tokens.curr.beginsStmt=!0),o=f.tokens.curr;if(s&&o.fud&&(!o.useFud||o.useFud(e)))n=f.tokens.curr.fud(e);else{f.tokens.curr.nud?n=f.tokens.curr.nud(e,t):F("E030",f.tokens.curr,f.tokens.curr.id);while(t<f.tokens.next.lbp&&!V(e))r=f.tokens.curr.value==="Array",i=f.tokens.curr.value==="Object",n&&(n.value||n.first&&n.first.value)&&(n.value!=="new"||n.first&&n.first.value&&n.first.value===".")&&(r=!1,n.value!==f.tokens.curr.value&&(i=!1)),W(),r&&f.tokens.curr.id==="("&&f.tokens.next.id===")"&&B("W009",f.tokens.curr),i&&f.tokens.curr.id==="("&&f.tokens.next.id===")"&&B("W010",f.tokens.curr),n&&f.tokens.curr.led?n=f.tokens.curr.led(e,n):F("E033",f.tokens.curr,f.tokens.curr.id)}return f.nameStack.pop(),n}function J(e,t){return e.line===(t.startLine||t.line)}function K(e,t){!f.option.laxbreak&&!J(e,t)&&B("W014",t,t.value)}function Q(e){e=e,J(e,f.tokens.next)||B("E022",e,e.value)}function G(e){var t=f.tokens.prev,n=f.tokens.curr;e=e||{},J(t,n)||f.option.laxcomma||(G.first&&(B("I001",n),G.first=!1),B("W014",t,n.value));if(f.tokens.next.identifier&&(!e.property||!f.inES5()))switch(f.tokens.next.value){case"break":case"case":case"catch":case"continue":case"default":case"do":case"else":case"finally":case"for":case"if":case"in":case"instanceof":case"return":case"switch":case"throw":case"try":case"var":case"let":case"while":case"with":return F("E024",f.tokens.next,f.tokens.next.value),!1}if(f.tokens.next.type==="(punctuator)")switch(f.tokens.next.value){case"}":case"]":case",":case")":if(e.allowTrailing)return!0;return F("E024",f.tokens.next,f.tokens.next.value),!1}return!0}function Y(e,t){var n=f.syntax[e];if(!n||typeof n!="object")f.syntax[e]=n={id:e,lbp:t,rbp:t,value:e};return n}function Z(e){var t=Y(e,0);return t.delim=!0,t}function et(e,t){var n=Z(e);return n.identifier=n.reserved=!0,n.fud=t,n}function tt(e,t){var n=et(e,t);return n.block=!0,n}function nt(e){var t=e.id.charAt(0);if(t>="a"&&t<="z"||t>="A"&&t<="Z")e.identifier=e.reserved=!0;return e}function rt(e,t){var n=Y(e,150);return nt(n),n.nud=typeof t=="function"?t:function(e){this.arity="unary",this.right=$(e,150);if(this.id==="++"||this.id==="--")f.option.plusplus&&B("W016",this,this.id),this.right&&vt(e,this.right,this);return this},n}function it(e,t){var n=Y(e,0);return n.type=e,n.nud=t,n}function st(e,t){var n=it(e,t);return n.identifier=!0,n.reserved=!0,n}function ot(e,t){var n=it(e,f.syntax["(identifier)"].nud);return t=t||{},t.isFutureReservedWord=!0,n.value=e,n.identifier=!0,n.reserved=!0,n.meta=t,n}function ut(e,t,n,r){var i=Y(e,n);return nt(i),i.infix=!0,i.led=function(i,s){return r||K(f.tokens.prev,f.tokens.curr),(e==="in"||e==="instanceof")&&s.id==="!"&&B("W018",s,"!"),typeof t=="function"?t(i,s,this):(this.left=s,this.right=$(i,n),this)},i}function at(e){var t=Y(e,42);return t.infix=!0,t.led=function(e,t){return K(f.tokens.prev,f.tokens.curr),this.left=t,this.right=Ut(e,{type:"arrow",loneArg:t}),this},t}function ft(e,t){var n=Y(e,100);return n.infix=!0,n.led=function(e,n){K(f.tokens.prev,f.tokens.curr),this.left=n;var r=this.right=$(e,100);return k(n,"NaN")||k(r,"NaN")?B("W019",this):t&&t.apply(this,[e,n,r]),(!n||!r)&&P("E041",f.tokens.curr),n.id==="!"&&B("W018",n,"!"),r.id==="!"&&B("W018",r,"!"),this},n}function lt(e){return e.arity==="unary"&&e.id!=="++"&&e.id!=="--"}function ht(e,t,n){var i;return n.option.notypeof?!1:!e||!t?!1:(i=n.inES6()?ct.es6:ct.es3,t.type==="(identifier)"&&t.value==="typeof"&&e.type==="(string)"?e.value==="bigint"?(n.option.unstable.bigint||B("W144",e,"BigInt","bigint"),!1):!r.includes(i,e.value):!1)}function pt(e,t){var n=!1;return e.type==="this"&&t.funct["(context)"]===null?n=!0:e.type==="(identifier)"&&(t.option.node&&e.value==="global"?n=!0:t.option.browser&&(e.value==="window"||e.value==="document")&&(n=!0)),n}function dt(e){function n(e){if(typeof e!="object")return;return e.right==="prototype"?e:n(e.left)}function r(e){while(!e.identifier&&typeof e.left=="object")e=e.left;if(e.identifier&&t.indexOf(e.value)>=0&&f.funct["(scope)"].isPredefined(e.value))return e.value}var t=["Array","ArrayBuffer","Boolean","Collator","DataView","Date","DateTimeFormat","Error","EvalError","Float32Array","Float64Array","Function","Infinity","Intl","Int16Array","Int32Array","Int8Array","Iterator","Number","NumberFormat","Object","RangeError","ReferenceError","RegExp","StopIteration","String","SyntaxError","TypeError","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray","URIError"],i=n(e);if(i)return r(i)}function vt(e,t,n,r){var i=r&&r.allowDestructuring;n=n||t;if(f.option.freeze){var s=dt(t);s&&B("W121",t,s)}t.identifier&&!t.isMetaProperty&&f.funct["(scope)"].block.reassign(t.value,t);if(t.id===".")return(!t.left||t.left.value==="arguments"&&!f.isStrict())&&B("W143",n),f.nameStack.set(f.tokens.prev),!0;if(t.id==="{"||t.id==="["){if(!i||!t.destructAssign)t.id==="{"||!t.left?B("E031",n):t.left.value==="arguments"&&!f.isStrict()&&B("W143",n);return t.id==="["&&f.nameStack.set(t.right),!0}if(t.identifier&&!L(e,t)&&!t.isMetaProperty){f.funct["(scope)"].bindingtype(t.value)==="exception"&&B("W022",t);if(t.value==="eval"&&f.isStrict())return F("E031",n),!1;if(t.value==="arguments"){if(!!f.isStrict())return F("E031",n),!1;B("W143",n)}return f.nameStack.set(t),!0}return F("E031",n),!1}function mt(e,t){var n=ut(e,typeof t=="function"?t:function(e,t,n){return n.left=t,vt(e,t,n,{allowDestructuring:!0}),n.right=$(e,10),n},20);return n.exps=!0,n.assign=!0,n}function gt(e,t,n){var r=Y(e,n);return nt(r),r.infix=!0,r.led=typeof t=="function"?t:function(e,t){return f.option.bitwise&&B("W016",this,this.id),this.left=t,this.right=$(e,n),this},r}function yt(e){return Y(e,20).exps=!0,ut(e,function(e,t,n){return f.option.bitwise&&B("W016",n,n.id),vt(e,t,n),n.right=$(e,10),n},20)}function bt(e){var t=Y(e,150);return t.led=function(e,t){return f.option.plusplus&&B("W016",this,this.id),vt(e,t,this),this.left=t,this},t}function wt(e,t,n){if(!f.tokens.next.identifier)return;n||W();var r=f.tokens.curr,i=f.tokens.curr.value;return L(e,r)?t&&f.inES5()?i:(B("W024",f.tokens.curr,f.tokens.curr.id),i):i}function Et(e){if(!cn(f.tokens.next,"..."))return!1;f.inES6(!0)||B("W119",f.tokens.next,e+" operator","6"),W();if(cn(f.tokens.next,"...")){B("E024",f.tokens.next,"...");while(cn(f.tokens.next,"..."))W()}return!0}function St(e,t){var n=wt(e,t,!1);if(n)return n;F("E030",f.tokens.next,f.tokens.next.value),f.tokens.next.id!==";"&&W()}function xt(e){var t=0,n;if(f.tokens.next.id!==";"||e.inBracelessBlock)return;for(;;){do n=U(t),t+=1;while(n.id!=="(end)"&&n.id==="(comment)");if(n.reach)return;if(n.id!=="(endline)"){if(n.id==="function"){f.option.latedef===!0&&B("W026",n);break}B("W027",n,n.value,e.value);break}}}function Tt(e){if(f.tokens.next.id!==";"){if(f.tokens.next.isUnclosed)return W();var t=J(f.tokens.curr,f.tokens.next)&&f.tokens.next.id!=="(end)",n=cn(f.tokens.next,"}");t&&!n&&(e.id!=="do"||!f.inES6(!0))?I("E058",f.tokens.curr.line,f.tokens.curr.character):f.option.asi||n&&t&&f.option.lastsemic||j("W033",f.tokens.curr.line,f.tokens.curr.character)}else W(";")}function Nt(e){var t=g,n,r=f.tokens.next,i=!1;e|=p.initial;if(r.id===";"){W(";");return}var s=L(e,r);s&&r.meta&&r.meta.isFutureReservedWord&&!r.fud&&(B("W024",r,r.id),s=!1),r.identifier&&!s&&U().id===":"&&(W(),W(":"),i=!0,f.funct["(scope)"].stack(),f.funct["(scope)"].block.addLabel(r.value,{token:f.tokens.curr}),!f.tokens.next.labelled&&f.tokens.next.value!=="{"&&B("W028",f.tokens.next,r.value,f.tokens.next.value),r=f.tokens.next);if(r.id==="{"){var o=f.funct["(verb)"]==="case"&&f.tokens.curr.value===":";Lt(e,!0,!0,!1,!1,o),i&&f.funct["(scope)"].unstack();return}return n=$(e,0),n&&(!n.identifier||n.value!=="function")&&(n.type!=="(punctuator)"||!n.left||!n.left.identifier||n.left.value!=="function")&&!f.isStrict()&&f.stmtMissingStrict()&&B("E007"),r.block||(!f.option.expr&&(!n||!n.exps)?B("W030",f.tokens.curr):f.option.nonew&&n&&n.left&&n.id==="("&&n.left.id==="new"&&B("W031",r),Tt(r)),g=t,i&&f.funct["(scope)"].unstack(),n}function Ct(e){var t=[],n;while(!f.tokens.next.reach&&f.tokens.next.id!=="(end)")f.tokens.next.id===";"?(n=U(),(!n||n.id!=="("&&n.id!=="[")&&B("W032"),W(";")):t.push(Nt(e));return t}function kt(){var e=f.tokens.next;while(f.tokens.next.id==="(string)"){var t=z();if(!V(0,e,t))break;e=t,W();var n=f.tokens.curr.value;(f.directive[n]||n==="use strict"&&f.option.strict==="implied")&&B("W034",f.tokens.curr,n),n==="use strict"&&f.inES7()&&!f.funct["(global)"]&&f.funct["(hasSimpleParams)"]===!1&&F("E065",f.tokens.curr),f.directive[n]=!0,Tt(e)}f.isStrict()&&(f.option.undef=!0)}function Lt(e,t,n,r,i,s){var o,u=m,a=g,l,c,h;m=t,c=f.tokens.next;var d=f.funct["(metrics)"];d.nestedBlockDepth+=1,d.verifyMaxNestedBlockDepthPerFunction();if(f.tokens.next.id==="{"){W("{"),f.funct["(scope)"].stack();if(f.tokens.next.id!=="}"){g+=f.option.indent;while(!t&&f.tokens.next.from>g)g+=f.option.indent;if(r){l={};for(h in f.directive)l[h]=f.directive[h];kt(),f.funct["(isStrict)"]=f.isStrict(),f.option.strict&&f.funct["(context)"]["(global)"]&&!l["use strict"]&&!f.isStrict()&&B("E007")}o=Ct(e),d.statementCount+=o.length,g-=f.option.indent}else r&&(f.funct["(isStrict)"]=f.isStrict());W("}",c),r&&(f.funct["(scope)"].validateParams(i),l&&(f.directive=l)),f.funct["(scope)"].unstack(),g=a}else if(!t)if(r){f.funct["(scope)"].stack(),n&&!i&&!f.inMoz()&&F("W118",f.tokens.curr,"function closure expressions"),i&&f.funct["(scope)"].validateParams(!0);var v=$(e,10);f.option.noreturnawait&&e&p.async&&v.identifier&&v.value==="await"&&B("W146",v),f.option.strict&&f.funct["(context)"]["(global)"]&&(f.isStrict()||B("E007")),f.funct["(scope)"].unstack()}else F("E021",f.tokens.next,"{",f.tokens.next.value);else{f.funct["(scope)"].stack(),(!n||f.option.curly)&&B("W116",f.tokens.next,"{",f.tokens.next.value);var y=f.funct["(verb)"]==="if"||f.tokens.curr.id==="else";f.tokens.next.inBracelessBlock=!0,g+=f.option.indent,o=[Nt(e)],g-=f.option.indent,o[0]&&o[0].declaration&&(!y||o[0].id!=="function")&&F("E048",o[0],o[0].id[0].toUpperCase()+o[0].id.slice(1)),f.funct["(scope)"].unstack()}switch(f.funct["(verb)"]){case"break":case"continue":case"return":case"throw":if(s)break;default:f.funct["(verb)"]=null}return m=u,t&&f.option.noempty&&(!o||o.length===0)&&B("W035",f.tokens.prev),d.nestedBlockDepth-=1,o}function At(e){E&&typeof E[e]!="boolean"&&B("W036",f.tokens.curr,e),typeof w[e]=="number"?w[e]+=1:w[e]=1}function _t(e,t){var n=Object.create(null),r,i,s,o,u,a;f.tokens.next.value==="{"?W("{"):(B("W116",f.tokens.curr,"identifier",f.tokens.next.type),W());while(f.tokens.next.value!=="}"){o=!1,u=!1,t&=~p.preAsync,f.tokens.next.value==="static"&&!cn(U(),"(")&&(o=!0,W()),f.tokens.next.value==="async"&&(cn(U(),"(")||(t|=p.preAsync,W(),Q(f.tokens.curr),cn(f.tokens.next,"*")&&(u=!0,W("*"),f.inES9()||B("W119",f.tokens.next,"async generators","9")),f.inES8()||B("W119",f.tokens.curr,"async functions","8"))),f.tokens.next.value==="*"&&(u=!0,W()),s=f.tokens.next,s.value!=="set"&&s.value!=="get"||!!cn(U(),"(")?i=null:(u&&F("E024",s,s.value),i=s.value,W(),s=f.tokens.next,!o&&s.value==="constructor"?F("E049",s,"class "+i+"ter method",s.value):o&&s.value==="prototype"&&F("E049",s,"static class "+i+"ter method",s.value));switch(s.value){case";":B("W032",s),W();break;case"constructor":o?(r=jt(t),un(n,r,s,!0,o),Dt(e,t,r,u)):(u||t&p.preAsync?F("E024",s,s.value):a?F("E024",s,s.value):a=!i&&!o,W(),Dt(e,t,f.nameStack.infer()));break;case"[":r=fn(t),Dt(e,t,r,u);break;default:r=jt(t);if(r===undefined){F("E024",s,s.value),W();break}i?(an(i,n,r,s,!0,o),r=f.nameStack.infer()):(o&&r==="prototype"&&F("E049",s,"static class method",r),un(n,r,s,!0,o)),Dt(e,t,r,u)}}W("}"),Vt(n),f.inClassBody=!1,f.funct["(scope)"].unstack()}function Dt(e,t,n,r){r&&(f.inES6()||B("W119",f.tokens.curr,"function*","6"));if(f.tokens.next.value!=="("){F("E054",f.tokens.next,f.tokens.next.value),W();if(f.tokens.next.value==="{"){W(),f.tokens.next.value==="}"&&(B("W116",f.tokens.next,"(",f.tokens.next.value),W(),St(t),W());return}while(f.tokens.next.value!=="(")W()}Ut(t,{name:n,type:r?"generator":null,isMethod:!0,statement:e})}function Pt(e){var t=f.tokens.next,n=-1,r;do t.value==="("?e+=1:t.value===")"&&(e-=1),n+=1,r=t,t=U(n);while((e!==0||r.value!==")")&&t.type!=="(end)");return t}function Ht(e){var t={};t.exps=!0,f.funct["(comparray)"].stack();var n=!1;return f.tokens.next.value!=="for"&&(n=!0,f.inMoz()||B("W116",f.tokens.next,"for",f.tokens.next.value),f.funct["(comparray)"].setState("use"),t.right=$(e,10)),W("for"),f.tokens.next.value==="each"&&(W("each"),f.inMoz()||B("W118",f.tokens.curr,"for each")),W("("),f.funct["(comparray)"].setState("define"),t.left=$(e,130),r.includes(["in","of"],f.tokens.next.value)?W():F("E045",f.tokens.curr),f.funct["(comparray)"].setState("generate"),$(e,10),W(")"),f.tokens.next.value==="if"&&(W("if"),W("("),f.funct["(comparray)"].setState("filter"),$(e,10),W(")")),n||(f.funct["(comparray)"].setState("use"),t.right=$(e,10)),W("]"),f.funct["(comparray)"].unstack(),t}function Bt(){return!!f.funct["(method)"]}function jt(e,t){var n,r=!0;return typeof t=="object"?n=t:(r=t,n=wt(e,!0,r)),n?typeof n=="object"&&(n.id==="(string)"||n.id==="(identifier)"?n=n.value:n.id==="(number)"&&(n=n.value.toString())):f.tokens.next.id==="(string)"?(n=f.tokens.next.value,r||W()):f.tokens.next.id==="(number)"&&(n=f.tokens.next.value.toString(),r||W()),n==="hasOwnProperty"&&B("W001"),n}function Ft(e,t){function d(e){f.funct["(scope)"].addParam.apply(f.funct["(scope)"],e)}var n,i=[],s,o=[],u,a=!1,l=!1,c=0,h=t&&t.loneArg,p=!1;if(h&&h.identifier===!0)return f.funct["(scope)"].addParam(h.value,h),{arity:1,params:[h.value],isSimple:!0};n=f.tokens.next,(!t||!t.parsedOpening)&&W("(");if(f.tokens.next.id===")"){W(")");return}for(;;){c++;var v=[];if(r.includes(["{","["],f.tokens.next.id)){p=!0,o=Jt(e);for(u in o)u=o[u],u.id&&(i.push(u.id),v.push([u.id,u.token]))}else{l=Et("rest"),s=St(e);if(s)i.push(s),v.push([s,f.tokens.curr]);else while(!ln(f.tokens.next,[",",")"]))W()}a&&f.tokens.next.id!=="="&&F("W138",f.tokens.curr),f.tokens.next.id==="="&&(f.inES6()||B("W119",f.tokens.next,"default parameters","6"),l&&F("E062",f.tokens.next),W("="),a=!0,$(e,10)),v.forEach(d),f.tokens.next.id===","&&(l&&B("W131",f.tokens.next),W(","),G({allowTrailing:!0}));if(f.tokens.next.id===")")return f.tokens.curr.id===","&&!f.inES8()&&B("W119",f.tokens.curr,"Trailing comma in function parameters","8"),W(")",n),{arity:c,params:i,isSimple:!p&&!l&&!a}}}function It(e,t,n){var i={"(name)":e,"(breakage)":0,"(loopage)":0,"(isStrict)":"unknown","(global)":!1,"(line)":null,"(character)":null,"(metrics)":null,"(statement)":null,"(context)":null,"(scope)":null,"(comparray)":null,"(yielded)":null,"(arrow)":null,"(async)":null,"(params)":null};return t&&r.extend(i,{"(line)":t.line,"(character)":t.character,"(metrics)":zt(t)}),r.extend(i,n),i["(context)"]&&(i["(scope)"]=i["(context)"]["(scope)"],i["(comparray)"]=i["(context)"]["(comparray)"]),i}function qt(e){return e["(global)"]&&!e["(verb)"]}function Rt(e,t){function o(){if(f.tokens.curr.template&&f.tokens.curr.tail&&f.tokens.curr.context===n)return!0;var e=f.tokens.next.template&&f.tokens.next.tail&&f.tokens.next.context===n;return e&&W(),e||f.tokens.next.isUnclosed}var n=this.context,r=this.noSubst,i=this.depth,s=typeof t=="number"?null:t;if(!r)while(!o())!f.tokens.next.template||f.tokens.next.depth>i?$(e,0):W();return{id:"(template)",type:"(template)",tag:s}}function Ut(e,t){var n,r,i,s,o,u,a,l,c,h=f.option,v=f.ignored,m=e&p.preAsync;t&&(i=t.name,s=t.statement,o=t.classExprBinding,u=t.type==="generator",a=t.type==="arrow",l=t.isMethod,c=t.ignoreLoopFunc),e&=~p.noin,e&=~p.tryClause,m?e|=p.async:e&=~p.async,u?e|=p.yield:a||(e&=~p.yield),e&=~p.preAsync,f.option=Object.create(f.option),f.ignored=Object.create(f.ignored),f.funct=It(i||f.nameStack.infer(),f.tokens.next,{"(statement)":s,"(context)":f.funct,"(arrow)":a,"(method)":l,"(async)":m}),n=f.funct,r=f.tokens.curr,d.push(f.funct),f.funct["(scope)"].stack("functionouter");var g=!l&&(i||o);g&&f.funct["(scope)"].block.add(g,o?"class":"function",f.tokens.curr,!1),a||f.funct["(scope)"].funct.add("arguments","var",r,!1),f.funct["(scope)"].stack("functionparams");var y=Ft(e,t);return y?(f.funct["(params)"]=y.params,f.funct["(hasSimpleParams)"]=y.isSimple,f.funct["(metrics)"].arity=y.arity,f.funct["(metrics)"].verifyMaxParametersPerFunction()):(f.funct["(params)"]=[],f.funct["(metrics)"].arity=0,f.funct["(hasSimpleParams)"]=!0),a&&(e&=~p.yield,f.inES6(!0)||B("W119",f.tokens.curr,"arrow function syntax (=>)","6"),t.loneArg||W("=>")),Lt(e,!1,!0,!0,a),!f.option.noyield&&u&&!f.funct["(yielded)"]&&B("W124",f.tokens.curr),f.funct["(metrics)"].verifyMaxStatementsPerFunction(),f.funct["(metrics)"].verifyMaxComplexityPerFunction(),f.funct["(unusedOption)"]=f.option.unused,f.option=h,f.ignored=v,f.funct["(last)"]=f.tokens.curr.line,f.funct["(lastcharacter)"]=f.tokens.curr.character,f.funct["(scope)"].unstack(),f.funct["(scope)"].unstack(),f.funct=f.funct["(context)"],!c&&!f.option.loopfunc&&f.funct["(loopage)"]&&n["(outerMutables)"]&&B("W083",r,n["(outerMutables)"].join(", ")),n}function zt(e){return{statementCount:0,nestedBlockDepth:-1,ComplexityCount:1,arity:0,verifyMaxStatementsPerFunction:function(){f.option.maxstatements&&this.statementCount>f.option.maxstatements&&B("W071",e,this.statementCount)},verifyMaxParametersPerFunction:function(){r.isNumber(f.option.maxparams)&&this.arity>f.option.maxparams&&B("W072",e,this.arity)},verifyMaxNestedBlockDepthPerFunction:function(){f.option.maxdepth&&this.nestedBlockDepth>0&&this.nestedBlockDepth===f.option.maxdepth+1&&B("W073",null,this.nestedBlockDepth)},verifyMaxComplexityPerFunction:function(){var t=f.option.maxcomplexity,n=this.ComplexityCount;t&&n>t&&B("W074",e,n)}}}function Wt(){f.funct["(metrics)"].ComplexityCount+=1}function Xt(e){if(!e||e.paren)return;if(e.id===","){Xt(e.right);return}switch(e.id){case"=":case"+=":case"-=":case"*=":case"%=":case"&=":case"|=":case"^=":case"/=":f.option.boss||B("W084",e)}}function Vt(e){if(f.inES5())for(var t in e)e[t]&&e[t].setterToken&&!e[t].getterToken&&!e[t].static&&B("W078",e[t].setterToken)}function $t(e,t,n){if(cn(f.tokens.next,".")){var r=f.tokens.curr.id;W(".");var i=St(e);return f.tokens.curr.isMetaProperty=!0,t!==i?F("E057",f.tokens.prev,r,i):n(),f.tokens.curr}}function Jt(e,t){var n=t&&t.assignment;return e&=~p.noin,f.inES6()||B("W104",f.tokens.curr,n?"destructuring assignment":"destructuring binding","6"),Kt(e,t)}function Kt(e,t){var n,r,i=[],s=t&&t.openingParsed,o=t&&t.assignment,u=o?{assignment:o}:null,a=s?f.tokens.curr:f.tokens.next,l=function(){var t;if(ln(f.tokens.next,["[","{"])){n=Kt(e,u);for(r=0;r<n.length;r++)i.push({id:n[r].id,token:n[r].token})}else if(cn(f.tokens.next,","))i.push({id:null,token:f.tokens.curr});else if(cn(f.tokens.next,"("))W("("),l(),W(")");else{if(o){var s=$(e,20);s&&(vt(e,s),s.identifier&&(t=s.value))}else t=St(e);t&&i.push({id:t,token:f.tokens.curr})}},c=function(e){var t,n;if(cn(f.tokens.next,"["))W("["),$(e,10),W("]"),W(":"),l();else if(f.tokens.next.id==="(string)"||f.tokens.next.id==="(number)")W(),W(":"),l();else{var r=Et("rest");r?(f.inES9()||B("W119",f.tokens.next,"object rest property","9"),f.tokens.next.type==="(identifier)"?t=St(e):(n=$(e,10),F("E030",n,n.value))):t=St(e),!r&&cn(f.tokens.next,":")?(W(":"),l()):t&&(o&&vt(e,f.tokens.curr),i.push({id:t,token:f.tokens.curr})),r&&cn(f.tokens.next,",")&&B("W130",f.tokens.next)}},h,p;if(cn(a,"[")){s||W("["),cn(f.tokens.next,"]")&&B("W137",f.tokens.curr);var d=!1;while(!cn(f.tokens.next,"]")){var v=Et("rest");l(),v&&!d&&cn(f.tokens.next,",")&&(B("W130",f.tokens.next),d=!0),!v&&cn(f.tokens.next,"=")&&(cn(f.tokens.prev,"...")?W("]"):W("="),h=f.tokens.prev,p=$(e,10),p&&p.identifier&&p.value==="undefined"&&B("W080",h,h.value)),cn(f.tokens.next,"]")||W(",")}W("]")}else if(cn(a,"{")){s||W("{"),cn(f.tokens.next,"}")&&B("W137",f.tokens.curr);while(!cn(f.tokens.next,"}")){c(e),cn(f.tokens.next,"=")&&(W("="),h=f.tokens.prev,p=$(e,10),p&&p.identifier&&p.value==="undefined"&&B("W080",h,h.value));if(!cn(f.tokens.next,"}")){W(",");if(cn(f.tokens.next,"}"))break}}W("}")}return i}function Qt(e,t){var n=t.first;if(!n)return;r.zip(e,Array.isArray(n)?n:[n]).forEach(function(e){var t=e[0],n=e[1];t&&n?t.first=n:t&&t.first&&!n&&B("W080",t.first,t.first.value)})}function Gt(e,t,n){var i=n&p.noin,s=n&p.export,o=e==="let",u=e==="const",a,l,c,h;f.inES6()||B("W104",f.tokens.curr,e,"6"),o&&Zt()&&(W("("),f.funct["(scope)"].stack(),h=!0,t.declaration=!1),t.first=[];for(;;){var d=[];r.includes(["{","["],f.tokens.next.value)?(a=Jt(n),l=!1):(a=[{id:St(n),token:f.tokens.curr}],l=!0),!i&&u&&f.tokens.next.id!=="="&&B("E012",f.tokens.curr,f.tokens.curr.value);for(var v in a)a.hasOwnProperty(v)&&(v=a[v],v.id==="let"&&B("W024",v.token,v.id),f.funct["(scope)"].block.isGlobal()&&S[v.id]===!1&&B("W079",v.token,v.id),v.id&&(f.funct["(scope)"].addbinding(v.id,{type:e,token:v.token}),d.push(v.token)));if(f.tokens.next.id==="="){t.hasInitializer=!0,W("="),!i&&U(0).id==="="&&f.tokens.next.identifier&&B("W120",f.tokens.next,f.tokens.next.value);var m=f.tokens.prev;c=$(n,10),c&&(c.identifier&&c.value==="undefined"&&B("W080",m,m.value),l||Qt(d,c))}if(f.tokens.next.value!=="in"&&f.tokens.next.value!=="of")for(v in a)a.hasOwnProperty(v)&&(v=a[v],f.funct["(scope)"].initialize(v.id),l&&s&&f.funct["(scope)"].setExported(v.token.value,v.token));t.first=t.first.concat(d);if(f.tokens.next.id!==",")break;t.hasComma=!0,W(","),G()}return h&&(W(")"),Lt(n,!0,!0),t.block=!0,f.funct["(scope)"].unstack()),t}function Zt(){return f.tokens.next.id==="("&&f.inMoz()}function rn(e,t){return e==="call"&&t["(async)"]?!1:e==="property"&&t["(method)"]?!0:e==="call"&&t["(statement)"]&&t["(statement)"].id==="class"?!0:t["(arrow)"]?rn(e,t["(context)"]):!1}function un(e,t,n,r,i,s){n.identifier&&(t=n.value);var o=t;r&&i&&(o="static "+t);if(e[o]&&t!=="__proto__"&&!s){var u=["key","class method","static class method"];u=u[(r||!1)+(i||!1)],B("W075",f.tokens.next,u,t)}else e[o]=Object.create(null);e[o].basic=!0,e[o].basictkn=n}function an(e,t,n,r,i,s){var o=e==="get"?"getterToken":"setterToken",u=n;f.tokens.curr.accessorType=e,f.nameStack.set(r),i&&s&&(u="static "+n);if(t[u]){if((t[u].basic||t[u][o])&&n!=="__proto__"){var a="";i?(s&&(a+="static "),a+=e+"ter method"):a="key",B("W075",f.tokens.next,a,n)}}else t[u]=Object.create(null);t[u][o]=r,s&&(t[u].static=!0)}function fn(e){W("["),f.tokens.curr.delim=!0,f.tokens.curr.lbp=0,f.inES6()||B("W119",f.tokens.curr,"computed property names","6");var t=$(e&~p.noin,10);return W("]"),t}function ln(e,t){return e.type==="(punctuator)"?r.includes(t,e.value):!1}function cn(e,t){return e.type==="(punctuator)"&&e.value===t}function hn(e){var t=on();t.notJson?(!f.inES6()&&t.isDestAssign&&B("W104",f.tokens.curr,"destructuring assignment","6"),Ct(e)):(f.option.laxbreak=!0,f.jsonMode=!0,dn())}function dn(){function e(){var e={},t=f.tokens.next;W("{");if(f.tokens.next.id!=="}")for(;;){if(f.tokens.next.id==="(end)")F("E026",f.tokens.next,t.line);else{if(f.tokens.next.id==="}"){B("W094",f.tokens.curr);break}f.tokens.next.id===","?F("E028",f.tokens.next):f.tokens.next.id!=="(string)"&&B("W095",f.tokens.next,f.tokens.next.value)}e[f.tokens.next.value]===!0?B("W075",f.tokens.next,"key",f.tokens.next.value):f.tokens.next.value==="__proto__"&&!f.option.proto||f.tokens.next.value==="__iterator__"&&!f.option.iterator?B("W096",f.tokens.next,f.tokens.next.value):e[f.tokens.next.value]=!0,W(),W(":"),dn();if(f.tokens.next.id!==",")break;W(",")}W("}")}function t(){var e=f.tokens.next;W("[");if(f.tokens.next.id!=="]")for(;;){if(f.tokens.next.id==="(end)")F("E027",f.tokens.next,e.line);else{if(f.tokens.next.id==="]"){B("W094",f.tokens.curr);break}f.tokens.next.id===","&&F("E028",f.tokens.next)}dn();if(f.tokens.next.id!==",")break;W(",")}W("]")}switch(f.tokens.next.id){case"{":e();break;case"[":t();break;case"true":case"false":case"null":case"(number)":case"(string)":W();break;case"-":W("-"),W("(number)");break;default:F("E003",f.tokens.next)}}function vn(e,t,n){var r,i,s,o;for(i=0;i<e.length;i+=1){o=e[i],t.scope=o.elem,r=v.errors.length,gn(o.code,t,n);for(s=r;s<v.errors.length;s+=1)v.errors[s].line+=o.token.line-1}}var e,t={"<":!0,"<=":!0,"==":!0,"===":!0,"!==":!0,"!=":!0,">":!0,">=":!0,"+":!0,"-":!0,"*":!0,"/":!0,"%":!0},n,d,m,g,y,b,w,E,S,x=[],T=new i.EventEmitter,ct={};ct.legacy=["xml","unknown"],ct.es3=["undefined","boolean","number","string","function","object"],ct.es3=ct.es3.concat(ct.legacy),ct.es6=ct.es3.concat("symbol","bigint"),it("(number)",function(){return f.tokens.next.id==="."&&B("W005",this),this}),it("(string)",function(){return this}),f.syntax["(identifier)"]={type:"(identifier)",lbp:0,identifier:!0,nud:function(e){var t=this.value,n=f.tokens.next.id==="=>";return L(e,this)?B("W024",this,t):!n&&!f.funct["(comparray)"].check(t)&&f.funct["(scope)"].block.use(t,f.tokens.curr),this},led:function(){F("E033",f.tokens.next,f.tokens.next.value)}};var Ot={identifier:!1,template:!0};f.syntax["(template)"]=r.extend({lbp:155,type:"(template)",nud:Rt,led:Rt,noSubst:!1},Ot),f.syntax["(template middle)"]=r.extend({lbp:0,type:"(template middle)",noSubst:!1},Ot),f.syntax["(template tail)"]=r.extend({lbp:0,type:"(template tail)",tail:!0,noSubst:!1},Ot),f.syntax["(no subst template)"]=r.extend({lbp:155,type:"(template)",nud:Rt,led:Rt,noSubst:!0,tail:!0},Ot),it("(regexp)",function(){return this}),Z("(endline)"),function(e){e.line=e.from=0}(Z("(begin)")),Z("(end)").reach=!0,Z("(error)").reach=!0,Z("}").reach=!0,Z(")"),Z("]"),Z('"').reach=!0,Z("'").reach=!0,Z(";"),Z(":").reach=!0,Z("#"),st("else"),st("case").reach=!0,st("catch"),st("default").reach=!0,st("finally"),st("true",function(){return this}),st("false",function(){return this}),st("null",function(){return this}),st("this",function(){return f.isStrict()&&!Bt()&&!f.option.validthis&&(f.funct["(statement)"]&&f.funct["(name)"].charAt(0)>"Z"||f.funct["(global)"])&&B("W040",this),this}),st("super",function(){return sn.call(f.tokens.curr,this),this}),mt("=","assign"),mt("+=","assignadd"),mt("-=","assignsub"),mt("*=","assignmult"),mt("/=","assigndiv").nud=function(){F("E014")},mt("%=","assignmod"),mt("**=",function(e,t,n){return f.inES7()||B("W119",n,"Exponentiation operator","7"),n.left=t,vt(e,t,n),n.right=$(e,10),n}),yt("&="),yt("|="),yt("^="),yt("<<="),yt(">>="),yt(">>>="),ut(",",function(e,t,n){return f.option.nocomma&&B("W127",n),n.left=t,G()?n.right=$(e,10):n.right=null,n},10,!0),ut("?",function(e,t,n){return Wt(),n.left=t,n.right=$(e&~p.noin,10),W(":"),$(e,10),n},30);var Mt=40;ut("||",function(e,t,n){return Wt(),n.left=t,n.right=$(e,Mt),n},Mt),ut("&&","and",50),ut("**",function(e,t,n){return f.inES7()||B("W119",n,"Exponentiation operator","7"),!t.paren&&lt(t)&&F("E024",n,"**"),n.left=t,n.right=$(e,n.rbp),n},150),f.syntax["**"].rbp=140,gt("|","bitor",70),gt("^","bitxor",80),gt("&","bitand",90),ft("==",function(e,t,n){var r=f.option.eqnull&&((t&&t.value)==="null"||(n&&n.value)==="null");switch(!0){case!r&&f.option.eqeqeq:this.from=this.character,B("W116",this,"===","==");break;case ht(n,t,f):B("W122",this,n.value);break;case ht(t,n,f):B("W122",this,t.value)}return this}),ft("===",function(e,t,n){return ht(n,t,f)?B("W122",this,n.value):ht(t,n,f)&&B("W122",this,t.value),this}),ft("!=",function(e,t,n){var r=f.option.eqnull&&((t&&t.value)==="null"||(n&&n.value)==="null");return!r&&f.option.eqeqeq?(this.from=this.character,B("W116",this,"!==","!=")):ht(n,t,f)?B("W122",this,n.value):ht(t,n,f)&&B("W122",this,t.value),this}),ft("!==",function(e,t,n){return ht(n,t,f)?B("W122",this,n.value):ht(t,n,f)&&B("W122",this,t.value),this}),ft("<"),ft(">"),ft("<="),ft(">="),gt("<<","shiftleft",120),gt(">>","shiftright",120),gt(">>>","shiftrightunsigned",120),ut("in","in",120),ut("instanceof",function(e,t,n){var r,i=f.funct["(scope)"];return n.left=t,n.right=r=$(e,120),r?((r.id==="(number)"||r.id==="(string)"||r.value==="null"||r.value==="undefined"&&!i.has("undefined")||r.arity==="unary"||r.id==="{"||r.id==="["&&!r.right||r.id==="(regexp)"||r.id==="(template)"&&!r.tag)&&F("E060"),r.id==="function"&&B("W139"),n):n},120),ut("+",function(e,t,n){var r=f.tokens.next,i;return n.left=t,n.right=i=$(e,130),t&&i&&t.id==="(string)"&&i.id==="(string)"?(t.value+=i.value,t.character=i.character,!f.option.scripturl&&a.javascriptURL.test(t.value)&&B("W050",t),t):((r.id==="+"||r.id==="++")&&B("W007",n.right),n)},130),rt("+",function(e){var t=f.tokens.next;return this.arity="unary",this.right=$(e,150),(t.id==="+"||t.id==="++")&&B("W007",this.right),this}),ut("-",function(e,t,n){var r=f.tokens.next;return n.left=t,n.right=$(e,130),(r.id==="-"||r.id==="--")&&B("W006",n.right),n},130),rt("-",function(e){var t=f.tokens.next;return this.arity="unary",this.right=$(e,150),(t.id==="-"||t.id==="--")&&B("W006",this.right),this}),ut("*","mult",140),ut("/","div",140),ut("%","mod",140),bt("++"),rt("++","preinc"),f.syntax["++"].exps=!0,bt("--"),rt("--","predec"),f.syntax["--"].exps=!0,rt("delete",function(e){this.arity="unary";var t=$(e,150);return t?(t.id!=="."&&t.id!=="["&&B("W051"),this.first=t,t.identifier&&!f.isStrict()&&(t.forgiveUndef=!0),this):this}).exps=!0,rt("~",function(e){return f.option.bitwise&&B("W016",this,"~"),this.arity="unary",this.right=$(e,150),this}),ut("..."),rt("!",function(e){return this.arity="unary",this.right=$(e,150),this.right||P("E041",this),t[this.right.id]===!0&&B("W018",this,"!"),this}),rt("typeof",function(e){this.arity="unary";var t=$(e,150);return this.first=this.right=t,t||P("E041",this),t.identifier&&(t.forgiveUndef=!0),this}),rt("new",function(e){var t=$t(e,"target",function(){f.inES6(!0)||B("W119",f.tokens.prev,"new.target","6");var e,t=f.funct;while(t){e=!t["(global)"];if(!t["(arrow)"])break;t=t["(context)"]}e||B("W136",f.tokens.prev,"new.target")});if(t)return t;var n=$(e,155),r;if(n&&n.id!=="function")if(n.identifier)switch(n.value){case"Number":case"String":case"Boolean":case"Math":case"JSON":B("W053",f.tokens.prev,n.value);break;case"Symbol":f.inES6()&&B("W053",f.tokens.prev,n.value);break;case"Function":f.option.evil||B("W054");break;case"Date":case"RegExp":case"this":break;default:r=n.value.substr(0,1),f.option.newcap&&(r<"A"||r>"Z")&&!f.funct["(scope)"].isPredefined(n.value)&&B("W055",f.tokens.curr)}else n.id!=="."&&n.id!=="["&&n.id!=="("&&B("W056",f.tokens.curr);else f.option.supernew||B("W057",this);return f.tokens.next.id!=="("&&!f.option.supernew&&B("W058",f.tokens.curr,f.tokens.curr.value),this.first=this.right=n,this}),f.syntax["new"].exps=!0,tt("class",function(e){var t,n,r=e&p.export;return f.inES6()||B("W104",f.tokens.curr,"class","6"),f.inClassBody=!0,f.tokens.next.identifier&&f.tokens.next.value!=="extends"&&(n=f.tokens.next,t=n.value,St(e),f.funct["(scope)"].addbinding(t,{type:"class",initialized:!1,token:n})),f.tokens.next.value==="extends"&&(W("extends"),$(e,0)),n&&(this.name=t,f.funct["(scope)"].initialize(t),r&&f.funct["(scope)"].setExported(t,n)),f.funct["(scope)"].stack(),_t(this,e),this}).exps=!0,rt("class",function(e){var t,n;return f.inES6()||B("W104",f.tokens.curr,"class","6"),f.inClassBody=!0,f.tokens.next.identifier&&f.tokens.next.value!=="extends"&&(n=f.tokens.next,t=n.value,St(e)),f.tokens.next.value==="extends"&&(W("extends"),$(e,0)),f.funct["(scope)"].stack(),n&&(this.name=t,f.funct["(scope)"].addbinding(t,{type:"class",initialized:!0,token:n}),f.funct["(scope)"].block.use(t,n)),_t(this,e),this}),rt("void").exps=!0,ut(".",function(e,t,n){var r=St(e,!0);return typeof r=="string"&&At(r),n.left=t,n.right=r,r&&r==="hasOwnProperty"&&f.tokens.next.value==="="&&B("W001"),!t||t.value!=="arguments"||r!=="callee"&&r!=="caller"?!f.option.evil&&t&&t.value==="document"&&(r==="write"||r==="writeln")&&B("W060",t):f.option.noarg?B("W059",t,r):f.isStrict()&&F("E008"),!f.option.evil&&(r==="eval"||r==="execScript")&&pt(t,f)&&B("W061"),n},160,!0),ut("(",function(e,t,n){f.option.immed&&t&&!t.immed&&t.id==="function"&&B("W062"),f.option.asi&&ln(f.tokens.prev,[")","]"])&&!J(f.tokens.prev,f.tokens.curr)&&B("W014",f.tokens.curr,f.tokens.curr.id);var r=0,i=[];t&&t.type==="(identifier)"&&t.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)&&"Array Number String Boolean Date Object Error Symbol".indexOf(t.value)===-1&&(t.value==="Math"?B("W063",t):f.option.newcap&&B("W064",t));if(f.tokens.next.id!==")")for(;;){Et("spread"),i[i.length]=$(e,10),r+=1;if(f.tokens.next.id!==",")break;W(","),G({allowTrailing:!0});if(f.tokens.next.id===")"){f.inES8()||B("W119",f.tokens.curr,"Trailing comma in arguments lists","8");break}}return W(")"),typeof t=="object"&&(!f.inES5()&&t.value==="parseInt"&&r===1&&B("W065",f.tokens.curr),f.option.evil||(t.value==="eval"||t.value==="Function"||t.value==="execScript"?B("W061",t):!i[0]||i[0].id!=="(string)"||t.value!=="setTimeout"&&t.value!=="setInterval"?i[0]&&i[0].id==="(string)"&&t.value==="."&&t.left.value==="window"&&(t.right==="setTimeout"||t.right==="setInterval")&&(B("W066",t),q(t,i[0])):(B("W066",t),q(t,i[0]))),!t.identifier&&t.id!=="."&&t.id!=="["&&t.id!=="=>"&&t.id!=="("&&t.id!=="&&"&&t.id!=="||"&&t.id!=="?"&&t.id!=="async"&&(!f.inES6()||!t["(name)"])&&B("W067",n)),n.left=t,n},155,!0).exps=!0,rt("(",function(e,t){var n,r,i,s,o=f.tokens.curr,u=f.tokens.prev,a=!f.option.singleGroups,l=Pt(1);f.tokens.next.id==="function"&&(r=f.tokens.next.immed=!0);if(l.value==="=>")return l.funct=Ut(e,{type:"arrow",parsedOpening:!0}),l;if(f.tokens.next.id===")"){W(")");return}n=$(e,0),W(")",this);if(!n)return;n.paren=!0,f.option.immed&&n&&n.id==="function"&&f.tokens.next.id!=="("&&f.tokens.next.id!=="."&&f.tokens.next.id!=="["&&B("W068",this);if(n.id===","){i=n.left;while(i.id===",")i=i.left;s=n.right}else i=s=n,a||(r||(r=n.id==="async"),a=o.beginsStmt&&(n.id==="{"||r)||r&&(!V()||f.tokens.prev.id!=="}")||n.id==="=>"&&!V()||n.id==="{"&&u.id==="=>"||lt(n)&&f.tokens.next.id==="**"||n.type==="(number)"&&cn(l,".")&&/^\d+$/.test(n.value)||o.beginsStmt&&n.id==="="&&n.left.id==="{");return!a&&(X(i)||i!==s)&&(a=t>i.lbp||t>0&&t===i.lbp||!V()&&s.rbp<f.tokens.next.lbp),a||B("W126",o),n}),at("=>"),ut("[",function(e,t,n){var r,i,s;return f.option.asi&&ln(f.tokens.prev,[")","]"])&&!J(f.tokens.prev,f.tokens.curr)&&B("W014",f.tokens.curr,f.tokens.curr.id),r=$(e&~p.noin,10),r&&r.type==="(string)"&&(!f.option.evil&&(r.value==="eval"||r.value==="execScript")&&pt(t,f)&&B("W061"),At(r.value),!f.option.sub&&a.identifier.test(r.value)&&(i=f.syntax[r.value],i?s=!L(e,i):s=r.value!=="eval"&&r.value!=="arguments",s&&B("W069",f.tokens.prev,r.value))),W("]",n),r&&r.value==="hasOwnProperty"&&f.tokens.next.value==="="&&B("W001"),n.left=t,n.right=r,n},160,!0),rt("[",function(e){var t=on();if(t.isCompArray)return!f.option.esnext&&!f.inMoz()&&B("W118",f.tokens.curr,"array comprehension"),Ht(e);if(t.isDestAssign)return this.destructAssign=Jt(e,{openingParsed:!0,assignment:!0}),this;var n=!J(f.tokens.curr,f.tokens.next);this.first=[],n&&(g+=f.option.indent,f.tokens.next.from===g+f.option.indent&&(g+=f.option.indent));while(f.tokens.next.id!=="(end)"){while(f.tokens.next.id===","){if(!f.option.elision){if(!!f.inES5()){B("W128");do W(",");while(f.tokens.next.id===",");continue}B("W070")}W(",")}if(f.tokens.next.id==="]")break;Et("spread"),this.first.push($(e,10));if(f.tokens.next.id!==","){f.option.trailingcomma&&f.inES5()&&j("W140",f.tokens.curr.line,f.tokens.curr.character);break}W(","),G({allowTrailing:!0});if(f.tokens.next.id==="]"&&!f.inES5()){B("W070",f.tokens.curr);break}}return n&&(g-=f.option.indent),W("]",this),this}),function(e){e.nud=function(e){var t,n,r,i,s,o=!1,u,a=Object.create(null),l=!1;t=!J(f.tokens.curr,f.tokens.next),t&&(g+=f.option.indent,f.tokens.next.from===g+f.option.indent&&(g+=f.option.indent));var c=on();if(c.isDestAssign)return this.destructAssign=Jt(e,{openingParsed:!0,assignment:!0}),this;f.inObjectBody=!0;for(;;){if(f.tokens.next.id==="}")break;u=f.tokens.next.value;if(!f.tokens.next.identifier||z().id!==","&&z().id!=="}")if(U().id===":"||u!=="get"&&u!=="set")if(Et("spread"))f.inES9()||B("W119",f.tokens.next,"object spread property","9"),$(e,10);else{f.tokens.next.id==="async"&&!ln(U(),["(",":"])?(f.inES8()||B("W119",f.tokens.next,"async functions","8"),l=!0,W(),Q(f.tokens.curr)):l=!1,f.tokens.next.value==="*"&&f.tokens.next.type==="(punctuator)"?(l&&!f.inES9()?B("W119",f.tokens.next,"async generators","9"):f.inES6()||B("W104",f.tokens.next,"generator functions","6"),W("*"),o=!0):o=!1;if(f.tokens.next.id==="[")r=fn(e),f.nameStack.set(r);else{f.nameStack.set(f.tokens.next),r=jt(e),un(a,r,f.tokens.next);if(typeof r!="string")break}f.tokens.next.value==="("?(f.inES6()||B("W104",f.tokens.curr,"concise methods","6"),Ut(l?e|p.preAsync:e,{isMethod:!0,type:o?"generator":null})):(W(":"),$(e,10))}else W(u),f.inES5()||F("E034"),f.tokens.next.id==="["?r=fn(e):(r=jt(e),!r&&!f.inES6()&&F("E035")),r&&an(u,a,r,f.tokens.curr),s=f.tokens.next,n=Ut(e,{isMethod:!0}),i=n["(params)"],u==="get"&&r&&i.length?B("W076",s,i[0],r):u==="set"&&r&&n["(metrics)"].arity!==1&&B("W077",s,r);else f.inES6()||B("W104",f.tokens.next,"object short notation","6"),r=jt(e,!0),un(a,r,f.tokens.next),$(e,10);At(r);if(f.tokens.next.id!==","){f.option.trailingcomma&&f.inES5()&&j("W140",f.tokens.curr.line,f.tokens.curr.character);break}W(","),G({allowTrailing:!0,property:!0}),f.tokens.next.id===","?B("W070",f.tokens.curr):f.tokens.next.id==="}"&&!f.inES5()&&B("W070",f.tokens.curr)}return t&&(g-=f.option.indent),W("}",this),Vt(a),f.inObjectBody=!1,this},e.fud=function(){F("E036",f.tokens.curr)}}(Z("{"));var Yt=et("const",function(e){return Gt("const",this,e)});Yt.exps=!0,Yt.declaration=!0;var en=et("let",function(e){return Gt("let",this,e)});en.nud=function(e,t){if(!Zt())return this.exps=!1,f.syntax["(identifier)"].nud.apply(this,arguments);f.funct["(scope)"].stack(),W("("),f.tokens.prev.fud(e),W(")"),$(e,t),f.funct["(scope)"].unstack()},en.meta={es5:!0,isFutureReservedWord:!1,strictOnly:!0},en.exps=!0,en.declaration=!0,en.useFud=function(e){var t=f.tokens.next,n;return this.line!==t.line&&!f.inES6()?!1:(n=t.identifier&&(!L(e,t)||t.id==="let"),n||ln(t,["{","["])||Zt())};var tn=et("var",function(e){var t=e&p.noin,n=e&p.export,i,o,u,a;this.first=[];for(;;){var l=[];r.includes(["{","["],f.tokens.next.value)?(i=Jt(e),o=!1):(i=[],a=St(e),a&&i.push({id:a,token:f.tokens.curr}),o=!0),f.option.varstmt&&B("W132",this);for(var c in i)i.hasOwnProperty(c)&&(c=i[c],f.funct["(global)"]&&!f.impliedClosure()&&(S[c.id]===!1?B("W079",c.token,c.id):f.option.futurehostile===!1&&(!f.inES5()&&s.ecmaIdentifiers[5][c.id]===!1||!f.inES6()&&s.ecmaIdentifiers[6][c.id]===!1)&&B("W129",c.token,c.id)),c.id&&(f.funct["(scope)"].addbinding(c.id,{type:"var",token:c.token}),o&&n&&f.funct["(scope)"].setExported(c.id,c.token),l.push(c.token)));f.tokens.next.id==="="&&(this.hasInitializer=!0,f.nameStack.set(f.tokens.curr),W("="),U(0).id==="="&&f.tokens.next.identifier&&(!t&&!f.funct["(params)"]||f.funct["(params)"].indexOf(f.tokens.next.value)===-1)&&B("W120",f.tokens.next,f.tokens.next.value),a=f.tokens.prev,u=$(e,10),u&&(!f.funct["(loopage)"]&&u.identifier&&u.value==="undefined"&&B("W080",a,a.value),o||Qt(l,u))),this.first=this.first.concat(l);if(f.tokens.next.id!==",")break;this.hasComma=!0,W(","),G()}return this});tn.exps=!0,tt("function",function(e){var t=e&p.export,n=!1,r=e&p.preAsync,i="";r&&(i="async "),f.tokens.next.value==="*"&&(r&&!f.inES9()?B("W119",f.tokens.prev,"async generators","9"):!r&&!f.inES6(!0)&&B("W119",f.tokens.next,"function*","6"),W("*"),i+="generator ",n=!0),i+="function",m&&B("W082",f.tokens.curr);var s=wt(e)?f.tokens.curr:null;s?(f.funct["(scope)"].addbinding(s.value,{type:i,token:f.tokens.curr,initialized:!0}),t&&f.funct["(scope)"].setExported(s.value,f.tokens.prev)):t||B("W025");var o=Ut(e,{name:s&&s.value,statement:this,type:n?"generator":null,ignoreLoopFunc:m}),u=o["(isStrict)"]&&!f.isStrict();return s&&(o["(name)"]==="arguments"||o["(name)"]==="eval")&&u&&F("E008",s),f.tokens.next.id==="("&&f.tokens.next.line===f.tokens.curr.line&&F("E039"),this}).declaration=!0,rt("function",function(e){var t=!1,n=e&p.preAsync;f.tokens.next.value==="*"&&(n&&!f.inES9()?B("W119",f.tokens.prev,"async generators","9"):!n&&!f.inES6(!0)&&B("W119",f.tokens.curr,"function*","6"),W("*"),t=!0);var r=wt(n?e|p.async:e)?f.tokens.curr:null,i=Ut(e,{name:r&&r.value,type:t?"generator":null});return t&&r&&r.value==="yield"&&F("E024",r,"yield"),r&&(i["(name)"]==="arguments"||i["(name)"]==="eval")&&i["(isStrict)"]&&F("E008",r),this}),tt("if",function(e){var t=f.tokens.next;Wt(),W("(");var n=$(e,0);n||P("E041",this),Xt(n);var r=null;f.option.forin&&f.forinifcheckneeded&&(f.forinifcheckneeded=!1,r=f.forinifchecks[f.forinifchecks.length-1],n.type==="(punctuator)"&&n.value==="!"?r.type="(negative)":r.type="(positive)"),W(")",t);var i=Lt(e,!0,!0);return r&&r.type==="(negative)"&&i&&i[0]&&i[0].type==="(identifier)"&&i[0].value==="continue"&&(r.type="(negative-with-continue)"),f.tokens.next.id==="else"&&(W("else"),f.tokens.next.id==="if"||f.tokens.next.id==="switch"?Nt(e):Lt(e,!0,!0)),this}),tt("try",function(e){function i(){W("(");if(ln(f.tokens.next,["[","{"])){var t=Jt(e);r.each(t,function(e){e.id&&f.funct["(scope)"].addParam(e.id,e,"exception")})}else f.tokens.next.type!=="(identifier)"?B("E030",f.tokens.next,f.tokens.next.value):f.funct["(scope)"].addParam(St(e),f.tokens.curr,"exception");f.tokens.next.value==="if"&&(f.inMoz()||B("W118",f.tokens.curr,"catch filter"),W("if"),$(e,0)),W(")")}var t,n=!1;Lt(e|p.tryClause,!0);while(f.tokens.next.id==="catch")Wt(),t&&!f.inMoz()&&B("W118",f.tokens.next,"multiple catch blocks"),W("catch"),f.tokens.next.id!=="{"?(f.funct["(scope)"].stack("catchparams"),n=!0,i()):f.inES10()||B("W119",f.tokens.curr,"optional catch binding","10"),Lt(e,!1),n&&(f.funct["(scope)"].unstack(),n=!1),t=!0;if(f.tokens.next.id==="finally"){W("finally"),Lt(e,!0);return}return t||F("E021",f.tokens.next,"catch",f.tokens.next.value),this}),tt("while",function(e){var t=f.tokens.next;return f.funct["(breakage)"]+=1,f.funct["(loopage)"]+=1,Wt(),W("("),Xt($(e,0)),W(")",t),Lt(e,!0,!0),f.funct["(breakage)"]-=1,f.funct["(loopage)"]-=1,this}).labelled=!0,tt("with",function(e){var t=f.tokens.next;return f.isStrict()?F("E010",f.tokens.curr):f.option.withstmt||B("W085",f.tokens.curr),W("("),$(e,0),W(")",t),Lt(e,!0,!0),this}),tt("switch",function(e){var t=f.tokens.next,n=!1,r=!1,i=!1;f.funct["(breakage)"]+=1,W("("),Xt($(e,0)),W(")",t),t=f.tokens.next,W("{"),f.funct["(scope)"].stack(),f.tokens.next.from===g&&(r=!0),r||(g+=f.option.indent);for(;;)switch(f.tokens.next.id){case"case":switch(f.funct["(verb)"]){case"yield":case"break":case"case":case"continue":case"return":case"switch":case"throw":break;case"default":f.option.leanswitch&&B("W145",f.tokens.next);break;default:f.tokens.curr.caseFallsThrough||B("W086",f.tokens.curr,"case")}W("case"),$(e,0),i=!0,Wt(),n=!0,W(":"),f.funct["(verb)"]="case";break;case"default":switch(f.funct["(verb)"]){case"yield":case"break":case"continue":case"return":case"throw":break;case"case":f.option.leanswitch&&B("W145",f.tokens.curr);break;default:i&&!f.tokens.curr.caseFallsThrough&&B("W086",f.tokens.curr,"default")}W("default"),n=!0,W(":"),f.funct["(verb)"]="default";break;case"}":r||(g-=f.option.indent),W("}",t),f.funct["(scope)"].unstack(),f.funct["(breakage)"]-=1,f.funct["(verb)"]=undefined;return;case"(end)":F("E023",f.tokens.next,"}");return;default:g+=f.option.indent;if(n)switch(f.tokens.curr.id){case",":F("E040");return;case":":n=!1,Ct(e);break;default:F("E025",f.tokens.curr);return}else{if(f.tokens.curr.id!==":"){F("E021",f.tokens.next,"case",f.tokens.next.value);return}W(":"),F("E024",f.tokens.curr,":"),Ct(e)}g-=f.option.indent}}).labelled=!0,et("debugger",function(){return f.option.debug||B("W087",this),this}).exps=!0,function(){var e=et("do",function(e){f.funct["(breakage)"]+=1,f.funct["(loopage)"]+=1,Wt(),this.first=Lt(e,!0,!0),W("while");var t=f.tokens.next;return W("("),Xt($(e,0)),W(")",t),f.funct["(breakage)"]-=1,f.funct["(loopage)"]-=1,this});e.labelled=!0,e.exps=!0}(),tt("for",function(e){var t,n=f.tokens.next,i=!1,s=!1,o=null;n.value==="each"&&(o=n,W("each"),f.inMoz()||B("W118",f.tokens.curr,"for each")),f.tokens.next.identifier&&f.tokens.next.value==="await"&&(W("await"),s=!0,e&p.async?f.inES9()||B("W119",f.tokens.curr,"asynchronous iteration","9"):F("E024",f.tokens.curr,"await")),Wt(),W("(");var u,a,l,c,h,d,v,m=U(),g=e|p.noin;if(f.tokens.next.id==="var")W("var"),v=f.tokens.curr.fud(g),a=v.hasComma?v:null,l=v.hasInitializer?v:null;else if(f.tokens.next.id==="const"||f.tokens.next.id==="let"&&(m.identifier&&m.id!=="in"||ln(m,["{","["])))W(f.tokens.next.id),i=!0,f.funct["(scope)"].stack(),v=f.tokens.curr.fud(g),a=v.hasComma?v:null,l=v.hasInitializer?v:null;else if(!cn(f.tokens.next,";")){h=[];while(f.tokens.next.value!=="in"&&f.tokens.next.value!=="of"&&!cn(f.tokens.next,";"))ln(f.tokens.next,["{","["])?(Jt(g,{assignment:!0}).forEach(function(e){this.push(e.token)},h),cn(f.tokens.next,"=")&&(W("="),l=f.tokens.curr,$(g,10))):(d=$(g,10),d&&(d.type==="(identifier)"?h.push(d):cn(d,"=")&&(l=d,h.push(d)))),cn(f.tokens.next,",")&&(W(","),a||(a=f.tokens.curr));!l&&!a&&h.forEach(function(e){f.funct["(scope)"].has(e.value)||B("W088",e,e.value)})}u=f.tokens.next,s&&u.value!=="of"&&F("E066",u);if(r.includes(["in","of"],u.value)){u.value==="of"?(c=20,f.inES6()||B("W104",u,"for of","6")):c=0,a&&F("W133",a,u.value,"more than one ForBinding"),l&&F("W133",l,u.value,"initializer is forbidden"),d&&!a&&!l&&vt(e,d,u),W(u.value),$(e,c),W(")",n),u.value==="in"&&f.option.forin&&(f.forinifcheckneeded=!0,f.forinifchecks===undefined&&(f.forinifchecks=[]),f.forinifchecks.push({type:"(none)"})),f.funct["(breakage)"]+=1,f.funct["(loopage)"]+=1,t=Lt(e,!0,!0);if(u.value==="in"&&f.option.forin){if(f.forinifchecks&&f.forinifchecks.length>0){var y=f.forinifchecks.pop();(t&&t.length>0&&(typeof t[0]!="object"||t[0].value!=="if")||y.type==="(positive)"&&t.length>1||y.type==="(negative)")&&B("W089",this)}f.forinifcheckneeded=!1}f.funct["(breakage)"]-=1,f.funct["(loopage)"]-=1}else{o&&F("E045",o),Q(f.tokens.curr),W(";"),v&&(v.value==="const"&&!v.hasInitializer&&B("E012",v,v.first[0].value),v.first.forEach(function(e){f.funct["(scope)"].initialize(e.value)})),f.funct["(loopage)"]+=1,f.tokens.next.id!==";"&&Xt($(e,0)),Q(f.tokens.curr),W(";"),f.tokens.next.id===";"&&F("E021",f.tokens.next,")",";");if(f.tokens.next.id!==")")for(;;){$(e,0);if(f.tokens.next.id!==",")break;W(","),G()}W(")",n),f.funct["(breakage)"]+=1,Lt(e,!0,!0),f.funct["(breakage)"]-=1,f.funct["(loopage)"]-=1}return i&&f.funct["(scope)"].unstack(),this}).labelled=!0,et("break",function(){var e=f.tokens.next.value;return f.option.asi||Q(this),f.tokens.next.identifier&&J(f.tokens.curr,f.tokens.next)?(f.funct["(scope)"].funct.hasLabel(e)||B("W090",f.tokens.next,e),this.first=f.tokens.next,W()):f.funct["(breakage)"]===0&&B("W052",f.tokens.next,this.value),xt(this),this}).exps=!0,et("continue",function(){var e=f.tokens.next.value;return(f.funct["(breakage)"]===0||!f.funct["(loopage)"])&&B("W052",f.tokens.next,this.value),f.option.asi||Q(this),f.tokens.next.identifier&&J(f.tokens.curr,f.tokens.next)&&(f.funct["(scope)"].funct.hasLabel(e)||B("W090",f.tokens.next,e),this.first=f.tokens.next,W()),xt(this),this}).exps=!0,et("return",function(e){return J(this,f.tokens.next)?f.tokens.next.id!==";"&&!f.tokens.next.reach&&(this.first=$(e,0),this.first&&this.first.type==="(punctuator)"&&this.first.value==="="&&!this.first.paren&&!f.option.boss&&B("W093",this.first),f.option.noreturnawait&&e&p.async&&!(e&p.tryClause)&&this.first.identifier&&this.first.value==="await"&&B("W146",this.first)):f.tokens.next.type==="(punctuator)"&&["[","{","+","-"].indexOf(f.tokens.next.value)>-1&&Q(this),xt(this),this}).exps=!0,rt("await",function(e){return e&p.async?(f.funct["(params)"]||F("E024",this,"await"),$(e,10),this):(this.exps=!1,f.syntax["(identifier)"].nud.apply(this,arguments))}).exps=!0,function(e){e.meta={es5:!0,isFutureReservedWord:!0,strictOnly:!0},e.isFunc=function(){var e=f.tokens.next,t;return this.line!==e.line?!1:e.id==="function"?!0:e.id==="("?(t=Pt(0),t.id==="=>"):e.identifier?U().id==="=>":!1},e.useFud=e.isFunc,e.fud=function(e){return f.inES8()||B("W119",this,"async functions","8"),e|=p.preAsync,e|=p.initial,this.func=$(e,0),this.block=this.func.block,this.exps=this.func.exps,this},e.exps=!0,delete e.reserved}(rt("async",function(e,t){return this.isFunc(e)?(f.inES8()||B("W119",this,"async functions","8"),e|=p.preAsync,this.func=$(e,t),this.identifier=!1,this):(this.exps=!1,f.syntax["(identifier)"].nud.apply(this,arguments))})),function(e){e.rbp=e.lbp=25,e.exps=!0}(rt("yield",function(e){if(f.inMoz())return nn.call(this,e);if(!(e&p.yield))return this.exps=!1,f.syntax["(identifier)"].nud.apply(this,arguments);var t=f.tokens.prev;f.funct["(params)"]||F("E024",this,"yield"),!this.beginsStmt&&t.lbp>30&&!ln(t,["("])&&F("E061",this),f.inES6()||B("W104",f.tokens.curr,"yield","6"),f.funct["(yielded)"]=!0,f.tokens.next.value==="*"&&W("*");if(f.tokens.curr.value==="*"||J(f.tokens.curr,f.tokens.next))f.tokens.next.nud?(K(f.tokens.curr,f.tokens.next),this.first=$(e,10),this.first.type==="(punctuator)"&&this.first.value==="="&&!this.first.paren&&!f.option.boss&&B("W093",this.first)):f.tokens.next.led&&f.tokens.next.id!==","&&F("W017",f.tokens.next);return this}));var nn=function(e){var t=f.tokens.prev;f.inES6(!0)&&!(e&p.yield)&&F("E046",f.tokens.curr,"yield"),f.funct["(yielded)"]=!0;var n=!1;f.tokens.next.value==="*"&&(n=!0,W("*"));if(J(this,f.tokens.next)){if(n||f.tokens.next.id!==";"&&!f.option.asi&&!f.tokens.next.reach&&f.tokens.next.nud)K(f.tokens.curr,f.tokens.next),this.first=$(e,10),this.first.type==="(punctuator)"&&this.first.value==="="&&!this.first.paren&&!f.option.boss&&B("W093",this.first);f.tokens.next.id!==")"&&(t.lbp>30||!t.assign&&!V())&&F("E050",this)}else f.option.asi||Q(this);return this};et("throw",function(e){return Q(this),this.first=$(e,20),xt(this),this}).exps=!0,et("import",function(e){f.funct["(scope)"].block.isGlobal()||F("E053",f.tokens.curr,"Import"),f.inES6()||B("W119",f.tokens.curr,"import","6");if(f.tokens.next.type==="(string)")return W("(string)"),this;if(f.tokens.next.identifier){this.name=St(e),f.funct["(scope)"].addbinding(this.name,{type:"import",initialized:!0,token:f.tokens.curr});if(f.tokens.next.value!==",")return W("from"),W("(string)"),this;W(",")}if(f.tokens.next.id==="*")W("*"),W("as"),f.tokens.next.identifier&&(this.name=St(e),f.funct["(scope)"].addbinding(this.name,{type:"import",initialized:!0,token:f.tokens.curr}));else{W("{");for(;;){if(f.tokens.next.value==="}"){W("}");break}var t;f.tokens.next.type==="default"?(t="default",W("default")):t=St(e),f.tokens.next.value==="as"&&(W("as"),t=St(e)),f.funct["(scope)"].addbinding(t,{type:"import",initialized:!0,token:f.tokens.curr});if(f.tokens.next.value!==","){if(f.tokens.next.value==="}"){W("}");break}F("E024",f.tokens.next,f.tokens.next.value);break}W(",")}}return W("from"),W("(string)"),this}).exps=!0,et("export",function(e){var t=!0,n,r,i;e|=p.export,f.inES6()||(B("W119",f.tokens.curr,"export","6"),t=!1),f.funct["(scope)"].block.isGlobal()||(F("E053",f.tokens.curr,"Export"),t=!1);if(f.tokens.next.value==="*")return W("*"),W("from"),W("(string)"),this;if(f.tokens.next.type==="default"){f.nameStack.set(f.tokens.next),W("default");var s=f.tokens.next.id;return s==="function"?(this.block=!0,W("function"),f.syntax["function"].fud(e)):s==="async"&&U().id==="function"?(this.block=!0,W("async"),W("function"),f.syntax["function"].fud(e|p.preAsync)):s==="class"?(this.block=!0,W("class"),f.syntax["class"].fud(e)):(n=$(e,10),n.identifier&&(r=n.value,f.funct["(scope)"].setExported(r,n))),this}if(f.tokens.next.value==="{"){W("{");var o=[];while(!cn(f.tokens.next,"}"))f.tokens.next.identifier||F("E030",f.tokens.next,f.tokens.next.value),W(),o.push(f.tokens.curr),f.tokens.next.value==="as"&&(W("as"),f.tokens.next.identifier||F("E030",f.tokens.next,f.tokens.next.value),W()),cn(f.tokens.next,"}")||W(",");return W("}"),f.tokens.next.value==="from"?(W("from"),i=f.tokens.next,W("(string)")):t&&o.forEach(function(e){f.funct["(scope)"].setExported(e.value,e)}),o.length===0&&(i?B("W142",this,"export",i.value):B("W141",this,"export")),this}return f.tokens.next.id==="var"?(W("var"),f.tokens.curr.fud(e)):f.tokens.next.id==="let"?(W("let"),f.tokens.curr.fud(e)):f.tokens.next.id==="const"?(W("const"),f.tokens.curr.fud(e)):f.tokens.next.id==="function"?(this.block=!0,W("function"),f.syntax["function"].fud(e)):f.tokens.next.id==="async"&&U().id==="function"?(this.block=!0,W("async"),W("function"),f.syntax["function"].fud(e|p.preAsync)):f.tokens.next.id==="class"?(this.block=!0,W("class"),f.syntax["class"].fud(e)):F("E024",f.tokens.next,f.tokens.next.value),this}).exps=!0;var sn=function(){var e=f.tokens.next;return ln(e,["[","."])?rn("property",f.funct)||F("E063",this):cn(e,"(")?rn("call",f.funct)||F("E064",this):F("E024",e,e.value||e.id),this};ot("abstract"),ot("boolean"),ot("byte"),ot("char"),ot("double"),ot("enum",{es5:!0}),ot("export",{es5:!0}),ot("extends",{es5:!0}),ot("final"),ot("float"),ot("goto"),ot("implements",{es5:!0,strictOnly:!0}),ot("import",{es5:!0}),ot("int"),ot("interface",{es5:!0,strictOnly:!0}),ot("long"),ot("native"),ot("package",{es5:!0,strictOnly:!0}),ot("private",{es5:!0,strictOnly:!0}),ot("protected",{es5:!0,strictOnly:!0}),ot("public",{es5:!0,strictOnly:!0}),ot("short"),ot("static",{es5:!0,strictOnly:!0}),ot("synchronized"),ot("transient"),ot("volatile");var on=function(){var e,t,n,r=-1,i=0,s={};ln(f.tokens.curr,["[","{"])&&(i+=1);do{n=r===-1?f.tokens.curr:e,e=r===-1?f.tokens.next:U(r),t=U(r+1),r+=1,ln(e,["[","{"])?i+=1:ln(e,["]","}"])&&(i-=1);if(i===1&&e.identifier&&e.value==="for"&&!cn(n,".")){s.isCompArray=!0,s.notJson=!0;break}if(i===0&&ln(e,["}","]"])){if(t.value==="="){s.isDestAssign=!0,s.notJson=!0;break}if(t.value==="."){s.notJson=!0;break}}cn(e,";")&&(s.notJson=!0)}while(i>0&&e.id!=="(end)");return s},pn=function(){function i(e){var t=n.variables.filter(function(t){if(t.value===e)return t.undef=!1,e}).length;return t!==0}function s(e){var t=n.variables.filter(function(t){if(t.value===e&&!t.undef)return t.unused===!0&&(t.unused=!1),e}).length;return t===0}var e=function(){this.mode="use",this.variables=[]},t=[],n;return{stack:function(){n=new e,t.push(n)},unstack:function(){n.variables.filter(function(e){e.unused&&B("W098",e.token,e.token.raw_text||e.value),e.undef&&f.funct["(scope)"].block.use(e.value,e.token)}),t.splice(-1,1),n=t[t.length-1]},setState:function(e){r.includes(["use","define","generate","filter"],e)&&(n.mode=e)},check:function(e){if(!n)return;return n&&n.mode==="use"?(s(e)&&n.variables.push({token:f.tokens.curr,value:e,undef:!0,unused:!1}),!0):n&&n.mode==="define"?(i(e)||n.variables.push({token:f.tokens.curr,value:e,undef:!1,unused:!0}),!0):n&&n.mode==="generate"?(f.funct["(scope)"].block.use(e,f.tokens.curr),!0):n&&n.mode==="filter"?(s(e)&&f.funct["(scope)"].block.use(e,f.tokens.curr),!0):!1}}},mn=function(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")},gn=function(t,i,o){function M(e,t){if(!e)return;!Array.isArray(e)&&typeof e=="object"&&(e=Object.keys(e)),e.forEach(t)}var a,l,c,p,k,L;i=r.clone(i),f.reset(),k=f.option,L=f.ignored,i&&i.scope?v.scope=i.scope:(v.errors=[],v.internals=[],v.blacklist={},v.scope="(main)"),S=Object.create(null),O(S,s.ecmaIdentifiers[3]),O(S,s.reservedVars),n=Object.create(null);var A=Object.create(null);if(i){M([i.predef,i.globals],function(e){M(e,function(t){var n,r;t[0]==="-"?(n=t.slice(1),v.blacklist[n]=n,delete S[n]):(r=Object.getOwnPropertyDescriptor(e,t),S[t]=r?r.value:!1)})}),M(i.exported||null,function(e){A[e]=!0}),delete i.predef,delete i.exported,p=Object.keys(i);for(a=0;a<p.length;a++)if(/^-W\d{3}$/g.test(p[a]))L[p[a].slice(1)]=!0;else{var H=p[a];k[H]=i[H]}}f.option=k,f.ignored=L,f.option.indent=f.option.indent||4,f.option.maxerr=f.option.maxerr||50,g=1;var q=h(f,S,A,n);q.on("warning",function(e){B.apply(null,[e.code,e.token].concat(e.data))}),q.on("error",function(e){F.apply(null,[e.code,e.token].concat(e.data))}),f.funct=It("(global)",null,{"(global)":!0,"(scope)":q,"(comparray)":pn(),"(metrics)":zt(f.tokens.next)}),d=[f.funct],w={},E=null,m=!1,y=[];if(!C(t)&&!Array.isArray(t))return I("E004",0),!1;e={get isJSON(){return f.jsonMode},getOption:function(e){return f.option[e]||null},getCache:function(e){return f.cache[e]},setCache:function(e,t){f.cache[e]=t},warn:function(e,t){j.apply(null,[e,t.line,t.char].concat(t.data))},on:function(e,t){e.split(" ").forEach(function(e){T.on(e,t)}.bind(this))}},T.removeAllListeners(),(x||[]).forEach(function(t){t(e)}),f.tokens.prev=f.tokens.curr=f.tokens.next=f.syntax["(begin)"],i&&i.ignoreDelimiters&&(Array.isArray(i.ignoreDelimiters)||(i.ignoreDelimiters=[i.ignoreDelimiters]),i.ignoreDelimiters.forEach(function(e){if(!e.start||!e.end)return;l=mn(e.start)+"[\\s\\S]*?"+mn(e.end),c=new RegExp(l,"ig"),t=t.replace(c,function(e){return e.replace(/./g," ")})})),b=new u(t),b.on("warning",function(e){j.apply(null,[e.code,e.line,e.character].concat(e.data))}),b.on("error",function(e){I.apply(null,[e.code,e.line,e.character].concat(e.data))}),b.on("fatal",function(e){P("E041",e)}),b.on("Identifier",function(e){T.emit("Identifier",e)}),b.on("String",function(e){T.emit("String",e)}),b.on("Number",function(e){T.emit("Number",e)});var R;for(R in i)r.has(i,R)&&N(R,!0,f.tokens.curr);if(i)for(R in i.unstable)r.has(i.unstable,R)&&N(R,!1,f.tokens.curr);try{D(),O(S,o||{}),G.first=!0,W();switch(f.tokens.next.id){case"{":case"[":hn(0);break;default:kt(),f.directive["use strict"]&&(f.allowsGlobalUsd()||B("W097",f.tokens.prev)),Ct(0)}f.tokens.next.id!=="(end)"&&P("E041",f.tokens.curr),f.funct["(scope)"].unstack()}catch(U){if(!U||U.name!=="JSHintError")throw U;var z=f.tokens.next||{};v.errors.push({scope:"(main)",raw:U.raw,code:U.code,reason:U.reason,line:U.line||z.line,character:U.character||z.from})}return v.scope==="(main)"&&vn(v.internals,i||{},o),v.errors.length===0};return gn.addModule=function(e){x.push(e)},gn.addModule(l.register),gn.data=function(){var e={functions:[],options:f.option},t,n,r,i,s;gn.errors.length&&(e.errors=gn.errors),f.jsonMode&&(e.json=!0);var o=f.funct["(scope)"].getImpliedGlobals();o.length>0&&(e.implieds=o),s=f.funct["(scope)"].getUsedOrDefinedGlobals(),s.length>0&&(e.globals=s);for(r=1;r<d.length;r+=1)n=d[r],t={},t.name=n["(name)"],t.param=n["(params)"],t.line=n["(line)"],t.character=n["(character)"],t.last=n["(last)"],t.lastcharacter=n["(lastcharacter)"],t.metrics={complexity:n["(metrics)"].ComplexityCount,parameters:n["(metrics)"].arity,statements:n["(metrics)"].statementCount},e.functions.push(t);var u=f.funct["(scope)"].getUnuseds();u.length>0&&(e.unused=u);for(i in w)if(typeof w[i]=="number"){e.member=w;break}return e},gn.jshint=gn,gn}();typeof n=="object"&&n&&(n.JSHINT=v)},{"./lex.js":"/../../jshint/src/lex.js","./messages.js":"/../../jshint/src/messages.js","./options.js":"/../../jshint/src/options.js","./prod-params.js":"/../../jshint/src/prod-params.js","./reg.js":"/../../jshint/src/reg.js","./scope-manager.js":"/../../jshint/src/scope-manager.js","./state.js":"/../../jshint/src/state.js","./style.js":"/../../jshint/src/style.js","./vars.js":"/../../jshint/src/vars.js","console-browserify":"/../../jshint/node_modules/console-browserify/index.js",events:"/../node_modules/events/events.js","lodash.clone":"/../../jshint/node_modules/lodash.clone/index.js",underscore:"/../../jshint/node_modules/underscore/underscore.js"}],"/../../jshint/src/lex.js":[function(e,t,n){"use strict";function v(e){return/^[0-9a-fA-F]+$/.test(e)}function m(e){return e.length===1&&v(e)}function g(){var e=[];return{push:function(t){e.push(t)},check:function(){for(var t=0;t<e.length;++t)e[t]();e.splice(0,e.length)}}}function y(e){var t=e;typeof t=="string"&&(t=t.replace(/\r\n/g,"\n").replace(/\r/g,"\n").split("\n")),t[0]&&t[0].substr(0,2)==="#!"&&(t[0].indexOf("node")!==-1&&(o.option.node=!0),t[0]=""),this.emitter=new i.EventEmitter,this.source=e,this.setLines(t),this.prereg=!0,this.line=0,this.char=1,this.from=1,this.input="",this.inComment=!1,this.context=[],this.templateStarts=[];for(var n=0;n<o.option.indent;n+=1)o.tab+=" "}var r=e("underscore"),i=e("events"),s=e("./reg.js"),o=e("./state.js").state,u=e("../data/ascii-identifier-data.js"),a=u.asciiIdentifierStartTable,f=u.asciiIdentifierPartTable,l=e("../data/non-ascii-identifier-start.js"),c=e("../data/non-ascii-identifier-part-only.js"),h,p={Identifier:1,Punctuator:2,NumericLiteral:3,StringLiteral:4,Comment:5,Keyword:6,RegExp:9,TemplateHead:10,TemplateMiddle:11,TemplateTail:12,NoSubstTemplate:13},d={Block:1,Template:2};y.prototype={_lines:[],inContext:function(e){return this.context.length>0&&this.context[this.context.length-1].type===e},pushContext:function(e){this.context.push({type:e})},popContext:function(){return this.context.pop()},currentContext:function(){return this.context.length>0&&this.context[this.context.length-1]},getLines:function(){return this._lines=o.lines,this._lines},setLines:function(e){this._lines=e,o.lines=this._lines},peek:function(e){return this.input.charAt(e||0)},skip:function(e){e=e||1,this.char+=e,this.input=this.input.slice(e)},on:function(e,t){e.split(" ").forEach(function(e){this.emitter.on(e,t)}.bind(this))},trigger:function(){this.emitter.emit.apply(this.emitter,Array.prototype.slice.call(arguments))},triggerAsync:function(e,t,n,r){n.push(function(){r()&&this.trigger(e,t)}.bind(this))},scanPunctuator:function(){var e=this.peek(),t,n,r;switch(e){case".":if(/^[0-9]$/.test(this.peek(1)))return null;if(this.peek(1)==="."&&this.peek(2)===".")return{type:p.Punctuator,value:"..."};case"(":case")":case";":case",":case"[":case"]":case":":case"~":case"?":return{type:p.Punctuator,value:e};case"{":return this.pushContext(d.Block),{type:p.Punctuator,value:e};case"}":return this.inContext(d.Block)&&this.popContext(),{type:p.Punctuator,value:e};case"#":return{type:p.Punctuator,value:e};case"":return null}return t=this.peek(1),n=this.peek(2),r=this.peek(3),e===">"&&t===">"&&n===">"&&r==="="?{type:p.Punctuator,value:">>>="}:e==="="&&t==="="&&n==="="?{type:p.Punctuator,value:"==="}:e==="!"&&t==="="&&n==="="?{type:p.Punctuator,value:"!=="}:e===">"&&t===">"&&n===">"?{type:p.Punctuator,value:">>>"}:e==="<"&&t==="<"&&n==="="?{type:p.Punctuator,value:"<<="}:e===">"&&t===">"&&n==="="?{type:p.Punctuator,value:">>="}:e==="="&&t===">"?{type:p.Punctuator,value:e+t}:e===t&&"+-<>&|*".indexOf(e)>=0?e==="*"&&n==="="?{type:p.Punctuator,value:e+t+n}:{type:p.Punctuator,value:e+t}:"<>=!+-*%&|^/".indexOf(e)>=0?t==="="?{type:p.Punctuator,value:e+t}:{type:p.Punctuator,value:e}:null},scanComments:function(e){function a(e,t,n){var r=["jshint","jshint.unstable","jslint","members","member","globals","global","exported"],i=!1,o=e+t,a="plain";return n=n||{},n.isMultiline&&(o+="*/"),t=t.replace(/\n/g," "),e==="/*"&&s.fallsThrough.test(t)&&(i=!0,a="falls through"),r.forEach(function(n){if(i)return;if(e==="//"&&n!=="jshint"&&n!=="jshint.unstable")return;t.charAt(n.length)===" "&&t.substr(0,n.length)===n&&(i=!0,e+=n,t=t.substr(n.length)),!i&&t.charAt(0)===" "&&t.charAt(n.length+1)===" "&&t.substr(1,n.length)===n&&(i=!0,e=e+" "+n,t=t.substr(n.length+1));var r=t.indexOf(n);if(!i&&r>=0&&t.charAt(r+n.length)===" "){var s=t.substr(0,r).trim().length===0;s&&(i=!0,t=t.substr(n.length+r))}if(!i)return;switch(n){case"member":a="members";break;case"global":a="globals";break;default:var o=t.split(":").map(function(e){return e.replace(/^\s+/,"").replace(/\s+$/,"")});if(o.length===2)switch(o[0]){case"ignore":switch(o[1]){case"start":u.ignoringLinterErrors=!0,i=!1;break;case"end":u.ignoringLinterErrors=!1,i=!1}}a=n}}),{type:p.Comment,commentType:a,value:o,body:t,isSpecial:i,isMalformed:n.isMalformed||!1}}var t=this.peek(),n=this.peek(1),r=this.input.substr(2),i=this.line,o=this.char,u=this;if(t==="*"&&n==="/")return this.trigger("error",{code:"E018",line:i,character:o}),this.skip(2),null;if(t!=="/"||n!=="*"&&n!=="/")return null;if(n==="/")return this.skip(this.input.length),a("//",r);var f="";if(n==="*"){this.inComment=!0,this.skip(2);while(this.peek()!=="*"||this.peek(1)!=="/")if(this.peek()===""){f+="\n";if(!this.nextLine(e))return this.trigger("error",{code:"E017",line:i,character:o}),this.inComment=!1,a("/*",f,{isMultiline:!0,isMalformed:!0})}else f+=this.peek(),this.skip();return this.skip(2),this.inComment=!1,a("/*",f,{isMultiline:!0})}},scanKeyword:function(){var e=/^[a-zA-Z_$][a-zA-Z0-9_$]*/.exec(this.input),t=["if","in","do","var","for","new","try","let","this","else","case","void","with","enum","while","break","catch","throw","const","yield","class","super","return","typeof","delete","switch","export","import","default","finally","extends","function","continue","debugger","instanceof","true","false","null","async","await"];return e&&t.indexOf(e[0])>=0?{type:p.Keyword,value:e[0]}:null},scanIdentifier:function(t){function u(e){return l.indexOf(e)>-1}function d(e){return u(e)||c.indexOf(e)>-1}function b(e){return e.replace(/\\u([0-9a-fA-F]{4})/g,function(e,t){return String.fromCharCode(parseInt(t,16))})}var n="",r=0,i,s,m=function(){r+=1;if(this.peek(r)!=="u")return null;var e=this.peek(r+1)+this.peek(r+2)+this.peek(r+3)+this.peek(r+4),t;return v(e)?(t=parseInt(e,16),f[t]||d(t)?(r+=5,"\\u"+e):null):null}.bind(this),g=function(){var e=this.peek(r),t=e.charCodeAt(0);return t===92?m():t<128?a[t]?(r+=1,e):null:u(t)?(r+=1,e):null}.bind(this),y=function(){var e=this.peek(r),t=e.charCodeAt(0);return t===92?m():t<128?f[t]?(r+=1,e):null:d(t)?(r+=1,e):null}.bind(this);i=g();if(i===null)return null;n=i;for(;;){i=y();if(i===null)break;n+=i}return s=b(n),o.inES6(!0)||(h=e("../data/es5-identifier-names.js"),h.test(s)||this.triggerAsync("warning",{code:"W119",line:this.line,character:this.char,data:["unicode 8","6"]},t,function(){return!0})),{type:p.Identifier,value:s,text:n,tokenLength:n.length}},scanNumericLiteral:function(e){function f(e){return/^[0-9]$/.test(e)}function l(e){return/^[0-7]$/.test(e)}function c(e){return/^[01]$/.test(e)}function h(e){return e==="$"||e==="_"||e==="\\"||e>="a"&&e<="z"||e>="A"&&e<="Z"}var t=0,n="",r=this.input.length,i=this.peek(t),s=f,u=10,a=!1;if(i!=="."&&!f(i))return null;if(i!=="."){n=this.peek(t),t+=1,i=this.peek(t);if(n==="0"){if(i==="x"||i==="X")s=m,u=16,t+=1,n+=i;if(i==="o"||i==="O")s=l,u=8,o.inES6(!0)||this.triggerAsync("warning",{code:"W119",line:this.line,character:this.char,data:["Octal integer literal","6"]},e,function(){return!0}),t+=1,n+=i;if(i==="b"||i==="B")s=c,u=2,o.inES6(!0)||this.triggerAsync("warning",{code:"W119",line:this.line,character:this.char,data:["Binary integer literal","6"]},e,function(){return!0}),t+=1,n+=i;l(i)&&(s=l,u=8,a=!0,t+=1,n+=i),!l(i)&&f(i)&&(t+=1,n+=i)}while(t<r){i=this.peek(t);if((!a||!f(i))&&!s(i))break;n+=i,t+=1}var d=this.peek(t)==="n";if(s!==f||d){if(d)o.option.unstable.bigint||this.triggerAsync("warning",{code:"W144",line:this.line,character:this.char,data:["BigInt","bigint"]},e,function(){return!0}),n+=i,t+=1;else if(!a&&n.length<=2)return{type:p.NumericLiteral,value:n,isMalformed:!0};if(t<r){i=this.peek(t);if(h(i))return null}return{type:p.NumericLiteral,value:n,base:u,isLegacy:a,isMalformed:!1}}}if(i==="."){n+=i,t+=1;while(t<r){i=this.peek(t);if(!f(i))break;n+=i,t+=1}}if(i==="e"||i==="E"){n+=i,t+=1,i=this.peek(t);if(i==="+"||i==="-")n+=this.peek(t),t+=1;i=this.peek(t);if(!f(i))return null;n+=i,t+=1;while(t<r){i=this.peek(t);if(!f(i))break;n+=i,t+=1}}if(t<r){i=this.peek(t);if(h(i))return null}return{type:p.NumericLiteral,value:n,base:u,isMalformed:!isFinite(n)}},scanEscapeSequence:function(e){var t=!1,n=1;this.skip();var r=this.peek();switch(r){case"'":this.triggerAsync("warning",{code:"W114",line:this.line,character:this.char,data:["\\'"]},e,function(){return o.jsonMode});break;case"b":r="\\b";break;case"f":r="\\f";break;case"n":r="\\n";break;case"r":r="\\r";break;case"t":r="\\t";break;case"0":r="\\0";var i=parseInt(this.peek(1),10);this.triggerAsync("warning",{code:"W115",line:this.line,character:this.char},e,function(){return i>=0&&i<=7&&o.isStrict()});break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":r="\\"+r,this.triggerAsync("warning",{code:"W115",line:this.line,character:this.char},e,function(){return o.isStrict()});break;case"u":var s=this.input.substr(1,4),u=parseInt(s,16);v(s)||this.trigger("warning",{code:"W052",line:this.line,character:this.char,data:["u"+s]}),r=String.fromCharCode(u),n=5;break;case"v":this.triggerAsync("warning",{code:"W114",line:this.line,character:this.char,data:["\\v"]},e,function(){return o.jsonMode}),r="\x0b";break;case"x":var a=parseInt(this.input.substr(1,2),16);this.triggerAsync("warning",{code:"W114",line:this.line,character:this.char,data:["\\x-"]},e,function(){return o.jsonMode}),r=String.fromCharCode(a),n=3;break;case"\\":r="\\\\";break;case'"':r='\\"';break;case"/":break;case"":t=!0,r=""}return{"char":r,jump:n,allowNewLine:t}},scanTemplateLiteral:function(e){var t,n="",r,i=this.line,s=this.char,u=this.templateStarts.length;if(this.peek()==="`")o.inES6(!0)||this.triggerAsync("warning",{code:"W119",line:this.line,character:this.char,data:["template literal syntax","6"]},e,function(){return!0}),t=p.TemplateHead,this.templateStarts.push({line:this.line,"char":this.char}),u=this.templateStarts.length,this.skip(1),this.pushContext(d.Template);else{if(!this.inContext(d.Template)||this.peek()!=="}")return null;t=p.TemplateMiddle}while(this.peek()!=="`"){while((r=this.peek())===""){n+="\n";if(!this.nextLine(e)){var a=this.templateStarts.pop();return this.trigger("error",{code:"E052",line:a.line,character:a.char}),{type:t,value:n,startLine:i,startChar:s,isUnclosed:!0,depth:u,context:this.popContext()}}}if(r==="$"&&this.peek(1)==="{")return n+="${",this.skip(2),{type:t,value:n,startLine:i,startChar:s,isUnclosed:!1,depth:u,context:this.currentContext()};if(r==="\\"){var f=this.scanEscapeSequence(e);n+=f.char,this.skip(f.jump)}else r!=="`"&&(n+=r,this.skip(1))}return t=t===p.TemplateHead?p.NoSubstTemplate:p.TemplateTail,this.skip(1),this.templateStarts.pop(),{type:t,value:n,startLine:i,startChar:s,isUnclosed:!1,depth:u,context:this.popContext()}},scanStringLiteral:function(e){var t=this.peek();if(t!=='"'&&t!=="'")return null;this.triggerAsync("warning",{code:"W108",line:this.line,character:this.char},e,function(){return o.jsonMode&&t!=='"'});var n="",r=this.line,i=this.char,s=!1;this.skip();while(this.peek()!==t)if(this.peek()===""){s?(s=!1,this.triggerAsync("warning",{code:"W043",line:this.line,character:this.char},e,function(){return!o.option.multistr}),this.triggerAsync("warning",{code:"W042",line:this.line,character:this.char},e,function(){return o.jsonMode&&o.option.multistr})):this.trigger("warning",{code:"W112",line:this.line,character:this.char});if(!this.nextLine(e))return{type:p.StringLiteral,value:n,startLine:r,startChar:i,isUnclosed:!0,quote:t}}else{s=!1;var u=this.peek(),a=1;u<" "&&this.triggerAsync("warning",{code:"W113",line:this.line,character:this.char,data:["<non-printable>"]},e,function(){return!0});if(u==="\\"){var f=this.scanEscapeSequence(e);u=f.char,a=f.jump,s=f.allowNewLine}u!==""&&(n+=u,this.skip(a))}return this.skip(),{type:p.StringLiteral,value:n,startLine:r,startChar:i,isUnclosed:!1,quote:t}},scanRegExp:function(e){var t=0,n=this.input.length,r=this.peek(),i=r,u="",a=[],f="",l="",c=!1,h=!1,d=!1,m=!1,g=!1,y=!1,b="",w=function(){return f.indexOf("u")>-1},E,S=0,x,T,N=function(){var n,o;t+=1,r=this.peek(t);if(s.nonzeroDigit.test(r)){o=r,n=this.peek(t+1);while(s.nonzeroDigit.test(n)||n==="0")t+=1,r=n,o+=r,u+=r,i+=r,n=this.peek(t+1);return a.push(Number(o)),o}b+=r;if(r==="u"&&this.peek(t+1)==="{"){var f=t+2;o="u{",n=this.peek(f);while(v(n))o+=n,f+=1,n=this.peek(f);if(n!=="}")this.triggerAsync("error",{code:"E016",line:this.line,character:this.char,data:["Invalid Unicode escape sequence"]},e,w);else if(o.length>2)return o+="}",u+=o,i+=o,t=f+1,o}return r<" "&&(c=!0,this.triggerAsync("warning",{code:"W048",line:this.line,character:this.char},e,function(){return!0})),r==="<"?(c=!0,this.triggerAsync("warning",{code:"W049",line:this.line,character:this.char,data:[r]},e,function(){return!0})):r==="0"&&s.decimalDigit.test(this.peek(t+1))&&this.triggerAsync("error",{code:"E016",line:this.line,character:this.char,data:["Invalid decimal escape sequence"]},e,w),t+=1,u+=r,i+=r,r}.bind(this),C=function(){var e=t,n="",r="",i;i=this.peek(e+1);while(s.decimalDigit.test(i))e+=1,n+=i,i=this.peek(e+1);if(!n)return!1;if(i==="}")return!0;if(i!==",")return!1;e+=1,i=this.peek(e+1);while(s.decimalDigit.test(i))e+=1,r+=i,i=this.peek(e+1);return i!=="}"?!1:r?Number(n)<=Number(r):!0}.bind(this),k=function(e){var t="\uffff";return e.replace(/\\u\{([0-9a-fA-F]+)\}|\\u([a-fA-F0-9]{4})/g,function(e,n,i){var o=parseInt(n||i,16),u;if(o>1114111){c=!0,this.trigger("error",{code:"E016",line:this.line,character:this.char,data:[r]});return}return u=String.fromCharCode(o),s.regexpSyntaxChars.test(u)?e:o<=65535?String.fromCharCode(o):t}.bind(this)).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,t)}.bind(this);if(!this.prereg||r!=="/")return null;t+=1,x=!1;while(t<n){d&=r==="-",r=this.peek(t),i+=r,u+=r;if(h)if(r==="]"){if(this.peek(t-1)!=="\\"||this.peek(t-2)==="\\")h=!1}else r==="-"&&(d=!0);if(r==="\\"){E=N(),h&&(this.peek(t)==="-"||d)&&s.regexpCharClasses.test(E)&&this.triggerAsync("error",{code:"E016",line:this.line,character:this.char,data:["Character class used in range"]},e,w);continue}if(h){t+=1;continue}r==="{"&&!y&&(y=!C());if(r==="["){h=!0,t+=1;continue}if(r==="(")m=!0,this.peek(t+1)==="?"&&(this.peek(t+2)==="="||this.peek(t+2)==="!")&&(g=!0);else if(r===")")g?(g=!1,s.regexpQuantifiers.test(this.peek(t+1))&&this.triggerAsync("error",{code:"E016",line:this.line,character:this.char,data:["Quantified quantifiable"]},e,w)):S+=1,m=!1;else if(r==="/"){u=u.substr(0,u.length-1),x=!0,t+=1;break}t+=1}if(!x)return this.trigger("error",{code:"E015",line:this.line,character:this.from}),void this.trigger("fatal",{line:this.line,from:this.from});while(t<n){r=this.peek(t);if(!/[gimyus]/.test(r))break;if(r==="y")o.inES6(!0)||this.triggerAsync("warning",{code:"W119",line:this.line,character:this.char,data:["Sticky RegExp flag","6"]},e,function(){return!0});else if(r==="u"){o.inES6(!0)||this.triggerAsync("warning",{code:"W119",line:this.line,character:this.char,data:["Unicode RegExp flag","6"]},e,function(){return!0});var L=function(e,t,n,r){var i=e.some(function(e){if(e>t)return!0});return i?!0:!n.split("").every(function(e){return e==="u"||e==="/"||e==="0"||r.regexpControlEscapes.test(e)||r.regexpCharClasses.test(e)||r.regexpSyntaxChars.test(e)})}(a,S,b,s);L?T="Invalid escape":y&&(T="Invalid quantifier"),u=k(u)}else r==="s"?(o.inES9()||this.triggerAsync("warning",{code:"W119",line:this.line,character:this.char,data:["DotAll RegExp flag","9"]},e,function(){return!0}),i.indexOf("s")>-1&&(T="Duplicate RegExp flag")):l+=r;f.indexOf(r)>-1&&(T="Duplicate RegExp flag"),f+=r,i+=r,f+=r,t+=1}f.indexOf("u")===-1&&this.triggerAsync("warning",{code:"W147",line:this.line,character:this.char},e,function(){return o.option.regexpu});try{new RegExp(u,l)}catch(A){T=A.message}return T?(c=!0,this.trigger("error",{code:"E016",line:this.line,character:this.char,data:[T]})):f.indexOf("s")>-1&&!s.regexpDot.test(u)&&this.trigger("warning",{code:"W148",line:this.line,character:this.char}),{type:p.RegExp,value:i,isMalformed:c}},scanNonBreakingSpaces:function(){return o.option.nonbsp?this.input.search(/(\u00A0)/):-1},next:function(e){this.from=this.char;while(s.whitespace.test(this.peek()))this.from+=1,this.skip();var t=this.scanComments(e)||this.scanStringLiteral(e)||this.scanTemplateLiteral(e);return t?t:(t=this.scanRegExp(e)||this.scanPunctuator()||this.scanKeyword()||this.scanIdentifier(e)||this.scanNumericLiteral(e),t?(this.skip(t.tokenLength||t.value.length),t):null)},nextLine:function(e){var t;if(this.line>=this.getLines().length)return!1;this.input=this.getLines()[this.line],this.line+=1,this.char=1,this.from=1;var n=this.input.trim(),i=function(){return r.some(arguments,function(e){return n.indexOf(e)===0})},u=function(){return r.some(arguments,function(e){return n.indexOf(e,n.length-e.length)!==-1})};this.ignoringLinterErrors===!0&&!i("/*","//")&&(!this.inComment||!u("*/"))&&(this.input=""),t=this.scanNonBreakingSpaces(),t>=0&&this.triggerAsync("warning",{code:"W125",line:this.line,character:t+1},e,function(){return!0}),this.input=this.input.replace(/\t/g,o.tab);if(!this.ignoringLinterErrors&&o.option.maxlen&&o.option.maxlen<this.input.length){var a=this.inComment||i.call(n,"//")||i.call(n,"/*"),f=!a||!s.maxlenException.test(n);f&&this.triggerAsync("warning",{code:"W101",line:this.line,character:this.input.length},e,function(){return!0})}return!0},token:function(){var e=g(),t,n=function(t,n,i,s){var u;t!=="(endline)"&&t!=="(end)"&&(this.prereg=!1);if(t==="(punctuator)"){switch(n){case".":case")":case"~":case"#":case"]":case"}":case"++":case"--":this.prereg=!1;break;default:this.prereg=!0}u=Object.create(o.syntax[n]||o.syntax["(error)"])}if(t==="(identifier)"){if(n==="return"||n==="case"||n==="yield"||n==="typeof"||n==="instanceof"||n==="void"||n==="await")this.prereg=!0;r.has(o.syntax,n)&&(u=Object.create(o.syntax[n]||o.syntax["(error)"]))}if(t==="(template)"||t==="(template middle)")this.prereg=!0;return u||(u=Object.create(o.syntax[t])),u.identifier=t==="(identifier)",u.type=u.type||t,u.value=n,u.line=this.line,u.character=this.char,u.from=this.from,u.identifier&&s&&(u.raw_text=s.text||s.value),s&&s.startLine&&s.startLine!==this.line&&(u.startLine=s.startLine),s&&s.context&&(u.context=s.context),s&&s.depth&&(u.depth=s.depth),s&&s.isUnclosed&&(u.isUnclosed=s.isUnclosed),i&&u.identifier&&(u.isProperty=i),u.check=e.check,u}.bind(this);for(;;){if(!this.input.length)return this.nextLine(e)?n("(endline)",""):this.exhausted?null:(this.exhausted=!0,n("(end)",""));t=this.next(e);if(!t){this.input.length&&(this.trigger("error",{code:"E024",line:this.line,character:this.char,data:[this.peek()]}),this.input="");continue}switch(t.type){case p.StringLiteral:return this.triggerAsync("String",{line:this.line,"char":this.char,from:this.from,startLine:t.startLine,startChar:t.startChar,value:t.value,quote:t.quote},e,function(){return!0}),n("(string)",t.value,null,t);case p.TemplateHead:return this.trigger("TemplateHead",{line:this.line,"char":this.char,from:this.from,startLine:t.startLine,startChar:t.startChar,value:t.value}),n("(template)",t.value,null,t);case p.TemplateMiddle:return this.trigger("TemplateMiddle",{line:this.line,"char":this.char,from:this.from,startLine:t.startLine,startChar:t.startChar,value:t.value}),n("(template middle)",t.value,null,t);case p.TemplateTail:return this.trigger("TemplateTail",{line:this.line,"char":this.char,from:this.from,startLine:t.startLine,startChar:t.startChar,value:t.value}),n("(template tail)",t.value,null,t);case p.NoSubstTemplate:return this.trigger("NoSubstTemplate",{line:this.line,"char":this.char,from:this.from,startLine:t.startLine,startChar:t.startChar,value:t.value}),n("(no subst template)",t.value,null,t);case p.Identifier:this.triggerAsync("Identifier",{line:this.line,"char":this.char,from:this.from,name:t.value,raw_name:t.text,isProperty:o.tokens.curr.id==="."},e,function(){return!0});case p.Keyword:return n("(identifier)",t.value,o.tokens.curr.id===".",t);case p.NumericLiteral:return t.isMalformed&&this.trigger("warning",{code:"W045",line:this.line,character:this.char,data:[t.value]}),this.triggerAsync("warning",{code:"W114",line:this.line,character:this.char,data:["0x-"]},e,function(){return t.base===16&&o.jsonMode}),this.triggerAsync("warning",{code:"W115",line:this.line,character:this.char},e,function(){return o.isStrict()&&t.base===8&&t.isLegacy}),this.trigger("Number",{line:this.line,"char":this.char,from:this.from,value:t.value,base:t.base,isMalformed:t.isMalformed}),n("(number)",t.value);case p.RegExp:return n("(regexp)",t.value);case p.Comment:if(t.isSpecial)return{id:"(comment)",value:t.value,body:t.body,type:t.commentType,isSpecial:t.isSpecial,line:this.line,character:this.char,from:this.from};break;default:return n("(punctuator)",t.value)}}}},n.Lexer=y,n.Context=d},{"../data/ascii-identifier-data.js":"/../../jshint/data/ascii-identifier-data.js","../data/es5-identifier-names.js":"/../../jshint/data/es5-identifier-names.js","../data/non-ascii-identifier-part-only.js":"/../../jshint/data/non-ascii-identifier-part-only.js","../data/non-ascii-identifier-start.js":"/../../jshint/data/non-ascii-identifier-start.js","./reg.js":"/../../jshint/src/reg.js","./state.js":"/../../jshint/src/state.js",events:"/../node_modules/events/events.js",underscore:"/../../jshint/node_modules/underscore/underscore.js"}],"/../../jshint/src/messages.js":[function(e,t,n){"use strict";var r=e("underscore"),i={E001:"Bad {a}option: '{b}'.",E002:"Bad option value.",E003:"Expected a JSON value.",E004:"Input is neither a string nor an array of strings.",E005:"Input is empty.",E006:"Unexpected early end of program.",E007:'Missing "use strict" statement.',E008:"Strict violation.",E009:"Option 'validthis' can't be used in a global scope.",E010:"'with' is not allowed in strict mode.",E011:"'{a}' has already been declared.",E012:"const '{a}' is initialized to 'undefined'.",E013:"Attempting to override '{a}' which is a constant.",E014:"A regular expression literal can be confused with '/='.",E015:"Unclosed regular expression.",E016:"Invalid regular expression.",E017:"Unclosed comment.",E018:"Unbegun comment.",E019:"Unmatched '{a}'.",E020:"Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",E021:"Expected '{a}' and instead saw '{b}'.",E022:"Line breaking error '{a}'.",E023:"Missing '{a}'.",E024:"Unexpected '{a}'.",E025:"Missing ':' on a case clause.",E026:"Missing '}' to match '{' from line {a}.",E027:"Missing ']' to match '[' from line {a}.",E028:"Illegal comma.",E029:"Unclosed string.",E030:"Expected an identifier and instead saw '{a}'.",E031:"Bad assignment.",E032:"Expected a small integer or 'false' and instead saw '{a}'.",E033:"Expected an operator and instead saw '{a}'.",E034:"get/set are ES5 features.",E035:"Missing property name.",E036:"Expected to see a statement and instead saw a block.",E037:null,E038:null,E039:"Function declarations are not invocable. Wrap the whole function invocation in parens.",E040:"Each value should have its own case label.",E041:"Unrecoverable syntax error.",E042:"Stopping.",E043:"Too many errors.",E044:null,E045:"Invalid for each loop.",E046:"Yield expressions may only occur within generator functions.",E047:null,E048:"{a} declaration not directly within block.",E049:"A {a} cannot be named '{b}'.",E050:"Mozilla requires the yield expression to be parenthesized here.",E051:null,E052:"Unclosed template literal.",E053:"{a} declarations are only allowed at the top level of module scope.",E054:"Class properties must be methods. Expected '(' but instead saw '{a}'.",E055:"The '{a}' option cannot be set after any executable code.",E056:"'{a}' was used before it was declared, which is illegal for '{b}' variables.",E057:"Invalid meta property: '{a}.{b}'.",E058:"Missing semicolon.",E059:"Incompatible values for the '{a}' and '{b}' linting options.",E060:"Non-callable values cannot be used as the second operand to instanceof.",E061:"Invalid position for 'yield' expression (consider wrapping in parenthesis).",E062:"Rest parameter does not a support default value.",E063:"Super property may only be used within method bodies.",E064:"Super call may only be used within class method bodies.",E065:"Functions defined outside of strict mode with non-simple parameter lists may not enable strict mode.",E066:"Asynchronous iteration is only available with for-of loops."},s={W001:"'hasOwnProperty' is a really bad name.",W002:"Value of '{a}' may be overwritten in IE 8 and earlier.",W003:"'{a}' was used before it was defined.",W004:"'{a}' is already defined.",W005:"A dot following a number can be confused with a decimal point.",W006:"Confusing minuses.",W007:"Confusing plusses.",W008:"A leading decimal point can be confused with a dot: '{a}'.",W009:"The array literal notation [] is preferable.",W010:"The object literal notation {} is preferable.",W011:null,W012:null,W013:null,W014:"Misleading line break before '{a}'; readers may interpret this as an expression boundary.",W015:null,W016:"Unexpected use of '{a}'.",W017:"Bad operand.",W018:"Confusing use of '{a}'.",W019:"Use the isNaN function to compare with NaN.",W020:"Read only.",W021:"Reassignment of '{a}', which is a {b}. Use 'var' or 'let' to declare bindings that may change.",W022:"Do not assign to the exception parameter.",W023:null,W024:"Expected an identifier and instead saw '{a}' (a reserved word).",W025:"Missing name in function declaration.",W026:"Inner functions should be listed at the top of the outer function.",W027:"Unreachable '{a}' after '{b}'.",W028:"Label '{a}' on {b} statement.",W030:"Expected an assignment or function call and instead saw an expression.",W031:"Do not use 'new' for side effects.",W032:"Unnecessary semicolon.",W033:"Missing semicolon.",W034:'Unnecessary directive "{a}".',W035:"Empty block.",W036:"Unexpected /*member '{a}'.",W037:"'{a}' is a statement label.",W038:"'{a}' used out of scope.",W039:null,W040:"If a strict mode function is executed using function invocation, its 'this' value will be undefined.",W041:null,W042:"Avoid EOL escaping.",W043:"Bad escaping of EOL. Use option multistr if needed.",W044:"Bad or unnecessary escaping.",W045:"Bad number '{a}'.",W046:"Don't use extra leading zeros '{a}'.",W047:"A trailing decimal point can be confused with a dot: '{a}'.",W048:"Unexpected control character in regular expression.",W049:"Unexpected escaped character '{a}' in regular expression.",W050:"JavaScript URL.",W051:"Variables should not be deleted.",W052:"Unexpected '{a}'.",W053:"Do not use {a} as a constructor.",W054:"The Function constructor is a form of eval.",W055:"A constructor name should start with an uppercase letter.",W056:"Bad constructor.",W057:"Weird construction. Is 'new' necessary?",W058:"Missing '()' invoking a constructor.",W059:"Avoid arguments.{a}.",W060:"document.write can be a form of eval.",W061:"eval can be harmful.",W062:"Wrap an immediate function invocation in parens to assist the reader in understanding that the expression is the result of a function, and not the function itself.",W063:"Math is not a function.",W064:"Missing 'new' prefix when invoking a constructor.",W065:"Missing radix parameter.",W066:"Implied eval. Consider passing a function instead of a string.",W067:"Bad invocation.",W068:"Wrapping non-IIFE function literals in parens is unnecessary.",W069:"['{a}'] is better written in dot notation.",W070:"Extra comma. (it breaks older versions of IE)",W071:"This function has too many statements. ({a})",W072:"This function has too many parameters. ({a})",W073:"Blocks are nested too deeply. ({a})",W074:"This function's cyclomatic complexity is too high. ({a})",W075:"Duplicate {a} '{b}'.",W076:"Unexpected parameter '{a}' in get {b} function.",W077:"Expected a single parameter in set {a} function.",W078:"Setter is defined without getter.",W079:"Redefinition of '{a}'.",W080:"It's not necessary to initialize '{a}' to 'undefined'.",W081:null,W082:"Function declarations should not be placed in blocks. Use a function expression or move the statement to the top of the outer function.",W083:"Functions declared within loops referencing an outer scoped variable may lead to confusing semantics. ({a})",W084:"Assignment in conditional expression",W085:"Don't use 'with'.",W086:"Expected a 'break' statement before '{a}'.",W087:"Forgotten 'debugger' statement?",W088:"Creating global 'for' variable. Should be 'for (var {a} ...'.",W089:"The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype.",W090:"'{a}' is not a statement label.",W091:null,W093:"Did you mean to return a conditional instead of an assignment?",W094:"Unexpected comma.",W095:"Expected a string and instead saw {a}.",W096:"The '{a}' key may produce unexpected results.",W097:'Use the function form of "use strict".',W098:"'{a}' is defined but never used.",W099:null,W100:null,W101:"Line is too long.",W102:null,W103:"The '{a}' property is deprecated.",W104:"'{a}' is available in ES{b} (use 'esversion: {b}') or Mozilla JS extensions (use moz).",W105:null,W106:"Identifier '{a}' is not in camel case.",W107:"Script URL.",W108:"Strings must use doublequote.",W109:"Strings must use singlequote.",W110:"Mixed double and single quotes.",W112:"Unclosed string.",W113:"Control character in string: {a}.",W114:"Avoid {a}.",W115:"Octal literals are not allowed in strict mode.",W116:"Expected '{a}' and instead saw '{b}'.",W117:"'{a}' is not defined.",W118:"'{a}' is only available in Mozilla JavaScript extensions (use moz option).",W119:"'{a}' is only available in ES{b} (use 'esversion: {b}').",W120:"You might be leaking a variable ({a}) here.",W121:"Extending prototype of native object: '{a}'.",W122:"Invalid typeof value '{a}'",W123:"'{a}' is already defined in outer scope.",W124:"A generator function should contain at least one yield expression.",W125:"This line contains non-breaking spaces: http://jshint.com/docs/options/#nonbsp",W126:"Unnecessary grouping operator.",W127:"Unexpected use of a comma operator.",W128:"Empty array elements require elision=true.",W129:"'{a}' is defined in a future version of JavaScript. Use a different variable name to avoid migration issues.",W130:"Invalid element after rest element.",W131:"Invalid parameter after rest parameter.",W132:"`var` declarations are forbidden. Use `let` or `const` instead.",W133:"Invalid for-{a} loop left-hand-side: {b}.",W134:"The '{a}' option is only available when linting ECMAScript {b} code.",W135:"{a} may not be supported by non-browser environments.",W136:"'{a}' must be in function scope.",W137:"Empty destructuring: this is unnecessary and can be removed.",W138:"Regular parameters should not come after default parameters.",W139:"Function expressions should not be used as the second operand to instanceof.",W140:"Missing comma.",W141:"Empty {a}: this is unnecessary and can be removed.",W142:"Empty {a}: consider replacing with `import '{b}';`.",W143:"Assignment to properties of a mapped arguments object may cause unexpected changes to formal parameters.",W144:"'{a}' is a non-standard language feature. Enable it using the '{b}' unstable option.",W145:"Superfluous 'case' clause.",W146:"Unnecessary `await` expression.",W147:"Regular expressions should include the 'u' flag.",W148:"Unnecessary RegExp 's' flag."},o={I001:"Comma warnings can be turned off with 'laxcomma'.",I002:null,I003:"ES5 option is now set per default"};n.errors={},n.warnings={},n.info={},r.each(i,function(e,t){n.errors[t]={code:t,desc:e}}),r.each(s,function(e,t){n.warnings[t]={code:t,desc:e}}),r.each(o,function(e,t){n.info[t]={code:t,desc:e}})},{underscore:"/../../jshint/node_modules/underscore/underscore.js"}],"/../../jshint/src/name-stack.js":[function(e,t,n){"use strict";function r(){this._stack=[]}Object.defineProperty(r.prototype,"length",{get:function(){return this._stack.length}}),r.prototype.push=function(){this._stack.push(null)},r.prototype.pop=function(){this._stack.pop()},r.prototype.set=function(e){this._stack[this.length-1]=e},r.prototype.infer=function(){var e=this._stack[this.length-1],t="",n;if(!e||e.type==="class")e=this._stack[this.length-2];return e?(n=e.type,n!=="(string)"&&n!=="(number)"&&n!=="(identifier)"&&n!=="default"?"(expression)":(e.accessorType&&(t=e.accessorType+" "),t+e.value)):"(empty)"},t.exports=r},{}],"/../../jshint/src/options.js":[function(e,t,n){"use strict";n.bool={enforcing:{bitwise:!0,freeze:!0,camelcase:!0,curly:!0,eqeqeq:!0,futurehostile:!0,es3:!0,es5:!0,forin:!0,immed:!0,leanswitch:!0,newcap:!0,noarg:!0,nocomma:!0,noempty:!0,nonbsp:!0,nonew:!0,noreturnawait:!0,regexpu:!0,undef:!0,singleGroups:!1,varstmt:!1,enforceall:!1,trailingcomma:!1},relaxing:{asi:!0,multistr:!0,debug:!0,boss:!0,evil:!0,funcscope:!0,globalstrict:!0,iterator:!0,notypeof:!0,plusplus:!0,proto:!0,scripturl:!0,sub:!0,supernew:!0,laxbreak:!0,laxcomma:!0,validthis:!0,withstmt:!0,moz:!0,noyield:!0,eqnull:!0,lastsemic:!0,loopfunc:!0,expr:!0,esnext:!0,elision:!0},environments:{mootools:!0,couch:!0,jasmine:!0,jquery:!0,node:!0,qunit:!0,rhino:!0,shelljs:!0,prototypejs:!0,yui:!0,mocha:!0,module:!0,wsh:!0,worker:!0,nonstandard:!0,browser:!0,browserify:!0,devel:!0,dojo:!0,typed:!0,phantom:!0},obsolete:{onecase:!0,regexp:!0,regexdash:!0}},n.val={maxlen:!1,indent:!1,maxerr:!1,predef:!1,globals:!1,quotmark:!1,scope:!1,maxstatements:!1,maxdepth:!1,maxparams:!1,maxcomplexity:!1,shadow:!1,strict:!0,unused:!0,latedef:!1,ignore:!1,ignoreDelimiters:!1,esversion:5},n.unstable={bigint:!0},n.inverted={bitwise:!0,forin:!0,newcap:!0,plusplus:!0,regexp:!0,undef:!0,eqeqeq:!0,strict:!0},n.validNames=Object.keys(n.val).concat(Object.keys(n.bool.relaxing)).concat(Object.keys(n.bool.enforcing)).concat(Object.keys(n.bool.obsolete)).concat(Object.keys(n.bool.environments)).concat(["unstable"]),n.unstableNames=Object.keys(n.unstable),n.renamed={eqeq:"eqeqeq",windows:"wsh",sloppy:"strict"},n.removed={nomen:!0,onevar:!0,passfail:!0,white:!0,gcl:!0,smarttabs:!0,trailing:!0},n.noenforceall={varstmt:!0,strict:!0,regexpu:!0}},{}],"/../../jshint/src/prod-params.js":[function(e,t,n){t.exports={"export":1,noin:2,initial:4,preAsync:8,async:16,tryClause:32,yield:64}},{}],"/../../jshint/src/reg.js":[function(e,t,n){"use strict";n.unsafeString=/@cc|<\/?|script|\]\s*\]|<\s*!|&lt/i,n.needEsc=/[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,n.needEscGlobal=/[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,n.starSlash=/\*\//,n.identifier=/^([a-zA-Z_$][a-zA-Z0-9_$]*)$/,n.javascriptURL=/^(?:javascript|jscript|ecmascript|vbscript|livescript)\s*:/i,n.fallsThrough=/^\s*falls?\sthrough\s*$/,n.maxlenException=/^(?:(?:\/\/|\/\*|\*) ?)?[^ ]+$/,n.whitespace=/[ \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/,n.nonzeroDigit=/^[1-9]$/,n.decimalDigit=/^[0-9]$/,n.regexpSyntaxChars=/[\^$\\.*+?()[\]{}|]/,n.regexpQuantifiers=/[*+?{]/,n.regexpControlEscapes=/[fnrtv]/,n.regexpCharClasses=/[dDsSwW]/,n.regexpDot=/(^|[^\\])(\\\\)*\./},{}],"/../../jshint/src/scope-manager.js":[function(e,t,n){"use strict";var r=e("underscore");r.slice=e("lodash.slice");var i=e("events"),s={},o=function(e,t,n,o){function f(e){u={"(bindings)":Object.create(null),"(usages)":Object.create(null),"(labels)":Object.create(null),"(parent)":u,"(type)":e,"(params)":e==="functionparams"||e==="catchparams"?[]:null},a.push(u)}function v(e,t){d.emit("warning",{code:e,token:t,data:r.slice(arguments,2)})}function m(e,t){d.emit("warning",{code:e,token:t,data:r.slice(arguments,2)})}function g(e){u["(usages)"][e]||(u["(usages)"][e]={"(modified)":[],"(reassigned)":[],"(tokens)":[]})}function w(){if(u["(type)"]==="functionparams"){E();return}var e=u["(bindings)"];for(var t in e)e[t]["(type)"]!=="exception"&&e[t]["(unused)"]&&b(t,e[t]["(token)"],"var")}function E(){var t=u["(params)"];if(!t)return;var n=t.pop(),r;while(n){var i=u["(bindings)"][n];r=y(e.funct["(unusedOption)"]);if(n==="undefined")return;if(i["(unused)"])b(n,i["(token)"],"param",e.funct["(unusedOption)"]);else if(r==="last-param")return;n=t.pop()}}function S(e){for(var t=a.length-1;t>=0;--t){var n=a[t]["(bindings)"];if(n[e])return n}}function x(e){for(var t=a.length-1;t>=0;t--){var n=a[t];if(n["(usages)"][e])return n["(usages)"][e];if(n===l)break}return!1}function T(t,n){if(e.option.shadow!=="outer")return;var r=l["(type)"]==="global",i=u["(type)"]==="functionparams",s=!r;for(var o=0;o<a.length;o++){var f=a[o];!i&&a[o+1]===l&&(s=!1),s&&f["(bindings)"][t]&&v("W123",n,t),f["(labels)"][t]&&v("W123",n,t)}}function N(t,n,r){var i;e.option.latedef&&(i=t==="function"||t==="generator function"||t==="async function",(e.option.latedef===!0&&i||!i)&&v("W003",r,n))}var u,a=[];f("global"),u["(predefined)"]=t;var l=u,c=Object.create(null),h=Object.create(null),p=[],d=new i.EventEmitter,y=function(t){return t===undefined&&(t=e.option.unused),t===!0&&(t="last-param"),t},b=function(e,t,n,r){var i=t.line,s=t.from,o=t.raw_text||e;r=y(r);var u={vars:["var"],"last-param":["var","param"],strict:["var","param","last-param"]};r&&u[r]&&u[r].indexOf(n)!==-1&&v("W098",{line:i,from:s},o),(r||n==="var")&&p.push({name:e,line:i,character:s})},C={on:function(e,t){e.split(" ").forEach(function(e){d.on(e,t)})},isPredefined:function(e){return!this.has(e)&&r.has(a[0]["(predefined)"],e)},stack:function(e){var t=u;f(e),!e&&t["(type)"]==="functionparams"&&(u["(isFuncBody)"]=!0,l=u)},unstack:function(){var t=a.length>1?a[a.length-2]:null,n=u===l,i=u["(type)"]==="functionparams",f=u["(type)"]==="functionouter",p,d,g,y,E=u["(usages)"],S=u["(bindings)"],x=Object.keys(E);E.__proto__&&x.indexOf("__proto__")===-1&&x.push("__proto__");for(p=0;p<x.length;p++){var T=x[p],N=E[T],C=S[T];if(C){var k=C["(type)"];g=k==="const"||k==="import";if(C["(useOutsideOfScope)"]&&!e.option.funcscope){var L=N["(tokens)"];for(d=0;d<L.length;d++)C["(function)"]===L[d]["(function)"]&&m("W038",L[d],T)}u["(bindings)"][T]["(unused)"]=!1;if(g&&N["(modified)"])for(d=0;d<N["(modified)"].length;d++)m("E013",N["(modified)"][d],T);y=k==="function"||k==="generator function"||k==="async function";if((y||k==="class")&&N["(reassigned)"])for(d=0;d<N["(reassigned)"].length;d++)N["(reassigned)"][d].ignoreW021||v("W021",N["(reassigned)"][d],T,k);continue}if(t){var A=this.bindingtype(T);g=A==="const"||A===null&&a[0]["(predefined)"][T]===!1,f&&!g&&(e.funct["(outerMutables)"]||(e.funct["(outerMutables)"]=[]),e.funct["(outerMutables)"].push(T));if(!t["(usages)"][T])t["(usages)"][T]=N,n&&(t["(usages)"][T]["(onlyUsedSubFunction)"]=!0);else{var O=t["(usages)"][T];O["(modified)"]=O["(modified)"].concat(N["(modified)"]),O["(tokens)"]=O["(tokens)"].concat(N["(tokens)"]),O["(reassigned)"]=O["(reassigned)"].concat(N["(reassigned)"])}}else if(typeof u["(predefined)"][T]=="boolean"){delete o[T],c[T]=s;if(u["(predefined)"][T]===!1&&N["(reassigned)"])for(d=0;d<N["(reassigned)"].length;d++)N["(reassigned)"][d].ignoreW020||v("W020",N["(reassigned)"][d])}else for(d=0;d<N["(tokens)"].length;d++){var M=N["(tokens)"][d];M.forgiveUndef||(e.option.undef&&!M.ignoreUndef&&v("W117",M,T),h[T]?h[T].line.push(M.line):h[T]={name:T,line:[M.line]})}}t||Object.keys(o).forEach(function(e){b(e,o[e],"var")});if(t&&!n&&!i&&!f){var D=Object.keys(S);for(p=0;p<D.length;p++){var P=D[p],H=S[P];if(!H["(blockscoped)"]&&H["(type)"]!=="exception"){var B=t["(bindings)"][P];B?B["(unused)"]&=H["(unused)"]:(H["(useOutsideOfScope)"]=l["(type)"]!=="global"&&!this.funct.has(P,{excludeCurrent:!0}),t["(bindings)"][P]=H),delete S[P]}}}w(),a.pop(),n&&(l=a[r.findLastIndex(a,function(e){return e["(isFuncBody)"]||e["(type)"]==="global"})]),u=t},addParam:function(t,n,i){i=i||"param";if(i==="exception"){var s=this.funct.bindingtype(t);s&&s!=="exception"&&(e.option.node||v("W002",e.tokens.next,t)),e.isStrict()&&(t==="arguments"||t==="eval")&&v("E008",n)}r.has(u["(bindings)"],t)?u["(bindings)"][t].duplicated=!0:(T(t,n),u["(bindings)"][t]={"(type)":i,"(token)":n,"(unused)":!0},u["(params)"].push(t));if(r.has(u["(usages)"],t)){var o=u["(usages)"][t];o["(onlyUsedSubFunction)"]?N(i,t,n):v("E056",n,t,i)}},validateParams:function(t){var n=e.isStrict(),r=l["(parent)"],i=e.funct["(hasSimpleParams)"],s=e.funct["(method)"];if(!r["(params)"])return;r["(params)"].forEach(function(o){var u=r["(bindings)"][o];u.duplicated&&(n||t||s||!i?v("E011",u["(token)"],o):e.option.shadow!==!0&&v("W004",u["(token)"],o)),n&&(o==="arguments"||o==="eval")&&v("E008",u["(token)"])})},getUsedOrDefinedGlobals:function(){var e=Object.keys(c);return c.__proto__===s&&e.indexOf("__proto__")===-1&&e.push("__proto__"),e},getImpliedGlobals:function(){var e=r.values(h),t=!1;return h.__proto__&&(t=e.some(function(e){return e.name==="__proto__"}),t||e.push(h.__proto__)),e},getUnuseds:function(){return p},has:function(e){return Boolean(S(e))},bindingtype:function(e){var t=S(e);return t?t[e]["(type)"]:null},addExported:function(e){var t=a[0]["(bindings)"];if(r.has(o,e))delete o[e];else if(r.has(t,e))t[e]["(unused)"]=!1;else{for(var i=1;i<a.length;i++){var s=a[i];if(!!s["(type)"])break;if(r.has(s["(bindings)"],e)&&!s["(bindings)"][e]["(blockscoped)"]){s["(bindings)"][e]["(unused)"]=!1;return}}n[e]=!0}},setExported:function(e,t){this.block.use(e,t)},initialize:function(e){u["(bindings)"][e]&&(u["(bindings)"][e]["(initialized)"]=!0)},addbinding:function(t,i){var o=i.type,a=i.token,f=o==="let"||o==="const"||o==="class"||o==="import"||o==="generator function"||o==="async function"||o==="async generator function",h=o==="function"||o==="generator function"||o==="async function"||o==="import",p=(f?u:l)["(type)"]==="global"&&r.has(n,t);T(t,a),e.isStrict()&&(t==="arguments"||t==="eval")&&v("E008",a);if(f){var d=u["(bindings)"][t];!d&&u===l&&u["(type)"]!=="global"&&(d=!!l["(parent)"]["(bindings)"][t]);if(!d&&u["(usages)"][t]){var m=u["(usages)"][t];m["(onlyUsedSubFunction)"]||h?N(o,t,a):h||v("E056",a,t,o)}d&&(!h||u["(type)"]!=="global"||o==="import")?v("E011",a,t):e.option.shadow==="outer"&&C.funct.has(t)&&v("W004",a,t),C.block.add(t,o,a,!p,i.initialized)}else{var g=C.funct.has(t);!g&&x(t)&&N(o,t,a),C.funct.has(t,{onlyBlockscoped:!0})?v("E011",a,t):e.option.shadow!==!0&&g&&t!=="__proto__"&&l["(type)"]!=="global"&&v("W004",a,t),C.funct.add(t,o,a,!p),l["(type)"]==="global"&&!e.impliedClosure()&&(c[t]=s)}},funct:{bindingtype:function(e,t){var n=t&&t.onlyBlockscoped,r=t&&t.excludeParams,i=a.length-(t&&t.excludeCurrent?2:1);for(var s=i;s>=0;s--){var o=a[s];if(o["(bindings)"][e]&&(!n||o["(bindings)"][e]["(blockscoped)"]))return o["(bindings)"][e]["(type)"];var u=r?a[s-1]:o;if(u&&u["(type)"]==="functionparams")return null}return null},hasLabel:function(e){for(var t=a.length-1;t>=0;t--){var n=a[t];if(n["(labels)"][e])return!0;if(n["(type)"]==="functionparams")return!1}return!1},has:function(e,t){return Boolean(this.bindingtype(e,t))},add:function(e,t,n,r){u["(bindings)"][e]={"(type)":t,"(token)":n,"(blockscoped)":!1,"(function)":l,"(unused)":r}}},block:{isGlobal:function(){return u["(type)"]==="global"},use:function(t,n){var r=l["(parent)"];r&&r["(bindings)"][t]&&r["(bindings)"][t]["(type)"]==="param"&&(C.funct.has(t,{excludeParams:!0,onlyBlockscoped:!0})||(r["(bindings)"][t]["(unused)"]=!1)),n&&(e.ignored.W117||e.option.undef===!1)&&(n.ignoreUndef=!0),g(t),u["(usages)"][t]["(onlyUsedSubFunction)"]=!1,n&&(n["(function)"]=l,u["(usages)"][t]["(tokens)"].push(n));var i=u["(bindings)"][t];i&&i["(blockscoped)"]&&!i["(initialized)"]&&m("E056",n,t,i["(type)"])},reassign:function(t,n){n.ignoreW020=e.ignored.W020,n.ignoreW021=e.ignored.W021,this.modify(t,n),u["(usages)"][t]["(reassigned)"].push(n)},modify:function(e,t){g(e),u["(usages)"][e]["(onlyUsedSubFunction)"]=!1,u["(usages)"][e]["(modified)"].push(t)},add:function(e,t,n,r,i){u["(bindings)"][e]={"(type)":t,"(token)":n,"(initialized)":!!i,"(blockscoped)":!0,"(unused)":r}},addLabel:function(t,n){var r=n.token;C.funct.hasLabel(t)?v("E011",r,t):e.option.shadow==="outer"&&(C.funct.has(t)?v("W004",r,t):T(t,r)),u["(labels)"][t]=r}}};return C};t.exports=o},{events:"/../node_modules/events/events.js","lodash.slice":"/../../jshint/node_modules/lodash.slice/index.js",underscore:"/../../jshint/node_modules/underscore/underscore.js"}],"/../../jshint/src/state.js":[function(e,t,n){"use strict";var r=e("./name-stack.js"),i={syntax:{},isStrict:function(){return this.directive["use strict"]||this.inClassBody||this.option.module||this.option.strict==="implied"},stmtMissingStrict:function(){return this.option.strict==="global"?!0:this.option.strict===!1?!1:this.option.globalstrict?!0:!1},allowsGlobalUsd:function(){return this.option.strict==="global"||this.option.globalstrict||this.option.module||this.impliedClosure()},impliedClosure:function(){return this.option.node||this.option.phantom||this.option.browserify},inMoz:function(){return this.option.moz},inES10:function(){return this.esVersion>=10},inES9:function(){return this.esVersion>=9},inES8:function(){return this.esVersion>=8},inES7:function(){return this.esVersion>=7},inES6:function(e){return!e&&this.option.moz?!0:this.esVersion>=6},inES5:function(){return!this.esVersion||this.esVersion>=5||this.option.moz},inferEsVersion:function(){var e=null;if(this.option.esversion){this.option.es3?e="es3":this.option.es5?e="es5":this.option.esnext&&(e="esnext");if(e)return e;this.option.esversion===2015?this.esVersion=6:this.esVersion=this.option.esversion}else this.option.es3?this.esVersion=3:this.option.esnext&&(this.esVersion=6);return null},reset:function(){this.tokens={prev:null,next:null,curr:null},this.option={unstable:{}},this.esVersion=5,this.funct=null,this.ignored={},this.directive=Object.create(null),this.jsonMode=!1,this.lines=[],this.tab="",this.cache={},this.ignoredLines={},this.forinifcheckneeded=!1,this.nameStack=new r,this.inClassBody=!1}};n.state=i},{"./name-stack.js":"/../../jshint/src/name-stack.js"}],"/../../jshint/src/style.js":[function(e,t,n){"use strict";n.register=function(e){e.on("Identifier",function(n){if(e.getOption("proto"))return;n.name==="__proto__"&&e.warn("W103",{line:n.line,"char":n.char,data:[n.name,"6"]})}),e.on("Identifier",function(n){if(e.getOption("iterator"))return;n.name==="__iterator__"&&e.warn("W103",{line:n.line,"char":n.char,data:[n.name]})}),e.on("Identifier",function(n){if(!e.getOption("camelcase"))return;n.name.replace(/^_+|_+$/g,"").indexOf("_")>-1&&!n.name.match(/^[A-Z0-9_]*$/)&&e.warn("W106",{line:n.line,"char":n.char,data:[n.name]})}),e.on("String",function(n){var r=e.getOption("quotmark"),i;if(!r)return;r==="single"&&n.quote!=="'"&&(i="W109"),r==="double"&&n.quote!=='"'&&(i="W108"),r===!0&&(e.getCache("quotmark")||e.setCache("quotmark",n.quote),e.getCache("quotmark")!==n.quote&&(i="W110")),i&&e.warn(i,{line:n.line,"char":n.char})}),e.on("Number",function(n){n.value.charAt(0)==="."&&e.warn("W008",{line:n.line,"char":n.char,data:[n.value]}),n.value.substr(n.value.length-1)==="."&&e.warn("W047",{line:n.line,"char":n.char,data:[n.value]}),/^00+/.test(n.value)&&e.warn("W046",{line:n.line,"char":n.char,data:[n.value]})}),e.on("String",function(n){var r=/^(?:javascript|jscript|ecmascript|vbscript|livescript)\s*:/i;if(e.getOption("scripturl"))return;r.test(n.value)&&e.warn("W107",{line:n.line,"char":n.char})})}},{}],"/../../jshint/src/vars.js":[function(e,t,n){"use strict";n.reservedVars={NaN:!1,"undefined":!1},n.ecmaIdentifiers={3:{Array:!1,Boolean:!1,Date:!1,decodeURI:!1,decodeURIComponent:!1,encodeURI:!1,encodeURIComponent:!1,Error:!1,eval:!1,EvalError:!1,Function:!1,hasOwnProperty:!1,Infinity:!1,isFinite:!1,isNaN:!1,Math:!1,Number:!1,Object:!1,parseInt:!1,parseFloat:!1,RangeError:!1,ReferenceError:!1,RegExp:!1,String:!1,SyntaxError:!1,TypeError:!1,URIError:!1},5:{JSON:!1},6:{ArrayBuffer:!1,DataView:!1,Float32Array:!1,Float64Array:!1,Int8Array:!1,Int16Array:!1,Int32Array:!1,Map:!1,Promise:!1,Proxy:!1,Reflect:!1,Set:!1,Symbol:!1,Uint8Array:!1,Uint16Array:!1,Uint32Array:!1,Uint8ClampedArray:!1,WeakMap:!1,WeakSet:!1},8:{Atomics:!1,SharedArrayBuffer:!1}},n.browser={Audio:!1,Blob:!1,addEventListener:!1,applicationCache:!1,atob:!1,blur:!1,btoa:!1,cancelAnimationFrame:!1,CanvasGradient:!1,CanvasPattern:!1,CanvasRenderingContext2D:!1,CSS:!1,CSSImportRule:!1,CSSGroupingRule:!1,CSSMarginRule:!1,CSSMediaRule:!1,CSSNamespaceRule:!1,CSSPageRule:!1,CSSRule:!1,CSSRuleList:!1,CSSStyleDeclaration:!1,CSSStyleRule:!1,CSSStyleSheet:!1,clearInterval:!1,clearTimeout:!1,close:!1,closed:!1,Comment:!1,CompositionEvent:!1,createImageBitmap:!1,CustomEvent:!1,DOMParser:!1,defaultStatus:!1,dispatchEvent:!1,Document:!1,document:!1,DocumentFragment:!1,Element:!1,ElementTimeControl:!1,Event:!1,event:!1,fetch:!1,File:!1,FileList:!1,FileReader:!1,FormData:!1,focus:!1,frames:!1,getComputedStyle:!1,Headers:!1,HTMLAnchorElement:!1,HTMLAreaElement:!1,HTMLAudioElement:!1,HTMLBaseElement:!1,HTMLBlockquoteElement:!1,HTMLBodyElement:!1,HTMLBRElement:!1,HTMLButtonElement:!1,HTMLCanvasElement:!1,HTMLCollection:!1,HTMLDataElement:!1,HTMLDataListElement:!1,HTMLDetailsElement:!1,HTMLDialogElement:!1,HTMLDirectoryElement:!1,HTMLDivElement:!1,HTMLDListElement:!1,HTMLElement:!1,HTMLEmbedElement:!1,HTMLFieldSetElement:!1,HTMLFontElement:!1,HTMLFormElement:!1,HTMLFrameElement:!1,HTMLFrameSetElement:!1,HTMLHeadElement:!1,HTMLHeadingElement:!1,HTMLHRElement:!1,HTMLHtmlElement:!1,HTMLIFrameElement:!1,HTMLImageElement:!1,HTMLInputElement:!1,HTMLIsIndexElement:!1,HTMLLabelElement:!1,HTMLLayerElement:!1,HTMLLegendElement:!1,HTMLLIElement:!1,HTMLLinkElement:!1,HTMLMapElement:!1,HTMLMarqueeElement:!1,HTMLMediaElement:!1,HTMLMenuElement:!1,HTMLMetaElement:!1,HTMLMeterElement:!1,HTMLModElement:!1,HTMLObjectElement:!1,HTMLOListElement:!1,HTMLOptGroupElement:!1,HTMLOptionElement:!1,HTMLParagraphElement:!1,HTMLParamElement:!1,HTMLPictureElement:!1,HTMLPreElement:!1,HTMLProgressElement:!1,HTMLQuoteElement:!1,HTMLScriptElement:!1,HTMLSelectElement:!1,HTMLSlotElement:!1,HTMLSourceElement:!1,HTMLStyleElement:!1,HTMLTableCaptionElement:!1,HTMLTableCellElement:!1,HTMLTableColElement:!1,HTMLTableElement:!1,HTMLTableRowElement:!1,HTMLTableSectionElement:!1,HTMLTemplateElement:!1,HTMLTextAreaElement:!1,HTMLTimeElement:!1,HTMLTitleElement:!1,HTMLTrackElement:!1,HTMLUListElement:!1,HTMLVideoElement:!1,history:!1,Image:!1,IntersectionObserver:!1,Intl:!1,length:!1,localStorage:!1,location:!1,matchMedia:!1,MediaList:!1,MediaRecorder:!1,MessageChannel:!1,MessageEvent:!1,MessagePort:!1,MouseEvent:!1,moveBy:!1,moveTo:!1,MutationObserver:!1,name:!1,Node:!1,NodeFilter:!1,NodeList:!1,Notification:!1,navigator:!1,onbeforeunload:!0,onblur:!0,onerror:!0,onfocus:!0,onload:!0,onresize:!0,onunload:!0,open:!1,openDatabase:!1,opener:!1,Option:!1,origin:!1,parent:!1,performance:!1,print:!1,queueMicrotask:!1,Range:!1,requestAnimationFrame:!1,removeEventListener:!1,Request:!1,resizeBy:!1,resizeTo:!1,Response:!1,screen:!1,scroll:!1,scrollBy:!1,scrollTo:!1,sessionStorage:!1,setInterval:!1,setTimeout:!1,SharedWorker:!1,status:!1,Storage:!1,StyleSheet:!1,SVGAElement:!1,SVGAltGlyphDefElement:!1,SVGAltGlyphElement:!1,SVGAltGlyphItemElement:!1,SVGAngle:!1,SVGAnimateColorElement:!1,SVGAnimateElement:!1,SVGAnimateMotionElement:!1,SVGAnimateTransformElement:!1,SVGAnimatedAngle:!1,SVGAnimatedBoolean:!1,SVGAnimatedEnumeration:!1,SVGAnimatedInteger:!1,SVGAnimatedLength:!1,SVGAnimatedLengthList:!1,SVGAnimatedNumber:!1,SVGAnimatedNumberList:!1,SVGAnimatedPathData:!1,SVGAnimatedPoints:!1,SVGAnimatedPreserveAspectRatio:!1,SVGAnimatedRect:!1,SVGAnimatedString:!1,SVGAnimatedTransformList:!1,SVGAnimationElement:!1,SVGCSSRule:!1,SVGCircleElement:!1,SVGClipPathElement:!1,SVGColor:!1,SVGColorProfileElement:!1,SVGColorProfileRule:!1,SVGComponentTransferFunctionElement:!1,SVGCursorElement:!1,SVGDefsElement:!1,SVGDescElement:!1,SVGDocument:!1,SVGElement:!1,SVGElementInstance:!1,SVGElementInstanceList:!1,SVGEllipseElement:!1,SVGExternalResourcesRequired:!1,SVGFEBlendElement:!1,SVGFEColorMatrixElement:!1,SVGFEComponentTransferElement:!1,SVGFECompositeElement:!1,SVGFEConvolveMatrixElement:!1,SVGFEDiffuseLightingElement:!1,SVGFEDisplacementMapElement:!1,SVGFEDistantLightElement:!1,SVGFEFloodElement:!1,SVGFEFuncAElement:!1,SVGFEFuncBElement:!1,SVGFEFuncGElement:!1,SVGFEFuncRElement:!1,SVGFEGaussianBlurElement:!1,SVGFEImageElement:!1,SVGFEMergeElement:!1,SVGFEMergeNodeElement:!1,SVGFEMorphologyElement:!1,SVGFEOffsetElement:!1,SVGFEPointLightElement:!1,SVGFESpecularLightingElement:!1,SVGFESpotLightElement:!1,SVGFETileElement:!1,SVGFETurbulenceElement:!1,SVGFilterElement:!1,SVGFilterPrimitiveStandardAttributes:!1,SVGFitToViewBox:!1,SVGFontElement:!1,SVGFontFaceElement:!1,SVGFontFaceFormatElement:!1,SVGFontFaceNameElement:!1,SVGFontFaceSrcElement:!1,SVGFontFaceUriElement:!1,SVGForeignObjectElement:!1,SVGGElement:!1,SVGGlyphElement:!1,SVGGlyphRefElement:!1,SVGGradientElement:!1,SVGHKernElement:!1,SVGICCColor:!1,SVGImageElement:!1,SVGLangSpace:!1,SVGLength:!1,SVGLengthList:!1,SVGLineElement:!1,SVGLinearGradientElement:!1,SVGLocatable:!1,SVGMPathElement:!1,SVGMarkerElement:!1,SVGMaskElement:!1,SVGMatrix:!1,SVGMetadataElement:!1,SVGMissingGlyphElement:!1,SVGNumber:!1,SVGNumberList:!1,SVGPaint:!1,SVGPathElement:!1,SVGPathSeg:!1,SVGPathSegArcAbs:!1,SVGPathSegArcRel:!1,SVGPathSegClosePath:!1,SVGPathSegCurvetoCubicAbs:!1,SVGPathSegCurvetoCubicRel:!1,SVGPathSegCurvetoCubicSmoothAbs:!1,SVGPathSegCurvetoCubicSmoothRel:!1,SVGPathSegCurvetoQuadraticAbs:!1,SVGPathSegCurvetoQuadraticRel:!1,SVGPathSegCurvetoQuadraticSmoothAbs:!1,SVGPathSegCurvetoQuadraticSmoothRel:!1,SVGPathSegLinetoAbs:!1,SVGPathSegLinetoHorizontalAbs:!1,SVGPathSegLinetoHorizontalRel:!1,SVGPathSegLinetoRel:!1,SVGPathSegLinetoVerticalAbs:!1,SVGPathSegLinetoVerticalRel:!1,SVGPathSegList:!1,SVGPathSegMovetoAbs:!1,SVGPathSegMovetoRel:!1,SVGPatternElement:!1,SVGPoint:!1,SVGPointList:!1,SVGPolygonElement:!1,SVGPolylineElement:!1,SVGPreserveAspectRatio:!1,SVGRadialGradientElement:!1,SVGRect:!1,SVGRectElement:!1,SVGRenderingIntent:!1,SVGSVGElement:!1,SVGScriptElement:!1,SVGSetElement:!1,SVGStopElement:!1,SVGStringList:!1,SVGStylable:!1,SVGStyleElement:!1,SVGSwitchElement:!1,SVGSymbolElement:!1,SVGTRefElement:!1,SVGTSpanElement:!1,SVGTests:!1,SVGTextContentElement:!1,SVGTextElement:!1,SVGTextPathElement:!1,SVGTextPositioningElement:!1,SVGTitleElement:!1,SVGTransform:!1,SVGTransformList:!1,SVGTransformable:!1,SVGURIReference:!1,SVGUnitTypes:!1,SVGUseElement:!1,SVGVKernElement:!1,SVGViewElement:!1,SVGViewSpec:!1,SVGZoomAndPan:!1,Text:!1,TextDecoder:!1,TextEncoder:!1,TimeEvent:!1,top:!1,URL:!1,WebGLActiveInfo:!1,WebGLBuffer:!1,WebGLContextEvent:!1,WebGLFramebuffer:!1,WebGLProgram:!1,WebGLRenderbuffer:!1,WebGLRenderingContext:!1,WebGLShader:!1,WebGLShaderPrecisionFormat:!1,WebGLTexture:!1,WebGLUniformLocation:!1,WebSocket:!1,window:!1,Window:!1,Worker:!1,XDomainRequest:!1,XMLDocument:!1,XMLHttpRequest:!1,XMLSerializer:!1,XPathEvaluator:!1,XPathException:!1,XPathExpression:!1,XPathNamespace:!1,XPathNSResolver:!1,XPathResult:!1},n.devel={alert:!1,confirm:!1,console:!1,Debug:!1,opera:!1,prompt:!1},n.worker={addEventListener:!0,atob:!0,btoa:!0,clearInterval:!0,clearTimeout:!0,createImageBitmap:!0,dispatchEvent:!0,importScripts:!0,onmessage:!0,origin:!0,postMessage:!0,queueMicrotask:!0,removeEventListener:!0,self:!0,setInterval:!0,setTimeout:!0,FileReaderSync:!0},n.nonstandard={escape:!1,unescape:!1},n.couch={require:!1,respond:!1,getRow:!1,emit:!1,send:!1,start:!1,sum:!1,log:!1,exports:!1,module:!1,provides:!1},n.node={__filename:!1,__dirname:!1,arguments:!1,GLOBAL:!1,global:!1,module:!1,require:!1,Buffer:!0,console:!0,exports:!0,process:!0,setTimeout:!0,clearTimeout:!0,setInterval:!0,clearInterval:!0,setImmediate:!0,clearImmediate:!0},n.browserify={__filename:!1,__dirname:!1,global:!1,module:!1,require:!1,Buffer:!0,exports:!0,process:!0},n.phantom={phantom:!0,require:!0,WebPage:!0,console:!0,exports:!0},n.qunit={asyncTest:!1,deepEqual:!1,equal:!1,expect:!1,module:!1,notDeepEqual:!1,notEqual:!1,notOk:!1,notPropEqual:!1,notStrictEqual:!1,ok:!1,propEqual:!1,QUnit:!1,raises:!1,start:!1,stop:!1,strictEqual:!1,test:!1,"throws":!1},n.rhino={arguments:!1,defineClass:!1,deserialize:!1,gc:!1,help:!1,importClass:!1,importPackage:!1,java:!1,load:!1,loadClass:!1,Packages:!1,print:!1,quit:!1,readFile:!1,readUrl:!1,runCommand:!1,seal:!1,serialize:!1,spawn:!1,sync:!1,toint32:!1,version:!1},n.shelljs={target:!1,echo:!1,exit:!1,cd:!1,pwd:!1,ls:!1,find:!1,cp:!1,rm:!1,mv:!1,mkdir:!1,test:!1,cat:!1,sed:!1,grep:!1,which:!1,dirs:!1,pushd:!1,popd:!1,env:!1,exec:!1,chmod:!1,config:!1,error:!1,tempdir:!1},n.typed={ArrayBuffer:!1,ArrayBufferView:!1,DataView:!1,Float32Array:!1,Float64Array:!1,Int16Array:!1,Int32Array:!1,Int8Array:!1,Uint16Array:!1,Uint32Array:!1,Uint8Array:!1,Uint8ClampedArray:!1},n.wsh={ActiveXObject:!0,Enumerator:!0,GetObject:!0,ScriptEngine:!0,ScriptEngineBuildVersion:!0,ScriptEngineMajorVersion:!0,ScriptEngineMinorVersion:!0,VBArray:!0,WSH:!0,WScript:!0,XDomainRequest:!0},n.dojo={dojo:!1,dijit:!1,dojox:!1,define:!1,require:!1},n.jquery={$:!1,jQuery:!1},n.mootools={$:!1,$$:!1,Asset:!1,Browser:!1,Chain:!1,Class:!1,Color:!1,Cookie:!1,Core:!1,Document:!1,DomReady:!1,DOMEvent:!1,DOMReady:!1,Drag:!1,Element:!1,Elements:!1,Event:!1,Events:!1,Fx:!1,Group:!1,Hash:!1,HtmlTable:!1,IFrame:!1,IframeShim:!1,InputValidator:!1,instanceOf:!1,Keyboard:!1,Locale:!1,Mask:!1,MooTools:!1,Native:!1,Options:!1,OverText:!1,Request:!1,Scroller:!1,Slick:!1,Slider:!1,Sortables:!1,Spinner:!1,Swiff:!1,Tips:!1,Type:!1,typeOf:!1,URI:!1,Window:!1},n.prototypejs={$:!1,$$:!1,$A:!1,$F:!1,$H:!1,$R:!1,$break:!1,$continue:!1,$w:!1,Abstract:!1,Ajax:!1,Class:!1,Enumerable:!1,Element:!1,Event:!1,Field:!1,Form:!1,Hash:!1,Insertion:!1,ObjectRange:!1,PeriodicalExecuter:!1,Position:!1,Prototype:!1,Selector:!1,Template:!1,Toggle:!1,Try:!1,Autocompleter:!1,Builder:!1,Control:!1,Draggable:!1,Draggables:!1,Droppables:!1,Effect:!1,Sortable:!1,SortableObserver:!1,Sound:!1,Scriptaculous:!1},n.yui={YUI:!1,Y:!1,YUI_config:!1},n.mocha={mocha:!1,describe:!1,xdescribe:!1,it:!1,xit:!1,context:!1,xcontext:!1,before:!1,after:!1,beforeEach:!1,afterEach:!1,suite:!1,test:!1,setup:!1,teardown:!1,suiteSetup:!1,suiteTeardown:!1},n.jasmine={jasmine:!1,describe:!1,xdescribe:!1,it:!1,xit:!1,beforeEach:!1,afterEach:!1,setFixtures:!1,loadFixtures:!1,spyOn:!1,expect:!1,runs:!1,waitsFor:!1,waits:!1,beforeAll:!1,afterAll:!1,fail:!1,fdescribe:!1,fit:!1,pending:!1,spyOnProperty:!1}},{}],"/../node_modules/assert/assert.js":[function(e,t,n){(function(n){"use strict";function i(e,t){if(e===t)return 0;var n=e.length,r=t.length;for(var i=0,s=Math.min(n,r);i<s;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0}function s(e){return n.Buffer&&typeof n.Buffer.isBuffer=="function"?n.Buffer.isBuffer(e):e!=null&&!!e._isBuffer}function l(e){return Object.prototype.toString.call(e)}function c(e){return s(e)?!1:typeof n.ArrayBuffer!="function"?!1:typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e?e instanceof DataView?!0:e.buffer&&e.buffer instanceof ArrayBuffer?!0:!1:!1}function d(e){if(!o.isFunction(e))return;if(f)return e.name;var t=e.toString(),n=t.match(p);return n&&n[1]}function v(e,t){return typeof e=="string"?e.length<t?e:e.slice(0,t):e}function m(e){if(f||!o.isFunction(e))return o.inspect(e);var t=d(e),n=t?": "+t:"";return"[Function"+n+"]"}function g(e){return v(m(e.actual),128)+" "+e.operator+" "+v(m(e.expected),128)}function y(e,t,n,r,i){throw new h.AssertionError({message:n,actual:e,expected:t,operator:r,stackStartFunction:i})}function b(e,t){e||y(e,!0,t,"==",h.ok)}function w(e,t,n,r){if(e===t)return!0;if(s(e)&&s(t))return i(e,t)===0;if(o.isDate(e)&&o.isDate(t))return e.getTime()===t.getTime();if(o.isRegExp(e)&&o.isRegExp(t))return e.source===t.source&&e.global===t.global&&e.multiline===t.multiline&&e.lastIndex===t.lastIndex&&e.ignoreCase===t.ignoreCase;if(e!==null&&typeof e=="object"||t!==null&&typeof t=="object"){if(!c(e)||!c(t)||l(e)!==l(t)||e instanceof Float32Array||e instanceof Float64Array){if(s(e)!==s(t))return!1;r=r||{actual:[],expected:[]};var u=r.actual.indexOf(e);return u!==-1&&u===r.expected.indexOf(t)?!0:(r.actual.push(e),r.expected.push(t),S(e,t,n,r))}return i(new Uint8Array(e.buffer),new Uint8Array(t.buffer))===0}return n?e===t:e==t}function E(e){return Object.prototype.toString.call(e)=="[object Arguments]"}function S(e,t,n,r){if(e===null||e===undefined||t===null||t===undefined)return!1;if(o.isPrimitive(e)||o.isPrimitive(t))return e===t;if(n&&Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;var i=E(e),s=E(t);if(i&&!s||!i&&s)return!1;if(i)return e=a.call(e),t=a.call(t),w(e,t,n);var u=L(e),f=L(t),l,c;if(u.length!==f.length)return!1;u.sort(),f.sort();for(c=u.length-1;c>=0;c--)if(u[c]!==f[c])return!1;for(c=u.length-1;c>=0;c--){l=u[c];if(!w(e[l],t[l],n,r))return!1}return!0}function x(e,t,n){w(e,t,!0)&&y(e,t,n,"notDeepStrictEqual",x)}function T(e,t){if(!e||!t)return!1;if(Object.prototype.toString.call(t)=="[object RegExp]")return t.test(e);try{if(e instanceof t)return!0}catch(n){}return Error.isPrototypeOf(t)?!1:t.call({},e)===!0}function N(e){var t;try{e()}catch(n){t=n}return t}function C(e,t,n,r){var i;if(typeof t!="function")throw new TypeError('"block" argument must be a function');typeof n=="string"&&(r=n,n=null),i=N(t),r=(n&&n.name?" ("+n.name+").":".")+(r?" "+r:"."),e&&!i&&y(i,n,"Missing expected exception"+r);var s=typeof r=="string",u=!e&&o.isError(i),a=!e&&i&&!n;(u&&s&&T(i,n)||a)&&y(i,n,"Got unwanted exception"+r);if(e&&i&&n&&!T(i,n)||!e&&i)throw i}function k(e,t){e||y(e,!0,t,"==",k)}var r=e("object-assign"),o=e("util/"),u=Object.prototype.hasOwnProperty,a=Array.prototype.slice,f=function(){return function(){}.name==="foo"}(),h=t.exports=b,p=/\s*function\s+([^\(\s]*)\s*/;h.AssertionError=function(t){this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=g(this),this.generatedMessage=!0);var n=t.stackStartFunction||y;if(Error.captureStackTrace)Error.captureStackTrace(this,n);else{var r=new Error;if(r.stack){var i=r.stack,s=d(n),o=i.indexOf("\n"+s);if(o>=0){var u=i.indexOf("\n",o+1);i=i.substring(u+1)}this.stack=i}}},o.inherits(h.AssertionError,Error),h.fail=y,h.ok=b,h.equal=function(t,n,r){t!=n&&y(t,n,r,"==",h.equal)},h.notEqual=function(t,n,r){t==n&&y(t,n,r,"!=",h.notEqual)},h.deepEqual=function(t,n,r){w(t,n,!1)||y(t,n,r,"deepEqual",h.deepEqual)},h.deepStrictEqual=function(t,n,r){w(t,n,!0)||y(t,n,r,"deepStrictEqual",h.deepStrictEqual)},h.notDeepEqual=function(t,n,r){w(t,n,!1)&&y(t,n,r,"notDeepEqual",h.notDeepEqual)},h.notDeepStrictEqual=x,h.strictEqual=function(t,n,r){t!==n&&y(t,n,r,"===",h.strictEqual)},h.notStrictEqual=function(t,n,r){t===n&&y(t,n,r,"!==",h.notStrictEqual)},h.throws=function(e,t,n){C(!0,e,t,n)},h.doesNotThrow=function(e,t,n){C(!1,e,t,n)},h.ifError=function(e){if(e)throw e},h.strict=r(k,h,{equal:h.strictEqual,deepEqual:h.deepStrictEqual,notEqual:h.notStrictEqual,notDeepEqual:h.notDeepStrictEqual}),h.strict.strict=h.strict;var L=Object.keys||function(e){var t=[];for(var n in e)u.call(e,n)&&t.push(n);return t}}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{"object-assign":"/../node_modules/object-assign/index.js","util/":"/../node_modules/assert/node_modules/util/util.js"}],"/../node_modules/assert/node_modules/inherits/inherits_browser.js":[function(e,t,n){typeof Object.create=="function"?t.exports=function(t,n){t.super_=n,t.prototype=Object.create(n.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(t,n){t.super_=n;var r=function(){};r.prototype=n.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],"/../node_modules/assert/node_modules/util/support/isBufferBrowser.js":[function(e,t,n){t.exports=function(t){return t&&typeof t=="object"&&typeof t.copy=="function"&&typeof t.fill=="function"&&typeof t.readUInt8=="function"}},{}],"/../node_modules/assert/node_modules/util/util.js":[function(e,t,n){(function(t,r){function u(e,t){var r={seen:[],stylize:f};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),y(t)?r.showHidden=t:t&&n._extend(r,t),T(r.showHidden)&&(r.showHidden=!1),T(r.depth)&&(r.depth=2),T(r.colors)&&(r.colors=!1),T(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=a),c(r,e,r.depth)}function a(e,t){var n=u.styles[t];return n?"["+u.colors[n][0]+"m"+e+"["+u.colors[n][1]+"m":e}function f(e,t){return e}function l(e){var t={};return e.forEach(function(e,n){t[e]=!0}),t}function c(e,t,r){if(e.customInspect&&t&&A(t.inspect)&&t.inspect!==n.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(r,e);return S(i)||(i=c(e,i,r)),i}var s=h(e,t);if(s)return s;var o=Object.keys(t),u=l(o);e.showHidden&&(o=Object.getOwnPropertyNames(t));if(L(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return p(t);if(o.length===0){if(A(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(N(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(k(t))return e.stylize(Date.prototype.toString.call(t),"date");if(L(t))return p(t)}var f="",y=!1,b=["{","}"];g(t)&&(y=!0,b=["[","]"]);if(A(t)){var w=t.name?": "+t.name:"";f=" [Function"+w+"]"}N(t)&&(f=" "+RegExp.prototype.toString.call(t)),k(t)&&(f=" "+Date.prototype.toUTCString.call(t)),L(t)&&(f=" "+p(t));if(o.length!==0||!!y&&t.length!=0){if(r<0)return N(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var E;return y?E=d(e,t,r,u,o):E=o.map(function(n){return v(e,t,r,u,n,y)}),e.seen.pop(),m(E,f,b)}return b[0]+f+b[1]}function h(e,t){if(T(t))return e.stylize("undefined","undefined");if(S(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(E(t))return e.stylize(""+t,"number");if(y(t))return e.stylize(""+t,"boolean");if(b(t))return e.stylize("null","null")}function p(e){return"["+Error.prototype.toString.call(e)+"]"}function d(e,t,n,r,i){var s=[];for(var o=0,u=t.length;o<u;++o)H(t,String(o))?s.push(v(e,t,n,r,String(o),!0)):s.push("");return i.forEach(function(i){i.match(/^\d+$/)||s.push(v(e,t,n,r,i,!0))}),s}function v(e,t,n,r,i,s){var o,u,a;a=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},a.get?a.set?u=e.stylize("[Getter/Setter]","special"):u=e.stylize("[Getter]","special"):a.set&&(u=e.stylize("[Setter]","special")),H(r,i)||(o="["+i+"]"),u||(e.seen.indexOf(a.value)<0?(b(n)?u=c(e,a.value,null):u=c(e,a.value,n-1),u.indexOf("\n")>-1&&(s?u=u.split("\n").map(function(e){return" "+e}).join("\n").substr(2):u="\n"+u.split("\n").map(function(e){return" "+e}).join("\n"))):u=e.stylize("[Circular]","special"));if(T(o)){if(s&&i.match(/^\d+$/))return u;o=JSON.stringify(""+i),o.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=e.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=e.stylize(o,"string"))}return o+": "+u}function m(e,t,n){var r=0,i=e.reduce(function(e,t){return r++,t.indexOf("\n")>=0&&r++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?n[0]+(t===""?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}function g(e){return Array.isArray(e)}function y(e){return typeof e=="boolean"}function b(e){return e===null}function w(e){return e==null}function E(e){return typeof e=="number"}function S(e){return typeof e=="string"}function x(e){return typeof e=="symbol"}function T(e){return e===void 0}function N(e){return C(e)&&M(e)==="[object RegExp]"}function C(e){return typeof e=="object"&&e!==null}function k(e){return C(e)&&M(e)==="[object Date]"}function L(e){return C(e)&&(M(e)==="[object Error]"||e instanceof Error)}function A(e){return typeof e=="function"}function O(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e=="undefined"}function M(e){return Object.prototype.toString.call(e)}function _(e){return e<10?"0"+e.toString(10):e.toString(10)}function P(){var e=new Date,t=[_(e.getHours()),_(e.getMinutes()),_(e.getSeconds())].join(":");return[e.getDate(),D[e.getMonth()],t].join(" ")}function H(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var i=/%[sdj%]/g;n.format=function(e){if(!S(e)){var t=[];for(var n=0;n<arguments.length;n++)t.push(u(arguments[n]));return t.join(" ")}var n=1,r=arguments,s=r.length,o=String(e).replace(i,function(e){if(e==="%%")return"%";if(n>=s)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"};default:return e}});for(var a=r[n];n<s;a=r[++n])b(a)||!C(a)?o+=" "+a:o+=" "+u(a);return o},n.deprecate=function(e,i){function o(){if(!s){if(t.throwDeprecation)throw new Error(i);t.traceDeprecation?console.trace(i):console.error(i),s=!0}return e.apply(this,arguments)}if(T(r.process))return function(){return n.deprecate(e,i).apply(this,arguments)};if(t.noDeprecation===!0)return e;var s=!1;return o};var s={},o;n.debuglog=function(e){T(o)&&(o=t.env.NODE_DEBUG||""),e=e.toUpperCase();if(!s[e])if((new RegExp("\\b"+e+"\\b","i")).test(o)){var r=t.pid;s[e]=function(){var t=n.format.apply(n,arguments);console.error("%s %d: %s",e,r,t)}}else s[e]=function(){};return s[e]},n.inspect=u,u.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},u.styles={special:"cyan",number:"yellow","boolean":"yellow","undefined":"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},n.isArray=g,n.isBoolean=y,n.isNull=b,n.isNullOrUndefined=w,n.isNumber=E,n.isString=S,n.isSymbol=x,n.isUndefined=T,n.isRegExp=N,n.isObject=C,n.isDate=k,n.isError=L,n.isFunction=A,n.isPrimitive=O,n.isBuffer=e("./support/isBuffer");var D=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];n.log=function(){console.log("%s - %s",P(),n.format.apply(n,arguments))},n.inherits=e("inherits"),n._extend=function(e,t){if(!t||!C(t))return e;var n=Object.keys(t),r=n.length;while(r--)e[n[r]]=t[n[r]];return e}}).call(this,e("_process"),typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{"./support/isBuffer":"/../node_modules/assert/node_modules/util/support/isBufferBrowser.js",_process:"/../node_modules/process/browser.js",inherits:"/../node_modules/assert/node_modules/inherits/inherits_browser.js"}],"/../node_modules/events/events.js":[function(e,t,n){function o(){if(!this._events||!Object.prototype.hasOwnProperty.call(this,"_events"))this._events=r(null),this._eventsCount=0;this._maxListeners=this._maxListeners||undefined}function c(e){return e._maxListeners===undefined?o.defaultMaxListeners:e._maxListeners}function h(e,t,n){if(t)e.call(n);else{var r=e.length,i=x(e,r);for(var s=0;s<r;++s)i[s].call(n)}}function p(e,t,n,r){if(t)e.call(n,r);else{var i=e.length,s=x(e,i);for(var o=0;o<i;++o)s[o].call(n,r)}}function d(e,t,n,r,i){if(t)e.call(n,r,i);else{var s=e.length,o=x(e,s);for(var u=0;u<s;++u)o[u].call(n,r,i)}}function v(e,t,n,r,i,s){if(t)e.call(n,r,i,s);else{var o=e.length,u=x(e,o);for(var a=0;a<o;++a)u[a].call(n,r,i,s)}}function m(e,t,n,r){if(t)e.apply(n,r);else{var i=e.length,s=x(e,i);for(var o=0;o<i;++o)s[o].apply(n,r)}}function g(e,t,n,i){var s,o,u;if(typeof n!="function")throw new TypeError('"listener" argument must be a function');o=e._events,o?(o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),u=o[t]):(o=e._events=r(null),e._eventsCount=0);if(!u)u=o[t]=n,++e._eventsCount;else{typeof u=="function"?u=o[t]=i?[n,u]:[u,n]:i?u.unshift(n):u.push(n);if(!u.warned){s=c(e);if(s&&s>0&&u.length>s){u.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+u.length+' "'+String(t)+'" listeners '+"added. Use emitter.setMaxListeners() to "+"increase limit.");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=u.length,typeof console=="object"&&console.warn&&console.warn("%s: %s",a.name,a.message)}}}return e}function y(){if(!this.fired){this.target.removeListener(this.type,this.wrapFn),this.fired=!0;switch(arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:var e=new Array(arguments.length);for(var t=0;t<e.length;++t)e[t]=arguments[t];this.listener.apply(this.target,e)}}}function b(e,t,n){var r={fired:!1,wrapFn:undefined,target:e,type:t,listener:n},i=s.call(y,r);return i.listener=n,r.wrapFn=i,i}function w(e,t,n){var r=e._events;if(!r)return[];var i=r[t];return i?typeof i=="function"?n?[i.listener||i]:[i]:n?T(i):x(i,i.length):[]}function E(e){var t=this._events;if(t){var n=t[e];if(typeof n=="function")return 1;if(n)return n.length}return 0}function S(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}function x(e,t){var n=new Array(t);for(var r=0;r<t;++r)n[r]=e[r];return n}function T(e){var t=new Array(e.length);for(var n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function N(e){var t=function(){};return t.prototype=e,new t}function C(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return n}function k(e){var t=this;return function(){return t.apply(e,arguments)}}var r=Object.create||N,i=Object.keys||C,s=Function.prototype.bind||k;t.exports=o,o.EventEmitter=o,o.prototype._events=undefined,o.prototype._maxListeners=undefined;var u=200,a;try{var f={};Object.defineProperty&&Object.defineProperty(f,"x",{value:0}),a=f.x===0}catch(l){a=!1}a?Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(e){if(typeof e!="number"||e<0||e!==e)throw new TypeError('"defaultMaxListeners" must be a positive number');u=e}}):o.defaultMaxListeners=u,o.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||isNaN(t))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=t,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(t){var n,r,i,s,o,u,a=t==="error";u=this._events;if(u)a=a&&u.error==null;else if(!a)return!1;if(a){arguments.length>1&&(n=arguments[1]);if(n instanceof Error)throw n;var f=new Error('Unhandled "error" event. ('+n+")");throw f.context=n,f}r=u[t];if(!r)return!1;var l=typeof r=="function";i=arguments.length;switch(i){case 1:h(r,l,this);break;case 2:p(r,l,this,arguments[1]);break;case 3:d(r,l,this,arguments[1],arguments[2]);break;case 4:v(r,l,this,arguments[1],arguments[2],arguments[3]);break;default:s=new Array(i-1);for(o=1;o<i;o++)s[o-1]=arguments[o];m(r,l,this,s)}return!0},o.prototype.addListener=function(t,n){return g(this,t,n,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(t,n){return g(this,t,n,!0)},o.prototype.once=function(t,n){if(typeof n!="function")throw new TypeError('"listener" argument must be a function');return this.on(t,b(this,t,n)),this},o.prototype.prependOnceListener=function(t,n){if(typeof n!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(t,b(this,t,n)),this},o.prototype.removeListener=function(t,n){var i,s,o,u,a;if(typeof n!="function")throw new TypeError('"listener" argument must be a function');s=this._events;if(!s)return this;i=s[t];if(!i)return this;if(i===n||i.listener===n)--this._eventsCount===0?this._events=r(null):(delete s[t],s.removeListener&&this.emit("removeListener",t,i.listener||n));else if(typeof i!="function"){o=-1;for(u=i.length-1;u>=0;u--)if(i[u]===n||i[u].listener===n){a=i[u].listener,o=u;break}if(o<0)return this;o===0?i.shift():S(i,o),i.length===1&&(s[t]=i[0]),s.removeListener&&this.emit("removeListener",t,a||n)}return this},o.prototype.removeAllListeners=function(t){var n,s,o;s=this._events;if(!s)return this;if(!s.removeListener)return arguments.length===0?(this._events=r(null),this._eventsCount=0):s[t]&&(--this._eventsCount===0?this._events=r(null):delete s[t]),this;if(arguments.length===0){var u=i(s),a;for(o=0;o<u.length;++o){a=u[o];if(a==="removeListener")continue;this.removeAllListeners(a)}return this.removeAllListeners("removeListener"),this._events=r(null),this._eventsCount=0,this}n=s[t];if(typeof n=="function")this.removeListener(t,n);else if(n)for(o=n.length-1;o>=0;o--)this.removeListener(t,n[o]);return this},o.prototype.listeners=function(t){return w(this,t,!0)},o.prototype.rawListeners=function(t){return w(this,t,!1)},o.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):E.call(e,t)},o.prototype.listenerCount=E,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],"/../node_modules/object-assign/index.js":[function(e,t,n){"use strict";function o(e){if(e===null||e===undefined)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function u(){try{if(!Object.assign)return!1;var e=new String("abc");e[5]="de";if(Object.getOwnPropertyNames(e)[0]==="5")return!1;var t={};for(var n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;var r=Object.getOwnPropertyNames(t).map(function(e){return t[e]});if(r.join("")!=="0123456789")return!1;var i={};return"abcdefghijklmnopqrst".split("").forEach(function(e){i[e]=e}),Object.keys(Object.assign({},i)).join("")!=="abcdefghijklmnopqrst"?!1:!0}catch(s){return!1}}var r=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;t.exports=u()?Object.assign:function(e,t){var n,u=o(e),a;for(var f=1;f<arguments.length;f++){n=Object(arguments[f]);for(var l in n)i.call(n,l)&&(u[l]=n[l]);if(r){a=r(n);for(var c=0;c<a.length;c++)s.call(n,a[c])&&(u[a[c]]=n[a[c]])}}return u}},{}],"/../node_modules/process/browser.js":[function(e,t,n){function o(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function a(e){if(i===setTimeout)return setTimeout(e,0);if((i===o||!i)&&setTimeout)return i=setTimeout,setTimeout(e,0);try{return i(e,0)}catch(t){try{return i.call(null,e,0)}catch(t){return i.call(this,e,0)}}}function f(e){if(s===clearTimeout)return clearTimeout(e);if((s===u||!s)&&clearTimeout)return s=clearTimeout,clearTimeout(e);try{return s(e)}catch(t){try{return s.call(null,e)}catch(t){return s.call(this,e)}}}function d(){if(!c||!h)return;c=!1,h.length?l=h.concat(l):p=-1,l.length&&v()}function v(){if(c)return;var e=a(d);c=!0;var t=l.length;while(t){h=l,l=[];while(++p<t)h&&h[p].run();p=-1,t=l.length}h=null,c=!1,f(e)}function m(e,t){this.fun=e,this.array=t}function g(){}var r=t.exports={},i,s;(function(){try{typeof setTimeout=="function"?i=setTimeout:i=o}catch(e){i=o}try{typeof clearTimeout=="function"?s=clearTimeout:s=u}catch(e){s=u}})();var l=[],c=!1,h,p=-1;r.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];l.push(new m(e,t)),l.length===1&&!c&&a(v)},m.prototype.run=function(){this.fun.apply(null,this.array)},r.title="browser",r.browser=!0,r.env={},r.argv=[],r.version="",r.versions={},r.on=g,r.addListener=g,r.once=g,r.off=g,r.removeListener=g,r.removeAllListeners=g,r.emit=g,r.prependListener=g,r.prependOnceListener=g,r.listeners=function(e){return[]},r.binding=function(e){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(e){throw new Error("process.chdir is not supported")},r.umask=function(){return 0}},{}],"/../node_modules/util/node_modules/inherits/inherits_browser.js":[function(e,t,n){arguments[4]["/../node_modules/assert/node_modules/inherits/inherits_browser.js"][0].apply(n,arguments)},{}],"/../node_modules/util/support/isBufferBrowser.js":[function(e,t,n){arguments[4]["/../node_modules/assert/node_modules/util/support/isBufferBrowser.js"][0].apply(n,arguments)},{}],"/../node_modules/util/util.js":[function(e,t,n){arguments[4]["/../node_modules/assert/node_modules/util/util.js"][0].apply(n,arguments)},{"./support/isBuffer":"/../node_modules/util/support/isBufferBrowser.js",_process:"/../node_modules/process/browser.js",inherits:"/../node_modules/util/node_modules/inherits/inherits_browser.js"}]},{},["/../../jshint/src/jshint.js"])}),ace.define("ace/mode/javascript_worker",[],function(require,exports,module){"use strict";function startRegex(e){return RegExp("^("+e.join("|")+")")}var oop=require("../lib/oop"),Mirror=require("../worker/mirror").Mirror,lint=require("./javascript/jshint").JSHINT,disabledWarningsRe=startRegex(["Bad for in variable '(.+)'.",'Missing "use strict"']),errorsRe=startRegex(["Unexpected","Expected ","Confusing (plus|minus)","\\{a\\} unterminated regular expression","Unclosed ","Unmatched ","Unbegun comment","Bad invocation","Missing space after","Missing operator at"]),infoRe=startRegex(["Expected an assignment","Bad escapement of EOL","Unexpected comma","Unexpected space","Missing radix parameter.","A leading decimal point can","\\['{a}'\\] is better written in dot notation.","'{a}' used out of scope"]),JavaScriptWorker=exports.JavaScriptWorker=function(e){Mirror.call(this,e),this.setTimeout(500),this.setOptions()};oop.inherits(JavaScriptWorker,Mirror),function(){this.setOptions=function(e){this.options=e||{esnext:!0,moz:!0,devel:!0,browser:!0,node:!0,laxcomma:!0,laxbreak:!0,lastsemic:!0,onevar:!1,passfail:!1,maxerr:100,expr:!0,multistr:!0,globalstrict:!0},this.doc.getValue()&&this.deferredUpdate.schedule(100)},this.changeOptions=function(e){oop.mixin(this.options,e),this.doc.getValue()&&this.deferredUpdate.schedule(100)},this.isValidJS=function(str){try{eval("throw 0;"+str)}catch(e){if(e===0)return!0}return!1},this.onUpdate=function(){var e=this.doc.getValue();e=e.replace(/^#!.*\n/,"\n");if(!e)return this.sender.emit("annotate",[]);var t=[],n=this.isValidJS(e)?"warning":"error";lint(e,this.options,this.options.globals);var r=lint.errors,i=!1;for(var s=0;s<r.length;s++){var o=r[s];if(!o)continue;var u=o.raw,a="warning";if(u=="Missing semicolon."){var f=o.evidence.substr(o.character);f=f.charAt(f.search(/\S/)),n=="error"&&f&&/[\w\d{(['"]/.test(f)?(o.reason='Missing ";" before statement',a="error"):a="info"}else{if(disabledWarningsRe.test(u))continue;infoRe.test(u)?a="info":errorsRe.test(u)?(i=!0,a=n):u=="'{a}' is not defined."?a="warning":u=="'{a}' is defined but never used."&&(a="info")}t.push({row:o.line-1,column:o.character-1,text:o.reason,type:a,raw:u}),i}this.sender.emit("annotate",t)}}.call(JavaScriptWorker.prototype)})
0
repos/LoLa/website
repos/LoLa/website/libs/mode-javascript.js
ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text_highlight_rules").TextHighlightRules,s=function(){this.$rules={start:[{token:"comment.doc.tag",regex:"@[\\w\\d_]+"},s.getTagRule(),{defaultToken:"comment.doc",caseInsensitive:!0}]}};r.inherits(s,i),s.getTagRule=function(e){return{token:"comment.doc.tag.storage.type",regex:"\\b(?:TODO|FIXME|XXX|HACK)\\b"}},s.getStartRule=function(e){return{token:"comment.doc",regex:"\\/\\*(?=\\*)",next:e}},s.getEndRule=function(e){return{token:"comment.doc",regex:"\\*\\/",next:e}},t.DocCommentHighlightRules=s}),ace.define("ace/mode/javascript_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"],function(e,t,n){"use strict";function a(){var e=o.replace("\\d","\\d\\-"),t={onMatch:function(e,t,n){var r=e.charAt(1)=="/"?2:1;if(r==1)t!=this.nextState?n.unshift(this.next,this.nextState,0):n.unshift(this.next),n[2]++;else if(r==2&&t==this.nextState){n[1]--;if(!n[1]||n[1]<0)n.shift(),n.shift()}return[{type:"meta.tag.punctuation."+(r==1?"":"end-")+"tag-open.xml",value:e.slice(0,r)},{type:"meta.tag.tag-name.xml",value:e.substr(r)}]},regex:"</?"+e+"",next:"jsxAttributes",nextState:"jsx"};this.$rules.start.unshift(t);var n={regex:"{",token:"paren.quasi.start",push:"start"};this.$rules.jsx=[n,t,{include:"reference"},{defaultToken:"string"}],this.$rules.jsxAttributes=[{token:"meta.tag.punctuation.tag-close.xml",regex:"/?>",onMatch:function(e,t,n){return t==n[0]&&n.shift(),e.length==2&&(n[0]==this.nextState&&n[1]--,(!n[1]||n[1]<0)&&n.splice(0,2)),this.next=n[0]||"start",[{type:this.token,value:e}]},nextState:"jsx"},n,f("jsxAttributes"),{token:"entity.other.attribute-name.xml",regex:e},{token:"keyword.operator.attribute-equals.xml",regex:"="},{token:"text.tag-whitespace.xml",regex:"\\s+"},{token:"string.attribute-value.xml",regex:"'",stateName:"jsx_attr_q",push:[{token:"string.attribute-value.xml",regex:"'",next:"pop"},{include:"reference"},{defaultToken:"string.attribute-value.xml"}]},{token:"string.attribute-value.xml",regex:'"',stateName:"jsx_attr_qq",push:[{token:"string.attribute-value.xml",regex:'"',next:"pop"},{include:"reference"},{defaultToken:"string.attribute-value.xml"}]},t],this.$rules.reference=[{token:"constant.language.escape.reference.xml",regex:"(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"}]}function f(e){return[{token:"comment",regex:/\/\*/,next:[i.getTagRule(),{token:"comment",regex:"\\*\\/",next:e||"pop"},{defaultToken:"comment",caseInsensitive:!0}]},{token:"comment",regex:"\\/\\/",next:[i.getTagRule(),{token:"comment",regex:"$|^",next:e||"pop"},{defaultToken:"comment",caseInsensitive:!0}]}]}var r=e("../lib/oop"),i=e("./doc_comment_highlight_rules").DocCommentHighlightRules,s=e("./text_highlight_rules").TextHighlightRules,o="[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*",u=function(e){var t=this.createKeywordMapper({"variable.language":"Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|Namespace|QName|XML|XMLList|ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|SyntaxError|TypeError|URIError|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|isNaN|parseFloat|parseInt|JSON|Math|this|arguments|prototype|window|document",keyword:"const|yield|import|get|set|async|await|break|case|catch|continue|default|delete|do|else|finally|for|function|if|in|of|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|__parent__|__count__|escape|unescape|with|__proto__|class|enum|extends|super|export|implements|private|public|interface|package|protected|static","storage.type":"const|let|var|function","constant.language":"null|Infinity|NaN|undefined","support.function":"alert","constant.language.boolean":"true|false"},"identifier"),n="case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void",r="\\\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|u{[0-9a-fA-F]{1,6}}|[0-2][0-7]{0,2}|3[0-7][0-7]?|[4-7][0-7]?|.)";this.$rules={no_regex:[i.getStartRule("doc-start"),f("no_regex"),{token:"string",regex:"'(?=.)",next:"qstring"},{token:"string",regex:'"(?=.)',next:"qqstring"},{token:"constant.numeric",regex:/0(?:[xX][0-9a-fA-F]+|[oO][0-7]+|[bB][01]+)\b/},{token:"constant.numeric",regex:/(?:\d\d*(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+\b)?/},{token:["storage.type","punctuation.operator","support.function","punctuation.operator","entity.name.function","text","keyword.operator"],regex:"("+o+")(\\.)(prototype)(\\.)("+o+")(\\s*)(=)",next:"function_arguments"},{token:["storage.type","punctuation.operator","entity.name.function","text","keyword.operator","text","storage.type","text","paren.lparen"],regex:"("+o+")(\\.)("+o+")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",next:"function_arguments"},{token:["entity.name.function","text","keyword.operator","text","storage.type","text","paren.lparen"],regex:"("+o+")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",next:"function_arguments"},{token:["storage.type","punctuation.operator","entity.name.function","text","keyword.operator","text","storage.type","text","entity.name.function","text","paren.lparen"],regex:"("+o+")(\\.)("+o+")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",next:"function_arguments"},{token:["storage.type","text","entity.name.function","text","paren.lparen"],regex:"(function)(\\s+)("+o+")(\\s*)(\\()",next:"function_arguments"},{token:["entity.name.function","text","punctuation.operator","text","storage.type","text","paren.lparen"],regex:"("+o+")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",next:"function_arguments"},{token:["text","text","storage.type","text","paren.lparen"],regex:"(:)(\\s*)(function)(\\s*)(\\()",next:"function_arguments"},{token:"keyword",regex:"from(?=\\s*('|\"))"},{token:"keyword",regex:"(?:"+n+")\\b",next:"start"},{token:["support.constant"],regex:/that\b/},{token:["storage.type","punctuation.operator","support.function.firebug"],regex:/(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/},{token:t,regex:o},{token:"punctuation.operator",regex:/[.](?![.])/,next:"property"},{token:"storage.type",regex:/=>/,next:"start"},{token:"keyword.operator",regex:/--|\+\+|\.{3}|===|==|=|!=|!==|<+=?|>+=?|!|&&|\|\||\?:|[!$%&*+\-~\/^]=?/,next:"start"},{token:"punctuation.operator",regex:/[?:,;.]/,next:"start"},{token:"paren.lparen",regex:/[\[({]/,next:"start"},{token:"paren.rparen",regex:/[\])}]/},{token:"comment",regex:/^#!.*$/}],property:[{token:"text",regex:"\\s+"},{token:["storage.type","punctuation.operator","entity.name.function","text","keyword.operator","text","storage.type","text","entity.name.function","text","paren.lparen"],regex:"("+o+")(\\.)("+o+")(\\s*)(=)(\\s*)(function)(?:(\\s+)(\\w+))?(\\s*)(\\()",next:"function_arguments"},{token:"punctuation.operator",regex:/[.](?![.])/},{token:"support.function",regex:/(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/},{token:"support.function.dom",regex:/(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName|ClassName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/},{token:"support.constant",regex:/(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/},{token:"identifier",regex:o},{regex:"",token:"empty",next:"no_regex"}],start:[i.getStartRule("doc-start"),f("start"),{token:"string.regexp",regex:"\\/",next:"regex"},{token:"text",regex:"\\s+|^$",next:"start"},{token:"empty",regex:"",next:"no_regex"}],regex:[{token:"regexp.keyword.operator",regex:"\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"},{token:"string.regexp",regex:"/[sxngimy]*",next:"no_regex"},{token:"invalid",regex:/\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/},{token:"constant.language.escape",regex:/\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/},{token:"constant.language.delimiter",regex:/\|/},{token:"constant.language.escape",regex:/\[\^?/,next:"regex_character_class"},{token:"empty",regex:"$",next:"no_regex"},{defaultToken:"string.regexp"}],regex_character_class:[{token:"regexp.charclass.keyword.operator",regex:"\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"},{token:"constant.language.escape",regex:"]",next:"regex"},{token:"constant.language.escape",regex:"-"},{token:"empty",regex:"$",next:"no_regex"},{defaultToken:"string.regexp.charachterclass"}],function_arguments:[{token:"variable.parameter",regex:o},{token:"punctuation.operator",regex:"[, ]+"},{token:"punctuation.operator",regex:"$"},{token:"empty",regex:"",next:"no_regex"}],qqstring:[{token:"constant.language.escape",regex:r},{token:"string",regex:"\\\\$",consumeLineEnd:!0},{token:"string",regex:'"|$',next:"no_regex"},{defaultToken:"string"}],qstring:[{token:"constant.language.escape",regex:r},{token:"string",regex:"\\\\$",consumeLineEnd:!0},{token:"string",regex:"'|$",next:"no_regex"},{defaultToken:"string"}]};if(!e||!e.noES6)this.$rules.no_regex.unshift({regex:"[{}]",onMatch:function(e,t,n){this.next=e=="{"?this.nextState:"";if(e=="{"&&n.length)n.unshift("start",t);else if(e=="}"&&n.length){n.shift(),this.next=n.shift();if(this.next.indexOf("string")!=-1||this.next.indexOf("jsx")!=-1)return"paren.quasi.end"}return e=="{"?"paren.lparen":"paren.rparen"},nextState:"start"},{token:"string.quasi.start",regex:/`/,push:[{token:"constant.language.escape",regex:r},{token:"paren.quasi.start",regex:/\${/,push:"start"},{token:"string.quasi.end",regex:/`/,next:"pop"},{defaultToken:"string.quasi"}]}),(!e||e.jsx!=0)&&a.call(this);this.embedRules(i,"doc-",[i.getEndRule("no_regex")]),this.normalizeRules()};r.inherits(u,s),t.JavaScriptHighlightRules=u}),ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"],function(e,t,n){"use strict";var r=e("../range").Range,i=function(){};(function(){this.checkOutdent=function(e,t){return/^\s+$/.test(e)?/^\s*\}/.test(t):!1},this.autoOutdent=function(e,t){var n=e.getLine(t),i=n.match(/^(\s*\})/);if(!i)return 0;var s=i[1].length,o=e.findMatchingBracket({row:t,column:s});if(!o||o.row==t)return 0;var u=this.$getIndent(e.getLine(o.row));e.replace(new r(t,0,t,s-1),u)},this.$getIndent=function(e){return e.match(/^\s*/)[0]}}).call(i.prototype),t.MatchingBraceOutdent=i}),ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"],function(e,t,n){"use strict";var r=e("../../lib/oop"),i=e("../../range").Range,s=e("./fold_mode").FoldMode,o=t.FoldMode=function(e){e&&(this.foldingStartMarker=new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/,"|"+e.start)),this.foldingStopMarker=new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/,"|"+e.end)))};r.inherits(o,s),function(){this.foldingStartMarker=/([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/,this.foldingStopMarker=/^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/,this.singleLineBlockCommentRe=/^\s*(\/\*).*\*\/\s*$/,this.tripleStarBlockCommentRe=/^\s*(\/\*\*\*).*\*\/\s*$/,this.startRegionRe=/^\s*(\/\*|\/\/)#?region\b/,this._getFoldWidgetBase=this.getFoldWidget,this.getFoldWidget=function(e,t,n){var r=e.getLine(n);if(this.singleLineBlockCommentRe.test(r)&&!this.startRegionRe.test(r)&&!this.tripleStarBlockCommentRe.test(r))return"";var i=this._getFoldWidgetBase(e,t,n);return!i&&this.startRegionRe.test(r)?"start":i},this.getFoldWidgetRange=function(e,t,n,r){var i=e.getLine(n);if(this.startRegionRe.test(i))return this.getCommentRegionBlock(e,i,n);var s=i.match(this.foldingStartMarker);if(s){var o=s.index;if(s[1])return this.openingBracketBlock(e,s[1],n,o);var u=e.getCommentFoldRange(n,o+s[0].length,1);return u&&!u.isMultiLine()&&(r?u=this.getSectionRange(e,n):t!="all"&&(u=null)),u}if(t==="markbegin")return;var s=i.match(this.foldingStopMarker);if(s){var o=s.index+s[0].length;return s[1]?this.closingBracketBlock(e,s[1],n,o):e.getCommentFoldRange(n,o,-1)}},this.getSectionRange=function(e,t){var n=e.getLine(t),r=n.search(/\S/),s=t,o=n.length;t+=1;var u=t,a=e.getLength();while(++t<a){n=e.getLine(t);var f=n.search(/\S/);if(f===-1)continue;if(r>f)break;var l=this.getFoldWidgetRange(e,"all",t);if(l){if(l.start.row<=s)break;if(l.isMultiLine())t=l.end.row;else if(r==f)break}u=t}return new i(s,o,u,e.getLine(u).length)},this.getCommentRegionBlock=function(e,t,n){var r=t.search(/\s*$/),s=e.getLength(),o=n,u=/^\s*(?:\/\*|\/\/|--)#?(end)?region\b/,a=1;while(++n<s){t=e.getLine(n);var f=u.exec(t);if(!f)continue;f[1]?a--:a++;if(!a)break}var l=n;if(l>o)return new i(o,r,l,t.length)}}.call(o.prototype)}),ace.define("ace/mode/javascript",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/javascript_highlight_rules","ace/mode/matching_brace_outdent","ace/worker/worker_client","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text").Mode,s=e("./javascript_highlight_rules").JavaScriptHighlightRules,o=e("./matching_brace_outdent").MatchingBraceOutdent,u=e("../worker/worker_client").WorkerClient,a=e("./behaviour/cstyle").CstyleBehaviour,f=e("./folding/cstyle").FoldMode,l=function(){this.HighlightRules=s,this.$outdent=new o,this.$behaviour=new a,this.foldingRules=new f};r.inherits(l,i),function(){this.lineCommentStart="//",this.blockComment={start:"/*",end:"*/"},this.$quotes={'"':'"',"'":"'","`":"`"},this.getNextLineIndent=function(e,t,n){var r=this.$getIndent(t),i=this.getTokenizer().getLineTokens(t,e),s=i.tokens,o=i.state;if(s.length&&s[s.length-1].type=="comment")return r;if(e=="start"||e=="no_regex"){var u=t.match(/^.*(?:\bcase\b.*:|[\{\(\[])\s*$/);u&&(r+=n)}else if(e=="doc-start"){if(o=="start"||o=="no_regex")return"";var u=t.match(/^\s*(\/?)\*/);u&&(u[1]&&(r+=" "),r+="* ")}return r},this.checkOutdent=function(e,t,n){return this.$outdent.checkOutdent(t,n)},this.autoOutdent=function(e,t,n){this.$outdent.autoOutdent(t,n)},this.createWorker=function(e){var t=new u(["ace"],"ace/mode/javascript_worker","JavaScriptWorker");return t.attachToDocument(e.getDocument()),t.on("annotate",function(t){e.setAnnotations(t.data)}),t.on("terminate",function(){e.clearAnnotations()}),t},this.$id="ace/mode/javascript",this.snippetFileId="ace/snippets/javascript"}.call(l.prototype),t.Mode=l}); (function() { ace.require(["ace/mode/javascript"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; } }); })();
0
repos/LoLa/website
repos/LoLa/website/libs/xterm.js
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var i in r)("object"==typeof exports?exports:e)[i]=r[i]}}(window,(function(){return function(e){var t={};function r(i){if(t[i])return t[i].exports;var n=t[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(i,n,function(t){return e[t]}.bind(null,n));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=32)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){this._listeners=[],this._disposed=!1}return Object.defineProperty(e.prototype,"event",{get:function(){var e=this;return this._event||(this._event=function(t){return e._listeners.push(t),{dispose:function(){if(!e._disposed)for(var r=0;r<e._listeners.length;r++)if(e._listeners[r]===t)return void e._listeners.splice(r,1)}}}),this._event},enumerable:!0,configurable:!0}),e.prototype.fire=function(e,t){for(var r=[],i=0;i<this._listeners.length;i++)r.push(this._listeners[i]);for(i=0;i<r.length;i++)r[i].call(void 0,e,t)},e.prototype.dispose=function(){this._listeners&&(this._listeners.length=0),this._disposed=!0},e}();t.EventEmitter=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(14);t.IBufferService=i.createDecorator("BufferService"),t.ICoreMouseService=i.createDecorator("CoreMouseService"),t.ICoreService=i.createDecorator("CoreService"),t.ICharsetService=i.createDecorator("CharsetService"),t.IDirtyRowService=i.createDecorator("DirtyRowService"),t.IInstantiationService=i.createDecorator("InstantiationService"),t.ILogService=i.createDecorator("LogService"),t.IOptionsService=i.createDecorator("OptionsService"),t.IUnicodeService=i.createDecorator("UnicodeService")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){this._disposables=[],this._isDisposed=!1}return e.prototype.dispose=function(){this._isDisposed=!0,this._disposables.forEach((function(e){return e.dispose()})),this._disposables.length=0},e.prototype.register=function(e){this._disposables.push(e)},e.prototype.unregister=function(e){var t=this._disposables.indexOf(e);-1!==t&&this._disposables.splice(t,1)},e}();t.Disposable=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_COLOR=256,t.DEFAULT_ATTR=256|t.DEFAULT_COLOR<<9,t.CHAR_DATA_ATTR_INDEX=0,t.CHAR_DATA_CHAR_INDEX=1,t.CHAR_DATA_WIDTH_INDEX=2,t.CHAR_DATA_CODE_INDEX=3,t.NULL_CELL_CHAR="",t.NULL_CELL_WIDTH=1,t.NULL_CELL_CODE=0,t.WHITESPACE_CELL_CHAR=" ",t.WHITESPACE_CELL_WIDTH=1,t.WHITESPACE_CELL_CODE=32},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(14);t.ICharSizeService=i.createDecorator("CharSizeService"),t.ICoreBrowserService=i.createDecorator("CoreBrowserService"),t.IMouseService=i.createDecorator("MouseService"),t.IRenderService=i.createDecorator("RenderService"),t.ISelectionService=i.createDecorator("SelectionService"),t.ISoundService=i.createDecorator("SoundService")},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(7),s=r(3),a=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.content=0,t.fg=0,t.bg=0,t.combinedData="",t}return n(t,e),t.fromCharData=function(e){var r=new t;return r.setFromCharData(e),r},t.prototype.isCombined=function(){return 2097152&this.content},t.prototype.getWidth=function(){return this.content>>22},t.prototype.getChars=function(){return 2097152&this.content?this.combinedData:2097151&this.content?o.stringFromCodePoint(2097151&this.content):""},t.prototype.getCode=function(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content},t.prototype.setFromCharData=function(e){this.fg=e[s.CHAR_DATA_ATTR_INDEX],this.bg=0;var t=!1;if(e[s.CHAR_DATA_CHAR_INDEX].length>2)t=!0;else if(2===e[s.CHAR_DATA_CHAR_INDEX].length){var r=e[s.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=r&&r<=56319){var i=e[s.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=i&&i<=57343?this.content=1024*(r-55296)+i-56320+65536|e[s.CHAR_DATA_WIDTH_INDEX]<<22:t=!0}else t=!0}else this.content=e[s.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|e[s.CHAR_DATA_WIDTH_INDEX]<<22;t&&(this.combinedData=e[s.CHAR_DATA_CHAR_INDEX],this.content=2097152|e[s.CHAR_DATA_WIDTH_INDEX]<<22)},t.prototype.getAsCharData=function(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]},t}(r(6).AttributeData);t.CellData=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){this.fg=0,this.bg=0}return e.toColorRGB=function(e){return[e>>>16&255,e>>>8&255,255&e]},e.fromColorRGB=function(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]},e.prototype.clone=function(){var t=new e;return t.fg=this.fg,t.bg=this.bg,t},e.prototype.isInverse=function(){return 67108864&this.fg},e.prototype.isBold=function(){return 134217728&this.fg},e.prototype.isUnderline=function(){return 268435456&this.fg},e.prototype.isBlink=function(){return 536870912&this.fg},e.prototype.isInvisible=function(){return 1073741824&this.fg},e.prototype.isItalic=function(){return 67108864&this.bg},e.prototype.isDim=function(){return 134217728&this.bg},e.prototype.getFgColorMode=function(){return 50331648&this.fg},e.prototype.getBgColorMode=function(){return 50331648&this.bg},e.prototype.isFgRGB=function(){return 50331648==(50331648&this.fg)},e.prototype.isBgRGB=function(){return 50331648==(50331648&this.bg)},e.prototype.isFgPalette=function(){return 16777216==(50331648&this.fg)||33554432==(50331648&this.fg)},e.prototype.isBgPalette=function(){return 16777216==(50331648&this.bg)||33554432==(50331648&this.bg)},e.prototype.isFgDefault=function(){return 0==(50331648&this.fg)},e.prototype.isBgDefault=function(){return 0==(50331648&this.bg)},e.prototype.isAttributeDefault=function(){return 0===this.fg&&0===this.bg},e.prototype.getFgColor=function(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}},e.prototype.getBgColor=function(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}},e}();t.AttributeData=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stringFromCodePoint=function(e){return e>65535?(e-=65536,String.fromCharCode(55296+(e>>10))+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)},t.utf32ToString=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=e.length);for(var i="",n=t;n<r;++n){var o=e[n];o>65535?(o-=65536,i+=String.fromCharCode(55296+(o>>10))+String.fromCharCode(o%1024+56320)):i+=String.fromCharCode(o)}return i};var i=function(){function e(){this._interim=0}return e.prototype.clear=function(){this._interim=0},e.prototype.decode=function(e,t){var r=e.length;if(!r)return 0;var i=0,n=0;this._interim&&(56320<=(a=e.charCodeAt(n++))&&a<=57343?t[i++]=1024*(this._interim-55296)+a-56320+65536:(t[i++]=this._interim,t[i++]=a),this._interim=0);for(var o=n;o<r;++o){var s=e.charCodeAt(o);if(55296<=s&&s<=56319){if(++o>=r)return this._interim=s,i;var a;56320<=(a=e.charCodeAt(o))&&a<=57343?t[i++]=1024*(s-55296)+a-56320+65536:(t[i++]=s,t[i++]=a)}else t[i++]=s}return i},e}();t.StringToUtf32=i;var n=function(){function e(){this.interim=new Uint8Array(3)}return e.prototype.clear=function(){this.interim.fill(0)},e.prototype.decode=function(e,t){var r=e.length;if(!r)return 0;var i,n,o,s,a=0,c=0,l=0;if(this.interim[0]){var h=!1,u=this.interim[0];u&=192==(224&u)?31:224==(240&u)?15:7;for(var f=0,_=void 0;(_=63&this.interim[++f])&&f<4;)u<<=6,u|=_;for(var d=192==(224&this.interim[0])?2:224==(240&this.interim[0])?3:4,p=d-f;l<p;){if(l>=r)return 0;if(128!=(192&(_=e[l++]))){l--,h=!0;break}this.interim[f++]=_,u<<=6,u|=63&_}h||(2===d?u<128?l--:t[a++]=u:3===d?u<2048||u>=55296&&u<=57343||(t[a++]=u):u<65536||u>1114111||(t[a++]=u)),this.interim.fill(0)}for(var v=r-4,g=l;g<r;){for(;!(!(g<v)||128&(i=e[g])||128&(n=e[g+1])||128&(o=e[g+2])||128&(s=e[g+3]));)t[a++]=i,t[a++]=n,t[a++]=o,t[a++]=s,g+=4;if((i=e[g++])<128)t[a++]=i;else if(192==(224&i)){if(g>=r)return this.interim[0]=i,a;if(128!=(192&(n=e[g++]))){g--;continue}if((c=(31&i)<<6|63&n)<128){g--;continue}t[a++]=c}else if(224==(240&i)){if(g>=r)return this.interim[0]=i,a;if(128!=(192&(n=e[g++]))){g--;continue}if(g>=r)return this.interim[0]=i,this.interim[1]=n,a;if(128!=(192&(o=e[g++]))){g--;continue}if((c=(15&i)<<12|(63&n)<<6|63&o)<2048||c>=55296&&c<=57343)continue;t[a++]=c}else if(240==(248&i)){if(g>=r)return this.interim[0]=i,a;if(128!=(192&(n=e[g++]))){g--;continue}if(g>=r)return this.interim[0]=i,this.interim[1]=n,a;if(128!=(192&(o=e[g++]))){g--;continue}if(g>=r)return this.interim[0]=i,this.interim[1]=n,this.interim[2]=o,a;if(128!=(192&(s=e[g++]))){g--;continue}if((c=(7&i)<<18|(63&n)<<12|(63&o)<<6|63&s)<65536||c>1114111)continue;t[a++]=c}}return a},e}();t.Utf8ToUtf32=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addDisposableDomListener=function(e,t,r,i){e.addEventListener(t,r,i);var n=!1;return{dispose:function(){n||(n=!0,e.removeEventListener(t,r,i))}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.INVERTED_DEFAULT_COLOR=257,t.DIM_OPACITY=.5,t.CHAR_ATLAS_CELL_SPACING=1},function(e,t,r){"use strict";var i,n,o,s;function a(e){var t=e.toString(16);return t.length<2?"0"+t:t}function c(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.toCss=function(e,t,r,i){return void 0!==i?"#"+a(e)+a(t)+a(r)+a(i):"#"+a(e)+a(t)+a(r)},e.toRgba=function(e,t,r,i){return void 0===i&&(i=255),(e<<24|t<<16|r<<8|i)>>>0}}(i=t.channels||(t.channels={})),(n=t.color||(t.color={})).blend=function(e,t){var r=(255&t.rgba)/255;if(1===r)return{css:t.css,rgba:t.rgba};var n=t.rgba>>24&255,o=t.rgba>>16&255,s=t.rgba>>8&255,a=e.rgba>>24&255,c=e.rgba>>16&255,l=e.rgba>>8&255,h=a+Math.round((n-a)*r),u=c+Math.round((o-c)*r),f=l+Math.round((s-l)*r);return{css:i.toCss(h,u,f),rgba:i.toRgba(h,u,f)}},n.ensureContrastRatio=function(e,t,r){var i=s.ensureContrastRatio(e.rgba,t.rgba,r);if(i)return s.toColor(i>>24&255,i>>16&255,i>>8&255)},n.opaque=function(e){var t=(255|e.rgba)>>>0,r=s.toChannels(t),n=r[0],o=r[1],a=r[2];return{css:i.toCss(n,o,a),rgba:t}},(t.css||(t.css={})).toColor=function(e){return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0}},function(e){function t(e,t,r){var i=e/255,n=t/255,o=r/255;return.2126*(i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4))+.7152*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))+.0722*(o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4))}e.relativeLuminance=function(e){return t(e>>16&255,e>>8&255,255&e)},e.relativeLuminance2=t}(o=t.rgb||(t.rgb={})),function(e){function t(e,t,r){for(var i=e>>24&255,n=e>>16&255,s=e>>8&255,a=t>>24&255,l=t>>16&255,h=t>>8&255,u=c(o.relativeLuminance2(a,h,l),o.relativeLuminance2(i,n,s));u<r&&(a>0||l>0||h>0);)a-=Math.max(0,Math.ceil(.1*a)),l-=Math.max(0,Math.ceil(.1*l)),h-=Math.max(0,Math.ceil(.1*h)),u=c(o.relativeLuminance2(a,h,l),o.relativeLuminance2(i,n,s));return(a<<24|l<<16|h<<8|255)>>>0}function r(e,t,r){for(var i=e>>24&255,n=e>>16&255,s=e>>8&255,a=t>>24&255,l=t>>16&255,h=t>>8&255,u=c(o.relativeLuminance2(a,h,l),o.relativeLuminance2(i,n,s));u<r&&(a<255||l<255||h<255);)a=Math.min(255,a+Math.ceil(.1*(255-a))),l=Math.min(255,l+Math.ceil(.1*(255-l))),h=Math.min(255,h+Math.ceil(.1*(255-h))),u=c(o.relativeLuminance2(a,h,l),o.relativeLuminance2(i,n,s));return(a<<24|l<<16|h<<8|255)>>>0}e.ensureContrastRatio=function(e,i,n){var s=o.relativeLuminance(e>>8),a=o.relativeLuminance(i>>8);if(c(s,a)<n)return a<s?t(e,i,n):r(e,i,n)},e.reduceLuminance=t,e.increaseLuminance=r,e.toChannels=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]},e.toColor=function(e,t,r){return{css:i.toCss(e,t,r),rgba:i.toRgba(e,t,r)}}}(s=t.rgba||(t.rgba={})),t.toPaddedHex=a,t.contrastRatio=c},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i="undefined"==typeof navigator,n=i?"node":navigator.userAgent,o=i?"node":navigator.platform;function s(e,t){return e.indexOf(t)>=0}t.isFirefox=!!~n.indexOf("Firefox"),t.isSafari=/^((?!chrome|android).)*safari/i.test(n),t.isMac=s(["Macintosh","MacIntel","MacPPC","Mac68K"],o),t.isIpad="iPad"===o,t.isIphone="iPhone"===o,t.isWindows=s(["Windows","Win16","Win32","WinCE"],o),t.isLinux=o.indexOf("Linux")>=0},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="",e.BS="\b",e.HT="\t",e.LF="\n",e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""}(t.C0||(t.C0={})),function(e){e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"}(t.C1||(t.C1={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(3),n=r(9),o=r(23),s=r(6),a=r(26),c=r(10),l=function(){function e(e,t,r,i,n,o,s,a){this._container=e,this._alpha=i,this._colors=n,this._rendererId=o,this._bufferService=s,this._optionsService=a,this._scaledCharWidth=0,this._scaledCharHeight=0,this._scaledCellWidth=0,this._scaledCellHeight=0,this._scaledCharLeft=0,this._scaledCharTop=0,this._currentGlyphIdentifier={chars:"",code:0,bg:0,fg:0,bold:!1,dim:!1,italic:!1},this._canvas=document.createElement("canvas"),this._canvas.classList.add("xterm-"+t+"-layer"),this._canvas.style.zIndex=r.toString(),this._initCanvas(),this._container.appendChild(this._canvas)}return e.prototype.dispose=function(){var e;this._container.removeChild(this._canvas),null===(e=this._charAtlas)||void 0===e||e.dispose()},e.prototype._initCanvas=function(){this._ctx=a.throwIfFalsy(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()},e.prototype.onOptionsChanged=function(){},e.prototype.onBlur=function(){},e.prototype.onFocus=function(){},e.prototype.onCursorMove=function(){},e.prototype.onGridChanged=function(e,t){},e.prototype.onSelectionChanged=function(e,t,r){void 0===r&&(r=!1)},e.prototype.setColors=function(e){this._refreshCharAtlas(e)},e.prototype._setTransparency=function(e){if(e!==this._alpha){var t=this._canvas;this._alpha=e,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,t),this._refreshCharAtlas(this._colors),this.onGridChanged(0,this._bufferService.rows-1)}},e.prototype._refreshCharAtlas=function(e){this._scaledCharWidth<=0&&this._scaledCharHeight<=0||(this._charAtlas=o.acquireCharAtlas(this._optionsService.options,this._rendererId,e,this._scaledCharWidth,this._scaledCharHeight),this._charAtlas.warmUp())},e.prototype.resize=function(e){this._scaledCellWidth=e.scaledCellWidth,this._scaledCellHeight=e.scaledCellHeight,this._scaledCharWidth=e.scaledCharWidth,this._scaledCharHeight=e.scaledCharHeight,this._scaledCharLeft=e.scaledCharLeft,this._scaledCharTop=e.scaledCharTop,this._canvas.width=e.scaledCanvasWidth,this._canvas.height=e.scaledCanvasHeight,this._canvas.style.width=e.canvasWidth+"px",this._canvas.style.height=e.canvasHeight+"px",this._alpha||this._clearAll(),this._refreshCharAtlas(this._colors)},e.prototype._fillCells=function(e,t,r,i){this._ctx.fillRect(e*this._scaledCellWidth,t*this._scaledCellHeight,r*this._scaledCellWidth,i*this._scaledCellHeight)},e.prototype._fillBottomLineAtCells=function(e,t,r){void 0===r&&(r=1),this._ctx.fillRect(e*this._scaledCellWidth,(t+1)*this._scaledCellHeight-window.devicePixelRatio-1,r*this._scaledCellWidth,window.devicePixelRatio)},e.prototype._fillLeftLineAtCell=function(e,t,r){this._ctx.fillRect(e*this._scaledCellWidth,t*this._scaledCellHeight,window.devicePixelRatio*r,this._scaledCellHeight)},e.prototype._strokeRectAtCell=function(e,t,r,i){this._ctx.lineWidth=window.devicePixelRatio,this._ctx.strokeRect(e*this._scaledCellWidth+window.devicePixelRatio/2,t*this._scaledCellHeight+window.devicePixelRatio/2,r*this._scaledCellWidth-window.devicePixelRatio,i*this._scaledCellHeight-window.devicePixelRatio)},e.prototype._clearAll=function(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))},e.prototype._clearCells=function(e,t,r,i){this._alpha?this._ctx.clearRect(e*this._scaledCellWidth,t*this._scaledCellHeight,r*this._scaledCellWidth,i*this._scaledCellHeight):(this._ctx.fillStyle=this._colors.background.css,this._ctx.fillRect(e*this._scaledCellWidth,t*this._scaledCellHeight,r*this._scaledCellWidth,i*this._scaledCellHeight))},e.prototype._fillCharTrueColor=function(e,t,r){this._ctx.font=this._getFont(!1,!1),this._ctx.textBaseline="middle",this._clipRow(r),this._ctx.fillText(e.getChars(),t*this._scaledCellWidth+this._scaledCharLeft,r*this._scaledCellHeight+this._scaledCharTop+this._scaledCharHeight/2)},e.prototype._drawChars=function(e,t,r){var o,s,a=this._getContrastColor(e);a||e.isFgRGB()||e.isBgRGB()?this._drawUncachedChars(e,t,r,a):(e.isInverse()?(o=e.isBgDefault()?n.INVERTED_DEFAULT_COLOR:e.getBgColor(),s=e.isFgDefault()?n.INVERTED_DEFAULT_COLOR:e.getFgColor()):(s=e.isBgDefault()?i.DEFAULT_COLOR:e.getBgColor(),o=e.isFgDefault()?i.DEFAULT_COLOR:e.getFgColor()),o+=this._optionsService.options.drawBoldTextInBrightColors&&e.isBold()&&o<8?8:0,this._currentGlyphIdentifier.chars=e.getChars()||i.WHITESPACE_CELL_CHAR,this._currentGlyphIdentifier.code=e.getCode()||i.WHITESPACE_CELL_CODE,this._currentGlyphIdentifier.bg=s,this._currentGlyphIdentifier.fg=o,this._currentGlyphIdentifier.bold=!!e.isBold(),this._currentGlyphIdentifier.dim=!!e.isDim(),this._currentGlyphIdentifier.italic=!!e.isItalic(),this._charAtlas&&this._charAtlas.draw(this._ctx,this._currentGlyphIdentifier,t*this._scaledCellWidth+this._scaledCharLeft,r*this._scaledCellHeight+this._scaledCharTop)||this._drawUncachedChars(e,t,r))},e.prototype._drawUncachedChars=function(e,t,r,i){if(this._ctx.save(),this._ctx.font=this._getFont(!!e.isBold(),!!e.isItalic()),this._ctx.textBaseline="middle",e.isInverse())if(i)this._ctx.fillStyle=i.css;else if(e.isBgDefault())this._ctx.fillStyle=c.color.opaque(this._colors.background).css;else if(e.isBgRGB())this._ctx.fillStyle="rgb("+s.AttributeData.toColorRGB(e.getBgColor()).join(",")+")";else{var o=e.getBgColor();this._optionsService.options.drawBoldTextInBrightColors&&e.isBold()&&o<8&&(o+=8),this._ctx.fillStyle=this._colors.ansi[o].css}else if(i)this._ctx.fillStyle=i.css;else if(e.isFgDefault())this._ctx.fillStyle=this._colors.foreground.css;else if(e.isFgRGB())this._ctx.fillStyle="rgb("+s.AttributeData.toColorRGB(e.getFgColor()).join(",")+")";else{var a=e.getFgColor();this._optionsService.options.drawBoldTextInBrightColors&&e.isBold()&&a<8&&(a+=8),this._ctx.fillStyle=this._colors.ansi[a].css}this._clipRow(r),e.isDim()&&(this._ctx.globalAlpha=n.DIM_OPACITY),this._ctx.fillText(e.getChars(),t*this._scaledCellWidth+this._scaledCharLeft,r*this._scaledCellHeight+this._scaledCharTop+this._scaledCharHeight/2),this._ctx.restore()},e.prototype._clipRow=function(e){this._ctx.beginPath(),this._ctx.rect(0,e*this._scaledCellHeight,this._bufferService.cols*this._scaledCellWidth,this._scaledCellHeight),this._ctx.clip()},e.prototype._getFont=function(e,t){return(t?"italic":"")+" "+(e?this._optionsService.options.fontWeightBold:this._optionsService.options.fontWeight)+" "+this._optionsService.options.fontSize*window.devicePixelRatio+"px "+this._optionsService.options.fontFamily},e.prototype._getContrastColor=function(e){if(1!==this._optionsService.options.minimumContrastRatio){var t=this._colors.contrastCache.getColor(e.bg,e.fg);if(void 0!==t)return t||void 0;var r=e.getFgColor(),i=e.getFgColorMode(),n=e.getBgColor(),o=e.getBgColorMode(),s=!!e.isInverse(),a=!!e.isInverse();if(s){var l=r;r=n,n=l;var h=i;i=o,o=h}var u=this._resolveBackgroundRgba(o,n,s),f=this._resolveForegroundRgba(i,r,s,a),_=c.rgba.ensureContrastRatio(u,f,this._optionsService.options.minimumContrastRatio);if(_){var d={css:c.channels.toCss(_>>24&255,_>>16&255,_>>8&255),rgba:_};return this._colors.contrastCache.setColor(e.bg,e.fg,d),d}this._colors.contrastCache.setColor(e.bg,e.fg,null)}},e.prototype._resolveBackgroundRgba=function(e,t,r){switch(e){case 16777216:case 33554432:return this._colors.ansi[t].rgba;case 50331648:return t<<8;case 0:default:return r?this._colors.foreground.rgba:this._colors.background.rgba}},e.prototype._resolveForegroundRgba=function(e,t,r,i){switch(e){case 16777216:case 33554432:return this._optionsService.options.drawBoldTextInBrightColors&&i&&t<8&&(t+=8),this._colors.ansi[t].rgba;case 50331648:return t<<8;case 0:default:return r?this._colors.background.rgba:this._colors.foreground.rgba}},e}();t.BaseRenderLayer=l},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});function i(e,t,r){t.di$target===t?t.di$dependencies.push({id:e,index:r}):(t.di$dependencies=[{id:e,index:r}],t.di$target=t)}t.serviceRegistry=new Map,t.getServiceDependencies=function(e){return e.di$dependencies||[]},t.createDecorator=function(e){if(t.serviceRegistry.has(e))return t.serviceRegistry.get(e);var r=function(e,t,n){if(3!==arguments.length)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");i(r,e,n)};return r.toString=function(){return e},t.serviceRegistry.set(e,r),r}},function(e,t,r){"use strict";function i(e,t,r,i){if(void 0===r&&(r=0),void 0===i&&(i=e.length),r>=e.length)return e;r=(e.length+r)%e.length,i=i>=e.length?e.length:(e.length+i)%e.length;for(var n=r;n<i;++n)e[n]=t;return e}Object.defineProperty(t,"__esModule",{value:!0}),t.fill=function(e,t,r,n){return e.fill?e.fill(t,r,n):i(e,t,r,n)},t.fillFallback=i,t.concat=function(e,t){var r=new e.constructor(e.length+t.length);return r.set(e),r.set(t,e.length),r}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(7),n=r(3),o=r(5),s=r(6);t.DEFAULT_ATTR_DATA=Object.freeze(new s.AttributeData);var a=function(){function e(e,t,r){void 0===r&&(r=!1),this.isWrapped=r,this._combined={},this._data=new Uint32Array(3*e);for(var i=t||o.CellData.fromCharData([0,n.NULL_CELL_CHAR,n.NULL_CELL_WIDTH,n.NULL_CELL_CODE]),s=0;s<e;++s)this.setCell(s,i);this.length=e}return e.prototype.get=function(e){var t=this._data[3*e+0],r=2097151&t;return[this._data[3*e+1],2097152&t?this._combined[e]:r?i.stringFromCodePoint(r):"",t>>22,2097152&t?this._combined[e].charCodeAt(this._combined[e].length-1):r]},e.prototype.set=function(e,t){this._data[3*e+1]=t[n.CHAR_DATA_ATTR_INDEX],t[n.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[e]=t[1],this._data[3*e+0]=2097152|e|t[n.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*e+0]=t[n.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|t[n.CHAR_DATA_WIDTH_INDEX]<<22},e.prototype.getWidth=function(e){return this._data[3*e+0]>>22},e.prototype.hasWidth=function(e){return 12582912&this._data[3*e+0]},e.prototype.getFg=function(e){return this._data[3*e+1]},e.prototype.getBg=function(e){return this._data[3*e+2]},e.prototype.hasContent=function(e){return 4194303&this._data[3*e+0]},e.prototype.getCodePoint=function(e){var t=this._data[3*e+0];return 2097152&t?this._combined[e].charCodeAt(this._combined[e].length-1):2097151&t},e.prototype.isCombined=function(e){return 2097152&this._data[3*e+0]},e.prototype.getString=function(e){var t=this._data[3*e+0];return 2097152&t?this._combined[e]:2097151&t?i.stringFromCodePoint(2097151&t):""},e.prototype.loadCell=function(e,t){var r=3*e;return t.content=this._data[r+0],t.fg=this._data[r+1],t.bg=this._data[r+2],2097152&t.content&&(t.combinedData=this._combined[e]),t},e.prototype.setCell=function(e,t){2097152&t.content&&(this._combined[e]=t.combinedData),this._data[3*e+0]=t.content,this._data[3*e+1]=t.fg,this._data[3*e+2]=t.bg},e.prototype.setCellFromCodePoint=function(e,t,r,i,n){this._data[3*e+0]=t|r<<22,this._data[3*e+1]=i,this._data[3*e+2]=n},e.prototype.addCodepointToCell=function(e,t){var r=this._data[3*e+0];2097152&r?this._combined[e]+=i.stringFromCodePoint(t):(2097151&r?(this._combined[e]=i.stringFromCodePoint(2097151&r)+i.stringFromCodePoint(t),r&=-2097152,r|=2097152):r=t|1<<22,this._data[3*e+0]=r)},e.prototype.insertCells=function(e,t,r,i){if((e%=this.length)&&2===this.getWidth(e-1)&&this.setCellFromCodePoint(e-1,0,1,(null==i?void 0:i.fg)||0,(null==i?void 0:i.bg)||0),t<this.length-e){for(var n=new o.CellData,s=this.length-e-t-1;s>=0;--s)this.setCell(e+t+s,this.loadCell(e+s,n));for(s=0;s<t;++s)this.setCell(e+s,r)}else for(s=e;s<this.length;++s)this.setCell(s,r);2===this.getWidth(this.length-1)&&this.setCellFromCodePoint(this.length-1,0,1,(null==i?void 0:i.fg)||0,(null==i?void 0:i.bg)||0)},e.prototype.deleteCells=function(e,t,r,i){if(e%=this.length,t<this.length-e){for(var n=new o.CellData,s=0;s<this.length-e-t;++s)this.setCell(e+s,this.loadCell(e+t+s,n));for(s=this.length-t;s<this.length;++s)this.setCell(s,r)}else for(s=e;s<this.length;++s)this.setCell(s,r);e&&2===this.getWidth(e-1)&&this.setCellFromCodePoint(e-1,0,1,(null==i?void 0:i.fg)||0,(null==i?void 0:i.bg)||0),0!==this.getWidth(e)||this.hasContent(e)||this.setCellFromCodePoint(e,0,1,(null==i?void 0:i.fg)||0,(null==i?void 0:i.bg)||0)},e.prototype.replaceCells=function(e,t,r,i){for(e&&2===this.getWidth(e-1)&&this.setCellFromCodePoint(e-1,0,1,(null==i?void 0:i.fg)||0,(null==i?void 0:i.bg)||0),t<this.length&&2===this.getWidth(t-1)&&this.setCellFromCodePoint(t,0,1,(null==i?void 0:i.fg)||0,(null==i?void 0:i.bg)||0);e<t&&e<this.length;)this.setCell(e++,r)},e.prototype.resize=function(e,t){if(e!==this.length){if(e>this.length){var r=new Uint32Array(3*e);this.length&&(3*e<this._data.length?r.set(this._data.subarray(0,3*e)):r.set(this._data)),this._data=r;for(var i=this.length;i<e;++i)this.setCell(i,t)}else if(e){(r=new Uint32Array(3*e)).set(this._data.subarray(0,3*e)),this._data=r;var n=Object.keys(this._combined);for(i=0;i<n.length;i++){var o=parseInt(n[i],10);o>=e&&delete this._combined[o]}}else this._data=new Uint32Array(0),this._combined={};this.length=e}},e.prototype.fill=function(e){this._combined={};for(var t=0;t<this.length;++t)this.setCell(t,e)},e.prototype.copyFrom=function(e){for(var t in this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={},e._combined)this._combined[t]=e._combined[t];this.isWrapped=e.isWrapped},e.prototype.clone=function(){var t=new e(0);for(var r in t._data=new Uint32Array(this._data),t.length=this.length,this._combined)t._combined[r]=this._combined[r];return t.isWrapped=this.isWrapped,t},e.prototype.getTrimmedLength=function(){for(var e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0])return e+(this._data[3*e+0]>>22);return 0},e.prototype.copyCellsFrom=function(e,t,r,i,n){var o=e._data;if(n)for(var s=i-1;s>=0;s--)for(var a=0;a<3;a++)this._data[3*(r+s)+a]=o[3*(t+s)+a];else for(s=0;s<i;s++)for(a=0;a<3;a++)this._data[3*(r+s)+a]=o[3*(t+s)+a];var c=Object.keys(e._combined);for(a=0;a<c.length;a++){var l=parseInt(c[a],10);l>=t&&(this._combined[l-t+r]=e._combined[l])}},e.prototype.translateToString=function(e,t,r){void 0===e&&(e=!1),void 0===t&&(t=0),void 0===r&&(r=this.length),e&&(r=Math.min(r,this.getTrimmedLength()));for(var o="";t<r;){var s=this._data[3*t+0],a=2097151&s;o+=2097152&s?this._combined[t]:a?i.stringFromCodePoint(a):n.WHITESPACE_CELL_CHAR,t+=s>>22||1}return o},e}();t.BufferLine=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.promptLabel="Terminal input",t.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CHARSETS={},t.DEFAULT_CHARSET=t.CHARSETS.B,t.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},t.CHARSETS.A={"#":"£"},t.CHARSETS.B=null,t.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},t.CHARSETS.C=t.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},t.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},t.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},t.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},t.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},t.CHARSETS.E=t.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},t.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},t.CHARSETS.H=t.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},t.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){if(void 0===e&&(e=32),void 0===t&&(t=32),this.maxLength=e,this.maxSubParamsLength=t,t>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}return e.fromArray=function(t){var r=new e;if(!t.length)return r;for(var i=t[0]instanceof Array?1:0;i<t.length;++i){var n=t[i];if(n instanceof Array)for(var o=0;o<n.length;++o)r.addSubParam(n[o]);else r.addParam(n)}return r},e.prototype.clone=function(){var t=new e(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t},e.prototype.toArray=function(){for(var e=[],t=0;t<this.length;++t){e.push(this.params[t]);var r=this._subParamsIdx[t]>>8,i=255&this._subParamsIdx[t];i-r>0&&e.push(Array.prototype.slice.call(this._subParams,r,i))}return e},e.prototype.reset=function(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1},e.prototype.addParam=function(e){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>2147483647?2147483647:e}},e.prototype.addSubParam=function(e){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>2147483647?2147483647:e,this._subParamsIdx[this.length-1]++}},e.prototype.hasSubParams=function(e){return(255&this._subParamsIdx[e])-(this._subParamsIdx[e]>>8)>0},e.prototype.getSubParams=function(e){var t=this._subParamsIdx[e]>>8,r=255&this._subParamsIdx[e];return r-t>0?this._subParams.subarray(t,r):null},e.prototype.getSubParamsAll=function(){for(var e={},t=0;t<this.length;++t){var r=this._subParamsIdx[t]>>8,i=255&this._subParamsIdx[t];i-r>0&&(e[t]=this._subParams.slice(r,i))}return e},e.prototype.addDigit=function(e){var t;if(!(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)){var r=this._digitIsSub?this._subParams:this.params,i=r[t-1];r[t-1]=~i?Math.min(10*i+e,2147483647):e}},e}();t.Params=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(21),n=r(7),o=function(){function e(){this._state=0,this._id=-1,this._handlers=Object.create(null),this._handlerFb=function(){}}return e.prototype.addHandler=function(e,t){void 0===this._handlers[e]&&(this._handlers[e]=[]);var r=this._handlers[e];return r.push(t),{dispose:function(){var e=r.indexOf(t);-1!==e&&r.splice(e,1)}}},e.prototype.setHandler=function(e,t){this._handlers[e]=[t]},e.prototype.clearHandler=function(e){this._handlers[e]&&delete this._handlers[e]},e.prototype.setHandlerFallback=function(e){this._handlerFb=e},e.prototype.dispose=function(){this._handlers=Object.create(null),this._handlerFb=function(){}},e.prototype.reset=function(){2===this._state&&this.end(!1),this._id=-1,this._state=0},e.prototype._start=function(){var e=this._handlers[this._id];if(e)for(var t=e.length-1;t>=0;t--)e[t].start();else this._handlerFb(this._id,"START")},e.prototype._put=function(e,t,r){var i=this._handlers[this._id];if(i)for(var o=i.length-1;o>=0;o--)i[o].put(e,t,r);else this._handlerFb(this._id,"PUT",n.utf32ToString(e,t,r))},e.prototype._end=function(e){var t=this._handlers[this._id];if(t){for(var r=t.length-1;r>=0&&!1===t[r].end(e);r--);for(r--;r>=0;r--)t[r].end(!1)}else this._handlerFb(this._id,"END",e)},e.prototype.start=function(){this.reset(),this._id=-1,this._state=1},e.prototype.put=function(e,t,r){if(3!==this._state){if(1===this._state)for(;t<r;){var i=e[t++];if(59===i){this._state=2,this._start();break}if(i<48||57<i)return void(this._state=3);-1===this._id&&(this._id=0),this._id=10*this._id+i-48}2===this._state&&r-t>0&&this._put(e,t,r)}},e.prototype.end=function(e){0!==this._state&&(3!==this._state&&(1===this._state&&this._start(),this._end(e)),this._id=-1,this._state=0)},e}();t.OscParser=o;var s=function(){function e(e){this._handler=e,this._data="",this._hitLimit=!1}return e.prototype.start=function(){this._data="",this._hitLimit=!1},e.prototype.put=function(e,t,r){this._hitLimit||(this._data+=n.utf32ToString(e,t,r),this._data.length>i.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))},e.prototype.end=function(e){var t;return this._hitLimit?t=!1:e&&(t=this._handler(this._data)),this._data="",this._hitLimit=!1,t},e}();t.OscHandler=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PAYLOAD_LIMIT=1e7},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(7),n=r(19),o=r(21),s=[],a=function(){function e(){this._handlers=Object.create(null),this._active=s,this._ident=0,this._handlerFb=function(){}}return e.prototype.dispose=function(){this._handlers=Object.create(null),this._handlerFb=function(){}},e.prototype.addHandler=function(e,t){void 0===this._handlers[e]&&(this._handlers[e]=[]);var r=this._handlers[e];return r.push(t),{dispose:function(){var e=r.indexOf(t);-1!==e&&r.splice(e,1)}}},e.prototype.setHandler=function(e,t){this._handlers[e]=[t]},e.prototype.clearHandler=function(e){this._handlers[e]&&delete this._handlers[e]},e.prototype.setHandlerFallback=function(e){this._handlerFb=e},e.prototype.reset=function(){this._active.length&&this.unhook(!1),this._active=s,this._ident=0},e.prototype.hook=function(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||s,this._active.length)for(var r=this._active.length-1;r>=0;r--)this._active[r].hook(t);else this._handlerFb(this._ident,"HOOK",t)},e.prototype.put=function(e,t,r){if(this._active.length)for(var n=this._active.length-1;n>=0;n--)this._active[n].put(e,t,r);else this._handlerFb(this._ident,"PUT",i.utf32ToString(e,t,r))},e.prototype.unhook=function(e){if(this._active.length){for(var t=this._active.length-1;t>=0&&!1===this._active[t].unhook(e);t--);for(t--;t>=0;t--)this._active[t].unhook(!1)}else this._handlerFb(this._ident,"UNHOOK",e);this._active=s,this._ident=0},e}();t.DcsParser=a;var c=function(){function e(e){this._handler=e,this._data="",this._hitLimit=!1}return e.prototype.hook=function(e){this._params=e.clone(),this._data="",this._hitLimit=!1},e.prototype.put=function(e,t,r){this._hitLimit||(this._data+=i.utf32ToString(e,t,r),this._data.length>o.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))},e.prototype.unhook=function(e){var t;return this._hitLimit?t=!1:e&&(t=this._handler(this._data,this._params?this._params:new n.Params)),this._params=void 0,this._data="",this._hitLimit=!1,t},e}();t.DcsHandler=c},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(24),n=r(42),o=[];t.acquireCharAtlas=function(e,t,r,s,a){for(var c=i.generateConfig(s,a,e,r),l=0;l<o.length;l++){var h=(u=o[l]).ownedBy.indexOf(t);if(h>=0){if(i.configEquals(u.config,c))return u.atlas;1===u.ownedBy.length?(u.atlas.dispose(),o.splice(l,1)):u.ownedBy.splice(h,1);break}}for(l=0;l<o.length;l++){var u=o[l];if(i.configEquals(u.config,c))return u.ownedBy.push(t),u.atlas}var f={atlas:new n.DynamicCharAtlas(document,c),config:c,ownedBy:[t]};return o.push(f),f.atlas},t.removeTerminalFromCache=function(e){for(var t=0;t<o.length;t++){var r=o[t].ownedBy.indexOf(e);if(-1!==r){1===o[t].ownedBy.length?(o[t].atlas.dispose(),o.splice(t,1)):o[t].ownedBy.splice(r,1);break}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(3);t.generateConfig=function(e,t,r,i){var n={foreground:i.foreground,background:i.background,cursor:void 0,cursorAccent:void 0,selection:void 0,ansi:i.ansi.slice(0,16)};return{devicePixelRatio:window.devicePixelRatio,scaledCharWidth:e,scaledCharHeight:t,fontFamily:r.fontFamily,fontSize:r.fontSize,fontWeight:r.fontWeight,fontWeightBold:r.fontWeightBold,allowTransparency:r.allowTransparency,colors:n}},t.configEquals=function(e,t){for(var r=0;r<e.colors.ansi.length;r++)if(e.colors.ansi[r].rgba!==t.colors.ansi[r].rgba)return!1;return e.devicePixelRatio===t.devicePixelRatio&&e.fontFamily===t.fontFamily&&e.fontSize===t.fontSize&&e.fontWeight===t.fontWeight&&e.fontWeightBold===t.fontWeightBold&&e.allowTransparency===t.allowTransparency&&e.scaledCharWidth===t.scaledCharWidth&&e.scaledCharHeight===t.scaledCharHeight&&e.colors.foreground===t.colors.foreground&&e.colors.background===t.colors.background},t.is256Color=function(e){return e<i.DEFAULT_COLOR}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(10),n=r(44),o=i.css.toColor("#ffffff"),s=i.css.toColor("#000000"),a=i.css.toColor("#ffffff"),c=i.css.toColor("#000000"),l={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};t.DEFAULT_ANSI_COLORS=function(){for(var e=[i.css.toColor("#2e3436"),i.css.toColor("#cc0000"),i.css.toColor("#4e9a06"),i.css.toColor("#c4a000"),i.css.toColor("#3465a4"),i.css.toColor("#75507b"),i.css.toColor("#06989a"),i.css.toColor("#d3d7cf"),i.css.toColor("#555753"),i.css.toColor("#ef2929"),i.css.toColor("#8ae234"),i.css.toColor("#fce94f"),i.css.toColor("#729fcf"),i.css.toColor("#ad7fa8"),i.css.toColor("#34e2e2"),i.css.toColor("#eeeeec")],t=[0,95,135,175,215,255],r=0;r<216;r++){var n=t[r/36%6|0],o=t[r/6%6|0],s=t[r%6];e.push({css:i.channels.toCss(n,o,s),rgba:i.channels.toRgba(n,o,s)})}for(r=0;r<24;r++){var a=8+10*r;e.push({css:i.channels.toCss(a,a,a),rgba:i.channels.toRgba(a,a,a)})}return e}();var h=function(){function e(e,r){this.allowTransparency=r;var h=e.createElement("canvas");h.width=1,h.height=1;var u=h.getContext("2d");if(!u)throw new Error("Could not get rendering context");this._ctx=u,this._ctx.globalCompositeOperation="copy",this._litmusColor=this._ctx.createLinearGradient(0,0,1,1),this._contrastCache=new n.ColorContrastCache,this.colors={foreground:o,background:s,cursor:a,cursorAccent:c,selection:l,selectionOpaque:i.color.blend(s,l),ansi:t.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache}}return e.prototype.onOptionsChange=function(e){"minimumContrastRatio"===e&&this._contrastCache.clear()},e.prototype.setTheme=function(e){void 0===e&&(e={}),this.colors.foreground=this._parseColor(e.foreground,o),this.colors.background=this._parseColor(e.background,s),this.colors.cursor=this._parseColor(e.cursor,a,!0),this.colors.cursorAccent=this._parseColor(e.cursorAccent,c,!0),this.colors.selection=this._parseColor(e.selection,l,!0),this.colors.selectionOpaque=i.color.blend(this.colors.background,this.colors.selection),this.colors.ansi[0]=this._parseColor(e.black,t.DEFAULT_ANSI_COLORS[0]),this.colors.ansi[1]=this._parseColor(e.red,t.DEFAULT_ANSI_COLORS[1]),this.colors.ansi[2]=this._parseColor(e.green,t.DEFAULT_ANSI_COLORS[2]),this.colors.ansi[3]=this._parseColor(e.yellow,t.DEFAULT_ANSI_COLORS[3]),this.colors.ansi[4]=this._parseColor(e.blue,t.DEFAULT_ANSI_COLORS[4]),this.colors.ansi[5]=this._parseColor(e.magenta,t.DEFAULT_ANSI_COLORS[5]),this.colors.ansi[6]=this._parseColor(e.cyan,t.DEFAULT_ANSI_COLORS[6]),this.colors.ansi[7]=this._parseColor(e.white,t.DEFAULT_ANSI_COLORS[7]),this.colors.ansi[8]=this._parseColor(e.brightBlack,t.DEFAULT_ANSI_COLORS[8]),this.colors.ansi[9]=this._parseColor(e.brightRed,t.DEFAULT_ANSI_COLORS[9]),this.colors.ansi[10]=this._parseColor(e.brightGreen,t.DEFAULT_ANSI_COLORS[10]),this.colors.ansi[11]=this._parseColor(e.brightYellow,t.DEFAULT_ANSI_COLORS[11]),this.colors.ansi[12]=this._parseColor(e.brightBlue,t.DEFAULT_ANSI_COLORS[12]),this.colors.ansi[13]=this._parseColor(e.brightMagenta,t.DEFAULT_ANSI_COLORS[13]),this.colors.ansi[14]=this._parseColor(e.brightCyan,t.DEFAULT_ANSI_COLORS[14]),this.colors.ansi[15]=this._parseColor(e.brightWhite,t.DEFAULT_ANSI_COLORS[15]),this._contrastCache.clear()},e.prototype._parseColor=function(e,t,r){if(void 0===r&&(r=this.allowTransparency),void 0===e)return t;if(this._ctx.fillStyle=this._litmusColor,this._ctx.fillStyle=e,"string"!=typeof this._ctx.fillStyle)return console.warn("Color: "+e+" is invalid using fallback "+t.css),t;this._ctx.fillRect(0,0,1,1);var n=this._ctx.getImageData(0,0,1,1).data;if(255!==n[3]){if(!r)return console.warn("Color: "+e+" is using transparency, but allowTransparency is false. Using fallback "+t.css+"."),t;var o=this._ctx.fillStyle.substring(5,this._ctx.fillStyle.length-1).split(",").map((function(e){return Number(e)})),s=o[0],a=o[1],c=o[2],l=o[3],h=Math.round(255*l);return{rgba:i.channels.toRgba(s,a,c,h),css:e}}return{css:this._ctx.fillStyle,rgba:i.channels.toRgba(n[0],n[1],n[2],n[3])}},e}();t.ColorManager=h},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.throwIfFalsy=function(e){if(!e)throw new Error("value must not be falsy");return e}},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(6),s=r(3),a=r(5),c=function(e){function t(t,r,i){var n=e.call(this)||this;return n.content=0,n.combinedData="",n.fg=t.fg,n.bg=t.bg,n.combinedData=r,n._width=i,n}return n(t,e),t.prototype.isCombined=function(){return 2097152},t.prototype.getWidth=function(){return this._width},t.prototype.getChars=function(){return this.combinedData},t.prototype.getCode=function(){return 2097151},t.prototype.setFromCharData=function(e){throw new Error("not implemented")},t.prototype.getAsCharData=function(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]},t}(o.AttributeData);t.JoinedCellData=c;var l=function(){function e(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new a.CellData}return e.prototype.registerCharacterJoiner=function(e){var t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id},e.prototype.deregisterCharacterJoiner=function(e){for(var t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1},e.prototype.getJoinedCharacters=function(e){if(0===this._characterJoiners.length)return[];var t=this._bufferService.buffer.lines.get(e);if(!t||0===t.length)return[];for(var r=[],i=t.translateToString(!0),n=0,o=0,a=0,c=t.getFg(0),l=t.getBg(0),h=0;h<t.getTrimmedLength();h++)if(t.loadCell(h,this._workCell),0!==this._workCell.getWidth()){if(this._workCell.fg!==c||this._workCell.bg!==l){if(h-n>1)for(var u=this._getJoinedRanges(i,a,o,t,n),f=0;f<u.length;f++)r.push(u[f]);n=h,a=o,c=this._workCell.fg,l=this._workCell.bg}o+=this._workCell.getChars().length||s.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-n>1)for(u=this._getJoinedRanges(i,a,o,t,n),f=0;f<u.length;f++)r.push(u[f]);return r},e.prototype._getJoinedRanges=function(t,r,i,n,o){for(var s=t.substring(r,i),a=this._characterJoiners[0].handler(s),c=1;c<this._characterJoiners.length;c++)for(var l=this._characterJoiners[c].handler(s),h=0;h<l.length;h++)e._mergeRanges(a,l[h]);return this._stringRangesToCellRanges(a,n,o),a},e.prototype._stringRangesToCellRanges=function(e,t,r){var i=0,n=!1,o=0,a=e[i];if(a){for(var c=r;c<this._bufferService.cols;c++){var l=t.getWidth(c),h=t.getString(c).length||s.WHITESPACE_CELL_CHAR.length;if(0!==l){if(!n&&a[0]<=o&&(a[0]=c,n=!0),a[1]<=o){if(a[1]=c,!(a=e[++i]))break;a[0]<=o?(a[0]=c,n=!0):n=!1}o+=h}}a&&(a[1]=this._bufferService.cols)}},e._mergeRanges=function(e,t){for(var r=!1,i=0;i<e.length;i++){var n=e[i];if(r){if(t[1]<=n[0])return e[i-1][1]=t[1],e;if(t[1]<=n[1])return e[i-1][1]=Math.max(t[1],n[1]),e.splice(i,1),e;e.splice(i,1),i--}else{if(t[1]<=n[0])return e.splice(i,0,t),e;if(t[1]<=n[1])return n[0]=Math.min(t[0],n[0]),e;t[0]<n[1]&&(n[0]=Math.min(t[0],n[0]),r=!0)}}return r?e[e.length-1][1]=t[1]:e.push(t),e},e}();t.CharacterJoinerRegistry=l},function(e,t,r){"use strict";function i(e,t){var r=t.getBoundingClientRect();return[e.clientX-r.left,e.clientY-r.top]}Object.defineProperty(t,"__esModule",{value:!0}),t.getCoordsRelativeToElement=i,t.getCoords=function(e,t,r,n,o,s,a,c){if(o){var l=i(e,t);if(l)return l[0]=Math.ceil((l[0]+(c?s/2:0))/s),l[1]=Math.ceil(l[1]/a),l[0]=Math.min(Math.max(l[0],1),r+(c?1:0)),l[1]=Math.min(Math.max(l[1],1),n),l}},t.getRawByteCoords=function(e){if(e)return{x:e[0]+32,y:e[1]+32}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){this._renderCallback=e}return e.prototype.dispose=function(){this._animationFrame&&(window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)},e.prototype.refresh=function(e,t,r){var i=this;this._rowCount=r,e=void 0!==e?e:0,t=void 0!==t?t:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,t):t,this._animationFrame||(this._animationFrame=window.requestAnimationFrame((function(){return i._innerRefresh()})))},e.prototype._innerRefresh=function(){void 0!==this._rowStart&&void 0!==this._rowEnd&&void 0!==this._rowCount&&(this._rowStart=Math.max(this._rowStart,0),this._rowEnd=Math.min(this._rowEnd,this._rowCount-1),this._renderCallback(this._rowStart,this._rowEnd),this._rowStart=void 0,this._rowEnd=void 0,this._animationFrame=void 0)},e}();t.RenderDebouncer=i},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._currentDevicePixelRatio=window.devicePixelRatio,t}return n(t,e),t.prototype.setListener=function(e){var t=this;this._listener&&this.clearListener(),this._listener=e,this._outerListener=function(){t._listener&&(t._listener(window.devicePixelRatio,t._currentDevicePixelRatio),t._updateDpr())},this._updateDpr()},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.clearListener()},t.prototype._updateDpr=function(){this._resolutionMediaMatchList&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._currentDevicePixelRatio=window.devicePixelRatio,this._resolutionMediaMatchList=window.matchMedia("screen and (resolution: "+window.devicePixelRatio+"dppx)"),this._resolutionMediaMatchList.addListener(this._outerListener))},t.prototype.clearListener=function(){this._resolutionMediaMatchList&&this._listener&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._listener=void 0,this._outerListener=void 0)},t}(r(2).Disposable);t.ScreenDprMonitor=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clone=function e(t,r){if(void 0===r&&(r=5),"object"!=typeof t)return t;var i=Array.isArray(t)?[]:{};for(var n in t)i[n]=r<=1?t[n]:t[n]?e(t[n],r-1):t[n];return i}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(5),n=r(33),o=r(17),s=r(0),a=r(81),c=function(){function e(e){this._core=new n.Terminal(e),this._addonManager=new a.AddonManager}return Object.defineProperty(e.prototype,"onCursorMove",{get:function(){return this._core.onCursorMove},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onLineFeed",{get:function(){return this._core.onLineFeed},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onSelectionChange",{get:function(){return this._core.onSelectionChange},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onData",{get:function(){return this._core.onData},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onBinary",{get:function(){return this._core.onBinary},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onTitleChange",{get:function(){return this._core.onTitleChange},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onScroll",{get:function(){return this._core.onScroll},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onKey",{get:function(){return this._core.onKey},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onRender",{get:function(){return this._core.onRender},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onResize",{get:function(){return this._core.onResize},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"element",{get:function(){return this._core.element},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parser",{get:function(){return this._parser||(this._parser=new f(this._core)),this._parser},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"unicode",{get:function(){return new _(this._core)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"textarea",{get:function(){return this._core.textarea},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rows",{get:function(){return this._core.rows},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cols",{get:function(){return this._core.cols},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buffer",{get:function(){return new h(this._core.buffers)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"markers",{get:function(){return this._core.markers},enumerable:!0,configurable:!0}),e.prototype.blur=function(){this._core.blur()},e.prototype.focus=function(){this._core.focus()},e.prototype.resize=function(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)},e.prototype.open=function(e){this._core.open(e)},e.prototype.attachCustomKeyEventHandler=function(e){this._core.attachCustomKeyEventHandler(e)},e.prototype.registerLinkMatcher=function(e,t,r){return this._core.registerLinkMatcher(e,t,r)},e.prototype.deregisterLinkMatcher=function(e){this._core.deregisterLinkMatcher(e)},e.prototype.registerLinkProvider=function(e){return this._core.registerLinkProvider(e)},e.prototype.registerCharacterJoiner=function(e){return this._core.registerCharacterJoiner(e)},e.prototype.deregisterCharacterJoiner=function(e){this._core.deregisterCharacterJoiner(e)},e.prototype.registerMarker=function(e){return this._verifyIntegers(e),this._core.addMarker(e)},e.prototype.addMarker=function(e){return this.registerMarker(e)},e.prototype.hasSelection=function(){return this._core.hasSelection()},e.prototype.select=function(e,t,r){this._verifyIntegers(e,t,r),this._core.select(e,t,r)},e.prototype.getSelection=function(){return this._core.getSelection()},e.prototype.getSelectionPosition=function(){return this._core.getSelectionPosition()},e.prototype.clearSelection=function(){this._core.clearSelection()},e.prototype.selectAll=function(){this._core.selectAll()},e.prototype.selectLines=function(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)},e.prototype.dispose=function(){this._addonManager.dispose(),this._core.dispose()},e.prototype.scrollLines=function(e){this._verifyIntegers(e),this._core.scrollLines(e)},e.prototype.scrollPages=function(e){this._verifyIntegers(e),this._core.scrollPages(e)},e.prototype.scrollToTop=function(){this._core.scrollToTop()},e.prototype.scrollToBottom=function(){this._core.scrollToBottom()},e.prototype.scrollToLine=function(e){this._verifyIntegers(e),this._core.scrollToLine(e)},e.prototype.clear=function(){this._core.clear()},e.prototype.write=function(e,t){this._core.write(e,t)},e.prototype.writeUtf8=function(e,t){this._core.write(e,t)},e.prototype.writeln=function(e,t){this._core.write(e),this._core.write("\r\n",t)},e.prototype.paste=function(e){this._core.paste(e)},e.prototype.getOption=function(e){return this._core.optionsService.getOption(e)},e.prototype.setOption=function(e,t){this._core.optionsService.setOption(e,t)},e.prototype.refresh=function(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)},e.prototype.reset=function(){this._core.reset()},e.prototype.loadAddon=function(e){return this._addonManager.loadAddon(this,e)},Object.defineProperty(e,"strings",{get:function(){return o},enumerable:!0,configurable:!0}),e.prototype._verifyIntegers=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];e.forEach((function(e){if(e===1/0||isNaN(e)||e%1!=0)throw new Error("This API only accepts integers")}))},e}();t.Terminal=c;var l=function(){function e(e,t){this._buffer=e,this.type=t}return e.prototype.init=function(e){return this._buffer=e,this},Object.defineProperty(e.prototype,"cursorY",{get:function(){return this._buffer.y},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cursorX",{get:function(){return this._buffer.x},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewportY",{get:function(){return this._buffer.ydisp},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"baseY",{get:function(){return this._buffer.ybase},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._buffer.lines.length},enumerable:!0,configurable:!0}),e.prototype.getLine=function(e){var t=this._buffer.lines.get(e);if(t)return new u(t)},e.prototype.getNullCell=function(){return new i.CellData},e}(),h=function(){function e(e){var t=this;this._buffers=e,this._onBufferChange=new s.EventEmitter,this._normal=new l(this._buffers.normal,"normal"),this._alternate=new l(this._buffers.alt,"alternate"),this._buffers.onBufferActivate((function(){return t._onBufferChange.fire(t.active)}))}return Object.defineProperty(e.prototype,"onBufferChange",{get:function(){return this._onBufferChange.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"active",{get:function(){if(this._buffers.active===this._buffers.normal)return this.normal;if(this._buffers.active===this._buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"normal",{get:function(){return this._normal.init(this._buffers.normal)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alternate",{get:function(){return this._alternate.init(this._buffers.alt)},enumerable:!0,configurable:!0}),e}(),u=function(){function e(e){this._line=e}return Object.defineProperty(e.prototype,"isWrapped",{get:function(){return this._line.isWrapped},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._line.length},enumerable:!0,configurable:!0}),e.prototype.getCell=function(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new i.CellData)},e.prototype.translateToString=function(e,t,r){return this._line.translateToString(e,t,r)},e}(),f=function(){function e(e){this._core=e}return e.prototype.registerCsiHandler=function(e,t){return this._core.addCsiHandler(e,(function(e){return t(e.toArray())}))},e.prototype.addCsiHandler=function(e,t){return this.registerCsiHandler(e,t)},e.prototype.registerDcsHandler=function(e,t){return this._core.addDcsHandler(e,(function(e,r){return t(e,r.toArray())}))},e.prototype.addDcsHandler=function(e,t){return this.registerDcsHandler(e,t)},e.prototype.registerEscHandler=function(e,t){return this._core.addEscHandler(e,t)},e.prototype.addEscHandler=function(e,t){return this.registerEscHandler(e,t)},e.prototype.registerOscHandler=function(e,t){return this._core.addOscHandler(e,t)},e.prototype.addOscHandler=function(e,t){return this.registerOscHandler(e,t)},e}(),_=function(){function e(e){this._core=e}return e.prototype.register=function(e){this._core.unicodeService.register(e)},Object.defineProperty(e.prototype,"versions",{get:function(){return this._core.unicodeService.versions},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"activeVersion",{get:function(){return this._core.unicodeService.activeVersion},set:function(e){this._core.unicodeService.activeVersion=e},enumerable:!0,configurable:!0}),e}()},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(34),s=r(35),a=r(36),c=r(12),l=r(37),h=r(39),u=r(49),f=r(50),_=r(11),d=r(8),p=r(17),v=r(53),g=r(54),y=r(55),b=r(56),m=r(58),S=r(0),C=r(16),w=r(59),E=r(25),L=r(60),A=r(1),k=r(61),R=r(4),x=r(62),D=r(63),T=r(2),M=r(69),O=r(70),P=r(71),H=r(72),I=r(73),B=r(74),F=r(75),j=r(76),W=r(77),q=r(78),U=r(80),N="undefined"!=typeof window?window.document:null,z=function(e){function t(t){void 0===t&&(t={});var r=e.call(this)||this;return r.browser=_,r.mouseEvents=0,r._keyDownHandled=!1,r._blankLine=null,r._onCursorMove=new S.EventEmitter,r._onData=new S.EventEmitter,r._onBinary=new S.EventEmitter,r._onKey=new S.EventEmitter,r._onLineFeed=new S.EventEmitter,r._onRender=new S.EventEmitter,r._onResize=new S.EventEmitter,r._onScroll=new S.EventEmitter,r._onSelectionChange=new S.EventEmitter,r._onTitleChange=new S.EventEmitter,r._onFocus=new S.EventEmitter,r._onBlur=new S.EventEmitter,r.onA11yCharEmitter=new S.EventEmitter,r.onA11yTabEmitter=new S.EventEmitter,r._instantiationService=new I.InstantiationService,r.optionsService=new k.OptionsService(t),r._instantiationService.setService(A.IOptionsService,r.optionsService),r._bufferService=r._instantiationService.createInstance(D.BufferService),r._instantiationService.setService(A.IBufferService,r._bufferService),r._logService=r._instantiationService.createInstance(P.LogService),r._instantiationService.setService(A.ILogService,r._logService),r._coreService=r._instantiationService.createInstance(O.CoreService,(function(){return r.scrollToBottom()})),r._instantiationService.setService(A.ICoreService,r._coreService),r._coreService.onData((function(e){return r._onData.fire(e)})),r._coreService.onBinary((function(e){return r._onBinary.fire(e)})),r._coreMouseService=r._instantiationService.createInstance(B.CoreMouseService),r._instantiationService.setService(A.ICoreMouseService,r._coreMouseService),r._dirtyRowService=r._instantiationService.createInstance(H.DirtyRowService),r._instantiationService.setService(A.IDirtyRowService,r._dirtyRowService),r.unicodeService=r._instantiationService.createInstance(q.UnicodeService),r._instantiationService.setService(A.IUnicodeService,r.unicodeService),r._charsetService=r._instantiationService.createInstance(U.CharsetService),r._instantiationService.setService(A.ICharsetService,r._charsetService),r._setupOptionsListeners(),r._setup(),r._writeBuffer=new F.WriteBuffer((function(e){return r._inputHandler.parse(e)})),r}return n(t,e),Object.defineProperty(t.prototype,"options",{get:function(){return this.optionsService.options},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cols",{get:function(){return this._bufferService.cols},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rows",{get:function(){return this._bufferService.rows},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onCursorMove",{get:function(){return this._onCursorMove.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onData",{get:function(){return this._onData.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBinary",{get:function(){return this._onBinary.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onKey",{get:function(){return this._onKey.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onLineFeed",{get:function(){return this._onLineFeed.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onRender",{get:function(){return this._onRender.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onResize",{get:function(){return this._onResize.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onScroll",{get:function(){return this._onScroll.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onSelectionChange",{get:function(){return this._onSelectionChange.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onTitleChange",{get:function(){return this._onTitleChange.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onFocus",{get:function(){return this._onFocus.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBlur",{get:function(){return this._onBlur.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onA11yChar",{get:function(){return this.onA11yCharEmitter.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onA11yTab",{get:function(){return this.onA11yTabEmitter.event},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){var t,r,i,n;this._isDisposed||(e.prototype.dispose.call(this),null===(t=this._windowsMode)||void 0===t||t.dispose(),this._windowsMode=void 0,null===(r=this._renderService)||void 0===r||r.dispose(),this._customKeyEventHandler=null,this.write=function(){},null===(n=null===(i=this.element)||void 0===i?void 0:i.parentNode)||void 0===n||n.removeChild(this.element))},t.prototype._setup=function(){var e=this;this._customKeyEventHandler=null,this.insertMode=!1,this.bracketedPasteMode=!1,this._userScrolling=!1,this._inputHandler?this._inputHandler.reset():(this._inputHandler=new l.InputHandler(this,this._bufferService,this._charsetService,this._coreService,this._dirtyRowService,this._logService,this.optionsService,this._coreMouseService,this.unicodeService,this._instantiationService),this._inputHandler.onRequestBell((function(){return e.bell()})),this._inputHandler.onRequestRefreshRows((function(t,r){return e.refresh(t,r)})),this._inputHandler.onRequestReset((function(){return e.reset()})),this._inputHandler.onCursorMove((function(){return e._onCursorMove.fire()})),this._inputHandler.onLineFeed((function(){return e._onLineFeed.fire()})),this.register(this._inputHandler)),this.linkifier||(this.linkifier=new u.Linkifier(this._bufferService,this._logService,this.optionsService,this.unicodeService)),this.linkifier2||(this.linkifier2=new j.Linkifier2(this._bufferService)),this.options.windowsMode&&this._enableWindowsMode()},t.prototype._enableWindowsMode=function(){var e=this;if(!this._windowsMode){var t=[];t.push(this.onLineFeed(w.updateWindowsModeWrappedState.bind(null,this._bufferService))),t.push(this.addCsiHandler({final:"H"},(function(){return w.updateWindowsModeWrappedState(e._bufferService),!1}))),this._windowsMode={dispose:function(){t.forEach((function(e){return e.dispose()}))}}}},Object.defineProperty(t.prototype,"buffer",{get:function(){return this.buffers.active},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buffers",{get:function(){return this._bufferService.buffers},enumerable:!0,configurable:!0}),t.prototype.focus=function(){this.textarea&&this.textarea.focus({preventScroll:!0})},t.prototype._setupOptionsListeners=function(){var e=this;this.optionsService.onOptionChange((function(t){var r,i,n,o,s;switch(t){case"fontFamily":case"fontSize":null===(r=e._renderService)||void 0===r||r.clear(),null===(i=e._charSizeService)||void 0===i||i.measure();break;case"cursorBlink":case"cursorStyle":e.refresh(e.buffer.y,e.buffer.y);break;case"drawBoldTextInBrightColors":case"letterSpacing":case"lineHeight":case"fontWeight":case"fontWeightBold":case"minimumContrastRatio":e._renderService&&(e._renderService.clear(),e._renderService.onResize(e.cols,e.rows),e.refresh(0,e.rows-1));break;case"rendererType":e._renderService&&(e._renderService.setRenderer(e._createRenderer()),e._renderService.onResize(e.cols,e.rows));break;case"scrollback":e.buffers.resize(e.cols,e.rows),null===(n=e.viewport)||void 0===n||n.syncScrollArea();break;case"screenReaderMode":e.optionsService.options.screenReaderMode?!e._accessibilityManager&&e._renderService&&(e._accessibilityManager=new y.AccessibilityManager(e,e._renderService)):(null===(o=e._accessibilityManager)||void 0===o||o.dispose(),e._accessibilityManager=null);break;case"tabStopWidth":e.buffers.setupTabStops();break;case"theme":e._setTheme(e.optionsService.options.theme);break;case"windowsMode":e.optionsService.options.windowsMode?e._enableWindowsMode():(null===(s=e._windowsMode)||void 0===s||s.dispose(),e._windowsMode=void 0)}}))},t.prototype._onTextAreaFocus=function(e){this.sendFocus&&this._coreService.triggerDataEvent(c.C0.ESC+"[I"),this.updateCursorStyle(e),this.element.classList.add("focus"),this.showCursor(),this._onFocus.fire()},t.prototype.blur=function(){return this.textarea.blur()},t.prototype._onTextAreaBlur=function(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.sendFocus&&this._coreService.triggerDataEvent(c.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()},t.prototype._initGlobal=function(){var e=this;this._bindKeys(),this.register(d.addDisposableDomListener(this.element,"copy",(function(t){e.hasSelection()&&a.copyHandler(t,e._selectionService)})));var t=function(t){return a.handlePasteEvent(t,e.textarea,e.bracketedPasteMode,e._coreService)};this.register(d.addDisposableDomListener(this.textarea,"paste",t)),this.register(d.addDisposableDomListener(this.element,"paste",t)),_.isFirefox?this.register(d.addDisposableDomListener(this.element,"mousedown",(function(t){2===t.button&&a.rightClickHandler(t,e.textarea,e.screenElement,e._selectionService,e.options.rightClickSelectsWord)}))):this.register(d.addDisposableDomListener(this.element,"contextmenu",(function(t){a.rightClickHandler(t,e.textarea,e.screenElement,e._selectionService,e.options.rightClickSelectsWord)}))),_.isLinux&&this.register(d.addDisposableDomListener(this.element,"auxclick",(function(t){1===t.button&&a.moveTextAreaUnderMouseCursor(t,e.textarea,e.screenElement)})))},t.prototype._bindKeys=function(){var e=this;this.register(d.addDisposableDomListener(this.textarea,"keyup",(function(t){return e._keyUp(t)}),!0)),this.register(d.addDisposableDomListener(this.textarea,"keydown",(function(t){return e._keyDown(t)}),!0)),this.register(d.addDisposableDomListener(this.textarea,"keypress",(function(t){return e._keyPress(t)}),!0)),this.register(d.addDisposableDomListener(this.textarea,"compositionstart",(function(){return e._compositionHelper.compositionstart()}))),this.register(d.addDisposableDomListener(this.textarea,"compositionupdate",(function(t){return e._compositionHelper.compositionupdate(t)}))),this.register(d.addDisposableDomListener(this.textarea,"compositionend",(function(){return e._compositionHelper.compositionend()}))),this.register(this.onRender((function(){return e._compositionHelper.updateCompositionElements()}))),this.register(this.onRender((function(t){return e._queueLinkification(t.start,t.end)})))},t.prototype.open=function(e){var t=this;if(!e)throw new Error("Terminal requires a parent element.");N.body.contains(e)||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=e.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),this.element.setAttribute("tabindex","0"),e.appendChild(this.element);var r=N.createDocumentFragment();this._viewportElement=N.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),r.appendChild(this._viewportElement),this._viewportScrollArea=N.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=N.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=N.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),r.appendChild(this.screenElement),this.textarea=N.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",p.promptLabel),this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this.register(d.addDisposableDomListener(this.textarea,"focus",(function(e){return t._onTextAreaFocus(e)}))),this.register(d.addDisposableDomListener(this.textarea,"blur",(function(){return t._onTextAreaBlur()}))),this._helperContainer.appendChild(this.textarea);var i=this._instantiationService.createInstance(W.CoreBrowserService,this.textarea);this._instantiationService.setService(R.ICoreBrowserService,i),this._charSizeService=this._instantiationService.createInstance(x.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(R.ICharSizeService,this._charSizeService),this._compositionView=N.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(o.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(r),this._theme=this.options.theme||this._theme,this.options.theme=void 0,this._colorManager=new E.ColorManager(N,this.options.allowTransparency),this.optionsService.onOptionChange((function(e){return t._colorManager.onOptionsChange(e)})),this._colorManager.setTheme(this._theme);var n=this._createRenderer();this._renderService=this._instantiationService.createInstance(L.RenderService,n,this.rows,this.screenElement),this._instantiationService.setService(R.IRenderService,this._renderService),this._renderService.onRender((function(e){return t._onRender.fire(e)})),this.onResize((function(e){return t._renderService.resize(e.cols,e.rows)})),this._soundService=this._instantiationService.createInstance(v.SoundService),this._instantiationService.setService(R.ISoundService,this._soundService),this._mouseService=this._instantiationService.createInstance(M.MouseService),this._instantiationService.setService(R.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(s.Viewport,(function(e,r){return t.scrollLines(e,r)}),this._viewportElement,this._viewportScrollArea),this.viewport.onThemeChange(this._colorManager.colors),this.register(this.viewport),this.register(this.onCursorMove((function(){return t._renderService.onCursorMove()}))),this.register(this.onResize((function(){return t._renderService.onResize(t.cols,t.rows)}))),this.register(this.onBlur((function(){return t._renderService.onBlur()}))),this.register(this.onFocus((function(){return t._renderService.onFocus()}))),this.register(this._renderService.onDimensionsChange((function(){return t.viewport.syncScrollArea()}))),this._selectionService=this._instantiationService.createInstance(f.SelectionService,(function(e,r){return t.scrollLines(e,r)}),this.element,this.screenElement),this._instantiationService.setService(R.ISelectionService,this._selectionService),this.register(this._selectionService.onSelectionChange((function(){return t._onSelectionChange.fire()}))),this.register(this._selectionService.onRedrawRequest((function(e){return t._renderService.onSelectionChanged(e.start,e.end,e.columnSelectMode)}))),this.register(this._selectionService.onLinuxMouseSelection((function(e){t.textarea.value=e,t.textarea.focus(),t.textarea.select()}))),this.register(this.onScroll((function(){t.viewport.syncScrollArea(),t._selectionService.refresh()}))),this.register(d.addDisposableDomListener(this._viewportElement,"scroll",(function(){return t._selectionService.refresh()}))),this._mouseZoneManager=this._instantiationService.createInstance(g.MouseZoneManager,this.element,this.screenElement),this.register(this._mouseZoneManager),this.register(this.onScroll((function(){return t._mouseZoneManager.clearAll()}))),this.linkifier.attachToDom(this.element,this._mouseZoneManager),this.linkifier2.attachToDom(this.element,this._mouseService,this._renderService),this.register(d.addDisposableDomListener(this.element,"mousedown",(function(e){return t._selectionService.onMouseDown(e)}))),this.mouseEvents?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager=new y.AccessibilityManager(this,this._renderService)),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()},t.prototype._createRenderer=function(){switch(this.options.rendererType){case"canvas":return this._instantiationService.createInstance(h.Renderer,this._colorManager.colors,this.screenElement,this.linkifier,this.linkifier2);case"dom":return this._instantiationService.createInstance(b.DomRenderer,this._colorManager.colors,this.element,this.screenElement,this._viewportElement,this.linkifier,this.linkifier2);default:throw new Error('Unrecognized rendererType "'+this.options.rendererType+'"')}},t.prototype._setTheme=function(e){var t,r,i;this._theme=e,null===(t=this._colorManager)||void 0===t||t.setTheme(e),null===(r=this._renderService)||void 0===r||r.setColors(this._colorManager.colors),null===(i=this.viewport)||void 0===i||i.onThemeChange(this._colorManager.colors)},t.prototype.bindMouse=function(){var e=this,t=this,r=this.element;function i(e){var r,i,n=t._mouseService.getRawByteCoords(e,t.screenElement,t.cols,t.rows);if(!n)return!1;switch(e.overrideType||e.type){case"mousemove":i=32,void 0===e.buttons?(r=3,void 0!==e.button&&(r=e.button<3?e.button:3)):r=1&e.buttons?0:4&e.buttons?1:2&e.buttons?2:3;break;case"mouseup":i=0,r=e.button<3?e.button:3;break;case"mousedown":i=1,r=e.button<3?e.button:3;break;case"wheel":0!==e.deltaY&&(i=e.deltaY<0?0:1),r=4;break;default:return!1}return!(void 0===i||void 0===r||r>4)&&t._coreMouseService.triggerMouseEvent({col:n.x-33,row:n.y-33,button:r,action:i,ctrl:e.ctrlKey,alt:e.altKey,shift:e.shiftKey})}var n={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o=function(t){return i(t),t.buttons||(e._document.removeEventListener("mouseup",n.mouseup),n.mousedrag&&e._document.removeEventListener("mousemove",n.mousedrag)),e.cancel(t)},s=function(t){return i(t),t.preventDefault(),e.cancel(t)},a=function(e){e.buttons&&i(e)},l=function(e){e.buttons||i(e)};this._coreMouseService.onProtocolChange((function(t){e.mouseEvents=t,t?("debug"===e.optionsService.options.logLevel&&e._logService.debug("Binding to mouse events:",e._coreMouseService.explainEvents(t)),e.element.classList.add("enable-mouse-events"),e._selectionService.disable()):(e._logService.debug("Unbinding from mouse events."),e.element.classList.remove("enable-mouse-events"),e._selectionService.enable()),8&t?n.mousemove||(r.addEventListener("mousemove",l),n.mousemove=l):(r.removeEventListener("mousemove",n.mousemove),n.mousemove=null),16&t?n.wheel||(r.addEventListener("wheel",s),n.wheel=s):(r.removeEventListener("wheel",n.wheel),n.wheel=null),2&t?n.mouseup||(n.mouseup=o):(e._document.removeEventListener("mouseup",n.mouseup),n.mouseup=null),4&t?n.mousedrag||(n.mousedrag=a):(e._document.removeEventListener("mousemove",n.mousedrag),n.mousedrag=null)})),this._coreMouseService.activeProtocol=this._coreMouseService.activeProtocol,this.register(d.addDisposableDomListener(r,"mousedown",(function(t){if(t.preventDefault(),e.focus(),e.mouseEvents&&!e._selectionService.shouldForceSelection(t))return i(t),n.mouseup&&e._document.addEventListener("mouseup",n.mouseup),n.mousedrag&&e._document.addEventListener("mousemove",n.mousedrag),e.cancel(t)}))),this.register(d.addDisposableDomListener(r,"wheel",(function(t){if(n.wheel);else if(!e.buffer.hasScrollback){var r=e.viewport.getLinesScrolled(t);if(0===r)return;for(var i=c.C0.ESC+(e._coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(t.deltaY<0?"A":"B"),o="",s=0;s<Math.abs(r);s++)o+=i;e._coreService.triggerDataEvent(o,!0)}}))),this.register(d.addDisposableDomListener(r,"wheel",(function(t){if(!n.wheel)return e.viewport.onWheel(t)?void 0:e.cancel(t)}))),this.register(d.addDisposableDomListener(r,"touchstart",(function(t){if(!e.mouseEvents)return e.viewport.onTouchStart(t),e.cancel(t)}))),this.register(d.addDisposableDomListener(r,"touchmove",(function(t){if(!e.mouseEvents)return e.viewport.onTouchMove(t)?void 0:e.cancel(t)})))},t.prototype.refresh=function(e,t){var r;null===(r=this._renderService)||void 0===r||r.refreshRows(e,t)},t.prototype._queueLinkification=function(e,t){var r;null===(r=this.linkifier)||void 0===r||r.linkifyRows(e,t)},t.prototype.updateCursorStyle=function(e){this._selectionService&&this._selectionService.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")},t.prototype.showCursor=function(){this._coreService.isCursorInitialized||(this._coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))},t.prototype.scroll=function(e,t){var r;void 0===t&&(t=!1),(r=this._blankLine)&&r.length===this.cols&&r.getFg(0)===e.fg&&r.getBg(0)===e.bg||(r=this.buffer.getBlankLine(e,t),this._blankLine=r),r.isWrapped=t;var i=this.buffer.ybase+this.buffer.scrollTop,n=this.buffer.ybase+this.buffer.scrollBottom;if(0===this.buffer.scrollTop){var o=this.buffer.lines.isFull;n===this.buffer.lines.length-1?o?this.buffer.lines.recycle().copyFrom(r):this.buffer.lines.push(r.clone()):this.buffer.lines.splice(n+1,0,r.clone()),o?this._userScrolling&&(this.buffer.ydisp=Math.max(this.buffer.ydisp-1,0)):(this.buffer.ybase++,this._userScrolling||this.buffer.ydisp++)}else{var s=n-i+1;this.buffer.lines.shiftElements(i+1,s-1,-1),this.buffer.lines.set(n,r.clone())}this._userScrolling||(this.buffer.ydisp=this.buffer.ybase),this._dirtyRowService.markRangeDirty(this.buffer.scrollTop,this.buffer.scrollBottom),this._onScroll.fire(this.buffer.ydisp)},t.prototype.scrollLines=function(e,t){if(e<0){if(0===this.buffer.ydisp)return;this._userScrolling=!0}else e+this.buffer.ydisp>=this.buffer.ybase&&(this._userScrolling=!1);var r=this.buffer.ydisp;this.buffer.ydisp=Math.max(Math.min(this.buffer.ydisp+e,this.buffer.ybase),0),r!==this.buffer.ydisp&&(t||this._onScroll.fire(this.buffer.ydisp),this.refresh(0,this.rows-1))},t.prototype.scrollPages=function(e){this.scrollLines(e*(this.rows-1))},t.prototype.scrollToTop=function(){this.scrollLines(-this.buffer.ydisp)},t.prototype.scrollToBottom=function(){this.scrollLines(this.buffer.ybase-this.buffer.ydisp)},t.prototype.scrollToLine=function(e){var t=e-this.buffer.ydisp;0!==t&&this.scrollLines(t)},t.prototype.paste=function(e){a.paste(e,this.textarea,this.bracketedPasteMode,this._coreService)},t.prototype.attachCustomKeyEventHandler=function(e){this._customKeyEventHandler=e},t.prototype.addEscHandler=function(e,t){return this._inputHandler.addEscHandler(e,t)},t.prototype.addDcsHandler=function(e,t){return this._inputHandler.addDcsHandler(e,t)},t.prototype.addCsiHandler=function(e,t){return this._inputHandler.addCsiHandler(e,t)},t.prototype.addOscHandler=function(e,t){return this._inputHandler.addOscHandler(e,t)},t.prototype.registerLinkMatcher=function(e,t,r){var i=this.linkifier.registerLinkMatcher(e,t,r);return this.refresh(0,this.rows-1),i},t.prototype.deregisterLinkMatcher=function(e){this.linkifier.deregisterLinkMatcher(e)&&this.refresh(0,this.rows-1)},t.prototype.registerLinkProvider=function(e){return this.linkifier2.registerLinkProvider(e)},t.prototype.registerCharacterJoiner=function(e){var t=this._renderService.registerCharacterJoiner(e);return this.refresh(0,this.rows-1),t},t.prototype.deregisterCharacterJoiner=function(e){this._renderService.deregisterCharacterJoiner(e)&&this.refresh(0,this.rows-1)},Object.defineProperty(t.prototype,"markers",{get:function(){return this.buffer.markers},enumerable:!0,configurable:!0}),t.prototype.addMarker=function(e){if(this.buffer===this.buffers.normal)return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)},t.prototype.hasSelection=function(){return!!this._selectionService&&this._selectionService.hasSelection},t.prototype.select=function(e,t,r){this._selectionService.setSelection(e,t,r)},t.prototype.getSelection=function(){return this._selectionService?this._selectionService.selectionText:""},t.prototype.getSelectionPosition=function(){if(this._selectionService.hasSelection)return{startColumn:this._selectionService.selectionStart[0],startRow:this._selectionService.selectionStart[1],endColumn:this._selectionService.selectionEnd[0],endRow:this._selectionService.selectionEnd[1]}},t.prototype.clearSelection=function(){var e;null===(e=this._selectionService)||void 0===e||e.clearSelection()},t.prototype.selectAll=function(){var e;null===(e=this._selectionService)||void 0===e||e.selectAll()},t.prototype.selectLines=function(e,t){var r;null===(r=this._selectionService)||void 0===r||r.selectLines(e,t)},t.prototype._keyDown=function(e){if(this._keyDownHandled=!1,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;if(!this._compositionHelper.keydown(e))return this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;var t=m.evaluateKeyboardEvent(e,this._coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),3===t.type||2===t.type){var r=this.rows-1;return this.scrollLines(2===t.type?-r:r),this.cancel(e,!0)}return 1===t.type&&this.selectAll(),!!this._isThirdLevelShift(this.browser,e)||(t.cancel&&this.cancel(e,!0),!t.key||(t.key!==c.C0.ETX&&t.key!==c.C0.CR||(this.textarea.value=""),this._onKey.fire({key:t.key,domEvent:e}),this.showCursor(),this._coreService.triggerDataEvent(t.key,!0),this.optionsService.options.screenReaderMode?void(this._keyDownHandled=!0):this.cancel(e,!0)))},t.prototype._isThirdLevelShift=function(e,t){var r=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey;return"keypress"===t.type?r:r&&(!t.keyCode||t.keyCode>47)},t.prototype._keyUp=function(e){this._customKeyEventHandler&&!1===this._customKeyEventHandler(e)||(function(e){return 16===e.keyCode||17===e.keyCode||18===e.keyCode}(e)||this.focus(),this.updateCursorStyle(e))},t.prototype._keyPress=function(e){var t;if(this._keyDownHandled)return!1;if(this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(null===e.which||void 0===e.which)t=e.keyCode;else{if(0===e.which||0===e.charCode)return!1;t=e.which}return!(!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e))&&(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this.showCursor(),this._coreService.triggerDataEvent(t,!0),!0)},t.prototype.bell=function(){var e=this;this._soundBell()&&this._soundService.playBellSound(),this._visualBell()&&(this.element.classList.add("visual-bell-active"),clearTimeout(this._visualBellTimer),this._visualBellTimer=window.setTimeout((function(){e.element.classList.remove("visual-bell-active")}),200))},t.prototype.resize=function(e,t){var r,i;isNaN(e)||isNaN(t)||(e!==this.cols||t!==this.rows?(e<D.MINIMUM_COLS&&(e=D.MINIMUM_COLS),t<D.MINIMUM_ROWS&&(t=D.MINIMUM_ROWS),this.buffers.resize(e,t),this._bufferService.resize(e,t),this.buffers.setupTabStops(this.cols),null===(r=this._charSizeService)||void 0===r||r.measure(),null===(i=this.viewport)||void 0===i||i.syncScrollArea(!0),this.refresh(0,this.rows-1),this._onResize.fire({cols:e,rows:t})):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure())},t.prototype.clear=function(){if(0!==this.buffer.ybase||0!==this.buffer.y){this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(var e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(C.DEFAULT_ATTR_DATA));this.refresh(0,this.rows-1),this._onScroll.fire(this.buffer.ydisp)}},t.prototype.is=function(e){return 0===(this.options.termName+"").indexOf(e)},t.prototype.handleTitle=function(e){this._onTitleChange.fire(e)},t.prototype.reset=function(){var e,t;this.options.rows=this.rows,this.options.cols=this.cols;var r=this._customKeyEventHandler,i=this._userScrolling;this._setup(),this._bufferService.reset(),this._charsetService.reset(),this._coreService.reset(),this._coreMouseService.reset(),null===(e=this._selectionService)||void 0===e||e.reset(),this._customKeyEventHandler=r,this._userScrolling=i,this.refresh(0,this.rows-1),null===(t=this.viewport)||void 0===t||t.syncScrollArea()},t.prototype.cancel=function(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1},t.prototype._visualBell=function(){return!1},t.prototype._soundBell=function(){return"sound"===this.options.bellStyle},t.prototype.write=function(e,t){this._writeBuffer.write(e,t)},t.prototype.writeSync=function(e){this._writeBuffer.writeSync(e)},t}(T.Disposable);t.Terminal=z},function(e,t,r){"use strict";var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(4),s=r(1),a=function(){function e(e,t,r,i,n,o){this._textarea=e,this._compositionView=t,this._bufferService=r,this._optionsService=i,this._charSizeService=n,this._coreService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0}}return e.prototype.compositionstart=function(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._compositionView.classList.add("active")},e.prototype.compositionupdate=function(e){var t=this;this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout((function(){t._compositionPosition.end=t._textarea.value.length}),0)},e.prototype.compositionend=function(){this._finalizeComposition(!0)},e.prototype.keydown=function(e){if(this._isComposing||this._isSendingComposition){if(229===e.keyCode)return!1;if(16===e.keyCode||17===e.keyCode||18===e.keyCode)return!1;this._finalizeComposition(!1)}return 229!==e.keyCode||(this._handleAnyTextareaChanges(),!1)},e.prototype._finalizeComposition=function(e){var t=this;if(this._compositionView.classList.remove("active"),this._isComposing=!1,this._clearTextareaPosition(),e){var r={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((function(){if(t._isSendingComposition){t._isSendingComposition=!1;var e=void 0;e=t._isComposing?t._textarea.value.substring(r.start,r.end):t._textarea.value.substring(r.start),t._coreService.triggerDataEvent(e,!0)}}),0)}else{this._isSendingComposition=!1;var i=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(i,!0)}},e.prototype._handleAnyTextareaChanges=function(){var e=this,t=this._textarea.value;setTimeout((function(){if(!e._isComposing){var r=e._textarea.value.replace(t,"");r.length>0&&e._coreService.triggerDataEvent(r,!0)}}),0)},e.prototype.updateCompositionElements=function(e){var t=this;if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){var r=Math.ceil(this._charSizeService.height*this._optionsService.options.lineHeight),i=this._bufferService.buffer.y*r,n=this._bufferService.buffer.x*this._charSizeService.width;this._compositionView.style.left=n+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=r+"px",this._compositionView.style.lineHeight=r+"px",this._compositionView.style.fontFamily=this._optionsService.options.fontFamily,this._compositionView.style.fontSize=this._optionsService.options.fontSize+"px";var o=this._compositionView.getBoundingClientRect();this._textarea.style.left=n+"px",this._textarea.style.top=i+"px",this._textarea.style.width=o.width+"px",this._textarea.style.height=o.height+"px",this._textarea.style.lineHeight=o.height+"px"}e||setTimeout((function(){return t.updateCompositionElements(!0)}),0)}},e.prototype._clearTextareaPosition=function(){this._textarea.style.left="",this._textarea.style.top=""},e=i([n(2,s.IBufferService),n(3,s.IOptionsService),n(4,o.ICharSizeService),n(5,s.ICoreService)],e)}();t.CompositionHelper=a},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var a=r(2),c=r(8),l=r(4),h=r(1),u=function(e){function t(t,r,i,n,o,s,a){var l=e.call(this)||this;return l._scrollLines=t,l._viewportElement=r,l._scrollArea=i,l._bufferService=n,l._optionsService=o,l._charSizeService=s,l._renderService=a,l.scrollBarWidth=0,l._currentRowHeight=0,l._lastRecordedBufferLength=0,l._lastRecordedViewportHeight=0,l._lastRecordedBufferHeight=0,l._lastTouchY=0,l._lastScrollTop=0,l._wheelPartialScroll=0,l._refreshAnimationFrame=null,l._ignoreNextScrollEvent=!1,l.scrollBarWidth=l._viewportElement.offsetWidth-l._scrollArea.offsetWidth||15,l.register(c.addDisposableDomListener(l._viewportElement,"scroll",l._onScroll.bind(l))),setTimeout((function(){return l.syncScrollArea()}),0),l}return n(t,e),t.prototype.onThemeChange=function(e){this._viewportElement.style.backgroundColor=e.background.css},t.prototype._refresh=function(e){var t=this;if(e)return this._innerRefresh(),void(null!==this._refreshAnimationFrame&&cancelAnimationFrame(this._refreshAnimationFrame));null===this._refreshAnimationFrame&&(this._refreshAnimationFrame=requestAnimationFrame((function(){return t._innerRefresh()})))},t.prototype._innerRefresh=function(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderService.dimensions.scaledCellHeight/window.devicePixelRatio,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;var e=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.canvasHeight);this._lastRecordedBufferHeight!==e&&(this._lastRecordedBufferHeight=e,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}var t=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==t&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=t),this._refreshAnimationFrame=null},t.prototype.syncScrollArea=function(e){if(void 0===e&&(e=!1),this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(e);if(this._lastRecordedViewportHeight===this._renderService.dimensions.canvasHeight){var t=this._bufferService.buffer.ydisp*this._currentRowHeight;this._lastScrollTop===t&&this._lastScrollTop===this._viewportElement.scrollTop&&this._renderService.dimensions.scaledCellHeight/window.devicePixelRatio===this._currentRowHeight||this._refresh(e)}else this._refresh(e)},t.prototype._onScroll=function(e){if(this._lastScrollTop=this._viewportElement.scrollTop,this._viewportElement.offsetParent)if(this._ignoreNextScrollEvent)this._ignoreNextScrollEvent=!1;else{var t=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._scrollLines(t,!0)}},t.prototype._bubbleScroll=function(e,t){var r=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(t<0&&0!==this._viewportElement.scrollTop||t>0&&r<this._lastRecordedBufferHeight)||(e.cancelable&&e.preventDefault(),!1)},t.prototype.onWheel=function(e){var t=this._getPixelsScrolled(e);return 0!==t&&(this._viewportElement.scrollTop+=t,this._bubbleScroll(e,t))},t.prototype._getPixelsScrolled=function(e){if(0===e.deltaY)return 0;var t=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_LINE?t*=this._currentRowHeight:e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(t*=this._currentRowHeight*this._bufferService.rows),t},t.prototype.getLinesScrolled=function(e){if(0===e.deltaY)return 0;var t=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(t/=this._currentRowHeight+0,this._wheelPartialScroll+=t,t=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(t*=this._bufferService.rows),t},t.prototype._applyScrollModifier=function(e,t){var r=this._optionsService.options.fastScrollModifier;return"alt"===r&&t.altKey||"ctrl"===r&&t.ctrlKey||"shift"===r&&t.shiftKey?e*this._optionsService.options.fastScrollSensitivity*this._optionsService.options.scrollSensitivity:e*this._optionsService.options.scrollSensitivity},t.prototype.onTouchStart=function(e){this._lastTouchY=e.touches[0].pageY},t.prototype.onTouchMove=function(e){var t=this._lastTouchY-e.touches[0].pageY;return this._lastTouchY=e.touches[0].pageY,0!==t&&(this._viewportElement.scrollTop+=t,this._bubbleScroll(e,t))},t=o([s(3,h.IBufferService),s(4,h.IOptionsService),s(5,l.ICharSizeService),s(6,l.IRenderService)],t)}(a.Disposable);t.Viewport=u},function(e,t,r){"use strict";function i(e){return e.replace(/\r?\n/g,"\r")}function n(e,t){return t?"[200~"+e+"[201~":e}function o(e,t,r,o){e=n(e=i(e),r),o.triggerDataEvent(e,!0),t.value=""}function s(e,t,r){var i=r.getBoundingClientRect(),n=e.clientX-i.left-10,o=e.clientY-i.top-10;t.style.position="absolute",t.style.width="20px",t.style.height="20px",t.style.left=n+"px",t.style.top=o+"px",t.style.zIndex="1000",t.focus(),setTimeout((function(){t.style.position="",t.style.width="",t.style.height="",t.style.left="",t.style.top="",t.style.zIndex=""}),200)}Object.defineProperty(t,"__esModule",{value:!0}),t.prepareTextForTerminal=i,t.bracketTextForPaste=n,t.copyHandler=function(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()},t.handlePasteEvent=function(e,t,r,i){e.stopPropagation(),e.clipboardData&&o(e.clipboardData.getData("text/plain"),t,r,i)},t.paste=o,t.moveTextAreaUnderMouseCursor=s,t.rightClickHandler=function(e,t,r,i,n){s(e,t,r),n&&!i.isClickInSelection(e)&&i.selectWordAtCursor(e),t.value=i.selectionText,t.select()}},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(12),s=r(18),a=r(38),c=r(2),l=r(15),h=r(7),u=r(16),f=r(0),_=r(3),d=r(5),p=r(6),v=r(20),g=r(22),y=r(4),b={"(":0,")":1,"*":2,"+":3,"-":1,".":2};function m(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var S=function(){function e(e,t,r,i){this._bufferService=e,this._coreService=t,this._logService=r,this._optionsService=i,this._data=new Uint32Array(0)}return e.prototype.hook=function(e){this._data=new Uint32Array(0)},e.prototype.put=function(e,t,r){this._data=l.concat(this._data,e.subarray(t,r))},e.prototype.unhook=function(e){if(e){var t=h.utf32ToString(this._data);switch(this._data=new Uint32Array(0),t){case'"q':return this._coreService.triggerDataEvent(o.C0.ESC+'P1$r0"q'+o.C0.ESC+"\\");case'"p':return this._coreService.triggerDataEvent(o.C0.ESC+'P1$r61;1"p'+o.C0.ESC+"\\");case"r":var r=this._bufferService.buffer.scrollTop+1+";"+(this._bufferService.buffer.scrollBottom+1)+"r";return this._coreService.triggerDataEvent(o.C0.ESC+"P1$r"+r+o.C0.ESC+"\\");case"m":return this._coreService.triggerDataEvent(o.C0.ESC+"P1$r0m"+o.C0.ESC+"\\");case" q":var i={block:2,underline:4,bar:6}[this._optionsService.options.cursorStyle];return i-=this._optionsService.options.cursorBlink?1:0,this._coreService.triggerDataEvent(o.C0.ESC+"P1$r"+i+" q"+o.C0.ESC+"\\");default:this._logService.debug("Unknown DCS $q %s",t),this._coreService.triggerDataEvent(o.C0.ESC+"P0$r"+o.C0.ESC+"\\")}}else this._data=new Uint32Array(0)},e}(),C=function(e){function t(t,r,i,n,c,l,_,p,g,y,b){void 0===b&&(b=new a.EscapeSequenceParser);var m=e.call(this)||this;m._terminal=t,m._bufferService=r,m._charsetService=i,m._coreService=n,m._dirtyRowService=c,m._logService=l,m._optionsService=_,m._coreMouseService=p,m._unicodeService=g,m._instantiationService=y,m._parser=b,m._parseBuffer=new Uint32Array(4096),m._stringDecoder=new h.StringToUtf32,m._utf8Decoder=new h.Utf8ToUtf32,m._workCell=new d.CellData,m._windowTitle="",m._iconName="",m._windowTitleStack=[],m._iconNameStack=[],m._curAttrData=u.DEFAULT_ATTR_DATA.clone(),m._eraseAttrDataInternal=u.DEFAULT_ATTR_DATA.clone(),m._onRequestRefreshRows=new f.EventEmitter,m._onRequestReset=new f.EventEmitter,m._onRequestBell=new f.EventEmitter,m._onCursorMove=new f.EventEmitter,m._onLineFeed=new f.EventEmitter,m._onScroll=new f.EventEmitter,m.register(m._parser),m._parser.setCsiHandlerFallback((function(e,t){m._logService.debug("Unknown CSI code: ",{identifier:m._parser.identToString(e),params:t.toArray()})})),m._parser.setEscHandlerFallback((function(e){m._logService.debug("Unknown ESC code: ",{identifier:m._parser.identToString(e)})})),m._parser.setExecuteHandlerFallback((function(e){m._logService.debug("Unknown EXECUTE code: ",{code:e})})),m._parser.setOscHandlerFallback((function(e,t,r){m._logService.debug("Unknown OSC code: ",{identifier:e,action:t,data:r})})),m._parser.setDcsHandlerFallback((function(e,t,r){"HOOK"===t&&(r=r.toArray()),m._logService.debug("Unknown DCS code: ",{identifier:m._parser.identToString(e),action:t,payload:r})})),m._parser.setPrintHandler((function(e,t,r){return m.print(e,t,r)})),m._parser.setCsiHandler({final:"@"},(function(e){return m.insertChars(e)})),m._parser.setCsiHandler({intermediates:" ",final:"@"},(function(e){return m.scrollLeft(e)})),m._parser.setCsiHandler({final:"A"},(function(e){return m.cursorUp(e)})),m._parser.setCsiHandler({intermediates:" ",final:"A"},(function(e){return m.scrollRight(e)})),m._parser.setCsiHandler({final:"B"},(function(e){return m.cursorDown(e)})),m._parser.setCsiHandler({final:"C"},(function(e){return m.cursorForward(e)})),m._parser.setCsiHandler({final:"D"},(function(e){return m.cursorBackward(e)})),m._parser.setCsiHandler({final:"E"},(function(e){return m.cursorNextLine(e)})),m._parser.setCsiHandler({final:"F"},(function(e){return m.cursorPrecedingLine(e)})),m._parser.setCsiHandler({final:"G"},(function(e){return m.cursorCharAbsolute(e)})),m._parser.setCsiHandler({final:"H"},(function(e){return m.cursorPosition(e)})),m._parser.setCsiHandler({final:"I"},(function(e){return m.cursorForwardTab(e)})),m._parser.setCsiHandler({final:"J"},(function(e){return m.eraseInDisplay(e)})),m._parser.setCsiHandler({prefix:"?",final:"J"},(function(e){return m.eraseInDisplay(e)})),m._parser.setCsiHandler({final:"K"},(function(e){return m.eraseInLine(e)})),m._parser.setCsiHandler({prefix:"?",final:"K"},(function(e){return m.eraseInLine(e)})),m._parser.setCsiHandler({final:"L"},(function(e){return m.insertLines(e)})),m._parser.setCsiHandler({final:"M"},(function(e){return m.deleteLines(e)})),m._parser.setCsiHandler({final:"P"},(function(e){return m.deleteChars(e)})),m._parser.setCsiHandler({final:"S"},(function(e){return m.scrollUp(e)})),m._parser.setCsiHandler({final:"T"},(function(e){return m.scrollDown(e)})),m._parser.setCsiHandler({final:"X"},(function(e){return m.eraseChars(e)})),m._parser.setCsiHandler({final:"Z"},(function(e){return m.cursorBackwardTab(e)})),m._parser.setCsiHandler({final:"`"},(function(e){return m.charPosAbsolute(e)})),m._parser.setCsiHandler({final:"a"},(function(e){return m.hPositionRelative(e)})),m._parser.setCsiHandler({final:"b"},(function(e){return m.repeatPrecedingCharacter(e)})),m._parser.setCsiHandler({final:"c"},(function(e){return m.sendDeviceAttributesPrimary(e)})),m._parser.setCsiHandler({prefix:">",final:"c"},(function(e){return m.sendDeviceAttributesSecondary(e)})),m._parser.setCsiHandler({final:"d"},(function(e){return m.linePosAbsolute(e)})),m._parser.setCsiHandler({final:"e"},(function(e){return m.vPositionRelative(e)})),m._parser.setCsiHandler({final:"f"},(function(e){return m.hVPosition(e)})),m._parser.setCsiHandler({final:"g"},(function(e){return m.tabClear(e)})),m._parser.setCsiHandler({final:"h"},(function(e){return m.setMode(e)})),m._parser.setCsiHandler({prefix:"?",final:"h"},(function(e){return m.setModePrivate(e)})),m._parser.setCsiHandler({final:"l"},(function(e){return m.resetMode(e)})),m._parser.setCsiHandler({prefix:"?",final:"l"},(function(e){return m.resetModePrivate(e)})),m._parser.setCsiHandler({final:"m"},(function(e){return m.charAttributes(e)})),m._parser.setCsiHandler({final:"n"},(function(e){return m.deviceStatus(e)})),m._parser.setCsiHandler({prefix:"?",final:"n"},(function(e){return m.deviceStatusPrivate(e)})),m._parser.setCsiHandler({intermediates:"!",final:"p"},(function(e){return m.softReset(e)})),m._parser.setCsiHandler({intermediates:" ",final:"q"},(function(e){return m.setCursorStyle(e)})),m._parser.setCsiHandler({final:"r"},(function(e){return m.setScrollRegion(e)})),m._parser.setCsiHandler({final:"s"},(function(e){return m.saveCursor(e)})),m._parser.setCsiHandler({final:"t"},(function(e){return m.windowOptions(e)})),m._parser.setCsiHandler({final:"u"},(function(e){return m.restoreCursor(e)})),m._parser.setCsiHandler({intermediates:"'",final:"}"},(function(e){return m.insertColumns(e)})),m._parser.setCsiHandler({intermediates:"'",final:"~"},(function(e){return m.deleteColumns(e)})),m._parser.setExecuteHandler(o.C0.BEL,(function(){return m.bell()})),m._parser.setExecuteHandler(o.C0.LF,(function(){return m.lineFeed()})),m._parser.setExecuteHandler(o.C0.VT,(function(){return m.lineFeed()})),m._parser.setExecuteHandler(o.C0.FF,(function(){return m.lineFeed()})),m._parser.setExecuteHandler(o.C0.CR,(function(){return m.carriageReturn()})),m._parser.setExecuteHandler(o.C0.BS,(function(){return m.backspace()})),m._parser.setExecuteHandler(o.C0.HT,(function(){return m.tab()})),m._parser.setExecuteHandler(o.C0.SO,(function(){return m.shiftOut()})),m._parser.setExecuteHandler(o.C0.SI,(function(){return m.shiftIn()})),m._parser.setExecuteHandler(o.C1.IND,(function(){return m.index()})),m._parser.setExecuteHandler(o.C1.NEL,(function(){return m.nextLine()})),m._parser.setExecuteHandler(o.C1.HTS,(function(){return m.tabSet()})),m._parser.setOscHandler(0,new v.OscHandler((function(e){m.setTitle(e),m.setIconName(e)}))),m._parser.setOscHandler(1,new v.OscHandler((function(e){return m.setIconName(e)}))),m._parser.setOscHandler(2,new v.OscHandler((function(e){return m.setTitle(e)}))),m._parser.setEscHandler({final:"7"},(function(){return m.saveCursor()})),m._parser.setEscHandler({final:"8"},(function(){return m.restoreCursor()})),m._parser.setEscHandler({final:"D"},(function(){return m.index()})),m._parser.setEscHandler({final:"E"},(function(){return m.nextLine()})),m._parser.setEscHandler({final:"H"},(function(){return m.tabSet()})),m._parser.setEscHandler({final:"M"},(function(){return m.reverseIndex()})),m._parser.setEscHandler({final:"="},(function(){return m.keypadApplicationMode()})),m._parser.setEscHandler({final:">"},(function(){return m.keypadNumericMode()})),m._parser.setEscHandler({final:"c"},(function(){return m.fullReset()})),m._parser.setEscHandler({final:"n"},(function(){return m.setgLevel(2)})),m._parser.setEscHandler({final:"o"},(function(){return m.setgLevel(3)})),m._parser.setEscHandler({final:"|"},(function(){return m.setgLevel(3)})),m._parser.setEscHandler({final:"}"},(function(){return m.setgLevel(2)})),m._parser.setEscHandler({final:"~"},(function(){return m.setgLevel(1)})),m._parser.setEscHandler({intermediates:"%",final:"@"},(function(){return m.selectDefaultCharset()})),m._parser.setEscHandler({intermediates:"%",final:"G"},(function(){return m.selectDefaultCharset()}));var C=function(e){w._parser.setEscHandler({intermediates:"(",final:e},(function(){return m.selectCharset("("+e)})),w._parser.setEscHandler({intermediates:")",final:e},(function(){return m.selectCharset(")"+e)})),w._parser.setEscHandler({intermediates:"*",final:e},(function(){return m.selectCharset("*"+e)})),w._parser.setEscHandler({intermediates:"+",final:e},(function(){return m.selectCharset("+"+e)})),w._parser.setEscHandler({intermediates:"-",final:e},(function(){return m.selectCharset("-"+e)})),w._parser.setEscHandler({intermediates:".",final:e},(function(){return m.selectCharset("."+e)})),w._parser.setEscHandler({intermediates:"/",final:e},(function(){return m.selectCharset("/"+e)}))},w=this;for(var E in s.CHARSETS)C(E);return m._parser.setEscHandler({intermediates:"#",final:"8"},(function(){return m.screenAlignmentPattern()})),m._parser.setErrorHandler((function(e){return m._logService.error("Parsing error: ",e),e})),m._parser.setDcsHandler({intermediates:"$",final:"q"},new S(m._bufferService,m._coreService,m._logService,m._optionsService)),m}return n(t,e),Object.defineProperty(t.prototype,"onRequestRefreshRows",{get:function(){return this._onRequestRefreshRows.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onRequestReset",{get:function(){return this._onRequestReset.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onRequestBell",{get:function(){return this._onRequestBell.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onCursorMove",{get:function(){return this._onCursorMove.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onLineFeed",{get:function(){return this._onLineFeed.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onScroll",{get:function(){return this._onScroll.event},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){e.prototype.dispose.call(this)},t.prototype.parse=function(e){var t=this._bufferService.buffer,r=t.x,i=t.y;if(this._logService.debug("parsing data",e),this._parseBuffer.length<e.length&&this._parseBuffer.length<131072&&(this._parseBuffer=new Uint32Array(Math.min(e.length,131072))),this._dirtyRowService.clearRange(),e.length>131072)for(var n=0;n<e.length;n+=131072){var o=n+131072<e.length?n+131072:e.length,s="string"==typeof e?this._stringDecoder.decode(e.substring(n,o),this._parseBuffer):this._utf8Decoder.decode(e.subarray(n,o),this._parseBuffer);this._parser.parse(this._parseBuffer,s)}else{s="string"==typeof e?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);this._parser.parse(this._parseBuffer,s)}(t=this._bufferService.buffer).x===r&&t.y===i||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowService.start,this._dirtyRowService.end)},t.prototype.print=function(e,t,r){var i,n,o=this._bufferService.buffer,s=this._charsetService.charset,a=this._optionsService.options.screenReaderMode,c=this._bufferService.cols,l=this._coreService.decPrivateModes.wraparound,u=this._terminal.insertMode,f=this._curAttrData,d=o.lines.get(o.y+o.ybase);this._dirtyRowService.markDirty(o.y),o.x&&r-t>0&&2===d.getWidth(o.x-1)&&d.setCellFromCodePoint(o.x-1,0,1,f.fg,f.bg);for(var p=t;p<r;++p){if(i=e[p],n=this._unicodeService.wcwidth(i),i<127&&s){var v=s[String.fromCharCode(i)];v&&(i=v.charCodeAt(0))}if(a&&this._terminal.onA11yCharEmitter.fire(h.stringFromCodePoint(i)),n||!o.x){if(o.x+n-1>=c)if(l)o.x=0,o.y++,o.y===o.scrollBottom+1?(o.y--,this._terminal.scroll(this._eraseAttrData(),!0)):(o.y>=this._bufferService.rows&&(o.y=this._bufferService.rows-1),o.lines.get(o.y).isWrapped=!0),d=o.lines.get(o.y+o.ybase);else if(o.x=c-1,2===n)continue;if(u&&(d.insertCells(o.x,n,o.getNullCell(f),f),2===d.getWidth(c-1)&&d.setCellFromCodePoint(c-1,_.NULL_CELL_CODE,_.NULL_CELL_WIDTH,f.fg,f.bg)),d.setCellFromCodePoint(o.x++,i,n,f.fg,f.bg),n>0)for(;--n;)d.setCellFromCodePoint(o.x++,0,0,f.fg,f.bg)}else d.getWidth(o.x-1)?d.addCodepointToCell(o.x-1,i):d.addCodepointToCell(o.x-2,i)}r-t>0&&(d.loadCell(o.x-1,this._workCell),2===this._workCell.getWidth()||this._workCell.getCode()>65535?this._parser.precedingCodepoint=0:this._workCell.isCombined()?this._parser.precedingCodepoint=this._workCell.getChars().charCodeAt(0):this._parser.precedingCodepoint=this._workCell.content),o.x<c&&r-t>0&&0===d.getWidth(o.x)&&!d.hasContent(o.x)&&d.setCellFromCodePoint(o.x,0,1,f.fg,f.bg),this._dirtyRowService.markDirty(o.y)},t.prototype.addCsiHandler=function(e,t){var r=this;return"t"!==e.final||e.prefix||e.intermediates?this._parser.addCsiHandler(e,t):this._parser.addCsiHandler(e,(function(e){return!m(e.params[0],r._optionsService.options.windowOptions)||t(e)}))},t.prototype.addDcsHandler=function(e,t){return this._parser.addDcsHandler(e,new g.DcsHandler(t))},t.prototype.addEscHandler=function(e,t){return this._parser.addEscHandler(e,t)},t.prototype.addOscHandler=function(e,t){return this._parser.addOscHandler(e,new v.OscHandler(t))},t.prototype.bell=function(){this._onRequestBell.fire()},t.prototype.lineFeed=function(){var e=this._bufferService.buffer;this._dirtyRowService.markDirty(e.y),this._optionsService.options.convertEol&&(e.x=0),e.y++,e.y===e.scrollBottom+1?(e.y--,this._terminal.scroll(this._eraseAttrData())):e.y>=this._bufferService.rows&&(e.y=this._bufferService.rows-1),e.x>=this._bufferService.cols&&e.x--,this._dirtyRowService.markDirty(e.y),this._onLineFeed.fire()},t.prototype.carriageReturn=function(){this._bufferService.buffer.x=0},t.prototype.backspace=function(){this._restrictCursor(),this._bufferService.buffer.x>0&&this._bufferService.buffer.x--},t.prototype.tab=function(){if(!(this._bufferService.buffer.x>=this._bufferService.cols)){var e=this._bufferService.buffer.x;this._bufferService.buffer.x=this._bufferService.buffer.nextStop(),this._optionsService.options.screenReaderMode&&this._terminal.onA11yTabEmitter.fire(this._bufferService.buffer.x-e)}},t.prototype.shiftOut=function(){this._charsetService.setgLevel(1)},t.prototype.shiftIn=function(){this._charsetService.setgLevel(0)},t.prototype._restrictCursor=function(){this._bufferService.buffer.x=Math.min(this._bufferService.cols-1,Math.max(0,this._bufferService.buffer.x)),this._bufferService.buffer.y=this._coreService.decPrivateModes.origin?Math.min(this._bufferService.buffer.scrollBottom,Math.max(this._bufferService.buffer.scrollTop,this._bufferService.buffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._bufferService.buffer.y)),this._dirtyRowService.markDirty(this._bufferService.buffer.y)},t.prototype._setCursor=function(e,t){this._dirtyRowService.markDirty(this._bufferService.buffer.y),this._coreService.decPrivateModes.origin?(this._bufferService.buffer.x=e,this._bufferService.buffer.y=this._bufferService.buffer.scrollTop+t):(this._bufferService.buffer.x=e,this._bufferService.buffer.y=t),this._restrictCursor(),this._dirtyRowService.markDirty(this._bufferService.buffer.y)},t.prototype._moveCursor=function(e,t){this._restrictCursor(),this._setCursor(this._bufferService.buffer.x+e,this._bufferService.buffer.y+t)},t.prototype.cursorUp=function(e){var t=this._bufferService.buffer.y-this._bufferService.buffer.scrollTop;t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1))},t.prototype.cursorDown=function(e){var t=this._bufferService.buffer.scrollBottom-this._bufferService.buffer.y;t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1)},t.prototype.cursorForward=function(e){this._moveCursor(e.params[0]||1,0)},t.prototype.cursorBackward=function(e){this._moveCursor(-(e.params[0]||1),0)},t.prototype.cursorNextLine=function(e){this.cursorDown(e),this._bufferService.buffer.x=0},t.prototype.cursorPrecedingLine=function(e){this.cursorUp(e),this._bufferService.buffer.x=0},t.prototype.cursorCharAbsolute=function(e){this._setCursor((e.params[0]||1)-1,this._bufferService.buffer.y)},t.prototype.cursorPosition=function(e){this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1)},t.prototype.charPosAbsolute=function(e){this._setCursor((e.params[0]||1)-1,this._bufferService.buffer.y)},t.prototype.hPositionRelative=function(e){this._moveCursor(e.params[0]||1,0)},t.prototype.linePosAbsolute=function(e){this._setCursor(this._bufferService.buffer.x,(e.params[0]||1)-1)},t.prototype.vPositionRelative=function(e){this._moveCursor(0,e.params[0]||1)},t.prototype.hVPosition=function(e){this.cursorPosition(e)},t.prototype.tabClear=function(e){var t=e.params[0];0===t?delete this._bufferService.buffer.tabs[this._bufferService.buffer.x]:3===t&&(this._bufferService.buffer.tabs={})},t.prototype.cursorForwardTab=function(e){if(!(this._bufferService.buffer.x>=this._bufferService.cols))for(var t=e.params[0]||1;t--;)this._bufferService.buffer.x=this._bufferService.buffer.nextStop()},t.prototype.cursorBackwardTab=function(e){if(!(this._bufferService.buffer.x>=this._bufferService.cols))for(var t=e.params[0]||1,r=this._bufferService.buffer;t--;)r.x=r.prevStop()},t.prototype._eraseInBufferLine=function(e,t,r,i){void 0===i&&(i=!1);var n=this._bufferService.buffer.lines.get(this._bufferService.buffer.ybase+e);n.replaceCells(t,r,this._bufferService.buffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),i&&(n.isWrapped=!1)},t.prototype._resetBufferLine=function(e){var t=this._bufferService.buffer.lines.get(this._bufferService.buffer.ybase+e);t.fill(this._bufferService.buffer.getNullCell(this._eraseAttrData())),t.isWrapped=!1},t.prototype.eraseInDisplay=function(e){var t;switch(this._restrictCursor(),e.params[0]){case 0:for(t=this._bufferService.buffer.y,this._dirtyRowService.markDirty(t),this._eraseInBufferLine(t++,this._bufferService.buffer.x,this._bufferService.cols,0===this._bufferService.buffer.x);t<this._bufferService.rows;t++)this._resetBufferLine(t);this._dirtyRowService.markDirty(t);break;case 1:for(t=this._bufferService.buffer.y,this._dirtyRowService.markDirty(t),this._eraseInBufferLine(t,0,this._bufferService.buffer.x+1,!0),this._bufferService.buffer.x+1>=this._bufferService.cols&&(this._bufferService.buffer.lines.get(t+1).isWrapped=!1);t--;)this._resetBufferLine(t);this._dirtyRowService.markDirty(0);break;case 2:for(t=this._bufferService.rows,this._dirtyRowService.markDirty(t-1);t--;)this._resetBufferLine(t);this._dirtyRowService.markDirty(0);break;case 3:var r=this._bufferService.buffer.lines.length-this._bufferService.rows;r>0&&(this._bufferService.buffer.lines.trimStart(r),this._bufferService.buffer.ybase=Math.max(this._bufferService.buffer.ybase-r,0),this._bufferService.buffer.ydisp=Math.max(this._bufferService.buffer.ydisp-r,0),this._onScroll.fire(0))}},t.prototype.eraseInLine=function(e){switch(this._restrictCursor(),e.params[0]){case 0:this._eraseInBufferLine(this._bufferService.buffer.y,this._bufferService.buffer.x,this._bufferService.cols);break;case 1:this._eraseInBufferLine(this._bufferService.buffer.y,0,this._bufferService.buffer.x+1);break;case 2:this._eraseInBufferLine(this._bufferService.buffer.y,0,this._bufferService.cols)}this._dirtyRowService.markDirty(this._bufferService.buffer.y)},t.prototype.insertLines=function(e){this._restrictCursor();var t=e.params[0]||1,r=this._bufferService.buffer;if(!(r.y>r.scrollBottom||r.y<r.scrollTop)){for(var i=r.y+r.ybase,n=this._bufferService.rows-1-r.scrollBottom,o=this._bufferService.rows-1+r.ybase-n+1;t--;)r.lines.splice(o-1,1),r.lines.splice(i,0,r.getBlankLine(this._eraseAttrData()));this._dirtyRowService.markRangeDirty(r.y,r.scrollBottom),r.x=0}},t.prototype.deleteLines=function(e){this._restrictCursor();var t=e.params[0]||1,r=this._bufferService.buffer;if(!(r.y>r.scrollBottom||r.y<r.scrollTop)){var i,n=r.y+r.ybase;for(i=this._bufferService.rows-1-r.scrollBottom,i=this._bufferService.rows-1+r.ybase-i;t--;)r.lines.splice(n,1),r.lines.splice(i,0,r.getBlankLine(this._eraseAttrData()));this._dirtyRowService.markRangeDirty(r.y,r.scrollBottom),r.x=0}},t.prototype.insertChars=function(e){this._restrictCursor();var t=this._bufferService.buffer.lines.get(this._bufferService.buffer.y+this._bufferService.buffer.ybase);t&&(t.insertCells(this._bufferService.buffer.x,e.params[0]||1,this._bufferService.buffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowService.markDirty(this._bufferService.buffer.y))},t.prototype.deleteChars=function(e){this._restrictCursor();var t=this._bufferService.buffer.lines.get(this._bufferService.buffer.y+this._bufferService.buffer.ybase);t&&(t.deleteCells(this._bufferService.buffer.x,e.params[0]||1,this._bufferService.buffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowService.markDirty(this._bufferService.buffer.y))},t.prototype.scrollUp=function(e){for(var t=e.params[0]||1,r=this._bufferService.buffer;t--;)r.lines.splice(r.ybase+r.scrollTop,1),r.lines.splice(r.ybase+r.scrollBottom,0,r.getBlankLine(this._eraseAttrData()));this._dirtyRowService.markRangeDirty(r.scrollTop,r.scrollBottom)},t.prototype.scrollDown=function(e){for(var t=e.params[0]||1,r=this._bufferService.buffer;t--;)r.lines.splice(r.ybase+r.scrollBottom,1),r.lines.splice(r.ybase+r.scrollTop,0,r.getBlankLine(u.DEFAULT_ATTR_DATA));this._dirtyRowService.markRangeDirty(r.scrollTop,r.scrollBottom)},t.prototype.scrollLeft=function(e){var t=this._bufferService.buffer;if(!(t.y>t.scrollBottom||t.y<t.scrollTop)){for(var r=e.params[0]||1,i=t.scrollTop;i<=t.scrollBottom;++i){var n=t.lines.get(t.ybase+i);n.deleteCells(0,r,t.getNullCell(this._eraseAttrData()),this._eraseAttrData()),n.isWrapped=!1}this._dirtyRowService.markRangeDirty(t.scrollTop,t.scrollBottom)}},t.prototype.scrollRight=function(e){var t=this._bufferService.buffer;if(!(t.y>t.scrollBottom||t.y<t.scrollTop)){for(var r=e.params[0]||1,i=t.scrollTop;i<=t.scrollBottom;++i){var n=t.lines.get(t.ybase+i);n.insertCells(0,r,t.getNullCell(this._eraseAttrData()),this._eraseAttrData()),n.isWrapped=!1}this._dirtyRowService.markRangeDirty(t.scrollTop,t.scrollBottom)}},t.prototype.insertColumns=function(e){var t=this._bufferService.buffer;if(!(t.y>t.scrollBottom||t.y<t.scrollTop)){for(var r=e.params[0]||1,i=t.scrollTop;i<=t.scrollBottom;++i){var n=this._bufferService.buffer.lines.get(t.ybase+i);n.insertCells(t.x,r,t.getNullCell(this._eraseAttrData()),this._eraseAttrData()),n.isWrapped=!1}this._dirtyRowService.markRangeDirty(t.scrollTop,t.scrollBottom)}},t.prototype.deleteColumns=function(e){var t=this._bufferService.buffer;if(!(t.y>t.scrollBottom||t.y<t.scrollTop)){for(var r=e.params[0]||1,i=t.scrollTop;i<=t.scrollBottom;++i){var n=t.lines.get(t.ybase+i);n.deleteCells(t.x,r,t.getNullCell(this._eraseAttrData()),this._eraseAttrData()),n.isWrapped=!1}this._dirtyRowService.markRangeDirty(t.scrollTop,t.scrollBottom)}},t.prototype.eraseChars=function(e){this._restrictCursor();var t=this._bufferService.buffer.lines.get(this._bufferService.buffer.y+this._bufferService.buffer.ybase);t&&(t.replaceCells(this._bufferService.buffer.x,this._bufferService.buffer.x+(e.params[0]||1),this._bufferService.buffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowService.markDirty(this._bufferService.buffer.y))},t.prototype.repeatPrecedingCharacter=function(e){if(this._parser.precedingCodepoint){for(var t=e.params[0]||1,r=new Uint32Array(t),i=0;i<t;++i)r[i]=this._parser.precedingCodepoint;this.print(r,0,r.length)}},t.prototype.sendDeviceAttributesPrimary=function(e){e.params[0]>0||(this._terminal.is("xterm")||this._terminal.is("rxvt-unicode")||this._terminal.is("screen")?this._coreService.triggerDataEvent(o.C0.ESC+"[?1;2c"):this._terminal.is("linux")&&this._coreService.triggerDataEvent(o.C0.ESC+"[?6c"))},t.prototype.sendDeviceAttributesSecondary=function(e){e.params[0]>0||(this._terminal.is("xterm")?this._coreService.triggerDataEvent(o.C0.ESC+"[>0;276;0c"):this._terminal.is("rxvt-unicode")?this._coreService.triggerDataEvent(o.C0.ESC+"[>85;95;0c"):this._terminal.is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._terminal.is("screen")&&this._coreService.triggerDataEvent(o.C0.ESC+"[>83;40003;0c"))},t.prototype.setMode=function(e){for(var t=0;t<e.length;t++)switch(e.params[t]){case 4:this._terminal.insertMode=!0}},t.prototype.setModePrivate=function(e){for(var t,r,i=0;i<e.length;i++)switch(e.params[i]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,s.DEFAULT_CHARSET),this._charsetService.setgCharset(1,s.DEFAULT_CHARSET),this._charsetService.setgCharset(2,s.DEFAULT_CHARSET),this._charsetService.setgCharset(3,s.DEFAULT_CHARSET);break;case 3:this._optionsService.options.windowOptions.setWinLines&&(this._terminal.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,null===(t=this._terminal.viewport)||void 0===t||t.syncScrollArea();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._terminal.sendFocus=!0;break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),null===(r=this._terminal.viewport)||void 0===r||r.syncScrollArea(),this._terminal.showCursor();break;case 2004:this._terminal.bracketedPasteMode=!0}},t.prototype.resetMode=function(e){for(var t=0;t<e.length;t++)switch(e.params[t]){case 4:this._terminal.insertMode=!1}},t.prototype.resetModePrivate=function(e){for(var t,r,i=0;i<e.length;i++)switch(e.params[i]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.options.windowOptions.setWinLines&&(this._terminal.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,null===(t=this._terminal.viewport)||void 0===t||t.syncScrollArea();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._terminal.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),1049===e.params[i]&&this.restoreCursor(),this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),null===(r=this._terminal.viewport)||void 0===r||r.syncScrollArea(),this._terminal.showCursor();break;case 2004:this._terminal.bracketedPasteMode=!1}},t.prototype._extractColor=function(e,t,r){var i=[0,0,-1,0,0,0],n=0,o=0;do{if(i[o+n]=e.params[t+o],e.hasSubParams(t+o)){var s=e.getSubParams(t+o),a=0;do{5===i[1]&&(n=1),i[o+a+1+n]=s[a]}while(++a<s.length&&a+o+1+n<i.length);break}if(5===i[1]&&o+n>=2||2===i[1]&&o+n>=5)break;i[1]&&(n=1)}while(++o+t<e.length&&o+n<i.length);for(a=2;a<i.length;++a)-1===i[a]&&(i[a]=0);return 38===i[0]?2===i[1]?(r.fg|=50331648,r.fg&=-16777216,r.fg|=p.AttributeData.fromColorRGB([i[3],i[4],i[5]])):5===i[1]&&(r.fg&=-50331904,r.fg|=33554432|255&i[3]):48===i[0]&&(2===i[1]?(r.bg|=50331648,r.bg&=-16777216,r.bg|=p.AttributeData.fromColorRGB([i[3],i[4],i[5]])):5===i[1]&&(r.bg&=-50331904,r.bg|=33554432|255&i[3])),o},t.prototype.charAttributes=function(e){if(1===e.length&&0===e.params[0])return this._curAttrData.fg=u.DEFAULT_ATTR_DATA.fg,void(this._curAttrData.bg=u.DEFAULT_ATTR_DATA.bg);for(var t,r=e.length,i=this._curAttrData,n=0;n<r;n++)(t=e.params[n])>=30&&t<=37?(i.fg&=-50331904,i.fg|=16777216|t-30):t>=40&&t<=47?(i.bg&=-50331904,i.bg|=16777216|t-40):t>=90&&t<=97?(i.fg&=-50331904,i.fg|=16777224|t-90):t>=100&&t<=107?(i.bg&=-50331904,i.bg|=16777224|t-100):0===t?(i.fg=u.DEFAULT_ATTR_DATA.fg,i.bg=u.DEFAULT_ATTR_DATA.bg):1===t?i.fg|=134217728:3===t?i.bg|=67108864:4===t?i.fg|=268435456:5===t?i.fg|=536870912:7===t?i.fg|=67108864:8===t?i.fg|=1073741824:2===t?i.bg|=134217728:22===t?(i.fg&=-134217729,i.bg&=-134217729):23===t?i.bg&=-67108865:24===t?i.fg&=-268435457:25===t?i.fg&=-536870913:27===t?i.fg&=-67108865:28===t?i.fg&=-1073741825:39===t?(i.fg&=-67108864,i.fg|=16777215&u.DEFAULT_ATTR_DATA.fg):49===t?(i.bg&=-67108864,i.bg|=16777215&u.DEFAULT_ATTR_DATA.bg):38===t||48===t?n+=this._extractColor(e,n,i):100===t?(i.fg&=-67108864,i.fg|=16777215&u.DEFAULT_ATTR_DATA.fg,i.bg&=-67108864,i.bg|=16777215&u.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",t)},t.prototype.deviceStatus=function(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(o.C0.ESC+"[0n");break;case 6:var t=this._bufferService.buffer.y+1,r=this._bufferService.buffer.x+1;this._coreService.triggerDataEvent(o.C0.ESC+"["+t+";"+r+"R")}},t.prototype.deviceStatusPrivate=function(e){switch(e.params[0]){case 6:var t=this._bufferService.buffer.y+1,r=this._bufferService.buffer.x+1;this._coreService.triggerDataEvent(o.C0.ESC+"[?"+t+";"+r+"R")}},t.prototype.softReset=function(e){var t;this._coreService.isCursorHidden=!1,this._terminal.insertMode=!1,null===(t=this._terminal.viewport)||void 0===t||t.syncScrollArea(),this._bufferService.buffer.scrollTop=0,this._bufferService.buffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=u.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._bufferService.buffer.savedX=0,this._bufferService.buffer.savedY=this._bufferService.buffer.ybase,this._bufferService.buffer.savedCurAttrData.fg=this._curAttrData.fg,this._bufferService.buffer.savedCurAttrData.bg=this._curAttrData.bg,this._bufferService.buffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1},t.prototype.setCursorStyle=function(e){var t=e.params[0]||1;switch(t){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}var r=t%2==1;this._optionsService.options.cursorBlink=r},t.prototype.setScrollRegion=function(e){var t,r=e.params[0]||1;(e.length<2||(t=e.params[1])>this._bufferService.rows||0===t)&&(t=this._bufferService.rows),t>r&&(this._bufferService.buffer.scrollTop=r-1,this._bufferService.buffer.scrollBottom=t-1,this._setCursor(0,0))},t.prototype.windowOptions=function(e){if(m(e.params[0],this._optionsService.options.windowOptions)){var t=e.length>1?e.params[1]:0,r=this._instantiationService.getService(y.IRenderService);switch(e.params[0]){case 14:if(r&&2!==t){console.log(r.dimensions);var i=r.dimensions.scaledCanvasWidth.toFixed(0),n=r.dimensions.scaledCanvasHeight.toFixed(0);this._coreService.triggerDataEvent(o.C0.ESC+"[4;"+n+";"+i+"t")}break;case 16:if(r){i=r.dimensions.scaledCellWidth.toFixed(0),n=r.dimensions.scaledCellHeight.toFixed(0);this._coreService.triggerDataEvent(o.C0.ESC+"[6;"+n+";"+i+"t")}break;case 18:this._bufferService&&this._coreService.triggerDataEvent(o.C0.ESC+"[8;"+this._bufferService.rows+";"+this._bufferService.cols+"t");break;case 22:0!==t&&2!==t||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),0!==t&&1!==t||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:0!==t&&2!==t||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),0!==t&&1!==t||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}}},t.prototype.saveCursor=function(e){this._bufferService.buffer.savedX=this._bufferService.buffer.x,this._bufferService.buffer.savedY=this._bufferService.buffer.ybase+this._bufferService.buffer.y,this._bufferService.buffer.savedCurAttrData.fg=this._curAttrData.fg,this._bufferService.buffer.savedCurAttrData.bg=this._curAttrData.bg,this._bufferService.buffer.savedCharset=this._charsetService.charset},t.prototype.restoreCursor=function(e){this._bufferService.buffer.x=this._bufferService.buffer.savedX||0,this._bufferService.buffer.y=Math.max(this._bufferService.buffer.savedY-this._bufferService.buffer.ybase,0),this._curAttrData.fg=this._bufferService.buffer.savedCurAttrData.fg,this._curAttrData.bg=this._bufferService.buffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._bufferService.buffer.savedCharset&&(this._charsetService.charset=this._bufferService.buffer.savedCharset),this._restrictCursor()},t.prototype.setTitle=function(e){this._windowTitle=e,this._terminal.handleTitle(e)},t.prototype.setIconName=function(e){this._iconName=e},t.prototype.nextLine=function(){this._bufferService.buffer.x=0,this.index()},t.prototype.keypadApplicationMode=function(){var e;this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,null===(e=this._terminal.viewport)||void 0===e||e.syncScrollArea()},t.prototype.keypadNumericMode=function(){var e;this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,null===(e=this._terminal.viewport)||void 0===e||e.syncScrollArea()},t.prototype.selectDefaultCharset=function(){this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,s.DEFAULT_CHARSET)},t.prototype.selectCharset=function(e){2===e.length?"/"!==e[0]&&this._charsetService.setgCharset(b[e[0]],s.CHARSETS[e[1]]||s.DEFAULT_CHARSET):this.selectDefaultCharset()},t.prototype.index=function(){this._restrictCursor();var e=this._bufferService.buffer;this._bufferService.buffer.y++,e.y===e.scrollBottom+1?(e.y--,this._terminal.scroll(this._eraseAttrData())):e.y>=this._bufferService.rows&&(e.y=this._bufferService.rows-1),this._restrictCursor()},t.prototype.tabSet=function(){this._bufferService.buffer.tabs[this._bufferService.buffer.x]=!0},t.prototype.reverseIndex=function(){this._restrictCursor();var e=this._bufferService.buffer;if(e.y===e.scrollTop){var t=e.scrollBottom-e.scrollTop;e.lines.shiftElements(e.y+e.ybase,t,1),e.lines.set(e.y+e.ybase,e.getBlankLine(this._eraseAttrData())),this._dirtyRowService.markRangeDirty(e.scrollTop,e.scrollBottom)}else e.y--,this._restrictCursor()},t.prototype.fullReset=function(){this._parser.reset(),this._onRequestReset.fire()},t.prototype.reset=function(){this._curAttrData=u.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=u.DEFAULT_ATTR_DATA.clone()},t.prototype._eraseAttrData=function(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal},t.prototype.setgLevel=function(e){this._charsetService.setgLevel(e)},t.prototype.screenAlignmentPattern=function(){var e=new d.CellData;e.content=1<<22|"E".charCodeAt(0),e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg;var t=this._bufferService.buffer;this._setCursor(0,0);for(var r=0;r<this._bufferService.rows;++r){var i=t.y+t.ybase+r;t.lines.get(i).fill(e),t.lines.get(i).isWrapped=!1}this._dirtyRowService.markAllDirty(),this._setCursor(0,0)},t}(c.Disposable);t.InputHandler=C},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(2),s=r(15),a=r(19),c=r(20),l=r(22),h=function(){function e(e){this.table=new Uint8Array(e)}return e.prototype.setDefault=function(e,t){s.fill(this.table,e<<4|t)},e.prototype.add=function(e,t,r,i){this.table[t<<8|e]=r<<4|i},e.prototype.addMany=function(e,t,r,i){for(var n=0;n<e.length;n++)this.table[t<<8|e[n]]=r<<4|i},e}();t.TransitionTable=h;t.VT500_TRANSITION_TABLE=function(){var e=new h(4095),t=Array.apply(null,Array(256)).map((function(e,t){return t})),r=function(e,r){return t.slice(e,r)},i=r(32,127),n=r(0,24);n.push(25),n.push.apply(n,r(28,32));var o,s=r(0,14);for(o in e.setDefault(1,0),e.addMany(i,0,2,0),s)e.addMany([24,26,153,154],o,3,0),e.addMany(r(128,144),o,3,0),e.addMany(r(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(n,0,3,0),e.addMany(n,1,3,1),e.add(127,1,0,1),e.addMany(n,8,0,8),e.addMany(n,3,3,3),e.add(127,3,0,3),e.addMany(n,4,3,4),e.add(127,4,0,4),e.addMany(n,6,3,6),e.addMany(n,5,3,5),e.add(127,5,0,5),e.addMany(n,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(i,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(r(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(i,7,0,7),e.addMany(n,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(r(64,127),3,7,0),e.addMany(r(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(r(48,60),4,8,4),e.addMany(r(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(r(32,64),6,0,6),e.add(127,6,0,6),e.addMany(r(64,127),6,0,0),e.addMany(r(32,48),3,9,5),e.addMany(r(32,48),5,9,5),e.addMany(r(48,64),5,0,6),e.addMany(r(64,127),5,7,0),e.addMany(r(32,48),4,9,5),e.addMany(r(32,48),1,9,2),e.addMany(r(32,48),2,9,2),e.addMany(r(48,127),2,10,0),e.addMany(r(48,80),1,10,0),e.addMany(r(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(r(96,127),1,10,0),e.add(80,1,11,9),e.addMany(n,9,0,9),e.add(127,9,0,9),e.addMany(r(28,32),9,0,9),e.addMany(r(32,48),9,9,12),e.addMany(r(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(n,11,0,11),e.addMany(r(32,128),11,0,11),e.addMany(r(28,32),11,0,11),e.addMany(n,10,0,10),e.add(127,10,0,10),e.addMany(r(28,32),10,0,10),e.addMany(r(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(r(32,48),10,9,12),e.addMany(n,12,0,12),e.add(127,12,0,12),e.addMany(r(28,32),12,0,12),e.addMany(r(32,48),12,9,12),e.addMany(r(48,64),12,0,11),e.addMany(r(64,127),12,12,13),e.addMany(r(64,127),10,12,13),e.addMany(r(64,127),9,12,13),e.addMany(n,13,13,13),e.addMany(i,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(160,0,2,0),e.add(160,8,5,8),e.add(160,6,0,6),e.add(160,11,0,11),e.add(160,13,13,13),e}();var u=function(e){function r(r){void 0===r&&(r=t.VT500_TRANSITION_TABLE);var i=e.call(this)||this;return i._transitions=r,i.initialState=0,i.currentState=i.initialState,i._params=new a.Params,i._params.addParam(0),i._collect=0,i.precedingCodepoint=0,i._printHandlerFb=function(e,t,r){},i._executeHandlerFb=function(e){},i._csiHandlerFb=function(e,t){},i._escHandlerFb=function(e){},i._errorHandlerFb=function(e){return e},i._printHandler=i._printHandlerFb,i._executeHandlers=Object.create(null),i._csiHandlers=Object.create(null),i._escHandlers=Object.create(null),i._oscParser=new c.OscParser,i._dcsParser=new l.DcsParser,i._errorHandler=i._errorHandlerFb,i.setEscHandler({final:"\\"},(function(){})),i}return n(r,e),r.prototype._identifier=function(e,t){void 0===t&&(t=[64,126]);var r=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if((r=e.prefix.charCodeAt(0))&&60>r||r>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(var i=0;i<e.intermediates.length;++i){var n=e.intermediates.charCodeAt(i);if(32>n||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");r<<=8,r|=n}}if(1!==e.final.length)throw new Error("final must be a single byte");var o=e.final.charCodeAt(0);if(t[0]>o||o>t[1])throw new Error("final must be in range "+t[0]+" .. "+t[1]);return r<<=8,r|=o},r.prototype.identToString=function(e){for(var t=[];e;)t.push(String.fromCharCode(255&e)),e>>=8;return t.reverse().join("")},r.prototype.dispose=function(){this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null),this._oscParser.dispose(),this._dcsParser.dispose()},r.prototype.setPrintHandler=function(e){this._printHandler=e},r.prototype.clearPrintHandler=function(){this._printHandler=this._printHandlerFb},r.prototype.addEscHandler=function(e,t){var r=this._identifier(e,[48,126]);void 0===this._escHandlers[r]&&(this._escHandlers[r]=[]);var i=this._escHandlers[r];return i.push(t),{dispose:function(){var e=i.indexOf(t);-1!==e&&i.splice(e,1)}}},r.prototype.setEscHandler=function(e,t){this._escHandlers[this._identifier(e,[48,126])]=[t]},r.prototype.clearEscHandler=function(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]},r.prototype.setEscHandlerFallback=function(e){this._escHandlerFb=e},r.prototype.setExecuteHandler=function(e,t){this._executeHandlers[e.charCodeAt(0)]=t},r.prototype.clearExecuteHandler=function(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]},r.prototype.setExecuteHandlerFallback=function(e){this._executeHandlerFb=e},r.prototype.addCsiHandler=function(e,t){var r=this._identifier(e);void 0===this._csiHandlers[r]&&(this._csiHandlers[r]=[]);var i=this._csiHandlers[r];return i.push(t),{dispose:function(){var e=i.indexOf(t);-1!==e&&i.splice(e,1)}}},r.prototype.setCsiHandler=function(e,t){this._csiHandlers[this._identifier(e)]=[t]},r.prototype.clearCsiHandler=function(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]},r.prototype.setCsiHandlerFallback=function(e){this._csiHandlerFb=e},r.prototype.addDcsHandler=function(e,t){return this._dcsParser.addHandler(this._identifier(e),t)},r.prototype.setDcsHandler=function(e,t){this._dcsParser.setHandler(this._identifier(e),t)},r.prototype.clearDcsHandler=function(e){this._dcsParser.clearHandler(this._identifier(e))},r.prototype.setDcsHandlerFallback=function(e){this._dcsParser.setHandlerFallback(e)},r.prototype.addOscHandler=function(e,t){return this._oscParser.addHandler(e,t)},r.prototype.setOscHandler=function(e,t){this._oscParser.setHandler(e,t)},r.prototype.clearOscHandler=function(e){this._oscParser.clearHandler(e)},r.prototype.setOscHandlerFallback=function(e){this._oscParser.setHandlerFallback(e)},r.prototype.setErrorHandler=function(e){this._errorHandler=e},r.prototype.clearErrorHandler=function(){this._errorHandler=this._errorHandlerFb},r.prototype.reset=function(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0},r.prototype.parse=function(e,t){for(var r=0,i=0,n=this.currentState,o=this._oscParser,s=this._dcsParser,a=this._collect,c=this._params,l=this._transitions.table,h=0;h<t;++h){switch((i=l[n<<8|((r=e[h])<160?r:160)])>>4){case 2:for(var u=h+1;;++u){if(u>=t||(r=e[u])<32||r>126&&r<160){this._printHandler(e,h,u),h=u-1;break}if(++u>=t||(r=e[u])<32||r>126&&r<160){this._printHandler(e,h,u),h=u-1;break}if(++u>=t||(r=e[u])<32||r>126&&r<160){this._printHandler(e,h,u),h=u-1;break}if(++u>=t||(r=e[u])<32||r>126&&r<160){this._printHandler(e,h,u),h=u-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:h,code:r,currentState:n,collect:a,params:c,abort:!1}).abort)return;break;case 7:for(var f=this._csiHandlers[a<<8|r],_=f?f.length-1:-1;_>=0&&!1===f[_](c);_--);_<0&&this._csiHandlerFb(a<<8|r,c),this.precedingCodepoint=0;break;case 8:do{switch(r){case 59:c.addParam(0);break;case 58:c.addSubParam(-1);break;default:c.addDigit(r-48)}}while(++h<t&&(r=e[h])>47&&r<60);h--;break;case 9:a<<=8,a|=r;break;case 10:for(var d=this._escHandlers[a<<8|r],p=d?d.length-1:-1;p>=0&&!1===d[p]();p--);p<0&&this._escHandlerFb(a<<8|r),this.precedingCodepoint=0;break;case 11:c.reset(),c.addParam(0),a=0;break;case 12:s.hook(a<<8|r,c);break;case 13:for(var v=h+1;;++v)if(v>=t||24===(r=e[v])||26===r||27===r||r>127&&r<160){s.put(e,h,v),h=v-1;break}break;case 14:s.unhook(24!==r&&26!==r),27===r&&(i|=1),c.reset(),c.addParam(0),a=0,this.precedingCodepoint=0;break;case 4:o.start();break;case 5:for(var g=h+1;;g++)if(g>=t||(r=e[g])<32||r>127&&r<=159){o.put(e,h,g),h=g-1;break}break;case 6:o.end(24!==r&&26!==r),27===r&&(i|=1),c.reset(),c.addParam(0),a=0,this.precedingCodepoint=0}n=15&i}this._collect=a,this.currentState=n},r}(o.Disposable);t.EscapeSequenceParser=u},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var a=r(40),c=r(46),l=r(47),h=r(48),u=r(27),f=r(2),_=r(4),d=r(1),p=r(23),v=r(0),g=1,y=function(e){function t(t,r,i,n,o,s,f,_,d){var p=e.call(this)||this;p._colors=t,p._screenElement=r,p.linkifier=i,p.linkifier2=n,p._bufferService=o,p._charSizeService=s,p._optionsService=f,p.coreService=_,p.coreBrowserService=d,p._id=g++,p._onRequestRefreshRows=new v.EventEmitter;var y=p._optionsService.options.allowTransparency;return p._characterJoinerRegistry=new u.CharacterJoinerRegistry(p._bufferService),p._renderLayers=[new a.TextRenderLayer(p._screenElement,0,p._colors,p._characterJoinerRegistry,y,p._id,p._bufferService,f),new c.SelectionRenderLayer(p._screenElement,1,p._colors,p._id,p._bufferService,f),new h.LinkRenderLayer(p._screenElement,2,p._colors,p._id,i,n,p._bufferService,f),new l.CursorRenderLayer(p._screenElement,3,p._colors,p._id,p._onRequestRefreshRows,p._bufferService,f,_,d)],p.dimensions={scaledCharWidth:0,scaledCharHeight:0,scaledCellWidth:0,scaledCellHeight:0,scaledCharLeft:0,scaledCharTop:0,scaledCanvasWidth:0,scaledCanvasHeight:0,canvasWidth:0,canvasHeight:0,actualCellWidth:0,actualCellHeight:0},p._devicePixelRatio=window.devicePixelRatio,p._updateDimensions(),p.onOptionsChanged(),p}return n(t,e),Object.defineProperty(t.prototype,"onRequestRefreshRows",{get:function(){return this._onRequestRefreshRows.event},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){e.prototype.dispose.call(this),this._renderLayers.forEach((function(e){return e.dispose()})),p.removeTerminalFromCache(this._id)},t.prototype.onDevicePixelRatioChange=function(){this._devicePixelRatio!==window.devicePixelRatio&&(this._devicePixelRatio=window.devicePixelRatio,this.onResize(this._bufferService.cols,this._bufferService.rows))},t.prototype.setColors=function(e){var t=this;this._colors=e,this._renderLayers.forEach((function(e){e.setColors(t._colors),e.reset()}))},t.prototype.onResize=function(e,t){var r=this;this._updateDimensions(),this._renderLayers.forEach((function(e){return e.resize(r.dimensions)})),this._screenElement.style.width=this.dimensions.canvasWidth+"px",this._screenElement.style.height=this.dimensions.canvasHeight+"px"},t.prototype.onCharSizeChanged=function(){this.onResize(this._bufferService.cols,this._bufferService.rows)},t.prototype.onBlur=function(){this._runOperation((function(e){return e.onBlur()}))},t.prototype.onFocus=function(){this._runOperation((function(e){return e.onFocus()}))},t.prototype.onSelectionChanged=function(e,t,r){void 0===r&&(r=!1),this._runOperation((function(i){return i.onSelectionChanged(e,t,r)}))},t.prototype.onCursorMove=function(){this._runOperation((function(e){return e.onCursorMove()}))},t.prototype.onOptionsChanged=function(){this._runOperation((function(e){return e.onOptionsChanged()}))},t.prototype.clear=function(){this._runOperation((function(e){return e.reset()}))},t.prototype._runOperation=function(e){this._renderLayers.forEach((function(t){return e(t)}))},t.prototype.renderRows=function(e,t){this._renderLayers.forEach((function(r){return r.onGridChanged(e,t)}))},t.prototype._updateDimensions=function(){this._charSizeService.hasValidSize&&(this.dimensions.scaledCharWidth=Math.floor(this._charSizeService.width*window.devicePixelRatio),this.dimensions.scaledCharHeight=Math.ceil(this._charSizeService.height*window.devicePixelRatio),this.dimensions.scaledCellHeight=Math.floor(this.dimensions.scaledCharHeight*this._optionsService.options.lineHeight),this.dimensions.scaledCharTop=1===this._optionsService.options.lineHeight?0:Math.round((this.dimensions.scaledCellHeight-this.dimensions.scaledCharHeight)/2),this.dimensions.scaledCellWidth=this.dimensions.scaledCharWidth+Math.round(this._optionsService.options.letterSpacing),this.dimensions.scaledCharLeft=Math.floor(this._optionsService.options.letterSpacing/2),this.dimensions.scaledCanvasHeight=this._bufferService.rows*this.dimensions.scaledCellHeight,this.dimensions.scaledCanvasWidth=this._bufferService.cols*this.dimensions.scaledCellWidth,this.dimensions.canvasHeight=Math.round(this.dimensions.scaledCanvasHeight/window.devicePixelRatio),this.dimensions.canvasWidth=Math.round(this.dimensions.scaledCanvasWidth/window.devicePixelRatio),this.dimensions.actualCellHeight=this.dimensions.canvasHeight/this._bufferService.rows,this.dimensions.actualCellWidth=this.dimensions.canvasWidth/this._bufferService.cols)},t.prototype.registerCharacterJoiner=function(e){return this._characterJoinerRegistry.registerCharacterJoiner(e)},t.prototype.deregisterCharacterJoiner=function(e){return this._characterJoinerRegistry.deregisterCharacterJoiner(e)},t=o([s(4,d.IBufferService),s(5,_.ICharSizeService),s(6,d.IOptionsService),s(7,d.ICoreService),s(8,_.ICoreBrowserService)],t)}(f.Disposable);t.Renderer=y},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(41),s=r(13),a=r(6),c=r(3),l=r(27),h=r(5),u=function(e){function t(t,r,i,n,s,a,c,l){var u=e.call(this,t,"text",r,s,i,a,c,l)||this;return u.bufferService=c,u.optionsService=l,u._characterWidth=0,u._characterFont="",u._characterOverlapCache={},u._workCell=new h.CellData,u._state=new o.GridCache,u._characterJoinerRegistry=n,u}return n(t,e),t.prototype.resize=function(t){e.prototype.resize.call(this,t);var r=this._getFont(!1,!1);this._characterWidth===t.scaledCharWidth&&this._characterFont===r||(this._characterWidth=t.scaledCharWidth,this._characterFont=r,this._characterOverlapCache={}),this._state.clear(),this._state.resize(this._bufferService.cols,this._bufferService.rows)},t.prototype.reset=function(){this._state.clear(),this._clearAll()},t.prototype._forEachCell=function(e,t,r,i){for(var n=e;n<=t;n++)for(var o=n+this._bufferService.buffer.ydisp,s=this._bufferService.buffer.lines.get(o),a=r?r.getJoinedCharacters(o):[],h=0;h<this._bufferService.cols;h++){s.loadCell(h,this._workCell);var u=this._workCell,f=!1,_=h;if(0!==u.getWidth()){if(a.length>0&&h===a[0][0]){f=!0;var d=a.shift();u=new l.JoinedCellData(this._workCell,s.translateToString(!0,d[0],d[1]),d[1]-d[0]),_=d[1]-1}!f&&this._isOverlapping(u)&&_<s.length-1&&s.getCodePoint(_+1)===c.NULL_CELL_CODE&&(u.content&=-12582913,u.content|=2<<22),i(u,h,n),h=_}}},t.prototype._drawBackground=function(e,t){var r=this,i=this._ctx,n=this._bufferService.cols,o=0,s=0,c=null;i.save(),this._forEachCell(e,t,null,(function(e,t,l){var h=null;e.isInverse()?h=e.isFgDefault()?r._colors.foreground.css:e.isFgRGB()?"rgb("+a.AttributeData.toColorRGB(e.getFgColor()).join(",")+")":r._colors.ansi[e.getFgColor()].css:e.isBgRGB()?h="rgb("+a.AttributeData.toColorRGB(e.getBgColor()).join(",")+")":e.isBgPalette()&&(h=r._colors.ansi[e.getBgColor()].css),null===c&&(o=t,s=l),l!==s?(i.fillStyle=c||"",r._fillCells(o,s,n-o,1),o=t,s=l):c!==h&&(i.fillStyle=c||"",r._fillCells(o,s,t-o,1),o=t,s=l),c=h})),null!==c&&(i.fillStyle=c,this._fillCells(o,s,n-o,1)),i.restore()},t.prototype._drawForeground=function(e,t){var r=this;this._forEachCell(e,t,this._characterJoinerRegistry,(function(e,t,i){if(!e.isInvisible()&&(r._drawChars(e,t,i),e.isUnderline())){if(r._ctx.save(),e.isInverse())if(e.isBgDefault())r._ctx.fillStyle=r._colors.background.css;else if(e.isBgRGB())r._ctx.fillStyle="rgb("+a.AttributeData.toColorRGB(e.getBgColor()).join(",")+")";else{var n=e.getBgColor();r._optionsService.options.drawBoldTextInBrightColors&&e.isBold()&&n<8&&(n+=8),r._ctx.fillStyle=r._colors.ansi[n].css}else if(e.isFgDefault())r._ctx.fillStyle=r._colors.foreground.css;else if(e.isFgRGB())r._ctx.fillStyle="rgb("+a.AttributeData.toColorRGB(e.getFgColor()).join(",")+")";else{var o=e.getFgColor();r._optionsService.options.drawBoldTextInBrightColors&&e.isBold()&&o<8&&(o+=8),r._ctx.fillStyle=r._colors.ansi[o].css}r._fillBottomLineAtCells(t,i,e.getWidth()),r._ctx.restore()}}))},t.prototype.onGridChanged=function(e,t){0!==this._state.cache.length&&(this._charAtlas&&this._charAtlas.beginFrame(),this._clearCells(0,e,this._bufferService.cols,t-e+1),this._drawBackground(e,t),this._drawForeground(e,t))},t.prototype.onOptionsChanged=function(){this._setTransparency(this._optionsService.options.allowTransparency)},t.prototype._isOverlapping=function(e){if(1!==e.getWidth())return!1;if(e.getCode()<256)return!1;var t=e.getChars();if(this._characterOverlapCache.hasOwnProperty(t))return this._characterOverlapCache[t];this._ctx.save(),this._ctx.font=this._characterFont;var r=Math.floor(this._ctx.measureText(t).width)>this._characterWidth;return this._ctx.restore(),this._characterOverlapCache[t]=r,r},t}(s.BaseRenderLayer);t.TextRenderLayer=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){this.cache=[]}return e.prototype.resize=function(e,t){for(var r=0;r<e;r++){this.cache.length<=r&&this.cache.push([]);for(var i=this.cache[r].length;i<t;i++)this.cache[r].push(void 0);this.cache[r].length=t}this.cache.length=e},e.prototype.clear=function(){for(var e=0;e<this.cache.length;e++)for(var t=0;t<this.cache[e].length;t++)this.cache[e][t]=void 0},e}();t.GridCache=i},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(9),s=r(43),a=r(25),c=r(45),l=r(11),h=r(26),u=r(10),f={css:"rgba(0, 0, 0, 0)",rgba:0};function _(e){return e.code<<21|e.bg<<12|e.fg<<3|(e.bold?0:4)+(e.dim?0:2)+(e.italic?0:1)}t.getGlyphCacheKey=_;var d=function(e){function t(t,r){var i=e.call(this)||this;i._config=r,i._drawToCacheCount=0,i._glyphsWaitingOnBitmap=[],i._bitmapCommitTimeout=null,i._bitmap=null,i._cacheCanvas=t.createElement("canvas"),i._cacheCanvas.width=1024,i._cacheCanvas.height=1024,i._cacheCtx=h.throwIfFalsy(i._cacheCanvas.getContext("2d",{alpha:!0}));var n=t.createElement("canvas");n.width=i._config.scaledCharWidth,n.height=i._config.scaledCharHeight,i._tmpCtx=h.throwIfFalsy(n.getContext("2d",{alpha:i._config.allowTransparency})),i._width=Math.floor(1024/i._config.scaledCharWidth),i._height=Math.floor(1024/i._config.scaledCharHeight);var o=i._width*i._height;return i._cacheMap=new c.LRUMap(o),i._cacheMap.prealloc(o),i}return n(t,e),t.prototype.dispose=function(){null!==this._bitmapCommitTimeout&&(window.clearTimeout(this._bitmapCommitTimeout),this._bitmapCommitTimeout=null)},t.prototype.beginFrame=function(){this._drawToCacheCount=0},t.prototype.draw=function(e,t,r,i){if(32===t.code)return!0;if(!this._canCache(t))return!1;var n=_(t),o=this._cacheMap.get(n);if(null!=o)return this._drawFromCache(e,o,r,i),!0;if(this._drawToCacheCount<100){var s=void 0;s=this._cacheMap.size<this._cacheMap.capacity?this._cacheMap.size:this._cacheMap.peek().index;var a=this._drawToCache(t,s);return this._cacheMap.set(n,a),this._drawFromCache(e,a,r,i),!0}return!1},t.prototype._canCache=function(e){return e.code<256},t.prototype._toCoordinateX=function(e){return e%this._width*this._config.scaledCharWidth},t.prototype._toCoordinateY=function(e){return Math.floor(e/this._width)*this._config.scaledCharHeight},t.prototype._drawFromCache=function(e,t,r,i){if(!t.isEmpty){var n=this._toCoordinateX(t.index),o=this._toCoordinateY(t.index);e.drawImage(t.inBitmap?this._bitmap:this._cacheCanvas,n,o,this._config.scaledCharWidth,this._config.scaledCharHeight,r,i,this._config.scaledCharWidth,this._config.scaledCharHeight)}},t.prototype._getColorFromAnsiIndex=function(e){return e<this._config.colors.ansi.length?this._config.colors.ansi[e]:a.DEFAULT_ANSI_COLORS[e]},t.prototype._getBackgroundColor=function(e){return this._config.allowTransparency?f:e.bg===o.INVERTED_DEFAULT_COLOR?this._config.colors.foreground:e.bg<256?this._getColorFromAnsiIndex(e.bg):this._config.colors.background},t.prototype._getForegroundColor=function(e){return e.fg===o.INVERTED_DEFAULT_COLOR?u.color.opaque(this._config.colors.background):e.fg<256?this._getColorFromAnsiIndex(e.fg):this._config.colors.foreground},t.prototype._drawToCache=function(e,t){this._drawToCacheCount++,this._tmpCtx.save();var r=this._getBackgroundColor(e);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=r.css,this._tmpCtx.fillRect(0,0,this._config.scaledCharWidth,this._config.scaledCharHeight),this._tmpCtx.globalCompositeOperation="source-over";var i=e.bold?this._config.fontWeightBold:this._config.fontWeight,n=e.italic?"italic":"";this._tmpCtx.font=n+" "+i+" "+this._config.fontSize*this._config.devicePixelRatio+"px "+this._config.fontFamily,this._tmpCtx.textBaseline="middle",this._tmpCtx.fillStyle=this._getForegroundColor(e).css,e.dim&&(this._tmpCtx.globalAlpha=o.DIM_OPACITY),this._tmpCtx.fillText(e.chars,0,this._config.scaledCharHeight/2),this._tmpCtx.restore();var s=this._tmpCtx.getImageData(0,0,this._config.scaledCharWidth,this._config.scaledCharHeight),a=!1;this._config.allowTransparency||(a=function(e,t){for(var r=!0,i=t.rgba>>>24,n=t.rgba>>>16&255,o=t.rgba>>>8&255,s=0;s<e.data.length;s+=4)e.data[s]===i&&e.data[s+1]===n&&e.data[s+2]===o?e.data[s+3]=0:r=!1;return r}(s,r));var c=this._toCoordinateX(t),l=this._toCoordinateY(t);this._cacheCtx.putImageData(s,c,l);var h={index:t,isEmpty:a,inBitmap:!1};return this._addGlyphToBitmap(h),h},t.prototype._addGlyphToBitmap=function(e){var t=this;!("createImageBitmap"in window)||l.isFirefox||l.isSafari||(this._glyphsWaitingOnBitmap.push(e),null===this._bitmapCommitTimeout&&(this._bitmapCommitTimeout=window.setTimeout((function(){return t._generateBitmap()}),100)))},t.prototype._generateBitmap=function(){var e=this,t=this._glyphsWaitingOnBitmap;this._glyphsWaitingOnBitmap=[],window.createImageBitmap(this._cacheCanvas).then((function(r){e._bitmap=r;for(var i=0;i<t.length;i++){t[i].inBitmap=!0}})),this._bitmapCommitTimeout=null},t}(s.BaseCharAtlas);t.DynamicCharAtlas=d;var p=function(e){function t(t,r){return e.call(this)||this}return n(t,e),t.prototype.draw=function(e,t,r,i){return!1},t}(s.BaseCharAtlas);t.NoneCharAtlas=p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){this._didWarmUp=!1}return e.prototype.dispose=function(){},e.prototype.warmUp=function(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)},e.prototype._doWarmUp=function(){},e.prototype.beginFrame=function(){},e}();t.BaseCharAtlas=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){this._color={},this._rgba={}}return e.prototype.clear=function(){this._color={},this._rgba={}},e.prototype.setCss=function(e,t,r){this._rgba[e]||(this._rgba[e]={}),this._rgba[e][t]=r},e.prototype.getCss=function(e,t){return this._rgba[e]?this._rgba[e][t]:void 0},e.prototype.setColor=function(e,t,r){this._color[e]||(this._color[e]={}),this._color[e][t]=r},e.prototype.getColor=function(e,t){return this._color[e]?this._color[e][t]:void 0},e}();t.ColorContrastCache=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){this.capacity=e,this._map={},this._head=null,this._tail=null,this._nodePool=[],this.size=0}return e.prototype._unlinkNode=function(e){var t=e.prev,r=e.next;e===this._head&&(this._head=r),e===this._tail&&(this._tail=t),null!==t&&(t.next=r),null!==r&&(r.prev=t)},e.prototype._appendNode=function(e){var t=this._tail;null!==t&&(t.next=e),e.prev=t,e.next=null,this._tail=e,null===this._head&&(this._head=e)},e.prototype.prealloc=function(e){for(var t=this._nodePool,r=0;r<e;r++)t.push({prev:null,next:null,key:null,value:null})},e.prototype.get=function(e){var t=this._map[e];return void 0!==t?(this._unlinkNode(t),this._appendNode(t),t.value):null},e.prototype.peekValue=function(e){var t=this._map[e];return void 0!==t?t.value:null},e.prototype.peek=function(){var e=this._head;return null===e?null:e.value},e.prototype.set=function(e,t){var r=this._map[e];if(void 0!==r)r=this._map[e],this._unlinkNode(r),r.value=t;else if(this.size>=this.capacity)r=this._head,this._unlinkNode(r),delete this._map[r.key],r.key=e,r.value=t,this._map[e]=r;else{var i=this._nodePool;i.length>0?((r=i.pop()).key=e,r.value=t):r={prev:null,next:null,key:e,value:t},this._map[e]=r,this.size++}this._appendNode(r)},e}();t.LRUMap=i},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(t,r,i,n,o,s){var a=e.call(this,t,"selection",r,!0,i,n,o,s)||this;return a.bufferService=o,a.optionsService=s,a._clearState(),a}return n(t,e),t.prototype._clearState=function(){this._state={start:void 0,end:void 0,columnSelectMode:void 0,ydisp:void 0}},t.prototype.resize=function(t){e.prototype.resize.call(this,t),this._clearState()},t.prototype.reset=function(){this._state.start&&this._state.end&&(this._clearState(),this._clearAll())},t.prototype.onSelectionChanged=function(e,t,r){if(this._didStateChange(e,t,r,this._bufferService.buffer.ydisp))if(this._clearAll(),e&&t){var i=e[1]-this._bufferService.buffer.ydisp,n=t[1]-this._bufferService.buffer.ydisp,o=Math.max(i,0),s=Math.min(n,this._bufferService.rows-1);if(!(o>=this._bufferService.rows||s<0)){if(this._ctx.fillStyle=this._colors.selection.css,r){var a=e[0],c=t[0]-a,l=s-o+1;this._fillCells(a,o,c,l)}else{a=i===o?e[0]:0;var h=o===s?t[0]:this._bufferService.cols;this._fillCells(a,o,h-a,1);var u=Math.max(s-o-1,0);if(this._fillCells(0,o+1,this._bufferService.cols,u),o!==s){var f=n===s?t[0]:this._bufferService.cols;this._fillCells(0,s,f,1)}}this._state.start=[e[0],e[1]],this._state.end=[t[0],t[1]],this._state.columnSelectMode=r,this._state.ydisp=this._bufferService.buffer.ydisp}}else this._clearState()},t.prototype._didStateChange=function(e,t,r,i){return!this._areCoordinatesEqual(e,this._state.start)||!this._areCoordinatesEqual(t,this._state.end)||r!==this._state.columnSelectMode||i!==this._state.ydisp},t.prototype._areCoordinatesEqual=function(e,t){return!(!e||!t)&&(e[0]===t[0]&&e[1]===t[1])},t}(r(13).BaseRenderLayer);t.SelectionRenderLayer=o},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(13),s=r(5),a=function(e){function t(t,r,i,n,o,a,c,l,h){var u=e.call(this,t,"cursor",r,!0,i,n,a,c)||this;return u._onRequestRefreshRowsEvent=o,u.bufferService=a,u.optionsService=c,u._coreService=l,u._coreBrowserService=h,u._cell=new s.CellData,u._state={x:0,y:0,isFocused:!1,style:"",width:0},u._cursorRenderers={bar:u._renderBarCursor.bind(u),block:u._renderBlockCursor.bind(u),underline:u._renderUnderlineCursor.bind(u)},u}return n(t,e),t.prototype.resize=function(t){e.prototype.resize.call(this,t),this._state={x:0,y:0,isFocused:!1,style:"",width:0}},t.prototype.reset=function(){this._clearCursor(),this._cursorBlinkStateManager&&(this._cursorBlinkStateManager.dispose(),this._cursorBlinkStateManager=void 0,this.onOptionsChanged())},t.prototype.onBlur=function(){this._cursorBlinkStateManager&&this._cursorBlinkStateManager.pause(),this._onRequestRefreshRowsEvent.fire({start:this._bufferService.buffer.y,end:this._bufferService.buffer.y})},t.prototype.onFocus=function(){this._cursorBlinkStateManager?this._cursorBlinkStateManager.resume():this._onRequestRefreshRowsEvent.fire({start:this._bufferService.buffer.y,end:this._bufferService.buffer.y})},t.prototype.onOptionsChanged=function(){var e,t=this;this._optionsService.options.cursorBlink?this._cursorBlinkStateManager||(this._cursorBlinkStateManager=new c(this._coreBrowserService.isFocused,(function(){t._render(!0)}))):(null===(e=this._cursorBlinkStateManager)||void 0===e||e.dispose(),this._cursorBlinkStateManager=void 0),this._onRequestRefreshRowsEvent.fire({start:this._bufferService.buffer.y,end:this._bufferService.buffer.y})},t.prototype.onCursorMove=function(){this._cursorBlinkStateManager&&this._cursorBlinkStateManager.restartBlinkAnimation()},t.prototype.onGridChanged=function(e,t){!this._cursorBlinkStateManager||this._cursorBlinkStateManager.isPaused?this._render(!1):this._cursorBlinkStateManager.restartBlinkAnimation()},t.prototype._render=function(e){if(this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden){var t=this._bufferService.buffer.ybase+this._bufferService.buffer.y,r=t-this._bufferService.buffer.ydisp;if(r<0||r>=this._bufferService.rows)this._clearCursor();else{var i=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1);if(this._bufferService.buffer.lines.get(t).loadCell(i,this._cell),void 0!==this._cell.content){if(!this._coreBrowserService.isFocused){this._clearCursor(),this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css;var n=this._optionsService.options.cursorStyle;return n&&"block"!==n?this._cursorRenderers[n](i,r,this._cell):this._renderBlurCursor(i,r,this._cell),this._ctx.restore(),this._state.x=i,this._state.y=r,this._state.isFocused=!1,this._state.style=n,void(this._state.width=this._cell.getWidth())}if(!this._cursorBlinkStateManager||this._cursorBlinkStateManager.isCursorVisible){if(this._state){if(this._state.x===i&&this._state.y===r&&this._state.isFocused===this._coreBrowserService.isFocused&&this._state.style===this._optionsService.options.cursorStyle&&this._state.width===this._cell.getWidth())return;this._clearCursor()}this._ctx.save(),this._cursorRenderers[this._optionsService.options.cursorStyle||"block"](i,r,this._cell),this._ctx.restore(),this._state.x=i,this._state.y=r,this._state.isFocused=!1,this._state.style=this._optionsService.options.cursorStyle,this._state.width=this._cell.getWidth()}else this._clearCursor()}}}else this._clearCursor()},t.prototype._clearCursor=function(){this._state&&(this._clearCells(this._state.x,this._state.y,this._state.width,1),this._state={x:0,y:0,isFocused:!1,style:"",width:0})},t.prototype._renderBarCursor=function(e,t,r){this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this._fillLeftLineAtCell(e,t,this._optionsService.options.cursorWidth),this._ctx.restore()},t.prototype._renderBlockCursor=function(e,t,r){this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this._fillCells(e,t,r.getWidth(),1),this._ctx.fillStyle=this._colors.cursorAccent.css,this._fillCharTrueColor(r,e,t),this._ctx.restore()},t.prototype._renderUnderlineCursor=function(e,t,r){this._ctx.save(),this._ctx.fillStyle=this._colors.cursor.css,this._fillBottomLineAtCells(e,t),this._ctx.restore()},t.prototype._renderBlurCursor=function(e,t,r){this._ctx.save(),this._ctx.strokeStyle=this._colors.cursor.css,this._strokeRectAtCell(e,t,r.getWidth(),1),this._ctx.restore()},t}(o.BaseRenderLayer);t.CursorRenderLayer=a;var c=function(){function e(e,t){this._renderCallback=t,this.isCursorVisible=!0,e&&this._restartInterval()}return Object.defineProperty(e.prototype,"isPaused",{get:function(){return!(this._blinkStartTimeout||this._blinkInterval)},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this._blinkInterval&&(window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)},e.prototype.restartBlinkAnimation=function(){var e=this;this.isPaused||(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||(this._animationFrame=window.requestAnimationFrame((function(){e._renderCallback(),e._animationFrame=void 0}))))},e.prototype._restartInterval=function(e){var t=this;void 0===e&&(e=600),this._blinkInterval&&window.clearInterval(this._blinkInterval),this._blinkStartTimeout=window.setTimeout((function(){if(t._animationTimeRestarted){var e=600-(Date.now()-t._animationTimeRestarted);if(t._animationTimeRestarted=void 0,e>0)return void t._restartInterval(e)}t.isCursorVisible=!1,t._animationFrame=window.requestAnimationFrame((function(){t._renderCallback(),t._animationFrame=void 0})),t._blinkInterval=window.setInterval((function(){if(t._animationTimeRestarted){var e=600-(Date.now()-t._animationTimeRestarted);return t._animationTimeRestarted=void 0,void t._restartInterval(e)}t.isCursorVisible=!t.isCursorVisible,t._animationFrame=window.requestAnimationFrame((function(){t._renderCallback(),t._animationFrame=void 0}))}),600)}),e)},e.prototype.pause=function(){this.isCursorVisible=!0,this._blinkInterval&&(window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)},e.prototype.resume=function(){this.pause(),this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation()},e}()},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(13),s=r(9),a=r(24),c=function(e){function t(t,r,i,n,o,s,a,c){var l=e.call(this,t,"link",r,!0,i,n,a,c)||this;return l.bufferService=a,l.optionsService=c,o.onLinkHover((function(e){return l._onLinkHover(e)})),o.onLinkLeave((function(e){return l._onLinkLeave(e)})),s.onLinkHover((function(e){return l._onLinkHover(e)})),s.onLinkLeave((function(e){return l._onLinkLeave(e)})),l}return n(t,e),t.prototype.resize=function(t){e.prototype.resize.call(this,t),this._state=void 0},t.prototype.reset=function(){this._clearCurrentLink()},t.prototype._clearCurrentLink=function(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);var e=this._state.y2-this._state.y1-1;e>0&&this._clearCells(0,this._state.y1+1,this._state.cols,e),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}},t.prototype._onLinkHover=function(e){if(e.fg===s.INVERTED_DEFAULT_COLOR?this._ctx.fillStyle=this._colors.background.css:e.fg&&a.is256Color(e.fg)?this._ctx.fillStyle=this._colors.ansi[e.fg].css:this._ctx.fillStyle=this._colors.foreground.css,e.y1===e.y2)this._fillBottomLineAtCells(e.x1,e.y1,e.x2-e.x1);else{this._fillBottomLineAtCells(e.x1,e.y1,e.cols-e.x1);for(var t=e.y1+1;t<e.y2;t++)this._fillBottomLineAtCells(0,t,e.cols);this._fillBottomLineAtCells(0,e.y2,e.x2)}this._state=e},t.prototype._onLinkLeave=function(e){this._clearCurrentLink()},t}(o.BaseRenderLayer);t.LinkRenderLayer=c},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(){function e(e,t,r,n){this._bufferService=e,this._logService=t,this._optionsService=r,this._unicodeService=n,this._linkMatchers=[],this._nextLinkMatcherId=0,this._onLinkHover=new i.EventEmitter,this._onLinkLeave=new i.EventEmitter,this._onLinkTooltip=new i.EventEmitter,this._rowsToLinkify={start:void 0,end:void 0}}return Object.defineProperty(e.prototype,"onLinkHover",{get:function(){return this._onLinkHover.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onLinkLeave",{get:function(){return this._onLinkLeave.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onLinkTooltip",{get:function(){return this._onLinkTooltip.event},enumerable:!0,configurable:!0}),e.prototype.attachToDom=function(e,t){this._element=e,this._mouseZoneManager=t},e.prototype.linkifyRows=function(t,r){var i=this;this._mouseZoneManager&&(void 0===this._rowsToLinkify.start||void 0===this._rowsToLinkify.end?(this._rowsToLinkify.start=t,this._rowsToLinkify.end=r):(this._rowsToLinkify.start=Math.min(this._rowsToLinkify.start,t),this._rowsToLinkify.end=Math.max(this._rowsToLinkify.end,r)),this._mouseZoneManager.clearAll(t,r),this._rowsTimeoutId&&clearTimeout(this._rowsTimeoutId),this._rowsTimeoutId=setTimeout((function(){return i._linkifyRows()}),e._timeBeforeLatency))},e.prototype._linkifyRows=function(){this._rowsTimeoutId=void 0;var e=this._bufferService.buffer;if(void 0!==this._rowsToLinkify.start&&void 0!==this._rowsToLinkify.end){var t=e.ydisp+this._rowsToLinkify.start;if(!(t>=e.lines.length)){for(var r=e.ydisp+Math.min(this._rowsToLinkify.end,this._bufferService.rows)+1,i=Math.ceil(2e3/this._bufferService.cols),n=this._bufferService.buffer.iterator(!1,t,r,i,i);n.hasNext();)for(var o=n.next(),s=0;s<this._linkMatchers.length;s++)this._doLinkifyRow(o.range.first,o.content,this._linkMatchers[s]);this._rowsToLinkify.start=void 0,this._rowsToLinkify.end=void 0}}else this._logService.debug("_rowToLinkify was unset before _linkifyRows was called")},e.prototype.registerLinkMatcher=function(e,t,r){if(void 0===r&&(r={}),!t)throw new Error("handler must be defined");var i={id:this._nextLinkMatcherId++,regex:e,handler:t,matchIndex:r.matchIndex,validationCallback:r.validationCallback,hoverTooltipCallback:r.tooltipCallback,hoverLeaveCallback:r.leaveCallback,willLinkActivate:r.willLinkActivate,priority:r.priority||0};return this._addLinkMatcherToList(i),i.id},e.prototype._addLinkMatcherToList=function(e){if(0!==this._linkMatchers.length){for(var t=this._linkMatchers.length-1;t>=0;t--)if(e.priority<=this._linkMatchers[t].priority)return void this._linkMatchers.splice(t+1,0,e);this._linkMatchers.splice(0,0,e)}else this._linkMatchers.push(e)},e.prototype.deregisterLinkMatcher=function(e){for(var t=0;t<this._linkMatchers.length;t++)if(this._linkMatchers[t].id===e)return this._linkMatchers.splice(t,1),!0;return!1},e.prototype._doLinkifyRow=function(e,t,r){for(var i,n=this,o=new RegExp(r.regex.source,(r.regex.flags||"")+"g"),s=-1,a=function(){var a=i["number"!=typeof r.matchIndex?0:r.matchIndex];if(!a)return c._logService.debug("match found without corresponding matchIndex",i,r),"break";if(s=t.indexOf(a,s+1),o.lastIndex=s+a.length,s<0)return"break";var l=c._bufferService.buffer.stringIndexToBufferIndex(e,s);if(l[0]<0)return"break";var h=c._bufferService.buffer.lines.get(l[0]);if(!h)return"break";var u=h.getFg(l[1]),f=u?u>>9&511:void 0;r.validationCallback?r.validationCallback(a,(function(e){n._rowsTimeoutId||e&&n._addLink(l[1],l[0]-n._bufferService.buffer.ydisp,a,r,f)})):c._addLink(l[1],l[0]-c._bufferService.buffer.ydisp,a,r,f)},c=this;null!==(i=o.exec(t));){if("break"===a())break}},e.prototype._addLink=function(e,t,r,i,n){var s=this;if(this._mouseZoneManager&&this._element){var a=this._unicodeService.getStringCellWidth(r),c=e%this._bufferService.cols,l=t+Math.floor(e/this._bufferService.cols),h=(c+a)%this._bufferService.cols,u=l+Math.floor((c+a)/this._bufferService.cols);0===h&&(h=this._bufferService.cols,u--),this._mouseZoneManager.add(new o(c+1,l+1,h+1,u+1,(function(e){if(i.handler)return i.handler(e,r);var t=window.open();t?(t.opener=null,t.location.href=r):console.warn("Opening link blocked as opener could not be cleared")}),(function(){s._onLinkHover.fire(s._createLinkHoverEvent(c,l,h,u,n)),s._element.classList.add("xterm-cursor-pointer")}),(function(e){s._onLinkTooltip.fire(s._createLinkHoverEvent(c,l,h,u,n)),i.hoverTooltipCallback&&i.hoverTooltipCallback(e,r,{start:{x:c,y:l},end:{x:h,y:u}})}),(function(){s._onLinkLeave.fire(s._createLinkHoverEvent(c,l,h,u,n)),s._element.classList.remove("xterm-cursor-pointer"),i.hoverLeaveCallback&&i.hoverLeaveCallback()}),(function(e){return!i.willLinkActivate||i.willLinkActivate(e,r)})))}},e.prototype._createLinkHoverEvent=function(e,t,r,i,n){return{x1:e,y1:t,x2:r,y2:i,cols:this._bufferService.cols,fg:n}},e._timeBeforeLatency=200,e}();t.Linkifier=n;var o=function(e,t,r,i,n,o,s,a,c){this.x1=e,this.y1=t,this.x2=r,this.y2=i,this.clickCallback=n,this.hoverCallback=o,this.tooltipCallback=s,this.leaveCallback=a,this.willLinkActivate=c};t.MouseZone=o},function(e,t,r){"use strict";var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(11),s=r(51),a=r(5),c=r(0),l=r(4),h=r(1),u=r(28),f=r(52),_=String.fromCharCode(160),d=new RegExp(_,"g"),p=function(){function e(e,t,r,i,n,o,l,h){var u=this;this._scrollLines=e,this._element=t,this._screenElement=r,this._charSizeService=i,this._bufferService=n,this._coreService=o,this._mouseService=l,this._optionsService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new a.CellData,this._mouseDownTimeStamp=0,this._onLinuxMouseSelection=new c.EventEmitter,this._onRedrawRequest=new c.EventEmitter,this._onSelectionChange=new c.EventEmitter,this._mouseMoveListener=function(e){return u._onMouseMove(e)},this._mouseUpListener=function(e){return u._onMouseUp(e)},this._coreService.onUserInput((function(){u.hasSelection&&u.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((function(e){return u._onTrim(e)})),this._bufferService.buffers.onBufferActivate((function(e){return u._onBufferActivate(e)})),this.enable(),this._model=new s.SelectionModel(this._bufferService),this._activeSelectionMode=0}return Object.defineProperty(e.prototype,"onLinuxMouseSelection",{get:function(){return this._onLinuxMouseSelection.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onRedrawRequest",{get:function(){return this._onRedrawRequest.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onSelectionChange",{get:function(){return this._onSelectionChange.event},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this._removeMouseDownListeners()},e.prototype.reset=function(){this.clearSelection()},e.prototype.disable=function(){this.clearSelection(),this._enabled=!1},e.prototype.enable=function(){this._enabled=!0},Object.defineProperty(e.prototype,"selectionStart",{get:function(){return this._model.finalSelectionStart},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"selectionEnd",{get:function(){return this._model.finalSelectionEnd},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasSelection",{get:function(){var e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!(!e||!t)&&(e[0]!==t[0]||e[1]!==t[1])},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"selectionText",{get:function(){var e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";var r=this._bufferService.buffer,i=[];if(3===this._activeSelectionMode){if(e[0]===t[0])return"";for(var n=e[1];n<=t[1];n++){var s=r.translateBufferLineToString(n,!0,e[0],t[0]);i.push(s)}}else{var a=e[1]===t[1]?t[0]:void 0;i.push(r.translateBufferLineToString(e[1],!0,e[0],a));for(n=e[1]+1;n<=t[1]-1;n++){var c=r.lines.get(n);s=r.translateBufferLineToString(n,!0);c&&c.isWrapped?i[i.length-1]+=s:i.push(s)}if(e[1]!==t[1]){c=r.lines.get(t[1]),s=r.translateBufferLineToString(t[1],!0,0,t[0]);c&&c.isWrapped?i[i.length-1]+=s:i.push(s)}}return i.map((function(e){return e.replace(d," ")})).join(o.isWindows?"\r\n":"\n")},enumerable:!0,configurable:!0}),e.prototype.clearSelection=function(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()},e.prototype.refresh=function(e){var t=this;(this._refreshAnimationFrame||(this._refreshAnimationFrame=window.requestAnimationFrame((function(){return t._refresh()}))),o.isLinux&&e)&&(this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText))},e.prototype._refresh=function(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:3===this._activeSelectionMode})},e.prototype.isClickInSelection=function(e){var t=this._getMouseBufferCoords(e),r=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!!(r&&i&&t)&&this._areCoordsInSelection(t,r,i)},e.prototype._areCoordsInSelection=function(e,t,r){return e[1]>t[1]&&e[1]<r[1]||t[1]===r[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<r[0]||t[1]<r[1]&&e[1]===r[1]&&e[0]<r[0]||t[1]<r[1]&&e[1]===t[1]&&e[0]>=t[0]},e.prototype.selectWordAtCursor=function(e){var t=this._getMouseBufferCoords(e);t&&(this._selectWordAt(t,!1),this._model.selectionEnd=void 0,this.refresh(!0))},e.prototype.selectAll=function(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()},e.prototype.selectLines=function(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()},e.prototype._onTrim=function(e){this._model.onTrim(e)&&this.refresh()},e.prototype._getMouseBufferCoords=function(e){var t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t},e.prototype._getMouseEventScrollAmount=function(e){var t=u.getCoordsRelativeToElement(e,this._screenElement)[1],r=this._bufferService.rows*Math.ceil(this._charSizeService.height*this._optionsService.options.lineHeight);return t>=0&&t<=r?0:(t>r&&(t-=r),t=Math.min(Math.max(t,-50),50),(t/=50)/Math.abs(t)+Math.round(14*t))},e.prototype.shouldForceSelection=function(e){return o.isMac?e.altKey&&this._optionsService.options.macOptionClickForcesSelection:e.shiftKey},e.prototype.onMouseDown=function(e){if(this._mouseDownTimeStamp=e.timeStamp,(2!==e.button||!this.hasSelection)&&0===e.button){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._onIncrementalClick(e):1===e.detail?this._onSingleClick(e):2===e.detail?this._onDoubleClick(e):3===e.detail&&this._onTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}},e.prototype._addMouseDownListeners=function(){var e=this;this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=window.setInterval((function(){return e._dragScroll()}),50)},e.prototype._removeMouseDownListeners=function(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0},e.prototype._onIncrementalClick=function(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))},e.prototype._onSingleClick=function(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),this._model.selectionStart){this._model.selectionEnd=void 0;var t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&0===t.hasWidth(this._model.selectionStart[0])&&this._model.selectionStart[0]++}},e.prototype._onDoubleClick=function(e){var t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=1,this._selectWordAt(t,!0))},e.prototype._onTripleClick=function(e){var t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))},e.prototype.shouldColumnSelect=function(e){return e.altKey&&!(o.isMac&&this._optionsService.options.macOptionClickForcesSelection)},e.prototype._onMouseMove=function(e){if(e.stopImmediatePropagation(),this._model.selectionStart){var t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),this._model.selectionEnd){2===this._activeSelectionMode?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:1===this._activeSelectionMode&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),3!==this._activeSelectionMode&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));var r=this._bufferService.buffer;if(this._model.selectionEnd[1]<r.lines.length){var i=r.lines.get(this._model.selectionEnd[1]);i&&0===i.hasWidth(this._model.selectionEnd[0])&&this._model.selectionEnd[0]++}t&&t[0]===this._model.selectionEnd[0]&&t[1]===this._model.selectionEnd[1]||this.refresh(!0)}else this.refresh(!0)}},e.prototype._dragScroll=function(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._scrollLines(this._dragScrollAmount,!1);var e=this._bufferService.buffer;this._dragScrollAmount>0?(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}},e.prototype._onMouseUp=function(e){var t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<500){if(e.altKey&&this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){var r=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(r&&void 0!==r[0]&&void 0!==r[1]){var i=f.moveToCellSequence(r[0]-1,r[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this.hasSelection&&this._onSelectionChange.fire()},e.prototype._onBufferActivate=function(e){var t=this;this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim((function(e){return t._onTrim(e)}))},e.prototype._convertViewportColToCharacterIndex=function(e,t){for(var r=t[0],i=0;t[0]>=i;i++){var n=e.loadCell(i,this._workCell).getChars().length;0===this._workCell.getWidth()?r--:n>1&&t[0]!==i&&(r+=n-1)}return r},e.prototype.setSelection=function(e,t,r){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=r,this.refresh()},e.prototype._getWordAt=function(e,t,r,i){if(void 0===r&&(r=!0),void 0===i&&(i=!0),!(e[0]>=this._bufferService.cols)){var n=this._bufferService.buffer,o=n.lines.get(e[1]);if(o){var s=n.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(o,e),c=a,l=e[0]-a,h=0,u=0,f=0,_=0;if(" "===s.charAt(a)){for(;a>0&&" "===s.charAt(a-1);)a--;for(;c<s.length&&" "===s.charAt(c+1);)c++}else{var d=e[0],p=e[0];0===o.getWidth(d)&&(h++,d--),2===o.getWidth(p)&&(u++,p++);var v=o.getString(p).length;for(v>1&&(_+=v-1,c+=v-1);d>0&&a>0&&!this._isCharWordSeparator(o.loadCell(d-1,this._workCell));){o.loadCell(d-1,this._workCell);var g=this._workCell.getChars().length;0===this._workCell.getWidth()?(h++,d--):g>1&&(f+=g-1,a-=g-1),a--,d--}for(;p<o.length&&c+1<s.length&&!this._isCharWordSeparator(o.loadCell(p+1,this._workCell));){o.loadCell(p+1,this._workCell);var y=this._workCell.getChars().length;2===this._workCell.getWidth()?(u++,p++):y>1&&(_+=y-1,c+=y-1),c++,p++}}c++;var b=a+l-h+f,m=Math.min(this._bufferService.cols,c-a+h+u-f-_);if(t||""!==s.slice(a,c).trim()){if(r&&0===b&&32!==o.getCodePoint(0)){var S=n.lines.get(e[1]-1);if(S&&o.isWrapped&&32!==S.getCodePoint(this._bufferService.cols-1)){var C=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(C){var w=this._bufferService.cols-C.start;b-=w,m+=w}}}if(i&&b+m===this._bufferService.cols&&32!==o.getCodePoint(this._bufferService.cols-1)){var E=n.lines.get(e[1]+1);if(E&&E.isWrapped&&32!==E.getCodePoint(0)){var L=this._getWordAt([0,e[1]+1],!1,!1,!0);L&&(m+=L.length)}}return{start:b,length:m}}}}},e.prototype._selectWordAt=function(e,t){var r=this._getWordAt(e,t);if(r){for(;r.start<0;)r.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[r.start,e[1]],this._model.selectionStartLength=r.length}},e.prototype._selectToWordAt=function(e){var t=this._getWordAt(e,!0);if(t){for(var r=e[1];t.start<0;)t.start+=this._bufferService.cols,r--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,r++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,r]}},e.prototype._isCharWordSeparator=function(e){return 0!==e.getWidth()&&this._optionsService.options.wordSeparator.indexOf(e.getChars())>=0},e.prototype._selectLineAt=function(e){var t=this._bufferService.buffer.getWrappedRangeForLine(e);this._model.selectionStart=[0,t.first],this._model.selectionEnd=[this._bufferService.cols,t.last],this._model.selectionStartLength=0},e=i([n(3,l.ICharSizeService),n(4,h.IBufferService),n(5,h.ICoreService),n(6,l.IMouseService),n(7,h.IOptionsService)],e)}();t.SelectionService=p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}return e.prototype.clearSelection=function(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0},Object.defineProperty(e.prototype,"finalSelectionStart",{get:function(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"finalSelectionEnd",{get:function(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){var e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}return this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]?[Math.max(this.selectionStart[0]+this.selectionStartLength,this.selectionEnd[0]),this.selectionEnd[1]]:this.selectionEnd}},enumerable:!0,configurable:!0}),e.prototype.areSelectionValuesReversed=function(){var e=this.selectionStart,t=this.selectionEnd;return!(!e||!t)&&(e[1]>t[1]||e[1]===t[1]&&e[0]>t[0])},e.prototype.onTrim=function(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)},e}();t.SelectionModel=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(12);function n(e,t,r,i){var n=e-o(r,e),s=t-o(r,t);return h(Math.abs(n-s)-function(e,t,r){for(var i=0,n=e-o(r,e),s=t-o(r,t),c=0;c<Math.abs(n-s);c++){var l="A"===a(e,t)?-1:1,h=r.buffer.lines.get(n+l*c);h&&h.isWrapped&&i++}return i}(e,t,r),l(a(e,t),i))}function o(e,t){for(var r=0,i=e.buffer.lines.get(t),n=i&&i.isWrapped;n&&t>=0&&t<e.rows;)r++,n=(i=e.buffer.lines.get(--t))&&i.isWrapped;return r}function s(e,t,r,i,s,a){var c;return c=n(r,i,s,a).length>0?i-o(s,i):t,e<r&&c<=i||e>=r&&c<i?"C":"D"}function a(e,t){return e>t?"A":"B"}function c(e,t,r,i,n,o){for(var s=e,a=t,c="";s!==r||a!==i;)s+=n?1:-1,n&&s>o.cols-1?(c+=o.buffer.translateBufferLineToString(a,!1,e,s),s=0,e=0,a++):!n&&s<0&&(c+=o.buffer.translateBufferLineToString(a,!1,0,e+1),e=s=o.cols-1,a--);return c+o.buffer.translateBufferLineToString(a,!1,e,s)}function l(e,t){var r=t?"O":"[";return i.C0.ESC+r+e}function h(e,t){e=Math.floor(e);for(var r="",i=0;i<e;i++)r+=t;return r}t.moveToCellSequence=function(e,t,r,i){var a,u=r.buffer.x,f=r.buffer.y;if(!r.buffer.hasScrollback)return function(e,t,r,i,s,a){if(0===n(t,i,s,a).length)return"";return h(c(e,t,e,t-o(s,t),!1,s).length,l("D",a))}(u,f,0,t,r,i)+n(f,t,r,i)+function(e,t,r,i,a,u){var f;f=n(t,i,a,u).length>0?i-o(a,i):t;var _=i,d=s(e,t,r,i,a,u);return h(c(e,f,r,_,"C"===d,a).length,l(d,u))}(u,f,e,t,r,i);if(f===t)return a=u>e?"D":"C",h(Math.abs(u-e),l(a,i));a=f>t?"D":"C";var _=Math.abs(f-t);return h(function(e,t){return t.cols-e}(f>t?e:u,r)+(_-1)*r.cols+1+((f>t?u:e)-1),l(a,i))}},function(e,t,r){"use strict";var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),s=function(){function e(e){this._optionsService=e}return Object.defineProperty(e,"audioContext",{get:function(){if(!e._audioContext){var t=window.AudioContext||window.webkitAudioContext;if(!t)return console.warn("Web Audio API is not supported by this browser. Consider upgrading to the latest version"),null;e._audioContext=new t}return e._audioContext},enumerable:!0,configurable:!0}),e.prototype.playBellSound=function(){var t=e.audioContext;if(t){var r=t.createBufferSource();t.decodeAudioData(this._base64ToArrayBuffer(this._removeMimeType(this._optionsService.options.bellSound)),(function(e){r.buffer=e,r.connect(t.destination),r.start(0)}))}},e.prototype._base64ToArrayBuffer=function(e){for(var t=window.atob(e),r=t.length,i=new Uint8Array(r),n=0;n<r;n++)i[n]=t.charCodeAt(n);return i.buffer},e.prototype._removeMimeType=function(e){return e.split(",")[1]},e=i([n(0,o.IOptionsService)],e)}();t.SoundService=s},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var a=r(2),c=r(8),l=r(4),h=r(1),u=function(e){function t(t,r,i,n,o){var s=e.call(this)||this;return s._element=t,s._screenElement=r,s._bufferService=i,s._mouseService=n,s._selectionService=o,s._zones=[],s._areZonesActive=!1,s._lastHoverCoords=[void 0,void 0],s._initialSelectionLength=0,s.register(c.addDisposableDomListener(s._element,"mousedown",(function(e){return s._onMouseDown(e)}))),s._mouseMoveListener=function(e){return s._onMouseMove(e)},s._mouseLeaveListener=function(e){return s._onMouseLeave(e)},s._clickListener=function(e){return s._onClick(e)},s}return n(t,e),t.prototype.dispose=function(){e.prototype.dispose.call(this),this._deactivate()},t.prototype.add=function(e){this._zones.push(e),1===this._zones.length&&this._activate()},t.prototype.clearAll=function(e,t){if(0!==this._zones.length){e&&t||(e=0,t=this._bufferService.rows-1);for(var r=0;r<this._zones.length;r++){var i=this._zones[r];(i.y1>e&&i.y1<=t+1||i.y2>e&&i.y2<=t+1||i.y1<e&&i.y2>t+1)&&(this._currentZone&&this._currentZone===i&&(this._currentZone.leaveCallback(),this._currentZone=void 0),this._zones.splice(r--,1))}0===this._zones.length&&this._deactivate()}},t.prototype._activate=function(){this._areZonesActive||(this._areZonesActive=!0,this._element.addEventListener("mousemove",this._mouseMoveListener),this._element.addEventListener("mouseleave",this._mouseLeaveListener),this._element.addEventListener("click",this._clickListener))},t.prototype._deactivate=function(){this._areZonesActive&&(this._areZonesActive=!1,this._element.removeEventListener("mousemove",this._mouseMoveListener),this._element.removeEventListener("mouseleave",this._mouseLeaveListener),this._element.removeEventListener("click",this._clickListener))},t.prototype._onMouseMove=function(e){this._lastHoverCoords[0]===e.pageX&&this._lastHoverCoords[1]===e.pageY||(this._onHover(e),this._lastHoverCoords=[e.pageX,e.pageY])},t.prototype._onHover=function(e){var t=this,r=this._findZoneEventAt(e);r!==this._currentZone&&(this._currentZone&&(this._currentZone.leaveCallback(),this._currentZone=void 0,this._tooltipTimeout&&clearTimeout(this._tooltipTimeout)),r&&(this._currentZone=r,r.hoverCallback&&r.hoverCallback(e),this._tooltipTimeout=setTimeout((function(){return t._onTooltip(e)}),500)))},t.prototype._onTooltip=function(e){this._tooltipTimeout=void 0;var t=this._findZoneEventAt(e);t&&t.tooltipCallback&&t.tooltipCallback(e)},t.prototype._onMouseDown=function(e){if(this._initialSelectionLength=this._getSelectionLength(),this._areZonesActive){var t=this._findZoneEventAt(e);(null==t?void 0:t.willLinkActivate(e))&&(e.preventDefault(),e.stopImmediatePropagation())}},t.prototype._onMouseLeave=function(e){this._currentZone&&(this._currentZone.leaveCallback(),this._currentZone=void 0,this._tooltipTimeout&&clearTimeout(this._tooltipTimeout))},t.prototype._onClick=function(e){var t=this._findZoneEventAt(e),r=this._getSelectionLength();t&&r===this._initialSelectionLength&&(t.clickCallback(e),e.preventDefault(),e.stopImmediatePropagation())},t.prototype._getSelectionLength=function(){var e=this._selectionService.selectionText;return e?e.length:0},t.prototype._findZoneEventAt=function(e){var t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows);if(t)for(var r=t[0],i=t[1],n=0;n<this._zones.length;n++){var o=this._zones[n];if(o.y1===o.y2){if(i===o.y1&&r>=o.x1&&r<o.x2)return o}else if(i===o.y1&&r>=o.x1||i===o.y2&&r<o.x2||i>o.y1&&i<o.y2)return o}},t=o([s(2,h.IBufferService),s(3,l.IMouseService),s(4,l.ISelectionService)],t)}(a.Disposable);t.MouseZoneManager=u},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(17),s=r(11),a=r(29),c=r(8),l=r(2),h=r(30),u=function(e){function t(t,r){var i=e.call(this)||this;i._terminal=t,i._renderService=r,i._liveRegionLineCount=0,i._charsToConsume=[],i._charsToAnnounce="",i._accessibilityTreeRoot=document.createElement("div"),i._accessibilityTreeRoot.classList.add("xterm-accessibility"),i._rowContainer=document.createElement("div"),i._rowContainer.classList.add("xterm-accessibility-tree"),i._rowContainer.setAttribute("role","list"),i._rowElements=[];for(var n=0;n<i._terminal.rows;n++)i._rowElements[n]=i._createAccessibilityTreeNode(),i._rowContainer.appendChild(i._rowElements[n]);return i._topBoundaryFocusListener=function(e){return i._onBoundaryFocus(e,0)},i._bottomBoundaryFocusListener=function(e){return i._onBoundaryFocus(e,1)},i._rowElements[0].addEventListener("focus",i._topBoundaryFocusListener),i._rowElements[i._rowElements.length-1].addEventListener("focus",i._bottomBoundaryFocusListener),i._refreshRowsDimensions(),i._accessibilityTreeRoot.appendChild(i._rowContainer),i._renderRowsDebouncer=new a.RenderDebouncer(i._renderRows.bind(i)),i._refreshRows(),i._liveRegion=document.createElement("div"),i._liveRegion.classList.add("live-region"),i._liveRegion.setAttribute("aria-live","assertive"),i._accessibilityTreeRoot.appendChild(i._liveRegion),i._terminal.element.insertAdjacentElement("afterbegin",i._accessibilityTreeRoot),i.register(i._renderRowsDebouncer),i.register(i._terminal.onResize((function(e){return i._onResize(e.rows)}))),i.register(i._terminal.onRender((function(e){return i._refreshRows(e.start,e.end)}))),i.register(i._terminal.onScroll((function(){return i._refreshRows()}))),i.register(i._terminal.onA11yChar((function(e){return i._onChar(e)}))),i.register(i._terminal.onLineFeed((function(){return i._onChar("\n")}))),i.register(i._terminal.onA11yTab((function(e){return i._onTab(e)}))),i.register(i._terminal.onKey((function(e){return i._onKey(e.key)}))),i.register(i._terminal.onBlur((function(){return i._clearLiveRegion()}))),i.register(i._renderService.onDimensionsChange((function(){return i._refreshRowsDimensions()}))),i._screenDprMonitor=new h.ScreenDprMonitor,i.register(i._screenDprMonitor),i._screenDprMonitor.setListener((function(){return i._refreshRowsDimensions()})),i.register(c.addDisposableDomListener(window,"resize",(function(){return i._refreshRowsDimensions()}))),i}return n(t,e),t.prototype.dispose=function(){e.prototype.dispose.call(this),this._terminal.element.removeChild(this._accessibilityTreeRoot),this._rowElements.length=0},t.prototype._onBoundaryFocus=function(e,t){var r=e.target,i=this._rowElements[0===t?1:this._rowElements.length-2];if(r.getAttribute("aria-posinset")!==(0===t?"1":""+this._terminal.buffer.lines.length)&&e.relatedTarget===i){var n,o;if(0===t?(n=r,o=this._rowElements.pop(),this._rowContainer.removeChild(o)):(n=this._rowElements.shift(),o=r,this._rowContainer.removeChild(n)),n.removeEventListener("focus",this._topBoundaryFocusListener),o.removeEventListener("focus",this._bottomBoundaryFocusListener),0===t){var s=this._createAccessibilityTreeNode();this._rowElements.unshift(s),this._rowContainer.insertAdjacentElement("afterbegin",s)}else{s=this._createAccessibilityTreeNode();this._rowElements.push(s),this._rowContainer.appendChild(s)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(0===t?-1:1),this._rowElements[0===t?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}},t.prototype._onResize=function(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(var t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()},t.prototype._createAccessibilityTreeNode=function(){var e=document.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e},t.prototype._onTab=function(e){for(var t=0;t<e;t++)this._onChar(" ")},t.prototype._onChar=function(e){var t=this;if(this._liveRegionLineCount<21){if(this._charsToConsume.length>0)this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e);else this._charsToAnnounce+=e;"\n"===e&&(this._liveRegionLineCount++,21===this._liveRegionLineCount&&(this._liveRegion.textContent+=o.tooMuchOutput)),s.isMac&&this._liveRegion.textContent&&this._liveRegion.textContent.length>0&&!this._liveRegion.parentNode&&setTimeout((function(){t._accessibilityTreeRoot.appendChild(t._liveRegion)}),0)}},t.prototype._clearLiveRegion=function(){this._liveRegion.textContent="",this._liveRegionLineCount=0,s.isMac&&this._liveRegion.parentNode&&this._accessibilityTreeRoot.removeChild(this._liveRegion)},t.prototype._onKey=function(e){this._clearLiveRegion(),this._charsToConsume.push(e)},t.prototype._refreshRows=function(e,t){this._renderRowsDebouncer.refresh(e,t,this._terminal.rows)},t.prototype._renderRows=function(e,t){for(var r=this._terminal.buffer,i=r.lines.length.toString(),n=e;n<=t;n++){var o=r.translateBufferLineToString(r.ydisp+n,!0),s=(r.ydisp+n+1).toString(),a=this._rowElements[n];a&&(0===o.length?a.innerHTML="&nbsp;":a.textContent=o,a.setAttribute("aria-posinset",s),a.setAttribute("aria-setsize",i))}this._announceCharacters()},t.prototype._refreshRowsDimensions=function(){if(this._renderService.dimensions.actualCellHeight){this._rowElements.length!==this._terminal.rows&&this._onResize(this._terminal.rows);for(var e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e])}},t.prototype._refreshRowDimensions=function(e){e.style.height=this._renderService.dimensions.actualCellHeight+"px"},t.prototype._announceCharacters=function(){0!==this._charsToAnnounce.length&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")},t}(l.Disposable);t.AccessibilityManager=u},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var a=r(57),c=r(9),l=r(2),h=r(4),u=r(1),f=r(0),_=r(10),d=1,p=function(e){function t(t,r,i,n,o,s,c,l,h){var u=e.call(this)||this;return u._colors=t,u._element=r,u._screenElement=i,u._viewportElement=n,u._linkifier=o,u._linkifier2=s,u._charSizeService=c,u._optionsService=l,u._bufferService=h,u._terminalClass=d++,u._rowElements=[],u._onRequestRefreshRows=new f.EventEmitter,u._rowContainer=document.createElement("div"),u._rowContainer.classList.add("xterm-rows"),u._rowContainer.style.lineHeight="normal",u._rowContainer.setAttribute("aria-hidden","true"),u._refreshRowElements(u._bufferService.cols,u._bufferService.rows),u._selectionContainer=document.createElement("div"),u._selectionContainer.classList.add("xterm-selection"),u._selectionContainer.setAttribute("aria-hidden","true"),u.dimensions={scaledCharWidth:0,scaledCharHeight:0,scaledCellWidth:0,scaledCellHeight:0,scaledCharLeft:0,scaledCharTop:0,scaledCanvasWidth:0,scaledCanvasHeight:0,canvasWidth:0,canvasHeight:0,actualCellWidth:0,actualCellHeight:0},u._updateDimensions(),u._injectCss(),u._rowFactory=new a.DomRendererRowFactory(document,u._optionsService,u._colors),u._element.classList.add("xterm-dom-renderer-owner-"+u._terminalClass),u._screenElement.appendChild(u._rowContainer),u._screenElement.appendChild(u._selectionContainer),u._linkifier.onLinkHover((function(e){return u._onLinkHover(e)})),u._linkifier.onLinkLeave((function(e){return u._onLinkLeave(e)})),u._linkifier2.onLinkHover((function(e){return u._onLinkHover(e)})),u._linkifier2.onLinkLeave((function(e){return u._onLinkLeave(e)})),u}return n(t,e),Object.defineProperty(t.prototype,"onRequestRefreshRows",{get:function(){return this._onRequestRefreshRows.event},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this._element.classList.remove("xterm-dom-renderer-owner-"+this._terminalClass),this._screenElement.removeChild(this._rowContainer),this._screenElement.removeChild(this._selectionContainer),this._screenElement.removeChild(this._themeStyleElement),this._screenElement.removeChild(this._dimensionsStyleElement),e.prototype.dispose.call(this)},t.prototype._updateDimensions=function(){var e=this;this.dimensions.scaledCharWidth=this._charSizeService.width*window.devicePixelRatio,this.dimensions.scaledCharHeight=Math.ceil(this._charSizeService.height*window.devicePixelRatio),this.dimensions.scaledCellWidth=this.dimensions.scaledCharWidth+Math.round(this._optionsService.options.letterSpacing),this.dimensions.scaledCellHeight=Math.floor(this.dimensions.scaledCharHeight*this._optionsService.options.lineHeight),this.dimensions.scaledCharLeft=0,this.dimensions.scaledCharTop=0,this.dimensions.scaledCanvasWidth=this.dimensions.scaledCellWidth*this._bufferService.cols,this.dimensions.scaledCanvasHeight=this.dimensions.scaledCellHeight*this._bufferService.rows,this.dimensions.canvasWidth=Math.round(this.dimensions.scaledCanvasWidth/window.devicePixelRatio),this.dimensions.canvasHeight=Math.round(this.dimensions.scaledCanvasHeight/window.devicePixelRatio),this.dimensions.actualCellWidth=this.dimensions.canvasWidth/this._bufferService.cols,this.dimensions.actualCellHeight=this.dimensions.canvasHeight/this._bufferService.rows,this._rowElements.forEach((function(t){t.style.width=e.dimensions.canvasWidth+"px",t.style.height=e.dimensions.actualCellHeight+"px",t.style.lineHeight=e.dimensions.actualCellHeight+"px",t.style.overflow="hidden"})),this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));var t=this._terminalSelector+" .xterm-rows span { display: inline-block; height: 100%; vertical-align: top; width: "+this.dimensions.actualCellWidth+"px}";this._dimensionsStyleElement.innerHTML=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=this.dimensions.canvasWidth+"px",this._screenElement.style.height=this.dimensions.canvasHeight+"px"},t.prototype.setColors=function(e){this._colors=e,this._injectCss()},t.prototype._injectCss=function(){var e=this;this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));var t=this._terminalSelector+" .xterm-rows { color: "+this._colors.foreground.css+"; font-family: "+this._optionsService.options.fontFamily+"; font-size: "+this._optionsService.options.fontSize+"px;}";t+=this._terminalSelector+" span:not(."+a.BOLD_CLASS+") { font-weight: "+this._optionsService.options.fontWeight+";}"+this._terminalSelector+" span."+a.BOLD_CLASS+" { font-weight: "+this._optionsService.options.fontWeightBold+";}"+this._terminalSelector+" span."+a.ITALIC_CLASS+" { font-style: italic;}",t+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { box-shadow: none; }}",t+="@keyframes blink_block_"+this._terminalClass+" { 0% { background-color: "+this._colors.cursor.css+"; color: "+this._colors.cursorAccent.css+"; } 50% { background-color: "+this._colors.cursorAccent.css+"; color: "+this._colors.cursor.css+"; }}",t+=this._terminalSelector+" .xterm-rows:not(.xterm-focus) ."+a.CURSOR_CLASS+"."+a.CURSOR_STYLE_BLOCK_CLASS+" { outline: 1px solid "+this._colors.cursor.css+"; outline-offset: -1px;}"+this._terminalSelector+" .xterm-rows.xterm-focus ."+a.CURSOR_CLASS+"."+a.CURSOR_BLINK_CLASS+":not(."+a.CURSOR_STYLE_BLOCK_CLASS+") { animation: blink_box_shadow_"+this._terminalClass+" 1s step-end infinite;}"+this._terminalSelector+" .xterm-rows.xterm-focus ."+a.CURSOR_CLASS+"."+a.CURSOR_BLINK_CLASS+"."+a.CURSOR_STYLE_BLOCK_CLASS+" { animation: blink_block_"+this._terminalClass+" 1s step-end infinite;}"+this._terminalSelector+" .xterm-rows.xterm-focus ."+a.CURSOR_CLASS+"."+a.CURSOR_STYLE_BLOCK_CLASS+" { background-color: "+this._colors.cursor.css+"; color: "+this._colors.cursorAccent.css+";}"+this._terminalSelector+" .xterm-rows ."+a.CURSOR_CLASS+"."+a.CURSOR_STYLE_BAR_CLASS+" { box-shadow: "+this._optionsService.options.cursorWidth+"px 0 0 "+this._colors.cursor.css+" inset;}"+this._terminalSelector+" .xterm-rows ."+a.CURSOR_CLASS+"."+a.CURSOR_STYLE_UNDERLINE_CLASS+" { box-shadow: 0 -1px 0 "+this._colors.cursor.css+" inset;}",t+=this._terminalSelector+" .xterm-selection { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}"+this._terminalSelector+" .xterm-selection div { position: absolute; background-color: "+this._colors.selection.css+";}",this._colors.ansi.forEach((function(r,i){t+=e._terminalSelector+" .xterm-fg-"+i+" { color: "+r.css+"; }"+e._terminalSelector+" .xterm-bg-"+i+" { background-color: "+r.css+"; }"})),t+=this._terminalSelector+" .xterm-fg-"+c.INVERTED_DEFAULT_COLOR+" { color: "+_.color.opaque(this._colors.background).css+"; }"+this._terminalSelector+" .xterm-bg-"+c.INVERTED_DEFAULT_COLOR+" { background-color: "+this._colors.foreground.css+"; }",this._themeStyleElement.innerHTML=t},t.prototype.onDevicePixelRatioChange=function(){this._updateDimensions()},t.prototype._refreshRowElements=function(e,t){for(var r=this._rowElements.length;r<=t;r++){var i=document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())},t.prototype.onResize=function(e,t){this._refreshRowElements(e,t),this._updateDimensions()},t.prototype.onCharSizeChanged=function(){this._updateDimensions()},t.prototype.onBlur=function(){this._rowContainer.classList.remove("xterm-focus")},t.prototype.onFocus=function(){this._rowContainer.classList.add("xterm-focus")},t.prototype.onSelectionChanged=function(e,t,r){for(;this._selectionContainer.children.length;)this._selectionContainer.removeChild(this._selectionContainer.children[0]);if(e&&t){var i=e[1]-this._bufferService.buffer.ydisp,n=t[1]-this._bufferService.buffer.ydisp,o=Math.max(i,0),s=Math.min(n,this._bufferService.rows-1);if(!(o>=this._bufferService.rows||s<0)){var a=document.createDocumentFragment();if(r)a.appendChild(this._createSelectionElement(o,e[0],t[0],s-o+1));else{var c=i===o?e[0]:0,l=o===s?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,c,l));var h=s-o-1;if(a.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,h)),o!==s){var u=n===s?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(s,0,u))}}this._selectionContainer.appendChild(a)}}},t.prototype._createSelectionElement=function(e,t,r,i){void 0===i&&(i=1);var n=document.createElement("div");return n.style.height=i*this.dimensions.actualCellHeight+"px",n.style.top=e*this.dimensions.actualCellHeight+"px",n.style.left=t*this.dimensions.actualCellWidth+"px",n.style.width=this.dimensions.actualCellWidth*(r-t)+"px",n},t.prototype.onCursorMove=function(){},t.prototype.onOptionsChanged=function(){this._updateDimensions(),this._injectCss()},t.prototype.clear=function(){this._rowElements.forEach((function(e){return e.innerHTML=""}))},t.prototype.renderRows=function(e,t){for(var r=this._bufferService.buffer.ybase+this._bufferService.buffer.y,i=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._optionsService.options.cursorBlink,o=e;o<=t;o++){var s=this._rowElements[o];s.innerHTML="";var a=o+this._bufferService.buffer.ydisp,c=this._bufferService.buffer.lines.get(a),l=this._optionsService.options.cursorStyle;s.appendChild(this._rowFactory.createRow(c,a===r,l,i,n,this.dimensions.actualCellWidth,this._bufferService.cols))}},Object.defineProperty(t.prototype,"_terminalSelector",{get:function(){return".xterm-dom-renderer-owner-"+this._terminalClass},enumerable:!0,configurable:!0}),t.prototype.registerCharacterJoiner=function(e){return-1},t.prototype.deregisterCharacterJoiner=function(e){return!1},t.prototype._onLinkHover=function(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)},t.prototype._onLinkLeave=function(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)},t.prototype._setCellUnderline=function(e,t,r,i,n,o){for(;e!==t||r!==i;){var s=this._rowElements[r];if(!s)return;var a=s.children[e];a&&(a.style.textDecoration=o?"underline":"none"),++e>=n&&(e=0,r++)}},t=o([s(6,h.ICharSizeService),s(7,u.IOptionsService),s(8,u.IBufferService)],t)}(l.Disposable);t.DomRenderer=p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(9),n=r(3),o=r(5),s=r(10);t.BOLD_CLASS="xterm-bold",t.DIM_CLASS="xterm-dim",t.ITALIC_CLASS="xterm-italic",t.UNDERLINE_CLASS="xterm-underline",t.CURSOR_CLASS="xterm-cursor",t.CURSOR_BLINK_CLASS="xterm-cursor-blink",t.CURSOR_STYLE_BLOCK_CLASS="xterm-cursor-block",t.CURSOR_STYLE_BAR_CLASS="xterm-cursor-bar",t.CURSOR_STYLE_UNDERLINE_CLASS="xterm-cursor-underline";var a=function(){function e(e,t,r){this._document=e,this._optionsService=t,this._colors=r,this._workCell=new o.CellData}return e.prototype.setColors=function(e){this._colors=e},e.prototype.createRow=function(e,r,o,a,l,h,u){for(var f=this._document.createDocumentFragment(),_=0,d=Math.min(e.length,u)-1;d>=0;d--)if(e.loadCell(d,this._workCell).getCode()!==n.NULL_CELL_CODE||r&&d===a){_=d+1;break}for(d=0;d<_;d++){e.loadCell(d,this._workCell);var p=this._workCell.getWidth();if(0!==p){var v=this._document.createElement("span");if(p>1&&(v.style.width=h*p+"px"),r&&d===a)switch(v.classList.add(t.CURSOR_CLASS),l&&v.classList.add(t.CURSOR_BLINK_CLASS),o){case"bar":v.classList.add(t.CURSOR_STYLE_BAR_CLASS);break;case"underline":v.classList.add(t.CURSOR_STYLE_UNDERLINE_CLASS);break;default:v.classList.add(t.CURSOR_STYLE_BLOCK_CLASS)}this._workCell.isBold()&&v.classList.add(t.BOLD_CLASS),this._workCell.isItalic()&&v.classList.add(t.ITALIC_CLASS),this._workCell.isDim()&&v.classList.add(t.DIM_CLASS),this._workCell.isUnderline()&&v.classList.add(t.UNDERLINE_CLASS),this._workCell.isInvisible()?v.textContent=n.WHITESPACE_CELL_CHAR:v.textContent=this._workCell.getChars()||n.WHITESPACE_CELL_CHAR;var g=this._workCell.getFgColor(),y=this._workCell.getFgColorMode(),b=this._workCell.getBgColor(),m=this._workCell.getBgColorMode(),S=!!this._workCell.isInverse();if(S){var C=g;g=b,b=C;var w=y;y=m,m=w}switch(y){case 16777216:case 33554432:this._workCell.isBold()&&g<8&&this._optionsService.options.drawBoldTextInBrightColors&&(g+=8),this._applyMinimumContrast(v,this._colors.background,this._colors.ansi[g])||v.classList.add("xterm-fg-"+g);break;case 50331648:var E=s.rgba.toColor(g>>16&255,g>>8&255,255&g);this._applyMinimumContrast(v,this._colors.background,E)||this._addStyle(v,"color:#"+c(g.toString(16),"0",6));break;case 0:default:this._applyMinimumContrast(v,this._colors.background,this._colors.foreground)||S&&v.classList.add("xterm-fg-"+i.INVERTED_DEFAULT_COLOR)}switch(m){case 16777216:case 33554432:v.classList.add("xterm-bg-"+b);break;case 50331648:this._addStyle(v,"background-color:#"+c(b.toString(16),"0",6));break;case 0:default:S&&v.classList.add("xterm-bg-"+i.INVERTED_DEFAULT_COLOR)}f.appendChild(v)}}return f},e.prototype._applyMinimumContrast=function(e,t,r){if(1===this._optionsService.options.minimumContrastRatio)return!1;var i=this._colors.contrastCache.getColor(this._workCell.bg,this._workCell.fg);return void 0===i&&(i=s.color.ensureContrastRatio(t,r,this._optionsService.options.minimumContrastRatio),this._colors.contrastCache.setColor(this._workCell.bg,this._workCell.fg,null!=i?i:null)),!!i&&(this._addStyle(e,"color:"+i.css),!0)},e.prototype._addStyle=function(e,t){e.setAttribute("style",""+(e.getAttribute("style")||"")+t+";")},e}();function c(e,t,r){for(;e.length<r;)e=t+e;return e}t.DomRendererRowFactory=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(12),n={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};t.evaluateKeyboardEvent=function(e,t,r,o){var s={type:0,cancel:!1,key:void 0},a=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:"UIKeyInputUpArrow"===e.key?s.key=t?i.C0.ESC+"OA":i.C0.ESC+"[A":"UIKeyInputLeftArrow"===e.key?s.key=t?i.C0.ESC+"OD":i.C0.ESC+"[D":"UIKeyInputRightArrow"===e.key?s.key=t?i.C0.ESC+"OC":i.C0.ESC+"[C":"UIKeyInputDownArrow"===e.key&&(s.key=t?i.C0.ESC+"OB":i.C0.ESC+"[B");break;case 8:if(e.shiftKey){s.key=i.C0.BS;break}if(e.altKey){s.key=i.C0.ESC+i.C0.DEL;break}s.key=i.C0.DEL;break;case 9:if(e.shiftKey){s.key=i.C0.ESC+"[Z";break}s.key=i.C0.HT,s.cancel=!0;break;case 13:s.key=i.C0.CR,s.cancel=!0;break;case 27:s.key=i.C0.ESC,s.cancel=!0;break;case 37:if(e.metaKey)break;a?(s.key=i.C0.ESC+"[1;"+(a+1)+"D",s.key===i.C0.ESC+"[1;3D"&&(s.key=i.C0.ESC+(r?"b":"[1;5D"))):s.key=t?i.C0.ESC+"OD":i.C0.ESC+"[D";break;case 39:if(e.metaKey)break;a?(s.key=i.C0.ESC+"[1;"+(a+1)+"C",s.key===i.C0.ESC+"[1;3C"&&(s.key=i.C0.ESC+(r?"f":"[1;5C"))):s.key=t?i.C0.ESC+"OC":i.C0.ESC+"[C";break;case 38:if(e.metaKey)break;a?(s.key=i.C0.ESC+"[1;"+(a+1)+"A",r||s.key!==i.C0.ESC+"[1;3A"||(s.key=i.C0.ESC+"[1;5A")):s.key=t?i.C0.ESC+"OA":i.C0.ESC+"[A";break;case 40:if(e.metaKey)break;a?(s.key=i.C0.ESC+"[1;"+(a+1)+"B",r||s.key!==i.C0.ESC+"[1;3B"||(s.key=i.C0.ESC+"[1;5B")):s.key=t?i.C0.ESC+"OB":i.C0.ESC+"[B";break;case 45:e.shiftKey||e.ctrlKey||(s.key=i.C0.ESC+"[2~");break;case 46:s.key=a?i.C0.ESC+"[3;"+(a+1)+"~":i.C0.ESC+"[3~";break;case 36:s.key=a?i.C0.ESC+"[1;"+(a+1)+"H":t?i.C0.ESC+"OH":i.C0.ESC+"[H";break;case 35:s.key=a?i.C0.ESC+"[1;"+(a+1)+"F":t?i.C0.ESC+"OF":i.C0.ESC+"[F";break;case 33:e.shiftKey?s.type=2:s.key=i.C0.ESC+"[5~";break;case 34:e.shiftKey?s.type=3:s.key=i.C0.ESC+"[6~";break;case 112:s.key=a?i.C0.ESC+"[1;"+(a+1)+"P":i.C0.ESC+"OP";break;case 113:s.key=a?i.C0.ESC+"[1;"+(a+1)+"Q":i.C0.ESC+"OQ";break;case 114:s.key=a?i.C0.ESC+"[1;"+(a+1)+"R":i.C0.ESC+"OR";break;case 115:s.key=a?i.C0.ESC+"[1;"+(a+1)+"S":i.C0.ESC+"OS";break;case 116:s.key=a?i.C0.ESC+"[15;"+(a+1)+"~":i.C0.ESC+"[15~";break;case 117:s.key=a?i.C0.ESC+"[17;"+(a+1)+"~":i.C0.ESC+"[17~";break;case 118:s.key=a?i.C0.ESC+"[18;"+(a+1)+"~":i.C0.ESC+"[18~";break;case 119:s.key=a?i.C0.ESC+"[19;"+(a+1)+"~":i.C0.ESC+"[19~";break;case 120:s.key=a?i.C0.ESC+"[20;"+(a+1)+"~":i.C0.ESC+"[20~";break;case 121:s.key=a?i.C0.ESC+"[21;"+(a+1)+"~":i.C0.ESC+"[21~";break;case 122:s.key=a?i.C0.ESC+"[23;"+(a+1)+"~":i.C0.ESC+"[23~";break;case 123:s.key=a?i.C0.ESC+"[24;"+(a+1)+"~":i.C0.ESC+"[24~";break;default:if(!e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)if(r&&!o||!e.altKey||e.metaKey)r&&!e.altKey&&!e.ctrlKey&&e.metaKey?65===e.keyCode&&(s.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&1===e.key.length?s.key=e.key:e.key&&e.ctrlKey&&"_"===e.key&&(s.key=i.C0.US);else{var c=n[e.keyCode],l=c&&c[e.shiftKey?1:0];if(l)s.key=i.C0.ESC+l;else if(e.keyCode>=65&&e.keyCode<=90){var h=e.ctrlKey?e.keyCode-64:e.keyCode+32;s.key=i.C0.ESC+String.fromCharCode(h)}}else e.keyCode>=65&&e.keyCode<=90?s.key=String.fromCharCode(e.keyCode-64):32===e.keyCode?s.key=i.C0.NUL:e.keyCode>=51&&e.keyCode<=55?s.key=String.fromCharCode(e.keyCode-51+27):56===e.keyCode?s.key=i.C0.DEL:219===e.keyCode?s.key=i.C0.ESC:220===e.keyCode?s.key=i.C0.FS:221===e.keyCode&&(s.key=i.C0.GS)}return s}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(3);t.updateWindowsModeWrappedState=function(e){var t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1),r=null==t?void 0:t.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&r&&(n.isWrapped=r[i.CHAR_DATA_CODE_INDEX]!==i.NULL_CELL_CODE&&r[i.CHAR_DATA_CODE_INDEX]!==i.WHITESPACE_CELL_CODE)}},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var a=r(29),c=r(0),l=r(2),h=r(30),u=r(8),f=r(1),_=r(4),d=function(e){function t(t,r,i,n,o){var s=e.call(this)||this;if(s._renderer=t,s._rowCount=r,s.screenElement=i,s.optionsService=n,s.charSizeService=o,s._isPaused=!1,s._needsFullRefresh=!1,s._canvasWidth=0,s._canvasHeight=0,s._onDimensionsChange=new c.EventEmitter,s._onRender=new c.EventEmitter,s._onRefreshRequest=new c.EventEmitter,s._renderDebouncer=new a.RenderDebouncer((function(e,t){return s._renderRows(e,t)})),s.register(s._renderDebouncer),s._screenDprMonitor=new h.ScreenDprMonitor,s._screenDprMonitor.setListener((function(){return s.onDevicePixelRatioChange()})),s.register(s._screenDprMonitor),s.register(n.onOptionChange((function(){return s._renderer.onOptionsChanged()}))),s.register(o.onCharSizeChange((function(){return s.onCharSizeChanged()}))),s._renderer.onRequestRefreshRows((function(e){return s.refreshRows(e.start,e.end)})),s.register(u.addDisposableDomListener(window,"resize",(function(){return s.onDevicePixelRatioChange()}))),"IntersectionObserver"in window){var l=new IntersectionObserver((function(e){return s._onIntersectionChange(e[e.length-1])}),{threshold:0});l.observe(i),s.register({dispose:function(){return l.disconnect()}})}return s}return n(t,e),Object.defineProperty(t.prototype,"onDimensionsChange",{get:function(){return this._onDimensionsChange.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onRender",{get:function(){return this._onRender.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onRefreshRequest",{get:function(){return this._onRefreshRequest.event},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dimensions",{get:function(){return this._renderer.dimensions},enumerable:!0,configurable:!0}),t.prototype._onIntersectionChange=function(e){this._isPaused=0===e.intersectionRatio,!this._isPaused&&this._needsFullRefresh&&(this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)},t.prototype.refreshRows=function(e,t){this._isPaused?this._needsFullRefresh=!0:this._renderDebouncer.refresh(e,t,this._rowCount)},t.prototype._renderRows=function(e,t){this._renderer.renderRows(e,t),this._onRender.fire({start:e,end:t})},t.prototype.resize=function(e,t){this._rowCount=t,this._fireOnCanvasResize()},t.prototype.changeOptions=function(){this._renderer.onOptionsChanged(),this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize()},t.prototype._fireOnCanvasResize=function(){this._renderer.dimensions.canvasWidth===this._canvasWidth&&this._renderer.dimensions.canvasHeight===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.dimensions)},t.prototype.dispose=function(){this._renderer.dispose(),e.prototype.dispose.call(this)},t.prototype.setRenderer=function(e){var t=this;this._renderer.dispose(),this._renderer=e,this._renderer.onRequestRefreshRows((function(e){return t.refreshRows(e.start,e.end)})),this.refreshRows(0,this._rowCount-1)},t.prototype._fullRefresh=function(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)},t.prototype.setColors=function(e){this._renderer.setColors(e),this._fullRefresh()},t.prototype.onDevicePixelRatioChange=function(){this._renderer.onDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1)},t.prototype.onResize=function(e,t){this._renderer.onResize(e,t),this._fullRefresh()},t.prototype.onCharSizeChanged=function(){this._renderer.onCharSizeChanged()},t.prototype.onBlur=function(){this._renderer.onBlur()},t.prototype.onFocus=function(){this._renderer.onFocus()},t.prototype.onSelectionChanged=function(e,t,r){this._renderer.onSelectionChanged(e,t,r)},t.prototype.onCursorMove=function(){this._renderer.onCursorMove()},t.prototype.clear=function(){this._renderer.clear()},t.prototype.registerCharacterJoiner=function(e){return this._renderer.registerCharacterJoiner(e)},t.prototype.deregisterCharacterJoiner=function(e){return this._renderer.deregisterCharacterJoiner(e)},t=o([s(3,f.IOptionsService),s(4,_.ICharSizeService)],t)}(l.Disposable);t.RenderService=d},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(11),o=r(31);t.DEFAULT_BELL_SOUND="data:audio/mp3;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjMyLjEwNAAAAAAAAAAAAAAA//tQxAADB8AhSmxhIIEVCSiJrDCQBTcu3UrAIwUdkRgQbFAZC1CQEwTJ9mjRvBA4UOLD8nKVOWfh+UlK3z/177OXrfOdKl7pyn3Xf//WreyTRUoAWgBgkOAGbZHBgG1OF6zM82DWbZaUmMBptgQhGjsyYqc9ae9XFz280948NMBWInljyzsNRFLPWdnZGWrddDsjK1unuSrVN9jJsK8KuQtQCtMBjCEtImISdNKJOopIpBFpNSMbIHCSRpRR5iakjTiyzLhchUUBwCgyKiweBv/7UsQbg8isVNoMPMjAAAA0gAAABEVFGmgqK////9bP/6XCykxBTUUzLjEwMKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq",t.DEFAULT_OPTIONS=Object.freeze({cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,bellSound:t.DEFAULT_BELL_SOUND,bellStyle:"none",drawBoldTextInBrightColors:!0,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",lineHeight:1,letterSpacing:0,logLevel:"info",scrollback:1e3,scrollSensitivity:1,screenReaderMode:!1,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rightClickSelectsWord:n.isMac,rendererType:"canvas",windowOptions:{},windowsMode:!1,wordSeparator:" ()[]{}',\"`",convertEol:!1,termName:"xterm",cancelEvents:!1});var s=["cols","rows"],a=function(){function e(e){var r=this;this._onOptionChange=new i.EventEmitter,this.options=o.clone(t.DEFAULT_OPTIONS),Object.keys(e).forEach((function(t){if(t in r.options){var i=e[t];r.options[t]=i}}))}return Object.defineProperty(e.prototype,"onOptionChange",{get:function(){return this._onOptionChange.event},enumerable:!0,configurable:!0}),e.prototype.setOption=function(e,r){if(!(e in t.DEFAULT_OPTIONS))throw new Error('No option with key "'+e+'"');if(-1!==s.indexOf(e))throw new Error('Option "'+e+'" can only be set in the constructor');this.options[e]!==r&&(r=this._sanitizeAndValidateOption(e,r),this.options[e]!==r&&(this.options[e]=r,this._onOptionChange.fire(e)))},e.prototype._sanitizeAndValidateOption=function(e,r){switch(e){case"bellStyle":case"cursorStyle":case"fontWeight":case"fontWeightBold":case"rendererType":case"wordSeparator":r||(r=t.DEFAULT_OPTIONS[e]);break;case"cursorWidth":r=Math.floor(r);case"lineHeight":case"tabStopWidth":if(r<1)throw new Error(e+" cannot be less than 1, value: "+r);break;case"minimumContrastRatio":r=Math.max(1,Math.min(21,Math.round(10*r)/10));break;case"scrollback":if((r=Math.min(r,4294967295))<0)throw new Error(e+" cannot be less than 0, value: "+r);break;case"fastScrollSensitivity":case"scrollSensitivity":if(r<=0)throw new Error(e+" cannot be less than or equal to 0, value: "+r)}return r},e.prototype.getOption=function(e){if(!(e in t.DEFAULT_OPTIONS))throw new Error('No option with key "'+e+'"');return this.options[e]},e}();t.OptionsService=a},function(e,t,r){"use strict";var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),s=r(0),a=function(){function e(e,t,r){this.document=e,this.parentElement=t,this._optionsService=r,this.width=0,this.height=0,this._onCharSizeChange=new s.EventEmitter,this._measureStrategy=new c(e,t,this._optionsService)}return Object.defineProperty(e.prototype,"hasValidSize",{get:function(){return this.width>0&&this.height>0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onCharSizeChange",{get:function(){return this._onCharSizeChange.event},enumerable:!0,configurable:!0}),e.prototype.measure=function(){var e=this._measureStrategy.measure();e.width===this.width&&e.height===this.height||(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())},e=i([n(2,o.IOptionsService)],e)}();t.CharSizeService=a;var c=function(){function e(e,t,r){this._document=e,this._parentElement=t,this._optionsService=r,this._result={width:0,height:0},this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W",this._measureElement.setAttribute("aria-hidden","true"),this._parentElement.appendChild(this._measureElement)}return e.prototype.measure=function(){this._measureElement.style.fontFamily=this._optionsService.options.fontFamily,this._measureElement.style.fontSize=this._optionsService.options.fontSize+"px";var e=this._measureElement.getBoundingClientRect();return 0!==e.width&&0!==e.height&&(this._result.width=e.width,this._result.height=Math.ceil(e.height)),this._result},e}()},function(e,t,r){"use strict";var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),s=r(64);t.MINIMUM_COLS=2,t.MINIMUM_ROWS=1;var a=function(){function e(e){this._optionsService=e,this.cols=Math.max(e.options.cols,t.MINIMUM_COLS),this.rows=Math.max(e.options.rows,t.MINIMUM_ROWS),this.buffers=new s.BufferSet(e,this)}return Object.defineProperty(e.prototype,"buffer",{get:function(){return this.buffers.active},enumerable:!0,configurable:!0}),e.prototype.resize=function(e,t){this.cols=e,this.rows=t},e.prototype.reset=function(){this.buffers=new s.BufferSet(this._optionsService,this)},e=i([n(0,o.IOptionsService)],e)}();t.BufferService=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(65),n=r(0),o=function(){function e(e,t){this.optionsService=e,this.bufferService=t,this._onBufferActivate=new n.EventEmitter,this._normal=new i.Buffer(!0,e,t),this._normal.fillViewportRows(),this._alt=new i.Buffer(!1,e,t),this._activeBuffer=this._normal,this.setupTabStops()}return Object.defineProperty(e.prototype,"onBufferActivate",{get:function(){return this._onBufferActivate.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alt",{get:function(){return this._alt},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"active",{get:function(){return this._activeBuffer},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"normal",{get:function(){return this._normal},enumerable:!0,configurable:!0}),e.prototype.activateNormalBuffer=function(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))},e.prototype.activateAltBuffer=function(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))},e.prototype.resize=function(e,t){this._normal.resize(e,t),this._alt.resize(e,t)},e.prototype.setupTabStops=function(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)},e}();t.BufferSet=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(66),n=r(16),o=r(5),s=r(3),a=r(67),c=r(68),l=r(18);t.MAX_BUFFER_SIZE=4294967295;var h=function(){function e(e,t,r){this._hasScrollback=e,this._optionsService=t,this._bufferService=r,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.savedY=0,this.savedX=0,this.savedCurAttrData=n.DEFAULT_ATTR_DATA.clone(),this.savedCharset=l.DEFAULT_CHARSET,this.markers=[],this._nullCell=o.CellData.fromCharData([0,s.NULL_CELL_CHAR,s.NULL_CELL_WIDTH,s.NULL_CELL_CODE]),this._whitespaceCell=o.CellData.fromCharData([0,s.WHITESPACE_CELL_CHAR,s.WHITESPACE_CELL_WIDTH,s.WHITESPACE_CELL_CODE]),this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new i.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}return e.prototype.getNullCell=function(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg):(this._nullCell.fg=0,this._nullCell.bg=0),this._nullCell},e.prototype.getWhitespaceCell=function(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0),this._whitespaceCell},e.prototype.getBlankLine=function(e,t){return new n.BufferLine(this._bufferService.cols,this.getNullCell(e),t)},Object.defineProperty(e.prototype,"hasScrollback",{get:function(){return this._hasScrollback&&this.lines.maxLength>this._rows},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isCursorInViewport",{get:function(){var e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows},enumerable:!0,configurable:!0}),e.prototype._getCorrectBufferLength=function(e){if(!this._hasScrollback)return e;var r=e+this._optionsService.options.scrollback;return r>t.MAX_BUFFER_SIZE?t.MAX_BUFFER_SIZE:r},e.prototype.fillViewportRows=function(e){if(0===this.lines.length){void 0===e&&(e=n.DEFAULT_ATTR_DATA);for(var t=this._rows;t--;)this.lines.push(this.getBlankLine(e))}},e.prototype.clear=function(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new i.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()},e.prototype.resize=function(e,t){var r=this.getNullCell(n.DEFAULT_ATTR_DATA),i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(var o=0;o<this.lines.length;o++)this.lines.get(o).resize(e,r);var s=0;if(this._rows<t)for(var a=this._rows;a<t;a++)this.lines.length<t+this.ybase&&(this._optionsService.options.windowsMode?this.lines.push(new n.BufferLine(e,r)):this.ybase>0&&this.lines.length<=this.ybase+this.y+s+1?(this.ybase--,s++,this.ydisp>0&&this.ydisp--):this.lines.push(new n.BufferLine(e,r)));else for(a=this._rows;a>t;a--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){var c=this.lines.length-i;c>0&&(this.lines.trimStart(c),this.ybase=Math.max(this.ybase-c,0),this.ydisp=Math.max(this.ydisp-c,0),this.savedY=Math.max(this.savedY-c,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),s&&(this.y+=s),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(o=0;o<this.lines.length;o++)this.lines.get(o).resize(e,r);this._cols=e,this._rows=t},Object.defineProperty(e.prototype,"_isReflowEnabled",{get:function(){return this._hasScrollback&&!this._optionsService.options.windowsMode},enumerable:!0,configurable:!0}),e.prototype._reflow=function(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))},e.prototype._reflowLarger=function(e,t){var r=a.reflowLargerGetLinesToRemove(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(n.DEFAULT_ATTR_DATA));if(r.length>0){var i=a.reflowLargerCreateNewLayout(this.lines,r);a.reflowLargerApplyNewLayout(this.lines,i.layout),this._reflowLargerAdjustViewport(e,t,i.countRemoved)}},e.prototype._reflowLargerAdjustViewport=function(e,t,r){for(var i=this.getNullCell(n.DEFAULT_ATTR_DATA),o=r;o-- >0;)0===this.ybase?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new n.BufferLine(e,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-r,0)},e.prototype._reflowSmaller=function(e,t){for(var r=this.getNullCell(n.DEFAULT_ATTR_DATA),i=[],o=0,s=this.lines.length-1;s>=0;s--){var c=this.lines.get(s);if(!(!c||!c.isWrapped&&c.getTrimmedLength()<=e)){for(var l=[c];c.isWrapped&&s>0;)c=this.lines.get(--s),l.unshift(c);var h=this.ybase+this.y;if(!(h>=s&&h<s+l.length)){var u=l[l.length-1].getTrimmedLength(),f=a.reflowSmallerGetNewLineLengths(l,this._cols,e),_=f.length-l.length,d=void 0;d=0===this.ybase&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+_):Math.max(0,this.lines.length-this.lines.maxLength+_);for(var p=[],v=0;v<_;v++){var g=this.getBlankLine(n.DEFAULT_ATTR_DATA,!0);p.push(g)}p.length>0&&(i.push({start:s+l.length+o,newLines:p}),o+=p.length),l.push.apply(l,p);var y=f.length-1,b=f[y];0===b&&(b=f[--y]);for(var m=l.length-_-1,S=u;m>=0;){var C=Math.min(S,b);if(l[y].copyCellsFrom(l[m],S-C,b-C,C,!0),0===(b-=C)&&(b=f[--y]),0===(S-=C)){m--;var w=Math.max(m,0);S=a.getWrappedLineTrimmedLength(l,w,this._cols)}}for(v=0;v<l.length;v++)f[v]<e&&l[v].setCell(f[v],r);for(var E=_-d;E-- >0;)0===this.ybase?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+_,this.ybase+t-1)}}}if(i.length>0){var L=[],A=[];for(v=0;v<this.lines.length;v++)A.push(this.lines.get(v));var k=this.lines.length,R=k-1,x=0,D=i[x];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);var T=0;for(v=Math.min(this.lines.maxLength-1,k+o-1);v>=0;v--)if(D&&D.start>R+T){for(var M=D.newLines.length-1;M>=0;M--)this.lines.set(v--,D.newLines[M]);v++,L.push({index:R+1,amount:D.newLines.length}),T+=D.newLines.length,D=i[++x]}else this.lines.set(v,A[R--]);var O=0;for(v=L.length-1;v>=0;v--)L[v].index+=O,this.lines.onInsertEmitter.fire(L[v]),O+=L[v].amount;var P=Math.max(0,k+o-this.lines.maxLength);P>0&&this.lines.onTrimEmitter.fire(P)}},e.prototype.stringIndexToBufferIndex=function(e,t,r){for(void 0===r&&(r=!1);t;){var i=this.lines.get(e);if(!i)return[-1,-1];for(var n=r?i.getTrimmedLength():i.length,o=0;o<n;++o)if(i.get(o)[s.CHAR_DATA_WIDTH_INDEX]&&(t-=i.get(o)[s.CHAR_DATA_CHAR_INDEX].length||1),t<0)return[e,o];e++}return[e,0]},e.prototype.translateBufferLineToString=function(e,t,r,i){void 0===r&&(r=0);var n=this.lines.get(e);return n?n.translateToString(t,r,i):""},e.prototype.getWrappedRangeForLine=function(e){for(var t=e,r=e;t>0&&this.lines.get(t).isWrapped;)t--;for(;r+1<this.lines.length&&this.lines.get(r+1).isWrapped;)r++;return{first:t,last:r}},e.prototype.setupTabStops=function(e){for(null!=e?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.options.tabStopWidth)this.tabs[e]=!0},e.prototype.prevStop=function(e){for(null==e&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e},e.prototype.nextStop=function(e){for(null==e&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e},e.prototype.addMarker=function(e){var t=this,r=new c.Marker(e);return this.markers.push(r),r.register(this.lines.onTrim((function(e){r.line-=e,r.line<0&&r.dispose()}))),r.register(this.lines.onInsert((function(e){r.line>=e.index&&(r.line+=e.amount)}))),r.register(this.lines.onDelete((function(e){r.line>=e.index&&r.line<e.index+e.amount&&r.dispose(),r.line>e.index&&(r.line-=e.amount)}))),r.register(r.onDispose((function(){return t._removeMarker(r)}))),r},e.prototype._removeMarker=function(e){this.markers.splice(this.markers.indexOf(e),1)},e.prototype.iterator=function(e,t,r,i,n){return new u(this,e,t,r,i,n)},e}();t.Buffer=h;var u=function(){function e(e,t,r,i,n,o){void 0===r&&(r=0),void 0===i&&(i=e.lines.length),void 0===n&&(n=0),void 0===o&&(o=0),this._buffer=e,this._trimRight=t,this._startIndex=r,this._endIndex=i,this._startOverscan=n,this._endOverscan=o,this._startIndex<0&&(this._startIndex=0),this._endIndex>this._buffer.lines.length&&(this._endIndex=this._buffer.lines.length),this._current=this._startIndex}return e.prototype.hasNext=function(){return this._current<this._endIndex},e.prototype.next=function(){var e=this._buffer.getWrappedRangeForLine(this._current);e.first<this._startIndex-this._startOverscan&&(e.first=this._startIndex-this._startOverscan),e.last>this._endIndex+this._endOverscan&&(e.last=this._endIndex+this._endOverscan),e.first=Math.max(e.first,0),e.last=Math.min(e.last,this._buffer.lines.length);for(var t="",r=e.first;r<=e.last;++r)t+=this._buffer.translateBufferLineToString(r,this._trimRight);return this._current=e.last+1,{range:e,content:t}},e}();t.BufferStringIterator=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(){function e(e){this._maxLength=e,this.onDeleteEmitter=new i.EventEmitter,this.onInsertEmitter=new i.EventEmitter,this.onTrimEmitter=new i.EventEmitter,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}return Object.defineProperty(e.prototype,"onDelete",{get:function(){return this.onDeleteEmitter.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onInsert",{get:function(){return this.onInsertEmitter.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onTrim",{get:function(){return this.onTrimEmitter.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxLength",{get:function(){return this._maxLength},set:function(e){if(this._maxLength!==e){for(var t=new Array(e),r=0;r<Math.min(e,this.length);r++)t[r]=this._array[this._getCyclicIndex(r)];this._array=t,this._maxLength=e,this._startIndex=0}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._length},set:function(e){if(e>this._length)for(var t=this._length;t<e;t++)this._array[t]=void 0;this._length=e},enumerable:!0,configurable:!0}),e.prototype.get=function(e){return this._array[this._getCyclicIndex(e)]},e.prototype.set=function(e,t){this._array[this._getCyclicIndex(e)]=t},e.prototype.push=function(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++},e.prototype.recycle=function(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]},Object.defineProperty(e.prototype,"isFull",{get:function(){return this._length===this._maxLength},enumerable:!0,configurable:!0}),e.prototype.pop=function(){return this._array[this._getCyclicIndex(this._length---1)]},e.prototype.splice=function(e,t){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];if(t){for(var n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t}for(n=this._length-1;n>=e;n--)this._array[this._getCyclicIndex(n+r.length)]=this._array[this._getCyclicIndex(n)];for(n=0;n<r.length;n++)this._array[this._getCyclicIndex(e+n)]=r[n];if(this._length+r.length>this._maxLength){var o=this._length+r.length-this._maxLength;this._startIndex+=o,this._length=this._maxLength,this.onTrimEmitter.fire(o)}else this._length+=r.length},e.prototype.trimStart=function(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)},e.prototype.shiftElements=function(e,t,r){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+r<0)throw new Error("Cannot shift elements in list beyond index 0");if(r>0){for(var i=t-1;i>=0;i--)this.set(e+i+r,this.get(e+i));var n=e+t+r-this._length;if(n>0)for(this._length+=n;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(i=0;i<t;i++)this.set(e+i+r,this.get(e+i))}},e.prototype._getCyclicIndex=function(e){return(this._startIndex+e)%this._maxLength},e}();t.CircularList=n},function(e,t,r){"use strict";function i(e,t,r){if(t===e.length-1)return e[t].getTrimmedLength();var i=!e[t].hasContent(r-1)&&1===e[t].getWidth(r-1),n=2===e[t+1].getWidth(0);return i&&n?r-1:r}Object.defineProperty(t,"__esModule",{value:!0}),t.reflowLargerGetLinesToRemove=function(e,t,r,n,o){for(var s=[],a=0;a<e.length-1;a++){var c=a,l=e.get(++c);if(l.isWrapped){for(var h=[e.get(a)];c<e.length&&l.isWrapped;)h.push(l),l=e.get(++c);if(n>=a&&n<c)a+=h.length-1;else{for(var u=0,f=i(h,u,t),_=1,d=0;_<h.length;){var p=i(h,_,t),v=p-d,g=r-f,y=Math.min(v,g);h[u].copyCellsFrom(h[_],d,f,y,!1),(f+=y)===r&&(u++,f=0),(d+=y)===p&&(_++,d=0),0===f&&0!==u&&2===h[u-1].getWidth(r-1)&&(h[u].copyCellsFrom(h[u-1],r-1,f++,1,!1),h[u-1].setCell(r-1,o))}h[u].replaceCells(f,r,o);for(var b=0,m=h.length-1;m>0&&(m>u||0===h[m].getTrimmedLength());m--)b++;b>0&&(s.push(a+h.length-b),s.push(b)),a+=h.length-1}}}return s},t.reflowLargerCreateNewLayout=function(e,t){for(var r=[],i=0,n=t[i],o=0,s=0;s<e.length;s++)if(n===s){var a=t[++i];e.onDeleteEmitter.fire({index:s-o,amount:a}),s+=a-1,o+=a,n=t[++i]}else r.push(s);return{layout:r,countRemoved:o}},t.reflowLargerApplyNewLayout=function(e,t){for(var r=[],i=0;i<t.length;i++)r.push(e.get(t[i]));for(i=0;i<r.length;i++)e.set(i,r[i]);e.length=t.length},t.reflowSmallerGetNewLineLengths=function(e,t,r){for(var n=[],o=e.map((function(r,n){return i(e,n,t)})).reduce((function(e,t){return e+t})),s=0,a=0,c=0;c<o;){if(o-c<r){n.push(o-c);break}s+=r;var l=i(e,a,t);s>l&&(s-=l,a++);var h=2===e[a].getWidth(s-1);h&&s--;var u=h?r-1:r;n.push(u),c+=u}return n},t.getWrappedLineTrimmedLength=i},function(e,t,r){"use strict";var i,n=this&&this.__extends||(i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var o=r(0),s=function(e){function t(r){var i=e.call(this)||this;return i.line=r,i._id=t._nextId++,i.isDisposed=!1,i._onDispose=new o.EventEmitter,i}return n(t,e),Object.defineProperty(t.prototype,"id",{get:function(){return this._id},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onDispose",{get:function(){return this._onDispose.event},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire())},t._nextId=1,t}(r(2).Disposable);t.Marker=s},function(e,t,r){"use strict";var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(4),s=r(28),a=function(){function e(e,t){this._renderService=e,this._charSizeService=t}return e.prototype.getCoords=function(e,t,r,i,n){return s.getCoords(e,t,r,i,this._charSizeService.hasValidSize,this._renderService.dimensions.actualCellWidth,this._renderService.dimensions.actualCellHeight,n)},e.prototype.getRawByteCoords=function(e,t,r,i){var n=this.getCoords(e,t,r,i);return s.getRawByteCoords(n)},e=i([n(0,o.IRenderService),n(1,o.ICharSizeService)],e)}();t.MouseService=a},function(e,t,r){"use strict";var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),s=r(0),a=r(31),c=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,origin:!1,wraparound:!0}),l=function(){function e(e,t,r,i){this._scrollToBottom=e,this._bufferService=t,this._logService=r,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=new s.EventEmitter,this._onUserInput=new s.EventEmitter,this._onBinary=new s.EventEmitter,this.decPrivateModes=a.clone(c)}return Object.defineProperty(e.prototype,"onData",{get:function(){return this._onData.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onUserInput",{get:function(){return this._onUserInput.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onBinary",{get:function(){return this._onBinary.event},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this.decPrivateModes=a.clone(c)},e.prototype.triggerDataEvent=function(e,t){if(void 0===t&&(t=!1),!this._optionsService.options.disableStdin){var r=this._bufferService.buffer;r.ybase!==r.ydisp&&this._scrollToBottom(),t&&this._onUserInput.fire(),this._logService.debug('sending data "'+e+'"',(function(){return e.split("").map((function(e){return e.charCodeAt(0)}))})),this._onData.fire(e)}},e.prototype.triggerBinaryEvent=function(e){this._optionsService.options.disableStdin||(this._logService.debug('sending binary "'+e+'"',(function(){return e.split("").map((function(e){return e.charCodeAt(0)}))})),this._onBinary.fire(e))},e=i([n(1,o.IBufferService),n(2,o.ILogService),n(3,o.IOptionsService)],e)}();t.CoreService=l},function(e,t,r){"use strict";var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}},o=this&&this.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var i=Array(e),n=0;for(t=0;t<r;t++)for(var o=arguments[t],s=0,a=o.length;s<a;s++,n++)i[n]=o[s];return i};Object.defineProperty(t,"__esModule",{value:!0});var s,a=r(1);!function(e){e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e[e.OFF=4]="OFF"}(s=t.LogLevel||(t.LogLevel={}));var c={debug:s.DEBUG,info:s.INFO,warn:s.WARN,error:s.ERROR,off:s.OFF},l=function(){function e(e){var t=this;this._optionsService=e,this._updateLogLevel(),this._optionsService.onOptionChange((function(e){"logLevel"===e&&t._updateLogLevel()}))}return e.prototype._updateLogLevel=function(){this._logLevel=c[this._optionsService.options.logLevel]},e.prototype._evalLazyOptionalParams=function(e){for(var t=0;t<e.length;t++)"function"==typeof e[t]&&(e[t]=e[t]())},e.prototype._log=function(e,t,r){this._evalLazyOptionalParams(r),e.call.apply(e,o([console,"xterm.js: "+t],r))},e.prototype.debug=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this._logLevel<=s.DEBUG&&this._log(console.log,e,t)},e.prototype.info=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this._logLevel<=s.INFO&&this._log(console.info,e,t)},e.prototype.warn=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this._logLevel<=s.WARN&&this._log(console.warn,e,t)},e.prototype.error=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];this._logLevel<=s.ERROR&&this._log(console.error,e,t)},e=i([n(0,a.IOptionsService)],e)}();t.LogService=l},function(e,t,r){"use strict";var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),s=function(){function e(e){this._bufferService=e,this.clearRange()}return Object.defineProperty(e.prototype,"start",{get:function(){return this._start},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"end",{get:function(){return this._end},enumerable:!0,configurable:!0}),e.prototype.clearRange=function(){this._start=this._bufferService.buffer.y,this._end=this._bufferService.buffer.y},e.prototype.markDirty=function(e){e<this._start?this._start=e:e>this._end&&(this._end=e)},e.prototype.markRangeDirty=function(e,t){if(e>t){var r=e;e=t,t=r}e<this._start&&(this._start=e),t>this._end&&(this._end=t)},e.prototype.markAllDirty=function(){this.markRangeDirty(0,this._bufferService.rows-1)},e=i([n(0,o.IBufferService)],e)}();t.DirtyRowService=s},function(e,t,r){"use strict";var i=this&&this.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var i=Array(e),n=0;for(t=0;t<r;t++)for(var o=arguments[t],s=0,a=o.length;s<a;s++,n++)i[n]=o[s];return i};Object.defineProperty(t,"__esModule",{value:!0});var n=r(1),o=r(14),s=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._entries=new Map;for(var r=0,i=e;r<i.length;r++){var n=i[r],o=n[0],s=n[1];this.set(o,s)}}return e.prototype.set=function(e,t){var r=this._entries.get(e);return this._entries.set(e,t),r},e.prototype.forEach=function(e){this._entries.forEach((function(t,r){return e(r,t)}))},e.prototype.has=function(e){return this._entries.has(e)},e.prototype.get=function(e){return this._entries.get(e)},e}();t.ServiceCollection=s;var a=function(){function e(){this._services=new s,this._services.set(n.IInstantiationService,this)}return e.prototype.setService=function(e,t){this._services.set(e,t)},e.prototype.getService=function(e){return this._services.get(e)},e.prototype.createInstance=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];for(var n=o.getServiceDependencies(e).sort((function(e,t){return e.index-t.index})),s=[],a=0,c=n;a<c.length;a++){var l=c[a],h=this._services.get(l.id);if(!h)throw new Error("[createInstance] "+e.name+" depends on UNKNOWN service "+l.id+".");s.push(h)}var u=n.length>0?n[0].index:t.length;if(t.length!==u)throw new Error("[createInstance] First service dependency of "+e.name+" at position "+(u+1)+" conflicts with "+t.length+" static arguments");return new(e.bind.apply(e,i([void 0],i(t,s))))},e}();t.InstantiationService=a},function(e,t,r){"use strict";var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__param||function(e,t){return function(r,i){t(r,i,e)}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),s=r(0),a={NONE:{events:0,restrict:function(){return!1}},X10:{events:1,restrict:function(e){return 4!==e.button&&1===e.action&&(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)}},VT200:{events:19,restrict:function(e){return 32!==e.action}},DRAG:{events:23,restrict:function(e){return 32!==e.action||3!==e.button}},ANY:{events:31,restrict:function(e){return!0}}};function c(e,t){var r=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return 4===e.button?(r|=64,r|=e.action):(r|=3&e.button,4&e.button&&(r|=64),8&e.button&&(r|=128),32===e.action?r|=32:0!==e.action||t||(r|=3)),r}var l=String.fromCharCode,h={DEFAULT:function(e){var t=[c(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":""+l(t[0])+l(t[1])+l(t[2])},SGR:function(e){var t=0===e.action&&4!==e.button?"m":"M";return"[<"+c(e,!0)+";"+e.col+";"+e.row+t}},u=function(){function e(e,t){var r=this;this._bufferService=e,this._coreService=t,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._onProtocolChange=new s.EventEmitter,this._lastEvent=null,Object.keys(a).forEach((function(e){return r.addProtocol(e,a[e])})),Object.keys(h).forEach((function(e){return r.addEncoding(e,h[e])})),this.reset()}return e.prototype.addProtocol=function(e,t){this._protocols[e]=t},e.prototype.addEncoding=function(e,t){this._encodings[e]=t},Object.defineProperty(e.prototype,"activeProtocol",{get:function(){return this._activeProtocol},set:function(e){if(!this._protocols[e])throw new Error('unknown protocol "'+e+'"');this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"activeEncoding",{get:function(){return this._activeEncoding},set:function(e){if(!this._encodings[e])throw new Error('unknown encoding "'+e+'"');this._activeEncoding=e},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null},Object.defineProperty(e.prototype,"onProtocolChange",{get:function(){return this._onProtocolChange.event},enumerable:!0,configurable:!0}),e.prototype.triggerMouseEvent=function(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows)return!1;if(4===e.button&&32===e.action)return!1;if(3===e.button&&32!==e.action)return!1;if(4!==e.button&&(2===e.action||3===e.action))return!1;if(e.col++,e.row++,32===e.action&&this._lastEvent&&this._compareEvents(this._lastEvent,e))return!1;if(!this._protocols[this._activeProtocol].restrict(e))return!1;var t=this._encodings[this._activeEncoding](e);return t&&("DEFAULT"===this._activeEncoding?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0},e.prototype.explainEvents=function(e){return{down:!!(1&e),up:!!(2&e),drag:!!(4&e),move:!!(8&e),wheel:!!(16&e)}},e.prototype._compareEvents=function(e,t){return e.col===t.col&&(e.row===t.row&&(e.button===t.button&&(e.action===t.action&&(e.ctrl===t.ctrl&&(e.alt===t.alt&&e.shift===t.shift)))))},e=i([n(0,o.IBufferService),n(1,o.ICoreService)],e)}();t.CoreMouseService=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0}return e.prototype.writeSync=function(e){if(this._writeBuffer.length){for(var t=this._bufferOffset;t<this._writeBuffer.length;++t){var r=this._writeBuffer[t],i=this._callbacks[t];this._action(r),i&&i()}this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=2147483647}this._action(e)},e.prototype.write=function(e,t){var r=this;if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");this._writeBuffer.length||(this._bufferOffset=0,setTimeout((function(){return r._innerWrite()}))),this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)},e.prototype._innerWrite=function(){for(var e=this,t=Date.now();this._writeBuffer.length>this._bufferOffset;){var r=this._writeBuffer[this._bufferOffset],i=this._callbacks[this._bufferOffset];if(this._bufferOffset++,this._action(r),this._pendingData-=r.length,i&&i(),Date.now()-t>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((function(){return e._innerWrite()}),0)):(this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0)},e}();t.WriteBuffer=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=function(){function e(e){this._bufferService=e,this._linkProviders=[],this._linkCacheDisposables=[],this._onLinkHover=new i.EventEmitter,this._onLinkLeave=new i.EventEmitter}return Object.defineProperty(e.prototype,"onLinkHover",{get:function(){return this._onLinkHover.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onLinkLeave",{get:function(){return this._onLinkLeave.event},enumerable:!0,configurable:!0}),e.prototype.registerLinkProvider=function(e){var t=this;return this._linkProviders.push(e),{dispose:function(){var r=t._linkProviders.indexOf(e);-1!==r&&t._linkProviders.splice(r,1)}}},e.prototype.attachToDom=function(e,t,r){this._element=e,this._mouseService=t,this._renderService=r,this._element.addEventListener("mousemove",this._onMouseMove.bind(this)),this._element.addEventListener("click",this._onMouseDown.bind(this))},e.prototype._onMouseMove=function(e){if(this._lastMouseEvent=e,this._element&&this._mouseService){var t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&(this._lastBufferCell&&t.x===this._lastBufferCell.x&&t.y===this._lastBufferCell.y||(this._onHover(t),this._lastBufferCell=t))}},e.prototype._onHover=function(e){this._currentLink?this._linkAtPosition(this._currentLink,e)||(this._clearCurrentLink(),this._askForLink(e)):this._askForLink(e)},e.prototype._askForLink=function(e){var t=this,r=new Map,i=!1;this._linkProviders.forEach((function(n,o){n.provideLink(e,(function(e){r.set(o,e);for(var n=!1,s=0;s<o;s++)r.has(s)&&!r.get(s)||(n=!0);if(!n&&e&&(i=!0,t._handleNewLink(e)),r.size===t._linkProviders.length&&!i)for(s=0;s<r.size;s++){var a=r.get(s);if(a){t._handleNewLink(a);break}}}))}))},e.prototype._onMouseDown=function(e){if(this._element&&this._mouseService&&this._currentLink){var t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._linkAtPosition(this._currentLink,t)&&this._currentLink.activate(e,this._currentLink.text)}},e.prototype._clearCurrentLink=function(e,t){this._element&&this._currentLink&&this._lastMouseEvent&&(!e||!t||this._currentLink.range.start.y>=e&&this._currentLink.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink,this._lastMouseEvent),this._currentLink=void 0,this._linkCacheDisposables.forEach((function(e){return e.dispose()})),this._linkCacheDisposables=[])},e.prototype._handleNewLink=function(e){var t=this;if(this._element&&this._lastMouseEvent&&this._mouseService){var r=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);r&&this._linkAtPosition(e,r)&&(this._currentLink=e,this._linkHover(this._element,e,this._lastMouseEvent),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRender((function(e){t._clearCurrentLink(e.start+1+t._bufferService.buffer.ydisp,e.end+1+t._bufferService.buffer.ydisp)}))))}},e.prototype._linkHover=function(e,t,r){var i=t.range,n=this._bufferService.buffer.ydisp;this._onLinkHover.fire(this._createLinkHoverEvent(i.start.x-1,i.start.y-n-1,i.end.x,i.end.y-n-1,void 0)),e.classList.add("xterm-cursor-pointer"),t.hover&&t.hover(r,t.text)},e.prototype._linkLeave=function(e,t,r){var i=t.range,n=this._bufferService.buffer.ydisp;this._onLinkLeave.fire(this._createLinkHoverEvent(i.start.x-1,i.start.y-n-1,i.end.x,i.end.y-n-1,void 0)),e.classList.remove("xterm-cursor-pointer"),t.leave&&t.leave(r,t.text)},e.prototype._linkAtPosition=function(e,t){var r=e.range.start.y===e.range.end.y,i=e.range.start.y<t.y,n=e.range.end.y>t.y;return(r&&e.range.start.x<=t.x&&e.range.end.x>=t.x||i&&e.range.end.x>=t.x||n&&e.range.start.x<=t.x||i&&n)&&e.range.start.y<=t.y&&e.range.end.y>=t.y},e.prototype._positionFromMouseEvent=function(e,t,r){var i=r.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}},e.prototype._createLinkHoverEvent=function(e,t,r,i,n){return{x1:e,y1:t,x2:r,y2:i,cols:this._bufferService.cols,fg:n}},e}();t.Linkifier2=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){this._textarea=e}return Object.defineProperty(e.prototype,"isFocused",{get:function(){return document.activeElement===this._textarea&&document.hasFocus()},enumerable:!0,configurable:!0}),e}();t.CoreBrowserService=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(0),n=r(79),o=function(){function e(){this._providers=Object.create(null),this._active="",this._onChange=new i.EventEmitter;var e=new n.UnicodeV6;this.register(e),this._active=e.version,this._activeProvider=e}return Object.defineProperty(e.prototype,"onChange",{get:function(){return this._onChange.event},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"versions",{get:function(){return Object.keys(this._providers)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"activeVersion",{get:function(){return this._active},set:function(e){if(!this._providers[e])throw new Error('unknown Unicode version "'+e+'"');this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)},enumerable:!0,configurable:!0}),e.prototype.register=function(e){this._providers[e.version]=e},e.prototype.wcwidth=function(e){return this._activeProvider.wcwidth(e)},e.prototype.getStringCellWidth=function(e){for(var t=0,r=e.length,i=0;i<r;++i){var n=e.charCodeAt(i);if(55296<=n&&n<=56319){if(++i>=r)return t+this.wcwidth(n);var o=e.charCodeAt(i);56320<=o&&o<=57343?n=1024*(n-55296)+o-56320+65536:t+=this.wcwidth(o)}t+=this.wcwidth(n)}return t},e}();t.UnicodeService=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i,n=r(15),o=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],s=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];var a=function(){function e(){if(this.version="6",!i){i=new Uint8Array(65536),n.fill(i,1),i[0]=0,n.fill(i,0,1,32),n.fill(i,0,127,160),n.fill(i,2,4352,4448),i[9001]=2,i[9002]=2,n.fill(i,2,11904,42192),i[12351]=1,n.fill(i,2,44032,55204),n.fill(i,2,63744,64256),n.fill(i,2,65040,65050),n.fill(i,2,65072,65136),n.fill(i,2,65280,65377),n.fill(i,2,65504,65511);for(var e=0;e<o.length;++e)n.fill(i,0,o[e][0],o[e][1]+1)}}return e.prototype.wcwidth=function(e){return e<32?0:e<127?1:e<65536?i[e]:function(e,t){var r,i=0,n=t.length-1;if(e<t[0][0]||e>t[n][1])return!1;for(;n>=i;)if(e>t[r=i+n>>1][1])i=r+1;else{if(!(e<t[r][0]))return!0;n=r-1}return!1}(e,s)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1},e}();t.UnicodeV6=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){this.charsets=[],this.glevel=0}return e.prototype.reset=function(){this.charset=void 0,this.charsets=[],this.glevel=0},e.prototype.setgLevel=function(e){this.glevel=e,this.charset=this.charsets[e]},e.prototype.setgCharset=function(e,t){this.charsets[e]=t,this.glevel===e&&(this.charset=t)},e}();t.CharsetService=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){this._addons=[]}return e.prototype.dispose=function(){for(var e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()},e.prototype.loadAddon=function(e,t){var r=this,i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=function(){return r._wrappedAddonDispose(i)},t.activate(e)},e.prototype._wrappedAddonDispose=function(e){if(!e.isDisposed){for(var t=-1,r=0;r<this._addons.length;r++)if(this._addons[r]===e){t=r;break}if(-1===t)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},e}();t.AddonManager=i}])})); //# sourceMappingURL=xterm.js.map
0
repos/LoLa
repos/LoLa/.vscode/settings.json
{ "files.associations": { "array": "cpp", "atomic": "cpp", "hash_map": "cpp", "bit": "cpp", "*.tcc": "cpp", "bitset": "cpp", "cctype": "cpp", "chrono": "cpp", "clocale": "cpp", "cmath": "cpp", "codecvt": "cpp", "compare": "cpp", "complex": "cpp", "concepts": "cpp", "condition_variable": "cpp", "csignal": "cpp", "cstdarg": "cpp", "cstddef": "cpp", "cstdint": "cpp", "cstdio": "cpp", "cstdlib": "cpp", "cstring": "cpp", "ctime": "cpp", "cwchar": "cpp", "cwctype": "cpp", "deque": "cpp", "list": "cpp", "map": "cpp", "set": "cpp", "unordered_map": "cpp", "vector": "cpp", "exception": "cpp", "algorithm": "cpp", "functional": "cpp", "iterator": "cpp", "memory": "cpp", "memory_resource": "cpp", "numeric": "cpp", "optional": "cpp", "random": "cpp", "ratio": "cpp", "string": "cpp", "string_view": "cpp", "system_error": "cpp", "tuple": "cpp", "type_traits": "cpp", "utility": "cpp", "fstream": "cpp", "initializer_list": "cpp", "iomanip": "cpp", "iosfwd": "cpp", "iostream": "cpp", "istream": "cpp", "limits": "cpp", "mutex": "cpp", "new": "cpp", "ostream": "cpp", "ranges": "cpp", "sstream": "cpp", "stdexcept": "cpp", "stop_token": "cpp", "streambuf": "cpp", "thread": "cpp", "cinttypes": "cpp", "typeinfo": "cpp", "valarray": "cpp", "variant": "cpp", "__bit_reference": "cpp", "__config": "cpp", "__debug": "cpp", "__errc": "cpp", "__functional_base": "cpp", "__hash_table": "cpp", "__locale": "cpp", "__mutex_base": "cpp", "__node_handle": "cpp", "__nullptr": "cpp", "__split_buffer": "cpp", "__string": "cpp", "__threading_support": "cpp", "__tree": "cpp", "__tuple": "cpp", "ios": "cpp", "locale": "cpp", "queue": "cpp", "stack": "cpp" } }
0
repos/LoLa
repos/LoLa/documentation/standard-library.md
# LoLa Standard Library This file documents the LoLa Standard Library, a set of basic routines to enable LoLa programs. ## String API ### `Length(string): number` Returns the length of the string. ### `SubString(string, start, [length]): string` Returns a portion of `string`. The portion starts at `start` and is `length` bytes long. If `length` is not given, only the start of the string is cut. ### `Trim(string): string` Removes leading and trailing white space from the string. White space is on of the following ascii characters: - `0x09` (horizontal tab) - `0x0A` (line feed) - `0x0B` (vertical tab) - `0x0C` (form feed) - `0x0D` (carriage return) - `0x20` (space) ### `TrimLeft(string): string` Removes leading white space from the string. ### `TrimRight(string): string` Removes trailing white space from the string. ### `IndexOf(string, text): number|void` Searches for the first occurrence `text` in `string`, returns the offset to the start in bytes. If `text` is not found, `void` is returned. ### `LastIndexOf(string, text): number|void` Searches for the last occurrence of `text` in `string`, returns the offset to the start in bytes. If `text` is not found, `void` is returned. ### `Byte(string): number` Returns the first byte of the string as a number value. If the string is empty, `void` is returned, if the string contains more than one byte, still only the first byte is considered. ### `Chr(byte): string` Returns a string of the length 1 containing `byte` as a byte value. ### `NumToString(num, [base]=10): string` Converts the number `num` into a string represenation to base `base`. If `base` is given, it will format the integer value of the number to `base`, otherwise, a decimal floating point output will be given. ### `StringToNum(str, [base]=10): number|void` Converts the string `str` to a number. If `base` is not given, the number is assumed to be base 10 and a floating point value. Otherwise, `base` is used as the numeric base for conversion, and only integer values are accepted. If the conversion fails, `void` is returned. If `base` is 16, `0x` is accepted as a prefix, and `h` as a postfix. ### `Split(str, sep, [removeEmpty]): array` Splits the string `str` into chunks separated by `sep`. When `removeEmpty` is given and `true`, all empty entries will be removed. ### `Join(array, [sep]): string` Joins all items in `array`, optionally separated by `sep`. Each item in `array` must be a `string`. ## Array API ### `Array(count, [init]): array` Returns an array with `count` items initialized with `init` if given. Otherwise, the array will be filled with `void`. ### `Range(count): array` Returns an array with `count` increasing numbers starting at 0. ### `Range(start, count)` Returns an array with `count` increasing numbers starting at `start`. ### `Length(array): number` Returns the number of items in `array`. ### `Slice(array, start, length): array` Returns a portion of the `array`, starting at `index` (inclusive) and taking up to `length` items from the array. If less items are possible, an empty array is returned. ### `IndexOf(array, item): number|void` Returns the index of a given `item` in `array`. If the item is not found, `void` is returned. ### `LastIndexOf(array, item): number|void` Returns the last index of a given `item` in `array`. If the item is not found, `void` is returned. ## Math ### `Pi: number` Global constant containing the number _pi_. ### `DeltaEqual(a, b, delta): boolean` Compares `a` and `b` with a certain `delta`. Returns `true` when `abs(a-b) < delta`. ### ``Floor(x): number` Rounds `x` towards negative infinity. ### ``Ceiling(x): number` Rounds `x` towards positive infinity. ### ``Round(x): number` Rounds `x` to the closest integer. ### `Sin(a): number`, `Cos(a): number`, `Tan(a): number` Trigonometric functions, all use radians. ### `Atan(y, [x]): number` Calculates the arcus tangens of `y`, and, if `x` is given, divides `y` by `x` before. Use the two-parameter version for higher precision. ### `Sqrt(x): number` Calculates the square root of `x`. ### `Pow(v, e): number` Returns `v` to the power of `e`. ### `Log(v, [base]): number` Returns the logarithm of `v` to base `base`. If `base` is not given, base 10 is used. ### `Exp(v): number` Returns _e_ to the power of `v`. _e_ is the euler number. ### `Random([min],[max]): number` Returns a random number between `min` and `max`. If no argument is given, a random number between `0.0` and `1.0` is returned. If only `min` is given, a number between `0.0` and `min` (inclusive) is returned. ### `RandomInt([min],[max]): number` Returns a random integer between `min` and `max`. If no argument is given, a random positive number is returned. If only `min` is given, a number between `0` and `min` (exclusive) is returned. ## Auxiliary ### `Sleep(secs): void` Sleeps for `secs` seconds. ### `Timestamp(): number` Returns the current wall clock time as a unix timestamp. ### `TypeOf(arg): string` Returns the type of the argument as a string. Returns one of the following: ```lola "void", "boolean", "string", "number", "object", "array" ``` ### `ToString(val): string` Converts the input `val` into a string representation. ### `HasFunction(name): boolean` Returns `true` if the current environment has a function called `name`, `false` otherwise. ### `HasFunction(object, name): boolean` Returns `true` if the `object` has a function called `name`, `false` otherwise. ### `Serialize(value): string` Serializes any `value` into a binary representation. This representation can later be loaded by via `Deserialize` and return the exact same value again. Note that objects are stored as opaque handles and are not transferrable between different systems. ### `Deserialize(string): any` Deserializes a previously serialized value. If the deserialization fails, a panic will occurr. ### `Yield(): void` This function will yield control back to the host, pausing the current execution. This can be inserted in loops to reduce CPU usage.
0
repos/LoLa
repos/LoLa/documentation/LoLa.md
# LoLa – Quick Reference ## Example ```js var stack = CreateStack(); stack.Push(10); stack.Push(20); stack.Push(30); function Operation(op) { if(op == "print") { Print(stack.Pop()); } if(op == "add") { var lhs = stack.Pop(); var rhs = stack.Pop(); stack.Push(lhs + rhs); } if(op == "mul") { var lhs = stack.Pop(); var rhs = stack.Pop(); stack.Push(lhs * rhs); } } Operation("mul"); Operation("add"); Operation("print"); Print("Stack Length: ", stack.GetSize()); ``` ## Overview - Allows script-style top-level code - Dynamic typing - Static scope ### Data Types - Void (single value type, marks something "not existent") - Boolean (Logic value, is either `true` or `false`) - Number (IEEE754 binary64) - String (ASCII-like or UTF-8 encoded string) - Array (A ordered list of values, zero-indexed) - Object (A thing that has methods which can be called) ### Syntax #### Expressions - literals - number (`1.0`, `4.33`, `2`, …) - string (`""`, `"hello"`, `"line\nfeed"`, …) - boolean (`true`, `false`, …) - variable access (`x`, `var`, `var_2`, …) - array (`[]`, `[expr]`, `[expr, expr]`, …) - array index (`expr[expr])` - unary operation (`-expr`, `not expr`, …) - binary operaton (`expr + expr`, `expr and expr`, …) - function call (`f()`, `f(expr)`, `f(expr,expr)`, …) - method call (`o.m()`, `o.m(expr)`, …) - parenthesis (`(expr)`) #### Operators Operator precedence in the list low to high. A higher precedence means that these operators *bind* more to the variables and will be applied first. **Binary:** - `and`, `or` - `==`, `!=`, `>=`, `<=`, `>`, `<` - `+`, `-` - `*`, `/`, `%` **Unary:** - `not`, `-` #### Statements - terminated by semicolon (`;`) - allowed on top level **Elements:** - scope (`{ … }`) - var declaration (`var x;`, `var x = expr;` …) - function call (`f();`, …) - assignment (`lval = rval;`, `lval[expr] = rval;`, …) - for loop (`for(x in expr) { … }`) - while loop (`while(expr) { … }`) - condition (`if(expr) { … }`, `if(expr) { … } else { … }`) - return (`return;`, `return expr;`) #### Function Declarations ```js function name() { … } function name(arg) { … } function name(arg1, arg2) { … } ```
0
repos/LoLa
repos/LoLa/documentation/runtime-library.md
# LoLa Runtime Library This file documents the LoLa Runtime Library, a set of basic I/O routines to enable standalone LoLa programs. The API in this document is meant for the standalone LoLa interpreter and functions listed here are not necessarily available in embedded programs! ## Generic ### `Exit(code: number): noreturn` This function will stop execution of the program and will return `code` to the OS. ## File I/O ### `ReadFile(path: string): string|void` Reads in the contents of a file located at `path` as a `string` or returns `void` when the file does not exist or the given path is not a file. ### `WriteFile(path: string, contents: string): void` Writes `contents` to the file located at `path`. If the file does not exist, it will be created. ### `FileExists(path: string): boolean` Returns `true` if a file exists at the given `path`, `else` otherwise. ## Console I/O ### `Print(…): void` Will print every argument to the standard output. All arguments of type `string` will be printed verbatim, non-`string` arguments are converted into a human-readable form and will then be printed. After all arguments are printed, a line break will be outputted. ### `ReadLine(): string|void` Reads a line of text from the standard input and returns it as a `string`. If the standard input is in the *end of file* state, `void` will be returned. ## Standard Objects ### `CreateList([init: array]): object` Returns a new object that implements a dynamic list. If `init` is given, the list will be initialized with the contents of `init`. This list has the following API: #### `list.Add(item): void` Appends a new item to the back of the list. #### `list.Remove(item): boolean` Removes all occurrances of `item` in the list. #### `list.RemoveAt(index): void` Removes the item at `index`. Indices start at `0`. When the index is out of range, nothing will happen. #### `list.GetCount(): number` Returns the current number of elements in the list. #### `list.GetItem(index): any` Returns the item at `index` or panics with `OutOfRange`; #### `list.SetItem(index, value): void` Replaces the item at `index` with `value`. #### `list.ToArray(): array` Returns the current list as an array. #### `list.IndexOf(item): number` Returns first the index of `item` in the list or `void` if the item was not found. #### `list.Resize(size): void` Resizes the list to `size` items. New items will be set to `void`. #### `list.Clear(): void` Removes all items from the list. ### `CreateDictionary(): object` Returns a new object that implements a key-value store. #### `dict.Get(key): any` Returns the value associated with `key` or returns `void` if `key` does not have a associated value. #### `dict.Set(key, value): void` Sets the associated value for `key` to `value`. If `value` is `void`, the key will be removed. #### `dict.Remove(key): boolean` Removes any value associated with `key`. Returns `true` when a key was removed else `false`. #### `dict.Contains(key): boolean` Returns `true` if the dictionary contains a value associated with `key`. #### `dict.GetKeys(): array` Returns an array with all keys stored in the dictionary. #### `dict.GetValues(): array` Returns an array with all values stored in the dictionary. #### `dict.Clear(): void` Removes all values from the dictionary. #### `dict.GetCount(): number` Returns the number of keys currently stored in the list.
0
repos/LoLa
repos/LoLa/documentation/checklist.txt
Programming Language Checklist by Colin McMillen, Jason Reed, and Elly Fong-Jones, 2011-10-10. Filled out for LoLa You appear to be advocating a new: [ ] functional [X] imperative [X] object-oriented [X] procedural [ ] stack-based [ ] "multi-paradigm" [ ] lazy [X] eager [ ] statically-typed [X] dynamically-typed [ ] pure [X] impure [ ] non-hygienic [ ] visual [X] beginner-friendly [ ] non-programmer-friendly [ ] completely incomprehensible programming language. Your language will not work. Here is why it will not work. You appear to believe that: [ ] Syntax is what makes programming difficult [ ] Garbage collection is free [X] Computers have infinite memory [X] Nobody really needs: [X] concurrency [X] a REPL [X] debugger support [X] IDE support [X] I/O [ ] to interact with code not written in your language [X] The entire world speaks 7-bit ASCII [X] Scaling up to large software projects will be easy [X] Convincing programmers to adopt a new language will be easy [ ] Convincing programmers to adopt a language-specific IDE will be easy [ ] Programmers love writing lots of boilerplate [ ] Specifying behaviors as "undefined" means that programmers won't rely on them [ ] "Spooky action at a distance" makes programming more fun Unfortunately, your language (has/lacks): [X] comprehensible syntax [X] semicolons [ ] significant whitespace [ ] macros [ ] implicit type conversion [ ] explicit casting [ ] type inference [ ] goto [ ] exceptions [ ] closures [ ] tail recursion [ ] coroutines [ ] reflection [ ] subtyping [ ] multiple inheritance [ ] operator overloading [ ] algebraic datatypes [ ] recursive types [ ] polymorphic types [ ] covariant array typing [ ] monads [ ] dependent types [X] infix operators [ ] nested comments [ ] multi-line strings [ ] regexes [X] call-by-value [ ] call-by-name [ ] call-by-reference [ ] call-cc The following philosophical objections apply: [ ] Programmers should not need to understand category theory to write "Hello, World!" [ ] Programmers should not develop RSI from writing "Hello, World!" [ ] The most significant program written in your language is its own compiler [X] The most significant program written in your language isn't even its own compiler [ ] No language spec [ ] "The implementation is the spec" [ ] The implementation is closed-source [ ] covered by patents [ ] not owned by you [ ] Your type system is unsound [ ] Your language cannot be unambiguously parsed [ ] a proof of same is attached [ ] invoking this proof crashes the compiler [ ] The name of your language makes it impossible to find on Google [X] Interpreted languages will never be as fast as C [X] Compiled languages will never be "extensible" [ ] Writing a compiler that understands English is AI-complete [ ] Your language relies on an optimization which has never been shown possible [ ] There are less than 100 programmers on Earth smart enough to use your language [X] __anything that'd be fast in C__ takes exponential time [ ] ________________________________ is known to be undecidable Your implementation has the following flaws: [X] CPUs do not work that way [X] RAM does not work that way [ ] VMs do not work that way [ ] Compilers do not work that way [ ] Compilers cannot work that way [ ] Shift-reduce conflicts in parsing seem to be resolved using rand() [ ] You require the compiler to be present at runtime [X] You require the language runtime to be present at compile-time [X] Your compiler errors are completely inscrutable [ ] Dangerous behavior is only a warning [ ] The compiler crashes if you look at it funny [ ] The VM crashes if you look at it funny [X] You don't seem to understand basic optimization techniques [X] You don't seem to understand basic systems programming [X] You don't seem to understand pointers [ ] You don't seem to understand functions Additionally, your marketing has the following problems: [ ] Unsupported claims of increased productivity [ ] Unsupported claims of greater "ease of use" [ ] Obviously rigged benchmarks [ ] Graphics, simulation, or crypto benchmarks where your code just calls handwritten assembly through your FFI [ ] String-processing benchmarks where you just call PCRE [ ] Matrix-math benchmarks where you just call BLAS [X] Noone really believes that your language is faster than: [ ] assembly [ ] C [ ] FORTRAN [ ] Java [X] Ruby [ ] Prolog [ ] Rejection of orthodox programming-language theory without justification [X] Rejection of orthodox systems programming without justification [ ] Rejection of orthodox algorithmic theory without justification [ ] Rejection of basic computer science without justification Taking the wider ecosystem into account, I would like to note that: [X] Your complex sample code would be one line in: any other language [ ] We already have an unsafe imperative language [ ] We already have a safe imperative OO language [ ] We already have a safe statically-typed eager functional language [ ] You have reinvented Lisp but worse [ ] You have reinvented Javascript but worse [ ] You have reinvented Java but worse [ ] You have reinvented C++ but worse [ ] You have reinvented PHP but worse [ ] You have reinvented PHP better, but that's still no justification [ ] You have reinvented Brainfuck but non-ironically In conclusion, this is what I think of you: [ ] You have some interesting ideas, but this won't fly. [ ] This is a bad language, and you should feel bad for inventing it. [X] Programming in this language is an adequate punishment for inventing it.
0
repos/LoLa
repos/LoLa/documentation/ir.md
# LoLa Intermedia Language This document describes all available instructions of the Lola intermediate language as well as it's encoding in a binary stream. ## Instructions The following list contains each instruction and describes it's effects on the virtual machine state. - `nop` No operation - `store_global_name` stores global variable by name `[ var:str ]` - pops a value and stores it in the environment-global `str` - `load_global_name` loads global variable by name `[ var:str ]` - pushes a value stored in the environment-global `str` - `push_str` pushes string literal `[ val:str ]` - pushes the string `str` - `push_num` pushes number literal `[ val:f64 ]` - pushes the number `val` - `array_pack` packs *num* elements into an array `[ num:u16 ]` - pops `num` elements front-to-back and packs them into an array front to back - stack top will be the first element - `call_fn` calls a function `[ fun:str ] [argc:u8 ]` - pops `argc` elements front-to-back into the argument list, then calls function `fun` - stack top will be the first argument - `call_obj` calls an object method `[ fun:str ] [argc:u8 ]` - pops the object to call, - then pops `argc` elements front-to-back into the argument list, - then calls function `fun` - stack top will be the first argument - `pop` destroys stack top - pops a value and discards it - `add` adds rhs and lhs together - first pops the right hand side, - then the left hand side, - then adds right to left, pushes the result - `sub` subtracts rhs and lhs together - first pops the right hand side, - then the left hand side, - then subtracts right from left, pushes the result - `mul` multiplies rhs and lhs together - first pops the left hand side, - then the right hand side, - then multiplies left and right, pushes the result - `div` divides rhs and lhs together - first pops the left hand side, - then the right hand side, - then divides left by right, pushing the divisor - `mod` modulo division of rhs and lhs - first pops the left hand side, - then the right hand side, - then divides left by right, pushing the module - `(-5 % 2) == 1` - `bool_and` conjunct rhs and lhs - first pops the left hand side, - then the right hand side, - then pushes `true` when both left and right hand side are `true` - `bool_or` disjuncts rhs and lhs - first pops the left hand side, - then the right hand side, - then pushes `true` when either of left or right hand side is `true` - `bool_not` logically inverts stack top - pops a value from the stack - pushs `true` if the value was `false`, otherwise `true` - `negate` arithmetically inverts stack top - pops a value from the stack - then pushes the negative value - `eq` - pops two values from the stack and compares if they are equal - pushes a boolean containing the result of the comparison - `neq` - pops two values from the stack and compares if they are not equal - pushes a boolean containing the result of the comparison - `less_eq` - first pops the right hand side, - then the left hand side, - then pushes `true` when left hand side is less or equal to the right hand side. - `greater_eq` - first pops the right hand side, - then the left hand side, - then pushes `true` when left hand side is greater or equal to the right hand side. - `less` - first pops the right hand side, - then the left hand side, - then pushes `true` when left hand side is less to the right hand side. - `greater` - first pops the right hand side, - then the left hand side, - then pushes `true` when left hand side is greater to the right hand side. - `jmp` jumps unconditionally `[target:u32 ]` - Sets the instruction pointer to `target` - `jnf` jump when not false `[target:u32 ]` - Pops a value from the stack - If that value is `true` - Sets the instruction pointer to `target` - `iter_make` - Pops an *array* from the stack - Creates an *iterator* over that *array*. - Pushes the created *iterator*. - `iter_next` - Peeks an *iterator* from the stack - If that *iterator* still has values to yield: - Push the *value* from the *iterator* - Push `true` - Advance the iterator by 1 - else: - Push `false` - `array_store` - Then pops the *array* from the stack - Then pops the *index* from the stack - Pops the *value* from the stack - Stores *value* at *index* in *array* - Pushes *array* to the stack. - `array_load` - Pops *array* from the stack - Pops *index* from the stack - Loads a *value* from the *array* at *index* - Pushes *value* to the stack - `ret` returns from the current function with Void - returns from the function call with a `void` value - `store_local` stores a local variable `[index : u16 ]` - Pops a *value* from the stack - Stores that *value* in the function-local variable at *index*. - `load_local` loads a local variable `[index : u16 ]` - Loads a *value* from the function-local *index*. - Pushes that *value* to the stack. - `retval` returns from the current function with a value - pops a value from the stack - returns from the function call with the popped value - `jif` jump when false `[ target:u32 ]` - Pops a value from the stack - If that value is `false` - Sets the instruction pointer to `target` - `store_global_idx` stores global variable by index `[ idx:u16 ]` - Pops a value from the stack - Stores this value in the object-global storage - `load_global_idx` loads global variable by index `[ idx:u16 ]` - Loads a value from the object-global storage - Pushes that value to the stack - `push_true` - pushes literal boolean `true` - `push_false` - pushes literal boolean `false` - `push_void` - pushes void value ## Encoding ### Instructions The instructions are encoded in an intermediate language. Each instruction is encoded by a single byte, followed by arguments different for each instruction. Argument types are noted in `name:type` notation where type is one of the following: `str`, `f64`, `u16`, `u8`, `u32`. The encoding of these types is described below the table. | Instruction | Value | Arguments | Description | | ----------------- | ----- | ------------------ | ---------------------------------------------- | | nop | 0 | | No operation | | scope_push | 1 | | *reserved* | | scope_pop | 2 | | *reserved* | | declare | 3 | `var:str` | *reserved* | | store_global_name | 4 | `var:str` | stores global variable by name | | load_global_name | 5 | `var:str` | loads global variable by name | | push_str | 6 | `val:str` | pushes string literal | | push_num | 7 | `val:f64` | pushes number literal | | array_pack | 8 | `num:u16` | packs *num* elements into an array | | call_fn | 9 | `fun:str, argc:u8` | calls a function | | call_obj | 10 | `fun:str, argc:u8` | calls an object method | | pop | 11 | | destroys stack top | | add | 12 | | adds rhs and lhs together | | sub | 13 | | subtracts rhs and lhs together | | mul | 14 | | multiplies rhs and lhs together | | div | 15 | | divides rhs and lhs together | | mod | 16 | | reminder division of rhs and lhs | | bool_and | 17 | | conjunct rhs and lhs | | bool_or | 18 | | disjuncts rhs and lhs | | bool_not | 19 | | logically inverts stack top | | negate | 20 | | arithmetically inverts stack top | | eq | 21 | | | | neq | 22 | | | | less_eq | 23 | | | | greater_eq | 24 | | | | less | 25 | | | | greater | 26 | | | | jmp | 27 | `target:u32` | jumps unconditionally | | jnf | 28 | `target:u32` | jump when not false | | iter_make | 29 | | | | iter_next | 30 | | | | array_store | 31 | | | | array_load | 32 | | | | ret | 33 | | returns from the current function with Void | | store_local | 34 | `index:u16` | | | load_local | 35 | `index:u16` | | | retval | 37 | | returns from the current function with a value | | jif | 38 | `target:u32` | jump when false | | store_global_idx | 39 | `idx:u16` | stores global variable by index | | load_global_idx | 40 | `idx:u16` | loads global variable by index | | push_true | 41 | | pushes a boolean `true` | | push_false | 42 | | pushes a boolean `false` | | push_void | 43 | | pushes a `void` value. | ### Types #### `u8`, `u16`, `u32` Each of these corresponds to a single, little endian encoded unsigned integer with either 8, 16 or 32 bits width. #### `f64` A 64 bit floating point number, encoded with **IEEE 754** *binary64* format, also known as `double`. #### `str` A literal string value with a maximum of 65535 bytes length. It's text is encoded in an application-defined encoding where all values below 128 must follow the ASCII encoding scheme. Values equal or above 128 are interpreted by an application-defined logic. A string is started by a 16 bit unsigned integer defining the length of the string, followed by *length* bytes of content. **Rationale:** The encoding is not fixed to UTF-8 as the language is meant to be embedded into games where a unicode encoding would be a burden to the player. Thus, a string is defined to be "at least" ASCII-compatible and allows UTF-8 encoding, but does not enforce this.
0
repos/LoLa
repos/LoLa/documentation/README.md
# The LoLa Programming Language ## Introduction LoLa is a small programming language developed to be embedded in games. It's not meant as a scripting language to create games with but as language to be **programmed in the game by the player**. The design goals of the language are: - Easy to learn - Small set of language features - No complex features, there are only value types - Exhaustible execution – Limit how long a certain script run at most in a single script call ## Hello World ```js Print("Hello, World!"); ``` As you can see, the *Hello World*-Program is quite short and expressive. The language itself uses a C-like syntax with semicolons at the end of a statement. More [Examples](#Examples) can be found at the end of the document. ## Comments LoLa provides only single-line comments: ```js // This is a comment Print("Hello"); // this is a statement, followed by a comment ``` Everything that is in a comment is ignored by the compiler. A comment is introduced by a double-slash (`//`) and is ended by a line feed character or the end of the file. ## Types The language provides a small set of types data can have: | Type | Description | | --------- | ------------------------------------------------------------ | | `void` | The `void` type can only have a single value (which is also `void`) and indicates the absence of a value. Functions that do not return something will return this. | | `boolean` | A truth value, which is either `true` or `false`. This type is the result of comparisons and can be passed to conditionals. It is also the input to the [boolean algebra](https://en.wikipedia.org/wiki/Boolean_algebra) operators. | | `number` | A [IEEE-754 binary64](https://en.wikipedia.org/wiki/Double-precision_floating-point_format) encoded real number. This is the basic type for all algebraic operations. | | `string` | A [string](https://en.wikipedia.org/wiki/String_(computer_science)) in LoLa is a sequence of bytes, usually encodes text as [ASCII](https://en.wikipedia.org/wiki/ASCII) or [UTF-8](https://en.wikipedia.org/wiki/UTF-8). | | `object` | An object is a thing that has an interface with callable methods. | | `array` | An array is a sequence of arbitrary values. | ## Literals Literals provide a way to create a primitive value in the language. All of the types except `object` have a literal syntax: | Type | Examples | | --------- | --------------------------------------------- | | `void` | `void` (no other values are allowed) | | `boolean` | `true`, `false` (no other values are allowed) | | `number` | `0`, `1`, `0.0`, `10.0`, `0.25`, `13.37`, … | | `string` | `"Hello, World!"`, `""`, `"One\nTwo\nThree"` | | `array` | `[]`, `[1,2,3,4,5]`, `[true, false, void]` | LoLa also supports character literals. Character literals have the type `number` and will be equivalent to their unicode codepoint and might be written literally (`ö`) or with the same rules as string escapes (`\xF3`): ```js 0x20 == ' ' 0x07 == '\a' 0x1F4A9 == '💩' 0xF3 == '\xF3' 0x1F4A9 == '\xf0\x9f\x92\xa9' ``` As LoLa doesn't enforce utf-8 encoding, all single-byte literals will be copied verbatim, allowing support for any 8-bit encoding. All literals that take up more than a single byte will be assumed utf-8 encoded. ### String Escape Sequence As strings are contained in double quotes and don't allow to contain a line feed, one needs the possibility to escape those characters. For this, LoLa provides two ways to include escaped and non-printable characters in a string: - Use a hexadecimal escape (`\x63`) - Use one of the predefined escape shorthands (`\r`, `\n`) The hexadecimal escape allows the programmer to embed any byte value into the string. It is introduced by the escape character `\`, followed by a small `x`, then a two-digit hexadecimal number. The number is then converted into a byte value and inserted into the string. The predefined escape codes provide often-required whitespace and control characters without the need to remember their exact value: | Shorthand | ASCII Value | Name | | --------- | ----------- | --------------- | | `\a` | 7 | Alert / Bell | | `\b` | 8 | Backspace | | `\t` | 9 | Horizontal Tab | | `\n` | 10 | Line Feed | | `\r` | 13 | Carriage Return | | `\e` | 27 | Escape | | `\"` | 34 | Double Quotes | | `\'` | 39 | Single Quote | ## Variables Variables provide a way to store something beyond the context of a single computation. ```js var x; // Uninitialized, global variable var y = 10; // Initialized global variable { var z; // Unitialized local variable var w = 0; // Initialized local variable } ``` There are three kind of variables in LoLa: - Global Variables - Local Variables Global variables are accessible from any scope and are stored in the execution environment. **If a global variable has no initializer, it's value is preserved over multiple calls of the script.** Local variables could also be called temporary variables as they are only alive for a short time. A local variables is any variable declared in brackets, so explicit declared locals, loop variables and function parameters. All variables are dynamically typed and may change the type of the stored value on assignment. ### Shadowing LoLa allows shadowing of variable names. This means, that you can have a variable with the same name as a previously declared variable. The previously declared variable will be hidden (shadowed) by the newly declared variable for the scope of the shadowing variable. ## Operators LoLa provides several operators that execute arithmetic, logic or comparison operations. ### Table of Operators | Operator | Applies to | Description | Example | | -------- | --------------------------- | ----------------------------------------- | ------------------------------------------------------------ | | `a + b` <br /> `a += b` | `string`, `number`, `array` | Adds numbers, concats strings and arrays. | `3 + 2 == 5`, `"a" + "b" == "ab"`, `[ 1, 2 ] + [ 3 ] == [ 1, 2, 3 ]` | | `a - b` <br />`a -= b` | `number` |Subtraction|`5 - 2 == 3`| | `-a` | `number` | Negation |`-(4) == -4`| | `a * b` <br />`a *= b` | `number` |Multiplication|`5 * 2 == 10`| | `a / b `<br />`a /= b` | `number` |Division|`10 / 5 == 2`| | `a % b` <br />`a %= b` | `number` |Remainder Division|`10 % 4 == 2`| | `a and b` | `boolean` |Boolean AND|`true and false == false`| | `a or b` | `boolean` |Boolean OR|`true or false == true`| | `not a` | `boolean` |Boolean NOT|`not false == true`| | `a == b` | *all* |Equality test|`(3 == 3) == true`| | `a != b` | *all* |Inequality test|`(3 != 2) == true`| | `a >= b` | `number` |Greater-or-equal test|`(3 >= 2) == true`| | `a <= b` | `number` |Less-or-equal test|`(3 <= 2) == false`| | `a > b` | `number` |Greater-than test|`(3 > 2) == true`| | `a < b` | `number` |Less-than test|`(3 < 2) == false`| | `a[i]` | `array`, `string` | Array index, string index | `([1,2,3])[1] == 2` | ### Operator Precedence Operator precedence in the list low to high. A higher precedence means that these operators *bind* more to the variables and will be applied first. #### Binary - `and`, `or` - `==`, `!=`, `>=`, `<=`, `>`, `<` - `+`, `-` - `*`, `/`, `%` #### Unary - `not`, `-` - `a[i]` ## Control Flow Structures LoLa provides a small set of control flow structures that are simple to use and are widespread in a lot of programming languages. ### Blocks ```js { // Blocks are always introduced by a curly bracket var x; // local to this block // here is the block content } // and are closed by a curly bracket // x is not valid here anymore! ``` Blocks are a convenient way of introducing structure into the code. Each block has its own set of local variables, but can access the local variables of its parent as well. Each control structure in LoLa is followed by a block, but blocks can also be freestanding as in the example above. ### Assignments Assignments in LoLa are statements that return no value. This is different from other programming languages like C that allow nesting assignments into expressions (~~`a + (b = c)`~~). ```js a = b; // simple assignment, copy the value from b into a. ``` An assignment will always copy the value that is assigned. It will not create equality of the two names: ```js a = 1; b = a; a = 2; Print(a, b); // Will print "2, 1" as b has not been changed ``` You can always assign an item of array: ```js a[i] = c; // indexed assignment: copy the value of c into the i'th index of the array a. ``` This allows mutating the contents of the array. The same rules as for a normal variable assignment apply here. ### `if`-Conditional The conditional `if` statement provides a simple way to do things depending on a condition: ```js if(a > 5) { // This code is executed only when a > 5. } ``` The code in the curly brackets is only executed when the condition in the round brackets is `true`. The condition must always be a `boolean` value. If the code should do an *either-or* semantic, you can add an else block: ```js if(a > 5) { // This code is executed only when a > 5. } else { // This code is executed when a <= 5. } ``` The `else` part is optional. `if` also provides a short-hand version if only a single statement is conditional: ```js if(condition) Statement(); // Function call, control flow or assignment if(condition) Statement(); else Statement(); ``` ### `while`-Loop If a piece of code should repeat itself, a loop structure is helpful: ```js while(a > 5) { // this code repeats as long as a > 5. } ``` The `while` loop will check the condition in the round brackets. If the condition is `true`, the code in the curly brackets will be executed. After that, the condition will be checked again and the process starts again. ### `for`-Loop Iterating over an array is such a common task that LoLa provides a built-in loop for that: ```js for(x in data) { // For each loop iteration, x will contain a value from data } ``` The syntax for the loop is `for(var in data) { … }` where `var` is a new local variable, and `data` is an array value. The loop will execute one time for each item in `data`, filling `var` with the current item. The items are processed in order. ### Function Calls ```js Print("Hello, World!"); // Calls the function Print with one arg. x = GetSomething(); // stores the return value of GetSomething() ``` Function calls will execute a sub-program that may return a value to their caller. A function call may take zero or more arguments, but will always return a value. If the return value is not stored, it will be discarded. ### Method Calls Methods calls are similar to function calls, but require an `object` value to be executed: ```js var obj = …; // We require a variable of type object obj.Print("Hello, World!"); // Call the method Print on obj. ``` The `Print` in this case is not a usual function but a method. Methods are defined on objects and pass the object to the method as well. This allows the script runtime to provide the user with more complex data structures or interfaces that are implemented via objects instead of free functions. Objects can also represent resources like [sockets](https://en.wikipedia.org/wiki/Network_socket) or [key-value-stores](https://en.wikipedia.org/wiki/Key-value_database) that are available to the user. ### `return` `return` will stop the execution of the current sub-program and will return control to the caller. ```js return; // Stop execution now, return void return true; // Stop execution now and return true ``` `return` may take an optional value that will be returned as a result of the sub-program. Returning a value from global execution environment is not allowed, returning a value to the script host should be done with a function provided by the host. ### `break` `break` will cancel the current loop execution. This means that it will continue execution after the loop-block: ```js var i = 0; var j = 0; while(true) { i += 1; Print("i = ", i); if(i > 5) break; // this will jump to after the while-loop j += 1; } // <= break will continue execution here Print(i, j); // Will print 6, 5 ``` The same goes for `for` loops: ```js for(x in [ 1, 2, 3, 4 ]) { if(x > 2) break; // this will jump to after the for-loop } // <= break will continue execution here ``` ### `continue` `continue` is the counterpart to `break`: It will continue with the next loop iteration instead of completing the current one. This can be used to skip a whole bunch of code: ```js var a = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; var skipped = 0; for(x in a) { // continue will continue from here if(x < 3) { skipped += 1; continue; // jumps to the start of the loop with the next var } Print(x); } Print("Skipped ", skipped, " elements!"); ``` The same goes for `while` loops as well: ```js var i = 0; while(i < 10) { // continue will continue from here i += 1; if(i < 4) continue; // jumps to the start of the loop Print(i); } ``` ## Functions Functions allows the user to declare custom sub-programs in the script: ```js function AddFive(a) { return a + 5; } function Compare(a, b) { if(a > b) { return "larger"; } else if(a < b) { return "smaller"; } else { return "equal"; } } ``` Functions have their own scope, and may `return` a value to their caller. ## Top Level Code Similar to other scripting languages, LoLa allows not only top-level declarations, but also top-level code. This means there is no `main` function that is called when starting execution, but the top-level code will be run instead. ```js // This is not a snippet, but a valid file! SayHelloTo("me"); function SayHelloTo(name) { Print("Hello, " + name + "!"); } ``` As you can see, the order of declaration is not relevant in LoLa. Functions may be called from top-level before or after declaration. ## Error Handling The LoLa language has not a very sophisticated error handling concept. If something goes wrong, the runtime will just panic and return execution to the host system with the position where the panic happened as well as some basic info about what failed. Possible panics are: - `OutOfMemory` (the host ran out of memory while executing the code) - `TypeMismatch` (an operation or function expected one type, but got another) - `IndexOutOfBounds` (an array was indexed outside the boundaries of the array) - `InvalidArgs` (a wrong number of arguments was passed to a function) - `OutOfRange` (a numeric value wasn't in the allowed range) A panic may be caused by the LoLa virtual machine or any library functions. ## Objects Objects in LoLa are opaque handles except for their methods. Users cannot declare or create objects without the help of the script host. Object handles are usually valid as long as the LoLa script has access to that handle, but the script host might destroy objects actively as well. Object handles can be considered a reference type as you don't get a copy of the object when you pass a handle around. This type would be the only exception to LoLas design of *value types only*. ## LoLa File Types The following list contains LoLa-related file types - LoLa Code (`*.lola`) These files contain actual LoLa source code and can be compiled into modules. - [LoLa Modules](Modules.md) (`*.lola.lm`) These files contain compiled LoLa byte code and can be executed by a [LoLa VM](IR.md). ## Frequently Asked Questions This section tries to answer questions that are commonly asked. ### Why does the language not allow user-defined objects? The design decision of LoLa was to be a simple as possible without losing too much features. User-defined objects would make the language way more complex and harder to reason about code. As the focus group of the language is mostly programmer novices, this complexity was left out and passed to the script host. It is still possible to create user-defined objects and classes though: The script host might implement a function `MakeObject(str)` which compiles a LoLa source and returns the compiled script as a object, evaluating the top-level code as some kind of constructor and exporting all functions as methods to that object. ## List of Keywords - `and` - `break` - `const` - `continue` - `else` - `for` - `function` - `if` - `in` - `not` - `or` - `return` - `var` - `while` ## Wording The following chapter explains some of the words used in this document with concrete focus on the meaning inside LoLa. ### Statement A statement is something that can be written as a line of code or execution unit. The following constructs count as statements: - Conditionals (`if`) - Loops (`while`, `for`) - Everything with a semicolon at the end (`a = …;`, `a[i] = …;`, `Print("Hi!");`) ### Expression An expression is something that yields a value that can be used in another expression or can be assigned to a value. Examples for expressions are: - `1` - `"Hello"` - `expr + expr` - `SumOf(10, 20)` - … LoLa does not allow lone statements except for function and method calls. These are special in a way that they may discard their value. The resulting value of all other expressions may not be discarded. ### Block Any piece of code between `{` and `}`. The block con ## Examples The following section will contain small examples on how to use the language. ### Sum the values of an array ```js var a = [ 1, 2, 3 ]; var sum = 0; for(v in a) { sum += a; } Print("Sum = ", sum); ``` ### Bubble Sort ```js function BubbleSort(arr) { var len = Length(arr); var n = len; while(n > 1) { var i = 0; while(i < n - 1) { if (arr[i] > arr[i+1]) { var tmp = arr[i]; arr[i] = arr[i+1]; arr[i+1] = tmp; } i += 1; } n -= 1; } return arr; } Print(BubbleSort([ 7, 8, 9, 3, 2, 1 ])); ``` ### Reversing an array ```js // Reverse an array function RevertArray(arr) { var i = 0; var l = Length(arr); while(i < l/2) { var tmp = arr[i]; arr[i] = arr[l - i - 1]; arr[l - i - 1] = tmp; i += 1; } return arr; } ``` ### Using an object ```js var stack = CreateStack(); stack.Push(10); stack.Push(20); stack.Push(30); function Operation(op) { if(op == "print") { Print(stack.Pop()); } if(op == "add") { var lhs = stack.Pop(); var rhs = stack.Pop(); stack.Push(lhs + rhs); } if(op == "mul") { var lhs = stack.Pop(); var rhs = stack.Pop(); stack.Push(lhs * rhs); } } Operation("mul"); Operation("add"); Operation("print"); Print("Stack Length: ", stack.GetSize()); ```
0
repos/LoLa
repos/LoLa/documentation/modules.md
# LoLa Module Format Native LoLa has a binary module format that contains compiled intermediate code. This format both contains meta-data like function names, but also the compiled code. ## Data Structure The description uses a file notation similar to Zig syntax. Each segment of the file is described as a structure with fields. The fields are packed and don't have any padding bits. Each field is noted by name, colon, type, and an optional fixed value. `u8`, `u16`, … denote a unsigned integer type with *n* bits, `[x]T` is an Array of `x` times `T` where `T` is a type and `x` is either a constant or variable size of a field declared earlier. Some fields are commented with C++ style comments, introduced by a `//`. ```rust // Structure of the whole file File { header: FileHeader, // contains the module header globalCount: u16, // number of global script variables temporaryCount: u16, // number of temporary variables (global) functionCount: u16, // number of declared functions codeSize: u32, // size of the intermediate code in bytes numSymbols: u32, // number of debug symbols functions: [functionCount]Function, // contains the function meta data code: [codeSize]u8, // intermediate code debugSymbols: [numSymbols]DebugSymbol, // debug symbols } FileHeader { identifier: [8]u8 = "LoLa\xB9\x40\x80\x5A" version: u32 = 1, // will increment in future versions comment: [256]u8, // zero terminated } Function { name: [128]u8, // zero-terminated function name entryPoint: u32, // start of the function in the intermediate code localCount: u16, // number of local variable slots. } DebugSymbol { offset: u32, // offset in code sourceLine: u32, // line of the original source sourceColumn: u16, // } ```
0
repos/LoLa
repos/LoLa/documentation/zig-api.md
# Zig API The Zig API is the main API for the LoLa implementation. It exposes all concepts in a convenient matter ## Basic Architecture ``` ObjectPool CompileUnit \ / \ / \ / \ / Environment | | VirtualMachine ``` ### Compile Unit A structure describing a compiled LoLa source file, containing the bytecode and defined function entry points. ### Object Pool A structure to manage LoLa objects. It's used for garbage collection, handle creation and lifetime management. ### Environment A script execution environment. This can be seen as an instantiation of a compile unit. Each environment has its own set of global variables and functions. ### Virtual Machine A virtual machine executes the code instantiated by one or more environments.
0
repos
repos/zig-sparse-set/LICENSE.txt
/* ------------------------------------------------------------------------------ This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------ ALTERNATIVE A - MIT License Copyright (c) 2019 Anders Elfgren Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ ALTERNATIVE B - Public Domain (www.unlicense.org) This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ */
0
repos
repos/zig-sparse-set/README.md
# :ferris_wheel: zig-sparse-set :ferris_wheel: An implementation of Sparse Sets for Zig. ## :confused: What is a Sparse Set? :confused: A Sparse Set - well, this implementation technique specifically at least - is a fairly simple data structure with some properties that make it especially useful for some aspects in game development, but you know... it's probably interesting for other areas too. Here's a good introduction: https://research.swtch.com/sparse Basically, sparse sets solve this problem: You have a bunch of ***sparse*** handles, but you want to loop over the values they represent linearly over memory. ## :point_down: Example :point_down: Maybe your game has a few hundred **entities** with a certain **component** (specific piece of game data) at any given time. An entity is a 16 bit ID (handle) and the entities containing this component eventually gets spread out randomly over 0..65535 during runtime. :anguished: In your frame update function, it would be nice to **not** do this... :anguished: ```zig for (active_entities) |entity| { var some_big_component = &self.big_components[entity]; some_big_component.x += 3; } ``` ... because it would waste memory. Or, in the case that the component isn't huge, but it's expensive to instantiate (i.e. you can't just zero-init it, for example), you need to do that 65k times at startup. Additionally, you'll be skipping over swaths of memory, so every access will likely be a cache miss. :worried: Similarly, you might want to avoid this... :worried: ```zig for (self.components) |some_component| { if (some_component.enabled) { some_component.x += 3; } } ``` ...because you'll be doing a lot of looping over data that isn't of interest. Also, you need to store a flag for every component. So potentially cache misses for the `+=` operation here too. (Note that the flag could be implemented as a bitset lookup, for example, which would probably be better, but still have the same underlying problem). :heart_eyes: With a sparse set, you can always simply loop over the data linearly: :heart_eyes: ```zig for (self.component_set.toValueSlice()) |*some_component| { some_component.x += 3; } ``` ## :sunglasses: But wait, there's more! :sunglasses: 1) **O(1)** Lookup from sparse to dense, and vice versa. 2) **O(1)** **Has,** **Add**, and **Remove**. 3) **O(1)** **Clear** (remove all elements). 4) **O(d)** iteration (dense list). 5) Elements of sparse and dense lists do not need to be (and are not) initialized upon startup - they are undefined. 6) Supports SOA-style component layout. (See **References** below if you're unfamiliar with what that is) 7) Supports AOS-style too by optionally storing and managing a value array internally. 8) Can be inspected "easily" in a debugger. 9) Optional error-handling. 10) Even if you don't need to loop over the values, a sparse set is a potential alternative to a hash map. 11) Optionally growable. :star: [1] This is nice and important because you can then do: ```zig for (self.component_set.toValueSlice()) |*some_component, dense_index| { some_component.x += 3; var entity = self.component_set.getByDense(dense_index); self.some_other_system.doStuffWithEntity(entity, some_component.x, 1234567); } ``` :star: [2] The O(1) remove is important. It is solved by swapping in the last element into the removed spot. So there's two things to consider there: 1) Is it cheap to copy the data? Like, if your component is large or needs some kind of allocation logic on copy. 2) Is it OK that the list of components are **unsorted**? If not, sparse sets are not a good fit. :star: [5] Special care has been taken (depending on a couple of coming Zig changes) to ensure that neither Valgrind nor Zig will complain about possibly accessing uninitialized memory. :star: [6] With the standard SparseSet implementation, it doesn't actually store any data - you have to do that manually. If you want to, you can store it in an SOA - "Structure of Arrays" manner, like so: (**Note:** For both the following SOA example and the AOS example below, you can look at src/test.zig for the whole example.) ```zig const Entity = u32; const Vec3 = struct { x: f32 = 0, y: f32 = 0, z: f32 = 0, }; const MyPositionSystemSOA = struct { component_set: sparse_set.SparseSet(Entity, u8) = undefined, xs: [256]f32 = [_]f32{0} ** 256, ys: [256]f32 = [_]f32{0} ** 256, zs: [256]f32 = [_]f32{0} ** 256, ``` The trick then is to **make sure** you handle the dense indices: ```zig const MyPositionSystem = struct { // ... pub fn addComp(self: *Self, ent: Entity, pos: Vec3) void { var dense = self.component_set.add(ent); self.xs[dense] = pos.x; self.ys[dense] = pos.y; self.zs[dense] = pos.z; } pub fn removeComp(self: *Self, ent: Entity) void { var dense_old: u8 = undefined; var dense_new: u8 = undefined; self.component_set.removeWithInfo(ent, &dense_old, &dense_new); self.xs[dense_new] = self.xs[dense_old]; self.ys[dense_new] = self.ys[dense_old]; self.zs[dense_new] = self.zs[dense_old]; } pub fn updateComps(self: *Self) void { for (self.component_set.toSparseSlice()) |ent, dense| { self.xs[dense] += 3; } } }; ``` :star: [7] With SparseSetAOS, things are simplified for you, and this will probably be the most common use case. It has the same API but has a few additional functions, and also stores an internal list of all the data. ```zig const MyPositionSystemAOS = struct { component_set: sparse_set_aos.SparseSetAOS(Entity, u8, Vec3) = undefined, // ... pub fn addComp(self: *Self, ent: Entity, pos: Vec3) void { _ = self.component_set.add(ent, pos); } pub fn removeComp(self: *Self, ent: Entity) void { self.component_set.remove(ent); } pub fn getComp(self: *Self, ent: Entity) Vec3 { return self.component_set.getValueBySparse(ent).*; } pub fn updateComps(self: Self) void { for (self.component_set.toValueSlice()) |*value, dense| { value.x += 3; } } ``` :star: [8] Compared to a sparse-handle-as-index lookup, you don't have a long list of "duds" between each valid element. And compared to a hash map, it should be more straightforward to introspect the sparse set's linear list. :star: [9] All functions that can assert from bad usage (e.g. adding more handles than the capacity, or indexing out of bounds) also has a corresponding "OrError" function that does Zig-style error handling. ## :smiling_imp: Hold up... What's the catch? :smiling_imp: 1) Well, there's the unsorted thing. 2) If you remove things frequently, and/or your objects are expensive to copy, it may outweigh the benefit of having the data continuous in memory. 3) The lookup requires `@sizeOf(DenseT) * MaxSparseValue` bytes. So for the example above, if you know that you will never have more than 256 of a specific component, then you can store the dense index as a `u8`. This would result in you needing `65536 * 1 byte = 64 kilobytes`. If you need more than 256 components, and say only 16k entities, you'd need 32 kilobytes. * **Note:** The dense -> sparse lookup is likely significantly smaller: `@sizeof(SparseT) * MaxDenseValue`, so for example `256 * 2 bytes = 512 bytes`. 4) If you don't need to loop over the elements, and are starved for memory, a hash map might be a better option. 5) Compared to looking the value up directly using the sparse handle as an array index, there's an extra indirection. 6) Using uninitialized memory may cause some validators to complain. As mentioned above, Valgrind and Zig should be fine. So, all in all, there are of course benefits and drawbacks to sparse sets. You'll have to consider this on a case-by-case basis. ## :page_with_curl: License :page_with_curl: Pick your license: Public Domain (Unlicense) or MIT. ## :statue_of_liberty: Examples :statue_of_liberty: See `src/test.zig`. Especially the MyPositionSystem ones. Here is the "unit test" that is used for generating documentation, it uses all of the functionality: ```zig test "docs" { const Entity = u32; const DenseT = u8; const DocValueT = i32; const DocsSparseSet = SparseSet(.{ .SparseT = Entity, .DenseT = DenseT, .ValueT = DocValueT, .allow_resize = .NoResize, .value_layout = .InternalArrayOfStructs, }); var ss = DocsSparseSet.init(std.debug.global_allocator, 128, 8) catch unreachable; defer ss.deinit(); var ent1: Entity = 1; var ent2: Entity = 2; _ = try ss.addOrError(ent1); _ = try ss.addValueOrError(ent2, 2); std.testing.expectEqual(@as(DenseT, 2), ss.len()); try ss.removeOrError(ent1); var old: DenseT = undefined; var new: DenseT = undefined; try ss.removeWithInfoOrError(ent2, &old, &new); _ = ss.toSparseSlice(); _ = ss.toValueSlice(); std.testing.expectEqual(@as(DenseT, 0), ss.len()); ss.clear(); std.testing.expectEqual(@as(DenseT, 8), ss.remainingCapacity()); _ = try ss.addValueOrError(ent1, 10); std.testing.expectEqual(@as(DenseT, 0), try ss.getBySparseOrError(ent1)); std.testing.expectEqual(@as(DocValueT, 10), (try ss.getValueBySparseOrError(ent1)).*); std.testing.expectEqual(@as(Entity, ent1), try ss.getByDenseOrError(0)); std.testing.expectEqual(@as(DocValueT, 10), (try ss.getValueByDenseOrError(0)).*); } ``` ## :paperclip: References :paperclip: * [incrediblejr's](https://gist.github.com/incrediblejr) C implementation [ijss](https://gist.github.com/incrediblejr/931efb7587e1ab328fa65ecc94d1009f). * The above [article](https://research.swtch.com/sparse) describing this technique. * The [Zig](https://ziglang.org/) language. * Jonathan Blow SOA/AOS [video](https://youtu.be/YGTZr6bmNmk) overview. * My [twitter](https://twitter.com/Srekel).
0
repos
repos/zig-sparse-set/build.zig
const std = @import("std"); const builtin = @import("builtin"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const test_all_step = b.step("test", "Run all tests in all modes."); inline for ([_]std.builtin.OptimizeMode{ .Debug, .ReleaseFast, .ReleaseSafe, .ReleaseSmall }) |test_mode| { const mode_str = @tagName(test_mode); const tests = b.addTest(.{ .name = mode_str ++ " ", .root_source_file = b.path("src/test.zig"), .target = target, .optimize = test_mode, }); const run_test_step = b.addRunArtifact(tests); const test_step = b.step("test-" ++ mode_str, "Run all tests in " ++ mode_str ++ "."); test_step.dependOn(&run_test_step.step); test_all_step.dependOn(test_step); } const tests = b.addTest(.{ .root_source_file = b.path("src/sparse_set.zig"), }); const install_docs = b.addInstallDirectory(.{ .source_dir = tests.getEmittedDocs(), .install_dir = .prefix, .install_subdir = "docs", }); const all_step = b.step("all", "Build everything and runs all tests"); all_step.dependOn(&install_docs.step); all_step.dependOn(test_all_step); b.default_step.dependOn(all_step); }
0
repos
repos/zig-sparse-set/_config.yml
theme: jekyll-theme-cayman
0
repos/zig-sparse-set
repos/zig-sparse-set/src/test.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const testing = std.testing; const SparseSet = @import("sparse_set.zig").SparseSet; const Entity = u32; const DenseT = u8; const Vec3 = struct { x: f32 = 0, y: f32 = 0, z: f32 = 0, }; const DefaultTestSparseSet = SparseSet(.{ .SparseT = Entity, .DenseT = DenseT, .allow_resize = .NoResize, .value_layout = .ExternalStructOfArraysSupport, }); const ResizableDefaultTestSparseSet = SparseSet(.{ .SparseT = Entity, .DenseT = DenseT, .allow_resize = .ResizeAllowed, .value_layout = .ExternalStructOfArraysSupport, }); const DefaultTestAOSSimpleSparseSet = SparseSet(.{ .SparseT = Entity, .DenseT = DenseT, .ValueT = i32, .allow_resize = .NoResize, .value_layout = .InternalArrayOfStructs, }); const DefaultTestAOSSystemSparseSet = SparseSet(.{ .SparseT = Entity, .DenseT = DenseT, .ValueT = Vec3, .allow_resize = .NoResize, .value_layout = .InternalArrayOfStructs, }); const DefaultTestAOSVec3ResizableSparseSet = SparseSet(.{ .SparseT = Entity, .DenseT = DenseT, .ValueT = Vec3, .allow_resize = .ResizeAllowed, .value_layout = .InternalArrayOfStructs, .value_init = .ZeroInitialized, }); test "init safe" { var ss = DefaultTestSparseSet.init(std.testing.allocator, 128, 8) catch unreachable; try testing.expectEqual(@as(DefaultTestSparseSet.DenseCapacityT, @intCast(0)), ss.len()); for (ss.sparse_to_dense, 0..) |dense_undefined, sparse| { _ = dense_undefined; const usparse = @as(Entity, @intCast(sparse)); try testing.expect(!(ss.hasSparse(usparse))); } try testing.expectEqual(@as(DefaultTestSparseSet.DenseCapacityT, @intCast(0)), ss.len()); ss.deinit(); } test "add / remove safe 1" { var ss = DefaultTestSparseSet.init(std.testing.allocator, 128, 8) catch unreachable; defer ss.deinit(); for (ss.dense_to_sparse, 0..) |sparse_undefined, sparse| { _ = sparse_undefined; const usparse = @as(Entity, @intCast(sparse)) + 10; const dense_new = ss.add(usparse); try testing.expectEqual(@as(DefaultTestSparseSet.DenseCapacityT, @intCast(sparse)), dense_new); try testing.expect(ss.hasSparse(usparse)); try testing.expectEqual(dense_new, ss.getBySparse(usparse)); try testing.expectEqual(usparse, ss.getByDense(dense_new)); } try testing.expectError(error.OutOfBounds, ss.addOrError(1)); try testing.expectEqual(@as(DefaultTestSparseSet.DenseCapacityT, @intCast(0)), ss.remainingCapacity()); ss.clear(); try testing.expect(!(ss.hasSparse(1))); } test "add / remove safe 2" { var ss = DefaultTestSparseSet.init(std.testing.allocator, 128, 8) catch unreachable; defer ss.deinit(); try testing.expect(!(ss.hasSparse(1))); try testing.expectEqual(@as(DefaultTestSparseSet.DenseCapacityT, @intCast(0)), ss.add(1)); try testing.expect(ss.hasSparse(1)); try testing.expectError(error.AlreadyRegistered, ss.addOrError(1)); ss.remove(1); try testing.expect(!(ss.hasSparse(1))); } test "add / remove safe 3" { var ss = DefaultTestSparseSet.init(std.testing.allocator, 128, 8) catch unreachable; defer ss.deinit(); for (ss.dense_to_sparse, 0..) |sparse_undefined, sparse| { _ = sparse_undefined; const usparse = @as(Entity, @intCast(sparse)) + 10; _ = ss.add(usparse); } try testing.expectEqual(@as(DefaultTestSparseSet.DenseCapacityT, @intCast(0)), ss.remainingCapacity()); try testing.expect(!(ss.hasSparse(5))); try testing.expect(ss.hasSparse(15)); ss.remove(15); try testing.expect(!(ss.hasSparse(15))); try testing.expectEqual(@as(DefaultTestSparseSet.DenseCapacityT, @intCast(1)), ss.remainingCapacity()); _ = ss.add(15); try testing.expect(ss.hasSparse(15)); try testing.expectEqual(@as(DefaultTestSparseSet.DenseCapacityT, @intCast(0)), ss.remainingCapacity()); } test "AOS" { var ss = DefaultTestAOSSimpleSparseSet.init(std.testing.allocator, 128, 8) catch unreachable; defer ss.deinit(); for (ss.dense_to_sparse, 0..) |sparse_undefined, sparse| { _ = sparse_undefined; const usparse = @as(Entity, @intCast(sparse)) + 10; const value = -@as(i32, @intCast(sparse)); const dense_new = ss.addValue(usparse, value); try testing.expectEqual(@as(DenseT, @intCast(sparse)), dense_new); try testing.expect(ss.hasSparse(usparse)); try testing.expectEqual(dense_new, ss.getBySparse(usparse)); try testing.expectEqual(usparse, ss.getByDense(dense_new)); try testing.expectEqual(value, (ss.getValueByDense(dense_new)).*); try testing.expectEqual(value, ss.getValueBySparse(usparse).*); } try testing.expectEqual(@as(DefaultTestSparseSet.DenseCapacityT, @intCast(0)), ss.remainingCapacity()); ss.clear(); try testing.expect(!ss.hasSparse(1)); } test "AOS system" { var sys = MyPositionSystemAOS.init(); defer sys.deinit(); const ent1: Entity = 10; const ent2: Entity = 20; const v1 = Vec3{ .x = 10, .y = 0, .z = 0 }; const v2 = Vec3{ .x = 20, .y = 0, .z = 0 }; sys.addComp(ent1, v1); sys.addComp(ent2, v2); try testing.expectEqual(v1, sys.getComp(ent1)); try testing.expectEqual(v2, sys.getComp(ent2)); try testing.expectEqual(v1, sys.component_set.values[0]); try testing.expectEqual(v2, sys.component_set.values[1]); try testing.expectEqual(@as(DenseT, 0), sys.component_set.getBySparse(ent1)); try testing.expectEqual(@as(DenseT, 1), sys.component_set.getBySparse(ent2)); sys.removeComp(ent1); try testing.expectEqual(v2, sys.getComp(ent2)); try testing.expectEqual(v2, sys.component_set.values[0]); try testing.expectEqual(@as(DenseT, 0), sys.component_set.getBySparse(ent2)); sys.updateComps(); try testing.expectEqual(Vec3{ .x = 23, .y = 0, .z = 0 }, sys.getComp(ent2)); } test "SOA system" { var sys = MyPositionSystemSOA.init(); defer sys.deinit(); const ent1: Entity = 10; const ent2: Entity = 20; const v1 = Vec3{ .x = 10, .y = 0, .z = 0 }; const v2 = Vec3{ .x = 20, .y = 0, .z = 0 }; sys.addComp(ent1, v1); sys.addComp(ent2, v2); try testing.expectEqual(v1, sys.getComp(ent1)); try testing.expectEqual(v2, sys.getComp(ent2)); try testing.expectEqual(@as(DenseT, 0), sys.component_set.getBySparse(ent1)); try testing.expectEqual(@as(DenseT, 1), sys.component_set.getBySparse(ent2)); sys.removeComp(ent1); try testing.expectEqual(v2, sys.getComp(ent2)); try testing.expectEqual(@as(DenseT, 0), sys.component_set.getBySparse(ent2)); sys.updateComps(); try testing.expectEqual(Vec3{ .x = 23, .y = 0, .z = 0 }, sys.getComp(ent2)); } test "SOA resize true" { var ss = ResizableDefaultTestSparseSet.init(std.testing.allocator, 128, 8) catch unreachable; defer ss.deinit(); try testing.expectError(error.OutOfBounds, ss.hasSparseOrError(500)); for (ss.dense_to_sparse, 0..) |sparse_undefined, sparse| { _ = sparse_undefined; const usparse = @as(Entity, @intCast(sparse)) + 10; _ = ss.add(usparse); try testing.expect(ss.hasSparse(usparse)); } try testing.expect(!ss.hasSparse(18)); try testing.expectEqual(@as(DenseT, @intCast(8)), ss.add(18)); try testing.expect(ss.hasSparse(18)); try testing.expect(!ss.hasSparse(19)); try testing.expectEqual(@as(u32, @intCast(16)), @as(u32, @intCast(ss.dense_to_sparse.len))); try testing.expectEqual(@as(DefaultTestSparseSet.DenseCapacityT, @intCast(7)), ss.remainingCapacity()); try testing.expectEqual(@as(Entity, @intCast(10)), ss.dense_to_sparse[0]); try testing.expectEqual(@as(Entity, @intCast(11)), ss.dense_to_sparse[1]); try testing.expectEqual(@as(Entity, @intCast(12)), ss.dense_to_sparse[2]); try testing.expectEqual(@as(Entity, @intCast(13)), ss.dense_to_sparse[3]); try testing.expectEqual(@as(Entity, @intCast(16)), ss.dense_to_sparse[6]); try testing.expectEqual(@as(Entity, @intCast(17)), ss.dense_to_sparse[7]); try testing.expectEqual(@as(Entity, @intCast(18)), ss.dense_to_sparse[8]); ss.clear(); try testing.expect(!(ss.hasSparse(1))); } test "AOS resize true" { var ss = DefaultTestAOSVec3ResizableSparseSet.init(std.testing.allocator, 128, 8) catch unreachable; defer ss.deinit(); try testing.expectError(error.OutOfBounds, ss.hasSparseOrError(500)); for (ss.dense_to_sparse, 0..) |sparse_undefined, sparse| { _ = sparse_undefined; const usparse = @as(Entity, @intCast(sparse)) + 10; const value = Vec3{ .x = @as(f32, @floatFromInt(sparse)), .y = 0, .z = 0 }; _ = ss.addValue(usparse, value); try testing.expect(ss.hasSparse(usparse)); try testing.expectEqual(value, ss.getValueBySparse(usparse).*); } try testing.expect(!ss.hasSparse(18)); try testing.expectEqual(@as(DenseT, @intCast(8)), ss.addValue(18, Vec3{ .x = 8, .y = 0, .z = 0 })); try testing.expect(ss.hasSparse(18)); try testing.expect(!ss.hasSparse(19)); try testing.expectEqual(@as(DefaultTestSparseSet.DenseCapacityT, @intCast(7)), ss.remainingCapacity()); try testing.expectEqual(Vec3{ .x = 0, .y = 0, .z = 0 }, ss.getValueBySparse(10).*); try testing.expectEqual(Vec3{ .x = 1, .y = 0, .z = 0 }, ss.getValueBySparse(11).*); try testing.expectEqual(Vec3{ .x = 2, .y = 0, .z = 0 }, ss.getValueBySparse(12).*); try testing.expectEqual(Vec3{ .x = 3, .y = 0, .z = 0 }, ss.getValueBySparse(13).*); try testing.expectEqual(Vec3{ .x = 4, .y = 0, .z = 0 }, ss.getValueBySparse(14).*); try testing.expectEqual(Vec3{ .x = 5, .y = 0, .z = 0 }, ss.getValueBySparse(15).*); try testing.expectEqual(Vec3{ .x = 6, .y = 0, .z = 0 }, ss.getValueBySparse(16).*); try testing.expectEqual(Vec3{ .x = 7, .y = 0, .z = 0 }, ss.getValueBySparse(17).*); try testing.expectEqual(Vec3{ .x = 8, .y = 0, .z = 0 }, ss.getValueBySparse(18).*); ss.clear(); try testing.expect(!(ss.hasSparse(1))); } const MyPositionSystemAOS = struct { component_set: DefaultTestAOSSystemSparseSet = undefined, const Self = @This(); pub fn init() MyPositionSystemAOS { return Self{ .component_set = DefaultTestAOSSystemSparseSet.init(std.testing.allocator, 128, 8) catch unreachable, }; } pub fn deinit(self: *MyPositionSystemAOS) void { self.component_set.deinit(); } pub fn addComp(self: *Self, ent: Entity, pos: Vec3) void { _ = self.component_set.addValue(ent, pos); } pub fn removeComp(self: *Self, ent: Entity) void { self.component_set.remove(ent); } pub fn getComp(self: *Self, ent: Entity) Vec3 { return self.component_set.getValueBySparse(ent).*; } pub fn updateComps(self: Self) void { for (self.component_set.toValueSlice()) |*value| { value.x += 3; } } }; const MyPositionSystemSOA = struct { component_set: DefaultTestSparseSet = undefined, xs: [256]f32 = [_]f32{0} ** 256, ys: [256]f32 = [_]f32{0} ** 256, zs: [256]f32 = [_]f32{0} ** 256, const Self = @This(); pub fn init() MyPositionSystemSOA { return Self{ .component_set = DefaultTestSparseSet.init(std.testing.allocator, 128, 8) catch unreachable, }; } pub fn deinit(self: *MyPositionSystemSOA) void { self.component_set.deinit(); } pub fn addComp(self: *Self, ent: Entity, pos: Vec3) void { const dense = self.component_set.add(ent); self.xs[dense] = pos.x; self.ys[dense] = pos.y; self.zs[dense] = pos.z; } pub fn removeComp(self: *Self, ent: Entity) void { var dense_old: DenseT = undefined; var dense_new: DenseT = undefined; self.component_set.removeWithInfo(ent, &dense_old, &dense_new); self.xs[dense_new] = self.xs[dense_old]; self.ys[dense_new] = self.ys[dense_old]; self.zs[dense_new] = self.zs[dense_old]; } pub fn getComp(self: *Self, ent: Entity) Vec3 { const dense = self.component_set.getBySparse(ent); return Vec3{ .x = self.xs[dense], .y = self.ys[dense], .z = self.zs[dense] }; } pub fn updateComps(self: *Self) void { for (self.component_set.toSparseSlice(), 0..) |ent, dense| { _ = ent; self.xs[dense] += 3; } } };
0
repos/zig-sparse-set
repos/zig-sparse-set/src/sparse_set.zig
//! Sparse Set //! //! Version 1.0.2 //! //! See https://github.com/Srekel/zig-sparse-set for latest version and documentation. //! //! See unit tests for usage examples. //! //! Dual license: Unlicense / MIT const std = @import("std"); const Allocator = std.mem.Allocator; const assert = std.debug.assert; pub const AllowResize = union(enum) { /// The fields **dense_to_sparse** and **values** will grow on **add()** and **addValue()**. ResizeAllowed, /// Errors will be generated when adding more elements than **capacity_dense**. NoResize, }; pub const ValueLayout = union(enum) { /// AOS style. InternalArrayOfStructs, /// SOA style. ExternalStructOfArraysSupport, }; pub const ValueInitialization = union(enum) { /// New values added with add() will contain uninitialized/random memory. Untouched, /// New values added with add() will be memset to zero. ZeroInitialized, }; pub const SparseSetConfig = struct { /// The type used for the sparse handle. SparseT: type, /// The type used for dense indices. DenseT: type, /// Optional: The type used for values when using **InternalArrayOfStructs**. ValueT: type = void, /// If you only have a single array of structs - AOS - letting SparseSet handle it /// with **InternalArrayOfStructs** is convenient. If you want to manage the data /// yourself or if you're using SOA, use **ExternalStructOfArraysSupport**. value_layout: ValueLayout, /// Set to **ZeroInitialized** to make values created with add() be zero initialized. /// Only valid with **value_layout == .InternalArrayOfStructs**. /// Defaults to **Untouched**. value_init: ValueInitialization = .Untouched, /// Whether or not the amount of dense indices (and values) can grow. allow_resize: AllowResize = .NoResize, }; /// Creates a specific Sparse Set type based on the config. pub fn SparseSet(comptime config: SparseSetConfig) type { const SparseT = config.SparseT; const DenseT = config.DenseT; const ValueT = config.ValueT; const allow_resize = config.allow_resize; const value_layout = config.value_layout; const value_init = config.value_init; assert((value_layout == .ExternalStructOfArraysSupport) or (ValueT != @TypeOf(void))); return struct { const Self = @This(); pub const SparseCapacityT = std.math.IntFittingRange(0, std.math.maxInt(SparseT) + 1); pub const DenseCapacityT = std.math.IntFittingRange(0, std.math.maxInt(DenseT) + 1); /// Allocator used for allocating, growing and freeing **dense_to_sparse**, **sparse_to_dense**, and **values**. allocator: Allocator, /// Mapping from dense indices to sparse handles. dense_to_sparse: []SparseT, /// Mapping from sparse handles to dense indices (and values). sparse_to_dense: []DenseT, /// Optional: A list of **ValueT** that is used with **InternalArrayOfStructs**. values: if (value_layout == .InternalArrayOfStructs) []ValueT else void, /// Current amount of used handles. dense_count: DenseCapacityT, /// Amount of dense indices that can be stored. capacity_dense: DenseCapacityT, /// Amount of sparse handles that can be used for lookups. capacity_sparse: SparseCapacityT, /// You can think of **capacity_sparse** as how many entities you want to support, and /// **capacity_dense** as how many components. pub fn init( allocator: Allocator, capacity_sparse: SparseCapacityT, capacity_dense: DenseCapacityT, ) !Self { // Could be <= but I'm not sure why'd you use a sparse_set if you don't have more sparse // indices than dense... assert(capacity_dense < capacity_sparse); const dense_to_sparse = try allocator.alloc(SparseT, capacity_dense); errdefer allocator.free(dense_to_sparse); const sparse_to_dense = try allocator.alloc(DenseT, capacity_sparse); errdefer allocator.free(sparse_to_dense); var self: Self = undefined; if (value_layout == .InternalArrayOfStructs) { const values = try allocator.alloc(ValueT, capacity_dense); errdefer allocator.free(values); self = Self{ .allocator = allocator, .dense_to_sparse = dense_to_sparse, .sparse_to_dense = sparse_to_dense, .values = values, .capacity_dense = capacity_dense, .capacity_sparse = capacity_sparse, .dense_count = 0, }; } else { self = Self{ .allocator = allocator, .dense_to_sparse = dense_to_sparse, .sparse_to_dense = sparse_to_dense, .values = {}, .capacity_dense = capacity_dense, .capacity_sparse = capacity_sparse, .dense_count = 0, }; } // Ensure Valgrind doesn't complain about hasSparse _ = std.valgrind.memcheck.makeMemDefined(std.mem.asBytes(&self.sparse_to_dense)); return self; } /// Deallocates **dense_to_sparse**, **sparse_to_dense**, and optionally **values**. pub fn deinit(self: Self) void { self.allocator.free(self.dense_to_sparse); self.allocator.free(self.sparse_to_dense); if (value_layout == .InternalArrayOfStructs) { self.allocator.free(self.values); } } /// Resets the set cheaply. pub fn clear(self: *Self) void { self.dense_count = 0; } /// Returns the amount of allocated handles. pub fn len(self: Self) DenseCapacityT { return self.dense_count; } /// Returns a slice that can be used to loop over the sparse handles. pub fn toSparseSlice(self: Self) []SparseT { return self.dense_to_sparse[0..self.dense_count]; } // A bit of a hack to comptime add a function // TODO: Rewrite after https://github.com/ziglang/zig/issues/1717 pub usingnamespace switch (value_layout) { .InternalArrayOfStructs => struct { /// Returns a slice that can be used to loop over the values. pub fn toValueSlice(self: Self) []ValueT { return self.values[0..self.dense_count]; } }, else => struct {}, }; /// Returns how many dense indices are still available pub fn remainingCapacity(self: Self) DenseCapacityT { return self.capacity_dense - self.dense_count; } /// Registers the sparse value and matches it to a dense index. /// Grows .dense_to_sparse and .values if needed and resizing is allowed. /// Note: If resizing is allowed, you must use an allocator that you are sure /// will never fail for your use cases. /// If that is not an option, use addOrError. pub fn add(self: *Self, sparse: SparseT) DenseT { if (allow_resize == .ResizeAllowed) { if (self.dense_count == self.capacity_dense) { self.capacity_dense = self.capacity_dense * 2; self.dense_to_sparse = self.allocator.realloc(self.dense_to_sparse, self.capacity_dense) catch unreachable; if (value_layout == .InternalArrayOfStructs) { self.values = self.allocator.realloc(self.values, self.capacity_dense) catch unreachable; } } } assert(sparse < self.capacity_sparse); assert(self.dense_count < self.capacity_dense); assert(!self.hasSparse(sparse)); self.dense_to_sparse[self.dense_count] = sparse; self.sparse_to_dense[sparse] = @intCast(self.dense_count); if (value_layout == .InternalArrayOfStructs and value_init == .ZeroInitialized) { self.values[self.dense_count] = std.mem.zeroes(ValueT); } self.dense_count += 1; return @intCast(self.dense_count - 1); } /// May return error.OutOfBounds or error.AlreadyRegistered, otherwise calls add. /// Grows .dense_to_sparse and .values if needed and resizing is allowed. pub fn addOrError(self: *Self, sparse: SparseT) !DenseT { if (sparse >= self.capacity_sparse) { return error.OutOfBounds; } if (try self.hasSparseOrError(sparse)) { return error.AlreadyRegistered; } if (self.dense_count == self.capacity_dense) { if (allow_resize == .ResizeAllowed) { self.capacity_dense = self.capacity_dense * 2; self.dense_to_sparse = try self.allocator.realloc(self.dense_to_sparse, self.capacity_dense); if (value_layout == .InternalArrayOfStructs) { self.values = try self.allocator.realloc(self.values, self.capacity_dense); } } else { return error.OutOfBounds; } } return self.add(sparse); } // TODO: Rewrite after https://github.com/ziglang/zig/issues/1717 pub usingnamespace switch (value_layout) { .InternalArrayOfStructs => struct { /// Registers the sparse value and matches it to a dense index /// Grows .dense_to_sparse and .values if needed and resizing is allowed. /// Note: If resizing is allowed, you must use an allocator that you are sure /// will never fail for your use cases. /// If that is not an option, use addOrError. pub fn addValue(self: *Self, sparse: SparseT, value: ValueT) DenseT { if (allow_resize == .ResizeAllowed) { if (self.dense_count == self.capacity_dense) { self.capacity_dense = self.capacity_dense * 2; self.dense_to_sparse = self.allocator.realloc(self.dense_to_sparse, self.capacity_dense) catch unreachable; if (value_layout == .InternalArrayOfStructs) { self.values = self.allocator.realloc(self.values, self.capacity_dense) catch unreachable; } } } assert(sparse < self.capacity_sparse); assert(self.dense_count < self.capacity_dense); assert(!self.hasSparse(sparse)); self.dense_to_sparse[self.dense_count] = sparse; self.sparse_to_dense[sparse] = @intCast(self.dense_count); self.values[self.dense_count] = value; self.dense_count += 1; return @intCast(self.dense_count - 1); } /// May return error.OutOfBounds or error.AlreadyRegistered, otherwise calls add. /// Grows .dense_to_sparse and .values if needed and resizing is allowed. pub fn addValueOrError(self: *Self, sparse: SparseT, value: ValueT) !DenseT { if (sparse >= self.capacity_sparse) { return error.OutOfBounds; } if (try self.hasSparseOrError(sparse)) { return error.AlreadyRegistered; } if (self.dense_count == self.capacity_dense) { if (allow_resize == .ResizeAllowed) { self.capacity_dense = self.capacity_dense * 2; self.dense_to_sparse = try self.allocator.realloc(self.dense_to_sparse, self.capacity_dense); if (value_layout == .InternalArrayOfStructs) { self.values = try self.allocator.realloc(self.values, self.capacity_dense); } } else { return error.OutOfBounds; } } return self.addValue(sparse, value); } }, else => struct {}, }; /// Removes the sparse/dense index, and replaces it with the last ones. /// dense_old and dense_new is pub fn removeWithInfo(self: *Self, sparse: SparseT, dense_old: *DenseT, dense_new: *DenseT) void { assert(self.dense_count > 0); assert(self.hasSparse(sparse)); const last_dense: DenseT = @intCast(self.dense_count - 1); const last_sparse = self.dense_to_sparse[last_dense]; const dense = self.sparse_to_dense[sparse]; self.dense_to_sparse[dense] = last_sparse; self.sparse_to_dense[last_sparse] = dense; if (value_layout == .InternalArrayOfStructs) { self.values[dense] = self.values[last_dense]; } self.dense_count -= 1; dense_old.* = last_dense; dense_new.* = dense; } /// May return error.OutOfBounds, otherwise calls removeWithInfo. pub fn removeWithInfoOrError(self: *Self, sparse: SparseT, dense_old: *DenseT, dense_new: *DenseT) !void { if (self.dense_count == 0) { return error.OutOfBounds; } if (!try self.hasSparseOrError(sparse)) { return error.NotRegistered; } return self.removeWithInfo(sparse, dense_old, dense_new); } /// Like removeWithInfo info, but slightly faster, in case you don't care about the switch. pub fn remove(self: *Self, sparse: SparseT) void { assert(self.dense_count > 0); assert(self.hasSparse(sparse)); const last_dense = self.dense_count - 1; const last_sparse = self.dense_to_sparse[last_dense]; const dense = self.sparse_to_dense[sparse]; self.dense_to_sparse[dense] = last_sparse; self.sparse_to_dense[last_sparse] = dense; if (value_layout == .InternalArrayOfStructs) { self.values[dense] = self.values[last_dense]; } self.dense_count -= 1; } /// May return error.OutOfBounds or error.NotRegistered, otherwise calls remove. pub fn removeOrError(self: *Self, sparse: SparseT) !void { if (self.dense_count == 0) { return error.OutOfBounds; } if (!try self.hasSparseOrError(sparse)) { return error.NotRegistered; } self.remove(sparse); } /// Returns true if the sparse is registered to a dense index. pub fn hasSparse(self: Self, sparse: SparseT) bool { // Unsure if this call to disable runtime safety is needed - can add later if so. // Related: https://github.com/ziglang/zig/issues/978 // @setRuntimeSafety(false); assert(sparse < self.capacity_sparse); const dense = self.sparse_to_dense[sparse]; return dense < self.dense_count and self.dense_to_sparse[dense] == sparse; } /// May return error.OutOfBounds, otherwise calls hasSparse. pub fn hasSparseOrError(self: Self, sparse: SparseT) !bool { if (sparse >= self.capacity_sparse) { return error.OutOfBounds; } return self.hasSparse(sparse); } /// Returns corresponding dense index. pub fn getBySparse(self: Self, sparse: SparseT) DenseT { assert(self.hasSparse(sparse)); return self.sparse_to_dense[sparse]; } /// Tries hasSparseOrError, then returns getBySparse. pub fn getBySparseOrError(self: Self, sparse: SparseT) !DenseT { if (!try self.hasSparseOrError(sparse)) { return error.NotRegistered; } return self.getBySparse(sparse); } /// Returns corresponding sparse index. pub fn getByDense(self: Self, dense: DenseT) SparseT { assert(dense < self.dense_count); return self.dense_to_sparse[dense]; } /// Returns OutOfBounds or getByDense. pub fn getByDenseOrError(self: Self, dense: DenseT) !SparseT { if (dense >= self.dense_count) { return error.OutOfBounds; } return self.getByDense(dense); } // TODO: Rewrite after https://github.com/ziglang/zig/issues/1717 pub usingnamespace switch (value_layout) { .InternalArrayOfStructs => struct { /// Returns a pointer to the SOA value corresponding to the sparse parameter. pub fn getValueBySparse(self: Self, sparse: SparseT) *ValueT { assert(self.hasSparse(sparse)); const dense = self.sparse_to_dense[sparse]; return &self.values[dense]; } /// First tries hasSparse, then returns getValueBySparse(). pub fn getValueBySparseOrError(self: Self, sparse: SparseT) !*ValueT { if (!try self.hasSparseOrError(sparse)) { return error.NotRegistered; } return self.getValueBySparse(sparse); } /// Returns a pointer to the SOA value corresponding to the sparse parameter. pub fn getValueByDense(self: Self, dense: DenseT) *ValueT { assert(dense < self.dense_count); return &self.values[dense]; } /// Returns error.OutOfBounds or getValueByDense(). pub fn getValueByDenseOrError(self: Self, dense: DenseT) !*ValueT { if (dense >= self.dense_count) { return error.OutOfBounds; } return self.getValueByDense(dense); } }, else => struct {}, }; }; } test "docs" { const Entity = u32; const DenseT = u8; const DocValueT = i32; const DocsSparseSet = SparseSet(.{ .SparseT = Entity, .DenseT = DenseT, .ValueT = DocValueT, .allow_resize = .NoResize, .value_layout = .InternalArrayOfStructs, }); var ss = DocsSparseSet.init(std.testing.allocator, 128, 8) catch unreachable; defer ss.deinit(); const ent1: Entity = 1; const ent2: Entity = 2; _ = try ss.addOrError(ent1); _ = try ss.addValueOrError(ent2, 2); try std.testing.expectEqual(@as(DocsSparseSet.DenseCapacityT, 2), ss.len()); try ss.removeOrError(ent1); var old: DenseT = undefined; var new: DenseT = undefined; try ss.removeWithInfoOrError(ent2, &old, &new); _ = ss.toSparseSlice(); _ = ss.toValueSlice(); try std.testing.expectEqual(@as(DocsSparseSet.DenseCapacityT, 0), ss.len()); ss.clear(); try std.testing.expectEqual(@as(DocsSparseSet.DenseCapacityT, 8), ss.remainingCapacity()); _ = try ss.addValueOrError(ent1, 10); try std.testing.expectEqual(@as(DenseT, 0), try ss.getBySparseOrError(ent1)); try std.testing.expectEqual(@as(DocValueT, 10), (try ss.getValueBySparseOrError(ent1)).*); try std.testing.expectEqual(@as(Entity, ent1), try ss.getByDenseOrError(0)); try std.testing.expectEqual(@as(DocValueT, 10), (try ss.getValueByDenseOrError(0)).*); }
0
repos
repos/waylock/README.md
# waylock Waylock is a small screenlocker for Wayland compositors implementing `ext-session-lock-v1`. The `ext-session-lock-v1` protocol is significantly more robust than previous client-side Wayland screen locking approaches. Importantly, the screenlocker crashing does not cause the session to be unlocked. Install from your [package manager](https://repology.org/project/waylock/versions) The main repository is on [codeberg](https://codeberg.org/ifreund/waylock), which is where the issue tracker may be found and where contributions are accepted. Read-only mirrors exist on [sourcehut](https://git.sr.ht/~ifreund/waylock) and [github](https://github.com/ifreund/waylock). ## Building Note: If you are packaging waylock for distribution, see [PACKAGING.md](PACKAGING.md). To compile waylock first ensure that you have the following dependencies installed: - [zig](https://ziglang.org/download/) 0.13.0 - wayland - wayland-protocols - xkbcommon - pam - pkg-config - scdoc (optional, but required for man page generation) Then run, for example: ``` zig build -Doptimize=ReleaseSafe --prefix /usr install ``` Note that PAM will only use configuration files in the system directory, likely `/etc/pam.d` by default. Therefore care must be taken if installing to a prefix other than `/usr` to ensure the configuration file [pam.d/waylock](pam.d/waylock) is found by PAM. ## Usage See the `waylock(1)` man page or the output of `waylock -h` for an overview of the command line options. Run the waylock executable to lock the session. All monitors will be blanked with the `-init-color`. Typing causes the color to change to the `-input-color`. `Esc` or `Ctrl-U` clears all current input, while `backspace` deletes the last UTF-8 codepoint. To unlock the session, type your password and press `Enter`. If the password is correct, waylock will unlock the session and exit. Otherwise, the color will change to the `-fail-color` and you may try again. In order to automatically run waylock after a certain amount of time with no input or before sleep, the [swayidle](https://github.com/swaywm/swayidle) utility or a similar program may be used. See the `swayidle(1)` man page for details. ## Licensing Waylock is released under the ISC License.
0
repos
repos/waylock/build.zig.zon
.{ .name = "waylock", .version = "1.3.0-dev", .paths = .{""}, .dependencies = .{ .@"zig-wayland" = .{ .url = "https://codeberg.org/ifreund/zig-wayland/archive/v0.2.0.tar.gz", .hash = "1220687c8c47a48ba285d26a05600f8700d37fc637e223ced3aa8324f3650bf52242", }, .@"zig-xkbcommon" = .{ .url = "https://codeberg.org/ifreund/zig-xkbcommon/archive/v0.2.0.tar.gz", .hash = "1220c90b2228d65fd8427a837d31b0add83e9fade1dcfa539bb56fd06f1f8461605f", }, }, }
0
repos
repos/waylock/build.zig
const std = @import("std"); const assert = std.debug.assert; const Build = std.Build; const fs = std.fs; const mem = std.mem; const Scanner = @import("zig-wayland").Scanner; /// While a waylock release is in development, this string should contain the version in /// development with the "-dev" suffix. /// When a release is tagged, the "-dev" suffix should be removed for the commit that gets tagged. /// Directly after the tagged commit, the version should be bumped and the "-dev" suffix added. const version = "1.3.0-dev"; pub fn build(b: *Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const strip = b.option(bool, "strip", "Omit debug information") orelse false; const pie = b.option(bool, "pie", "Build a Position Independent Executable") orelse false; const man_pages = b.option( bool, "man-pages", "Set to true to build man pages. Requires scdoc. Defaults to true if scdoc is found.", ) orelse scdoc_found: { _ = b.findProgram(&.{"scdoc"}, &.{}) catch |err| switch (err) { error.FileNotFound => break :scdoc_found false, else => return err, }; break :scdoc_found true; }; if (man_pages) { // Workaround for https://github.com/ziglang/zig/issues/16369 // Even passing a buffer to std.Build.Step.Run appears to be racy and occasionally deadlocks. const scdoc = b.addSystemCommand(&.{ "sh", "-c", "scdoc < doc/waylock.1.scd" }); // This makes the caching work for the Workaround, and the extra argument is ignored by /bin/sh. scdoc.addFileArg(b.path("doc/waylock.1.scd")); const stdout = scdoc.captureStdOut(); b.getInstallStep().dependOn(&b.addInstallFile(stdout, "share/man/man1/waylock.1").step); } const install_prefix = try std.fs.path.resolve(b.allocator, &.{b.install_prefix}); if (mem.eql(u8, install_prefix, "/usr")) { b.installFile("pam.d/waylock", "../etc/pam.d/waylock"); } else { b.installFile("pam.d/waylock", "etc/pam.d/waylock"); } const full_version = blk: { if (mem.endsWith(u8, version, "-dev")) { var ret: u8 = undefined; const git_describe_long = b.runAllowFail( &.{ "git", "-C", b.build_root.path orelse ".", "describe", "--long" }, &ret, .Inherit, ) catch break :blk version; var it = mem.split(u8, mem.trim(u8, git_describe_long, &std.ascii.whitespace), "-"); _ = it.next().?; // previous tag const commit_count = it.next().?; const commit_hash = it.next().?; assert(it.next() == null); assert(commit_hash[0] == 'g'); // Follow semantic versioning, e.g. 0.2.0-dev.42+d1cf95b break :blk b.fmt(version ++ ".{s}+{s}", .{ commit_count, commit_hash[1..] }); } else { break :blk version; } }; const options = b.addOptions(); options.addOption([]const u8, "version", full_version); const scanner = Scanner.create(b, .{}); scanner.addSystemProtocol("staging/ext-session-lock/ext-session-lock-v1.xml"); scanner.addSystemProtocol("staging/single-pixel-buffer/single-pixel-buffer-v1.xml"); scanner.addSystemProtocol("stable/viewporter/viewporter.xml"); scanner.generate("wl_compositor", 4); scanner.generate("wl_output", 3); scanner.generate("wl_seat", 5); scanner.generate("ext_session_lock_manager_v1", 1); scanner.generate("wp_viewporter", 1); scanner.generate("wp_single_pixel_buffer_manager_v1", 1); const wayland = b.createModule(.{ .root_source_file = scanner.result }); const xkbcommon = b.dependency("zig-xkbcommon", .{}).module("xkbcommon"); const waylock = b.addExecutable(.{ .name = "waylock", .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); waylock.root_module.addOptions("build_options", options); waylock.linkLibC(); waylock.linkSystemLibrary("pam"); waylock.root_module.addImport("wayland", wayland); waylock.linkSystemLibrary("wayland-client"); waylock.root_module.addImport("xkbcommon", xkbcommon); waylock.linkSystemLibrary("xkbcommon"); // TODO: remove when zig issue #131 is implemented scanner.addCSource(waylock); waylock.root_module.strip = strip; waylock.pie = pie; b.installArtifact(waylock); }
0
repos
repos/waylock/PACKAGING.md
# Packaging waylock for distribution First of all, I apologize for writing waylock in Zig. It will likely make your job harder until Zig is more mature/stable. I do however believe that writing my software in Zig allows me to deliver the best quality I can despite the drawbacks of depending on a relatively immature language/toolchain. ## Source tarballs Source tarballs with stable checksums may be found on the [codeberg releases](https://codeberg.org/ifreund/waylock/releases) page. These tarballs are signed with the PGP key available on my website at <https://isaacfreund.com/public_key.txt>. For the 0.4.0 release for example, the tarball and signature URLs are: ``` https://codeberg.org/ifreund/waylock/releases/download/v0.4.0/waylock-0.4.0.tar.gz https://codeberg.org/ifreund/waylock/releases/download/v0.4.0/waylock-0.4.0.tar.gz.sig ``` ## Zig version Until Zig 1.0, Zig releases will often have breaking changes that prevent waylock from building. Waylock tracks the latest minor version Zig release and is only compatible with that release and any patch releases. At the time of writing for example waylock is compatible with Zig 0.9.0 and 0.9.1 but not Zig 0.8.0 or 0.10.0. ## Zig Package Manager Waylock uses the built-in Zig package manager for its (few) Zig dependencies. By default, running `zig build` will fetch waylock's Zig dependencies from the internet and store them in the global zig cache before building waylock. Since accessing the internet is forbidden or at least frowned upon by most distro packaging infrastructure, there are ways to fetch the Zig dependencies in a separate step before building waylock: 1. Fetch step with internet access: For each package in the `build.zig.zon` manifest file run the following command with the tarball URL in the `build.zig.zon`: ``` zig fetch --global-cache-dir /tmp/foobar $URL ``` This command will download and unpack the tarball, hash the contents of the tarball, and store the contents in the `/tmp/foobar/p/$HASH` directory. This hash should match the corresponding hash field in the `build.zig.zon`. 2. Build step with no internet access: The `--system` flag for `zig build` takes a path to an arbitrary directory in which zig packages stored in subdirectories matching their hash can be found. ``` zig build --system /tmp/foobar/p/ ... ``` This flag will disable all internet access and error if a package is not found in the provided directory. It is also possible for distros to distribute Zig package manager packages as distro packages although there are still some rough edges as the support for this is not yet mature. See this patchset for Chimera Linux for an example of how this can work: https://github.com/chimera-linux/cports/pull/1395 ## Build options Waylock is built using the Zig build system. To see all available build options run `zig build --help`. Important: By default Zig will build for the host system/cpu using the equivalent of `-march=native`. To produce a portable binary `-Dcpu=baseline` at a minimum must be passed. Here are a few other options that are particularly relevant to packagers: - `-Dcpu=baseline`: Build for the "baseline" CPU of the target architecture, or any other CPU/feature set (e.g. `-Dcpu=x86_64_v2`). - Individual features can be added/removed with `+`/`-` (e.g. `-Dcpu=x86_64+avx2-cmov`). - For a list of CPUs see for example `zig targets | jq '.cpus.x86_64 | keys'`. - For a list of features see for example `zig targets | jq '.cpusFeatures.x86_64'`. - `-Dtarget=x86_64-linux-gnu`: Target architecture, OS, and ABI triple. See the output of `zig targets` for an exhaustive list of targets and CPU features, use of `jq(1)` to inspect the output recommended. - `-Dpie`: Build a position independent executable. - `-Dstrip`: Build without debug info. This not the same as invoking `strip(1)` on the resulting binary as it prevents the compiler from emitting debug info in the first place. For greatest effect, both may be used. - `--sysroot /path/to/sysroot`: Set the sysroot for cross compilation. - `--libc my_libc.txt`: Set system libc paths for cross compilation. Run `zig libc` to see a documented template for what this file should contain. - Enable compiler optimizations: - `-Doptimize=ReleaseSafe`: Optimize for execution speed, keep all assertions and runtime safety checks active. - `-Doptimize=ReleaseFast`: Optimize for execution speed, disable all assertions and runtime safety checks. - `-Doptimize=ReleaseSmall`: Optimize for binary size, disable all assertions and runtime safety checks. Please use `-Doptimize=ReleaseSafe` when building waylock for general use. This software is not at all demanding when it comes to CPU execution speed and the increased safety is more than worth the binary size trade-off in my opinion. ## Build prefix and DESTDIR To control the build prefix and directory use `--prefix` and the `DESTDIR` environment variable. For example ```bash DESTDIR="/foo/bar" zig build --prefix /usr install ``` will install waylock to `/foo/bar/usr/bin/waylock`. The Zig build system only has a single install step, there is no way to build artifacts for a given prefix and then install those artifacts to that prefix at some later time. However, much existing distribution packaging tooling expect separate build and install steps. To fit the Zig build system into this tooling, I recommend the following pattern: ```bash build() { DESTDIR="/tmp/waylock-destdir" zig build --prefix /usr install } install() { cp -r /tmp/waylock-destdir/* /desired/install/location } ``` ## Examples Build for the host architecture and libc ABI: ```bash DESTDIR=/foo/bar zig build -Doptimize=ReleaseSafe -Dcpu=baseline \ -Dstrip -Dpie --prefix /usr install ``` Cross compile for aarch64 musl libc based linux: ```bash cat > xbps_zig_libc.txt <<-EOF include_dir=${XBPS_CROSS_BASE}/usr/include sys_include_dir=${XBPS_CROSS_BASE}/usr/include crt_dir=${XBPS_CROSS_BASE}/usr/lib msvc_lib_dir= kernel32_lib_dir= gcc_dir= EOF DESTDIR="/foo/bar" zig build \ --sysroot "${XBPS_CROSS_BASE}" \ --libc xbps_zig_libc.txt \ -Dtarget=aarch64-linux-musl -Dcpu=baseline \ -Doptimize=ReleaseSafe -Dstrip -Dpie \ --prefix /usr install ``` ## Questions? If you have any questions feel free to reach out to me at `[email protected]` or in `#zig` or `#river` on `irc.libera.chat`, my nick is `ifreund`.
0
repos/waylock
repos/waylock/.builds/freebsd.yml
image: freebsd/latest packages: - devel/pkgconf - graphics/wayland - graphics/wayland-protocols - scdoc - security/ca_root_nss - wget - x11/libxkbcommon sources: - https://codeberg.org/ifreund/waylock tasks: - install_deps: | # Eat Github's resources rather than the Zig Software Foundation's resources! wget -nv https://github.com/ifreund/zig-tarball-mirror/releases/download/0.13.0/zig-freebsd-x86_64-0.13.0.tar.xz tar xf zig-freebsd-x86_64-0.13.0.tar.xz sudo mv zig-freebsd-x86_64-0.13.0/zig /usr/bin/ sudo mv zig-freebsd-x86_64-0.13.0/lib /usr/lib/zig - build: | cd waylock zig build -Dman-pages - fmt: | cd waylock zig fmt --check build.zig zig fmt --check src/
0
repos/waylock
repos/waylock/.builds/archlinux.yml
image: archlinux packages: - libxkbcommon - pam - pkgconf - scdoc - tar - wayland - wayland-protocols - wget - xz sources: - https://codeberg.org/ifreund/waylock tasks: - install_deps: | # Eat Github's resources rather than the Zig Software Foundation's resources! wget -nv https://github.com/ifreund/zig-tarball-mirror/releases/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz tar xf zig-linux-x86_64-0.13.0.tar.xz sudo mv zig-linux-x86_64-0.13.0/zig /usr/bin/ sudo mv zig-linux-x86_64-0.13.0/lib /usr/lib/zig - build: | cd waylock zig build -Dman-pages - fmt: | cd waylock zig fmt --check build.zig zig fmt --check src/
0
repos/waylock
repos/waylock/.builds/alpine.yml
image: alpine/edge packages: - libxkbcommon-dev - linux-pam-dev - pkgconf - scdoc - tar - wayland-dev - wayland-protocols - wget - xz sources: - https://codeberg.org/ifreund/waylock tasks: - install_deps: | # Eat Github's resources rather than the Zig Software Foundation's resources! wget -nv https://github.com/ifreund/zig-tarball-mirror/releases/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz tar xf zig-linux-x86_64-0.13.0.tar.xz sudo mv zig-linux-x86_64-0.13.0/zig /usr/bin/ sudo mv zig-linux-x86_64-0.13.0/lib /usr/lib/zig - build: | cd waylock zig build -Dman-pages - fmt: | cd waylock zig fmt --check build.zig zig fmt --check src/
0
repos/waylock
repos/waylock/src/pam.zig
extern fn pam_start( service_name: [*:0]const u8, user: ?[*:0]const u8, conversation: *const Conv, pamh: **Handle, ) Result; pub const start = pam_start; pub const Handle = opaque { extern fn pam_end( pamh: *Handle, /// Should be set to the result of the last pam library call. pam_status: Result, ) Result; pub const end = pam_end; extern fn pam_authenticate(pamh: *Handle, flags: c_int) Result; pub const authenticate = pam_authenticate; extern fn pam_setcred(pamh: *Handle, flags: c_int) Result; pub const setcred = pam_setcred; }; pub const Message = extern struct { msg_style: enum(c_int) { prompt_echo_off = 1, prompt_echo_on = 2, error_msg = 3, text_info = 4, }, msg: [*:0]const u8, }; pub const Response = extern struct { /// This field should always be either null or allocated using libc's malloc, never undefined. resp: ?[*:0]u8 = null, /// From pam_conv(3): /// "The resp_retcode member of this struct is unused and should be set to zero." resp_retcode: c_int = 0, }; pub const Conv = extern struct { conv: *const fn ( num_msg: c_int, /// Note: This matches the Linux-PAM API, apparently Solaris PAM differs /// in how the msg argument is used. msg: [*]*const Message, /// Out parameter, the [*]Response array will be free'd using free(3) /// by the caller. resp: *[*]Response, appdata_ptr: ?*anyopaque, ) callconv(.C) Result, appdata_ptr: ?*anyopaque, }; pub const Result = enum(c_int) { /// Successful function return success = 0, /// dlopen() failure when dynamically loading a service module open_err = 1, /// Symbol not found symbol_err = 2, /// Error in service module service_err = 3, /// System error system_err = 4, /// Memory buffer error buf_err = 5, /// Permission denied perm_denied = 6, /// Authentication failure auth_err = 7, /// Can not access authentication data due to insufficient credentials cred_insufficient = 8, /// Underlying authentication service can not retrieve authentication information authinfo_unavail = 9, /// User not known to the underlying authentication module user_unknown = 10, /// An authentication service has maintained a retry count which has /// been reached. No further retries should be attempted maxtries = 11, /// New authentication token required. This is normally returned if the /// machine security policies require that the password should be changed /// because the password is NULL or it has aged new_authtok_reqd = 12, /// User account has expired acct_expired = 13, /// Can not make/remove an entry for the specified session session_err = 14, /// Underlying authentication service can not retrieve user credentials unavailable cred_unavail = 15, /// User credentials expired cred_expired = 16, /// Failure setting user credentials cred_err = 17, /// No module specific data is present no_module_data = 18, /// Conversation error conv_err = 19, /// Authentication token manipulation error authtok_err = 20, /// Authentication information cannot be recovered authtok_recovery_err = 21, /// Authentication token lock busy authtok_lock_busy = 22, /// Authentication token aging disabled authtok_disable_aging = 23, /// Preliminary check by password service try_again = 24, /// Ignore underlying account module regardless of whether the control /// flag is required, optional, or sufficient ignore = 25, /// Critical error (?module fail now request) abort = 26, /// user's authentication token has expired authtok_expired = 27, /// module is not known module_unknown = 28, /// Bad item passed to pam_*_item() bad_item = 29, /// conversation function is event driven and data is not available yet conv_again = 30, /// please call this function again to complete authentication /// stack. Before calling again, verify that conversation is completed incomplete = 31, /// The pamh argument to this function is ignored by the implementation. extern fn pam_strerror(pamh: ?*Handle, errnum: Result) [*:0]const u8; pub fn description(result: Result) [*:0]const u8 { return pam_strerror(null, result); } }; // Flags intended to be bitwise or'ed together pub const flags = struct { /// Authentication service should not generate any messages pub const silent = 0x8000; // Note: these flags are used by pam_authenticate{,_secondary}() /// The authentication service should return .auth_err if /// user has a null authentication token pub const disallow_null_authtok = 0x0001; // Note: these flags are used for pam_setcred() /// Set user credentials for an authentication service pub const estblish_cred = 0x0002; /// Delete user credentials associated with an authentication service pub const delete_cred = 0x0004; /// Reinitialize user credentials pub const reinitialize_cred = 0x0008; /// Extend lifetime of user credentials pub const refresh_cred = 0x0010; };
0
repos/waylock
repos/waylock/src/Seat.zig
const Seat = @This(); const std = @import("std"); const log = std.log; const posix = std.posix; const wayland = @import("wayland"); const wl = wayland.client.wl; const ext = wayland.client.ext; const xkb = @import("xkbcommon"); const Lock = @import("Lock.zig"); const gpa = std.heap.c_allocator; lock: *Lock, name: u32, wl_seat: *wl.Seat, wl_pointer: ?*wl.Pointer = null, wl_keyboard: ?*wl.Keyboard = null, xkb_state: ?*xkb.State = null, pub fn init(seat: *Seat, lock: *Lock, name: u32, wl_seat: *wl.Seat) void { seat.* = .{ .lock = lock, .name = name, .wl_seat = wl_seat, }; wl_seat.setListener(*Seat, seat_listener, seat); } pub fn destroy(seat: *Seat) void { seat.wl_seat.release(); if (seat.wl_pointer) |wl_pointer| wl_pointer.release(); if (seat.wl_keyboard) |wl_keyboard| wl_keyboard.release(); if (seat.xkb_state) |xkb_state| xkb_state.unref(); const node: *std.SinglyLinkedList(Seat).Node = @fieldParentPtr("data", seat); seat.lock.seats.remove(node); gpa.destroy(node); } fn seat_listener(wl_seat: *wl.Seat, event: wl.Seat.Event, seat: *Seat) void { switch (event) { .name => {}, .capabilities => |ev| { if (ev.capabilities.pointer and seat.wl_pointer == null) { seat.wl_pointer = wl_seat.getPointer() catch { log.err("failed to allocate memory for wl_pointer object", .{}); return; }; seat.wl_pointer.?.setListener(?*anyopaque, pointer_listener, null); } else if (!ev.capabilities.pointer and seat.wl_pointer != null) { seat.wl_pointer.?.release(); seat.wl_pointer = null; } if (ev.capabilities.keyboard and seat.wl_keyboard == null) { seat.wl_keyboard = wl_seat.getKeyboard() catch { log.err("failed to allocate memory for wl_keyboard object", .{}); return; }; seat.wl_keyboard.?.setListener(*Seat, keyboard_listener, seat); } else if (!ev.capabilities.keyboard and seat.wl_keyboard != null) { seat.wl_keyboard.?.release(); seat.wl_keyboard = null; } }, } } fn pointer_listener(wl_pointer: *wl.Pointer, event: wl.Pointer.Event, _: ?*anyopaque) void { switch (event) { .enter => |ev| { // Hide the cursor when it enters any surface of this client. wl_pointer.setCursor(ev.serial, null, 0, 0); }, else => {}, } } fn keyboard_listener(_: *wl.Keyboard, event: wl.Keyboard.Event, seat: *Seat) void { switch (event) { .enter => { // It doesn't matter which surface gains keyboard focus or what keys are // currently pressed. We don't implement key repeat for simiplicity. }, .leave => { // There's nothing to do as we don't implement key repeat and // only care about press events, not release. }, .keymap => |ev| { defer posix.close(ev.fd); if (ev.format != .xkb_v1) { log.err("unsupported keymap format {d}", .{@intFromEnum(ev.format)}); return; } const keymap_string = posix.mmap(null, ev.size, posix.PROT.READ, .{ .TYPE = .PRIVATE }, ev.fd, 0) catch |err| { log.err("failed to mmap() keymap fd: {s}", .{@errorName(err)}); return; }; defer posix.munmap(keymap_string); const keymap = xkb.Keymap.newFromBuffer( seat.lock.xkb_context, keymap_string.ptr, // The string is 0 terminated keymap_string.len - 1, .text_v1, .no_flags, ) orelse { log.err("failed to parse xkb keymap", .{}); return; }; defer keymap.unref(); const state = xkb.State.new(keymap) orelse { log.err("failed to create xkb state", .{}); return; }; defer state.unref(); if (seat.xkb_state) |s| s.unref(); seat.xkb_state = state.ref(); }, .modifiers => |ev| { if (seat.xkb_state) |xkb_state| { _ = xkb_state.updateMask( ev.mods_depressed, ev.mods_latched, ev.mods_locked, 0, 0, ev.group, ); } }, .key => |ev| { if (ev.state != .pressed) return; if (seat.lock.state == .exiting) return; const xkb_state = seat.xkb_state orelse return; // The wayland protocol gives us an input event code. To convert this to an xkb // keycode we must add 8. const keycode = ev.key + 8; const keysym = xkb_state.keyGetOneSym(keycode); if (keysym == .NoSymbol) return; const lock = seat.lock; switch (@intFromEnum(keysym)) { xkb.Keysym.Return, xkb.Keysym.KP_Enter, => { // Ignore the attempt to submit the password if the locked event has not yet // been received. This should be pretty much impossible to happen in practice // as the compositor should send the locked event in a matter of milliseconds. // However if the compositor is behaving strangely it is better to ignore this // than crash on an assertion failure or commit a protocol error. if (lock.state == .locked) { lock.submit_password(); } return; }, xkb.Keysym.Escape => { lock.password.clear(); lock.set_color(.init); return; }, xkb.Keysym.u => { const Component = xkb.State.Component; const ctrl_active = xkb_state.modNameIsActive( xkb.names.mod.ctrl, @enumFromInt(Component.mods_depressed | Component.mods_latched), ) == 1; if (ctrl_active) { lock.password.clear(); lock.set_color(.init); return; } }, xkb.Keysym.BackSpace => { lock.password.pop_codepoint(); if (lock.password.buffer.len == 0) { lock.set_color(.init); } return; }, else => {}, } // If key was not handled, write to password buffer const delta = xkb_state.keyGetUtf8(keycode, lock.password.unused_slice()); if (delta > 0) { lock.set_color(.input); } lock.password.grow(delta) catch log.err("password exceeds 1024 byte limit", .{}); }, .repeat_info => {}, } }
0
repos/waylock
repos/waylock/src/flags.zig
// Zero allocation argument parsing for unix-like systems. // Released under the Zero Clause BSD (0BSD) license: // // Copyright 2023 Isaac Freund // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted. // // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. const std = @import("std"); const mem = std.mem; pub const Flag = struct { name: [:0]const u8, kind: enum { boolean, arg }, }; pub fn parser(comptime Arg: type, comptime flags: []const Flag) type { switch (Arg) { // TODO consider allowing []const u8 [:0]const u8, [*:0]const u8 => {}, // ok else => @compileError("invalid argument type: " ++ @typeName(Arg)), } return struct { pub const Result = struct { /// Remaining args after the recognized flags args: []const Arg, /// Data obtained from parsed flags flags: Flags, pub const Flags = flags_type: { var fields: []const std.builtin.Type.StructField = &.{}; for (flags) |flag| { const field: std.builtin.Type.StructField = switch (flag.kind) { .boolean => .{ .name = flag.name, .type = bool, .default_value = &false, .is_comptime = false, .alignment = @alignOf(bool), }, .arg => .{ .name = flag.name, .type = ?[:0]const u8, .default_value = &@as(?[:0]const u8, null), .is_comptime = false, .alignment = @alignOf(?[:0]const u8), }, }; fields = fields ++ [_]std.builtin.Type.StructField{field}; } break :flags_type @Type(.{ .Struct = .{ .layout = .auto, .fields = fields, .decls = &.{}, .is_tuple = false, } }); }; }; pub fn parse(args: []const Arg) !Result { var result_flags: Result.Flags = .{}; var i: usize = 0; outer: while (i < args.len) : (i += 1) { const arg = switch (Arg) { [*:0]const u8 => mem.sliceTo(args[i], 0), [:0]const u8 => args[i], else => unreachable, }; inline for (flags) |flag| { if (mem.eql(u8, "-" ++ flag.name, arg)) { switch (flag.kind) { .boolean => @field(result_flags, flag.name) = true, .arg => { i += 1; if (i == args.len) { std.log.err("option '-" ++ flag.name ++ "' requires an argument but none was provided!", .{}); return error.MissingFlagArgument; } @field(result_flags, flag.name) = switch (Arg) { [*:0]const u8 => mem.sliceTo(args[i], 0), [:0]const u8 => args[i], else => unreachable, }; }, } continue :outer; } } break; } return Result{ .args = args[i..], .flags = result_flags, }; } }; }
0
repos/waylock
repos/waylock/src/main.zig
const std = @import("std"); const assert = std.debug.assert; const io = std.io; const mem = std.mem; const posix = std.posix; const log = std.log; const build_options = @import("build_options"); const builtin = @import("builtin"); const Lock = @import("Lock.zig"); const flags = @import("flags.zig"); const usage = \\usage: waylock [options] \\ \\ -h Print this help message and exit. \\ -version Print the version number and exit. \\ -log-level <level> Set the log level to error, warning, info, or debug. \\ \\ -fork-on-lock Fork to the background after locking. \\ -ready-fd <fd> Write a newline to fd after locking. \\ -ignore-empty-password Do not validate an empty password. \\ \\ -init-color 0xRRGGBB Set the initial color. \\ -input-color 0xRRGGBB Set the color used after input. \\ -fail-color 0xRRGGBB Set the color used on authentication failure. \\ ; pub fn main() void { const result = flags.parser([*:0]const u8, &.{ .{ .name = "h", .kind = .boolean }, .{ .name = "version", .kind = .boolean }, .{ .name = "log-level", .kind = .arg }, .{ .name = "fork-on-lock", .kind = .boolean }, .{ .name = "ready-fd", .kind = .arg }, .{ .name = "ignore-empty-password", .kind = .boolean }, .{ .name = "init-color", .kind = .arg }, .{ .name = "input-color", .kind = .arg }, .{ .name = "fail-color", .kind = .arg }, }).parse(std.os.argv[1..]) catch { io.getStdErr().writeAll(usage) catch {}; posix.exit(1); }; if (result.flags.h) { io.getStdOut().writeAll(usage) catch posix.exit(1); posix.exit(0); } if (result.args.len != 0) { log.err("unknown option '{s}'", .{result.args[0]}); io.getStdErr().writeAll(usage) catch {}; posix.exit(1); } if (result.flags.version) { io.getStdOut().writeAll(build_options.version ++ "\n") catch posix.exit(1); posix.exit(0); } if (result.flags.@"log-level") |level| { if (mem.eql(u8, level, "error")) { runtime_log_level = .err; } else if (mem.eql(u8, level, "warning")) { runtime_log_level = .warn; } else if (mem.eql(u8, level, "info")) { runtime_log_level = .info; } else if (mem.eql(u8, level, "debug")) { runtime_log_level = .debug; } else { log.err("invalid log level '{s}'", .{level}); posix.exit(1); } } var options: Lock.Options = .{ .fork_on_lock = result.flags.@"fork-on-lock", .ignore_empty_password = result.flags.@"ignore-empty-password", }; if (result.flags.@"ready-fd") |raw| { options.ready_fd = std.fmt.parseInt(posix.fd_t, raw, 10) catch { log.err("invalid file descriptor '{s}'", .{raw}); posix.exit(1); }; } if (result.flags.@"init-color") |raw| options.init_color = parse_color(raw); if (result.flags.@"input-color") |raw| options.input_color = parse_color(raw); if (result.flags.@"fail-color") |raw| options.fail_color = parse_color(raw); Lock.run(options); } fn parse_color(raw: []const u8) u24 { if (raw.len != 8) fatal_bad_color(raw); if (!mem.eql(u8, raw[0..2], "0x")) fatal_bad_color(raw); return std.fmt.parseUnsigned(u24, raw[2..], 16) catch fatal_bad_color(raw); } fn fatal_bad_color(raw: []const u8) noreturn { log.err("invalid color '{s}', expected format '0xRRGGBB'", .{raw}); posix.exit(1); } /// Set the default log level based on the build mode. var runtime_log_level: log.Level = switch (builtin.mode) { .Debug => .debug, .ReleaseSafe, .ReleaseFast, .ReleaseSmall => .err, }; pub const std_options: std.Options = .{ // Tell std.log to leave all log level filtering to us. .log_level = .debug, .logFn = logFn, }; fn logFn( comptime level: log.Level, comptime scope: @TypeOf(.EnumLiteral), comptime format: []const u8, args: anytype, ) void { // waylock is small enough that we don't need scopes comptime assert(scope == .default); if (@intFromEnum(level) > @intFromEnum(runtime_log_level)) return; const stderr = io.getStdErr().writer(); stderr.print(level.asText() ++ ": " ++ format ++ "\n", args) catch {}; }
0
repos/waylock
repos/waylock/src/Output.zig
const Output = @This(); const std = @import("std"); const log = std.log; const math = std.math; const mem = std.mem; const os = std.os; const wayland = @import("wayland"); const wl = wayland.client.wl; const wp = wayland.client.wp; const ext = wayland.client.ext; const Lock = @import("Lock.zig"); const gpa = std.heap.c_allocator; lock: *Lock, name: u32, wl_output: *wl.Output, surface: ?*wl.Surface = null, viewport: ?*wp.Viewport = null, lock_surface: ?*ext.SessionLockSurfaceV1 = null, // These fields are not used before the first configure is received. width: u31 = undefined, height: u31 = undefined, pub fn create_surface(output: *Output) !void { const surface = try output.lock.compositor.?.createSurface(); output.surface = surface; const lock_surface = try output.lock.session_lock.?.getLockSurface(surface, output.wl_output); lock_surface.setListener(*Output, lock_surface_listener, output); output.lock_surface = lock_surface; output.viewport = try output.lock.viewporter.?.getViewport(surface); } pub fn destroy(output: *Output) void { output.wl_output.release(); if (output.viewport) |viewport| viewport.destroy(); if (output.lock_surface) |lock_surface| lock_surface.destroy(); if (output.surface) |surface| surface.destroy(); const node: *std.SinglyLinkedList(Output).Node = @fieldParentPtr("data", output); output.lock.outputs.remove(node); gpa.destroy(node); } fn lock_surface_listener( _: *ext.SessionLockSurfaceV1, event: ext.SessionLockSurfaceV1.Event, output: *Output, ) void { const lock = output.lock; switch (event) { .configure => |ev| { output.width = @min(std.math.maxInt(u31), ev.width); output.height = @min(std.math.maxInt(u31), ev.height); output.lock_surface.?.ackConfigure(ev.serial); output.attach_buffer(lock.buffers[@intFromEnum(lock.color)]); }, } } pub fn attach_buffer(output: *Output, buffer: *wl.Buffer) void { output.surface.?.attach(buffer, 0, 0); output.surface.?.damageBuffer(0, 0, math.maxInt(i32), math.maxInt(i32)); output.viewport.?.setDestination(output.width, output.height); output.surface.?.commit(); }
0
repos/waylock
repos/waylock/src/auth.zig
const builtin = @import("builtin"); const std = @import("std"); const assert = std.debug.assert; const log = std.log; const mem = std.mem; const posix = std.posix; const c = @cImport({ @cInclude("unistd.h"); // getuid() @cInclude("pwd.h"); // getpwuid() }); const pam = @import("pam.zig"); const PasswordBuffer = @import("PasswordBuffer.zig"); pub const Connection = struct { read_fd: posix.fd_t, write_fd: posix.fd_t, pub fn reader(conn: Connection) std.fs.File.Reader { const file = std.fs.File{ .handle = conn.read_fd }; return file.reader(); } pub fn writer(conn: Connection) std.fs.File.Writer { const file = std.fs.File{ .handle = conn.write_fd }; return file.writer(); } }; pub fn fork_child() !Connection { const parent_to_child = try posix.pipe(); const child_to_parent = try posix.pipe(); const pid = try posix.fork(); if (pid == 0) { // We are the child posix.close(parent_to_child[1]); posix.close(child_to_parent[0]); run(.{ .read_fd = parent_to_child[0], .write_fd = child_to_parent[1], }); } else { // We are the parent posix.close(parent_to_child[0]); posix.close(child_to_parent[1]); return Connection{ .read_fd = child_to_parent[0], .write_fd = parent_to_child[1], }; } } var password: PasswordBuffer = undefined; pub fn run(conn: Connection) noreturn { password = PasswordBuffer.init(); const conv: pam.Conv = .{ .conv = converse, .appdata_ptr = null, }; var pamh: *pam.Handle = undefined; { const pw = @as(?*c.struct_passwd, c.getpwuid(c.getuid())) orelse { log.err("failed to get name of current user", .{}); posix.exit(1); }; const result = pam.start("waylock", pw.pw_name, &conv, &pamh); if (result != .success) { log.err("failed to initialize PAM: {s}", .{result.description()}); posix.exit(1); } } while (true) { read_password(conn) catch |err| { log.err("failed to read password from pipe: {s}", .{@errorName(err)}); posix.exit(1); }; const auth_result = pamh.authenticate(0); password.clear(); if (auth_result == .success) { log.debug("PAM authentication succeeded", .{}); conn.writer().writeByte(@intFromBool(true)) catch |err| { log.err("failed to notify parent of success: {s}", .{@errorName(err)}); posix.exit(1); }; // We don't need to prevent unlocking if this fails. Failure just // means that some extra things like Kerberos might not work without // user intervention. const setcred_result = pamh.setcred(pam.flags.reinitialize_cred); if (setcred_result != .success) { log.err("PAM failed to reinitialize credentials: {s}", .{ setcred_result.description(), }); } const end_result = pamh.end(setcred_result); if (end_result != .success) { log.err("PAM deinitialization failed: {s}", .{end_result.description()}); } posix.exit(0); } else { log.err("PAM authentication failed: {s}", .{auth_result.description()}); conn.writer().writeByte(@intFromBool(false)) catch |err| { log.err("failed to notify parent of failure: {s}", .{@errorName(err)}); posix.exit(1); }; if (auth_result == .abort) { const end_result = pamh.end(auth_result); if (end_result != .success) { log.err("PAM deinitialization failed: {s}", .{end_result.description()}); } posix.exit(1); } } } } fn read_password(conn: Connection) !void { assert(password.buffer.len == 0); const reader = conn.reader(); const length = try reader.readInt(u32, builtin.cpu.arch.endian()); try password.grow(length); try reader.readNoEof(password.buffer); } fn converse( num_msg: c_int, msg: [*]*const pam.Message, resp: *[*]pam.Response, _: ?*anyopaque, ) callconv(.C) pam.Result { const ally = std.heap.raw_c_allocator; const responses = ally.alloc(pam.Response, @intCast(num_msg)) catch { return .buf_err; }; @memset(responses, .{}); resp.* = responses.ptr; for (msg, responses) |message, *response| { switch (message.msg_style) { .prompt_echo_off => { response.* = .{ .resp = ally.dupeZ(u8, password.buffer) catch { return .buf_err; }, }; }, .prompt_echo_on, .error_msg, .text_info => { log.warn("ignoring PAM message: msg_style={s} msg='{s}'", .{ @tagName(message.msg_style), message.msg, }); }, } } return .success; }
0
repos/waylock
repos/waylock/src/Lock.zig
const Lock = @This(); const std = @import("std"); const builtin = @import("builtin"); const assert = std.debug.assert; const log = std.log; const mem = std.mem; const posix = std.posix; const wayland = @import("wayland"); const wl = wayland.client.wl; const wp = wayland.client.wp; const ext = wayland.client.ext; const xkb = @import("xkbcommon"); const auth = @import("auth.zig"); const Output = @import("Output.zig"); const Seat = @import("Seat.zig"); const PasswordBuffer = @import("PasswordBuffer.zig"); const gpa = std.heap.c_allocator; pub const Color = enum { init, input, fail, }; pub const Options = struct { fork_on_lock: bool, ready_fd: ?posix.fd_t = null, ignore_empty_password: bool, init_color: u24 = 0x002b36, input_color: u24 = 0x6c71c4, fail_color: u24 = 0xdc322f, fn rgb(options: Options, color: Color) u24 { return switch (color) { .init => options.init_color, .input => options.input_color, .fail => options.fail_color, }; } }; state: enum { /// The session lock object has not yet been created. initializing, /// The session lock object has been created but the locked event has not been received. locking, /// The compositor has sent the locked event indicating that the session is locked. locked, /// Gracefully exiting and cleaning up resources. This could happen because the compositor /// did not grant waylock's request to lock the screen or because the user or compositor /// has unlocked the session. exiting, } = .initializing, color: Color = .init, fork_on_lock: bool, ready_fd: ?posix.fd_t, ignore_empty_password: bool, pollfds: [2]posix.pollfd, display: *wl.Display, compositor: ?*wl.Compositor = null, session_lock_manager: ?*ext.SessionLockManagerV1 = null, session_lock: ?*ext.SessionLockV1 = null, viewporter: ?*wp.Viewporter = null, buffer_manager: ?*wp.SinglePixelBufferManagerV1 = null, buffers: [3]*wl.Buffer, seats: std.SinglyLinkedList(Seat) = .{}, outputs: std.SinglyLinkedList(Output) = .{}, xkb_context: *xkb.Context, password: PasswordBuffer, auth_connection: auth.Connection, pub fn run(options: Options) void { var lock: Lock = .{ .fork_on_lock = options.fork_on_lock, .ready_fd = options.ready_fd, .ignore_empty_password = options.ignore_empty_password, .pollfds = undefined, .display = wl.Display.connect(null) catch |err| { fatal("failed to connect to a wayland compositor: {s}", .{@errorName(err)}); }, .buffers = undefined, .xkb_context = xkb.Context.new(.no_flags) orelse fatal_oom(), .password = PasswordBuffer.init(), .auth_connection = auth.fork_child() catch |err| { fatal("failed to fork child authentication process: {s}", .{@errorName(err)}); }, }; defer lock.deinit(); const poll_wayland = 0; const poll_auth = 1; lock.pollfds[poll_wayland] = .{ .fd = lock.display.getFd(), .events = posix.POLL.IN, .revents = 0, }; lock.pollfds[poll_auth] = .{ .fd = lock.auth_connection.read_fd, .events = posix.POLL.IN, .revents = 0, }; const registry = lock.display.getRegistry() catch fatal_oom(); defer registry.destroy(); registry.setListener(*Lock, registry_listener, &lock); { const errno = lock.display.roundtrip(); if (errno != .SUCCESS) { fatal("initial roundtrip failed: {s}", .{@tagName(errno)}); } } if (lock.compositor == null) fatal_not_advertised(wl.Compositor); if (lock.session_lock_manager == null) fatal_not_advertised(ext.SessionLockManagerV1); if (lock.viewporter == null) fatal_not_advertised(wp.Viewporter); if (lock.buffer_manager == null) fatal_not_advertised(wp.SinglePixelBufferManagerV1); lock.buffers = create_buffers(lock.buffer_manager.?, options) catch fatal_oom(); lock.buffer_manager.?.destroy(); lock.buffer_manager = null; lock.session_lock = lock.session_lock_manager.?.lock() catch fatal_oom(); lock.session_lock.?.setListener(*Lock, session_lock_listener, &lock); lock.session_lock_manager.?.destroy(); lock.session_lock_manager = null; // From this point onwards we may no longer handle OOM by exiting. assert(lock.state == .initializing); lock.state = .locking; { var it = lock.outputs.first; while (it) |node| { // Do this up front in case the node gets removed. it = node.next; node.data.create_surface() catch { log.err("out of memory", .{}); // Removes the node from the list. node.data.destroy(); continue; }; } } while (lock.state != .exiting) { lock.flush_wayland_and_prepare_read(); _ = posix.poll(&lock.pollfds, -1) catch |err| { fatal("poll() failed: {s}", .{@errorName(err)}); }; if (lock.pollfds[poll_wayland].revents & posix.POLL.IN != 0) { const errno = lock.display.readEvents(); if (errno != .SUCCESS) { fatal("error reading wayland events: {s}", .{@tagName(errno)}); } } else { lock.display.cancelRead(); } if (lock.pollfds[poll_auth].revents & posix.POLL.IN != 0) { const byte = lock.auth_connection.reader().readByte() catch |err| { fatal("failed to read response from child authentication process: {s}", .{@errorName(err)}); }; switch (byte) { @intFromBool(true) => { lock.session_lock.?.unlockAndDestroy(); lock.session_lock = null; lock.state = .exiting; }, @intFromBool(false) => { lock.set_color(.fail); }, else => { fatal("unexpected response received from child authentication process: {d}", .{byte}); }, } } } // Calling flush_wayland_and_prepare_read() is not sufficient here as we // don't want to exit cleanly until the server processes our request to // unlock the session. The only way to guarantee this has occurred is // through a roundtrip using the wl_display.sync request. const errno = lock.display.roundtrip(); if (errno != .SUCCESS) { fatal("final roundtrip failed: E{s}", .{@tagName(errno)}); } } /// This function does the following: /// 1. Dispatch buffered wayland events to their listener callbacks. /// 2. Prepare the wayland connection for reading. /// 3. Send all buffered wayland requests to the server. /// After this function has been called, either wl.Display.readEvents() or /// wl.Display.cancelRead() read must be called. fn flush_wayland_and_prepare_read(lock: *Lock) void { while (!lock.display.prepareRead()) { const errno = lock.display.dispatchPending(); if (errno != .SUCCESS) { fatal("failed to dispatch pending wayland events: E{s}", .{@tagName(errno)}); } } while (true) { const errno = lock.display.flush(); switch (errno) { .SUCCESS => return, .PIPE => { // libwayland uses this error to indicate that the wayland server // closed its side of the wayland socket. We want to continue to // read any buffered messages from the server though as there is // likely a protocol error message we'd like libwayland to log. _ = lock.display.readEvents(); fatal("connection to wayland server unexpectedly terminated", .{}); }, .AGAIN => { // The socket buffer is full, so wait for it to become writable again. var wayland_out = [_]posix.pollfd{.{ .fd = lock.display.getFd(), .events = posix.POLL.OUT, .revents = 0, }}; _ = posix.poll(&wayland_out, -1) catch |err| { fatal("poll() failed: {s}", .{@errorName(err)}); }; // No need to check for POLLHUP/POLLERR here, just fall // through to the next flush() to handle them in one place. }, else => { fatal("failed to flush wayland requests: E{s}", .{@tagName(errno)}); }, } } } /// Clean up resources just so we can better use tooling such as valgrind to check for leaks. fn deinit(lock: *Lock) void { if (lock.compositor) |compositor| compositor.destroy(); if (lock.viewporter) |viewporter| viewporter.destroy(); for (lock.buffers) |buffer| buffer.destroy(); assert(lock.buffer_manager == null); assert(lock.session_lock_manager == null); assert(lock.session_lock == null); while (lock.seats.first) |node| node.data.destroy(); while (lock.outputs.first) |node| node.data.destroy(); lock.display.disconnect(); lock.xkb_context.unref(); // There may be further input after submitting a valid password. lock.password.clear(); lock.* = undefined; } fn registry_listener(registry: *wl.Registry, event: wl.Registry.Event, lock: *Lock) void { lock.registry_event(registry, event) catch |err| switch (err) { error.OutOfMemory => { log.err("out of memory", .{}); return; }, }; } fn registry_event(lock: *Lock, registry: *wl.Registry, event: wl.Registry.Event) !void { switch (event) { .global => |ev| { if (mem.orderZ(u8, ev.interface, wl.Compositor.getInterface().name) == .eq) { // Version 4 required for wl_surface.damage_buffer if (ev.version < 4) { fatal("advertised wl_compositor version too old, version 4 required", .{}); } lock.compositor = try registry.bind(ev.name, wl.Compositor, 4); } else if (mem.orderZ(u8, ev.interface, ext.SessionLockManagerV1.getInterface().name) == .eq) { lock.session_lock_manager = try registry.bind(ev.name, ext.SessionLockManagerV1, 1); } else if (mem.orderZ(u8, ev.interface, wl.Output.getInterface().name) == .eq) { // Version 3 required for wl_output.release if (ev.version < 3) { fatal("advertised wl_output version too old, version 3 required", .{}); } const wl_output = try registry.bind(ev.name, wl.Output, 3); errdefer wl_output.release(); const node = try gpa.create(std.SinglyLinkedList(Output).Node); errdefer node.data.destroy(); node.data = .{ .lock = lock, .name = ev.name, .wl_output = wl_output, }; lock.outputs.prepend(node); switch (lock.state) { .initializing, .exiting => {}, .locking, .locked => try node.data.create_surface(), } } else if (mem.orderZ(u8, ev.interface, wl.Seat.getInterface().name) == .eq) { // Version 5 required for wl_seat.release if (ev.version < 5) { fatal("advertised wl_seat version too old, version 5 required.", .{}); } const wl_seat = try registry.bind(ev.name, wl.Seat, 5); errdefer wl_seat.release(); const node = try gpa.create(std.SinglyLinkedList(Seat).Node); errdefer gpa.destroy(node); node.data.init(lock, ev.name, wl_seat); lock.seats.prepend(node); } else if (mem.orderZ(u8, ev.interface, wp.Viewporter.getInterface().name) == .eq) { lock.viewporter = try registry.bind(ev.name, wp.Viewporter, 1); } else if (mem.orderZ(u8, ev.interface, wp.SinglePixelBufferManagerV1.getInterface().name) == .eq) { lock.buffer_manager = try registry.bind(ev.name, wp.SinglePixelBufferManagerV1, 1); } }, .global_remove => |ev| { { var it = lock.outputs.first; while (it) |node| : (it = node.next) { if (node.data.name == ev.name) { node.data.destroy(); break; } } } { var it = lock.seats.first; while (it) |node| : (it = node.next) { if (node.data.name == ev.name) { node.data.destroy(); break; } } } }, } } fn session_lock_listener(_: *ext.SessionLockV1, event: ext.SessionLockV1.Event, lock: *Lock) void { switch (event) { .locked => { assert(lock.state == .locking); lock.state = .locked; if (lock.ready_fd) |ready_fd| { const file = std.fs.File{ .handle = ready_fd }; file.writeAll("\n") catch |err| { log.err("failed to send readiness notification: {s}", .{@errorName(err)}); posix.exit(1); }; file.close(); lock.ready_fd = null; } if (lock.fork_on_lock) { fork_to_background(); lock.password.protect_after_fork(); } }, .finished => { switch (lock.state) { .initializing => unreachable, .locking => { log.err("the wayland compositor has denied our attempt to lock the session, " ++ "is another ext-session-lock client already running?", .{}); posix.exit(1); }, .locked => { log.info("the wayland compositor has unlocked the session, exiting", .{}); posix.exit(0); }, .exiting => unreachable, } }, } } pub fn submit_password(lock: *Lock) void { assert(lock.state == .locked); if (lock.ignore_empty_password and lock.password.buffer.len == 0) { log.info("ignoring submission of empty password", .{}); return; } lock.send_password_to_auth() catch |err| { fatal("failed to send password to child authentication process: {s}", .{@errorName(err)}); }; } fn send_password_to_auth(lock: *Lock) !void { defer lock.password.clear(); const writer = lock.auth_connection.writer(); try writer.writeInt(u32, @as(u32, @intCast(lock.password.buffer.len)), builtin.cpu.arch.endian()); try writer.writeAll(lock.password.buffer); } pub fn set_color(lock: *Lock, color: Color) void { if (lock.color == color) return; lock.color = color; var it = lock.outputs.first; while (it) |node| : (it = node.next) { node.data.attach_buffer(lock.buffers[@intFromEnum(lock.color)]); } } fn fatal(comptime format: []const u8, args: anytype) noreturn { log.err(format, args); posix.exit(1); } fn fatal_oom() noreturn { fatal("out of memory during initialization", .{}); } fn fatal_not_advertised(comptime Global: type) noreturn { fatal("{s} not advertised", .{Global.getInterface().name}); } fn create_buffers( buffer_manager: *wp.SinglePixelBufferManagerV1, options: Options, ) error{OutOfMemory}![3]*wl.Buffer { var buffers: [3]*wl.Buffer = undefined; for ([_]Color{ .init, .input, .fail }) |color| { const rgb = options.rgb(color); buffers[@intFromEnum(color)] = try buffer_manager.createU32RgbaBuffer( @as(u32, (rgb >> 16) & 0xff) * (0xffff_ffff / 0xff), @as(u32, (rgb >> 8) & 0xff) * (0xffff_ffff / 0xff), @as(u32, (rgb >> 0) & 0xff) * (0xffff_ffff / 0xff), 0xffff_ffff, ); } return buffers; } // TODO: Upstream this to the Zig standard library extern fn setsid() posix.pid_t; fn fork_to_background() void { const pid = posix.fork() catch |err| fatal("fork failed: {s}", .{@errorName(err)}); if (pid == 0) { // This can't fail as we are the child of a fork() and therefore not // a process group leader. assert(setsid() != -1); // Ensure the working directory is on the root filesystem to avoid potentially // blocking some other filesystem from being unmounted. posix.chdirZ("/") catch |err| { // While this is a nice thing to do, it is not critical to the locking functionality // and it is better to allow potentially unlocking the session rather than aborting // and leaving the session locked if this fails. log.warn("failed to change working directory to / on fork: {s}", .{@errorName(err)}); }; } else { // Terminate the parent process with a clean exit code. posix.exit(0); } }
0
repos/waylock
repos/waylock/src/PasswordBuffer.zig
const PasswordBuffer = @This(); const std = @import("std"); const builtin = @import("builtin"); const assert = std.debug.assert; const log = std.log; const mem = std.mem; const posix = std.posix; const auth = @import("auth.zig"); const gpa = std.heap.c_allocator; pub const size_max = 1024; buffer: []align(mem.page_size) u8, pub fn init() PasswordBuffer { var password: PasswordBuffer = .{ .buffer = gpa.alignedAlloc(u8, mem.page_size, size_max) catch { log.err("failed to allocate password buffer", .{}); posix.exit(1); }, }; prevent_swapping(password.buffer); prevent_dumping_best_effort(password.buffer); password.buffer.len = 0; return password; } pub fn protect_after_fork(password: *PasswordBuffer) void { prevent_swapping(password.buffer); prevent_dumping_best_effort(password.buffer); } pub fn unused_slice(password: PasswordBuffer) []u8 { return password.buffer.ptr[password.buffer.len..size_max]; } pub fn grow(password: *PasswordBuffer, delta: usize) error{Overflow}!void { if (password.buffer.len + delta > size_max) { return error.Overflow; } password.buffer.len += delta; } pub fn pop_codepoint(password: *PasswordBuffer) void { if (password.buffer.len == 0) { return; } // Unicode codepoints may be encoded in 1-4 bytes. // Check for a 1 byte final codepoint, then a 2 byte, etc. for (1..@min(password.buffer.len, 4) + 1) |check_len| { const codepoint_bytes = password.buffer[password.buffer.len - check_len ..]; const actual_len = std.unicode.utf8ByteSequenceLength(codepoint_bytes[0]) catch continue; assert(check_len == actual_len); std.crypto.utils.secureZero(u8, codepoint_bytes); password.buffer.len -= actual_len; return; } // Only valid UTF-8 is written to the buffer. unreachable; } pub fn clear(password: *PasswordBuffer) void { std.crypto.utils.secureZero(u8, password.buffer); password.buffer.len = 0; } fn prevent_swapping(buffer: []align(mem.page_size) const u8) void { var attempts: usize = 0; while (attempts < 10) : (attempts += 1) { const errno = posix.errno(mlock(buffer.ptr, buffer.len)); switch (errno) { .SUCCESS => return, .AGAIN => continue, else => { log.err("mlock() on password buffer failed: E{s}", .{@tagName(errno)}); posix.exit(1); }, } } log.err("mlock() on password buffer failed: EAGAIN after 10 attempts", .{}); posix.exit(1); } fn prevent_dumping_best_effort(buffer: []align(mem.page_size) u8) void { if (builtin.target.os.tag != .linux) return; var attempts: usize = 0; while (attempts < 10) : (attempts += 1) { const errno = posix.errno(std.os.linux.madvise(buffer.ptr, buffer.len, posix.MADV.DONTDUMP)); switch (errno) { .SUCCESS => return, .AGAIN => continue, else => { log.warn("madvise() on password buffer failed: E{s}", .{@tagName(errno)}); return; }, } } log.warn("madvise() on password buffer failed: EAGAIN after 10 attempts", .{}); } // TODO: Upstream this to the Zig standard library extern fn mlock(addr: *const anyopaque, len: usize) c_int;
0
repos/waylock
repos/waylock/doc/waylock.1.scd
WAYLOCK(1) "https://codeberg.org/ifreund/waylock" "General Commands Manual" # NAME waylock - a small Wayland screenlocker # SYNOPSIS *waylock* [_options_] # DESCRIPTION Waylock is a small screenlocker for Wayland compositors implementing *ext-session-lock-v1*. The *ext-session-lock-v1* protocol is significantly more robust than previous client-side Wayland screen locking approaches. Importantly, the screenlocker crashing does not cause the session to be unlocked. # OPTIONS *-h* Print a help message and exit. *-version* Print the version number and exit. *-log-level* [*error*|*warning*|*info*|*debug*] Set the log level of waylock. At the *error* log level, only errors are logged. At the *debug* log level, everything is logged including verbose debug messages. *-fork-on-lock* Fork to the background after locking the session. This is useful to integrate with idle management daemons without racing to lock the session before suspend. With this option waylock will exit once the session has been locked and it is safe to suspend. *-ready-fd* _fd_ Write a newline to file descriptor _fd_ (a number) after locking and close the _fd_. This is useful if a fork-less lock notification is needed; for example, for integration with a service manager. *-ignore-empty-password* Do not submit empty passwords to PAM for validation when the Enter key is pressed. Instead, do nothing. This may be useful if, for example, the Enter key is used to wake the computer from sleep. *-init-color* _0xRRGGBB_ Set the initial color. (default: 0x002b36) *-input-color* _0xRRGGBB_ Set the color used after input. (default: 0x6c71c4) *-fail-color* _0xRRGGBB_ Set the color used on authentication failure. (default: 0xdc322f) # USAGE Run the waylock executable to lock the session. All monitors will be blanked with the *-init-color*. Typing causes the color to change to the *-input-color*. Esc or Ctrl-U clears all current input, while backspace deletes the last UTF-8 codepoint. To unlock the session, type your password and press Enter. If the password is correct, waylock will unlock the session and exit. Otherwise, the color will change to the *-fail-color* and you may try again. In order to automatically run waylock after a certain amount of time with no input or before sleep, the *swayidle*(1) utility or a similar program may be used. See the *swayidle*(1) man page for details. # AUTHORS Maintained by Isaac Freund <[email protected]> who is assisted by open source contributors. For more information about waylock's development, see https://codeberg.org/ifreund/waylock. # SEE ALSO *pam*(8), *swayidle*(1)
0
repos
repos/libyaml-zys/.appveyor.yml
version: 0.2.5.{build} image: - Visual Studio 2015 - Visual Studio 2013 build_script: # # CMake based in-source build and tests using Visual Studio # # Use 32-bit default generator ("Visual Studio 12 2013" or "Visual Studio 14 2015") - cmake . - cmake --build . --config Release --clean-first - ctest -C Release # # Autoconf based in-source build and tests under Cygwin using gcc # # 32-bit cygwin build - C:\cygwin\bin\sh -c "export PATH=/usr/bin:/usr/local/bin:$PATH && ./bootstrap && ./configure && make && make test && make distclean" # 64-bit cygwin build - C:\cygwin64\bin\sh -c "export PATH=/usr/bin:/usr/local/bin:$PATH && ./bootstrap && ./configure && make && make test && make distclean" # 32-bit mingw-w64 build - C:\cygwin\bin\sh -c "export PATH=/usr/bin:/usr/local/bin:$PATH && ./bootstrap && ./configure --host=i686-w64-mingw32 --target=i686-w64-mingw32 && make && make test && make distclean" # 64-bit mingw-w64 build - C:\cygwin64\bin\sh -c "export PATH=/usr/bin:/usr/local/bin:$PATH && ./bootstrap && ./configure --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 && make && make test && make distclean"
0
repos
repos/libyaml-zys/ReadMe.md
## LibYAML - A C library for parsing and emitting YAML. To build and install the library, run: $ ./configure $ make # make install Required packages: - gcc - libtool - make If you checked the source code from the Git repository, run $ ./bootstrap $ ./configure $ make # make install Required packages: - autoconf - libtool - make For more information, check the [LibYAML homepage](https://github.com/yaml/libyaml). Discuss LibYAML with the maintainers in IRC #libyaml irc.freenode.net. You may also use the [YAML-Core mailing list](http://lists.sourceforge.net/lists/listinfo/yaml-core). Submit bug reports and feature requests to the [LibYAML bug tracker](https://github.com/yaml/libyaml/issues/new). This project was developed for Python Software Foundation as a part of Google Summer of Code under the mentorship of Clark Evans. The LibYAML module was written by Kirill Simonov <[email protected]>. It is currently maintained by the YAML community. LibYAML is released under the MIT license. See the file LICENSE for more details.
0
repos
repos/libyaml-zys/yaml-0.1.pc.in
prefix=@prefix@ exec_prefix=@exec_prefix@ includedir=@includedir@ libdir=@libdir@ Name: LibYAML Description: Library to parse and emit YAML Version: @PACKAGE_VERSION@ Cflags: -I${includedir} Libs: -L${libdir} -lyaml
0
repos
repos/libyaml-zys/CMakeLists.txt
cmake_minimum_required(VERSION 3.0) project (yaml C) set (YAML_VERSION_MAJOR 0) set (YAML_VERSION_MINOR 2) set (YAML_VERSION_PATCH 5) set (YAML_VERSION_STRING "${YAML_VERSION_MAJOR}.${YAML_VERSION_MINOR}.${YAML_VERSION_PATCH}") option(BUILD_SHARED_LIBS "Build libyaml as a shared library" OFF) set(YAML_STATIC_LIB_NAME "yaml" CACHE STRING "Base name of static library output") # # Output directories for a build tree # if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) endif() # # Install relative directories # if(NOT DEFINED INSTALL_LIB_DIR) set(INSTALL_LIB_DIR lib) endif() if(NOT DEFINED INSTALL_BIN_DIR) set(INSTALL_BIN_DIR bin) endif() if(NOT DEFINED INSTALL_INCLUDE_DIR) set(INSTALL_INCLUDE_DIR include) endif() if(NOT DEFINED INSTALL_CMAKE_DIR) set(INSTALL_CMAKE_DIR cmake) endif() # # Build library # set(SRCS src/api.c src/dumper.c src/emitter.c src/loader.c src/parser.c src/reader.c src/scanner.c src/writer.c ) set(config_h ${CMAKE_CURRENT_BINARY_DIR}/include/config.h) configure_file( cmake/config.h.in ${config_h} ) add_library(yaml ${SRCS}) if(NOT BUILD_SHARED_LIBS) set_target_properties(yaml PROPERTIES OUTPUT_NAME ${YAML_STATIC_LIB_NAME} ) endif() set_target_properties(yaml PROPERTIES DEFINE_SYMBOL YAML_DECLARE_EXPORT ) target_compile_definitions(yaml PRIVATE HAVE_CONFIG_H PUBLIC $<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:YAML_DECLARE_STATIC> $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS> ) target_include_directories(yaml PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include> $<INSTALL_INTERFACE:${INSTALL_INCLUDE_DIR}> ) # # Install rules # install( FILES include/yaml.h DESTINATION include COMPONENT Development ) install( TARGETS yaml EXPORT yamlTargets RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT Runtime LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT Development ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT Development ) # # Add tests # include(CTest) # This module defines BUILD_TESTING option if(BUILD_TESTING) add_subdirectory(tests) endif() # # Generate 'yamlConfig.cmake', 'yamlConfigVersion.cmake' and 'yamlTargets.cmake' # include(CMakePackageConfigHelpers) # Configure 'yamlConfig.cmake' for a build tree set(CONFIG_DIR_CONFIG ${PROJECT_BINARY_DIR}) set(config_file ${PROJECT_BINARY_DIR}/yamlConfig.cmake) configure_package_config_file( yamlConfig.cmake.in ${config_file} INSTALL_DESTINATION ${PROJECT_BINARY_DIR} PATH_VARS CONFIG_DIR_CONFIG NO_CHECK_REQUIRED_COMPONENTS_MACRO ) # Configure 'yamlTargets.cmake' for a build tree export(TARGETS yaml FILE ${PROJECT_BINARY_DIR}/yamlTargets.cmake ) # Configure and install 'yamlConfig.cmake' for an install tree set(CONFIG_DIR_CONFIG ${INSTALL_CMAKE_DIR}) set(install_config_file ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/yamlConfig.cmake ) configure_package_config_file( yamlConfig.cmake.in ${install_config_file} INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/${INSTALL_CMAKE_DIR} PATH_VARS CONFIG_DIR_CONFIG NO_CHECK_REQUIRED_COMPONENTS_MACRO ) install( FILES ${install_config_file} DESTINATION ${INSTALL_CMAKE_DIR} COMPONENT Development ) # Configure and install 'yamlTargets.cmake' for an install tree install(EXPORT yamlTargets FILE yamlTargets.cmake DESTINATION ${INSTALL_CMAKE_DIR} COMPONENT Development ) # Configure 'yamlConfigVersion.cmake' for a build tree set(config_version_file ${PROJECT_BINARY_DIR}/yamlConfigVersion.cmake) write_basic_package_version_file( ${config_version_file} VERSION ${YAML_VERSION_STRING} COMPATIBILITY AnyNewerVersion ) # ... and install for an install tree install( FILES ${config_version_file} DESTINATION ${INSTALL_CMAKE_DIR} COMPONENT Development )
0
repos
repos/libyaml-zys/build.zig.zon
.{ .name = "libyaml-zys", .version = "0.2.5", .minimum_zig_version = "0.13.0", .dependencies = .{ .statically = .{ .url = "https://github.com/zigify/statically/archive/4e054dca69b4eb974d8b0369a06de23878274f26.tar.gz", .hash = "1220d15497d26bea869a45ecf86e696d236b6fbcb3366aadcf934bb4b03c8c8b6263", }, }, .paths = .{ "README", "COPYING", "build.zig", "build.zig.zon", "src", "include", }, }
0
repos
repos/libyaml-zys/build.zig
const std = @import("std"); const statically = @import("statically"); const src = &.{ "src/api.c", "src/dumper.c", "src/emitter.c", "src/loader.c", "src/parser.c", "src/reader.c", "src/scanner.c", "src/writer.c", }; pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); _ = statically.option(b); statically.log("libyaml"); const options = .{ .name = "yaml", .target = target, .optimize = optimize, .link_libc = true, }; const lib = statically.library(b, options, options); const c_flags = &.{ "-DYAML_VERSION_MAJOR=0", "-DYAML_VERSION_MINOR=2", "-DYAML_VERSION_PATCH=5", "-DYAML_VERSION_STRING=\"0.2.5-zigify\"", }; lib.addCSourceFiles(.{ .files = src, .flags = c_flags }); lib.addIncludePath(b.path("src")); lib.addIncludePath(b.path("include")); lib.installHeader(b.path("include/yaml.h"), "yaml.h"); b.installArtifact(lib); }
0
repos
repos/libyaml-zys/flake.nix
{ description = "Zig Library for making static compilation simpler with C dependencies "; inputs = { nixpkgs.url = "github:nixos/nixpkgs/release-24.05"; flake-utils.url = "github:numtide/flake-utils"; zig.url = "github:mitchellh/zig-overlay"; zls.url = "github:zigtools/zls/0.13.0"; }; outputs = inputs@{ self, nixpkgs, flake-utils, ... }: let overlays = [ (final: prev: rec { zigpkgs = inputs.zig.packages.${prev.system}; zig = zigpkgs."0.13.0"; zls = inputs.zls.packages.${prev.system}.zls.overrideAttrs (old: { nativeBuildInputs = [ zig ]; }); }) ]; systems = builtins.attrNames inputs.zig.packages; in flake-utils.lib.eachSystem systems (system: let pkgs = import nixpkgs { inherit overlays system; }; in { devShells.default = pkgs.mkShell { nativeBuildInputs = with pkgs; [ zig zls ]; }; devShell = self.devShells.${system}.default; }); }