ReferenceError");
});
});
});
}());
================================================
FILE: src/_user_code_test.js
================================================
// Copyright (c) 2013 Titanium I.T. LLC. All rights reserved. See LICENSE.TXT for details.
(function() {
"use strict";
describe("user code", function() {
var evaluate;
var samples;
beforeEach(function() {
evaluate = jdls.usercode.evaluate;
samples = jdls.usercode.samples;
});
it("evaluates to an object", function() {
var code = "" +
"this.foo = {" +
" a: 1," +
" b: 2" +
"}";
expect(evaluate(code)).to.eql({
foo: {
a: 1,
b: 2
}
});
});
describe("samples", function() {
function check(sample) {
try {
evaluate(sample.code);
}
catch (ex) {
console.log("Warning: '" + sample.name + "' sample doesn't compile");
// ES6 samples don't work on all browsers, so following line is commented out to
// prevent test failure
// throw ex;
}
}
it("all compile", function() {
/*jshint forin:false */
for (var sampleName in samples) {
var sample = samples[sampleName];
check(sample);
}
});
});
});
}());
================================================
FILE: src/_viz_visualizer_test.js
================================================
// Copyright (c) 2013 Titanium I.T. LLC. All rights reserved. See LICENSE.TXT for details.
(function() {
"use strict";
describe("Viz.js Visualizer", function() {
var graph;
var details;
beforeEach(function() {
var object = {
a: {
b: "b"
}
};
graph = new jdls.ObjectGraph("name", object);
details = jdls.viz.details;
});
it("escapes HTML strings", function() {
var esc = details.escapeHtml;
expect(esc("&&")).to.equal("&&");
expect(esc("<<>>")).to.equal("<<>>");
expect(esc('""')).to.equal("""");
expect(esc("''")).to.equal("''");
expect(esc("\n\n")).to.equal("
");
expect(esc("\t\t")).to.equal(" ");
});
it("converts nodes (with alternating property colors)", function() {
var node = new jdls.ObjectNode("name", { a: 1, b: 2, c: 3 });
expect(details.nodeToViz(node)).to.equal(
' "' + node.id() + '" [label=<\n' +
' | name | \n' + '
| a: 1 |
| b: 2 |
| c: 3 |
| Object.prototype |
If you hang around the JavaScript world long enough, you’ll come across a bunch of different recipes for object-oriented programming. The standard way, so much as there can be a standard way, is this.
And this is the recipe for inheritance.
That’s the standard. But why this? Why this… mess? And why does it work?
Hi, everyone. My name is James Shore and this is Let’s Code: Test-Driven JavaScript. I’m here with my Lessons Learned on object-oriented programming in JavaScript. I’m recording this on June 1st, 2013.
In today’s episode, we’re going to build up these recipes from first principles. We’ll start with a review of object fundamentals, then look at how functions work in JavaScript. Next, we’ll cover prototypes and inheritance, then polymorphism and method overriding. We’ll discuss classes and instantiation in the prototypal model, then see how these concepts map to the classical model most people use. Finally, we’ll delve into the inner workings of the instanceof keyword, before closing with a look at future directions, a tool for exploring these concepts further, and my recommendations.
This is a big topic and we’re going to cover a lot of ground. Be sure to take advantage of the pause and rewind buttons in your video player. You can use the timestamps here to jump to sections of interest.
Let’s start with the basics. These are the common JavaScript types—these are everything you can actually type into your source code. However, most of these are not actually primitive types. The only things that are really primitives are strings, numbers, and booleans; a couple of ways of saying “can’t find it,” and objects. Everything else—functions, arrays, and regular expressions, as well as all the other objects you use in your program—those are all variant kinds of objects.
So, what is an object? Well, it is a set of name/value pairs. In other languages, you might call it a dictionary, or a hash, or maybe an associative array, but fundamentally, it’s key/value pairs. You can use any number of keys with any name, as long as it’s a string, and each string can be associated with any value. Those values can be of any type: any of our basic primitive types, as well as any object type, including functions, and of course, objects themselves.
An important thing to note about objects is that, although primitives are passed by value, objects are passed by reference. Let’s see what that means.
So if we have two variables, named number1 and number2, and we assign a value to number1—let’s say 3.14 etcetera—and then we copy that variable into number2, those two values are not connected. So if we change number2, number1 is unaffected.
Objects, on the other hand, are stored by reference. What that means is that if you assign an object to one of these variables and then we copy that object into a new variable, we’re not copying the object. There’s still only one object. What we’re doing is copying the reference. The pointer. The arrow. So if we change object2, object1 gets changed as well. object2.a is 42, but also, object1.a is 42.
One last thing before we’re done with the basics.
If you ask for a property that isn’t found in an object, you’ll get undefined as your result back. Now, you can assign undefined to any property you want. That doesn’t actually delete the property. If for some reason you want to get the property out of the object entirely, you have to use the delete keyword. Now honestly, in practice, the distinction is usually not that important.
I mentioned earlier that functions are just regular kinds of objects, and that’s true. When you define a function, JavaScript creates an object for you that has three properties already defined: the name, which is the name of the function; the length, which is the number of arguments; and a prototype, which I’ll explain later.
Because functions are just regular objects, you can do everything with them that you can do with a normal object. You can assign properties to them; you can assign them to different variables; and when you do, they’re passed by reference, so you can run that function from its new location by just saying the variable name and parentheses.
When you put a function inside of an object, it’s typically called a “method.” You can run methods just like you run any other function by saying object.methodname and then parentheses.
When you do that, JavaScript will set the this keyword to the object that you used. So if you say myObject.get(), this will be set to myObject. Then when the function returns, this will be set back to whatever value it had before.
The this keyword is JavaScript’s biggest gotcha. It depends on the object, not where the function was defined, and this can cause a lot of problems.
So, if we have myMethod which returns this.val, and we call object1.get(), we’ll get a 42 back. If we call object2.get(), this will be set to object2 and we’ll get 3.14159 back. If we just call myMethod() directly, this won’t be set to anything in particular. It could be undefined if we’re using strict mode; it could be the global object; it’s really hard to tell for sure.
So you have to be really careful when you’re using this. If possible, I really recommend that use strict mode whenever you can because that will force this to be undefined. It won’t prevent mistakes relating to this, but it will help you catch them more quickly.
If you have a case where you need this to be a particular value, you can force it by using either call(), apply(), or bind(). Now the details of those functions are outside the scope of this episode, but let me show you an example of one of them.
If we say myMethod.call(), then that will run the myMethod function and force the this value to whatever we said. So myMethod.call(object1) will set this to object1.
Okay, that’s the basics. Let’s get into some of the more complicated stuff.
It’s pretty rare that you’re going to be defining all of your object from scratch. You’ll typically have some sort of repeated pattern. For example, in this case, object1, object2, and object3 are all using the same function. And rather than define them all separately like that, which would be a maintenance nightmare in the long run, what you can do is use something called “prototypes.”
The way this works is that you can define a single object, and then have other objects inherit from it, or “extend” it. The way you do that is by calling Object.create().
So if I have a parent object with a function and a value, I can create a new object (which I’ve called child) by saying Object.create(child). You can do anything with this child object that you do with any other object. You can add values to it or even extend it with another child.
Now the cool part is what happens when we start to use these objects.
The base object is just like before. Let’s say we say parent.get(). Well, this is going to be set to parent, and then JavaScript will look for get on that object. And when it finds it, it’ll call the function, which will say return this.val, which will cause JavaScript to look for val on parent. So that’s pretty normal.
But here’s the cool part. If we call child.get(), then this is set to child. JavaScript will look for get on child, but it won’t find it. So it will look at the prototype—it will go up the prototype chain—and look at parent, and it will find get there. When it finds that function, it will try to return this.val, which means it will go back to child, look for val, and find it. So child.get() will return 3.14 rather than 42, even though it’s using the function that was defined in parent.
JavaScript will go as far up the prototype chain as it needs to go in order to find a property. So if we said grandchild.get(), then JavaScript will look for get on the grandchild. It won’t find it, so it will go up to the prototype and look for get on child. It won’t find it there, so it will go to parent, look for get there, and find it. It will call the function, try to return this.val, so again it will go back to grandchild, look for val. It won’t find it, so it will go up to child, look for val, find it there, and return 3.14159.
This is the fundamentals of inheritance in JavaScript. Now, if you’ve seen other ways of talking about objects in JavaScript, they might have focused on classes or something else first. But this right here—this prototype-based inheritance—is fundamentally how JavaScript works. Actually, JavaScript doesn’t have any other form of inheritance other than this prototypal inheritance I’m showing you here.
There’s one more wrinkle I want to share, and that is that every single object has a prototype, except for the base object, and any objects you create yourself to explicitly not have prototypes. Here’s what they look like.
By default, objects that you create have Object.prototype as their prototype, and functions have Function.prototype as their prototype. Notice that this is where those call(), apply(), and bind() methods I was talking about earlier come from.
Now, this is way too much detail to show in most of these visualizations, so what I’m going to do is just use [[Object]] and [[Function]] to refer to those prototypes from here on out.
Once you have objects in a prototype chain, you might find that you want children to behave differently from their parent, even when the same method name is called. This is called “polymorphism.” Polymorphism means, “the same name, but different behaviors.” Now, technically, you can have polymorphism without inheritance, but we’re not going to get into that right now.
It’s easy to do polymorphism in JavaScript; you just use the same property name, but assign a different method. So if we wanted to have a firmAnswer object that answered something differently—or answered in a different way—we’d just say firmAnswer.get and assign the function. In this case, what we’re going to do is we’re going to return the same value and return “!!” at the end.
So if we say answer.get(), that will give us “42” back, but if we say firmAnswer.get(), that will say “42!!” back. Anyway, you get the idea.
This relationship is actually a little easier to see if we don’t have the function visualizations in there, so I’m going to stop showing them for now.
Now you’ll notice here that our fn2 is looking at this.val and our fn1 is looking at this.val. That’s a bit of duplicated logic. It’s not too bad here, but in more complicated programs, you find that that sort of logic is very difficult to maintain. So typically, what we’re going to want to do, is call fn1 from fn2.
Unfortunately, that’s not quite as easy as it might seem. The obvious answer is to just call fn1… to just say answer.get(). That doesn’t work. It returns the wrong answer. It’s going to return 42. Do you know why? If you don’t, pause the video for a moment and see if you can figure it out.
Okay, here’s why.
When we call firmAnswer.get(), this is set to firmAnswer and JavaScript looks for the get property. It finds it and it runs fn2. That runs answer.get(), which is going to set this to answer, and then look for the get property on answer. When it finds it, it will run fn1 and try to return this.val. But because this is set to answer, when it looks for this.val, it will find it on the answer object and return 42 rather than 3.14159, which is what we expect.
So, in order for this to work properly, we need to use the call function. We need to say answer.get.call(this). See if you can figure out why this would work.
Okay, here’s how it works.
When we call firmAnswer.get(), this is set to firmAnswer… it looks for get… finds it… runs fn2… and now it says answer.get.call(this). That sets this to, well, the same this again. But then it runs answer.get() directly, which tries to return this.val, which looks for val on firmAnswer, finds it, and returns the correct answer.
You can organize your JavaScript objects any way you like, but a really common way of organizing it is to separate your methods from your data.
For example, we have this answer object which, when you ask it to get the value, returns the value that it has stored.
Well, it’s pretty typical to want to have multiple copies of this object, so typically what people will do is they will put the function in a prototype—which we’ll call AnswerPrototype—and then they’ll have multiple objects extend that prototype to give us special values.
So we see here that lifeAnswer has the value of 42, because it’s the answer to Life, the Universe, and Everything, and dessertAnswer has the value of pi, for, well, obvious reasons.
If you want to specialize that answer, as we did with firmAnswer before, you can do the same thing. We have our FirmAnswerPrototype add its fn2—the one that puts “!!” on the end—that extends AnswerPrototype. And then we have our luckyAnswer and magicAnswer extend that.
When you use this approach to organize your objects, the prototypes are typically called “classes,” and the objects—the objects that extend them—are typically called “instances.” A class that extends another class is called a “subclass.”
Creating an instance is called “instantiation,” and you’ll notice that there’s a two-step process for that. First, you create the object by extending the prototype, and then second, you initialize its data. (Remember, instances are usually about the data and the prototypes are about the methods—the classes are about the methods.) So we extend and then we initialize.
The problem with this is that this initialization logic is duplicated every time we create a new object. In this simple example, it’s not such as big deal, but in real programs, the initialization logic is usually pretty complicated. So we don’t want to duplicate it everywhere. That would be a big maintenance problem.
It also violates encapsulation. One of the nice things about object-oriented programming is that it allows you to decide how your data is going to be stored in a way that nobody else has to worry about. You just provide access to that data through your methods and then, if you want to change the way data is stored, then you just do it. You update your methods—your object’s methods—but you don’t have to update all the rest of the program.
But here, because all our instances are accessing val directly, we can’t change the way val is stored without having to change all of our instances.
So what’s really common is to use some sort of initialization function. In this case, I’m going to call it constructor(). This is a common method that is used to initialize your objects.
Here’s how this works. Let’s say that we want to create a new instance for magicAnswer. We’ll extend FirmAnswerPrototype and then we’ll say magicAnswer.constructor(3). That will set this to magicAnswer and it will look for the constructor property. It won’t find it on magicAnswer, so it will look at the prototype. It won’t find it there, so it will look at the prototype of FirmAnswerPrototype. It will find constructor there and then run fn0(value). fn0 is going to set this._val to value. So it goes to this, sets the value, and there we go.
Note that I’ve changed _val to have an underscore in front. This is a common convention in JavaScript to say that a property is private. In other words, you shouldn’t access or change this property. Now, nothing in JavaScript is going to enforce that it doesn’t get changed, but that’s the polite thing to do. And if you follow that rule, that means we can change AnswerPrototype without breaking any of the rest of our code: without changing the way FirmAnswerPrototype has to be programmed or any of our instances.
So that is a complete view of prototypal inheritance in JavaScript. It is a little bit different than what I showed you at the beginning, though, so we’re not quite done yet. But you could do all object-oriented programming in JavaScript using this model.
Now, let’s look at the classical model. This is going to build on everything we’ve done up until now.
To start with, remember how, in the prototypal model, we instantiate an object by creating the object and then running a constructor of some sort? That’s so common that JavaScript has a special keyword just for that. It’s called new.
However, new is a little bit, well, weird. It doesn’t work the way we’ve seen up until now, and that’s what makes the classical model I’m about to show you different from the prototypal model I’ve been showing you up until now.
Now, before we get into that, I have to show something a little bit strange about functions. Remember that prototype property I said I’d explain later? Well, I’m going to explain it now. And it is… it’s weird.
When you define a function, JavaScript creates an object with name, length, and prototype properties. That prototype property actually points to a whole ’nother new object with a constructor property that points back to the function you’ve just created. So whenever you create a function in JavaScript, you’re actually creating two objects: the function object, and then this prototype object that’s just hanging out there.
I told you it was weird.
Now look at this closely. Does this look familiar?
Yeah. It’s a prototype. It is, basically, a class. So every time you define a function in JavaScript, you’re actually defining a constructor that’s associated with a little do-nothing class.
Now, of course, not every function you define is meant to be a constructor. So the common convention in JavaScript is that, if it’s meant to be a constructor, it starts with a capital letter, and if it’s meant to be just a normal function, then you start it with a lower-case letter.
Okay, so that’s a little weirdness of functions. Let’s see how this plays out to create the classical model.
First, let’s go back to our prototypal model. We’ll walk through it step by step.
So what we’re going to do is we’re going to create a class called AnswerPrototype. We’re going to create a constructor in it. And when we create that constructor, JavaScript is going to define a function object and a prototype object (which we don’t care about; we’re just going to ignore it). We’re also going to create a get function on our AnswerPrototype and we’re going to create a couple of instances: lifeAnswer and dessertAnswer.
So that’s a basic example using the prototypal model. Now let’s do the exact same thing, but this time using the classical model and the new keyword.
In the classical model, we define the constructor first. So we’ll create this Answer function. JavaScript will automatically create an object to go along with it with a constructor property that points back to our Answer function. That prototype is our class. It’s going to fulfill the exact same purpose that AnswerPrototype fills in the top example. So we’ll set our get method on AnswerPrototype. Then we can instantiate it by calling new Answer(). We’ll say new Answer(42) and that gives us the right value. That’s going to create a child of Answer.prototype and initialize it by calling the Answer constructor with the value of 42.
The way it knows to create lifeAnswer with Answer.prototype as its prototype is because JavaScript looks at the prototype property of the constructor when you use the new keyword.
The same thing happens with dessertAnswer.
That’s the classical model.
Now, it gets a little more complicated when we start dealing with subclasses. So let’s take a look at how this would work with a subclass. Let’s add the FirmAnswer class that we looked at in our previous prototypal example.
Again, we’ll start out by creating a FirmAnswer constructor first. JavaScript will automatically create the FirmAnswer.prototype, but this one we can’t use because we need our FirmAnswer.prototype to extend Answer.prototype—and it doesn’t. So what we’ll do is, we’ll set FirmAnswer.prototype to a new object that we’ll create by extending Answer.prototype. That will cause the old FirmAnswer.prototype to have nothing pointing to it, so it will get collected by the garbage collector.
Next, we’ll set the constructor property to point back to FirmAnswer. Now, as far as I can tell, this constructor property is not necessary. Everything that’s built into JavaScript will work just fine without it. But we’re going to set it here to be consistent. You could probably get away with not using it, but I have to admit, I haven’t been brave enough to try that, so remove it at your own risk.
All right, so we have FirmAnswer.prototype with a constructor. Now we need to set our get method on it. Then we can instantiate it as normal. we’ll say new FirmAnswer(7). That will create our luckyAnswer extending FirmAnswer.prototype and we can do the same thing with magicAnswer.
Here’s a side-by-side comparison of the two models. I’ve numbered each of the sections so they correspond. So number one in the prototypal model is doing the exact same thing as in the classical model. Go ahead and pause the video here if you’d like to study this further.
There’s one more detail I’d like to share with you.
It’s often convenient to know which class was used to instantiate an object. To achieve that purpose, JavaScript has a keyword: instanceof. The way this works is it looks at the prototype of the constructor and compares it to the object. This is actually a little hard to understand unless you see it, so let me just show it to you.
We can ask if lifeAnswer is an instance of Answer. And intuitively, we know that’s true. But how does JavaScript know? Well, here’s what happens:
First, it looks at Answer.prototype. Not Answer’s prototype, but Answer’s prototype property. Then it looks at lifeAnswer’s actual prototype. And if those two things are the same object then, yes, it’s an instance.
So lifeAnswer wouldn’t be an instance of FirmAnswer. FirmAnswer.prototype is over here. lifeAnswer’s actual prototype is up here. They don’t match, so it’s not an instanceof.
However, there is one caveat to this—one exception to the rule. luckyAnswer is an instance of Answer because JavaScript will go up the prototype chain. So JavaScript will look at Answer.prototype. Then it will look at luckyAnswer’s prototype. That’s not a match, but it will go up the prototype chain and look at Answer.prototype as well. That is a match, so luckyAnswer is an instance of Answer.
That’s everything you need to know in order to understand how inheritance works in JavaScript. I do want to share a few more things with you, though.
First, in the upcoming version of JavaScript, as defined in the EcmaScript 6 specification, there’s going to be a new syntax which makes it easier to do the classical model of inheritance in JavaScript. It’s the class syntax, and I’ve got it shown here on the left.
Now, as far as I can tell in my research, that yields the exact same underlying object model that classical inheritance does, as I’ve shown here on the right. But it’s going to be much easier to work with.
If you want to see how that compares to the classical model, I have a side-by-side comparison here. Go ahead and pause the video if you want to study this in depth.
I’ve called this episode “The Definitive Guide to Object-Oriented JavaScript,” which was perhaps a little presumptuous of me. It isn’t possible for single tutorial, no matter how long—and I didn’t really want it to be that long—anyway, it’s not possible for a single tutorial to cover absolutely everything there is to know about JavaScript. There’s some stuff I’ve intentionally left out, such as getters and setters, static variables, much more… the details of bind and apply, for example…
What makes this the definitive guide is the website I’ve created to accompany this video. This site is an object visualizer. So what you can do is type in JavaScript and it will analyze what you type and display the object map on the screen. So if we wanted to see what a function did, we could just add it here. We could “Show all functions” and see how that function is turned into objects.
This is a very cool tool. It’s a lot of fun; it’s got a lot of default examples for you to play with. Check it out. This is the best way to really understand how inheritance works in JavaScript and how objects work in JavaScript. Test your understanding by typing in some code here, clicking the evaluate button, and see what comes out. Play with your own ways of making inheritance structures; try your own abstractions; try other people’s abstractions. (I’ve got John Resig’s in here, for example, but you can do much, much more.)
Anyway, this is the real definitive resource because it actually runs in your real browser. So it will tell you whatever your browser—it will tell you the JavaScript model used by your actual browser. Check it out.
To close, here are my recommendations for object-oriented JavaScript in your programs.
First, use the classical model. I know it’s not very popular, and it’s kind of weird, but it is the standard. Everybody understands it. If you use the classical model, anybody who has the slightest familiarity with object-oriented JavaScript will understand this approach. That can’t be said about any other approach you use.
It also is the one that’s most likely to have good IDE support if you want to do some sort of automatic syntax checking or refactoring in your IDE, and it’s also the only approach that supports instanceof. You can hack in support for instanceof into the prototypal model, but it’s not very convenient and actually ends up being uglier than the classical model.
Second, "use strict";. Use the strict mode. It will help prevent situations where this isn’t defined properly.
Third, use JSHint or some other linter. It will help you catch cases where you forgot to use new or you used it in the wrong spot, as long as you use the convention where a class name starts with a capital letter.
Fourth, when the EcmaScript 6 class syntax becomes available, go ahead and use it. It might be a while: at the time I record this, it’s not available in any of the popular browsers, and that means it’s going to be a long time before it’s available in IE. But when it is available, go ahead and use it. It’s a nice, elegant syntax. It maps down to the regular classical model, which means it’ll play nice with all your existing stuff.
And finally, experiment with Object Playground. I created that site specifically to be a way to learn more about object-oriented JavaScript. You’d be surprised what you can find out about it. For example, go ahead and see whether or not you need that constructor property. What happens when you take it out? Can you find any case where it’s needed, or any case where it’s not needed?
So that’s what I’ve learned about object-oriented programming in JavaScript. Thanks for watching, everybody, and I’ll catch you next time!
" + string.replace(//g, ">").replace(/\"/g, """) + ""; } function failFastIfSampleNameMustBeEscaped(name) { if (contains(["<", ">", '"', "&"])) throw new Error("Sample name [" + name + "] includes text that must be HTML-escaped; that's not implemented yet."); function contains(forbiddenChars) { return forbiddenChars.some(function(char) { return name.indexOf(char) !== -1; }); } } }()); ================================================ FILE: src/user_code.js ================================================ // Copyright (c) 2013 Titanium I.T. LLC. All rights reserved. See LICENSE.TXT for details. window.jdls = window.jdls || {}; // Functions related to user-entered code. (function() { "use strict"; var exports = window.jdls.usercode = {}; var samples = exports.samples = {}; exports.evaluate = function evaluate(code) { /*jshint evil:true, newcap: false */ var context = {}; Function(code).call(context); return context; }; samples.instructions = { name: "Instructions", code: '// Enter JavaScript code in this box and then click the "Evaluate" button.\n' + '// Any variable you assign to "this" will be graphed below.\n' + '// Try the presets above for more examples!\n' + '\n' + '// Example:\n' + 'this.a = undefined;\n' + 'this.b = null;\n' + 'this.c = true;\n' + 'this.d = "foo";\n' + 'this.e = 3.14159;\n' + 'this.f = function bar() {};\n' + 'this.g = { h: "baz" };\n' }; samples.es5class = { name: "ES5 Class", code: '// Constructor\n' + 'function MyClass() {\n' + ' this.a = 42;\n' + '}\n' + '\n' + '// Method\n' + 'MyClass.prototype.method = function method() {};\n' + '\n' + '// Instantiate\n' + 'this.instance = new MyClass();\n' }; samples.es6class = { name: "ES6 Class", code: '// This example only works on browsers that support ES6 classes\n' + '\n' + '// Class\n' + 'class MyClass {\n' + '\n' + ' // Constructor\n' + ' constructor() {\n' + ' this.a = 42;\n' + ' }\n' + '\n' + ' // Method\n' + ' method() {}\n' + '\n' + '}\n' + '\n' + '// Instantiate\n' + 'this.instance = new MyClass();\n' }; samples.es5inheritance = { name: "ES5 Inheritance", code: '// Parent class constructor\n' + 'function Parent() {\n' + ' this.a = 42;\n' + '}\n' + '\n' + '// Parent class method\n' + 'Parent.prototype.method = function method() {};\n' + '\n' + '// Child class constructor\n' + 'function Child() {\n' + ' Parent.call(this);\n' + ' this.b = 3.14159\n' + '}\n' + '\n' + '// Inherit from the parent class\n' + 'Child.prototype = Object.create(Parent.prototype);\n' + 'Child.prototype.constructor = Child;\n' + '\n' + '// Child class method\n' + 'Child.prototype.method = function method() {\n' + ' Parent.prototype.method.call(this);\n' + '};\n' + '\n' + '// Instantiate\n' + 'this.instance = new Child();\n' }; samples.es6inheritance = { name: "ES6 Inheritance", code: '// This example only works on browsers that support ES6 classes\n' + '\n' + '// Parent class\n' + 'class Parent {\n' + '\n' + ' // Parent class constructor\n' + ' constructor() {\n' + ' this.a = 42;\n' + ' }\n' + '\n' + ' // Parent class method\n' + ' method() {}\n' + '\n' + '}\n' + '\n' + '// Child class inherits from Parent\n' + 'class Child extends Parent {\n' + '\n' + ' // Child class constructor\n' + ' constructor() {\n' + ' super();\n' + ' this.b = 3.14159;\n' + ' }\n' + '\n' + ' // Child class method\n' + ' method() {\n' + ' super.method();\n' + ' }\n' + '\n' + '}\n' + '\n' + '// Instantiate\n' + 'this.instance = new Child();\n' }; samples.inception = { name: "Inception!", code: 'this.jdls = jdls;\n' + '\n' + '// Can you figure out what the following line does?\n' + '// Caution: It\'s commented out because some people have\n' + '// reported their browser crashes when this line runs. D\'oh!\n' + '\n' + '// this.inception = new jdls.ObjectGraph("root", jdls);\n' }; exports.DEFAULT_SAMPLE = samples.instructions; }()); ================================================ FILE: src/viz/.gitattributes ================================================ viz.js -diff ================================================ FILE: src/viz/.gitignore ================================================ graphviz-src.tar.gz graphviz-src libexpat-src libexpat-src.tar.gz ================================================ FILE: src/viz/COPYING ================================================ * The original parts of this project (including files used in compiling the viz.js file) are made available under the following terms: Copyright (c) 2012 Michael Daines 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. * Graphviz is distributed under the Eclipse Public License: AT&T has previously made versions of this software available under the AT&T Source Code Agreement, version 1.2D and earlier. If you received a copy of the software under that license agreement, you may continue to use and distribute the same version of the software subject to the terms and conditions of the license agreement under which the software was received. However, current versions of the software are now licensed on an open source basis only under The Eclipse Public License (EPL). For more information on the Eclipse Public License, see the FAQ. If you have any concerns about the what the license means, especially if money is involved, you should contact an intellectual property lawyer. Eclipse Public License - v 1.0 THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 1. DEFINITIONS "Contribution" means: a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and b) in the case of each subsequent Contributor: i) changes to the Program, and ii) additions to the Program; where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. "Contributor" means any person or entity that distributes the Program. "Licensed Patents" mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. "Program" means the Contributions distributed in accordance with this Agreement. "Recipient" means anyone who receives the Program under this Agreement, including all Contributors. 2. GRANT OF RIGHTS a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form. b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program. d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. 3. REQUIREMENTS A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: a) it complies with the terms and conditions of this Agreement; and b) its license agreement: i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. When the Program is made available in source code form: a) it must be made available under this Agreement; and b) a copy of this Agreement must be included with each copy of the Program. Contributors may not remove or alter any copyright notices contained within the Program. Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. 4. COMMERCIAL DISTRIBUTION Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. 5. NO WARRANTY EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. 6. DISCLAIMER OF LIABILITY EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 7. GENERAL If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. * This project, including the Makefile, uses work by Satoshi Ueyama, made available under the following terms: -> Liviz.js (JSViz) <- Interactive GraphViz on DHTML -- MIT License Copyright (c) 2011-2012 Satoshi Ueyama 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. ================================================ FILE: src/viz/Makefile ================================================ # To compile, emcc must be in your path or EMSCRIPTEN_ROOT must be set. EMCC:=$(shell if command -v emcc > /dev/null; then echo "emcc"; else echo "$(EMSCRIPTEN_ROOT)/emcc"; fi) SRCDIR=graphviz-src EPSRCDIR=libexpat-src viz.js: $(SRCDIR) $(EPSRCDIR) viz.c $(EPSRCDIR)/lib/lib-em.bc $(SRCDIR)/lib/cdt/libcdt-em.bc $(SRCDIR)/lib/common/libcommon-em.bc $(SRCDIR)/lib/gvc/libgvc-em.bc $(SRCDIR)/lib/pathplan/libpathplan-em.bc $(SRCDIR)/lib/graph/libgraph-em.bc $(SRCDIR)/lib/dotgen/libdotgen-em.bc $(SRCDIR)/plugin/core/libgvplugin_core-em.bc $(SRCDIR)/plugin/dot_layout/libgvplugin_dot_layout-em.bc post.js pre.js $(EMCC) -v -O2 -s EXPORTED_FUNCTIONS='["_vizRenderFromString"]' -o viz.js -I$(SRCDIR)/lib/gvc -I$(SRCDIR)/lib/common -I$(SRCDIR)/lib/pathplan -I$(SRCDIR)/lib/cdt -I$(SRCDIR)/lib/graph -I$(EPSRCDIR)/lib viz.c $(SRCDIR)/lib/cdt/libcdt-em.bc $(SRCDIR)/lib/common/libcommon-em.bc $(SRCDIR)/lib/gvc/libgvc-em.bc $(SRCDIR)/lib/pathplan/libpathplan-em.bc $(SRCDIR)/lib/graph/libgraph-em.bc $(SRCDIR)/lib/dotgen/libdotgen-em.bc $(SRCDIR)/plugin/dot_layout/libgvplugin_dot_layout-em.bc $(SRCDIR)/plugin/core/libgvplugin_core-em.bc $(EPSRCDIR)/lib/lib-em.bc --pre-js pre.js --post-js post.js --closure 1 $(SRCDIR)/lib/cdt/libcdt-em.bc: cd $(SRCDIR)/lib/cdt; $(EMCC) -o libcdt-em.bc -I. dtclose.c dtdisc.c dtextract.c dtflatten.c dthash.c dtlist.c dtmethod.c dtopen.c dtsize.c dtstrhash.c dttree.c dttreeset.c dtrestore.c dtview.c dtwalk.c $(EPSRCDIR)/lib/lib-em.bc: cd $(EPSRCDIR)/lib; $(EMCC) -o lib-em.bc -I. -I.. -DHAVE_BCOPY xmlparse.c xmlrole.c xmltok.c $(SRCDIR)/lib/common/libcommon-em.bc: cd $(SRCDIR)/lib/common; $(EMCC) -o libcommon-em.bc -I. -I.. -I../.. -I../../.. -I../gvc -I../pathplan -I../cdt -I../graph -I../xdot -I../../../$(EPSRCDIR)/lib -DHAVE_CONFIG_H -DHAVE_EXPAT_H -DHAVE_EXPAT arrows.c emit.c utils.c labels.c memory.c fontmetrics.c geom.c globals.c htmllex.c htmlparse.c htmltable.c ns.c pointset.c postproc.c routespl.c shapes.c splines.c colxlate.c psusershape.c input.c timing.c output.c $(SRCDIR)/lib/gvc/libgvc-em.bc: cd $(SRCDIR)/lib/gvc; $(EMCC) -o libgvc-em.bc -I. -I.. -I../.. -I../../.. -I../common -I../pathplan -I../cdt -I../graph -DHAVE_CONFIG_H gvc.c gvconfig.c gvcontext.c gvdevice.c gvlayout.c gvevent.c gvjobs.c gvplugin.c gvrender.c gvusershape.c gvloadimage.c gvtextlayout.c $(SRCDIR)/lib/pathplan/libpathplan-em.bc: cd $(SRCDIR)/lib/pathplan; $(EMCC) -o libpathplan-em.bc -I. cvt.c inpoly.c route.c shortest.c solvers.c triang.c util.c visibility.c $(SRCDIR)/lib/graph/libgraph-em.bc: cd $(SRCDIR)/lib/graph; $(EMCC) -o libgraph-em.bc -I. -I../cdt -I../gvc -I../common -I../pathplan agxbuf.c attribs.c edge.c graph.c graphio.c lexer.c node.c parser.c refstr.c trie.c $(SRCDIR)/lib/dotgen/libdotgen-em.bc: cd $(SRCDIR)/lib/dotgen; $(EMCC) -o libdotgen-em.bc -I. -I.. -I../.. -I../../.. -I../common -I../gvc -I../pathplan -I../cdt -I../graph -DHAVE_CONFIG_H acyclic.c aspect.c class1.c class2.c cluster.c compound.c conc.c decomp.c dotinit.c dotsplines.c fastgr.c flat.c mincross.c position.c rank.c sameport.c $(SRCDIR)/plugin/core/libgvplugin_core-em.bc: cd $(SRCDIR)/plugin/core; $(EMCC) -o libgvplugin_core-em.bc -I. -I.. -I../.. -I../../.. -I../../lib -I../../lib/common -I../../lib/gvc -I../../lib/pathplan -I../../lib/cdt -I../../lib/graph -DHAVE_CONFIG_H gvplugin_core.c gvrender_core_dot.c gvrender_core_fig.c gvrender_core_map.c gvrender_core_ps.c gvrender_core_svg.c gvrender_core_tk.c gvrender_core_vml.c gvloadimage_core.c $(SRCDIR)/plugin/dot_layout/libgvplugin_dot_layout-em.bc: cd $(SRCDIR)/plugin/dot_layout; $(EMCC) -o libgvplugin_dot_layout-em.bc -I. -I.. -I../.. -I../../.. -I../../lib -I../../lib/common -I../../lib/gvc -I../../lib/pathplan -I../../lib/cdt -I../../lib/graph -DHAVE_CONFIG_H gvplugin_dot_layout.c gvlayout_dot_layout.c $(SRCDIR): | graphviz-src.tar.gz mkdir -p $(SRCDIR) tar xf graphviz-src.tar.gz -C $(SRCDIR) --strip=1 $(EPSRCDIR): | libexpat-src.tar.gz mkdir -p $(EPSRCDIR) tar xf libexpat-src.tar.gz -C $(EPSRCDIR) --strip=1 graphviz-src.tar.gz: curl "http://www.graphviz.org/pub/graphviz/stable/SOURCES/graphviz-2.30.1.tar.gz" -o graphviz-src.tar.gz libexpat-src.tar.gz: curl -L "http://sourceforge.net/projects/expat/files/expat/2.1.0/expat-2.1.0.tar.gz/download" -o libexpat-src.tar.gz clean: rm -f $(SRCDIR)/lib/*/*.bc rm -f $(SRCDIR)/plugin/*/*.bc rm -f $(EPSRCDIR)/lib/*.bc rm -f viz.js clobber: clean rm -rf $(SRCDIR) rm -rf $(EPSRCDIR) rm -f graphviz-src.tar.gz rm -f libexpat-src.tar.gz ================================================ FILE: src/viz/README.txt ================================================ Viz.js ====== Simple Graphviz for the web, compiled with Emscripten. To render as SVG (produces an XML string): svg = Viz("digraph { a -> b; }", "svg"); This project is based on work by Satoshi Ueyama and Brenton Partridge: https://github.com/gyuque/livizjs https://github.com/bpartridge/graphviz.js ================================================ FILE: src/viz/config.h ================================================ #define GVPLUGIN_CONFIG_FILE "config6" #define GVPLUGIN_VERSION 6 #define PACKAGE "graphviz" #define PACKAGE_BUGREPORT "http://www.graphviz.org/" #define PACKAGE_NAME "graphviz" #define PACKAGE_STRING "graphviz 2.28.0" #define PACKAGE_TARNAME "graphviz" #define PACKAGE_URL "" #define PACKAGE_VERSION "2.28.0" #define VERSION "2.28.0" #define HAVE_BOOL 1 #undef ENABLE_LTDL #define HAVE_ERRNO_H 1 #define DEFAULT_DPI 96 #define HAVE_STRDUP 1 ================================================ FILE: src/viz/example.html ================================================
>24&&(m[s+58|0]=0);c=Y(f,5386632);0!=(c|0)&&0!=m[c]<<24>>24&&(m[a[n+3]+161|0]=1);n=a[n+3];lk(d,a[a[a[n+24>>2]+4>>2]+8>>2],n,c);c=d>>2;e=(s+68|0)>>2;for(p=c+10;c
>24&&(m[s+98|0]=0);h=k}function kk(s,i){var f=s|0,e=mc(f,a[1347845],14,1),n=i|0;g[b>>3]=e;a[n>>2]=a[b>>2];a[n+4>>2]=a[b+4>>2];a[i+8>>2]=ib(f,a[1347846],5386144);a[i+12>>2]=ib(f,a[1347847],5383496)}function bp(s,i,f){var e=i+8|0;0==(a[e>>2]|0)&&kk(s,i);var s=s|0,n=i|0,n=mc(s,a[1347836],(a[b>>2]=a[n>>2],a[b+4>>2]=a[n+4>>2],g[b>>3]),1),k=f|0;g[b>>3]=n;a[k>>2]=a[b>>2];a[k+4>>2]=a[b+4>>2];a[f+8>>2]=ib(s,a[1347837],a[e>>2]);a[f+12>>2]=ib(s,a[1347838],a[i+12>>2])}function lk(b,i,f,e){var n,k=h;h=h+80|0;var j=k+40,c=Dc(e,58);if(0==(c|0)){B[i](j,f,e,0);var i=j>>2,c=a[i+9],j=a[i+8],d=a[i+7],g=a[i+6],r=a[i+5],q=a[i+4],u=a[i+3],l=a[i+2],f=a[i+1],i=a[i]}else{m[c]=0;j=c+1|0;B[i](k,f,e,j);n=k>>2;var i=a[n],f=a[n+1],l=a[n+2],u=a[n+3],q=a[n+4],r=a[n+5],g=a[n+6],d=a[n+7],t=a[n+8];n=a[n+9];m[c]=58;c=n&0|j;j=t&-1|0;d=d&-1|0;g=g&-1|0;r=r&-1|0;q=q&-1|0;u=u&-1|0;l=l&-1|0;f=f&-1|0;i=i&-1|0}b>>=2;a[b]=i&-1|0;a[b+1]=f&-1|0;a[b+2]=l&-1|0;a[b+3]=u&-1|0;a[b+4]=q&-1|0;a[b+5]=r&-1|0;a[b+6]=g&-1|0;a[b+7]=d&-1|0;a[b+8]=j&-1|0;a[b+9]=c&0|e;h=k}function cp(b,i){if(0==(i|0)){var f=0}else{f=Gb(b|0,a[i+8>>2]),f=0==(f|0)?0:0==m[f]<<24>>24?0:0==Wd(f)<<24>>24&1}return f}function jh(s,i){var f,e,n=h;h=h+32|0;f=s+52|0;var k,j=a[s+152>>2]&1,c,d,p,r;e=h;c=f>>2;k=h;h=h+32|0;a[k>>2]=a[c];a[k+4>>2]=a[c+1];a[k+8>>2]=a[c+2];a[k+12>>2]=a[c+3];a[k+16>>2]=a[c+4];a[k+20>>2]=a[c+5];a[k+24>>2]=a[c+6];a[k+28>>2]=a[c+7];c=i+56|0;d=(a[b>>2]=a[c>>2],a[b+4>>2]=a[c+4>>2],g[b>>3]);c=i+64|0;c=(a[b>>2]=a[c>>2],a[b+4>>2]=a[c+4>>2],g[b>>3]);var j=0==j<<24>>24,m=i+24|0,m=(a[b>>2]=a[m>>2],a[b+4>>2]=a[m+4>>2],g[b>>3]),u=i+32|0,u=(a[b>>2]=a[u>>2],a[b+4>>2]=a[u+4>>2],g[b>>3]);r=.5*(j?m:u);p=d-r;d+=r;r=(k|0)>>2;if(p<(a[b>>2]=a[r],a[b+4>>2]=a[r+1],g[b>>3])){g[b>>3]=p,a[r]=a[b>>2],a[r+1]=a[b+4>>2]}p=(k+16|0)>>2;if(d>(a[b>>2]=a[p],a[b+4>>2]=a[p+1],g[b>>3])){g[b>>3]=d,a[p]=a[b>>2],a[p+1]=a[b+4>>2]}d=.5*(j?u:m);j=c-d;c+=d;d=(k+8|0)>>2;if(j<(a[b>>2]=a[d],a[b+4>>2]=a[d+1],g[b>>3])){g[b>>3]=j,a[d]=a[b>>2],a[d+1]=a[b+4>>2]}j=(k+24|0)>>2;if(c>(a[b>>2]=a[j],a[b+4>>2]=a[j+1],g[b>>3])){g[b>>3]=c,a[j]=a[b>>2],a[j+1]=a[b+4>>2]}c=n>>2;k>>=2;a[c]=a[k];a[c+1]=a[k+1];a[c+2]=a[k+2];a[c+3]=a[k+3];a[c+4]=a[k+4];a[c+5]=a[k+5];a[c+6]=a[k+6];a[c+7]=a[k+7];h=e;e=f>>2;f=n>>2;a[e]=a[f];a[e+1]=a[f+1];a[e+2]=a[f+2];a[e+3]=a[f+3];a[e+4]=a[f+4];a[e+5]=a[f+5];a[e+6]=a[f+6];a[e+7]=a[f+7];h=n}function we(a,b,f){var e=0;if(0==(f|0)){var n;return 0}for(;;){var k=f-1|0;if(0==(f|0)){e=2250;break}if((ne(E[a])|0)!=(ne(E[b])|0)){e=2250;break}if(0==(k|0)){n=0;e=2255;break}if(0==m[a]<<24>>24){n=0;e=2253;break}if(0==m[b]<<24>>24){n=0;e=2256;break}a=a+1|0;b=b+1|0;f=k}if(2250==e){return n=ne(E[a])-ne(E[b])|0}if(2255==e||2253==e||2256==e){return n}}function dp(b){var i=si(b,5363812),f=b+20|0,e=wa(a[f>>2]);a:do{if(0!=(e|0)){for(var n=b+28|0,k=e;;){var j=Fb(b,k);b:do{if(0!=(j|0)){for(var c=j;;){var d=i,g=a[c+16>>2],h=a[c+12>>2];0==m[g+134|0]<<24>>24&&0==m[h+134|0]<<24>>24||(g=mk(g,d),d=mk(h,d),ti(c|0,ye(a[g+20>>2],g,d)|0));c=Jb(a[n>>2],c);if(0==(c|0)){break b}}}}while(0);k=Ba(a[f>>2],k);if(0==(k|0)){break a}}}}while(0);f=i+20|0;e=wa(a[f>>2]);if(0!=(e|0)){for(;!(kh(b,e|0),e=Ba(a[f>>2],e),0==(e|0));){}}Fe(i)}function nc(a,b,f,e){b=ha(b,f);return 0!=(b|0)?b:a=B[e](a,f,5345e3)}function ep(b){var i=h;h=h+20|0;var f=i+8,e=Dc(b,59),n=a[1311730];n>>>0>>0||(la(5246916,1),n=a[1311730]);a[1311730]=n+1|0;m[n]=38;if(0==(e|0)){return h=i,b}var k=e-b|0;if(6<(k-2|0)>>>0){return h=i,b}n=f|0;Uf(n,b,k);m[f+k|0]=0;a[i>>2]=n;f=Vf(i,5260236,252,8,178);if(0==(f|0)){return h=i,b}wb(n,5342300,(l=h,h=h+4|0,a[l>>2]=a[f+4>>2],l));b=a[1311730];b>>>0>>0||(la(5246916,1),b=a[1311730]);a[1311730]=b+1|0;m[b]=35;Ib(5246916,n);b=a[1311730];b>>>0>>0||(la(5246916,1),b=a[1311730]);a[1311730]=b+1|0;m[b]=59;h=i;return e+1|0}function Rw(s,i){var f,e=h;f=s>>2;s=h;h=h+32|0;a[s>>2]=a[f];a[s+4>>2]=a[f+1];a[s+8>>2]=a[f+2];a[s+12>>2]=a[f+3];a[s+16>>2]=a[f+4];a[s+20>>2]=a[f+5];a[s+24>>2]=a[f+6];a[s+28>>2]=a[f+7];f=i>>2;i=h;h=h+32|0;a[i>>2]=a[f];a[i+4>>2]=a[f+1];a[i+8>>2]=a[f+2];a[i+12>>2]=a[f+3];a[i+16>>2]=a[f+4];a[i+20>>2]=a[f+5];a[i+24>>2]=a[f+6];a[i+28>>2]=a[f+7];f=s+16|0;var n=i|0;if((a[b>>2]=a[f>>2],a[b+4>>2]=a[f+4>>2],g[b>>3])<(a[b>>2]=a[n>>2],a[b+4>>2]=a[n+4>>2],g[b>>3])){return h=e,0}f=i+16|0;n=s|0;if((a[b>>2]=a[f>>2],a[b+4>>2]=a[f+4>>2],g[b>>3])<(a[b>>2]=a[n>>2],a[b+4>>2]=a[n+4>>2],g[b>>3])){return h=e,0}f=s+24|0;n=i+8|0;if((a[b>>2]=a[f>>2],a[b+4>>2]=a[f+4>>2],g[b>>3])<(a[b>>2]=a[n>>2],a[b+4>>2]=a[n+4>>2],g[b>>3])){return h=e,0}f=i+24|0;n=s+8|0;f=(a[b>>2]=a[f>>2],a[b+4>>2]=a[f+4>>2],g[b>>3])>=(a[b>>2]=a[n>>2],a[b+4>>2]=a[n+4>>2],g[b>>3]);h=e;return f&1}function nk(b){var i=h;h=h+20|0;var f=i+8,e=a[b>>2];a:do{if(35==m[e]<<24>>24){var n=m[e+1|0],k=n&255;b:do{if(120==n<<24>>24|88==n<<24>>24){for(var j=0,c=2,d=k;;){if(8<=(c|0)){var g=j,r=c,q=d;break b}var d=m[e+c|0],u=d&255;do{if(6>(d-65&255)){var l=u-55|0}else{if(6>(d-97&255)){l=u-87|0}else{if(10<=(d-48&255)){g=j;r=c;q=u;break b}l=u-48|0}}}while(0);j=(j<<4)+l|0;c=c+1|0;d=l}}else{j=0;c=1;for(d=k;;){if(8<=(c|0)){g=j;r=c;q=d;break b}d=m[e+c|0];u=d&255;if(10<=(d-48&255)){g=j;r=c;q=u;break b}j=(10*j&-1)-48+u|0;c=c+1|0;d=u}}}while(0);59!=(q|0)?(k=0,n=e):(k=g,n=r+(e+1)|0)}else{n=f|0;k=a[i>>2]=n;for(n=0;;){if(8<=(n|0)){k=0;n=e;break a}j=m[e+n|0];if(0==j<<24>>24){k=0;n=e;break a}else{if(59==j<<24>>24){break}}m[k]=j;k=k+1|0;n=n+1|0}m[k]=0;k=Vf(i,5260236,252,8,178);0==(k|0)?(k=0,n=e):(k=a[k+4>>2],n=n+(e+1)|0)}}while(0);a[b>>2]=n;h=i;return k}function ok(b){var i,f,e=h;h=h+1044|0;f=e>>2;var n=e+4;Ob(n,1024,e+20|0);a[f]=b+1|0;var k=m[b],b=(n+4|0)>>2;i=(n+8|0)>>2;a:do{if(0!=k<<24>>24){for(var j=k;;){38==j<<24>>24?(j=nk(e),j=0==(j|0)?38:j):j&=255;if(127>j>>>0){var c=a[b];c>>>0>>0||(la(n,1),c=a[b]);a[b]=c+1|0;m[c]=j&255}else{var d=a[b],c=a[i],g=d>>>0>=c>>>0;2047>j>>>0?(g&&(la(n,1),d=a[b],c=a[i]),g=d+1|0,a[b]=g,m[d]=(j>>>6|192)&255):(g&&(la(n,1),d=a[b],c=a[i]),g=d+1|0,a[b]=g,m[d]=(j>>>12|224)&255,g>>>0 >2]=a[n>>2],a[b+4>>2]=a[n+4>>2],g[b>>3])<(a[b>>2]=a[p>>2],a[b+4>>2]=a[p+4>>2],g[b>>3])){return h=k,0}n=i+24|0;if((a[b>>2]=a[n>>2],a[b+4>>2]=a[n+4>>2],g[b>>3]) >2]=a[r>>2],a[b+4>>2]=a[r+4>>2],g[b>>3]))){return i=0,h=c,i}r=n+16|0;r=(a[b>>2]=a[r>>2],a[b+4>>2]=a[r+4>>2],g[b>>3]);l+=(r-k)*j;if(l>=p){var t=n+24|0;if(!(l>(a[b>>2]=a[t>>2],a[b+4>>2]=a[t+4>>2],g[b>>3])|r >2;var $a=da>J,gc=$a&1;d=(($<<5)+i+24|0)>>2;var ec=ga P?P:Y),ha=Z/$a;if(0 >31&a[c>>2]|0),a[i]=a[b>>2],a[i+1]=a[b+4>>2],x=a[f],i=(h+(36*x&-1)+28|0)>>2,p=(a[b>>2]=a[i],a[b+4>>2]=a[i+1],g[b>>3]),m=e+(24*k&-1)+16|0,m=72*(a[b>>2]=a[m>>2],a[b+4>>2]=a[m+4>>2],g[b>>3]),p>>0?q=u:(la(j,1),q=a[f]),a[f]=q+1|0,m[q]=(g>>>6&63|128)&255);g=(g&63|128)&255}}}}else{if(224>(d&255)){if(-128!=(m[c]&-64)<<24>>24){n=2436;break a}g=a[f];g>>>0>>0||(la(j,1),g=a[f]);a[f]=g+1|0;m[g]=d;a[e]=b+2|0;g=m[c]}else{if(240<=(d&255)){n=2446;break a}if(-128!=(m[c]&-64)<<24>>24){n=2456;break a}g=b+2|0;if(-128!=(m[g]&-64)<<24>>24){n=2455;break a}q=a[f];r=a[i];q>>>0
>2]=a[p>>2],a[b+4>>2]=a[p+4>>2],g[b>>3])>i?p=0:(p=n+24|0,p=(a[b>>2]=a[p>>2],a[b+4>>2]=a[p+4>>2],g[b>>3])>=i))}if(k>f){j=2742}else{var r=n+16|0;if((a[b>>2]=a[r>>2],a[b+4>>2]=a[r+4>>2],g[b>>3])>>0){f=3234;break}i=q<<1;q=1e4>>0?1e4:i;i=Hb(6*q&-1|3);if(0==(i|0)){f=3234;break}var l=i,t=d;Fc(i,t,g<<1);i=((q>>>1&1073741823)<<2)+i|0;Fc(i,r,g<<2);(d|0)!=(n|0)&&H(t);if((q-1|0)>(k|0)){u=l,g=(k<<1)+l|0,r=i,l=(k<<2)+i|0,i=l>>2,k=q}else{var w=l;break}}if(27==(j|0)){w=u;break}q=D[(j<<1)+5255636>>1];t=q<<16>>16;if(-11==q<<16>>16){f=3177}else{var y=a[1314037];-2==(y|0)&&(y=zp(),a[1314037]=y);y=1>(y|0)?a[1314037]=0:286>y>>>0?E[y+5255008|0]:2;t=y+t|0;if(181
>2]=a[k],a[b+4>>2]=a[k+1],g[b>>3]),X=a[U>>2],X=0==(X|0)?a[t>>2]:X,U=a[U+4>>2];if(0==(U|0)){H=S,O=X,q=600}else{var Ga=U,Mb=S,V=X}}600==q&&(q=0,Ga=a[j>>2],Mb=H,V=O);rb(s,Ga);a[w>>2]=a[p];a[y>>2]=V;g[b>>3]=Mb;a[A>>2]=a[b>>2];a[A+4>>2]=a[b+4>>2];U=T+40|0;U=(a[b>>2]=a[U>>2],a[b+4>>2]=a[U+4>>2],g[b>>3]);g[b>>3]=U;a[C>>2]=a[b>>2];a[C+4>>2]=a[b+4>>2];g[b>>3]=1;a[F>>2]=a[b>>2];a[F+4>>2]=a[b+4>>2];a[N>>2]=a[p+1];a[Fa>>2]=a[p+2];p=(T+32|0)>>2;U=(a[b>>2]=a[p],a[b+4>>2]=a[p+1],g[b>>3]);g[b>>3]=U;a[B>>2]=a[b>>2];a[B+4>>2]=a[b+4>>2];U=(a[b>>2]=a[c],a[b+4>>2]=a[c+1],g[b>>3]);g[b>>3]=U;a[ka>>2]=a[b>>2];a[ka+4>>2]=a[b+4>>2];m[z]=108;hk(s,L,E,l);K=K+1|0;if((K|0)<(D[Ca>>1]<<16>>16|0)){L+=(a[b>>2]=a[p],a[b+4>>2]=a[p+1],g[b>>3]),T=T+76|0,p=T>>2}else{break a}}}}while(0);n=n+1|0;if((n|0)==(i|0)){break}}}rp(s);h=l}function mh(b,i,f,e,n,k){var j,c,d=0,g=h;h=h+176|0;j=e>>2;e=h;h=h+32|0;a[e>>2]=a[j];a[e+4>>2]=a[j+1];a[e+8>>2]=a[j+2];a[e+12>>2]=a[j+3];a[e+16>>2]=a[j+4];a[e+20>>2]=a[j+5];a[e+24>>2]=a[j+6];a[e+28>>2]=a[j+7];c=g>>2;var r=g+16,q=g+48,u=b+16|0,v=a[u>>2];j=(v+148|0)>>2;var t=n|0;a[t>>2]=a[j];var w=v+168|0;a[n+4>>2]=a[w>>2];var y=v+184|0;a[n+8>>2]=a[y>>2];var A=v+152|0;a[n+12>>2]=a[A>>2];var C=v+200|0,n=n+16|0;m[n]=a[C>>2]<<31>>31&255;var F=a[f+16>>2];if(0==(F|0)){d=608}else{if(0==m[F]<<24>>24){d=608}else{var N=0,Fa=F}}if(608==d){Ob(g,128,q|0);N=i+52|0;Fa=a[N>>2];0==(Fa|0)&&(Fa=jb(ki(a[a[a[a[b>>2]+128>>2]+44>>2]+92>>2],a[v+8>>2]|0,g)),a[N>>2]=Fa,m[i+56|0]=1);i=Fa;Ib(g,i);i=r|0;r=a[1313736];a[1313736]=r+1|0;wb(i,5349448,(l=h,h=h+4|0,a[l>>2]=r,l));Ib(g,i);i=(g+4|0)>>2;r=a[i];r>>>0>>0||(la(g,1),r=a[i]);m[r]=0;r=a[c];a[i]=r;var N=1,B=Fa=r}f=Oj(a[u>>2],a[b+148>>2],0,a[f>>2],a[f+12>>2],a[f+8>>2],Fa,a[v+8>>2]|0);N&&Yb(B,a[c+3]);if(0==(f|0)){return h=g,f}0!=(k|0)&&!(0==(a[t>>2]|0)&&0==m[n]<<24>>24)&&Zd(b);if(0==(a[j]|0)&&0==(a[C>>2]&1|0)){return h=g,f}li(b,e);Ic(b,a[j],a[w>>2],a[y>>2],a[A>>2]);h=g;return f}function Kp(b,i,f){var e,n=h;e=f>>2;f=h;h=h+32|0;a[f>>2]=a[e];a[f+4>>2]=a[e+1];a[f+8>>2]=a[e+2];a[f+12>>2]=a[e+3];a[f+16>>2]=a[e+4];a[f+20>>2]=a[e+5];a[f+24>>2]=a[e+6];a[f+28>>2]=a[e+7];Ub(b,i);rb(b,i);Af(b,f,1);h=n}function Lp(s,i,f,e){var n,k=h;n=e>>2;e=h;h=h+32|0;a[e>>2]=a[n];a[e+4>>2]=a[n+1];a[e+8>>2]=a[n+2];a[e+12>>2]=a[n+3];a[e+16>>2]=a[n+4];a[e+20>>2]=a[n+5];a[e+24>>2]=a[n+6];a[e+28>>2]=a[n+7];i=0==(i|0)?5383496:i;Ub(s,i);rb(s,i);if(1==(f|0)){Af(s,e,0)}else{i=e+24|0;i=(a[b>>2]=a[i>>2],a[b+4>>2]=a[i+4>>2],g[b>>3]);n=e+8|0;n=(a[b>>2]=a[n>>2],a[b+4>>2]=a[n+4>>2],g[b>>3]);var j=i-n,c=e+16|0,c=(a[b>>2]=a[c>>2],a[b+4>>2]=a[c+4>>2],g[b>>3]),e=e|0,e=(a[b>>2]=a[e>>2],a[b+4>>2]=a[e+4>>2],g[b>>3]),d=c-e,p=f-1|0;Ai(s,e,n,p,j);f=1-f|0;Ai(s,e,i,d,f);Ai(s,c,i,f,-j);Ai(s,c,n,-d,p)}h=k}function Mp(s,i,f){var e,n,k,j,c=h;h=h+68|0;var d=c+36,p=i|0;j=d>>2;k=(i+40|0)>>2;a[j]=a[k];a[j+1]=a[k+1];a[j+2]=a[k+2];a[j+3]=a[k+3];a[j+4]=a[k+4];a[j+5]=a[k+5];a[j+6]=a[k+6];a[j+7]=a[k+7];k=f|0;e=(a[b>>2]=a[k>>2],a[b+4>>2]=a[k+4>>2],g[b>>3]);k=f+8|0;j=(a[b>>2]=a[k>>2],a[b+4>>2]=a[k+4>>2],g[b>>3]);k=0==(a[i>>2]|0)?0!=(a[i+8>>2]|0):1;n=(d|0)>>2;var r=(a[b>>2]=a[n],a[b+4>>2]=a[n+1],g[b>>3])+e;g[b>>3]=r;a[n]=a[b>>2];a[n+1]=a[b+4>>2];n=(d+16|0)>>2;e=(a[b>>2]=a[n],a[b+4>>2]=a[n+1],g[b>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0;g[b>>3]=l;a[r>>2]=a[b>>2];a[r+4>>2]=a[b+4>>2];r=i+48|0;g[b>>3]=q;a[r>>2]=a[b>>2];a[r+4>>2]=a[b+4>>2];r=i+56|0;g[b>>3]=n;a[r>>2]=a[b>>2];a[r+4>>2]=a[b+4>>2];n=a[e+36>>2];0==(n|0)&&(n=a[f+48>>2]);e=a[(e+32|0)>>2];Jk(s,e,i|0,4,1,n);h=i}else{Ip(s,a[e],f)}}0!=(j|0)&&nh(s,c,1);k&&0!=(a[s+148>>2]&4|0)&&0!=(mh(s,f,p,d,c,0)|0)&&nh(s,c,0);h=c}function nh(b,i,f){var e,n,k;e=0;var j=a[b+16>>2];k=(j+148|0)>>2;0==(a[k]|0)?0==(a[j+200>>2]&1|0)?n=0:e=660:e=660;660==e&&(Zd(b),n=a[k]);e=i|0;(n|0)!=(a[e>>2]|0)&&(H(n),a[k]=a[e>>2]);n=(j+168|0)>>2;e=a[n];var c=i+4|0;(e|0)!=(a[c>>2]|0)&&(H(e),a[n]=a[c>>2]);e=(j+184|0)>>2;var c=a[e],d=i+8|0;(c|0)!=(a[d>>2]|0)&&(H(c),a[e]=a[d>>2]);var c=j+152|0,d=a[c>>2],g=i+12|0;(d|0)!=(a[g>>2]|0)&&(H(d),d=a[g>>2],a[c>>2]=d);c=d;i=m[i+16|0]&1;j=j+200|0;a[j>>2]=a[j>>2]&-2|i;0!=(f|0)&&(f=a[k],0==(f|0)&0==(i|0)||Ic(b,f,a[n],a[e],c))}function Ai(s,i,f,e,n){var k=h;h=h+32|0;var j=k|0;g[b>>3]=i;a[j>>2]=a[b>>2];a[j+4>>2]=a[b+4>>2];j=k+8|0;g[b>>3]=f;a[j>>2]=a[b>>2];a[j+4>>2]=a[b+4>>2];j=k+16|0;g[b>>3]=i+e;a[j>>2]=a[b>>2];a[j+4>>2]=a[b+4>>2];i=k+24|0;g[b>>3]=f+n;a[i>>2]=a[b>>2];a[i+4>>2]=a[b+4>>2];Af(s,k,1);h=k}function oh(b,i,f){0==($p(b)|0)&&aq();if(1>(f|0)){return Kk(),0}b=Y(b|0,5355344);b=0==(b|0)?30:Ye(b,Mc);a[1347590]=b;if(0==(bq()|0)){b=0}else{return Kk(),1}for(;;){var e=cq();if(0==(e|0)){break}dq(e,eq(a[e+12>>2],a[e+16>>2]));b=b+1|0;if((b|0)>=(f|0)){break}}2==(i|0)?fq():1==(i|0)?gq():hq();return 0}function $p(b){var i;a[1347820]=b;a[1347591]=0;a[1347634]=0;a[1347623]=0;var b=b+216|0,f=a[b>>2];if(0==(f|0)){i=0}else{for(var e=0,n=0;;){m[f+163|0]=0;i=e+1|0;a[1347623]=i;e=a[f+184>>2];a:do{if(0==(a[e>>2]|0)){var k=n}else{for(var j=0,c=n;;){if(c=c+1|0,a[1347634]=c,j=j+1|0,0==(a[e+(j<<2)>>2]|0)){k=c;break a}}}}while(0);f=a[f+168>>2];if(0==(f|0)){break}else{e=i,n=k}}i<<=2}k=a[1347423];i=0==(k|0)?Xa(i):La(k,i);a[1347423]=i;a[1347422]=0;i=a[1347425];i=0==(i|0)?Xa(a[1347623]<<2):La(i,a[1347623]<<2);a[1347425]=i;a[1347424]=0;b=a[b>>2];if(0==(b|0)){var d;return 1}f=1;k=b;for(b=k>>2;;){i=(k+292|0)>>2;a[i]=0;k=k+176|0;e=a[a[k>>2]>>2];if(0==(e|0)){i=f,k=4}else{n=f;for(j=f=1;;){a[i]=j;a[e+168>>2]=0;a[e+172>>2]=-1;var g=0==(n|0)?0:(a[a[e+12>>2]+236>>2]-a[a[e+16>>2]+236>>2]|0)<(Za[e+178>>1]|0)?0:n,e=a[a[k>>2]+(f<<2)>>2];if(0==(e|0)){break}n=g;f=f+1|0;j=a[i]+1|0}i=g;k=(f<<2)+4|0}a[b+66]=Z(k);a[b+67]=0;k=a[b+46];for(f=0;;){var h=f+1|0;if(0==(a[k+(f<<2)>>2]|0)){break}else{f=h}}a[b+68]=Z(h<<2);a[b+69]=0;b=a[b+42];if(0==(b|0)){d=i;break}else{f=i,k=b,b=k>>2}}return d}function cq(){for(var b=0,i=a[1347591],f=a[1347424],e=0,n=0,k=i;(k|0)<(f|0);){var j=a[a[1347425]+(k<<2)>>2],c=a[j+168>>2];if(0>(c|0)){if(c=0==(e|0)?j:(a[e+168>>2]|0)>(c|0)?j:e,j=n+1|0,(j|0)<(a[1347590]|0)){e=c,n=j}else{var d=c,b=742;break}}k=k+1|0;a[1347591]=k}if(742==b){return d}if(0<(i|0)){f=0}else{return e}for(;;){a[1347591]=f;if((f|0)>=(i|0)){d=e;b=741;break}k=a[a[1347425]+(f<<2)>>2];j=a[k+168>>2];if(0>(j|0)&&(e=0==(e|0)?k:(a[e+168>>2]|0)>(j|0)?k:e,n=n+1|0,(n|0)>=(a[1347590]|0))){d=e;b=743;break}f=f+1|0}if(743==b||741==b){return d}}function hq(){a[1347641]=2147483647;a[1347643]=-2147483647;var b=a[a[1347820]+216>>2];a:do{if(0==(b|0)){var i=2147483647,f=-2147483647}else{for(var e=b,n=2147483647,k=-2147483647;;){if(0==m[e+162|0]<<24>>24){var j=a[e+236>>2],c=(n|0)<(j|0)?n:j;a[1347641]=c;k=(k|0)>(j|0)?k:j;a[1347643]=k;j=c}else{j=n}c=k;e=a[e+168>>2];if(0==(e|0)){break}else{n=j,k=c}}if(0==(j|0)){return}for(e=b;;){if(k=e+236|0,a[k>>2]=a[k>>2]-j|0,e=a[e+168>>2],0==(e|0)){i=j;f=c;break a}}}}while(0);a[1347643]=f-i|0;a[1347641]=0}function aq(){var b,i=h,f=Xo(a[1347623]),e=a[a[1347820]+216>>2];a:do{if(0!=(e|0)){for(var n=e;;){if(0==(a[n+292>>2]|0)&&fh(f,n),n=a[n+168>>2],0==(n|0)){break a}}}}while(0);e=gh(f);a:do{if(0==(e|0)){b=0}else{for(var n=0,k=e;;){var j=k+236|0;a[j>>2]=0;var n=n+1|0,c=a[k+176>>2],d=a[c>>2];b:do{if(0!=(d|0)){for(var g=0,r=d,m=0;;){if(r=Za[r+178>>1]+a[a[r+16>>2]+236>>2]|0,m=(m|0)>(r|0)?m:r,a[j>>2]=m,g=g+1|0,r=a[c+(g<<2)>>2],0==(r|0)){break b}}}}while(0);k=k+184|0;j=a[a[k>>2]>>2];b:do{if(0!=(j|0)){c=0;for(d=j;;){if(d=d+12|0,g=a[d>>2]+292|0,m=a[g>>2]-1|0,a[g>>2]=m,1>(m|0)&&fh(f,a[d>>2]),c=c+1|0,d=a[a[k>>2]+(c<<2)>>2],0==(d|0)){break b}}}}while(0);k=gh(f);if(0==(k|0)){b=n;break a}}}}while(0);if((b|0)!=(a[1347623]|0)&&(W(1,5344168,(l=h,h=h+1|0,h=h+3>>2<<2,a[l>>2]=0,l)),b=a[a[1347820]+216>>2],0!=(b|0))){for(b>>=2;!(e=a[b+73],0!=(e|0)&&W(3,5341104,(l=h,h=h+8|0,a[l>>2]=a[b+3],a[l+4>>2]=e,l)),b=a[b+42],0==(b|0));){b>>=2}}H(a[f>>2]);H(f);h=i}function Kk(){var b;b=a[a[1347820]+216>>2];if(0!=(b|0)){var i=b;for(b=i>>2;;){var f=a[b+66];0!=(f|0)&&H(f);f=a[b+68];0!=(f|0)&&H(f);m[i+163|0]=0;b=a[b+42];if(0==(b|0)){break}else{i=b,b=i>>2}}}}function bq(){var b=0;if(2>(a[1347623]|0)){var i;return 0}a:for(;;){if((iq()|0)>=(a[1347623]|0)){b=801;break}var f=a[a[1347820]+216>>2];if(0==(f|0)){i=1;b=806;break}else{var e=0}for(;;){var n=a[f+184>>2],k=a[n>>2];b:do{if(0==(k|0)){var j=e}else{for(var c=e,d=0,g=k;;){if(0>(a[g+172>>2]|0)){var h=a[g+12>>2],m=a[g+16>>2],c=0==(jq(h,m)|0)?c:0!=(c|0)&&(a[h+236>>2]-a[m+236>>2]-Za[g+178>>1]|0)>=(a[a[c+12>>2]+236>>2]-a[a[c+16>>2]+236>>2]-Za[c+178>>1]|0)?c:g}d=d+1|0;g=a[n+(d<<2)>>2];if(0==(g|0)){j=c;break b}}}}while(0);f=a[f+168>>2];if(0==(f|0)){break}else{e=j}}if(0==(j|0)){i=1;b=805;break}e=a[j+12>>2];f=a[j+16>>2];n=a[e+236>>2]-a[f+236>>2]|0;k=Za[j+178>>1];c=n-k|0;if((n|0)!=(k|0)&&(e=(jq(e,f)|0)==(e|0)?-c|0:c,f=a[1347422],0<(f|0))){n=a[1347423];for(k=0;;){if(c=a[n+(k<<2)>>2]+236|0,a[c>>2]=a[c>>2]+e|0,k=k+1|0,(k|0)>=(f|0)){continue a}}}}if(801==b){return b=a[1347820]+216|0,ph(a[b>>2],0,1),Lk(a[b>>2],0),0}if(806==b||805==b){return i}}function eq(b,i){var f=(a[i+288>>2]|0)<(a[b+288>>2]|0),e=f?i:b;a[1347824]=0;a[1347433]=2147483647;a[1347645]=a[e+284>>2];a[1347648]=a[e+288>>2];f?Bi(e):Ci(e);return f=a[1347824]}function gq(){var b,i;hq();var f=Z((a[1347643]<<2)+4|0);i=f>>2;b=a[1347643];a:do{if(0<=(b|0)){for(var e=0;;){if(a[(e<<2>>2)+i]=0,e=e+1|0,(e|0)>(b|0)){break a}}}}while(0);b=a[1347820]+216|0;e=a[b>>2];if(0!=(e|0)){for(;;){if(0==m[e+162|0]<<24>>24){var n=(a[e+236>>2]<<2)+f|0;a[n>>2]=a[n>>2]+1|0}e=a[e+168>>2];if(0==(e|0)){break}}b=a[b>>2];if(0!=(b|0)){e=b;for(b=e>>2;;){if(0==m[e+162|0]<<24>>24){var n=a[1347643],k=a[b+44],j=a[k>>2];a:do{if(0==(j|0)){var c=0,d=0}else{for(var g=0,h=0,q=0,l=j;;){if(g=g+vb[l+164>>2]&-1,l=Za[l+178>>1]+a[a[l+16>>2]+236>>2]|0,h=(h|0)>(l|0)?h:l,q=q+1|0,l=a[k+(q<<2)>>2],0==(l|0)){c=g;d=h;break a}}}}while(0);k=a[b+46];j=a[k>>2];a:do{if(0==(j|0)){var v=0,t=n}else{g=0;h=n;q=0;for(l=j;;){if(g=g+vb[l+164>>2]&-1,l=a[a[l+12>>2]+236>>2]-Za[l+178>>1]|0,h=(h|0)<(l|0)?h:l,q=q+1|0,l=a[k+(q<<2)>>2],0==(l|0)){v=g;t=h;break a}}}}while(0);n=0>(d|0)?0:d;if((c|0)==(v|0)){k=n+1|0;a:do{if((k|0)>(t|0)){var w=n}else{j=n;for(h=k;;){if(j=(a[(h<<2>>2)+i]|0)<(a[(j<<2>>2)+i]|0)?h:j,h=h+1|0,(h|0)>(t|0)){w=j;break a}}}}while(0);n=e+236|0;k=(a[n>>2]<<2)+f|0;a[k>>2]=a[k>>2]-1|0;k=(w<<2)+f|0;a[k>>2]=a[k>>2]+1|0;a[n>>2]=w}n=a[b+66];0!=(n|0)&&H(n);n=a[b+68];0!=(n|0)&&H(n);m[e+163|0]=0}b=a[b+42];if(0==(b|0)){break}else{e=b,b=e>>2}}}}H(f)}function fq(){var b=a[1347424];if(0<(b|0)){for(var i=a[1347425],f=0;;){var e=a[i+(f<<2)>>2];if(0==(a[e+168>>2]|0)){var n=e+12|0,k=e+16|0,e=eq(a[n>>2],a[k>>2]);0!=(e|0)&&(e=a[a[e+12>>2]+236>>2]-a[a[e+16>>2]+236>>2]-Za[e+178>>1]|0,2>(e|0)||(k=a[k>>2],n=a[n>>2],(a[k+288>>2]|0)<(a[n+288>>2]|0)?bf(k,(e|0)/2&-1):bf(n,(e|0)/-2&-1)))}f=f+1|0;if((f|0)>=(b|0)){break}}}Kk()}function bf(b,i){var f=b+236|0;a[f>>2]=a[f>>2]-i|0;var f=b+272|0,e=a[f>>2],n=a[e>>2];a:do{if(0!=(n|0)){for(var k=b+280|0,j=1,c=n,d=e;;){(c|0)!=(a[k>>2]|0)&&(bf(a[c+12>>2],i),d=a[f>>2]);c=a[d+(j<<2)>>2];if(0==(c|0)){break a}j=j+1|0}}}while(0);f=b+264|0;j=a[f>>2];k=a[j>>2];if(0!=(k|0)){e=b+280|0;for(n=1;;){(k|0)!=(a[e>>2]|0)&&(bf(a[k+16>>2],i),j=a[f>>2]);k=a[j+(n<<2)>>2];if(0==(k|0)){break}n=n+1|0}}}function dq(b,i){var f,e,n,k;k=(i+12|0)>>2;n=(i+16|0)>>2;var j=a[a[k]+236>>2]-a[a[n]+236>>2]-Za[i+178>>1]|0;if(0<(j|0)){var c=a[b+16>>2];e=c>>2;if(1==(a[e+69]+a[e+67]|0)){bf(c,j)}else{var d=a[b+12>>2];f=d>>2;1==(a[f+69]+a[f+67]|0)?bf(d,-j|0):(a[e+72]|0)<(a[f+72]|0)?bf(c,j):bf(d,-j|0)}}f=b+168|0;e=a[f>>2];j=kq(a[n],a[k],e,1);(kq(a[k],a[n],e,0)|0)==(j|0)?(a[i+168>>2]=-e|0,a[f>>2]=0,lq(b,i),ph(j,a[j+280>>2],a[j+284>>2])):ba()}function kq(b,i,f,e){var n,i=i+288|0,k=-f|0,j=0==(e|0)&1;for(n=b>>2;;){var c=a[i>>2];if((a[n+71]|0)<=(c|0)&&(c|0)<=(a[n+72]|0)){break}c=a[n+70];n=a[c+16>>2];var d=c+168|0;a[d>>2]=(0==(((b|0)==(n|0)?e:j)|0)?k:f)+a[d>>2]|0;b=a[c+12>>2];b=(a[n+288>>2]|0)>(a[b+288>>2]|0)?n:b;n=b>>2}return b}function lq(b,i){var f,e;e=(b+172|0)>>2;a[i+172>>2]=a[e];a[a[1347425]+(a[e]<<2)>>2]=i;a[e]=-1;var n=a[b+16>>2],k=n+276|0;e=a[k>>2]-1|0;a[k>>2]=e;for(var n=n+272|0,k=a[n>>2],j=0;;){var c=(j<<2)+k|0;if((j|0)>(e|0)){var d=c;break}if((a[c>>2]|0)==(b|0)){d=c;break}else{j=j+1|0}}a[d>>2]=a[k+(e<<2)>>2];a[a[n>>2]+(e<<2)>>2]=0;e=a[b+12>>2];n=e+268|0;d=a[n>>2]-1|0;a[n>>2]=d;e=e+264|0;n=a[e>>2];for(k=0;;){j=(k<<2)+n|0;if((k|0)>(d|0)){f=j;break}if((a[j>>2]|0)==(b|0)){f=j;break}else{k=k+1|0}}a[f>>2]=a[n+(d<<2)>>2];a[a[e>>2]+(d<<2)>>2]=0;e=a[i+16>>2];f=(e+276|0)>>2;d=a[f];a[f]=d+1|0;e=e+272|0;a[a[e>>2]+(d<<2)>>2]=i;a[a[e>>2]+(a[f]<<2)>>2]=0;e=a[i+12>>2];f=(e+268|0)>>2;d=a[f];a[f]=d+1|0;e=e+264|0;a[a[e>>2]+(d<<2)>>2]=i;a[a[e>>2]+(a[f]<<2)>>2]=0}function jq(a,b){var f=0,e=0==m[a+163|0]<<24>>24;if(0==m[b+163|0]<<24>>24){if(e){f=892}else{var n=a}}else{e?n=b:f=892}892==f&&(n=0);return n}function Mk(b,i,f){var b=b>>2,e=0,n=a[b+4],k=(n|0)==(i|0),n=a[(k?a[b+3]:n)+288>>2];if((a[i+284>>2]|0)>(n|0)){e=898}else{if((n|0)>(a[i+288>>2]|0)){e=898}else{var j=0,c=(-1<(a[b+43]|0)?a[b+42]|0:0)-vb[b+41]}}898==e&&(j=1,c=vb[b+41]);c&=-1;i=0<(f|0)?(a[b+3]|0)==(i|0)?1:-1:k?1:-1;j=0==(j|0)?i:-i|0;return j=0>(j|0)?-c|0:c}function ph(b,i,f){a[b+280>>2]=i;a[b+284>>2]=f;var e=b+272|0,n=a[e>>2],k=a[n>>2];a:do{if(0==(k|0)){var j=f}else{for(var c=0,d=f,g=k,h=n;;){if((g|0)!=(i|0)&&(d=ph(a[g+12>>2],g,d),h=a[e>>2]),c=c+1|0,g=a[h+(c<<2)>>2],0==(g|0)){j=d;break a}}}}while(0);f=b+264|0;n=a[f>>2];k=a[n>>2];if(0==(k|0)){var m=j;a[(b+288|0)>>2]=m;return m+1|0}for(e=0;;){if((k|0)!=(i|0)&&(j=ph(a[k+16>>2],k,j),n=a[f>>2]),e=e+1|0,k=a[n+(e<<2)>>2],0==(k|0)){m=j;break}}a[(b+288|0)>>2]=m;return m+1|0}function Ci(b){var i=b+184|0,f=a[i>>2],e=a[f>>2];a:do{if(0!=(e|0)){for(var n=b+288|0,k=0,j=e,c=f;;){if(0>(a[j+172>>2]|0)){var d=a[j+12>>2],g=a[d+288>>2];(a[1347645]|0)>(g|0)|(g|0)>(a[1347648]|0)&&(d=a[d+236>>2]-a[a[j+16>>2]+236>>2]-Za[j+178>>1]|0,(d|0)<(a[1347433]|0)|0==(a[1347824]|0)&&(a[1347824]=j,a[1347433]=d))}else{j=a[j+12>>2],(a[j+288>>2]|0)<(a[n>>2]|0)&&(Ci(j),c=a[i>>2])}k=k+1|0;j=a[c+(k<<2)>>2];if(0==(j|0)){break a}}}}while(0);i=b+264|0;k=a[i>>2];e=a[k>>2];n=a[1347433];if(0!=(e|0)&0<(n|0)){b=b+288|0;for(f=1;;){e=a[e+16>>2];(a[e+288>>2]|0)<(a[b>>2]|0)&&(Ci(e),k=a[i>>2],n=a[1347433]);e=a[k+(f<<2)>>2];if(!(0!=(e|0)&0<(n|0))){break}f=f+1|0}}}function Bi(b){var i=b+176|0,f=a[i>>2],e=a[f>>2];a:do{if(0!=(e|0)){for(var n=b+288|0,k=0,j=e,c=f;;){if(0>(a[j+172>>2]|0)){var d=a[j+16>>2],g=a[d+288>>2];(a[1347645]|0)>(g|0)|(g|0)>(a[1347648]|0)&&(d=a[a[j+12>>2]+236>>2]-a[d+236>>2]-Za[j+178>>1]|0,(d|0)<(a[1347433]|0)|0==(a[1347824]|0)&&(a[1347824]=j,a[1347433]=d))}else{j=a[j+16>>2],(a[j+288>>2]|0)<(a[n>>2]|0)&&(Bi(j),c=a[i>>2])}k=k+1|0;j=a[c+(k<<2)>>2];if(0==(j|0)){break a}}}}while(0);i=b+272|0;k=a[i>>2];e=a[k>>2];n=a[1347433];if(0!=(e|0)&0<(n|0)){b=b+288|0;for(f=1;;){e=a[e+12>>2];(a[e+288>>2]|0)<(a[b>>2]|0)&&(Bi(e),k=a[i>>2],n=a[1347433]);e=a[k+(f<<2)>>2];if(!(0!=(e|0)&0<(n|0))){break}f=f+1|0}}}function iq(){var b,i=a[1347820]+216|0,f=a[i>>2];a:do{if(0!=(f|0)){var e=f;for(b=e>>2;;){if(m[e+163|0]=0,a[a[b+68]>>2]=0,a[a[b+66]>>2]=0,a[b+69]=0,a[b+67]=0,b=a[b+42],0==(b|0)){break a}else{e=b,b=e>>2}}}}while(0);f=a[1347424];a:do{if(0<(f|0)){b=a[1347425];for(e=0;;){if(a[a[b+(e<<2)>>2]+172>>2]=-1,e=e+1|0,(e|0)>=(f|0)){break a}}}}while(0);a[1347424]=0;a[1347422]=0;i=a[i>>2];if(0==(i|0)){return 0}for(;!(Di(i),i=a[i+168>>2],!(0!=(i|0)&0==(a[1347424]|0)));){}return i=a[1347422]}function Lk(b,i){var f=b+272|0,e=a[f>>2],n=a[e>>2];a:do{if(0!=(n|0)){for(var k=0,j=n,c=e;;){if((j|0)!=(i|0)&&(Lk(a[j+12>>2],j),c=a[f>>2]),k=k+1|0,j=a[c+(k<<2)>>2],0==(j|0)){break a}}}}while(0);f=b+264|0;e=a[f>>2];n=a[e>>2];a:do{if(0!=(n|0)){k=0;j=n;for(c=e;;){if((j|0)!=(i|0)&&(Lk(a[j+16>>2],j),c=a[f>>2]),k=k+1|0,j=a[c+(k<<2)>>2],0==(j|0)){break a}}}}while(0);if(0!=(i|0)){e=a[i+16>>2];(a[e+280>>2]|0)==(i|0)?f=1:(f=-1,e=a[i+12>>2]);n=a[e+184>>2];k=a[n>>2];a:do{if(0==(k|0)){var d=0}else{for(var j=c=0,g=k;;){if(c=Mk(g,e,f)+c|0,j=j+1|0,g=a[n+(j<<2)>>2],0==(g|0)){d=c;break a}}}}while(0);n=a[e+176>>2];c=a[n>>2];if(0==(c|0)){var h=d}else{for(k=0;;){if(d=Mk(c,e,f)+d|0,k=k+1|0,c=a[n+(k<<2)>>2],0==(c|0)){h=d;break}}}d=i+168|0;a[d>>2]=h}}function Di(b){var i=0,f=b+184|0,e=0;a:for(;;){var n=a[a[f>>2]+(e<<2)>>2];if(0==(n|0)){i=991;break}var k=n+12|0,j=a[k>>2];do{if(0==m[j+163|0]<<24>>24&&(a[j+236>>2]-a[a[n+16>>2]+236>>2]|0)==(Za[n+178>>1]|0)){Nk(n);if((a[1347424]|0)==(a[1347623]-1|0)){var c=1,i=1004;break a}if(0!=(Di(a[k>>2])|0)){c=1;i=1005;break a}}}while(0);e=e+1|0}if(991==i){b=b+176|0;f=0;a:for(;;){e=a[a[b>>2]+(f<<2)>>2];if(0==(e|0)){c=0;i=1008;break}n=e+16|0;k=a[n>>2];do{if(0==m[k+163|0]<<24>>24&&(a[a[e+12>>2]+236>>2]-a[k+236>>2]|0)==(Za[e+178>>1]|0)){Nk(e);if((a[1347424]|0)==(a[1347623]-1|0)){c=1;i=1007;break a}if(0!=(Di(a[n>>2])|0)){c=1;i=1006;break a}}}while(0);f=f+1|0}if(1006==i||1007==i||1008==i){return c}}else{if(1004==i||1005==i){return c}}}function Hf(s,i,f){var e=s|0;g[b>>3]=i;a[e>>2]=a[b>>2];a[e+4>>2]=a[b+4>>2];s=s+8|0;g[b>>3]=f;a[s>>2]=a[b>>2];a[s+4>>2]=a[b+4>>2]}function Ok(s,i){var f,e,n,k,j,c=h;h=h+144|0;var d=c+16,p=c+32,r=c+48,m=c+64,l=c+80,v=c+96,t=c+112;f=c+128;j=(s+52|0)>>2;var w=(a[b>>2]=a[j],a[b+4>>2]=a[j+1],g[b>>3]);k=(s+60|0)>>2;var y=(a[b>>2]=a[k],a[b+4>>2]=a[k+1],g[b>>3]);n=(s+68|0)>>2;var A=(a[b>>2]=a[n],a[b+4>>2]=a[n+1],g[b>>3]);e=(s+76|0)>>2;var C=(a[b>>2]=a[e],a[b+4>>2]=a[e+1],g[b>>3]);2>(i-1|0)>>>0?(Hf(c,w,C),t=c|0,v=c+8|0,kd(d,(a[b>>2]=a[t>>2],a[b+4>>2]=a[t+4>>2],g[b>>3]),(a[b>>2]=a[v>>2],a[b+4>>2]=a[v+4>>2],g[b>>3])),t=d|0,t=(a[b>>2]=a[t>>2],a[b+4>>2]=a[t+4>>2],g[b>>3]),v=d+8|0,v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f],a[e+1]=a[f+1],a[e+2]=a[f+2],a[e+3]=a[f+3]);f=s+208|0;if(1<=(a[f>>2]|0)){e=s+212|0;for(n=1;!(Ok(a[a[e>>2]+(n<<2)>>2],i),n=n+1|0,(n|0)>(a[f>>2]|0));){}}h=c}function kd(s,i,f){var e=h;h=h+16|0;kg(e,i,f,90*a[1347604]&-1);var i=e|0,i=(a[b>>2]=a[i>>2],a[b+4>>2]=a[i+4>>2],g[b>>3]),f=e+8|0,f=(a[b>>2]=a[f>>2],a[b+4>>2]=a[f+4>>2],g[b>>3]),i=i-(a[b>>2]=a[1347606],a[b+4>>2]=a[1347607],g[b>>3]),f=f-(a[b>>2]=a[1347608],a[b+4>>2]=a[1347609],g[b>>3]),n=s|0;g[b>>3]=i;a[n>>2]=a[b>>2];a[n+4>>2]=a[b+4>>2];s=s+8|0;g[b>>3]=f;a[s>>2]=a[b>>2];a[s+4>>2]=a[b+4>>2];h=e}function Pk(s){var i,f,e,n=h;h=h+48|0;i=n+16;var k=n+32,j=s+20|0,c=wa(a[j>>2]);if(0!=(c|0)){for(;;){var d,p=c+24|0,r=a[c+124>>2];if(0!=(r|0)){f=p+8|0;e=(a[b>>2]=a[f>>2],a[b+4>>2]=a[f+4>>2],g[b>>3]);f=p+16|0;f=(a[b>>2]=a[f>>2],a[b+4>>2]=a[f+4>>2],g[b>>3]);var p=p+88|0,q=r+24|0;d=d+(e+(a[b>>2]=a[p>>2],a[b+4>>2]=a[p+4>>2],g[b>>3]))+.5*(a[b>>2]=a[q>>2],a[b+4>>2]=a[q+4>>2],g[b>>3]);e=r+56|0;g[b>>3]=d;a[e>>2]=a[b>>2];a[e+4>>2]=a[b+4>>2];e=r+64|0;g[b>>3]=f;a[e>>2]=a[b>>2];a[e+4>>2]=a[b+4>>2];m[r+81|0]=1}r=d;c=Ba(a[j>>2],c);if(0==(c|0)){break}else{d=r}}}j=a[s+152>>2];c=j&3;a[1347604]=c;j&=1;m[5391284]=j;(f=0==j<<24>>24)?Qk(s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3]),(a[b>>2]=a[k>>2],a[b+4>>2]=a[k+4>>2],g[b>>3])),i=n>>2,a[1347606]=a[i],a[1347607]=a[i+1],a[1347608]=a[i+2],a[1347609]=a[i+3]):2==(c|0)?(k=s+52|0,c=s+76|0,Hf(i,(a[b>>2]=a[k>>2],a[b+4>>2]=a[k+4>>2],g[b>>3]),-(a[b>>2]=a[c>>2],a[b+4>>2]=a[c+4>>2],g[b>>3])),i>>=2,a[1347606]=a[i],a[1347607]=a[i+1],a[1347608]=a[i+2],a[1347609]=a[i+3]):0==(c|0)?(i=(s+52|0)>>2,a[1347606]=a[i],a[1347607]=a[i+1],a[1347608]=a[i+2],a[1347609]=a[i+3]):3==(c|0)&&(i=s+60|0,c=s+52|0,Hf(k,(a[b>>2]=a[i>>2],a[b+4>>2]=a[i+4>>2],g[b>>3]),(a[b>>2]=a[c>>2],a[b+4>>2]=a[c+4>>2],g[b>>3])),i=k>>2,a[1347606]=a[i],a[1347607]=a[i+1],a[1347608]=a[i+2],a[1347609]=a[i+3]);mq(s);i=a[j>>2];0!=(i|0)&&0==m[i+81|0]<<24>>24&&(j=r,i=d,k=m[s+283|0],c=k<<24>>24,0==(c&4|0)?(r=s+52|0,r=(a[b>>2]=a[r>>2],a[b+4>>2]=a[r+4>>2],g[b>>3]),0==(c&2|0)?(j=s+68|0,j=.5*(r+(a[b>>2]=a[j>>2],a[b+4>>2]=a[j+4>>2],g[b>>3]))):j=r+.5*j):(c=s+68|0,j=(a[b>>2]=a[c>>2],a[b+4>>2]=a[c+4>>2],g[b>>3])-.5*j),0==(k&1)<<24>>24?(k=s+60|0,i=(a[b>>2]=a[k>>2],a[b+4>>2]=a[k+4>>2],g[b>>3])+.5*i):(k=s+76|0,i=(a[b>>2]=a[k>>2],a[b+4>>2]=a[k+4>>2],g[b>>3])-.5*i),s=s+48|0,k=a[s>>2],c=k+56|0,g[b>>3]=j,a[c>>2]=a[b>>2],a[c+4>>2]=a[b+4>>2],k=k+64|0,g[b>>3]=i,a[k>>2]=a[b>>2],a[k+4>>2]=a[b+4>>2],m[a[s>>2]+81|0]=1);h=n}function Rk(s){if((a[s+32>>2]|0)!=(s|0)){var i=s+48|0,f=a[i>>2];if(0!=(f|0)&&0==m[f+81|0]<<24>>24){var e=m[s+283|0];if(0==(e&1)<<24>>24){var n=s+132|0,n=(a[b>>2]=a[n>>2],a[b+4>>2]=a[n+4>>2],g[b>>3]),k=s+52|0,n=(a[b>>2]=a[k>>2],a[b+4>>2]=a[k+4>>2],g[b>>3])+.5*n,k=s+140|0}else{n=s+100|0,n=(a[b>>2]=a[n>>2],a[b+4>>2]=a[n+4>>2],g[b>>3]),k=s+68|0,n=(a[b>>2]=a[k>>2],a[b+4>>2]=a[k+4>>2],g[b>>3])-.5*n,k=s+108|0}k=(a[b>>2]=a[k>>2],a[b+4>>2]=a[k+4>>2],g[b>>3]);e=e<<24>>24;0==(e&4|0)?0==(e&2|0)?(e=s+60|0,k=s+76|0,e=.5*((a[b>>2]=a[e>>2],a[b+4>>2]=a[e+4>>2],g[b>>3])+(a[b>>2]=a[k>>2],a[b+4>>2]=a[k+4>>2],g[b>>3]))):(e=s+76|0,e=(a[b>>2]=a[e>>2],a[b+4>>2]=a[e+4>>2],g[b>>3])-.5*k):(e=s+60|0,e=(a[b>>2]=a[e>>2],a[b+4>>2]=a[e+4>>2],g[b>>3])+.5*k);k=f+56|0;g[b>>3]=n;a[k>>2]=a[b>>2];a[k+4>>2]=a[b+4>>2];f=f+64|0;g[b>>3]=e;a[f>>2]=a[b>>2];a[f+4>>2]=a[b+4>>2];m[a[i>>2]+81|0]=1}}i=s+208|0;if(1<=(a[i>>2]|0)){s=s+212|0;for(f=1;!(Rk(a[a[s>>2]+(f<<2)>>2]),f=f+1|0,(f|0)>(a[i>>2]|0));){}}}function Qk(s){if((a[s+32>>2]|0)!=(s|0)){var i=s+48|0,f=a[i>>2];if(0!=(f|0)&&0==m[f+81|0]<<24>>24){var e=m[s+283|0];if(0==(e&1)<<24>>24){var n=s+92|0,n=(a[b>>2]=a[n>>2],a[b+4>>2]=a[n+4>>2],g[b>>3]),k=s+60|0,n=(a[b>>2]=a[k>>2],a[b+4>>2]=a[k+4>>2],g[b>>3])+.5*n,k=s+84|0}else{n=s+124|0,n=(a[b>>2]=a[n>>2],a[b+4>>2]=a[n+4>>2],g[b>>3]),k=s+76|0,n=(a[b>>2]=a[k>>2],a[b+4>>2]=a[k+4>>2],g[b>>3])-.5*n,k=s+116|0}k=(a[b>>2]=a[k>>2],a[b+4>>2]=a[k+4>>2],g[b>>3]);e=e<<24>>24;if(0==(e&4|0)){var j=s+52|0,j=(a[b>>2]=a[j>>2],a[b+4>>2]=a[j+4>>2],g[b>>3]);0==(e&2|0)?(e=s+68|0,e=.5*(j+(a[b>>2]=a[e>>2],a[b+4>>2]=a[e+4>>2],g[b>>3]))):e=j+.5*k}else{e=s+68|0,e=(a[b>>2]=a[e>>2],a[b+4>>2]=a[e+4>>2],g[b>>3])-.5*k}k=f+56|0;g[b>>3]=e;a[k>>2]=a[b>>2];a[k+4>>2]=a[b+4>>2];f=f+64|0;g[b>>3]=n;a[f>>2]=a[b>>2];a[f+4>>2]=a[b+4>>2];m[a[i>>2]+81|0]=1}}i=s+208|0;if(1<=(a[i>>2]|0)){s=s+212|0;for(f=1;!(Qk(a[a[s>>2]+(f<<2)>>2]),f=f+1|0,(f|0)>(a[i>>2]|0));){}}}function mq(s){var i,f,e,n=h;h=h+32|0;var k=n+16;if(0==(a[b>>2]=a[1347606],a[b+4>>2]=a[1347607],g[b>>3])){if(!(0!=(a[b>>2]=a[1347608],a[b+4>>2]=a[1347609],g[b>>3])|0!=(a[1347604]|0))){h=n;return}}var j=s+20|0,c=wa(a[j>>2]);a:do{if(0!=(c|0)){e=n>>2;f=k>>2;for(var d=s+28|0,p=c;;){0!=(a[1347604]|0)&&rk(p,0);var r=i=p+32|0,m=p+40|0;kd(n,(a[b>>2]=a[r>>2],a[b+4>>2]=a[r+4>>2],g[b>>3]),(a[b>>2]=a[m>>2],a[b+4>>2]=a[m+4>>2],g[b>>3]));i>>=2;a[i]=a[e];a[i+1]=a[e+1];a[i+2]=a[e+2];a[i+3]=a[e+3];r=a[p+124>>2];0!=(r|0)&&(m=r+56|0,i=m>>2,r=r+64|0,kd(k,(a[b>>2]=a[m>>2],a[b+4>>2]=a[m+4>>2],g[b>>3]),(a[b>>2]=a[r>>2],a[b+4>>2]=a[r+4>>2],g[b>>3])),a[i]=a[f],a[i+1]=a[f+1],a[i+2]=a[f+2],a[i+3]=a[f+3]);b:do{if(1==(a[1347431]|0)&&(i=Fb(s,p),0!=(i|0))){for(;;){if(nq(i),i=Jb(a[d>>2],i),0==(i|0)){break b}}}}while(0);p=Ba(a[j>>2],p);if(0==(p|0)){break a}}}}while(0);Ok(s,a[s+152>>2]&3);h=n}function Nk(b){var i,f;i=b+172|0;-1<(a[i>>2]|0)&&ba();f=a[1347424];a[i>>2]=f;a[1347424]=f+1|0;a[a[1347425]+(f<<2)>>2]=b;f=b+16|0;i=a[f>>2];if(0==m[i+163|0]<<24>>24){var e=a[1347422];a[1347422]=e+1|0;a[a[1347423]+(e<<2)>>2]=i}i=b+12|0;e=a[i>>2];if(0==m[e+163|0]<<24>>24){var n=a[1347422];a[1347422]=n+1|0;a[a[1347423]+(n<<2)>>2]=e}e=a[f>>2];m[e+163|0]=1;f=(e+276|0)>>2;n=a[f];a[f]=n+1|0;var k=e+272|0;a[a[k>>2]+(n<<2)>>2]=b;a[a[k>>2]+(a[f]<<2)>>2]=0;0==(a[a[e+184>>2]+(a[f]-1<<2)>>2]|0)&&ba();f=a[i>>2];m[f+163|0]=1;i=(f+268|0)>>2;e=a[i];a[i]=e+1|0;n=f+264|0;a[a[n>>2]+(e<<2)>>2]=b;a[a[n>>2]+(a[i]<<2)>>2]=0;0==(a[a[f+176>>2]+(a[i]-1<<2)>>2]|0)&&ba()}function nq(s){var i,f,e,n,k,j,c,d,p,r,q;f=s>>2;var u=h;h=h+112|0;var v=u+16,t=u+32;k=u+48;n=u+64;e=u+80;i=u+96;j=(s+24|0)>>2;var w=a[j];if(0==(w|0)){if(0!=m[5391452]<<24>>24&&6==m[s+124|0]<<24>>24){h=u;return}i=a[a[f+3]+12>>2];W(1,5355284,(l=h,h=h+8|0,a[l>>2]=a[a[f+4]+12>>2],a[l+4>>2]=i,l))}else{a:do{if(0<(a[w+4>>2]|0)){q=t>>2;r=v>>2;var s=u>>2,y=0;for(c=w;;){c=a[c>>2]>>2;d=a[((48*y&-1)>>2)+c];var A=a[((48*y&-1)+4>>2)+c],C=a[((48*y&-1)+8>>2)+c];c=a[((48*y&-1)+12>>2)+c];b:do{if(0<(A|0)){for(var F=0;;){p=(F<<4)+d|0;var N=p|0,Fa=(F<<4)+d+8|0;kd(u,(a[b>>2]=a[N>>2],a[b+4>>2]=a[N+4>>2],g[b>>3]),(a[b>>2]=a[Fa>>2],a[b+4>>2]=a[Fa+4>>2],g[b>>3]));p>>=2;a[p]=a[s];a[p+1]=a[s+1];a[p+2]=a[s+2];a[p+3]=a[s+3];F=F+1|0;if((F|0)==(A|0)){break b}}}}while(0);0!=(C|0)&&(C=a[a[j]>>2],d=C+(48*y&-1)+16|0,A=d|0,C=C+(48*y&-1)+24|0,kd(v,(a[b>>2]=a[A>>2],a[b+4>>2]=a[A+4>>2],g[b>>3]),(a[b>>2]=a[C>>2],a[b+4>>2]=a[C+4>>2],g[b>>3])),d>>=2,a[d]=a[r],a[d+1]=a[r+1],a[d+2]=a[r+2],a[d+3]=a[r+3]);0!=(c|0)&&(A=a[a[j]>>2],c=A+(48*y&-1)+32|0,d=c|0,A=A+(48*y&-1)+40|0,kd(t,(a[b>>2]=a[d>>2],a[b+4>>2]=a[d+4>>2],g[b>>3]),(a[b>>2]=a[A>>2],a[b+4>>2]=a[A+4>>2],g[b>>3])),c>>=2,a[c]=a[q],a[c+1]=a[q+1],a[c+2]=a[q+2],a[c+3]=a[q+3]);y=y+1|0;c=a[j];if((y|0)>=(a[c+4>>2]|0)){break a}}}}while(0);t=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]=a[b+4>>2];f=d+24|0;g[b>>3]=e;a[f>>2]=a[b>>2];a[f+4>>2]=a[b+4>>2];if(-1==(Tk(r,d|0,m)|0)){return h=r,0}do{if(0==(j|0)){e=a[n>>2];m=a[1315584];(e|0)>(a[1315585]|0)&&(m=0==(m|0)?Xa(e<<5):La(m,e<<5),a[1315584]=m,a[1315585]=e);a:do{if(0<(e|0)){d=a[c>>2];for(f=0;;){if(s=((f<<5)+m|0)>>2,i=((f<<4)+d|0)>>2,a[s]=a[i],a[s+1]=a[i+1],a[s+2]=a[i+2],a[s+3]=a[i+3],i=f+1|0,s=((f<<5)+m+16|0)>>2,f=(((i|0)%(e|0)<<4)+d|0)>>2,a[s]=a[f],a[s+1]=a[f+1],a[s+2]=a[f+2],a[s+3]=a[f+3],(i|0)<(e|0)){f=i}else{break a}}}}while(0);d=v>>2;a[d]=0;a[d+1]=0;a[d+2]=0;a[d+3]=0;a[d+4]=0;a[d+5]=0;a[d+6]=0;a[d+7]=0;if(-1==(oq(m,e,a[p],a[p+1],v|0,l)|0)){return k=0,h=r,k}}else{Uk(a[p],a[p+1],l)}}while(0);j=a[l+4>>2];pq(j);p=a[1312047];a:do{if(0<(j|0)){v=a[l>>2];for(e=0;;){if(n=((e<<4)+p|0)>>2,c=((e<<4)+v|0)>>2,a[n]=a[c],a[n+1]=a[c+1],a[n+2]=a[c+2],a[n+3]=a[c+3],c=e+1|0,(c|0)<(j|0)){e=c}else{var w=p;break a}}}else{w=p}}while(0);a[k>>2]=j;h=r;return w}function pq(b){var i=h,f=a[1313372];(f|0)<(b|0)&&(b=f+(b+300)-(b|0)%300|0,f=La(a[1312047],b<<4),a[1312047]=f,0==(f|0)&&(W(1,5355248,(l=h,h=h+1|0,h=h+3>>2<<2,a[l>>2]=0,l)),ba()),a[1313372]=b);h=i}function Ie(s,i,f){var e,n,k,j,c,d,p,r,q,u,v,t,w,y,A,C,F,N,Fa,B,ka,z,D,E,L,K,T=0,U=h;h=h+88|0;var H=U+8;K=H>>2;var O=U+16,S=U+24,X=U+56;a[1312951]=a[1312951]+1|0;var Ga=a[s+80>>2];a[1312952]=a[1312952]+Ga|0;var Mb=a[s+88>>2];for(L=Mb>>2;;){if(0==(Mb|0)){T=1216;break}if(0==m[Mb+124|0]<<24>>24){break}Mb=a[L+32];L=Mb>>2}1216==T&&(W(1,5351024,(l=h,h=h+1|0,h=h+3>>2<<2,a[l>>2]=0,l)),ba());var V=a[s+84>>2];qq(Ga,V,s);var aa=Ga<<3;if((aa|0)>(a[1312364]|0)){var I=a[1312363],$=0==(I|0)?Xa(Ga<<7):La(I,Ga<<7);a[1312363]=$;a[1312364]=aa}a:do{if(1<(Ga|0)){var ca=V+8|0,da=(a[b>>2]=a[ca>>2],a[b+4>>2]=a[ca+4>>2],g[b>>3]),ga=V+40|0;if(da>(a[b>>2]=a[ga>>2],a[b+4>>2]=a[ga+4>>2],g[b>>3])){if(0<(Ga|0)){for(var Oa=0,Ua=da;;){E=((Oa<<5)+V+24|0)>>2;var P=(a[b>>2]=a[E],a[b+4>>2]=a[E+1],g[b>>3]),J=(Oa<<5)+V+8|0;g[b>>3]=-1*Ua;a[E]=a[b>>2];a[E+1]=a[b+4>>2];g[b>>3]=-P;a[J>>2]=a[b>>2];a[J+4>>2]=a[b+4>>2];var R=Oa+1|0;if((R|0)==(Ga|0)){M=1;break a}var ma=(R<<5)+V+8|0,Oa=R,Ua=(a[b>>2]=a[ma>>2],a[b+4>>2]=a[ma+4>>2],g[b>>3])}}else{M=1}}else{var M=0}}else{M=0}}while(0);(a[L+4]|0)==(a[L+3]|0)&&ba();var Q=Ga-1|0,$a=a[1312363],gc=0,ec=0;a:for(;;){if((ec|0)>=(Ga|0)){var Db=gc,za=Q;break}if(0<(ec|0)){var Z=(ec<<5)+V+8|0,Da=(ec-1<<5)+V+8|0,qa=(a[b>>2]=a[Z>>2],a[b+4>>2]=a[Z+4>>2],g[b>>3])>(a[b>>2]=a[Da>>2],a[b+4>>2]=a[Da+4>>2],g[b>>3])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+1]=a[b+4>>2];var Ib=Cc+1|0;if((Ib|0)==(Ga|0)){break b}else{Cc=Ib}}}}while(0);if(0<(Db|0)){for(var yb=0;;){v=((yb<<4)+$a+8|0)>>2;var gd=-1*(a[b>>2]=a[v],a[b+4>>2]=a[v+1],g[b>>3]);g[b>>3]=gd;a[v]=a[b>>2];a[v+1]=a[b+4>>2];var bd=yb+1|0;if((bd|0)==(Db|0)){break a}else{yb=bd}}}}}while(0);var Ze=0<(Ga|0);a:do{if(Ze){for(var Qc=0;;){var Fd=(Qc<<5)+V|0;g[b>>3]=2147483647;a[Fd>>2]=a[b>>2];a[Fd+4>>2]=a[b+4>>2];var Uc=(Qc<<5)+V+16|0;g[b>>3]=-2147483648;a[Uc>>2]=a[b>>2];a[Uc+4>>2]=a[b+4>>2];var ed=Qc+1|0;if((ed|0)==(Ga|0)){break a}else{Qc=ed}}}}while(0);a[U>>2]=$a;var Zc=U+4|0;a[Zc>>2]=Db;var cd=s|0,$c=(a[b>>2]=a[cd>>2],a[b+4>>2]=a[cd+4>>2],g[b>>3]),Vc=S|0,Pb=S|0;g[b>>3]=$c;a[Pb>>2]=a[b>>2];a[Pb+4>>2]=a[b+4>>2];var Ub=s+8|0,Sb=(a[b>>2]=a[Ub>>2],a[b+4>>2]=a[Ub+4>>2],g[b>>3]),ge=S+8|0;g[b>>3]=Sb;a[ge>>2]=a[b>>2];a[ge+4>>2]=a[b+4>>2];var Yb=s+40|0,se=(a[b>>2]=a[Yb>>2],a[b+4>>2]=a[Yb+4>>2],g[b>>3]),cc=S+16|0;g[b>>3]=se;a[cc>>2]=a[b>>2];a[cc+4>>2]=a[b+4>>2];var bc=s+48|0,fd=(a[b>>2]=a[bc>>2],a[b+4>>2]=a[bc+4>>2],g[b>>3]),Qb=S+24|0;g[b>>3]=fd;a[Qb>>2]=a[b>>2];a[Qb+4>>2]=a[b+4>>2];-1==(Tk(U,Vc,H)|0)&&ba();do{if(0==(f|0)){var hd=a[Zc>>2];if((hd|0)>(a[1315585]|0)){var Ob=a[1315584],oc=0==(Ob|0)?Xa(hd<<5):La(Ob,hd<<5);a[1315584]=oc;a[1315585]=hd}a:do{if(0<(hd|0)){for(var nc=a[1315584],Xb=a[1312363],rd=0;;){u=((rd<<5)+nc|0)>>2;q=((rd<<4)+Xb|0)>>2;a[u]=a[q];a[u+1]=a[q+1];a[u+2]=a[q+2];a[u+3]=a[q+3];var ac=rd+1|0;r=((rd<<5)+nc+16|0)>>2;p=(((ac|0)%(hd|0)<<4)+Xb|0)>>2;a[r]=a[p];a[r+1]=a[p+1];a[r+2]=a[p+2];a[r+3]=a[p+3];if((ac|0)<(hd|0)){rd=ac}else{break a}}}}while(0);if(0==m[s+29|0]<<24>>24){d=X>>2,a[d]=0,a[d+1]=0,a[d+2]=0,a[d+3]=0}else{var dc=s+16|0,qc=(a[b>>2]=a[dc>>2],a[b+4>>2]=a[dc+4>>2],g[b>>3]),Gd=X|0;g[b>>3]=Math.cos(qc);a[Gd>>2]=a[b>>2];a[Gd+4>>2]=a[b+4>>2];var Ke=X+8|0;g[b>>3]=Math.sin(qc);a[Ke>>2]=a[b>>2];a[Ke+4>>2]=a[b+4>>2]}if(0==m[s+69|0]<<24>>24){c=(X+16|0)>>2,a[c]=0,a[c+1]=0,a[c+2]=0,a[c+3]=0}else{var mc=s+56|0,Vb=(a[b>>2]=a[mc>>2],a[b+4>>2]=a[mc+4>>2],g[b>>3]),ud=X+16|0;g[b>>3]=-Math.cos(Vb);a[ud>>2]=a[b>>2];a[ud+4>>2]=a[b+4>>2];var id=X+24|0;g[b>>3]=-Math.sin(Vb);a[id>>2]=a[b>>2];a[id+4>>2]=a[b+4>>2]}-1==(oq(a[1315584],hd,a[K],a[K+1],X|0,O)|0)&&ba()}else{Uk(a[K],a[K+1],O)}}while(0);var xe=a[O+4>>2];pq(xe);a:do{if(Ze){for(var yd=0;;){var Kd=(yd<<5)+V|0;g[b>>3]=2147483647;a[Kd>>2]=a[b>>2];a[Kd+4>>2]=a[b+4>>2];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):1==(s|0)?(g[b>>3]=h,a[e]=a[b>>2],a[e+1]=a[b+4>>2],g[b>>3]=f,a[n]=a[b>>2],a[n+1]=a[b+4>>2],g[b>>3]=d,a[c]=a[b>>2],a[c+1]=a[b+4>>2]):2==(s|0)?(g[b>>3]=d,a[e]=a[b>>2],a[e+1]=a[b+4>>2],g[b>>3]=f,a[n]=a[b>>2],a[n+1]=a[b+4>>2],g[b>>3]=i,a[c]=a[b>>2],a[c+1]=a[b+4>>2]):3==(s|0)?(g[b>>3]=d,a[e]=a[b>>2],a[e+1]=a[b+4>>2],g[b>>3]=h,a[n]=a[b>>2],a[n+1]=a[b+4>>2],g[b>>3]=f,a[c]=a[b>>2],a[c+1]=a[b+4>>2]):4==(s|0)?(g[b>>3]=i,a[e]=a[b>>2],a[e+1]=a[b+4>>2],g[b>>3]=d,a[n]=a[b>>2],a[n+1]=a[b+4>>2],g[b>>3]=f,a[c]=a[b>>2],a[c+1]=a[b+4>>2]):5==(s|0)&&(g[b>>3]=f,a[e]=a[b>>2],a[e+1]=a[b+4>>2],g[b>>3]=d,a[n]=a[b>>2],a[n+1]=a[b+4>>2],g[b>>3]=h,a[c]=a[b>>2],a[c+1]=a[b+4>>2])}else{g[b>>3]=f,a[e]=a[b>>2],a[e+1]=a[b+4>>2],g[b>>3]=f,a[n]=a[b>>2],a[n+1]=a[b+4>>2],g[b>>3]=f,a[c]=a[b>>2],a[c+1]=a[b+4>>2]}}function Tq(s,i,f){var e,n,c,d,G,x,p,r,q,u,v,t,w,y,A,C,F=i>>2,N=0,B=h;h=h+108|0;var z=B+12;C=z>>2;var D=B+20;A=D>>2;var H=B+28;y=H>>2;var I=B+36;w=I>>2;var Ca=B+44;t=Ca>>2;var L=B+52;v=L>>2;var K=B+60;u=K>>2;var T=B+68;q=T>>2;var U=B+76;r=U>>2;var J=B+84;p=J>>2;var O=B+92;x=O>>2;var S=B+96;G=S>>2;var X=B+100;d=X>>2;var Ga=B+104;c=Ga>>2;a[F+8]=f;for(var M=s;;){if(32==m[M]<<24>>24){M=M+1|0}else{break}}a[c]=255;var V=m[M];if(35==V<<24>>24){if(2<(Ld(M,5336672,(l=h,h=h+16|0,a[l>>2]=O,a[l+4>>2]=S,a[l+8>>2]=X,a[l+12>>2]=Ga,l))|0)){if(1==(f|0)){m[i]=a[x]&255;m[i+1|0]=a[G]&255;m[i+2|0]=a[d]&255;m[i+3|0]=a[c]&255;var aa=0}else{if(3==(f|0)){var Q=(a[x]>>>0)/255;g[b>>3]=Q;a[w]=a[b>>2];a[w+1]=a[b+4>>2];var $=(a[G]>>>0)/255;g[b>>3]=$;a[t]=a[b>>2];a[t+1]=a[b+4>>2];var ca=(a[d]>>>0)/255;g[b>>3]=ca;a[v]=a[b>>2];a[v+1]=a[b+4>>2];il(Q,$,ca,K,T,U,J);m[i]=255*((a[b>>2]=a[u],a[b+4>>2]=a[u+1],g[b>>3])&-1)&255;m[i+1|0]=255*((a[b>>2]=a[q],a[b+4>>2]=a[q+1],g[b>>3])&-1)&255;m[i+2|0]=255*((a[b>>2]=a[r],a[b+4>>2]=a[r+1],g[b>>3])&-1)&255;m[i+3|0]=255*((a[b>>2]=a[p],a[b+4>>2]=a[p+1],g[b>>3])&-1)&255}else{if(2==(f|0)){a[F]=Math.floor(((65535*a[x]&-1)>>>0)/255),a[i+4>>2]=Math.floor(((65535*a[G]&-1)>>>0)/255),a[F+2]=Math.floor(((65535*a[d]&-1)>>>0)/255),a[i+12>>2]=Math.floor(((65535*a[c]&-1)>>>0)/255)}else{if(4==(f|0)){var da=i|0;g[b>>3]=(a[x]>>>0)/255;a[da>>2]=a[b>>2];a[da+4>>2]=a[b+4>>2];var ga=i+8|0;g[b>>3]=(a[G]>>>0)/255;a[ga>>2]=a[b>>2];a[ga+4>>2]=a[b+4>>2];var Oa=i+16|0;g[b>>3]=(a[d]>>>0)/255;a[Oa>>2]=a[b>>2];a[Oa+4>>2]=a[b+4>>2];var Ua=i+24|0;g[b>>3]=(a[c]>>>0)/255;a[Ua>>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[y+28>>2]=a[G+7];G=d|0;We(G,a[A+28>>2]);i=d+Wa(G)|0;yb=58;m[i]=yb&255;yb>>=8;m[i+1|0]=yb&255;ue(G,t);t=wf(a[s>>2],4,G);0==(t|0)?t=999:(t=a[t+16>>2],a[s+92>>2]=a[t+12>>2],a[s+96>>2]=a[t>>2],t=300);999==(t|0)&&W(0,5383004,(l=h,h=h+4|0,a[l>>2]=G,l));G=a[s+92>>2];if(0!=(G|0)&&(G=a[G>>2],0!=(G|0))){B[G](s,A,y,n)}h=d}}}h=w}function tr(b){var i=h;h=h+64|0;var f=a[1347740];if(0==(f|0)){return h=i,0}a[i+8>>2]=b;b=B[a[f>>2]](f,i,4);h=i;return b}function ur(b){var i=h;0==(b|0)&&sa(5381776,363,5388672,5344740);var f=b+8|0;0==(a[f>>2]|0)&&sa(5381776,364,5388672,5344444);var e=b+20|0,n=a[e>>2];0==(n|0)?(f=qi(a[f>>2]),0==(f|0)?b=1:(n=Qg(f,5353392),a[e>>2]=n,0==(n|0)?(b=Yf(a[fb.d>>2]),W(0,5349260,(l=h,h=h+8|0,a[l>>2]=b,a[l+4>>2]=f,l)),b=0):(e=a[1314040],49<(e|0)?m[b+17|0]=1:a[1314040]=e+1|0,b=1))):(ff(n,0,0),b=1);h=i;return b}function vr(b){if(0!=m[b+17|0]<<24>>24){var b=b+20|0,i=a[b>>2];0!=(i|0)&&(Xf(i),a[b>>2]=0)}}function Ik(s,i,f){0!=(f|0)&&0!=m[f]<<24>>24?(i=a[i+44>>2]+24|0,i=(a[b>>2]=a[i>>2],a[b+4>>2]=a[i+4>>2],g[b>>3]),i=1>i?96:i,sr(s,wr(f),i,i)):(a[s>>2]=-1,a[s+4>>2]=-1)}function wr(b){var i=h;0==(a[1347740]|0)&&(a[1347740]=pc(5390888,5389092));var f=tr(b);if(0==(f|0)){f=Z(64);if(0==(f|0)){return h=i,0}var e=f+8|0;a[e>>2]=b;if(0==ur(f)<<24>>24){return h=i,0}b=xr(f);if(4==(b|0)){yr(f)}else{if(3==(b|0)){e=h;h=h+8|0;var n=e+4;a[f+48>>2]=0;b=(f+20|0)>>2;ff(a[b],16,0);0!=Te(a[b],4,e)<<24>>24&&0!=Te(a[b],4,n)<<24>>24&&(a[f+40>>2]=a[e>>2],a[f+44>>2]=a[n>>2]);h=e}else{if(6==(b|0)){var b=f>>2,c=0,e=h;h=h+1040|0;var d=e+1024,g=e+1028,n=e+1032,x=e+1036;a[b+12]=72;var p=f+20|0;ff(a[p>>2],0,0);for(var m=e|0;;){if(0==(Tf(m,1024,a[p>>2])|0)){c=1610;break}var q=bi(m,5371540);if(0!=(q|0)&&4==(Ld(q,5369348,(l=h,h=h+16|0,a[l>>2]=d,a[l+4>>2]=g,a[l+8>>2]=n,a[l+12>>2]=x,l))|0)){break}}1610!=c&&(c=a[d>>2],a[b+8]=c,g=a[g>>2],a[b+9]=g,a[b+10]=a[n>>2]-c|0,a[b+11]=a[x>>2]-g|0);h=e}else{if(0==(b|0)){return b=a[e>>2],e=jk(b),a[f+52>>2]=e,0==(e|0)&&W(0,5345788,(l=h,h=h+4|0,a[l>>2]=b,l)),H(f),h=i,0}2==(b|0)?(e=h,h=h+8|0,n=e+4,a[f+48>>2]=0,b=(f+20|0)>>2,ff(a[b],6,0),0!=ug(a[b],e)<<24>>24&&0!=ug(a[b],n)<<24>>24&&(a[f+40>>2]=a[e>>2],a[f+44>>2]=a[n>>2]),h=e):1==(b|0)?(e=h,h=h+16|0,n=e+4,x=e+8,g=e+12,a[f+48>>2]=0,b=(f+20|0)>>2,ff(a[b],16,0),0!=ug(a[b],e)<<24>>24&&0!=ug(a[b],n)<<24>>24&&0!=ug(a[b],x)<<24>>24&&0!=ug(a[b],g)<<24>>24&&(a[f+40>>2]=a[e>>2]<<16|a[n>>2],a[f+44>>2]=a[x>>2]<<16|a[g>>2]),h=e):8==(b|0)&&zr(f)}}}b=a[1347740];B[a[b>>2]](b,f,1)}vr(f);h=i;return f}function xr(b){var i=0,f=h;h=h+220|0;var e=f+20,n=b+20|0,c=a[n>>2];a:do{if(0!=(c|0)){var d=f|0;if(20==(Tn(d,1,20,c)|0)){var c=b+28|0,g=b+24|0,e=e|0,x=0;b:for(;;){if(8<=x>>>0){break a}c:do{if(0==(ie(d,a[(x<<4)+5254400>>2],a[(x<<4)+5254404>>2])|0)){a[c>>2]=a[(x<<4)+5254412>>2];var p=a[(x<<4)+5254408>>2];a[g>>2]=p;if(7!=(x|0)){var m=p,i=1550;break b}for(;;){if(0==(Tf(e,200,a[n>>2])|0)){break c}if(0==(ie(e,5367272,4)|0)){break b}}}}while(0);x=x+1|0}if(1550==i){return h=f,m}a[c>>2]=5362232;m=a[g>>2]=8;h=f;return m}}}while(0);a[b+28>>2]=5363796;a[b+24>>2]=0;h=f;return 0}function yr(b){var i=b>>2,f=0,e=h;h=h+20|0;var n=e+4,c=e+8,d=e+12,g=e+16;a[i+12]=0;for(b=(b+20|0)>>2;;){if(0==Te(a[b],1,e)<<24>>24){f=1603;break}var x=a[e>>2];if(255!=(x|0)&&0==(Dc(5254528,x)|0)){if(192==(x|0)){f=1582;break}var p=a[b];if(194==(x|0)){f=1587;break}if(0==Te(p,2,n)<<24>>24){f=1602;break}ff(a[b],a[n>>2]-2|0,1)}}1582==f?(0!=Te(a[b],3,g)<<24>>24&&0!=Te(a[b],2,c)<<24>>24&&0!=Te(a[b],2,d)<<24>>24&&(a[i+11]=a[c>>2],a[i+10]=a[d>>2]),h=e):1587==f?(0!=Te(p,3,g)<<24>>24&&0!=Te(a[b],2,c)<<24>>24&&0!=Te(a[b],2,d)<<24>>24&&(a[i+11]=a[c>>2],a[i+10]=a[d>>2]),h=e):1602==f?h=e:1603==f&&(h=e)}function Ar(a){var b=1-a;return 3*a*b*b}function Ae(s,i,f,e){var n=s|0;g[b>>3]=i*e;a[n>>2]=a[b>>2];a[n+4>>2]=a[b+4>>2];s=s+8|0;g[b>>3]=f*e;a[s>>2]=a[b>>2];a[s+4>>2]=a[b+4>>2]}function zr(s){var i,f=0,e=h;h=h+220|0;i=e>>2;var n=s+20|0,c=e+20|0;ff(a[n>>2],-Wa(c)|0,1);var d=e+8|0,G=0,x=0,p=0,r=0;a:for(;;){if(0==(Tf(c,200,a[n>>2])|0)){f=1628;break}if(!(0==r<<24>>24|0==G<<24>>24)){f=1627;break}for(var q=G,u=x,v=p,t=fe(c,5375156,dd),w=r;;){if(0==(t|0)){G=q;x=u;p=v;r=w;continue a}if(62==m[t+(Wa(t)-1)|0]<<24>>24){G=q;x=u;p=v;r=w;continue a}if(2==(Ld(t,5339688,(l=h,h=h+8|0,a[l>>2]=e,a[l+4>>2]=d,l))|0)){if(u=vl((a[b>>2]=a[i],a[b+4>>2]=a[i+1],g[b>>3]),d),0==q<<24>>24){w=1}else{G=q;x=u;p=v;r=1;continue a}}if(2==(Ld(t,5336424,(l=h,h=h+8|0,a[l>>2]=e,a[l+4>>2]=d,l))|0)){if(v=vl((a[b>>2]=a[i],a[b+4>>2]=a[i+1],g[b>>3]),d),0==w<<24>>24){q=1}else{G=1;x=u;p=v;r=w;continue a}}t=fe(0,5375156,dd)}}1628==f?(a[(s+48|0)>>2]=72,a[(s+40|0)>>2]=x,a[(s+44|0)>>2]=p,h=e):1627==f&&(a[(s+48|0)>>2]=72,a[(s+40|0)>>2]=x,a[(s+44|0)>>2]=p,h=e)}function vl(a,b){if(0==(ea(b,5337312)|0)){var f=72*a;return(0>f?f-.5:f+.5)&-1}if(0==(ea(b,5387408)|0)){return f=72*a/96,(0>f?f-.5:f+.5)&-1}if(0==(ea(b,5384652)|0)){return f=72*a/6,(0>f?f-.5:f+.5)&-1}if(0!=(ea(b,5381724)|0)&&0!=(ea(b,5344764)|0)){if(0==(ea(b,5376528)|0)){return f=28.346456664*a,(0>f?f-.5:f+.5)&-1}if(0!=(ea(b,5374136)|0)){return 0}f=2.8346456663999997*a;return(0>f?f-.5:f+.5)&-1}return(0>a?a-.5:a+.5)&-1}function Te(b,i,f){for(var e=0,n=a[f>>2]=0;;){if(n>>>0>=i>>>0){var c=1,e=1673;break}var d=Sf(b);if(0!=(Number(Q.b[b]&&Q.b[b].f)|0)){c=0;e=1674;break}a[f>>2]=a[f>>2]<<8|d;n=n+1|0}if(1674==e||1673==e){return c}}function ug(b,i){for(var f=0,e=a[i>>2]=0;;){if(2<=e>>>0){var n=1,f=1680;break}var c=Sf(b);if(0!=(Number(Q.b[b]&&Q.b[b].f)|0)){n=0;f=1681;break}a[i>>2]|=c<<(e<<3);e=e+1|0}if(1680==f||1681==f){return n}}function oq(s,i,f,e,n,c){var d,G,x,p,m,q=h;h=h+32|0;d=q+16;m=(n|0)>>2;p=(n+8|0)>>2;uh(q,(a[b>>2]=a[m],a[b+4>>2]=a[m+1],g[b>>3]),(a[b>>2]=a[p],a[b+4>>2]=a[p+1],g[b>>3]));G=n>>2;x=q>>2;a[G]=a[x];a[G+1]=a[x+1];a[G+2]=a[x+2];a[G+3]=a[x+3];G=n+16|0;x=(G|0)>>2;n=(n+24|0)>>2;uh(d,(a[b>>2]=a[x],a[b+4>>2]=a[x+1],g[b>>3]),(a[b>>2]=a[n],a[b+4>>2]=a[n+1],g[b>>3]));G>>=2;d>>=2;a[G]=a[d];a[G+1]=a[d+1];a[G+2]=a[d+2];a[G+3]=a[d+3];a[1312862]=0;wl(4);d=a[1312862];a[1312862]=d+1|0;G=((d<<4)+a[1312859]|0)>>2;d=f>>2;a[G]=a[d];a[G+1]=a[d+1];a[G+2]=a[d+2];a[G+3]=a[d+3];m=(a[b>>2]=a[m],a[b+4>>2]=a[m+1],g[b>>3]);p=(a[b>>2]=a[p],a[b+4>>2]=a[p+1],g[b>>3]);if(-1==(Oi(s,i,f,e,m,p,(a[b>>2]=a[x],a[b+4>>2]=a[x+1],g[b>>3]),(a[b>>2]=a[n],a[b+4>>2]=a[n+1],g[b>>3]))|0)){return h=q,-1}a[c+4>>2]=a[1312862];a[c>>2]=a[1312859];h=q;return 0}function uh(s,i,f){var e=i*i+f*f;1e-6
k)){p=c|0;g[b>>3]=r;a[p>>2]=a[b>>2];a[p+4>>2]=a[b+4>>2];c=c+8|0;g[b>>3]=v;a[c>>2]=a[b>>2];a[c+4>>2]=a[b+4>>2];h=j;return}}if(u