Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@calumk

calumk/index.php Secret

Created June 29, 2015 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calumk/3a37c8be5fe1451d9270 to your computer and use it in GitHub Desktop.
Save calumk/3a37c8be5fe1451d9270 to your computer and use it in GitHub Desktop.
Inline Python
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js" type="text/javascript"></script>
<script src="skulpt.min.js" type="text/javascript"></script>
<script src="skulpt-stdlib.js" type="text/javascript"></script>
<script src="script.js" type="text/javascript"></script>
<style>
python{
display: none;
}
</style>
</head>
<body>
<python data-output="thediv">
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
age = raw_input('How old are you?\nEG: 21')
print 'Ahh ok, you are %s.' % age
</python>
<pre id="thediv">
hello world
</pre>
</body>
</html>
function builtinRead(x) {
if (Sk.builtinFiles === undefined || Sk.builtinFiles["files"][x] === undefined)
throw "File not found: '" + x + "'";
return Sk.builtinFiles["files"][x];
}
var outputDiv = null;
function outil(text) {
var mypre = document.getElementById(outputDiv);
mypre.innerHTML = mypre.innerHTML + text;
}
$(function() {
var a = document.getElementsByTagName("python");
for(i = 0; i < a.length; ++i){
var prog = a[i].innerHTML;
outputDiv = $(a[i]).data('output');
Sk.configure({output:outil, read:builtinRead});
try {
eval(Sk.importMainWithBody("<stdin>",false,prog));
}
catch(e) {
alert(e.toString())
}
}
});
Sk.builtinFiles={"files": {"src/lib/pythonds/trees/binheap.py": "# Bradley N. Miller, David L. Ranum\n# Introduction to Data Structures and Algorithms in Python\n# Copyright 2005\n# \n\n# this heap takes key value pairs, we will assume that the keys are integers\nclass BinHeap:\n def __init__(self):\n self.heapList = [0]\n self.currentSize = 0\n\n\n def buildHeap(self,alist):\n i = len(alist) // 2\n self.currentSize = len(alist)\n self.heapList = [0] + alist[:]\n print(len(self.heapList), i)\n while (i > 0):\n print(self.heapList, i)\n self.percDown(i)\n i = i - 1\n print(self.heapList,i)\n \n def percDown(self,i):\n while (i * 2) <= self.currentSize:\n mc = self.minChild(i)\n if self.heapList[i] > self.heapList[mc]:\n tmp = self.heapList[i]\n self.heapList[i] = self.heapList[mc]\n self.heapList[mc] = tmp\n i = mc\n \n def minChild(self,i):\n if i * 2 + 1 > self.currentSize:\n return i * 2\n else:\n if self.heapList[i * 2] < self.heapList[i * 2 + 1]:\n return i * 2\n else:\n return i * 2 + 1\n\n def percUp(self,i):\n while i // 2 > 0:\n if self.heapList[i] < self.heapList[i//2]:\n tmp = self.heapList[i // 2]\n self.heapList[i // 2] = self.heapList[i]\n self.heapList[i] = tmp\n i = i // 2\n \n def insert(self,k):\n self.heapList.append(k)\n self.currentSize = self.currentSize + 1\n self.percUp(self.currentSize)\n\n def delMin(self):\n retval = self.heapList[1]\n self.heapList[1] = self.heapList[self.currentSize]\n self.currentSize = self.currentSize - 1\n self.heapList.pop()\n self.percDown(1)\n return retval\n \n def isEmpty(self):\n if currentSize == 0:\n return True\n else:\n return False\n", "src/lib/pythonds/basic/stack.py": "# Bradley N. Miller, David L. Ranum\n# Introduction to Data Structures and Algorithms in Python\n# Copyright 2005\n# \n#stack.py\r\n\r\nclass Stack:\r\n def __init__(self):\r\n self.items = []\r\n\r\n def isEmpty(self):\r\n return self.items == []\r\n\r\n def push(self, item):\r\n self.items.append(item)\r\n\r\n def pop(self):\r\n return self.items.pop()\r\n\r\n def peek(self):\r\n return self.items[len(self.items)-1]\r\n\r\n def size(self):\r\n return len(self.items)\r\n\r\n", "src/lib/pythonds/trees/bst.py": "#!/bin/env python3.1\n# Bradley N. Miller, David L. Ranum\n# Introduction to Data Structures and Algorithms in Python\n# Copyright 2005, 2010\n# \n\nclass BinarySearchTree:\n '''\n Author: Brad Miller\n Date: 1/15/2005\n Description: Imlement a binary search tree with the following interface\n functions: \n __contains__(y) <==> y in x\n __getitem__(y) <==> x[y]\n __init__()\n __len__() <==> len(x)\n __setitem__(k,v) <==> x[k] = v\n clear()\n get(k)\n items() \n keys() \n values()\n put(k,v)\n in\n del <==> \n '''\n\n def __init__(self):\n self.root = None\n self.size = 0\n \n def put(self,key,val):\n if self.root:\n self._put(key,val,self.root)\n else:\n self.root = TreeNode(key,val)\n self.size = self.size + 1\n\n def _put(self,key,val,currentNode):\n if key < currentNode.key:\n if currentNode.hasLeftChild():\n self._put(key,val,currentNode.leftChild)\n else:\n currentNode.leftChild = TreeNode(key,val,parent=currentNode)\n else:\n if currentNode.hasRightChild():\n self._put(key,val,currentNode.rightChild)\n else:\n currentNode.rightChild = TreeNode(key,val,parent=currentNode)\n \n def __setitem__(self,k,v):\n self.put(k,v)\n\n def get(self,key):\n if self.root:\n res = self._get(key,self.root)\n if res:\n return res.payload\n else:\n return None\n else:\n return None\n \n def _get(self,key,currentNode):\n if not currentNode:\n return None\n elif currentNode.key == key:\n return currentNode\n elif key < currentNode.key:\n return self._get(key,currentNode.leftChild)\n else:\n return self._get(key,currentNode.rightChild)\n \n \n def __getitem__(self,key):\n res = self.get(key)\n if res:\n return res\n else:\n raise KeyError('Error, key not in tree')\n \n\n def __contains__(self,key):\n if self._get(key,self.root):\n return True\n else:\n return False\n \n def length(self):\n return self.size\n\n def __len__(self):\n return self.size\n\n def __iter__(self):\n return self.root.__iter__()\n \n def delete(self,key):\n if self.size > 1:\n nodeToRemove = self._get(key,self.root)\n if nodeToRemove:\n self.remove(nodeToRemove)\n self.size = self.size-1\n else:\n raise KeyError('Error, key not in tree')\n elif self.size == 1 and self.root.key == key:\n self.root = None\n self.size = self.size - 1\n else:\n raise KeyError('Error, key not in tree')\n\n def __delitem__(self,key):\n self.delete(key)\n \n def remove(self,currentNode):\n if currentNode.isLeaf(): #leaf\n if currentNode == currentNode.parent.leftChild:\n currentNode.parent.leftChild = None\n else:\n currentNode.parent.rightChild = None\n elif currentNode.hasBothChildren(): #interior\n succ = currentNode.findSuccessor()\n succ.spliceOut()\n currentNode.key = succ.key\n currentNode.payload = succ.payload\n else: # this node has one child\n if currentNode.hasLeftChild():\n if currentNode.isLeftChild():\n currentNode.leftChild.parent = currentNode.parent\n currentNode.parent.leftChild = currentNode.leftChild\n elif currentNode.isRightChild():\n currentNode.leftChild.parent = currentNode.parent\n currentNode.parent.rightChild = currentNode.leftChild\n else:\n currentNode.replaceNodeData(currentNode.leftChild.key,\n currentNode.leftChild.payload,\n currentNode.leftChild.leftChild,\n currentNode.leftChild.rightChild)\n else:\n if currentNode.isLeftChild():\n currentNode.rightChild.parent = currentNode.parent\n currentNode.parent.leftChild = currentNode.rightChild\n elif currentNode.isRightChild():\n currentNode.rightChild.parent = currentNode.parent\n currentNode.parent.rightChild = currentNode.rightChild\n else:\n currentNode.replaceNodeData(currentNode.rightChild.key,\n currentNode.rightChild.payload,\n currentNode.rightChild.leftChild,\n currentNode.rightChild.rightChild)\n\n def inorder(self):\n self._inorder(self.root)\n\n def _inorder(self,tree):\n if tree != None:\n self._inorder(tree.leftChild)\n print(tree.key)\n self._inorder(tree.rightChild)\n\n def postorder(self):\n self._postorder(self.root)\n\n def _postorder(self, tree):\n if tree:\n self._postorder(tree.rightChild)\n self._postorder(tree.leftChild)\n print(tree.key) \n\n def preorder(self):\n self._preorder(self,self.root)\n\n def _preorder(self,tree):\n if tree:\n print(tree.key) \n self._preorder(tree.leftChild)\n self._preorder(tree.rightChild)\n\n \nclass TreeNode:\n def __init__(self,key,val,left=None,right=None,parent=None):\n self.key = key\n self.payload = val\n self.leftChild = left\n self.rightChild = right\n self.parent = parent\n self.balanceFactor = 0\n \n def hasLeftChild(self):\n return self.leftChild\n\n def hasRightChild(self):\n return self.rightChild\n \n def isLeftChild(self):\n return self.parent and self.parent.leftChild == self\n\n def isRightChild(self):\n return self.parent and self.parent.rightChild == self\n\n def isRoot(self):\n return not self.parent\n\n def isLeaf(self):\n return not (self.rightChild or self.leftChild)\n\n def hasAnyChildren(self):\n return self.rightChild or self.leftChild\n\n def hasBothChildren(self):\n return self.rightChild and self.leftChild\n \n def replaceNodeData(self,key,value,lc,rc):\n self.key = key\n self.payload = value\n self.leftChild = lc\n self.rightChild = rc\n if self.hasLeftChild():\n self.leftChild.parent = self\n if self.hasRightChild():\n self.rightChild.parent = self\n \n def findSuccessor(self):\n succ = None\n if self.hasRightChild():\n succ = self.rightChild.findMin()\n else:\n if self.parent:\n if self.isLeftChild():\n succ = self.parent\n else:\n self.parent.rightChild = None\n succ = self.parent.findSuccessor()\n self.parent.rightChild = self\n return succ\n\n\n def spliceOut(self):\n if self.isLeaf():\n if self.isLeftChild():\n self.parent.leftChild = None\n else:\n self.parent.rightChild = None\n elif self.hasAnyChildren():\n if self.hasLeftChild():\n if self.isLeftChild():\n self.parent.leftChild = self.leftChild\n else:\n self.parent.rightChild = self.leftChild\n self.leftChild.parent = self.parent\n else:\n if self.isLeftChild():\n self.parent.leftChild = self.rightChild\n else:\n self.parent.rightChild = self.rightChild\n self.rightChild.parent = self.parent\n\n def findMin(self):\n current = self\n while current.hasLeftChild():\n current = current.leftChild\n return current\n\n def __iter__(self):\n \"\"\"The standard inorder traversal of a binary tree.\"\"\"\n if self:\n if self.hasLeftChild():\n for elem in self.leftChild:\n yield elem\n yield self.key\n if self.hasRightChild():\n for elem in self.rightChild:\n yield elem\n\n \n", "src/lib/time/__init__.js": "\n/*\n\tBarebones implementation of the Python time package.\n\n\tFor now, only the time() function is implemented.\n*/\n \nvar $builtinmodule = function(name)\n{\n var mod = {};\n\n mod.time = new Sk.builtin.func(function() {\n\t return Sk.builtin.assk$(new Date().getTime() / 1000, undefined);\n });\n\n return mod;\n}\n", "src/lib/operator/__init__.js": "/*\n * __author__: Isaac Dontje Lindell (i@isaacdontjelindell.com)\n *\n * Implementation of the Python operator module.\n */\n\nvar $builtinmodule = function(name) {\n var mod = {};\n\n mod.lt = new Sk.builtin.func(function(a, b) { return Sk.builtin.bool(Sk.misceval.richCompareBool(a, b, 'Lt')); });\n mod.__lt__ = mod.lt;\n\n mod.le = new Sk.builtin.func(function(a, b) { return Sk.builtin.bool(Sk.misceval.richCompareBool(a, b, 'LtE')); });\n mod.__le__ = mod.le;\n\n mod.eq = new Sk.builtin.func(function(a, b) { return Sk.builtin.bool(Sk.misceval.richCompareBool(a, b, 'Eq')); });\n mod.__eq__ = mod.eq;\n\n mod.ne = new Sk.builtin.func(function(a, b) { return Sk.builtin.bool(Sk.misceval.richCompareBool(a, b, 'NotEq')); });\n mod.__ne__ = mod.ne;\n\n mod.ge = new Sk.builtin.func(function(a, b) { return Sk.builtin.bool(Sk.misceval.richCompareBool(a, b, 'GtE')); });\n mod.__ge__ = mod.ge;\n\n mod.gt = new Sk.builtin.func(function(a, b) { return Sk.builtin.bool(Sk.misceval.richCompareBool(a, b, 'Gt')); });\n mod.__gt__ = mod.gt;\n\n mod.not_ = new Sk.builtin.func(function (obj) { throw new Sk.builtin.NotImplementedError(\"operator.not_() is not yet implemented in Skulpt\"); });\n\n mod.truth = new Sk.builtin.func(function(obj) { return Sk.builtin.bool(obj); });\n\n mod.is_ = new Sk.builtin.func(function(a, b) { return Sk.builtin.bool(Sk.misceval.richCompareBool(a, b, 'Is')); });\n\n mod.is_not = new Sk.builtin.func(function(a, b) { return Sk.builtin.bool(Sk.misceval.richCompareBool(a, b, 'IsNot')); });\n\n mod.abs = new Sk.builtin.func(function(obj) { return Sk.misceval.callsim(Sk.builtin.abs, obj); });\n mod.__abs__ = mod.abs;\n\n // The documentation says that operator.add() is defined for a and b numbers, but\n // CPython (2.6) allows a and b to be other types (e.g. str)\n mod.add = new Sk.builtin.func(function (a, b) { return Sk.abstr.objectAdd(a, b); });\n mod.__add__ = mod.add;\n\n mod.and_ = new Sk.builtin.func(function (a, b) { return Sk.builtin.nmber.prototype['nb$and'].call(a, b); });\n mod.__and__ = mod.and_;\n\n mod.div = new Sk.builtin.func(function (a, b) { return Sk.builtin.nmber.prototype['nb$divide'].call(a, b); });\n mod.__div__ = mod.div;\n\n mod.floordiv = new Sk.builtin.func(function (a, b) { return Sk.builtin.nmber.prototype['nb$floor_divide'].call(a, b); });\n mod.__floordiv__ = mod.floordiv;\n\n // Doesn't look like anything has the __index__ magic function anyway\n mod.index = new Sk.builtin.func(function (a) { throw new Sk.builtin.NotImplementedError(\"operator.index() is not yet implemented in Skulpt\"); });\n mod.__index__ = mod.index;\n\n // Note: Sk.abstr.numberUnaryOp(obj, 'Invert') looks for the function nb$invert() on obj.\n // However, it doesn't look like that function has been implemented for any existing object types.\n // I've gone ahead and created this function for completeness' sake, but expect any use of it to\n // result in an error.\n mod.inv = new Sk.builtin.func(function (obj) { return Sk.abstr.numberUnaryOp(obj, 'Invert'); });\n mod.__inv__ = mod.inv;\n mod.invert = mod.inv;\n mod.__invert__ = mod.inv;\n\n mod.lshift = new Sk.builtin.func(function (a, b) { return Sk.builtin.nmber.prototype['nb$lshift'].call(a, b); });\n mod.__lshift__ = mod.lshift;\n\n mod.mod = new Sk.builtin.func(function (a, b) { return Sk.builtin.nmber.prototype['nb$remainder'].call(a, b); });\n mod.__mod__ = mod.mod;\n\n mod.mul = new Sk.builtin.func(function (a, b) { return Sk.builtin.nmber.prototype['nb$multiply'].call(a, b); });\n mod.__mul__ = mod.mul;\n\n mod.neg = new Sk.builtin.func(function (obj) { return Sk.abstr.objectNegative(obj); });\n mod.__neg__ = mod.neg;\n\n mod.or_ = new Sk.builtin.func(function (a, b) { return Sk.builtin.nmber.prototype['nb$or'].call(a, b); });\n mod.__or__ = mod.or_;\n\n mod.pos = new Sk.builtin.func(function (obj) { return Sk.abstr.objectPositive(obj); });\n mod.__pos__ = mod.pos;\n\n mod.pow = new Sk.builtin.func(function (a, b) { return Sk.builtin.nmber.prototype['nb$power'].call(a, b); });\n mod.__pow__ = mod.pow;\n\n mod.rshift = new Sk.builtin.func(function (a, b) { return Sk.builtin.nmber.prototype['nb$rshift'].call(a, b); });\n mod.__rshift__ = mod.rshift;\n\n mod.sub = new Sk.builtin.func(function (a, b) { return Sk.builtin.nmber.prototype['nb$subtract'].call(a, b); });\n mod.__sub__ = mod.sub;\n\n mod.truediv = mod.div;\n mod.__truediv__ = mod.div;\n\n mod.xor = new Sk.builtin.func(function (a, b) { return Sk.builtin.nmber.prototype['nb$xor'].call(a, b); });\n mod.__xor__ = mod.xor;\n\n mod.concat = new Sk.builtin.func(function (a, b) { return Sk.abstr.sequenceConcat(a, b); });\n mod.__concat__ = mod.concat;\n\n mod.contains = new Sk.builtin.func(function (a, b) { return Sk.builtin.bool(Sk.abstr.sequenceContains(a, b)); });\n mod.__contains__ = mod.contains;\n\n mod.countOf = new Sk.builtin.func(function (a, b) { return Sk.abstr.sequenceGetCountOf(a, b); });\n\n mod.delitem = new Sk.builtin.func(function (a, b) { return Sk.abstr.sequenceDelItem(a, b); });\n mod.__delitem__ = mod.delitem;\n\n mod.getitem = new Sk.builtin.func(function (a, b) { return Sk.abstr.sequenceGetItem(a, b); });\n mod.__getitem__ = mod.getitem;\n\n mod.indexOf = new Sk.builtin.func(function (a, b) { return Sk.abstr.sequenceGetIndexOf(a, b); });\n\n mod.setitem = new Sk.builtin.func(function (a, b, c) { return Sk.abstr.sequenceSetItem(a, b, c); });\n mod.__setitem__ = mod.setitem;\n\n return mod;\n};\n", "src/lib/image/__init__.js": "var ImageMod; // the single identifier needed in the global scope\n\nif (! ImageMod) {\n ImageMod = { };\n ImageMod.canvasLib = [];\n}\n\n// todo create an empty image by reading image data from a blank canvas of the appropriate size\n\nvar $builtinmodule = function(name) {\n var mod = {};\n\n var image = function($gbl, $loc) {\n $loc.__init__ = new Sk.builtin.func(function(self,imageId) {\n self.image = document.getElementById(imageId.v);\n if (self.image == null) {\n throw \"There is no image on this page named: \" + imageId.v;\n }\n self.width = self.image.width;\n self.height = self.image.height;\n self.canvas = document.createElement(\"canvas\");\n self.canvas.height = self.height;\n self.canvas.width = self.width;\n self.ctx = self.canvas.getContext(\"2d\");\n self.ctx.drawImage(self.image,0,0)\n self.imagedata = self.ctx.getImageData(0,0,self.width,self.height);\n });\n\n $loc.getPixel = new Sk.builtin.func(function(self,x,y) {\n\t\t\tx = Sk.builtin.asnum$(x);\n\t\t\ty = Sk.builtin.asnum$(y);\n var index = (y*4)*self.width+(x*4);\n var red = self.imagedata.data[index]\n var green = self.imagedata.data[index+1]\n var blue = self.imagedata.data[index+2]\n return Sk.misceval.callsim(mod.Pixel,red,green,blue);\n });\n\n $loc.setPixel = new Sk.builtin.func(function(self, x, y, pix) {\n\t\t\tx = Sk.builtin.asnum$(x);\n\t\t\ty = Sk.builtin.asnum$(y);\n var index = (y*4)*self.width+(x*4);\n self.imagedata.data[index] = Sk.misceval.callsim(pix.getRed,pix);\n self.imagedata.data[index+1] = Sk.misceval.callsim(pix.getGreen,pix);\n self.imagedata.data[index+2] = Sk.misceval.callsim(pix.getBlue,pix);\n self.imagedata.data[index+3] = 255;\n });\n\n $loc.getHeight = new Sk.builtin.func(function(self) {\n return self.image.height;\n });\n\n $loc.getWidth = new Sk.builtin.func(function(self,titlestring) {\n return self.image.width;\n });\n\n $loc.draw = new Sk.builtin.func(function(self,win,ulx,uly) {\n\t\t\twin = Sk.builtin.asnum$(win);\n\t\t\tulx = Sk.builtin.asnum$(ulx);\n\t\t\tuly = Sk.builtin.asnum$(uly);\n var can = Sk.misceval.callsim(win.getWin,win);\n var ctx = can.getContext(\"2d\");\n //ctx.putImageData(self.imagedata,0,0,0,0,self.imagedata.width,self.imagedata.height);\n if (! ulx) {\n ulx = 0;\n uly = 0;\n }\n ctx.putImageData(self.imagedata,ulx,uly);\n });\n\n // toList\n\n }\n\n mod.Image = Sk.misceval.buildClass(mod, image, 'Image', []);\n\n var eImage = function($gbl, $loc) {\n $loc.__init__ = new Sk.builtin.func(function(self,width,height) {\n self.width = Sk.builtin.asnum$(width);\n self.height = Sk.builtin.asnum$(height);\n self.canvas = document.createElement(\"canvas\");\n self.ctx = self.canvas.getContext('2d');\n self.canvas.height = self.height;\n self.canvas.width = self.width;\n self.imagedata = self.ctx.getImageData(0,0,self.width,self.height);\n });\n\n }\n\n mod.EmptyImage = Sk.misceval.buildClass(mod, eImage, 'EmptyImage', [mod.Image]);\n\n // create a ListImage object\n\n \n var pixel = function($gbl, $loc) {\n $loc.__init__ = new Sk.builtin.func(function(self,r,g,b) {\n self.red = Sk.builtin.asnum$(r);\n self.green = Sk.builtin.asnum$(g);\n self.blue = Sk.builtin.asnum$(b);\n });\n\n $loc.getRed = new Sk.builtin.func(function(self) {\n return self.red;\n });\n\n $loc.getGreen = new Sk.builtin.func(function(self) {\n return self.green;\n });\n\n $loc.getBlue = new Sk.builtin.func(function(self) {\n return self.blue;\n });\n\n $loc.setRed = new Sk.builtin.func(function(self,r) {\n self.red = Sk.builtin.asnum$(r);\n });\n\n $loc.setGreen = new Sk.builtin.func(function(self,g) {\n self.green = Sk.builtin.asnum$(g);\n });\n\n $loc.setBlue = new Sk.builtin.func(function(self,b) {\n self.blue = Sk.builtin.asnum$(b);\n });\n\n $loc.__getitem__ = new Sk.builtin.func(function(self,k) {\n\t\t k = Sk.builtin.asnum$(k);\n if(k == 0) {\n return self.red;\n } else if (k == 1) {\n return self.green;\n } else if (k == 2) {\n return self.blue;\n }\n });\n\n $loc.__str__ = new Sk.builtin.func(function(self) {\n return \"[\" + self.red + \",\" + self.green + \",\" + self.blue + \"]\"\n });\n \n //getColorTuple\n $loc.getColorTuple = new Sk.builtin.func(function(self,x,y) {\n\n });\n\n //setRange -- change from 0..255 to 0.0 .. 1.0\n $loc.setRange = new Sk.builtin.func(function(self,mx) {\n self.max = Sk.builtin.asnum$(mx);\n });\n\n }\n mod.Pixel = Sk.misceval.buildClass(mod, pixel, 'Pixel', []);\n\n\n\n var screen = function($gbl, $loc) {\n $loc.__init__ = new Sk.builtin.func(function(self,width,height) {\n var currentCanvas = ImageMod.canvasLib[Sk.canvas];\n if (currentCanvas === undefined) {\n self.theScreen = document.getElementById(Sk.canvas);\n if (width !== undefined) {\n self.theScreen.height = height;\n self.theScreen.width = width;\n }\n\n ImageMod.canvasLib[Sk.canvas] = self.theScreen;\n } else {\n self.theScreen = currentCanvas;\n self.theScreen.height = self.theScreen.height;\n }\n self.theScreen.style.display = \"block\";\n });\n\n $loc.getWin = new Sk.builtin.func(function(self) {\n return self.theScreen;\n });\n\n // exitonclick\n $loc.exitonclick = new Sk.builtin.func(function(self) {\n var canvas_id = self.theScreen.id;\n self.theScreen.onclick = function() {\n document.getElementById(canvas_id).style.display = 'none';\n document.getElementById(canvas_id).onclick = null;\n delete ImageMod.canvasLib[canvas_id];\n }\n\n });\n //getMouse\n }\n\n mod.ImageWin = Sk.misceval.buildClass(mod, screen, 'ImageWin', []);\n\n return mod\n}\n", "src/lib/pythonds/basic/__init__.py": "\n#__all__ = [\"stack\"]\n\n\n#from .stack import Stack\n#from .queue import Queue\n\n\n\n", "src/lib/unittest/__init__.py": "__author__ = 'bmiller'\n'''\nThis is the start of something that behaves like\nthe unittest module from cpython.\n\n'''\n\n\nclass TestCase:\n def __init__(self):\n self.numPassed = 0\n self.numFailed = 0\n\n self.tlist = []\n testNames = {}\n for name in dir(self):\n if name[:4] == 'test' and name not in testNames:\n self.tlist.append(getattr(self,name))\n testNames[name]=True\n\n def setup(self):\n pass\n\n def tearDown(self):\n pass\n\n def main(self):\n\n for func in self.tlist:\n try:\n self.setup()\n func()\n self.tearDown()\n except:\n self.appendResult('Error',None,None,None)\n self.numFailed += 1\n self.showSummary()\n\n def assertEqual(self, actual, expected, feedback=\"\"):\n res = actual==expected\n self.appendResult(res,str(actual)+' to be equal to ',expected, feedback)\n\n def assertNotEqual(actual, expected, feedback=\"\"):\n res = actual != expected\n self.appendResult(res,str(actual)+' to not equal ',expected,feedback)\n\n def assertTrue(self,x, feedback=\"\"):\n res = x\n self.appendResult(res,str(x)+' to be ',True,feedback)\n\n def assertFalse(self,x, feedback=\"\"):\n res = not x\n self.appendResult(res,str(x)+' to be ',False,feedback)\n\n def assertIs(self,a,b, feedback=\"\"):\n res = a is b\n self.appendResult(res,str(a)+' to be the same object as ',b,feedback)\n\n def assertIsNot(self,a,b, feedback=\"\"):\n res = a is not b\n self.appendResult(res,str(a)+' to not be the same object as ',b,feedback)\n\n def assertIsNone(self,x, feedback=\"\"):\n res = x is None\n self.appendResult(res,x,None,feedback)\n\n def assertIsNotNone(self,x, feedback=\"\"):\n res = x is not None\n self.appendResult(res,str(x)+' to not be ',None,feedback)\n\n def assertIn(self,a,b, feedback=\"\"):\n res = a in b\n self.appendResult(res,str(a)+' to be in ',b,feedback)\n\n def assertNotIn(self,a,b, feedback=\"\"):\n res = a not in b\n self.appendResult(res,str(a)+' to not be in ',b,feedback)\n\n def assertIsInstance(self,a,b, feedback=\"\"):\n res = isinstance(a,b)\n self.appendResult(res,str(a)+' to be an instance of ',b,feedback)\n\n def assertNotIsInstance(self,a,b, feedback=\"\"):\n res = not isinstance(a,b)\n self.appendResult(res,str(a)+' to not be an instance of ',b,feedback)\n\n def assertAlmostEqual(self,a,b, feedback=\"\"):\n res = round(a-b,7) == 0\n self.appendResult(res,str(a)+' to equal ',b,feedback)\n\n def assertNotAlmostEqual(self,a,b, feedback=\"\"):\n res = round(a-b,7) != 0\n self.appendResult(res,str(a)+' to not equal ',b,feedback)\n\n def assertGreater(self,a,b, feedback=\"\"):\n res = a > b\n self.appendResult(res,str(a)+' to be greater than ',b,feedback)\n\n def assertGreaterEqual(self,a,b, feedback=\"\"):\n res = a >= b\n self.appendResult(res,str(a)+' to be greater than or equal to ',b,feedback)\n\n def assertLess(self,a,b, feedback=\"\"):\n res = a < b\n self.appendResult(res,str(a)+' to be less than ',b,feedback)\n\n def assertLessEqual(self,a,b, feedback=\"\"):\n res = a <= b\n self.appendResult(res,str(a)+' to be less than or equal to ',b,feedback)\n\n def appendResult(self,res,actual,expected,feedback):\n if res == 'Error':\n msg = 'Error'\n elif res:\n msg = 'Pass'\n self.numPassed += 1\n else:\n msg = 'Fail: expected %s %s ' % (str(actual),str(expected)) + feedback\n self.numFailed += 1\n\n def showSummary(self):\n pct = self.numPassed / (self.numPassed+self.numFailed) * 100\n print \"ran %d tests, passed %d \\n\" % (self.numPassed+self.numFailed, self.numPassed)\n\n\n\ndef main():\n glob = globals() # globals() still needs work\n for name in glob:\n if issubclass(glob[name],TestCase):\n glob[name]().main() \n\n", "src/lib/test/__init__.py": "__author__ = 'bmiller'\n\ndef testEqual(actual, expected):\n if type(expected) == type(1):\n if actual == expected:\n print('Pass')\n return True\n elif type(expected) == type(1.11):\n if abs(actual-expected) < 0.00001:\n print('Pass')\n return True\n else:\n if actual == expected:\n print('Pass')\n return True\n print('Test Failed: expected ' + str(expected) + ' but got ' + str(actual))\n return False\n\ndef testNotEqual(actual, expected):\n pass\n\n", "src/lib/string/__init__.js": "/*\n * __author__: Isaac Dontje Lindell (i@isaacdontjelindell.com)\n *\n * Implementation of the Python string module.\n */\n\n\nvar $builtinmodule = function(name) {\n var mod = {};\n\n mod.ascii_lowercase = Sk.builtin.str('abcdefghijklmnopqrstuvwxyz');\n mod.ascii_uppercase = Sk.builtin.str('ABCDEFGHIJKLMNOPQRSTUVWXYZ');\n mod.ascii_letters = Sk.builtin.str(mod.ascii_lowercase.v + mod.ascii_uppercase.v);\n\n mod.lowercase = Sk.builtin.str('abcdefghijklmnopqrstuvwxyz');\n mod.uppercase = Sk.builtin.str('ABCDEFGHIJKLMNOPQRSTUVWXYZ');\n mod.letters = Sk.builtin.str(mod.lowercase.v + mod.uppercase.v);\n\n mod.digits = Sk.builtin.str('0123456789', Sk.builtin.str);\n mod.hexdigits = Sk.builtin.str('0123456789abcdefABCDEF');\n mod.octdigits = Sk.builtin.str('01234567');\n\n mod.punctuation = Sk.builtin.str('!\"#$%&\\'()*+,-./:;<=>?@[\\\\]^_`{|}~');\n mod.whitespace = Sk.builtin.str('\\t\\n\\x0b\\x0c\\r ');\n\n /* Note: The docs for string.printable say that it's the concatenation of string.digits,\n * string.letters, string.punctuation, and string.whitespace. The CPython interpreter\n * outputs the whitespace characters in one order when string.whitespace is used, and a\n * slightly different order when string.printable is used. I've elected to follow the\n * behavior of CPython here rather than the spec. */\n mod.printable = Sk.builtin.str(mod.digits.v + mod.letters.v + mod.punctuation.v + \" \\t\\n\\r\\x0b\\x0c\");\n\n\n mod.split = new Sk.builtin.func(function(s, sep, maxsplit) {\n return Sk.misceval.callsim(Sk.builtin.str.prototype['split'], s, sep, maxsplit);\n });\n\n /* Return a copy of word with only its first character capitalized. */\n mod.capitalize = new Sk.builtin.func(function(word) {\n return Sk.misceval.callsim(Sk.builtin.str.prototype['capitalize'], word);\n });\n\n /* Concatenate a list or tuple of words with intervening occurrences\n * of sep. The default value for sep is a single space character. */\n mod.join = new Sk.builtin.func(function(words, sep) {\n if (sep === undefined) {\n sep = Sk.builtin.str(' ');\n }\n return Sk.misceval.callsim(Sk.builtin.str.prototype['join'], sep, words);\n });\n\n\n /* Split the argument into words using split(), capitalize each word\n * using capitalize(), and join the capitalized words using join().\n * Note that this replaces runs of whitespace characters by a single\n * space, and removes leading and trailing whitespace. */\n mod.capwords = new Sk.builtin.func(function(s, sep) {\n Sk.builtin.pyCheckArgs('capwords', arguments, 1, 2);\n if (!Sk.builtin.checkString(s)) {\n throw new Sk.builtin.TypeError(\"s must be a string\");\n }\n if (sep === undefined) {\n sep = Sk.builtin.str(' ');\n }\n if(!Sk.builtin.checkString(sep)) {\n throw new Sk.builtin.TypeError(\"sep must be a string\");\n }\n\n var words = Sk.misceval.callsim(mod.split, s, sep);\n var capWords = [];\n for (var i=0; i<words.v.length; i++) {\n var word = Sk.builtin.list.prototype['list_subscript_'].call(words, i);\n var cap = Sk.misceval.callsim(mod.capitalize, word);\n capWords.push(cap);\n }\n\n return Sk.misceval.callsim(mod.join, Sk.builtin.list(capWords), sep);\n });\n\n\n return mod;\n};", "src/builtin/sys.js": "var $builtinmodule = function(name)\n{\n var sys = {};\n\n var args = [];\n var argv = Sk.getSysArgv();\n for (var i = 0; i < argv.length; ++i)\n args.push(new Sk.builtin.str(argv[i]));\n sys.argv = new Sk.builtins['list'](args);\n\n sys.copyright = Sk.builtin['str'](\"Copyright 2009-2010 Scott Graham.\\nAll Rights Reserved.\\n\");\n\n sys.modules = Sk.sysmodules;\n\n sys.path = Sk.realsyspath;\n\n sys.getExecutionLimit = new Sk.builtin.func(function() {\n return Sk.builtin.assk$(Sk.execLimit, Sk.builtin.nmber.int$);\n });\n\n sys.setExecutionLimit = new Sk.builtin.func(function(t) {\n if (t !== undefined) {\n Sk.execLimit = Sk.builtin.asnum$(t);\n }\n });\n\n sys.resetTimeout = new Sk.builtin.func(function() {\n Sk.execStart = new Date();\n });\n\n sys.debug = new Sk.builtin.func(function() {\n debugger;\n });\n\n return sys;\n};\n", "src/lib/pythonds/trees/balance.py": "#!/bin/env python3.1\n# Bradley N. Miller, David L. Ranum\n# Introduction to Data Structures and Algorithms in Python\n# Copyright 2005, 2010\n# \n\nfrom .bst import BinarySearchTree, TreeNode\n\nclass AVLTree(BinarySearchTree):\n '''\n Author: Brad Miller\n Date: 1/15/2005\n Description: Imlement a binary search tree with the following interface\n functions: \n __contains__(y) <==> y in x\n __getitem__(y) <==> x[y]\n __init__()\n __len__() <==> len(x)\n __setitem__(k,v) <==> x[k] = v\n clear()\n get(k)\n has_key(k)\n items() \n keys() \n values()\n put(k,v)\n '''\n\n\n def _put(self,key,val,currentNode):\n if key < currentNode.key:\n if currentNode.hasLeftChild():\n self._put(key,val,currentNode.leftChild)\n else:\n currentNode.leftChild = TreeNode(key,val,parent=currentNode)\n self.updateBalance(currentNode.leftChild)\n else:\n if currentNode.hasRightChild():\n self._put(key,val,currentNode.rightChild)\n else:\n currentNode.rightChild = TreeNode(key,val,parent=currentNode)\n self.updateBalance(currentNode.rightChild) \n\n def updateBalance(self,node):\n if node.balanceFactor > 1 or node.balanceFactor < -1:\n self.rebalance(node)\n return\n if node.parent != None:\n if node.isLeftChild():\n node.parent.balanceFactor += 1\n elif node.isRightChild():\n node.parent.balanceFactor -= 1\n\n if node.parent.balanceFactor != 0:\n self.updateBalance(node.parent)\n\n def rebalance(self,node):\n if node.balanceFactor < 0:\n if node.rightChild.balanceFactor > 0:\n # Do an LR Rotation\n self.rotateRight(node.rightChild)\n self.rotateLeft(node)\n else:\n # single left\n self.rotateLeft(node)\n elif node.balanceFactor > 0:\n if node.leftChild.balanceFactor < 0:\n # Do an RL Rotation\n self.rotateLeft(node.leftChild)\n self.rotateRight(node)\n else:\n # single right\n self.rotateRight(node)\n\n def rotateLeft(self,rotRoot):\n newRoot = rotRoot.rightChild\n rotRoot.rightChild = newRoot.leftChild\n if newRoot.leftChild != None:\n newRoot.leftChild.parent = rotRoot\n newRoot.parent = rotRoot.parent\n if rotRoot.isRoot():\n self.root = newRoot\n else:\n if rotRoot.isLeftChild():\n rotRoot.parent.leftChild = newRoot\n else:\n rotRoot.parent.rightChild = newRoot\n newRoot.leftChild = rotRoot\n rotRoot.parent = newRoot\n rotRoot.balanceFactor = rotRoot.balanceFactor + 1 - min(newRoot.balanceFactor, 0)\n newRoot.balanceFactor = newRoot.balanceFactor + 1 + max(rotRoot.balanceFactor, 0)\n\n\n def rotateRight(self,rotRoot):\n newRoot = rotRoot.leftChild\n rotRoot.leftChild = newRoot.rightChild\n if newRoot.rightChild != None:\n newRoot.rightChild.parent = rotRoot\n newRoot.parent = rotRoot.parent\n if rotRoot.isRoot():\n self.root = newRoot\n else:\n if rotRoot.isRightChild():\n rotRoot.parent.rightChild = newRoot\n else:\n rotRoot.parent.leftChild = newRoot\n newRoot.rightChild = rotRoot\n rotRoot.parent = newRoot\n rotRoot.balanceFactor = rotRoot.balanceFactor - 1 - max(newRoot.balanceFactor, 0)\n newRoot.balanceFactor = newRoot.balanceFactor - 1 + min(rotRoot.balanceFactor, 0)\n \n", "src/lib/urllib/request/__init__.js": "var $builtinmodule = function(name)\n{\n var request = {};\n\n\n //~ Classes .................................................................\n\n // Response class\n //\n // Response objects are returned by the request, get, post, etc.\n // methods, allowing the user to access the response text, status\n // code, and other information.\n\n // ------------------------------------------------------------\n var response = function($gbl, $loc) {\n\n // ------------------------------------------------------------\n $loc.__init__ = new Sk.builtin.func(function(self, xhr) {\n self.data$ = xhr.responseText;\n self.lineList = self.data$.split(\"\\n\");\n self.lineList = self.lineList.slice(0,-1);\n for(var i =0 ; i < self.lineList.length; i++) {\n self.lineList[i] = self.lineList[i]+'\\n';\n }\n self.currentLine = 0;\n self.pos$ = 0;\n });\n\n\n // ------------------------------------------------------------\n $loc.__str__ = new Sk.builtin.func(function(self) {\n return Sk.ffi.remapToPy('<Response>');\n });\n\n\n // ------------------------------------------------------------\n $loc.__iter__ = new Sk.builtin.func(function(self) {\n var allLines = self.lineList;\n\n return Sk.builtin.makeGenerator(function() {\n if (this.$index >= this.$lines.length) return undefined;\n return new Sk.builtin.str(this.$lines[this.$index++]);\n }, {\n $obj: self,\n $index: 0,\n $lines: allLines\n });\n });\n\n\n // ------------------------------------------------------------\n $loc.read = new Sk.builtin.func(function(self, size) {\n if (self.closed) throw new Sk.builtin.ValueError(\"I/O operation on closed file\");\n var len = self.data$.length;\n if (size === undefined) size = len;\n var ret = new Sk.builtin.str(self.data$.substr(self.pos$, size));\n self.pos$ += size;\n if (self.pos$ >= len) self.pos$ = len;\n return ret;\n });\n\n\n // ------------------------------------------------------------\n $loc.readline = new Sk.builtin.func(function(self, size) {\n var line = \"\";\n if (self.currentLine < self.lineList.length) {\n line = self.lineList[self.currentLine];\n self.currentLine++;\n }\n return new Sk.builtin.str(line);\n });\n\n\n // ------------------------------------------------------------\n $loc.readlines = new Sk.builtin.func(function(self, sizehint) {\n var arr = [];\n for(var i = self.currentLine; i < self.lineList.length; i++) {\n arr.push(new Sk.builtin.str(self.lineList[i]));\n }\n return new Sk.builtin.list(arr);\n });\n\n };\n\n request.Response =\n Sk.misceval.buildClass(request, response, 'Response', []);\n\n\n //~ Module functions ........................................................\n\n // ------------------------------------------------------------\n /**\n * Constructs and sends a Request. Returns Response object.\n *\n * http://docs.python-requests.org/en/latest/api/#requests.request\n *\n * For now, this implementation doesn't actually construct a Request\n * object; it just makes the request through jQuery.ajax and then\n * constructs a Response.\n */\n request.urlopen = new Sk.builtin.func(function(url, data, timeout) {\n var xmlhttp = new XMLHttpRequest();\n xmlhttp.open(\"GET\",url.v,false);\n xmlhttp.send(null);\n\n return Sk.misceval.callsim(request.Response,xmlhttp)\n });\n\n\n return request;\n};\n", "src/lib/pythonds/basic/queue.py": "# Bradley N. Miller, David L. Ranum\n# Introduction to Data Structures and Algorithms in Python\n# Copyright 2005\n# \n#queue.py\r\n\r\nclass Queue:\r\n def __init__(self):\r\n self.items = []\r\n\r\n def isEmpty(self):\r\n return self.items == []\r\n\r\n def enqueue(self, item):\r\n self.items.insert(0,item)\r\n\r\n def dequeue(self):\r\n return self.items.pop()\r\n\r\n def size(self):\r\n return len(self.items)\r\n", "src/lib/pythonds/graphs/adjGraph.py": "#\n# adjGraph\n#\n# Created by Brad Miller on 2005-02-24.\n# Copyright (c) 2005 Brad Miller, David Ranum, Luther College. All rights reserved.\n#\n\nimport sys\nimport os\nimport unittest\n\nclass Graph:\n def __init__(self):\n self.vertices = {}\n self.numVertices = 0\n \n def addVertex(self,key):\n self.numVertices = self.numVertices + 1\n newVertex = Vertex(key)\n self.vertices[key] = newVertex\n return newVertex\n \n def getVertex(self,n):\n if n in self.vertices:\n return self.vertices[n]\n else:\n return None\n\n def __contains__(self,n):\n return n in self.vertices\n \n def addEdge(self,f,t,cost=0):\n if f not in self.vertices:\n nv = self.addVertex(f)\n if t not in self.vertices:\n nv = self.addVertex(t)\n self.vertices[f].addNeighbor(self.vertices[t],cost)\n \n def getVertices(self):\n return list(self.vertices.keys())\n \n def __iter__(self):\n return iter(self.vertices.values())\n \nclass Vertex:\n def __init__(self,num):\n self.id = num\n self.connectedTo = {}\n self.color = 'white'\n self.dist = sys.maxsize\n self.pred = None\n self.disc = 0\n self.fin = 0\n\n # def __lt__(self,o):\n # return self.id < o.id\n \n def addNeighbor(self,nbr,weight=0):\n self.connectedTo[nbr] = weight\n \n def setColor(self,color):\n self.color = color\n \n def setDistance(self,d):\n self.dist = d\n\n def setPred(self,p):\n self.pred = p\n\n def setDiscovery(self,dtime):\n self.disc = dtime\n \n def setFinish(self,ftime):\n self.fin = ftime\n \n def getFinish(self):\n return self.fin\n \n def getDiscovery(self):\n return self.disc\n \n def getPred(self):\n return self.pred\n \n def getDistance(self):\n return self.dist\n \n def getColor(self):\n return self.color\n \n def getConnections(self):\n return self.connectedTo.keys()\n \n def getWeight(self,nbr):\n return self.connectedTo[nbr]\n \n def __str__(self):\n return str(self.id) + \":color \" + self.color + \":disc \" + str(self.disc) + \":fin \" + str(self.fin) + \":dist \" + str(self.dist) + \":pred \\n\\t[\" + str(self.pred)+ \"]\\n\"\n \n def getId(self):\n return self.id\n\nclass adjGraphTests(unittest.TestCase):\n def setUp(self):\n self.tGraph = Graph()\n \n def testMakeGraph(self):\n gFile = open(\"test.dat\")\n for line in gFile:\n fVertex, tVertex = line.split('|')\n fVertex = int(fVertex)\n tVertex = int(tVertex)\n self.tGraph.addEdge(fVertex,tVertex)\n for i in self.tGraph:\n adj = i.getAdj()\n for k in adj:\n print(i, k)\n\n \nif __name__ == '__main__':\n unittest.main()\n \n", "src/lib/turtle/__init__.js": "//\n//\n// Turtle Graphics Module for Skulpt\n//\n// Brad Miller\n//\n//\n//\nvar TurtleGraphics;\n// the single identifier needed in the global scope\nif (!TurtleGraphics) {\n TurtleGraphics = {\n doneDelegates: [],\n fadeOnExit: true,\n\t\tdefaults: {\n\t\t\tcanvasID: 'mycanvas',\n\t\t\tdegrees: true,\n\t\t\tanimate: true\n\t\t}\n };\n}\n(function () {\n 'use strict';\n // Define private constants\n var Degree2Rad = Math.PI / 180,\n // conversion factor for degrees to radians\n Rad2Degree = 180 / Math.PI,\n render,\n allDone,\n segmentLine,\n clear_canvas;\n\n // Create a 3d Vector class for manipulating turtle heading, and position.\n function Vector(x, y, z) {\n var i;\n if ((typeof x).toLowerCase() === 'number') {\n Array.prototype.push.call(this, x);\n Array.prototype.push.call(this, y);\n Array.prototype.push.call(this, z);\n } else {\n for (i = 0; i < x.length; i = i + 1) {\n Array.prototype.push.call(this, x[i]);\n }\n }\n }\n // Create a vector object given a direction as an angle.\n Vector.angle2vec = function (phi) {\n var res = new Vector([0, 0, 0]);\n phi = phi * Degree2Rad;\n res[0] = Math.cos(phi);\n res[1] = Math.sin(phi);\n return res.normalize();\n };\n // This trick allows you to access a Vector object like an array\n // myVec[0] == x\n // myVec[1] == y\n // myVec[2] == z\n // we really only need the z for the convenience of rotating\n Vector.prototype.addItem = function (item) {\n Array.prototype.push.call(this, item);\n };\n Vector.prototype.linear = function (a, b, v) {\n if (this.length !== 3 || v.length !== 3) {\n return;\n }\n return new Vector([a * this[0] + b * v[0],\n a * this[1] + b * v[1],\n a * this[2] + b * v[2]]);\n\n\n };\n Vector.prototype.cross = function (v) {\n if (this.length !== 3 || v.length !== 3) {\n return;\n }\n\n return new Vector([this[1] * v[2] - this[2] * v[1],\n this[2] * v[0] - this[0] * v[2],\n this[0] * v[1] - this[1] * v[0]]);\n };\n Vector.prototype.rotate = function (angle) {\n // Rotate this counter clockwise by angle.\n var perp = new Vector(-this[1], this[0], 0),\n c,\n s;\n angle = angle * Degree2Rad;\n c = Math.cos(angle);\n s = Math.sin(angle);\n return new Vector(this[0] * c + perp[0] * s, this[1] * c + perp[1] * s, 0);\n };\n Vector.prototype.rotateNormal = function (v, alpha) {\n // Return rotation of this in direction of v about w over alpha\n // Requires: v, w are vectors; alpha is angle in radians\n // this, v, w are orthonormal\n return this.linear(Math.cos(alpha), Math.sin(alpha), v);\n };\n Vector.prototype.normalize = function () {\n var n = this.len(),\n res = this.div(n);\n return res;\n };\n Vector.prototype.toAngle = function () {\n // workaround for values getting set to +/i xxx e -16 fooling the +/- checks below\n if (Math.abs(this[1]) < 0.00001) {\n this[1] = 0;\n }\n if (Math.abs(this[0]) < 0.00001) {\n this[0] = 0;\n }\n var rads = Math.atan(Math.abs(this[1]) / Math.abs(this[0])),\n deg = rads * Rad2Degree;\n if (this[0] < 0 && this[1] > 0) {\n deg = 180 - deg;\n } else if (this[0] < 0 && this[1] <= 0) {\n deg = 180 + deg;\n } else if (this[0] >= 0 && this[1] < 0) {\n deg = 360 - deg;\n }\n return deg;\n };\n // divide all vector components by the same value\n Vector.prototype.div = function (n) {\n var res = [];\n res[0] = this[0] / n;\n res[1] = this[1] / n;\n res[2] = this[2] / n;\n return new Vector(res);\n };\n // subtract one vector from another\n Vector.prototype.sub = function (v) {\n var res = new Vector(0, 0, 0);\n res[0] = this[0] - v[0];\n res[1] = this[1] - v[1];\n res[2] = this[2] - v[2];\n return res;\n };\n Vector.prototype.add = function (v) {\n var res = new Vector(0, 0, 0);\n res[0] = this[0] + v[0];\n res[1] = this[1] + v[1];\n res[2] = this[2] + v[2];\n return res;\n };\n Vector.prototype.smul = function (k) {\n // scalar multiplication\n var res = new Vector(0, 0, 0);\n res[0] = this[0] * k;\n res[1] = this[1] * k;\n res[2] = this[2] * k;\n return res;\n };\n Vector.prototype.scale = function (xs, ys) {\n var res = new Vector(0, 0, 0);\n res[0] = this[0] * ys;\n res[1] = this[1] * xs;\n res[2] = 1;\n return res;\n };\n Vector.prototype.len = function () {\n return Math.sqrt(this[0] * this[0] + this[1] * this[1] + this[2] * this[2]);\n };\n\n allDone = function () {\n var done = true, tix, theT;\n for (tix = 0; tix < TurtleGraphics.turtleList.length; tix = tix + 1) {\n theT = TurtleGraphics.turtleList[tix];\n done = done && theT.aCount >= theT.drawingEvents.length;\n }\n return done;\n };\n //\n // This is the function that provides the animation\n //\n render = function () {\n var context = document.getElementById(TurtleGraphics.defaults.canvasID).getContext('2d'),\n canvasLib = TurtleGraphics.canvasLib[TurtleGraphics.defaults.canvasID],\n incr = TurtleGraphics.canvasLib[TurtleGraphics.defaults.canvasID].getCounter(),\n t,\n tix,\n i,\n\t\t\tcurrentPos,\n currentHead,\n filling,\n oper,\n ts,\n tmpColor,\n size,\n speed;\n\n\t\tcontext.moveTo(0, 0);\n\t\tcontext.lineCap = 'round';\n\t\tcontext.lineJoin = 'round';\n context.clearRect(canvasLib.llx, canvasLib.lly, canvasLib.urx - canvasLib.llx, canvasLib.ury - canvasLib.lly); //canvas.style.setProperty(\"background-color\",TurtleGraphics.turtleCanvas.bgcolor.v);\n TurtleGraphics.renderClock += incr;\n for (tix = 0; tix < TurtleGraphics.turtleList.length; tix = tix + 1) {\n currentPos = new Vector(0, 0, 0);\n currentHead = new Vector(1, 0, 0);\n context.fillStyle = 'black';\n context.strokeStyle = 'black';\n t = TurtleGraphics.turtleList[tix];\n\t\t\tcurrentHead = t.heading;\n context.lastCanvas = t.turtleCanvas;\n if (t.aCount >= t.drawingEvents.length) {\n t.aCount = t.drawingEvents.length - 1;\n }\n\n\t\t\tcontext.lineWidth = t.get_pen_width();\n\n filling = false;\n if (isNaN(t.turtleCanvas.delay)) {\n t.turtleCanvas.delay = 0;\n }\n //console.log(tix + \" : \" + t.clearPoint + \" to \" + t.aCount)\n for (i = t.clearPoint; (i <= t.aCount || t.turtleCanvas.delay === 0) && i < t.drawingEvents.length; i = i + 1) {\n if (i > t.aCount) {\n //If se jump past aCount, jump it ahead\n t.aCount = i;\n }\n oper = t.drawingEvents[i];\n ts = oper[oper.length - 1];\n //console.log(i + \"/\" + ts + oper [0] + \"{\" + oper [1] + \"}\" + t.turtleCanvas.delay)\n if (ts <= TurtleGraphics.renderClock || t.turtleCanvas.delay === 0) {\n if (ts > TurtleGraphics.renderClock) {\n //If we go past the render clock, jump it ahead\n TurtleGraphics.renderClock = ts;\n }\n //console.log(\"<==\")\n switch (oper[0]) {\n case 'LT': //line To\n if (!filling) {\n context.beginPath();\n context.moveTo(oper[1], oper[2]);\n }\n context.lineTo(oper[3], oper[4]);\n context.strokeStyle = oper[5];\n context.stroke();\n currentPos = new Vector(oper[3], oper[4], 0);\n if (!filling) {\n context.closePath();\n }\n break;\n case 'MT': //move to\n context.moveTo(oper[3], oper[4]);\n currentPos = new Vector(oper[3], oper[4], 0);\n break;\n case 'BF': //begin fill\n context.beginPath();\n context.moveTo(oper[1], oper[2]);\n filling = true;\n break;\n case 'EF': //end fill\n context.fillStyle = oper[3];\n context.stroke();\n context.fill();\n context.closePath();\n filling = false;\n break;\n case 'FC': // fill color\n\t\t\t\t\t\tcontext.fillStyle = oper[1];\n break;\n case 'TC': // turtle color\n context.strokeStyle = oper[1];\n break;\n case 'PW': // Pen width\n context.lineWidth = oper[1];\n break;\n case 'DT': // Dot\n tmpColor = context.fillStyle;\n context.fillStyle = oper[2];\n size = oper[1];\n context.fillRect(oper[3] - size / 2, oper[4] - size / 2, size, size);\n context.fillStyle = tmpColor;\n break;\n case 'CI': // Circle\n if (!filling) {\n context.beginPath();\n }\n context.arc(oper[1], oper[2], oper[3], oper[4], oper[5], oper[6]);\n currentPos = new Vector(oper[1] + Math.cos(oper[5]) * oper[3], oper[2] + Math.sin(oper[5]) * oper[3], 0);\n context.stroke();\n if (!filling) {\n context.closePath();\n }\n break;\n case 'WT':\n // write\n if (context.font) {\n context.font = oper[2];\n }\n context.scale(1, -1);\n context.fillText(oper[1], oper[3], -oper[4]);\n context.scale(1, -1);\n break;\n case 'ST':\n // stamp\n t.drawturtle(oper[3], new Vector(oper[1], oper[2], 0));\n break;\n case 'HT': // hide turtle\n t.visible = false;\n break;\n case 'SH': // show turtle\n t.visible = true;\n break;\n case 'TT': // turn\n currentHead = oper[1];\n break;\n case 'CL': // clear\n clear_canvas(t.canvasID);\n t.clearPoint = i; // Different from reset that calls clear because it leaves the turtles where they are\n break;\n case 'DL': // delay\n t.turtleCanvas.delay = oper[1];\n break;\n case 'SC': // speed change\n speed = oper[1];\n\n if (speed < 0) {\n t.turtleCanvas.delay = 0;\n } else {\n if (speed > 10) {\n speed = 10;\n }\n t.turtleCanvas.delay = (10 - speed % 11 + 1) * t.turtleCanvas.timeFactor; //10\n }\n\n //t.turtleCanvas.intervalId = clearInterval(t.turtleCanvas.intervalId);\n //t.turtleCanvas.intervalId = setInterval(render, t.turtleCanvas.delay)\n if (oper[2]) {\n t.turtleCanvas.setSegmentLength(oper[2]);\n }\n break;\n case 'NO':\n break;\n } //else {\n //console.log('unknown op: ' + oper[0]);\n //} // end of oper[0] test\n } // end of if ts < render clock\n }\n // end of for\n // console.log(TurtleGraphics.renderClock + \" / \" + t.aCount)\n // console.log(\"------------------------------\")\n t.aCount += incr;\n if (t.visible) {\n // draw the turtle\n t.drawturtle(currentHead.toAngle(), currentPos); // just use currentHead\n }\n }\n //if (t.aCount >= t.drawingEvents.length) {\n if (TurtleGraphics.renderClock > TurtleGraphics.eventCount) {\n // && allDone() ){\n // t.turtleCanvas.doneAnimating(t);\n // console.log(\"done animating\")\n if (context.lastCanvas) {\n context.lastCanvas.doneAnimating(t);\n }\n } else {\n //t.turtleCanvas.intervalId = setTimeout(render, t.turtleCanvas.delay)\n if (context.lastCanvas) {\n context.lastCanvas.intervalId = setTimeout(render, context.lastCanvas.delay);\n }\n }\n };\n //\n // Drawing Functions\n //\n // break a line into segments\n // sp: Vector of starting position\n // ep: Vector of ending position\n // sl: int length of segments\n segmentLine = function (sp, ep, sL, pen) {\n var head = ep.sub(sp).normalize(),\n numSegs = Math.floor(ep.sub(sp).len() / sL),\n res = [],\n oldp = sp,\n newp,\n op = '',\n i;\n if (pen) {\n op = 'LT';\n } else {\n op = 'MT';\n }\n for (i = 0; i < numSegs; i = i + 1) {\n newp = oldp.linear(1, sL, head);\n res.push([\n op,\n oldp[0],\n oldp[1],\n newp[0],\n newp[1]\n ]);\n oldp = newp;\n }\n if (!(oldp[0] === ep[0] && oldp[1] === ep[1])) {\n res.push([\n op,\n oldp[0],\n oldp[1],\n ep[0],\n ep[1]\n ]);\n }\n return res;\n };\n\n clear_canvas = function (canId) {\n var ctx = document.getElementById(canId).getContext('2d');\n //if (arguments.length >= 2) {\n // fillStyle = arguments[1];\n // fillRect(0, 0, canvas.width, canvas.height);\n //}\n ctx.clearRect(-ctx.canvas.width / 2, -ctx.canvas.height / 2, ctx.canvas.width, ctx.canvas.height);\n };\n //\n // Define TurtleCanvas\n //\n function TurtleCanvas(options) {\n this.canvasID = TurtleGraphics.defaults.canvasID;\n if (options.canvasID) {\n this.canvasID = options.canvasID;\n }\n this.canvas = document.getElementById(this.canvasID);\n this.context = this.canvas.getContext('2d');\n this.canvas.style.display = 'block';\n this.canvas.style.opacity = 1;\n //$(this.canvas).fadeIn();\n this.lineScale = 1;\n this.xptscale = 1;\n this.yptscale = 1;\n this.llx = -this.canvas.width / 2;\n this.lly = -this.canvas.height / 2;\n this.urx = this.canvas.width / 2;\n this.ury = this.canvas.height / 2;\n this.setup(this.canvas.width, this.canvas.height);\n TurtleGraphics.canvasInit = true;\n this.tlist = [];\n this.timeFactor = 5;\n if (TurtleGraphics.defaults.animate) {\n this.delay = 5 * this.timeFactor;\n } else {\n this.delay = 0;\n }\n this.segmentLength = 10;\n this.renderCounter = 1;\n this.clearPoint = 0;\n TurtleGraphics.canvasLib[this.canvasID] = this;\n }\n TurtleCanvas.prototype.setup = function (width, height) {\n this.canvas.width = width;\n this.canvas.height = height;\n this.lineScale = 1;\n this.xptscale = 1;\n this.yptscale = 1;\n this.llx = -this.canvas.width / 2;\n this.lly = -this.canvas.height / 2;\n this.urx = this.canvas.width / 2;\n this.ury = this.canvas.height / 2;\n this.renderCounter = 1;\n this.clearPoint = 0;\n this.timeFactor = 5;\n if (TurtleGraphics.defaults.animate) {\n this.delay = 5 * this.timeFactor;\n } else {\n this.delay = 0;\n }\n if (TurtleGraphics.canvasInit === false) {\n this.context.save();\n this.context.translate(this.canvas.width / 2, this.canvas.height / 2);\n // move 0,0 to center.\n this.context.scale(1, -1);\n // scaling like this flips the y axis the right way.\n TurtleGraphics.canvasInit = true;\n TurtleGraphics.eventCount = 0;\n TurtleGraphics.renderClock = 0;\n TurtleGraphics.renderTime = 0; // RNL\n } else {\n this.context.restore();\n this.context.translate(this.canvas.width / 2, this.canvas.height / 2);\n // move 0,0 to center.\n this.context.scale(1, -1);\n // scaling like this flips the y axis the right way.\n this.context.clearRect(-this.canvas.width / 2, -this.canvas.height / 2, this.canvas.width, this.canvas.height);\n }\n };\n TurtleCanvas.prototype.addToCanvas = function (t) {\n this.tlist.push(t);\n };\n TurtleCanvas.prototype.onCanvas = function (t) {\n return this.tlist.indexOf(t) >= 0;\n };\n TurtleCanvas.prototype.isAnimating = function () {\n return this.tlist.length > 0;\n };\n TurtleCanvas.prototype.startAnimating = function (t) {\n if (!this.isAnimating()) {\n this.intervalId = setTimeout(render, this.delay); //setInterval(render, this.delay);\n }\n if (!this.onCanvas(t)) {\n //Added by RNL in case startAnimating is called after it's already been added\n this.addToCanvas(t);\n }\n\t\ttry {\n\t\t\tSk.isTurtleProgram = true;\n\t\t} catch (ReferenceEror) {\n\t\t}\n };\n TurtleCanvas.prototype.doneAnimating = function () {\n var i;\n this.tlist.splice(0, this.tlist.length);\n clearTimeout(this.intervalId);\n if (TurtleGraphics.doneDelegates) {\n for (i = 0; i < TurtleGraphics.doneDelegates.length; i = i + 1) {\n TurtleGraphics.doneDelegates[i]();\n }\n }\n };\n TurtleCanvas.prototype.cancelAnimation = function () {\n var t;\n if (this.intervalId) {\n clearTimeout(this.intervalId);\n }\n for (t = 0; t < this.tlist.length; t = t + 1) {\n this.tlist[t].aCount = this.tlist[t].drawingEvents.length - 1;\n }\n render();\n };\n TurtleCanvas.prototype.setSpeedDelay = function (s) {\n // RNL\n var df = 10 - s % 11 + 1;\n this.delay = df * this.timeFactor; //RNL was 10;\n };\n TurtleCanvas.prototype.setDelay = function (d) {\n this.delay = d;\n };\n TurtleCanvas.prototype.getDelay = function () {\n //RNL\n return this.delay;\n };\n TurtleCanvas.prototype.setCounter = function (s) {\n if (!s || s <= 0) {\n //Don't let this be less than 1\n s = 1;\n }\n this.renderCounter = s;\n };\n TurtleCanvas.prototype.getCounter = function () {\n return this.renderCounter;\n };\n TurtleCanvas.prototype.setworldcoordinates = function (llx, lly, urx, ury) {\n this.context.restore();\n this.context.scale(this.canvas.width / (urx - llx), -this.canvas.height / (ury - lly));\n if (lly === 0) {\n this.context.translate(-llx, lly - (ury - lly));\n } else if (lly > 0) {\n this.context.translate(-llx, -lly * 2);\n } else {\n this.context.translate(-llx, -ury);\n }\n var xlinescale = (urx - llx) / this.canvas.width,\n ylinescale = (ury - lly) / this.canvas.height;\n this.xptscale = xlinescale;\n this.yptscale = ylinescale;\n this.lineScale = Math.min(xlinescale, ylinescale);\n this.context.save();\n this.llx = llx;\n this.lly = lly;\n this.urx = urx;\n this.ury = ury;\n };\n TurtleCanvas.prototype.window_width = function () {\n return this.canvas.width;\n };\n TurtleCanvas.prototype.window_height = function () {\n return this.canvas.height;\n };\n TurtleCanvas.prototype.bgcolor = function (c) {\n this.background_color = c;\n this.canvas.style.setProperty('background-color', c.v); //$(this.canvas).css(\"background-color\",c.v);\n };\n TurtleCanvas.prototype.setSegmentLength = function (s) {\n this.segmentLength = s;\n };\n TurtleCanvas.prototype.getSegmentLength = function () {\n return this.segmentLength;\n };\n // todo: if animating, this should be deferred until the proper time\n TurtleCanvas.prototype.exitonclick = function () {\n var canvas_id = this.canvasID,\n theCanvas = this,\n eventHandler = function () {\n if (!theCanvas.isAnimating()) {\n if (TurtleGraphics.fadeOnExit) {\n //Let's this be configurable\n document.getElementById(canvas_id).style.display = 'none'; //$(\"#\"+canvas_id).hide();\n }\n document.getElementById(canvas_id).removeEventListener('click', eventHandler);\n //$(\"#\"+canvas_id).unbind('click');\n TurtleGraphics.canvasInit = false;\n delete TurtleGraphics.canvasLib[canvas_id];\n }\n };\n this.canvas.addEventListener('click', eventHandler, false);\n };\n TurtleCanvas.prototype.turtles = function () {\n return TurtleGraphics.turtleList;\n };\n TurtleCanvas.prototype.tracer = function (t, d) {\n var i;\n //New version NOT attached to a turtle (as per real turtle)\n this.setCounter(t);\n if (t === 0) {\n for (i = 0; i < this.turtleList; i = i + 1) {\n this.turtleList[i].animate = false;\n }\n this.cancelAnimation();\n }\n if (d !== undefined) {\n this.setDelay(d);\n }\n };\n // Constructor for Turtle objects\n function Turtle(opt) {\n this.initialize(opt);\n TurtleGraphics.turtleList.push(this);\n }\n Turtle.prototype.go_home = function () {\n // Put turtle in initial state\n // turtle is headed to the right\n // with location 0,0,0 in the middle of the canvas.\n // x grows to the right\n // y grows towards the top of the canvas\n this.position = this.home;\n this.context.moveTo(this.home[0], this.home[1]);\n this.heading = new Vector([1, 0, 0]);\n // to the right; in turtle space x+ direction\n this.normal = new Vector([0, 0, -1]); // in z- direction\n };\n Turtle.prototype.initialize = function (opt) {\n function turtleShapePoints() {\n var pl = [\n [ 0, 16 ],\n [ -2, 14 ],\n [ -1, 10 ],\n [ -4, 7 ],\n [ -7, 9 ],\n [ -9, 8 ],\n [ -6, 5 ],\n [ -7, 1 ],\n [ -5, -3 ],\n [ -8, -6 ],\n [ -6, -8 ],\n [ -4, -5 ],\n [ 0, -7 ],\n [ 4, -5 ],\n [ 6, -8 ],\n [ 8, -6 ],\n [ 5, -3 ],\n [ 7, 1 ],\n [ 6, 5 ],\n [ 9, 8 ],\n [ 7, 9 ],\n [ 4, 7 ],\n [ 1, 10 ],\n [ 2, 14 ]\n ],\n res = [],\n p;\n for (p = 0; p < pl.length; p = p + 1) {\n res.push(new Vector(pl[p]));\n }\n return res;\n }\n\n function defaultShapePoints() {\n var pl = [\n [ -10, 0 ],\n [ 10, 0 ],\n [ 0, 10 ]\n ],\n res = [],\n p;\n for (p = 0; p < pl.length; p = p + 1) {\n res.push(new Vector(pl[p]));\n }\n return res;\n }\n\n function circleShapePoints() {\n var pl = [\n [ 10, 0 ],\n [ 9.51, 3.09 ],\n [ 8.09, 5.88 ],\n [ 5.88, 8.09 ],\n [ 3.09, 9.51 ],\n [ 0, 10 ],\n [ -3.09, 9.51 ],\n [ -5.88, 8.09 ],\n [ -8.09, 5.88 ],\n [ -9.51, 3.09 ],\n [ -10, 0 ],\n [ -9.51, -3.09 ],\n [ -8.09, -5.88 ],\n [ -5.88, -8.09 ],\n [ -3.09, -9.51 ],\n [ -0, -10 ],\n [ 3.09, -9.51 ],\n [ 5.88, -8.09 ],\n [ 8.09, -5.88 ],\n [ 9.51, -3.09 ]\n ],\n res = [],\n p;\n for (p = 0; p < pl.length; p = p + 1) {\n res.push(new Vector(pl[p]));\n }\n return res;\n }\n\n function triangleShapePoints() {\n var pl = [\n [ 10, -5.77 ],\n [ 0, 11.55 ],\n [ -10, -5.77 ]\n ],\n res = [],\n p;\n for (p = 0; p < pl.length; p = p + 1) {\n res.push(new Vector(pl[p]));\n }\n return res;\n }\n\n function squareShapePoints() {\n var pl = [\n [ 10, -10 ],\n [ 10, 10 ],\n [ -10, 10 ],\n [ -10, -10 ]\n ],\n res = [],\n p;\n for (p = 0; p < pl.length; p = p + 1) {\n res.push(new Vector(pl[p]));\n }\n return res;\n }\n\n function classicShapePoints() {\n var pl = [\n [ 0, 0 ],\n [ -5, -9 ],\n [ 0, -7 ],\n [ 5, -9 ]\n ],\n res = [],\n p;\n for (p = 0; p < pl.length; p = p + 1) {\n res.push(new Vector(pl[p]));\n }\n return res;\n }\n\n // Initialize the turtle.\n var options = {}, ctx = null;\n if (opt) {\n options = opt;\n }\n this.canvasID = TurtleGraphics.defaults.canvasID;\n if (options.canvasID) {\n this.canvasID = options.canvasID;\n }\n this.context = document.getElementById(this.canvasID).getContext('2d');\n this.animate = TurtleGraphics.defaults.animate;\n ctx = this.context;\n if (TurtleGraphics.canvasInit === false) {\n // This is a workaround until I understand skulpt re-running better\n // the downside is that this limits us to a single turtle...\n ctx.save();\n ctx.translate(ctx.canvas.width / 2, ctx.canvas.height / 2);\n // move 0,0 to center.\n ctx.scale(1, -1);\n // scaling like this flips the y axis the right way.\n if (!TurtleGraphics.canvasLib[this.canvasID]) {\n TurtleGraphics.canvasLib[this.canvasID] = new TurtleCanvas(options);\n }\n TurtleGraphics.canvasInit = true;\n } else {\n clear_canvas(this.canvasID);\n }\n this.turtleCanvas = TurtleGraphics.canvasLib[this.canvasID];\n this.home = new Vector([0, 0, 0]);\n this.visible = true;\n this.shapeStore = {};\n this.shapeStore.turtle = turtleShapePoints();\n this.shapeStore.arrow = defaultShapePoints();\n this.shapeStore.circle = circleShapePoints();\n this.shapeStore.square = squareShapePoints();\n this.shapeStore.triangle = triangleShapePoints();\n this.shapeStore.blank = [new Vector(0, 0)];\n this.shapeStore.classic = classicShapePoints();\n this.currentShape = 'classic';\n this.drawingEvents = [];\n this.filling = false;\n this.pen = true;\n this.penStyle = 'black';\n this.penWidth = 2;\n this.fillStyle = 'black';\n this.position = [];\n this.heading = [];\n this.normal = [];\n this.go_home();\n this.aCount = 0;\n this.clearPoint = 0; // RNL for clear/clearScreen\n };\n Turtle.prototype.clean = function (color) {\n // Clean the canvas\n // Optional second argument is color\n if (arguments.length >= 1) {\n clear_canvas(this.canvasID, color);\n } else {\n clear_canvas(this.canvasID);\n }\n this.initialize();\n };\n Turtle.prototype.addDrawingEvent = function (eventList) {\n TurtleGraphics.eventCount += 1;\n eventList.push(TurtleGraphics.eventCount);\n this.drawingEvents.push(eventList);\n };\n Turtle.prototype.draw_line = function (newposition) {\n var ctx = this.context,\n r,\n s;\n if (!this.animate) {\n if (!this.filling) {\n ctx.beginPath();\n ctx.moveTo(this.position[0], this.position[1]);\n }\n ctx.lineCap = 'round';\n ctx.lineJoin = 'round';\n ctx.lineWidth = this.get_pen_width();\n ctx.strokeStyle = this.penStyle;\n ctx.lineTo(newposition[0], newposition[1]);\n\t\t\t//ctx.moveTo(newposition[0], newposition[1]);\n\t\t\tthis.position = newposition;\n ctx.stroke();\n if (!this.filling) {\n ctx.closePath();\n }\n } else {\n r = segmentLine(this.position, newposition, this.turtleCanvas.getSegmentLength(), this.pen);\n for (s = 0; s < r.length; s = s + 1) {\n r[s].push(this.penStyle);\n this.addDrawingEvent(r[s]);\n }\n if (!this.turtleCanvas.isAnimating()) {\n this.turtleCanvas.startAnimating(this);\n } else {\n if (!this.turtleCanvas.onCanvas(this)) {\n this.turtleCanvas.addToCanvas(this);\n }\n }\n }\n };\n Turtle.prototype.forward = function (d) {\n var newposition = this.position.linear(1, d, this.heading);\n this.goto(newposition);\n };\n Turtle.prototype.backward = function (d) {\n this.forward(-d);\n };\n //This is an internal function that sets the position without doing any drawing\n Turtle.prototype.teleport_to = function (nx, ny) {\n var newposition;\n if (nx instanceof Vector) {\n newposition = nx;\n } else {\n newposition = new Vector([nx, ny, 0]);\n }\n this.context.moveTo(newposition[0], newposition[1]);\n this.position = newposition;\n };\n Turtle.prototype.goto = function (nx, ny) {\n var newposition, r, s;\n if (nx instanceof Vector) {\n newposition = nx;\n } else {\n newposition = new Vector([nx, ny, 0]);\n }\n\t\tif (this.pen) {\n this.draw_line(newposition);\n } else {\n if (!this.animate) {\n this.context.moveTo(newposition[0], newposition[1]);\n } else {\n r = segmentLine(this.position, newposition, this.turtleCanvas.getSegmentLength(), this.pen);\n for (s = 0; s < r.length; s = s + 1) {\n this.addDrawingEvent(r[s]);\n }\n if (!this.turtleCanvas.isAnimating()) {\n this.turtleCanvas.startAnimating(this);\n } else {\n if (!this.turtleCanvas.onCanvas(this)) {\n this.turtleCanvas.addToCanvas(this);\n }\n }\n }\n }\n this.position = newposition;\n };\n Turtle.prototype.delay = function (d) {\n // RNL\n if (d !== null) {\n if (d < 0) {\n d = -d;\n }\n if (!this.animate) {\n this.turtleCanvas.setDelay(d);\n } else {\n this.turtleCanvas.setDelay(d);\n this.addDrawingEvent([ 'DL', d ]);\n this.addDrawingEvent(['NO']);\n }\n }\n return this.turtleCanvas.getDelay();\n };\n Turtle.prototype.speed = function (s, t) {\n if (s > 0 && !this.animate) {\n this.animate = true;\n this.turtleCanvas.setSpeedDelay(s);\n } else if (s === 0 ) {\n this.animate = false;\n this.turtleCanvas.cancelAnimation();\n } else {\n this.turtleCanvas.setSpeedDelay(s);\n this.addDrawingEvent([ 'SC', s, t ]);\n this.addDrawingEvent(['NO']);\n }\n if (t) {\n this.turtleCanvas.setSegmentLength(t); // set the number of units to divide a segment into\n } else {\n this.turtleCanvas.setSegmentLength(10);\n }\n };\n Turtle.prototype.tracer = function (t, d) {\n this.turtleCanvas.setCounter(t);\n if (t === 0) {\n this.animate = false;\n this.turtleCanvas.cancelAnimation();\n }\n if (d !== undefined) {\n this.turtleCanvas.setDelay(d);\n }\n };\n Turtle.prototype.getRenderCounter = function () {\n return this.turtleCanvas.getCounter();\n };\n Turtle.prototype.turn = function (phi) {\n var alpha = phi * Degree2Rad,\n left = this.normal.cross(this.heading),\n newheading = this.heading.rotateNormal(left, alpha);\n this.heading = newheading;\n if (this.animate) {\n this.addDrawingEvent([ 'TT', this.heading ]);\n }\n };\n Turtle.prototype.right = Turtle.prototype.turn;\n Turtle.prototype.left = function (phi) {\n this.turn(-phi);\n };\n Turtle.prototype.get_heading = function () {\n if (TurtleGraphics.defaults.degrees) {\n return this.heading.toAngle();\n }\n return this.heading;\n };\n Turtle.prototype.get_position = function () {\n return this.position;\n };\n Turtle.prototype.getx = function () {\n return this.position[0];\n };\n Turtle.prototype.gety = function () {\n return this.position[1];\n };\n Turtle.prototype.set_heading = function (newhead) {\n if ((typeof newhead).toLowerCase() === 'number') {\n this.heading = Vector.angle2vec(newhead);\n } else {\n this.heading = newhead;\n }\n };\n Turtle.prototype.towards = function (to, y) {\n // set heading vector to point towards another point.\n if ((typeof to).toLowerCase() === 'number') {\n to = new Vector(to, y, 0);\n } else if (!(to instanceof Vector)) {\n to = new Vector(to);\n }\n var res = to.sub(this.position);\n res = res.normalize();\n if (TurtleGraphics.defaults.degrees) {\n return res.toAngle();\n }\n return res;\n };\n Turtle.prototype.distance = function (to, y) {\n if ((typeof to).toLowerCase() === 'number') {\n to = new Vector(to, y, 0);\n }\n return this.position.sub(new Vector(to)).len();\n };\n Turtle.prototype.dot = function (psize, pcolor) {\n var size = 2,\n ctx = this.context,\n curPenStyle = this.penStyle,\n\t\t\tcurFillStyle = this.fillStyle;\n\n if (arguments.length >= 1) {\n size = psize;\n }\n size = size * this.turtleCanvas.lineScale;\n\n if (!this.animate) {\n\t\t\tif (pcolor) {\n\t\t\t\tctx.fillStyle = pcolor;\n\t\t\t\tctx.strokeStyle = pcolor;\n\t\t\t}\n ctx.fillRect(this.position[0] - size / 2, this.position[1] - size / 2, size, size);\n\t\t\tif (pcolor) {\n\t\t\t\tctx.fillStyle = curFillStyle;\n\t\t\t\tctx.strokeStyle = curPenStyle;\n\t\t\t}\n } else {\n this.addDrawingEvent([\n 'DT',\n size,\n pcolor || ctx.strokeStyle,\n this.position[0],\n this.position[1]\n ]);\n }\n };\n Turtle.prototype.circle = function (radius, extent) {\n var arcLen, segLen, extentPart, extentLeft;\n if (extent === undefined) {\n extent = 360;\n }\n if (this.animate) {\n arcLen = Math.abs(radius * Math.PI * 2 * extent / 360);\n segLen = this.turtleCanvas.getSegmentLength();\n if (arcLen <= segLen) {\n this.arc(radius, extent);\n } else {\n //Break the arc into segments for animation\n extentPart = segLen / arcLen * extent;\n extentLeft = extent;\n while (Math.abs(extentLeft) > Math.abs(extentPart)) {\n this.arc(radius, extentPart);\n extentLeft = extentLeft - extentPart;\n }\n if (Math.abs(extentLeft) > 0.01) {\n this.arc(radius, extentLeft);\n }\n }\n if (!this.turtleCanvas.isAnimating()) {\n this.turtleCanvas.startAnimating(this);\n } else {\n if (!this.turtleCanvas.onCanvas(this)) {\n this.turtleCanvas.addToCanvas(this);\n }\n }\n } else {\n this.arc(radius, extent);\n }\n };\n Turtle.prototype.arc = function (radius, extent) {\n //Figure out where the turtle is and which way it's facing\n var turtleHeading = this.get_heading(),\n tx = this.position[0],\n ty = this.position[1],\n //Figure out the circle center\n cx = tx + radius * Math.cos((turtleHeading + 90) * Degree2Rad),\n cy = ty + radius * Math.sin((turtleHeading + 90) * Degree2Rad),\n //Canvas arc angles go CLOCKWISE, not COUNTERCLOCKWISE like Turtle\n //Figure out our arc angles\n startAngleDeg,\n endAngleDeg,\n startAngle,\n endAngle,\n turtleArc,\n newTurtleHeading,\n nx,\n ny;\n\n if (radius >= 0) {\n startAngleDeg = turtleHeading - 90;\n } else {\n startAngleDeg = turtleHeading + 90;\n }\n\n if (extent) {\n if (radius >= 0) {\n endAngleDeg = startAngleDeg + extent;\n } else {\n endAngleDeg = startAngleDeg - extent;\n }\n } else {\n if (radius >= 0) {\n endAngleDeg = startAngleDeg + 360;\n } else {\n endAngleDeg = startAngleDeg - 360;\n }\n }\n //Canvas angles are opposite\n startAngleDeg = 360 - startAngleDeg;\n endAngleDeg = 360 - endAngleDeg;\n //Becuase the y axis has been flipped in HTML5 Canvas with a tanslation, we need to adjust the angles\n startAngleDeg = -startAngleDeg;\n endAngleDeg = -endAngleDeg;\n //Convert to radians\n startAngle = startAngleDeg * Degree2Rad;\n endAngle = endAngleDeg * Degree2Rad;\n //Do the drawing\n if (!this.animate) {\n if (!this.filling) {\n this.context.beginPath();\n }\n this.context.arc(cx, cy, Math.abs(radius), startAngle, endAngle, radius * extent <= 0);\n this.context.stroke();\n if (!this.filling) {\n this.context.closePath();\n }\n } else {\n this.addDrawingEvent([\n 'CI',\n cx,\n cy,\n Math.abs(radius),\n startAngle,\n endAngle,\n radius * extent <= 0\n ]);\n }\n //Move the turtle only if we have to\n if (extent && extent % 360 !== 0) {\n if (radius >= 0) {\n turtleArc = extent;\n } else {\n turtleArc = -extent;\n }\n newTurtleHeading = (turtleHeading + turtleArc) % 360;\n if (newTurtleHeading < 0) {\n newTurtleHeading = newTurtleHeading + 360;\n }\n nx = cx + radius * Math.cos((newTurtleHeading - 90) * Degree2Rad);\n ny = cy + radius * Math.sin((newTurtleHeading - 90) * Degree2Rad);\n //y coord is inverted in turtle\n //Move it internally\n this.set_heading(newTurtleHeading);\n this.teleport_to(nx, ny);\n //If we're animating the turtle, move it on the screen\n if (this.animate) {\n this.addDrawingEvent([\n 'TT',\n this.heading\n ]);\n }\n }\n };\n Turtle.prototype.write = function (theText, /*move, align, */font) {\n if (!this.animate) {\n if (font) {\n this.context.font = font.v;\n }\n this.context.scale(1, -1);\n this.context.fillText(theText, this.position[0], -this.position[1]);\n this.context.scale(1, -1);\n } else {\n var fontspec;\n if (font) {\n fontspec = font.v;\n }\n this.addDrawingEvent([\n 'WT',\n theText,\n fontspec,\n this.position[0],\n this.position[1]\n ]);\n }\n };\n Turtle.prototype.setworldcoordinates = function (llx, lly, urx, ury) {\n this.turtleCanvas.setworldcoordinates(llx, lly, urx, ury);\n };\n //\n // Pen and Style functions\n //\n Turtle.prototype.pen_down = function () {\n this.pen = true;\n };\n Turtle.prototype.down = Turtle.prototype.pen_down;\n Turtle.prototype.pen_up = function () {\n this.pen = false;\n };\n Turtle.prototype.up = Turtle.prototype.pen_up;\n Turtle.prototype.get_pen = function () {\n return this.pen;\n };\n Turtle.prototype.set_pen_width = function (w) {\n if (this.animate) {\n this.addDrawingEvent([\n 'PW',\n w * this.turtleCanvas.lineScale\n ]);\n } else {\n this.penWidth = w;\n }\n };\n Turtle.prototype.get_pen_width = function () {\n return this.penWidth * this.turtleCanvas.lineScale;\n };\n Turtle.prototype.set_pen_color = function (c, g, b) {\n if (typeof c === 'string') {\n this.penStyle = c;\n } else {\n var rs, gs, bs, c0, c1, c2;\n if (Array.isArray(c)) {\n c0 = c[0];\n c1 = c[1];\n c2 = c[2];\n } else {\n c0 = c;\n c1 = g;\n c2 = b;\n }\n rs = Math.abs(c0).toString(16);\n gs = Math.abs(c1).toString(16);\n bs = Math.abs(c2).toString(16);\n while (rs.length < 2) {\n rs = '0' + rs;\n }\n while (gs.length < 2) {\n gs = '0' + gs;\n }\n while (bs.length < 2) {\n bs = '0' + bs;\n }\n c = '#' + rs + gs + bs;\n this.penStyle = c;\n }\n this.context.strokeStyle = c;\n if (this.animate) {\n this.addDrawingEvent([\n 'TC',\n c\n ]);\n }\n };\n Turtle.prototype.set_fill_color = function (c, g, b) {\n if (typeof c === 'string') {\n this.fillStyle = c;\n } else {\n var rs, gs, bs, c0, c1, c2;\n if (Array.isArray(c)) {\n c0 = c[0];\n c1 = c[1];\n c2 = c[2];\n } else {\n c0 = c;\n c1 = g;\n c2 = b;\n }\n rs = Math.abs(c0).toString(16);\n gs = Math.abs(c1).toString(16);\n bs = Math.abs(c2).toString(16);\n while (rs.length < 2) {\n rs = '0' + rs;\n }\n while (gs.length < 2) {\n gs = '0' + gs;\n }\n while (bs.length < 2) {\n bs = '0' + bs;\n }\n c = '#' + rs + gs + bs;\n this.fillStyle = c;\n }\n this.context.fillStyle = c;\n if (this.animate) {\n this.addDrawingEvent([\n 'FC',\n c\n ]);\n }\n };\n Turtle.prototype.begin_fill = function () {\n if (!this.animate) {\n this.filling = true;\n this.context.beginPath();\n this.context.moveTo(this.position[0], this.position[1]);\n } else {\n this.addDrawingEvent([\n 'BF',\n this.position[0],\n this.position[1]\n ]);\n }\n };\n Turtle.prototype.end_fill = function () {\n if (!this.animate) {\n this.context.stroke();\n this.context.fill();\n this.context.closePath();\n this.filling = false;\n } else {\n this.addDrawingEvent([\n 'EF',\n this.position[0],\n this.position[1],\n this.fillStyle\n ]);\n }\n };\n Turtle.prototype.showturtle = function () {\n if (this.animate) {\n this.addDrawingEvent(['SH']);\n }\n this.visible = true;\n };\n Turtle.prototype.hideturtle = function () {\n if (this.animate) {\n this.addDrawingEvent(['HT']);\n }\n this.visible = false;\n };\n Turtle.prototype.isvisible = function () {\n return this.visible;\n };\n //\n // Appearance\n //\n Turtle.prototype.shape = function (s) {\n if (this.shapeStore[s]) {\n this.currentShape = s;\n }\n };\n Turtle.prototype.drawturtle = function (pHeading, pos) {\n var rtPoints = [],\n plist = this.shapeStore[this.currentShape],\n head,\n p,\n i;\n\n if (pHeading !== undefined) {\n head = pHeading - 90;\n } else {\n head = this.heading.toAngle() - 90;\n }\n\n if (!pos) {\n pos = this.position;\n }\n\n for (p = 0; p < plist.length; p = p + 1) {\n rtPoints.push(plist[p]\n .scale(this.turtleCanvas.xptscale, this.turtleCanvas.yptscale)\n .rotate(head)\n .add(pos));\n }\n this.context.beginPath();\n this.context.moveTo(rtPoints[0][0], rtPoints[0][1]);\n for (i = 1; i < rtPoints.length; i = i + 1) {\n this.context.lineTo(rtPoints[i][0], rtPoints[i][1]);\n }\n this.context.closePath();\n this.context.stroke();\n if (this.fillStyle) {\n this.context.fill();\n }\n };\n Turtle.prototype.stamp = function () {\n // either call drawTurtle or just add a DT with current position and heading to the drawingEvents list.\n if (this.animate) {\n this.addDrawingEvent([\n 'ST',\n this.position[0],\n this.position[1],\n this.heading.toAngle()\n ]);\n } else {\n this.drawturtle();\n }\n };\n Turtle.prototype.clear = function () {\n if (this.animate) {\n this.addDrawingEvent(['CL']);\n } else {\n\t\t\tclear_canvas(this.canvasID);\n\t\t\tthis.penStyle = 'black';\n\t\t\tthis.penWidth = 2;\n\t\t\tthis.fillStyle = 'black';\n }\n };\n TurtleGraphics.turtleList = [];\n TurtleGraphics.Turtle = Turtle;\n TurtleGraphics.TurtleCanvas = TurtleCanvas;\n TurtleGraphics.canvasLib = {};\n TurtleGraphics.clear_canvas = clear_canvas;\n TurtleGraphics.Vector = Vector;\n TurtleGraphics.canvasInit = false;\n TurtleGraphics.eventCount = 0;\n TurtleGraphics.renderClock = 0;\n TurtleGraphics.renderTime = 0; // RNL\n}());\n//\n// Wrapper around the Turtle Module starts here.\n//\nvar $builtinmodule = function (name) {\n 'use strict';\n var mod = {},\n\t\tinitializeTurtlegraphics = function() {\n\t\t\tif (!TurtleGraphics) { TurtleGraphics = {}; }\n\t\t\tif (!TurtleGraphics.defaults) {\n\t\t\t\tTurtleGraphics.defaults = {\n\t\t\t\t\tanimate: true,\n\t\t\t\t\tcanvasID: Sk.canvas,\n\t\t\t\t\tdegrees: true\n\t\t\t\t}\n\t\t\t} else if (Sk.canvas) {\n\t\t\t\tTurtleGraphics.defaults.canvasID = Sk.canvas;\n\t\t\t}\n\t\t\tif (!TurtleGraphics.doneDelegates) { TurtleGraphics.doneDelegates = []; }\n\t\t},\n\t\tremoveDisabled = function () {\n\t\t\tif (Sk.runButton) {\n\t\t\t\tSk.runButton.removeAttribute('disabled');\n\t\t\t}\n\t\t},\n checkArgs = function (expected, actual, func) {\n if (actual !== expected) {\n throw new Sk.builtin.TypeError(func + ' takes exactly ' + expected + ' positional argument (' + actual + ' given)');\n }\n },\n turtle = function ($gbl, $loc) {\n $loc.__init__ = new Sk.builtin.func(function (self) {\n\t\t\t\tinitializeTurtlegraphics();\n\t\t\t\tif (TurtleGraphics.doneDelegates.indexOf(removeDisabled) === -1){\n\t\t\t\t\tTurtleGraphics.doneDelegates.push(removeDisabled);\n\t\t\t\t}\n self.theTurtle = new TurtleGraphics.Turtle();\n });\n //\n // Turtle Motion\n //\n //\n // Move and Draw\n //\n $loc.forward = new Sk.builtin.func(function (self, dist) {\n dist = Sk.builtin.asnum$(dist);\n checkArgs(2, arguments.length, 'forward()');\n self.theTurtle.forward(dist);\n });\n $loc.fd = $loc.forward;\n $loc.backward = new Sk.builtin.func(function (self, dist) {\n dist = Sk.builtin.asnum$(dist);\n checkArgs(2, arguments.length, 'backward()');\n self.theTurtle.forward(-dist);\n });\n $loc.back = $loc.backward;\n $loc.bk = $loc.backward;\n $loc.right = new Sk.builtin.func(function (self, angle) {\n angle = Sk.builtin.asnum$(angle);\n checkArgs(2, arguments.length, 'right()');\n self.theTurtle.turn(angle);\n });\n $loc.rt = $loc.right;\n $loc.left = new Sk.builtin.func(function (self, angle) {\n angle = Sk.builtin.asnum$(angle);\n checkArgs(2, arguments.length, 'left()');\n self.theTurtle.turn(-angle);\n });\n $loc.lt = $loc.left;\n $loc.goto_$rw$ = new Sk.builtin.func(function (self, nx, ny) {\n nx = Sk.builtin.asnum$(nx);\n ny = Sk.builtin.asnum$(ny);\n checkArgs(3, arguments.length, 'goto()');\n self.theTurtle.goto(nx, ny);\n });\n $loc.setposition = new Sk.builtin.func(function (self, nx, ny) {\n nx = Sk.builtin.asnum$(nx);\n ny = Sk.builtin.asnum$(ny);\n checkArgs(3, arguments.length, 'setposition()');\n self.theTurtle.up();\n self.theTurtle.goto(nx, ny);\n self.theTurtle.down();\n });\n $loc.setpos = $loc.setposition;\n $loc.setx = new Sk.builtin.func(function (self, nx) {\n nx = Sk.builtin.asnum$(nx);\n checkArgs(2, arguments.length, 'setx()');\n self.theTurtle.goto(nx, self.theTurtle.GetY());\n });\n $loc.sety = new Sk.builtin.func(function (self, ny) {\n ny = Sk.builtin.asnum$(ny);\n checkArgs(2, arguments.length, 'sety()');\n self.theTurtle.goto(self.theTurtle.GetX(), ny);\n });\n $loc.setheading = new Sk.builtin.func(function (self, newhead) {\n newhead = Sk.builtin.asnum$(newhead);\n checkArgs(2, arguments.length, 'setheading()');\n return self.theTurtle.set_heading(newhead);\n });\n $loc.seth = $loc.setheading;\n $loc.home = new Sk.builtin.func(function (self) {\n self.theTurtle.go_home();\n });\n $loc.dot = new Sk.builtin.func(function (self, size, color) {\n size = Sk.builtin.asnum$(size);\n size = size || 1;\n if (color) {\n color = color.v || self.theTurtle.penStyle;\n }\n self.theTurtle.dot(size, color);\n });\n $loc.circle = new Sk.builtin.func(function (self, radius, extent) {\n radius = Sk.builtin.asnum$(radius);\n extent = Sk.builtin.asnum$(extent);\n self.theTurtle.circle(radius, extent);\n });\n $loc.delay = new Sk.builtin.func(function (self, d) {\n d = Sk.builtin.asnum$(d);\n return self.theTurtle.delay(d);\n });\n $loc.speed = new Sk.builtin.func(function (self, s, t) {\n s = Sk.builtin.asnum$(s);\n t = Sk.builtin.asnum$(t);\n self.theTurtle.speed(s, t);\n });\n $loc.tracer = new Sk.builtin.func(function (self, t, d) {\n t = Sk.builtin.asnum$(t);\n d = Sk.builtin.asnum$(d);\n self.theTurtle.tracer(t, d);\n });\n $loc.update = new Sk.builtin.func(function (self) {});\n // todo: stamp, clearstamp, clearstamps, undo, speed\n //\n // Tell Turtle's state\n //\n $loc.heading = new Sk.builtin.func(function (self) {\n checkArgs(1, arguments.length, 'heading()');\n return Sk.builtin.assk$(self.theTurtle.get_heading(), Sk.builtin.nmber.float$);\n });\n $loc.position = new Sk.builtin.func(function (self) {\n checkArgs(1, arguments.length, 'position()');\n var res = self.theTurtle.get_position(),\n x = new Sk.builtin.tuple([\n Sk.builtin.assk$(res[0], Sk.builtin.nmber.float$),\n Sk.builtin.assk$(res[1], Sk.builtin.nmber.float$)\n ]);\n return x;\n });\n $loc.pos = $loc.position;\n $loc.xcor = new Sk.builtin.func(function (self) {\n checkArgs(1, arguments.length, 'xcor()');\n var res = self.theTurtle.getx();\n return Sk.builtin.assk$(res, Sk.builtin.nmber.float$);\n });\n $loc.ycor = new Sk.builtin.func(function (self) {\n checkArgs(1, arguments.length, 'ycor()');\n var res = self.theTurtle.gety();\n return Sk.builtin.assk$(res, Sk.builtin.nmber.float$);\n });\n $loc.towards = new Sk.builtin.func(function (self, tx, ty) {\n tx = Sk.builtin.asnum$(tx);\n ty = Sk.builtin.asnum$(ty);\n if ((typeof tx).toLowerCase() === 'number') {\n tx = [ tx, ty, 0 ];\n } else {\n tx = [\n Sk.builtin.asnum$(tx.theTurtle.getx()),\n Sk.builtin.asnum$(tx.theTurtle.gety()),\n Sk.builtin.asnum$(0)\n ];\n }\n return Sk.builtin.assk$(self.theTurtle.towards(tx), Sk.builtin.nmber.float$);\n });\n // tx can be either a number or a vector position.\n // tx can not be a turtle at this time as multiple turtles have not been implemented yet.\n $loc.distance = new Sk.builtin.func(function (self, tx, ty) {\n tx = Sk.builtin.asnum$(tx);\n ty = Sk.builtin.asnum$(ty);\n if ((typeof tx).toLowerCase() === 'number') {\n tx = [\n tx,\n ty,\n 0\n ];\n } else {\n tx = [\n tx.theTurtle.getx(),\n tx.theTurtle.gety(),\n 0\n ];\n }\n return Sk.builtin.assk$(self.theTurtle.distance(tx), Sk.builtin.nmber.float$);\n });\n //\n // Setting and Measurement\n //\n // todo: degrees and radians...\n //\n // Pen Control\n //\n //\n // Drawing State\n //\n $loc.up = new Sk.builtin.func(function (self) {\n checkArgs(1, arguments.length, 'up()');\n self.theTurtle.pen_up();\n });\n $loc.penup = $loc.up;\n $loc.pu = $loc.up;\n $loc.down = new Sk.builtin.func(function (self) {\n checkArgs(1, arguments.length, 'down()');\n self.theTurtle.pen_down();\n });\n $loc.pendown = $loc.down;\n $loc.pd = $loc.down;\n $loc.width = new Sk.builtin.func(function (self, w) {\n w = Sk.builtin.asnum$(w);\n checkArgs(2, arguments.length, 'width()');\n self.theTurtle.set_pen_width(w);\n });\n $loc.pensize = $loc.width;\n $loc.isdown = new Sk.builtin.func(function (self) {\n checkArgs(1, arguments.length, 'isdown()');\n return self.theTurtle.get_pen();\n });\n // todo: pen -- return a dictionary full of pen stuff\n //\n // Color Control\n //\n $loc.fillcolor = new Sk.builtin.func(function (self, color, green, blue) {\n if (color) {\n if (blue) {\n color = Sk.builtin.asnum$(color);\n green = Sk.builtin.asnum$(green);\n blue = Sk.builtin.asnum$(blue);\n self.theTurtle.set_fill_color(color, green, blue);\n } else {\n color = color.v || self.theTurtle.context.fillStyle;\n self.theTurtle.set_fill_color(color);\n }\n } else {\n return self.theTurtle.fillStyle;\n }\n });\n $loc.pencolor = new Sk.builtin.func(function (self, color, green, blue) {\n if (color) {\n if (blue) {\n color = Sk.builtin.asnum$(color);\n green = Sk.builtin.asnum$(green);\n blue = Sk.builtin.asnum$(blue);\n self.theTurtle.set_pen_color(color, green, blue);\n } else {\n color = color.v || self.theTurtle.context.fillStyle;\n self.theTurtle.set_pen_color(color);\n }\n } else {\n return self.theTurtle.penStyle;\n }\n });\n $loc.color = new Sk.builtin.func(function (self, color, green, blue) {\n if (color) {\n if (blue) {\n color = Sk.builtin.asnum$(color);\n green = Sk.builtin.asnum$(green);\n blue = Sk.builtin.asnum$(blue);\n self.theTurtle.set_pen_color(color, green, blue);\n self.theTurtle.set_fill_color(color, green, blue);\n } else {\n color = color.v || self.theTurtle.context.fillStyle;\n self.theTurtle.set_pen_color(color);\n self.theTurtle.set_fill_color(color);\n }\n } else {\n return [\n self.theTurtle.penStyle,\n self.theTurtle.fillStyle\n ];\n }\n });\n //\n // Filling\n //\n $loc.begin_fill = new Sk.builtin.func(function (self) {\n checkArgs(1, arguments.length, 'begin_fill()');\n self.theTurtle.begin_fill();\n });\n $loc.end_fill = new Sk.builtin.func(function (self) {\n checkArgs(1, arguments.length, 'end_fill()');\n self.theTurtle.end_fill();\n });\n $loc.fill = new Sk.builtin.func(function (self, fillt) {\n if (fillt === undefined) {\n return self.theTurtle.filling;\n }\n if (fillt) {\n self.theTurtle.begin_fill();\n } else {\n self.theTurtle.end_fill();\n }\n });\n //\n // More drawing control\n //\n $loc.reset = new Sk.builtin.func(function (self) {\n self.theTurtle.clean();\n });\n $loc.showturtle = new Sk.builtin.func(function (self) {\n checkArgs(1, arguments.length, 'showturtle()');\n self.theTurtle.showturtle();\n });\n $loc.st = $loc.showturtle;\n $loc.hideturtle = new Sk.builtin.func(function (self) {\n checkArgs(1, arguments.length, 'hideturtle()');\n self.theTurtle.hideturtle();\n });\n $loc.ht = $loc.hideturtle;\n $loc.isvisible = new Sk.builtin.func(function (self) {\n checkArgs(1, arguments.length, 'isvisible()');\n self.theTurtle.isvisible();\n });\n $loc.stamp = new Sk.builtin.func(function (self) {\n checkArgs(1, arguments.length, 'stamp()');\n self.theTurtle.stamp();\n });\n $loc.shape = new Sk.builtin.func(function (self, s) {\n checkArgs(2, arguments.length, 'shape()');\n self.theTurtle.shape(s.v);\n });\n //todo the move, align, and font parameters should be kwargs...\n $loc.write = new Sk.builtin.func(function (self, mystr, move, align, font) {\n self.theTurtle.write(mystr.v, /*move, align, */font);\n });\n //todo clean -- again multiple turtles\n $loc.setworldcoordinates = new Sk.builtin.func(function (self, llx, lly, urx, ury) {\n llx = Sk.builtin.asnum$(llx);\n lly = Sk.builtin.asnum$(lly);\n urx = Sk.builtin.asnum$(urx);\n ury = Sk.builtin.asnum$(ury);\n self.theTurtle.setworldcoordinates(llx, lly, urx, ury);\n });\n //Added by RNL\n $loc.clear = new Sk.builtin.func(function (self) {\n self.theTurtle.clear();\n });\n },\n screen = function ($gbl, $loc) {\n $loc.__init__ = new Sk.builtin.func(function (self) {\n\t\t\t\tinitializeTurtlegraphics();\n var currentCanvas = TurtleGraphics.canvasLib[TurtleGraphics.defaults.canvasID];\n if (currentCanvas === undefined) {\n self.theScreen = new TurtleGraphics.TurtleCanvas(TurtleGraphics.defaults);\n } else {\n self.theScreen = currentCanvas;\n }\n });\n $loc.bgcolor = new Sk.builtin.func(function (self, c) {\n self.theScreen.bgcolor(c);\n });\n $loc.setworldcoordinates = new Sk.builtin.func(function (self, llx, lly, urx, ury) {\n llx = Sk.builtin.asnum$(llx);\n lly = Sk.builtin.asnum$(lly);\n urx = Sk.builtin.asnum$(urx);\n ury = Sk.builtin.asnum$(ury);\n self.theScreen.setworldcoordinates(llx, lly, urx, ury);\n });\n $loc.exitonclick = new Sk.builtin.func(function (self) {\n self.theScreen.exitonclick();\n });\n $loc.title = new Sk.builtin.func(function (self, titlestring) {});\n $loc.window_width = new Sk.builtin.func(function (self) {\n return Sk.builtin.assk$(self.theScreen.window_width(), Sk.builtin.nmber.int$);\n });\n $loc.window_height = new Sk.builtin.func(function (self) {\n return Sk.builtin.assk$(self.theScreen.window_height(), Sk.builtin.nmber.int$);\n });\n $loc.turtles = new Sk.builtin.func(function (self) {\n return self.theScreen.turtles();\n });\n $loc.colormode = new Sk.builtin.func(function (self) {});\n // $loc.clear = new Sk.builtin.func(function(self) {\n //\n // });\n var myfunc = function (self, width, height, startx, starty) {\n width = Sk.builtin.asnum$(width);\n height = Sk.builtin.asnum$(height);\n self.theScreen.setup(width, height);\n };\n // this should allow for named parameters\n myfunc.co_varnames = [\n 'self',\n 'width',\n 'height',\n 'startx',\n 'starty'\n ];\n myfunc.$defaults = [\n null,\n 500,\n 500,\n 0,\n 0\n ];\n $loc.setup = new Sk.builtin.func(myfunc);\n };\n // First we create an object, this will end up being the class\n // class\n Sk.tg = TurtleGraphics;\n mod.Turtle = Sk.misceval.buildClass(mod, turtle, 'Turtle', []);\n mod.Screen = Sk.misceval.buildClass(mod, screen, 'Screen', []);\n mod.tracer = new Sk.builtin.func(function (t, d) {\n var i;\n t = Sk.builtin.asnum$(t);\n d = Sk.builtin.asnum$(d);\n for (i = 0; i < Sk.tg.canvasLib.length; i = i + 1) {\n Sk.tg.canvasLib[i].tracer(t, d);\n }\n });\n mod.update = new Sk.builtin.func(function (self) {});\n return mod;\n};\n", "src/lib/webgl/math.js": "var $builtinmodule = function(name)\n{\n var mod = {};\n\n // todo; should probably put this in a math package\n mod.Mat44 = Sk.misceval.buildClass(mod, function($gbl, $loc)\n {\n $loc.__init__ = new Sk.builtin.func(function(self)\n {\n Sk.misceval.callsim($loc.loadIdentity, self);\n self.stack = [];\n });\n\n $loc.push = new Sk.builtin.func(function(self)\n {\n self.stack.push(self.elements.slice(0));\n });\n\n $loc.pop = new Sk.builtin.func(function(self)\n {\n self.elements = self.stack.pop();\n });\n\n $loc.loadIdentity = new Sk.builtin.func(function(self)\n {\n self.elements = [1.0, 0.0, 0.0, 0.0,\n 0.0, 1.0, 0.0, 0.0,\n 0.0, 0.0, 1.0, 0.0,\n 0.0, 0.0, 0.0, 1.0];\n });\n\n $loc.transform3 = new Sk.builtin.func(function(self, v)\n {\n var e = self.elements;\n return Sk.misceval.callsim(mod.Vec3,\n e[0] * v.x + e[4] * v.y + e[8] * v.z,\n e[1] * v.x + e[5] * v.y + e[9] * v.z,\n e[2] * v.x + e[6] * v.y + e[10] * v.z);\n });\n\n $loc.scale = new Sk.builtin.func(function(self, sx, sy, sz)\n {\n self.elements[0*4+0] *= sx;\n self.elements[0*4+1] *= sx;\n self.elements[0*4+2] *= sx;\n self.elements[0*4+3] *= sx;\n\n self.elements[1*4+0] *= sy;\n self.elements[1*4+1] *= sy;\n self.elements[1*4+2] *= sy;\n self.elements[1*4+3] *= sy;\n\n self.elements[2*4+0] *= sz;\n self.elements[2*4+1] *= sz;\n self.elements[2*4+2] *= sz;\n self.elements[2*4+3] *= sz;\n\n return self;\n });\n\n $loc.translate = new Sk.builtin.func(function(self, tx, ty, tz)\n {\n self.elements[3*4+0] += self.elements[0*4+0] * tx + self.elements[1*4+0] * ty + self.elements[2*4+0] * tz;\n self.elements[3*4+1] += self.elements[0*4+1] * tx + self.elements[1*4+1] * ty + self.elements[2*4+1] * tz;\n self.elements[3*4+2] += self.elements[0*4+2] * tx + self.elements[1*4+2] * ty + self.elements[2*4+2] * tz;\n self.elements[3*4+3] += self.elements[0*4+3] * tx + self.elements[1*4+3] * ty + self.elements[2*4+3] * tz;\n return self;\n });\n\n $loc.rotate = new Sk.builtin.func(function(self, angle, x, y, z)\n {\n var mag = Math.sqrt(x*x + y*y + z*z);\n var sinAngle = Math.sin(angle * Math.PI / 180.0);\n var cosAngle = Math.cos(angle * Math.PI / 180.0);\n\n if (mag > 0)\n {\n var xx, yy, zz, xy, yz, zx, xs, ys, zs;\n var oneMinusCos;\n var rotMat;\n\n x /= mag;\n y /= mag;\n z /= mag;\n\n xx = x * x;\n yy = y * y;\n zz = z * z;\n xy = x * y;\n yz = y * z;\n zx = z * x;\n xs = x * sinAngle;\n ys = y * sinAngle;\n zs = z * sinAngle;\n oneMinusCos = 1.0 - cosAngle;\n\n rotMat = Sk.misceval.callsim(mod.Mat44);\n\n rotMat.elements[0*4+0] = (oneMinusCos * xx) + cosAngle;\n rotMat.elements[0*4+1] = (oneMinusCos * xy) - zs;\n rotMat.elements[0*4+2] = (oneMinusCos * zx) + ys;\n rotMat.elements[0*4+3] = 0.0;\n\n rotMat.elements[1*4+0] = (oneMinusCos * xy) + zs;\n rotMat.elements[1*4+1] = (oneMinusCos * yy) + cosAngle;\n rotMat.elements[1*4+2] = (oneMinusCos * yz) - xs;\n rotMat.elements[1*4+3] = 0.0;\n\n rotMat.elements[2*4+0] = (oneMinusCos * zx) - ys;\n rotMat.elements[2*4+1] = (oneMinusCos * yz) + xs;\n rotMat.elements[2*4+2] = (oneMinusCos * zz) + cosAngle;\n rotMat.elements[2*4+3] = 0.0;\n\n rotMat.elements[3*4+0] = 0.0;\n rotMat.elements[3*4+1] = 0.0;\n rotMat.elements[3*4+2] = 0.0;\n rotMat.elements[3*4+3] = 1.0;\n\n rotMat = rotMat.multiply(self);\n self.elements = rotMat.elements;\n }\n return self;\n });\n\n $loc.multiply = new Sk.builtin.func(function(self, right)\n {\n var tmp = Sk.misceval.callsim(mod.Mat44);\n\n for (var i = 0; i < 4; i++)\n {\n tmp.elements[i*4+0] =\n (self.elements[i*4+0] * right.elements[0*4+0]) +\n (self.elements[i*4+1] * right.elements[1*4+0]) +\n (self.elements[i*4+2] * right.elements[2*4+0]) +\n (self.elements[i*4+3] * right.elements[3*4+0]) ;\n\n tmp.elements[i*4+1] =\n (self.elements[i*4+0] * right.elements[0*4+1]) +\n (self.elements[i*4+1] * right.elements[1*4+1]) +\n (self.elements[i*4+2] * right.elements[2*4+1]) +\n (self.elements[i*4+3] * right.elements[3*4+1]) ;\n\n tmp.elements[i*4+2] =\n (self.elements[i*4+0] * right.elements[0*4+2]) +\n (self.elements[i*4+1] * right.elements[1*4+2]) +\n (self.elements[i*4+2] * right.elements[2*4+2]) +\n (self.elements[i*4+3] * right.elements[3*4+2]) ;\n\n tmp.elements[i*4+3] =\n (self.elements[i*4+0] * right.elements[0*4+3]) +\n (self.elements[i*4+1] * right.elements[1*4+3]) +\n (self.elements[i*4+2] * right.elements[2*4+3]) +\n (self.elements[i*4+3] * right.elements[3*4+3]) ;\n }\n\n self.elements = tmp.elements;\n return self;\n });\n\n /* Following gluLookAt implementation is adapted from\n * the Mesa 3D Graphics library. http://www.mesa3d.org\n */\n // todo; rewrite this with proper vec/mat ops\n $loc.lookAt = new Sk.builtin.func(function(self, eyeX, eyeY, eyeZ,\n centerX, centerY, centerZ,\n upX, upY, upZ)\n {\n /* Z vector */\n var z = [\n eyeX - centerX,\n eyeY - centerY,\n eyeZ - centerZ\n ];\n var mag = Math.sqrt(z[0] * z[0] + z[1] * z[1] + z[2] * z[2]);\n if (mag)\n {\n z[0] /= mag;\n z[1] /= mag;\n z[2] /= mag;\n }\n\n /* Y vector */\n var y = [ upX, upY, upZ ];\n\n /* X vector = Y cross Z */\n var x = [];\n x[0] = y[1] * z[2] - y[2] * z[1];\n x[1] = -y[0] * z[2] + y[2] * z[0];\n x[2] = y[0] * z[1] - y[1] * z[0];\n\n /* Recompute Y = Z cross X */\n y[0] = z[1] * x[2] - z[2] * x[1];\n y[1] = -z[0] * x[2] + z[2] * x[0];\n y[2] = z[0] * x[1] - z[1] * x[0];\n\n /* mpichler, 19950515 */\n /* cross product gives area of parallelogram, which is < 1.0 for\n * non-perpendicular unit-length vectors; so normalize x, y here\n */\n\n mag = Math.sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);\n if (mag) {\n x[0] /= mag;\n x[1] /= mag;\n x[2] /= mag;\n }\n\n mag = Math.sqrt(y[0] * y[0] + y[1] * y[1] + y[2] * y[2]);\n if (mag) {\n y[0] /= mag;\n y[1] /= mag;\n y[2] /= mag;\n }\n\n var lookAt = Sk.misceval.callsim(mod.Mat44);\n lookAt.elements[0 * 4 + 0] = x[0];\n lookAt.elements[1 * 4 + 0] = x[1];\n lookAt.elements[2 * 4 + 0] = x[2];\n lookAt.elements[3 * 4 + 0] = 0.;\n lookAt.elements[0 * 4 + 1] = y[0];\n lookAt.elements[1 * 4 + 1] = y[1];\n lookAt.elements[2 * 4 + 1] = y[2];\n lookAt.elements[3 * 4 + 1] = 0.;\n lookAt.elements[0 * 4 + 2] = z[0];\n lookAt.elements[1 * 4 + 2] = z[1];\n lookAt.elements[2 * 4 + 2] = z[2];\n lookAt.elements[3 * 4 + 2] = 0.;\n lookAt.elements[0 * 4 + 3] = 0.;\n lookAt.elements[1 * 4 + 3] = 0.;\n lookAt.elements[2 * 4 + 3] = 0.;\n lookAt.elements[3 * 4 + 3] = 1.;\n\n // log(lookAt.elements);\n\n lookAt = lookAt.multiply(self);\n self.elements = lookAt.elements;\n self.translate(-eyeX, -eyeY, -eyeZ);\n\n // log(this.elements);\n\n return self;\n });\n },\n 'Mat44', []);\n\n // todo; should probably put this in a math package\n mod.Mat33 = Sk.misceval.buildClass(mod, function($gbl, $loc)\n {\n $loc.__init__ = new Sk.builtin.func(function(self)\n {\n Sk.misceval.callsim($loc.loadIdentity, self);\n });\n\n $loc.loadIdentity = new Sk.builtin.func(function(self)\n {\n self.elements = [1.0, 0.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 0.0, 1.0];\n });\n },\n 'Mat33', []);\n\n mod.Vec3 = Sk.misceval.buildClass(mod, function($gbl, $loc)\n {\n $loc.__init__ = new Sk.builtin.func(function(self, x, y, z)\n {\n self.x = x;\n self.y = y;\n self.z = z;\n });\n $loc.__sub__ = new Sk.builtin.func(function(self, other)\n {\n return Sk.misceval.callsim(mod.Vec3, self.x - other.x, self.y - other.y, self.z - other.z);\n });\n },\n 'Vec3', []);\n \n mod.cross = new Sk.builtin.func(function(v1, v2)\n {\n goog.asserts.assert(v1 instanceof mod.Vec3 && v2 instanceof mod.Vec3);\n return Sk.misceval.callsim(mod.Vec3,\n v1.y * v2.z - v1.z * v2.y,\n v1.z * v2.x - v1.x * v2.z,\n v1.x * v2.y - v1.y * v2.x);\n });\n\n return mod;\n};\n", "src/lib/pythonds/graphs/__init__.py": "\n\nfrom .adjGraph import Graph\nfrom .adjGraph import Vertex\nfrom .priorityQueue import PriorityQueue\n", "src/lib/pythonds/graphs/priorityQueue.py": "# Bradley N. Miller, David L. Ranum\n# Introduction to Data Structures and Algorithms in Python\n# Copyright 2005\n# \nimport unittest\n\n# this implementation of binary heap takes key value pairs,\n# we will assume that the keys are all comparable\n\nclass PriorityQueue:\n def __init__(self):\n self.heapArray = [(0,0)]\n self.currentSize = 0\n\n def buildHeap(self,alist):\n self.currentSize = len(alist)\n self.heapArray = [(0,0)]\n for i in alist:\n self.heapArray.append(i)\n i = len(alist) // 2 \n while (i > 0):\n self.percDown(i)\n i = i - 1\n \n def percDown(self,i):\n while (i * 2) <= self.currentSize:\n mc = self.minChild(i)\n if self.heapArray[i][0] > self.heapArray[mc][0]:\n tmp = self.heapArray[i]\n self.heapArray[i] = self.heapArray[mc]\n self.heapArray[mc] = tmp\n i = mc\n \n def minChild(self,i):\n if i*2 > self.currentSize:\n return -1\n else:\n if i*2 + 1 > self.currentSize:\n return i*2\n else:\n if self.heapArray[i*2][0] < self.heapArray[i*2+1][0]:\n return i*2\n else:\n return i*2+1\n\n def percUp(self,i):\n while i // 2 > 0:\n if self.heapArray[i][0] < self.heapArray[i//2][0]:\n tmp = self.heapArray[i//2]\n self.heapArray[i//2] = self.heapArray[i]\n self.heapArray[i] = tmp\n i = i//2\n \n def add(self,k):\n self.heapArray.append(k)\n self.currentSize = self.currentSize + 1\n self.percUp(self.currentSize)\n\n def delMin(self):\n retval = self.heapArray[1][1]\n self.heapArray[1] = self.heapArray[self.currentSize]\n self.currentSize = self.currentSize - 1\n self.heapArray.pop()\n self.percDown(1)\n return retval\n \n def isEmpty(self):\n if self.currentSize == 0:\n return True\n else:\n return False\n\n def decreaseKey(self,val,amt):\n # this is a little wierd, but we need to find the heap thing to decrease by\n # looking at its value\n done = False\n i = 1\n myKey = 0\n while not done and i <= self.currentSize:\n if self.heapArray[i][1] == val:\n done = True\n myKey = i\n else:\n i = i + 1\n if myKey > 0:\n self.heapArray[myKey] = (amt,self.heapArray[myKey][1])\n self.percUp(myKey)\n \n def __contains__(self,vtx):\n for pair in self.heapArray:\n if pair[1] == vtx:\n return True\n return False\n \nclass TestBinHeap(unittest.TestCase):\n def setUp(self):\n self.theHeap = PriorityQueue()\n self.theHeap.add((2,'x'))\n self.theHeap.add((3,'y'))\n self.theHeap.add((5,'z'))\n self.theHeap.add((6,'a'))\n self.theHeap.add((4,'d'))\n\n\n def testInsert(self):\n assert self.theHeap.currentSize == 5\n\n def testDelmin(self):\n assert self.theHeap.delMin() == 'x'\n assert self.theHeap.delMin() == 'y'\n \n def testDecKey(self):\n self.theHeap.decreaseKey('d',1)\n assert self.theHeap.delMin() == 'd'\n \nif __name__ == '__main__':\n unittest.main()\n", "src/lib/pythonds/__init__.py": "", "src/lib/pythonds/basic/deque.py": "# Bradley N. Miller, David L. Ranum\n# Introduction to Data Structures and Algorithms in Python\n# Copyright 2005\n# \n#deque.py\r\n\r\n\r\nclass Deque:\r\n def __init__(self):\r\n self.items = []\r\n\r\n def isEmpty(self):\r\n return self.items == []\r\n\r\n def addFront(self, item):\r\n self.items.append(item)\r\n\r\n def addRear(self, item):\r\n self.items.insert(0,item)\r\n\r\n def removeFront(self):\r\n return self.items.pop()\r\n\r\n def removeRear(self):\r\n return self.items.pop(0)\r\n\r\n def size(self):\r\n return len(self.items)\r\n", "src/lib/processing/__init__.js": "var $builtinmodule = function(name)\n{\n var mod = {};\n var imList = [];\n var looping = true;\n\n // We need this to store a reference to the actual processing object which is not created\n // until the run function is called. Even then the processing object is passed by the\n // processing-js sytem as a parameter to the sketchProc function. Why not set it to None here\n //\n\n // See: http://processingjs.org/reference/\n\n mod.processing = null\n mod.p = null\n\n mod.CENTER = Sk.builtin.assk$(3, Sk.builtin.nmber.int$);\n mod.RADIUS = Sk.builtin.assk$(2, Sk.builtin.nmber.int$);\n mod.CORNERS = Sk.builtin.assk$(1, Sk.builtin.nmber.int$);\n mod.CORNER = Sk.builtin.assk$(0, Sk.builtin.nmber.int$);\n mod.RGB = Sk.builtin.assk$(1, Sk.builtin.nmber.int$);\n mod.HSB = Sk.builtin.assk$(3, Sk.builtin.nmber.int$);\n mod.CMYK = Sk.builtin.assk$(5, Sk.builtin.nmber.int$);\n mod.MITER = new Sk.builtin.str('miter');\n mod.BEVEL = new Sk.builtin.str('bevel');\n mod.ROUND = new Sk.builtin.str('round');\n mod.SQUARE = new Sk.builtin.str('butt');\n mod.PROJECT = new Sk.builtin.str('square');\n\n// 2D - Primitives\n mod.line = new Sk.builtin.func(function(x1, y1, x2, y2) {\n mod.processing.line(x1.v, y1.v, x2.v, y2.v);\n });\n \n mod.ellipse = new Sk.builtin.func(function(x,y,r1,r2) {\n mod.processing.ellipse(x.v,y.v,r1.v,r2.v)\n \n });\n\n mod.text = new Sk.builtin.func(function(theText, x, y) {\n mod.processing.text(theText.v, x.v, y.v);\n });\n\n mod.point = new Sk.builtin.func(function(x1,y1) {\n mod.processing.point(x1.v,y1.v)\n });\n \n mod.arc = new Sk.builtin.func(function(x, y, width, height, start, stop) {\n mod.processing.arc(x.v, y.v, width.v, height.v, start.v, stop.v)\n });\n\n mod.quad = new Sk.builtin.func(function(x1, y1, x2, y2, x3, y3, x4, y4) {\n mod.processing.quad(x1.v, y1.v, x2.v, y2.v, x3.v, y3.v, x4.v, y4.v)\n });\n \n mod.rect = new Sk.builtin.func(function(x, y, width, height, radius) {\n if (typeof(radius) == 'undefined') {\n var rad = 0\n } else {\n var rad = radius.v\n }\n mod.processing.rect(x.v, y.v, width.v, height.v, rad)\n });\n \n mod.triangle = new Sk.builtin.func(function(x1, y1, x2, y2, x3, y3) {\n mod.processing.triangle(x1.v, y1.v, x2.v, y2.v, x3.v, y3.v)\n });\n \n\n // 3D Primitives\n\n // todo: box, sphere, sphereDetail\n\n // Color\n mod.background = new Sk.builtin.func(function(r,g,b) {\n\n if (typeof(g) !== 'undefined')\n g = g.v\n if (typeof(b) !== 'undefined')\n b = b.v\n\n mod.processing.background(r.v,g,b)\n \n });\n\n mod.fill = new Sk.builtin.func(function(r,g,b) {\n // r will be either:\n // a number in which case the fill will be grayscale\n // a color object\n // g, and b may be undefined. If they hold values it will\n // be assumed that we have an r,g,b color tuple\n if (typeof(g) !== 'undefined')\n g = g.v\n if (typeof(b) !== 'undefined')\n b = b.v\n \n mod.processing.fill(r.v,g,b)\n \n });\n\n\n mod.stroke = new Sk.builtin.func(function(r,g,b) {\n\n if (typeof(g) !== 'undefined')\n g = g.v\n if (typeof(b) !== 'undefined')\n b = b.v\n\n mod.processing.stroke(r.v,g,b)\n \n });\n\n mod.noStroke = new Sk.builtin.func(function() {\n mod.processing.noStroke()\n });\n \n\n mod.colorMode = new Sk.builtin.func(function(model, maxV) {\n if (typeof(maxV) === 'undefined')\n maxV = 255\n else\n maxV = maxV.v\n mod.processing.colorMode(model.v, maxV)\n });\n\n mod.noFill = new Sk.builtin.func(function() {\n mod.processing.noFill()\n });\n \n\n // Environment\n\n mod.loop = new Sk.builtin.func(function() {\n if (mod.processing === null) {\n throw new Sk.builtin.Exception(\"Loop should be called in setup\")\n }\n looping = true;\n mod.processing.loop()\n });\n \n mod.noLoop = new Sk.builtin.func(function() {\n if (mod.processing === null) {\n throw new Sk.builtin.Exception(\"noLoop should be called in setup\")\n }\n looping = false;\n mod.processing.noLoop()\n });\n \n mod.frameRate = new Sk.builtin.func(function(fr) {\n mod.processing.frameRate(fr.v)\n \n });\n\n mod.size = new Sk.builtin.func(function(h,w) {\n mod.processing.size(h.v,w.v)\n \n });\n\n mod.exitp = new Sk.builtin.func(function(h,w) {\n mod.processing.exit()\n });\n\n\n mod.mouseX = new Sk.builtin.func(function() {\n return Sk.builtin.assk$(mod.processing.mouseX, Sk.builtin.nmber.int$);\n \n });\n\n mod.mouseY = new Sk.builtin.func(function() {\n return Sk.builtin.assk$(mod.processing.mouseY, Sk.builtin.nmber.int$);\n \n });\n\n // Attributes\n mod.rectMode = new Sk.builtin.func(function(mode) {\n mod.processing.rectMode(mode.v)\n });\n\n mod.strokeWeight = new Sk.builtin.func(function(wt) {\n mod.processing.strokeWeight(wt.v)\n \n });\n\n mod.smooth = new Sk.builtin.func(function() {\n mod.processing.smooth()\n });\n\n mod.noSmooth = new Sk.builtin.func(function() {\n mod.processing.noSmooth()\n });\n \n mod.ellipseMode = new Sk.builtin.func(function(mode) {\n mod.processing.ellipseMode(mode.v)\n });\n\n mod.strokeCap = new Sk.builtin.func(function(mode) {\n mod.processing.strokeCap(mode.v)\n });\n\n mod.strokeJoin = new Sk.builtin.func(function(mode) {\n mod.processing.strokeJoin(mode.v)\n });\n \n\n\n // Transforms\n\n mod.rotate = new Sk.builtin.func(function(rads) {\n // rotation in radians\n mod.processing.rotate(rads.v)\n \n });\n\n mod.scale = new Sk.builtin.func(function(sx, sy, sz) {\n if (typeof(sy) == 'undefined') {\n sy = 1.0\n } else \n sy = sy.v\n if (typeof(sz) == 'undefined') {\n sz = 1.0\n } else\n sz = sz.v\n mod.processing.scale(sx.v, sy, sz)\n });\n\n mod.translate = new Sk.builtin.func(function(sx, sy, sz) {\n if (typeof(sy) == 'undefined') {\n sy = 1.0\n } else \n sy = sy.v\n if (typeof(sz) == 'undefined') {\n sz = 1.0\n } else\n sz = sz.v\n mod.processing.translate(sx.v, sy, sz)\n });\n\n // todo: applyMatrix, popMatrix, printMatrix??, pushMatrix, resetMatrix, rotate{X,Y,Z}\n \n\n // //////////////////////////////////////////////////////////////////////\n // Run\n // \n // Create the processing context and setup of calls to setup, draw etc.\n //\n //\n // ////////////////////////////////////////////////////////////////////// \n mod.run = new Sk.builtin.func(function() {\n function sketchProc(processing) {\n mod.processing = processing\n\n // processing.setup = function() {\n // if Sk.globals['setup']\n // Sk.misceval.callsim(Sk.globals['setup'])\n // }\n\n \n processing.draw = function() {\n // if there are pending image loads then just use the natural looping calls to \n // retry until all the images are loaded. If noLoop was called in setup then make\n // sure to revert to that after all the images in hand.\n var wait = false\n for (var i in imList) {\n if (imList[i].width == 0) {\n wait = true\n }\n }\n if (wait == true) {\n if (looping == true) \n return\n else {\n processing.loop()\n return\n }\n\n } else {\n if (looping == false)\n processing.noLoop()\n }\n\n mod.frameCount = processing.frameCount \n if (Sk.globals['draw'])\n Sk.misceval.callsim(Sk.globals['draw'])\n }\n \n var callBacks = ['setup', 'mouseMoved','mouseClicked', 'mouseDragged', 'mouseMoved', 'mouseOut',\n 'mouseOver', 'mousePressed', 'mouseReleased', 'keyPressed', 'keyReleased', 'keyTyped'\n ];\n\n for(var cb in callBacks) {\n if (Sk.globals[callBacks[cb]]) {\n console.log('defining ' + callBacks[cb]) \n processing[callBacks[cb]] = new Function(\"Sk.misceval.callsim(Sk.globals['\"+callBacks[cb]+\"']);\")\n }\n }\n }\n \n var canvas = document.getElementById(Sk.canvas)\n $(canvas).show()\n mod.p = new Processing(canvas, sketchProc)\n\n \n });\n\n var mouseClass = function($gbl, $loc) {\n\n $loc.__getattr__ = new Sk.builtin.func(function(self,key) {\n if (key == 'x') \n return mod.processing.mouseX;\n else if (key == 'y') \n return mod.processing.mouseY;\n else if (key == 'px')\n return mod.processing.pmouseX;\n else if (key == 'py')\n return mod.processing.pmouseY;\n else if (key == 'pressed')\n return mod.processing.mousePressed;\n else if (key == 'button')\n return mod.processing.mouseButton\n });\n\n\n }\n\n\n mod.Mouse = Sk.misceval.buildClass(mod, mouseClass, 'Mouse', []);\n\n mod.mouse = Sk.misceval.callsim(mod.Mouse)\n\n var keyboardClass = function($gbl, $loc) {\n\n $loc.__getattr__ = new Sk.builtin.func(function(self,key) {\n if (key == 'key') {\n console.log(mod.processing.key)\n return new Sk.builtin.str(mod.processing.key.toString())\n }\n else if (key == 'keyCode') \n return mod.processing.keyCode\n else if (key == 'keyPressed')\n return new Sk.builtin.str(mod.processing.keyPressed) // todo bool\n });\n\n\n }\n\n mod.Keyboard = Sk.misceval.buildClass(mod,keyboardClass,'Keyboard', [])\n\n mod.keyboard = Sk.misceval.callsim(mod.Keyboard)\n\n\n\n var environmentClass = function($gbl, $loc) {\n\n $loc.__getattr__ = new Sk.builtin.func(function(self,key) {\n if (key == 'frameCount') \n return mod.processing.frameCount\n else if (key == 'frameRate') \n return mod.processing.frameRate\n else if (key == 'height')\n return mod.processing.height\n else if (key == 'width')\n return mod.processing.width\n else if (key == 'online')\n return mod.processing.online\n else if (key == 'focused')\n return mod.processing.focused\n });\n\n\n }\n\n mod.Environment = Sk.misceval.buildClass(mod,environmentClass,'Environment', [])\n\n mod.environment = Sk.misceval.callsim(mod.Environment)\n\n var screenClass = function($gbl, $loc) {\n\n $loc.__init__ = new Sk.builtin.func(function(self) {\n self.pixels = null;\n });\n\n $loc.__getattr__ = new Sk.builtin.func(function(self,key) {\n if (key == 'height')\n return mod.processing.height\n else if (key == 'width')\n return mod.processing.width\n else if (key == 'pixels')\n if (self.pixels == null) {\n self.pixels = new Sk.builtin.list(mod.processing.pixels.toArray())\n }\n return self.pixels\n });\n\n }\n\n mod.Screen = Sk.misceval.buildClass(mod,screenClass,'Screen', [])\n\n mod.screen = Sk.misceval.callsim(mod.Screen)\n\n mod.loadPixels = new Sk.builtin.func(function() {\n mod.processing.loadPixels()\n console.log(mod.processing.pixels)\n });\n \n\n var colorClass = function($gbl, $loc) {\n /* images are loaded async.. so its best to preload them */\n $loc.__init__ = new Sk.builtin.func(function(self, val1, val2, val3, alpha) {\n if (typeof(val2) !== 'undefined')\n val2 = val2.v\n if (typeof(val3) !== 'undefined')\n val3 = val3.v\n if (typeof(alpha) !== 'undefined')\n alpha = alpha.v\n self.v = mod.processing.color(val1.v, val2, val3, alpha)\n })\n \n }\n\n mod.color = Sk.misceval.buildClass(mod,colorClass,'color', [])\n\n mod.red = new Sk.builtin.func(function(clr) {\n return Sk.builtin.assk$(mod.processing.red(clr.v), Sk.builtin.nmber.int$);\n });\n \n mod.green = new Sk.builtin.func(function(clr) {\n return Sk.builtin.assk$(mod.processing.green(clr.v), Sk.builtin.nmber.int$);\n });\n\n mod.blue = new Sk.builtin.func(function(clr) {\n return Sk.builtin.assk$(mod.processing.blue(clr.v), Sk.builtin.nmber.int$);\n });\n\n // Image class and functions\n //\n var imageClass = function($gbl, $loc) {\n /* images are loaded async.. so its best to preload them */\n $loc.__init__ = new Sk.builtin.func(function(self,im) {\n self.v = im\n self.width = Sk.builtin.assk$(im.width, Sk.builtin.nmber.int$);\n self.height = Sk.builtin.assk$(im.height, Sk.builtin.nmber.int$);\n })\n\n $loc.__getattr__ = new Sk.builtin.func(function(self,key) {\n if (key == 'width') return self.v.width;\n if (key == 'height') return self.v.height;\n });\n \n }\n\n mod.PImage = Sk.misceval.buildClass(mod,imageClass,'PImage', [])\n\n mod.loadImage = new Sk.builtin.func(function(imfile) {\n var i = mod.processing.loadImage(imfile.v);\n imList.push(i);\n return Sk.misceval.callsim(mod.PImage,i);\n });\n \n\n mod.image = new Sk.builtin.func(function(im,x,y) {\n if (im.v.width > 0)\n mod.processing.image(im.v,x.v,y.v,im.v.width,im.v.height)\n });\n\n mod.get = new Sk.builtin.func(function(x,y) {\n var clr = mod.processing.get(x.v,y.v)\n return Sk.misceval.callsim(mod.color,\n Sk.builtin.assk$(mod.processing.red(clr), Sk.builtin.nmber.int$),\n Sk.builtin.assk$(mod.processing.green(clr), Sk.builtin.nmber.int$),\n Sk.builtin.assk$(mod.processing.blue(clr), Sk.builtin.nmber.int$));\n });\n\n mod.set = new Sk.builtin.func(function(x, y, color) {\n mod.processing.set(x.v, y.v, color.v)\n });\n \n// todo -- add a color class for creating color objects.\n\n\n return mod;\n}\n", "src/lib/webgl/models.js": "// most of this file is from/based on 'tdl'\n\nvar $builtinmodule = function(name)\n{\n var mod = {};\n\n var Buffer = function(array, opt_target) {\n var target = opt_target || gl.ARRAY_BUFFER;\n var buf = gl.createBuffer();\n this.target = target;\n this.buf = buf;\n this.set(array);\n this.numComponents_ = array.numComponents;\n this.numElements_ = array.numElements;\n this.totalComponents_ = this.numComponents_ * this.numElements_;\n if (array.buffer instanceof Float32Array) {\n this.type_ = gl.FLOAT;\n } else if (array.buffer instanceof Uint8Array) {\n this.type_ = gl.UNSIGNED_BYTE;\n } else if (array.buffer instanceof Int8Array) {\n this.type_ = gl._BYTE;\n } else if (array.buffer instanceof Uint16Array) {\n this.type_ = gl.UNSIGNED_SHORT;\n } else if (array.buffer instanceof Int16Array) {\n this.type_ = gl.SHORT;\n } else {\n throw(\"unhandled type:\" + (typeof array.buffer));\n }\n };\n\n Buffer.prototype.set = function(array) {\n gl.bindBuffer(this.target, this.buf);\n gl.bufferData(this.target, array.buffer, gl.STATIC_DRAW);\n }\n\n Buffer.prototype.type = function() {\n return this.type_;\n };\n\n Buffer.prototype.numComponents = function() {\n return this.numComponents_;\n };\n\n Buffer.prototype.numElements = function() {\n return this.numElements_;\n };\n\n Buffer.prototype.totalComponents = function() {\n return this.totalComponents_;\n };\n\n Buffer.prototype.buffer = function() {\n return this.buf;\n };\n\n Buffer.prototype.stride = function() {\n return 0;\n };\n\n Buffer.prototype.offset = function() {\n return 0;\n };\n\n\n\n mod.Model = Sk.misceval.buildClass(mod, function($gbl, $loc)\n {\n $loc.__init__ = new Sk.builtin.func(function(self, shader, arrays, textures)\n {\n self.buffers = {};\n var setBuffer = function(name, array)\n {\n var target = (name == 'indices') ? gl.ELEMENT_ARRAY_BUFFER : gl.ARRAY_BUFFER;\n b = self.buffers[name];\n if (!b)\n b = new Buffer(array, target);\n else\n b.set(array);\n self.buffers[name] = b;\n };\n for (name in arrays)\n setBuffer(name, arrays[name]);\n\n var textureUnits = {};\n var unit = 0;\n for (var texture in textures)\n {\n textureUnits[texture] = unit++;\n }\n\n self.mode = gl.TRIANGLES;\n self.textures = textures.v;\n self.textureUnits = textureUnits;\n self.shader = shader;\n });\n\n /**\n * Sets up the shared parts of drawing this model. Uses the\n * program, binds the buffers, sets the textures.\n *\n * @param {!Object.<string, *>} uniforms An object of names to\n * values to set on this models uniforms.\n */\n $loc.drawPrep = new Sk.builtin.func(function(self, uniforms)\n {\n var shader = self.shader;\n var buffers = self.buffers;\n var textures = self.textures;\n\n uniforms = Sk.ffi.remapToJs(uniforms);\n\n Sk.misceval.callsim(shader.use, shader);\n\n for (var buffer in buffers) {\n var b = buffers[buffer];\n if (buffer == 'indices') {\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, b.buffer());\n } else {\n var attrib = shader.attrib[buffer];\n if (attrib) {\n attrib(b);\n }\n }\n }\n\n for (var texture in textures) {\n var unit = self.textureUnits[texture];\n shader.setUniform$impl(shader, textuer, unit);\n textures[texture].bindToUnit(unit);\n }\n\n for (var uniform in uniforms) {\n shader.setUniform$impl(shader, uniform, uniforms[uniform]);\n }\n });\n\n /**\n * Draws this model.\n *\n * After calling tdl.models.Model.drawPrep you can call this\n * function multiple times to draw this model.\n *\n * @param {!Object.<string, *>} uniforms An object of names to\n * values to set on this models uniforms.\n */\n $loc.draw = new Sk.builtin.func(function(self, uniforms, opt_textures)\n {\n var shader = self.shader;\n uniforms = Sk.ffi.remapToJs(uniforms);\n for (uniform in uniforms) {\n shader.setUniform$impl(shader, uniform, uniforms[uniform]);\n }\n\n if (opt_textures) {\n for (var texture in opt_textures) {\n var unit = self.textureUnits[texture];\n shader.setUniform$impl(shader, texture, unit);\n opt_textures[texture].bindToUnit(unit);\n }\n }\n\n var buffers = self.buffers;\n gl.drawElements(self.mode, buffers.indices.totalComponents(), gl.UNSIGNED_SHORT, 0);\n });\n },\n 'Model', []);\n\n return mod;\n};\n", "src/lib/pythonds/trees/__init__.py": "\n# from .binaryTree import BinaryTree\n# from .balance import AVLTree\n# from .bst import BinarySearchTree\n# from .binheap import BinHeap\n\n\n", "src/lib/pythonds/trees/binaryTree.py": "# Bradley N. Miller, David L. Ranum\n# Introduction to Data Structures and Algorithms in Python\n# Copyright 2005\n# \n\nclass BinaryTree:\n \"\"\"\n A recursive implementation of Binary Tree\n Using links and Nodes approach.\n \"\"\" \n def __init__(self,rootObj):\n self.key = rootObj\n self.leftChild = None\n self.rightChild = None\n\n def insertLeft(self,newNode):\n if self.leftChild == None:\n self.leftChild = BinaryTree(newNode)\n else:\n t = BinaryTree(newNode)\n t.left = self.leftChild\n self.leftChild = t\n \n def insertRight(self,newNode):\n if self.rightChild == None:\n self.rightChild = BinaryTree(newNode)\n else:\n t = BinaryTree(newNode)\n t.right = self.rightChild\n self.rightChild = t\n\n def isLeaf(self):\n return ((not self.leftChild) and (not self.rightChild))\n\n def getRightChild(self):\n return self.rightChild\n\n def getLeftChild(self):\n return self.leftChild\n\n def setRootVal(self,obj):\n self.key = obj\n\n def getRootVal(self,):\n return self.key\n\n def inorder(self):\n if self.leftChild:\n self.leftChild.inorder()\n print(self.key)\n if self.rightChild:\n self.rightChild.inorder()\n\n def postorder(self):\n if self.leftChild:\n self.leftChild.postorder()\n if self.rightChild:\n self.rightChild.postorder()\n print(self.key)\n\n\n def preorder(self):\n print(self.key)\n if self.leftChild:\n self.leftChild.preorder()\n if self.rightChild:\n self.rightChild.preorder()\n\n def printexp(self):\n if self.leftChild:\n print('(')\n self.leftChild.printexp()\n print(self.key)\n if self.rightChild:\n self.rightChild.printexp()\n print(')')\n\n def postordereval(self):\n opers = {'+':operator.add, '-':operator.sub, '*':operator.mul, '/':operator.truediv}\n res1 = None\n res2 = None\n if self.leftChild:\n res1 = self.leftChild.postordereval() #// \\label{peleft}\n if self.rightChild:\n res2 = self.rightChild.postordereval() #// \\label{peright}\n if res1 and res2:\n return opers[self.key](res1,res2) #// \\label{peeval}\n else:\n return self.key\n\ndef inorder(tree):\n if tree != None:\n inorder(tree.getLeftChild())\n print(tree.getRootVal())\n inorder(tree.getRightChild())\n\ndef printexp(tree):\n if tree.leftChild:\n print('(')\n printexp(tree.getLeftChild())\n print(tree.getRootVal())\n if tree.rightChild:\n printexp(tree.getRightChild())\n print(')') \n\ndef printexp(tree):\n sVal = \"\"\n if tree:\n sVal = '(' + printexp(tree.getLeftChild())\n sVal = sVal + str(tree.getRootVal())\n sVal = sVal + printexp(tree.getRightChild()) + ')'\n return sVal\n\ndef postordereval(tree):\n opers = {'+':operator.add, '-':operator.sub, '*':operator.mul, '/':operator.truediv}\n res1 = None\n res2 = None\n if tree:\n res1 = postordereval(tree.getLeftChild()) #// \\label{peleft}\n res2 = postordereval(tree.getRightChild()) #// \\label{peright}\n if res1 and res2:\n return opers[tree.getRootVal()](res1,res2) #// \\label{peeval}\n else:\n return tree.getRootVal()\n\ndef height(tree):\n if tree == None:\n return -1\n else:\n return 1 + max(height(tree.leftChild),height(tree.rightChild))\n\n# t = BinaryTree(7)\n# t.insertLeft(3)\n# t.insertRight(9)\n# inorder(t)\n# import operator\n# x = BinaryTree('*')\n# x.insertLeft('+')\n# l = x.getLeftChild()\n# l.insertLeft(4)\n# l.insertRight(5)\n# x.insertRight(7)\n# print(printexp(x))\n# print(postordereval(x))\n# print(height(x))\n", "src/builtin/this.py": "s = \"\"\"Gur Mra bs Clguba, ol Gvz Crgref\n\nOrnhgvshy vf orggre guna htyl.\nRkcyvpvg vf orggre guna vzcyvpvg.\nFvzcyr vf orggre guna pbzcyrk.\nPbzcyrk vf orggre guna pbzcyvpngrq.\nSyng vf orggre guna arfgrq.\nFcnefr vf orggre guna qrafr.\nErnqnovyvgl pbhagf.\nFcrpvny pnfrf nera'g fcrpvny rabhtu gb oernx gur ehyrf.\nNygubhtu cenpgvpnyvgl orngf chevgl.\nReebef fubhyq arire cnff fvyragyl.\nHayrff rkcyvpvgyl fvyraprq.\nVa gur snpr bs nzovthvgl, ershfr gur grzcgngvba gb thrff.\nGurer fubhyq or bar-- naq cersrenoyl bayl bar --boivbhf jnl gb qb vg.\nNygubhtu gung jnl znl abg or boivbhf ng svefg hayrff lbh'er Qhgpu.\nAbj vf orggre guna arire.\nNygubhtu arire vf bsgra orggre guna *evtug* abj.\nVs gur vzcyrzragngvba vf uneq gb rkcynva, vg'f n onq vqrn.\nVs gur vzcyrzragngvba vf rnfl gb rkcynva, vg znl or n tbbq vqrn.\nAnzrfcnprf ner bar ubaxvat terng vqrn -- yrg'f qb zber bs gubfr!\"\"\"\n\nd = {}\nfor c in (65, 97):\n for i in range(26):\n d[chr(i+c)] = chr((i+13) % 26 + c)\n\nprint \"\".join([d.get(c, c) for c in s])\n", "src/lib/webgl/primitives.js": "// most of this file is from 'tdl'\n\nvar $builtinmodule = function(name)\n{\n var mod = {};\n\n\n\n /**\n * AttribBuffer manages a TypedArray as an array of vectors.\n *\n * @param {number} numComponents Number of components per\n * vector.\n * @param {number|!Array.<number>} numElements Number of vectors or the data.\n * @param {string} opt_type The type of the TypedArray to\n * create. Default = 'Float32Array'.\n * @param {!Array.<number>} opt_data The data for the array.\n */\n var AttribBuffer = function(\n numComponents, numElements, opt_type) {\n opt_type = opt_type || 'Float32Array';\n var type = window[opt_type];\n if (numElements.length) {\n this.buffer = new type(numElements);\n numElements = this.buffer.length / numComponents;\n this.cursor = numElements;\n } else {\n this.buffer = new type(numComponents * numElements);\n this.cursor = 0;\n }\n this.numComponents = numComponents;\n this.numElements = numElements;\n this.type = opt_type;\n };\n\n AttribBuffer.prototype.stride = function() {\n return 0;\n };\n\n AttribBuffer.prototype.offset = function() {\n return 0;\n };\n\n AttribBuffer.prototype.getElement = function(index) {\n var offset = index * this.numComponents;\n var value = [];\n for (var ii = 0; ii < this.numComponents; ++ii) {\n value.push(this.buffer[offset + ii]);\n }\n return value;\n };\n\n AttribBuffer.prototype.setElement = function(index, value) {\n var offset = index * this.numComponents;\n for (var ii = 0; ii < this.numComponents; ++ii) {\n this.buffer[offset + ii] = value[ii];\n }\n };\n\n AttribBuffer.prototype.clone = function() {\n var copy = new AttribBuffer(\n this.numComponents, this.numElements, this.type);\n copy.pushArray(this);\n return copy;\n }\n\n AttribBuffer.prototype.push = function(value) {\n this.setElement(this.cursor++, value);\n };\n\n AttribBuffer.prototype.pushArray = function(array) {\n // this.buffer.set(array, this.cursor * this.numComponents);\n // this.cursor += array.numElements;\n for (var ii = 0; ii < array.numElements; ++ii) {\n this.push(array.getElement(ii));\n }\n };\n\n AttribBuffer.prototype.pushArrayWithOffset =\n function(array, offset) {\n for (var ii = 0; ii < array.numElements; ++ii) {\n var elem = array.getElement(ii);\n for (var jj = 0; jj < offset.length; ++jj) {\n elem[jj] += offset[jj];\n }\n this.push(elem);\n }\n };\n\n /**\n * Computes the extents\n * @param {!AttribBuffer} positions The positions\n * @return {!{min: !tdl.math.Vector3, max:!tdl.math.Vector3}}\n * The min and max extents.\n */\n AttribBuffer.prototype.computeExtents = function() {\n var numElements = this.numElements;\n var numComponents = this.numComponents;\n var minExtent = this.getElement(0);\n var maxExtent = this.getElement(0);\n for (var ii = 1; ii < numElements; ++ii) {\n var element = this.getElement(ii);\n for (var jj = 0; jj < numComponents; ++jj) {\n minExtent[jj] = Math.min(minExtent[jj], element[jj]);\n maxExtent[jj] = Math.max(maxExtent[jj], element[jj]);\n }\n }\n return {min: minExtent, max: maxExtent};\n };\n\n\n /**\n * Creates the vertices and indices for a cube. The\n * cube will be created around the origin. (-size / 2, size / 2)\n *\n * @param {number} size Width, height and depth of the cube.\n * @return {!Object.<string, !tdl.primitives.AttribBuffer>} The\n * created plane vertices.\n */\n mod.createCube = new Sk.builtin.func(function(size)\n {\n var CUBE_FACE_INDICES_ = [\n [3, 7, 5, 1],\n [0, 4, 6, 2],\n [6, 7, 3, 2],\n [0, 1, 5, 4],\n [5, 7, 6, 4],\n [2, 3, 1, 0]\n ];\n\n var k = size / 2;\n\n var cornerVertices = [\n [-k, -k, -k],\n [+k, -k, -k],\n [-k, +k, -k],\n [+k, +k, -k],\n [-k, -k, +k],\n [+k, -k, +k],\n [-k, +k, +k],\n [+k, +k, +k]\n ];\n\n var faceNormals = [\n [+1, +0, +0],\n [-1, +0, +0],\n [+0, +1, +0],\n [+0, -1, +0],\n [+0, +0, +1],\n [+0, +0, -1]\n ];\n\n var uvCoords = [\n [0, 0],\n [1, 0],\n [1, 1],\n [0, 1]\n ];\n\n var numVertices = 6 * 4;\n var positions = new AttribBuffer(3, numVertices);\n var normals = new AttribBuffer(3, numVertices);\n var texCoords = new AttribBuffer(2, numVertices);\n var indices = new AttribBuffer(3, 6 * 2, 'Uint16Array');\n\n for (var f = 0; f < 6; ++f) {\n var faceIndices = CUBE_FACE_INDICES_[f];\n for (var v = 0; v < 4; ++v) {\n var position = cornerVertices[faceIndices[v]];\n var normal = faceNormals[f];\n var uv = uvCoords[v];\n\n // Each face needs all four vertices because the normals and texture\n // coordinates are not all the same.\n positions.push(position);\n normals.push(normal);\n texCoords.push(uv);\n\n }\n // Two triangles make a square face.\n var offset = 4 * f;\n indices.push([offset + 0, offset + 1, offset + 2]);\n indices.push([offset + 0, offset + 2, offset + 3]);\n }\n\n return {\n position: positions,\n normal: normals,\n texCoord: texCoords,\n indices: indices\n };\n });\n\n return mod;\n};\n", "src/lib/document/__init__.js": "var $builtinmodule = function(name) {\n var mod = {};\n\n mod.getElementById = new Sk.builtin.func(function(id) {\n var result = document.getElementById(id.v);\n if (result) {\n return Sk.misceval.callsim(mod.Element,result);\n }\n return Sk.builtin.none.none$;\n });\n\n mod.createElement = new Sk.builtin.func(function(eName) {\n var r = document.createElement(eName.v);\n if (r) {\n return Sk.misceval.callsim(mod.Element,r);\n }\n });\n\n\n mod.getElementsByTagName = new Sk.builtin.func(function(tag) {\n var r = document.getElementsByTagName(tag.v)\n var reslist = [];\n for (var i = r.length - 1; i >= 0; i--) {\n reslist.push(Sk.misceval.callsim(mod.Element,r[i]))\n }\n return new Sk.builtin.list(reslist)\n });\n\n mod.getElementsByClassName = new Sk.builtin.func(function(cname) {\n var r = document.getElementsByClassName(cname.v);\n var reslist = [];\n for (var i = 0; i < r.length; i++) {\n reslist.push(Sk.misceval.callsim(mod.Element,r[i]));\n };\n return new Sk.builtin.list(reslist);\n });\n \n mod.getElementsByName = new Sk.builtin.func(function(cname) {\n var r = document.getElementsByName(cname.v);\n var reslist = [];\n for (var i = 0; i < r.length; i++) {\n reslist.push(Sk.misceval.callsim(mod.Element,r[i]));\n };\n return new Sk.builtin.list(reslist);\n });\n \n mod.currentDiv = new Sk.builtin.func(function() {\n if (Sk.divid !== undefined) {\n return new Sk.builtin.str(Sk.divid)\n }\n else {\n throw new Sk.builtin.AttributeError(\"There is no value set for divid\");\n }\n })\n var elementClass = function($gbl, $loc) {\n /*\n Notes: self['$d'] is the dictionary used by the GenericGetAttr mechanism for an object.\n for various reasons if you create a class in Javascript and have self.xxxx instance\n variables, you cannot say instance.xxx and get the value of the instance variable unless \n it is stored in the self['$d'] object. This seems like a duplication of storage to me\n but that is how it works right now (5/2013)\n\n Writing your own __getattr__ is also an option but this gets very tricky when an attr is \n a method...\n */\n $loc.__init__ = new Sk.builtin.func(function(self,elem) {\n self.v = elem\n self.innerHTML = elem.innerHTML\n self.innerText = elem.innerText\n if (elem.value !== undefined) {\n self.value = elem.value\n Sk.abstr.objectSetItem(self['$d'], new Sk.builtin.str('value'), new Sk.builtin.str(self.value)) \n }\n\n if (elem.checked !== undefined) {\n self.checked = elem.checked\n Sk.abstr.objectSetItem(self['$d'], new Sk.builtin.str('checked'), new Sk.builtin.str(self.checked)) \n }\n\n Sk.abstr.objectSetItem(self['$d'], new Sk.builtin.str('innerHTML'), new Sk.builtin.str(self.innerHTML))\n Sk.abstr.objectSetItem(self['$d'], new Sk.builtin.str('innerText'), new Sk.builtin.str(self.innerText)) \n\n })\n\n $loc.tp$getattr = Sk.builtin.object.prototype.GenericGetAttr;\n\n $loc.__setattr__ = new Sk.builtin.func(function(self,key,value) {\n if (key === 'innerHTML') {\n self.innerHTML = value\n self.v.innerHTML = value.v\n Sk.abstr.objectSetItem(self['$d'], new Sk.builtin.str('innerHTML'), value) \n }\n if (key === 'innerText') {\n self.innerText = value\n self.v.innerText = value.v\n Sk.abstr.objectSetItem(self['$d'], new Sk.builtin.str('innerText'), value) \n }\n });\n\n\n $loc.appendChild = new Sk.builtin.func(function(self,ch) {\n self.v.appendChild(ch.v);\n });\n\n $loc.removeChild = new Sk.builtin.func(function(self,node) {\n self.v.removeChild(node.v)\n })\n\n // getCSS\n \n $loc.getCSS = new Sk.builtin.func(function(self,key) {\n return new Sk.builtin.str(self.v.style[key.v]);\n });\n \n\n $loc.setCSS = new Sk.builtin.func(function(self,attr,value) {\n self.v.style[attr.v] = value.v\n\n })\n\n $loc.getAttribute = new Sk.builtin.func(function(self,key) {\n var res = self.v.getAttribute(key.v)\n if (res) {\n return new Sk.builtin.str(res)\n } else {\n return Sk.builtin.none.none$;\n }\n });\n\n $loc.setAttribute = new Sk.builtin.func(function(self,attr,value) {\n self.v.setAttribute(attr.v,value.v)\n });\n \n $loc.getProperty = new Sk.builtin.func(function(self,key) {\n var res = self.v[key.v]\n if (res) {\n return new Sk.builtin.str(res)\n } else {\n return Sk.builtin.none.none$;\n }\n });\n\n $loc.__str__ = new Sk.builtin.func(function(self) {\n console.log(self.v.tagName);\n return new Sk.builtin.str(self.v.tagName)\n })\n\n $loc.__repr__ = new Sk.builtin.func(function(self) {\n return new Sk.builtin.str('[DOM Element]')\n })\n\n \n };\n\n mod.Element = Sk.misceval.buildClass(mod,elementClass,'Element', []);\n\n return mod;\n\n} ", "src/lib/webgl/matrix4.js": "// more from 'tdl'\nvar $builtinmodule = function(name)\n{\n var mod = {};\n\n var temp0v3_ = new Float32Array(3);\n var temp1v3_ = new Float32Array(3);\n var temp2v3_ = new Float32Array(3);\n\n var temp0v4_ = new Float32Array(4);\n var temp1v4_ = new Float32Array(4);\n var temp2v4_ = new Float32Array(4);\n\n var temp0m4_ = new Float32Array(16);\n var temp1m4_ = new Float32Array(16);\n var temp2m4_ = new Float32Array(16);\n\n var normalize = function(dst, a) {\n var n = 0.0;\n var aLength = a.length;\n for (var i = 0; i < aLength; ++i)\n n += a[i] * a[i];\n n = Math.sqrt(n);\n if (n > 0.00001) {\n for (var i = 0; i < aLength; ++i)\n dst[i] = a[i] / n;\n } else {\n for (var i = 0; i < aLength; ++i)\n dst[i] = 0;\n }\n return dst;\n };\n\n var cross = function(dst, a, b) {\n dst[0] = a[1] * b[2] - a[2] * b[1];\n dst[1] = a[2] * b[0] - a[0] * b[2];\n dst[2] = a[0] * b[1] - a[1] * b[0];\n return dst;\n };\n\n var subVector = function(dst, a, b) {\n var aLength = a.length;\n for (var i = 0; i < aLength; ++i)\n dst[i] = a[i] - b[i];\n return dst;\n };\n\n var dot = function(a, b) {\n return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]);\n };\n\n mod.lookAt = new Sk.builtin.func(function(view, eye, target, up)\n {\n var t0 = temp0v3_;\n var t1 = temp1v3_;\n var t2 = temp2v3_;\n\n var vz = normalize(t0, subVector(t0, eye.v, target.v));\n var vx = normalize(t1, cross(t1, up.v, vz));\n var vy = cross(t2, vz, vx);\n\n var dst = view.v;\n dst[ 0] = vx[0];\n dst[ 1] = vy[0];\n dst[ 2] = vz[0];\n dst[ 3] = 0;\n dst[ 4] = vx[1];\n dst[ 5] = vy[1];\n dst[ 6] = vz[1];\n dst[ 7] = 0;\n dst[ 8] = vx[2];\n dst[ 9] = vy[2];\n dst[10] = vz[2];\n dst[11] = 0;\n dst[12] = -dot(vx, eye.v);\n dst[13] = -dot(vy, eye.v);\n dst[14] = -dot(vz, eye.v);\n dst[15] = 1;\n\n return view;\n });\n\n mod.perspective = new Sk.builtin.func(function(proj, angle, aspect, near, far)\n {\n var f = Math.tan(Math.PI * 0.5 - 0.5 * (angle * Math.PI / 180));\n var rangeInv = 1.0 / (near - far);\n\n var dst = proj.v;\n\n dst[0] = f / aspect;\n dst[1] = 0;\n dst[2] = 0;\n dst[3] = 0;\n\n dst[4] = 0;\n dst[5] = f;\n dst[6] = 0;\n dst[7] = 0;\n\n dst[8] = 0;\n dst[9] = 0;\n dst[10] = (near + far) * rangeInv;\n dst[11] = -1;\n\n dst[12] = 0;\n dst[13] = 0;\n dst[14] = near * far * rangeInv * 2;\n dst[15] = 0;\n\n return proj;\n });\n\n // builds, not appending\n mod.rotationY = new Sk.builtin.func(function(target, angle)\n {\n var dst = target.v;\n var c = Math.cos(angle * Math.PI / 180);\n var s = Math.sin(angle * Math.PI / 180);\n\n dst[ 0] = c;\n dst[ 1] = 0;\n dst[ 2] = -s;\n dst[ 3] = 0;\n dst[ 4] = 0;\n dst[ 5] = 1;\n dst[ 6] = 0;\n dst[ 7] = 0;\n dst[ 8] = s;\n dst[ 9] = 0;\n dst[10] = c;\n dst[11] = 0;\n dst[12] = 0;\n dst[13] = 0;\n dst[14] = 0;\n dst[15] = 1;\n\n return target;\n });\n\n mod.identity = new Sk.builtin.func(function(target)\n {\n var dst = target.v;\n dst[ 0] = 1;\n dst[ 1] = 0;\n dst[ 2] = 0;\n dst[ 3] = 0;\n dst[ 4] = 0;\n dst[ 5] = 1;\n dst[ 6] = 0;\n dst[ 7] = 0;\n dst[ 8] = 0;\n dst[ 9] = 0;\n dst[10] = 1;\n dst[11] = 0;\n dst[12] = 0;\n dst[13] = 0;\n dst[14] = 0;\n dst[15] = 1;\n return target;\n });\n\n // row major\n mod.mul = new Sk.builtin.func(function(target, x, y)\n {\n var dst = target.v;\n var a = x.v;\n var b = y.v;\n var a00 = a[0];\n var a01 = a[1];\n var a02 = a[2];\n var a03 = a[3];\n var a10 = a[ 4 + 0];\n var a11 = a[ 4 + 1];\n var a12 = a[ 4 + 2];\n var a13 = a[ 4 + 3];\n var a20 = a[ 8 + 0];\n var a21 = a[ 8 + 1];\n var a22 = a[ 8 + 2];\n var a23 = a[ 8 + 3];\n var a30 = a[12 + 0];\n var a31 = a[12 + 1];\n var a32 = a[12 + 2];\n var a33 = a[12 + 3];\n var b00 = b[0];\n var b01 = b[1];\n var b02 = b[2];\n var b03 = b[3];\n var b10 = b[ 4 + 0];\n var b11 = b[ 4 + 1];\n var b12 = b[ 4 + 2];\n var b13 = b[ 4 + 3];\n var b20 = b[ 8 + 0];\n var b21 = b[ 8 + 1];\n var b22 = b[ 8 + 2];\n var b23 = b[ 8 + 3];\n var b30 = b[12 + 0];\n var b31 = b[12 + 1];\n var b32 = b[12 + 2];\n var b33 = b[12 + 3];\n dst[ 0] = a00 * b00 + a01 * b10 + a02 * b20 + a03 * b30;\n dst[ 1] = a00 * b01 + a01 * b11 + a02 * b21 + a03 * b31;\n dst[ 2] = a00 * b02 + a01 * b12 + a02 * b22 + a03 * b32;\n dst[ 3] = a00 * b03 + a01 * b13 + a02 * b23 + a03 * b33;\n dst[ 4] = a10 * b00 + a11 * b10 + a12 * b20 + a13 * b30;\n dst[ 5] = a10 * b01 + a11 * b11 + a12 * b21 + a13 * b31;\n dst[ 6] = a10 * b02 + a11 * b12 + a12 * b22 + a13 * b32;\n dst[ 7] = a10 * b03 + a11 * b13 + a12 * b23 + a13 * b33;\n dst[ 8] = a20 * b00 + a21 * b10 + a22 * b20 + a23 * b30;\n dst[ 9] = a20 * b01 + a21 * b11 + a22 * b21 + a23 * b31;\n dst[10] = a20 * b02 + a21 * b12 + a22 * b22 + a23 * b32;\n dst[11] = a20 * b03 + a21 * b13 + a22 * b23 + a23 * b33;\n dst[12] = a30 * b00 + a31 * b10 + a32 * b20 + a33 * b30;\n dst[13] = a30 * b01 + a31 * b11 + a32 * b21 + a33 * b31;\n dst[14] = a30 * b02 + a31 * b12 + a32 * b22 + a33 * b32;\n dst[15] = a30 * b03 + a31 * b13 + a32 * b23 + a33 * b33;\n return target;\n });\n\n mod.invert = new Sk.builtin.func(function(target, mat)\n {\n var dst = target.v;\n var m = mat.v;\n var m00 = m[0 * 4 + 0];\n var m01 = m[0 * 4 + 1];\n var m02 = m[0 * 4 + 2];\n var m03 = m[0 * 4 + 3];\n var m10 = m[1 * 4 + 0];\n var m11 = m[1 * 4 + 1];\n var m12 = m[1 * 4 + 2];\n var m13 = m[1 * 4 + 3];\n var m20 = m[2 * 4 + 0];\n var m21 = m[2 * 4 + 1];\n var m22 = m[2 * 4 + 2];\n var m23 = m[2 * 4 + 3];\n var m30 = m[3 * 4 + 0];\n var m31 = m[3 * 4 + 1];\n var m32 = m[3 * 4 + 2];\n var m33 = m[3 * 4 + 3];\n var tmp_0 = m22 * m33;\n var tmp_1 = m32 * m23;\n var tmp_2 = m12 * m33;\n var tmp_3 = m32 * m13;\n var tmp_4 = m12 * m23;\n var tmp_5 = m22 * m13;\n var tmp_6 = m02 * m33;\n var tmp_7 = m32 * m03;\n var tmp_8 = m02 * m23;\n var tmp_9 = m22 * m03;\n var tmp_10 = m02 * m13;\n var tmp_11 = m12 * m03;\n var tmp_12 = m20 * m31;\n var tmp_13 = m30 * m21;\n var tmp_14 = m10 * m31;\n var tmp_15 = m30 * m11;\n var tmp_16 = m10 * m21;\n var tmp_17 = m20 * m11;\n var tmp_18 = m00 * m31;\n var tmp_19 = m30 * m01;\n var tmp_20 = m00 * m21;\n var tmp_21 = m20 * m01;\n var tmp_22 = m00 * m11;\n var tmp_23 = m10 * m01;\n\n var t0 = (tmp_0 * m11 + tmp_3 * m21 + tmp_4 * m31) -\n (tmp_1 * m11 + tmp_2 * m21 + tmp_5 * m31);\n var t1 = (tmp_1 * m01 + tmp_6 * m21 + tmp_9 * m31) -\n (tmp_0 * m01 + tmp_7 * m21 + tmp_8 * m31);\n var t2 = (tmp_2 * m01 + tmp_7 * m11 + tmp_10 * m31) -\n (tmp_3 * m01 + tmp_6 * m11 + tmp_11 * m31);\n var t3 = (tmp_5 * m01 + tmp_8 * m11 + tmp_11 * m21) -\n (tmp_4 * m01 + tmp_9 * m11 + tmp_10 * m21);\n\n var d = 1.0 / (m00 * t0 + m10 * t1 + m20 * t2 + m30 * t3);\n\n dst[ 0] = d * t0;\n dst[ 1] = d * t1;\n dst[ 2] = d * t2;\n dst[ 3] = d * t3;\n dst[ 4] = d * ((tmp_1 * m10 + tmp_2 * m20 + tmp_5 * m30) -\n (tmp_0 * m10 + tmp_3 * m20 + tmp_4 * m30));\n dst[ 5] = d * ((tmp_0 * m00 + tmp_7 * m20 + tmp_8 * m30) -\n (tmp_1 * m00 + tmp_6 * m20 + tmp_9 * m30));\n dst[ 6] = d * ((tmp_3 * m00 + tmp_6 * m10 + tmp_11 * m30) -\n (tmp_2 * m00 + tmp_7 * m10 + tmp_10 * m30));\n dst[ 7] = d * ((tmp_4 * m00 + tmp_9 * m10 + tmp_10 * m20) -\n (tmp_5 * m00 + tmp_8 * m10 + tmp_11 * m20));\n dst[ 8] = d * ((tmp_12 * m13 + tmp_15 * m23 + tmp_16 * m33) -\n (tmp_13 * m13 + tmp_14 * m23 + tmp_17 * m33));\n dst[ 9] = d * ((tmp_13 * m03 + tmp_18 * m23 + tmp_21 * m33) -\n (tmp_12 * m03 + tmp_19 * m23 + tmp_20 * m33));\n dst[10] = d * ((tmp_14 * m03 + tmp_19 * m13 + tmp_22 * m33) -\n (tmp_15 * m03 + tmp_18 * m13 + tmp_23 * m33));\n dst[11] = d * ((tmp_17 * m03 + tmp_20 * m13 + tmp_23 * m23) -\n (tmp_16 * m03 + tmp_21 * m13 + tmp_22 * m23));\n dst[12] = d * ((tmp_14 * m22 + tmp_17 * m32 + tmp_13 * m12) -\n (tmp_16 * m32 + tmp_12 * m12 + tmp_15 * m22));\n dst[13] = d * ((tmp_20 * m32 + tmp_12 * m02 + tmp_19 * m22) -\n (tmp_18 * m22 + tmp_21 * m32 + tmp_13 * m02));\n dst[14] = d * ((tmp_18 * m12 + tmp_23 * m32 + tmp_15 * m02) -\n (tmp_22 * m32 + tmp_14 * m02 + tmp_19 * m12));\n dst[15] = d * ((tmp_22 * m22 + tmp_16 * m02 + tmp_21 * m12) -\n (tmp_20 * m12 + tmp_23 * m22 + tmp_17 * m02));\n return target;\n });\n\n mod.transpose = new Sk.builtin.func(function(target, mat)\n {\n var dst = target.v;\n var m = mat.v;\n for (var j = 0; j < 4; ++j) {\n for (var i = 0; i < 4; ++i)\n dst[j * 4 + i] = m[i * 4 + j];\n }\n return dst;\n });\n\n return mod;\n};\n", "src/lib/re/__init__.js": "var $builtinmodule = function(name)\n{\n var mod = {};\n\n // Constants (mostly unsupported)\n mod.I = 2;\n mod.IGNORECASE = 2;\n // mod.L = 4;\n // mod.LOCALE = 4;\n mod.M = 8;\n mod.MULTILINE = 8;\n // mod.S = 16;\n // mod.DOTALL = 16;\n // mod.U = 32;\n // mod.UNICODE = 32;\n // mod.X = 64;\n // mod.VERBOSE = 64;\n\n var validGroups = [\"(?:\", \"(?=\", \"(?!\"];\n\n var convert = function(pattern) {\n var newpattern;\n var match;\n var i;\n\n // Look for disallowed constructs\n match = pattern.match(/\\(\\?./g);\n if (match) {\n for (i=0; i<match.length; i++) {\n if (validGroups.indexOf(match[i]) == -1) {\n throw new Sk.builtin.ValueError(\"Disallowed group in pattern: '\"\n + match[i] + \"'\");\n };\n };\n };\n\n newpattern = pattern.replace('/\\\\/g', '\\\\\\\\');\n newpattern = pattern.replace(/([^\\\\]){,(?![^\\[]*\\])/g, '$1{0,');\n\n return newpattern;\n };\n\n var getFlags = function(flags) {\n var jsflags = \"g\";\n if ((flags & mod.IGNORECASE) == mod.IGNORECASE) {\n jsflags += \"i\";\n };\n if ((flags & mod.MULTILINE) == mod.MULTILINE) {\n jsflags += \"m\";\n }; \n return jsflags;\n };\n\n mod.split = Sk.nativejs.func(function split(pattern, string, maxsplit, flags) {\n Sk.builtin.pyCheckArgs(\"split\", arguments, 2, 4);\n if (!Sk.builtin.checkString(pattern)) {\n throw new Sk.builtin.TypeError(\"pattern must be a string\");\n };\n if (!Sk.builtin.checkString(string)) {\n throw new Sk.builtin.TypeError(\"string must be a string\");\n };\n if (maxsplit === undefined) {\n maxsplit = 0;\n };\n if (!Sk.builtin.checkNumber(maxsplit)) {\n throw new Sk.builtin.TypeError(\"maxsplit must be a number\");\n };\n if (flags === undefined) {\n flags = 0;\n };\n if (!Sk.builtin.checkNumber(flags)) {\n throw new Sk.builtin.TypeError(\"flags must be a number\");\n };\n\n\tmaxsplit = Sk.builtin.asnum$(maxsplit);\n var pat = Sk.ffi.unwrapo(pattern);\n var str = Sk.ffi.unwrapo(string);\n \n // Convert pat from Python to Javascript regex syntax\n pat = convert(pat);\n //print(\"Pat: \" + pat);\n //print(\"Str: \" + str);\n\n var captured = !(pat.match(/^\\(.*\\)$/) === null);\n //print(\"Captured: \", captured);\n\n var jsflags = getFlags(flags);\n //print(\"Flags: \", jsflags);\n\n var regex = new RegExp(pat, jsflags);\n\n var result = [];\n var match;\n var index = 0;\n var splits = 0;\n while ((match = regex.exec(str)) != null) {\n //print(\"Matched '\" + match[0] + \"' at position \" + match.index + \n // \"; next search at \" + regex.lastIndex);\n if (match.index === regex.lastIndex) {\n // empty match\n break;\n };\n result.push(new Sk.builtin.str(str.substring(index, match.index)));\n if (captured) {\n // Add matching pattern, too\n result.push(new Sk.builtin.str(match[0]));\n };\n index = regex.lastIndex;\n splits += 1;\n if (maxsplit && (splits >= maxsplit)) {\n break;\n };\n };\n result.push(new Sk.builtin.str(str.substring(index)));\n\n return new Sk.builtin.list(result);\n });\n\n mod.findall = Sk.nativejs.func(function findall(pattern, string, flags) {\n Sk.builtin.pyCheckArgs(\"findall\", arguments, 2, 3);\n if (!Sk.builtin.checkString(pattern)) {\n throw new Sk.builtin.TypeError(\"pattern must be a string\");\n };\n if (!Sk.builtin.checkString(string)) {\n throw new Sk.builtin.TypeError(\"string must be a string\");\n };\n if (flags === undefined) {\n flags = 0;\n };\n if (!Sk.builtin.checkNumber(flags)) {\n throw new Sk.builtin.TypeError(\"flags must be a number\");\n };\n\n var pat = Sk.ffi.unwrapo(pattern);\n var str = Sk.ffi.unwrapo(string);\n \n // Convert pat from Python to Javascript regex syntax\n pat = convert(pat);\n //print(\"Pat: \" + pat);\n //print(\"Str: \" + str);\n\n var jsflags = getFlags(flags);\n //print(\"Flags: \", jsflags);\n\n var regex = new RegExp(pat, jsflags);\n\n if (pat.match(/\\$/)) {\n\t var newline_at_end = new RegExp(/\\n$/);\n\t if (str.match(newline_at_end)) {\n\t str = str.slice(0,-1);\n\t }\n }\n\n var result = [];\n var match;\n while ((match = regex.exec(str)) != null) {\n //print(\"Matched '\" + match[0] + \"' at position \" + match.index + \n // \"; next search at \" + regex.lastIndex);\n // print(\"match: \" + JSON.stringify(match));\n if (match.length < 2) {\n result.push(new Sk.builtin.str(match[0]));\n } else if (match.length == 2) {\n result.push(new Sk.builtin.str(match[1]));\n } else {\n var groups = [];\n for (var i=1; i<match.length; i++) {\n groups.push(new Sk.builtin.str(match[i])); \n };\n result.push(new Sk.builtin.tuple(groups));\n };\n if (match.index === regex.lastIndex) {\n regex.lastIndex += 1;\n };\n };\n\n return new Sk.builtin.list(result);\n });\n\n\n var matchobj = function($gbl, $loc) {\n $loc.__init__ = new Sk.builtin.func(function(self,thematch, pattern, string) {\n self.thematch = thematch;\n\t self.re = pattern;\n\t self.string = string;\n });\n\n\t$loc.groups = new Sk.builtin.func(function(self) {\n\t return new Sk.builtin.tuple(self.thematch.v.slice(1))\n\t});\n\n\t$loc.group = new Sk.builtin.func(function(self,grpnum) {\n\t if (grpnum === undefined) {\n grpnum = 0;\n }\n else {\n grpnum = Sk.builtin.asnum$(grpnum);\n }\n\t if(grpnum >= self.thematch.v.length) {\n\t\tthrow new Sk.builtin.IndexError(\"Index out of range: \" + grpnum);\n\t\t}\n\t return self.thematch.v[grpnum]\n\t});\n\n }\n\n mod.MatchObject = Sk.misceval.buildClass(mod, matchobj, 'MatchObject', []);\n\n // Internal function to return a Python list of strings \n // From a JS regular expression string\n mod._findre = function(res, string) {\n\tres = res.replace(/([^\\\\]){,(?![^\\[]*\\])/g, '$1{0,');\n var re = eval(res);\n\tvar patt = new RegExp('\\n$');\n\tif (string.v.match(patt))\n\t var matches = string.v.slice(0,-1).match(re);\n\telse\n var matches = string.v.match(re);\n retval = new Sk.builtin.list();\n if ( matches == null ) return retval;\n for (var i = 0; i < matches.length; ++i) {\n var sitem = new Sk.builtin.str(matches[i]);\n retval.v.push(sitem);\n }\n return retval;\n }\n\n mod.search = new Sk.builtin.func(function(pattern, string, flags) {\n\tSk.builtin.pyCheckArgs('search', arguments, 2, 3);\n if (!Sk.builtin.checkString(pattern)) {\n throw new Sk.builtin.TypeError(\"pattern must be a string\");\n };\n if (!Sk.builtin.checkString(string)) {\n throw new Sk.builtin.TypeError(\"string must be a string\");\n };\n\tif (flags === undefined) {\n flags = 0;\n };\n if (!Sk.builtin.checkNumber(flags)) {\n throw new Sk.builtin.TypeError(\"flags must be a number\");\n };\n var res = \"/\"+pattern.v.replace(/\\//g,\"\\\\/\")+\"/\";\n lst = mod._findre(res,string);\n if ( lst.v.length < 1 ) return Sk.builtin.none.none$;\n var mob = Sk.misceval.callsim(mod.MatchObject, lst, pattern, string);\n return mob;\n });\n\n mod.match = new Sk.builtin.func(function(pattern, string, flags) {\n\tSk.builtin.pyCheckArgs('match', arguments, 2, 3);\n if (!Sk.builtin.checkString(pattern)) {\n throw new Sk.builtin.TypeError(\"pattern must be a string\");\n };\n if (!Sk.builtin.checkString(string)) {\n throw new Sk.builtin.TypeError(\"string must be a string\");\n };\n\tif (flags === undefined) {\n flags = 0;\n };\n if (!Sk.builtin.checkNumber(flags)) {\n throw new Sk.builtin.TypeError(\"flags must be a number\");\n };\n var res = \"/^\"+pattern.v.replace(/\\//g,\"\\\\/\")+\"/\";\n lst = mod._findre(res,string);\n if ( lst.v.length < 1 ) return Sk.builtin.none.none$;\n var mob = Sk.misceval.callsim(mod.MatchObject, lst, pattern, string);\n return mob;\n });\n\n return mod;\n}\n", "src/lib/unittest/gui.py": "import document\nfrom unittest import TestCase\n\nclass TestCaseGui(TestCase):\n\tdef __init__(self):\n\t\tTestCase.__init__(self)\n\n\t\tself.divid = document.currentDiv()\n\t\tself.mydiv = document.getElementById(self.divid)\n\t\tres = document.getElementById(self.divid+'_unit_results')\n\t\tif res:\n\t\t\tself.resdiv = res\n\t\t\tres.innerHTML = ''\n\t\telse:\n\t\t\tself.resdiv = document.createElement('div')\n\t\t\tself.resdiv.setAttribute('id',self.divid+'_unit_results')\n\t\t\tself.resdiv.setAttribute('class','unittest-results')\n\t\tself.mydiv.appendChild(self.resdiv)\n\n\n\tdef main(self):\n\t\tl = document.createElement('ul')\n\t\tself.resdiv.appendChild(l)\n\t\tself.resList = l\n\n\t\tfor func in self.tlist:\n\t\t\ttry:\n\t\t\t\tself.setup()\n\t\t\t\tfunc()\n\t\t\t\tself.tearDown()\n\t\t\texcept:\n\t\t\t\tself.appendResult('Error')\n\t\t\t\tself.numFailed += 1\n\t\tself.showSummary()\n\n\tdef appendResult(self,res,actual,expected,feedback):\n\t\tif res == 'Error':\n\t\t\tmsg = 'Error'\n\t\telif res:\n\t\t\tmsg = 'Pass'\n\t\t\tself.numPassed += 1\n\t\telse:\n\t\t\tmsg = 'Fail: expected %s %s ' % (str(actual),str(expected)) + feedback\n\t\t\tself.numFailed += 1\n\n\t\tpTag = document.createElement('li')\n\t\tpTag.innerHTML = msg\n\t\tself.resList.appendChild(pTag)\n\n\n\n\tdef showSummary(self):\n\t\tpct = self.numPassed / (self.numPassed+self.numFailed) * 100\n\t\tpTag = document.createElement('p')\n\t\tpTag.innerHTML = \"You passed: \" + str(pct) + \"% of the tests\"\n\t\tself.resdiv.appendChild(pTag)\n\t\tif pct < 90:\n\t\t\tself.resdiv.setCSS('background-color','#de8e96')\n\t\telse:\n\t\t\tself.resdiv.setCSS('background-color','#83d382')\n", "src/lib/urllib/__init__.js": "var $builtinmodule = function(name)\n{\n var urllib = {};\n\n return urllib;\n};\n", "src/lib/random/__init__.js": "\n/*\n I've wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace\n so it's better encapsulated. Now you can have multiple random number generators\n and they won't stomp all over eachother's state.\n \n If you want to use this as a substitute for Math.random(), use the random()\n method like so:\n \n var m = new MersenneTwister();\n var randomNumber = m.random();\n \n You can also call the other genrand_{foo}() methods on the instance.\n\n If you want to use a specific seed in order to get a repeatable random\n sequence, pass an integer into the constructor:\n\n var m = new MersenneTwister(123);\n\n and that will always produce the same random sequence.\n\n Sean McCullough (banksean@gmail.com)\n*/\n\n/* \n A C-program for MT19937, with initialization improved 2002/1/26.\n Coded by Takuji Nishimura and Makoto Matsumoto.\n \n Before using, initialize the state by using init_genrand(seed) \n or init_by_array(init_key, key_length).\n \n Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,\n All rights reserved. \n \n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions\n are met:\n \n 1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n \n 2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n \n 3. The names of its contributors may not be used to endorse or promote \n products derived from this software without specific prior written \n permission.\n \n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n \n \n Any feedback is very welcome.\n http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html\n email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)\n*/\n\nvar MersenneTwister = function(seed) {\n if (seed == undefined) {\n seed = new Date().getTime();\n } \n /* Period parameters */ \n this.N = 624;\n this.M = 397;\n this.MATRIX_A = 0x9908b0df; /* constant vector a */\n this.UPPER_MASK = 0x80000000; /* most significant w-r bits */\n this.LOWER_MASK = 0x7fffffff; /* least significant r bits */\n \n this.mt = new Array(this.N); /* the array for the state vector */\n this.mti=this.N+1; /* mti==N+1 means mt[N] is not initialized */\n\n this.init_genrand(seed);\n} \n \n/* initializes mt[N] with a seed */\nMersenneTwister.prototype.init_genrand = function(s) {\n this.mt[0] = s >>> 0;\n for (this.mti=1; this.mti<this.N; this.mti++) {\n var s = this.mt[this.mti-1] ^ (this.mt[this.mti-1] >>> 30);\n this.mt[this.mti] = (((((s & 0xffff0000) >>> 16) * 1812433253) << 16) + (s & 0x0000ffff) * 1812433253)\n + this.mti;\n /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */\n /* In the previous versions, MSBs of the seed affect */\n /* only MSBs of the array mt[]. */\n /* 2002/01/09 modified by Makoto Matsumoto */\n this.mt[this.mti] >>>= 0;\n /* for >32 bit machines */\n }\n}\n \n/* initialize by an array with array-length */\n/* init_key is the array for initializing keys */\n/* key_length is its length */\n/* slight change for C++, 2004/2/26 */\nMersenneTwister.prototype.init_by_array = function(init_key, key_length) {\n var i, j, k;\n this.init_genrand(19650218);\n i=1; j=0;\n k = (this.N>key_length ? this.N : key_length);\n for (; k; k--) {\n var s = this.mt[i-1] ^ (this.mt[i-1] >>> 30)\n this.mt[i] = (this.mt[i] ^ (((((s & 0xffff0000) >>> 16) * 1664525) << 16) + ((s & 0x0000ffff) * 1664525)))\n + init_key[j] + j; /* non linear */\n this.mt[i] >>>= 0; /* for WORDSIZE > 32 machines */\n i++; j++;\n if (i>=this.N) { this.mt[0] = this.mt[this.N-1]; i=1; }\n if (j>=key_length) j=0;\n }\n for (k=this.N-1; k; k--) {\n var s = this.mt[i-1] ^ (this.mt[i-1] >>> 30);\n this.mt[i] = (this.mt[i] ^ (((((s & 0xffff0000) >>> 16) * 1566083941) << 16) + (s & 0x0000ffff) * 1566083941))\n - i; /* non linear */\n this.mt[i] >>>= 0; /* for WORDSIZE > 32 machines */\n i++;\n if (i>=this.N) { this.mt[0] = this.mt[this.N-1]; i=1; }\n }\n\n this.mt[0] = 0x80000000; /* MSB is 1; assuring non-zero initial array */ \n}\n \n/* generates a random number on [0,0xffffffff]-interval */\nMersenneTwister.prototype.genrand_int32 = function() {\n var y;\n var mag01 = new Array(0x0, this.MATRIX_A);\n /* mag01[x] = x * MATRIX_A for x=0,1 */\n\n if (this.mti >= this.N) { /* generate N words at one time */\n var kk;\n\n if (this.mti == this.N+1) /* if init_genrand() has not been called, */\n this.init_genrand(5489); /* a default initial seed is used */\n\n for (kk=0;kk<this.N-this.M;kk++) {\n y = (this.mt[kk]&this.UPPER_MASK)|(this.mt[kk+1]&this.LOWER_MASK);\n this.mt[kk] = this.mt[kk+this.M] ^ (y >>> 1) ^ mag01[y & 0x1];\n }\n for (;kk<this.N-1;kk++) {\n y = (this.mt[kk]&this.UPPER_MASK)|(this.mt[kk+1]&this.LOWER_MASK);\n this.mt[kk] = this.mt[kk+(this.M-this.N)] ^ (y >>> 1) ^ mag01[y & 0x1];\n }\n y = (this.mt[this.N-1]&this.UPPER_MASK)|(this.mt[0]&this.LOWER_MASK);\n this.mt[this.N-1] = this.mt[this.M-1] ^ (y >>> 1) ^ mag01[y & 0x1];\n\n this.mti = 0;\n }\n\n y = this.mt[this.mti++];\n\n /* Tempering */\n y ^= (y >>> 11);\n y ^= (y << 7) & 0x9d2c5680;\n y ^= (y << 15) & 0xefc60000;\n y ^= (y >>> 18);\n\n return y >>> 0;\n}\n \n/* generates a random number on [0,0x7fffffff]-interval */\nMersenneTwister.prototype.genrand_int31 = function() {\n return (this.genrand_int32()>>>1);\n}\n \n/* generates a random number on [0,1]-real-interval */\nMersenneTwister.prototype.genrand_real1 = function() {\n return this.genrand_int32()*(1.0/4294967295.0); \n /* divided by 2^32-1 */ \n}\n\n/* generates a random number on [0,1)-real-interval */\nMersenneTwister.prototype.random = function() {\n return this.genrand_int32()*(1.0/4294967296.0); \n /* divided by 2^32 */\n}\n \n/* generates a random number on (0,1)-real-interval */\nMersenneTwister.prototype.genrand_real3 = function() {\n return (this.genrand_int32() + 0.5)*(1.0/4294967296.0); \n /* divided by 2^32 */\n}\n \n/* generates a random number on [0,1) with 53-bit resolution*/\nMersenneTwister.prototype.genrand_res53 = function() { \n var a=this.genrand_int32()>>>5, b=this.genrand_int32()>>>6; \n return(a*67108864.0+b)*(1.0/9007199254740992.0); \n} \n\n/* These real versions are due to Isaku Wada, 2002/01/09 added */\n\n\n\nvar $builtinmodule = function(name)\n{\n\n var mod = {};\n\n var myGenerator = new MersenneTwister();\n\n mod.seed = new Sk.builtin.func(function(x) {\n Sk.builtin.pyCheckArgs(\"seed\", arguments, 0, 1);\n\tx = Sk.builtin.asnum$(x);\n\n if (arguments.length > 0)\n myGenerator = new MersenneTwister(x);\n else\n myGenerator = new MersenneTwister();\n\n\treturn Sk.builtin.none.none$;\n });\n\n mod.random = new Sk.builtin.func(function() {\n Sk.builtin.pyCheckArgs(\"random\", arguments, 0, 0);\n\n\treturn new Sk.builtin.nmber(myGenerator.genrand_res53(), Sk.builtin.nmber.float$);\n });\n\n var toInt = function(num) {\n return num | 0;\n };\n\n var randrange = function(start, stop, step) {\n // Ported from CPython 2.7\n var width, n, ret;\n\n if (!Sk.builtin.checkInt(start)) {\n throw new Sk.builtin.ValueError(\"non-integer first argument for randrange()\");\n };\n\n if (stop === undefined) {\n // Random in [0, start)\n ret = toInt(myGenerator.genrand_res53() * start);\n\t return new Sk.builtin.nmber(ret, Sk.builtin.nmber.int$);\n };\n\n if (!Sk.builtin.checkInt(stop)) {\n throw new Sk.builtin.ValueError(\"non-integer stop for randrange()\");\n };\n\n if (step === undefined) {\n step = 1;\n };\n\n width = stop - start;\n\n if ((step == 1) && (width > 0)) {\n // Random in [start, stop), must use toInt on product for correct results with negative ranges\n ret = start + toInt(myGenerator.genrand_res53() * width);\n\t return new Sk.builtin.nmber(ret, Sk.builtin.nmber.int$);\n };\n\n if (step == 1) {\n throw new Sk.builtin.ValueError(\"empty range for randrange() (\" + start + \", \" + stop + \", \" + width + \")\");\n };\n\n if (!Sk.builtin.checkInt(step)) {\n throw new Sk.builtin.ValueError(\"non-integer step for randrange()\");\n };\n\n if (step > 0) {\n n = toInt((width + step - 1) / step);\n } else if (step < 0) {\n n = toInt((width + step + 1) / step);\n } else {\n throw new Sk.builtin.ValueError(\"zero step for randrange()\");\n };\n\n if (n <= 0) {\n throw new Sk.builtin.ValueError(\"empty range for randrange()\");\n };\n\n // Random in range(start, stop, step)\n ret = start + (step * toInt(myGenerator.genrand_res53() * n));\n\treturn new Sk.builtin.nmber(ret, Sk.builtin.nmber.int$);\n };\n\n mod.randint = new Sk.builtin.func(function(a, b) {\n Sk.builtin.pyCheckArgs(\"randint\", arguments, 2, 2);\n\n\ta = Sk.builtin.asnum$(a);\n\tb = Sk.builtin.asnum$(b);\n return randrange(a, b+1);\n });\n\n mod.randrange = new Sk.builtin.func(function(start, stop, step) {\n Sk.builtin.pyCheckArgs(\"randrange\", arguments, 1, 3);\n\n\tstart = Sk.builtin.asnum$(start);\n\tstop = Sk.builtin.asnum$(stop);\n\tstep = Sk.builtin.asnum$(step);\n return randrange(start, stop, step);\n });\n\n mod.choice = new Sk.builtin.func(function(seq) {\n Sk.builtin.pyCheckArgs(\"choice\", arguments, 1, 1);\n Sk.builtin.pyCheckType(\"seq\", \"sequence\", Sk.builtin.checkSequence(seq));\n\n if (seq.sq$length !== undefined) {\n var r = toInt(myGenerator.genrand_res53() * seq.sq$length());\n return seq.mp$subscript(r);\n } else {\n throw new Sk.builtin.TypeError(\"object has no length\");\n }\n });\n\n mod.shuffle = new Sk.builtin.func(function(x) {\n Sk.builtin.pyCheckArgs(\"shuffle\", arguments, 1, 1);\n Sk.builtin.pyCheckType(\"x\", \"sequence\", Sk.builtin.checkSequence(x));\n\n if (x.sq$length !== undefined) {\n if (x.mp$ass_subscript !== undefined) {\n for (var i = x.sq$length() - 1; i > 0; i -= 1) {\n var r = toInt(myGenerator.genrand_res53() * (i + 1));\n var tmp = x.mp$subscript(r);\n x.mp$ass_subscript(r, x.mp$subscript(i));\n x.mp$ass_subscript(i, tmp);\n };\n } else {\n throw new Sk.builtin.TypeError(\"object is immutable\");\n };\n } else {\n throw new Sk.builtin.TypeError(\"object has no length\");\n }; \n\n\treturn Sk.builtin.none.none$;\n });\n\n return mod;\n}\n", "src/lib/webgl/__init__.js": "var $builtinmodule = function(name)\n{\n var mod = {};\n\n var makeFailHTML = function(msg) {\n return '' +\n '<table style=\"background-color: #8CE; width: 100%; height: 100%;\"><tr>' +\n '<td align=\"center\">' +\n '<div style=\"display: table-cell; vertical-align: middle;\">' +\n '<div style=\"\">' + msg + '</div>' +\n '</div>' +\n '</td></tr></table>';\n };\n\n var GET_A_WEBGL_BROWSER = '' +\n 'This page requires a browser that supports WebGL.<br/>' +\n '<a href=\"http://get.webgl.org\">Click here to upgrade your browser.</a>';\n\n var NEED_HARDWARE = '' +\n \"It doesn't appear your computer can support WebGL.<br/>\" +\n '<a href=\"http://get.webgl.org\">Click here for more information.</a>';\n \n var create3DContext = function(canvas) {\n var names = [\"webgl\", \"experimental-webgl\", \"webkit-3d\", \"moz-webgl\"];\n var gl = null;\n for (var ii = 0; ii < names.length; ++ii) {\n try {\n gl = canvas.getContext(names[ii]);\n }\n catch(e) {\n }\n if (gl) {\n break;\n }\n }\n if (gl) {\n // Disallow selection by default. This keeps the cursor from changing to an\n // I-beam when the user clicks and drags. It's easier on the eyes.\n function returnFalse() {\n return false;\n }\n\n canvas.onselectstart = returnFalse;\n canvas.onmousedown = returnFalse;\n }\n return gl;\n };\n\n var setupWebGL = function(canvasContainerId, opt_canvas) {\n var container = document.getElementById(canvasContainerId);\n var context;\n if (!opt_canvas) {\n opt_canvas = container.getElementsByTagName(\"canvas\")[0];\n }\n if (!opt_canvas) {\n // this browser doesn't support the canvas tag at all. Not even 2d.\n container.innerHTML = makeFailHTML(GET_A_WEBGL_BROWSER);\n return;\n }\n\n var gl = create3DContext(opt_canvas);\n if (!gl) {\n // TODO(gman): fix to official way to detect that it's the user's machine, not the browser.\n var browserStrings = navigator.userAgent.match(/(\\w+\\/.*? )/g);\n var browsers = {};\n try {\n for (var b = 0; b < browserStrings.length; ++b) {\n var parts = browserStrings[b].match(/(\\w+)/g);\n var bb = [];\n for (var ii = 1; ii < parts.length; ++ii) {\n bb.push(parseInt(parts[ii]));\n }\n browsers[parts[0]] = bb;\n }\n }\n catch (e) {\n }\n if (browsers.Chrome &&\n (browsers.Chrome[0] > 7 ||\n (browsers.Chrome[0] == 7 && browsers.Chrome[1] > 0) ||\n (browsers.Chrome[0] == 7 && browsers.Chrome[1] == 0 && browsers.Chrome[2] >= 521))) {\n container.innerHTML = makeFailHTML(NEED_HARDWARE);\n }\n else {\n container.innerHTML = makeFailHTML(GET_A_WEBGL_BROWSER);\n }\n }\n return gl;\n };\n\n /**\n * The Context encapsulates the underlying WebGL native JavaScript API.\n */\n mod.Context = Sk.misceval.buildClass(mod, function($gbl, $loc) {\n $loc.__init__ = new Sk.builtin.func(\n function(self, canvasid) {\n var canvas = document.getElementById(canvasid.v);\n var gl = setupWebGL(canvasid.v, canvas)\n if (!gl) {\n throw new Error(\"Your browser does not appear to support WebGL.\");\n }\n\n self.gl = gl;\n\n // Copy symbolic constants and functions from native WebGL, encapsulating where necessary. \n for (var k in gl.__proto__) {\n if (typeof gl.__proto__[k] === 'number') {\n Sk.abstr.objectSetItem(self['$d'], new Sk.builtin.str(k), gl.__proto__[k]);\n }\n else if (typeof gl.__proto__[k] === \"function\") {\n switch(k) {\n case 'bufferData': {\n }\n break;\n case 'clearColor': {\n }\n break;\n case 'drawArrays': {\n }\n break;\n case 'getAttribLocation': {\n }\n break;\n case 'getUniformLocation': {\n }\n break;\n case 'shaderSource': {\n }\n break;\n case 'uniformMatrix4fv': {\n }\n break;\n case 'vertexAttribPointer': {\n }\n break;\n case 'viewport': {\n }\n break;\n default: {\n (function(key) {\n Sk.abstr.objectSetItem(self['$d'], new Sk.builtin.str(k), new Sk.builtin.func(function() {\n var f = gl.__proto__[key];\n return f.apply(gl, arguments);\n }));\n }(k));\n }\n }\n }\n }\n\n gl.clearColor(100.0/255.0, 149.0/255.0, 237.0/255.0, 1.0);\n gl.clear(gl.COLOR_BUFFER_BIT);\n }\n );\n\n $loc.tp$getattr = Sk.builtin.object.prototype.GenericGetAttr;\n\n $loc.bufferData = new Sk.builtin.func(\n function(self, target, data, usage) {\n self.gl.bufferData(target, data.v, usage);\n }\n );\n\n $loc.clearColor = new Sk.builtin.func(\n function(self, red, green, blue, alpha) {\n self.gl.clearColor(Sk.builtin.asnum$(red), Sk.builtin.asnum$(green), Sk.builtin.asnum$(blue), Sk.builtin.asnum$(alpha));\n }\n );\n\n $loc.getAttribLocation = new Sk.builtin.func(\n function(self, program, name) {\n return self.gl.getAttribLocation(program, name.v);\n }\n );\n\n $loc.getUniformLocation = new Sk.builtin.func(\n function(self, program, name) {\n return self.gl.getUniformLocation(program, name.v);\n }\n );\n\n $loc.shaderSource = new Sk.builtin.func(\n function(self, shader, src) {\n self.gl.shaderSource(shader, src.v);\n }\n );\n\n $loc.drawArrays = new Sk.builtin.func(\n function(self, mode, first, count) {\n self.gl.drawArrays(Sk.builtin.asnum$(mode), Sk.builtin.asnum$(first), Sk.builtin.asnum$(count));\n }\n );\n\n $loc.vertexAttribPointer = new Sk.builtin.func(\n function(self, index, size, type, normalized, stride, dunno) {\n self.gl.vertexAttribPointer(index, Sk.builtin.asnum$(size), Sk.builtin.asnum$(type), normalized, Sk.builtin.asnum$(stride), Sk.builtin.asnum$(dunno));\n }\n );\n\n $loc.viewport = new Sk.builtin.func(\n function(self, x, y, width, height) {\n self.gl.viewport(Sk.builtin.asnum$(x), Sk.builtin.asnum$(y), Sk.builtin.asnum$(width), Sk.builtin.asnum$(height));\n }\n );\n\n $loc.uniformMatrix4fv = new Sk.builtin.func(\n function(self, location, transpose, values) {\n// console.log(\"location \" + (typeof location));\n// console.log(\"transpose \" + (typeof transpose));\n// console.log(\"values.v \" + (typeof values.v));\n self.gl.uniformMatrix4fv(Sk.builtin.asnum$(location), transpose, values.v);\n }\n );\n\n $loc.setDrawFunc = new Sk.builtin.func(function(self, func) {\n var startTime = (new Date()).getTime();\n var intervalId = setInterval(\n function() {\n Sk.misceval.callsim(func, self, (new Date()).getTime() - startTime);\n }, 1000.0 / 60.0); // 60 fps\n });\n\n }, 'Context', []);\n\n mod.Float32Array = Sk.misceval.buildClass(mod, function($gbl, $loc) {\n $loc.__init__ = new Sk.builtin.func(function(self, data) {\n if (typeof data === \"number\") {\n self.v = new Float32Array(data);\n }\n else {\n self.v = new Float32Array(Sk.ffi.remapToJs(data));\n }\n });\n\n $loc.__repr__ = new Sk.builtin.func(function(self) {\n var copy = [];\n for (var i = 0; i < self.v.length; ++i) {\n copy.push(self.v[i]);\n }\n return new Sk.builtin.str(\"[\" + copy.join(', ') + \"]\");\n });\n }, 'Float32Array', []);\n\n /**\n * A 4x4 (mutable) matrix suitable for OpenGL.\n *\n * Mutability is chosen for performance.\n * The inderlying implementation is Float32Array.\n * The indexing of the elements is\n * 0 4 8 12\n * 1 5 9 13\n * 2 6 10 14\n * 3 7 11 15\n */\n mod.Matrix4x4 = Sk.misceval.buildClass(mod, function($gbl, $loc) {\n $loc.__init__ = new Sk.builtin.func(function(self, data) {\n self.v = new Float32Array(Sk.ffi.remapToJs(data));\n });\n\n $loc.identity = new Sk.builtin.func(\n function(self) {\n\n var m = self.v;\n\n m[0] = 1;\n m[1] = 0;\n m[2] = 0;\n m[3] = 0;\n\n m[4] = 0;\n m[5] = 1;\n m[6] = 0;\n m[7] = 0;\n\n m[8] = 0;\n m[9] = 0;\n m[10] = 1;\n m[11] = 0;\n\n m[12] = 0;\n m[13] = 0;\n m[14] = 0;\n m[15] = 1;\n }\n );\n\n $loc.perspective = new Sk.builtin.func(\n function(self, fov, aspect, near, far) {\n \n var t = Math.tan(Math.PI * 0.5 - 0.5 * (Sk.builtin.asnum$(fov) * Math.PI / 180));\n var a = Sk.builtin.asnum$(aspect)\n var n = Sk.builtin.asnum$(near)\n var f = Sk.builtin.asnum$(far)\n var k = 1.0 / (n - f);\n\n var m = self.v;\n\n m[0] = t / a;\n m[1] = 0;\n m[2] = 0;\n m[3] = 0;\n\n m[4] = 0;\n m[5] = t;\n m[6] = 0;\n m[7] = 0;\n\n m[8] = 0;\n m[9] = 0;\n m[10] = (n + f) * k;\n m[11] = -1;\n\n m[12] = 0;\n m[13] = 0;\n m[14] = n * f * k * 2;\n m[15] = 0;\n }\n );\n\n $loc.translate = new Sk.builtin.func(\n function(self, translation) {\n\n var m = self.v;\n var t = Sk.ffi.remapToJs(translation);\n\n m[0] = 1;\n m[1] = 0;\n m[2] = 0;\n m[3] = 0;\n\n m[4] = 0;\n m[5] = 1;\n m[6] = 0;\n m[7] = 0;\n\n m[8] = 0;\n m[9] = 0;\n m[10] = 1;\n m[11] = 0;\n\n m[12] = t[0];\n m[13] = t[1];\n m[14] = t[2];\n m[15] = 1;\n }\n );\n\n $loc.__repr__ = new Sk.builtin.func(function(self) {\n var copy = [];\n for (var i = 0; i < self.v.length; ++i) {\n copy.push(self.v[i]);\n }\n return new Sk.builtin.str(\"[\" + copy.join(', ') + \"]\");\n });\n }, 'Matrix4x4', []);\n\n return mod;\n};", "src/lib/math/__init__.js": "var $builtinmodule = function(name)\n{\n var mod = {};\n mod.pi = Sk.builtin.assk$(Math.PI, Sk.builtin.nmber.float$);\n mod.e = Sk.builtin.assk$(Math.E, Sk.builtin.nmber.float$);\n\n//\tRNL\tadded\n mod.fabs = new Sk.builtin.func(function(x) {\n Sk.builtin.pyCheckArgs(\"fabs\", arguments, 1, 1);\n Sk.builtin.pyCheckType(\"x\", \"number\", Sk.builtin.checkNumber(x));\n\n\treturn new Sk.builtin.nmber(Math.abs(Sk.builtin.asnum$(x)), Sk.builtin.nmber.float$);\n });\n\n mod.asin = new Sk.builtin.func(function(rad) {\n Sk.builtin.pyCheckArgs(\"asin\", arguments, 1, 1);\n Sk.builtin.pyCheckType(\"rad\", \"number\", Sk.builtin.checkNumber(rad));\n\n\treturn new Sk.builtin.nmber(Math.asin(Sk.builtin.asnum$(rad)), Sk.builtin.nmber.float$);\n });\n\n mod.acos = new Sk.builtin.func(function(rad) {\n Sk.builtin.pyCheckArgs(\"acos\", arguments, 1, 1);\n Sk.builtin.pyCheckType(\"rad\", \"number\", Sk.builtin.checkNumber(rad));\n\n\treturn new Sk.builtin.nmber(Math.acos(Sk.builtin.asnum$(rad)), Sk.builtin.nmber.float$);\n });\n\n mod.atan = new Sk.builtin.func(function(rad) {\n Sk.builtin.pyCheckArgs(\"atan\", arguments, 1, 1);\n Sk.builtin.pyCheckType(\"rad\", \"number\", Sk.builtin.checkNumber(rad));\n\n\treturn new Sk.builtin.nmber(Math.atan(Sk.builtin.asnum$(rad)), Sk.builtin.nmber.float$);\n });\n\n mod.atan2 = new Sk.builtin.func(function(y, x) {\n Sk.builtin.pyCheckArgs(\"atan2\", arguments, 2, 2);\n Sk.builtin.pyCheckType(\"y\", \"number\", Sk.builtin.checkNumber(y));\n Sk.builtin.pyCheckType(\"x\", \"number\", Sk.builtin.checkNumber(x));\n\n\treturn new Sk.builtin.nmber(Math.atan2(Sk.builtin.asnum$(y), Sk.builtin.asnum$(x)), Sk.builtin.nmber.float$);\n });\n\n mod.sin = new Sk.builtin.func(function(rad) {\n Sk.builtin.pyCheckArgs(\"sin\", arguments, 1, 1);\n Sk.builtin.pyCheckType(\"rad\", \"number\", Sk.builtin.checkNumber(rad));\n\n\treturn new Sk.builtin.nmber(Math.sin(Sk.builtin.asnum$(rad)), Sk.builtin.nmber.float$);\n });\n\n mod.cos = new Sk.builtin.func(function(rad) {\n Sk.builtin.pyCheckArgs(\"cos\", arguments, 1, 1);\n Sk.builtin.pyCheckType(\"rad\", \"number\", Sk.builtin.checkNumber(rad));\n\n\treturn new Sk.builtin.nmber(Math.cos(Sk.builtin.asnum$(rad)), Sk.builtin.nmber.float$);\n });\n\n mod.tan = new Sk.builtin.func(function(rad) {\n Sk.builtin.pyCheckArgs(\"tan\", arguments, 1, 1);\n Sk.builtin.pyCheckType(\"rad\", \"number\", Sk.builtin.checkNumber(rad));\n\n\treturn new Sk.builtin.nmber(Math.tan(Sk.builtin.asnum$(rad)), Sk.builtin.nmber.float$);\n });\n\n mod.asinh = new Sk.builtin.func(function(x) {\n\tSk.builtin.pyCheckArgs(\"asinh\", arguments, 1, 1);\n\tSk.builtin.pyCheckType(\"x\", \"number\", Sk.builtin.checkNumber(x));\n\n\tx = Sk.builtin.asnum$(x);\n\n\tvar L = x + Math.sqrt(x*x+1);\n\n\treturn new Sk.builtin.nmber(Math.log(L), Sk.builtin.nmber.float$);\n });\n\n mod.acosh = new Sk.builtin.func(function(x) {\n\tSk.builtin.pyCheckArgs(\"acosh\", arguments, 1, 1);\n\tSk.builtin.pyCheckType(\"x\", \"number\", Sk.builtin.checkNumber(x));\n\n\tx = Sk.builtin.asnum$(x);\n\n\tvar L = x + Math.sqrt(x*x-1);\n\n\treturn new Sk.builtin.nmber(Math.log(L), Sk.builtin.nmber.float$);\n });\n\n mod.atanh = new Sk.builtin.func(function(x) {\n\tSk.builtin.pyCheckArgs(\"atanh\", arguments, 1, 1);\n\tSk.builtin.pyCheckType(\"x\", \"number\", Sk.builtin.checkNumber(x));\n\n\tx = Sk.builtin.asnum$(x);\n\n\tvar L = (1+x)/(1-x);\n\n\treturn new Sk.builtin.nmber(Math.log(L)/2, Sk.builtin.nmber.float$);\n });\n\n mod.sinh = new Sk.builtin.func(function(x) {\n\tSk.builtin.pyCheckArgs(\"sinh\", arguments, 1, 1);\n\tSk.builtin.pyCheckType(\"x\", \"number\", Sk.builtin.checkNumber(x));\n\n\tx = Sk.builtin.asnum$(x);\n\n\tvar e = Math.E;\n\tvar p = Math.pow(e, x);\n\tvar n = 1/p;\n\tvar result = (p-n)/2;\n\n\treturn new Sk.builtin.nmber(result, Sk.builtin.nmber.float$);\n });\n\n mod.cosh = new Sk.builtin.func(function(x) {\n\tSk.builtin.pyCheckArgs(\"cosh\", arguments, 1, 1);\n\tSk.builtin.pyCheckType(\"x\", \"number\", Sk.builtin.checkNumber(x));\n\n\tx = Sk.builtin.asnum$(x);\n\n\tvar e = Math.E;\n\tvar p = Math.pow(e, x);\n\tvar n = 1/p;\n\tvar result = (p+n)/2;\n\n\treturn new Sk.builtin.nmber(result, Sk.builtin.nmber.float$);\n });\n\n mod.tanh = new Sk.builtin.func(function(x) {\n\tSk.builtin.pyCheckArgs(\"tanh\", arguments, 1, 1);\n\tSk.builtin.pyCheckType(\"x\", \"number\", Sk.builtin.checkNumber(x));\n\n\tx = Sk.builtin.asnum$(x);\n\n\tvar e = Math.E;\n\tvar p = Math.pow(e, x);\n\tvar n = 1/p;\n\tvar result = ((p-n)/2)/((p+n)/2);\n\n\treturn new Sk.builtin.nmber(result, Sk.builtin.nmber.float$);\n });\n\n mod.ceil = new Sk.builtin.func(function(x) {\n Sk.builtin.pyCheckArgs(\"ceil\", arguments, 1, 1);\n Sk.builtin.pyCheckType(\"x\", \"number\", Sk.builtin.checkNumber(x));\n\n\treturn new Sk.builtin.nmber(Math.ceil(Sk.builtin.asnum$(x)), Sk.builtin.nmber.float$);\n });\n\n mod.floor = new Sk.builtin.func(function(x) {\n Sk.builtin.pyCheckArgs(\"floor\", arguments, 1, 1);\n Sk.builtin.pyCheckType(\"x\", \"number\", Sk.builtin.checkNumber(x));\n\n\treturn new Sk.builtin.nmber(Math.floor(Sk.builtin.asnum$(x)), Sk.builtin.nmber.float$);\n });\n\n mod.sqrt = new Sk.builtin.func(function(x) {\n Sk.builtin.pyCheckArgs(\"sqrt\", arguments, 1, 1);\n Sk.builtin.pyCheckType(\"x\", \"number\", Sk.builtin.checkNumber(x));\n\n\treturn new Sk.builtin.nmber(Math.sqrt(Sk.builtin.asnum$(x)), Sk.builtin.nmber.float$);\n });\n\n mod.trunc = new Sk.builtin.func(function(x) {\n Sk.builtin.pyCheckArgs(\"trunc\", arguments, 1, 1);\n Sk.builtin.pyCheckType(\"x\", \"number\", Sk.builtin.checkNumber(x));\n\n return new Sk.builtin.nmber(Sk.builtin.asnum$(x)|0, Sk.builtin.nmber.int$);\n });\n\n mod.log = new Sk.builtin.func(function(x, base) {\n Sk.builtin.pyCheckArgs(\"log\", arguments, 1, 2);\n Sk.builtin.pyCheckType(\"x\", \"number\", Sk.builtin.checkNumber(x));\n\n if (base === undefined) {\n\t return new Sk.builtin.nmber(Math.log(Sk.builtin.asnum$(x)), Sk.builtin.nmber.float$);\n } else {\n Sk.builtin.pyCheckType(\"base\", \"number\", Sk.builtin.checkNumber(base));\n var ret = Math.log(Sk.builtin.asnum$(x)) / Math.log(Sk.builtin.asnum$(base));\n\t return new Sk.builtin.nmber(ret, Sk.builtin.nmber.float$);\n }\n });\n\n mod.log10 = new Sk.builtin.func(function(x) {\n Sk.builtin.pyCheckArgs(\"log10\", arguments, 1, 1);\n Sk.builtin.pyCheckType(\"x\", \"number\", Sk.builtin.checkNumber(x));\n\n var ret = Math.log(Sk.builtin.asnum$(x)) / Math.log(10);\n\treturn new Sk.builtin.nmber(ret, Sk.builtin.nmber.float$);\n });\n\n mod.exp = new Sk.builtin.func(function(x) {\n Sk.builtin.pyCheckArgs(\"exp\", arguments, 1, 1);\n Sk.builtin.pyCheckType(\"x\", \"number\", Sk.builtin.checkNumber(x));\n\n\treturn new Sk.builtin.nmber(Math.exp(Sk.builtin.asnum$(x)), Sk.builtin.nmber.float$);\n });\n\n mod.pow = new Sk.builtin.func(function(x,y) {\n Sk.builtin.pyCheckArgs(\"pow\", arguments, 2, 2);\n Sk.builtin.pyCheckType(\"x\", \"number\", Sk.builtin.checkNumber(x));\n Sk.builtin.pyCheckType(\"y\", \"number\", Sk.builtin.checkNumber(y));\n\n\treturn new Sk.builtin.nmber(Math.pow(Sk.builtin.asnum$(x), Sk.builtin.asnum$(y)), Sk.builtin.nmber.float$);\n });\n\n mod.radians = new Sk.builtin.func(function(deg) {\n Sk.builtin.pyCheckArgs(\"radians\", arguments, 1, 1);\n Sk.builtin.pyCheckType(\"deg\", \"number\", Sk.builtin.checkNumber(deg));\n\n\tvar ret = Math.PI / 180.0 * Sk.builtin.asnum$(deg);\n\treturn new Sk.builtin.nmber(ret, Sk.builtin.nmber.float$);\n });\n\n mod.degrees = new Sk.builtin.func(function(rad) {\n Sk.builtin.pyCheckArgs(\"degrees\", arguments, 1, 1);\n Sk.builtin.pyCheckType(\"rad\", \"number\", Sk.builtin.checkNumber(rad));\n\n\tvar ret = 180.0 / Math.PI * Sk.builtin.asnum$(rad);\n\treturn new Sk.builtin.nmber(ret, Sk.builtin.nmber.float$);\n });\n\n mod.hypot = new Sk.builtin.func(function(x, y) {\n\tSk.builtin.pyCheckArgs(\"hypot\", arguments, 2, 2);\n Sk.builtin.pyCheckType(\"x\", \"number\", Sk.builtin.checkNumber(x));\n\tSk.builtin.pyCheckType(\"y\", \"number\", Sk.builtin.checkNumber(y));\n\n\t\tx = Sk.builtin.asnum$(x);\n\t\ty = Sk.builtin.asnum$(y);\n\treturn new Sk.builtin.nmber(Math.sqrt((x*x)+(y*y)), Sk.builtin.nmber.float$);\n });\n\n\tmod.factorial = new Sk.builtin.func(function(x) {\n\t Sk.builtin.pyCheckArgs(\"factorial\", arguments, 1, 1);\n Sk.builtin.pyCheckType(\"x\", \"number\", Sk.builtin.checkNumber(x));\n\n\t\tx = Math.floor(Sk.builtin.asnum$(x));\n\t\tvar r = 1;\n\t\tfor (var i = 2; i <= x; i++)\n\t\t\tr *= i;\n\t\treturn new Sk.builtin.nmber(r, Sk.builtin.nmber.int$);\n\t});\n\n return mod;\n}"}}
(function(){var COMPILED=!0,goog=goog||{};goog.global=this;goog.exportPath_=function(a,b,c){a=a.split(".");c=c||goog.global;a[0]in c||!c.execScript||c.execScript("var "+a[0]);for(var d;a.length&&(d=a.shift());)a.length||void 0===b?c=c[d]?c[d]:c[d]={}:c[d]=b};goog.define=function(a,b){var c=b;COMPILED||goog.global.CLOSURE_DEFINES&&Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_DEFINES,a)&&(c=goog.global.CLOSURE_DEFINES[a]);goog.exportPath_(a,c)};goog.DEBUG=!1;goog.LOCALE="en";goog.TRUSTED_SITE=!0;
goog.provide=function(a){if(!COMPILED){if(goog.isProvided_(a))throw Error('Namespace "'+a+'" already declared.');delete goog.implicitNamespaces_[a];for(var b=a;(b=b.substring(0,b.lastIndexOf(".")))&&!goog.getObjectByName(b);)goog.implicitNamespaces_[b]=!0}goog.exportPath_(a)};goog.setTestOnly=function(a){if(COMPILED&&!goog.DEBUG)throw a=a||"",Error("Importing test-only code into non-debug environment"+a?": "+a:".");};
COMPILED||(goog.isProvided_=function(a){return!goog.implicitNamespaces_[a]&&!!goog.getObjectByName(a)},goog.implicitNamespaces_={});goog.getObjectByName=function(a,b){for(var c=a.split("."),d=b||goog.global,e;e=c.shift();)if(goog.isDefAndNotNull(d[e]))d=d[e];else return null;return d};goog.globalize=function(a,b){var c=b||goog.global,d;for(d in a)c[d]=a[d]};
goog.addDependency=function(a,b,c){if(goog.DEPENDENCIES_ENABLED){var d;a=a.replace(/\\/g,"/");for(var e=goog.dependencies_,f=0;d=b[f];f++)e.nameToPath[d]=a,a in e.pathToNames||(e.pathToNames[a]={}),e.pathToNames[a][d]=!0;for(d=0;b=c[d];d++)a in e.requires||(e.requires[a]={}),e.requires[a][b]=!0}};goog.ENABLE_DEBUG_LOADER=!0;
goog.require=function(a){if(!COMPILED&&!goog.isProvided_(a)){if(goog.ENABLE_DEBUG_LOADER){var b=goog.getPathFromDeps_(a);if(b){goog.included_[b]=!0;goog.writeScripts_();return}}a="goog.require could not find: "+a;goog.global.console&&goog.global.console.error(a);throw Error(a);}};goog.basePath="";goog.nullFunction=function(){};goog.identityFunction=function(a,b){return a};goog.abstractMethod=function(){throw Error("unimplemented abstract method");};
goog.addSingletonGetter=function(a){a.getInstance=function(){if(a.instance_)return a.instance_;goog.DEBUG&&(goog.instantiatedSingletons_[goog.instantiatedSingletons_.length]=a);return a.instance_=new a}};goog.instantiatedSingletons_=[];goog.DEPENDENCIES_ENABLED=!COMPILED&&goog.ENABLE_DEBUG_LOADER;
goog.DEPENDENCIES_ENABLED&&(goog.included_={},goog.dependencies_={pathToNames:{},nameToPath:{},requires:{},visited:{},written:{}},goog.inHtmlDocument_=function(){var a=goog.global.document;return"undefined"!=typeof a&&"write"in a},goog.findBasePath_=function(){if(goog.global.CLOSURE_BASE_PATH)goog.basePath=goog.global.CLOSURE_BASE_PATH;else if(goog.inHtmlDocument_())for(var a=goog.global.document.getElementsByTagName("script"),b=a.length-1;0<=b;--b){var c=a[b].src,d=c.lastIndexOf("?"),d=-1==d?c.length:
d;if("base.js"==c.substr(d-7,7)){goog.basePath=c.substr(0,d-7);break}}},goog.importScript_=function(a){var b=goog.global.CLOSURE_IMPORT_SCRIPT||goog.writeScriptTag_;!goog.dependencies_.written[a]&&b(a)&&(goog.dependencies_.written[a]=!0)},goog.writeScriptTag_=function(a){if(goog.inHtmlDocument_()){var b=goog.global.document;if("complete"==b.readyState){if(/\bdeps.js$/.test(a))return!1;throw Error('Cannot write "'+a+'" after document load');}b.write('<script type="text/javascript" src="'+a+'">\x3c/script>');
return!0}return!1},goog.writeScripts_=function(){function a(e){if(!(e in d.written)){if(!(e in d.visited)&&(d.visited[e]=!0,e in d.requires))for(var g in d.requires[e])if(!goog.isProvided_(g))if(g in d.nameToPath)a(d.nameToPath[g]);else throw Error("Undefined nameToPath for "+g);e in c||(c[e]=!0,b.push(e))}}var b=[],c={},d=goog.dependencies_,e;for(e in goog.included_)d.written[e]||a(e);for(e=0;e<b.length;e++)if(b[e])goog.importScript_(goog.basePath+b[e]);else throw Error("Undefined script input");
},goog.getPathFromDeps_=function(a){return a in goog.dependencies_.nameToPath?goog.dependencies_.nameToPath[a]:null},goog.findBasePath_(),goog.global.CLOSURE_NO_DEPS||goog.importScript_(goog.basePath+"deps.js"));
goog.typeOf=function(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";
else if("function"==b&&"undefined"==typeof a.call)return"object";return b};goog.isDef=function(a){return void 0!==a};goog.isNull=function(a){return null===a};goog.isDefAndNotNull=function(a){return null!=a};goog.isArray=function(a){return"array"==goog.typeOf(a)};goog.isArrayLike=function(a){var b=goog.typeOf(a);return"array"==b||"object"==b&&"number"==typeof a.length};goog.isDateLike=function(a){return goog.isObject(a)&&"function"==typeof a.getFullYear};goog.isString=function(a){return"string"==typeof a};
goog.isBoolean=function(a){return"boolean"==typeof a};goog.isNumber=function(a){return"number"==typeof a};goog.isFunction=function(a){return"function"==goog.typeOf(a)};goog.isObject=function(a){var b=typeof a;return"object"==b&&null!=a||"function"==b};goog.getUid=function(a){return a[goog.UID_PROPERTY_]||(a[goog.UID_PROPERTY_]=++goog.uidCounter_)};goog.removeUid=function(a){"removeAttribute"in a&&a.removeAttribute(goog.UID_PROPERTY_);try{delete a[goog.UID_PROPERTY_]}catch(b){}};
goog.UID_PROPERTY_="closure_uid_"+(1E9*Math.random()>>>0);goog.uidCounter_=0;goog.getHashCode=goog.getUid;goog.removeHashCode=goog.removeUid;goog.cloneObject=function(a){var b=goog.typeOf(a);if("object"==b||"array"==b){if(a.clone)return a.clone();var b="array"==b?[]:{},c;for(c in a)b[c]=goog.cloneObject(a[c]);return b}return a};goog.bindNative_=function(a,b,c){return a.call.apply(a.bind,arguments)};
goog.bindJs_=function(a,b,c){if(!a)throw Error();if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var c=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(c,d);return a.apply(b,c)}}return function(){return a.apply(b,arguments)}};goog.bind=function(a,b,c){Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?goog.bind=goog.bindNative_:goog.bind=goog.bindJs_;return goog.bind.apply(null,arguments)};
goog.partial=function(a,b){var c=Array.prototype.slice.call(arguments,1);return function(){var b=Array.prototype.slice.call(arguments);b.unshift.apply(b,c);return a.apply(this,b)}};goog.mixin=function(a,b){for(var c in b)a[c]=b[c]};goog.now=goog.TRUSTED_SITE&&Date.now||function(){return+new Date};
goog.globalEval=function(a){if(goog.global.execScript)goog.global.execScript(a,"JavaScript");else if(goog.global.eval)if(null==goog.evalWorksForGlobals_&&(goog.global.eval("var _et_ = 1;"),"undefined"!=typeof goog.global._et_?(delete goog.global._et_,goog.evalWorksForGlobals_=!0):goog.evalWorksForGlobals_=!1),goog.evalWorksForGlobals_)goog.global.eval(a);else{var b=goog.global.document,c=b.createElement("script");c.type="text/javascript";c.defer=!1;c.appendChild(b.createTextNode(a));b.body.appendChild(c);
b.body.removeChild(c)}else throw Error("goog.globalEval not available");};goog.evalWorksForGlobals_=null;goog.getCssName=function(a,b){var c=function(a){return goog.cssNameMapping_[a]||a},d=function(a){a=a.split("-");for(var b=[],d=0;d<a.length;d++)b.push(c(a[d]));return b.join("-")},d=goog.cssNameMapping_?"BY_WHOLE"==goog.cssNameMappingStyle_?c:d:function(a){return a};return b?a+"-"+d(b):d(a)};goog.setCssNameMapping=function(a,b){goog.cssNameMapping_=a;goog.cssNameMappingStyle_=b};
!COMPILED&&goog.global.CLOSURE_CSS_NAME_MAPPING&&(goog.cssNameMapping_=goog.global.CLOSURE_CSS_NAME_MAPPING);goog.getMsg=function(a,b){var c=b||{},d;for(d in c){var e=(""+c[d]).replace(/\$/g,"$$$$");a=a.replace(RegExp("\\{\\$"+d+"\\}","gi"),e)}return a};goog.getMsgWithFallback=function(a,b){return a};goog.exportSymbol=function(a,b,c){goog.exportPath_(a,b,c)};goog.exportProperty=function(a,b,c){a[b]=c};
goog.inherits=function(a,b){function c(){}c.prototype=b.prototype;a.superClass_=b.prototype;a.prototype=new c;a.prototype.constructor=a};
goog.base=function(a,b,c){var d=arguments.callee.caller;if(goog.DEBUG&&!d)throw Error("arguments.caller not defined. goog.base() expects not to be running in strict mode. See http://www.ecma-international.org/ecma-262/5.1/#sec-C");if(d.superClass_)return d.superClass_.constructor.apply(a,Array.prototype.slice.call(arguments,1));for(var e=Array.prototype.slice.call(arguments,2),f=!1,g=a.constructor;g;g=g.superClass_&&g.superClass_.constructor)if(g.prototype[b]===d)f=!0;else if(f)return g.prototype[b].apply(a,
e);if(a[b]===d)return a.constructor.prototype[b].apply(a,e);throw Error("goog.base called from a method of one name to a method of a different name");};goog.scope=function(a){a.call(goog.global)};goog.string={};goog.string.Unicode={NBSP:"\u00a0"};goog.string.startsWith=function(a,b){return 0==a.lastIndexOf(b,0)};goog.string.endsWith=function(a,b){var c=a.length-b.length;return 0<=c&&a.indexOf(b,c)==c};goog.string.caseInsensitiveStartsWith=function(a,b){return 0==goog.string.caseInsensitiveCompare(b,a.substr(0,b.length))};goog.string.caseInsensitiveEndsWith=function(a,b){return 0==goog.string.caseInsensitiveCompare(b,a.substr(a.length-b.length,b.length))};
goog.string.caseInsensitiveEquals=function(a,b){return a.toLowerCase()==b.toLowerCase()};goog.string.subs=function(a,b){for(var c=a.split("%s"),d="",e=Array.prototype.slice.call(arguments,1);e.length&&1<c.length;)d+=c.shift()+e.shift();return d+c.join("%s")};goog.string.collapseWhitespace=function(a){return a.replace(/[\s\xa0]+/g," ").replace(/^\s+|\s+$/g,"")};goog.string.isEmpty=function(a){return/^[\s\xa0]*$/.test(a)};goog.string.isEmptySafe=function(a){return goog.string.isEmpty(goog.string.makeSafe(a))};
goog.string.isBreakingWhitespace=function(a){return!/[^\t\n\r ]/.test(a)};goog.string.isAlpha=function(a){return!/[^a-zA-Z]/.test(a)};goog.string.isNumeric=function(a){return!/[^0-9]/.test(a)};goog.string.isAlphaNumeric=function(a){return!/[^a-zA-Z0-9]/.test(a)};goog.string.isSpace=function(a){return" "==a};goog.string.isUnicodeChar=function(a){return 1==a.length&&" "<=a&&"~">=a||"\u0080"<=a&&"\ufffd">=a};goog.string.stripNewlines=function(a){return a.replace(/(\r\n|\r|\n)+/g," ")};
goog.string.canonicalizeNewlines=function(a){return a.replace(/(\r\n|\r|\n)/g,"\n")};goog.string.normalizeWhitespace=function(a){return a.replace(/\xa0|\s/g," ")};goog.string.normalizeSpaces=function(a){return a.replace(/\xa0|[ \t]+/g," ")};goog.string.collapseBreakingSpaces=function(a){return a.replace(/[\t\r\n ]+/g," ").replace(/^[\t\r\n ]+|[\t\r\n ]+$/g,"")};goog.string.trim=function(a){return a.replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")};
goog.string.trimLeft=function(a){return a.replace(/^[\s\xa0]+/,"")};goog.string.trimRight=function(a){return a.replace(/[\s\xa0]+$/,"")};goog.string.caseInsensitiveCompare=function(a,b){var c=String(a).toLowerCase(),d=String(b).toLowerCase();return c<d?-1:c==d?0:1};goog.string.numerateCompareRegExp_=/(\.\d+)|(\d+)|(\D+)/g;
goog.string.numerateCompare=function(a,b){if(a==b)return 0;if(!a)return-1;if(!b)return 1;for(var c=a.toLowerCase().match(goog.string.numerateCompareRegExp_),d=b.toLowerCase().match(goog.string.numerateCompareRegExp_),e=Math.min(c.length,d.length),f=0;f<e;f++){var g=c[f],h=d[f];if(g!=h)return c=parseInt(g,10),!isNaN(c)&&(d=parseInt(h,10),!isNaN(d)&&c-d)?c-d:g<h?-1:1}return c.length!=d.length?c.length-d.length:a<b?-1:1};goog.string.urlEncode=function(a){return encodeURIComponent(String(a))};
goog.string.urlDecode=function(a){return decodeURIComponent(a.replace(/\+/g," "))};goog.string.newLineToBr=function(a,b){return a.replace(/(\r\n|\r|\n)/g,b?"<br />":"<br>")};
goog.string.htmlEscape=function(a,b){if(b)return a.replace(goog.string.amperRe_,"&amp;").replace(goog.string.ltRe_,"&lt;").replace(goog.string.gtRe_,"&gt;").replace(goog.string.quotRe_,"&quot;");if(!goog.string.allRe_.test(a))return a;-1!=a.indexOf("&")&&(a=a.replace(goog.string.amperRe_,"&amp;"));-1!=a.indexOf("<")&&(a=a.replace(goog.string.ltRe_,"&lt;"));-1!=a.indexOf(">")&&(a=a.replace(goog.string.gtRe_,"&gt;"));-1!=a.indexOf('"')&&(a=a.replace(goog.string.quotRe_,"&quot;"));return a};
goog.string.amperRe_=/&/g;goog.string.ltRe_=/</g;goog.string.gtRe_=/>/g;goog.string.quotRe_=/\"/g;goog.string.allRe_=/[&<>\"]/;goog.string.unescapeEntities=function(a){return goog.string.contains(a,"&")?"document"in goog.global?goog.string.unescapeEntitiesUsingDom_(a):goog.string.unescapePureXmlEntities_(a):a};
goog.string.unescapeEntitiesUsingDom_=function(a){var b={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"'},c=document.createElement("div");return a.replace(goog.string.HTML_ENTITY_PATTERN_,function(a,e){var f=b[a];if(f)return f;if("#"==e.charAt(0)){var g=Number("0"+e.substr(1));isNaN(g)||(f=String.fromCharCode(g))}f||(c.innerHTML=a+" ",f=c.firstChild.nodeValue.slice(0,-1));return b[a]=f})};
goog.string.unescapePureXmlEntities_=function(a){return a.replace(/&([^;]+);/g,function(a,c){switch(c){case "amp":return"&";case "lt":return"<";case "gt":return">";case "quot":return'"';default:if("#"==c.charAt(0)){var d=Number("0"+c.substr(1));if(!isNaN(d))return String.fromCharCode(d)}return a}})};goog.string.HTML_ENTITY_PATTERN_=/&([^;\s<&]+);?/g;goog.string.whitespaceEscape=function(a,b){return goog.string.newLineToBr(a.replace(/ /g," &#160;"),b)};
goog.string.stripQuotes=function(a,b){for(var c=b.length,d=0;d<c;d++){var e=1==c?b:b.charAt(d);if(a.charAt(0)==e&&a.charAt(a.length-1)==e)return a.substring(1,a.length-1)}return a};goog.string.truncate=function(a,b,c){c&&(a=goog.string.unescapeEntities(a));a.length>b&&(a=a.substring(0,b-3)+"...");c&&(a=goog.string.htmlEscape(a));return a};
goog.string.truncateMiddle=function(a,b,c,d){c&&(a=goog.string.unescapeEntities(a));if(d&&a.length>b){d>b&&(d=b);var e=a.length-d;a=a.substring(0,b-d)+"..."+a.substring(e)}else a.length>b&&(d=Math.floor(b/2),e=a.length-d,a=a.substring(0,d+b%2)+"..."+a.substring(e));c&&(a=goog.string.htmlEscape(a));return a};goog.string.specialEscapeChars_={"\x00":"\\0","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\x0B",'"':'\\"',"\\":"\\\\"};goog.string.jsEscapeCache_={"'":"\\'"};
goog.string.quote=function(a){a=String(a);if(a.quote)return a.quote();for(var b=['"'],c=0;c<a.length;c++){var d=a.charAt(c),e=d.charCodeAt(0);b[c+1]=goog.string.specialEscapeChars_[d]||(31<e&&127>e?d:goog.string.escapeChar(d))}b.push('"');return b.join("")};goog.string.escapeString=function(a){for(var b=[],c=0;c<a.length;c++)b[c]=goog.string.escapeChar(a.charAt(c));return b.join("")};
goog.string.escapeChar=function(a){if(a in goog.string.jsEscapeCache_)return goog.string.jsEscapeCache_[a];if(a in goog.string.specialEscapeChars_)return goog.string.jsEscapeCache_[a]=goog.string.specialEscapeChars_[a];var b=a,c=a.charCodeAt(0);if(31<c&&127>c)b=a;else{if(256>c){if(b="\\x",16>c||256<c)b+="0"}else b="\\u",4096>c&&(b+="0");b+=c.toString(16).toUpperCase()}return goog.string.jsEscapeCache_[a]=b};goog.string.toMap=function(a){for(var b={},c=0;c<a.length;c++)b[a.charAt(c)]=!0;return b};
goog.string.contains=function(a,b){return-1!=a.indexOf(b)};goog.string.countOf=function(a,b){return a&&b?a.split(b).length-1:0};goog.string.removeAt=function(a,b,c){var d=a;0<=b&&(b<a.length&&0<c)&&(d=a.substr(0,b)+a.substr(b+c,a.length-b-c));return d};goog.string.remove=function(a,b){var c=RegExp(goog.string.regExpEscape(b),"");return a.replace(c,"")};goog.string.removeAll=function(a,b){var c=RegExp(goog.string.regExpEscape(b),"g");return a.replace(c,"")};
goog.string.regExpEscape=function(a){return String(a).replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g,"\\$1").replace(/\x08/g,"\\x08")};goog.string.repeat=function(a,b){return Array(b+1).join(a)};goog.string.padNumber=function(a,b,c){a=goog.isDef(c)?a.toFixed(c):String(a);c=a.indexOf(".");-1==c&&(c=a.length);return goog.string.repeat("0",Math.max(0,b-c))+a};goog.string.makeSafe=function(a){return null==a?"":String(a)};goog.string.buildString=function(a){return Array.prototype.join.call(arguments,"")};
goog.string.getRandomString=function(){return Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^goog.now()).toString(36)};
goog.string.compareVersions=function(a,b){for(var c=0,d=goog.string.trim(String(a)).split("."),e=goog.string.trim(String(b)).split("."),f=Math.max(d.length,e.length),g=0;0==c&&g<f;g++){var h=d[g]||"",k=e[g]||"",l=RegExp("(\\d*)(\\D*)","g"),m=RegExp("(\\d*)(\\D*)","g");do{var n=l.exec(h)||["","",""],p=m.exec(k)||["","",""];if(0==n[0].length&&0==p[0].length)break;var c=0==n[1].length?0:parseInt(n[1],10),q=0==p[1].length?0:parseInt(p[1],10),c=goog.string.compareElements_(c,q)||goog.string.compareElements_(0==
n[2].length,0==p[2].length)||goog.string.compareElements_(n[2],p[2])}while(0==c)}return c};goog.string.compareElements_=function(a,b){return a<b?-1:a>b?1:0};goog.string.HASHCODE_MAX_=4294967296;goog.string.hashCode=function(a){for(var b=0,c=0;c<a.length;++c)b=31*b+a.charCodeAt(c),b%=goog.string.HASHCODE_MAX_;return b};goog.string.uniqueStringCounter_=2147483648*Math.random()|0;goog.string.createUniqueString=function(){return"goog_"+goog.string.uniqueStringCounter_++};
goog.string.toNumber=function(a){var b=Number(a);return 0==b&&goog.string.isEmpty(a)?NaN:b};goog.string.isLowerCamelCase=function(a){return/^[a-z]+([A-Z][a-z]*)*$/.test(a)};goog.string.isUpperCamelCase=function(a){return/^([A-Z][a-z]*)+$/.test(a)};goog.string.toCamelCase=function(a){return String(a).replace(/\-([a-z])/g,function(a,c){return c.toUpperCase()})};goog.string.toSelectorCase=function(a){return String(a).replace(/([A-Z])/g,"-$1").toLowerCase()};
goog.string.toTitleCase=function(a,b){var c=goog.isString(b)?goog.string.regExpEscape(b):"\\s";return a.replace(RegExp("(^"+(c?"|["+c+"]+":"")+")([a-z])","g"),function(a,b,c){return b+c.toUpperCase()})};goog.string.parseInt=function(a){isFinite(a)&&(a=String(a));return goog.isString(a)?/^\s*-?0x/i.test(a)?parseInt(a,16):parseInt(a,10):NaN};goog.string.splitLimit=function(a,b,c){a=a.split(b);for(var d=[];0<c&&a.length;)d.push(a.shift()),c--;a.length&&d.push(a.join(b));return d};goog.debug={};goog.debug.Error=function(a){Error.captureStackTrace?Error.captureStackTrace(this,goog.debug.Error):this.stack=Error().stack||"";a&&(this.message=String(a))};goog.inherits(goog.debug.Error,Error);goog.debug.Error.prototype.name="CustomError";goog.asserts={};goog.asserts.ENABLE_ASSERTS=goog.DEBUG;goog.asserts.AssertionError=function(a,b){b.unshift(a);goog.debug.Error.call(this,goog.string.subs.apply(null,b));b.shift();this.messagePattern=a};goog.inherits(goog.asserts.AssertionError,goog.debug.Error);goog.asserts.AssertionError.prototype.name="AssertionError";goog.asserts.doAssertFailure_=function(a,b,c,d){var e="Assertion failed";if(c)var e=e+(": "+c),f=d;else a&&(e+=": "+a,f=b);throw new goog.asserts.AssertionError(""+e,f||[]);};
goog.asserts.assert=function(a,b,c){goog.asserts.ENABLE_ASSERTS&&!a&&goog.asserts.doAssertFailure_("",null,b,Array.prototype.slice.call(arguments,2));return a};goog.asserts.fail=function(a,b){if(goog.asserts.ENABLE_ASSERTS)throw new goog.asserts.AssertionError("Failure"+(a?": "+a:""),Array.prototype.slice.call(arguments,1));};
goog.asserts.assertNumber=function(a,b,c){goog.asserts.ENABLE_ASSERTS&&!goog.isNumber(a)&&goog.asserts.doAssertFailure_("Expected number but got %s: %s.",[goog.typeOf(a),a],b,Array.prototype.slice.call(arguments,2));return a};goog.asserts.assertString=function(a,b,c){goog.asserts.ENABLE_ASSERTS&&!goog.isString(a)&&goog.asserts.doAssertFailure_("Expected string but got %s: %s.",[goog.typeOf(a),a],b,Array.prototype.slice.call(arguments,2));return a};
goog.asserts.assertFunction=function(a,b,c){goog.asserts.ENABLE_ASSERTS&&!goog.isFunction(a)&&goog.asserts.doAssertFailure_("Expected function but got %s: %s.",[goog.typeOf(a),a],b,Array.prototype.slice.call(arguments,2));return a};goog.asserts.assertObject=function(a,b,c){goog.asserts.ENABLE_ASSERTS&&!goog.isObject(a)&&goog.asserts.doAssertFailure_("Expected object but got %s: %s.",[goog.typeOf(a),a],b,Array.prototype.slice.call(arguments,2));return a};
goog.asserts.assertArray=function(a,b,c){goog.asserts.ENABLE_ASSERTS&&!goog.isArray(a)&&goog.asserts.doAssertFailure_("Expected array but got %s: %s.",[goog.typeOf(a),a],b,Array.prototype.slice.call(arguments,2));return a};goog.asserts.assertBoolean=function(a,b,c){goog.asserts.ENABLE_ASSERTS&&!goog.isBoolean(a)&&goog.asserts.doAssertFailure_("Expected boolean but got %s: %s.",[goog.typeOf(a),a],b,Array.prototype.slice.call(arguments,2));return a};
goog.asserts.assertInstanceof=function(a,b,c,d){!goog.asserts.ENABLE_ASSERTS||a instanceof b||goog.asserts.doAssertFailure_("instanceof check failed.",null,c,Array.prototype.slice.call(arguments,3));return a};goog.asserts.assertObjectPrototypeIsIntact=function(){for(var a in Object.prototype)goog.asserts.fail(a+" should not be enumerable in Object.prototype.")};var Sk=Sk||{};
Sk.configure=function(a){Sk.output=a.output||Sk.output;goog.asserts.assert("function"===typeof Sk.output);Sk.debugout=a.debugout||Sk.debugout;goog.asserts.assert("function"===typeof Sk.debugout);Sk.read=a.read||Sk.read;goog.asserts.assert("function"===typeof Sk.read);Sk.timeoutMsg=a.timeoutMsg||Sk.timeoutMsg;goog.asserts.assert("function"===typeof Sk.timeoutMsg);goog.exportSymbol("Sk.timeoutMsg",Sk.timeoutMsg);Sk.sysargv=a.sysargv||Sk.sysargv;goog.asserts.assert(goog.isArrayLike(Sk.sysargv));Sk.python3=
a.python3||Sk.python3;goog.asserts.assert("boolean"===typeof Sk.python3);Sk.inputfun=a.inputfun||Sk.inputfun;goog.asserts.assert("function"===typeof Sk.inputfun);Sk.throwSystemExit=a.systemexit||!1;goog.asserts.assert("boolean"===typeof Sk.throwSystemExit);Sk.retainGlobals=a.retainglobals||!1;goog.asserts.assert("boolean"===typeof Sk.throwSystemExit);a.syspath&&(Sk.syspath=a.syspath,goog.asserts.assert(goog.isArrayLike(Sk.syspath)),Sk.realsyspath=void 0,Sk.sysmodules=new Sk.builtin.dict([]));Sk.misceval.softspace_=
!1};goog.exportSymbol("Sk.configure",Sk.configure);Sk.timeoutMsg=function(){return"Program exceeded run time limit."};goog.exportSymbol("Sk.timeoutMsg",Sk.timeoutMsg);Sk.output=function(a){};Sk.read=function(a){throw"Sk.read has not been implemented";};Sk.sysargv=[];Sk.getSysArgv=function(){return Sk.sysargv};goog.exportSymbol("Sk.getSysArgv",Sk.getSysArgv);Sk.syspath=[];Sk.inBrowser=void 0!==goog.global.document;Sk.debugout=function(a){};
(function(){void 0!==goog.global.write?Sk.output=goog.global.write:void 0!==goog.global.console&&void 0!==goog.global.console.log?Sk.output=function(a){goog.global.console.log(a)}:void 0!==goog.global.print&&(Sk.output=goog.global.print);void 0!==goog.global.print&&(Sk.debugout=goog.global.print)})();Sk.inBrowser||(goog.global.CLOSURE_IMPORT_SCRIPT=function(a){goog.global.eval(goog.global.read("support/closure-library/closure/goog/"+a));return!0});Sk.python3=!1;Sk.inputfun=function(a){return prompt(a)};
goog.exportSymbol("Sk.python3",Sk.python3);goog.exportSymbol("Sk.inputfun",Sk.inputfun);Sk.builtin={};
Sk.builtin.range=function(a,b,c){var d=[],e;Sk.builtin.pyCheckArgs("range",arguments,1,3);Sk.builtin.pyCheckType("start","integer",Sk.builtin.checkInt(a));void 0!==b&&Sk.builtin.pyCheckType("stop","integer",Sk.builtin.checkInt(b));void 0!==c&&Sk.builtin.pyCheckType("step","integer",Sk.builtin.checkInt(c));a=Sk.builtin.asnum$(a);b=Sk.builtin.asnum$(b);c=Sk.builtin.asnum$(c);void 0===b&&void 0===c?(b=a,a=0,c=1):void 0===c&&(c=1);if(0===c)throw new Sk.builtin.ValueError("range() step argument must not be zero");if(0<
c)for(e=a;e<b;e+=c)d.push(new Sk.builtin.nmber(e,Sk.builtin.nmber.int$));else for(e=a;e>b;e+=c)d.push(new Sk.builtin.nmber(e,Sk.builtin.nmber.int$));return new Sk.builtin.list(d)};
Sk.builtin.asnum$=function(a){return void 0===a||null===a?a:a.constructor===Sk.builtin.none?null:a.constructor===Sk.builtin.bool?a.v?1:0:"number"===typeof a?a:"string"===typeof a?a:a.constructor===Sk.builtin.nmber?a.v:a.constructor===Sk.builtin.lng?a.cantBeInt()?a.str$(10,!0):a.toInt$():a.constructor===Sk.builtin.biginteger?0<a.trueCompare(new Sk.builtin.biginteger(Sk.builtin.nmber.threshold$))||0>a.trueCompare(new Sk.builtin.biginteger(-Sk.builtin.nmber.threshold$))?a.toString():a.intValue():a};
goog.exportSymbol("Sk.builtin.asnum$",Sk.builtin.asnum$);Sk.builtin.assk$=function(a,b){return new Sk.builtin.nmber(a,b)};goog.exportSymbol("Sk.builtin.assk$",Sk.builtin.assk$);
Sk.builtin.asnum$nofloat=function(a){if(void 0===a||null===a)return a;if(a.constructor===Sk.builtin.none)return null;if(a.constructor===Sk.builtin.bool)return a.v?1:0;"number"===typeof a&&(a=a.toString());a.constructor===Sk.builtin.nmber&&(a=a.v.toString());a.constructor===Sk.builtin.lng&&(a=a.str$(10,!0));a.constructor===Sk.builtin.biginteger&&(a=a.toString());if(0>a.indexOf(".")&&0>a.indexOf("e")&&0>a.indexOf("E"))return a;var b=0,c;0<=a.indexOf("e")?(c=a.substr(0,a.indexOf("e")),b=a.substr(a.indexOf("e")+
1)):0<=a.indexOf("E")?(c=a.substr(0,a.indexOf("e")),b=a.substr(a.indexOf("E")+1)):c=a;b=parseInt(b,10);a=c.indexOf(".");if(0>a){if(0<=b){for(;0<b--;)c+="0";return c}return c.length>-b?c.substr(0,c.length+b):0}c=0==a?c.substr(1):a<c.length?c.substr(0,a)+c.substr(a+1):c.substr(0,a);for(a+=b;a>c.length;)c+="0";return c=0>=a?0:c.substr(0,a)};goog.exportSymbol("Sk.builtin.asnum$nofloat",Sk.builtin.asnum$nofloat);
Sk.builtin.round=function(a,b){var c;Sk.builtin.pyCheckArgs("round",arguments,1,2);if(!Sk.builtin.checkNumber(a))throw new Sk.builtin.TypeError("a float is required");if(void 0!==b&&!Sk.misceval.isIndex(b))throw new Sk.builtin.TypeError("'"+Sk.abstr.typeName(b)+"' object cannot be interpreted as an index");void 0===b&&(b=0);a=Sk.builtin.asnum$(a);b=Sk.misceval.asIndex(b);c=Math.pow(10,b);c=Math.round(a*c)/c;return new Sk.builtin.nmber(c,Sk.builtin.nmber.float$)};
Sk.builtin.len=function(a){Sk.builtin.pyCheckArgs("len",arguments,1,1);if(a.sq$length)return new Sk.builtin.nmber(a.sq$length(),Sk.builtin.nmber.int$);if(a.mp$length)return new Sk.builtin.nmber(a.mp$length(),Sk.builtin.nmber.int$);if(a.tp$length)return new Sk.builtin.nmber(a.tp$length(),Sk.builtin.nmber.int$);throw new Sk.builtin.TypeError("object of type '"+Sk.abstr.typeName(a)+"' has no len()");};
Sk.builtin.min=function(){Sk.builtin.pyCheckArgs("min",arguments,1);var a=Sk.misceval.arrayFromArguments(arguments),b=a[0];if(void 0===b)throw new Sk.builtin.ValueError("min() arg is an empty sequence");for(var c=1;c<a.length;++c)Sk.misceval.richCompareBool(a[c],b,"Lt")&&(b=a[c]);return b};
Sk.builtin.max=function(){Sk.builtin.pyCheckArgs("max",arguments,1);var a=Sk.misceval.arrayFromArguments(arguments),b=a[0];if(void 0===b)throw new Sk.builtin.ValueError("max() arg is an empty sequence");for(var c=1;c<a.length;++c)Sk.misceval.richCompareBool(a[c],b,"Gt")&&(b=a[c]);return b};
Sk.builtin.any=function(a){var b,c;Sk.builtin.pyCheckArgs("any",arguments,1);if(!Sk.builtin.checkIterable(a))throw new Sk.builtin.TypeError("'"+Sk.abstr.typeName(a)+"' object is not iterable");b=a.tp$iter();for(c=b.tp$iternext();void 0!==c;c=b.tp$iternext())if(Sk.misceval.isTrue(c))return Sk.builtin.bool.true$;return Sk.builtin.bool.false$};
Sk.builtin.all=function(a){var b,c;Sk.builtin.pyCheckArgs("all",arguments,1);if(!Sk.builtin.checkIterable(a))throw new Sk.builtin.TypeError("'"+Sk.abstr.typeName(a)+"' object is not iterable");b=a.tp$iter();for(c=b.tp$iternext();void 0!==c;c=b.tp$iternext())if(!Sk.misceval.isTrue(c))return Sk.builtin.bool.false$;return Sk.builtin.bool.true$};
Sk.builtin.sum=function(a,b){var c,d,e,f;Sk.builtin.pyCheckArgs("sum",arguments,1,2);Sk.builtin.pyCheckType("iter","iterable",Sk.builtin.checkIterable(a));if(void 0!==b&&Sk.builtin.checkString(b))throw new Sk.builtin.TypeError("sum() can't sum strings [use ''.join(seq) instead]");c=void 0===b?new Sk.builtin.nmber(0,Sk.builtin.nmber.int$):b;d=a.tp$iter();for(e=d.tp$iternext();void 0!==e;e=d.tp$iternext())if(e.skType===Sk.builtin.nmber.float$?(f=!0,c.skType!==Sk.builtin.nmber.float$&&(c=new Sk.builtin.nmber(Sk.builtin.asnum$(c),
Sk.builtin.nmber.float$))):e instanceof Sk.builtin.lng&&(f||c instanceof Sk.builtin.lng||(c=new Sk.builtin.lng(c))),void 0!==c.nb$add(e))c=c.nb$add(e);else throw new Sk.builtin.TypeError("unsupported operand type(s) for +: '"+Sk.abstr.typeName(c)+"' and '"+Sk.abstr.typeName(e)+"'");return c};
Sk.builtin.zip=function(){if(0===arguments.length)return new Sk.builtin.list([]);for(var a=[],b=0;b<arguments.length;b++)if(arguments[b].tp$iter)a.push(arguments[b].tp$iter());else throw"TypeError: argument "+b+" must support iteration";for(var c=[],d=!1;!d;){for(var e=[],b=0;b<arguments.length;b++){var f=a[b].tp$iternext();if(void 0===f){d=!0;break}e.push(f)}d||c.push(new Sk.builtin.tuple(e))}return new Sk.builtin.list(c)};
Sk.builtin.abs=function(a){Sk.builtin.pyCheckArgs("abs",arguments,1,1);Sk.builtin.pyCheckType("x","number",Sk.builtin.checkNumber(a));return new Sk.builtin.nmber(Math.abs(Sk.builtin.asnum$(a)),a.skType)};
Sk.builtin.ord=function(a){Sk.builtin.pyCheckArgs("ord",arguments,1,1);if(!Sk.builtin.checkString(a))throw new Sk.builtin.TypeError("ord() expected a string of length 1, but "+Sk.abstr.typeName(a)+" found");if(1!==a.v.length)throw new Sk.builtin.TypeError("ord() expected a character, but string of length "+a.v.length+" found");return new Sk.builtin.nmber(a.v.charCodeAt(0),Sk.builtin.nmber.int$)};
Sk.builtin.chr=function(a){Sk.builtin.pyCheckArgs("chr",arguments,1,1);if(!Sk.builtin.checkInt(a))throw new Sk.builtin.TypeError("an integer is required");a=Sk.builtin.asnum$(a);if(0>a||255<a)throw new Sk.builtin.ValueError("chr() arg not in range(256)");return new Sk.builtin.str(String.fromCharCode(a))};
Sk.builtin.int2str_=function(a,b,c){var d="";if(a instanceof Sk.builtin.lng){var e="";2!==b&&(e="L");d=a.str$(b,!1);return a.nb$isnegative()?new Sk.builtin.str("-"+c+d+e):new Sk.builtin.str(c+d+e)}a=Sk.misceval.asIndex(a);d=a.toString(b);return 0>a?new Sk.builtin.str("-"+c+d.slice(1)):new Sk.builtin.str(c+d)};
Sk.builtin.hex=function(a){Sk.builtin.pyCheckArgs("hex",arguments,1,1);if(!Sk.misceval.isIndex(a))throw new Sk.builtin.TypeError("hex() argument can't be converted to hex");return Sk.builtin.int2str_(a,16,"0x")};Sk.builtin.oct=function(a){Sk.builtin.pyCheckArgs("oct",arguments,1,1);if(!Sk.misceval.isIndex(a))throw new Sk.builtin.TypeError("oct() argument can't be converted to hex");return Sk.builtin.int2str_(a,8,"0")};
Sk.builtin.bin=function(a){Sk.builtin.pyCheckArgs("bin",arguments,1,1);if(!Sk.misceval.isIndex(a))throw new Sk.builtin.TypeError("'"+Sk.abstr.typeName(a)+"' object can't be interpreted as an index");return Sk.builtin.int2str_(a,2,"0b")};
Sk.builtin.dir=function(a){Sk.builtin.pyCheckArgs("dir",arguments,1,1);var b=function(a){var b=null;if(-1!==["__bases__","__mro__","__class__"].indexOf(a))return null;-1!==a.indexOf("$")?b=Sk.builtin.dir.slotNameToRichName(a):"_"!==a.charAt(a.length-1)?b=a:"_"===a.charAt(0)&&(b=a);return b},c=[],d,e,f,g,h;for(d in a.constructor.prototype)(e=b(d))&&c.push(new Sk.builtin.str(e));if(a.$d)if(a.$d.tp$iter)for(f=a.$d.tp$iter(),d=f.tp$iternext();void 0!==d;d=f.tp$iternext())e=new Sk.builtin.str(d),(e=b(e.v))&&
c.push(new Sk.builtin.str(e));else for(e in a.$d)c.push(new Sk.builtin.str(e));if(f=a.tp$mro)for(f=a.tp$mro,d=0;d<f.v.length;++d)for(h in g=f.v[d],g)g.hasOwnProperty(h)&&(e=b(h))&&c.push(new Sk.builtin.str(e));c.sort(function(a,b){return(a.v>b.v)-(a.v<b.v)});return new Sk.builtin.list(c.filter(function(a,b,c){return a!==c[b+1]}))};Sk.builtin.dir.slotNameToRichName=function(a){};Sk.builtin.repr=function(a){Sk.builtin.pyCheckArgs("repr",arguments,1,1);return Sk.misceval.objectRepr(a)};
Sk.builtin.open=function(a,b,c){Sk.builtin.pyCheckArgs("open",arguments,1,3);void 0===b&&(b=new Sk.builtin.str("r"));if("r"!==b.v&&"rb"!==b.v)throw"todo; haven't implemented non-read opens";return new Sk.builtin.file(a,b,c)};
Sk.builtin.isinstance=function(a,b){Sk.builtin.pyCheckArgs("isinstance",arguments,2,2);if(!(Sk.builtin.checkClass(b)||b instanceof Sk.builtin.tuple))throw new Sk.builtin.TypeError("isinstance() arg 2 must be a class, type, or tuple of classes and types");if(b===Sk.builtin.int_.prototype.ob$type)return"number"===a.tp$name&&a.skType===Sk.builtin.nmber.int$?Sk.builtin.bool.true$:Sk.builtin.bool.false$;if(b===Sk.builtin.float_.prototype.ob$type)return"number"===a.tp$name&&a.skType===Sk.builtin.nmber.float$?
Sk.builtin.bool.true$:Sk.builtin.bool.false$;if(b===Sk.builtin.none.prototype.ob$type)return a instanceof Sk.builtin.none?Sk.builtin.bool.true$:Sk.builtin.bool.false$;if(a.ob$type===b)return Sk.builtin.bool.true$;if(b instanceof Sk.builtin.tuple){for(var c=0;c<b.v.length;++c)if(Sk.misceval.isTrue(Sk.builtin.isinstance(a,b.v[c])))return Sk.builtin.bool.true$;return Sk.builtin.bool.false$}var d=function(a,b){if(a===b)return Sk.builtin.bool.true$;if(void 0===a.$d)return Sk.builtin.bool.false$;for(var c=
a.$d.mp$subscript(Sk.builtin.type.basesStr_),h=0;h<c.v.length;++h)if(Sk.misceval.isTrue(d(c.v[h],b)))return Sk.builtin.bool.true$;return Sk.builtin.bool.false$};return d(a.ob$type,b)};Sk.builtin.hashCount=0;
Sk.builtin.hash=function(a){Sk.builtin.pyCheckArgs("hash",arguments,1,1);if(a instanceof Object&&void 0!==a.tp$hash){if(a.$savedHash_)return a.$savedHash_;a.$savedHash_=a.tp$hash();return a.$savedHash_}if(a instanceof Object&&void 0!==a.__hash__)return Sk.misceval.callsim(a.__hash__,a);if(a instanceof Sk.builtin.bool)return a.v?new Sk.builtin.nmber(1,Sk.builtin.nmber.int$):new Sk.builtin.nmber(0,Sk.builtin.nmber.int$);if(a instanceof Sk.builtin.none)return new Sk.builtin.nmber(0,Sk.builtin.nmber.int$);
if(a instanceof Object)return void 0===a.__id&&(Sk.builtin.hashCount+=1,a.__id=Sk.builtin.hashCount),new Sk.builtin.nmber(a.__id,Sk.builtin.nmber.int$);if("number"===typeof a||null===a||!0===a||!1===a)throw new Sk.builtin.TypeError("unsupported Javascript type");return new Sk.builtin.str(typeof a+" "+String(a))};
Sk.builtin.getattr=function(a,b,c){Sk.builtin.pyCheckArgs("getattr",arguments,2,3);if(!Sk.builtin.checkString(b))throw new Sk.builtin.TypeError("attribute name must be string");var d=a.tp$getattr(b.v);if(void 0===d){if(void 0!==c)return c;throw new Sk.builtin.AttributeError("'"+Sk.abstr.typeName(a)+"' object has no attribute '"+b.v+"'");}return d};Sk.builtin.raw_input=function(a){a=a?a.v:"";a=Sk.inputfun(a);return new Sk.builtin.str(a)};Sk.builtin.input=Sk.builtin.raw_input;Sk.builtin.jseval=function(a){goog.global.eval(a)};
Sk.builtin.jsmillis=function(){return(new Date).valueOf()};Sk.builtin.superbi=function(){throw new Sk.builtin.NotImplementedError("super is not yet implemented, please report your use case as a github issue.");};Sk.builtin.eval_=function(){throw new Sk.builtin.NotImplementedError("eval is not yet implemented");};
Sk.builtin.map=function(a,b){Sk.builtin.pyCheckArgs("map",arguments,2);if(2<arguments.length){var c=[],d=Array.prototype.slice.apply(arguments).slice(1),e;for(e in d){if(!Sk.builtin.checkIterable(d[e]))throw c=parseInt(e,10)+2,new Sk.builtin.TypeError("argument "+c+" to map() must support iteration");d[e]=d[e].tp$iter()}for(;;){var f=[],g=0;for(e in d){var h=d[e].tp$iternext();void 0===h?(f.push(Sk.builtin.none.none$),g++):f.push(h)}if(g!==d.length)c.push(f);else break}b=new Sk.builtin.list(c)}if(!Sk.builtin.checkIterable(b))throw new Sk.builtin.TypeError("'"+
Sk.abstr.typeName(b)+"' object is not iterable");c=[];d=b.tp$iter();for(e=d.tp$iternext();void 0!==e;e=d.tp$iternext())a===Sk.builtin.none.none$?(e instanceof Array&&(e=new Sk.builtin.tuple(e)),c.push(e)):(e instanceof Array||(e=[e]),c.push(Sk.misceval.apply(a,void 0,void 0,void 0,e)));return new Sk.builtin.list(c)};
Sk.builtin.reduce=function(a,b,c){Sk.builtin.pyCheckArgs("reduce",arguments,2,3);if(!Sk.builtin.checkIterable(b))throw new Sk.builtin.TypeError("'"+Sk.abstr.typeName(b)+"' object is not iterable");var d=b.tp$iter();if(void 0===c&&(c=d.tp$iternext(),void 0===c))throw new Sk.builtin.TypeError("reduce() of empty sequence with no initial value");var e=c,f;for(f=d.tp$iternext();void 0!==f;f=d.tp$iternext())e=Sk.misceval.callsim(a,e,f);return e};
Sk.builtin.filter=function(a,b){Sk.builtin.pyCheckArgs("filter",arguments,2,2);if(!Sk.builtin.checkIterable(b))throw new Sk.builtin.TypeError("'"+Sk.abstr.typeName(b)+"' object is not iterable");var c=function(){return[]},d=function(a,b){a.push(b);return a},e=function(a){return new Sk.builtin.list(a)};b.__class__===Sk.builtin.str?(c=function(){return new Sk.builtin.str("")},d=function(a,b){return a.sq$concat(b)},e=function(a){return a}):b.__class__===Sk.builtin.tuple&&(e=function(a){return new Sk.builtin.tuple(a)});
var c=c(),f,g,h;f=b.tp$iter();for(g=f.tp$iternext();void 0!==g;g=f.tp$iternext())h=a===Sk.builtin.none.none$?Sk.builtin.bool(g):Sk.misceval.callsim(a,g),Sk.misceval.isTrue(h)&&(c=d(c,g));return e(c)};
Sk.builtin.hasattr=function(a,b){Sk.builtin.pyCheckArgs("hasattr",arguments,2,2);if(!Sk.builtin.checkString(b))throw new Sk.builtin.TypeError("hasattr(): attribute name must be string");if(a.tp$getattr)return a.tp$getattr(b.v)?Sk.builtin.bool.true$:Sk.builtin.bool.false$;throw new Sk.builtin.AttributeError("Object has no tp$getattr method");};
Sk.builtin.pow=function(a,b,c){Sk.builtin.pyCheckArgs("pow",arguments,2,3);c instanceof Sk.builtin.none&&(c=void 0);var d=Sk.builtin.asnum$(a),e=Sk.builtin.asnum$(b);Sk.builtin.asnum$(c);if(!Sk.builtin.checkNumber(a)||!Sk.builtin.checkNumber(b)){if(void 0===c)throw new Sk.builtin.TypeError("unsupported operand type(s) for pow(): '"+Sk.abstr.typeName(a)+"' and '"+Sk.abstr.typeName(b)+"'");throw new Sk.builtin.TypeError("unsupported operand type(s) for pow(): '"+Sk.abstr.typeName(a)+"', '"+Sk.abstr.typeName(b)+
"', '"+Sk.abstr.typeName(c)+"'");}if(0>d&&b.skType===Sk.builtin.nmber.float$)throw new Sk.builtin.ValueError("negative number cannot be raised to a fractional power");if(void 0===c){if(a.skType===Sk.builtin.nmber.float$||b.skType===Sk.builtin.nmber.float$||0>e)return new Sk.builtin.nmber(Math.pow(d,e),Sk.builtin.nmber.float$);d=new Sk.builtin.nmber(d,Sk.builtin.nmber.int$);e=new Sk.builtin.nmber(e,Sk.builtin.nmber.int$);e=d.nb$power(e);return a instanceof Sk.builtin.lng||b instanceof Sk.builtin.lng?
new Sk.builtin.lng(e):e}if(!Sk.builtin.checkInt(a)||!Sk.builtin.checkInt(b)||!Sk.builtin.checkInt(c))throw new Sk.builtin.TypeError("pow() 3rd argument not allowed unless all arguments are integers");if(0>e)throw new Sk.builtin.TypeError("pow() 2nd argument cannot be negative when 3rd argument specified");return a instanceof Sk.builtin.lng||(b instanceof Sk.builtin.lng||c instanceof Sk.builtin.lng)||Infinity===Math.pow(d,e)?(a=new Sk.builtin.lng(a),a.nb$power(b,c)):(new Sk.builtin.nmber(Math.pow(d,
e),Sk.builtin.nmber.int$)).nb$remainder(c)};Sk.builtin.quit=function(a){a=(new Sk.builtin.str(a)).v;throw new Sk.builtin.SystemExit(a);};
Sk.builtin.sorted=function(a,b,c,d){var e;if(void 0===c||c instanceof Sk.builtin.none)b instanceof Sk.builtin.none||void 0===b||(e=b),a=new Sk.builtin.list(a);else{e=b instanceof Sk.builtin.none||void 0===b?function(a,b){return Sk.misceval.richCompareBool(a[0],b[0],"Lt")?new Sk.builtin.nmber(-1,Sk.builtin.nmber.int$):new Sk.builtin.nmber(0,Sk.builtin.nmber.int$)}:function(a,c){return Sk.misceval.callsim(b,a[0],c[0])};a=a.tp$iter();for(var f=a.tp$iternext(),g=[];void 0!==f;)g.push([Sk.misceval.callsim(c,
f),f]),f=a.tp$iternext();a=new Sk.builtin.list(g)}void 0!==e?a.list_sort_(a,e):a.list_sort_(a);d&&a.list_reverse_(a);if(void 0!==c&&!(c instanceof Sk.builtin.none)){a=a.tp$iter();f=a.tp$iternext();for(g=[];void 0!==f;)g.push(f[1]),f=a.tp$iternext();a=new Sk.builtin.list(g)}return a};Sk.builtin.sorted.co_varnames=["cmp","key","reverse"];Sk.builtin.sorted.$defaults=[Sk.builtin.none,Sk.builtin.none,!1];Sk.builtin.sorted.co_numargs=4;
Sk.builtin.issubclass=function(a,b){Sk.builtin.pyCheckArgs("issubclass",arguments,2,2);if(!(Sk.builtin.checkClass(b)||b instanceof Sk.builtin.tuple))throw new Sk.builtin.TypeError("issubclass() arg 2 must be a classinfo, type, or tuple of classes and types");if(b===Sk.builtin.int_.prototype.ob$type||b===Sk.builtin.float_.prototype.ob$type||b===Sk.builtin.none.prototype.ob$type||a.ob$type===b)return!0;var c=function(a,b){if(a===b)return!0;if(void 0!==a.$d&&a.$d.mp$subscript)var d=a.$d.mp$subscript(Sk.builtin.type.basesStr_);
else return!1;for(var h=0;h<d.v.length;++h)if(c(d.v[h],b))return!0;return!1};if(b instanceof Sk.builtin.tuple){for(var d=0;d<b.v.length;++d)if(Sk.builtin.issubclass(a,b.v[d]))return!0;return!1}return c(a,b)};Sk.builtin.globals=function(){var a=new Sk.builtin.dict([]),b;for(b in Sk.globals)a.mp$ass_subscript(new Sk.builtin.str(b),Sk.globals[b]);return a};Sk.builtin.bytearray=function(){throw new Sk.builtin.NotImplementedError("bytearray is not yet implemented");};
Sk.builtin.callable=function(){throw new Sk.builtin.NotImplementedError("callable is not yet implemented");};Sk.builtin.complex=function(){throw new Sk.builtin.NotImplementedError("complex is not yet implemented");};Sk.builtin.delattr=function(){throw new Sk.builtin.NotImplementedError("delattr is not yet implemented");};Sk.builtin.divmod=function(){throw new Sk.builtin.NotImplementedError("divmod is not yet implemented");};
Sk.builtin.execfile=function(){throw new Sk.builtin.NotImplementedError("execfile is not yet implemented");};Sk.builtin.format=function(){throw new Sk.builtin.NotImplementedError("format is not yet implemented");};Sk.builtin.frozenset=function(){throw new Sk.builtin.NotImplementedError("frozenset is not yet implemented");};Sk.builtin.help=function(){throw new Sk.builtin.NotImplementedError("help is not yet implemented");};
Sk.builtin.iter=function(){throw new Sk.builtin.NotImplementedError("iter is not yet implemented");};Sk.builtin.locals=function(){throw new Sk.builtin.NotImplementedError("locals is not yet implemented");};Sk.builtin.memoryview=function(){throw new Sk.builtin.NotImplementedError("memoryview is not yet implemented");};Sk.builtin.next_=function(){throw new Sk.builtin.NotImplementedError("next is not yet implemented");};
Sk.builtin.property=function(){throw new Sk.builtin.NotImplementedError("property is not yet implemented");};Sk.builtin.reload=function(){throw new Sk.builtin.NotImplementedError("reload is not yet implemented");};Sk.builtin.reversed=function(){throw new Sk.builtin.NotImplementedError("reversed is not yet implemented");};Sk.builtin.unichr=function(){throw new Sk.builtin.NotImplementedError("unichr is not yet implemented");};
Sk.builtin.vars=function(){throw new Sk.builtin.NotImplementedError("vars is not yet implemented");};Sk.builtin.xrange=Sk.builtin.range;Sk.builtin.apply_=function(){throw new Sk.builtin.NotImplementedError("apply is not yet implemented");};Sk.builtin.buffer=function(){throw new Sk.builtin.NotImplementedError("buffer is not yet implemented");};Sk.builtin.coerce=function(){throw new Sk.builtin.NotImplementedError("coerce is not yet implemented");};
Sk.builtin.intern=function(){throw new Sk.builtin.NotImplementedError("intern is not yet implemented");};Sk.builtin.Exception=function(a){a=Array.prototype.slice.call(arguments);for(var b=0;b<a.length;++b)"string"===typeof a[b]&&(a[b]=new Sk.builtin.str(a[b]));this.args=new Sk.builtin.tuple(a);Sk.currFilename?this.filename=Sk.currFilename:3<=this.args.sq$length()?this.filename=this.args.v[1].v?this.args.v[1].v:"<unknown>":this.filename="<unknown>";3<=this.args.sq$length()?this.lineno=this.args.v[2]:this.lineno=0<Sk.currLineNo?Sk.currLineNo:"<unknown>";this.colno=0<Sk.currColNo?Sk.currColNo:"<unknown>"};
Sk.builtin.Exception.prototype.tp$name="Exception";Sk.builtin.Exception.prototype.tp$str=function(){var a;a=""+this.tp$name;this.args&&(a+=": "+(0<this.args.v.length?this.args.v[0].v:""));a+=" on line "+this.lineno;if(4<this.args.v.length){a+="\n"+this.args.v[4].v+"\n";for(var b=0;b<this.args.v[3];++b)a+=" ";a+="^\n"}return new Sk.builtin.str(a)};Sk.builtin.Exception.prototype.toString=function(){return this.tp$str().v};goog.exportSymbol("Sk.builtin.Exception",Sk.builtin.Exception);
Sk.builtin.AssertionError=function(a){if(!(this instanceof Sk.builtin.AssertionError)){var b=Object.create(Sk.builtin.AssertionError.prototype);b.constructor.apply(b,arguments);return b}Sk.builtin.Exception.apply(this,arguments)};goog.inherits(Sk.builtin.AssertionError,Sk.builtin.Exception);Sk.builtin.AssertionError.prototype.tp$name="AssertionError";goog.exportSymbol("Sk.builtin.AssertionError",Sk.builtin.AssertionError);
Sk.builtin.AttributeError=function(a){if(!(this instanceof Sk.builtin.AttributeError)){var b=Object.create(Sk.builtin.AttributeError.prototype);b.constructor.apply(b,arguments);return b}Sk.builtin.Exception.apply(this,arguments)};goog.inherits(Sk.builtin.AttributeError,Sk.builtin.Exception);Sk.builtin.AttributeError.prototype.tp$name="AttributeError";
Sk.builtin.ImportError=function(a){if(!(this instanceof Sk.builtin.ImportError)){var b=Object.create(Sk.builtin.ImportError.prototype);b.constructor.apply(b,arguments);return b}Sk.builtin.Exception.apply(this,arguments)};goog.inherits(Sk.builtin.ImportError,Sk.builtin.Exception);Sk.builtin.ImportError.prototype.tp$name="ImportError";
Sk.builtin.IndentationError=function(a){if(!(this instanceof Sk.builtin.IndentationError)){var b=Object.create(Sk.builtin.IndentationError.prototype);b.constructor.apply(b,arguments);return b}Sk.builtin.Exception.apply(this,arguments)};goog.inherits(Sk.builtin.IndentationError,Sk.builtin.Exception);Sk.builtin.IndentationError.prototype.tp$name="IndentationError";
Sk.builtin.IndexError=function(a){if(!(this instanceof Sk.builtin.IndexError)){var b=Object.create(Sk.builtin.IndexError.prototype);b.constructor.apply(b,arguments);return b}Sk.builtin.Exception.apply(this,arguments)};goog.inherits(Sk.builtin.IndexError,Sk.builtin.Exception);Sk.builtin.IndexError.prototype.tp$name="IndexError";
Sk.builtin.KeyError=function(a){if(!(this instanceof Sk.builtin.KeyError)){var b=Object.create(Sk.builtin.KeyError.prototype);b.constructor.apply(b,arguments);return b}Sk.builtin.Exception.apply(this,arguments)};goog.inherits(Sk.builtin.KeyError,Sk.builtin.Exception);Sk.builtin.KeyError.prototype.tp$name="KeyError";
Sk.builtin.NameError=function(a){if(!(this instanceof Sk.builtin.NameError)){var b=Object.create(Sk.builtin.NameError.prototype);b.constructor.apply(b,arguments);return b}Sk.builtin.Exception.apply(this,arguments)};goog.inherits(Sk.builtin.NameError,Sk.builtin.Exception);Sk.builtin.NameError.prototype.tp$name="NameError";
Sk.builtin.OverflowError=function(a){if(!(this instanceof Sk.builtin.OverflowError)){var b=Object.create(Sk.builtin.OverflowError.prototype);b.constructor.apply(b,arguments);return b}Sk.builtin.Exception.apply(this,arguments)};goog.inherits(Sk.builtin.OverflowError,Sk.builtin.Exception);Sk.builtin.OverflowError.prototype.tp$name="OverflowError";
Sk.builtin.ParseError=function(a){if(!(this instanceof Sk.builtin.ParseError)){var b=Object.create(Sk.builtin.ParseError.prototype);b.constructor.apply(b,arguments);return b}Sk.builtin.Exception.apply(this,arguments)};goog.inherits(Sk.builtin.ParseError,Sk.builtin.Exception);Sk.builtin.ParseError.prototype.tp$name="ParseError";
Sk.builtin.SystemExit=function(a){if(!(this instanceof Sk.builtin.SystemExit)){var b=Object.create(Sk.builtin.SystemExit.prototype);b.constructor.apply(b,arguments);return b}Sk.builtin.Exception.apply(this,arguments)};goog.inherits(Sk.builtin.SystemExit,Sk.builtin.Exception);Sk.builtin.SystemExit.prototype.tp$name="SystemExit";goog.exportSymbol("Sk.builtin.SystemExit",Sk.builtin.SystemExit);
Sk.builtin.SyntaxError=function(a){if(!(this instanceof Sk.builtin.SyntaxError)){var b=Object.create(Sk.builtin.SyntaxError.prototype);b.constructor.apply(b,arguments);return b}Sk.builtin.Exception.apply(this,arguments)};goog.inherits(Sk.builtin.SyntaxError,Sk.builtin.Exception);Sk.builtin.SyntaxError.prototype.tp$name="SyntaxError";
Sk.builtin.TokenError=function(a){if(!(this instanceof Sk.builtin.TokenError)){var b=Object.create(Sk.builtin.TokenError.prototype);b.constructor.apply(b,arguments);return b}Sk.builtin.Exception.apply(this,arguments)};goog.inherits(Sk.builtin.TokenError,Sk.builtin.Exception);Sk.builtin.TokenError.prototype.tp$name="TokenError";
Sk.builtin.TypeError=function(a){if(!(this instanceof Sk.builtin.TypeError)){var b=Object.create(Sk.builtin.TypeError.prototype);b.constructor.apply(b,arguments);return b}Sk.builtin.Exception.apply(this,arguments)};goog.inherits(Sk.builtin.TypeError,Sk.builtin.Exception);Sk.builtin.TypeError.prototype.tp$name="TypeError";goog.exportSymbol("Sk.builtin.TypeError",Sk.builtin.TypeError);
Sk.builtin.ValueError=function(a){if(!(this instanceof Sk.builtin.ValueError)){var b=Object.create(Sk.builtin.ValueError.prototype);b.constructor.apply(b,arguments);return b}Sk.builtin.Exception.apply(this,arguments)};goog.inherits(Sk.builtin.ValueError,Sk.builtin.Exception);Sk.builtin.ValueError.prototype.tp$name="ValueError";goog.exportSymbol("Sk.builtin.ValueError",Sk.builtin.ValueError);
Sk.builtin.ZeroDivisionError=function(a){if(!(this instanceof Sk.builtin.ZeroDivisionError)){var b=Object.create(Sk.builtin.ZeroDivisionError.prototype);b.constructor.apply(b,arguments);return b}Sk.builtin.Exception.apply(this,arguments)};goog.inherits(Sk.builtin.ZeroDivisionError,Sk.builtin.Exception);Sk.builtin.ZeroDivisionError.prototype.tp$name="ZeroDivisionError";
Sk.builtin.TimeLimitError=function(a){if(!(this instanceof Sk.builtin.TimeLimitError)){var b=Object.create(Sk.builtin.TimeLimitError.prototype);b.constructor.apply(b,arguments);return b}Sk.builtin.Exception.apply(this,arguments)};goog.inherits(Sk.builtin.TimeLimitError,Sk.builtin.Exception);Sk.builtin.TimeLimitError.prototype.tp$name="TimeLimitError";goog.exportSymbol("Sk.builtin.TimeLimitError",Sk.builtin.TimeLimitError);
Sk.builtin.IOError=function(a){if(!(this instanceof Sk.builtin.IOError)){var b=Object.create(Sk.builtin.IOError.prototype);b.constructor.apply(b,arguments);return b}Sk.builtin.Exception.apply(this,arguments)};goog.inherits(Sk.builtin.IOError,Sk.builtin.Exception);Sk.builtin.IOError.prototype.tp$name="IOError";goog.exportSymbol("Sk.builtin.IOError",Sk.builtin.IOError);
Sk.builtin.NotImplementedError=function(a){if(!(this instanceof Sk.builtin.NotImplementedError)){var b=Object.create(Sk.builtin.NotImplementedError.prototype);b.constructor.apply(b,arguments);return b}Sk.builtin.Exception.apply(this,arguments)};goog.inherits(Sk.builtin.NotImplementedError,Sk.builtin.Exception);Sk.builtin.NotImplementedError.prototype.tp$name="NotImplementedError";goog.exportSymbol("Sk.builtin.NotImplementedError",Sk.builtin.NotImplementedError);
Sk.builtin.NegativePowerError=function(a){if(!(this instanceof Sk.builtin.NegativePowerError)){var b=Object.create(Sk.builtin.NegativePowerError.prototype);b.constructor.apply(b,arguments);return b}Sk.builtin.Exception.apply(this,arguments)};goog.inherits(Sk.builtin.NegativePowerError,Sk.builtin.Exception);Sk.builtin.NegativePowerError.prototype.tp$name="NegativePowerError";goog.exportSymbol("Sk.builtin.NegativePowerError",Sk.builtin.NegativePowerError);
Sk.builtin.OperationError=function(a){if(!(this instanceof Sk.builtin.OperationError)){var b=Object.create(Sk.builtin.OperationError.prototype);b.constructor.apply(b,arguments);return b}Sk.builtin.Exception.apply(this,arguments)};goog.inherits(Sk.builtin.OperationError,Sk.builtin.Exception);Sk.builtin.OperationError.prototype.tp$name="OperationError";goog.exportSymbol("Sk.builtin.OperationError",Sk.builtin.OperationError);
Sk.builtin.SystemError=function(a){if(!(this instanceof Sk.builtin.SystemError)){var b=Object.create(Sk.builtin.SystemError.prototype);b.constructor.apply(b,arguments);return b}Sk.builtin.Exception.apply(this,arguments)};goog.inherits(Sk.builtin.SystemError,Sk.builtin.Exception);Sk.builtin.SystemError.prototype.tp$name="SystemError";goog.exportSymbol("Sk.builtin.SystemError",Sk.builtin.SystemError);Sk.currLineNo=-1;Sk.currColNo=-1;Sk.currFilename="";goog.exportSymbol("Sk",Sk);
goog.exportProperty(Sk,"currLineNo",Sk.currLineNo);goog.exportProperty(Sk,"currColNo",Sk.currColNo);goog.exportProperty(Sk,"currFilename",Sk.currFilename);Sk.builtin.type=function(a,b,c){if(void 0===b&&void 0===c)return a.constructor===Sk.builtin.nmber?a.skType===Sk.builtin.nmber.int$?Sk.builtin.int_.prototype.ob$type:Sk.builtin.float_.prototype.ob$type:a.ob$type;var d=function(a,b,c,e){if(!(this instanceof d))return new d(a,b,c,e);e=e||[];this.$d=new Sk.builtin.dict([]);var l=Sk.builtin.type.typeLookup(this.ob$type,"__init__");void 0!==l&&(e.unshift(this),Sk.misceval.apply(l,a,b,c,e));return this},e;for(e in c)d.prototype[e]=c[e],d[e]=c[e];d.__class__=
d;d.sk$klass=!0;d.prototype.tp$getattr=Sk.builtin.object.prototype.GenericGetAttr;d.prototype.tp$setattr=Sk.builtin.object.prototype.GenericSetAttr;d.prototype.tp$descr_get=function(){goog.asserts.fail("in type tp$descr_get")};d.prototype.$r=function(){var b=this.tp$getattr("__repr__");if(void 0!==b)return Sk.misceval.apply(b,void 0,void 0,void 0,[]);var b=c.__module__,d="";b&&(d=b.v+".");return new Sk.builtin.str("<"+d+a+" object>")};d.prototype.tp$str=function(){var a=this.tp$getattr("__str__");
return void 0!==a?Sk.misceval.apply(a,void 0,void 0,void 0,[]):this.$r()};d.prototype.tp$length=function(){var a=this.tp$getattr("__len__");if(void 0!==a)return Sk.misceval.apply(a,void 0,void 0,void 0,[]);a=Sk.abstr.typeName(this);throw new Sk.builtin.AttributeError(a+" instance has no attribute '__len__'");};d.prototype.tp$call=function(a,b){var c=this.tp$getattr("__call__");if(c)return Sk.misceval.apply(c,void 0,void 0,b,a);throw new Sk.builtin.TypeError("'"+Sk.abstr.typeName(this)+"' object is not callable");
};d.prototype.tp$iter=function(){var a=this.tp$getattr("__iter__"),b=Sk.abstr.typeName(this);if(a)return Sk.misceval.callsim(a);throw new Sk.builtin.TypeError("'"+b+"' object is not iterable");};d.prototype.tp$iternext=function(){var a=this.tp$getattr("next");goog.asserts.assert(void 0!==a,"iter() should have caught this");return Sk.misceval.callsim(a)};d.prototype.tp$getitem=function(a){var b=this.tp$getattr("__getitem__");if(void 0!==b)return Sk.misceval.apply(b,void 0,void 0,void 0,[a]);throw new Sk.builtin.TypeError("'"+
Sk.abstr.typeName(this)+"' object does not support indexing");};d.prototype.tp$setitem=function(a,b){var c=this.tp$getattr("__setitem__");if(void 0!==c)return Sk.misceval.apply(c,void 0,void 0,void 0,[a,b]);throw new Sk.builtin.TypeError("'"+Sk.abstr.typeName(this)+"' object does not support item assignment");};d.prototype.tp$name=a;b&&(d.$d=new Sk.builtin.dict([]),d.$d.mp$ass_subscript(Sk.builtin.type.basesStr_,new Sk.builtin.tuple(b)),b=Sk.builtin.type.buildMRO(d),d.$d.mp$ass_subscript(Sk.builtin.type.mroStr_,
b),d.tp$mro=b);d.prototype.ob$type=d;Sk.builtin.type.makeIntoTypeObj(a,d);d.tp$setattr=Sk.builtin.type.prototype.tp$setattr;return d};Sk.builtin.type.makeTypeObj=function(a,b){Sk.builtin.type.makeIntoTypeObj(a,b);return b};
Sk.builtin.type.makeIntoTypeObj=function(a,b){goog.asserts.assert(void 0!==a);goog.asserts.assert(void 0!==b);b.ob$type=Sk.builtin.type;b.tp$name=a;b.$r=function(){var a=b.__module__,d="";a&&(d=a.v+".");var e="class";a||b.sk$klass||(e="type");return new Sk.builtin.str("<"+e+" '"+d+b.tp$name+"'>")};b.tp$str=void 0;b.tp$getattr=Sk.builtin.type.prototype.tp$getattr;b.tp$setattr=Sk.builtin.object.prototype.GenericSetAttr;b.tp$richcompare=Sk.builtin.type.prototype.tp$richcompare;b.sk$type=!0;return b};
Sk.builtin.type.ob$type=Sk.builtin.type;Sk.builtin.type.tp$name="type";Sk.builtin.type.$r=function(){return new Sk.builtin.str("<type 'type'>")};Sk.builtin.type.prototype.tp$getattr=function(a){var b=Sk.builtin.type.typeLookup(this,a),c;void 0!==b&&(null!==b&&void 0!==b.ob$type)&&(c=b.ob$type.tp$descr_get);if(this.$d&&(a=this.$d.mp$lookup(new Sk.builtin.str(a)),void 0!==a))return a;if(c)return c.call(b,null,this);if(void 0!==b)return b};Sk.builtin.type.prototype.tp$setattr=function(a,b){this[a]=b};
Sk.builtin.type.typeLookup=function(a,b){var c=a.tp$mro,d=new Sk.builtin.str(b),e,f;if(!c)return a.prototype[b];for(f=0;f<c.v.length;++f){e=c.v[f];if(e.hasOwnProperty(b))return e[b];e=e.$d.mp$lookup(d);if(void 0!==e)return e}};
Sk.builtin.type.mroMerge_=function(a){for(var b=[];;){for(var c=0;c<a.length;++c){var d=a[c];if(0!==d.length)break}if(c===a.length)return b;for(var e=[],c=0;c<a.length;++c)if(d=a[c],0!==d.length){var d=d[0],f=0;a:for(;f<a.length;++f)for(var g=a[f],h=1;h<g.length;++h)if(g[h]===d)break a;f===a.length&&e.push(d)}if(0===e.length)throw new Sk.builtin.TypeError("Inconsistent precedences in type hierarchy");e=e[0];b.push(e);for(c=0;c<a.length;++c)d=a[c],0<d.length&&d[0]===e&&d.splice(0,1)}};
Sk.builtin.type.buildMRO_=function(a){var b=[[a]];a=a.$d.mp$subscript(Sk.builtin.type.basesStr_);for(var c=0;c<a.v.length;++c)b.push(Sk.builtin.type.buildMRO_(a.v[c]));for(var d=[],c=0;c<a.v.length;++c)d.push(a.v[c]);b.push(d);return Sk.builtin.type.mroMerge_(b)};Sk.builtin.type.buildMRO=function(a){return new Sk.builtin.tuple(Sk.builtin.type.buildMRO_(a))};
Sk.builtin.type.prototype.tp$richcompare=function(a,b){if(a.ob$type==Sk.builtin.type&&this.$r&&a.$r){var c=this.$r(),d=a.$r();return c.tp$richcompare(d,b)}};Sk.builtin.object=function(){if(!(this instanceof Sk.builtin.object))return new Sk.builtin.object;this.$d=new Sk.builtin.dict([]);return this};
Sk.builtin.object.prototype.GenericGetAttr=function(a){goog.asserts.assert("string"===typeof a);var b=this.ob$type;goog.asserts.assert(void 0!==b,"object has no ob$type!");var b=Sk.builtin.type.typeLookup(b,a),c;void 0!==b&&(null!==b&&void 0!==b.ob$type)&&(c=b.ob$type.tp$descr_get);if(this.$d){var d;if(this.$d.mp$lookup)d=this.$d.mp$lookup(new Sk.builtin.str(a));else if(this.$d.mp$subscript)try{d=this.$d.mp$subscript(new Sk.builtin.str(a))}catch(e){d=void 0}else"object"===typeof this.$d&&(d=this.$d[a]);
if(void 0!==d)return d}if(c)return c.call(b,this,this.ob$type);if(void 0!==b)return b};goog.exportSymbol("Sk.builtin.object.prototype.GenericGetAttr",Sk.builtin.object.prototype.GenericGetAttr);Sk.builtin.object.prototype.GenericSetAttr=function(a,b){goog.asserts.assert("string"===typeof a);this.$d.mp$ass_subscript?this.$d.mp$ass_subscript(new Sk.builtin.str(a),b):"object"===typeof this.$d&&(this.$d[a]=b)};goog.exportSymbol("Sk.builtin.object.prototype.GenericSetAttr",Sk.builtin.object.prototype.GenericSetAttr);
Sk.builtin.object.prototype.HashNotImplemented=function(){throw new Sk.builtin.TypeError("unhashable type: '"+Sk.abstr.typeName(this)+"'");};Sk.builtin.object.prototype.tp$getattr=Sk.builtin.object.prototype.GenericGetAttr;Sk.builtin.object.prototype.tp$setattr=Sk.builtin.object.prototype.GenericSetAttr;Sk.builtin.object.prototype.ob$type=Sk.builtin.type.makeIntoTypeObj("object",Sk.builtin.object);Sk.builtin.none=function(){};
Sk.builtin.none.prototype.ob$type=Sk.builtin.type.makeIntoTypeObj("NoneType",Sk.builtin.none);Sk.builtin.none.prototype.tp$name="NoneType";Sk.builtin.none.none$=Object.create(Sk.builtin.none.prototype,{v:{value:null,enumerable:!0}});goog.exportSymbol("Sk.builtin.none",Sk.builtin.none);Sk.builtin.bool=function(a){Sk.builtin.pyCheckArgs("bool",arguments,1);return Sk.misceval.isTrue(a)?Sk.builtin.bool.true$:Sk.builtin.bool.false$};Sk.builtin.bool.prototype.tp$name="bool";Sk.builtin.bool.prototype.ob$type=Sk.builtin.type.makeIntoTypeObj("bool",Sk.builtin.bool);Sk.builtin.bool.prototype.$r=function(){return this.v?new Sk.builtin.str("True"):new Sk.builtin.str("False")};Sk.builtin.bool.true$=Object.create(Sk.builtin.bool.prototype,{v:{value:!0,enumerable:!0}});
Sk.builtin.bool.false$=Object.create(Sk.builtin.bool.prototype,{v:{value:!1,enumerable:!0}});goog.exportSymbol("Sk.builtin.bool",Sk.builtin.bool);Sk.builtin.pyCheckArgs=function(a,b,c,d,e,f){b=b.length;var g="";void 0===d&&(d=Infinity);e&&(b-=1);f&&(b-=1);if(b<c||b>d)throw g=(c===d?a+"() takes exactly "+c+" arguments":b<c?a+"() takes at least "+c+" arguments":a+"() takes at most "+d+" arguments")+(" ("+b+" given)"),new Sk.builtin.TypeError(g);};goog.exportSymbol("Sk.builtin.pyCheckArgs",Sk.builtin.pyCheckArgs);Sk.builtin.pyCheckType=function(a,b,c){if(!c)throw new Sk.builtin.TypeError(a+" must be a "+b);};
goog.exportSymbol("Sk.builtin.pyCheckType",Sk.builtin.pyCheckType);Sk.builtin.checkSequence=function(a){return null!==a&&void 0!==a.mp$subscript};goog.exportSymbol("Sk.builtin.checkSequence",Sk.builtin.checkSequence);Sk.builtin.checkIterable=function(a){return null!==a&&void 0!==a.tp$iter};goog.exportSymbol("Sk.builtin.checkIterable",Sk.builtin.checkIterable);
Sk.builtin.checkNumber=function(a){return null!==a&&("number"===typeof a||a instanceof Sk.builtin.nmber||a instanceof Sk.builtin.lng||a instanceof Sk.builtin.bool)};goog.exportSymbol("Sk.builtin.checkNumber",Sk.builtin.checkNumber);Sk.builtin.checkInt=function(a){return null!==a&&("number"===typeof a&&a===(a|0)||a instanceof Sk.builtin.nmber&&a.skType===Sk.builtin.nmber.int$||a instanceof Sk.builtin.lng||a instanceof Sk.builtin.bool)};goog.exportSymbol("Sk.builtin.checkInt",Sk.builtin.checkInt);
Sk.builtin.checkString=function(a){return null!==a&&a.__class__==Sk.builtin.str};goog.exportSymbol("Sk.builtin.checkString",Sk.builtin.checkString);Sk.builtin.checkClass=function(a){return null!==a&&a.sk$type};goog.exportSymbol("Sk.builtin.checkClass",Sk.builtin.checkClass);Sk.builtin.checkBool=function(a){return a instanceof Sk.builtin.bool};goog.exportSymbol("Sk.builtin.checkBool",Sk.builtin.checkBool);Sk.builtin.checkNone=function(a){return a instanceof Sk.builtin.none};
goog.exportSymbol("Sk.builtin.checkNone",Sk.builtin.checkNone);Sk.builtin.checkFunction=function(a){return null!==a&&void 0!==a.tp$call};goog.exportSymbol("Sk.builtin.checkFunction",Sk.builtin.checkFunction);Sk.builtin.func=function(a,b,c,d){this.func_code=a;this.func_globals=b||null;if(void 0!==d)for(var e in d)c[e]=d[e];this.func_closure=c;return this};goog.exportSymbol("Sk.builtin.func",Sk.builtin.func);Sk.builtin.func.prototype.tp$name="function";
Sk.builtin.func.prototype.tp$descr_get=function(a,b){goog.asserts.assert(void 0!==a&&void 0!==b);return null==a?this:new Sk.builtin.method(this,a)};
Sk.builtin.func.prototype.tp$call=function(a,b){var c;this.func_closure&&a.push(this.func_closure);c=this.func_code.co_kwargs;var d=[];if(this.func_code.no_kw&&b)throw c=this.func_code&&this.func_code.co_name&&this.func_code.co_name.v||"<native JS>",new Sk.builtin.TypeError(c+"() takes no keyword arguments");if(b)for(var e=b.length,f=this.func_code.co_varnames,g=f&&f.length,h=0;h<e;h+=2){for(var k=0;k<g&&b[h]!==f[k];++k);if(f&&k!==g)a[k]=b[h+1];else if(c)d.push(new Sk.builtin.str(b[h])),d.push(b[h+
1]);else throw c=this.func_code&&this.func_code.co_name&&this.func_code.co_name.v||"<native JS>",new Sk.builtin.TypeError(c+"() got an unexpected keyword argument '"+b[h]+"'");}c&&a.unshift(d);return this.func_code.apply(this.func_globals,a)};Sk.builtin.func.prototype.tp$getattr=function(a){return this[a]};Sk.builtin.func.prototype.tp$setattr=function(a,b){this[a]=b};Sk.builtin.func.prototype.ob$type=Sk.builtin.type.makeTypeObj("function",new Sk.builtin.func(null,null));
Sk.builtin.func.prototype.$r=function(){return new Sk.builtin.str("<function "+(this.func_code&&this.func_code.co_name&&this.func_code.co_name.v||"<native JS>")+">")};Sk.nativejs={FN_ARGS:/^function\s*[^\(]*\(\s*([^\)]*)\)/m,FN_ARG_SPLIT:/,/,FN_ARG:/^\s*(_?)(\S+?)\1\s*$/,STRIP_COMMENTS:/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg,formalParameterList:function(a){var b=[];a=a.toString().replace(this.STRIP_COMMENTS,"").match(this.FN_ARGS)[1].split(this.FN_ARG_SPLIT);for(var c in a)a[c].replace(this.FN_ARG,function(a,c,f){b.push(f)});return b},func:function(a){a.co_name=new Sk.builtin.str(a.name);a.co_varnames=Sk.nativejs.formalParameterList(a);return new Sk.builtin.func(a)},
func_nokw:function(a){a.co_name=new Sk.builtin.str(a.name);a.co_varnames=Sk.nativejs.formalParameterList(a);a.no_kw=!0;return new Sk.builtin.func(a)}};goog.exportSymbol("Sk.nativejs.func",Sk.nativejs.func);goog.exportSymbol("Sk.nativejs.func_nokw",Sk.nativejs.func_nokw);Sk.builtin.method=function(a,b){this.im_func=a;this.im_self=b};goog.exportSymbol("Sk.builtin.method",Sk.builtin.method);
Sk.builtin.method.prototype.tp$call=function(a,b){goog.asserts.assert(this.im_self,"should just be a function, not a method since there's no self?");goog.asserts.assert(this.im_func instanceof Sk.builtin.func);a.unshift(this.im_self);if(b)for(var c=b.length,d=0;d<c;d+=2){for(var e=this.im_func.func_code.co_varnames,f=e&&e.length,g=0;g<f&&b[d]!==e[g];++g);a[g]=b[d+1]}return this.im_func.func_code.apply(this.im_func.func_globals,a)};
Sk.builtin.method.prototype.$r=function(){return new Sk.builtin.str("<bound method "+this.im_self.ob$type.tp$name+"."+(this.im_func.func_code&&this.im_func.func_code.co_name&&this.im_func.func_code.co_name.v||"<native JS>")+" of "+this.im_self.$r().v+">")};Sk.misceval={};Sk.misceval.isIndex=function(a){return null===a||a.constructor===Sk.builtin.lng||a.tp$index||!0===a||!1===a?!0:Sk.builtin.checkInt(a)};goog.exportSymbol("Sk.misceval.isIndex",Sk.misceval.isIndex);Sk.misceval.asIndex=function(a){if(Sk.misceval.isIndex(a)&&null!==a){if(!0===a)return 1;if(!1===a)return 0;if("number"===typeof a)return a;if(a.constructor===Sk.builtin.nmber)return a.v;if(a.constructor===Sk.builtin.lng)return a.tp$index();goog.asserts.fail("todo asIndex;")}};
Sk.misceval.applySlice=function(a,b,c){return a.sq$slice&&Sk.misceval.isIndex(b)&&Sk.misceval.isIndex(c)?(b=Sk.misceval.asIndex(b),void 0===b&&(b=0),c=Sk.misceval.asIndex(c),void 0===c&&(c=1E100),Sk.abstr.sequenceGetSlice(a,b,c)):Sk.abstr.objectGetItem(a,new Sk.builtin.slice(b,c,null))};goog.exportSymbol("Sk.misceval.applySlice",Sk.misceval.applySlice);
Sk.misceval.assignSlice=function(a,b,c,d){if(a.sq$ass_slice&&Sk.misceval.isIndex(b)&&Sk.misceval.isIndex(c))b=Sk.misceval.asIndex(b)||0,c=Sk.misceval.asIndex(c)||1E100,null===d?Sk.abstr.sequenceDelSlice(a,b,c):Sk.abstr.sequenceSetSlice(a,b,c,d);else return c=new Sk.builtin.slice(b,c),null===d?Sk.abstr.objectDelItem(a,c):Sk.abstr.objectSetItem(a,c,d)};goog.exportSymbol("Sk.misceval.assignSlice",Sk.misceval.assignSlice);
Sk.misceval.arrayFromArguments=function(a){if(1!=a.length)return a;var b=a[0];b instanceof Sk.builtin.set?b=b.tp$iter().$obj:b instanceof Sk.builtin.dict&&(b=Sk.builtin.dict.prototype.keys.func_code(b));if(b instanceof Sk.builtin.list||b instanceof Sk.builtin.tuple)return b.v;if(void 0!==b.tp$iter){a=[];for(var b=b.tp$iter(),c=b.tp$iternext();void 0!==c;c=b.tp$iternext())a.push(c);return a}throw new Sk.builtin.TypeError("'"+Sk.abstr.typeName(b)+"' object is not iterable");};
goog.exportSymbol("Sk.misceval.arrayFromArguments",Sk.misceval.arrayFromArguments);Sk.misceval.swappedOp_={Eq:"Eq",NotEq:"NotEq",Lt:"GtE",LtE:"Gt",Gt:"LtE",GtE:"Lt",Is:"IsNot",IsNot:"Is",In_:"NotIn",NotIn:"In_"};
Sk.misceval.richCompareBool=function(a,b,c){goog.asserts.assert(null!==a&&void 0!==a,"passed null or undefined parameter to Sk.misceval.richCompareBool");goog.asserts.assert(null!==b&&void 0!==b,"passed null or undefined parameter to Sk.misceval.richCompareBool");var d=new Sk.builtin.type(a),e=new Sk.builtin.type(b);if(d!==e&&("GtE"===c||"Gt"===c||"LtE"===c||"Lt"===c)){var f=[Sk.builtin.float_.prototype.ob$type,Sk.builtin.int_.prototype.ob$type,Sk.builtin.lng.prototype.ob$type,Sk.builtin.bool.prototype.ob$type],
g=[Sk.builtin.dict.prototype.ob$type,Sk.builtin.enumerate.prototype.ob$type,Sk.builtin.list.prototype.ob$type,Sk.builtin.str.prototype.ob$type,Sk.builtin.tuple.prototype.ob$type],h=f.indexOf(d),k=g.indexOf(d),f=f.indexOf(e),g=g.indexOf(e);if(d===Sk.builtin.none.prototype.ob$type)switch(c){case "Lt":return!0;case "LtE":return!0;case "Gt":return!1;case "GtE":return!1}if(e===Sk.builtin.none.prototype.ob$type)switch(c){case "Lt":return!1;case "LtE":return!1;case "Gt":return!0;case "GtE":return!0}if(-1!==
h&&-1!==g)switch(c){case "Lt":return!0;case "LtE":return!0;case "Gt":return!1;case "GtE":return!1}if(-1!==k&&-1!==f)switch(c){case "Lt":return!1;case "LtE":return!1;case "Gt":return!0;case "GtE":return!0}if(-1!==k&&-1!==g)switch(c){case "Lt":return k<g;case "LtE":return k<=g;case "Gt":return k>g;case "GtE":return k>=g}}if("Is"===c)return a instanceof Sk.builtin.nmber&&b instanceof Sk.builtin.nmber?0===a.numberCompare(b)&&a.skType===b.skType:a instanceof Sk.builtin.lng&&b instanceof Sk.builtin.lng?
0===a.longCompare(b):a===b;if("IsNot"===c)return a instanceof Sk.builtin.nmber&&b instanceof Sk.builtin.nmber?0!==a.numberCompare(b)||a.skType!==b.skType:a instanceof Sk.builtin.lng&&b instanceof Sk.builtin.lng?0!==a.longCompare(b):a!==b;if("In"===c)return Sk.abstr.sequenceContains(b,a);if("NotIn"===c)return!Sk.abstr.sequenceContains(b,a);var l;if(a.tp$richcompare&&void 0!==(l=a.tp$richcompare(b,c))||b.tp$richcompare&&void 0!==(l=b.tp$richcompare(a,Sk.misceval.swappedOp_[c])))return l;e={Eq:"__eq__",
NotEq:"__ne__",Gt:"__gt__",GtE:"__ge__",Lt:"__lt__",LtE:"__le__"};d=e[c];e=e[Sk.misceval.swappedOp_[c]];if(a[d])return Sk.misceval.isTrue(Sk.misceval.callsim(a[d],a,b));if(b[e])return Sk.misceval.isTrue(Sk.misceval.callsim(b[e],b,a));if(a.__cmp__){d=Sk.misceval.callsim(a.__cmp__,a,b);d=Sk.builtin.asnum$(d);if("Eq"===c)return 0===d;if("NotEq"===c)return 0!==d;if("Lt"===c)return 0>d;if("Gt"===c)return 0<d;if("LtE"===c)return 0>=d;if("GtE"===c)return 0<=d}if(b.__cmp__){d=Sk.misceval.callsim(b.__cmp__,
b,a);d=Sk.builtin.asnum$(d);if("Eq"===c)return 0===d;if("NotEq"===c)return 0!==d;if("Lt"===c)return 0<d;if("Gt"===c)return 0>d;if("LtE"===c)return 0<=d;if("GtE"===c)return 0>=d}if(a instanceof Sk.builtin.none&&b instanceof Sk.builtin.none||a instanceof Sk.builtin.bool&&b instanceof Sk.builtin.bool){if("Eq"===c)return a.v===b.v;if("NotEq"===c)return a.v!==b.v;if("Gt"===c)return a.v>b.v;if("GtE"===c)return a.v>=b.v;if("Lt"===c)return a.v<b.v;if("LtE"===c)return a.v<=b.v}if("Eq"===c)return a instanceof
Sk.builtin.str&&b instanceof Sk.builtin.str?a.v===b.v:a===b;if("NotEq"===c)return a instanceof Sk.builtin.str&&b instanceof Sk.builtin.str?a.v!==b.v:a!==b;a=Sk.abstr.typeName(a);b=Sk.abstr.typeName(b);throw new Sk.builtin.ValueError("don't know how to compare '"+a+"' and '"+b+"'");};goog.exportSymbol("Sk.misceval.richCompareBool",Sk.misceval.richCompareBool);
Sk.misceval.objectRepr=function(a){goog.asserts.assert(void 0!==a,"trying to repr undefined");return null===a||a instanceof Sk.builtin.none?new Sk.builtin.str("None"):!0===a?new Sk.builtin.str("True"):!1===a?new Sk.builtin.str("False"):"number"===typeof a?new Sk.builtin.str(""+a):a.$r?a.constructor===Sk.builtin.nmber?Infinity===a.v?new Sk.builtin.str("inf"):-Infinity===a.v?new Sk.builtin.str("-inf"):a.$r():a.$r():a.tp$name?new Sk.builtin.str("<"+a.tp$name+" object>"):new Sk.builtin.str("<unknown>")};
goog.exportSymbol("Sk.misceval.objectRepr",Sk.misceval.objectRepr);Sk.misceval.opAllowsEquality=function(a){switch(a){case "LtE":case "Eq":case "GtE":return!0}return!1};goog.exportSymbol("Sk.misceval.opAllowsEquality",Sk.misceval.opAllowsEquality);
Sk.misceval.isTrue=function(a){if(!0===a)return!0;if(!1===a||null===a||a.constructor===Sk.builtin.none)return!1;if(a.constructor===Sk.builtin.bool)return a.v;if("number"===typeof a)return 0!==a;if(a instanceof Sk.builtin.lng)return a.nb$nonzero();if(a.constructor===Sk.builtin.nmber)return 0!==a.v;if(a.mp$length)return 0!==a.mp$length();if(a.sq$length)return 0!==a.sq$length();if(a.__nonzero__){a=Sk.misceval.callsim(a.__nonzero__,a);if(!Sk.builtin.checkInt(a))throw new Sk.builtin.TypeError("__nonzero__ should return an int");
return 0!==Sk.builtin.asnum$(a)}if(a.__len__){a=Sk.misceval.callsim(a.__len__,a);if(!Sk.builtin.checkInt(a))throw new Sk.builtin.TypeError("__len__ should return an int");return 0!==Sk.builtin.asnum$(a)}return!0};goog.exportSymbol("Sk.misceval.isTrue",Sk.misceval.isTrue);Sk.misceval.softspace_=!1;
Sk.misceval.print_=function(a){Sk.misceval.softspace_&&("\n"!==a&&Sk.output(" "),Sk.misceval.softspace_=!1);a=new Sk.builtin.str(a);Sk.output(a.v);if(0===a.v.length||"\n"!==a.v[a.v.length-1]&&"\t"!==a.v[a.v.length-1]&&"\r"!==a.v[a.v.length-1]||" "===a.v[a.v.length-1])Sk.misceval.softspace_=!0};goog.exportSymbol("Sk.misceval.print_",Sk.misceval.print_);
Sk.misceval.loadname=function(a,b){var c=b[a];if(void 0!==c)return c;c=Sk.builtins[a];if(void 0!==c)return c;a=a.replace("_$rw$","");a=a.replace("_$rn$","");throw new Sk.builtin.NameError("name '"+a+"' is not defined");};goog.exportSymbol("Sk.misceval.loadname",Sk.misceval.loadname);Sk.misceval.call=function(a,b,c,d,e){e=Array.prototype.slice.call(arguments,4);return Sk.misceval.apply(a,b,c,d,e)};goog.exportSymbol("Sk.misceval.call",Sk.misceval.call);
Sk.misceval.callsim=function(a,b){b=Array.prototype.slice.call(arguments,1);return Sk.misceval.apply(a,void 0,void 0,void 0,b)};goog.exportSymbol("Sk.misceval.callsim",Sk.misceval.callsim);
Sk.misceval.apply=function(a,b,c,d,e){if(null===a||a instanceof Sk.builtin.none)throw new Sk.builtin.TypeError("'"+Sk.abstr.typeName(a)+"' object is not callable");if("function"===typeof a){if(a.sk$klass)return a.apply(null,[b,c,d,e]);if(c){var f=c.tp$iter();for(c=f.tp$iternext();void 0!==c;c=f.tp$iternext())e.push(c)}b&&goog.asserts.fail("kwdict not implemented;");if(void 0!==d&&0<d.length){if(!a.co_varnames)throw new Sk.builtin.ValueError("Keyword arguments are not supported by this function");
b=a.co_numargs-a.co_varnames.length;var g=e.length-b;e=e.concat(a.$defaults.slice(g));for(c=0;c<d.length;c+=2){f=a.co_varnames.indexOf(d[c]);if(-1===f)throw new Sk.builtin.TypeError("'"+d[c]+"' is an invalid keyword argument for this function");if(f<g)throw new Sk.builtin.TypeError("Argument given by name ('"+d[c]+"') and position ("+(f+b+1)+")");e[f+b]=d[c+1]}}return a.apply(null,e)}g=a.tp$call;if(void 0!==g){if(c)for(f=c.tp$iter(),c=f.tp$iternext();void 0!==c;c=f.tp$iternext())e.push(c);b&&goog.asserts.fail("kwdict not implemented;");
return g.call(a,e,d,b)}g=a.__call__;if(void 0!==g)return e.unshift(a),Sk.misceval.apply(g,d,e,b,c);throw new Sk.builtin.TypeError("'"+Sk.abstr.typeName(a)+"' object is not callable");};goog.exportSymbol("Sk.misceval.apply",Sk.misceval.apply);Sk.misceval.buildClass=function(a,b,c,d){var e=Sk.builtin.type,f={};b(a,f,[]);f.__module__=a.__name__;return Sk.misceval.callsim(e,c,d,f)};goog.exportSymbol("Sk.misceval.buildClass",Sk.misceval.buildClass);Sk.abstr={};Sk.abstr.typeName=function(a){return a instanceof Sk.builtin.nmber?a.skType:void 0!==a.tp$name?a.tp$name:"<invalid type>"};Sk.abstr.binop_type_error=function(a,b,c){a=Sk.abstr.typeName(a);b=Sk.abstr.typeName(b);throw new Sk.builtin.TypeError("unsupported operand type(s) for "+c+": '"+a+"' and '"+b+"'");};Sk.abstr.unop_type_error=function(a,b){var c=Sk.abstr.typeName(a);throw new Sk.builtin.TypeError("bad operand type for unary "+{UAdd:"+",USub:"-",Invert:"~"}[b]+": '"+c+"'");};
Sk.abstr.boNameToSlotFuncLhs_=function(a,b){if(null!==a)switch(b){case "Add":return a.nb$add?a.nb$add:a.__add__;case "Sub":return a.nb$subtract?a.nb$subtract:a.__sub__;case "Mult":return a.nb$multiply?a.nb$multiply:a.__mul__;case "Div":return a.nb$divide?a.nb$divide:a.__div__;case "FloorDiv":return a.nb$floor_divide?a.nb$floor_divide:a.__floordiv__;case "Mod":return a.nb$remainder?a.nb$remainder:a.__mod__;case "Pow":return a.nb$power?a.nb$power:a.__pow__;case "LShift":return a.nb$lshift?a.nb$lshift:
a.__lshift__;case "RShift":return a.nb$rshift?a.nb$rshift:a.__rshift__;case "BitAnd":return a.nb$and?a.nb$and:a.__and__;case "BitXor":return a.nb$xor?a.nb$xor:a.__xor__;case "BitOr":return a.nb$or?a.nb$or:a.__or__}};
Sk.abstr.boNameToSlotFuncRhs_=function(a,b){if(null!==a)switch(b){case "Add":return a.nb$add?a.nb$add:a.__radd__;case "Sub":return a.nb$subtract?a.nb$subtract:a.__rsub__;case "Mult":return a.nb$multiply?a.nb$multiply:a.__rmul__;case "Div":return a.nb$divide?a.nb$divide:a.__rdiv__;case "FloorDiv":return a.nb$floor_divide?a.nb$floor_divide:a.__rfloordiv__;case "Mod":return a.nb$remainder?a.nb$remainder:a.__rmod__;case "Pow":return a.nb$power?a.nb$power:a.__rpow__;case "LShift":return a.nb$lshift?a.nb$lshift:
a.__rlshift__;case "RShift":return a.nb$rshift?a.nb$rshift:a.__rrshift__;case "BitAnd":return a.nb$and?a.nb$and:a.__rand__;case "BitXor":return a.nb$xor?a.nb$xor:a.__rxor__;case "BitOr":return a.nb$or?a.nb$or:a.__ror__}};
Sk.abstr.iboNameToSlotFunc_=function(a,b){switch(b){case "Add":return a.nb$inplace_add?a.nb$inplace_add:a.__iadd__;case "Sub":return a.nb$inplace_subtract?a.nb$inplace_subtract:a.__isub__;case "Mult":return a.nb$inplace_multiply?a.nb$inplace_multiply:a.__imul__;case "Div":return a.nb$inplace_divide?a.nb$inplace_divide:a.__idiv__;case "FloorDiv":return a.nb$inplace_floor_divide?a.nb$inplace_floor_divide:a.__ifloordiv__;case "Mod":return a.nb$inplace_remainder;case "Pow":return a.nb$inplace_power;case "LShift":return a.nb$inplace_lshift?
a.nb$inplace_lshift:a.__ilshift__;case "RShift":return a.nb$inplace_rshift?a.nb$inplace_rshift:a.__irshift__;case "BitAnd":return a.nb$inplace_and;case "BitOr":return a.nb$inplace_or;case "BitXor":return a.nb$inplace_xor?a.nb$inplace_xor:a.__ixor__}};Sk.abstr.uoNameToSlotFunc_=function(a,b){if(null!==a)switch(b){case "USub":return a.nb$negative?a.nb$negative:a.__neg__;case "UAdd":return a.nb$positive?a.nb$positive:a.__pos__;case "Invert":return a.nb$invert?a.nb$invert:a.__invert__}};
Sk.abstr.binary_op_=function(a,b,c){var d;d=Sk.abstr.boNameToSlotFuncLhs_(a,c);if(void 0!==d&&(d=d.call?d.call(a,b):Sk.misceval.callsim(d,a,b),void 0!==d))return d;d=Sk.abstr.boNameToSlotFuncRhs_(b,c);if(void 0!==d&&(d=d.call?d.call(b,a):Sk.misceval.callsim(d,b,a),void 0!==d))return d;Sk.abstr.binop_type_error(a,b,c)};
Sk.abstr.binary_iop_=function(a,b,c){var d;d=Sk.abstr.iboNameToSlotFunc_(a,c);if(void 0!==d&&(d=d.call?d.call(a,b):Sk.misceval.callsim(d,a,b),void 0!==d))return d;d=Sk.abstr.iboNameToSlotFunc_(b,c);if(void 0!==d&&(d=d.call?d.call(b,a):Sk.misceval.callsim(d,b,a),void 0!==d))return d;Sk.abstr.binop_type_error(a,b,c)};Sk.abstr.unary_op_=function(a,b){var c;c=Sk.abstr.uoNameToSlotFunc_(a,b);if(void 0!==c&&(c=c.call?c.call(a):Sk.misceval.callsim(c,a),void 0!==c))return c;Sk.abstr.unop_type_error(a,b)};
Sk.abstr.numOpAndPromote=function(a,b,c){if(null!==a&&null!==b){if("number"===typeof a&&"number"===typeof b)return c=c(a,b),(c>Sk.builtin.nmber.threshold$||c<-Sk.builtin.nmber.threshold$)&&Math.floor(c)===c?[Sk.builtin.lng.fromInt$(a),Sk.builtin.lng.fromInt$(b)]:c;if(void 0===a||void 0===b)throw new Sk.builtin.NameError("Undefined variable in expression");if(a.constructor===Sk.builtin.lng||a.constructor===Sk.builtin.nmber)return[a,b];if("number"===typeof a)return[new Sk.builtin.nmber(a,void 0),b]}};
Sk.abstr.boNumPromote_={Add:function(a,b){return a+b},Sub:function(a,b){return a-b},Mult:function(a,b){return a*b},Mod:function(a,b){if(0===b)throw new Sk.builtin.ZeroDivisionError("division or modulo by zero");var c=a%b;return 0>c*b?c+b:c},Div:function(a,b){if(0===b)throw new Sk.builtin.ZeroDivisionError("division or modulo by zero");return a/b},FloorDiv:function(a,b){if(0===b)throw new Sk.builtin.ZeroDivisionError("division or modulo by zero");return Math.floor(a/b)},Pow:Math.pow,BitAnd:function(a,
b){var c=a&b;0>c&&(c+=4294967296);return c},BitOr:function(a,b){var c=a|b;0>c&&(c+=4294967296);return c},BitXor:function(a,b){var c=a^b;0>c&&(c+=4294967296);return c},LShift:function(a,b){if(0>b)throw new Sk.builtin.ValueError("negative shift count");var c=a<<b;return c>a?c:a*Math.pow(2,b)},RShift:function(a,b){if(0>b)throw new Sk.builtin.ValueError("negative shift count");var c=a>>b;0<a&&0>c&&(c&=Math.pow(2,32-b)-1);return c}};
Sk.abstr.numberBinOp=function(a,b,c){var d=Sk.abstr.boNumPromote_[c];if(void 0!==d){d=Sk.abstr.numOpAndPromote(a,b,d);if("number"===typeof d)return d;if(void 0!==d&&d.constructor===Sk.builtin.nmber||void 0!==d&&d.constructor===Sk.builtin.lng)return d;void 0!==d&&(a=d[0],b=d[1])}return Sk.abstr.binary_op_(a,b,c)};goog.exportSymbol("Sk.abstr.numberBinOp",Sk.abstr.numberBinOp);
Sk.abstr.numberInplaceBinOp=function(a,b,c){var d=Sk.abstr.boNumPromote_[c];if(void 0!==d){d=Sk.abstr.numOpAndPromote(a,b,d);if("number"===typeof d)return d;if(void 0!==d&&d.constructor===Sk.builtin.nmber||void 0!==d&&d.constructor===Sk.builtin.lng)return d;void 0!==d&&(a=d[0],b=d[1])}return Sk.abstr.binary_iop_(a,b,c)};goog.exportSymbol("Sk.abstr.numberInplaceBinOp",Sk.abstr.numberInplaceBinOp);
Sk.abstr.numberUnaryOp=function(a,b){if("Not"===b)return Sk.misceval.isTrue(a)?Sk.builtin.bool.false$:Sk.builtin.bool.true$;if(a instanceof Sk.builtin.nmber||a instanceof Sk.builtin.bool){var c=Sk.builtin.asnum$(a);if("USub"===b)return new Sk.builtin.nmber(-c,a.skType);if("UAdd"===b)return new Sk.builtin.nmber(c,a.skType);if("Invert"===b)return new Sk.builtin.nmber(~c,a.skType)}else{if("USub"===b&&a.nb$negative)return a.nb$negative();if("UAdd"===b&&a.nb$positive)return a.nb$positive();if("Invert"===
b&&a.nb$invert)return a.nb$invert()}return Sk.abstr.unary_op_(a,b)};goog.exportSymbol("Sk.abstr.numberUnaryOp",Sk.abstr.numberUnaryOp);Sk.abstr.fixSeqIndex_=function(a,b){b=Sk.builtin.asnum$(b);0>b&&a.sq$length&&(b+=a.sq$length());return b};
Sk.abstr.sequenceContains=function(a,b){if(a.sq$contains)return a.sq$contains(b);var c=Sk.abstr.typeName(a);if(!a.tp$iter)throw new Sk.builtin.TypeError("argument of type '"+c+"' is not iterable");for(var c=a.tp$iter(),d=c.tp$iternext();void 0!==d;d=c.tp$iternext())if(Sk.misceval.richCompareBool(d,b,"Eq"))return!0;return!1};Sk.abstr.sequenceConcat=function(a,b){if(a.sq$concat)return a.sq$concat(b);var c=Sk.abstr.typeName(a);throw new Sk.builtin.TypeError("'"+c+"' object can't be concatenated");};
Sk.abstr.sequenceGetIndexOf=function(a,b){if(a.index)return Sk.misceval.callsim(a.index,a,b);var c=Sk.abstr.typeName(a);if("dict"===c)throw new Sk.builtin.NotImplementedError("looking up dict key from value is not yet implemented (supported in Python 2.6)");throw new Sk.builtin.TypeError("argument of type '"+c+"' is not iterable");};
Sk.abstr.sequenceGetCountOf=function(a,b){if(a.count)return Sk.misceval.callsim(a.count,a,b);var c=Sk.abstr.typeName(a);throw new Sk.builtin.TypeError("argument of type '"+c+"' is not iterable");};Sk.abstr.sequenceGetItem=function(a,b){if(a.mp$subscript)return a.mp$subscript(b);var c=Sk.abstr.typeName(a);throw new Sk.builtin.TypeError("'"+c+"' object is unsubscriptable");};
Sk.abstr.sequenceSetItem=function(a,b,c){if(a.mp$ass_subscript)return a.mp$ass_subscript(b,c);a=Sk.abstr.typeName(a);throw new Sk.builtin.TypeError("'"+a+"' object does not support item assignment");};Sk.abstr.sequenceDelItem=function(a,b){if(a.sq$del_item)b=Sk.abstr.fixSeqIndex_(a,b),a.sq$del_item(b);else{var c=Sk.abstr.typeName(a);throw new Sk.builtin.TypeError("'"+c+"' object does not support item deletion");}};
Sk.abstr.sequenceRepeat=function(a,b,c){c=Sk.builtin.asnum$(c);if(void 0===Sk.misceval.asIndex(c))throw a=Sk.abstr.typeName(c),new Sk.builtin.TypeError("can't multiply sequence by non-int of type '"+a+"'");return a.call(b,c)};
Sk.abstr.sequenceGetSlice=function(a,b,c){if(a.sq$slice)return b=Sk.abstr.fixSeqIndex_(a,b),c=Sk.abstr.fixSeqIndex_(a,c),a.sq$slice(b,c);if(a.mp$subscript)return a.mp$subscript(new Sk.builtin.slice(b,c));a=Sk.abstr.typeName(a);throw new Sk.builtin.TypeError("'"+a+"' object is unsliceable");};
Sk.abstr.sequenceDelSlice=function(a,b,c){if(a.sq$del_slice)b=Sk.abstr.fixSeqIndex_(a,b),c=Sk.abstr.fixSeqIndex_(a,c),a.sq$del_slice(b,c);else throw a=Sk.abstr.typeName(a),new Sk.builtin.TypeError("'"+a+"' doesn't support slice deletion");};
Sk.abstr.sequenceSetSlice=function(a,b,c,d){if(a.sq$ass_slice)b=Sk.abstr.fixSeqIndex_(a,b),c=Sk.abstr.fixSeqIndex_(a,c),a.sq$ass_slice(b,c,d);else if(a.mp$ass_subscript)a.mp$ass_subscript(new Sk.builtin.slice(b,c),d);else throw a=Sk.abstr.typeName(a),new Sk.builtin.TypeError("'"+a+"' object doesn't support slice assignment");};
Sk.abstr.objectAdd=function(a,b){if(a.nb$add)return a.nb$add(b);var c=Sk.abstr.typeName(a),d=Sk.abstr.typeName(b);throw new Sk.builtin.TypeError("unsupported operand type(s) for +: '"+c+"' and '"+d+"'");};Sk.abstr.objectNegative=function(a){if("number"===typeof Sk.builtin.asnum$(a))return Sk.builtin.nmber.prototype.nb$negative.call(a);a=Sk.abstr.typeName(a);throw new Sk.builtin.TypeError("bad operand type for unary -: '"+a+"'");};
Sk.abstr.objectPositive=function(a){var b=Sk.abstr.typeName(a),c=Sk.builtin.asnum$(a);if("bool"===b)return new Sk.builtin.nmber(c,"int");if("number"===typeof c)return Sk.builtin.nmber.prototype.nb$positive.call(a);throw new Sk.builtin.TypeError("bad operand type for unary +: '"+b+"'");};
Sk.abstr.objectDelItem=function(a,b){if(null!==a){if(a.mp$del_subscript){a.mp$del_subscript(b);return}if(a.sq$ass_item){var c=Sk.misceval.asIndex(b);if(void 0===c)throw c=Sk.abstr.typeName(b),new Sk.builtin.TypeError("sequence index must be integer, not '"+c+"'");Sk.abstr.sequenceDelItem(a,c);return}}c=Sk.abstr.typeName(a);throw new Sk.builtin.TypeError("'"+c+"' object does not support item deletion");};goog.exportSymbol("Sk.abstr.objectDelItem",Sk.abstr.objectDelItem);
Sk.abstr.objectGetItem=function(a,b){if(null!==a){if(a.mp$subscript)return a.mp$subscript(b);if(Sk.misceval.isIndex(b)&&a.sq$item)return Sk.abstr.sequenceGetItem(a,Sk.misceval.asIndex(b));if(a.tp$getitem)return a.tp$getitem(b)}var c=Sk.abstr.typeName(a);throw new Sk.builtin.TypeError("'"+c+"' does not support indexing");};goog.exportSymbol("Sk.abstr.objectGetItem",Sk.abstr.objectGetItem);
Sk.abstr.objectSetItem=function(a,b,c){if(null!==a){if(a.mp$ass_subscript)return a.mp$ass_subscript(b,c);if(Sk.misceval.isIndex(b)&&a.sq$ass_item)return Sk.abstr.sequenceSetItem(a,Sk.misceval.asIndex(b),c);if(a.tp$setitem)return a.tp$setitem(b,c)}a=Sk.abstr.typeName(a);throw new Sk.builtin.TypeError("'"+a+"' does not support item assignment");};goog.exportSymbol("Sk.abstr.objectSetItem",Sk.abstr.objectSetItem);
Sk.abstr.gattr=function(a,b){var c=Sk.abstr.typeName(a);if(null===a)throw new Sk.builtin.AttributeError("'"+c+"' object has no attribute '"+b+"'");var d=void 0;a.__getattr__?d=Sk.misceval.callsim(a.__getattr__,a,b):void 0!==a.tp$getattr&&(d=a.tp$getattr(b));if(void 0===d)throw new Sk.builtin.AttributeError("'"+c+"' object has no attribute '"+b+"'");return d};goog.exportSymbol("Sk.abstr.gattr",Sk.abstr.gattr);
Sk.abstr.sattr=function(a,b,c){var d=Sk.abstr.typeName(a);if(null===a)throw new Sk.builtin.AttributeError("'"+d+"' object has no attribute '"+b+"'");if(a.__setattr__)Sk.misceval.callsim(a.__setattr__,a,b,c);else if(void 0!==a.tp$setattr)a.tp$setattr(b,c);else throw new Sk.builtin.AttributeError("'"+d+"' object has no attribute '"+b+"'");};goog.exportSymbol("Sk.abstr.sattr",Sk.abstr.sattr);
Sk.abstr.iter=function(a){if(a.tp$iter)return a.tp$iter();throw new Sk.builtin.TypeError("'"+Sk.abstr.typeName(a)+"' object is not iterable");};goog.exportSymbol("Sk.abstr.iter",Sk.abstr.iter);Sk.abstr.iternext=function(a){return a.tp$iternext()};goog.exportSymbol("Sk.abstr.iternext",Sk.abstr.iternext);Sk.mergeSort=function(a,b,c,d){Sk.quickSort(a,b,c,d)};Sk.quickSort=function(a,b,c,d){goog.asserts.assert(!c,"todo;");b||(b=Sk.mergeSort.stdCmp);var e=function(a,c,d,k){if(d-1>c){var l=c+Math.floor(Math.random()*(d-c)),m,n=a[l];m=a[l];a[l]=a[d-1];a[d-1]=m;var l=c,p;for(p=c;p<d-1;++p)m=k?Sk.misceval.callsim(b,n,a[p]):Sk.misceval.callsim(b,a[p],n),0>Sk.builtin.asnum$(m)&&(m=a[l],a[l]=a[p],a[p]=m,++l);m=a[d-1];a[d-1]=a[l];a[l]=m;e(a,c,l,k);e(a,l+1,d,k)}};e(a,0,a.length,d);return null};
Sk.mergeSort.stdCmp=new Sk.builtin.func(function(a,b){return Sk.misceval.richCompareBool(a,b,"Lt")?-1:0});Sk.builtin.list=function(a){if(!(this instanceof Sk.builtin.list))return new Sk.builtin.list(a);if(void 0===a)this.v=[];else if("[object Array]"===Object.prototype.toString.apply(a))this.v=a;else if(a.tp$iter){this.v=[];a=a.tp$iter();for(var b=a.tp$iternext();void 0!==b;b=a.tp$iternext())this.v.push(b)}else throw new Sk.builtin.ValueError("expecting Array or iterable");this.__class__=Sk.builtin.list;this.v=this.v;return this};
Sk.builtin.list.prototype.ob$type=Sk.builtin.type.makeIntoTypeObj("list",Sk.builtin.list);Sk.builtin.list.prototype.list_iter_=function(){var a={tp$iter:function(){return a},$obj:this,$index:0,tp$iternext:function(){return a.$index>=a.$obj.v.length?void 0:a.$obj.v[a.$index++]}};return a};
Sk.builtin.list.prototype.list_concat_=function(a){if(!a.__class__||a.__class__!=Sk.builtin.list)throw new Sk.builtin.TypeError("can only concatenate list to list");for(var b=this.v.slice(),c=0;c<a.v.length;++c)b.push(a.v[c]);return new Sk.builtin.list(b)};
Sk.builtin.list.prototype.list_extend_=function(a){if(!Sk.builtin.checkIterable(a))throw new Sk.builtin.TypeError("'"+Sk.abstr.typeName(a)+"' object is not iterable");if(this==a){var b=[];a=a.tp$iter();for(var c=a.tp$iternext();void 0!==c;c=a.tp$iternext())b.push(c);this.v.push.apply(this.v,b)}else for(a=a.tp$iter(),c=a.tp$iternext();void 0!==c;c=a.tp$iternext())this.v.push(c);return this};
Sk.builtin.list.prototype.list_del_item_=function(a){a=Sk.builtin.asnum$(a);if(0>a||a>=this.v.length)throw new Sk.builtin.IndexError("list assignment index out of range");this.list_del_slice_(a,a+1)};Sk.builtin.list.prototype.list_del_slice_=function(a,b){a=Sk.builtin.asnum$(a);b=Sk.builtin.asnum$(b);var c=[];c.unshift(b-a);c.unshift(a);this.v.splice.apply(this.v,c)};
Sk.builtin.list.prototype.list_ass_item_=function(a,b){a=Sk.builtin.asnum$(a);if(0>a||a>=this.v.length)throw new Sk.builtin.IndexError("list assignment index out of range");this.v[a]=b};Sk.builtin.list.prototype.list_ass_slice_=function(a,b,c){a=Sk.builtin.asnum$(a);b=Sk.builtin.asnum$(b);c=c.v.slice(0);c.unshift(b-a);c.unshift(a);this.v.splice.apply(this.v,c)};Sk.builtin.list.prototype.tp$name="list";
Sk.builtin.list.prototype.$r=function(){for(var a=[],b=this.tp$iter(),c=b.tp$iternext();void 0!==c;c=b.tp$iternext())a.push(Sk.misceval.objectRepr(c).v);return new Sk.builtin.str("["+a.join(", ")+"]")};Sk.builtin.list.prototype.tp$getattr=Sk.builtin.object.prototype.GenericGetAttr;Sk.builtin.list.prototype.tp$hash=Sk.builtin.object.prototype.HashNotImplemented;
Sk.builtin.list.prototype.tp$richcompare=function(a,b){if(this===a&&Sk.misceval.opAllowsEquality(b))return!0;if(!a.__class__||a.__class__!=Sk.builtin.list)return"Eq"===b?!1:"NotEq"===b?!0:!1;var c=this.v;a=a.v;var d=c.length,e=a.length,f;for(f=0;f<d&&f<e&&Sk.misceval.richCompareBool(c[f],a[f],"Eq");++f);if(f>=d||f>=e)switch(b){case "Lt":return d<e;case "LtE":return d<=e;case "Eq":return d===e;case "NotEq":return d!==e;case "Gt":return d>e;case "GtE":return d>=e;default:goog.asserts.fail()}return"Eq"===
b?!1:"NotEq"===b?!0:Sk.misceval.richCompareBool(c[f],a[f],b)};Sk.builtin.list.prototype.tp$iter=Sk.builtin.list.prototype.list_iter_;Sk.builtin.list.prototype.sq$length=function(){return this.v.length};Sk.builtin.list.prototype.sq$concat=Sk.builtin.list.prototype.list_concat_;Sk.builtin.list.prototype.nb$add=Sk.builtin.list.prototype.list_concat_;Sk.builtin.list.prototype.nb$inplace_add=Sk.builtin.list.prototype.list_extend_;
Sk.builtin.list.prototype.sq$repeat=function(a){if(!Sk.builtin.checkInt(a))throw new Sk.builtin.TypeError("can't multiply sequence by non-int of type '"+Sk.abstr.typeName(a)+"'");a=Sk.builtin.asnum$(a);for(var b=[],c=0;c<a;++c)for(var d=0;d<this.v.length;++d)b.push(this.v[d]);return new Sk.builtin.list(b)};Sk.builtin.list.prototype.nb$multiply=Sk.builtin.list.prototype.sq$repeat;Sk.builtin.list.prototype.nb$inplace_multiply=Sk.builtin.list.prototype.sq$repeat;
Sk.builtin.list.prototype.sq$ass_item=Sk.builtin.list.prototype.list_ass_item_;Sk.builtin.list.prototype.sq$del_item=Sk.builtin.list.prototype.list_del_item_;Sk.builtin.list.prototype.sq$ass_slice=Sk.builtin.list.prototype.list_ass_slice_;Sk.builtin.list.prototype.sq$del_slice=Sk.builtin.list.prototype.list_del_slice_;
Sk.builtin.list.prototype.list_subscript_=function(a){if(Sk.misceval.isIndex(a)){var b=Sk.misceval.asIndex(a);if(void 0!==b){0>b&&(b=this.v.length+b);if(0>b||b>=this.v.length)throw new Sk.builtin.IndexError("list index out of range");return this.v[b]}}else if(a instanceof Sk.builtin.slice){var c=[];a.sssiter$(this,function(a,b){c.push(b.v[a])});return new Sk.builtin.list(c)}throw new Sk.builtin.TypeError("list indices must be integers, not "+Sk.abstr.typeName(a));};
Sk.builtin.list.prototype.list_ass_subscript_=function(a,b){if(Sk.misceval.isIndex(a)){var c=Sk.misceval.asIndex(a);if(void 0!==c){0>c&&(c=this.v.length+c);this.list_ass_item_(c,b);return}}else if(a instanceof Sk.builtin.slice){c=a.indices(this.v.length);if(1===c[2])this.list_ass_slice_(c[0],c[1],b);else{var d=[];a.sssiter$(this,function(a,b){d.push(a)});var e=0;if(d.length!==b.v.length)throw new Sk.builtin.ValueError("attempt to assign sequence of size "+b.v.length+" to extended slice of size "+
d.length);for(c=0;c<d.length;++c)this.v.splice(d[c],1,b.v[e]),e+=1}return}throw new Sk.builtin.TypeError("list indices must be integers, not "+Sk.abstr.typeName(a));};
Sk.builtin.list.prototype.list_del_subscript_=function(a){if(Sk.misceval.isIndex(a)){var b=Sk.misceval.asIndex(a);if(void 0!==b){0>b&&(b=this.v.length+b);this.list_del_item_(b);return}}else if(a instanceof Sk.builtin.slice){b=a.indices(this.v.length);if(1===b[2])this.list_del_slice_(b[0],b[1]);else{var c=this,d=0,e=0<b[2]?1:0;a.sssiter$(this,function(a,b){c.v.splice(a-d,1);d+=e})}return}throw new Sk.builtin.TypeError("list indices must be integers, not "+typeof a);};
Sk.builtin.list.prototype.mp$subscript=Sk.builtin.list.prototype.list_subscript_;Sk.builtin.list.prototype.mp$ass_subscript=Sk.builtin.list.prototype.list_ass_subscript_;Sk.builtin.list.prototype.mp$del_subscript=Sk.builtin.list.prototype.list_del_subscript_;Sk.builtin.list.prototype.__getitem__=new Sk.builtin.func(function(a,b){return Sk.builtin.list.prototype.list_subscript_.call(a,b)});
Sk.builtin.list.prototype.list_sort_=function(a,b,c,d){var e=void 0!==c&&null!==c,f=void 0!==b&&null!==b;void 0==d&&(d=!1);var g=new Sk.builtin.timSort(a);a.v=[];var h=new Sk.builtin.nmber(0,Sk.builtin.nmber.int$);if(e){g.lt=f?function(a,c){var d=Sk.misceval.callsim(b,a[0],c[0]);return Sk.misceval.richCompareBool(d,h,"Lt")}:function(a,b){return Sk.misceval.richCompareBool(a[0],b[0],"Lt")};for(var k=0;k<g.listlength;k++){var f=g.list.v[k],l=Sk.misceval.callsim(c,f);g.list.v[k]=[l,f]}}else f&&(g.lt=
function(a,c){var d=Sk.misceval.callsim(b,a,c);return Sk.misceval.richCompareBool(d,h,"Lt")});d&&g.list.list_reverse_(g.list);g.sort();d&&g.list.list_reverse_(g.list);if(e)for(c=0;c<g.listlength;c++)f=g.list.v[c][1],g.list.v[c]=f;c=0<a.sq$length();a.v=g.list.v;if(c)throw new Sk.builtin.OperationError("list modified during sort");return Sk.builtin.none.none$};
Sk.builtin.list.prototype.list_reverse_=function(a){Sk.builtin.pyCheckArgs("reverse",arguments,1,1);for(var b=a.v,c=[],d=a.v.length-1;-1<d;--d)c.push(b[d]);a.v=c;return Sk.builtin.none.none$};Sk.builtin.list.prototype.__iter__=new Sk.builtin.func(function(a){Sk.builtin.pyCheckArgs("__iter__",arguments,1,1);return a.list_iter_()});Sk.builtin.list.prototype.append=new Sk.builtin.func(function(a,b){Sk.builtin.pyCheckArgs("append",arguments,2,2);a.v.push(b);return Sk.builtin.none.none$});
Sk.builtin.list.prototype.insert=new Sk.builtin.func(function(a,b,c){Sk.builtin.pyCheckArgs("insert",arguments,3,3);if(!Sk.builtin.checkNumber(b))throw new Sk.builtin.TypeError("an integer is required");b=Sk.builtin.asnum$(b);0>b&&(b+=a.v.length);0>b?b=0:b>a.v.length&&(b=a.v.length);a.v.splice(b,0,c);return Sk.builtin.none.none$});Sk.builtin.list.prototype.extend=new Sk.builtin.func(function(a,b){Sk.builtin.pyCheckArgs("extend",arguments,2,2);a.list_extend_(b);return Sk.builtin.none.none$});
Sk.builtin.list.prototype.pop=new Sk.builtin.func(function(a,b){Sk.builtin.pyCheckArgs("pop",arguments,1,2);void 0===b&&(b=a.v.length-1);if(!Sk.builtin.checkNumber(b))throw new Sk.builtin.TypeError("an integer is required");b=Sk.builtin.asnum$(b);0>b&&(b+=a.v.length);if(0>b||b>=a.v.length)throw new Sk.builtin.IndexError("pop index out of range");var c=a.v[b];a.v.splice(b,1);return c});
Sk.builtin.list.prototype.remove=new Sk.builtin.func(function(a,b){Sk.builtin.pyCheckArgs("remove",arguments,2,2);var c=Sk.builtin.list.prototype.index.func_code(a,b);a.v.splice(Sk.builtin.asnum$(c),1);return Sk.builtin.none.none$});
Sk.builtin.list.prototype.index=new Sk.builtin.func(function(a,b,c,d){Sk.builtin.pyCheckArgs("index",arguments,2,4);if(void 0!==c&&!Sk.builtin.checkInt(c))throw new Sk.builtin.TypeError("slice indices must be integers");if(void 0!==d&&!Sk.builtin.checkInt(d))throw new Sk.builtin.TypeError("slice indices must be integers");var e=a.v.length,f=a.v;c=void 0===c?0:c.v;0>c&&(c=0<=c+e?c+e:0);d=void 0===d?e:d.v;0>d&&(d=0<=d+e?d+e:0);for(e=c;e<d;++e)if(Sk.misceval.richCompareBool(f[e],b,"Eq"))return Sk.builtin.assk$(e,
Sk.builtin.nmber.int$);throw new Sk.builtin.ValueError("list.index(x): x not in list");});Sk.builtin.list.prototype.count=new Sk.builtin.func(function(a,b){Sk.builtin.pyCheckArgs("count",arguments,2,2);for(var c=a.v.length,d=a.v,e=0,f=0;f<c;++f)Sk.misceval.richCompareBool(d[f],b,"Eq")&&(e+=1);return new Sk.builtin.nmber(e,Sk.builtin.nmber.int$)});Sk.builtin.list.prototype.reverse=new Sk.builtin.func(Sk.builtin.list.prototype.list_reverse_);Sk.builtin.list.prototype.sort=new Sk.builtin.func(Sk.builtin.list.prototype.list_sort_);
Sk.builtin.list.prototype.sort.func_code.co_varnames=["__self__","cmp","key","reverse"];goog.exportSymbol("Sk.builtin.list",Sk.builtin.list);var interned={};
Sk.builtin.str=function(a){void 0===a&&(a="");if(a instanceof Sk.builtin.str&&a!==Sk.builtin.str.prototype.ob$type)return a;if(!(this instanceof Sk.builtin.str))return new Sk.builtin.str(a);if(!0===a)a="True";else if(!1===a)a="False";else if(null===a||a instanceof Sk.builtin.none)a="None";else if(a instanceof Sk.builtin.bool)a=a.v?"True":"False";else if("number"===typeof a)a=a.toString(),"Infinity"===a?a="inf":"-Infinity"===a&&(a="-inf");else if("string"!==typeof a){if(void 0!==a.tp$str){a=a.tp$str();
if(!(a instanceof Sk.builtin.str))throw new Sk.builtin.ValueError("__str__ didn't return a str");return a}return Sk.misceval.objectRepr(a)}if(Object.prototype.hasOwnProperty.call(interned,"1"+a))return interned["1"+a];this.__class__=Sk.builtin.str;this.v=this.v=a;interned["1"+a]=this;return this};goog.exportSymbol("Sk.builtin.str",Sk.builtin.str);Sk.builtin.str.$emptystr=new Sk.builtin.str("");
Sk.builtin.str.prototype.mp$subscript=function(a){a=Sk.builtin.asnum$(a);if("number"===typeof a&&Math.floor(a)===a){0>a&&(a=this.v.length+a);if(0>a||a>=this.v.length)throw new Sk.builtin.IndexError("string index out of range");return new Sk.builtin.str(this.v.charAt(a))}if(a instanceof Sk.builtin.slice){var b="";a.sssiter$(this,function(a,d){0<=a&&a<d.v.length&&(b+=d.v.charAt(a))});return new Sk.builtin.str(b)}throw new Sk.builtin.TypeError("string indices must be numbers, not "+typeof a);};
Sk.builtin.str.prototype.sq$length=function(){return this.v.length};Sk.builtin.str.prototype.sq$concat=function(a){if(!a||!Sk.builtin.checkString(a))throw a=Sk.abstr.typeName(a),new Sk.builtin.TypeError("cannot concatenate 'str' and '"+a+"' objects");return new Sk.builtin.str(this.v+a.v)};Sk.builtin.str.prototype.nb$add=Sk.builtin.str.prototype.sq$concat;Sk.builtin.str.prototype.nb$inplace_add=Sk.builtin.str.prototype.sq$concat;
Sk.builtin.str.prototype.sq$repeat=function(a){if(!Sk.builtin.checkInt(a))throw new Sk.builtin.TypeError("can't multiply sequence by non-int of type '"+Sk.abstr.typeName(a)+"'");a=Sk.builtin.asnum$(a);for(var b="",c=0;c<a;++c)b+=this.v;return new Sk.builtin.str(b)};Sk.builtin.str.prototype.nb$multiply=Sk.builtin.str.prototype.sq$repeat;Sk.builtin.str.prototype.nb$inplace_multiply=Sk.builtin.str.prototype.sq$repeat;Sk.builtin.str.prototype.sq$item=function(){goog.asserts.fail()};
Sk.builtin.str.prototype.sq$slice=function(a,b){a=Sk.builtin.asnum$(a);b=Sk.builtin.asnum$(b);0>a&&(a=0);return new Sk.builtin.str(this.v.substr(a,b-a))};Sk.builtin.str.prototype.sq$contains=function(a){if(void 0===a.v||a.v.constructor!=String)throw new Sk.builtin.TypeError("TypeError: 'In <string> requires string as left operand");return-1!=this.v.indexOf(a.v)?!0:!1};Sk.builtin.str.prototype.tp$name="str";Sk.builtin.str.prototype.tp$getattr=Sk.builtin.object.prototype.GenericGetAttr;
Sk.builtin.str.prototype.tp$iter=function(){var a={tp$iter:function(){return a},$obj:this,$index:0,tp$iternext:function(){return a.$index>=a.$obj.v.length?void 0:new Sk.builtin.str(a.$obj.v.substr(a.$index++,1))}};return a};Sk.builtin.str.prototype.tp$richcompare=function(a,b){if(a instanceof Sk.builtin.str)switch(b){case "Lt":return this.v<a.v;case "LtE":return this.v<=a.v;case "Eq":return this.v===a.v;case "NotEq":return this.v!==a.v;case "Gt":return this.v>a.v;case "GtE":return this.v>=a.v;default:goog.asserts.fail()}};
Sk.builtin.str.prototype.$r=function(){var a="'";-1!==this.v.indexOf("'")&&-1===this.v.indexOf('"')&&(a='"');for(var b=this.v.length,c=a,d=0;d<b;++d){var e=this.v.charAt(d);e===a||"\\"===e?c+="\\"+e:"\t"===e?c+="\\t":"\n"===e?c+="\\n":"\r"===e?c+="\\r":" ">e||127<=e?(e=e.charCodeAt(0).toString(16),2>e.length&&(e="0"+e),c+="\\x"+e):c+=e}return new Sk.builtin.str(c+a)};
Sk.builtin.str.re_escape_=function(a){for(var b=[],c=/^[A-Za-z0-9]+$/,d=0;d<a.length;++d){var e=a.charAt(d);c.test(e)?b.push(e):"\\000"===e?b.push("\\000"):b.push("\\"+e)}return b.join("")};Sk.builtin.str.prototype.lower=new Sk.builtin.func(function(a){Sk.builtin.pyCheckArgs("lower",arguments,1,1);return new Sk.builtin.str(a.v.toLowerCase())});Sk.builtin.str.prototype.upper=new Sk.builtin.func(function(a){Sk.builtin.pyCheckArgs("upper",arguments,1,1);return new Sk.builtin.str(a.v.toUpperCase())});
Sk.builtin.str.prototype.capitalize=new Sk.builtin.func(function(a){Sk.builtin.pyCheckArgs("capitalize",arguments,1,1);var b=a.v,c,d;if(0===b.length)return new Sk.builtin.str("");c=b.charAt(0).toUpperCase();for(d=1;d<b.length;d++)c+=b.charAt(d).toLowerCase();return new Sk.builtin.str(c)});
Sk.builtin.str.prototype.join=new Sk.builtin.func(function(a,b){Sk.builtin.pyCheckArgs("join",arguments,2,2);Sk.builtin.pyCheckType("seq","iterable",Sk.builtin.checkIterable(b));for(var c=[],d=b.tp$iter(),e=d.tp$iternext();void 0!==e;e=d.tp$iternext()){if(e.constructor!==Sk.builtin.str)throw"TypeError: sequence item "+c.length+": expected string, "+typeof e+" found";c.push(e.v)}return new Sk.builtin.str(c.join(a.v))});
Sk.builtin.str.prototype.split=new Sk.builtin.func(function(a,b,c){Sk.builtin.pyCheckArgs("split",arguments,1,3);if(void 0===b||b instanceof Sk.builtin.none)b=null;if(null!==b&&!Sk.builtin.checkString(b))throw new Sk.builtin.TypeError("expected a string");if(null!==b&&""===b.v)throw new Sk.builtin.ValueError("empty separator");if(void 0!==c&&!Sk.builtin.checkInt(c))throw new Sk.builtin.TypeError("an integer is required");c=Sk.builtin.asnum$(c);var d=/[\s]+/g,e=a.v;null===b?e=e.trimLeft():(d=b.v.replace(/([.*+?=|\\\/()\[\]\{\}^$])/g,
"\\$1"),d=RegExp(d,"g"));for(var f=[],g,h=0,k=0;null!=(g=d.exec(e))&&g.index!==d.lastIndex&&!(f.push(new Sk.builtin.str(e.substring(h,g.index))),h=d.lastIndex,k+=1,c&&k>=c););e=e.substring(h);(null!==b||0<e.length)&&f.push(new Sk.builtin.str(e));return new Sk.builtin.list(f)});
Sk.builtin.str.prototype.strip=new Sk.builtin.func(function(a,b){Sk.builtin.pyCheckArgs("strip",arguments,1,2);if(void 0!==b&&!Sk.builtin.checkString(b))throw new Sk.builtin.TypeError("strip arg must be None or str");var c;void 0===b?c=/^\s+|\s+$/g:(c=Sk.builtin.str.re_escape_(b.v),c=RegExp("^["+c+"]+|["+c+"]+$","g"));return new Sk.builtin.str(a.v.replace(c,""))});
Sk.builtin.str.prototype.lstrip=new Sk.builtin.func(function(a,b){Sk.builtin.pyCheckArgs("lstrip",arguments,1,2);if(void 0!==b&&!Sk.builtin.checkString(b))throw new Sk.builtin.TypeError("lstrip arg must be None or str");var c;void 0===b?c=/^\s+/g:(c=Sk.builtin.str.re_escape_(b.v),c=RegExp("^["+c+"]+","g"));return new Sk.builtin.str(a.v.replace(c,""))});
Sk.builtin.str.prototype.rstrip=new Sk.builtin.func(function(a,b){Sk.builtin.pyCheckArgs("rstrip",arguments,1,2);if(void 0!==b&&!Sk.builtin.checkString(b))throw new Sk.builtin.TypeError("rstrip arg must be None or str");var c;void 0===b?c=/\s+$/g:(c=Sk.builtin.str.re_escape_(b.v),c=RegExp("["+c+"]+$","g"));return new Sk.builtin.str(a.v.replace(c,""))});
Sk.builtin.str.prototype.partition=new Sk.builtin.func(function(a,b){Sk.builtin.pyCheckArgs("partition",arguments,2,2);Sk.builtin.pyCheckType("sep","string",Sk.builtin.checkString(b));var c=new Sk.builtin.str(b),d=a.v.indexOf(c.v);return 0>d?new Sk.builtin.tuple([a,Sk.builtin.str.$emptystr,Sk.builtin.str.$emptystr]):new Sk.builtin.tuple([new Sk.builtin.str(a.v.substring(0,d)),c,new Sk.builtin.str(a.v.substring(d+c.v.length))])});
Sk.builtin.str.prototype.rpartition=new Sk.builtin.func(function(a,b){Sk.builtin.pyCheckArgs("rpartition",arguments,2,2);Sk.builtin.pyCheckType("sep","string",Sk.builtin.checkString(b));var c=new Sk.builtin.str(b),d=a.v.lastIndexOf(c.v);return 0>d?new Sk.builtin.tuple([Sk.builtin.str.$emptystr,Sk.builtin.str.$emptystr,a]):new Sk.builtin.tuple([new Sk.builtin.str(a.v.substring(0,d)),c,new Sk.builtin.str(a.v.substring(d+c.v.length))])});
Sk.builtin.str.prototype.count=new Sk.builtin.func(function(a,b,c,d){Sk.builtin.pyCheckArgs("count",arguments,2,4);if(!Sk.builtin.checkString(b))throw new Sk.builtin.TypeError("expected a character buffer object");if(void 0!==c&&!Sk.builtin.checkInt(c))throw new Sk.builtin.TypeError("slice indices must be integers or None or have an __index__ method");if(void 0!==d&&!Sk.builtin.checkInt(d))throw new Sk.builtin.TypeError("slice indices must be integers or None or have an __index__ method");void 0===
c?c=0:(c=Sk.builtin.asnum$(c),c=0<=c?c:a.v.length+c);void 0===d?d=a.v.length:(d=Sk.builtin.asnum$(d),d=0<=d?d:a.v.length+d);var e=RegExp(b.v,"g");return(e=a.v.slice(c,d).match(e))?new Sk.builtin.nmber(e.length,Sk.builtin.nmber.int$):new Sk.builtin.nmber(0,Sk.builtin.nmber.int$)});
Sk.builtin.str.prototype.ljust=new Sk.builtin.func(function(a,b,c){Sk.builtin.pyCheckArgs("ljust",arguments,2,3);if(!Sk.builtin.checkInt(b))throw new Sk.builtin.TypeError("integer argument exepcted, got "+Sk.abstr.typeName(b));if(void 0!==c&&(!Sk.builtin.checkString(c)||1!==c.v.length))throw new Sk.builtin.TypeError("must be char, not "+Sk.abstr.typeName(c));c=void 0===c?" ":c.v;b=Sk.builtin.asnum$(b);if(a.v.length>=b)return a;var d=Array.prototype.join.call({length:Math.floor(b-a.v.length)+1},c);
return new Sk.builtin.str(a.v+d)});
Sk.builtin.str.prototype.rjust=new Sk.builtin.func(function(a,b,c){Sk.builtin.pyCheckArgs("rjust",arguments,2,3);if(!Sk.builtin.checkInt(b))throw new Sk.builtin.TypeError("integer argument exepcted, got "+Sk.abstr.typeName(b));if(void 0!==c&&(!Sk.builtin.checkString(c)||1!==c.v.length))throw new Sk.builtin.TypeError("must be char, not "+Sk.abstr.typeName(c));c=void 0===c?" ":c.v;b=Sk.builtin.asnum$(b);if(a.v.length>=b)return a;var d=Array.prototype.join.call({length:Math.floor(b-a.v.length)+1},c);
return new Sk.builtin.str(d+a.v)});
Sk.builtin.str.prototype.center=new Sk.builtin.func(function(a,b,c){Sk.builtin.pyCheckArgs("center",arguments,2,3);if(!Sk.builtin.checkInt(b))throw new Sk.builtin.TypeError("integer argument exepcted, got "+Sk.abstr.typeName(b));if(void 0!==c&&(!Sk.builtin.checkString(c)||1!==c.v.length))throw new Sk.builtin.TypeError("must be char, not "+Sk.abstr.typeName(c));c=void 0===c?" ":c.v;b=Sk.builtin.asnum$(b);if(a.v.length>=b)return a;var d=Array.prototype.join.call({length:Math.floor((b-a.v.length)/2)+
1},c),d=d+a.v+d;d.length<b&&(d+=c);return new Sk.builtin.str(d)});
Sk.builtin.str.prototype.find=new Sk.builtin.func(function(a,b,c,d){Sk.builtin.pyCheckArgs("find",arguments,2,4);if(!Sk.builtin.checkString(b))throw new Sk.builtin.TypeError("expected a character buffer object");if(void 0!==c&&!Sk.builtin.checkInt(c))throw new Sk.builtin.TypeError("slice indices must be integers or None or have an __index__ method");if(void 0!==d&&!Sk.builtin.checkInt(d))throw new Sk.builtin.TypeError("slice indices must be integers or None or have an __index__ method");void 0===
c?c=0:(c=Sk.builtin.asnum$(c),c=0<=c?c:a.v.length+c);void 0===d?d=a.v.length:(d=Sk.builtin.asnum$(d),d=0<=d?d:a.v.length+d);var e=a.v.indexOf(b.v,c);return new Sk.builtin.nmber(e>=c&&e<d?e:-1,Sk.builtin.nmber.int$)});Sk.builtin.str.prototype.index=new Sk.builtin.func(function(a,b,c,d){Sk.builtin.pyCheckArgs("index",arguments,2,4);var e=Sk.misceval.callsim(a.find,a,b,c,d);if(-1===Sk.builtin.asnum$(e))throw new Sk.builtin.ValueError("substring not found");return e});
Sk.builtin.str.prototype.rfind=new Sk.builtin.func(function(a,b,c,d){Sk.builtin.pyCheckArgs("rfind",arguments,2,4);if(!Sk.builtin.checkString(b))throw new Sk.builtin.TypeError("expected a character buffer object");if(void 0!==c&&!Sk.builtin.checkInt(c))throw new Sk.builtin.TypeError("slice indices must be integers or None or have an __index__ method");if(void 0!==d&&!Sk.builtin.checkInt(d))throw new Sk.builtin.TypeError("slice indices must be integers or None or have an __index__ method");void 0===
c?c=0:(c=Sk.builtin.asnum$(c),c=0<=c?c:a.v.length+c);void 0===d?d=a.v.length:(d=Sk.builtin.asnum$(d),d=0<=d?d:a.v.length+d);var e=a.v.lastIndexOf(b.v,d),e=e!==d?e:a.v.lastIndexOf(b.v,d-1);return new Sk.builtin.nmber(e>=c&&e<d?e:-1,Sk.builtin.nmber.int$)});Sk.builtin.str.prototype.rindex=new Sk.builtin.func(function(a,b,c,d){Sk.builtin.pyCheckArgs("rindex",arguments,2,4);var e=Sk.misceval.callsim(a.rfind,a,b,c,d);if(-1===Sk.builtin.asnum$(e))throw new Sk.builtin.ValueError("substring not found");return e});
Sk.builtin.str.prototype.startswith=new Sk.builtin.func(function(a,b){Sk.builtin.pyCheckArgs("startswith",arguments,2,2);Sk.builtin.pyCheckType("tgt","string",Sk.builtin.checkString(b));return Sk.builtin.bool(0==a.v.indexOf(b.v))});Sk.builtin.str.prototype.endswith=new Sk.builtin.func(function(a,b){Sk.builtin.pyCheckArgs("endswith",arguments,2,2);Sk.builtin.pyCheckType("tgt","string",Sk.builtin.checkString(b));return Sk.builtin.bool(-1!==a.v.indexOf(b.v,a.v.length-b.v.length))});
Sk.builtin.str.prototype.replace=new Sk.builtin.func(function(a,b,c,d){Sk.builtin.pyCheckArgs("replace",arguments,3,4);Sk.builtin.pyCheckType("oldS","string",Sk.builtin.checkString(b));Sk.builtin.pyCheckType("newS","string",Sk.builtin.checkString(c));if(void 0!==d&&!Sk.builtin.checkInt(d))throw new Sk.builtin.TypeError("integer argument expected, got "+Sk.abstr.typeName(d));d=Sk.builtin.asnum$(d);var e=RegExp(Sk.builtin.str.re_escape_(b.v),"g");if(void 0===d||0>d)return new Sk.builtin.str(a.v.replace(e,
c.v));var f=0;return new Sk.builtin.str(a.v.replace(e,function(a){f++;return f<=d?c.v:a}))});Sk.builtin.str.prototype.isdigit=new Sk.builtin.func(function(a){Sk.builtin.pyCheckArgs("isdigit",arguments,1,1);if(0===a.v.length)return Sk.builtin.bool(!1);var b;for(b=0;b<a.v.length;b++){var c=a.v.charAt(b);if("0">c||"9"<c)return Sk.builtin.bool(!1)}return Sk.builtin.bool(!0)});Sk.builtin.str.prototype.ob$type=Sk.builtin.type.makeIntoTypeObj("str",Sk.builtin.str);
Sk.builtin.str.prototype.nb$remainder=function(a){a.constructor===Sk.builtin.tuple||void 0!==a.mp$subscript&&a.constructor!==Sk.builtin.str||(a=new Sk.builtin.tuple([a]));var b=0,c=this.v.replace(/%(\([a-zA-Z0-9]+\))?([#0 +\-]+)?(\*|[0-9]+)?(\.(\*|[0-9]+))?[hlL]?([diouxXeEfFgGcrs%])/g,function(c,e,f,g,h,k,l){g=Sk.builtin.asnum$(g);h=Sk.builtin.asnum$(h);var m;if(void 0===e||""===e)m=b++;""===h&&(h=void 0);var n=!1,p=!1,q=!1,r=!1,s=!1;f&&(-1!==f.indexOf("-")?p=!0:-1!==f.indexOf("0")&&(n=!0),-1!==f.indexOf("+")?
r=!0:-1!==f.indexOf(" ")&&(q=!0),s=-1!==f.indexOf("#"));h&&(h=parseInt(h.substr(1),10));f=function(a,b){b=Sk.builtin.asnum$(b);var c,d,e=!1;"number"===typeof a?(0>a&&(a=-a,e=!0),d=a.toString(b)):a instanceof Sk.builtin.nmber?(d=a.str$(b,!1),2<d.length&&".0"===d.substr(-2)&&(d=d.substr(0,d.length-2)),e=a.nb$isnegative()):a instanceof Sk.builtin.lng&&(d=a.str$(b,!1),e=a.nb$isnegative());goog.asserts.assert(void 0!==d,"unhandled number format");var f=!1;if(h)for(c=d.length;c<h;++c)d="0"+d,f=!0;c="";
e?c="-":r?c="+"+c:q&&(c=" "+c);s&&(16===b?c+="0x":8!==b||(f||"0"===d)||(c+="0"));return[c,d]};c=function(a){var b=a[0];a=a[1];var c;if(g)if(g=parseInt(g,10),c=a.length+b.length,n)for(;c<g;++c)a="0"+a;else if(p)for(;c<g;++c)a+=" ";else for(;c<g;++c)b=" "+b;return b+a};if(a.constructor===Sk.builtin.tuple)e=a.v[m];else if(void 0!==a.mp$subscript)e=e.substring(1,e.length-1),e=a.mp$subscript(new Sk.builtin.str(e));else throw new Sk.builtin.AttributeError(a.tp$name+" instance has no attribute 'mp$subscript'");
switch(l){case "d":case "i":return c(f(e,10));case "o":return c(f(e,8));case "x":return c(f(e,16));case "X":return c(f(e,16)).toUpperCase();case "f":case "F":case "e":case "E":case "g":case "G":e=Sk.builtin.asnum$(e);"string"===typeof e&&(e=Number(e));if(Infinity===e)return"inf";if(-Infinity===e)return"-inf";if(isNaN(e))return"nan";m=["toExponential","toFixed","toPrecision"]["efg".indexOf(l.toLowerCase())];if(void 0===h||""===h)if("e"===l||"E"===l)h=6;else if("f"===l||"F"===l)h=7;e=e[m](h);-1!=="EFG".indexOf(l)&&
(e=e.toUpperCase());return c(["",e]);case "c":if("number"===typeof e)return String.fromCharCode(e);if(e instanceof Sk.builtin.nmber)return String.fromCharCode(e.v);if(e instanceof Sk.builtin.lng)return String.fromCharCode(e.str$(10,!1)[0]);if(e.constructor===Sk.builtin.str)return e.v.substr(0,1);throw new Sk.builtin.TypeError("an integer is required");case "r":return l=Sk.builtin.repr(e),h?l.v.substr(0,h):l.v;case "s":return l=new Sk.builtin.str(e),h?l.v.substr(0,h):l.v;case "%":return"%"}});return new Sk.builtin.str(c)};Sk.builtin.tuple=function(a){if(!(this instanceof Sk.builtin.tuple))return new Sk.builtin.tuple(a);void 0===a&&(a=[]);if("[object Array]"===Object.prototype.toString.apply(a))this.v=a;else if(a.tp$iter){this.v=[];a=a.tp$iter();for(var b=a.tp$iternext();void 0!==b;b=a.tp$iternext())this.v.push(b)}else throw new Sk.builtin.ValueError("expecting Array or iterable");this.__class__=Sk.builtin.tuple;this.v=this.v;return this};Sk.builtin.tuple.prototype.tp$name="tuple";
Sk.builtin.tuple.prototype.$r=function(){if(0===this.v.length)return new Sk.builtin.str("()");for(var a=[],b=0;b<this.v.length;++b)a[b]=Sk.misceval.objectRepr(this.v[b]).v;a=a.join(", ");1===this.v.length&&(a+=",");return new Sk.builtin.str("("+a+")")};
Sk.builtin.tuple.prototype.mp$subscript=function(a){if(Sk.misceval.isIndex(a)){var b=Sk.misceval.asIndex(a);if(void 0!==b){0>b&&(b=this.v.length+b);if(0>b||b>=this.v.length)throw new Sk.builtin.IndexError("tuple index out of range");return this.v[b]}}else if(a instanceof Sk.builtin.slice){var c=[];a.sssiter$(this,function(a,b){c.push(b.v[a])});return new Sk.builtin.tuple(c)}throw new Sk.builtin.TypeError("tuple indices must be integers, not "+Sk.abstr.typeName(a));};
Sk.builtin.tuple.prototype.tp$hash=function(){for(var a=1000003,b=3430008,c=this.v.length,d=0;d<c;++d){var e=Sk.builtin.hash(this.v[d]).v;if(-1===e)return new Sk.builtin.nmber(-1,Sk.builtin.nmber.int$);b=(b^e)*a;a+=82520+c+c}b+=97531;-1===b&&(b=-2);return new Sk.builtin.nmber(b|0,Sk.builtin.nmber.int$)};Sk.builtin.tuple.prototype.sq$repeat=function(a){a=Sk.builtin.asnum$(a);for(var b=[],c=0;c<a;++c)for(var d=0;d<this.v.length;++d)b.push(this.v[d]);return new Sk.builtin.tuple(b)};
Sk.builtin.tuple.prototype.nb$multiply=Sk.builtin.tuple.prototype.sq$repeat;Sk.builtin.tuple.prototype.nb$inplace_multiply=Sk.builtin.tuple.prototype.sq$repeat;Sk.builtin.tuple.prototype.ob$type=Sk.builtin.type.makeIntoTypeObj("tuple",Sk.builtin.tuple);Sk.builtin.tuple.prototype.tp$iter=function(){var a={tp$iter:function(){return a},$obj:this,$index:0,tp$iternext:function(){return a.$index>=a.$obj.v.length?void 0:a.$obj.v[a.$index++]}};return a};
Sk.builtin.tuple.prototype.__iter__=new Sk.builtin.func(function(a){Sk.builtin.pyCheckArgs("__iter__",arguments,1,1);return a.tp$iter()});Sk.builtin.tuple.prototype.tp$getattr=Sk.builtin.object.prototype.GenericGetAttr;
Sk.builtin.tuple.prototype.tp$richcompare=function(a,b){if(!a.__class__||a.__class__!=Sk.builtin.tuple)return"Eq"===b?!1:"NotEq"===b?!0:!1;var c=this.v;a=a.v;var d=c.length,e=a.length,f;for(f=0;f<d&&f<e&&Sk.misceval.richCompareBool(c[f],a[f],"Eq");++f);if(f>=d||f>=e)switch(b){case "Lt":return d<e;case "LtE":return d<=e;case "Eq":return d===e;case "NotEq":return d!==e;case "Gt":return d>e;case "GtE":return d>=e;default:goog.asserts.fail()}return"Eq"===b?!1:"NotEq"===b?!0:Sk.misceval.richCompareBool(c[f],
a[f],b)};Sk.builtin.tuple.prototype.sq$concat=function(a){if(a.__class__!=Sk.builtin.tuple)throw a='can only concatenate tuple (not "'+(Sk.abstr.typeName(a)+'") to tuple'),new Sk.builtin.TypeError(a);return new Sk.builtin.tuple(this.v.concat(a.v))};Sk.builtin.tuple.prototype.nb$add=Sk.builtin.tuple.prototype.sq$concat;Sk.builtin.tuple.prototype.nb$inplace_add=Sk.builtin.tuple.prototype.sq$concat;Sk.builtin.tuple.prototype.sq$length=function(){return this.v.length};
Sk.builtin.tuple.prototype.index=new Sk.builtin.func(function(a,b){for(var c=a.v.length,d=a.v,e=0;e<c;++e)if(Sk.misceval.richCompareBool(d[e],b,"Eq"))return Sk.builtin.assk$(e,Sk.builtin.nmber.int$);throw new Sk.builtin.ValueError("tuple.index(x): x not in tuple");});Sk.builtin.tuple.prototype.count=new Sk.builtin.func(function(a,b){for(var c=a.v.length,d=a.v,e=0,f=0;f<c;++f)Sk.misceval.richCompareBool(d[f],b,"Eq")&&(e+=1);return new Sk.builtin.nmber(e,Sk.builtin.nmber.int$)});
goog.exportSymbol("Sk.builtin.tuple",Sk.builtin.tuple);Sk.builtin.dict=function(a){if(!(this instanceof Sk.builtin.dict))return new Sk.builtin.dict(a);void 0===a&&(a=[]);this.size=0;if("[object Array]"===Object.prototype.toString.apply(a))for(var b=0;b<a.length;b+=2)this.mp$ass_subscript(a[b],a[b+1]);else if(a instanceof Sk.builtin.dict)for(var c=a.tp$iter(),b=c.tp$iternext();void 0!==b;b=c.tp$iternext()){var d=a.mp$subscript(b);void 0===d&&(d=null);this.mp$ass_subscript(b,d)}else if(a.tp$iter)for(c=a.tp$iter(),b=c.tp$iternext();void 0!==b;b=c.tp$iternext())if(b.mp$subscript)this.mp$ass_subscript(b.mp$subscript(0),
b.mp$subscript(1));else throw new Sk.builtin.TypeError("element "+this.size+" is not a sequence");else throw new Sk.builtin.TypeError("object is not iterable");this.__class__=Sk.builtin.dict;return this};Sk.builtin.dict.prototype.ob$type=Sk.builtin.type.makeIntoTypeObj("dict",Sk.builtin.dict);var kf=Sk.builtin.hash;Sk.builtin.dict.prototype.key$lookup=function(a,b){var c,d,e;for(e=0;e<a.items.length;e++)if(c=a.items[e],d=Sk.misceval.richCompareBool(c.lhs,b,"Eq"))return c;return null};
Sk.builtin.dict.prototype.key$pop=function(a,b){var c,d,e;for(e=0;e<a.items.length;e++)if(c=a.items[e],d=Sk.misceval.richCompareBool(c.lhs,b,"Eq"))return a.items.splice(e,1),this.size-=1,c};Sk.builtin.dict.prototype.mp$lookup=function(a){var b=this[kf(a).v];if(void 0!==b&&(a=this.key$lookup(b,a)))return a.rhs};Sk.builtin.dict.prototype.mp$subscript=function(a){var b=this.mp$lookup(a);if(void 0!==b)return b;a=new Sk.builtin.str(a);throw new Sk.builtin.KeyError(a.v);};
Sk.builtin.dict.prototype.sq$contains=function(a){return void 0!==this.mp$lookup(a)};Sk.builtin.dict.prototype.mp$ass_subscript=function(a,b){var c=kf(a),d=this[c.v];void 0===d?(d={$hash:c,items:[{lhs:a,rhs:b}]},this[c.v]=d,this.size+=1):(c=this.key$lookup(d,a))?c.rhs=b:(d.items.push({lhs:a,rhs:b}),this.size+=1)};
Sk.builtin.dict.prototype.mp$del_subscript=function(a){var b=this[kf(a).v];if(void 0!==b&&(b=this.key$pop(b,a),void 0!==b))return;a=new Sk.builtin.str(a);throw new Sk.builtin.KeyError(a.v);};
Sk.builtin.dict.prototype.tp$iter=function(){var a=[],b;for(b in this)if(this.hasOwnProperty(b)){var c=this[b];if(c&&void 0!==c.$hash)for(var d=0;d<c.items.length;d++)a.push(c.items[d].lhs)}var e={tp$iter:function(){return e},$obj:this,$index:0,$keys:a,tp$iternext:function(){return e.$index>=e.$keys.length?void 0:e.$keys[e.$index++]}};return e};Sk.builtin.dict.prototype.__iter__=new Sk.builtin.func(function(a){Sk.builtin.pyCheckArgs("__iter__",arguments,1,1);return a.tp$iter()});
Sk.builtin.dict.prototype.$r=function(){for(var a=[],b=this.tp$iter(),c=b.tp$iternext();void 0!==c;c=b.tp$iternext()){var d=this.mp$subscript(c);void 0===d&&(d=null);a.push(Sk.misceval.objectRepr(c).v+": "+Sk.misceval.objectRepr(d).v)}return new Sk.builtin.str("{"+a.join(", ")+"}")};Sk.builtin.dict.prototype.mp$length=function(){return this.size};Sk.builtin.dict.prototype.tp$getattr=Sk.builtin.object.prototype.GenericGetAttr;Sk.builtin.dict.prototype.tp$hash=Sk.builtin.object.prototype.HashNotImplemented;
Sk.builtin.dict.prototype.tp$richcompare=function(a,b){if(this===a&&Sk.misceval.opAllowsEquality(b))return!0;switch(b){case "Lt":return;case "LtE":return;case "Eq":break;case "NotEq":break;case "Gt":return;case "GtE":return;default:goog.asserts.fail()}if(!(a instanceof Sk.builtin.dict)||this.size!==a.size)return"Eq"===b?!1:!0;for(var c=this.tp$iter(),d=c.tp$iternext();void 0!==d;d=c.tp$iternext()){var e=this.mp$subscript(d),d=a.mp$subscript(d);if(!Sk.misceval.richCompareBool(e,d,"Eq"))return"Eq"===
b?!1:!0}return"Eq"===b?!0:!1};Sk.builtin.dict.prototype.get=new Sk.builtin.func(function(a,b,c){void 0===c&&(c=Sk.builtin.none.none$);a=a.mp$lookup(b);void 0===a&&(a=c);return a});Sk.builtin.dict.prototype.pop=new Sk.builtin.func(function(a,b,c){var d=kf(b),d=a[d.v];if(void 0!==d&&(a=a.key$pop(d,b),void 0!==a))return a.rhs;if(void 0!==c)return c;b=new Sk.builtin.str(b);throw new Sk.builtin.KeyError(b.v);});Sk.builtin.dict.prototype.has_key=new Sk.builtin.func(function(a,b){return Sk.builtin.bool(a.sq$contains(b))});
Sk.builtin.dict.prototype.items=new Sk.builtin.func(function(a){for(var b=[],c=a.tp$iter(),d=c.tp$iternext();void 0!==d;d=c.tp$iternext()){var e=a.mp$subscript(d);void 0===e&&(e=null);b.push(new Sk.builtin.tuple([d,e]))}return new Sk.builtin.list(b)});Sk.builtin.dict.prototype.keys=new Sk.builtin.func(function(a){var b=[];a=a.tp$iter();for(var c=a.tp$iternext();void 0!==c;c=a.tp$iternext())b.push(c);return new Sk.builtin.list(b)});
Sk.builtin.dict.prototype.values=new Sk.builtin.func(function(a){for(var b=[],c=a.tp$iter(),d=c.tp$iternext();void 0!==d;d=c.tp$iternext())d=a.mp$subscript(d),void 0===d&&(d=null),b.push(d);return new Sk.builtin.list(b)});Sk.builtin.dict.prototype.tp$name="dict";goog.exportSymbol("Sk.builtin.dict",Sk.builtin.dict);Sk.builtin.biginteger=function(a,b,c){null!=a&&("number"==typeof a?this.fromNumber(a,b,c):null==b&&"string"!=typeof a?this.fromString(a,256):this.fromString(a,b))};Sk.builtin.biginteger.canary=0xdeadbeefcafe;Sk.builtin.biginteger.j_lm=15715070==(Sk.builtin.biginteger.canary&16777215);Sk.builtin.biginteger.nbi=function(){return new Sk.builtin.biginteger(null)};Sk.builtin.biginteger.prototype.am1=function(a,b,c,d,e,f){for(;0<=--f;){var g=b*this[a++]+c[d]+e;e=Math.floor(g/67108864);c[d++]=g&67108863}return e};
Sk.builtin.biginteger.prototype.am2=function(a,b,c,d,e,f){var g=b&32767;for(b>>=15;0<=--f;){var h=this[a]&32767,k=this[a++]>>15,l=b*h+k*g,h=g*h+((l&32767)<<15)+c[d]+(e&1073741823);e=(h>>>30)+(l>>>15)+b*k+(e>>>30);c[d++]=h&1073741823}return e};Sk.builtin.biginteger.prototype.am3=function(a,b,c,d,e,f){var g=b&16383;for(b>>=14;0<=--f;){var h=this[a]&16383,k=this[a++]>>14,l=b*h+k*g,h=g*h+((l&16383)<<14)+c[d]+e;e=(h>>28)+(l>>14)+b*k;c[d++]=h&268435455}return e};Sk.builtin.biginteger.prototype.am=Sk.builtin.biginteger.prototype.am3;
Sk.builtin.biginteger.dbits=28;Sk.builtin.biginteger.prototype.DB=Sk.builtin.biginteger.dbits;Sk.builtin.biginteger.prototype.DM=(1<<Sk.builtin.biginteger.dbits)-1;Sk.builtin.biginteger.prototype.DV=1<<Sk.builtin.biginteger.dbits;Sk.builtin.biginteger.BI_FP=52;Sk.builtin.biginteger.prototype.FV=Math.pow(2,Sk.builtin.biginteger.BI_FP);Sk.builtin.biginteger.prototype.F1=Sk.builtin.biginteger.BI_FP-Sk.builtin.biginteger.dbits;Sk.builtin.biginteger.prototype.F2=2*Sk.builtin.biginteger.dbits-Sk.builtin.biginteger.BI_FP;
Sk.builtin.biginteger.BI_RM="0123456789abcdefghijklmnopqrstuvwxyz";Sk.builtin.biginteger.BI_RC=[];var rr,vv;rr=48;for(vv=0;9>=vv;++vv)Sk.builtin.biginteger.BI_RC[rr++]=vv;rr=97;for(vv=10;36>vv;++vv)Sk.builtin.biginteger.BI_RC[rr++]=vv;rr=65;for(vv=10;36>vv;++vv)Sk.builtin.biginteger.BI_RC[rr++]=vv;Sk.builtin.biginteger.int2char=function(a){return Sk.builtin.biginteger.BI_RM.charAt(a)};Sk.builtin.biginteger.intAt=function(a,b){var c=Sk.builtin.biginteger.BI_RC[a.charCodeAt(b)];return null==c?-1:c};
Sk.builtin.biginteger.prototype.bnpCopyTo=function(a){for(var b=this.t-1;0<=b;--b)a[b]=this[b];a.t=this.t;a.s=this.s};Sk.builtin.biginteger.prototype.bnpFromInt=function(a){this.t=1;this.s=0>a?-1:0;0<a?this[0]=a:-1>a?this[0]=a+this.DV:this.t=0};Sk.builtin.biginteger.nbv=function(a){var b=new Sk.builtin.biginteger(null);b.bnpFromInt(a);return b};
Sk.builtin.biginteger.prototype.bnpFromString=function(a,b){var c;if(16==b)c=4;else if(8==b)c=3;else if(256==b)c=8;else if(2==b)c=1;else if(32==b)c=5;else if(4==b)c=2;else{this.fromRadix(a,b);return}this.s=this.t=0;for(var d=a.length,e=!1,f=0;0<=--d;){var g=8==c?a[d]&255:Sk.builtin.biginteger.intAt(a,d);0>g?"-"==a.charAt(d)&&(e=!0):(e=!1,0==f?this[this.t++]=g:f+c>this.DB?(this[this.t-1]|=(g&(1<<this.DB-f)-1)<<f,this[this.t++]=g>>this.DB-f):this[this.t-1]|=g<<f,f+=c,f>=this.DB&&(f-=this.DB))}8==c&&
0!=(a[0]&128)&&(this.s=-1,0<f&&(this[this.t-1]|=(1<<this.DB-f)-1<<f));this.clamp();e&&Sk.builtin.biginteger.ZERO.subTo(this,this)};Sk.builtin.biginteger.prototype.bnpClamp=function(){for(var a=this.s&this.DM;0<this.t&&this[this.t-1]==a;)--this.t};
Sk.builtin.biginteger.prototype.bnToString=function(a){if(0>this.s)return"-"+this.negate().toString(a);if(16==a)a=4;else if(8==a)a=3;else if(2==a)a=1;else if(32==a)a=5;else if(4==a)a=2;else return this.toRadix(a);var b=(1<<a)-1,c,d=!1,e="",f=this.t,g=this.DB-f*this.DB%a;if(0<f--)for(g<this.DB&&0<(c=this[f]>>g)&&(d=!0,e=Sk.builtin.biginteger.int2char(c));0<=f;)g<a?(c=(this[f]&(1<<g)-1)<<a-g,c|=this[--f]>>(g+=this.DB-a)):(c=this[f]>>(g-=a)&b,0>=g&&(g+=this.DB,--f)),0<c&&(d=!0),d&&(e+=Sk.builtin.biginteger.int2char(c));
return d?e:"0"};Sk.builtin.biginteger.prototype.bnNegate=function(){var a=Sk.builtin.biginteger.nbi();Sk.builtin.biginteger.ZERO.subTo(this,a);return a};Sk.builtin.biginteger.prototype.bnAbs=function(){return 0>this.s?this.negate():this};Sk.builtin.biginteger.prototype.bnCompareTo=function(a){var b=this.s-a.s;if(0!=b)return b;var c=this.t,b=c-a.t;if(0!=b)return 0>this.s?-b:b;for(;0<=--c;)if(0!=(b=this[c]-a[c]))return b;return 0};
Sk.builtin.biginteger.nbits=function(a){var b=1,c;0!=(c=a>>>16)&&(a=c,b+=16);0!=(c=a>>8)&&(a=c,b+=8);0!=(c=a>>4)&&(a=c,b+=4);0!=(c=a>>2)&&(a=c,b+=2);0!=a>>1&&(b+=1);return b};Sk.builtin.biginteger.prototype.bnBitLength=function(){return 0>=this.t?0:this.DB*(this.t-1)+Sk.builtin.biginteger.nbits(this[this.t-1]^this.s&this.DM)};Sk.builtin.biginteger.prototype.bnpDLShiftTo=function(a,b){var c;for(c=this.t-1;0<=c;--c)b[c+a]=this[c];for(c=a-1;0<=c;--c)b[c]=0;b.t=this.t+a;b.s=this.s};
Sk.builtin.biginteger.prototype.bnpDRShiftTo=function(a,b){for(var c=a;c<this.t;++c)b[c-a]=this[c];b.t=Math.max(this.t-a,0);b.s=this.s};Sk.builtin.biginteger.prototype.bnpLShiftTo=function(a,b){var c=a%this.DB,d=this.DB-c,e=(1<<d)-1,f=Math.floor(a/this.DB),g=this.s<<c&this.DM,h;for(h=this.t-1;0<=h;--h)b[h+f+1]=this[h]>>d|g,g=(this[h]&e)<<c;for(h=f-1;0<=h;--h)b[h]=0;b[f]=g;b.t=this.t+f+1;b.s=this.s;b.clamp()};
Sk.builtin.biginteger.prototype.bnpRShiftTo=function(a,b){b.s=this.s;var c=Math.floor(a/this.DB);if(c>=this.t)b.t=0;else{var d=a%this.DB,e=this.DB-d,f=(1<<d)-1;b[0]=this[c]>>d;for(var g=c+1;g<this.t;++g)b[g-c-1]|=(this[g]&f)<<e,b[g-c]=this[g]>>d;0<d&&(b[this.t-c-1]|=(this.s&f)<<e);b.t=this.t-c;b.clamp()}};
Sk.builtin.biginteger.prototype.bnpSubTo=function(a,b){for(var c=0,d=0,e=Math.min(a.t,this.t);c<e;)d+=this[c]-a[c],b[c++]=d&this.DM,d>>=this.DB;if(a.t<this.t){for(d-=a.s;c<this.t;)d+=this[c],b[c++]=d&this.DM,d>>=this.DB;d+=this.s}else{for(d+=this.s;c<a.t;)d-=a[c],b[c++]=d&this.DM,d>>=this.DB;d-=a.s}b.s=0>d?-1:0;-1>d?b[c++]=this.DV+d:0<d&&(b[c++]=d);b.t=c;b.clamp()};
Sk.builtin.biginteger.prototype.bnpMultiplyTo=function(a,b){var c=this.abs(),d=a.abs(),e=c.t;for(b.t=e+d.t;0<=--e;)b[e]=0;for(e=0;e<d.t;++e)b[e+c.t]=c.am(0,d[e],b,e,0,c.t);b.s=0;b.clamp();this.s!=a.s&&Sk.builtin.biginteger.ZERO.subTo(b,b)};
Sk.builtin.biginteger.prototype.bnpSquareTo=function(a){for(var b=this.abs(),c=a.t=2*b.t;0<=--c;)a[c]=0;for(c=0;c<b.t-1;++c){var d=b.am(c,b[c],a,2*c,0,1);(a[c+b.t]+=b.am(c+1,2*b[c],a,2*c+1,d,b.t-c-1))>=b.DV&&(a[c+b.t]-=b.DV,a[c+b.t+1]=1)}0<a.t&&(a[a.t-1]+=b.am(c,b[c],a,2*c,0,1));a.s=0;a.clamp()};
Sk.builtin.biginteger.prototype.bnpDivRemTo=function(a,b,c){var d=a.abs();if(!(0>=d.t)){var e=this.abs();if(e.t<d.t)null!=b&&b.fromInt(0),null!=c&&this.copyTo(c);else{null==c&&(c=Sk.builtin.biginteger.nbi());var f=Sk.builtin.biginteger.nbi(),g=this.s;a=a.s;var h=this.DB-Sk.builtin.biginteger.nbits(d[d.t-1]);0<h?(d.lShiftTo(h,f),e.lShiftTo(h,c)):(d.copyTo(f),e.copyTo(c));d=f.t;e=f[d-1];if(0!=e){var k=e*(1<<this.F1)+(1<d?f[d-2]>>this.F2:0),l=this.FV/k,k=(1<<this.F1)/k,m=1<<this.F2,n=c.t,p=n-d,q=null==
b?Sk.builtin.biginteger.nbi():b;f.dlShiftTo(p,q);0<=c.compareTo(q)&&(c[c.t++]=1,c.subTo(q,c));Sk.builtin.biginteger.ONE.dlShiftTo(d,q);for(q.subTo(f,f);f.t<d;)f[f.t++]=0;for(;0<=--p;){var r=c[--n]==e?this.DM:Math.floor(c[n]*l+(c[n-1]+m)*k);if((c[n]+=f.am(0,r,c,p,0,d))<r)for(f.dlShiftTo(p,q),c.subTo(q,c);c[n]<--r;)c.subTo(q,c)}null!=b&&(c.drShiftTo(d,b),g!=a&&Sk.builtin.biginteger.ZERO.subTo(b,b));c.t=d;c.clamp();0<h&&c.rShiftTo(h,c);0>g&&Sk.builtin.biginteger.ZERO.subTo(c,c)}}}};
Sk.builtin.biginteger.prototype.bnMod=function(a){var b=Sk.builtin.biginteger.nbi();this.abs().divRemTo(a,null,b);0>this.s&&0<b.compareTo(Sk.builtin.biginteger.ZERO)&&a.subTo(b,b);return b};Sk.builtin.biginteger.Classic=function(a){this.m=a};Sk.builtin.biginteger.prototype.cConvert=function(a){return 0>a.s||0<=a.compareTo(this.m)?a.mod(this.m):a};Sk.builtin.biginteger.prototype.cRevert=function(a){return a};Sk.builtin.biginteger.prototype.cReduce=function(a){a.divRemTo(this.m,null,a)};
Sk.builtin.biginteger.prototype.cMulTo=function(a,b,c){a.multiplyTo(b,c);this.reduce(c)};Sk.builtin.biginteger.prototype.cSqrTo=function(a,b){a.squareTo(b);this.reduce(b)};Sk.builtin.biginteger.Classic.prototype.convert=Sk.builtin.biginteger.prototype.cConvert;Sk.builtin.biginteger.Classic.prototype.revert=Sk.builtin.biginteger.prototype.cRevert;Sk.builtin.biginteger.Classic.prototype.reduce=Sk.builtin.biginteger.prototype.cReduce;Sk.builtin.biginteger.Classic.prototype.mulTo=Sk.builtin.biginteger.prototype.cMulTo;
Sk.builtin.biginteger.Classic.prototype.sqrTo=Sk.builtin.biginteger.prototype.cSqrTo;Sk.builtin.biginteger.prototype.bnpInvDigit=function(){if(1>this.t)return 0;var a=this[0];if(0==(a&1))return 0;var b=a&3,b=b*(2-(a&15)*b)&15,b=b*(2-(a&255)*b)&255,b=b*(2-((a&65535)*b&65535))&65535,b=b*(2-a*b%this.DV)%this.DV;return 0<b?this.DV-b:-b};Sk.builtin.biginteger.Montgomery=function(a){this.m=a;this.mp=a.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<a.DB-15)-1;this.mt2=2*a.t};
Sk.builtin.biginteger.prototype.montConvert=function(a){var b=Sk.builtin.biginteger.nbi();a.abs().dlShiftTo(this.m.t,b);b.divRemTo(this.m,null,b);0>a.s&&0<b.compareTo(Sk.builtin.biginteger.ZERO)&&this.m.subTo(b,b);return b};Sk.builtin.biginteger.prototype.montRevert=function(a){var b=Sk.builtin.biginteger.nbi();a.copyTo(b);this.reduce(b);return b};
Sk.builtin.biginteger.prototype.montReduce=function(a){for(;a.t<=this.mt2;)a[a.t++]=0;for(var b=0;b<this.m.t;++b){var c=a[b]&32767,d=c*this.mpl+((c*this.mph+(a[b]>>15)*this.mpl&this.um)<<15)&a.DM,c=b+this.m.t;for(a[c]+=this.m.am(0,d,a,b,0,this.m.t);a[c]>=a.DV;)a[c]-=a.DV,a[++c]++}a.clamp();a.drShiftTo(this.m.t,a);0<=a.compareTo(this.m)&&a.subTo(this.m,a)};Sk.builtin.biginteger.prototype.montSqrTo=function(a,b){a.squareTo(b);this.reduce(b)};
Sk.builtin.biginteger.prototype.montMulTo=function(a,b,c){a.multiplyTo(b,c);this.reduce(c)};Sk.builtin.biginteger.Montgomery.prototype.convert=Sk.builtin.biginteger.prototype.montConvert;Sk.builtin.biginteger.Montgomery.prototype.revert=Sk.builtin.biginteger.prototype.montRevert;Sk.builtin.biginteger.Montgomery.prototype.reduce=Sk.builtin.biginteger.prototype.montReduce;Sk.builtin.biginteger.Montgomery.prototype.mulTo=Sk.builtin.biginteger.prototype.montMulTo;
Sk.builtin.biginteger.Montgomery.prototype.sqrTo=Sk.builtin.biginteger.prototype.montSqrTo;Sk.builtin.biginteger.prototype.bnpIsEven=function(){return 0==(0<this.t?this[0]&1:this.s)};Sk.builtin.biginteger.prototype.bnpExp=function(a,b){if(4294967295<a||1>a)return Sk.builtin.biginteger.ONE;var c=Sk.builtin.biginteger.nbi(),d=Sk.builtin.biginteger.nbi(),e=b.convert(this),f=Sk.builtin.biginteger.nbits(a)-1;for(e.copyTo(c);0<=--f;)if(b.sqrTo(c,d),0<(a&1<<f))b.mulTo(d,e,c);else var g=c,c=d,d=g;return b.revert(c)};
Sk.builtin.biginteger.prototype.bnModPowInt=function(a,b){var c;c=256>a||b.isEven()?new Sk.builtin.biginteger.Classic(b):new Sk.builtin.biginteger.Montgomery(b);return this.exp(a,c)};Sk.builtin.biginteger.prototype.copyTo=Sk.builtin.biginteger.prototype.bnpCopyTo;Sk.builtin.biginteger.prototype.fromInt=Sk.builtin.biginteger.prototype.bnpFromInt;Sk.builtin.biginteger.prototype.fromString=Sk.builtin.biginteger.prototype.bnpFromString;Sk.builtin.biginteger.prototype.clamp=Sk.builtin.biginteger.prototype.bnpClamp;
Sk.builtin.biginteger.prototype.dlShiftTo=Sk.builtin.biginteger.prototype.bnpDLShiftTo;Sk.builtin.biginteger.prototype.drShiftTo=Sk.builtin.biginteger.prototype.bnpDRShiftTo;Sk.builtin.biginteger.prototype.lShiftTo=Sk.builtin.biginteger.prototype.bnpLShiftTo;Sk.builtin.biginteger.prototype.rShiftTo=Sk.builtin.biginteger.prototype.bnpRShiftTo;Sk.builtin.biginteger.prototype.subTo=Sk.builtin.biginteger.prototype.bnpSubTo;Sk.builtin.biginteger.prototype.multiplyTo=Sk.builtin.biginteger.prototype.bnpMultiplyTo;
Sk.builtin.biginteger.prototype.squareTo=Sk.builtin.biginteger.prototype.bnpSquareTo;Sk.builtin.biginteger.prototype.divRemTo=Sk.builtin.biginteger.prototype.bnpDivRemTo;Sk.builtin.biginteger.prototype.invDigit=Sk.builtin.biginteger.prototype.bnpInvDigit;Sk.builtin.biginteger.prototype.isEven=Sk.builtin.biginteger.prototype.bnpIsEven;Sk.builtin.biginteger.prototype.exp=Sk.builtin.biginteger.prototype.bnpExp;Sk.builtin.biginteger.prototype.toString=Sk.builtin.biginteger.prototype.bnToString;
Sk.builtin.biginteger.prototype.negate=Sk.builtin.biginteger.prototype.bnNegate;Sk.builtin.biginteger.prototype.abs=Sk.builtin.biginteger.prototype.bnAbs;Sk.builtin.biginteger.prototype.compareTo=Sk.builtin.biginteger.prototype.bnCompareTo;Sk.builtin.biginteger.prototype.bitLength=Sk.builtin.biginteger.prototype.bnBitLength;Sk.builtin.biginteger.prototype.mod=Sk.builtin.biginteger.prototype.bnMod;Sk.builtin.biginteger.prototype.modPowInt=Sk.builtin.biginteger.prototype.bnModPowInt;
Sk.builtin.biginteger.ZERO=Sk.builtin.biginteger.nbv(0);Sk.builtin.biginteger.ONE=Sk.builtin.biginteger.nbv(1);Sk.builtin.biginteger.prototype.bnClone=function(){var a=Sk.builtin.biginteger.nbi();this.copyTo(a);return a};Sk.builtin.biginteger.prototype.bnIntValue=function(){if(0>this.s){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]};
Sk.builtin.biginteger.prototype.bnByteValue=function(){return 0==this.t?this.s:this[0]<<24>>24};Sk.builtin.biginteger.prototype.bnShortValue=function(){return 0==this.t?this.s:this[0]<<16>>16};Sk.builtin.biginteger.prototype.bnpChunkSize=function(a){return Math.floor(Math.LN2*this.DB/Math.log(a))};Sk.builtin.biginteger.prototype.bnSigNum=function(){return 0>this.s?-1:0>=this.t||1==this.t&&0>=this[0]?0:1};
Sk.builtin.biginteger.prototype.bnpToRadix=function(a){null==a&&(a=10);if(0==this.signum()||2>a||36<a)return"0";var b=this.chunkSize(a),b=Math.pow(a,b),c=Sk.builtin.biginteger.nbv(b),d=Sk.builtin.biginteger.nbi(),e=Sk.builtin.biginteger.nbi(),f="";for(this.divRemTo(c,d,e);0<d.signum();)f=(b+e.intValue()).toString(a).substr(1)+f,d.divRemTo(c,d,e);return e.intValue().toString(a)+f};
Sk.builtin.biginteger.prototype.bnpFromRadix=function(a,b){this.fromInt(0);null==b&&(b=10);for(var c=this.chunkSize(b),d=Math.pow(b,c),e=!1,f=0,g=0,h=0;h<a.length;++h){var k=Sk.builtin.biginteger.intAt(a,h);if(0>k){if("-"==a.charAt(h)&&0==this.signum()&&(e=!0),"."==a.charAt(h))break}else g=b*g+k,++f>=c&&(this.dMultiply(d),this.dAddOffset(g,0),g=f=0)}0<f&&(this.dMultiply(Math.pow(b,f)),this.dAddOffset(g,0));e&&Sk.builtin.biginteger.ZERO.subTo(this,this)};
Sk.builtin.biginteger.prototype.bnpFromNumber=function(a,b,c){if("number"==typeof b)if(2>a)this.fromInt(1);else for(this.fromNumber(a,c),this.testBit(a-1)||this.bitwiseTo(Sk.builtin.biginteger.ONE.shiftLeft(a-1),Sk.builtin.biginteger.op_or,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(b);)this.dAddOffset(2,0),this.bitLength()>a&&this.subTo(Sk.builtin.biginteger.ONE.shiftLeft(a-1),this);this.fromString(a+"")};
Sk.builtin.biginteger.prototype.bnToByteArray=function(){var a=this.t,b=[];b[0]=this.s;var c=this.DB-a*this.DB%8,d,e=0;if(0<a--)for(c<this.DB&&(d=this[a]>>c)!=(this.s&this.DM)>>c&&(b[e++]=d|this.s<<this.DB-c);0<=a;)if(8>c?(d=(this[a]&(1<<c)-1)<<8-c,d|=this[--a]>>(c+=this.DB-8)):(d=this[a]>>(c-=8)&255,0>=c&&(c+=this.DB,--a)),0!=(d&128)&&(d|=-256),0==e&&(this.s&128)!=(d&128)&&++e,0<e||d!=this.s)b[e++]=d;return b};Sk.builtin.biginteger.prototype.bnEquals=function(a){return 0==this.compareTo(a)};
Sk.builtin.biginteger.prototype.bnMin=function(a){return 0>this.compareTo(a)?this:a};Sk.builtin.biginteger.prototype.bnMax=function(a){return 0<this.compareTo(a)?this:a};Sk.builtin.biginteger.prototype.bnpBitwiseTo=function(a,b,c){var d,e,f=Math.min(a.t,this.t);for(d=0;d<f;++d)c[d]=b(this[d],a[d]);if(a.t<this.t){e=a.s&this.DM;for(d=f;d<this.t;++d)c[d]=b(this[d],e);c.t=this.t}else{e=this.s&this.DM;for(d=f;d<a.t;++d)c[d]=b(e,a[d]);c.t=a.t}c.s=b(this.s,a.s);c.clamp()};
Sk.builtin.biginteger.op_and=function(a,b){return a&b};Sk.builtin.biginteger.prototype.bnAnd=function(a){var b=Sk.builtin.biginteger.nbi();this.bitwiseTo(a,Sk.builtin.biginteger.op_and,b);return b};Sk.builtin.biginteger.op_or=function(a,b){return a|b};Sk.builtin.biginteger.prototype.bnOr=function(a){var b=Sk.builtin.biginteger.nbi();this.bitwiseTo(a,Sk.builtin.biginteger.op_or,b);return b};Sk.builtin.biginteger.op_xor=function(a,b){return a^b};
Sk.builtin.biginteger.prototype.bnXor=function(a){var b=Sk.builtin.biginteger.nbi();this.bitwiseTo(a,Sk.builtin.biginteger.op_xor,b);return b};Sk.builtin.biginteger.op_andnot=function(a,b){return a&~b};Sk.builtin.biginteger.prototype.bnAndNot=function(a){var b=Sk.builtin.biginteger.nbi();this.bitwiseTo(a,Sk.builtin.biginteger.op_andnot,b);return b};Sk.builtin.biginteger.prototype.bnNot=function(){for(var a=Sk.builtin.biginteger.nbi(),b=0;b<this.t;++b)a[b]=this.DM&~this[b];a.t=this.t;a.s=~this.s;return a};
Sk.builtin.biginteger.prototype.bnShiftLeft=function(a){var b=Sk.builtin.biginteger.nbi();0>a?this.rShiftTo(-a,b):this.lShiftTo(a,b);return b};Sk.builtin.biginteger.prototype.bnShiftRight=function(a){var b=Sk.builtin.biginteger.nbi();0>a?this.lShiftTo(-a,b):this.rShiftTo(a,b);return b};Sk.builtin.biginteger.lbit=function(a){if(0==a)return-1;var b=0;0==(a&65535)&&(a>>=16,b+=16);0==(a&255)&&(a>>=8,b+=8);0==(a&15)&&(a>>=4,b+=4);0==(a&3)&&(a>>=2,b+=2);0==(a&1)&&++b;return b};
Sk.builtin.biginteger.prototype.bnGetLowestSetBit=function(){for(var a=0;a<this.t;++a)if(0!=this[a])return a*this.DB+Sk.builtin.biginteger.lbit(this[a]);return 0>this.s?this.t*this.DB:-1};Sk.builtin.biginteger.cbit=function(a){for(var b=0;0!=a;)a&=a-1,++b;return b};Sk.builtin.biginteger.prototype.bnBitCount=function(){for(var a=0,b=this.s&this.DM,c=0;c<this.t;++c)a+=Sk.builtin.biginteger.cbit(this[c]^b);return a};
Sk.builtin.biginteger.prototype.bnTestBit=function(a){var b=Math.floor(a/this.DB);return b>=this.t?0!=this.s:0!=(this[b]&1<<a%this.DB)};Sk.builtin.biginteger.prototype.bnpChangeBit=function(a,b){var c=Sk.builtin.biginteger.ONE.shiftLeft(a);this.bitwiseTo(c,b,c);return c};Sk.builtin.biginteger.prototype.bnSetBit=function(a){return this.changeBit(a,Sk.builtin.biginteger.op_or)};Sk.builtin.biginteger.prototype.bnClearBit=function(a){return this.changeBit(a,Sk.builtin.biginteger.op_andnot)};
Sk.builtin.biginteger.prototype.bnFlipBit=function(a){return this.changeBit(a,Sk.builtin.biginteger.op_xor)};Sk.builtin.biginteger.prototype.bnpAddTo=function(a,b){for(var c=0,d=0,e=Math.min(a.t,this.t);c<e;)d+=this[c]+a[c],b[c++]=d&this.DM,d>>=this.DB;if(a.t<this.t){for(d+=a.s;c<this.t;)d+=this[c],b[c++]=d&this.DM,d>>=this.DB;d+=this.s}else{for(d+=this.s;c<a.t;)d+=a[c],b[c++]=d&this.DM,d>>=this.DB;d+=a.s}b.s=0>d?-1:0;0<d?b[c++]=d:-1>d&&(b[c++]=this.DV+d);b.t=c;b.clamp()};
Sk.builtin.biginteger.prototype.bnAdd=function(a){var b=Sk.builtin.biginteger.nbi();this.addTo(a,b);return b};Sk.builtin.biginteger.prototype.bnSubtract=function(a){var b=Sk.builtin.biginteger.nbi();this.subTo(a,b);return b};Sk.builtin.biginteger.prototype.bnMultiply=function(a){var b=Sk.builtin.biginteger.nbi();this.multiplyTo(a,b);return b};Sk.builtin.biginteger.prototype.bnDivide=function(a){var b=Sk.builtin.biginteger.nbi();this.divRemTo(a,b,null);return b};
Sk.builtin.biginteger.prototype.bnRemainder=function(a){var b=Sk.builtin.biginteger.nbi();this.divRemTo(a,null,b);return b};Sk.builtin.biginteger.prototype.bnDivideAndRemainder=function(a){var b=Sk.builtin.biginteger.nbi(),c=Sk.builtin.biginteger.nbi();this.divRemTo(a,b,c);return[b,c]};Sk.builtin.biginteger.prototype.bnpDMultiply=function(a){this[this.t]=this.am(0,a-1,this,0,0,this.t);++this.t;this.clamp()};
Sk.builtin.biginteger.prototype.bnpDAddOffset=function(a,b){if(0!=a){for(;this.t<=b;)this[this.t++]=0;for(this[b]+=a;this[b]>=this.DV;)this[b]-=this.DV,++b>=this.t&&(this[this.t++]=0),++this[b]}};Sk.builtin.biginteger.NullExp=function(){};Sk.builtin.biginteger.prototype.nNop=function(a){return a};Sk.builtin.biginteger.prototype.nMulTo=function(a,b,c){a.multiplyTo(b,c)};Sk.builtin.biginteger.prototype.nSqrTo=function(a,b){a.squareTo(b)};Sk.builtin.biginteger.NullExp.prototype.convert=Sk.builtin.biginteger.prototype.nNop;
Sk.builtin.biginteger.NullExp.prototype.revert=Sk.builtin.biginteger.prototype.nNop;Sk.builtin.biginteger.NullExp.prototype.mulTo=Sk.builtin.biginteger.prototype.nMulTo;Sk.builtin.biginteger.NullExp.prototype.sqrTo=Sk.builtin.biginteger.prototype.nSqrTo;Sk.builtin.biginteger.prototype.bnPow=function(a){return this.exp(a,new Sk.builtin.biginteger.NullExp)};
Sk.builtin.biginteger.prototype.bnpMultiplyLowerTo=function(a,b,c){var d=Math.min(this.t+a.t,b);c.s=0;for(c.t=d;0<d;)c[--d]=0;var e;for(e=c.t-this.t;d<e;++d)c[d+this.t]=this.am(0,a[d],c,d,0,this.t);for(e=Math.min(a.t,b);d<e;++d)this.am(0,a[d],c,d,0,b-d);c.clamp()};Sk.builtin.biginteger.prototype.bnpMultiplyUpperTo=function(a,b,c){--b;var d=c.t=this.t+a.t-b;for(c.s=0;0<=--d;)c[d]=0;for(d=Math.max(b-this.t,0);d<a.t;++d)c[this.t+d-b]=this.am(b-d,a[d],c,0,0,this.t+d-b);c.clamp();c.drShiftTo(1,c)};
Sk.builtin.biginteger.Barrett=function(a){this.r2=Sk.builtin.biginteger.nbi();this.q3=Sk.builtin.biginteger.nbi();Sk.builtin.biginteger.ONE.dlShiftTo(2*a.t,this.r2);this.mu=this.r2.divide(a);this.m=a};Sk.builtin.biginteger.prototype.barrettConvert=function(a){if(0>a.s||a.t>2*this.m.t)return a.mod(this.m);if(0>a.compareTo(this.m))return a;var b=Sk.builtin.biginteger.nbi();a.copyTo(b);this.reduce(b);return b};Sk.builtin.biginteger.prototype.barrettRevert=function(a){return a};
Sk.builtin.biginteger.prototype.barrettReduce=function(a){a.drShiftTo(this.m.t-1,this.r2);a.t>this.m.t+1&&(a.t=this.m.t+1,a.clamp());this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);for(this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);0>a.compareTo(this.r2);)a.dAddOffset(1,this.m.t+1);for(a.subTo(this.r2,a);0<=a.compareTo(this.m);)a.subTo(this.m,a)};Sk.builtin.biginteger.prototype.barrettSqrTo=function(a,b){a.squareTo(b);this.reduce(b)};
Sk.builtin.biginteger.prototype.barrettMulTo=function(a,b,c){a.multiplyTo(b,c);this.reduce(c)};Sk.builtin.biginteger.Barrett.prototype.convert=Sk.builtin.biginteger.prototype.barrettConvert;Sk.builtin.biginteger.Barrett.prototype.revert=Sk.builtin.biginteger.prototype.barrettRevert;Sk.builtin.biginteger.Barrett.prototype.reduce=Sk.builtin.biginteger.prototype.barrettReduce;Sk.builtin.biginteger.Barrett.prototype.mulTo=Sk.builtin.biginteger.prototype.barrettMulTo;
Sk.builtin.biginteger.Barrett.prototype.sqrTo=Sk.builtin.biginteger.prototype.barrettSqrTo;
Sk.builtin.biginteger.prototype.bnModPow=function(a,b){var c=a.bitLength(),d,e=Sk.builtin.biginteger.nbv(1),f;if(0>=c)return e;d=18>c?1:48>c?3:144>c?4:768>c?5:6;f=8>c?new Sk.builtin.biginteger.Classic(b):b.isEven()?new Sk.builtin.biginteger.Barrett(b):new Sk.builtin.biginteger.Montgomery(b);var g=[],h=3,k=d-1,l=(1<<d)-1;g[1]=f.convert(this);if(1<d)for(c=Sk.builtin.biginteger.nbi(),f.sqrTo(g[1],c);h<=l;)g[h]=Sk.builtin.biginteger.nbi(),f.mulTo(c,g[h-2],g[h]),h+=2;for(var m=a.t-1,n,p=!0,q=Sk.builtin.biginteger.nbi(),
c=Sk.builtin.biginteger.nbits(a[m])-1;0<=m;){c>=k?n=a[m]>>c-k&l:(n=(a[m]&(1<<c+1)-1)<<k-c,0<m&&(n|=a[m-1]>>this.DB+c-k));for(h=d;0==(n&1);)n>>=1,--h;0>(c-=h)&&(c+=this.DB,--m);if(p)g[n].copyTo(e),p=!1;else{for(;1<h;)f.sqrTo(e,q),f.sqrTo(q,e),h-=2;0<h?f.sqrTo(e,q):(h=e,e=q,q=h);f.mulTo(q,g[n],e)}for(;0<=m&&0==(a[m]&1<<c);)f.sqrTo(e,q),h=e,e=q,q=h,0>--c&&(c=this.DB-1,--m)}return f.revert(e)};
Sk.builtin.biginteger.prototype.bnGCD=function(a){var b=0>this.s?this.negate():this.clone();a=0>a.s?a.negate():a.clone();if(0>b.compareTo(a)){var c=b,b=a;a=c}var c=b.getLowestSetBit(),d=a.getLowestSetBit();if(0>d)return b;c<d&&(d=c);0<d&&(b.rShiftTo(d,b),a.rShiftTo(d,a));for(;0<b.signum();)0<(c=b.getLowestSetBit())&&b.rShiftTo(c,b),0<(c=a.getLowestSetBit())&&a.rShiftTo(c,a),0<=b.compareTo(a)?(b.subTo(a,b),b.rShiftTo(1,b)):(a.subTo(b,a),a.rShiftTo(1,a));0<d&&a.lShiftTo(d,a);return a};
Sk.builtin.biginteger.prototype.bnpModInt=function(a){if(0>=a)return 0;var b=this.DV%a,c=0>this.s?a-1:0;if(0<this.t)if(0==b)c=this[0]%a;else for(var d=this.t-1;0<=d;--d)c=(b*c+this[d])%a;return c};
Sk.builtin.biginteger.prototype.bnModInverse=function(a){var b=a.isEven();if(this.isEven()&&b||0==a.signum())return Sk.builtin.biginteger.ZERO;for(var c=a.clone(),d=this.clone(),e=Sk.builtin.biginteger.nbv(1),f=Sk.builtin.biginteger.nbv(0),g=Sk.builtin.biginteger.nbv(0),h=Sk.builtin.biginteger.nbv(1);0!=c.signum();){for(;c.isEven();)c.rShiftTo(1,c),b?(e.isEven()&&f.isEven()||(e.addTo(this,e),f.subTo(a,f)),e.rShiftTo(1,e)):f.isEven()||f.subTo(a,f),f.rShiftTo(1,f);for(;d.isEven();)d.rShiftTo(1,d),b?
(g.isEven()&&h.isEven()||(g.addTo(this,g),h.subTo(a,h)),g.rShiftTo(1,g)):h.isEven()||h.subTo(a,h),h.rShiftTo(1,h);0<=c.compareTo(d)?(c.subTo(d,c),b&&e.subTo(g,e),f.subTo(h,f)):(d.subTo(c,d),b&&g.subTo(e,g),h.subTo(f,h))}if(0!=d.compareTo(Sk.builtin.biginteger.ONE))return Sk.builtin.biginteger.ZERO;if(0<=h.compareTo(a))return h.subtract(a);if(0>h.signum())h.addTo(a,h);else return h;return 0>h.signum()?h.add(a):h};
Sk.builtin.biginteger.lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509];
Sk.builtin.biginteger.lplim=67108864/Sk.builtin.biginteger.lowprimes[Sk.builtin.biginteger.lowprimes.length-1];
Sk.builtin.biginteger.prototype.bnIsProbablePrime=function(a){var b,c=this.abs();if(1==c.t&&c[0]<=Sk.builtin.biginteger.lowprimes[Sk.builtin.biginteger.lowprimes.length-1]){for(b=0;b<Sk.builtin.biginteger.lowprimes.length;++b)if(c[0]==Sk.builtin.biginteger.lowprimes[b])return!0;return!1}if(c.isEven())return!1;for(b=1;b<Sk.builtin.biginteger.lowprimes.length;){for(var d=Sk.builtin.biginteger.lowprimes[b],e=b+1;e<Sk.builtin.biginteger.lowprimes.length&&d<Sk.builtin.biginteger.lplim;)d*=Sk.builtin.biginteger.lowprimes[e++];
for(d=c.modInt(d);b<e;)if(0==d%Sk.builtin.biginteger.lowprimes[b++])return!1}return c.millerRabin(a)};
Sk.builtin.biginteger.prototype.bnpMillerRabin=function(a){var b=this.subtract(Sk.builtin.biginteger.ONE),c=b.getLowestSetBit();if(0>=c)return!1;var d=b.shiftRight(c);a=a+1>>1;a>Sk.builtin.biginteger.lowprimes.length&&(a=Sk.builtin.biginteger.lowprimes.length);for(var e=Sk.builtin.biginteger.nbi(),f=0;f<a;++f){e.fromInt(Sk.builtin.biginteger.lowprimes[f]);var g=e.modPow(d,this);if(0!=g.compareTo(Sk.builtin.biginteger.ONE)&&0!=g.compareTo(b)){for(var h=1;h++<c&&0!=g.compareTo(b);)if(g=g.modPowInt(2,
this),0==g.compareTo(Sk.builtin.biginteger.ONE))return!1;if(0!=g.compareTo(b))return!1}}return!0};Sk.builtin.biginteger.prototype.isnegative=function(){return 0>this.s};Sk.builtin.biginteger.prototype.ispositive=function(){return 0<=this.s};Sk.builtin.biginteger.prototype.trueCompare=function(a){return 0<=this.s&&0>a.s?1:0>this.s&&0<=a.s?-1:this.compare(a)};Sk.builtin.biginteger.prototype.chunkSize=Sk.builtin.biginteger.prototype.bnpChunkSize;Sk.builtin.biginteger.prototype.toRadix=Sk.builtin.biginteger.prototype.bnpToRadix;
Sk.builtin.biginteger.prototype.fromRadix=Sk.builtin.biginteger.prototype.bnpFromRadix;Sk.builtin.biginteger.prototype.fromNumber=Sk.builtin.biginteger.prototype.bnpFromNumber;Sk.builtin.biginteger.prototype.bitwiseTo=Sk.builtin.biginteger.prototype.bnpBitwiseTo;Sk.builtin.biginteger.prototype.changeBit=Sk.builtin.biginteger.prototype.bnpChangeBit;Sk.builtin.biginteger.prototype.addTo=Sk.builtin.biginteger.prototype.bnpAddTo;Sk.builtin.biginteger.prototype.dMultiply=Sk.builtin.biginteger.prototype.bnpDMultiply;
Sk.builtin.biginteger.prototype.dAddOffset=Sk.builtin.biginteger.prototype.bnpDAddOffset;Sk.builtin.biginteger.prototype.multiplyLowerTo=Sk.builtin.biginteger.prototype.bnpMultiplyLowerTo;Sk.builtin.biginteger.prototype.multiplyUpperTo=Sk.builtin.biginteger.prototype.bnpMultiplyUpperTo;Sk.builtin.biginteger.prototype.modInt=Sk.builtin.biginteger.prototype.bnpModInt;Sk.builtin.biginteger.prototype.millerRabin=Sk.builtin.biginteger.prototype.bnpMillerRabin;Sk.builtin.biginteger.prototype.clone=Sk.builtin.biginteger.prototype.bnClone;
Sk.builtin.biginteger.prototype.intValue=Sk.builtin.biginteger.prototype.bnIntValue;Sk.builtin.biginteger.prototype.byteValue=Sk.builtin.biginteger.prototype.bnByteValue;Sk.builtin.biginteger.prototype.shortValue=Sk.builtin.biginteger.prototype.bnShortValue;Sk.builtin.biginteger.prototype.signum=Sk.builtin.biginteger.prototype.bnSigNum;Sk.builtin.biginteger.prototype.toByteArray=Sk.builtin.biginteger.prototype.bnToByteArray;Sk.builtin.biginteger.prototype.equals=Sk.builtin.biginteger.prototype.bnEquals;
Sk.builtin.biginteger.prototype.compare=Sk.builtin.biginteger.prototype.compareTo;Sk.builtin.biginteger.prototype.min=Sk.builtin.biginteger.prototype.bnMin;Sk.builtin.biginteger.prototype.max=Sk.builtin.biginteger.prototype.bnMax;Sk.builtin.biginteger.prototype.and=Sk.builtin.biginteger.prototype.bnAnd;Sk.builtin.biginteger.prototype.or=Sk.builtin.biginteger.prototype.bnOr;Sk.builtin.biginteger.prototype.xor=Sk.builtin.biginteger.prototype.bnXor;Sk.builtin.biginteger.prototype.andNot=Sk.builtin.biginteger.prototype.bnAndNot;
Sk.builtin.biginteger.prototype.not=Sk.builtin.biginteger.prototype.bnNot;Sk.builtin.biginteger.prototype.shiftLeft=Sk.builtin.biginteger.prototype.bnShiftLeft;Sk.builtin.biginteger.prototype.shiftRight=Sk.builtin.biginteger.prototype.bnShiftRight;Sk.builtin.biginteger.prototype.getLowestSetBit=Sk.builtin.biginteger.prototype.bnGetLowestSetBit;Sk.builtin.biginteger.prototype.bitCount=Sk.builtin.biginteger.prototype.bnBitCount;Sk.builtin.biginteger.prototype.testBit=Sk.builtin.biginteger.prototype.bnTestBit;
Sk.builtin.biginteger.prototype.setBit=Sk.builtin.biginteger.prototype.bnSetBit;Sk.builtin.biginteger.prototype.clearBit=Sk.builtin.biginteger.prototype.bnClearBit;Sk.builtin.biginteger.prototype.flipBit=Sk.builtin.biginteger.prototype.bnFlipBit;Sk.builtin.biginteger.prototype.add=Sk.builtin.biginteger.prototype.bnAdd;Sk.builtin.biginteger.prototype.subtract=Sk.builtin.biginteger.prototype.bnSubtract;Sk.builtin.biginteger.prototype.multiply=Sk.builtin.biginteger.prototype.bnMultiply;
Sk.builtin.biginteger.prototype.divide=Sk.builtin.biginteger.prototype.bnDivide;Sk.builtin.biginteger.prototype.remainder=Sk.builtin.biginteger.prototype.bnRemainder;Sk.builtin.biginteger.prototype.divideAndRemainder=Sk.builtin.biginteger.prototype.bnDivideAndRemainder;Sk.builtin.biginteger.prototype.modPow=Sk.builtin.biginteger.prototype.bnModPow;Sk.builtin.biginteger.prototype.modInverse=Sk.builtin.biginteger.prototype.bnModInverse;Sk.builtin.biginteger.prototype.pow=Sk.builtin.biginteger.prototype.bnPow;
Sk.builtin.biginteger.prototype.gcd=Sk.builtin.biginteger.prototype.bnGCD;Sk.builtin.biginteger.prototype.isProbablePrime=Sk.builtin.biginteger.prototype.bnIsProbablePrime;Sk.builtin.nmber=function(a,b){if(!(this instanceof Sk.builtin.nmber))return new Sk.builtin.nmber(a,b);a instanceof Sk.builtin.str&&(a=a.v);if(a instanceof Sk.builtin.nmber)this.v=a.v,this.skType=a.skType;else if("number"===typeof a)if(this.v=a,void 0===b)this.skType=a>Sk.builtin.nmber.threshold$||a<-Sk.builtin.nmber.threshold$||0!=a%1?Sk.builtin.nmber.float$:Sk.builtin.nmber.int$;else{if(this.skType=b,b===Sk.builtin.nmber.int$&&(a>Sk.builtin.nmber.threshold$||a<-Sk.builtin.nmber.threshold$))return new Sk.builtin.lng(a)}else{if("string"===
typeof a){var c=Sk.numberFromStr(a);void 0!==b&&(c.skType=b);return b===Sk.builtin.nmber.int$&&(c.v>Sk.builtin.nmber.threshold$||c.v<-Sk.builtin.nmber.threshold$-1)?new Sk.builtin.lng(a):c}if(a instanceof Sk.builtin.lng)return Sk.numberFromStr(a.str$(10,!0));if(a instanceof Sk.builtin.biginteger){if(c=Sk.numberFromStr(a.toString()),void 0!==b&&(c.skType=b),b===Sk.builtin.nmber.int$&&(c.v>Sk.builtin.nmber.threshold$||c.v<-Sk.builtin.nmber.threshold$))return new Sk.builtin.lng(a)}else this.v=0,this.skType=
void 0===b?Sk.builtin.nmber.int$:b}return this};Sk.builtin.nmber.prototype.tp$index=function(){return this.v};Sk.builtin.nmber.prototype.tp$hash=function(){return new Sk.builtin.nmber(this.v,Sk.builtin.nmber.int$)};Sk.builtin.nmber.prototype.tp$name="number";Sk.builtin.nmber.prototype.ob$type=Sk.builtin.type.makeIntoTypeObj("number",Sk.builtin.nmber);Sk.builtin.nmber.threshold$=Math.pow(2,53)-1;Sk.builtin.nmber.float$="float";Sk.builtin.nmber.int$="int";
Sk.builtin.nmber.fromInt$=function(a){return new Sk.builtin.nmber(a,void 0)};
Sk.numberFromStr=function(a){if("inf"==a)return new Sk.builtin.nmber(Infinity,void 0);if("-inf"==a)return new Sk.builtin.nmber(-Infinity,void 0);var b=new Sk.builtin.nmber(0,void 0);if(-1!==a.indexOf(".")||-1!==a.indexOf("e")||-1!==a.indexOf("E"))return b.v=parseFloat(a),b.skType=Sk.builtin.nmber.float$,b;var c=a;"-"===a.charAt(0)&&(c=a.substr(1));a="0"!==c.charAt(0)||"x"!==c.charAt(1)&&"X"!==c.charAt(1)?"0"!==c.charAt(0)||"b"!==c.charAt(1)&&"B"!==c.charAt(1)?"0"===c.charAt(0)?parseInt(a,8):parseInt(a,
10):parseInt(a,2):parseInt(a,16);b.v=a;b.skType=Sk.builtin.nmber.int$;return b};goog.exportSymbol("Sk.numberFromStr",Sk.numberFromStr);Sk.builtin.nmber.prototype.clone=function(){return new Sk.builtin.nmber(this,void 0)};Sk.builtin.nmber.prototype.toFixed=function(a){a=Sk.builtin.asnum$(a);return this.v.toFixed(a)};
Sk.builtin.nmber.prototype.nb$add=function(a){var b;"number"===typeof a?a=new Sk.builtin.nmber(a,void 0):a instanceof Sk.builtin.bool&&(a=new Sk.builtin.nmber(Sk.builtin.asnum$(a),void 0));a instanceof Sk.builtin.bool&&(a=new Sk.builtin.nmber(Sk.builtin.asnum$(a),void 0));if(a instanceof Sk.builtin.nmber){b=new Sk.builtin.nmber(this.v+a.v,void 0);if(this.skType===Sk.builtin.nmber.float$||a.skType===Sk.builtin.nmber.float$)b.skType=Sk.builtin.nmber.float$;else if(b.skType=Sk.builtin.nmber.int$,b.v>
Sk.builtin.nmber.threshold$||b.v<-Sk.builtin.nmber.threshold$)b=(new Sk.builtin.lng(this.v)).nb$add(a.v);return b}if(a instanceof Sk.builtin.lng)return b=this.skType===Sk.builtin.nmber.float$?new Sk.builtin.nmber(this.v+parseFloat(a.str$(10,!0)),Sk.builtin.nmber.float$):(new Sk.builtin.lng(this.v)).nb$add(a)};
Sk.builtin.nmber.prototype.nb$subtract=function(a){var b;"number"===typeof a?a=new Sk.builtin.nmber(a,void 0):a instanceof Sk.builtin.bool&&(a=new Sk.builtin.nmber(Sk.builtin.asnum$(a),void 0));a instanceof Sk.builtin.bool&&(a=new Sk.builtin.nmber(Sk.builtin.asnum$(a),void 0));if(a instanceof Sk.builtin.nmber){b=new Sk.builtin.nmber(this.v-a.v,void 0);if(this.skType===Sk.builtin.nmber.float$||a.skType===Sk.builtin.nmber.float$)b.skType=Sk.builtin.nmber.float$;else if(b.skType=Sk.builtin.nmber.int$,
b.v>Sk.builtin.nmber.threshold$||b.v<-Sk.builtin.nmber.threshold$)b=(new Sk.builtin.lng(this.v)).nb$subtract(a.v);return b}if(a instanceof Sk.builtin.lng)return b=this.skType===Sk.builtin.nmber.float$?new Sk.builtin.nmber(this.v-parseFloat(a.str$(10,!0)),Sk.builtin.nmber.float$):(new Sk.builtin.lng(this.v)).nb$subtract(a)};
Sk.builtin.nmber.prototype.nb$multiply=function(a){var b;"number"===typeof a?a=new Sk.builtin.nmber(a,void 0):a instanceof Sk.builtin.bool&&(a=new Sk.builtin.nmber(Sk.builtin.asnum$(a),void 0));a instanceof Sk.builtin.bool&&(a=new Sk.builtin.nmber(Sk.builtin.asnum$(a),void 0));if(a instanceof Sk.builtin.nmber){b=new Sk.builtin.nmber(this.v*a.v,void 0);if(this.skType===Sk.builtin.nmber.float$||a.skType===Sk.builtin.nmber.float$)b.skType=Sk.builtin.nmber.float$;else if(b.skType=Sk.builtin.nmber.int$,
b.v>Sk.builtin.nmber.threshold$||b.v<-Sk.builtin.nmber.threshold$)b=(new Sk.builtin.lng(this.v)).nb$multiply(a.v);return b}if(a instanceof Sk.builtin.lng)return b=this.skType===Sk.builtin.nmber.float$?new Sk.builtin.nmber(this.v*parseFloat(a.str$(10,!0)),Sk.builtin.nmber.float$):(new Sk.builtin.lng(this.v)).nb$multiply(a)};
Sk.builtin.nmber.prototype.nb$divide=function(a){var b;"number"===typeof a?a=new Sk.builtin.nmber(a,void 0):a instanceof Sk.builtin.bool&&(a=new Sk.builtin.nmber(Sk.builtin.asnum$(a),void 0));a instanceof Sk.builtin.bool&&(a=new Sk.builtin.nmber(Sk.builtin.asnum$(a),void 0));if(a instanceof Sk.builtin.nmber){if(0==a.v)throw new Sk.builtin.ZeroDivisionError("integer division or modulo by zero");if(Infinity===this.v)return Infinity===a.v||-Infinity===a.v?new Sk.builtin.nmber(NaN,Sk.builtin.nmber.float$):
a.nb$isnegative()?new Sk.builtin.nmber(-Infinity,Sk.builtin.nmber.float$):new Sk.builtin.nmber(Infinity,Sk.builtin.nmber.float$);if(-Infinity===this.v)return Infinity===a.v||-Infinity===a.v?new Sk.builtin.nmber(NaN,Sk.builtin.nmber.float$):a.nb$isnegative()?new Sk.builtin.nmber(Infinity,Sk.builtin.nmber.float$):new Sk.builtin.nmber(-Infinity,Sk.builtin.nmber.float$);b=new Sk.builtin.nmber(this.v/a.v,void 0);if(this.skType===Sk.builtin.nmber.float$||a.skType===Sk.builtin.nmber.float$||Sk.python3)b.skType=
Sk.builtin.nmber.float$;else if(b.v=Math.floor(b.v),b.skType=Sk.builtin.nmber.int$,b.v>Sk.builtin.nmber.threshold$||b.v<-Sk.builtin.nmber.threshold$)b=(new Sk.builtin.lng(this.v)).nb$divide(a.v);return b}if(a instanceof Sk.builtin.lng){if(0==a.longCompare(Sk.builtin.biginteger.ZERO))throw new Sk.builtin.ZeroDivisionError("integer division or modulo by zero");return Infinity===this.v?a.nb$isnegative()?new Sk.builtin.nmber(-Infinity,Sk.builtin.nmber.float$):new Sk.builtin.nmber(Infinity,Sk.builtin.nmber.float$):
-Infinity===this.v?a.nb$isnegative()?new Sk.builtin.nmber(Infinity,Sk.builtin.nmber.float$):new Sk.builtin.nmber(-Infinity,Sk.builtin.nmber.float$):b=this.skType===Sk.builtin.nmber.float$||Sk.python3?new Sk.builtin.nmber(this.v/parseFloat(a.str$(10,!0)),Sk.builtin.nmber.float$):(new Sk.builtin.lng(this.v)).nb$divide(a)}};
Sk.builtin.nmber.prototype.nb$floor_divide=function(a){var b;"number"===typeof a?a=new Sk.builtin.nmber(a,void 0):a instanceof Sk.builtin.bool&&(a=new Sk.builtin.nmber(Sk.builtin.asnum$(a),void 0));a instanceof Sk.builtin.bool&&(a=new Sk.builtin.nmber(Sk.builtin.asnum$(a),void 0));if(Infinity===this.v||-Infinity===this.v)return new Sk.builtin.nmber(NaN,Sk.builtin.nmber.float$);if(a instanceof Sk.builtin.nmber){if(0==a.v)throw new Sk.builtin.ZeroDivisionError("integer division or modulo by zero");
if(Infinity===a.v)return this.nb$isnegative()?new Sk.builtin.nmber(-1,Sk.builtin.nmber.float$):new Sk.builtin.nmber(0,Sk.builtin.nmber.float$);if(-Infinity===a.v)return this.nb$isnegative()||!this.nb$nonzero()?new Sk.builtin.nmber(0,Sk.builtin.nmber.float$):new Sk.builtin.nmber(-1,Sk.builtin.nmber.float$);b=new Sk.builtin.nmber(Math.floor(this.v/a.v),void 0);if(this.skType===Sk.builtin.nmber.float$||a.skType===Sk.builtin.nmber.float$)b.skType=Sk.builtin.nmber.float$;else if(b.v=Math.floor(b.v),b.skType=
Sk.builtin.nmber.int$,b.v>Sk.builtin.nmber.threshold$||b.v<-Sk.builtin.nmber.threshold$)b=(new Sk.builtin.lng(this.v)).nb$floor_divide(a.v);return b}if(a instanceof Sk.builtin.lng){if(0==a.longCompare(Sk.builtin.biginteger.ZERO))throw new Sk.builtin.ZeroDivisionError("integer division or modulo by zero");this.skType===Sk.builtin.nmber.float$?(b=Math.floor(this.v/parseFloat(a.str$(10,!0))),b=new Sk.builtin.nmber(b,Sk.builtin.nmber.float$)):b=(new Sk.builtin.lng(this.v)).nb$floor_divide(a);return b}};
Sk.builtin.nmber.prototype.nb$remainder=function(a){var b;"number"===typeof a?a=new Sk.builtin.nmber(a,void 0):a instanceof Sk.builtin.bool&&(a=new Sk.builtin.nmber(Sk.builtin.asnum$(a),void 0));a instanceof Sk.builtin.bool&&(a=new Sk.builtin.nmber(Sk.builtin.asnum$(a),void 0));if(a instanceof Sk.builtin.nmber){if(0==a.v)throw new Sk.builtin.ZeroDivisionError("integer division or modulo by zero");if(0==this.v)return this.skType==Sk.builtin.nmber.float$||a.skType==Sk.builtin.nmber.float$?new Sk.builtin.nmber(0,
Sk.builtin.nmber.float$):new Sk.builtin.nmber(0,Sk.builtin.nmber.int$);if(Infinity===a.v)return Infinity===this.v||-Infinity===this.v?new Sk.builtin.nmber(NaN,Sk.builtin.nmber.float$):this.nb$ispositive()?new Sk.builtin.nmber(this.v,Sk.builtin.nmber.float$):new Sk.builtin.nmber(Infinity,Sk.builtin.nmber.float$);b=this.v%a.v;0>this.v?0<a.v&&0>b&&(b+=a.v):0>a.v&&0!=b&&(b+=a.v);if(this.skType===Sk.builtin.nmber.float$||a.skType===Sk.builtin.nmber.float$)b=new Sk.builtin.nmber(b,Sk.builtin.nmber.float$);
else if(b=new Sk.builtin.nmber(b,Sk.builtin.nmber.int$),b.v>Sk.builtin.nmber.threshold$||b.v<-Sk.builtin.nmber.threshold$)b=(new Sk.builtin.lng(this.v)).nb$remainder(a.v);return b}if(a instanceof Sk.builtin.lng){if(0==a.longCompare(Sk.builtin.biginteger.ZERO))throw new Sk.builtin.ZeroDivisionError("integer division or modulo by zero");if(0==this.v)return this.skType===Sk.builtin.nmber.int$?new Sk.builtin.lng(0):new Sk.builtin.nmber(0,this.skType);this.skType===Sk.builtin.nmber.float$?(a=parseFloat(a.str$(10,
!0)),b=this.v%a,0>b?0<a&&0!=b&&(b+=a):0>a&&0!=b&&(b+=a),b=new Sk.builtin.nmber(b,Sk.builtin.nmber.float$)):b=(new Sk.builtin.lng(this.v)).nb$remainder(a);return b}};
Sk.builtin.nmber.prototype.nb$power=function(a){var b;"number"===typeof a?a=new Sk.builtin.nmber(a,void 0):a instanceof Sk.builtin.bool&&(a=new Sk.builtin.nmber(Sk.builtin.asnum$(a),void 0));a instanceof Sk.builtin.bool&&(a=new Sk.builtin.nmber(Sk.builtin.asnum$(a),void 0));if(a instanceof Sk.builtin.nmber){if(0>this.v&&0!=a.v%1)throw new Sk.builtin.NegativePowerError("cannot raise a negative number to a fractional power");if(0==this.v&&0>a.v)throw new Sk.builtin.NegativePowerError("cannot raise zero to a negative power");
b=new Sk.builtin.nmber(Math.pow(this.v,a.v),void 0);if(this.skType===Sk.builtin.nmber.float$||a.skType===Sk.builtin.nmber.float$||0>a.v)b.skType=Sk.builtin.nmber.float$;else if(b.v=Math.floor(b.v),b.skType=Sk.builtin.nmber.int$,b.v>Sk.builtin.nmber.threshold$||b.v<-Sk.builtin.nmber.threshold$)b=(new Sk.builtin.lng(this.v)).nb$power(a.v);if(Infinity===Math.abs(b.v)&&Infinity!==Math.abs(this.v)&&Infinity!==Math.abs(a.v))throw new Sk.builtin.OverflowError("Numerical result out of range");return b}if(a instanceof
Sk.builtin.lng){if(0==this.v&&0>a.longCompare(Sk.builtin.biginteger.ZERO))throw new Sk.builtin.NegativePowerError("cannot raise zero to a negative power");return b=this.skType===Sk.builtin.nmber.float$||a.nb$isnegative()?new Sk.builtin.nmber(Math.pow(this.v,parseFloat(a.str$(10,!0))),Sk.builtin.nmber.float$):(new Sk.builtin.lng(this.v)).nb$power(a)}};
Sk.builtin.nmber.prototype.nb$and=function(a){a=Sk.builtin.asnum$(a);a&=this.v;void 0!==a&&0>a&&(a+=4294967296);if(void 0!==a)return new Sk.builtin.nmber(a,void 0)};Sk.builtin.nmber.prototype.nb$or=function(a){a=Sk.builtin.asnum$(a);a|=this.v;void 0!==a&&0>a&&(a+=4294967296);if(void 0!==a)return new Sk.builtin.nmber(a,void 0)};Sk.builtin.nmber.prototype.nb$xor=function(a){a=Sk.builtin.asnum$(a);a^=this.v;void 0!==a&&0>a&&(a+=4294967296);if(void 0!==a)return new Sk.builtin.nmber(a,void 0)};
Sk.builtin.nmber.prototype.nb$lshift=function(a){var b;a=Sk.builtin.asnum$(a);if(void 0!==a){if(0>a)throw new Sk.builtin.ValueError("negative shift count");b=this.v<<a;if(b<=this.v)return Sk.builtin.lng.fromInt$(this.v).nb$lshift(a)}if(void 0!==b)return new Sk.builtin.nmber(b,this.skType)};
Sk.builtin.nmber.prototype.nb$rshift=function(a){var b;a=Sk.builtin.asnum$(a);if(void 0!==a){if(0>a)throw new Sk.builtin.ValueError("negative shift count");b=this.v>>a;0<this.v&&0>b&&(b&=Math.pow(2,32-a)-1)}if(void 0!==b)return new Sk.builtin.nmber(b,this.skType)};Sk.builtin.nmber.prototype.nb$inplace_add=Sk.builtin.nmber.prototype.nb$add;Sk.builtin.nmber.prototype.nb$inplace_subtract=Sk.builtin.nmber.prototype.nb$subtract;Sk.builtin.nmber.prototype.nb$inplace_multiply=Sk.builtin.nmber.prototype.nb$multiply;
Sk.builtin.nmber.prototype.nb$inplace_divide=Sk.builtin.nmber.prototype.nb$divide;Sk.builtin.nmber.prototype.nb$inplace_remainder=Sk.builtin.nmber.prototype.nb$remainder;Sk.builtin.nmber.prototype.nb$inplace_floor_divide=Sk.builtin.nmber.prototype.nb$floor_divide;Sk.builtin.nmber.prototype.nb$inplace_power=Sk.builtin.nmber.prototype.nb$power;Sk.builtin.nmber.prototype.nb$inplace_and=Sk.builtin.nmber.prototype.nb$and;Sk.builtin.nmber.prototype.nb$inplace_or=Sk.builtin.nmber.prototype.nb$or;
Sk.builtin.nmber.prototype.nb$inplace_xor=Sk.builtin.nmber.prototype.nb$xor;Sk.builtin.nmber.prototype.nb$inplace_lshift=Sk.builtin.nmber.prototype.nb$lshift;Sk.builtin.nmber.prototype.nb$inplace_rshift=Sk.builtin.nmber.prototype.nb$rshift;Sk.builtin.nmber.prototype.nb$negative=function(){return new Sk.builtin.nmber(-this.v,void 0)};Sk.builtin.nmber.prototype.nb$positive=function(){return this.clone()};Sk.builtin.nmber.prototype.nb$nonzero=function(){return 0!==this.v};
Sk.builtin.nmber.prototype.nb$isnegative=function(){return 0>this.v};Sk.builtin.nmber.prototype.nb$ispositive=function(){return 0<=this.v};
Sk.builtin.nmber.prototype.numberCompare=function(a){a instanceof Sk.builtin.bool&&(a=Sk.builtin.asnum$(a));a instanceof Sk.builtin.none&&(a=0);if("number"===typeof a)return this.v-a;if(a instanceof Sk.builtin.nmber)return Infinity==this.v&&Infinity==a.v||-Infinity==this.v&&-Infinity==a.v?0:this.v-a.v;if(a instanceof Sk.builtin.lng){if(this.skType===Sk.builtin.nmber.int$||0==this.v%1)return(new Sk.builtin.lng(this.v)).longCompare(a);a=this.nb$subtract(a);if(a instanceof Sk.builtin.nmber)return a.v;
if(a instanceof Sk.builtin.lng)return a.longCompare(Sk.builtin.biginteger.ZERO)}};Sk.builtin.nmber.prototype.__eq__=function(a,b){return 0==a.numberCompare(b)&&!(b instanceof Sk.builtin.none)};Sk.builtin.nmber.prototype.__ne__=function(a,b){return 0!=a.numberCompare(b)||b instanceof Sk.builtin.none};Sk.builtin.nmber.prototype.__lt__=function(a,b){return 0>a.numberCompare(b)};Sk.builtin.nmber.prototype.__le__=function(a,b){return 0>=a.numberCompare(b)};
Sk.builtin.nmber.prototype.__gt__=function(a,b){return 0<a.numberCompare(b)};Sk.builtin.nmber.prototype.__ge__=function(a,b){return 0<=a.numberCompare(b)};Sk.builtin.nmber.prototype.tp$getattr=Sk.builtin.object.prototype.GenericGetAttr;Sk.builtin.nmber.prototype.$r=function(){return new Sk.builtin.str(this.str$(10,!0))};Sk.builtin.nmber.prototype.tp$str=function(){return new Sk.builtin.str(this.str$(10,!0))};
Sk.builtin.nmber.prototype.str$=function(a,b){if(isNaN(this.v))return"nan";void 0===b&&(b=!0);if(Infinity==this.v)return"inf";if(-Infinity==this.v&&b)return"-inf";if(-Infinity==this.v&&!b)return"inf";var c=b?this.v:Math.abs(this.v),d;if(void 0===a||10===a)if(this.skType==Sk.builtin.nmber.float$){d=c.toPrecision(12);var e=d.indexOf("."),f=c.toString().slice(0,e),e=c.toString().slice(e);for(f.match(/^-?0$/)&&e.slice(1).match(/^0{4,}/)&&(d=12>d.length?c.toExponential():c.toExponential(11));"0"==d.charAt(d.length-
1)&&0>d.indexOf("e");)d=d.substring(0,d.length-1);"."==d.charAt(d.length-1)&&(d+="0");d=d.replace(/\.0+e/,"e","i");d=d.replace(/(e[-+])([1-9])$/,"$10$2");d=d.replace(/0+(e.*)/,"$1")}else d=c.toString();else d=c.toString(a);if(this.skType!==Sk.builtin.nmber.float$)return d;0>d.indexOf(".")&&(0>d.indexOf("E")&&0>d.indexOf("e"))&&(d+=".0");return d};goog.exportSymbol("Sk.builtin.nmber",Sk.builtin.nmber);Sk.builtin.lng=function(a,b){b=Sk.builtin.asnum$(b);if(!(this instanceof Sk.builtin.lng))return new Sk.builtin.lng(a,b);if(void 0===a)return this.biginteger=new Sk.builtin.biginteger(0),this;if(a instanceof Sk.builtin.lng)return this.biginteger=a.biginteger.clone(),this;if(a instanceof Sk.builtin.biginteger)return this.biginteger=a,this;if(a instanceof String)return Sk.longFromStr(a,b);if(a instanceof Sk.builtin.str)return Sk.longFromStr(a.v,b);if(void 0!==a&&!Sk.builtin.checkString(a)&&!Sk.builtin.checkNumber(a))if(!0===
a)a=1;else if(!1===a)a=0;else throw new Sk.builtin.TypeError("long() argument must be a string or a number, not '"+Sk.abstr.typeName(a)+"'");a=Sk.builtin.asnum$nofloat(a);this.biginteger=new Sk.builtin.biginteger(a);return this};Sk.builtin.lng.co_varnames=["base"];Sk.builtin.lng.co_numargs=2;Sk.builtin.lng.$defaults=[new Sk.builtin.nmber(10,Sk.builtin.nmber.int$)];Sk.builtin.lng.prototype.tp$index=function(){return parseInt(this.str$(10,!0),10)};
Sk.builtin.lng.prototype.tp$hash=function(){return new Sk.builtin.nmber(this.tp$index(),Sk.builtin.nmber.int$)};Sk.builtin.lng.prototype.tp$name="long";Sk.builtin.lng.prototype.ob$type=Sk.builtin.type.makeIntoTypeObj("long",Sk.builtin.lng);Sk.builtin.lng.MAX_INT$=new Sk.builtin.lng(Sk.builtin.nmber.threshold$);Sk.builtin.lng.MIN_INT$=new Sk.builtin.lng(-Sk.builtin.nmber.threshold$);Sk.builtin.lng.prototype.cantBeInt=function(){return 0<this.longCompare(Sk.builtin.lng.MAX_INT$)||0>this.longCompare(Sk.builtin.lng.MIN_INT$)};
Sk.builtin.lng.fromInt$=function(a){return new Sk.builtin.lng(a)};Sk.longFromStr=function(a,b){var c=Sk.str2number(a,b,function(a,b){return 10===b?new Sk.builtin.biginteger(a):new Sk.builtin.biginteger(a,b)},function(a){return a.negate()},"long");return new Sk.builtin.lng(c)};goog.exportSymbol("Sk.longFromStr",Sk.longFromStr);Sk.builtin.lng.prototype.toInt$=function(){return this.biginteger.intValue()};Sk.builtin.lng.prototype.clone=function(){return new Sk.builtin.lng(this)};
Sk.builtin.lng.prototype.nb$add=function(a){var b;a instanceof Sk.builtin.bool&&(a=new Sk.builtin.lng(Sk.builtin.asnum$(a)));if(a instanceof Sk.builtin.nmber){if(a.skType===Sk.builtin.nmber.float$)return b=new Sk.builtin.nmber(this.str$(10,!0),Sk.builtin.nmber.float$),b.nb$add(a);a=new Sk.builtin.lng(a.v)}return a instanceof Sk.builtin.lng?new Sk.builtin.lng(this.biginteger.add(a.biginteger)):a instanceof Sk.builtin.biginteger?new Sk.builtin.lng(this.biginteger.add(a)):new Sk.builtin.lng(this.biginteger.add(new Sk.builtin.biginteger(a)))};
Sk.builtin.lng.prototype.nb$inplace_add=Sk.builtin.lng.prototype.nb$add;
Sk.builtin.lng.prototype.nb$subtract=function(a){var b;a instanceof Sk.builtin.bool&&(a=new Sk.builtin.lng(Sk.builtin.asnum$(a)));if(a instanceof Sk.builtin.nmber){if(a.skType===Sk.builtin.nmber.float$)return b=new Sk.builtin.nmber(this.str$(10,!0),Sk.builtin.nmber.float$),b.nb$subtract(a);a=new Sk.builtin.lng(a.v)}return a instanceof Sk.builtin.lng?new Sk.builtin.lng(this.biginteger.subtract(a.biginteger)):a instanceof Sk.builtin.biginteger?new Sk.builtin.lng(this.biginteger.subtract(a)):new Sk.builtin.lng(this.biginteger.subtract(new Sk.builtin.biginteger(a)))};
Sk.builtin.lng.prototype.nb$inplace_subtract=Sk.builtin.lng.prototype.nb$subtract;
Sk.builtin.lng.prototype.nb$multiply=function(a){a instanceof Sk.builtin.bool&&(a=new Sk.builtin.lng(Sk.builtin.asnum$(a)));if(a instanceof Sk.builtin.nmber){if(a.skType===Sk.builtin.nmber.float$)return(new Sk.builtin.nmber(this.str$(10,!0),Sk.builtin.nmber.float$)).nb$multiply(a);a=new Sk.builtin.lng(a.v)}return a instanceof Sk.builtin.lng?new Sk.builtin.lng(this.biginteger.multiply(a.biginteger)):a instanceof Sk.builtin.biginteger?new Sk.builtin.lng(this.biginteger.multiply(a)):new Sk.builtin.lng(this.biginteger.multiply(new Sk.builtin.biginteger(a)))};
Sk.builtin.lng.prototype.nb$inplace_multiply=Sk.builtin.lng.prototype.nb$multiply;
Sk.builtin.lng.prototype.nb$divide=function(a){var b,c;a instanceof Sk.builtin.bool&&(a=new Sk.builtin.lng(Sk.builtin.asnum$(a)));if(a instanceof Sk.builtin.nmber){if(a.skType===Sk.builtin.nmber.float$)return b=new Sk.builtin.nmber(this.str$(10,!0),Sk.builtin.nmber.float$),b.nb$divide(a);a=new Sk.builtin.lng(a.v)}a instanceof Sk.builtin.lng||(a=new Sk.builtin.lng(a));b=this.nb$isnegative();c=a.nb$isnegative();if(b&&!c||c&&!b){a=this.biginteger.divideAndRemainder(a.biginteger);if(0===a[1].trueCompare(Sk.builtin.biginteger.ZERO))return new Sk.builtin.lng(a[0]);
a=a[0].subtract(Sk.builtin.biginteger.ONE);return new Sk.builtin.lng(a)}return new Sk.builtin.lng(this.biginteger.divide(a.biginteger))};Sk.builtin.lng.prototype.nb$inplace_divide=Sk.builtin.lng.prototype.nb$divide;Sk.builtin.lng.prototype.nb$floor_divide=function(a){a instanceof Sk.builtin.bool&&(a=new Sk.builtin.lng(Sk.builtin.asnum$(a)));return a instanceof Sk.builtin.nmber&&a.skType===Sk.builtin.nmber.float$?(new Sk.builtin.nmber(this.str$(10,!0),Sk.builtin.nmber.float$)).nb$floor_divide(a):this.nb$divide(a)};
Sk.builtin.lng.prototype.nb$inplace_floor_divide=Sk.builtin.lng.prototype.nb$floor_divide;
Sk.builtin.lng.prototype.nb$remainder=function(a){var b;a instanceof Sk.builtin.bool&&(a=new Sk.builtin.lng(Sk.builtin.asnum$(a)));if(0===this.biginteger.trueCompare(Sk.builtin.biginteger.ZERO))return a instanceof Sk.builtin.nmber&&a.skType===Sk.builtin.nmber.float$?new Sk.builtin.nmber(0,Sk.builtin.nmber.float$):new Sk.builtin.lng(0);if(a instanceof Sk.builtin.nmber){if(a.skType===Sk.builtin.nmber.float$)return b=new Sk.builtin.nmber(this.str$(10,!0),Sk.builtin.nmber.float$),b.nb$remainder(a);a=
new Sk.builtin.lng(a.v)}a instanceof Sk.builtin.lng||(a=new Sk.builtin.lng(a));b=new Sk.builtin.lng(this.biginteger.remainder(a.biginteger));this.nb$isnegative()?a.nb$ispositive()&&b.nb$nonzero()&&(b=b.nb$add(a).nb$remainder(a)):a.nb$isnegative()&&b.nb$nonzero()&&(b=b.nb$add(a));return b};Sk.builtin.lng.prototype.nb$inplace_remainder=Sk.builtin.lng.prototype.nb$remainder;
Sk.builtin.lng.prototype.nb$power=function(a,b){var c;if(void 0!==b)return a=new Sk.builtin.biginteger(Sk.builtin.asnum$(a)),b=new Sk.builtin.biginteger(Sk.builtin.asnum$(b)),new Sk.builtin.lng(this.biginteger.modPowInt(a,b));if("number"===typeof a)return 0>a?(c=new Sk.builtin.nmber(this.str$(10,!0),Sk.builtin.nmber.float$),c.nb$power(a)):new Sk.builtin.lng(this.biginteger.pow(new Sk.builtin.biginteger(a)));if(a instanceof Sk.builtin.bool)return new Sk.builtin.lng(this.biginteger.pow(new Sk.builtin.biginteger(Sk.builtin.asnum$(a))));
if(a instanceof Sk.builtin.nmber){if(a.skType===Sk.builtin.nmber.float$||0>a.v)return c=new Sk.builtin.nmber(this.str$(10,!0),Sk.builtin.nmber.float$),c.nb$power(a);a=new Sk.builtin.lng(a.v)}return a instanceof Sk.builtin.lng?a.nb$isnegative()?(c=new Sk.builtin.nmber(this.str$(10,!0),Sk.builtin.nmber.float$),c.nb$power(a)):new Sk.builtin.lng(this.biginteger.pow(a.biginteger)):a instanceof Sk.builtin.biginteger?a.isnegative()?(c=new Sk.builtin.nmber(this.str$(10,!0),Sk.builtin.nmber.float$),c.nb$power(a)):
new Sk.builtin.lng(this.biginteger.pow(a)):new Sk.builtin.lng(this.biginteger.pow(new Sk.builtin.biginteger(a)))};Sk.builtin.lng.prototype.nb$inplace_power=Sk.builtin.lng.prototype.nb$power;
Sk.builtin.lng.prototype.nb$lshift=function(a){if(a instanceof Sk.builtin.lng){if(0>a.biginteger.signum())throw new Sk.builtin.ValueError("negative shift count");return new Sk.builtin.lng(this.biginteger.shiftLeft(a.biginteger))}if(a instanceof Sk.builtin.biginteger){if(0>a.signum())throw new Sk.builtin.ValueError("negative shift count");return new Sk.builtin.lng(this.biginteger.shiftLeft(a))}if(0>a)throw new Sk.builtin.ValueError("negative shift count");a=Sk.builtin.asnum$(a);return new Sk.builtin.lng(this.biginteger.shiftLeft(new Sk.builtin.biginteger(a)))};
Sk.builtin.lng.prototype.nb$inplace_lshift=Sk.builtin.lng.prototype.nb$lshift;
Sk.builtin.lng.prototype.nb$rshift=function(a){if(a instanceof Sk.builtin.lng){if(0>a.biginteger.signum())throw new Sk.builtin.ValueError("negative shift count");return new Sk.builtin.lng(this.biginteger.shiftRight(a.biginteger))}if(a instanceof Sk.builtin.biginteger){if(0>a.signum())throw new Sk.builtin.ValueError("negative shift count");return new Sk.builtin.lng(this.biginteger.shiftRight(a))}if(0>a)throw new Sk.builtin.ValueError("negative shift count");a=Sk.builtin.asnum$(a);return new Sk.builtin.lng(this.biginteger.shiftRight(new Sk.builtin.biginteger(a)))};
Sk.builtin.lng.prototype.nb$inplace_rshift=Sk.builtin.lng.prototype.nb$rshift;Sk.builtin.lng.prototype.nb$and=function(a){if(a instanceof Sk.builtin.lng)return new Sk.builtin.lng(this.biginteger.and(a.biginteger));if(a instanceof Sk.builtin.biginteger)return new Sk.builtin.lng(this.biginteger.and(a));a=Sk.builtin.asnum$(a);return new Sk.builtin.lng(this.biginteger.and(new Sk.builtin.biginteger(a)))};Sk.builtin.lng.prototype.nb$inplace_and=Sk.builtin.lng.prototype.nb$and;
Sk.builtin.lng.prototype.nb$or=function(a){if(a instanceof Sk.builtin.lng)return new Sk.builtin.lng(this.biginteger.or(a.biginteger));if(a instanceof Sk.builtin.biginteger)return new Sk.builtin.lng(this.biginteger.or(a));a=Sk.builtin.asnum$(a);return new Sk.builtin.lng(this.biginteger.or(new Sk.builtin.biginteger(a)))};Sk.builtin.lng.prototype.nb$inplace_or=Sk.builtin.lng.prototype.nb$or;
Sk.builtin.lng.prototype.nb$xor=function(a){if(a instanceof Sk.builtin.lng)return new Sk.builtin.lng(this.biginteger.xor(a.biginteger));if(a instanceof Sk.builtin.biginteger)return new Sk.builtin.lng(this.biginteger.xor(a));a=Sk.builtin.asnum$(a);return new Sk.builtin.lng(this.biginteger.xor(new Sk.builtin.biginteger(a)))};Sk.builtin.lng.prototype.nb$inplace_xor=Sk.builtin.lng.prototype.nb$xor;Sk.builtin.lng.prototype.nb$negative=function(){return new Sk.builtin.lng(this.biginteger.negate())};
Sk.builtin.lng.prototype.nb$positive=function(){return this.clone()};Sk.builtin.lng.prototype.nb$nonzero=function(){return 0!==this.biginteger.trueCompare(Sk.builtin.biginteger.ZERO)};Sk.builtin.lng.prototype.nb$isnegative=function(){return this.biginteger.isnegative()};Sk.builtin.lng.prototype.nb$ispositive=function(){return!this.biginteger.isnegative()};
Sk.builtin.lng.prototype.longCompare=function(a){var b;"boolean"===typeof a&&(a=a?1:0);"number"===typeof a&&(a=new Sk.builtin.lng(a));if(a instanceof Sk.builtin.nmber){if(a.skType===Sk.builtin.nmber.int$||0===a.v%1)return a=new Sk.builtin.lng(a.v),this.longCompare(a);b=new Sk.builtin.nmber(this,Sk.builtin.nmber.float$);return b.numberCompare(a)}return a instanceof Sk.builtin.lng?this.biginteger.subtract(a.biginteger):a instanceof Sk.builtin.biginteger?this.biginteger.subtract(a):this.biginteger.subtract(new Sk.builtin.biginteger(a))};
Sk.builtin.lng.prototype.__eq__=function(a,b){return 0==a.longCompare(b)&&!(b instanceof Sk.builtin.none)};Sk.builtin.lng.prototype.__ne__=function(a,b){return 0!=a.longCompare(b)||b instanceof Sk.builtin.none};Sk.builtin.lng.prototype.__lt__=function(a,b){return 0>a.longCompare(b)};Sk.builtin.lng.prototype.__le__=function(a,b){return 0>=a.longCompare(b)};Sk.builtin.lng.prototype.__gt__=function(a,b){return 0<a.longCompare(b)};Sk.builtin.lng.prototype.__ge__=function(a,b){return 0<=a.longCompare(b)};
Sk.builtin.lng.prototype.$r=function(){return new Sk.builtin.str(this.str$(10,!0)+"L")};Sk.builtin.lng.prototype.tp$str=function(){return new Sk.builtin.str(this.str$(10,!0))};Sk.builtin.lng.prototype.str$=function(a,b){void 0===b&&(b=!0);var c=b?this.biginteger:this.biginteger.abs();return void 0===a||10===a?c.toString():c.toString(a)};Sk.str2number=function(a,b,c,d,e){var f=a,g=!1,h,k,l;a=a.replace(/^\s+|\s+$/g,"");"-"===a.charAt(0)&&(g=!0,a=a.substring(1));"+"===a.charAt(0)&&(a=a.substring(1));void 0===b&&(b=10);if((2>b||36<b)&&0!==b)throw new Sk.builtin.ValueError(e+"() base must be >= 2 and <= 36");if("0x"===a.substring(0,2).toLowerCase())if(16===b||0===b)a=a.substring(2),b=16;else{if(34>b)throw new Sk.builtin.ValueError("invalid literal for "+e+"() with base "+b+": '"+f+"'");}else if("0b"===a.substring(0,2).toLowerCase())if(2===
b||0===b)a=a.substring(2),b=2;else{if(12>b)throw new Sk.builtin.ValueError("invalid literal for "+e+"() with base "+b+": '"+f+"'");}else if("0o"===a.substring(0,2).toLowerCase())if(8===b||0===b)a=a.substring(2),b=8;else{if(25>b)throw new Sk.builtin.ValueError("invalid literal for "+e+"() with base "+b+": '"+f+"'");}else if("0"===a.charAt(0)){if("0"===a)return 0;if(8===b||0===b)b=8}0===b&&(b=10);if(0===a.length)throw new Sk.builtin.ValueError("invalid literal for "+e+"() with base "+b+": '"+f+"'");
for(h=0;h<a.length;h+=1)if(k=a.charCodeAt(h),l=b,48<=k&&57>=k?l=k-48:65<=k&&90>=k?l=k-65+10:97<=k&&122>=k&&(l=k-97+10),l>=b)throw new Sk.builtin.ValueError("invalid literal for "+e+"() with base "+b+": '"+f+"'");l=c(a,b);g&&(l=d(l));return l};
Sk.builtin.int_=function(a,b){var c;if(void 0!==a&&!Sk.builtin.checkString(a)&&!Sk.builtin.checkNumber(a))if(a instanceof Sk.builtin.bool)a=Sk.builtin.asnum$(a);else throw new Sk.builtin.TypeError("int() argument must be a string or a number, not '"+Sk.abstr.typeName(a)+"'");if(a instanceof Sk.builtin.str)return b=Sk.builtin.asnum$(b),c=Sk.str2number(a.v,b,parseInt,function(a){return-a},"int"),c>Sk.builtin.nmber.threshold$||c<-Sk.builtin.nmber.threshold$?new Sk.builtin.lng(a,b):new Sk.builtin.nmber(c,
Sk.builtin.nmber.int$);if(void 0!==b)throw new Sk.builtin.TypeError("int() can't convert non-string with explicit base");if(void 0===a||a===Sk.builtin.none)a=0;if(a instanceof Sk.builtin.lng)return a.cantBeInt()?new Sk.builtin.lng(a):new Sk.builtin.nmber(a.toInt$(),Sk.builtin.nmber.int$);a=Sk.builtin.asnum$(a);return a>Sk.builtin.nmber.threshold$||a<-Sk.builtin.nmber.threshold$?new Sk.builtin.lng(a):new Sk.builtin.nmber(parseInt(a,b),Sk.builtin.nmber.int$)};Sk.builtin.int_.co_varnames=["base"];
Sk.builtin.int_.co_numargs=2;Sk.builtin.int_.$defaults=[new Sk.builtin.nmber(10,Sk.builtin.nmber.int$)];Sk.builtin.int_.prototype.tp$name="int";Sk.builtin.int_.prototype.ob$type=Sk.builtin.type.makeIntoTypeObj("int",Sk.builtin.int_);Sk.builtin.float_=function(a){if(void 0===a)return new Sk.builtin.nmber(0,Sk.builtin.nmber.float$);if(a instanceof Sk.builtin.str){if(a.v.match(/^-inf$/i))a=-Infinity;else if(a.v.match(/^[+]?inf$/i))a=Infinity;else if(a.v.match(/^[-+]?nan$/i))a=NaN;else{if(isNaN(a.v))throw new Sk.builtin.ValueError("float: Argument: "+a.v+" is not number");a=parseFloat(a.v)}return new Sk.builtin.nmber(a,Sk.builtin.nmber.float$)}if("number"===typeof a||a instanceof Sk.builtin.nmber||a instanceof Sk.builtin.lng)return a=
Sk.builtin.asnum$(a),new Sk.builtin.nmber(a,Sk.builtin.nmber.float$);if(a instanceof Sk.builtin.bool)return a=Sk.builtin.asnum$(a),new Sk.builtin.nmber(a,Sk.builtin.nmber.float$);throw new Sk.builtin.TypeError("float() argument must be a string or a number");};Sk.builtin.float_.prototype.tp$name="float";Sk.builtin.float_.prototype.ob$type=Sk.builtin.type.makeIntoTypeObj("float",Sk.builtin.float_);Sk.builtin.slice=function(a,b,c){if(0===Sk.builtin.asnum$(c))throw new Sk.builtin.ValueError("slice step cannot be zero");if(!(this instanceof Sk.builtin.slice))return new Sk.builtin.slice(a,b,c);void 0===b&&void 0===c&&(b=a,a=Sk.builtin.none.none$);void 0===b&&(b=Sk.builtin.none.none$);void 0===c&&(c=Sk.builtin.none.none$);this.start=a;this.stop=b;this.step=c;this.__class__=Sk.builtin.slice;this.$d=new Sk.builtin.dict([Sk.builtin.slice$start,this.start,Sk.builtin.slice$stop,this.stop,Sk.builtin.slice$step,
this.step]);return this};Sk.builtin.slice.prototype.tp$name="slice";Sk.builtin.slice.prototype.ob$type=Sk.builtin.type.makeIntoTypeObj("slice",Sk.builtin.slice);Sk.builtin.slice.prototype.$r=function(){var a=Sk.builtin.repr(this.start).v,b=Sk.builtin.repr(this.stop).v,c=Sk.builtin.repr(this.step).v;return new Sk.builtin.str("slice("+a+", "+b+", "+c+")")};Sk.builtin.slice.prototype.tp$getattr=Sk.builtin.object.prototype.GenericGetAttr;
Sk.builtin.slice.prototype.tp$richcompare=function(a,b){if(!a.__class__||a.__class__!=Sk.builtin.slice)return"Eq"===b?!1:"NotEq"===b?!0:!1;var c,d;c=new Sk.builtin.tuple([this.start,this.stop,this.step]);d=new Sk.builtin.tuple([a.start,a.stop,a.step]);return c.tp$richcompare(d,b)};
Sk.builtin.slice.prototype.indices=function(a){if(!Sk.builtin.checkInt(this.start)&&!Sk.builtin.checkNone(this.start)||!Sk.builtin.checkInt(this.stop)&&!Sk.builtin.checkNone(this.stop)||!Sk.builtin.checkInt(this.step)&&!Sk.builtin.checkNone(this.step))throw new Sk.builtin.TypeError("slice indices must be integers or None");var b=Sk.builtin.asnum$(this.start),c=Sk.builtin.asnum$(this.stop),d=Sk.builtin.asnum$(this.step);a=Sk.builtin.asnum$(a);null===d&&(d=1);0<d?(null===b&&(b=0),null===c&&(c=a),c>
a&&(c=a),0>b&&(b=a+b,0>b&&(b=0)),0>c&&(c=a+c)):(null===b&&(b=a-1),b>=a&&(b=a-1),null===c?c=-1:0>c&&(c=a+c,0>c&&(c=-1)),0>b&&(b=a+b));return[b,c,d]};Sk.builtin.slice.prototype.sssiter$=function(a,b){var c=Sk.builtin.asnum$(a),d=this.indices("number"===typeof c?c:a.v.length);if(0<d[2]){var e;for(e=d[0];e<d[1]&&!1!==b(e,c);e+=d[2]);}else for(e=d[0];e>d[1]&&!1!==b(e,c);e+=d[2]);};Sk.builtin.slice$start=new Sk.builtin.str("start");Sk.builtin.slice$stop=new Sk.builtin.str("stop");
Sk.builtin.slice$step=new Sk.builtin.str("step");Sk.builtin.set=function(a){if(!(this instanceof Sk.builtin.set))return new Sk.builtin.set(a);"undefined"===typeof a&&(a=[]);this.set_reset_();a=(new Sk.builtin.list(a)).tp$iter();for(var b=a.tp$iternext();void 0!==b;b=a.tp$iternext())Sk.builtin.set.prototype.add.func_code(this,b);this.__class__=Sk.builtin.set;this.v=this.v;return this};Sk.builtin.set.prototype.ob$type=Sk.builtin.type.makeIntoTypeObj("set",Sk.builtin.set);Sk.builtin.set.prototype.set_iter_=function(){return Sk.builtin.dict.prototype.keys.func_code(this.v).tp$iter()};
Sk.builtin.set.prototype.set_reset_=function(){this.v=new Sk.builtin.dict([])};Sk.builtin.set.prototype.tp$name="set";Sk.builtin.set.prototype.$r=function(){for(var a=[],b=this.tp$iter(),c=b.tp$iternext();void 0!==c;c=b.tp$iternext())a.push(Sk.misceval.objectRepr(c).v);return new Sk.builtin.str("set(["+a.join(", ")+"])")};Sk.builtin.set.prototype.tp$getattr=Sk.builtin.object.prototype.GenericGetAttr;Sk.builtin.set.prototype.tp$hash=Sk.builtin.object.prototype.HashNotImplemented;
Sk.builtin.set.prototype.tp$richcompare=function(a,b){if(this===a&&Sk.misceval.opAllowsEquality(b))return!0;if(!a.__class__||a.__class__!=Sk.builtin.set)return"Eq"===b?!1:"NotEq"===b?!0:!1;var c=this.sq$length(),d=a.sq$length();if(d!==c){if("Eq"===b)return!1;if("NotEq"===b)return!0}var e=!1,f=!1;switch(b){case "Lt":case "LtE":case "Eq":case "NotEq":e=Sk.builtin.set.prototype.issubset.func_code(this,a);break;case "Gt":case "GtE":f=Sk.builtin.set.prototype.issuperset.func_code(this,a);break;default:goog.asserts.fail()}switch(b){case "Lt":return c<
d&&e;case "LtE":case "Eq":return e;case "NotEq":return!e;case "Gt":return c>d&&f;case "GtE":return f}};Sk.builtin.set.prototype.tp$iter=Sk.builtin.set.prototype.set_iter_;Sk.builtin.set.prototype.sq$length=function(){return this.v.mp$length()};Sk.builtin.set.prototype.isdisjoint=new Sk.builtin.func(function(a,b){for(var c=a.tp$iter(),d=c.tp$iternext();void 0!==d;d=c.tp$iternext())if(Sk.abstr.sequenceContains(b,d))return Sk.builtin.bool.false$;return Sk.builtin.bool.true$});
Sk.builtin.set.prototype.issubset=new Sk.builtin.func(function(a,b){var c=a.sq$length(),d=b.sq$length();if(c>d)return Sk.builtin.bool.false$;c=a.tp$iter();for(d=c.tp$iternext();void 0!==d;d=c.tp$iternext())if(!Sk.abstr.sequenceContains(b,d))return Sk.builtin.bool.false$;return Sk.builtin.bool.true$});Sk.builtin.set.prototype.issuperset=new Sk.builtin.func(function(a,b){return Sk.builtin.set.prototype.issubset.func_code(b,a)});
Sk.builtin.set.prototype.union=new Sk.builtin.func(function(a){for(var b=new Sk.builtin.set(a),c=1;c<arguments.length;c++)Sk.builtin.set.prototype.update.func_code(b,arguments[c]);return b});Sk.builtin.set.prototype.intersection=new Sk.builtin.func(function(a){var b=Sk.builtin.set.prototype.copy.func_code(a);arguments[0]=b;Sk.builtin.set.prototype.intersection_update.func_code.apply(null,arguments);return b});
Sk.builtin.set.prototype.difference=new Sk.builtin.func(function(a,b){var c=Sk.builtin.set.prototype.copy.func_code(a);arguments[0]=c;Sk.builtin.set.prototype.difference_update.func_code.apply(null,arguments);return c});
Sk.builtin.set.prototype.symmetric_difference=new Sk.builtin.func(function(a,b){for(var c=Sk.builtin.set.prototype.union.func_code(a,b),d=c.tp$iter(),e=d.tp$iternext();void 0!==e;e=d.tp$iternext())Sk.abstr.sequenceContains(a,e)&&Sk.abstr.sequenceContains(b,e)&&Sk.builtin.set.prototype.discard.func_code(c,e);return c});Sk.builtin.set.prototype.copy=new Sk.builtin.func(function(a){return new Sk.builtin.set(a)});
Sk.builtin.set.prototype.update=new Sk.builtin.func(function(a,b){for(var c=b.tp$iter(),d=c.tp$iternext();void 0!==d;d=c.tp$iternext())Sk.builtin.set.prototype.add.func_code(a,d);return Sk.builtin.none.none$});Sk.builtin.set.prototype.intersection_update=new Sk.builtin.func(function(a,b){for(var c=a.tp$iter(),d=c.tp$iternext();void 0!==d;d=c.tp$iternext())for(var e=1;e<arguments.length;e++)if(!Sk.abstr.sequenceContains(arguments[e],d)){Sk.builtin.set.prototype.discard.func_code(a,d);break}return Sk.builtin.none.none$});
Sk.builtin.set.prototype.difference_update=new Sk.builtin.func(function(a,b){for(var c=a.tp$iter(),d=c.tp$iternext();void 0!==d;d=c.tp$iternext())for(var e=1;e<arguments.length;e++)if(Sk.abstr.sequenceContains(arguments[e],d)){Sk.builtin.set.prototype.discard.func_code(a,d);break}return Sk.builtin.none.none$});
Sk.builtin.set.prototype.symmetric_difference_update=new Sk.builtin.func(function(a,b){var c=Sk.builtin.set.prototype.symmetric_difference.func_code(a,b);a.set_reset_();Sk.builtin.set.prototype.update.func_code(a,c);return Sk.builtin.none.none$});Sk.builtin.set.prototype.add=new Sk.builtin.func(function(a,b){a.v.mp$ass_subscript(b,!0);return Sk.builtin.none.none$});
Sk.builtin.set.prototype.discard=new Sk.builtin.func(function(a,b){Sk.builtin.dict.prototype.pop.func_code(a.v,b,Sk.builtin.none.none$);return Sk.builtin.none.none$});Sk.builtin.set.prototype.pop=new Sk.builtin.func(function(a){if(0===a.sq$length())throw new Sk.builtin.KeyError("pop from an empty set");var b=a.tp$iter().tp$iternext();Sk.builtin.set.prototype.discard.func_code(a,b);return b});Sk.builtin.set.prototype.remove=new Sk.builtin.func(function(a,b){a.v.mp$del_subscript(b);return Sk.builtin.none.none$});
goog.exportSymbol("Sk.builtin.set",Sk.builtin.set);Sk.builtin.module=function(){};goog.exportSymbol("Sk.builtin.module",Sk.builtin.module);Sk.builtin.module.prototype.ob$type=Sk.builtin.type.makeIntoTypeObj("module",Sk.builtin.module);Sk.builtin.module.prototype.tp$getattr=Sk.builtin.object.prototype.GenericGetAttr;Sk.builtin.module.prototype.tp$setattr=Sk.builtin.object.prototype.GenericSetAttr;Sk.builtin.generator=function(a,b,c,d,e){if(a){this.func_code=a;this.func_globals=b||null;this.gi$running=!1;this.gi$resumeat=0;this.gi$sentvalue=void 0;this.gi$locals={};this.gi$cells={};if(0<c.length)for(b=0;b<a.co_varnames.length;++b)this.gi$locals[a.co_varnames[b]]=c[b];if(void 0!==e)for(var f in e)d[f]=e[f];this.func_closure=d;return this}};goog.exportSymbol("Sk.builtin.generator",Sk.builtin.generator);Sk.builtin.generator.prototype.tp$getattr=Sk.builtin.object.prototype.GenericGetAttr;
Sk.builtin.generator.prototype.tp$iter=function(){return this};Sk.builtin.generator.prototype.tp$iternext=function(a){this.gi$running=!0;void 0===a&&(a=null);this.gi$sentvalue=a;a=[this];this.func_closure&&a.push(this.func_closure);a=this.func_code.apply(this.func_globals,a);this.gi$running=!1;goog.asserts.assert(void 0!==a);if(a!==Sk.builtin.none.none$)return this.gi$resumeat=a[0],a=a[1]};Sk.builtin.generator.prototype.next=new Sk.builtin.func(function(a){return a.tp$iternext()});
Sk.builtin.generator.prototype.ob$type=Sk.builtin.type.makeIntoTypeObj("generator",Sk.builtin.generator);Sk.builtin.generator.prototype.$r=function(){return new Sk.builtin.str("<generator object "+this.func_code.co_name.v+">")};Sk.builtin.generator.prototype.send=new Sk.builtin.func(function(a,b){return a.tp$iternext(b)});Sk.builtin.makeGenerator=function(a,b){var c=new Sk.builtin.generator(null,null,null);c.tp$iternext=a;for(var d in b)b.hasOwnProperty(d)&&(c[d]=b[d]);return c};
goog.exportSymbol("Sk.builtin.makeGenerator",Sk.builtin.makeGenerator);Sk.builtin.file=function(a,b,c){this.mode=b;this.name=a;this.closed=!1;if(Sk.inBrowser){b=document.getElementById(a.v);if(null==b)throw new Sk.builtin.IOError("[Errno 2] No such file or directory: '"+a.v+"'");"textarea"==b.nodeName.toLowerCase()?this.data$=b.value:this.data$=b.textContent}else this.data$=Sk.read(a.v);this.lineList=this.data$.split("\n");this.lineList=this.lineList.slice(0,-1);for(var d in this.lineList)this.lineList[d]+="\n";this.pos$=this.currentLine=0;this.__class__=Sk.builtin.file;
return this};Sk.builtin.file.prototype.ob$type=Sk.builtin.type.makeIntoTypeObj("file",Sk.builtin.file);Sk.builtin.file.prototype.tp$getattr=Sk.builtin.object.prototype.GenericGetAttr;Sk.builtin.file.prototype.$r=function(){return new Sk.builtin.str("<"+(this.closed?"closed":"open")+"file '"+this.name+"', mode '"+this.mode+"'>")};
Sk.builtin.file.prototype.tp$iter=function(){var a={tp$iter:function(){return a},$obj:this,$index:0,$lines:this.lineList,tp$iternext:function(){return a.$index>=a.$lines.length?void 0:new Sk.builtin.str(a.$lines[a.$index++])}};return a};Sk.builtin.file.prototype.close=new Sk.builtin.func(function(a){a.closed=!0});Sk.builtin.file.prototype.flush=new Sk.builtin.func(function(a){});Sk.builtin.file.prototype.fileno=new Sk.builtin.func(function(a){return 10});Sk.builtin.file.prototype.isatty=new Sk.builtin.func(function(a){return!1});
Sk.builtin.file.prototype.read=new Sk.builtin.func(function(a,b){if(a.closed)throw new Sk.builtin.ValueError("I/O operation on closed file");var c=a.data$.length;void 0===b&&(b=c);var d=new Sk.builtin.str(a.data$.substr(a.pos$,b));a.pos$+=b;a.pos$>=c&&(a.pos$=c);return d});Sk.builtin.file.prototype.readline=new Sk.builtin.func(function(a,b){var c="";a.currentLine<a.lineList.length&&(c=a.lineList[a.currentLine],a.currentLine++);return new Sk.builtin.str(c)});
Sk.builtin.file.prototype.readlines=new Sk.builtin.func(function(a,b){for(var c=[],d=a.currentLine;d<a.lineList.length;d++)c.push(new Sk.builtin.str(a.lineList[d]));return new Sk.builtin.list(c)});Sk.builtin.file.prototype.seek=new Sk.builtin.func(function(a,b,c){void 0===c&&(c=1);a.pos$=1==c?b:a.data$+b});Sk.builtin.file.prototype.tell=new Sk.builtin.func(function(a){return a.pos$});Sk.builtin.file.prototype.truncate=new Sk.builtin.func(function(a,b){goog.asserts.fail()});
Sk.builtin.file.prototype.write=new Sk.builtin.func(function(a,b){goog.asserts.fail()});goog.exportSymbol("Sk.builtin.file",Sk.builtin.file);Sk.ffi=Sk.ffi||{};
Sk.ffi.remapToPy=function(a){if("[object Array]"===Object.prototype.toString.call(a)){for(var b=[],c=0;c<a.length;++c)b.push(Sk.ffi.remapToPy(a[c]));return new Sk.builtin.list(b)}if("object"===typeof a){b=[];for(c in a)b.push(Sk.ffi.remapToPy(c)),b.push(Sk.ffi.remapToPy(a[c]));return new Sk.builtin.dict(b)}if("string"===typeof a)return new Sk.builtin.str(a);if("number"===typeof a)return new Sk.builtin.nmber(a,void 0);if("boolean"===typeof a)return a;goog.asserts.fail("unhandled remap type "+typeof a)};
goog.exportSymbol("Sk.ffi.remapToPy",Sk.ffi.remapToPy);
Sk.ffi.remapToJs=function(a){if(a instanceof Sk.builtin.dict){for(var b={},c=a.tp$iter(),d=c.tp$iternext();void 0!==d;d=c.tp$iternext()){var e=a.mp$subscript(d);void 0===e&&(e=null);d=Sk.ffi.remapToJs(d);b[d]=Sk.ffi.remapToJs(e)}return b}if(a instanceof Sk.builtin.list||a instanceof Sk.builtin.tuple){b=[];for(c=0;c<a.v.length;++c)b.push(Sk.ffi.remapToJs(a.v[c]));return b}return a instanceof Sk.builtin.nmber?Sk.builtin.asnum$(a):a instanceof Sk.builtin.lng?Sk.builtin.asnum$(a):"number"===typeof a||
"boolean"===typeof a?a:a.v};goog.exportSymbol("Sk.ffi.remapToJs",Sk.ffi.remapToJs);Sk.ffi.callback=function(a){return void 0===a?a:function(){return Sk.misceval.apply(a,void 0,void 0,void 0,Array.prototype.slice.call(arguments,0))}};goog.exportSymbol("Sk.ffi.callback",Sk.ffi.callback);Sk.ffi.stdwrap=function(a,b){var c=new a;c.v=b;return c};goog.exportSymbol("Sk.ffi.stdwrap",Sk.ffi.stdwrap);
Sk.ffi.basicwrap=function(a){if(a instanceof Sk.builtin.nmber)return Sk.builtin.asnum$(a);if(a instanceof Sk.builtin.lng)return Sk.builtin.asnum$(a);if("number"===typeof a||"boolean"===typeof a)return a;if("string"===typeof a)return new Sk.builtin.str(a);goog.asserts.fail("unexpected type for basicwrap")};goog.exportSymbol("Sk.ffi.basicwrap",Sk.ffi.basicwrap);Sk.ffi.unwrapo=function(a){return void 0===a?void 0:a.v};goog.exportSymbol("Sk.ffi.unwrapo",Sk.ffi.unwrapo);
Sk.ffi.unwrapn=function(a){return null===a?null:a.v};goog.exportSymbol("Sk.ffi.unwrapn",Sk.ffi.unwrapn);Sk.builtin.enumerate=function(a,b){if(!(this instanceof Sk.builtin.enumerate))return new Sk.builtin.enumerate(a,b);Sk.builtin.pyCheckArgs("enumerate",arguments,1,2);if(!Sk.builtin.checkIterable(a))throw new Sk.builtin.TypeError("'"+Sk.abstr.typeName(a)+"' object is not iterable");if(void 0!==b)if(Sk.misceval.isIndex(b))b=Sk.misceval.asIndex(b);else throw new Sk.builtin.TypeError("'"+Sk.abstr.typeName(b)+"' object cannot be interpreted as an index");else b=0;var c=a.tp$iter();this.tp$iter=function(){return this};
this.$index=b;this.tp$iternext=function(){var a=c.tp$iternext();if(void 0!==a){var b=Sk.builtin.assk$(this.$index++,Sk.builtin.nmber.int$);return new Sk.builtin.tuple([b,a])}};this.__class__=Sk.builtin.enumerate;return this};Sk.builtin.enumerate.prototype.tp$name="enumerate";Sk.builtin.enumerate.prototype.ob$type=Sk.builtin.type.makeIntoTypeObj("enumerate",Sk.builtin.enumerate);Sk.builtin.enumerate.prototype.tp$getattr=Sk.builtin.object.prototype.GenericGetAttr;
Sk.builtin.enumerate.prototype.__iter__=new Sk.builtin.func(function(a){return a.tp$iter()});Sk.builtin.enumerate.prototype.next=new Sk.builtin.func(function(a){return a.tp$iternext()});Sk.Tokenizer=function(a,b,c){this.filename=a;this.callback=c;this.parenlev=this.lnum=0;this.continued=!1;this.namechars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";this.numchars="0123456789";this.contstr="";this.needcont=!1;this.contline=void 0;this.indents=[0];this.endprog=/.*/;this.strstart=[-1,-1];this.interactive=b;this.doneFunc=function(){for(var a=1;a<this.indents.length;++a)if(this.callback(Sk.Tokenizer.Tokens.T_DEDENT,"",[this.lnum,0],[this.lnum,0],""))return"done";return this.callback(Sk.Tokenizer.Tokens.T_ENDMARKER,
"",[this.lnum,0],[this.lnum,0],"")?"done":"failed"}};
Sk.Tokenizer.Tokens={T_ENDMARKER:0,T_NAME:1,T_NUMBER:2,T_STRING:3,T_NEWLINE:4,T_INDENT:5,T_DEDENT:6,T_LPAR:7,T_RPAR:8,T_LSQB:9,T_RSQB:10,T_COLON:11,T_COMMA:12,T_SEMI:13,T_PLUS:14,T_MINUS:15,T_STAR:16,T_SLASH:17,T_VBAR:18,T_AMPER:19,T_LESS:20,T_GREATER:21,T_EQUAL:22,T_DOT:23,T_PERCENT:24,T_BACKQUOTE:25,T_LBRACE:26,T_RBRACE:27,T_EQEQUAL:28,T_NOTEQUAL:29,T_LESSEQUAL:30,T_GREATEREQUAL:31,T_TILDE:32,T_CIRCUMFLEX:33,T_LEFTSHIFT:34,T_RIGHTSHIFT:35,T_DOUBLESTAR:36,T_PLUSEQUAL:37,T_MINEQUAL:38,T_STAREQUAL:39,
T_SLASHEQUAL:40,T_PERCENTEQUAL:41,T_AMPEREQUAL:42,T_VBAREQUAL:43,T_CIRCUMFLEXEQUAL:44,T_LEFTSHIFTEQUAL:45,T_RIGHTSHIFTEQUAL:46,T_DOUBLESTAREQUAL:47,T_DOUBLESLASH:48,T_DOUBLESLASHEQUAL:49,T_AT:50,T_OP:51,T_COMMENT:52,T_NL:53,T_RARROW:54,T_ERRORTOKEN:55,T_N_TOKENS:56,T_NT_OFFSET:256};function group(a){return"("+Array.prototype.slice.call(arguments).join("|")+")"}function any(a){return group.apply(null,arguments)+"*"}function maybe(a){return group.apply(null,arguments)+"?"}
var Whitespace="[ \\f\\t]*",Comment_="#[^\\r\\n]*",Ident="[a-zA-Z_]\\w*",Binnumber="0[bB][01]*",Hexnumber="0[xX][\\da-fA-F]*[lL]?",Octnumber="0[oO]?[0-7]*[lL]?",Decnumber="[1-9]\\d*[lL]?",Intnumber=group(Binnumber,Hexnumber,Octnumber,Decnumber),Exponent="[eE][-+]?\\d+",Pointfloat=group("\\d+\\.\\d*","\\.\\d+")+maybe(Exponent),Expfloat="\\d+"+Exponent,Floatnumber=group(Pointfloat,Expfloat),Imagnumber=group("\\d+[jJ]",Floatnumber+"[jJ]"),Number_=group(Imagnumber,Floatnumber,Intnumber),Single="^[^'\\\\]*(?:\\\\.[^'\\\\]*)*'",
Double_='^[^"\\\\]*(?:\\\\.[^"\\\\]*)*"',Single3="[^'\\\\]*(?:(?:\\\\.|'(?!''))[^'\\\\]*)*'''",Double3='[^"\\\\]*(?:(?:\\\\.|"(?!""))[^"\\\\]*)*"""',Triple=group("[ubUB]?[rR]?'''",'[ubUB]?[rR]?"""'),String_=group("[uU]?[rR]?'[^\\n'\\\\]*(?:\\\\.[^\\n'\\\\]*)*'",'[uU]?[rR]?"[^\\n"\\\\]*(?:\\\\.[^\\n"\\\\]*)*"'),Operator=group("\\*\\*=?",">>=?","<<=?","<>","!=","//=?","->","[+\\-*/%&|^=<>]=?","~"),Bracket="[\\][(){}]",Special=group("\\r?\\n","[:;.,`@]"),Funny=group(Operator,Bracket,Special),ContStr=
group("[uUbB]?[rR]?'[^\\n'\\\\]*(?:\\\\.[^\\n'\\\\]*)*"+group("'","\\\\\\r?\\n"),'[uUbB]?[rR]?"[^\\n"\\\\]*(?:\\\\.[^\\n"\\\\]*)*'+group('"',"\\\\\\r?\\n")),PseudoExtras=group("\\\\\\r?\\n",Comment_,Triple),PseudoToken="^"+group(PseudoExtras,Number_,Funny,ContStr,Ident),pseudoprog,single3prog,double3prog,endprogs={},triple_quoted={"'''":!0,'"""':!0,"r'''":!0,'r"""':!0,"R'''":!0,'R"""':!0,"u'''":!0,'u"""':!0,"U'''":!0,'U"""':!0,"b'''":!0,'b"""':!0,"B'''":!0,'B"""':!0,"ur'''":!0,'ur"""':!0,"Ur'''":!0,
'Ur"""':!0,"uR'''":!0,'uR"""':!0,"UR'''":!0,'UR"""':!0,"br'''":!0,'br"""':!0,"Br'''":!0,'Br"""':!0,"bR'''":!0,'bR"""':!0,"BR'''":!0,'BR"""':!0},single_quoted={"'":!0,'"':!0,"r'":!0,'r"':!0,"R'":!0,'R"':!0,"u'":!0,'u"':!0,"U'":!0,'U"':!0,"b'":!0,'b"':!0,"B'":!0,'B"':!0,"ur'":!0,'ur"':!0,"Ur'":!0,'Ur"':!0,"uR'":!0,'uR"':!0,"UR'":!0,'UR"':!0,"br'":!0,'br"':!0,"Br'":!0,'Br"':!0,"bR'":!0,'bR"':!0,"BR'":!0,'BR"':!0};(function(){for(var a in triple_quoted);for(a in single_quoted);})();var tabsize=8;
function contains(a,b){for(var c=a.length;c--;)if(a[c]===b)return!0;return!1}function rstrip(a,b){for(var c=a.length;0<c&&-1!==b.indexOf(a.charAt(c-1));--c);return a.substring(0,c)}
Sk.Tokenizer.prototype.generateTokens=function(a){var b,c,d,e,f,g=RegExp(PseudoToken);c=RegExp(Single3,"g");f=RegExp(Double3,"g");var h={"'":RegExp(Single,"g"),'"':RegExp(Double_,"g"),"'''":c,'"""':f,"r'''":c,'r"""':f,"u'''":c,'u"""':f,"b'''":c,'b"""':f,"ur'''":c,'ur"""':f,"br'''":c,'br"""':f,"R'''":c,'R"""':f,"U'''":c,'U"""':f,"B'''":c,'B"""':f,"uR'''":c,'uR"""':f,"Ur'''":c,'Ur"""':f,"UR'''":c,'UR"""':f,"bR'''":c,'bR"""':f,"Br'''":c,'Br"""':f,"BR'''":c,'BR"""':f,r:null,R:null,u:null,U:null,b:null,
B:null};a||(a="");this.lnum+=1;c=0;f=a.length;if(0<this.contstr.length){if(!a)throw new Sk.builtin.TokenError("EOF in multi-line string",this.filename,this.strstart[0],this.strstart[1],this.contline);this.endprog.lastIndex=0;if(b=this.endprog.test(a)){c=e=this.endprog.lastIndex;if(this.callback(Sk.Tokenizer.Tokens.T_STRING,this.contstr+a.substring(0,e),this.strstart,[this.lnum,e],this.contline+a))return"done";this.contstr="";this.needcont=!1;this.contline=void 0}else{if(this.needcont&&"\\\n"!==a.substring(a.length-
2)&&"\\\r\n"!==a.substring(a.length-3)){if(this.callback(Sk.Tokenizer.Tokens.T_ERRORTOKEN,this.contstr+a,this.strstart,[this.lnum,a.length],this.contline))return"done";this.contstr="";this.contline=void 0}else this.contstr+=a,this.contline+=a;return!1}}else if(0!==this.parenlev||this.continued){if(!a)throw new Sk.builtin.TokenError("EOF in multi-line statement",this.filename,this.lnum,0,a);this.continued=!1}else{if(!a)return this.doneFunc();for(d=0;c<f;){if(" "===a.charAt(c))d+=1;else if("\t"===a.charAt(c))d=
(d/tabsize+1)*tabsize;else if("\f"===a.charAt(c))d=0;else break;c+=1}if(c===f)return this.doneFunc();if(-1!=="#\r\n".indexOf(a.charAt(c))){if("#"===a.charAt(c))return g=rstrip(a.substring(c),"\r\n"),f=c+g.length,this.callback(Sk.Tokenizer.Tokens.T_COMMENT,g,[this.lnum,c],[this.lnum,c+g.length],a)||this.callback(Sk.Tokenizer.Tokens.T_NL,a.substring(f),[this.lnum,f],[this.lnum,a.length],a)?"done":!1;if(this.callback(Sk.Tokenizer.Tokens.T_NL,a.substring(c),[this.lnum,c],[this.lnum,a.length],a))return"done";
if(!this.interactive)return!1}if(d>this.indents[this.indents.length-1]&&(this.indents.push(d),this.callback(Sk.Tokenizer.Tokens.T_INDENT,a.substring(0,c),[this.lnum,0],[this.lnum,c],a)))return"done";for(;d<this.indents[this.indents.length-1];){if(!contains(this.indents,d))throw new Sk.builtin.IndentationError("unindent does not match any outer indentation level",this.filename,this.lnum,c,a);this.indents.splice(this.indents.length-1,1);if(this.callback(Sk.Tokenizer.Tokens.T_DEDENT,"",[this.lnum,c],
[this.lnum,c],a))return"done"}}for(;c<f;){for(d=a.charAt(c);" "===d||"\f"===d||"\t"===d;)c+=1,d=a.charAt(c);g.lastIndex=0;var k=g.exec(a.substring(c));if(k){d=c;e=d+k[1].length;k=[this.lnum,d];b=[this.lnum,e];c=e;e=a.substring(d,e);var l=a.charAt(d);if(-1!==this.numchars.indexOf(l)||"."===l&&"."!==e){if(this.callback(Sk.Tokenizer.Tokens.T_NUMBER,e,k,b,a))return"done"}else if("\r"===l||"\n"===l){if(d=Sk.Tokenizer.Tokens.T_NEWLINE,0<this.parenlev&&(d=Sk.Tokenizer.Tokens.T_NL),this.callback(d,e,k,b,
a))return"done"}else if("#"===l){if(this.callback(Sk.Tokenizer.Tokens.T_COMMENT,e,k,b,a))return"done"}else if(triple_quoted.hasOwnProperty(e))if(this.endprog=h[e],this.endprog.lastIndex=0,b=this.endprog.test(a.substring(c))){if(c=this.endprog.lastIndex+c,e=a.substring(d,c),this.callback(Sk.Tokenizer.Tokens.T_STRING,e,k,[this.lnum,c],a))return"done"}else{this.strstart=[this.lnum,d];this.contstr=a.substring(d);this.contline=a;break}else if(single_quoted.hasOwnProperty(l)||single_quoted.hasOwnProperty(e.substring(0,
2))||single_quoted.hasOwnProperty(e.substring(0,3)))if("\n"===e[e.length-1]){this.strstart=[this.lnum,d];this.endprog=h[l]||h[e[1]]||h[e[2]];this.contstr=a.substring(d);this.needcont=!0;this.contline=a;break}else{if(this.callback(Sk.Tokenizer.Tokens.T_STRING,e,k,b,a))return"done"}else if(-1!==this.namechars.indexOf(l)){if(this.callback(Sk.Tokenizer.Tokens.T_NAME,e,k,b,a))return"done"}else if("\\"===l){if(this.callback(Sk.Tokenizer.Tokens.T_NL,e,k,[this.lnum,c],a))return"done";this.continued=!0}else if(-1!==
"([{".indexOf(l)?this.parenlev+=1:-1!==")]}".indexOf(l)&&(this.parenlev-=1),this.callback(Sk.Tokenizer.Tokens.T_OP,e,k,b,a))return"done"}else{if(this.callback(Sk.Tokenizer.Tokens.T_ERRORTOKEN,a.charAt(c),[this.lnum,c],[this.lnum,c+1],a))return"done";c+=1}}return!1};
Sk.Tokenizer.tokenNames={0:"T_ENDMARKER",1:"T_NAME",2:"T_NUMBER",3:"T_STRING",4:"T_NEWLINE",5:"T_INDENT",6:"T_DEDENT",7:"T_LPAR",8:"T_RPAR",9:"T_LSQB",10:"T_RSQB",11:"T_COLON",12:"T_COMMA",13:"T_SEMI",14:"T_PLUS",15:"T_MINUS",16:"T_STAR",17:"T_SLASH",18:"T_VBAR",19:"T_AMPER",20:"T_LESS",21:"T_GREATER",22:"T_EQUAL",23:"T_DOT",24:"T_PERCENT",25:"T_BACKQUOTE",26:"T_LBRACE",27:"T_RBRACE",28:"T_EQEQUAL",29:"T_NOTEQUAL",30:"T_LESSEQUAL",31:"T_GREATEREQUAL",32:"T_TILDE",33:"T_CIRCUMFLEX",34:"T_LEFTSHIFT",
35:"T_RIGHTSHIFT",36:"T_DOUBLESTAR",37:"T_PLUSEQUAL",38:"T_MINEQUAL",39:"T_STAREQUAL",40:"T_SLASHEQUAL",41:"T_PERCENTEQUAL",42:"T_AMPEREQUAL",43:"T_VBAREQUAL",44:"T_CIRCUMFLEXEQUAL",45:"T_LEFTSHIFTEQUAL",46:"T_RIGHTSHIFTEQUAL",47:"T_DOUBLESTAREQUAL",48:"T_DOUBLESLASH",49:"T_DOUBLESLASHEQUAL",50:"T_AT",51:"T_OP",52:"T_COMMENT",53:"T_NL",54:"T_RARROW",55:"T_ERRORTOKEN",56:"T_N_TOKENS",256:"T_NT_OFFSET"};goog.exportSymbol("Sk.Tokenizer",Sk.Tokenizer);
goog.exportSymbol("Sk.Tokenizer.prototype.generateTokens",Sk.Tokenizer.prototype.generateTokens);goog.exportSymbol("Sk.Tokenizer.tokenNames",Sk.Tokenizer.tokenNames);Sk.OpMap={"(":Sk.Tokenizer.Tokens.T_LPAR,")":Sk.Tokenizer.Tokens.T_RPAR,"[":Sk.Tokenizer.Tokens.T_LSQB,"]":Sk.Tokenizer.Tokens.T_RSQB,":":Sk.Tokenizer.Tokens.T_COLON,",":Sk.Tokenizer.Tokens.T_COMMA,";":Sk.Tokenizer.Tokens.T_SEMI,"+":Sk.Tokenizer.Tokens.T_PLUS,"-":Sk.Tokenizer.Tokens.T_MINUS,"*":Sk.Tokenizer.Tokens.T_STAR,"/":Sk.Tokenizer.Tokens.T_SLASH,"|":Sk.Tokenizer.Tokens.T_VBAR,"&":Sk.Tokenizer.Tokens.T_AMPER,"<":Sk.Tokenizer.Tokens.T_LESS,">":Sk.Tokenizer.Tokens.T_GREATER,"=":Sk.Tokenizer.Tokens.T_EQUAL,
".":Sk.Tokenizer.Tokens.T_DOT,"%":Sk.Tokenizer.Tokens.T_PERCENT,"`":Sk.Tokenizer.Tokens.T_BACKQUOTE,"{":Sk.Tokenizer.Tokens.T_LBRACE,"}":Sk.Tokenizer.Tokens.T_RBRACE,"@":Sk.Tokenizer.Tokens.T_AT,"==":Sk.Tokenizer.Tokens.T_EQEQUAL,"!=":Sk.Tokenizer.Tokens.T_NOTEQUAL,"<>":Sk.Tokenizer.Tokens.T_NOTEQUAL,"<=":Sk.Tokenizer.Tokens.T_LESSEQUAL,">=":Sk.Tokenizer.Tokens.T_GREATEREQUAL,"~":Sk.Tokenizer.Tokens.T_TILDE,"^":Sk.Tokenizer.Tokens.T_CIRCUMFLEX,"<<":Sk.Tokenizer.Tokens.T_LEFTSHIFT,">>":Sk.Tokenizer.Tokens.T_RIGHTSHIFT,
"**":Sk.Tokenizer.Tokens.T_DOUBLESTAR,"+=":Sk.Tokenizer.Tokens.T_PLUSEQUAL,"-=":Sk.Tokenizer.Tokens.T_MINEQUAL,"*=":Sk.Tokenizer.Tokens.T_STAREQUAL,"/=":Sk.Tokenizer.Tokens.T_SLASHEQUAL,"%=":Sk.Tokenizer.Tokens.T_PERCENTEQUAL,"&=":Sk.Tokenizer.Tokens.T_AMPEREQUAL,"|=":Sk.Tokenizer.Tokens.T_VBAREQUAL,"^=":Sk.Tokenizer.Tokens.T_CIRCUMFLEXEQUAL,"<<=":Sk.Tokenizer.Tokens.T_LEFTSHIFTEQUAL,">>=":Sk.Tokenizer.Tokens.T_RIGHTSHIFTEQUAL,"**=":Sk.Tokenizer.Tokens.T_DOUBLESTAREQUAL,"//":Sk.Tokenizer.Tokens.T_DOUBLESLASH,
"//=":Sk.Tokenizer.Tokens.T_DOUBLESLASHEQUAL,"->":Sk.Tokenizer.Tokens.T_RARROW};
Sk.ParseTables={sym:{and_expr:257,and_test:258,arglist:259,argument:260,arith_expr:261,assert_stmt:262,atom:263,augassign:264,break_stmt:265,classdef:266,comp_op:267,comparison:268,compound_stmt:269,continue_stmt:270,decorated:271,decorator:272,decorators:273,del_stmt:274,dictmaker:275,dotted_as_name:276,dotted_as_names:277,dotted_name:278,encoding_decl:279,eval_input:280,except_clause:281,exec_stmt:282,expr:283,expr_stmt:284,exprlist:285,factor:286,file_input:287,flow_stmt:288,for_stmt:289,fpdef:290,
fplist:291,funcdef:292,gen_for:293,gen_if:294,gen_iter:295,global_stmt:296,if_stmt:297,import_as_name:298,import_as_names:299,import_from:300,import_name:301,import_stmt:302,lambdef:303,list_for:304,list_if:305,list_iter:306,listmaker:307,not_test:308,old_lambdef:309,old_test:310,or_test:311,parameters:312,pass_stmt:313,power:314,print_stmt:315,raise_stmt:316,return_stmt:317,shift_expr:318,simple_stmt:319,single_input:256,sliceop:320,small_stmt:321,stmt:322,subscript:323,subscriptlist:324,suite:325,
term:326,test:327,testlist:328,testlist1:329,testlist_gexp:330,testlist_safe:331,trailer:332,try_stmt:333,varargslist:334,while_stmt:335,with_stmt:336,with_var:337,xor_expr:338,yield_expr:339,yield_stmt:340},number2symbol:{256:"single_input",257:"and_expr",258:"and_test",259:"arglist",260:"argument",261:"arith_expr",262:"assert_stmt",263:"atom",264:"augassign",265:"break_stmt",266:"classdef",267:"comp_op",268:"comparison",269:"compound_stmt",270:"continue_stmt",271:"decorated",272:"decorator",273:"decorators",
274:"del_stmt",275:"dictmaker",276:"dotted_as_name",277:"dotted_as_names",278:"dotted_name",279:"encoding_decl",280:"eval_input",281:"except_clause",282:"exec_stmt",283:"expr",284:"expr_stmt",285:"exprlist",286:"factor",287:"file_input",288:"flow_stmt",289:"for_stmt",290:"fpdef",291:"fplist",292:"funcdef",293:"gen_for",294:"gen_if",295:"gen_iter",296:"global_stmt",297:"if_stmt",298:"import_as_name",299:"import_as_names",300:"import_from",301:"import_name",302:"import_stmt",303:"lambdef",304:"list_for",
305:"list_if",306:"list_iter",307:"listmaker",308:"not_test",309:"old_lambdef",310:"old_test",311:"or_test",312:"parameters",313:"pass_stmt",314:"power",315:"print_stmt",316:"raise_stmt",317:"return_stmt",318:"shift_expr",319:"simple_stmt",320:"sliceop",321:"small_stmt",322:"stmt",323:"subscript",324:"subscriptlist",325:"suite",326:"term",327:"test",328:"testlist",329:"testlist1",330:"testlist_gexp",331:"testlist_safe",332:"trailer",333:"try_stmt",334:"varargslist",335:"while_stmt",336:"with_stmt",
337:"with_var",338:"xor_expr",339:"yield_expr",340:"yield_stmt"},dfas:{256:[[[[1,1],[2,1],[3,2]],[[0,1]],[[2,1]]],{2:1,4:1,5:1,6:1,7:1,8:1,9:1,10:1,11:1,12:1,13:1,14:1,15:1,16:1,17:1,18:1,19:1,20:1,21:1,22:1,23:1,24:1,25:1,26:1,27:1,28:1,29:1,30:1,31:1,32:1,33:1,34:1,35:1,36:1}],257:[[[[37,1]],[[38,0],[0,1]]],{6:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1}],258:[[[[39,1]],[[40,0],[0,1]]],{6:1,7:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1}],259:[[[[41,1],[42,2],[43,3]],[[44,4]],[[45,5],[0,2]],[[44,
6]],[[45,7],[0,4]],[[41,1],[42,2],[43,3],[0,5]],[[0,6]],[[42,4],[43,3]]],{6:1,7:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1,36:1,41:1,43:1}],260:[[[[44,1]],[[46,2],[47,3],[0,1]],[[0,2]],[[44,2]]],{6:1,7:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1,36:1}],261:[[[[48,1]],[[24,0],[35,0],[0,1]]],{6:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1}],262:[[[[19,1]],[[44,2]],[[45,3],[0,2]],[[44,4]],[[0,4]]],{19:1}],263:[[[[17,1],[8,2],[9,5],[28,4],[11,3],[13,6],[20,2]],[[17,1],[0,1]],[[0,2]],[[49,7],[50,2]],
[[51,2],[52,8],[53,8]],[[54,9],[55,2]],[[56,10]],[[50,2]],[[51,2]],[[55,2]],[[13,2]]],{8:1,9:1,11:1,13:1,17:1,20:1,28:1}],264:[[[[57,1],[58,1],[59,1],[60,1],[61,1],[62,1],[63,1],[64,1],[65,1],[66,1],[67,1],[68,1]],[[0,1]]],{57:1,58:1,59:1,60:1,61:1,62:1,63:1,64:1,65:1,66:1,67:1,68:1}],265:[[[[31,1]],[[0,1]]],{31:1}],266:[[[[10,1]],[[20,2]],[[69,3],[28,4]],[[70,5]],[[51,6],[71,7]],[[0,5]],[[69,3]],[[51,6]]],{10:1}],267:[[[[72,1],[73,1],[7,2],[74,1],[72,1],[75,1],[76,1],[77,3],[78,1],[79,1]],[[0,1]],
[[75,1]],[[7,1],[0,3]]],{7:1,72:1,73:1,74:1,75:1,76:1,77:1,78:1,79:1}],268:[[[[80,1]],[[81,0],[0,1]]],{6:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1}],269:[[[[82,1],[83,1],[84,1],[85,1],[86,1],[87,1],[88,1],[89,1]],[[0,1]]],{4:1,10:1,14:1,16:1,27:1,30:1,33:1,34:1}],270:[[[[32,1]],[[0,1]]],{32:1}],271:[[[[90,1]],[[88,2],[85,2]],[[0,2]]],{33:1}],272:[[[[33,1]],[[91,2]],[[28,4],[2,3]],[[0,3]],[[51,5],[92,6]],[[2,3]],[[51,5]]],{33:1}],273:[[[[93,1]],[[93,1],[0,1]]],{33:1}],274:[[[[21,1]],[[94,2]],[[0,
2]]],{21:1}],275:[[[[44,1]],[[69,2]],[[44,3]],[[45,4],[0,3]],[[44,1],[0,4]]],{6:1,7:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1,36:1}],276:[[[[91,1]],[[95,2],[0,1]],[[20,3]],[[0,3]]],{20:1}],277:[[[[96,1]],[[45,0],[0,1]]],{20:1}],278:[[[[20,1]],[[97,0],[0,1]]],{20:1}],279:[[[[20,1]],[[0,1]]],{20:1}],280:[[[[71,1]],[[2,1],[98,2]],[[0,2]]],{6:1,7:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1,36:1}],281:[[[[99,1]],[[44,2],[0,1]],[[95,3],[45,3],[0,2]],[[44,4]],[[0,4]]],{99:1}],282:[[[[15,1]],[[80,2]],
[[75,3],[0,2]],[[44,4]],[[45,5],[0,4]],[[44,6]],[[0,6]]],{15:1}],283:[[[[100,1]],[[101,0],[0,1]]],{6:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1}],284:[[[[71,1]],[[102,2],[47,3],[0,1]],[[71,4],[53,4]],[[71,5],[53,5]],[[0,4]],[[47,3],[0,5]]],{6:1,7:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1,36:1}],285:[[[[80,1]],[[45,2],[0,1]],[[80,1],[0,2]]],{6:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1}],286:[[[[103,2],[24,1],[6,1],[35,1]],[[104,2]],[[0,2]]],{6:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1}],
287:[[[[2,0],[98,1],[105,0]],[[0,1]]],{2:1,4:1,5:1,6:1,7:1,8:1,9:1,10:1,11:1,12:1,13:1,14:1,15:1,16:1,17:1,18:1,19:1,20:1,21:1,22:1,23:1,24:1,25:1,26:1,27:1,28:1,29:1,30:1,31:1,32:1,33:1,34:1,35:1,36:1,98:1}],288:[[[[106,1],[107,1],[108,1],[109,1],[110,1]],[[0,1]]],{5:1,18:1,25:1,31:1,32:1}],289:[[[[27,1]],[[94,2]],[[75,3]],[[71,4]],[[69,5]],[[70,6]],[[111,7],[0,6]],[[69,8]],[[70,9]],[[0,9]]],{27:1}],290:[[[[28,1],[20,2]],[[112,3]],[[0,2]],[[51,2]]],{20:1,28:1}],291:[[[[113,1]],[[45,2],[0,1]],[[113,
1],[0,2]]],{20:1,28:1}],292:[[[[4,1]],[[20,2]],[[114,3]],[[69,4]],[[70,5]],[[0,5]]],{4:1}],293:[[[[27,1]],[[94,2]],[[75,3]],[[115,4]],[[116,5],[0,4]],[[0,5]]],{27:1}],294:[[[[30,1]],[[117,2]],[[116,3],[0,2]],[[0,3]]],{30:1}],295:[[[[46,1],[118,1]],[[0,1]]],{27:1,30:1}],296:[[[[26,1]],[[20,2]],[[45,1],[0,2]]],{26:1}],297:[[[[30,1]],[[44,2]],[[69,3]],[[70,4]],[[111,5],[119,1],[0,4]],[[69,6]],[[70,7]],[[0,7]]],{30:1}],298:[[[[20,1]],[[95,2],[0,1]],[[20,3]],[[0,3]]],{20:1}],299:[[[[120,1]],[[45,2],[0,
1]],[[120,1],[0,2]]],{20:1}],300:[[[[29,1]],[[91,2],[97,3]],[[23,4]],[[91,2],[23,4],[97,3]],[[121,5],[41,5],[28,6]],[[0,5]],[[121,7]],[[51,5]]],{29:1}],301:[[[[23,1]],[[122,2]],[[0,2]]],{23:1}],302:[[[[123,1],[124,1]],[[0,1]]],{23:1,29:1}],303:[[[[36,1]],[[69,2],[125,3]],[[44,4]],[[69,2]],[[0,4]]],{36:1}],304:[[[[27,1]],[[94,2]],[[75,3]],[[126,4]],[[127,5],[0,4]],[[0,5]]],{27:1}],305:[[[[30,1]],[[117,2]],[[127,3],[0,2]],[[0,3]]],{30:1}],306:[[[[128,1],[129,1]],[[0,1]]],{27:1,30:1}],307:[[[[44,1]],
[[128,2],[45,3],[0,1]],[[0,2]],[[44,4],[0,3]],[[45,3],[0,4]]],{6:1,7:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1,36:1}],308:[[[[7,1],[130,2]],[[39,2]],[[0,2]]],{6:1,7:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1}],309:[[[[36,1]],[[69,2],[125,3]],[[117,4]],[[69,2]],[[0,4]]],{36:1}],310:[[[[131,1],[115,1]],[[0,1]]],{6:1,7:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1,36:1}],311:[[[[132,1]],[[133,0],[0,1]]],{6:1,7:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1}],312:[[[[28,1]],[[51,2],[125,3]],[[0,2]],
[[51,2]]],{28:1}],313:[[[[22,1]],[[0,1]]],{22:1}],314:[[[[134,1]],[[135,1],[43,2],[0,1]],[[104,3]],[[0,3]]],{8:1,9:1,11:1,13:1,17:1,20:1,28:1}],315:[[[[12,1]],[[44,2],[136,3],[0,1]],[[45,4],[0,2]],[[44,5]],[[44,2],[0,4]],[[45,6],[0,5]],[[44,7]],[[45,8],[0,7]],[[44,7],[0,8]]],{12:1}],316:[[[[5,1]],[[44,2],[0,1]],[[45,3],[0,2]],[[44,4]],[[45,5],[0,4]],[[44,6]],[[0,6]]],{5:1}],317:[[[[18,1]],[[71,2],[0,1]],[[0,2]]],{18:1}],318:[[[[137,1]],[[136,0],[138,0],[0,1]]],{6:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,
28:1,35:1}],319:[[[[139,1]],[[2,2],[140,3]],[[0,2]],[[139,1],[2,2]]],{5:1,6:1,7:1,8:1,9:1,11:1,12:1,13:1,15:1,17:1,18:1,19:1,20:1,21:1,22:1,23:1,24:1,25:1,26:1,28:1,29:1,31:1,32:1,35:1,36:1}],320:[[[[69,1]],[[44,2],[0,1]],[[0,2]]],{69:1}],321:[[[[141,1],[142,1],[143,1],[144,1],[145,1],[146,1],[147,1],[148,1],[149,1]],[[0,1]]],{5:1,6:1,7:1,8:1,9:1,11:1,12:1,13:1,15:1,17:1,18:1,19:1,20:1,21:1,22:1,23:1,24:1,25:1,26:1,28:1,29:1,31:1,32:1,35:1,36:1}],322:[[[[1,1],[3,1]],[[0,1]]],{4:1,5:1,6:1,7:1,8:1,
9:1,10:1,11:1,12:1,13:1,14:1,15:1,16:1,17:1,18:1,19:1,20:1,21:1,22:1,23:1,24:1,25:1,26:1,27:1,28:1,29:1,30:1,31:1,32:1,33:1,34:1,35:1,36:1}],323:[[[[44,1],[69,2],[97,3]],[[69,2],[0,1]],[[44,4],[150,5],[0,2]],[[97,6]],[[150,5],[0,4]],[[0,5]],[[97,5]]],{6:1,7:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1,36:1,69:1,97:1}],324:[[[[151,1]],[[45,2],[0,1]],[[151,1],[0,2]]],{6:1,7:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1,36:1,69:1,97:1}],325:[[[[1,1],[2,2]],[[0,1]],[[152,3]],[[105,4]],[[153,1],[105,4]]],
{2:1,5:1,6:1,7:1,8:1,9:1,11:1,12:1,13:1,15:1,17:1,18:1,19:1,20:1,21:1,22:1,23:1,24:1,25:1,26:1,28:1,29:1,31:1,32:1,35:1,36:1}],326:[[[[104,1]],[[154,0],[41,0],[155,0],[156,0],[0,1]]],{6:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1}],327:[[[[115,1],[157,2]],[[30,3],[0,1]],[[0,2]],[[115,4]],[[111,5]],[[44,2]]],{6:1,7:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1,36:1}],328:[[[[44,1]],[[45,2],[0,1]],[[44,1],[0,2]]],{6:1,7:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1,36:1}],329:[[[[44,1]],[[45,0],[0,1]]],
{6:1,7:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1,36:1}],330:[[[[44,1]],[[46,2],[45,3],[0,1]],[[0,2]],[[44,4],[0,3]],[[45,3],[0,4]]],{6:1,7:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1,36:1}],331:[[[[117,1]],[[45,2],[0,1]],[[117,3]],[[45,4],[0,3]],[[117,3],[0,4]]],{6:1,7:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1,36:1}],332:[[[[28,1],[97,2],[11,3]],[[51,4],[92,5]],[[20,4]],[[158,6]],[[0,4]],[[51,4]],[[50,4]]],{11:1,28:1,97:1}],333:[[[[14,1]],[[69,2]],[[70,3]],[[159,4],[160,5]],[[69,6]],[[69,7]],
[[70,8]],[[70,9]],[[159,4],[111,10],[160,5],[0,8]],[[0,9]],[[69,11]],[[70,12]],[[160,5],[0,12]]],{14:1}],334:[[[[41,1],[113,2],[43,3]],[[20,4]],[[47,5],[45,6],[0,2]],[[20,7]],[[45,8],[0,4]],[[44,9]],[[41,1],[113,2],[43,3],[0,6]],[[0,7]],[[43,3]],[[45,6],[0,9]]],{20:1,28:1,41:1,43:1}],335:[[[[16,1]],[[44,2]],[[69,3]],[[70,4]],[[111,5],[0,4]],[[69,6]],[[70,7]],[[0,7]]],{16:1}],336:[[[[34,1]],[[44,2]],[[69,3],[161,4]],[[70,5]],[[69,3]],[[0,5]]],{34:1}],337:[[[[95,1]],[[80,2]],[[0,2]]],{95:1}],338:[[[[162,
1]],[[163,0],[0,1]]],{6:1,8:1,9:1,11:1,13:1,17:1,20:1,24:1,28:1,35:1}],339:[[[[25,1]],[[71,2],[0,1]],[[0,2]]],{25:1}],340:[[[[53,1]],[[0,1]]],{25:1}]},states:[[[[1,1],[2,1],[3,2]],[[0,1]],[[2,1]]],[[[37,1]],[[38,0],[0,1]]],[[[39,1]],[[40,0],[0,1]]],[[[41,1],[42,2],[43,3]],[[44,4]],[[45,5],[0,2]],[[44,6]],[[45,7],[0,4]],[[41,1],[42,2],[43,3],[0,5]],[[0,6]],[[42,4],[43,3]]],[[[44,1]],[[46,2],[47,3],[0,1]],[[0,2]],[[44,2]]],[[[48,1]],[[24,0],[35,0],[0,1]]],[[[19,1]],[[44,2]],[[45,3],[0,2]],[[44,4]],
[[0,4]]],[[[17,1],[8,2],[9,5],[28,4],[11,3],[13,6],[20,2]],[[17,1],[0,1]],[[0,2]],[[49,7],[50,2]],[[51,2],[52,8],[53,8]],[[54,9],[55,2]],[[56,10]],[[50,2]],[[51,2]],[[55,2]],[[13,2]]],[[[57,1],[58,1],[59,1],[60,1],[61,1],[62,1],[63,1],[64,1],[65,1],[66,1],[67,1],[68,1]],[[0,1]]],[[[31,1]],[[0,1]]],[[[10,1]],[[20,2]],[[69,3],[28,4]],[[70,5]],[[51,6],[71,7]],[[0,5]],[[69,3]],[[51,6]]],[[[72,1],[73,1],[7,2],[74,1],[72,1],[75,1],[76,1],[77,3],[78,1],[79,1]],[[0,1]],[[75,1]],[[7,1],[0,3]]],[[[80,1]],[[81,
0],[0,1]]],[[[82,1],[83,1],[84,1],[85,1],[86,1],[87,1],[88,1],[89,1]],[[0,1]]],[[[32,1]],[[0,1]]],[[[90,1]],[[88,2],[85,2]],[[0,2]]],[[[33,1]],[[91,2]],[[28,4],[2,3]],[[0,3]],[[51,5],[92,6]],[[2,3]],[[51,5]]],[[[93,1]],[[93,1],[0,1]]],[[[21,1]],[[94,2]],[[0,2]]],[[[44,1]],[[69,2]],[[44,3]],[[45,4],[0,3]],[[44,1],[0,4]]],[[[91,1]],[[95,2],[0,1]],[[20,3]],[[0,3]]],[[[96,1]],[[45,0],[0,1]]],[[[20,1]],[[97,0],[0,1]]],[[[20,1]],[[0,1]]],[[[71,1]],[[2,1],[98,2]],[[0,2]]],[[[99,1]],[[44,2],[0,1]],[[95,3],
[45,3],[0,2]],[[44,4]],[[0,4]]],[[[15,1]],[[80,2]],[[75,3],[0,2]],[[44,4]],[[45,5],[0,4]],[[44,6]],[[0,6]]],[[[100,1]],[[101,0],[0,1]]],[[[71,1]],[[102,2],[47,3],[0,1]],[[71,4],[53,4]],[[71,5],[53,5]],[[0,4]],[[47,3],[0,5]]],[[[80,1]],[[45,2],[0,1]],[[80,1],[0,2]]],[[[103,2],[24,1],[6,1],[35,1]],[[104,2]],[[0,2]]],[[[2,0],[98,1],[105,0]],[[0,1]]],[[[106,1],[107,1],[108,1],[109,1],[110,1]],[[0,1]]],[[[27,1]],[[94,2]],[[75,3]],[[71,4]],[[69,5]],[[70,6]],[[111,7],[0,6]],[[69,8]],[[70,9]],[[0,9]]],[[[28,
1],[20,2]],[[112,3]],[[0,2]],[[51,2]]],[[[113,1]],[[45,2],[0,1]],[[113,1],[0,2]]],[[[4,1]],[[20,2]],[[114,3]],[[69,4]],[[70,5]],[[0,5]]],[[[27,1]],[[94,2]],[[75,3]],[[115,4]],[[116,5],[0,4]],[[0,5]]],[[[30,1]],[[117,2]],[[116,3],[0,2]],[[0,3]]],[[[46,1],[118,1]],[[0,1]]],[[[26,1]],[[20,2]],[[45,1],[0,2]]],[[[30,1]],[[44,2]],[[69,3]],[[70,4]],[[111,5],[119,1],[0,4]],[[69,6]],[[70,7]],[[0,7]]],[[[20,1]],[[95,2],[0,1]],[[20,3]],[[0,3]]],[[[120,1]],[[45,2],[0,1]],[[120,1],[0,2]]],[[[29,1]],[[91,2],[97,
3]],[[23,4]],[[91,2],[23,4],[97,3]],[[121,5],[41,5],[28,6]],[[0,5]],[[121,7]],[[51,5]]],[[[23,1]],[[122,2]],[[0,2]]],[[[123,1],[124,1]],[[0,1]]],[[[36,1]],[[69,2],[125,3]],[[44,4]],[[69,2]],[[0,4]]],[[[27,1]],[[94,2]],[[75,3]],[[126,4]],[[127,5],[0,4]],[[0,5]]],[[[30,1]],[[117,2]],[[127,3],[0,2]],[[0,3]]],[[[128,1],[129,1]],[[0,1]]],[[[44,1]],[[128,2],[45,3],[0,1]],[[0,2]],[[44,4],[0,3]],[[45,3],[0,4]]],[[[7,1],[130,2]],[[39,2]],[[0,2]]],[[[36,1]],[[69,2],[125,3]],[[117,4]],[[69,2]],[[0,4]]],[[[131,
1],[115,1]],[[0,1]]],[[[132,1]],[[133,0],[0,1]]],[[[28,1]],[[51,2],[125,3]],[[0,2]],[[51,2]]],[[[22,1]],[[0,1]]],[[[134,1]],[[135,1],[43,2],[0,1]],[[104,3]],[[0,3]]],[[[12,1]],[[44,2],[136,3],[0,1]],[[45,4],[0,2]],[[44,5]],[[44,2],[0,4]],[[45,6],[0,5]],[[44,7]],[[45,8],[0,7]],[[44,7],[0,8]]],[[[5,1]],[[44,2],[0,1]],[[45,3],[0,2]],[[44,4]],[[45,5],[0,4]],[[44,6]],[[0,6]]],[[[18,1]],[[71,2],[0,1]],[[0,2]]],[[[137,1]],[[136,0],[138,0],[0,1]]],[[[139,1]],[[2,2],[140,3]],[[0,2]],[[139,1],[2,2]]],[[[69,
1]],[[44,2],[0,1]],[[0,2]]],[[[141,1],[142,1],[143,1],[144,1],[145,1],[146,1],[147,1],[148,1],[149,1]],[[0,1]]],[[[1,1],[3,1]],[[0,1]]],[[[44,1],[69,2],[97,3]],[[69,2],[0,1]],[[44,4],[150,5],[0,2]],[[97,6]],[[150,5],[0,4]],[[0,5]],[[97,5]]],[[[151,1]],[[45,2],[0,1]],[[151,1],[0,2]]],[[[1,1],[2,2]],[[0,1]],[[152,3]],[[105,4]],[[153,1],[105,4]]],[[[104,1]],[[154,0],[41,0],[155,0],[156,0],[0,1]]],[[[115,1],[157,2]],[[30,3],[0,1]],[[0,2]],[[115,4]],[[111,5]],[[44,2]]],[[[44,1]],[[45,2],[0,1]],[[44,1],
[0,2]]],[[[44,1]],[[45,0],[0,1]]],[[[44,1]],[[46,2],[45,3],[0,1]],[[0,2]],[[44,4],[0,3]],[[45,3],[0,4]]],[[[117,1]],[[45,2],[0,1]],[[117,3]],[[45,4],[0,3]],[[117,3],[0,4]]],[[[28,1],[97,2],[11,3]],[[51,4],[92,5]],[[20,4]],[[158,6]],[[0,4]],[[51,4]],[[50,4]]],[[[14,1]],[[69,2]],[[70,3]],[[159,4],[160,5]],[[69,6]],[[69,7]],[[70,8]],[[70,9]],[[159,4],[111,10],[160,5],[0,8]],[[0,9]],[[69,11]],[[70,12]],[[160,5],[0,12]]],[[[41,1],[113,2],[43,3]],[[20,4]],[[47,5],[45,6],[0,2]],[[20,7]],[[45,8],[0,4]],[[44,
9]],[[41,1],[113,2],[43,3],[0,6]],[[0,7]],[[43,3]],[[45,6],[0,9]]],[[[16,1]],[[44,2]],[[69,3]],[[70,4]],[[111,5],[0,4]],[[69,6]],[[70,7]],[[0,7]]],[[[34,1]],[[44,2]],[[69,3],[161,4]],[[70,5]],[[69,3]],[[0,5]]],[[[95,1]],[[80,2]],[[0,2]]],[[[162,1]],[[163,0],[0,1]]],[[[25,1]],[[71,2],[0,1]],[[0,2]]],[[[53,1]],[[0,1]]]],labels:[[0,"EMPTY"],[319,null],[4,null],[269,null],[1,"def"],[1,"raise"],[32,null],[1,"not"],[2,null],[26,null],[1,"class"],[9,null],[1,"print"],[25,null],[1,"try"],[1,"exec"],[1,"while"],
[3,null],[1,"return"],[1,"assert"],[1,null],[1,"del"],[1,"pass"],[1,"import"],[15,null],[1,"yield"],[1,"global"],[1,"for"],[7,null],[1,"from"],[1,"if"],[1,"break"],[1,"continue"],[50,null],[1,"with"],[14,null],[1,"lambda"],[318,null],[19,null],[308,null],[1,"and"],[16,null],[260,null],[36,null],[327,null],[12,null],[293,null],[22,null],[326,null],[307,null],[10,null],[8,null],[330,null],[339,null],[275,null],[27,null],[329,null],[46,null],[39,null],[41,null],[47,null],[42,null],[43,null],[37,null],
[44,null],[49,null],[40,null],[38,null],[45,null],[11,null],[325,null],[328,null],[29,null],[21,null],[28,null],[1,"in"],[30,null],[1,"is"],[31,null],[20,null],[283,null],[267,null],[333,null],[297,null],[289,null],[266,null],[336,null],[335,null],[292,null],[271,null],[273,null],[278,null],[259,null],[272,null],[285,null],[1,"as"],[276,null],[23,null],[0,null],[1,"except"],[338,null],[18,null],[264,null],[314,null],[286,null],[322,null],[265,null],[270,null],[316,null],[317,null],[340,null],[1,"else"],
[291,null],[290,null],[312,null],[311,null],[295,null],[310,null],[294,null],[1,"elif"],[298,null],[299,null],[277,null],[301,null],[300,null],[334,null],[331,null],[306,null],[304,null],[305,null],[268,null],[309,null],[258,null],[1,"or"],[263,null],[332,null],[35,null],[261,null],[34,null],[321,null],[13,null],[288,null],[262,null],[284,null],[313,null],[315,null],[274,null],[282,null],[296,null],[302,null],[320,null],[323,null],[5,null],[6,null],[48,null],[17,null],[24,null],[303,null],[324,null],
[281,null],[1,"finally"],[337,null],[257,null],[33,null]],keywords:{and:40,as:95,assert:19,"break":31,"class":10,"continue":32,def:4,del:21,elif:119,"else":111,except:99,exec:15,"finally":160,"for":27,from:29,global:26,"if":30,"import":23,"in":75,is:77,lambda:36,not:7,or:133,pass:22,print:12,raise:5,"return":18,"try":14,"while":16,"with":34,yield:25},tokens:{0:98,1:20,2:8,3:17,4:2,5:152,6:153,7:28,8:51,9:11,10:50,11:69,12:45,13:140,14:35,15:24,16:41,17:155,18:101,19:38,20:79,21:73,22:47,23:97,24:156,
25:13,26:9,27:55,28:74,29:72,30:76,31:78,32:6,33:163,34:138,35:136,36:43,37:63,38:67,39:58,40:66,41:59,42:61,43:62,44:64,45:68,46:57,47:60,48:154,49:65,50:33},start:256};function Parser(a,b){this.filename=a;this.grammar=b;return this}Parser.prototype.setup=function(a){a=a||this.grammar.start;this.stack=[{dfa:this.grammar.dfas[a],state:0,node:{type:a,value:null,context:null,children:[]}}];this.used_names={}};function findInDfa(a,b){for(var c=a.length;c--;)if(a[c][0]===b[0]&&a[c][1]===b[1])return!0;return!1}
Parser.prototype.addtoken=function(a,b,c){var d=this.classify(a,b,c);a:for(;;){for(var e=this.stack[this.stack.length-1],f=e.dfa[0],g=f[e.state],h=0;h<g.length;++h){var k=g[h][0],l=g[h][1],m=this.grammar.labels[k][0];if(d===k){goog.asserts.assert(256>m);this.shift(a,b,l,c);for(a=l;1===f[a].length&&0===f[a][0][0]&&f[a][0][1]===a;){this.pop();if(0===this.stack.length)return!0;e=this.stack[this.stack.length-1];a=e.state;f=e.dfa[0]}return!1}if(256<=m&&this.grammar.dfas[m][1].hasOwnProperty(d)){this.push(m,
this.grammar.dfas[m],l,c);continue a}}if(findInDfa(g,[0,e.state])){if(this.pop(),0===this.stack.length)throw new Sk.builtin.ParseError("too much input",this.filename);}else throw new Sk.builtin.ParseError("bad input",this.filename,c[0][0],c);}};
Parser.prototype.classify=function(a,b,c){if(a===Sk.Tokenizer.Tokens.T_NAME&&(this.used_names[b]=!0,b=this.grammar.keywords.hasOwnProperty(b)&&this.grammar.keywords[b]))return b;b=this.grammar.tokens.hasOwnProperty(a)&&this.grammar.tokens[a];if(!b)throw new Sk.builtin.ParseError("bad token",this.filename,c[0][0],c);return b};
Parser.prototype.shift=function(a,b,c,d){var e=this.stack[this.stack.length-1].dfa,f=this.stack[this.stack.length-1].node;f.children.push({type:a,value:b,lineno:d[0][0],col_offset:d[0][1],children:null});this.stack[this.stack.length-1]={dfa:e,state:c,node:f}};
Parser.prototype.push=function(a,b,c,d){a={type:a,value:null,lineno:d[0][0],col_offset:d[0][1],children:[]};this.stack[this.stack.length-1]={dfa:this.stack[this.stack.length-1].dfa,state:c,node:this.stack[this.stack.length-1].node};this.stack.push({dfa:b,state:0,node:a})};Parser.prototype.pop=function(){var a=this.stack.pop().node;a&&(0!==this.stack.length?this.stack[this.stack.length-1].node.children.push(a):(this.rootnode=a,this.rootnode.used_names=this.used_names))};
function makeParser(a,b){void 0===b&&(b="file_input");var c=new Parser(a,Sk.ParseTables);"file_input"===b?c.setup(Sk.ParseTables.sym.file_input):goog.asserts.fail("todo;");var d=Sk.Tokenizer.Tokens.T_COMMENT,e=Sk.Tokenizer.Tokens.T_NL,f=Sk.Tokenizer.Tokens.T_OP,g=new Sk.Tokenizer(a,"single_input"===b,function(a,b,g,m,n){if(a!==d&&a!==e&&(a===f&&(a=Sk.OpMap[b]),c.addtoken(a,b,[g,m,n])))return!0});return function(a){if(a=g.generateTokens(a)){if("done"!==a)throw new Sk.builtin.ParseError("incomplete input",
this.filename);return c.rootnode}return!1}}Sk.parse=function(a,b){var c=makeParser(a);"\n"!==b.substr(b.length-1,1)&&(b+="\n");for(var d=b.split("\n"),e,f=0;f<d.length;++f)e=c(d[f]+(f===d.length-1?"":"\n"));return e};Sk.parseTreeDump=function(a,b){b=b||"";var c;c=""+b;if(256<=a.type){c+=Sk.ParseTables.number2symbol[a.type]+"\n";for(var d=0;d<a.children.length;++d)c+=Sk.parseTreeDump(a.children[d],b+" ")}else c+=Sk.Tokenizer.tokenNames[a.type]+": "+(new Sk.builtin.str(a.value)).$r().v+"\n";return c};
goog.exportSymbol("Sk.parse",Sk.parse);goog.exportSymbol("Sk.parseTreeDump",Sk.parseTreeDump);function Load(){}function Store(){}function Del(){}function AugLoad(){}function AugStore(){}function Param(){}function And(){}function Or(){}function Add(){}function Sub(){}function Mult(){}function Div(){}function Mod(){}function Pow(){}function LShift(){}function RShift(){}function BitOr(){}function BitXor(){}function BitAnd(){}function FloorDiv(){}function Invert(){}function Not(){}function UAdd(){}function USub(){}function Eq(){}function NotEq(){}function Lt(){}function LtE(){}
function Gt(){}function GtE(){}function Is(){}function IsNot(){}function In_(){}function NotIn(){}function Module(a){this.body=a;return this}function Interactive(a){this.body=a;return this}function Expression(a){goog.asserts.assert(null!==a&&void 0!==a);this.body=a;return this}function Suite(a){this.body=a;return this}
function FunctionDef(a,b,c,d,e,f){goog.asserts.assert(null!==a&&void 0!==a);goog.asserts.assert(null!==b&&void 0!==b);this.name=a;this.args=b;this.body=c;this.decorator_list=d;this.lineno=e;this.col_offset=f;return this}function ClassDef(a,b,c,d,e,f){goog.asserts.assert(null!==a&&void 0!==a);this.name=a;this.bases=b;this.body=c;this.decorator_list=d;this.lineno=e;this.col_offset=f;return this}function Return_(a,b,c){this.value=a;this.lineno=b;this.col_offset=c;return this}
function Delete_(a,b,c){this.targets=a;this.lineno=b;this.col_offset=c;return this}function Assign(a,b,c,d){goog.asserts.assert(null!==b&&void 0!==b);this.targets=a;this.value=b;this.lineno=c;this.col_offset=d;return this}function AugAssign(a,b,c,d,e){goog.asserts.assert(null!==a&&void 0!==a);goog.asserts.assert(null!==b&&void 0!==b);goog.asserts.assert(null!==c&&void 0!==c);this.target=a;this.op=b;this.value=c;this.lineno=d;this.col_offset=e;return this}
function Print(a,b,c,d,e){this.dest=a;this.values=b;this.nl=c;this.lineno=d;this.col_offset=e;return this}function For_(a,b,c,d,e,f){goog.asserts.assert(null!==a&&void 0!==a);goog.asserts.assert(null!==b&&void 0!==b);this.target=a;this.iter=b;this.body=c;this.orelse=d;this.lineno=e;this.col_offset=f;return this}function While_(a,b,c,d,e){goog.asserts.assert(null!==a&&void 0!==a);this.test=a;this.body=b;this.orelse=c;this.lineno=d;this.col_offset=e;return this}
function If_(a,b,c,d,e){goog.asserts.assert(null!==a&&void 0!==a);this.test=a;this.body=b;this.orelse=c;this.lineno=d;this.col_offset=e;return this}function With_(a,b,c,d,e){goog.asserts.assert(null!==a&&void 0!==a);this.context_expr=a;this.optional_vars=b;this.body=c;this.lineno=d;this.col_offset=e;return this}function Raise(a,b,c,d,e){this.type=a;this.inst=b;this.tback=c;this.lineno=d;this.col_offset=e;return this}
function TryExcept(a,b,c,d,e){this.body=a;this.handlers=b;this.orelse=c;this.lineno=d;this.col_offset=e;return this}function TryFinally(a,b,c,d){this.body=a;this.finalbody=b;this.lineno=c;this.col_offset=d;return this}function Assert(a,b,c,d){goog.asserts.assert(null!==a&&void 0!==a);this.test=a;this.msg=b;this.lineno=c;this.col_offset=d;return this}function Import_(a,b,c){this.names=a;this.lineno=b;this.col_offset=c;return this}
function ImportFrom(a,b,c,d,e){goog.asserts.assert(null!==a&&void 0!==a);this.module=a;this.names=b;this.level=c;this.lineno=d;this.col_offset=e;return this}function Exec(a,b,c,d,e){goog.asserts.assert(null!==a&&void 0!==a);this.body=a;this.globals=b;this.locals=c;this.lineno=d;this.col_offset=e;return this}function Global(a,b,c){this.names=a;this.lineno=b;this.col_offset=c;return this}
function Expr(a,b,c){goog.asserts.assert(null!==a&&void 0!==a);this.value=a;this.lineno=b;this.col_offset=c;return this}function Pass(a,b){this.lineno=a;this.col_offset=b;return this}function Break_(a,b){this.lineno=a;this.col_offset=b;return this}function Continue_(a,b){this.lineno=a;this.col_offset=b;return this}function BoolOp(a,b,c,d){goog.asserts.assert(null!==a&&void 0!==a);this.op=a;this.values=b;this.lineno=c;this.col_offset=d;return this}
function BinOp(a,b,c,d,e){goog.asserts.assert(null!==a&&void 0!==a);goog.asserts.assert(null!==b&&void 0!==b);goog.asserts.assert(null!==c&&void 0!==c);this.left=a;this.op=b;this.right=c;this.lineno=d;this.col_offset=e;return this}function UnaryOp(a,b,c,d){goog.asserts.assert(null!==a&&void 0!==a);goog.asserts.assert(null!==b&&void 0!==b);this.op=a;this.operand=b;this.lineno=c;this.col_offset=d;return this}
function Lambda(a,b,c,d){goog.asserts.assert(null!==a&&void 0!==a);goog.asserts.assert(null!==b&&void 0!==b);this.args=a;this.body=b;this.lineno=c;this.col_offset=d;return this}function IfExp(a,b,c,d,e){goog.asserts.assert(null!==a&&void 0!==a);goog.asserts.assert(null!==b&&void 0!==b);goog.asserts.assert(null!==c&&void 0!==c);this.test=a;this.body=b;this.orelse=c;this.lineno=d;this.col_offset=e;return this}
function Dict(a,b,c,d){this.keys=a;this.values=b;this.lineno=c;this.col_offset=d;return this}function ListComp(a,b,c,d){goog.asserts.assert(null!==a&&void 0!==a);this.elt=a;this.generators=b;this.lineno=c;this.col_offset=d;return this}function GeneratorExp(a,b,c,d){goog.asserts.assert(null!==a&&void 0!==a);this.elt=a;this.generators=b;this.lineno=c;this.col_offset=d;return this}function Yield(a,b,c){this.value=a;this.lineno=b;this.col_offset=c;return this}
function Compare(a,b,c,d,e){goog.asserts.assert(null!==a&&void 0!==a);this.left=a;this.ops=b;this.comparators=c;this.lineno=d;this.col_offset=e;return this}function Call(a,b,c,d,e,f,g){goog.asserts.assert(null!==a&&void 0!==a);this.func=a;this.args=b;this.keywords=c;this.starargs=d;this.kwargs=e;this.lineno=f;this.col_offset=g;return this}function Num(a,b,c){goog.asserts.assert(null!==a&&void 0!==a);this.n=a;this.lineno=b;this.col_offset=c;return this}
function Str(a,b,c){goog.asserts.assert(null!==a&&void 0!==a);this.s=a;this.lineno=b;this.col_offset=c;return this}function Attribute(a,b,c,d,e){goog.asserts.assert(null!==a&&void 0!==a);goog.asserts.assert(null!==b&&void 0!==b);goog.asserts.assert(null!==c&&void 0!==c);this.value=a;this.attr=b;this.ctx=c;this.lineno=d;this.col_offset=e;return this}
function Subscript(a,b,c,d,e){goog.asserts.assert(null!==a&&void 0!==a);goog.asserts.assert(null!==b&&void 0!==b);goog.asserts.assert(null!==c&&void 0!==c);this.value=a;this.slice=b;this.ctx=c;this.lineno=d;this.col_offset=e;return this}function Name(a,b,c,d){goog.asserts.assert(null!==a&&void 0!==a);goog.asserts.assert(null!==b&&void 0!==b);this.id=a;this.ctx=b;this.lineno=c;this.col_offset=d;return this}
function List(a,b,c,d){goog.asserts.assert(null!==b&&void 0!==b);this.elts=a;this.ctx=b;this.lineno=c;this.col_offset=d;return this}function Tuple(a,b,c,d){goog.asserts.assert(null!==b&&void 0!==b);this.elts=a;this.ctx=b;this.lineno=c;this.col_offset=d;return this}function Ellipsis(){return this}function Slice(a,b,c){this.lower=a;this.upper=b;this.step=c;return this}function ExtSlice(a){this.dims=a;return this}function Index(a){goog.asserts.assert(null!==a&&void 0!==a);this.value=a;return this}
function comprehension(a,b,c){goog.asserts.assert(null!==a&&void 0!==a);goog.asserts.assert(null!==b&&void 0!==b);this.target=a;this.iter=b;this.ifs=c;return this}function ExceptHandler(a,b,c,d,e){this.type=a;this.name=b;this.body=c;this.lineno=d;this.col_offset=e;return this}function arguments_(a,b,c,d){this.args=a;this.vararg=b;this.kwarg=c;this.defaults=d;return this}
function keyword(a,b){goog.asserts.assert(null!==a&&void 0!==a);goog.asserts.assert(null!==b&&void 0!==b);this.arg=a;this.value=b;return this}function alias(a,b){goog.asserts.assert(null!==a&&void 0!==a);this.name=a;this.asname=b;return this}Module.prototype._astname="Module";Module.prototype._fields=["body",function(a){return a.body}];Interactive.prototype._astname="Interactive";Interactive.prototype._fields=["body",function(a){return a.body}];Expression.prototype._astname="Expression";
Expression.prototype._fields=["body",function(a){return a.body}];Suite.prototype._astname="Suite";Suite.prototype._fields=["body",function(a){return a.body}];FunctionDef.prototype._astname="FunctionDef";FunctionDef.prototype._fields=["name",function(a){return a.name},"args",function(a){return a.args},"body",function(a){return a.body},"decorator_list",function(a){return a.decorator_list}];ClassDef.prototype._astname="ClassDef";
ClassDef.prototype._fields=["name",function(a){return a.name},"bases",function(a){return a.bases},"body",function(a){return a.body},"decorator_list",function(a){return a.decorator_list}];Return_.prototype._astname="Return";Return_.prototype._fields=["value",function(a){return a.value}];Delete_.prototype._astname="Delete";Delete_.prototype._fields=["targets",function(a){return a.targets}];Assign.prototype._astname="Assign";Assign.prototype._fields=["targets",function(a){return a.targets},"value",function(a){return a.value}];
AugAssign.prototype._astname="AugAssign";AugAssign.prototype._fields=["target",function(a){return a.target},"op",function(a){return a.op},"value",function(a){return a.value}];Print.prototype._astname="Print";Print.prototype._fields=["dest",function(a){return a.dest},"values",function(a){return a.values},"nl",function(a){return a.nl}];For_.prototype._astname="For";
For_.prototype._fields=["target",function(a){return a.target},"iter",function(a){return a.iter},"body",function(a){return a.body},"orelse",function(a){return a.orelse}];While_.prototype._astname="While";While_.prototype._fields=["test",function(a){return a.test},"body",function(a){return a.body},"orelse",function(a){return a.orelse}];If_.prototype._astname="If";If_.prototype._fields=["test",function(a){return a.test},"body",function(a){return a.body},"orelse",function(a){return a.orelse}];
With_.prototype._astname="With";With_.prototype._fields=["context_expr",function(a){return a.context_expr},"optional_vars",function(a){return a.optional_vars},"body",function(a){return a.body}];Raise.prototype._astname="Raise";Raise.prototype._fields=["type",function(a){return a.type},"inst",function(a){return a.inst},"tback",function(a){return a.tback}];TryExcept.prototype._astname="TryExcept";
TryExcept.prototype._fields=["body",function(a){return a.body},"handlers",function(a){return a.handlers},"orelse",function(a){return a.orelse}];TryFinally.prototype._astname="TryFinally";TryFinally.prototype._fields=["body",function(a){return a.body},"finalbody",function(a){return a.finalbody}];Assert.prototype._astname="Assert";Assert.prototype._fields=["test",function(a){return a.test},"msg",function(a){return a.msg}];Import_.prototype._astname="Import";Import_.prototype._fields=["names",function(a){return a.names}];
ImportFrom.prototype._astname="ImportFrom";ImportFrom.prototype._fields=["module",function(a){return a.module},"names",function(a){return a.names},"level",function(a){return a.level}];Exec.prototype._astname="Exec";Exec.prototype._fields=["body",function(a){return a.body},"globals",function(a){return a.globals},"locals",function(a){return a.locals}];Global.prototype._astname="Global";Global.prototype._fields=["names",function(a){return a.names}];Expr.prototype._astname="Expr";
Expr.prototype._fields=["value",function(a){return a.value}];Pass.prototype._astname="Pass";Pass.prototype._fields=[];Break_.prototype._astname="Break";Break_.prototype._fields=[];Continue_.prototype._astname="Continue";Continue_.prototype._fields=[];BoolOp.prototype._astname="BoolOp";BoolOp.prototype._fields=["op",function(a){return a.op},"values",function(a){return a.values}];BinOp.prototype._astname="BinOp";
BinOp.prototype._fields=["left",function(a){return a.left},"op",function(a){return a.op},"right",function(a){return a.right}];UnaryOp.prototype._astname="UnaryOp";UnaryOp.prototype._fields=["op",function(a){return a.op},"operand",function(a){return a.operand}];Lambda.prototype._astname="Lambda";Lambda.prototype._fields=["args",function(a){return a.args},"body",function(a){return a.body}];IfExp.prototype._astname="IfExp";
IfExp.prototype._fields=["test",function(a){return a.test},"body",function(a){return a.body},"orelse",function(a){return a.orelse}];Dict.prototype._astname="Dict";Dict.prototype._fields=["keys",function(a){return a.keys},"values",function(a){return a.values}];ListComp.prototype._astname="ListComp";ListComp.prototype._fields=["elt",function(a){return a.elt},"generators",function(a){return a.generators}];GeneratorExp.prototype._astname="GeneratorExp";
GeneratorExp.prototype._fields=["elt",function(a){return a.elt},"generators",function(a){return a.generators}];Yield.prototype._astname="Yield";Yield.prototype._fields=["value",function(a){return a.value}];Compare.prototype._astname="Compare";Compare.prototype._fields=["left",function(a){return a.left},"ops",function(a){return a.ops},"comparators",function(a){return a.comparators}];Call.prototype._astname="Call";
Call.prototype._fields=["func",function(a){return a.func},"args",function(a){return a.args},"keywords",function(a){return a.keywords},"starargs",function(a){return a.starargs},"kwargs",function(a){return a.kwargs}];Num.prototype._astname="Num";Num.prototype._fields=["n",function(a){return a.n}];Str.prototype._astname="Str";Str.prototype._fields=["s",function(a){return a.s}];Attribute.prototype._astname="Attribute";
Attribute.prototype._fields=["value",function(a){return a.value},"attr",function(a){return a.attr},"ctx",function(a){return a.ctx}];Subscript.prototype._astname="Subscript";Subscript.prototype._fields=["value",function(a){return a.value},"slice",function(a){return a.slice},"ctx",function(a){return a.ctx}];Name.prototype._astname="Name";Name.prototype._fields=["id",function(a){return a.id},"ctx",function(a){return a.ctx}];List.prototype._astname="List";
List.prototype._fields=["elts",function(a){return a.elts},"ctx",function(a){return a.ctx}];Tuple.prototype._astname="Tuple";Tuple.prototype._fields=["elts",function(a){return a.elts},"ctx",function(a){return a.ctx}];Load.prototype._astname="Load";Load.prototype._isenum=!0;Store.prototype._astname="Store";Store.prototype._isenum=!0;Del.prototype._astname="Del";Del.prototype._isenum=!0;AugLoad.prototype._astname="AugLoad";AugLoad.prototype._isenum=!0;AugStore.prototype._astname="AugStore";
AugStore.prototype._isenum=!0;Param.prototype._astname="Param";Param.prototype._isenum=!0;Ellipsis.prototype._astname="Ellipsis";Ellipsis.prototype._fields=[];Slice.prototype._astname="Slice";Slice.prototype._fields=["lower",function(a){return a.lower},"upper",function(a){return a.upper},"step",function(a){return a.step}];ExtSlice.prototype._astname="ExtSlice";ExtSlice.prototype._fields=["dims",function(a){return a.dims}];Index.prototype._astname="Index";Index.prototype._fields=["value",function(a){return a.value}];
And.prototype._astname="And";And.prototype._isenum=!0;Or.prototype._astname="Or";Or.prototype._isenum=!0;Add.prototype._astname="Add";Add.prototype._isenum=!0;Sub.prototype._astname="Sub";Sub.prototype._isenum=!0;Mult.prototype._astname="Mult";Mult.prototype._isenum=!0;Div.prototype._astname="Div";Div.prototype._isenum=!0;Mod.prototype._astname="Mod";Mod.prototype._isenum=!0;Pow.prototype._astname="Pow";Pow.prototype._isenum=!0;LShift.prototype._astname="LShift";LShift.prototype._isenum=!0;
RShift.prototype._astname="RShift";RShift.prototype._isenum=!0;BitOr.prototype._astname="BitOr";BitOr.prototype._isenum=!0;BitXor.prototype._astname="BitXor";BitXor.prototype._isenum=!0;BitAnd.prototype._astname="BitAnd";BitAnd.prototype._isenum=!0;FloorDiv.prototype._astname="FloorDiv";FloorDiv.prototype._isenum=!0;Invert.prototype._astname="Invert";Invert.prototype._isenum=!0;Not.prototype._astname="Not";Not.prototype._isenum=!0;UAdd.prototype._astname="UAdd";UAdd.prototype._isenum=!0;
USub.prototype._astname="USub";USub.prototype._isenum=!0;Eq.prototype._astname="Eq";Eq.prototype._isenum=!0;NotEq.prototype._astname="NotEq";NotEq.prototype._isenum=!0;Lt.prototype._astname="Lt";Lt.prototype._isenum=!0;LtE.prototype._astname="LtE";LtE.prototype._isenum=!0;Gt.prototype._astname="Gt";Gt.prototype._isenum=!0;GtE.prototype._astname="GtE";GtE.prototype._isenum=!0;Is.prototype._astname="Is";Is.prototype._isenum=!0;IsNot.prototype._astname="IsNot";IsNot.prototype._isenum=!0;
In_.prototype._astname="In";In_.prototype._isenum=!0;NotIn.prototype._astname="NotIn";NotIn.prototype._isenum=!0;comprehension.prototype._astname="comprehension";comprehension.prototype._fields=["target",function(a){return a.target},"iter",function(a){return a.iter},"ifs",function(a){return a.ifs}];ExceptHandler.prototype._astname="ExceptHandler";ExceptHandler.prototype._fields=["type",function(a){return a.type},"name",function(a){return a.name},"body",function(a){return a.body}];
arguments_.prototype._astname="arguments";arguments_.prototype._fields=["args",function(a){return a.args},"vararg",function(a){return a.vararg},"kwarg",function(a){return a.kwarg},"defaults",function(a){return a.defaults}];keyword.prototype._astname="keyword";keyword.prototype._fields=["arg",function(a){return a.arg},"value",function(a){return a.value}];alias.prototype._astname="alias";alias.prototype._fields=["name",function(a){return a.name},"asname",function(a){return a.asname}];var SYM=Sk.ParseTables.sym,TOK=Sk.Tokenizer.Tokens;function Compiling(a,b){this.c_encoding=a;this.c_filename=b}function NCH(a){goog.asserts.assert(void 0!==a);return null===a.children?0:a.children.length}function CHILD(a,b){goog.asserts.assert(void 0!==a);goog.asserts.assert(void 0!==b);return a.children[b]}function REQ(a,b){goog.asserts.assert(a.type===b,"node wasn't expected type")}
function strobj(a){goog.asserts.assert("string"===typeof a,"expecting string, got "+typeof a);return new Sk.builtin.str(a)}
function numStmts(a){switch(a.type){case SYM.single_input:if(CHILD(a,0).type===TOK.T_NEWLINE)break;else return numStmts(CHILD(a,0));case SYM.file_input:for(var b=0,c=0;c<NCH(a);++c){var d=CHILD(a,c);d.type===SYM.stmt&&(b+=numStmts(d))}return b;case SYM.stmt:return numStmts(CHILD(a,0));case SYM.compound_stmt:return 1;case SYM.simple_stmt:return Math.floor(NCH(a)/2);case SYM.suite:if(1===NCH(a))return numStmts(CHILD(a,0));b=0;for(c=2;c<NCH(a)-1;++c)b+=numStmts(CHILD(a,c));return b;default:goog.asserts.fail("Non-statement found")}return 0}
function forbiddenCheck(a,b,c,d){if("None"===c)throw new Sk.builtin.SyntaxError("assignment to None",a.c_filename,d);if("True"===c||"False"===c)throw new Sk.builtin.SyntaxError("assignment to True or False is forbidden",a.c_filename,d);}
function setContext(a,b,c,d){goog.asserts.assert(c!==AugStore&&c!==AugLoad);var e=null,f=null;switch(b.constructor){case Attribute:case Name:c===Store&&forbiddenCheck(a,d,b.attr,d.lineno);b.ctx=c;break;case Subscript:b.ctx=c;break;case List:b.ctx=c;e=b.elts;break;case Tuple:if(0===b.elts.length)throw new Sk.builtin.SyntaxError("can't assign to ()",a.c_filename,d.lineno);b.ctx=c;e=b.elts;break;case Lambda:f="lambda";break;case Call:f="function call";break;case BoolOp:case BinOp:case UnaryOp:f="operator";
break;case GeneratorExp:f="generator expression";break;case Yield:f="yield expression";break;case ListComp:f="list comprehension";break;case Dict:case Num:case Str:f="literal";break;case Compare:f="comparison";break;case IfExp:f="conditional expression";break;default:goog.asserts.fail("unhandled expression in assignment")}if(f)throw new Sk.builtin.SyntaxError("can't "+(c===Store?"assign to":"delete")+" "+f,a.c_filename,d.lineno);if(e)for(b=0;b<e.length;++b)setContext(a,e[b],c,d)}var operatorMap={};
(function(){operatorMap[TOK.T_VBAR]=BitOr;operatorMap[TOK.T_VBAR]=BitOr;operatorMap[TOK.T_CIRCUMFLEX]=BitXor;operatorMap[TOK.T_AMPER]=BitAnd;operatorMap[TOK.T_LEFTSHIFT]=LShift;operatorMap[TOK.T_RIGHTSHIFT]=RShift;operatorMap[TOK.T_PLUS]=Add;operatorMap[TOK.T_MINUS]=Sub;operatorMap[TOK.T_STAR]=Mult;operatorMap[TOK.T_SLASH]=Div;operatorMap[TOK.T_DOUBLESLASH]=FloorDiv;operatorMap[TOK.T_PERCENT]=Mod})();
function getOperator(a){goog.asserts.assert(void 0!==operatorMap[a.type]);return operatorMap[a.type]}
function astForCompOp(a,b){REQ(b,SYM.comp_op);if(1===NCH(b))switch(b=CHILD(b,0),b.type){case TOK.T_LESS:return Lt;case TOK.T_GREATER:return Gt;case TOK.T_EQEQUAL:return Eq;case TOK.T_LESSEQUAL:return LtE;case TOK.T_GREATEREQUAL:return GtE;case TOK.T_NOTEQUAL:return NotEq;case TOK.T_NAME:if("in"===b.value)return In_;if("is"===b.value)return Is}else if(2===NCH(b)&&CHILD(b,0).type===TOK.T_NAME){if("in"===CHILD(b,1).value)return NotIn;if("is"===CHILD(b,0).value)return IsNot}goog.asserts.fail("invalid comp_op")}
function seqForTestlist(a,b){goog.asserts.assert(b.type===SYM.testlist||b.type===SYM.listmaker||b.type===SYM.testlist_gexp||b.type===SYM.testlist_safe||b.type===SYM.testlist1);for(var c=[],d=0;d<NCH(b);d+=2)goog.asserts.assert(CHILD(b,d).type===SYM.test||CHILD(b,d).type===SYM.old_test),c[d/2]=astForExpr(a,CHILD(b,d));return c}
function astForSuite(a,b){REQ(b,SYM.suite);var c=[],d=0,e;if(CHILD(b,0).type===SYM.simple_stmt){b=CHILD(b,0);e=NCH(b)-1;CHILD(b,e-1).type===TOK.T_SEMI&&(e-=1);for(var f=0;f<e;f+=2)c[d++]=astForStmt(a,CHILD(b,f))}else for(f=2;f<NCH(b)-1;++f)if(e=CHILD(b,f),REQ(e,SYM.stmt),1===numStmts(e))c[d++]=astForStmt(a,e);else{e=CHILD(e,0);REQ(e,SYM.simple_stmt);for(var g=0;g<NCH(e);g+=2){if(0===NCH(CHILD(e,g))){goog.asserts.assert(g+1===NCH(e));break}c[d++]=astForStmt(a,CHILD(e,g))}}goog.asserts.assert(d===numStmts(b));
return c}
function astForExceptClause(a,b,c){REQ(b,SYM.except_clause);REQ(c,SYM.suite);if(1===NCH(b))return new ExceptHandler(null,null,astForSuite(a,c),b.lineno,b.col_offset);if(2===NCH(b))return new ExceptHandler(astForExpr(a,CHILD(b,1)),null,astForSuite(a,c),b.lineno,b.col_offset);if(4===NCH(b)){var d=astForExpr(a,CHILD(b,3));setContext(a,d,Store,CHILD(b,3));return new ExceptHandler(astForExpr(a,CHILD(b,1)),d,astForSuite(a,c),b.lineno,b.col_offset)}goog.asserts.fail("wrong number of children for except clause")}
function astForTryStmt(a,b){var c=NCH(b),d=(c-3)/3,e,f=[],g=null;REQ(b,SYM.try_stmt);e=astForSuite(a,CHILD(b,2));if(CHILD(b,c-3).type===TOK.T_NAME)"finally"===CHILD(b,c-3).value?(9<=c&&CHILD(b,c-6).type===TOK.T_NAME&&(f=astForSuite(a,CHILD(b,c-4)),d--),g=astForSuite(a,CHILD(b,c-1))):f=astForSuite(a,CHILD(b,c-1)),d--;else if(CHILD(b,c-3).type!==SYM.except_clause)throw new Sk.builtin.SyntaxError("malformed 'try' statement",a.c_filename,b.lineno);if(0<d){for(var c=[],h=0;h<d;++h)c[h]=astForExceptClause(a,
CHILD(b,3+3*h),CHILD(b,5+3*h));d=new TryExcept(e,c,f,b.lineno,b.col_offset);if(!g)return d;e=[d]}goog.asserts.assert(null!==g);return new TryFinally(e,g,b.lineno,b.col_offset)}function astForDottedName(a,b){REQ(b,SYM.dotted_name);for(var c=b.lineno,d=b.col_offset,e=strobj(CHILD(b,0).value),f=new Name(e,Load,c,d),g=2;g<NCH(b);g+=2)e=strobj(CHILD(b,g).value),f=new Attribute(f,e,Load,c,d);return f}
function astForDecorator(a,b){REQ(b,SYM.decorator);REQ(CHILD(b,0),TOK.T_AT);REQ(CHILD(b,NCH(b)-1),TOK.T_NEWLINE);var c=astForDottedName(a,CHILD(b,1));return 3===NCH(b)?c:5===NCH(b)?new Call(c,[],[],null,null,b.lineno,b.col_offset):astForCall(a,CHILD(b,3),c)}function astForDecorators(a,b){REQ(b,SYM.decorators);for(var c=[],d=0;d<NCH(b);++d)c[d]=astForDecorator(a,CHILD(b,d));return c}
function astForDecorated(a,b){REQ(b,SYM.decorated);var c=astForDecorators(a,CHILD(b,0));goog.asserts.assert(CHILD(b,1).type===SYM.funcdef||CHILD(b,1).type===SYM.classdef);var d=null;CHILD(b,1).type===SYM.funcdef?d=astForFuncdef(a,CHILD(b,1),c):CHILD(b,1)===SYM.classdef&&(d=astForClassdef(a,CHILD(b,1),c));d&&(d.lineno=b.lineno,d.col_offset=b.col_offset);return d}function astForWithVar(a,b){REQ(b,SYM.with_var);return astForExpr(a,CHILD(b,1))}
function astForWithStmt(a,b){var c=3;goog.asserts.assert(b.type===SYM.with_stmt);var d=astForExpr(a,CHILD(b,1));if(CHILD(b,2).type===SYM.with_var){var e=astForWithVar(a,CHILD(b,2));setContext(a,e,Store,b);c=4}return new With_(d,e,astForSuite(a,CHILD(b,c)),b.lineno,b.col_offset)}
function astForExecStmt(a,b){var c,d=null,e=null,f=NCH(b);goog.asserts.assert(2===f||4===f||6===f);REQ(b,SYM.exec_stmt);c=astForExpr(a,CHILD(b,1));4<=f&&(d=astForExpr(a,CHILD(b,3)));6===f&&(e=astForExpr(a,CHILD(b,5)));return new Exec(c,d,e,b.lineno,b.col_offset)}
function astForIfStmt(a,b){REQ(b,SYM.if_stmt);if(4===NCH(b))return new If_(astForExpr(a,CHILD(b,1)),astForSuite(a,CHILD(b,3)),[],b.lineno,b.col_offset);var c=CHILD(b,4).value.charAt(2);if("s"===c)return new If_(astForExpr(a,CHILD(b,1)),astForSuite(a,CHILD(b,3)),astForSuite(a,CHILD(b,6)),b.lineno,b.col_offset);if("i"===c){var c=NCH(b)-4,d=!1,e=[];CHILD(b,c+1).type===TOK.T_NAME&&"s"===CHILD(b,c+1).value.charAt(2)&&(d=!0,c-=3);c/=4;d&&(e=[new If_(astForExpr(a,CHILD(b,NCH(b)-6)),astForSuite(a,CHILD(b,
NCH(b)-4)),astForSuite(a,CHILD(b,NCH(b)-1)),CHILD(b,NCH(b)-6).lineno,CHILD(b,NCH(b)-6).col_offset)],c--);for(d=0;d<c;++d)var f=5+4*(c-d-1),e=[new If_(astForExpr(a,CHILD(b,f)),astForSuite(a,CHILD(b,f+2)),e,CHILD(b,f).lineno,CHILD(b,f).col_offset)];return new If_(astForExpr(a,CHILD(b,1)),astForSuite(a,CHILD(b,3)),e,b.lineno,b.col_offset)}goog.asserts.fail("unexpected token in 'if' statement")}
function astForExprlist(a,b,c){REQ(b,SYM.exprlist);for(var d=[],e=0;e<NCH(b);e+=2){var f=astForExpr(a,CHILD(b,e));d[e/2]=f;c&&setContext(a,f,c,CHILD(b,e))}return d}function astForDelStmt(a,b){REQ(b,SYM.del_stmt);return new Delete_(astForExprlist(a,CHILD(b,1),Del),b.lineno,b.col_offset)}function astForGlobalStmt(a,b){REQ(b,SYM.global_stmt);for(var c=[],d=1;d<NCH(b);d+=2)c[(d-1)/2]=strobj(CHILD(b,d).value);return new Global(c,b.lineno,b.col_offset)}
function astForAssertStmt(a,b){REQ(b,SYM.assert_stmt);if(2===NCH(b))return new Assert(astForExpr(a,CHILD(b,1)),null,b.lineno,b.col_offset);if(4===NCH(b))return new Assert(astForExpr(a,CHILD(b,1)),astForExpr(a,CHILD(b,3)),b.lineno,b.col_offset);goog.asserts.fail("improper number of parts to assert stmt")}
function aliasForImportName(a,b){a:for(;;)switch(b.type){case SYM.import_as_name:var c=null,d=strobj(CHILD(b,0).value);3===NCH(b)&&(c=CHILD(b,2).value);return new alias(d,null==c?null:strobj(c));case SYM.dotted_as_name:if(1===NCH(b)){b=CHILD(b,0);continue a}else return c=aliasForImportName(a,CHILD(b,0)),goog.asserts.assert(!c.asname),c.asname=strobj(CHILD(b,2).value),c;case SYM.dotted_name:if(1===NCH(b))return new alias(strobj(CHILD(b,0).value),null);c="";for(d=0;d<NCH(b);d+=2)c+=CHILD(b,d).value+
".";return new alias(strobj(c.substr(0,c.length-1)),null);case TOK.T_STAR:return new alias(strobj("*"),null);default:throw new Sk.builtin.SyntaxError("unexpected import name",a.c_filename,b.lineno);}}
function astForImportStmt(a,b){REQ(b,SYM.import_stmt);var c=b.lineno,d=b.col_offset;b=CHILD(b,0);if(b.type===SYM.import_name){b=CHILD(b,1);REQ(b,SYM.dotted_as_names);for(var e=[],f=0;f<NCH(b);f+=2)e[f/2]=aliasForImportName(a,CHILD(b,f));return new Import_(e,c,d)}if(b.type===SYM.import_from){for(var g=null,h=0,e=1;e<NCH(b);++e){if(CHILD(b,e).type===SYM.dotted_name){g=aliasForImportName(a,CHILD(b,e));e++;break}else if(CHILD(b,e).type!==TOK.T_DOT)break;h++}++e;switch(CHILD(b,e).type){case TOK.T_STAR:b=
CHILD(b,e);break;case TOK.T_LPAR:b=CHILD(b,e+1);NCH(b);break;case SYM.import_as_names:b=CHILD(b,e);e=NCH(b);if(0===e%2)throw new Sk.builtin.SyntaxError("trailing comma not allowed without surrounding parentheses",a.c_filename,b.lineno);break;default:throw new Sk.builtin.SyntaxError("Unexpected node-type in from-import",a.c_filename,b.lineno);}e=[];if(b.type===TOK.T_STAR)e[0]=aliasForImportName(a,b);else for(f=0;f<NCH(b);f+=2)e[f/2]=aliasForImportName(a,CHILD(b,f));return new ImportFrom(strobj(g?g.name.v:
""),e,h,c,d)}throw new Sk.builtin.SyntaxError("unknown import statement",a.c_filename,b.lineno);}function astForTestlistGexp(a,b){goog.asserts.assert(b.type===SYM.testlist_gexp||b.type===SYM.argument);return 1<NCH(b)&&CHILD(b,1).type===SYM.gen_for?astForGenexp(a,b):astForTestlist(a,b)}
function astForListcomp(a,b){function c(a,b){for(var c=0;;){REQ(b,SYM.list_iter);if(CHILD(b,0).type===SYM.list_for)return c;b=CHILD(b,0);REQ(b,SYM.list_if);c++;if(2==NCH(b))return c;b=CHILD(b,2)}}REQ(b,SYM.listmaker);goog.asserts.assert(1<NCH(b));for(var d=astForExpr(a,CHILD(b,0)),e=function(a,b){var c=0,d=CHILD(b,1);a:for(;;){c++;REQ(d,SYM.list_for);if(5===NCH(d))d=CHILD(d,4);else return c;b:for(;;){REQ(d,SYM.list_iter);d=CHILD(d,0);if(d.type===SYM.list_for)continue a;else if(d.type===SYM.list_if)if(3===
NCH(d)){d=CHILD(d,2);continue b}else return c;break}break}}(a,b),f=[],g=CHILD(b,1),h=0;h<e;++h){REQ(g,SYM.list_for);var k=CHILD(g,1),l=astForExprlist(a,k,Store),m=astForTestlist(a,CHILD(g,3)),k=1===NCH(k)?new comprehension(l[0],m,[]):new comprehension(new Tuple(l,Store,g.lineno,g.col_offset),m,[]);if(5===NCH(g)){for(var g=CHILD(g,4),l=c(a,g),m=[],n=0;n<l;++n)REQ(g,SYM.list_iter),g=CHILD(g,0),REQ(g,SYM.list_if),m[n]=astForExpr(a,CHILD(g,1)),3===NCH(g)&&(g=CHILD(g,2));g.type===SYM.list_iter&&(g=CHILD(g,
0));k.ifs=m}f[h]=k}return new ListComp(d,f,b.lineno,b.col_offset)}
function astForFactor(a,b){if(CHILD(b,0).type===TOK.T_MINUS&&2===NCH(b)){var c=CHILD(b,1);if(c.type===SYM.factor&&1===NCH(c)&&(c=CHILD(c,0),c.type===SYM.power&&1===NCH(c)&&(c=CHILD(c,0),c.type===SYM.atom))){var d=CHILD(c,0);if(d.type===TOK.T_NUMBER)return d.value="-"+d.value,astForAtom(a,c)}}c=astForExpr(a,CHILD(b,1));switch(CHILD(b,0).type){case TOK.T_PLUS:return new UnaryOp(UAdd,c,b.lineno,b.col_offset);case TOK.T_MINUS:return new UnaryOp(USub,c,b.lineno,b.col_offset);case TOK.T_TILDE:return new UnaryOp(Invert,
c,b.lineno,b.col_offset)}goog.asserts.fail("unhandled factor")}function astForForStmt(a,b){var c=[];REQ(b,SYM.for_stmt);9===NCH(b)&&(c=astForSuite(a,CHILD(b,8)));var d=CHILD(b,1),e=astForExprlist(a,d,Store),d=1===NCH(d)?e[0]:new Tuple(e,Store,b.lineno,b.col_offset);return new For_(d,astForTestlist(a,CHILD(b,3)),astForSuite(a,CHILD(b,5)),c,b.lineno,b.col_offset)}
function astForCall(a,b,c){REQ(b,SYM.arglist);for(var d=0,e=0,f=0,g=0;g<NCH(b);++g){var h=CHILD(b,g);h.type===SYM.argument&&(1===NCH(h)?d++:CHILD(h,1).type===SYM.gen_for?f++:e++)}if(1<f||f&&(d||e))throw new Sk.builtin.SyntaxError("Generator expression must be parenthesized if not sole argument",a.c_filename,b.lineno);if(255<d+e+f)throw new Sk.builtin.SyntaxError("more than 255 arguments",a.c_filename,b.lineno);for(var f=[],k=[],e=d=0,l=null,m=null,g=0;g<NCH(b);++g)if(h=CHILD(b,g),h.type===SYM.argument)if(1===
NCH(h)){if(e)throw new Sk.builtin.SyntaxError("non-keyword arg after keyword arg",a.c_filename,b.lineno);if(l)throw new Sk.builtin.SyntaxError("only named arguments may follow *expression",a.c_filename,b.lineno);f[d++]=astForExpr(a,CHILD(h,0))}else if(CHILD(h,1).type===SYM.gen_for)f[d++]=astForGenexp(a,h);else{var n=astForExpr(a,CHILD(h,0));if(n.constructor===Lambda)throw new Sk.builtin.SyntaxError("lambda cannot contain assignment",a.c_filename,b.lineno);if(n.constructor!==Name)throw new Sk.builtin.SyntaxError("keyword can't be an expression",
a.c_filename,b.lineno);n=n.id;forbiddenCheck(a,CHILD(h,0),n,b.lineno);for(var p=0;p<e;++p)if(k[p].arg===n)throw new Sk.builtin.SyntaxError("keyword argument repeated",a.c_filename,b.lineno);k[e++]=new keyword(n,astForExpr(a,CHILD(h,2)))}else h.type===TOK.T_STAR?l=astForExpr(a,CHILD(b,++g)):h.type===TOK.T_DOUBLESTAR&&(m=astForExpr(a,CHILD(b,++g)));return new Call(c,f,k,l,m,c.lineno,c.col_offset)}
function astForTrailer(a,b,c){REQ(b,SYM.trailer);if(CHILD(b,0).type===TOK.T_LPAR)return 2===NCH(b)?new Call(c,[],[],null,null,b.lineno,b.col_offset):astForCall(a,CHILD(b,1),c);if(CHILD(b,0).type===TOK.T_DOT)return new Attribute(c,strobj(CHILD(b,1).value),Load,b.lineno,b.col_offset);REQ(CHILD(b,0),TOK.T_LSQB);REQ(CHILD(b,2),TOK.T_RSQB);b=CHILD(b,1);if(1===NCH(b))return new Subscript(c,astForSlice(a,CHILD(b,0)),Load,b.lineno,b.col_offset);for(var d=!0,e=[],f=0;f<NCH(b);f+=2){var g=astForSlice(a,CHILD(b,
f));g.constructor!==Index&&(d=!1);e[f/2]=g}if(!d)return new Subscript(c,new ExtSlice(e),Load,b.lineno,b.col_offset);a=[];for(f=0;f<e.length;++f)g=e[f],goog.asserts.assert(g.constructor===Index&&null!==g.value&&void 0!==g.value),a[f]=g.value;e=new Tuple(a,Load,b.lineno,b.col_offset);return new Subscript(c,new Index(e),Load,b.lineno,b.col_offset)}
function astForFlowStmt(a,b){var c;REQ(b,SYM.flow_stmt);c=CHILD(b,0);switch(c.type){case SYM.break_stmt:return new Break_(b.lineno,b.col_offset);case SYM.continue_stmt:return new Continue_(b.lineno,b.col_offset);case SYM.yield_stmt:return new Expr(astForExpr(a,CHILD(c,0)),b.lineno,b.col_offset);case SYM.return_stmt:return 1===NCH(c)?new Return_(null,b.lineno,b.col_offset):new Return_(astForTestlist(a,CHILD(c,1)),b.lineno,b.col_offset);case SYM.raise_stmt:if(1===NCH(c))return new Raise(null,null,null,
b.lineno,b.col_offset);if(2===NCH(c))return new Raise(astForExpr(a,CHILD(c,1)),null,null,b.lineno,b.col_offset);if(4===NCH(c))return new Raise(astForExpr(a,CHILD(c,1)),astForExpr(a,CHILD(c,3)),null,b.lineno,b.col_offset);if(6===NCH(c))return new Raise(astForExpr(a,CHILD(c,1)),astForExpr(a,CHILD(c,3)),astForExpr(a,CHILD(c,5)),b.lineno,b.col_offset);default:goog.asserts.fail("unexpected flow_stmt")}goog.asserts.fail("unhandled flow statement")}
function astForArguments(a,b){var c,d=null,e=null;if(b.type===SYM.parameters){if(2===NCH(b))return new arguments_([],null,null,[]);b=CHILD(b,1)}REQ(b,SYM.varargslist);for(var f=[],g=[],h=!1,k=0,l=0,m=0;k<NCH(b);)switch(c=CHILD(b,k),c.type){case SYM.fpdef:var n=0;a:for(;;){if(k+1<NCH(b)&&CHILD(b,k+1).type===TOK.T_EQUAL)g[l++]=astForExpr(a,CHILD(b,k+2)),k+=2,h=!0;else if(h){if(n)throw new Sk.builtin.SyntaxError("parenthesized arg with default",a.c_filename,b.lineno);throw new Sk.builtin.SyntaxError("non-default argument follows default argument",
a.c_filename,b.lineno);}if(3===NCH(c)){c=CHILD(c,1);if(1!==NCH(c))throw new Sk.builtin.SyntaxError("tuple parameter unpacking has been removed",a.c_filename,b.lineno);n=!0;c=CHILD(c,0);goog.asserts.assert(c.type===SYM.fpdef);continue a}if(CHILD(c,0).type===TOK.T_NAME){forbiddenCheck(a,b,CHILD(c,0).value,b.lineno);var p=strobj(CHILD(c,0).value);f[m++]=new Name(p,Param,c.lineno,c.col_offset)}k+=2;if(n)throw new Sk.builtin.SyntaxError("parenthesized argument names are invalid",a.c_filename,b.lineno);
break}break;case TOK.T_STAR:forbiddenCheck(a,CHILD(b,k+1),CHILD(b,k+1).value,b.lineno);d=strobj(CHILD(b,k+1).value);k+=3;break;case TOK.T_DOUBLESTAR:forbiddenCheck(a,CHILD(b,k+1),CHILD(b,k+1).value,b.lineno);e=strobj(CHILD(b,k+1).value);k+=3;break;default:goog.asserts.fail("unexpected node in varargslist")}return new arguments_(f,d,e,g)}
function astForFuncdef(a,b,c){REQ(b,SYM.funcdef);var d=strobj(CHILD(b,1).value);forbiddenCheck(a,CHILD(b,1),CHILD(b,1).value,b.lineno);var e=astForArguments(a,CHILD(b,2));a=astForSuite(a,CHILD(b,4));return new FunctionDef(d,e,a,c,b.lineno,b.col_offset)}function astForClassBases(a,b){goog.asserts.assert(0<NCH(b));REQ(b,SYM.testlist);return 1===NCH(b)?[astForExpr(a,CHILD(b,0))]:seqForTestlist(a,b)}
function astForClassdef(a,b,c){REQ(b,SYM.classdef);forbiddenCheck(a,b,CHILD(b,1).value,b.lineno);var d=strobj(CHILD(b,1).value);if(4===NCH(b))return new ClassDef(d,[],astForSuite(a,CHILD(b,3)),c,b.lineno,b.col_offset);if(CHILD(b,3).type===TOK.T_RPAR)return new ClassDef(d,[],astForSuite(a,CHILD(b,5)),c,b.lineno,b.col_offset);var e=astForClassBases(a,CHILD(b,3));a=astForSuite(a,CHILD(b,6));return new ClassDef(d,e,a,c,b.lineno,b.col_offset)}
function astForLambdef(a,b){var c,d;3===NCH(b)?(c=new arguments_([],null,null,[]),d=astForExpr(a,CHILD(b,2))):(c=astForArguments(a,CHILD(b,1)),d=astForExpr(a,CHILD(b,3)));return new Lambda(c,d,b.lineno,b.col_offset)}
function astForGenexp(a,b){function c(a,b){for(var c=0;;){REQ(b,SYM.gen_iter);if(CHILD(b,0).type===SYM.gen_for)return c;b=CHILD(b,0);REQ(b,SYM.gen_if);c++;if(2==NCH(b))return c;b=CHILD(b,2)}}goog.asserts.assert(b.type===SYM.testlist_gexp||b.type===SYM.argument);goog.asserts.assert(1<NCH(b));for(var d=astForExpr(a,CHILD(b,0)),e=function(a,b){var c=0,d=CHILD(b,1);a:for(;;){c++;REQ(d,SYM.gen_for);if(5===NCH(d))d=CHILD(d,4);else return c;b:for(;;){REQ(d,SYM.gen_iter);d=CHILD(d,0);if(d.type===SYM.gen_for)continue a;
else if(d.type===SYM.gen_if)if(3===NCH(d)){d=CHILD(d,2);continue b}else return c;break}break}goog.asserts.fail("logic error in countGenFors")}(a,b),f=[],g=CHILD(b,1),h=0;h<e;++h){REQ(g,SYM.gen_for);var k=CHILD(g,1),l=astForExprlist(a,k,Store),m=astForExpr(a,CHILD(g,3)),k=1===NCH(k)?new comprehension(l[0],m,[]):new comprehension(new Tuple(l,Store,g.lineno,g.col_offset),m,[]);if(5===NCH(g)){for(var g=CHILD(g,4),l=c(a,g),n=[],p=0;p<l;++p)REQ(g,SYM.gen_iter),g=CHILD(g,0),REQ(g,SYM.gen_if),m=astForExpr(a,
CHILD(g,1)),n[p]=m,3===NCH(g)&&(g=CHILD(g,2));g.type===SYM.gen_iter&&(g=CHILD(g,0));k.ifs=n}f[h]=k}return new GeneratorExp(d,f,b.lineno,b.col_offset)}
function astForWhileStmt(a,b){REQ(b,SYM.while_stmt);if(4===NCH(b))return new While_(astForExpr(a,CHILD(b,1)),astForSuite(a,CHILD(b,3)),[],b.lineno,b.col_offset);if(7===NCH(b))return new While_(astForExpr(a,CHILD(b,1)),astForSuite(a,CHILD(b,3)),astForSuite(a,CHILD(b,6)),b.lineno,b.col_offset);goog.asserts.fail("wrong number of tokens for 'while' stmt")}
function astForAugassign(a,b){REQ(b,SYM.augassign);b=CHILD(b,0);switch(b.value.charAt(0)){case "+":return Add;case "-":return Sub;case "/":return"/"===b.value.charAt(1)?FloorDiv:Div;case "%":return Mod;case "<":return LShift;case ">":return RShift;case "&":return BitAnd;case "^":return BitXor;case "|":return BitOr;case "*":return"*"===b.value.charAt(1)?Pow:Mult;default:goog.asserts.fail("invalid augassign")}}
function astForBinop(a,b){for(var c=new BinOp(astForExpr(a,CHILD(b,0)),getOperator(CHILD(b,1)),astForExpr(a,CHILD(b,2)),b.lineno,b.col_offset),d=(NCH(b)-1)/2,e=1;e<d;++e)var f=CHILD(b,2*e+1),g=getOperator(f),h=astForExpr(a,CHILD(b,2*e+2)),c=new BinOp(c,g,h,f.lineno,f.col_offset);return c}
function astForTestlist(a,b){goog.asserts.assert(0<NCH(b));b.type===SYM.testlist_gexp?1<NCH(b)&&goog.asserts.assert(CHILD(b,1).type!==SYM.gen_for):goog.asserts.assert(b.type===SYM.testlist||b.type===SYM.testlist_safe||b.type===SYM.testlist1);return 1===NCH(b)?astForExpr(a,CHILD(b,0)):new Tuple(seqForTestlist(a,b),Load,b.lineno,b.col_offset)}
function astForExprStmt(a,b){REQ(b,SYM.expr_stmt);if(1===NCH(b))return new Expr(astForTestlist(a,CHILD(b,0)),b.lineno,b.col_offset);if(CHILD(b,1).type===SYM.augassign){var c=CHILD(b,0),d=astForTestlist(a,c);switch(d.constructor){case GeneratorExp:throw new Sk.builtin.SyntaxError("augmented assignment to generator expression not possible",a.c_filename,b.lineno);case Yield:throw new Sk.builtin.SyntaxError("augmented assignment to yield expression not possible",a.c_filename,b.lineno);case Name:forbiddenCheck(a,
c,d.id,b.lineno);break;case Attribute:case Subscript:break;default:throw new Sk.builtin.SyntaxError("illegal expression for augmented assignment",a.c_filename,b.lineno);}setContext(a,d,Store,c);c=CHILD(b,2);c=c.type===SYM.testlist?astForTestlist(a,c):astForExpr(a,c);return new AugAssign(d,astForAugassign(a,CHILD(b,1)),c,b.lineno,b.col_offset)}REQ(CHILD(b,1),TOK.T_EQUAL);for(var d=[],e=0;e<NCH(b)-2;e+=2){c=CHILD(b,e);if(c.type===SYM.yield_expr)throw new Sk.builtin.SyntaxError("assignment to yield expression not possible",
a.c_filename,b.lineno);c=astForTestlist(a,c);setContext(a,c,Store,CHILD(b,e));d[e/2]=c}c=CHILD(b,NCH(b)-1);c=c.type===SYM.testlist?astForTestlist(a,c):astForExpr(a,c);return new Assign(d,c,b.lineno,b.col_offset)}function astForIfexpr(a,b){goog.asserts.assert(5===NCH(b));return new IfExp(astForExpr(a,CHILD(b,2)),astForExpr(a,CHILD(b,0)),astForExpr(a,CHILD(b,4)),b.lineno,b.col_offset)}
function parsestr(a,b){var c=b.charAt(0),d=!1;if("u"===c||"U"===c)b=b.substr(1),c=b.charAt(0);else if("r"===c||"R"===c)b=b.substr(1),c=b.charAt(0),d=!0;goog.asserts.assert("b"!==c&&"B"!==c,"todo; haven't done b'' strings yet");goog.asserts.assert("'"===c||'"'===c&&b.charAt(b.length-1)===c);b=b.substr(1,b.length-2);4<=b.length&&(b.charAt(0)===c&&b.charAt(1)===c)&&(goog.asserts.assert(b.charAt(b.length-1)===c&&b.charAt(b.length-2)===c),b=b.substr(2,b.length-4));if(d||-1===b.indexOf("\\"))c=strobj(decodeURIComponent(escape(b)));
else{for(var c=strobj,d=b,e=d.length,f="",g=0;g<e;++g){var h=d.charAt(g);if("\\"===h)if(++g,h=d.charAt(g),"n"===h)f+="\n";else if("\\"===h)f+="\\";else if("t"===h)f+="\t";else if("r"===h)f+="\r";else if("b"===h)f+="\b";else if("f"===h)f+="\f";else if("v"===h)f+="\v";else if("0"===h)f+="\x00";else if('"'===h)f+='"';else if("'"===h)f+="'";else{if("\n"!==h)if("x"===h)var h=d.charAt(++g),k=d.charAt(++g),f=f+String.fromCharCode(parseInt(h+k,16));else if("u"===h||"U"===h)var h=d.charAt(++g),k=d.charAt(++g),
l=d.charAt(++g),m=d.charAt(++g),f=f+String.fromCharCode(parseInt(h+k,16),parseInt(l+m,16));else f+="\\"+h}else f+=h}c=c(f)}return c}function parsestrplus(a,b){REQ(CHILD(b,0),TOK.T_STRING);for(var c=new Sk.builtin.str(""),d=0;d<NCH(b);++d)try{c=c.sq$concat(parsestr(a,CHILD(b,d).value))}catch(e){throw new Sk.builtin.SyntaxError("invalid string (possibly contains a unicode character)",a.c_filename,CHILD(b,d).lineno);}return c}
function parsenumber(a,b,c){var d=b.charAt(b.length-1);if("j"===d||"J"===d)throw new Sk.builtin.SyntaxError("complex numbers are currently unsupported",a.c_filename,c);if("l"===d||"L"===d)return Sk.longFromStr(b.substr(0,b.length-1),0);if(-1!==b.indexOf("."))return new Sk.builtin.nmber(parseFloat(b),Sk.builtin.nmber.float$);c=b;a=!1;"-"===b.charAt(0)&&(c=b.substr(1),a=!0);if("0"!==c.charAt(0)||"x"!==c.charAt(1)&&"X"!==c.charAt(1)){if(-1!==b.indexOf("e")||-1!==b.indexOf("E"))return new Sk.builtin.nmber(parseFloat(b),
Sk.builtin.nmber.float$);if("0"!==c.charAt(0)||"b"!==c.charAt(1)&&"B"!==c.charAt(1))if("0"===c.charAt(0))if("0"===c)c=0;else{c=c.substring(1);if("o"===c.charAt(0)||"O"===c.charAt(0))c=c.substring(1);c=parseInt(c,8)}else c=parseInt(c,10);else c=c.substring(2),c=parseInt(c,2)}else c=c.substring(2),c=parseInt(c,16);return c>Sk.builtin.nmber.threshold$&&Math.floor(c)===c&&-1===b.indexOf("e")&&-1===b.indexOf("E")?Sk.longFromStr(b,0):a?new Sk.builtin.nmber(-c,Sk.builtin.int$):new Sk.builtin.nmber(c,Sk.builtin.int$)}
function astForSlice(a,b){REQ(b,SYM.subscript);var c=CHILD(b,0),d=null,e=null,f=null;if(c.type===TOK.T_DOT)return new Ellipsis;if(1===NCH(b)&&c.type===SYM.test)return new Index(astForExpr(a,c));c.type===SYM.test&&(d=astForExpr(a,c));c.type===TOK.T_COLON?1<NCH(b)&&(c=CHILD(b,1),c.type===SYM.test&&(e=astForExpr(a,c))):2<NCH(b)&&(c=CHILD(b,2),c.type===SYM.test&&(e=astForExpr(a,c)));c=CHILD(b,NCH(b)-1);c.type===SYM.sliceop&&(1===NCH(c)?(c=CHILD(c,0),f=new Name(strobj("None"),Load,c.lineno,c.col_offset)):
(c=CHILD(c,1),c.type===SYM.test&&(f=astForExpr(a,c))));return new Slice(d,e,f)}
function astForAtom(a,b){var c=CHILD(b,0);switch(c.type){case TOK.T_NAME:return new Name(strobj(c.value),Load,b.lineno,b.col_offset);case TOK.T_STRING:return new Str(parsestrplus(a,b),b.lineno,b.col_offset);case TOK.T_NUMBER:return new Num(parsenumber(a,c.value,b.lineno),b.lineno,b.col_offset);case TOK.T_LPAR:return c=CHILD(b,1),c.type===TOK.T_RPAR?new Tuple([],Load,b.lineno,b.col_offset):c.type===SYM.yield_expr?astForExpr(a,c):1<NCH(c)&&CHILD(c,1).type===SYM.gen_for?astForGenexp(a,c):astForTestlistGexp(a,
c);case TOK.T_LSQB:c=CHILD(b,1);if(c.type===TOK.T_RSQB)return new List([],Load,b.lineno,b.col_offset);REQ(c,SYM.listmaker);return 1===NCH(c)||CHILD(c,1).type===TOK.T_COMMA?new List(seqForTestlist(a,c),Load,b.lineno,b.col_offset):astForListcomp(a,c);case TOK.T_LBRACE:c=CHILD(b,1);NCH(c);for(var d=[],e=[],f=0;f<NCH(c);f+=4)d[f/4]=astForExpr(a,CHILD(c,f)),e[f/4]=astForExpr(a,CHILD(c,f+2));return new Dict(d,e,b.lineno,b.col_offset);case TOK.T_BACKQUOTE:throw new Sk.builtin.SyntaxError("backquote not supported, use repr()",
a.c_filename,b.lineno);default:goog.asserts.fail("unhandled atom",c.type)}}function astForPower(a,b){REQ(b,SYM.power);var c=astForAtom(a,CHILD(b,0));if(1===NCH(b))return c;for(var d=1;d<NCH(b);++d){var e=CHILD(b,d);if(e.type!==SYM.trailer)break;e=astForTrailer(a,e,c);e.lineno=c.lineno;e.col_offset=c.col_offset;c=e}CHILD(b,NCH(b)-1).type===SYM.factor&&(d=astForExpr(a,CHILD(b,NCH(b)-1)),c=new BinOp(c,Pow,d,b.lineno,b.col_offset));return c}
function astForExpr(a,b){a:for(;;){switch(b.type){case SYM.test:case SYM.old_test:if(CHILD(b,0).type===SYM.lambdef||CHILD(b,0).type===SYM.old_lambdef)return astForLambdef(a,CHILD(b,0));if(1<NCH(b))return astForIfexpr(a,b);case SYM.or_test:case SYM.and_test:if(1===NCH(b)){b=CHILD(b,0);continue a}for(var c=[],d=0;d<NCH(b);d+=2)c[d/2]=astForExpr(a,CHILD(b,d));if("and"===CHILD(b,1).value)return new BoolOp(And,c,b.lineno,b.col_offset);goog.asserts.assert("or"===CHILD(b,1).value);return new BoolOp(Or,c,
b.lineno,b.col_offset);case SYM.not_test:if(1===NCH(b)){b=CHILD(b,0);continue a}else return new UnaryOp(Not,astForExpr(a,CHILD(b,1)),b.lineno,b.col_offset);case SYM.comparison:if(1===NCH(b)){b=CHILD(b,0);continue a}else{for(var c=[],e=[],d=1;d<NCH(b);d+=2)c[(d-1)/2]=astForCompOp(a,CHILD(b,d)),e[(d-1)/2]=astForExpr(a,CHILD(b,d+1));return new Compare(astForExpr(a,CHILD(b,0)),c,e,b.lineno,b.col_offset)}case SYM.expr:case SYM.xor_expr:case SYM.and_expr:case SYM.shift_expr:case SYM.arith_expr:case SYM.term:if(1===
NCH(b)){b=CHILD(b,0);continue a}return astForBinop(a,b);case SYM.yield_expr:return d=null,2===NCH(b)&&(d=astForTestlist(a,CHILD(b,1))),new Yield(d,b.lineno,b.col_offset);case SYM.factor:if(1===NCH(b)){b=CHILD(b,0);continue a}return astForFactor(a,b);case SYM.power:return astForPower(a,b);default:goog.asserts.fail("unhandled expr","n.type: %d",b.type)}break}}
function astForPrintStmt(a,b){var c=1,d=null;REQ(b,SYM.print_stmt);2<=NCH(b)&&CHILD(b,1).type===TOK.T_RIGHTSHIFT&&(d=astForExpr(a,CHILD(b,2)),c=4);for(var e=[],f=0;c<NCH(b);c+=2,++f)e[f]=astForExpr(a,CHILD(b,c));c=CHILD(b,NCH(b)-1).type===TOK.T_COMMA?!1:!0;return new Print(d,e,c,b.lineno,b.col_offset)}
function astForStmt(a,b){b.type===SYM.stmt&&(goog.asserts.assert(1===NCH(b)),b=CHILD(b,0));b.type===SYM.simple_stmt&&(goog.asserts.assert(1===numStmts(b)),b=CHILD(b,0));if(b.type===SYM.small_stmt)switch(REQ(b,SYM.small_stmt),b=CHILD(b,0),b.type){case SYM.expr_stmt:return astForExprStmt(a,b);case SYM.print_stmt:return astForPrintStmt(a,b);case SYM.del_stmt:return astForDelStmt(a,b);case SYM.pass_stmt:return new Pass(b.lineno,b.col_offset);case SYM.flow_stmt:return astForFlowStmt(a,b);case SYM.import_stmt:return astForImportStmt(a,
b);case SYM.global_stmt:return astForGlobalStmt(a,b);case SYM.exec_stmt:return astForExecStmt(a,b);case SYM.assert_stmt:return astForAssertStmt(a,b);default:goog.asserts.fail("unhandled small_stmt")}else{var c=CHILD(b,0);REQ(b,SYM.compound_stmt);switch(c.type){case SYM.if_stmt:return astForIfStmt(a,c);case SYM.while_stmt:return astForWhileStmt(a,c);case SYM.for_stmt:return astForForStmt(a,c);case SYM.try_stmt:return astForTryStmt(a,c);case SYM.with_stmt:return astForWithStmt(a,c);case SYM.funcdef:return astForFuncdef(a,
c,[]);case SYM.classdef:return astForClassdef(a,c,[]);case SYM.decorated:return astForDecorated(a,c);default:goog.asserts.assert("unhandled compound_stmt")}}}
Sk.astFromParse=function(a,b){var c=new Compiling("utf-8",b),d=[],e,f=0;switch(a.type){case SYM.file_input:for(var g=0;g<NCH(a)-1;++g)if(e=CHILD(a,g),a.type!==TOK.T_NEWLINE){REQ(e,SYM.stmt);var h=numStmts(e);if(1===h)d[f++]=astForStmt(c,e);else{e=CHILD(e,0);REQ(e,SYM.simple_stmt);for(var k=0;k<h;++k)d[f++]=astForStmt(c,CHILD(e,2*k))}}return new Module(d);case SYM.eval_input:goog.asserts.fail("todo;");case SYM.single_input:goog.asserts.fail("todo;");default:goog.asserts.fail("todo;")}};
Sk.astDump=function(a){var b=function(a){for(var b="",c=0;c<a;++c)b+=" ";return b},c=function(a,e){if(null===a)return e+"None";if(a.prototype&&void 0!==a.prototype._astname&&a.prototype._isenum)return e+a.prototype._astname+"()";if(void 0!==a._astname){for(var f=b(a._astname.length+1),g=[],h=0;h<a._fields.length;h+=2){var k=a._fields[h],l=a._fields[h+1](a),m=b(k.length+1);g.push([k,c(l,e+f+m)])}k=[];for(h=0;h<g.length;++h)l=g[h],k.push(l[0]+"="+l[1].replace(/^\s+/,""));h=k.join(",\n"+e+f);return e+
a._astname+"("+h+")"}if(goog.isArrayLike(a)){f=[];for(h=0;h<a.length;++h)f.push(c(a[h],e+" "));h=f.join(",\n");return e+"["+h.replace(/^\s+/,"")+"]"}h=!0===a?"True":!1===a?"False":a instanceof Sk.builtin.lng?a.tp$str().v:a instanceof Sk.builtin.str?a.$r().v:""+a;return e+h};return c(a,"")};goog.exportSymbol("Sk.astFromParse",Sk.astFromParse);goog.exportSymbol("Sk.astDump",Sk.astDump);var DEF_GLOBAL=1,DEF_LOCAL=2,DEF_PARAM=4,USE=8,DEF_STAR=16,DEF_DOUBLESTAR=32,DEF_INTUPLE=64,DEF_FREE=128,DEF_FREE_GLOBAL=256,DEF_FREE_CLASS=512,DEF_IMPORT=1024,DEF_BOUND=DEF_LOCAL|DEF_PARAM|DEF_IMPORT,SCOPE_OFF=11,SCOPE_MASK=7,LOCAL=1,GLOBAL_EXPLICIT=2,GLOBAL_IMPLICIT=3,FREE=4,CELL=5,OPT_IMPORT_STAR=1,OPT_EXEC=2,OPT_BARE_EXEC=4,OPT_TOPLEVEL=8,GENERATOR=2,GENERATOR_EXPRESSION=2,ModuleBlock="module",FunctionBlock="function",ClassBlock="class";
function Symbol(a,b,c){this.__name=a;this.__flags=b;this.__scope=b>>SCOPE_OFF&SCOPE_MASK;this.__namespaces=c||[]}Symbol.prototype.get_name=function(){return this.__name};Symbol.prototype.is_referenced=function(){return!!(this.__flags&USE)};Symbol.prototype.is_parameter=function(){return!!(this.__flags&DEF_PARAM)};Symbol.prototype.is_global=function(){return this.__scope===GLOBAL_IMPLICIT||this.__scope==GLOBAL_EXPLICIT};Symbol.prototype.is_declared_global=function(){return this.__scope==GLOBAL_EXPLICIT};
Symbol.prototype.is_local=function(){return!!(this.__flags&DEF_BOUND)};Symbol.prototype.is_free=function(){return this.__scope==FREE};Symbol.prototype.is_imported=function(){return!!(this.__flags&DEF_IMPORT)};Symbol.prototype.is_assigned=function(){return!!(this.__flags&DEF_LOCAL)};Symbol.prototype.is_namespace=function(){return this.__namespaces&&0<this.__namespaces.length};Symbol.prototype.get_namespaces=function(){return this.__namespaces};var astScopeCounter=0;
function SymbolTableScope(a,b,c,d,e){this.symFlags={};this.name=b;this.varnames=[];this.children=[];this.blockType=c;this.returnsValue=this.varkeywords=this.varargs=this.generator=this.childHasFree=this.hasFree=this.isNested=!1;this.lineno=e;this.table=a;a.cur&&(a.cur.nested||a.cur.blockType===FunctionBlock)&&(this.isNested=!0);d.scopeId=astScopeCounter++;a.stss[d.scopeId]=this;this.symbols={}}SymbolTableScope.prototype.get_type=function(){return this.blockType};
SymbolTableScope.prototype.get_name=function(){return this.name};SymbolTableScope.prototype.get_lineno=function(){return this.lineno};SymbolTableScope.prototype.is_nested=function(){return this.isNested};SymbolTableScope.prototype.has_children=function(){return 0<this.children.length};SymbolTableScope.prototype.get_identifiers=function(){return this._identsMatching(function(a){return!0})};
SymbolTableScope.prototype.lookup=function(a){if(this.symbols.hasOwnProperty(a))a=this.symbols[a];else{var b=this.symFlags[a],c=this.__check_children(a);a=this.symbols[a]=new Symbol(a,b,c)}return a};SymbolTableScope.prototype.__check_children=function(a){for(var b=[],c=0;c<this.children.length;++c){var d=this.children[c];d.name===a&&b.push(d)}return b};
SymbolTableScope.prototype._identsMatching=function(a){var b=[],c;for(c in this.symFlags)this.symFlags.hasOwnProperty(c)&&a(this.symFlags[c])&&b.push(c);b.sort();return b};SymbolTableScope.prototype.get_parameters=function(){goog.asserts.assert("function"==this.get_type(),"get_parameters only valid for function scopes");this._funcParams||(this._funcParams=this._identsMatching(function(a){return a&DEF_PARAM}));return this._funcParams};
SymbolTableScope.prototype.get_locals=function(){goog.asserts.assert("function"==this.get_type(),"get_locals only valid for function scopes");this._funcLocals||(this._funcLocals=this._identsMatching(function(a){return a&DEF_BOUND}));return this._funcLocals};
SymbolTableScope.prototype.get_globals=function(){goog.asserts.assert("function"==this.get_type(),"get_globals only valid for function scopes");this._funcGlobals||(this._funcGlobals=this._identsMatching(function(a){a=a>>SCOPE_OFF&SCOPE_MASK;return a==GLOBAL_IMPLICIT||a==GLOBAL_EXPLICIT}));return this._funcGlobals};
SymbolTableScope.prototype.get_frees=function(){goog.asserts.assert("function"==this.get_type(),"get_frees only valid for function scopes");this._funcFrees||(this._funcFrees=this._identsMatching(function(a){return(a>>SCOPE_OFF&SCOPE_MASK)==FREE}));return this._funcFrees};
SymbolTableScope.prototype.get_methods=function(){goog.asserts.assert("class"==this.get_type(),"get_methods only valid for class scopes");if(!this._classMethods){for(var a=[],b=0;b<this.children.length;++b)a.push(this.children[b].name);a.sort();this._classMethods=a}return this._classMethods};SymbolTableScope.prototype.getScope=function(a){a=this.symFlags[a];return void 0===a?0:a>>SCOPE_OFF&SCOPE_MASK};
function SymbolTable(a){this.filename=a;this.top=this.cur=null;this.stack=[];this.curClass=this.global=null;this.tmpname=0;this.stss={}}SymbolTable.prototype.getStsForAst=function(a){goog.asserts.assert(void 0!==a.scopeId,"ast wasn't added to st?");a=this.stss[a.scopeId];goog.asserts.assert(void 0!==a,"unknown sym tab entry");return a};
SymbolTable.prototype.SEQStmt=function(a){goog.asserts.assert(goog.isArrayLike(a),"SEQ: nodes isn't array? got %s",a);for(var b=a.length,c=0;c<b;++c){var d=a[c];d&&this.visitStmt(d)}};SymbolTable.prototype.SEQExpr=function(a){goog.asserts.assert(goog.isArrayLike(a),"SEQ: nodes isn't array? got %s",a);for(var b=a.length,c=0;c<b;++c){var d=a[c];d&&this.visitExpr(d)}};
SymbolTable.prototype.enterBlock=function(a,b,c,d){a=fixReservedNames(a);var e=null;this.cur&&(e=this.cur,this.stack.push(this.cur));this.cur=new SymbolTableScope(this,a,b,c,d);"top"===a&&(this.global=this.cur.symFlags);e&&e.children.push(this.cur)};SymbolTable.prototype.exitBlock=function(){this.cur=null;0<this.stack.length&&(this.cur=this.stack.pop())};
SymbolTable.prototype.visitParams=function(a,b){for(var c=0;c<a.length;++c){var d=a[c];if(d.constructor===Name)goog.asserts.assert(d.ctx===Param||d.ctx===Store&&!b),this.addDef(d.id,DEF_PARAM,d.lineno);else throw new Sk.builtin.SyntaxError("invalid expression in parameter list",this.filename);}};
SymbolTable.prototype.visitArguments=function(a,b){a.args&&this.visitParams(a.args,!0);a.vararg&&(this.addDef(a.vararg,DEF_PARAM,b),this.cur.varargs=!0);a.kwarg&&(this.addDef(a.kwarg,DEF_PARAM,b),this.cur.varkeywords=!0)};SymbolTable.prototype.newTmpname=function(a){this.addDef(new Sk.builtin.str("_["+ ++this.tmpname+"]"),DEF_LOCAL,a)};
SymbolTable.prototype.addDef=function(a,b,c){var d=mangleName(this.curClass,new Sk.builtin.str(a)).v,d=fixReservedNames(d),e=this.cur.symFlags[d];if(void 0!==e){if(b&DEF_PARAM&&e&DEF_PARAM)throw new Sk.builtin.SyntaxError("duplicate argument '"+a.v+"' in function definition",this.filename,c);e|=b}else e=b;this.cur.symFlags[d]=e;b&DEF_PARAM?this.cur.varnames.push(d):b&DEF_GLOBAL&&(e=b,a=this.global[d],void 0!==a&&(e|=a),this.global[d]=e)};
SymbolTable.prototype.visitSlice=function(a){switch(a.constructor){case Slice:a.lower&&this.visitExpr(a.lower);a.upper&&this.visitExpr(a.upper);a.step&&this.visitExpr(a.step);break;case ExtSlice:for(var b=0;b<a.dims.length;++b)this.visitSlice(a.dims[b]);break;case Index:this.visitExpr(a.value)}};
SymbolTable.prototype.visitStmt=function(a){goog.asserts.assert(void 0!==a,"visitStmt called with undefined");switch(a.constructor){case FunctionDef:this.addDef(a.name,DEF_LOCAL,a.lineno);a.args.defaults&&this.SEQExpr(a.args.defaults);a.decorator_list&&this.SEQExpr(a.decorator_list);this.enterBlock(a.name.v,FunctionBlock,a,a.lineno);this.visitArguments(a.args,a.lineno);this.SEQStmt(a.body);this.exitBlock();break;case ClassDef:this.addDef(a.name,DEF_LOCAL,a.lineno);this.SEQExpr(a.bases);a.decorator_list&&
this.SEQExpr(a.decorator_list);this.enterBlock(a.name.v,ClassBlock,a,a.lineno);var b=this.curClass;this.curClass=a.name;this.SEQStmt(a.body);this.curCalss=b;this.exitBlock();break;case Return_:if(a.value&&(this.visitExpr(a.value),this.cur.returnsValue=!0,this.cur.generator))throw new Sk.builtin.SyntaxError("'return' with argument inside generator",this.filename);break;case Delete_:this.SEQExpr(a.targets);break;case Assign:this.SEQExpr(a.targets);this.visitExpr(a.value);break;case AugAssign:this.visitExpr(a.target);
this.visitExpr(a.value);break;case Print:a.dest&&this.visitExpr(a.dest);this.SEQExpr(a.values);break;case For_:this.visitExpr(a.target);this.visitExpr(a.iter);this.SEQStmt(a.body);a.orelse&&this.SEQStmt(a.orelse);break;case While_:this.visitExpr(a.test);this.SEQStmt(a.body);a.orelse&&this.SEQStmt(a.orelse);break;case If_:this.visitExpr(a.test);this.SEQStmt(a.body);a.orelse&&this.SEQStmt(a.orelse);break;case Raise:a.type&&(this.visitExpr(a.type),a.inst&&(this.visitExpr(a.inst),a.tback&&this.visitExpr(a.tback)));
break;case TryExcept:this.SEQStmt(a.body);this.SEQStmt(a.orelse);this.visitExcepthandlers(a.handlers);break;case TryFinally:this.SEQStmt(a.body);this.SEQStmt(a.finalbody);break;case Assert:this.visitExpr(a.test);a.msg&&this.visitExpr(a.msg);break;case Import_:case ImportFrom:this.visitAlias(a.names,a.lineno);break;case Exec:this.visitExpr(a.body);a.globals&&(this.visitExpr(a.globals),a.locals&&this.visitExpr(a.locals));break;case Global:for(var b=a.names.length,c=0;c<b;++c){var d=mangleName(this.curClass,
a.names[c]).v,d=fixReservedNames(d),e=this.cur.symFlags[d];if(e&(DEF_LOCAL|USE)){if(e&DEF_LOCAL)throw new Sk.builtin.SyntaxError("name '"+d+"' is assigned to before global declaration",this.filename,a.lineno);throw new Sk.builtin.SyntaxError("name '"+d+"' is used prior to global declaration",this.filename,a.lineno);}this.addDef(new Sk.builtin.str(d),DEF_GLOBAL,a.lineno)}break;case Expr:this.visitExpr(a.value);break;case Pass:case Break_:case Continue_:break;case With_:this.newTmpname(a.lineno);this.visitExpr(a.context_expr);
a.optional_vars&&(this.newTmpname(a.lineno),this.visitExpr(a.optional_vars));this.SEQStmt(a.body);break;default:goog.asserts.fail("Unhandled type "+a.constructor.name+" in visitStmt")}};
SymbolTable.prototype.visitExpr=function(a){goog.asserts.assert(void 0!==a,"visitExpr called with undefined");switch(a.constructor){case BoolOp:this.SEQExpr(a.values);break;case BinOp:this.visitExpr(a.left);this.visitExpr(a.right);break;case UnaryOp:this.visitExpr(a.operand);break;case Lambda:this.addDef(new Sk.builtin.str("lambda"),DEF_LOCAL,a.lineno);a.args.defaults&&this.SEQExpr(a.args.defaults);this.enterBlock("lambda",FunctionBlock,a,a.lineno);this.visitArguments(a.args,a.lineno);this.visitExpr(a.body);
this.exitBlock();break;case IfExp:this.visitExpr(a.test);this.visitExpr(a.body);this.visitExpr(a.orelse);break;case Dict:this.SEQExpr(a.keys);this.SEQExpr(a.values);break;case ListComp:this.newTmpname(a.lineno);this.visitExpr(a.elt);this.visitComprehension(a.generators,0);break;case GeneratorExp:this.visitGenexp(a);break;case Yield:a.value&&this.visitExpr(a.value);this.cur.generator=!0;if(this.cur.returnsValue)throw new Sk.builtin.SyntaxError("'return' with argument inside generator",this.filename);
break;case Compare:this.visitExpr(a.left);this.SEQExpr(a.comparators);break;case Call:this.visitExpr(a.func);this.SEQExpr(a.args);for(var b=0;b<a.keywords.length;++b)this.visitExpr(a.keywords[b].value);a.starargs&&this.visitExpr(a.starargs);a.kwargs&&this.visitExpr(a.kwargs);break;case Num:case Str:break;case Attribute:this.visitExpr(a.value);break;case Subscript:this.visitExpr(a.value);this.visitSlice(a.slice);break;case Name:this.addDef(a.id,a.ctx===Load?USE:DEF_LOCAL,a.lineno);break;case List:case Tuple:this.SEQExpr(a.elts);
break;default:goog.asserts.fail("Unhandled type "+a.constructor.name+" in visitExpr")}};SymbolTable.prototype.visitComprehension=function(a,b){for(var c=a.length,d=b;d<c;++d){var e=a[d];this.visitExpr(e.target);this.visitExpr(e.iter);this.SEQExpr(e.ifs)}};
SymbolTable.prototype.visitAlias=function(a,b){for(var c=0;c<a.length;++c){var d=a[c],e=d=null===d.asname?d.name.v:d.asname.v,f=d.indexOf(".");-1!==f&&(e=d.substr(0,f));if("*"!==d)this.addDef(new Sk.builtin.str(e),DEF_IMPORT,b);else if(this.cur.blockType!==ModuleBlock)throw new Sk.builtin.SyntaxError("import * only allowed at module level",this.filename);}};
SymbolTable.prototype.visitGenexp=function(a){var b=a.generators[0];this.visitExpr(b.iter);this.enterBlock("genexpr",FunctionBlock,a,a.lineno);this.cur.generator=!0;this.addDef(new Sk.builtin.str(".0"),DEF_PARAM,a.lineno);this.visitExpr(b.target);this.SEQExpr(b.ifs);this.visitComprehension(a.generators,1);this.visitExpr(a.elt);this.exitBlock()};SymbolTable.prototype.visitExcepthandlers=function(a){for(var b=0,c;c=a[b];++b)c.type&&this.visitExpr(c.type),c.name&&this.visitExpr(c.name),this.SEQStmt(c.body)};
function _dictUpdate(a,b){for(var c in b)a[c]=b[c]}
SymbolTable.prototype.analyzeBlock=function(a,b,c,d){var e={},f={},g={},h={},k={};a.blockType==ClassBlock&&(_dictUpdate(g,d),b&&_dictUpdate(h,b));for(var l in a.symFlags)this.analyzeName(a,f,l,a.symFlags[l],b,e,c,d);a.blockType!==ClassBlock&&(a.blockType===FunctionBlock&&_dictUpdate(h,e),b&&_dictUpdate(h,b),_dictUpdate(g,d));d={};e=a.children.length;for(l=0;l<e;++l){var m=a.children[l];this.analyzeChildBlock(m,h,k,g,d);if(m.hasFree||m.childHasFree)a.childHasFree=!0}_dictUpdate(k,d);a.blockType===
FunctionBlock&&this.analyzeCells(f,k);this.updateSymbols(a.symFlags,f,b,k,a.blockType===ClassBlock);_dictUpdate(c,k)};SymbolTable.prototype.analyzeChildBlock=function(a,b,c,d,e){var f={};_dictUpdate(f,b);b={};_dictUpdate(b,c);c={};_dictUpdate(c,d);this.analyzeBlock(a,f,b,c);_dictUpdate(e,b)};SymbolTable.prototype.analyzeCells=function(a,b){for(var c in a)a[c]===LOCAL&&void 0!==b[c]&&(a[c]=CELL,delete b[c])};
SymbolTable.prototype.updateSymbols=function(a,b,c,d,e){for(var f in a){var g=a[f],g=g|b[f]<<SCOPE_OFF;a[f]=g}b=FREE<<SCOPE_OFF;for(f in d)d=a[f],void 0!==d?e&&d&(DEF_BOUND|DEF_GLOBAL)&&(a[f]=d|DEF_FREE_CLASS):void 0!==c[f]&&(a[f]=b)};
SymbolTable.prototype.analyzeName=function(a,b,c,d,e,f,g,h){if(d&DEF_GLOBAL){if(d&DEF_PARAM)throw new Sk.builtin.SyntaxError("name '"+c+"' is local and global",this.filename,a.lineno);b[c]=GLOBAL_EXPLICIT;h[c]=null;e&&void 0!==e[c]&&delete e[c]}else d&DEF_BOUND?(b[c]=LOCAL,f[c]=null,delete h[c]):e&&void 0!==e[c]?(b[c]=FREE,a.hasFree=!0,g[c]=null):(h&&void 0!==h[c]||!a.isNested||(a.hasFree=!0),b[c]=GLOBAL_IMPLICIT)};SymbolTable.prototype.analyze=function(){this.analyzeBlock(this.top,null,{},{})};
Sk.symboltable=function(a,b){var c=new SymbolTable(b);c.enterBlock("top",ModuleBlock,a,0);c.top=c.cur;for(var d=0;d<a.body.length;++d)c.visitStmt(a.body[d]);c.exitBlock();c.analyze();return c};
Sk.dumpSymtab=function(a){var b=function(a){return a?"True":"False"},c=function(a){for(var b=[],c=0;c<a.length;++c)b.push((new Sk.builtin.str(a[c])).$r().v);return"["+b.join(", ")+"]"},d=function(a,f){void 0===f&&(f="");var g;g=""+(f+"Sym_type: "+a.get_type()+"\n");g+=f+"Sym_name: "+a.get_name()+"\n";g+=f+"Sym_lineno: "+a.get_lineno()+"\n";g+=f+"Sym_nested: "+b(a.is_nested())+"\n";g+=f+"Sym_haschildren: "+b(a.has_children())+"\n";"class"===a.get_type()?g+=f+"Class_methods: "+c(a.get_methods())+"\n":
"function"===a.get_type()&&(g+=f+"Func_params: "+c(a.get_parameters())+"\n",g+=f+"Func_locals: "+c(a.get_locals())+"\n",g+=f+"Func_globals: "+c(a.get_globals())+"\n",g+=f+"Func_frees: "+c(a.get_frees())+"\n");g+=f+"-- Identifiers --\n";for(var h=a.get_identifiers(),k=h.length,l=0;l<k;++l){var m=a.lookup(h[l]);g+=f+"name: "+m.get_name()+"\n";g+=f+" is_referenced: "+b(m.is_referenced())+"\n";g+=f+" is_imported: "+b(m.is_imported())+"\n";g+=f+" is_parameter: "+b(m.is_parameter())+"\n";g+=f+" is_global: "+
b(m.is_global())+"\n";g+=f+" is_declared_global: "+b(m.is_declared_global())+"\n";g+=f+" is_local: "+b(m.is_local())+"\n";g+=f+" is_free: "+b(m.is_free())+"\n";g+=f+" is_assigned: "+b(m.is_assigned())+"\n";g+=f+" is_namespace: "+b(m.is_namespace())+"\n";var m=m.get_namespaces(),n=m.length;g+=f+" namespaces: [\n";for(var p=[],q=0;q<n;++q)p.push(d(m[q],f+" "));g+=p.join("\n");g+=f+" ]\n"}return g};return d(a.top,"")};goog.exportSymbol("Sk.symboltable",Sk.symboltable);
goog.exportSymbol("Sk.dumpSymtab",Sk.dumpSymtab);var out;Sk.gensymcount=0;function Compiler(a,b,c,d){this.filename=a;this.st=b;this.flags=c;this.interactive=!1;this.nestlevel=0;this.u=null;this.stack=[];this.result=[];this.allUnits=[];this.source=d?d.split("\n"):!1}
function CompilerUnit(){this.private_=this.name=this.ste=null;this.lineno=this.firstlineno=0;this.linenoSet=!1;this.localnames=[];this.blocknum=0;this.blocks=[];this.curblock=0;this.scopename=null;this.suffixCode=this.switchCode=this.varDeclsCode=this.prefixCode="";this.breakBlocks=[];this.continueBlocks=[];this.exceptBlocks=[];this.finallyBlocks=[]}CompilerUnit.prototype.activateScope=function(){var a=this;out=function(){for(var b=a.blocks[a.curblock],c=0;c<arguments.length;++c)b.push(arguments[c])}};
Compiler.prototype.getSourceLine=function(a){goog.asserts.assert(this.source);return this.source[a-1]};Compiler.prototype.annotateSource=function(a){if(this.source){var b=a.lineno;a=a.col_offset;out("\n//\n// line ",b,":\n// ",this.getSourceLine(b),"\n// ");for(var c=0;c<a;++c)out(" ");out("^\n//\n");out("\nSk.currLineNo = ",b,";\nSk.currColNo = ",a,"\n\n");out("\nSk.currFilename = '",this.filename,"';\n\n")}};Compiler.prototype.gensym=function(a){a="$"+(a||"");return a+=Sk.gensymcount++};
Compiler.prototype.niceName=function(a){return this.gensym(a.replace("<","").replace(">","").replace(" ","_"))};
var reservedWords_={"abstract":!0,as:!0,"boolean":!0,"break":!0,"byte":!0,"case":!0,"catch":!0,"char":!0,"class":!0,"continue":!0,"const":!0,"debugger":!0,"default":!0,"delete":!0,"do":!0,"double":!0,"else":!0,"enum":!0,"export":!0,"extends":!0,"false":!0,"final":!0,"finally":!0,"float":!0,"for":!0,"function":!0,"goto":!0,"if":!0,"implements":!0,"import":!0,"in":!0,"instanceof":!0,"int":!0,"interface":!0,is:!0,"long":!0,namespace:!0,"native":!0,"new":!0,"null":!0,"package":!0,"private":!0,"protected":!0,
"public":!0,"return":!0,"short":!0,"static":!0,"super":!1,"switch":!0,"synchronized":!0,"this":!0,"throw":!0,"throws":!0,"transient":!0,"true":!0,"try":!0,"typeof":!0,use:!0,"var":!0,"void":!0,"volatile":!0,"while":!0,"with":!0};function fixReservedWords(a){return!0!==reservedWords_[a]?a:a+"_$rw$"}
var reservedNames_={__defineGetter__:!0,__defineSetter__:!0,apply:!0,call:!0,eval:!0,hasOwnProperty:!0,isPrototypeOf:!0,__lookupGetter__:!0,__lookupSetter__:!0,__noSuchMethod__:!0,propertyIsEnumerable:!0,toSource:!0,toLocaleString:!0,toString:!0,unwatch:!0,valueOf:!0,watch:!0,length:!0};function fixReservedNames(a){return reservedNames_[a]?a+"_$rn$":a}
function mangleName(a,b){var c=b.v,d=null;if(null===a||(null===c||"_"!==c.charAt(0)||"_"!==c.charAt(1))||"_"===c.charAt(c.length-1)&&"_"===c.charAt(c.length-2))return b;d=a.v;d.replace(/_/g,"");if(""===d)return b;d=a.v;d.replace(/^_*/,"");return d=new Sk.builtin.str("_"+d+c)}Compiler.prototype._gr=function(a,b){var c=this.gensym(a);out("var ",c,"=");for(var d=1;d<arguments.length;++d)out(arguments[d]);out(";");return c};
Compiler.prototype._interruptTest=function(){out("if (Sk.execStart === undefined) {Sk.execStart=new Date()}");out("if (Sk.execLimit != null && new Date() - Sk.execStart > Sk.execLimit) {throw new Sk.builtin.TimeLimitError(Sk.timeoutMsg())}")};Compiler.prototype._jumpfalse=function(a,b){var c=this._gr("jfalse","(",a,"===false||!Sk.misceval.isTrue(",a,"))");this._interruptTest();out("if(",c,"){/*test failed */$blk=",b,";continue;}")};
Compiler.prototype._jumpundef=function(a,b){this._interruptTest();out("if(",a,"===undefined){$blk=",b,";continue;}")};Compiler.prototype._jumptrue=function(a,b){var c=this._gr("jtrue","(",a,"===true||Sk.misceval.isTrue(",a,"))");this._interruptTest();out("if(",c,"){/*test passed */$blk=",b,";continue;}")};Compiler.prototype._jump=function(a){this._interruptTest();out("$blk=",a,";/* jump */continue;")};
Compiler.prototype.ctupleorlist=function(a,b,c){goog.asserts.assert("tuple"===c||"list"===c);if(a.ctx===Store)for(var d=0;d<a.elts.length;++d)this.vexpr(a.elts[d],"Sk.abstr.objectGetItem("+b+","+d+")");else if(a.ctx===Load){b=[];for(d=0;d<a.elts.length;++d)b.push(this._gr("elem",this.vexpr(a.elts[d])));return this._gr("load"+c,"new Sk.builtins['",c,"']([",b,"])")}};
Compiler.prototype.cdict=function(a){goog.asserts.assert(a.values.length===a.keys.length);for(var b=[],c=0;c<a.values.length;++c){var d=this.vexpr(a.values[c]);b.push(this.vexpr(a.keys[c]));b.push(d)}return this._gr("loaddict","new Sk.builtins['dict']([",b,"])")};
Compiler.prototype.clistcompgen=function(a,b,c,d){var e=this.newBlock("list gen start"),f=this.newBlock("list gen skip"),g=this.newBlock("list gen anchor"),h=b[c],k=this.vexpr(h.iter),k=this._gr("iter","Sk.abstr.iter(",k,")");this._jump(e);this.setBlock(e);k=this._gr("next","Sk.abstr.iternext(",k,")");this._jumpundef(k,g);this.vexpr(h.target,k);for(var k=h.ifs.length,l=0;l<k;++l){var m=this.vexpr(h.ifs[l]);this._jumpfalse(m,e)}++c<b.length&&this.clistcompgen(a,b,c,d);c>=b.length&&(b=this.vexpr(d),
out(a,".v.push(",b,");"),this._jump(f),this.setBlock(f));this._jump(e);this.setBlock(g);return a};Compiler.prototype.clistcomp=function(a){goog.asserts.assert(a instanceof ListComp);var b=this._gr("_compr","new Sk.builtins['list']([])");return this.clistcompgen(b,a.generators,0,a.elt)};
Compiler.prototype.cyield=function(a){if(this.u.ste.blockType!==FunctionBlock)throw new SyntaxError("'yield' outside function");var b="null";a.value&&(b=this.vexpr(a.value));a=this.newBlock("after yield");out("return [/*resume*/",a,",/*ret*/",b,"];");this.setBlock(a);return"$gen.gi$sentvalue"};
Compiler.prototype.ccompare=function(a){goog.asserts.assert(a.ops.length===a.comparators.length);for(var b=this.vexpr(a.left),c=a.ops.length,d=this.newBlock("done"),e=this._gr("compareres","null"),f=0;f<c;++f){var g=this.vexpr(a.comparators[f]),b=this._gr("compare","Sk.builtin.bool(Sk.misceval.richCompareBool(",b,",",g,",'",a.ops[f].prototype._astname,"'))");out(e,"=",b,";");this._jumpfalse(b,d);b=g}this._jump(d);this.setBlock(d);return e};
Compiler.prototype.ccall=function(a){var b=this.vexpr(a.func),c=this.vseqexpr(a.args);if(0<a.keywords.length||a.starargs||a.kwargs){for(var d=[],e=0;e<a.keywords.length;++e)d.push("'"+a.keywords[e].arg.v+"'"),d.push(this.vexpr(a.keywords[e].value));var d="["+d.join(",")+"]",f=e="undefined";a.starargs&&(e=this.vexpr(a.starargs));a.kwargs&&(f=this.vexpr(a.kwargs));return this._gr("call","Sk.misceval.call(",b,",",f,",",e,",",d,0<c.length?",":"",c,")")}return this._gr("call","Sk.misceval.callsim(",b,
0<c.length?",":"",c,")")};Compiler.prototype.cslice=function(a){goog.asserts.assert(a instanceof Slice);var b=a.lower?this.vexpr(a.lower):a.step?"Sk.builtin.none.none$":"new Sk.builtin.nmber(0)",c=a.upper?this.vexpr(a.upper):a.step?"Sk.builtin.none.none$":"new Sk.builtin.nmber(2147483647)";a=a.step?this.vexpr(a.step):"Sk.builtin.none.none$";return this._gr("slice","new Sk.builtins['slice'](",b,",",c,",",a,")")};
Compiler.prototype.eslice=function(a){goog.asserts.assert(a instanceof Array);for(var b=[],c=0;c<a.length;c++)b.push(this.vslicesub(a[c]));return this._gr("extslice","new Sk.builtins['tuple']([",b,"])")};Compiler.prototype.vslicesub=function(a){var b;switch(a.constructor){case Number:case String:b=a;break;case Index:b=this.vexpr(a.value);break;case Slice:b=this.cslice(a);break;case Ellipsis:goog.asserts.fail("todo compile.js Ellipsis;");break;case ExtSlice:b=this.eslice(a.dims);break;default:goog.asserts.fail("invalid subscript kind")}return b};
Compiler.prototype.vslice=function(a,b,c,d){a=this.vslicesub(a);return this.chandlesubscr(b,c,a,d)};Compiler.prototype.chandlesubscr=function(a,b,c,d){if(a===Load||a===AugLoad)return this._gr("lsubscr","Sk.abstr.objectGetItem(",b,",",c,")");a===Store||a===AugStore?out("Sk.abstr.objectSetItem(",b,",",c,",",d,");"):a===Del?out("Sk.abstr.objectDelItem(",b,",",c,");"):goog.asserts.fail("handlesubscr fail")};
Compiler.prototype.cboolop=function(a){goog.asserts.assert(a instanceof BoolOp);var b;b=a.op===And?this._jumpfalse:this._jumptrue;var c=this.newBlock("end of boolop");a=a.values;for(var d=a.length,e,f=0;f<d;++f){var g=this.vexpr(a[f]);0===f&&(e=this._gr("boolopsucc",g));out(e,"=",g,";");b.call(this,g,c)}this._jump(c);this.setBlock(c);return e};
Compiler.prototype.vexpr=function(a,b,c){a.lineno>this.u.lineno&&(this.u.lineno=a.lineno,this.u.linenoSet=!1);switch(a.constructor){case BoolOp:return this.cboolop(a);case BinOp:return this._gr("binop","Sk.abstr.numberBinOp(",this.vexpr(a.left),",",this.vexpr(a.right),",'",a.op.prototype._astname,"')");case UnaryOp:return this._gr("unaryop","Sk.abstr.numberUnaryOp(",this.vexpr(a.operand),",'",a.op.prototype._astname,"')");case Lambda:return this.clambda(a);case IfExp:return this.cifexp(a);case Dict:return this.cdict(a);
case ListComp:return this.clistcomp(a);case GeneratorExp:return this.cgenexp(a);case Yield:return this.cyield(a);case Compare:return this.ccompare(a);case Call:return b=this.ccall(a),this.annotateSource(a),b;case Num:if("number"===typeof a.n)return a.n;if(a.n instanceof Sk.builtin.nmber)return"new Sk.builtin.nmber("+a.n.v+",'"+a.n.skType+"')";if(a.n instanceof Sk.builtin.lng)return"Sk.longFromStr('"+a.n.tp$str().v+"')";goog.asserts.fail("unhandled Num type");case Str:return this._gr("str","new Sk.builtins['str'](",
a.s.$r().v,")");case Attribute:var d;a.ctx!==AugStore&&(d=this.vexpr(a.value));var e=a.attr.$r().v,e=e.substring(1,e.length-1),e=mangleName(this.u.private_,new Sk.builtin.str(e)).v,e=fixReservedWords(e),e=fixReservedNames(e);switch(a.ctx){case AugLoad:case Load:return this._gr("lattr","Sk.abstr.gattr(",d,",'",e,"')");case AugStore:out("if(",b,"!==undefined){");d=this.vexpr(c||null);out("Sk.abstr.sattr(",d,",'",e,"',",b,");");out("}");break;case Store:out("Sk.abstr.sattr(",d,",'",e,"',",b,");");break;
case Del:goog.asserts.fail("todo Del;");break;default:goog.asserts.fail("invalid attribute expression")}break;case Subscript:switch(a.ctx){case AugLoad:case Load:case Store:case Del:return this.vslice(a.slice,a.ctx,this.vexpr(a.value),b);case AugStore:out("if(",b,"!==undefined){");d=this.vexpr(c||null);this.vslice(a.slice,a.ctx,d,b);out("}");break;default:goog.asserts.fail("invalid subscript expression")}break;case Name:return this.nameop(a.id,a.ctx,b);case List:return this.ctupleorlist(a,b,"list");
case Tuple:return this.ctupleorlist(a,b,"tuple");default:goog.asserts.fail("unhandled case in vexpr")}};Compiler.prototype.vseqexpr=function(a,b){goog.asserts.assert(void 0===b||a.length===b.length);for(var c=[],d=0;d<a.length;++d)c.push(this.vexpr(a[d],void 0===b?void 0:b[d]));return c};
Compiler.prototype.caugassign=function(a){goog.asserts.assert(a instanceof AugAssign);var b=a.target;switch(b.constructor){case Attribute:var c=new Attribute(b.value,b.attr,AugLoad,b.lineno,b.col_offset),d=this.vexpr(c),e=this.vexpr(a.value);a=this._gr("inplbinopattr","Sk.abstr.numberInplaceBinOp(",d,",",e,",'",a.op.prototype._astname,"')");c.ctx=AugStore;return this.vexpr(c,a,b.value);case Subscript:return c=this.vslicesub(b.slice),c=new Subscript(b.value,c,AugLoad,b.lineno,b.col_offset),d=this.vexpr(c),
e=this.vexpr(a.value),a=this._gr("inplbinopsubscr","Sk.abstr.numberInplaceBinOp(",d,",",e,",'",a.op.prototype._astname,"')"),c.ctx=AugStore,this.vexpr(c,a,b.value);case Name:return c=this.nameop(b.id,Load),e=this.vexpr(a.value),a=this._gr("inplbinop","Sk.abstr.numberInplaceBinOp(",c,",",e,",'",a.op.prototype._astname,"')"),this.nameop(b.id,Store,a);default:goog.asserts.fail("unhandled case in augassign")}};
Compiler.prototype.exprConstant=function(a){switch(a.constructor){case Num:return Sk.misceval.isTrue(a.n);case Str:return Sk.misceval.isTrue(a.s);default:return-1}};Compiler.prototype.newBlock=function(a){var b=this.u.blocknum++;this.u.blocks[b]=[];this.u.blocks[b]._name=a||"<unnamed>";return b};Compiler.prototype.setBlock=function(a){goog.asserts.assert(0<=a&&a<this.u.blocknum);this.u.curblock=a};Compiler.prototype.pushBreakBlock=function(a){goog.asserts.assert(0<=a&&a<this.u.blocknum);this.u.breakBlocks.push(a)};
Compiler.prototype.popBreakBlock=function(){this.u.breakBlocks.pop()};Compiler.prototype.pushContinueBlock=function(a){goog.asserts.assert(0<=a&&a<this.u.blocknum);this.u.continueBlocks.push(a)};Compiler.prototype.popContinueBlock=function(){this.u.continueBlocks.pop()};Compiler.prototype.pushExceptBlock=function(a){goog.asserts.assert(0<=a&&a<this.u.blocknum);this.u.exceptBlocks.push(a)};Compiler.prototype.popExceptBlock=function(){this.u.exceptBlocks.pop()};
Compiler.prototype.pushFinallyBlock=function(a){goog.asserts.assert(0<=a&&a<this.u.blocknum);this.u.finallyBlocks.push(a)};Compiler.prototype.popFinallyBlock=function(){this.u.finallyBlocks.pop()};Compiler.prototype.setupExcept=function(a){out("$exc.push(",a,");")};Compiler.prototype.endExcept=function(){out("$exc.pop();")};
Compiler.prototype.outputLocals=function(a){for(var b={},c=0;a.argnames&&c<a.argnames.length;++c)b[a.argnames[c]]=!0;a.localnames.sort();for(var d=[],c=0;c<a.localnames.length;++c){var e=a.localnames[c];void 0===b[e]&&(d.push(e),b[e]=!0)}return 0<d.length?"var "+d.join(",")+"; /* locals */":""};
Compiler.prototype.outputAllUnits=function(){for(var a="",b=0;b<this.allUnits.length;++b){for(var c=this.allUnits[b],a=a+c.prefixCode,a=a+this.outputLocals(c),a=a+c.varDeclsCode,a=a+c.switchCode,d=c.blocks,e=0;e<d.length;++e)a+="case "+e+": /* --- "+d[e]._name+" --- */",a+=d[e].join(""),a+="throw new Sk.builtin.SystemError('internal error: unterminated block');";a+=c.suffixCode}return a};
Compiler.prototype.cif=function(a){goog.asserts.assert(a instanceof If_);var b=this.exprConstant(a.test);if(0===b)a.orelse&&this.vseqstmt(a.orelse);else if(1===b)this.vseqstmt(a.body);else{var c=this.newBlock("end of if"),b=this.newBlock("next branch of if"),d=this.vexpr(a.test);this._jumpfalse(d,b);this.vseqstmt(a.body);this._jump(c);this.setBlock(b);a.orelse&&this.vseqstmt(a.orelse);this._jump(c)}this.setBlock(c)};
Compiler.prototype.cwhile=function(a){if(0===this.exprConstant(a.test))a.orelse&&this.vseqstmt(a.orelse);else{var b=this.newBlock("while test");this._jump(b);this.setBlock(b);var c=this.newBlock("after while"),d=0<a.orelse.length?this.newBlock("while orelse"):null,e=this.newBlock("while body");this._jumpfalse(this.vexpr(a.test),d?d:c);this._jump(e);this.pushBreakBlock(c);this.pushContinueBlock(b);this.setBlock(e);this.vseqstmt(a.body);this._jump(b);this.popContinueBlock();this.popBreakBlock();0<a.orelse.length&&
(this.setBlock(d),this.vseqstmt(a.orelse),this._jump(c));this.setBlock(c)}};
Compiler.prototype.cfor=function(a){var b=this.newBlock("for start"),c=this.newBlock("for cleanup"),d=this.newBlock("for end");this.pushBreakBlock(d);this.pushContinueBlock(b);var e=this.vexpr(a.iter),f;this.u.ste.generator?(f="$loc."+this.gensym("iter"),out(f,"=Sk.abstr.iter(",e,");")):f=this._gr("iter","Sk.abstr.iter(",e,")");this._jump(b);this.setBlock(b);e=this._gr("next","Sk.abstr.iternext(",f,")");this._jumpundef(e,c);this.vexpr(a.target,e);this.vseqstmt(a.body);this._jump(b);this.setBlock(c);
this.popContinueBlock();this.popBreakBlock();this.vseqstmt(a.orelse);this._jump(d);this.setBlock(d)};Compiler.prototype.craise=function(a){if(a&&a.type&&a.type.id&&"StopIteration"===a.type.id.v)out("return undefined;");else{var b="";a.inst?(b=this.vexpr(a.inst),out("throw ",this.vexpr(a.type),"(",b,");")):a.type?a.type.func?out("throw ",this.vexpr(a.type),";"):out("throw ",this.vexpr(a.type),"('');"):out("throw $err;")}};
Compiler.prototype.ctryexcept=function(a){for(var b=a.handlers.length,c=[],d=0;d<b;++d)c.push(this.newBlock("except_"+d+"_"));var e=this.newBlock("unhandled"),f=this.newBlock("orelse"),g=this.newBlock("end");this.setupExcept(c[0]);this.vseqstmt(a.body);this.endExcept();this._jump(f);for(d=0;d<b;++d){this.setBlock(c[d]);var h=a.handlers[d];if(!h.type&&d<b-1)throw new SyntaxError("default 'except:' must be last");if(h.type){var k=this.vexpr(h.type),l=d==b-1?e:c[d+1],k=this._gr("instance","$err instanceof ",
k);this._jumpfalse(k,l)}h.name&&this.vexpr(h.name,"$err");this.vseqstmt(h.body);this._jump(g)}this.setBlock(e);out("throw $err;");this.setBlock(f);this.vseqstmt(a.orelse);this._jump(g);this.setBlock(g)};Compiler.prototype.ctryfinally=function(a){out("/*todo; tryfinally*/");this.ctryexcept(a.body[0])};Compiler.prototype.cassert=function(a){var b=this.vexpr(a.test),c=this.newBlock("end");this._jumptrue(b,c);out("throw new Sk.builtin.AssertionError(",a.msg?this.vexpr(a.msg):"",");");this.setBlock(c)};
Compiler.prototype.cimportas=function(a,b,c){a=a.v;var d=a.indexOf(".");if(-1!==d)for(a=a.substr(d+1);-1!==d;){var d=a.indexOf("."),e=-1!==d?a.substr(0,d):a;c=this._gr("lattr","Sk.abstr.gattr(",c,",'",e,"')");a=a.substr(d+1)}return this.nameop(b,Store,c)};
Compiler.prototype.cimport=function(a){for(var b=a.names.length,c=0;c<b;++c){var d=a.names[c],e=this._gr("module","Sk.builtin.__import__(",d.name.$r().v,",$gbl,$loc,[])");if(d.asname)this.cimportas(d.name,d.asname,e);else{var d=d.name,f=d.v.indexOf(".");-1!==f&&(d=new Sk.builtin.str(d.v.substr(0,f)));this.nameop(d,Store,e)}}};
Compiler.prototype.cfromimport=function(a){for(var b=a.names.length,c=[],d=0;d<b;++d)c[d]=a.names[d].name.$r().v;c=this._gr("module","Sk.builtin.__import__(",a.module.$r().v,",$gbl,$loc,[",c,"])");for(d=0;d<b;++d){var e=a.names[d];if(0===d&&"*"===e.name.v){goog.asserts.assert(1===b);out("Sk.importStar(",c,",$loc, $gbl);");break}var f=this._gr("item","Sk.abstr.gattr(",c,",",e.name.$r().v,")"),g=e.name;e.asname&&(g=e.asname);this.nameop(g,Store,f)}};
Compiler.prototype.buildcodeobj=function(a,b,c,d,e){var f=[],g=null,h=null;c&&this.vseqexpr(c);d&&d.defaults&&(f=this.vseqexpr(d.defaults));d&&d.vararg&&(g=d.vararg);d&&d.kwarg&&(h=d.kwarg);a=this.enterScope(b,a,a.lineno);c=this.u.ste.generator;var k=this.u.ste.hasFree,l=this.u.ste.childHasFree,m=this.newBlock("codeobj entry");this.u.prefixCode="var "+a+"=(function "+this.niceName(b.v)+"$(";var n=[];if(c){if(h)throw new SyntaxError(b.v+"(): keyword arguments in generators not supported");if(g)throw new SyntaxError(b.v+
"(): variable number of arguments in generators not supported");n.push("$gen")}else{h&&n.push("$kwa");for(var p=0;d&&p<d.args.length;++p)n.push(this.nameop(d.args[p].id,Param))}k&&n.push("$free");this.u.prefixCode+=n.join(",");this.u.prefixCode+="){";c&&(this.u.prefixCode+="\n// generator\n");k&&(this.u.prefixCode+="\n// has free\n");l&&(this.u.prefixCode+="\n// has cell\n");p="{}";c&&(m="$gen.gi$resumeat",p="$gen.gi$locals");var q="";l&&(q=c?",$cell=$gen.gi$cells":",$cell={}");this.u.varDeclsCode+=
"var $blk="+m+",$exc=[],$loc="+p+q+",$gbl=this,$err=undefined;";if(0<f.length)for(l=d.args.length-f.length,p=0;p<f.length;++p)m=this.nameop(d.args[p+l].id,Param),this.u.varDeclsCode+="if("+m+"===undefined)"+m+"="+a+".$defaults["+p+"];";for(p=0;d&&p<d.args.length;++p)l=d.args[p].id,this.isCell(l)&&(this.u.varDeclsCode+="$cell."+l.v+"="+l.v+";");c||(this.u.varDeclsCode+='Sk.builtin.pyCheckArgs("'+b.v+'", arguments, '+(d?d.args.length-f.length:0)+", "+(g?Infinity:d?d.args.length:0)+", "+(h?!0:!1)+", "+
k+");");g&&(this.u.varDeclsCode+=g.v+"=new Sk.builtins['tuple'](Array.prototype.slice.call(arguments,"+n.length+")); /*vararg*/");h&&(this.u.varDeclsCode+=h.v+"=new Sk.builtins['dict']($kwa);");this.u.switchCode="while(true){try{ switch($blk){";this.u.suffixCode="} }catch(err){if ($exc.length>0) { $err = err; $blk=$exc.pop(); continue; } else { throw err; }} }});";e.call(this,a);var r;if(d&&0<d.args.length){e=[];for(p=0;p<d.args.length;++p)e.push(d.args[p].id.v);r=e.join("', '");this.u.argnames=e}this.exitScope();
0<f.length&&out(a,".$defaults=[",f.join(","),"];");r&&out(a,".co_varnames=['",r,"'];");h&&out(a,".co_kwargs=1;");h="";k&&(h=",$cell",this.u.ste.hasFree&&(h+=",$free"));return c?d&&0<d.args.length?this._gr("gener","new Sk.builtins['function']((function(){var $origargs=Array.prototype.slice.call(arguments);Sk.builtin.pyCheckArgs(\"",b.v,'",arguments,',d.args.length-f.length,",",d.args.length,");return new Sk.builtins['generator'](",a,",$gbl,$origargs",h,");}))"):this._gr("gener","new Sk.builtins['function']((function(){Sk.builtin.pyCheckArgs(\"",
b.v,"\",arguments,0,0);return new Sk.builtins['generator'](",a,",$gbl,[]",h,");}))"):this._gr("funcobj","new Sk.builtins['function'](",a,",$gbl",h,")")};Compiler.prototype.cfunction=function(a){goog.asserts.assert(a instanceof FunctionDef);var b=this.buildcodeobj(a,a.name,a.decorator_list,a.args,function(b){this.vseqstmt(a.body);out("return Sk.builtin.none.none$;")});this.nameop(a.name,Store,b)};
Compiler.prototype.clambda=function(a){goog.asserts.assert(a instanceof Lambda);return this.buildcodeobj(a,new Sk.builtin.str("<lambda>"),null,a.args,function(b){b=this.vexpr(a.body);out("return ",b,";")})};
Compiler.prototype.cifexp=function(a){var b=this.newBlock("next of ifexp"),c=this.newBlock("end of ifexp"),d=this._gr("res","null"),e=this.vexpr(a.test);this._jumpfalse(e,b);out(d,"=",this.vexpr(a.body),";");this._jump(c);this.setBlock(b);out(d,"=",this.vexpr(a.orelse),";");this._jump(c);this.setBlock(c);return d};
Compiler.prototype.cgenexpgen=function(a,b,c){var d=this.newBlock("start for "+b),e=this.newBlock("skip for "+b);this.newBlock("if cleanup for "+b);var f=this.newBlock("end for "+b),g=a[b],h;if(0===b)h="$loc.$iter0";else{var k=this.vexpr(g.iter);h="$loc."+this.gensym("iter");out(h,"=","Sk.abstr.iter(",k,");")}this._jump(d);this.setBlock(d);h=this._gr("next","Sk.abstr.iternext(",h,")");this._jumpundef(h,f);this.vexpr(g.target,h);h=g.ifs.length;for(k=0;k<h;++k){var l=this.vexpr(g.ifs[k]);this._jumpfalse(l,
d)}++b<a.length&&this.cgenexpgen(a,b,c);b>=a.length&&(a=this.vexpr(c),out("return [",e,"/*resume*/,",a,"/*ret*/];"),this.setBlock(e));this._jump(d);this.setBlock(f);1===b&&out("return Sk.builtin.none.none$;")};Compiler.prototype.cgenexp=function(a){var b=this.buildcodeobj(a,new Sk.builtin.str("<genexpr>"),null,null,function(b){this.cgenexpgen(a.generators,0,a.elt)}),b=this._gr("gener","Sk.misceval.callsim(",b,");");out(b,".gi$locals.$iter0=Sk.abstr.iter(",this.vexpr(a.generators[0].iter),");");return b};
Compiler.prototype.cclass=function(a){goog.asserts.assert(a instanceof ClassDef);var b=this.vseqexpr(a.bases),c=this.enterScope(a.name,a,a.lineno),d=this.newBlock("class entry");this.u.prefixCode="var "+c+"=(function $"+a.name.v+"$class_outer($globals,$locals,$rest){var $gbl=$globals,$loc=$locals;";this.u.switchCode+="return(function "+a.name.v+"(){";this.u.switchCode+="var $blk="+d+",$exc=[];while(true){switch($blk){";this.u.suffixCode="}break;}}).apply(null,$rest);});";this.u.private_=a.name;this.cbody(a.body);
out("break;");this.exitScope();b=this._gr("built","Sk.misceval.buildClass($gbl,",c,",",a.name.$r().v,",[",b,"])");this.nameop(a.name,Store,b)};Compiler.prototype.ccontinue=function(a){if(0===this.u.continueBlocks.length)throw new SyntaxError("'continue' outside loop");this._jump(this.u.continueBlocks[this.u.continueBlocks.length-1])};
Compiler.prototype.vstmt=function(a){this.u.lineno=a.lineno;this.u.linenoSet=!1;this.annotateSource(a);switch(a.constructor){case FunctionDef:this.cfunction(a);break;case ClassDef:this.cclass(a);break;case Return_:if(this.u.ste.blockType!==FunctionBlock)throw new SyntaxError("'return' outside function");a.value?out("return ",this.vexpr(a.value),";"):out("return Sk.builtin.none.none$;");break;case Delete_:this.vseqexpr(a.targets);break;case Assign:for(var b=a.targets.length,c=this.vexpr(a.value),d=
0;d<b;++d)this.vexpr(a.targets[d],c);break;case AugAssign:return this.caugassign(a);case Print:this.cprint(a);break;case For_:return this.cfor(a);case While_:return this.cwhile(a);case If_:return this.cif(a);case Raise:return this.craise(a);case TryExcept:return this.ctryexcept(a);case TryFinally:return this.ctryfinally(a);case Assert:return this.cassert(a);case Import_:return this.cimport(a);case ImportFrom:return this.cfromimport(a);case Global:break;case Expr:this.vexpr(a.value);break;case Pass:break;
case Break_:if(0===this.u.breakBlocks.length)throw new SyntaxError("'break' outside loop");this._jump(this.u.breakBlocks[this.u.breakBlocks.length-1]);break;case Continue_:this.ccontinue(a);break;default:goog.asserts.fail("unhandled case in vstmt")}};Compiler.prototype.vseqstmt=function(a){for(var b=0;b<a.length;++b)this.vstmt(a[b])};var OP_FAST=0,OP_GLOBAL=1,OP_DEREF=2,OP_NAME=3,D_NAMES=0,D_FREEVARS=1,D_CELLVARS=2;
Compiler.prototype.isCell=function(a){a=mangleName(this.u.private_,a).v;return this.u.ste.getScope(a)===CELL?!0:!1};
Compiler.prototype.nameop=function(a,b,c){if((b===Store||b===AugStore||b===Del)&&"__debug__"===a.v)throw new Sk.builtin.SyntaxError("can not assign to __debug__");if((b===Store||b===AugStore||b===Del)&&"None"===a.v)throw new Sk.builtin.SyntaxError("can not assign to None");if("None"===a.v)return"Sk.builtin.none.none$";if("True"===a.v)return"Sk.builtin.bool.true$";if("False"===a.v)return"Sk.builtin.bool.false$";var d=mangleName(this.u.private_,a).v,d=fixReservedNames(d),e=OP_NAME,f=this.u.ste.getScope(d),
g=null;switch(f){case FREE:g="$free";e=OP_DEREF;break;case CELL:g="$cell";e=OP_DEREF;break;case LOCAL:this.u.ste.blockType!==FunctionBlock||this.u.ste.generator||(e=OP_FAST);break;case GLOBAL_IMPLICIT:this.u.ste.blockType===FunctionBlock&&(e=OP_GLOBAL);break;case GLOBAL_EXPLICIT:e=OP_GLOBAL}d=fixReservedWords(d);goog.asserts.assert(f||"_"===a.v.charAt(1));a=d;this.u.ste.generator||this.u.ste.blockType!==FunctionBlock?d="$loc."+d:e!==OP_FAST&&e!==OP_NAME||this.u.localnames.push(d);switch(e){case OP_FAST:switch(b){case Load:case Param:return out("if (",
d," === undefined) { throw new Error('local variable \\'",d,"\\' referenced before assignment'); }\n"),d;case Store:out(d,"=",c,";");break;case Del:out("delete ",d,";");break;default:goog.asserts.fail("unhandled")}break;case OP_NAME:switch(b){case Load:return b=this.gensym("loadname"),out("var ",b,"=",d,"!==undefined?",d,":Sk.misceval.loadname('",a,"',$gbl);"),b;case Store:out(d,"=",c,";");break;case Del:out("delete ",d,";");break;case Param:return d;default:goog.asserts.fail("unhandled")}break;case OP_GLOBAL:switch(b){case Load:return this._gr("loadgbl",
"Sk.misceval.loadname('",a,"',$gbl)");case Store:out("$gbl.",a,"=",c,";");break;case Del:out("delete $gbl.",a);break;default:goog.asserts.fail("unhandled case in name op_global")}break;case OP_DEREF:switch(b){case Load:return g+"."+a;case Store:out(g,".",a,"=",c,";");break;case Param:return a;default:goog.asserts.fail("unhandled case in name op_deref")}break;default:goog.asserts.fail("unhandled case")}};
Compiler.prototype.enterScope=function(a,b,c){var d=new CompilerUnit;d.ste=this.st.getStsForAst(b);d.name=a;d.firstlineno=c;this.u&&this.u.private_&&(d.private_=this.u.private_);this.stack.push(this.u);this.allUnits.push(d);a=this.gensym("scope");d.scopename=a;this.u=d;this.u.activateScope();this.nestlevel++;return a};
Compiler.prototype.exitScope=function(){var a=this.u;this.nestlevel--;(this.u=0<=this.stack.length-1?this.stack.pop():null)&&this.u.activateScope();if("<module>"!==a.name.v){var b=a.name.$r().v,b=b.substring(1,b.length-1),b=fixReservedWords(b),b=fixReservedNames(b);out(a.scopename,".co_name=new Sk.builtins['str']('",b,"');")}};Compiler.prototype.cbody=function(a){for(var b=0;b<a.length;++b)this.vstmt(a[b])};
Compiler.prototype.cprint=function(a){goog.asserts.assert(a instanceof Print);a.dest&&this.vexpr(a.dest);for(var b=a.values.length,c=0;c<b;++c)out("Sk.misceval.print_(","new Sk.builtins['str'](",this.vexpr(a.values[c]),").v);");a.nl&&out("Sk.misceval.print_(",'"\\n");')};
Compiler.prototype.cmod=function(a){var b=this.enterScope(new Sk.builtin.str("<module>"),a,0),c=this.newBlock("module entry");this.u.prefixCode="var "+b+"=(function($modname){";this.u.varDeclsCode="var $gbl = {};if (Sk.retainGlobals) { if (Sk.globals) { $gbl = Sk.globals; Sk.globals = $gbl } else { Sk.globals = $gbl; }} else { Sk.globals = $gbl; }var $blk="+c+",$exc=[],$loc=$gbl,$err=undefined;$gbl.__name__=$modname;";this.u.switchCode="try { while(true){try{ switch($blk){";this.u.suffixCode=
"} }catch(err){if ($exc.length>0) { $err = err; $blk=$exc.pop(); continue; } else { throw err; }} } }catch(err){ if (err instanceof Sk.builtin.SystemExit && !Sk.throwSystemExit) { Sk.misceval.print_(err.toString() + '\\n'); return $loc; } else { throw err; } } });";switch(a.constructor){case Module:this.cbody(a.body);out("return $loc;");break;default:goog.asserts.fail("todo; unhandled case in compilerMod")}this.exitScope();this.result.push(this.outputAllUnits());return b};
Sk.compile=function(a,b,c){c=Sk.parse(b,a);c=Sk.astFromParse(c,b);var d=Sk.symboltable(c,b);a=new Compiler(b,d,0,a);b=a.cmod(c);a=a.result.join("");return{funcname:b,code:a}};goog.exportSymbol("Sk.compile",Sk.compile);Sk.resetCompiler=function(){Sk.gensymcount=0};goog.exportSymbol("Sk.resetCompiler",Sk.resetCompiler);Sk.sysmodules=new Sk.builtin.dict([]);Sk.realsyspath=void 0;Sk.externalLibraryCache={};Sk.loadExternalLibraryInternal_=function(a,b){var c;if(null!=a){if(Sk.externalLibraryCache[a])return Sk.externalLibraryCache[a];c=new XMLHttpRequest;c.open("GET",a,!1);c.send();if(200===c.status){c=c.responseText;if(b){var d=document.createElement("script");d.type="text/javascript";d.text=c;document.getElementsByTagName("head")[0].appendChild(d)}return c}}};
Sk.loadExternalLibrary=function(a){var b,c,d,e,f;if(Sk.externalLibraryCache[a])return Sk.externalLibraryCache[a];if(b=Sk.externalLibraries&&Sk.externalLibraries[a]){c="string"===typeof b?b:b.path;if("string"!==typeof c)throw new Sk.builtin.ImportError("Invalid path specified for "+a);f=b.type;f||(f=(d=c.match(/\.(js|py)$/))&&d[1]);if(!f)throw new Sk.builtin.ImportError("Invalid file extension specified for "+a);d=Sk.loadExternalLibraryInternal_(c,!1);if(!d)throw new Sk.builtin.ImportError("Failed to load remote module '"+
a+"'");if((b=b.dependencies)&&b.length)for(var g=0;g<b.length;g++)if(e=Sk.loadExternalLibraryInternal_(b[g],!0),!e)throw new Sk.builtin.ImportError("Failed to load dependencies required for "+a);c="js"===f?{funcname:"$builtinmodule",code:d}:Sk.compile(d,c,"exec");return Sk.externalLibraryCache[a]=c}};
Sk.importSearchPathForName=function(a,b,c){for(var d=Sk.realsyspath.tp$iter(),e=d.tp$iternext();void 0!==e;e=d.tp$iternext())for(var f=a.replace(/\./g,"/"),e=[e.v+"/"+f+b,e.v+"/"+f+"/__init__"+b],f=0;f<e.length;++f){var g=e[f];try{return Sk.read(g),g}catch(h){}}if(!c)throw new Sk.builtin.ImportError("No module named "+a);};
Sk.doOneTimeInitialization=function(){Sk.builtin.type.basesStr_=new Sk.builtin.str("__bases__");Sk.builtin.type.mroStr_=new Sk.builtin.str("__mro__");Sk.builtin.object.$d=new Sk.builtin.dict([]);Sk.builtin.object.$d.mp$ass_subscript(Sk.builtin.type.basesStr_,new Sk.builtin.tuple([]));Sk.builtin.object.$d.mp$ass_subscript(Sk.builtin.type.mroStr_,new Sk.builtin.tuple([Sk.builtin.object]))};
Sk.importSetUpPath=function(){if(!Sk.realsyspath){for(var a=[new Sk.builtin.str("src/builtin"),new Sk.builtin.str("src/lib"),new Sk.builtin.str(".")],b=0;b<Sk.syspath.length;++b)a.push(new Sk.builtin.str(Sk.syspath[b]));Sk.realsyspath=new Sk.builtin.list(a);Sk.doOneTimeInitialization()}};if(COMPILED)var js_beautify=function(a){return a};
Sk.importModuleInternal_=function(a,b,c,d){Sk.importSetUpPath();void 0===c&&(c=a);var e=null,f=c.split("."),g;try{var h=Sk.sysmodules.mp$subscript(c);return 1<f.length?Sk.sysmodules.mp$subscript(f[0]):h}catch(k){}1<f.length&&(g=f.slice(0,f.length-1).join("."),e=Sk.importModuleInternal_(g,b));h=new Sk.builtin.module;Sk.sysmodules.mp$ass_subscript(a,h);if(d)a=Sk.compile(d,a+".py","exec");else{if(Sk.onBeforeImport&&"function"===typeof Sk.onBeforeImport){d=Sk.onBeforeImport(a);if(!1===d)throw new Sk.builtin.ImportError("Importing "+
a+" is not allowed");if("string"===typeof d)throw new Sk.builtin.ImportError(d);}(d=Sk.loadExternalLibrary(a))?a=d:(d=Sk.importSearchPathForName(a,".js",!0))?a={funcname:"$builtinmodule",code:Sk.read(d)}:(d=Sk.importSearchPathForName(a,".py"),a=Sk.compile(Sk.read(d),d,"exec"))}d=h.$js=a.code;null!=Sk.dateSet&&Sk.dateSet||(d="Sk.execStart = new Date();\n"+a.code,Sk.dateSet=!0);if(b){b=js_beautify(a.code).split("\n");for(d=1;d<=b.length;++d){for(var l="",m=(""+d).length;5>m;++m)l+=" ";b[d-1]="/* "+
l+d+" */ "+b[d-1]}d=b.join("\n");Sk.debugout(d)}d+="\n"+a.funcname+"("+("new Sk.builtin.str('"+c+"')")+");";b=goog.global.eval(d);b.__name__||(b.__name__=new Sk.builtin.str(c));h.$d=b;return e?(Sk.sysmodules.mp$subscript(g).tp$setattr(f[f.length-1],h),e):h};Sk.importModule=function(a,b){return Sk.importModuleInternal_(a,b)};
Sk.importMain=function(a,b){Sk.dateSet=!1;Sk.filesLoaded=!1;Sk.sysmodules=new Sk.builtin.dict([]);Sk.realsyspath=void 0;Sk.resetCompiler();return Sk.importModuleInternal_(a,b,"__main__")};Sk.importMainWithBody=function(a,b,c){Sk.dateSet=!1;Sk.filesLoaded=!1;Sk.sysmodules=new Sk.builtin.dict([]);Sk.realsyspath=void 0;Sk.resetCompiler();return Sk.importModuleInternal_(a,b,"__main__",c)};
Sk.builtin.__import__=function(a,b,c,d){b=Sk.globals;c=Sk.importModuleInternal_(a);b!==Sk.globals&&(Sk.globals=b);if(!d||0===d.length)return c;c=Sk.sysmodules.mp$subscript(a);goog.asserts.assert(c);return c};Sk.importStar=function(a,b,c){var d=c.__name__,e=Object.getOwnPropertyNames(a.$d),f;for(f in e)b[e[f]]=a.$d[e[f]];c.__name__!==d&&(c.__name__=d)};goog.exportSymbol("Sk.importMain",Sk.importMain);goog.exportSymbol("Sk.importMainWithBody",Sk.importMainWithBody);
goog.exportSymbol("Sk.builtin.__import__",Sk.builtin.__import__);goog.exportSymbol("Sk.importStar",Sk.importStar);Sk.builtin.timSort=function(a,b){this.list=new Sk.builtin.list(a.v);this.MIN_GALLOP=7;this.listlength=b?b:a.sq$length()};Sk.builtin.timSort.prototype.lt=function(a,b){return Sk.misceval.richCompareBool(a,b,"Lt")};Sk.builtin.timSort.prototype.le=function(a,b){return!this.lt(b,a)};Sk.builtin.timSort.prototype.setitem=function(a,b){this.list.v[a]=b};
Sk.builtin.timSort.prototype.binary_sort=function(a,b){for(var c=a.base+b;c<a.base+a.len;c++){for(var d=a.base,e=c,f=a.getitem(e);d<e;){var g=d+(e-d>>1);this.lt(f,a.getitem(g))?e=g:d=g+1}goog.asserts.assert(d===e);for(g=c;g>d;g--)a.setitem(g,a.getitem(g-1));a.setitem(d,f)}};
Sk.builtin.timSort.prototype.count_run=function(a){var b;if(1>=a.len){var c=a.len;b=!1}else if(c=2,this.lt(a.getitem(a.base+1),a.getitem(a.base))){b=!0;for(var d=a.base+2;d<a.base+a.len;d++)if(this.lt(a.getitem(d),a.getitem(d-1)))c++;else break}else for(b=!1,d=a.base+2;d<a.base+a.len&&!this.lt(a.getitem(d),a.getitem(d-1));d++)c++;return{run:new Sk.builtin.listSlice(a.list,a.base,c),descending:b}};
Sk.builtin.timSort.prototype.sort=function(){var a=new Sk.builtin.listSlice(this.list,0,this.listlength);if(!(2>a.len)){this.merge_init();for(var b=this.merge_compute_minrun(a.len);0<a.len;){var c=this.count_run(a);c.descending&&c.run.reverse();if(c.run.len<b){var d=c.run.len;c.run.len=b<a.len?b:a.len;this.binary_sort(c.run,d)}a.advance(c.run.len);this.pending.push(c.run);this.merge_collapse()}goog.asserts.assert(a.base==this.listlength);this.merge_force_collapse();goog.asserts.assert(1==this.pending.length);
goog.asserts.assert(0==this.pending[0].base);goog.asserts.assert(this.pending[0].len==this.listlength)}};
Sk.builtin.timSort.prototype.gallop=function(a,b,c,d){goog.asserts.assert(0<=c&&c<b.len);var e=this;d=d?function(a,b){return e.le(a,b)}:function(a,b){return e.lt(a,b)};var f=b.base+c,g=0,h=1,k;if(d(b.getitem(f),a)){for(k=b.len-c;h<k;)if(d(b.getitem(f+h),a)){g=h;try{h=(h<<1)+1}catch(l){h=k}}else break;h>k&&(h=k);g+=c;h+=c}else{for(k=c+1;h<k&&!d(b.getitem(f-h),a);){g=h;try{h=(h<<1)+1}catch(m){h=k}}h>k&&(h=k);f=c-g;g=c-h;h=f}goog.asserts.assert(-1<=g<h<=b.len);for(g+=1;g<h;)c=g+(h-g>>1),d(b.getitem(b.base+
c),a)?g=c+1:h=c;goog.asserts.assert(g==h);return h};Sk.builtin.timSort.prototype.merge_init=function(){this.min_gallop=this.MIN_GALLOP;this.pending=[]};
Sk.builtin.timSort.prototype.merge_lo=function(a,b){goog.asserts.assert(0<a.len&&0<b.len&&a.base+a.len==b.base);var c=this.min_gallop,d=a.base;a=a.copyitems();try{if(this.setitem(d,b.popleft()),d++,1!=a.len&&0!=b.len)for(var e,f;;){for(f=e=0;;)if(this.lt(b.getitem(b.base),a.getitem(a.base))){this.setitem(d,b.popleft());d++;if(0==b.len)return;f++;e=0;if(f>=c)break}else{this.setitem(d,a.popleft());d++;if(1==a.len)return;e++;f=0;if(e>=c)break}for(c+=1;;){this.min_gallop=c-=1<c;e=this.gallop(b.getitem(b.base),
a,0,!0);for(var g=a.base;g<a.base+e;g++)this.setitem(d,a.getitem(g)),d++;a.advance(e);if(1>=a.len)return;this.setitem(d,b.popleft());d++;if(0==b.len)return;f=this.gallop(a.getitem(a.base),b,0,!1);for(g=b.base;g<b.base+f;g++)this.setitem(d,b.getitem(g)),d++;b.advance(f);if(0==b.len)return;this.setitem(d,a.popleft());d++;if(1==a.len)return;if(e<this.MIN_GALLOP&&f<this.MIN_GALLOP)break;c++;this.min_gallop=c}}}finally{goog.asserts.assert(0<=a.len&&0<=b.len);for(g=b.base;g<b.base+b.len;g++)this.setitem(d,
b.getitem(g)),d++;for(g=a.base;g<a.base+a.len;g++)this.setitem(d,a.getitem(g)),d++}};
Sk.builtin.timSort.prototype.merge_hi=function(a,b){goog.asserts.assert(0<a.len&&0<b.len&&a.base+a.len==b.base);var c=this.min_gallop,d=b.base+b.len;b=b.copyitems();try{if(d--,this.setitem(d,a.popright()),0!=a.len&&1!=b.len)for(var e,f,g,h;;){for(f=e=0;;)if(g=a.getitem(a.base+a.len-1),h=b.getitem(b.base+b.len-1),this.lt(h,g)){d--;this.setitem(d,g);a.len--;if(0==a.len)return;e++;f=0;if(e>=c)break}else{d--;this.setitem(d,h);b.len--;if(1==b.len)return;f++;e=0;if(f>=c)break}for(c+=1;;){this.min_gallop=
c-=1<c;h=b.getitem(b.base+b.len-1);var k=this.gallop(h,a,a.len-1,!0);e=a.len-k;for(var l=a.base+a.len-1;l>a.base+k-1;l--)d--,this.setitem(d,a.getitem(l));a.len-=e;if(0==a.len)return;d--;this.setitem(d,b.popright());if(1==b.len)return;g=a.getitem(a.base+a.len-1);k=this.gallop(g,b,b.len-1,!1);f=b.len-k;for(l=b.base+b.len-1;l>b.base+k-1;l--)d--,this.setitem(d,b.getitem(l));b.len-=f;if(1>=b.len)return;d--;this.setitem(d,a.popright());if(0==a.len)return;if(e<this.MIN_GALLOP&&f<this.MIN_GALLOP)break;c++;
this.min_gallop=c}}}finally{goog.asserts.assert(0<=a.len&&0<=b.len);for(l=a.base+a.len-1;l>a.base-1;l--)d--,this.setitem(d,a.getitem(l));for(l=b.base+b.len-1;l>b.base-1;l--)d--,this.setitem(d,b.getitem(l))}};
Sk.builtin.timSort.prototype.merge_at=function(a){0>a&&(a=this.pending.length+a);var b=this.pending[a],c=this.pending[a+1];goog.asserts.assert(0<b.len&&0<c.len);goog.asserts.assert(b.base+b.len==c.base);this.pending[a]=new Sk.builtin.listSlice(this.list,b.base,b.len+c.len);this.pending.splice(a+1,1);a=this.gallop(c.getitem(c.base),b,0,!0);b.advance(a);0!=b.len&&(c.len=this.gallop(b.getitem(b.base+b.len-1),c,c.len-1,!1),0!=c.len&&(b.len<=c.len?this.merge_lo(b,c):this.merge_hi(b,c)))};
Sk.builtin.timSort.prototype.merge_collapse=function(){for(var a=this.pending;1<a.length;)if(3<=a.length&&a[a.length-3].len<=a[a.length-2].len+a[a.length-1].len)a[a.length-3].len<a[a.length-1].len?this.merge_at(-3):this.merge_at(-2);else if(a[a.length-2].len<=a[a.length-1].len)this.merge_at(-2);else break};Sk.builtin.timSort.prototype.merge_force_collapse=function(){for(var a=this.pending;1<a.length;)3<=a.length&&a[a.length-3].len<a[a.length-1].len?this.merge_at(-3):this.merge_at(-2)};
Sk.builtin.timSort.prototype.merge_compute_minrun=function(a){for(var b=0;64<=a;)b|=a&1,a>>=1;return a+b};Sk.builtin.listSlice=function(a,b,c){this.list=a;this.base=b;this.len=c};Sk.builtin.listSlice.prototype.copyitems=function(){var a=this.base,b=this.base+this.len;goog.asserts.assert(0<=a<=b);return new Sk.builtin.listSlice(new Sk.builtin.list(this.list.v.slice(a,b)),0,this.len)};Sk.builtin.listSlice.prototype.advance=function(a){this.base+=a;this.len-=a;goog.asserts.assert(this.base<=this.list.sq$length())};
Sk.builtin.listSlice.prototype.getitem=function(a){return this.list.v[a]};Sk.builtin.listSlice.prototype.setitem=function(a,b){this.list.v[a]=b};Sk.builtin.listSlice.prototype.popleft=function(){var a=this.list.v[this.base];this.base++;this.len--;return a};Sk.builtin.listSlice.prototype.popright=function(){this.len--;return this.list.v[this.base+this.len]};
Sk.builtin.listSlice.prototype.reverse=function(){for(var a=this.list,b=this.base,c=b+this.len-1;b<c;){var d=a.v[b];a.v[b]=a.v[c];a.v[c]=d;b++;c--}};goog.exportSymbol("Sk.builtin.listSlice",Sk.builtin.listSlice);goog.exportSymbol("Sk.builtin.timSort",Sk.builtin.timSort);Sk.builtins={range:Sk.builtin.range,round:Sk.builtin.round,len:Sk.builtin.len,min:Sk.builtin.min,max:Sk.builtin.max,sum:Sk.builtin.sum,zip:Sk.builtin.zip,abs:Sk.builtin.abs,fabs:Sk.builtin.abs,ord:Sk.builtin.ord,chr:Sk.builtin.chr,hex:Sk.builtin.hex,oct:Sk.builtin.oct,bin:Sk.builtin.bin,dir:Sk.builtin.dir,repr:Sk.builtin.repr,open:Sk.builtin.open,isinstance:Sk.builtin.isinstance,hash:Sk.builtin.hash,getattr:Sk.builtin.getattr,float_$rw$:Sk.builtin.float_,int_$rw$:Sk.builtin.int_,hasattr:Sk.builtin.hasattr,
map:Sk.builtin.map,filter:Sk.builtin.filter,reduce:Sk.builtin.reduce,sorted:Sk.builtin.sorted,bool:Sk.builtin.bool,any:Sk.builtin.any,all:Sk.builtin.all,enumerate:Sk.builtin.enumerate,AttributeError:Sk.builtin.AttributeError,ValueError:Sk.builtin.ValueError,Exception:Sk.builtin.Exception,ZeroDivisionError:Sk.builtin.ZeroDivisionError,AssertionError:Sk.builtin.AssertionError,ImportError:Sk.builtin.ImportError,IndentationError:Sk.builtin.IndentationError,IndexError:Sk.builtin.IndexError,KeyError:Sk.builtin.KeyError,
TypeError:Sk.builtin.TypeError,NameError:Sk.builtin.NameError,IOError:Sk.builtin.IOError,NotImplementedError:Sk.builtin.NotImplementedError,SystemExit:Sk.builtin.SystemExit,OverflowError:Sk.builtin.OverflowError,OperationError:Sk.builtin.OperationError,dict:Sk.builtin.dict,file:Sk.builtin.file,"function":Sk.builtin.func,generator:Sk.builtin.generator,list:Sk.builtin.list,long_$rw$:Sk.builtin.lng,method:Sk.builtin.method,object:Sk.builtin.object,slice:Sk.builtin.slice,str:Sk.builtin.str,set:Sk.builtin.set,
tuple:Sk.builtin.tuple,type:Sk.builtin.type,input:Sk.builtin.input,raw_input:Sk.builtin.raw_input,jseval:Sk.builtin.jseval,jsmillis:Sk.builtin.jsmillis,quit:Sk.builtin.quit,exit:Sk.builtin.quit,bytearray:Sk.builtin.bytearray,callable:Sk.builtin.callable,complex:Sk.builtin.complex,delattr:Sk.builtin.delattr,divmod:Sk.builtin.divmod,eval_$rn$:Sk.builtin.eval_,execfile:Sk.builtin.execfile,format:Sk.builtin.format,frozenset:Sk.builtin.frozenset,globals:Sk.builtin.globals,help:Sk.builtin.help,issubclass:Sk.builtin.issubclass,
iter:Sk.builtin.iter,locals:Sk.builtin.locals,memoryview:Sk.builtin.memoryview,next:Sk.builtin.next_,pow:Sk.builtin.pow,property:Sk.builtin.property,reload:Sk.builtin.reload,reversed:Sk.builtin.reversed,"super":Sk.builtin.superbi,unichr:Sk.builtin.unichr,vars:Sk.builtin.vars,xrange:Sk.builtin.xrange,apply_$rn$:Sk.builtin.apply_,buffer:Sk.builtin.buffer,coerce:Sk.builtin.coerce,intern:Sk.builtin.intern};goog.exportSymbol("Sk.builtins",Sk.builtins);}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment