diff --git a/harkka3/samson/assets/tilemaps/beach-grass-tile.png b/harkka3/samson/assets/tilemaps/beach-grass-tile.png new file mode 100644 index 0000000000000000000000000000000000000000..e1be081f7cee5a00dbc5d4403a4e176a193e1e87 Binary files /dev/null and b/harkka3/samson/assets/tilemaps/beach-grass-tile.png differ diff --git a/harkka3/samson/assets/tilemaps/beach.json b/harkka3/samson/assets/tilemaps/beach.json new file mode 100644 index 0000000000000000000000000000000000000000..5fcc081800c5f50c7975c8941d15d5bb6f2eb503 --- /dev/null +++ b/harkka3/samson/assets/tilemaps/beach.json @@ -0,0 +1,74 @@ +{ "compressionlevel":-1, + "editorsettings": + { + "export": + { + "format":"json", + "target":"beach.json" + } + }, + "height":31, + "infinite":false, + "layers":[ + { + "data":[10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 10, 10, 10, 11, 11, 10, 10, 11, 10, 10, 10, 11, 10, 10, 10, 10, 10, 10, 10, 10, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 10, 11, 11, 10, 10, 10, 11, 11, 10, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 10, 10, 11, 10, 10, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 10, 11, 10, 10, 11, 10, 10, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 10, 10, 11, 10, 10, 11, 10, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 10, 11, 11, 10, 11, 10, 10, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 10, 10, 10, 10, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 10, 11, 11, 10, 10, 11, 11, 10, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 10, 10, 10, 11, 10, 11, 11, 10, 10, 10, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 10, 10, 10, 10, 10, 10, 10, 11, 10, 10, 10, 10, 10, 10, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 10, 10, 10, 10, 10, 10, 10, 10, 11, 10, 10, 10, 10, 10, 10, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 10, 10, 10, 10, 10, 10, 10, 11, 10, 10, 10, 11, 10, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 10, 10, 11, 10, 10, 10, 11, 11, 11, 10, 10, 10, 10, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 10, 10, 11, 11, 11, 10, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10], + "height":31, + "id":1, + "name":"beach", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":42, + "x":0, + "y":0 + }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 8, 8, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 9, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":31, + "id":2, + "name":"rocks", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":42, + "x":0, + "y":0 + }], + "nextlayerid":3, + "nextobjectid":1, + "orientation":"orthogonal", + "renderorder":"right-down", + "tiledversion":"1.3.2", + "tileheight":32, + "tilesets":[ + { + "columns":3, + "firstgid":1, + "image":"rock-tile.png", + "imageheight":96, + "imagewidth":96, + "margin":0, + "name":"rock-tile", + "spacing":0, + "tilecount":9, + "tileheight":32, + "tilewidth":32 + }, + { + "columns":1, + "firstgid":10, + "image":"beach-grass-tile.png", + "imageheight":64, + "imagewidth":32, + "margin":0, + "name":"beach-grass-tile", + "spacing":0, + "tilecount":2, + "tileheight":32, + "tilewidth":32 + }], + "tilewidth":32, + "type":"map", + "version":1.2, + "width":42 +} \ No newline at end of file diff --git a/harkka3/samson/assets/tilemaps/rock-tile.png b/harkka3/samson/assets/tilemaps/rock-tile.png new file mode 100644 index 0000000000000000000000000000000000000000..f274b91a54931791db3922f40e9e6d4a9d7afe44 Binary files /dev/null and b/harkka3/samson/assets/tilemaps/rock-tile.png differ diff --git a/harkka3/samson/beach-grass-tile.tsx b/harkka3/samson/beach-grass-tile.tsx new file mode 100644 index 0000000000000000000000000000000000000000..57f47b3d2b24bd88186c6dbb9bf0cb0c4b413d57 --- /dev/null +++ b/harkka3/samson/beach-grass-tile.tsx @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<tileset version="1.2" tiledversion="1.3.2" name="beach-grass-tile" tilewidth="32" tileheight="32" tilecount="2" columns="1"> + <image source="assets/tilemaps/beach-grass-tile.png" width="32" height="64"/> +</tileset> diff --git a/harkka3/samson/green-tile.tsx b/harkka3/samson/green-tile.tsx new file mode 100644 index 0000000000000000000000000000000000000000..643c8f29fa62aed2ad75a8dc603d7af37d633fcc --- /dev/null +++ b/harkka3/samson/green-tile.tsx @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<tileset version="1.2" tiledversion="1.3.2" name="green-tile" tilewidth="32" tileheight="32" tilecount="2" columns="1"> + <image source="assets/tilemaps/green-tile.png" width="32" height="64"/> +</tileset> diff --git a/harkka3/samson/phaser/phaser.min.js b/harkka3/samson/phaser/phaser.min.js index 847a62b3b49f94586192d60ff91b0750284910ce..45dba0e97497f884794850cb9ee90d0fada14517 100644 --- a/harkka3/samson/phaser/phaser.min.js +++ b/harkka3/samson/phaser/phaser.min.js @@ -1,4 +1,27 @@ -/* Phaser v2.14.0 - http://phaser.io - @photonstorm - (c) 2016 Photon Storm Ltd. */ +/* Phaser v2.4.4 - http://phaser.io - @photonstorm - (c) 2015 Photon Storm Ltd. */ -!function(t){if("object"==typeof exports)module.exports=t();else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.p2=t()}}(function(){return function t(e,i,s){function n(o,a){if(!i[o]){if(!e[o]){var h="function"==typeof require&&require;if(!a&&h)return h(o,!0);if(r)return r(o,!0);throw new Error("Cannot find module '"+o+"'")}var l=i[o]={exports:{}};e[o][0].call(l.exports,function(t){var i=e[o][1][t];return n(i||t)},l,l.exports,t,e,i,s)}return i[o].exports}for(var r="function"==typeof require&&require,o=0;o<s.length;o++)n(s[o]);return n}({1:[function(t,e,i){function s(){}var n=t("./Scalar");e.exports=s,s.lineInt=function(t,e,i){i=i||0;var s,r,o,a,h,l,c,u=[0,0];return s=t[1][1]-t[0][1],r=t[0][0]-t[1][0],o=s*t[0][0]+r*t[0][1],a=e[1][1]-e[0][1],h=e[0][0]-e[1][0],l=a*e[0][0]+h*e[0][1],c=s*h-a*r,n.eq(c,0,i)||(u[0]=(h*o-r*l)/c,u[1]=(s*l-a*o)/c),u},s.segmentsIntersect=function(t,e,i,s){var n=e[0]-t[0],r=e[1]-t[1],o=s[0]-i[0],a=s[1]-i[1];if(o*r-a*n==0)return!1;var h=(n*(i[1]-t[1])+r*(t[0]-i[0]))/(o*r-a*n),l=(o*(t[1]-i[1])+a*(i[0]-t[0]))/(a*n-o*r);return h>=0&&h<=1&&l>=0&&l<=1}},{"./Scalar":4}],2:[function(t,e,i){function s(){}e.exports=s,s.area=function(t,e,i){return(e[0]-t[0])*(i[1]-t[1])-(i[0]-t[0])*(e[1]-t[1])},s.left=function(t,e,i){return s.area(t,e,i)>0},s.leftOn=function(t,e,i){return s.area(t,e,i)>=0},s.right=function(t,e,i){return s.area(t,e,i)<0},s.rightOn=function(t,e,i){return s.area(t,e,i)<=0};var n=[],r=[];s.collinear=function(t,e,i,o){if(o){var a=n,h=r;a[0]=e[0]-t[0],a[1]=e[1]-t[1],h[0]=i[0]-e[0],h[1]=i[1]-e[1];var l=a[0]*h[0]+a[1]*h[1],c=Math.sqrt(a[0]*a[0]+a[1]*a[1]),u=Math.sqrt(h[0]*h[0]+h[1]*h[1]);return Math.acos(l/(c*u))<o}return 0==s.area(t,e,i)},s.sqdist=function(t,e){var i=e[0]-t[0],s=e[1]-t[1];return i*i+s*s}},{}],3:[function(t,e,i){function s(){this.vertices=[]}function n(t,e,i,s,n){n=n||0;var r=e[1]-t[1],o=t[0]-e[0],h=r*t[0]+o*t[1],l=s[1]-i[1],c=i[0]-s[0],u=l*i[0]+c*i[1],d=r*c-l*o;return a.eq(d,0,n)?[0,0]:[(c*h-o*u)/d,(r*u-l*h)/d]}var r=t("./Line"),o=t("./Point"),a=t("./Scalar");e.exports=s,s.prototype.at=function(t){var e=this.vertices,i=e.length;return e[t<0?t%i+i:t%i]},s.prototype.first=function(){return this.vertices[0]},s.prototype.last=function(){return this.vertices[this.vertices.length-1]},s.prototype.clear=function(){this.vertices.length=0},s.prototype.append=function(t,e,i){if(void 0===e)throw new Error("From is not given!");if(void 0===i)throw new Error("To is not given!");if(i-1<e)throw new Error("lol1");if(i>t.vertices.length)throw new Error("lol2");if(e<0)throw new Error("lol3");for(var s=e;s<i;s++)this.vertices.push(t.vertices[s])},s.prototype.makeCCW=function(){for(var t=0,e=this.vertices,i=1;i<this.vertices.length;++i)(e[i][1]<e[t][1]||e[i][1]==e[t][1]&&e[i][0]>e[t][0])&&(t=i);o.left(this.at(t-1),this.at(t),this.at(t+1))||this.reverse()},s.prototype.reverse=function(){for(var t=[],e=0,i=this.vertices.length;e!==i;e++)t.push(this.vertices.pop());this.vertices=t},s.prototype.isReflex=function(t){return o.right(this.at(t-1),this.at(t),this.at(t+1))};var h=[],l=[];s.prototype.canSee=function(t,e){var i,s,n=h,a=l;if(o.leftOn(this.at(t+1),this.at(t),this.at(e))&&o.rightOn(this.at(t-1),this.at(t),this.at(e)))return!1;s=o.sqdist(this.at(t),this.at(e));for(var c=0;c!==this.vertices.length;++c)if((c+1)%this.vertices.length!==t&&c!==t&&o.leftOn(this.at(t),this.at(e),this.at(c+1))&&o.rightOn(this.at(t),this.at(e),this.at(c))&&(n[0]=this.at(t),n[1]=this.at(e),a[0]=this.at(c),a[1]=this.at(c+1),i=r.lineInt(n,a),o.sqdist(this.at(t),i)<s))return!1;return!0},s.prototype.copy=function(t,e,i){var n=i||new s;if(n.clear(),t<e)for(r=t;r<=e;r++)n.vertices.push(this.vertices[r]);else{for(r=0;r<=e;r++)n.vertices.push(this.vertices[r]);for(var r=t;r<this.vertices.length;r++)n.vertices.push(this.vertices[r])}return n},s.prototype.getCutEdges=function(){for(var t=[],e=[],i=[],n=new s,r=Number.MAX_VALUE,o=0;o<this.vertices.length;++o)if(this.isReflex(o))for(var a=0;a<this.vertices.length;++a)if(this.canSee(o,a)){e=this.copy(o,a,n).getCutEdges(),i=this.copy(a,o,n).getCutEdges();for(var h=0;h<i.length;h++)e.push(i[h]);e.length<r&&(t=e,r=e.length,t.push([this.at(o),this.at(a)]))}return t},s.prototype.decomp=function(){var t=this.getCutEdges();return t.length>0?this.slice(t):[this]},s.prototype.slice=function(t){if(0==t.length)return[this];if(t instanceof Array&&t.length&&t[0]instanceof Array&&2==t[0].length&&t[0][0]instanceof Array){for(var e=[this],i=0;i<t.length;i++)for(var s=t[i],n=0;n<e.length;n++){var r=e[n].slice(s);if(r){e.splice(n,1),e.push(r[0],r[1]);break}}return e}var s=t,i=this.vertices.indexOf(s[0]),n=this.vertices.indexOf(s[1]);return-1!=i&&-1!=n&&[this.copy(i,n),this.copy(n,i)]},s.prototype.isSimple=function(){for(var t=this.vertices,e=0;e<t.length-1;e++)for(var i=0;i<e-1;i++)if(r.segmentsIntersect(t[e],t[e+1],t[i],t[i+1]))return!1;for(e=1;e<t.length-2;e++)if(r.segmentsIntersect(t[0],t[t.length-1],t[e],t[e+1]))return!1;return!0},s.prototype.quickDecomp=function(t,e,i,r,a,h){a=a||100,h=h||0,r=r||25,t=void 0!==t?t:[],e=e||[],i=i||[];var l=[0,0],c=[0,0],u=[0,0],d=0,p=0,f=0,g=0,m=0,y=0,v=0,x=new s,b=new s,_=this,w=this.vertices;if(w.length<3)return t;if(++h>a)return console.warn("quickDecomp: max level ("+a+") reached."),t;for(var T=0;T<this.vertices.length;++T)if(_.isReflex(T)){e.push(_.vertices[T]),d=p=Number.MAX_VALUE;for(P=0;P<this.vertices.length;++P)o.left(_.at(T-1),_.at(T),_.at(P))&&o.rightOn(_.at(T-1),_.at(T),_.at(P-1))&&(u=n(_.at(T-1),_.at(T),_.at(P),_.at(P-1)),o.right(_.at(T+1),_.at(T),u)&&(f=o.sqdist(_.vertices[T],u))<p&&(p=f,c=u,y=P)),o.left(_.at(T+1),_.at(T),_.at(P+1))&&o.rightOn(_.at(T+1),_.at(T),_.at(P))&&(u=n(_.at(T+1),_.at(T),_.at(P),_.at(P+1)),o.left(_.at(T-1),_.at(T),u)&&(f=o.sqdist(_.vertices[T],u))<d&&(d=f,l=u,m=P));if(y==(m+1)%this.vertices.length)u[0]=(c[0]+l[0])/2,u[1]=(c[1]+l[1])/2,i.push(u),T<m?(x.append(_,T,m+1),x.vertices.push(u),b.vertices.push(u),0!=y&&b.append(_,y,_.vertices.length),b.append(_,0,T+1)):(0!=T&&x.append(_,T,_.vertices.length),x.append(_,0,m+1),x.vertices.push(u),b.vertices.push(u),b.append(_,y,T+1));else{if(y>m&&(m+=this.vertices.length),g=Number.MAX_VALUE,m<y)return t;for(var P=y;P<=m;++P)o.leftOn(_.at(T-1),_.at(T),_.at(P))&&o.rightOn(_.at(T+1),_.at(T),_.at(P))&&(f=o.sqdist(_.at(T),_.at(P)))<g&&(g=f,v=P%this.vertices.length);T<v?(x.append(_,T,v+1),0!=v&&b.append(_,v,w.length),b.append(_,0,T+1)):(0!=T&&x.append(_,T,w.length),x.append(_,0,v+1),b.append(_,v,T+1))}return x.vertices.length<b.vertices.length?(x.quickDecomp(t,e,i,r,a,h),b.quickDecomp(t,e,i,r,a,h)):(b.quickDecomp(t,e,i,r,a,h),x.quickDecomp(t,e,i,r,a,h)),t}return t.push(this),t},s.prototype.removeCollinearPoints=function(t){for(var e=0,i=this.vertices.length-1;this.vertices.length>3&&i>=0;--i)o.collinear(this.at(i-1),this.at(i),this.at(i+1),t)&&(this.vertices.splice(i%this.vertices.length,1),i--,e++);return e}},{"./Line":1,"./Point":2,"./Scalar":4}],4:[function(t,e,i){function s(){}e.exports=s,s.eq=function(t,e,i){return i=i||0,Math.abs(t-e)<i}},{}],5:[function(t,e,i){e.exports={Polygon:t("./Polygon"),Point:t("./Point")}},{"./Point":2,"./Polygon":3}],6:[function(t,e,i){e.exports={name:"p2",version:"0.7.1",description:"A JavaScript 2D physics engine.",author:"Stefan Hedman <schteppe@gmail.com> (http://steffe.se)",keywords:["p2.js","p2","physics","engine","2d"],main:"./src/p2.js",engines:{node:"*"},repository:{type:"git",url:"https://github.com/schteppe/p2.js.git"},bugs:{url:"https://github.com/schteppe/p2.js/issues"},licenses:[{type:"MIT"}],devDependencies:{grunt:"^0.4.5","grunt-contrib-jshint":"^0.11.2","grunt-contrib-nodeunit":"^0.4.1","grunt-contrib-uglify":"~0.4.0","grunt-contrib-watch":"~0.5.0","grunt-browserify":"~2.0.1","grunt-contrib-concat":"^0.4.0"},dependencies:{"poly-decomp":"0.1.1"}}},{}],7:[function(t,e,i){function s(t){this.lowerBound=n.create(),t&&t.lowerBound&&n.copy(this.lowerBound,t.lowerBound),this.upperBound=n.create(),t&&t.upperBound&&n.copy(this.upperBound,t.upperBound)}var n=t("../math/vec2");t("../utils/Utils");e.exports=s;var r=n.create();s.prototype.setFromPoints=function(t,e,i,s){var o=this.lowerBound,a=this.upperBound;"number"!=typeof i&&(i=0),0!==i?n.rotate(o,t[0],i):n.copy(o,t[0]),n.copy(a,o);for(var h=Math.cos(i),l=Math.sin(i),c=1;c<t.length;c++){var u=t[c];if(0!==i){var d=u[0],p=u[1];r[0]=h*d-l*p,r[1]=l*d+h*p,u=r}for(var f=0;f<2;f++)u[f]>a[f]&&(a[f]=u[f]),u[f]<o[f]&&(o[f]=u[f])}e&&(n.add(this.lowerBound,this.lowerBound,e),n.add(this.upperBound,this.upperBound,e)),s&&(this.lowerBound[0]-=s,this.lowerBound[1]-=s,this.upperBound[0]+=s,this.upperBound[1]+=s)},s.prototype.copy=function(t){n.copy(this.lowerBound,t.lowerBound),n.copy(this.upperBound,t.upperBound)},s.prototype.extend=function(t){for(var e=2;e--;){var i=t.lowerBound[e];this.lowerBound[e]>i&&(this.lowerBound[e]=i);var s=t.upperBound[e];this.upperBound[e]<s&&(this.upperBound[e]=s)}},s.prototype.overlaps=function(t){var e=this.lowerBound,i=this.upperBound,s=t.lowerBound,n=t.upperBound;return(s[0]<=i[0]&&i[0]<=n[0]||e[0]<=n[0]&&n[0]<=i[0])&&(s[1]<=i[1]&&i[1]<=n[1]||e[1]<=n[1]&&n[1]<=i[1])},s.prototype.containsPoint=function(t){var e=this.lowerBound,i=this.upperBound;return e[0]<=t[0]&&t[0]<=i[0]&&e[1]<=t[1]&&t[1]<=i[1]},s.prototype.overlapsRay=function(t){var e=1/t.direction[0],i=1/t.direction[1],s=(this.lowerBound[0]-t.from[0])*e,n=(this.upperBound[0]-t.from[0])*e,r=(this.lowerBound[1]-t.from[1])*i,o=(this.upperBound[1]-t.from[1])*i,a=Math.max(Math.max(Math.min(s,n),Math.min(r,o))),h=Math.min(Math.min(Math.max(s,n),Math.max(r,o)));return h<0?-1:a>h?-1:a}},{"../math/vec2":30,"../utils/Utils":57}],8:[function(t,e,i){function s(t){this.type=t,this.result=[],this.world=null,this.boundingVolumeType=s.AABB}var n=t("../math/vec2"),r=t("../objects/Body");e.exports=s,s.AABB=1,s.BOUNDING_CIRCLE=2,s.prototype.setWorld=function(t){this.world=t},s.prototype.getCollisionPairs=function(t){};var o=n.create();s.boundingRadiusCheck=function(t,e){n.sub(o,t.position,e.position);var i=n.squaredLength(o),s=t.boundingRadius+e.boundingRadius;return i<=s*s},s.aabbCheck=function(t,e){return t.getAABB().overlaps(e.getAABB())},s.prototype.boundingVolumeCheck=function(t,e){var i;switch(this.boundingVolumeType){case s.BOUNDING_CIRCLE:i=s.boundingRadiusCheck(t,e);break;case s.AABB:i=s.aabbCheck(t,e);break;default:throw new Error("Bounding volume type not recognized: "+this.boundingVolumeType)}return i},s.canCollide=function(t,e){var i=r.KINEMATIC,s=r.STATIC;return(t.type!==s||e.type!==s)&&(!(t.type===i&&e.type===s||t.type===s&&e.type===i)&&((t.type!==i||e.type!==i)&&((t.sleepState!==r.SLEEPING||e.sleepState!==r.SLEEPING)&&!(t.sleepState===r.SLEEPING&&e.type===s||e.sleepState===r.SLEEPING&&t.type===s))))},s.NAIVE=1,s.SAP=2},{"../math/vec2":30,"../objects/Body":31}],9:[function(t,e,i){function s(){n.call(this,n.NAIVE)}t("../shapes/Circle"),t("../shapes/Plane"),t("../shapes/Shape"),t("../shapes/Particle");var n=t("../collision/Broadphase");t("../math/vec2");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.getCollisionPairs=function(t){var e=t.bodies,i=this.result;i.length=0;for(var s=0,r=e.length;s!==r;s++)for(var o=e[s],a=0;a<s;a++){var h=e[a];n.canCollide(o,h)&&this.boundingVolumeCheck(o,h)&&i.push(o,h)}return i},s.prototype.aabbQuery=function(t,e,i){i=i||[];for(var s=t.bodies,n=0;n<s.length;n++){var r=s[n];r.aabbNeedsUpdate&&r.updateAABB(),r.aabb.overlaps(e)&&i.push(r)}return i}},{"../collision/Broadphase":8,"../math/vec2":30,"../shapes/Circle":39,"../shapes/Particle":43,"../shapes/Plane":44,"../shapes/Shape":45}],10:[function(t,e,i){function s(){this.contactEquations=[],this.frictionEquations=[],this.enableFriction=!0,this.enabledEquations=!0,this.slipForce=10,this.frictionCoefficient=.3,this.surfaceVelocity=0,this.contactEquationPool=new c({size:32}),this.frictionEquationPool=new u({size:64}),this.restitution=0,this.stiffness=p.DEFAULT_STIFFNESS,this.relaxation=p.DEFAULT_RELAXATION,this.frictionStiffness=p.DEFAULT_STIFFNESS,this.frictionRelaxation=p.DEFAULT_RELAXATION,this.enableFrictionReduction=!0,this.collidingBodiesLastStep=new d,this.contactSkinSize=.01}function n(t,e){o.set(t.vertices[0],.5*-e.length,-e.radius),o.set(t.vertices[1],.5*e.length,-e.radius),o.set(t.vertices[2],.5*e.length,e.radius),o.set(t.vertices[3],.5*-e.length,e.radius)}function r(t,e,i,s){for(var n=H,r=q,l=Y,c=z,u=t,d=e.vertices,p=null,f=0;f!==d.length+1;f++){var g=d[f%d.length],m=d[(f+1)%d.length];o.rotate(n,g,s),o.rotate(r,m,s),h(n,n,i),h(r,r,i),a(l,n,u),a(c,r,u);var y=o.crossLength(l,c);if(null===p&&(p=y),y*p<=0)return!1;p=y}return!0}var o=t("../math/vec2"),a=o.sub,h=o.add,l=o.dot,c=(t("../utils/Utils"),t("../utils/ContactEquationPool")),u=t("../utils/FrictionEquationPool"),d=t("../utils/TupleDictionary"),p=t("../equations/Equation"),f=(t("../equations/ContactEquation"),t("../equations/FrictionEquation"),t("../shapes/Circle")),g=t("../shapes/Convex"),m=t("../shapes/Shape"),y=(t("../objects/Body"),t("../shapes/Box"));e.exports=s;var v=o.fromValues(0,1),x=o.fromValues(0,0),b=o.fromValues(0,0),_=o.fromValues(0,0),w=o.fromValues(0,0),T=o.fromValues(0,0),P=o.fromValues(0,0),C=o.fromValues(0,0),S=o.fromValues(0,0),A=o.fromValues(0,0),E=o.fromValues(0,0),M=o.fromValues(0,0),R=o.fromValues(0,0),L=o.fromValues(0,0),B=o.fromValues(0,0),I=o.fromValues(0,0),O=o.fromValues(0,0),k=o.fromValues(0,0),F=o.fromValues(0,0),D=[],U=o.create(),G=o.create();s.prototype.bodiesOverlap=function(t,e){for(var i=U,s=G,n=0,r=t.shapes.length;n!==r;n++){var o=t.shapes[n];t.toWorldFrame(i,o.position);for(var a=0,h=e.shapes.length;a!==h;a++){var l=e.shapes[a];if(e.toWorldFrame(s,l.position),this[o.type|l.type](t,o,i,o.angle+t.angle,e,l,s,l.angle+e.angle,!0))return!0}}return!1},s.prototype.collidedLastStep=function(t,e){var i=0|t.id,s=0|e.id;return!!this.collidingBodiesLastStep.get(i,s)},s.prototype.reset=function(){this.collidingBodiesLastStep.reset();for(var t=this.contactEquations,e=t.length;e--;){var i=t[e],s=i.bodyA.id,n=i.bodyB.id;this.collidingBodiesLastStep.set(s,n,!0)}for(var r=this.contactEquations,o=this.frictionEquations,a=0;a<r.length;a++)this.contactEquationPool.release(r[a]);for(a=0;a<o.length;a++)this.frictionEquationPool.release(o[a]);this.contactEquations.length=this.frictionEquations.length=0},s.prototype.createContactEquation=function(t,e,i,s){var n=this.contactEquationPool.get();return n.bodyA=t,n.bodyB=e,n.shapeA=i,n.shapeB=s,n.restitution=this.restitution,n.firstImpact=!this.collidedLastStep(t,e),n.stiffness=this.stiffness,n.relaxation=this.relaxation,n.needsUpdate=!0,n.enabled=this.enabledEquations,n.offset=this.contactSkinSize,n},s.prototype.createFrictionEquation=function(t,e,i,s){var n=this.frictionEquationPool.get();return n.bodyA=t,n.bodyB=e,n.shapeA=i,n.shapeB=s,n.setSlipForce(this.slipForce),n.frictionCoefficient=this.frictionCoefficient,n.relativeVelocity=this.surfaceVelocity,n.enabled=this.enabledEquations,n.needsUpdate=!0,n.stiffness=this.frictionStiffness,n.relaxation=this.frictionRelaxation,n.contactEquations.length=0,n},s.prototype.createFrictionFromContact=function(t){var e=this.createFrictionEquation(t.bodyA,t.bodyB,t.shapeA,t.shapeB);return o.copy(e.contactPointA,t.contactPointA),o.copy(e.contactPointB,t.contactPointB),o.rotate90cw(e.t,t.normalA),e.contactEquations.push(t),e},s.prototype.createFrictionFromAverage=function(t){var e=this.contactEquations[this.contactEquations.length-1],i=this.createFrictionEquation(e.bodyA,e.bodyB,e.shapeA,e.shapeB),s=e.bodyA;e.bodyB;o.set(i.contactPointA,0,0),o.set(i.contactPointB,0,0),o.set(i.t,0,0);for(var n=0;n!==t;n++)(e=this.contactEquations[this.contactEquations.length-1-n]).bodyA===s?(o.add(i.t,i.t,e.normalA),o.add(i.contactPointA,i.contactPointA,e.contactPointA),o.add(i.contactPointB,i.contactPointB,e.contactPointB)):(o.sub(i.t,i.t,e.normalA),o.add(i.contactPointA,i.contactPointA,e.contactPointB),o.add(i.contactPointB,i.contactPointB,e.contactPointA)),i.contactEquations.push(e);var r=1/t;return o.scale(i.contactPointA,i.contactPointA,r),o.scale(i.contactPointB,i.contactPointB,r),o.normalize(i.t,i.t),o.rotate90cw(i.t,i.t),i},s.prototype[m.LINE|m.CONVEX]=s.prototype.convexLine=function(t,e,i,s,n,r,o,a,h){return!h&&0},s.prototype[m.LINE|m.BOX]=s.prototype.lineBox=function(t,e,i,s,n,r,o,a,h){return!h&&0};var N=new y({width:1,height:1}),X=o.create();s.prototype[m.CAPSULE|m.CONVEX]=s.prototype[m.CAPSULE|m.BOX]=s.prototype.convexCapsule=function(t,e,i,s,r,a,h,l,c){var u=X;o.set(u,a.length/2,0),o.rotate(u,u,l),o.add(u,u,h);var d=this.circleConvex(r,a,u,l,t,e,i,s,c,a.radius);o.set(u,-a.length/2,0),o.rotate(u,u,l),o.add(u,u,h);var p=this.circleConvex(r,a,u,l,t,e,i,s,c,a.radius);if(c&&(d||p))return!0;var f=N;return n(f,a),this.convexConvex(t,e,i,s,r,f,h,l,c)+d+p},s.prototype[m.CAPSULE|m.LINE]=s.prototype.lineCapsule=function(t,e,i,s,n,r,o,a,h){return!h&&0};var W=o.create(),j=o.create(),V=new y({width:1,height:1});s.prototype[m.CAPSULE|m.CAPSULE]=s.prototype.capsuleCapsule=function(t,e,i,s,r,a,h,l,c){for(var u=W,d=j,p=0,f=0;f<2;f++){o.set(u,(0===f?-1:1)*e.length/2,0),o.rotate(u,u,s),o.add(u,u,i);for(var g=0;g<2;g++){o.set(d,(0===g?-1:1)*a.length/2,0),o.rotate(d,d,l),o.add(d,d,h),this.enableFrictionReduction&&(x=this.enableFriction,this.enableFriction=!1);var m=this.circleCircle(t,e,u,s,r,a,d,l,c,e.radius,a.radius);if(this.enableFrictionReduction&&(this.enableFriction=x),c&&m)return!0;p+=m}}this.enableFrictionReduction&&(x=this.enableFriction,this.enableFriction=!1);var y=V;n(y,e);var v=this.convexCapsule(t,y,i,s,r,a,h,l,c);if(this.enableFrictionReduction&&(this.enableFriction=x),c&&v)return!0;if(p+=v,this.enableFrictionReduction){var x=this.enableFriction;this.enableFriction=!1}n(y,a);var b=this.convexCapsule(r,y,h,l,t,e,i,s,c);return this.enableFrictionReduction&&(this.enableFriction=x),!(!c||!b)||(p+=b,this.enableFrictionReduction&&p&&this.enableFriction&&this.frictionEquations.push(this.createFrictionFromAverage(p)),p)},s.prototype[m.LINE|m.LINE]=s.prototype.lineLine=function(t,e,i,s,n,r,o,a,h){return!h&&0},s.prototype[m.PLANE|m.LINE]=s.prototype.planeLine=function(t,e,i,s,n,r,c,u,d){var p=x,f=b,g=_,m=w,y=T,E=P,M=C,R=S,L=A,B=D,I=0;o.set(p,-r.length/2,0),o.set(f,r.length/2,0),o.rotate(g,p,u),o.rotate(m,f,u),h(g,g,c),h(m,m,c),o.copy(p,g),o.copy(f,m),a(y,f,p),o.normalize(E,y),o.rotate90cw(L,E),o.rotate(R,v,s),B[0]=p,B[1]=f;for(var O=0;O<B.length;O++){var k=B[O];a(M,k,i);var F=l(M,R);if(F<0){if(d)return!0;var U=this.createContactEquation(t,n,e,r);I++,o.copy(U.normalA,R),o.normalize(U.normalA,U.normalA),o.scale(M,R,F),a(U.contactPointA,k,M),a(U.contactPointA,U.contactPointA,t.position),a(U.contactPointB,k,c),h(U.contactPointB,U.contactPointB,c),a(U.contactPointB,U.contactPointB,n.position),this.contactEquations.push(U),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(U))}}return!d&&(this.enableFrictionReduction||I&&this.enableFriction&&this.frictionEquations.push(this.createFrictionFromAverage(I)),I)},s.prototype[m.PARTICLE|m.CAPSULE]=s.prototype.particleCapsule=function(t,e,i,s,n,r,o,a,h){return this.circleLine(t,e,i,s,n,r,o,a,h,r.radius,0)},s.prototype[m.CIRCLE|m.LINE]=s.prototype.circleLine=function(t,e,i,s,n,r,c,u,d,p,f){var p=p||0,f=void 0!==f?f:e.radius,g=x,m=b,y=_,v=w,I=T,O=P,k=C,F=S,U=A,G=E,N=M,X=R,W=L,j=B,V=D;o.set(F,-r.length/2,0),o.set(U,r.length/2,0),o.rotate(G,F,u),o.rotate(N,U,u),h(G,G,c),h(N,N,c),o.copy(F,G),o.copy(U,N),a(O,U,F),o.normalize(k,O),o.rotate90cw(I,k),a(X,i,F);var H=l(X,I);a(v,F,c),a(W,i,c);var q=f+p;if(Math.abs(H)<q){o.scale(g,I,H),a(y,i,g),o.scale(m,I,l(I,W)),o.normalize(m,m),o.scale(m,m,p),h(y,y,m);var Y=l(k,y),z=l(k,F),K=l(k,U);if(Y>z&&Y<K){if(d)return!0;Z=this.createContactEquation(t,n,e,r);return o.scale(Z.normalA,g,-1),o.normalize(Z.normalA,Z.normalA),o.scale(Z.contactPointA,Z.normalA,f),h(Z.contactPointA,Z.contactPointA,i),a(Z.contactPointA,Z.contactPointA,t.position),a(Z.contactPointB,y,c),h(Z.contactPointB,Z.contactPointB,c),a(Z.contactPointB,Z.contactPointB,n.position),this.contactEquations.push(Z),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(Z)),1}}V[0]=F,V[1]=U;for(var J=0;J<V.length;J++){var Q=V[J];if(a(X,Q,i),o.squaredLength(X)<Math.pow(q,2)){if(d)return!0;var Z=this.createContactEquation(t,n,e,r);return o.copy(Z.normalA,X),o.normalize(Z.normalA,Z.normalA),o.scale(Z.contactPointA,Z.normalA,f),h(Z.contactPointA,Z.contactPointA,i),a(Z.contactPointA,Z.contactPointA,t.position),a(Z.contactPointB,Q,c),o.scale(j,Z.normalA,-p),h(Z.contactPointB,Z.contactPointB,j),h(Z.contactPointB,Z.contactPointB,c),a(Z.contactPointB,Z.contactPointB,n.position),this.contactEquations.push(Z),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(Z)),1}}return 0},s.prototype[m.CIRCLE|m.CAPSULE]=s.prototype.circleCapsule=function(t,e,i,s,n,r,o,a,h){return this.circleLine(t,e,i,s,n,r,o,a,h,r.radius)},s.prototype[m.CIRCLE|m.CONVEX]=s.prototype[m.CIRCLE|m.BOX]=s.prototype.circleConvex=function(t,e,i,s,n,l,c,u,d,p){for(var p="number"==typeof p?p:e.radius,f=x,g=b,m=_,y=w,v=T,P=E,C=M,S=L,A=B,R=I,k=O,F=!1,D=Number.MAX_VALUE,U=l.vertices,G=0;G!==U.length+1;G++){var N=U[G%U.length],X=U[(G+1)%U.length];if(o.rotate(f,N,u),o.rotate(g,X,u),h(f,f,c),h(g,g,c),a(m,g,f),o.normalize(y,m),o.rotate90cw(v,y),o.scale(A,v,-e.radius),h(A,A,i),r(A,l,c,u)){o.sub(R,f,A);var W=Math.abs(o.dot(R,v));W<D&&(o.copy(k,A),D=W,o.scale(S,v,W),o.add(S,S,A),F=!0)}}if(F){if(d)return!0;V=this.createContactEquation(t,n,e,l);return o.sub(V.normalA,k,i),o.normalize(V.normalA,V.normalA),o.scale(V.contactPointA,V.normalA,p),h(V.contactPointA,V.contactPointA,i),a(V.contactPointA,V.contactPointA,t.position),a(V.contactPointB,S,c),h(V.contactPointB,V.contactPointB,c),a(V.contactPointB,V.contactPointB,n.position),this.contactEquations.push(V),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(V)),1}if(p>0)for(G=0;G<U.length;G++){var j=U[G];if(o.rotate(C,j,u),h(C,C,c),a(P,C,i),o.squaredLength(P)<Math.pow(p,2)){if(d)return!0;var V=this.createContactEquation(t,n,e,l);return o.copy(V.normalA,P),o.normalize(V.normalA,V.normalA),o.scale(V.contactPointA,V.normalA,p),h(V.contactPointA,V.contactPointA,i),a(V.contactPointA,V.contactPointA,t.position),a(V.contactPointB,C,c),h(V.contactPointB,V.contactPointB,c),a(V.contactPointB,V.contactPointB,n.position),this.contactEquations.push(V),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(V)),1}}return 0};var H=o.create(),q=o.create(),Y=o.create(),z=o.create();s.prototype[m.PARTICLE|m.CONVEX]=s.prototype[m.PARTICLE|m.BOX]=s.prototype.particleConvex=function(t,e,i,s,n,c,u,d,p){var f=x,g=b,m=_,y=w,v=T,S=P,A=C,M=E,R=L,B=k,I=F,O=Number.MAX_VALUE,D=!1,U=c.vertices;if(!r(i,c,u,d))return 0;if(p)return!0;for(var G=0;G!==U.length+1;G++){var N=U[G%U.length],X=U[(G+1)%U.length];o.rotate(f,N,d),o.rotate(g,X,d),h(f,f,u),h(g,g,u),a(m,g,f),o.normalize(y,m),o.rotate90cw(v,y),a(M,i,f);l(M,v);a(S,f,u),a(A,i,u),o.sub(B,f,i);var W=Math.abs(o.dot(B,v));W<O&&(O=W,o.scale(R,v,W),o.add(R,R,i),o.copy(I,v),D=!0)}if(D){var j=this.createContactEquation(t,n,e,c);return o.scale(j.normalA,I,-1),o.normalize(j.normalA,j.normalA),o.set(j.contactPointA,0,0),h(j.contactPointA,j.contactPointA,i),a(j.contactPointA,j.contactPointA,t.position),a(j.contactPointB,R,u),h(j.contactPointB,j.contactPointB,u),a(j.contactPointB,j.contactPointB,n.position),this.contactEquations.push(j),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(j)),1}return 0},s.prototype[m.CIRCLE]=s.prototype.circleCircle=function(t,e,i,s,n,r,l,c,u,d,p){var f=x,d=d||e.radius,p=p||r.radius;a(f,i,l);var g=d+p;if(o.squaredLength(f)>Math.pow(g,2))return 0;if(u)return!0;var m=this.createContactEquation(t,n,e,r);return a(m.normalA,l,i),o.normalize(m.normalA,m.normalA),o.scale(m.contactPointA,m.normalA,d),o.scale(m.contactPointB,m.normalA,-p),h(m.contactPointA,m.contactPointA,i),a(m.contactPointA,m.contactPointA,t.position),h(m.contactPointB,m.contactPointB,l),a(m.contactPointB,m.contactPointB,n.position),this.contactEquations.push(m),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(m)),1},s.prototype[m.PLANE|m.CONVEX]=s.prototype[m.PLANE|m.BOX]=s.prototype.planeConvex=function(t,e,i,s,n,r,c,u,d){var p=x,f=b,g=_,m=0;o.rotate(f,v,s);for(var y=0;y!==r.vertices.length;y++){var w=r.vertices[y];if(o.rotate(p,w,u),h(p,p,c),a(g,p,i),l(g,f)<=0){if(d)return!0;m++;var T=this.createContactEquation(t,n,e,r);a(g,p,i),o.copy(T.normalA,f);var P=l(g,T.normalA);o.scale(g,T.normalA,P),a(T.contactPointB,p,n.position),a(T.contactPointA,p,g),a(T.contactPointA,T.contactPointA,t.position),this.contactEquations.push(T),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(T))}}return this.enableFrictionReduction&&this.enableFriction&&m&&this.frictionEquations.push(this.createFrictionFromAverage(m)),m},s.prototype[m.PARTICLE|m.PLANE]=s.prototype.particlePlane=function(t,e,i,s,n,r,h,c,u){var d=x,p=b;c=c||0,a(d,i,h),o.rotate(p,v,c);var f=l(d,p);if(f>0)return 0;if(u)return!0;var g=this.createContactEquation(n,t,r,e);return o.copy(g.normalA,p),o.scale(d,g.normalA,f),a(g.contactPointA,i,d),a(g.contactPointA,g.contactPointA,n.position),a(g.contactPointB,i,t.position),this.contactEquations.push(g),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(g)),1},s.prototype[m.CIRCLE|m.PARTICLE]=s.prototype.circleParticle=function(t,e,i,s,n,r,l,c,u){var d=x;if(a(d,l,i),o.squaredLength(d)>Math.pow(e.radius,2))return 0;if(u)return!0;var p=this.createContactEquation(t,n,e,r);return o.copy(p.normalA,d),o.normalize(p.normalA,p.normalA),o.scale(p.contactPointA,p.normalA,e.radius),h(p.contactPointA,p.contactPointA,i),a(p.contactPointA,p.contactPointA,t.position),a(p.contactPointB,l,n.position),this.contactEquations.push(p),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(p)),1};var K=new f({radius:1}),J=o.create(),Q=o.create();o.create();s.prototype[m.PLANE|m.CAPSULE]=s.prototype.planeCapsule=function(t,e,i,s,n,r,a,l,c){var u=J,d=Q,p=K;o.set(u,-r.length/2,0),o.rotate(u,u,l),h(u,u,a),o.set(d,r.length/2,0),o.rotate(d,d,l),h(d,d,a),p.radius=r.radius;var f;this.enableFrictionReduction&&(f=this.enableFriction,this.enableFriction=!1);var g=this.circlePlane(n,p,u,0,t,e,i,s,c),m=this.circlePlane(n,p,d,0,t,e,i,s,c);if(this.enableFrictionReduction&&(this.enableFriction=f),c)return g||m;var y=g+m;return this.enableFrictionReduction&&y&&this.frictionEquations.push(this.createFrictionFromAverage(y)),y},s.prototype[m.CIRCLE|m.PLANE]=s.prototype.circlePlane=function(t,e,i,s,n,r,c,u,d){var p=t,f=e,g=i,m=n,y=c,w=u;w=w||0;var T=x,P=b,C=_;a(T,g,y),o.rotate(P,v,w);var S=l(P,T);if(S>f.radius)return 0;if(d)return!0;var A=this.createContactEquation(m,p,r,e);return o.copy(A.normalA,P),o.scale(A.contactPointB,A.normalA,-f.radius),h(A.contactPointB,A.contactPointB,g),a(A.contactPointB,A.contactPointB,p.position),o.scale(C,A.normalA,S),a(A.contactPointA,T,C),h(A.contactPointA,A.contactPointA,y),a(A.contactPointA,A.contactPointA,m.position),this.contactEquations.push(A),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(A)),1},s.prototype[m.CONVEX]=s.prototype[m.CONVEX|m.BOX]=s.prototype[m.BOX]=s.prototype.convexConvex=function(t,e,i,n,r,c,u,d,p,f){var g=x,m=b,y=_,v=w,P=T,E=C,M=S,R=A,L=0,f="number"==typeof f?f:0;if(!s.findSeparatingAxis(e,i,n,c,u,d,g))return 0;a(M,u,i),l(g,M)>0&&o.scale(g,g,-1);var B=s.getClosestEdge(e,n,g,!0),I=s.getClosestEdge(c,d,g);if(-1===B||-1===I)return 0;for(var O=0;O<2;O++){var k=B,F=I,D=e,U=c,G=i,N=u,X=n,W=d,j=t,V=r;if(0===O){var H;H=k,k=F,F=H,H=D,D=U,U=H,H=G,G=N,N=H,H=X,X=W,W=H,H=j,j=V,V=H}for(var q=F;q<F+2;q++){var Y=U.vertices[(q+U.vertices.length)%U.vertices.length];o.rotate(m,Y,W),h(m,m,N);for(var z=0,K=k-1;K<k+2;K++){var J=D.vertices[(K+D.vertices.length)%D.vertices.length],Q=D.vertices[(K+1+D.vertices.length)%D.vertices.length];o.rotate(y,J,X),o.rotate(v,Q,X),h(y,y,G),h(v,v,G),a(P,v,y),o.rotate90cw(R,P),o.normalize(R,R),a(M,m,y);$=l(R,M);(K===k&&$<=f||K!==k&&$<=0)&&z++}if(z>=3){if(p)return!0;var Z=this.createContactEquation(j,V,D,U);L++;var J=D.vertices[k%D.vertices.length],Q=D.vertices[(k+1)%D.vertices.length];o.rotate(y,J,X),o.rotate(v,Q,X),h(y,y,G),h(v,v,G),a(P,v,y),o.rotate90cw(Z.normalA,P),o.normalize(Z.normalA,Z.normalA),a(M,m,y);var $=l(Z.normalA,M);o.scale(E,Z.normalA,$),a(Z.contactPointA,m,G),a(Z.contactPointA,Z.contactPointA,E),h(Z.contactPointA,Z.contactPointA,G),a(Z.contactPointA,Z.contactPointA,j.position),a(Z.contactPointB,m,N),h(Z.contactPointB,Z.contactPointB,N),a(Z.contactPointB,Z.contactPointB,V.position),this.contactEquations.push(Z),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(Z))}}}return this.enableFrictionReduction&&this.enableFriction&&L&&this.frictionEquations.push(this.createFrictionFromAverage(L)),L};var Z=o.fromValues(0,0);s.projectConvexOntoAxis=function(t,e,i,s,n){var r,a,h=null,c=null,u=Z;o.rotate(u,s,-i);for(var d=0;d<t.vertices.length;d++)r=t.vertices[d],a=l(r,u),(null===h||a>h)&&(h=a),(null===c||a<c)&&(c=a);if(c>h){var p=c;c=h,h=p}var f=l(e,s);o.set(n,c+f,h+f)};var $=o.fromValues(0,0),tt=o.fromValues(0,0),et=o.fromValues(0,0),it=o.fromValues(0,0),st=o.fromValues(0,0),nt=o.fromValues(0,0);s.findSeparatingAxis=function(t,e,i,n,r,h,l){var c=null,u=!1,d=!1,p=$,f=tt,g=et,m=it,v=st,x=nt;if(t instanceof y&&n instanceof y)for(P=0;2!==P;P++){var b=t,_=i;1===P&&(b=n,_=h);for(C=0;2!==C;C++){0===C?o.set(m,0,1):1===C&&o.set(m,1,0),0!==_&&o.rotate(m,m,_),s.projectConvexOntoAxis(t,e,i,m,v),s.projectConvexOntoAxis(n,r,h,m,x);var w=v,T=x;v[0]>x[0]&&(T=v,w=x,!0),u=(S=T[0]-w[1])<=0,(null===c||S>c)&&(o.copy(l,m),c=S,d=u)}}else for(var P=0;2!==P;P++){var b=t,_=i;1===P&&(b=n,_=h);for(var C=0;C!==b.vertices.length;C++){o.rotate(f,b.vertices[C],_),o.rotate(g,b.vertices[(C+1)%b.vertices.length],_),a(p,g,f),o.rotate90cw(m,p),o.normalize(m,m),s.projectConvexOntoAxis(t,e,i,m,v),s.projectConvexOntoAxis(n,r,h,m,x);var w=v,T=x;v[0]>x[0]&&(T=v,w=x,!0);var S=T[0]-w[1];u=S<=0,(null===c||S>c)&&(o.copy(l,m),c=S,d=u)}}return d};var rt=o.fromValues(0,0),ot=o.fromValues(0,0),at=o.fromValues(0,0);s.getClosestEdge=function(t,e,i,s){var n=rt,r=ot,h=at;o.rotate(n,i,-e),s&&o.scale(n,n,-1);for(var c=-1,u=t.vertices.length,d=-1,p=0;p!==u;p++){a(r,t.vertices[(p+1)%u],t.vertices[p%u]),o.rotate90cw(h,r),o.normalize(h,h);var f=l(h,n);(-1===c||f>d)&&(c=p%u,d=f)}return c};var ht=o.create(),lt=o.create(),ct=o.create(),ut=o.create(),dt=o.create(),pt=o.create(),ft=o.create();s.prototype[m.CIRCLE|m.HEIGHTFIELD]=s.prototype.circleHeightfield=function(t,e,i,s,n,r,l,c,u,d){var p=r.heights,d=d||e.radius,f=r.elementWidth,g=lt,m=ht,y=dt,v=ft,x=pt,b=ct,_=ut,w=Math.floor((i[0]-d-l[0])/f),T=Math.ceil((i[0]+d-l[0])/f);w<0&&(w=0),T>=p.length&&(T=p.length-1);for(var P=p[w],C=p[T],S=w;S<T;S++)p[S]<C&&(C=p[S]),p[S]>P&&(P=p[S]);if(i[1]-d>P)return!u&&0;for(var A=!1,S=w;S<T;S++){o.set(b,S*f,p[S]),o.set(_,(S+1)*f,p[S+1]),o.add(b,b,l),o.add(_,_,l),o.sub(x,_,b),o.rotate(x,x,Math.PI/2),o.normalize(x,x),o.scale(m,x,-d),o.add(m,m,i),o.sub(g,m,b);var E=o.dot(g,x);if(m[0]>=b[0]&&m[0]<_[0]&&E<=0){if(u)return!0;A=!0,o.scale(g,x,-E),o.add(y,m,g),o.copy(v,x);M=this.createContactEquation(n,t,r,e);o.copy(M.normalA,v),o.scale(M.contactPointB,M.normalA,-d),h(M.contactPointB,M.contactPointB,i),a(M.contactPointB,M.contactPointB,t.position),o.copy(M.contactPointA,y),o.sub(M.contactPointA,M.contactPointA,n.position),this.contactEquations.push(M),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(M))}}if(A=!1,d>0)for(S=w;S<=T;S++)if(o.set(b,S*f,p[S]),o.add(b,b,l),o.sub(g,i,b),o.squaredLength(g)<Math.pow(d,2)){if(u)return!0;A=!0;var M=this.createContactEquation(n,t,r,e);o.copy(M.normalA,g),o.normalize(M.normalA,M.normalA),o.scale(M.contactPointB,M.normalA,-d),h(M.contactPointB,M.contactPointB,i),a(M.contactPointB,M.contactPointB,t.position),a(M.contactPointA,b,l),h(M.contactPointA,M.contactPointA,l),a(M.contactPointA,M.contactPointA,n.position),this.contactEquations.push(M),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(M))}return A?1:0};var gt=o.create(),mt=o.create(),yt=o.create(),vt=new g({vertices:[o.create(),o.create(),o.create(),o.create()]});s.prototype[m.BOX|m.HEIGHTFIELD]=s.prototype[m.CONVEX|m.HEIGHTFIELD]=s.prototype.convexHeightfield=function(t,e,i,s,n,r,a,h,l){var c=r.heights,u=r.elementWidth,d=gt,p=mt,f=yt,g=vt,m=Math.floor((t.aabb.lowerBound[0]-a[0])/u),y=Math.ceil((t.aabb.upperBound[0]-a[0])/u);m<0&&(m=0),y>=c.length&&(y=c.length-1);for(var v=c[m],x=c[y],b=m;b<y;b++)c[b]<x&&(x=c[b]),c[b]>v&&(v=c[b]);if(t.aabb.lowerBound[1]>v)return!l&&0;for(var _=0,b=m;b<y;b++){o.set(d,b*u,c[b]),o.set(p,(b+1)*u,c[b+1]),o.add(d,d,a),o.add(p,p,a);o.set(f,.5*(p[0]+d[0]),.5*(p[1]+d[1]-100)),o.sub(g.vertices[0],p,f),o.sub(g.vertices[1],d,f),o.copy(g.vertices[2],g.vertices[1]),o.copy(g.vertices[3],g.vertices[0]),g.vertices[2][1]-=100,g.vertices[3][1]-=100,_+=this.convexConvex(t,e,i,s,n,g,f,0,l)}return _}},{"../equations/ContactEquation":21,"../equations/Equation":22,"../equations/FrictionEquation":23,"../math/vec2":30,"../objects/Body":31,"../shapes/Box":37,"../shapes/Circle":39,"../shapes/Convex":40,"../shapes/Shape":45,"../utils/ContactEquationPool":48,"../utils/FrictionEquationPool":49,"../utils/TupleDictionary":56,"../utils/Utils":57}],11:[function(t,e,i){function s(t){t=t||{},this.from=t.from?r.fromValues(t.from[0],t.from[1]):r.create(),this.to=t.to?r.fromValues(t.to[0],t.to[1]):r.create(),this.checkCollisionResponse=void 0===t.checkCollisionResponse||t.checkCollisionResponse,this.skipBackfaces=!!t.skipBackfaces,this.collisionMask=void 0!==t.collisionMask?t.collisionMask:-1,this.collisionGroup=void 0!==t.collisionGroup?t.collisionGroup:-1,this.mode=void 0!==t.mode?t.mode:s.ANY,this.callback=t.callback||function(t){},this.direction=r.create(),this.length=1,this.update()}function n(t,e,i){r.sub(a,i,t);var s=r.dot(a,e);return r.scale(h,e,s),r.add(h,h,t),r.squaredDistance(i,h)}e.exports=s;var r=t("../math/vec2");t("../collision/RaycastResult"),t("../shapes/Shape"),t("../collision/AABB");s.prototype.constructor=s,s.CLOSEST=1,s.ANY=2,s.ALL=4,s.prototype.update=function(){var t=this.direction;r.sub(t,this.to,this.from),this.length=r.length(t),r.normalize(t,t)},s.prototype.intersectBodies=function(t,e){for(var i=0,s=e.length;!t.shouldStop(this)&&i<s;i++){var n=e[i],r=n.getAABB();(r.overlapsRay(this)>=0||r.containsPoint(this.from))&&this.intersectBody(t,n)}};var o=r.create();s.prototype.intersectBody=function(t,e){var i=this.checkCollisionResponse;if(!i||e.collisionResponse)for(var s=o,n=0,a=e.shapes.length;n<a;n++){var h=e.shapes[n];if((!i||h.collisionResponse)&&(0!=(this.collisionGroup&h.collisionMask)&&0!=(h.collisionGroup&this.collisionMask))){r.rotate(s,h.position,e.angle),r.add(s,s,e.position);var l=h.angle+e.angle;if(this.intersectShape(t,h,l,s,e),t.shouldStop(this))break}}},s.prototype.intersectShape=function(t,e,i,s,r){n(this.from,this.direction,s)>e.boundingRadius*e.boundingRadius||(this._currentBody=r,this._currentShape=e,e.raycast(t,this,s,i),this._currentBody=this._currentShape=null)},s.prototype.getAABB=function(t){var e=this.to,i=this.from;r.set(t.lowerBound,Math.min(e[0],i[0]),Math.min(e[1],i[1])),r.set(t.upperBound,Math.max(e[0],i[0]),Math.max(e[1],i[1]))};r.create();s.prototype.reportIntersection=function(t,e,i,n){this.from,this.to;var o=this._currentShape,a=this._currentBody;if(!(this.skipBackfaces&&r.dot(i,this.direction)>0))switch(this.mode){case s.ALL:t.set(i,o,a,e,n),this.callback(t);break;case s.CLOSEST:(e<t.fraction||!t.hasHit())&&t.set(i,o,a,e,n);break;case s.ANY:t.set(i,o,a,e,n)}};var a=r.create(),h=r.create()},{"../collision/AABB":7,"../collision/RaycastResult":12,"../math/vec2":30,"../shapes/Shape":45}],12:[function(t,e,i){function s(){this.normal=n.create(),this.shape=null,this.body=null,this.faceIndex=-1,this.fraction=-1,this.isStopped=!1}var n=t("../math/vec2"),r=t("../collision/Ray");e.exports=s,s.prototype.reset=function(){n.set(this.normal,0,0),this.shape=null,this.body=null,this.faceIndex=-1,this.fraction=-1,this.isStopped=!1},s.prototype.getHitDistance=function(t){return n.distance(t.from,t.to)*this.fraction},s.prototype.hasHit=function(){return-1!==this.fraction},s.prototype.getHitPoint=function(t,e){n.lerp(t,e.from,e.to,this.fraction)},s.prototype.stop=function(){this.isStopped=!0},s.prototype.shouldStop=function(t){return this.isStopped||-1!==this.fraction&&t.mode===r.ANY},s.prototype.set=function(t,e,i,s,r){n.copy(this.normal,t),this.shape=e,this.body=i,this.fraction=s,this.faceIndex=r}},{"../collision/Ray":11,"../math/vec2":30}],13:[function(t,e,i){function s(){r.call(this,r.SAP),this.axisList=[],this.axisIndex=0;var t=this;this._addBodyHandler=function(e){t.axisList.push(e.body)},this._removeBodyHandler=function(e){var i=t.axisList.indexOf(e.body);-1!==i&&t.axisList.splice(i,1)}}var n=t("../utils/Utils"),r=t("../collision/Broadphase");e.exports=s,(s.prototype=new r).constructor=s,s.prototype.setWorld=function(t){this.axisList.length=0,n.appendArray(this.axisList,t.bodies),t.off("addBody",this._addBodyHandler).off("removeBody",this._removeBodyHandler),t.on("addBody",this._addBodyHandler).on("removeBody",this._removeBodyHandler),this.world=t},s.sortAxisList=function(t,e){e|=0;for(var i=1,s=t.length;i<s;i++){for(var n=t[i],r=i-1;r>=0&&!(t[r].aabb.lowerBound[e]<=n.aabb.lowerBound[e]);r--)t[r+1]=t[r];t[r+1]=n}return t},s.prototype.sortList=function(){var t=this.axisList,e=this.axisIndex;s.sortAxisList(t,e)},s.prototype.getCollisionPairs=function(t){var e=this.axisList,i=this.result,s=this.axisIndex;i.length=0;for(var n=e.length;n--;){var o=e[n];o.aabbNeedsUpdate&&o.updateAABB()}this.sortList();for(var a=0,h=0|e.length;a!==h;a++)for(var l=e[a],c=a+1;c<h;c++){var u=e[c];if(!(u.aabb.lowerBound[s]<=l.aabb.upperBound[s]))break;r.canCollide(l,u)&&this.boundingVolumeCheck(l,u)&&i.push(l,u)}return i},s.prototype.aabbQuery=function(t,e,i){i=i||[],this.sortList();var s=this.axisIndex,n="x";1===s&&(n="y"),2===s&&(n="z");for(var r=this.axisList,o=(e.lowerBound[n],e.upperBound[n],0);o<r.length;o++){var a=r[o];a.aabbNeedsUpdate&&a.updateAABB(),a.aabb.overlaps(e)&&i.push(a)}return i}},{"../collision/Broadphase":8,"../utils/Utils":57}],14:[function(t,e,i){function s(t,e,i,s){this.type=i,s=n.defaults(s,{collideConnected:!0,wakeUpBodies:!0}),this.equations=[],this.bodyA=t,this.bodyB=e,this.collideConnected=s.collideConnected,s.wakeUpBodies&&(t&&t.wakeUp(),e&&e.wakeUp())}e.exports=s;var n=t("../utils/Utils");s.prototype.update=function(){throw new Error("method update() not implmemented in this Constraint subclass!")},s.DISTANCE=1,s.GEAR=2,s.LOCK=3,s.PRISMATIC=4,s.REVOLUTE=5,s.prototype.setStiffness=function(t){for(var e=this.equations,i=0;i!==e.length;i++){var s=e[i];s.stiffness=t,s.needsUpdate=!0}},s.prototype.setRelaxation=function(t){for(var e=this.equations,i=0;i!==e.length;i++){var s=e[i];s.relaxation=t,s.needsUpdate=!0}}},{"../utils/Utils":57}],15:[function(t,e,i){function s(t,e,i){i=a.defaults(i,{localAnchorA:[0,0],localAnchorB:[0,0]}),n.call(this,t,e,n.DISTANCE,i),this.localAnchorA=o.fromValues(i.localAnchorA[0],i.localAnchorA[1]),this.localAnchorB=o.fromValues(i.localAnchorB[0],i.localAnchorB[1]);var s=this.localAnchorA,h=this.localAnchorB;if(this.distance=0,"number"==typeof i.distance)this.distance=i.distance;else{var l=o.create(),c=o.create(),u=o.create();o.rotate(l,s,t.angle),o.rotate(c,h,e.angle),o.add(u,e.position,c),o.sub(u,u,l),o.sub(u,u,t.position),this.distance=o.length(u)}var d;d=void 0===i.maxForce?Number.MAX_VALUE:i.maxForce;var p=new r(t,e,-d,d);this.equations=[p],this.maxForce=d;var u=o.create(),f=o.create(),g=o.create(),m=this;p.computeGq=function(){var t=this.bodyA,e=this.bodyB,i=t.position,n=e.position;return o.rotate(f,s,t.angle),o.rotate(g,h,e.angle),o.add(u,n,g),o.sub(u,u,f),o.sub(u,u,i),o.length(u)-m.distance},this.setMaxForce(d),this.upperLimitEnabled=!1,this.upperLimit=1,this.lowerLimitEnabled=!1,this.lowerLimit=0,this.position=0}var n=t("./Constraint"),r=t("../equations/Equation"),o=t("../math/vec2"),a=t("../utils/Utils");e.exports=s,(s.prototype=new n).constructor=s;var h=o.create(),l=o.create(),c=o.create();s.prototype.update=function(){var t=this.equations[0],e=this.bodyA,i=this.bodyB,s=(this.distance,e.position),n=i.position,r=this.equations[0],a=t.G;o.rotate(l,this.localAnchorA,e.angle),o.rotate(c,this.localAnchorB,i.angle),o.add(h,n,c),o.sub(h,h,l),o.sub(h,h,s),this.position=o.length(h);var u=!1;if(this.upperLimitEnabled&&this.position>this.upperLimit&&(r.maxForce=0,r.minForce=-this.maxForce,this.distance=this.upperLimit,u=!0),this.lowerLimitEnabled&&this.position<this.lowerLimit&&(r.maxForce=this.maxForce,r.minForce=0,this.distance=this.lowerLimit,u=!0),!this.lowerLimitEnabled&&!this.upperLimitEnabled||u){r.enabled=!0,o.normalize(h,h);var d=o.crossLength(l,h),p=o.crossLength(c,h);a[0]=-h[0],a[1]=-h[1],a[2]=-d,a[3]=h[0],a[4]=h[1],a[5]=p}else r.enabled=!1},s.prototype.setMaxForce=function(t){var e=this.equations[0];e.minForce=-t,e.maxForce=t},s.prototype.getMaxForce=function(){return this.equations[0].maxForce}},{"../equations/Equation":22,"../math/vec2":30,"../utils/Utils":57,"./Constraint":14}],16:[function(t,e,i){function s(t,e,i){i=i||{},n.call(this,t,e,n.GEAR,i),this.ratio=void 0!==i.ratio?i.ratio:1,this.angle=void 0!==i.angle?i.angle:e.angle-this.ratio*t.angle,i.angle=this.angle,i.ratio=this.ratio,this.equations=[new r(t,e,i)],void 0!==i.maxTorque&&this.setMaxTorque(i.maxTorque)}var n=t("./Constraint"),r=(t("../equations/Equation"),t("../equations/AngleLockEquation"));t("../math/vec2");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.update=function(){var t=this.equations[0];t.ratio!==this.ratio&&t.setRatio(this.ratio),t.angle=this.angle},s.prototype.setMaxTorque=function(t){this.equations[0].setMaxTorque(t)},s.prototype.getMaxTorque=function(t){return this.equations[0].maxForce}},{"../equations/AngleLockEquation":20,"../equations/Equation":22,"../math/vec2":30,"./Constraint":14}],17:[function(t,e,i){function s(t,e,i){i=i||{},n.call(this,t,e,n.LOCK,i);var s=void 0===i.maxForce?Number.MAX_VALUE:i.maxForce,a=(i.localAngleB,new o(t,e,-s,s)),h=new o(t,e,-s,s),l=new o(t,e,-s,s),c=r.create(),u=r.create(),d=this;a.computeGq=function(){return r.rotate(c,d.localOffsetB,t.angle),r.sub(u,e.position,t.position),r.sub(u,u,c),u[0]},h.computeGq=function(){return r.rotate(c,d.localOffsetB,t.angle),r.sub(u,e.position,t.position),r.sub(u,u,c),u[1]};var p=r.create(),f=r.create();l.computeGq=function(){return r.rotate(p,d.localOffsetB,e.angle-d.localAngleB),r.scale(p,p,-1),r.sub(u,t.position,e.position),r.add(u,u,p),r.rotate(f,p,-Math.PI/2),r.normalize(f,f),r.dot(u,f)},this.localOffsetB=r.create(),i.localOffsetB?r.copy(this.localOffsetB,i.localOffsetB):(r.sub(this.localOffsetB,e.position,t.position),r.rotate(this.localOffsetB,this.localOffsetB,-t.angle)),this.localAngleB=0,"number"==typeof i.localAngleB?this.localAngleB=i.localAngleB:this.localAngleB=e.angle-t.angle,this.equations.push(a,h,l),this.setMaxForce(s)}var n=t("./Constraint"),r=t("../math/vec2"),o=t("../equations/Equation");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.setMaxForce=function(t){for(var e=this.equations,i=0;i<this.equations.length;i++)e[i].maxForce=t,e[i].minForce=-t},s.prototype.getMaxForce=function(){return this.equations[0].maxForce};var a=r.create(),h=r.create(),l=r.create(),c=r.fromValues(1,0),u=r.fromValues(0,1);s.prototype.update=function(){var t=this.equations[0],e=this.equations[1],i=this.equations[2],s=this.bodyA,n=this.bodyB;r.rotate(a,this.localOffsetB,s.angle),r.rotate(h,this.localOffsetB,n.angle-this.localAngleB),r.scale(h,h,-1),r.rotate(l,h,Math.PI/2),r.normalize(l,l),t.G[0]=-1,t.G[1]=0,t.G[2]=-r.crossLength(a,c),t.G[3]=1,e.G[0]=0,e.G[1]=-1,e.G[2]=-r.crossLength(a,u),e.G[4]=1,i.G[0]=-l[0],i.G[1]=-l[1],i.G[3]=l[0],i.G[4]=l[1],i.G[5]=r.crossLength(h,l)}},{"../equations/Equation":22,"../math/vec2":30,"./Constraint":14}],18:[function(t,e,i){function s(t,e,i){i=i||{},n.call(this,t,e,n.PRISMATIC,i);var s=a.fromValues(0,0),l=a.fromValues(1,0),c=a.fromValues(0,0);i.localAnchorA&&a.copy(s,i.localAnchorA),i.localAxisA&&a.copy(l,i.localAxisA),i.localAnchorB&&a.copy(c,i.localAnchorB),this.localAnchorA=s,this.localAnchorB=c,this.localAxisA=l;var u=this.maxForce=void 0!==i.maxForce?i.maxForce:Number.MAX_VALUE,d=new o(t,e,-u,u),p=new a.create,f=new a.create,g=new a.create,m=new a.create;if(d.computeGq=function(){return a.dot(g,m)},d.updateJacobian=function(){var i=this.G,n=t.position,r=e.position;a.rotate(p,s,t.angle),a.rotate(f,c,e.angle),a.add(g,r,f),a.sub(g,g,n),a.sub(g,g,p),a.rotate(m,l,t.angle+Math.PI/2),i[0]=-m[0],i[1]=-m[1],i[2]=-a.crossLength(p,m)+a.crossLength(m,g),i[3]=m[0],i[4]=m[1],i[5]=a.crossLength(f,m)},this.equations.push(d),!i.disableRotationalLock){var y=new h(t,e,-u,u);this.equations.push(y)}this.position=0,this.velocity=0,this.lowerLimitEnabled=void 0!==i.lowerLimit,this.upperLimitEnabled=void 0!==i.upperLimit,this.lowerLimit=void 0!==i.lowerLimit?i.lowerLimit:0,this.upperLimit=void 0!==i.upperLimit?i.upperLimit:1,this.upperLimitEquation=new r(t,e),this.lowerLimitEquation=new r(t,e),this.upperLimitEquation.minForce=this.lowerLimitEquation.minForce=0,this.upperLimitEquation.maxForce=this.lowerLimitEquation.maxForce=u,this.motorEquation=new o(t,e),this.motorEnabled=!1,this.motorSpeed=0;var v=this,x=this.motorEquation;x.computeGW;x.computeGq=function(){return 0},x.computeGW=function(){var t=this.G,e=this.bodyA,i=this.bodyB,s=e.velocity,n=i.velocity,r=e.angularVelocity,o=i.angularVelocity;return this.gmult(t,s,r,n,o)+v.motorSpeed}}var n=t("./Constraint"),r=t("../equations/ContactEquation"),o=t("../equations/Equation"),a=t("../math/vec2"),h=t("../equations/RotationalLockEquation");e.exports=s,(s.prototype=new n).constructor=s;var l=a.create(),c=a.create(),u=a.create(),d=a.create(),p=a.create(),f=a.create();s.prototype.update=function(){var t=this.equations,e=t[0],i=this.upperLimit,s=this.lowerLimit,n=this.upperLimitEquation,r=this.lowerLimitEquation,o=this.bodyA,h=this.bodyB,g=this.localAxisA,m=this.localAnchorA,y=this.localAnchorB;e.updateJacobian(),a.rotate(l,g,o.angle),a.rotate(d,m,o.angle),a.add(c,d,o.position),a.rotate(p,y,h.angle),a.add(u,p,h.position);var v=this.position=a.dot(u,l)-a.dot(c,l);if(this.motorEnabled){var x=this.motorEquation.G;x[0]=l[0],x[1]=l[1],x[2]=a.crossLength(l,p),x[3]=-l[0],x[4]=-l[1],x[5]=-a.crossLength(l,d)}if(this.upperLimitEnabled&&v>i?(a.scale(n.normalA,l,-1),a.sub(n.contactPointA,c,o.position),a.sub(n.contactPointB,u,h.position),a.scale(f,l,i),a.add(n.contactPointA,n.contactPointA,f),-1===t.indexOf(n)&&t.push(n)):-1!==(b=t.indexOf(n))&&t.splice(b,1),this.lowerLimitEnabled&&v<s)a.scale(r.normalA,l,1),a.sub(r.contactPointA,c,o.position),a.sub(r.contactPointB,u,h.position),a.scale(f,l,s),a.sub(r.contactPointB,r.contactPointB,f),-1===t.indexOf(r)&&t.push(r);else{var b=t.indexOf(r);-1!==b&&t.splice(b,1)}},s.prototype.enableMotor=function(){this.motorEnabled||(this.equations.push(this.motorEquation),this.motorEnabled=!0)},s.prototype.disableMotor=function(){if(this.motorEnabled){var t=this.equations.indexOf(this.motorEquation);this.equations.splice(t,1),this.motorEnabled=!1}},s.prototype.setLimits=function(t,e){"number"==typeof t?(this.lowerLimit=t,this.lowerLimitEnabled=!0):(this.lowerLimit=t,this.lowerLimitEnabled=!1),"number"==typeof e?(this.upperLimit=e,this.upperLimitEnabled=!0):(this.upperLimit=e,this.upperLimitEnabled=!1)}},{"../equations/ContactEquation":21,"../equations/Equation":22,"../equations/RotationalLockEquation":24,"../math/vec2":30,"./Constraint":14}],19:[function(t,e,i){function s(t,e,i){i=i||{},n.call(this,t,e,n.REVOLUTE,i);var s=this.maxForce=void 0!==i.maxForce?i.maxForce:Number.MAX_VALUE;this.pivotA=h.create(),this.pivotB=h.create(),i.worldPivot?(h.sub(this.pivotA,i.worldPivot,t.position),h.sub(this.pivotB,i.worldPivot,e.position),h.rotate(this.pivotA,this.pivotA,-t.angle),h.rotate(this.pivotB,this.pivotB,-e.angle)):(h.copy(this.pivotA,i.localPivotA),h.copy(this.pivotB,i.localPivotB));var f=this.equations=[new r(t,e,-s,s),new r(t,e,-s,s)],g=f[0],m=f[1],y=this;g.computeGq=function(){return h.rotate(l,y.pivotA,t.angle),h.rotate(c,y.pivotB,e.angle),h.add(p,e.position,c),h.sub(p,p,t.position),h.sub(p,p,l),h.dot(p,u)},m.computeGq=function(){return h.rotate(l,y.pivotA,t.angle),h.rotate(c,y.pivotB,e.angle),h.add(p,e.position,c),h.sub(p,p,t.position),h.sub(p,p,l),h.dot(p,d)},m.minForce=g.minForce=-s,m.maxForce=g.maxForce=s,this.motorEquation=new o(t,e),this.motorEnabled=!1,this.angle=0,this.lowerLimitEnabled=!1,this.upperLimitEnabled=!1,this.lowerLimit=0,this.upperLimit=0,this.upperLimitEquation=new a(t,e),this.lowerLimitEquation=new a(t,e),this.upperLimitEquation.minForce=0,this.lowerLimitEquation.maxForce=0}var n=t("./Constraint"),r=t("../equations/Equation"),o=t("../equations/RotationalVelocityEquation"),a=t("../equations/RotationalLockEquation"),h=t("../math/vec2");e.exports=s;var l=h.create(),c=h.create(),u=h.fromValues(1,0),d=h.fromValues(0,1),p=h.create();(s.prototype=new n).constructor=s,s.prototype.setLimits=function(t,e){"number"==typeof t?(this.lowerLimit=t,this.lowerLimitEnabled=!0):(this.lowerLimit=t,this.lowerLimitEnabled=!1),"number"==typeof e?(this.upperLimit=e,this.upperLimitEnabled=!0):(this.upperLimit=e,this.upperLimitEnabled=!1)},s.prototype.update=function(){var t=this.bodyA,e=this.bodyB,i=this.pivotA,s=this.pivotB,n=this.equations,r=(n[0],n[1],n[0]),o=n[1],a=this.upperLimit,p=this.lowerLimit,f=this.upperLimitEquation,g=this.lowerLimitEquation,m=this.angle=e.angle-t.angle;if(this.upperLimitEnabled&&m>a?(f.angle=a,-1===n.indexOf(f)&&n.push(f)):-1!==(y=n.indexOf(f))&&n.splice(y,1),this.lowerLimitEnabled&&m<p)g.angle=p,-1===n.indexOf(g)&&n.push(g);else{var y=n.indexOf(g);-1!==y&&n.splice(y,1)}h.rotate(l,i,t.angle),h.rotate(c,s,e.angle),r.G[0]=-1,r.G[1]=0,r.G[2]=-h.crossLength(l,u),r.G[3]=1,r.G[4]=0,r.G[5]=h.crossLength(c,u),o.G[0]=0,o.G[1]=-1,o.G[2]=-h.crossLength(l,d),o.G[3]=0,o.G[4]=1,o.G[5]=h.crossLength(c,d)},s.prototype.enableMotor=function(){this.motorEnabled||(this.equations.push(this.motorEquation),this.motorEnabled=!0)},s.prototype.disableMotor=function(){if(this.motorEnabled){var t=this.equations.indexOf(this.motorEquation);this.equations.splice(t,1),this.motorEnabled=!1}},s.prototype.setMotorSpeed=function(t){if(this.motorEnabled){var e=this.equations.indexOf(this.motorEquation);this.equations[e].relativeVelocity=t}},s.prototype.getMotorSpeed=function(){return!!this.motorEnabled&&this.motorEquation.relativeVelocity}},{"../equations/Equation":22,"../equations/RotationalLockEquation":24,"../equations/RotationalVelocityEquation":25,"../math/vec2":30,"./Constraint":14}],20:[function(t,e,i){function s(t,e,i){i=i||{},n.call(this,t,e,-Number.MAX_VALUE,Number.MAX_VALUE),this.angle=i.angle||0,this.ratio="number"==typeof i.ratio?i.ratio:1,this.setRatio(this.ratio)}var n=t("./Equation");t("../math/vec2");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.computeGq=function(){return this.ratio*this.bodyA.angle-this.bodyB.angle+this.angle},s.prototype.setRatio=function(t){var e=this.G;e[2]=t,e[5]=-1,this.ratio=t},s.prototype.setMaxTorque=function(t){this.maxForce=t,this.minForce=-t}},{"../math/vec2":30,"./Equation":22}],21:[function(t,e,i){function s(t,e){n.call(this,t,e,0,Number.MAX_VALUE),this.contactPointA=r.create(),this.penetrationVec=r.create(),this.contactPointB=r.create(),this.normalA=r.create(),this.restitution=0,this.firstImpact=!1,this.shapeA=null,this.shapeB=null}var n=t("./Equation"),r=t("../math/vec2");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.computeB=function(t,e,i){var s=this.bodyA,n=this.bodyB,o=this.contactPointA,a=this.contactPointB,h=s.position,l=n.position,c=this.penetrationVec,u=this.normalA,d=this.G,p=r.crossLength(o,u),f=r.crossLength(a,u);d[0]=-u[0],d[1]=-u[1],d[2]=-p,d[3]=u[0],d[4]=u[1],d[5]=f,r.add(c,l,a),r.sub(c,c,h),r.sub(c,c,o);var g,m;return this.firstImpact&&0!==this.restitution?(m=0,g=1/e*(1+this.restitution)*this.computeGW()):(m=r.dot(u,c)+this.offset,g=this.computeGW()),-m*t-g*e-i*this.computeGiMf()};var o=r.create(),a=r.create(),h=r.create();s.prototype.getVelocityAlongNormal=function(){return this.bodyA.getVelocityAtPoint(o,this.contactPointA),this.bodyB.getVelocityAtPoint(a,this.contactPointB),r.subtract(h,o,a),r.dot(this.normalA,h)}},{"../math/vec2":30,"./Equation":22}],22:[function(t,e,i){function s(t,e,i,n){this.minForce=void 0===i?-Number.MAX_VALUE:i,this.maxForce=void 0===n?Number.MAX_VALUE:n,this.bodyA=t,this.bodyB=e,this.stiffness=s.DEFAULT_STIFFNESS,this.relaxation=s.DEFAULT_RELAXATION,this.G=new r.ARRAY_TYPE(6);for(var o=0;o<6;o++)this.G[o]=0;this.offset=0,this.a=0,this.b=0,this.epsilon=0,this.timeStep=1/60,this.needsUpdate=!0,this.multiplier=0,this.relativeVelocity=0,this.enabled=!0}e.exports=s;var n=t("../math/vec2"),r=t("../utils/Utils");t("../objects/Body");s.prototype.constructor=s,s.DEFAULT_STIFFNESS=1e6,s.DEFAULT_RELAXATION=4,s.prototype.update=function(){var t=this.stiffness,e=this.relaxation,i=this.timeStep;this.a=4/(i*(1+4*e)),this.b=4*e/(1+4*e),this.epsilon=4/(i*i*t*(1+4*e)),this.needsUpdate=!1},s.prototype.gmult=function(t,e,i,s,n){return t[0]*e[0]+t[1]*e[1]+t[2]*i+t[3]*s[0]+t[4]*s[1]+t[5]*n},s.prototype.computeB=function(t,e,i){var s=this.computeGW();return-this.computeGq()*t-s*e-this.computeGiMf()*i};var o=n.create(),a=n.create();s.prototype.computeGq=function(){var t=this.G,e=this.bodyA,i=this.bodyB,s=(e.position,i.position,e.angle),n=i.angle;return this.gmult(t,o,s,a,n)+this.offset},s.prototype.computeGW=function(){var t=this.G,e=this.bodyA,i=this.bodyB,s=e.velocity,n=i.velocity,r=e.angularVelocity,o=i.angularVelocity;return this.gmult(t,s,r,n,o)+this.relativeVelocity},s.prototype.computeGWlambda=function(){var t=this.G,e=this.bodyA,i=this.bodyB,s=e.vlambda,n=i.vlambda,r=e.wlambda,o=i.wlambda;return this.gmult(t,s,r,n,o)};var h=n.create(),l=n.create();s.prototype.computeGiMf=function(){var t=this.bodyA,e=this.bodyB,i=t.force,s=t.angularForce,r=e.force,o=e.angularForce,a=t.invMassSolve,c=e.invMassSolve,u=t.invInertiaSolve,d=e.invInertiaSolve,p=this.G;return n.scale(h,i,a),n.multiply(h,t.massMultiplier,h),n.scale(l,r,c),n.multiply(l,e.massMultiplier,l),this.gmult(p,h,s*u,l,o*d)},s.prototype.computeGiMGt=function(){var t=this.bodyA,e=this.bodyB,i=t.invMassSolve,s=e.invMassSolve,n=t.invInertiaSolve,r=e.invInertiaSolve,o=this.G;return o[0]*o[0]*i*t.massMultiplier[0]+o[1]*o[1]*i*t.massMultiplier[1]+o[2]*o[2]*n+o[3]*o[3]*s*e.massMultiplier[0]+o[4]*o[4]*s*e.massMultiplier[1]+o[5]*o[5]*r};var c=n.create(),u=n.create(),d=n.create();n.create(),n.create(),n.create();s.prototype.addToWlambda=function(t){var e=this.bodyA,i=this.bodyB,s=c,r=u,o=d,a=e.invMassSolve,h=i.invMassSolve,l=e.invInertiaSolve,p=i.invInertiaSolve,f=this.G;r[0]=f[0],r[1]=f[1],o[0]=f[3],o[1]=f[4],n.scale(s,r,a*t),n.multiply(s,s,e.massMultiplier),n.add(e.vlambda,e.vlambda,s),e.wlambda+=l*f[2]*t,n.scale(s,o,h*t),n.multiply(s,s,i.massMultiplier),n.add(i.vlambda,i.vlambda,s),i.wlambda+=p*f[5]*t},s.prototype.computeInvC=function(t){return 1/(this.computeGiMGt()+t)}},{"../math/vec2":30,"../objects/Body":31,"../utils/Utils":57}],23:[function(t,e,i){function s(t,e,i){r.call(this,t,e,-i,i),this.contactPointA=n.create(),this.contactPointB=n.create(),this.t=n.create(),this.contactEquations=[],this.shapeA=null,this.shapeB=null,this.frictionCoefficient=.3}var n=t("../math/vec2"),r=t("./Equation");t("../utils/Utils");e.exports=s,(s.prototype=new r).constructor=s,s.prototype.setSlipForce=function(t){this.maxForce=t,this.minForce=-t},s.prototype.getSlipForce=function(){return this.maxForce},s.prototype.computeB=function(t,e,i){this.bodyA,this.bodyB;var s=this.contactPointA,r=this.contactPointB,o=this.t,a=this.G;return a[0]=-o[0],a[1]=-o[1],a[2]=-n.crossLength(s,o),a[3]=o[0],a[4]=o[1],a[5]=n.crossLength(r,o),-this.computeGW()*e-i*this.computeGiMf()}},{"../math/vec2":30,"../utils/Utils":57,"./Equation":22}],24:[function(t,e,i){function s(t,e,i){i=i||{},n.call(this,t,e,-Number.MAX_VALUE,Number.MAX_VALUE),this.angle=i.angle||0;var s=this.G;s[2]=1,s[5]=-1}var n=t("./Equation"),r=t("../math/vec2");e.exports=s,(s.prototype=new n).constructor=s;var o=r.create(),a=r.create(),h=r.fromValues(1,0),l=r.fromValues(0,1);s.prototype.computeGq=function(){return r.rotate(o,h,this.bodyA.angle+this.angle),r.rotate(a,l,this.bodyB.angle),r.dot(o,a)}},{"../math/vec2":30,"./Equation":22}],25:[function(t,e,i){function s(t,e){n.call(this,t,e,-Number.MAX_VALUE,Number.MAX_VALUE),this.relativeVelocity=1,this.ratio=1}var n=t("./Equation");t("../math/vec2");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.computeB=function(t,e,i){var s=this.G;s[2]=-1,s[5]=this.ratio;var n=this.computeGiMf();return-this.computeGW()*e-i*n}},{"../math/vec2":30,"./Equation":22}],26:[function(t,e,i){var s=function(){};e.exports=s,s.prototype={constructor:s,on:function(t,e,i){e.context=i||this,void 0===this._listeners&&(this._listeners={});var s=this._listeners;return void 0===s[t]&&(s[t]=[]),-1===s[t].indexOf(e)&&s[t].push(e),this},has:function(t,e){if(void 0===this._listeners)return!1;var i=this._listeners;if(e){if(void 0!==i[t]&&-1!==i[t].indexOf(e))return!0}else if(void 0!==i[t])return!0;return!1},off:function(t,e){if(void 0===this._listeners)return this;var i=this._listeners,s=i[t].indexOf(e);return-1!==s&&i[t].splice(s,1),this},emit:function(t){if(void 0===this._listeners)return this;var e=this._listeners[t.type];if(void 0!==e){t.target=this;for(var i=0,s=e.length;i<s;i++){var n=e[i];n.call(n.context,t)}}return this}}},{}],27:[function(t,e,i){function s(t,e,i){if(i=i||{},!(t instanceof n&&e instanceof n))throw new Error("First two arguments must be Material instances.");this.id=s.idCounter++,this.materialA=t,this.materialB=e,this.friction=void 0!==i.friction?Number(i.friction):.3,this.restitution=void 0!==i.restitution?Number(i.restitution):0,this.stiffness=void 0!==i.stiffness?Number(i.stiffness):r.DEFAULT_STIFFNESS,this.relaxation=void 0!==i.relaxation?Number(i.relaxation):r.DEFAULT_RELAXATION,this.frictionStiffness=void 0!==i.frictionStiffness?Number(i.frictionStiffness):r.DEFAULT_STIFFNESS,this.frictionRelaxation=void 0!==i.frictionRelaxation?Number(i.frictionRelaxation):r.DEFAULT_RELAXATION,this.surfaceVelocity=void 0!==i.surfaceVelocity?Number(i.surfaceVelocity):0,this.contactSkinSize=.005}var n=t("./Material"),r=t("../equations/Equation");e.exports=s,s.idCounter=0},{"../equations/Equation":22,"./Material":28}],28:[function(t,e,i){function s(t){this.id=t||s.idCounter++}e.exports=s,s.idCounter=0},{}],29:[function(t,e,i){var s={};s.GetArea=function(t){if(t.length<6)return 0;for(var e=t.length-2,i=0,s=0;s<e;s+=2)i+=(t[s+2]-t[s])*(t[s+1]+t[s+3]);return.5*-(i+=(t[0]-t[e])*(t[e+1]+t[1]))},s.Triangulate=function(t){var e=t.length>>1;if(e<3)return[];for(var i=[],n=[],r=0;r<e;r++)n.push(r);for(var r=0,o=e;o>3;){var a=n[(r+0)%o],h=n[(r+1)%o],l=n[(r+2)%o],c=t[2*a],u=t[2*a+1],d=t[2*h],p=t[2*h+1],f=t[2*l],g=t[2*l+1],m=!1;if(s._convex(c,u,d,p,f,g)){m=!0;for(var y=0;y<o;y++){var v=n[y];if(v!=a&&v!=h&&v!=l&&s._PointInTriangle(t[2*v],t[2*v+1],c,u,d,p,f,g)){m=!1;break}}}if(m)i.push(a,h,l),n.splice((r+1)%o,1),o--,r=0;else if(r++>3*o)break}return i.push(n[0],n[1],n[2]),i},s._PointInTriangle=function(t,e,i,s,n,r,o,a){var h=o-i,l=a-s,c=n-i,u=r-s,d=t-i,p=e-s,f=h*h+l*l,g=h*c+l*u,m=h*d+l*p,y=c*c+u*u,v=c*d+u*p,x=1/(f*y-g*g),b=(y*m-g*v)*x,_=(f*v-g*m)*x;return b>=0&&_>=0&&b+_<1},s._convex=function(t,e,i,s,n,r){return(e-s)*(n-i)+(i-t)*(r-s)>=0},e.exports=s},{}],30:[function(t,e,i){var s=e.exports={},n=t("../utils/Utils");s.crossLength=function(t,e){return t[0]*e[1]-t[1]*e[0]},s.crossVZ=function(t,e,i){return s.rotate(t,e,-Math.PI/2),s.scale(t,t,i),t},s.crossZV=function(t,e,i){return s.rotate(t,i,Math.PI/2),s.scale(t,t,e),t},s.rotate=function(t,e,i){if(0!==i){var s=Math.cos(i),n=Math.sin(i),r=e[0],o=e[1];t[0]=s*r-n*o,t[1]=n*r+s*o}else t[0]=e[0],t[1]=e[1]},s.rotate90cw=function(t,e){var i=e[0],s=e[1];t[0]=s,t[1]=-i},s.toLocalFrame=function(t,e,i,n){s.copy(t,e),s.sub(t,t,i),s.rotate(t,t,-n)},s.toGlobalFrame=function(t,e,i,n){s.copy(t,e),s.rotate(t,t,n),s.add(t,t,i)},s.vectorToLocalFrame=function(t,e,i){s.rotate(t,e,-i)},s.vectorToGlobalFrame=function(t,e,i){s.rotate(t,e,i)},s.centroid=function(t,e,i,n){return s.add(t,e,i),s.add(t,t,n),s.scale(t,t,1/3),t},s.create=function(){var t=new n.ARRAY_TYPE(2);return t[0]=0,t[1]=0,t},s.clone=function(t){var e=new n.ARRAY_TYPE(2);return e[0]=t[0],e[1]=t[1],e},s.fromValues=function(t,e){var i=new n.ARRAY_TYPE(2);return i[0]=t,i[1]=e,i},s.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t},s.set=function(t,e,i){return t[0]=e,t[1]=i,t},s.add=function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t},s.subtract=function(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t},s.sub=s.subtract,s.multiply=function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t},s.mul=s.multiply,s.divide=function(t,e,i){return t[0]=e[0]/i[0],t[1]=e[1]/i[1],t},s.div=s.divide,s.scale=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t},s.distance=function(t,e){var i=e[0]-t[0],s=e[1]-t[1];return Math.sqrt(i*i+s*s)},s.dist=s.distance,s.squaredDistance=function(t,e){var i=e[0]-t[0],s=e[1]-t[1];return i*i+s*s},s.sqrDist=s.squaredDistance,s.length=function(t){var e=t[0],i=t[1];return Math.sqrt(e*e+i*i)},s.len=s.length,s.squaredLength=function(t){var e=t[0],i=t[1];return e*e+i*i},s.sqrLen=s.squaredLength,s.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t},s.normalize=function(t,e){var i=e[0],s=e[1],n=i*i+s*s;return n>0&&(n=1/Math.sqrt(n),t[0]=e[0]*n,t[1]=e[1]*n),t},s.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},s.str=function(t){return"vec2("+t[0]+", "+t[1]+")"},s.lerp=function(t,e,i,s){var n=e[0],r=e[1];return t[0]=n+s*(i[0]-n),t[1]=r+s*(i[1]-r),t},s.reflect=function(t,e,i){var s=e[0]*i[0]+e[1]*i[1];t[0]=e[0]-2*i[0]*s,t[1]=e[1]-2*i[1]*s},s.getLineSegmentsIntersection=function(t,e,i,n,r){var o=s.getLineSegmentsIntersectionFraction(e,i,n,r);return!(o<0)&&(t[0]=e[0]+o*(i[0]-e[0]),t[1]=e[1]+o*(i[1]-e[1]),!0)},s.getLineSegmentsIntersectionFraction=function(t,e,i,s){var n,r,o=e[0]-t[0],a=e[1]-t[1],h=s[0]-i[0],l=s[1]-i[1];return n=(-a*(t[0]-i[0])+o*(t[1]-i[1]))/(-h*a+o*l),r=(h*(t[1]-i[1])-l*(t[0]-i[0]))/(-h*a+o*l),n>=0&&n<=1&&r>=0&&r<=1?r:-1}},{"../utils/Utils":57}],31:[function(t,e,i){function s(t){t=t||{},c.call(this),this.id=t.id||++s._idCounter,this.world=null,this.shapes=[],this.mass=t.mass||0,this.invMass=0,this.inertia=0,this.invInertia=0,this.invMassSolve=0,this.invInertiaSolve=0,this.fixedRotation=!!t.fixedRotation,this.fixedX=!!t.fixedX,this.fixedY=!!t.fixedY,this.massMultiplier=n.create(),this.position=n.fromValues(0,0),t.position&&n.copy(this.position,t.position),this.interpolatedPosition=n.fromValues(0,0),this.interpolatedAngle=0,this.previousPosition=n.fromValues(0,0),this.previousAngle=0,this.velocity=n.fromValues(0,0),t.velocity&&n.copy(this.velocity,t.velocity),this.vlambda=n.fromValues(0,0),this.wlambda=0,this.angle=t.angle||0,this.angularVelocity=t.angularVelocity||0,this.force=n.create(),t.force&&n.copy(this.force,t.force),this.angularForce=t.angularForce||0,this.damping="number"==typeof t.damping?t.damping:.1,this.angularDamping="number"==typeof t.angularDamping?t.angularDamping:.1,this.type=s.STATIC,void 0!==t.type?this.type=t.type:t.mass?this.type=s.DYNAMIC:this.type=s.STATIC,this.boundingRadius=0,this.aabb=new l,this.aabbNeedsUpdate=!0,this.allowSleep=void 0===t.allowSleep||t.allowSleep,this.wantsToSleep=!1,this.sleepState=s.AWAKE,this.sleepSpeedLimit=void 0!==t.sleepSpeedLimit?t.sleepSpeedLimit:.2,this.sleepTimeLimit=void 0!==t.sleepTimeLimit?t.sleepTimeLimit:1,this.gravityScale=void 0!==t.gravityScale?t.gravityScale:1,this.collisionResponse=void 0===t.collisionResponse||t.collisionResponse,this.idleTime=0,this.timeLastSleepy=0,this.ccdSpeedThreshold=void 0!==t.ccdSpeedThreshold?t.ccdSpeedThreshold:-1,this.ccdIterations=void 0!==t.ccdIterations?t.ccdIterations:10,this.concavePath=null,this._wakeUpAfterNarrowphase=!1,this.updateMassProperties()}var n=t("../math/vec2"),r=t("poly-decomp"),o=t("../shapes/Convex"),a=t("../collision/RaycastResult"),h=t("../collision/Ray"),l=t("../collision/AABB"),c=t("../events/EventEmitter");e.exports=s,s.prototype=new c,s.prototype.constructor=s,s._idCounter=0,s.prototype.updateSolveMassProperties=function(){this.sleepState===s.SLEEPING||this.type===s.KINEMATIC?(this.invMassSolve=0,this.invInertiaSolve=0):(this.invMassSolve=this.invMass,this.invInertiaSolve=this.invInertia)},s.prototype.setDensity=function(t){var e=this.getArea();this.mass=e*t,this.updateMassProperties()},s.prototype.getArea=function(){for(var t=0,e=0;e<this.shapes.length;e++)t+=this.shapes[e].area;return t},s.prototype.getAABB=function(){return this.aabbNeedsUpdate&&this.updateAABB(),this.aabb};var u=new l,d=n.create();s.prototype.updateAABB=function(){for(var t=this.shapes,e=t.length,i=d,s=this.angle,r=0;r!==e;r++){var o=t[r],a=o.angle+s;n.rotate(i,o.position,s),n.add(i,i,this.position),o.computeAABB(u,i,a),0===r?this.aabb.copy(u):this.aabb.extend(u)}this.aabbNeedsUpdate=!1},s.prototype.updateBoundingRadius=function(){for(var t=this.shapes,e=t.length,i=0,s=0;s!==e;s++){var r=t[s],o=n.length(r.position),a=r.boundingRadius;o+a>i&&(i=o+a)}this.boundingRadius=i},s.prototype.addShape=function(t,e,i){if(t.body)throw new Error("A shape can only be added to one body.");t.body=this,e?n.copy(t.position,e):n.set(t.position,0,0),t.angle=i||0,this.shapes.push(t),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0},s.prototype.removeShape=function(t){var e=this.shapes.indexOf(t);return-1!==e&&(this.shapes.splice(e,1),this.aabbNeedsUpdate=!0,t.body=null,!0)},s.prototype.updateMassProperties=function(){if(this.type===s.STATIC||this.type===s.KINEMATIC)this.mass=Number.MAX_VALUE,this.invMass=0,this.inertia=Number.MAX_VALUE,this.invInertia=0;else{var t=this.shapes,e=t.length,i=this.mass/e,r=0;if(this.fixedRotation)this.inertia=Number.MAX_VALUE,this.invInertia=0;else{for(var o=0;o<e;o++){var a=t[o],h=n.squaredLength(a.position);r+=a.computeMomentOfInertia(i)+i*h}this.inertia=r,this.invInertia=r>0?1/r:0}this.invMass=1/this.mass,n.set(this.massMultiplier,this.fixedX?0:1,this.fixedY?0:1)}};n.create();s.prototype.applyForce=function(t,e){if(n.add(this.force,this.force,t),e){var i=n.crossLength(e,t);this.angularForce+=i}};var p=n.create(),f=n.create(),g=n.create();s.prototype.applyForceLocal=function(t,e){e=e||g;var i=p,s=f;this.vectorToWorldFrame(i,t),this.vectorToWorldFrame(s,e),this.applyForce(i,s)};var m=n.create();s.prototype.applyImpulse=function(t,e){if(this.type===s.DYNAMIC){var i=m;if(n.scale(i,t,this.invMass),n.multiply(i,this.massMultiplier,i),n.add(this.velocity,i,this.velocity),e){var r=n.crossLength(e,t);r*=this.invInertia,this.angularVelocity+=r}}};var y=n.create(),v=n.create(),x=n.create();s.prototype.applyImpulseLocal=function(t,e){e=e||x;var i=y,s=v;this.vectorToWorldFrame(i,t),this.vectorToWorldFrame(s,e),this.applyImpulse(i,s)},s.prototype.toLocalFrame=function(t,e){n.toLocalFrame(t,e,this.position,this.angle)},s.prototype.toWorldFrame=function(t,e){n.toGlobalFrame(t,e,this.position,this.angle)},s.prototype.vectorToLocalFrame=function(t,e){n.vectorToLocalFrame(t,e,this.angle)},s.prototype.vectorToWorldFrame=function(t,e){n.vectorToGlobalFrame(t,e,this.angle)},s.prototype.fromPolygon=function(t,e){e=e||{};for(h=this.shapes.length;h>=0;--h)this.removeShape(this.shapes[h]);var i=new r.Polygon;if(i.vertices=t,i.makeCCW(),"number"==typeof e.removeCollinearPoints&&i.removeCollinearPoints(e.removeCollinearPoints),void 0===e.skipSimpleCheck&&!i.isSimple())return!1;this.concavePath=i.vertices.slice(0);for(h=0;h<this.concavePath.length;h++){u=[0,0];n.copy(u,this.concavePath[h]),this.concavePath[h]=u}var s;s=e.optimalDecomp?i.decomp():i.quickDecomp();for(var a=n.create(),h=0;h!==s.length;h++){for(var l=new o({vertices:s[h].vertices}),c=0;c!==l.vertices.length;c++){var u=l.vertices[c];n.sub(u,u,l.centerOfMass)}n.scale(a,l.centerOfMass,1),l.updateTriangles(),l.updateCenterOfMass(),l.updateBoundingRadius(),this.addShape(l,a)}return this.adjustCenterOfMass(),this.aabbNeedsUpdate=!0,!0};n.fromValues(0,0);var b=n.fromValues(0,0),_=n.fromValues(0,0),w=n.fromValues(0,0);s.prototype.adjustCenterOfMass=function(){var t=b,e=_,i=w,s=0;n.set(e,0,0);for(o=0;o!==this.shapes.length;o++){r=this.shapes[o];n.scale(t,r.position,r.area),n.add(e,e,t),s+=r.area}n.scale(i,e,1/s);for(o=0;o!==this.shapes.length;o++){var r=this.shapes[o];n.sub(r.position,r.position,i)}n.add(this.position,this.position,i);for(var o=0;this.concavePath&&o<this.concavePath.length;o++)n.sub(this.concavePath[o],this.concavePath[o],i);this.updateMassProperties(),this.updateBoundingRadius()},s.prototype.setZeroForce=function(){n.set(this.force,0,0),this.angularForce=0},s.prototype.resetConstraintVelocity=function(){var t=this,e=t.vlambda;n.set(e,0,0),t.wlambda=0},s.prototype.addConstraintVelocity=function(){var t=this,e=t.velocity;n.add(e,e,t.vlambda),t.angularVelocity+=t.wlambda},s.prototype.applyDamping=function(t){if(this.type===s.DYNAMIC){var e=this.velocity;n.scale(e,e,Math.pow(1-this.damping,t)),this.angularVelocity*=Math.pow(1-this.angularDamping,t)}},s.prototype.wakeUp=function(){var t=this.sleepState;this.sleepState=s.AWAKE,this.idleTime=0,t!==s.AWAKE&&this.emit(s.wakeUpEvent)},s.prototype.sleep=function(){this.sleepState=s.SLEEPING,this.angularVelocity=0,this.angularForce=0,n.set(this.velocity,0,0),n.set(this.force,0,0),this.emit(s.sleepEvent)},s.prototype.sleepTick=function(t,e,i){if(this.allowSleep&&this.type!==s.SLEEPING){this.wantsToSleep=!1;this.sleepState;n.squaredLength(this.velocity)+Math.pow(this.angularVelocity,2)>=Math.pow(this.sleepSpeedLimit,2)?(this.idleTime=0,this.sleepState=s.AWAKE):(this.idleTime+=i,this.sleepState=s.SLEEPY),this.idleTime>this.sleepTimeLimit&&(e?this.wantsToSleep=!0:this.sleep())}},s.prototype.overlaps=function(t){return this.world.overlapKeeper.bodiesAreOverlapping(this,t)};var T=n.create(),P=n.create();s.prototype.integrate=function(t){var e=this.invMass,i=this.force,s=this.position,r=this.velocity;n.copy(this.previousPosition,this.position),this.previousAngle=this.angle,this.fixedRotation||(this.angularVelocity+=this.angularForce*this.invInertia*t),n.scale(T,i,t*e),n.multiply(T,this.massMultiplier,T),n.add(r,T,r),this.integrateToTimeOfImpact(t)||(n.scale(P,r,t),n.add(s,s,P),this.fixedRotation||(this.angle+=this.angularVelocity*t)),this.aabbNeedsUpdate=!0};var C=new a,S=new h({mode:h.ALL}),A=n.create(),E=n.create(),M=n.create(),R=n.create();s.prototype.integrateToTimeOfImpact=function(t){if(this.ccdSpeedThreshold<0||n.squaredLength(this.velocity)<Math.pow(this.ccdSpeedThreshold,2))return!1;n.normalize(A,this.velocity),n.scale(E,this.velocity,t),n.add(E,E,this.position),n.sub(M,E,this.position);var e,i=this.angularVelocity*t,s=n.length(M),r=1,o=this;if(C.reset(),S.callback=function(t){t.body!==o&&(e=t.body,t.getHitPoint(E,S),n.sub(M,E,o.position),r=n.length(M)/s,t.stop())},n.copy(S.from,this.position),n.copy(S.to,E),S.update(),this.world.raycast(C,S),!e)return!1;var a=this.angle;n.copy(R,this.position);for(var h=0,l=0,c=0,u=r;u>=l&&h<this.ccdIterations;)h++,c=(u-l)/2,n.scale(P,M,r),n.add(this.position,R,P),this.angle=a+i*r,this.updateAABB(),this.aabb.overlaps(e.aabb)&&this.world.narrowphase.bodiesOverlap(this,e)?l=c:u=c;return r=c,n.copy(this.position,R),this.angle=a,n.scale(P,M,r),n.add(this.position,this.position,P),this.fixedRotation||(this.angle+=i*r),!0},s.prototype.getVelocityAtPoint=function(t,e){return n.crossVZ(t,e,this.angularVelocity),n.subtract(t,this.velocity,t),t},s.sleepyEvent={type:"sleepy"},s.sleepEvent={type:"sleep"},s.wakeUpEvent={type:"wakeup"},s.DYNAMIC=1,s.STATIC=2,s.KINEMATIC=4,s.AWAKE=0,s.SLEEPY=1,s.SLEEPING=2},{"../collision/AABB":7,"../collision/Ray":11,"../collision/RaycastResult":12,"../events/EventEmitter":26,"../math/vec2":30,"../shapes/Convex":40,"poly-decomp":5}],32:[function(t,e,i){function s(t,e,i){i=i||{},r.call(this,t,e,i),this.localAnchorA=n.fromValues(0,0),this.localAnchorB=n.fromValues(0,0),i.localAnchorA&&n.copy(this.localAnchorA,i.localAnchorA),i.localAnchorB&&n.copy(this.localAnchorB,i.localAnchorB),i.worldAnchorA&&this.setWorldAnchorA(i.worldAnchorA),i.worldAnchorB&&this.setWorldAnchorB(i.worldAnchorB);var s=n.create(),o=n.create();this.getWorldAnchorA(s),this.getWorldAnchorB(o);var a=n.distance(s,o);this.restLength="number"==typeof i.restLength?i.restLength:a}var n=t("../math/vec2"),r=t("./Spring");t("../utils/Utils");e.exports=s,(s.prototype=new r).constructor=s,s.prototype.setWorldAnchorA=function(t){this.bodyA.toLocalFrame(this.localAnchorA,t)},s.prototype.setWorldAnchorB=function(t){this.bodyB.toLocalFrame(this.localAnchorB,t)},s.prototype.getWorldAnchorA=function(t){this.bodyA.toWorldFrame(t,this.localAnchorA)},s.prototype.getWorldAnchorB=function(t){this.bodyB.toWorldFrame(t,this.localAnchorB)};var o=n.create(),a=n.create(),h=n.create(),l=n.create(),c=n.create(),u=n.create(),d=n.create(),p=n.create(),f=n.create();s.prototype.applyForce=function(){var t=this.stiffness,e=this.damping,i=this.restLength,s=this.bodyA,r=this.bodyB,g=o,m=a,y=h,v=l,x=f,b=c,_=u,w=d,T=p;this.getWorldAnchorA(b),this.getWorldAnchorB(_),n.sub(w,b,s.position),n.sub(T,_,r.position),n.sub(g,_,b);var P=n.len(g);n.normalize(m,g),n.sub(y,r.velocity,s.velocity),n.crossZV(x,r.angularVelocity,T),n.add(y,y,x),n.crossZV(x,s.angularVelocity,w),n.sub(y,y,x),n.scale(v,m,-t*(P-i)-e*n.dot(y,m)),n.sub(s.force,s.force,v),n.add(r.force,r.force,v);var C=n.crossLength(w,v),S=n.crossLength(T,v);s.angularForce-=C,r.angularForce+=S}},{"../math/vec2":30,"../utils/Utils":57,"./Spring":34}],33:[function(t,e,i){function s(t,e,i){i=i||{},n.call(this,t,e,i),this.restAngle="number"==typeof i.restAngle?i.restAngle:e.angle-t.angle}t("../math/vec2");var n=t("./Spring");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.applyForce=function(){var t=this.stiffness,e=this.damping,i=this.restAngle,s=this.bodyA,n=this.bodyB,r=-t*(n.angle-s.angle-i)-e*(n.angularVelocity-s.angularVelocity)*0;s.angularForce-=r,n.angularForce+=r}},{"../math/vec2":30,"./Spring":34}],34:[function(t,e,i){function s(t,e,i){i=n.defaults(i,{stiffness:100,damping:1}),this.stiffness=i.stiffness,this.damping=i.damping,this.bodyA=t,this.bodyB=e}t("../math/vec2");var n=t("../utils/Utils");e.exports=s,s.prototype.applyForce=function(){}},{"../math/vec2":30,"../utils/Utils":57}],35:[function(t,e,i){function s(t,e){e=e||{},this.chassisBody=t,this.wheels=[],this.groundBody=new h({mass:0}),this.world=null;var i=this;this.preStepCallback=function(){i.update()}}function n(t,e){e=e||{},this.vehicle=t,this.forwardEquation=new a(t.chassisBody,t.groundBody),this.sideEquation=new a(t.chassisBody,t.groundBody),this.steerValue=0,this.engineForce=0,this.setSideFriction(void 0!==e.sideFriction?e.sideFriction:5),this.localForwardVector=r.fromValues(0,1),e.localForwardVector&&r.copy(this.localForwardVector,e.localForwardVector),this.localPosition=r.fromValues(0,0),e.localPosition&&r.copy(this.localPosition,e.localPosition),o.apply(this,t.chassisBody,t.groundBody),this.equations.push(this.forwardEquation,this.sideEquation),this.setBrakeForce(0)}var r=t("../math/vec2"),o=(t("../utils/Utils"),t("../constraints/Constraint")),a=t("../equations/FrictionEquation"),h=t("../objects/Body");e.exports=s,s.prototype.addToWorld=function(t){this.world=t,t.addBody(this.groundBody),t.on("preStep",this.preStepCallback);for(var e=0;e<this.wheels.length;e++){var i=this.wheels[e];t.addConstraint(i)}},s.prototype.removeFromWorld=function(){var t=this.world;t.removeBody(this.groundBody),t.off("preStep",this.preStepCallback);for(var e=0;e<this.wheels.length;e++){var i=this.wheels[e];t.removeConstraint(i)}this.world=null},s.prototype.addWheel=function(t){var e=new n(this,t);return this.wheels.push(e),e},s.prototype.update=function(){for(var t=0;t<this.wheels.length;t++)this.wheels[t].update()},(n.prototype=new o).setBrakeForce=function(t){this.forwardEquation.setSlipForce(t)},n.prototype.setSideFriction=function(t){this.sideEquation.setSlipForce(t)};var l=r.create(),c=r.create();n.prototype.getSpeed=function(){return this.vehicle.chassisBody.vectorToWorldFrame(c,this.localForwardVector),this.vehicle.chassisBody.getVelocityAtPoint(l,c),r.dot(l,c)};var u=r.create();n.prototype.update=function(){this.vehicle.chassisBody.vectorToWorldFrame(this.forwardEquation.t,this.localForwardVector),r.rotate(this.sideEquation.t,this.localForwardVector,Math.PI/2),this.vehicle.chassisBody.vectorToWorldFrame(this.sideEquation.t,this.sideEquation.t),r.rotate(this.forwardEquation.t,this.forwardEquation.t,this.steerValue),r.rotate(this.sideEquation.t,this.sideEquation.t,this.steerValue),this.vehicle.chassisBody.toWorldFrame(this.forwardEquation.contactPointB,this.localPosition),r.copy(this.sideEquation.contactPointB,this.forwardEquation.contactPointB),this.vehicle.chassisBody.vectorToWorldFrame(this.forwardEquation.contactPointA,this.localPosition),r.copy(this.sideEquation.contactPointA,this.forwardEquation.contactPointA),r.normalize(u,this.forwardEquation.t),r.scale(u,u,this.engineForce),this.vehicle.chassisBody.applyForce(u,this.forwardEquation.contactPointA)}},{"../constraints/Constraint":14,"../equations/FrictionEquation":23,"../math/vec2":30,"../objects/Body":31,"../utils/Utils":57}],36:[function(t,e,i){var s=e.exports={AABB:t("./collision/AABB"),AngleLockEquation:t("./equations/AngleLockEquation"),Body:t("./objects/Body"),Broadphase:t("./collision/Broadphase"),Capsule:t("./shapes/Capsule"),Circle:t("./shapes/Circle"),Constraint:t("./constraints/Constraint"),ContactEquation:t("./equations/ContactEquation"),ContactEquationPool:t("./utils/ContactEquationPool"),ContactMaterial:t("./material/ContactMaterial"),Convex:t("./shapes/Convex"),DistanceConstraint:t("./constraints/DistanceConstraint"),Equation:t("./equations/Equation"),EventEmitter:t("./events/EventEmitter"),FrictionEquation:t("./equations/FrictionEquation"),FrictionEquationPool:t("./utils/FrictionEquationPool"),GearConstraint:t("./constraints/GearConstraint"),GSSolver:t("./solver/GSSolver"),Heightfield:t("./shapes/Heightfield"),Line:t("./shapes/Line"),LockConstraint:t("./constraints/LockConstraint"),Material:t("./material/Material"),Narrowphase:t("./collision/Narrowphase"),NaiveBroadphase:t("./collision/NaiveBroadphase"),Particle:t("./shapes/Particle"),Plane:t("./shapes/Plane"),Pool:t("./utils/Pool"),RevoluteConstraint:t("./constraints/RevoluteConstraint"),PrismaticConstraint:t("./constraints/PrismaticConstraint"),Ray:t("./collision/Ray"),RaycastResult:t("./collision/RaycastResult"),Box:t("./shapes/Box"),RotationalVelocityEquation:t("./equations/RotationalVelocityEquation"),SAPBroadphase:t("./collision/SAPBroadphase"),Shape:t("./shapes/Shape"),Solver:t("./solver/Solver"),Spring:t("./objects/Spring"),TopDownVehicle:t("./objects/TopDownVehicle"),LinearSpring:t("./objects/LinearSpring"),RotationalSpring:t("./objects/RotationalSpring"),Utils:t("./utils/Utils"),World:t("./world/World"),vec2:t("./math/vec2"),version:t("../package.json").version};Object.defineProperty(s,"Rectangle",{get:function(){return console.warn("The Rectangle class has been renamed to Box."),this.Box}})},{"../package.json":6,"./collision/AABB":7,"./collision/Broadphase":8,"./collision/NaiveBroadphase":9,"./collision/Narrowphase":10,"./collision/Ray":11,"./collision/RaycastResult":12,"./collision/SAPBroadphase":13,"./constraints/Constraint":14,"./constraints/DistanceConstraint":15,"./constraints/GearConstraint":16,"./constraints/LockConstraint":17,"./constraints/PrismaticConstraint":18,"./constraints/RevoluteConstraint":19,"./equations/AngleLockEquation":20,"./equations/ContactEquation":21,"./equations/Equation":22,"./equations/FrictionEquation":23,"./equations/RotationalVelocityEquation":25,"./events/EventEmitter":26,"./material/ContactMaterial":27,"./material/Material":28,"./math/vec2":30,"./objects/Body":31,"./objects/LinearSpring":32,"./objects/RotationalSpring":33,"./objects/Spring":34,"./objects/TopDownVehicle":35,"./shapes/Box":37,"./shapes/Capsule":38,"./shapes/Circle":39,"./shapes/Convex":40,"./shapes/Heightfield":41,"./shapes/Line":42,"./shapes/Particle":43,"./shapes/Plane":44,"./shapes/Shape":45,"./solver/GSSolver":46,"./solver/Solver":47,"./utils/ContactEquationPool":48,"./utils/FrictionEquationPool":49,"./utils/Pool":55,"./utils/Utils":57,"./world/World":61}],37:[function(t,e,i){function s(t){"number"==typeof arguments[0]&&"number"==typeof arguments[1]&&(t={width:arguments[0],height:arguments[1]},console.warn("The Rectangle has been renamed to Box and its constructor signature has changed. Please use the following format: new Box({ width: 1, height: 1, ... })")),t=t||{};var e=this.width=t.width||1,i=this.height=t.height||1,s=[n.fromValues(-e/2,-i/2),n.fromValues(e/2,-i/2),n.fromValues(e/2,i/2),n.fromValues(-e/2,i/2)],a=[n.fromValues(1,0),n.fromValues(0,1)];t.vertices=s,t.axes=a,t.type=r.BOX,o.call(this,t)}var n=t("../math/vec2"),r=t("./Shape"),o=t("./Convex");e.exports=s,(s.prototype=new o).constructor=s,s.prototype.computeMomentOfInertia=function(t){var e=this.width,i=this.height;return t*(i*i+e*e)/12},s.prototype.updateBoundingRadius=function(){var t=this.width,e=this.height;this.boundingRadius=Math.sqrt(t*t+e*e)/2};n.create(),n.create(),n.create(),n.create();s.prototype.computeAABB=function(t,e,i){t.setFromPoints(this.vertices,e,i,0)},s.prototype.updateArea=function(){this.area=this.width*this.height}},{"../math/vec2":30,"./Convex":40,"./Shape":45}],38:[function(t,e,i){function s(t){"number"==typeof arguments[0]&&"number"==typeof arguments[1]&&(t={length:arguments[0],radius:arguments[1]},console.warn("The Capsule constructor signature has changed. Please use the following format: new Capsule({ radius: 1, length: 1 })")),t=t||{},this.length=t.length||1,this.radius=t.radius||1,t.type=n.CAPSULE,n.call(this,t)}var n=t("./Shape"),r=t("../math/vec2");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.computeMomentOfInertia=function(t){var e=this.radius,i=this.length+e,s=2*e;return t*(s*s+i*i)/12},s.prototype.updateBoundingRadius=function(){this.boundingRadius=this.radius+this.length/2},s.prototype.updateArea=function(){this.area=Math.PI*this.radius*this.radius+2*this.radius*this.length};var o=r.create();s.prototype.computeAABB=function(t,e,i){var s=this.radius;r.set(o,this.length/2,0),0!==i&&r.rotate(o,o,i),r.set(t.upperBound,Math.max(o[0]+s,-o[0]+s),Math.max(o[1]+s,-o[1]+s)),r.set(t.lowerBound,Math.min(o[0]-s,-o[0]-s),Math.min(o[1]-s,-o[1]-s)),r.add(t.lowerBound,t.lowerBound,e),r.add(t.upperBound,t.upperBound,e)};var a=r.create(),h=r.create(),l=r.create(),c=r.create(),u=r.fromValues(0,1);s.prototype.raycast=function(t,e,i,s){for(var n=e.from,o=e.to,d=(e.direction,a),p=h,f=l,g=c,m=this.length/2,y=0;y<2;y++){var v=this.radius*(2*y-1);if(r.set(f,-m,v),r.set(g,m,v),r.toGlobalFrame(f,f,i,s),r.toGlobalFrame(g,g,i,s),(T=r.getLineSegmentsIntersectionFraction(n,o,f,g))>=0&&(r.rotate(p,u,s),r.scale(p,p,2*y-1),e.reportIntersection(t,T,p,-1),t.shouldStop(e)))return}for(var x=Math.pow(this.radius,2)+Math.pow(m,2),y=0;y<2;y++){r.set(f,m*(2*y-1),0),r.toGlobalFrame(f,f,i,s);var b=Math.pow(o[0]-n[0],2)+Math.pow(o[1]-n[1],2),_=2*((o[0]-n[0])*(n[0]-f[0])+(o[1]-n[1])*(n[1]-f[1])),w=Math.pow(n[0]-f[0],2)+Math.pow(n[1]-f[1],2)-Math.pow(this.radius,2),T=Math.pow(_,2)-4*b*w;if(!(T<0))if(0===T){if(r.lerp(d,n,o,T),r.squaredDistance(d,i)>x&&(r.sub(p,d,f),r.normalize(p,p),e.reportIntersection(t,T,p,-1),t.shouldStop(e)))return}else{var P=Math.sqrt(T),C=1/(2*b),S=(-_-P)*C,A=(-_+P)*C;if(S>=0&&S<=1&&(r.lerp(d,n,o,S),r.squaredDistance(d,i)>x&&(r.sub(p,d,f),r.normalize(p,p),e.reportIntersection(t,S,p,-1),t.shouldStop(e))))return;if(A>=0&&A<=1&&(r.lerp(d,n,o,A),r.squaredDistance(d,i)>x&&(r.sub(p,d,f),r.normalize(p,p),e.reportIntersection(t,A,p,-1),t.shouldStop(e))))return}}}},{"../math/vec2":30,"./Shape":45}],39:[function(t,e,i){function s(t){"number"==typeof arguments[0]&&(t={radius:arguments[0]},console.warn("The Circle constructor signature has changed. Please use the following format: new Circle({ radius: 1 })")),t=t||{},this.radius=t.radius||1,t.type=n.CIRCLE,n.call(this,t)}var n=t("./Shape"),r=t("../math/vec2");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.computeMomentOfInertia=function(t){var e=this.radius;return t*e*e/2},s.prototype.updateBoundingRadius=function(){this.boundingRadius=this.radius},s.prototype.updateArea=function(){this.area=Math.PI*this.radius*this.radius},s.prototype.computeAABB=function(t,e,i){var s=this.radius;r.set(t.upperBound,s,s),r.set(t.lowerBound,-s,-s),e&&(r.add(t.lowerBound,t.lowerBound,e),r.add(t.upperBound,t.upperBound,e))};var o=r.create(),a=r.create();s.prototype.raycast=function(t,e,i,s){var n=e.from,h=e.to,l=this.radius,c=Math.pow(h[0]-n[0],2)+Math.pow(h[1]-n[1],2),u=2*((h[0]-n[0])*(n[0]-i[0])+(h[1]-n[1])*(n[1]-i[1])),d=Math.pow(n[0]-i[0],2)+Math.pow(n[1]-i[1],2)-Math.pow(l,2),p=Math.pow(u,2)-4*c*d,f=o,g=a;if(!(p<0))if(0===p)r.lerp(f,n,h,p),r.sub(g,f,i),r.normalize(g,g),e.reportIntersection(t,p,g,-1);else{var m=Math.sqrt(p),y=1/(2*c),v=(-u-m)*y,x=(-u+m)*y;if(v>=0&&v<=1&&(r.lerp(f,n,h,v),r.sub(g,f,i),r.normalize(g,g),e.reportIntersection(t,v,g,-1),t.shouldStop(e)))return;x>=0&&x<=1&&(r.lerp(f,n,h,x),r.sub(g,f,i),r.normalize(g,g),e.reportIntersection(t,x,g,-1))}}},{"../math/vec2":30,"./Shape":45}],40:[function(t,e,i){function s(t){Array.isArray(arguments[0])&&(t={vertices:arguments[0],axes:arguments[1]},console.warn("The Convex constructor signature has changed. Please use the following format: new Convex({ vertices: [...], ... })")),t=t||{},this.vertices=[];for(var e=void 0!==t.vertices?t.vertices:[],i=0;i<e.length;i++){var s=r.create();r.copy(s,e[i]),this.vertices.push(s)}if(this.axes=[],t.axes)for(i=0;i<t.axes.length;i++){var o=r.create();r.copy(o,t.axes[i]),this.axes.push(o)}else for(i=0;i<this.vertices.length;i++){var a=this.vertices[i],h=this.vertices[(i+1)%this.vertices.length],l=r.create();r.sub(l,h,a),r.rotate90cw(l,l),r.normalize(l,l),this.axes.push(l)}if(this.centerOfMass=r.fromValues(0,0),this.triangles=[],this.vertices.length&&(this.updateTriangles(),this.updateCenterOfMass()),this.boundingRadius=0,t.type=n.CONVEX,n.call(this,t),this.updateBoundingRadius(),this.updateArea(),this.area<0)throw new Error("Convex vertices must be given in conter-clockwise winding.")}var n=t("./Shape"),r=t("../math/vec2"),o=t("../math/polyk");t("poly-decomp");e.exports=s,(s.prototype=new n).constructor=s;var a=r.create(),h=r.create();s.prototype.projectOntoLocalAxis=function(t,e){for(var i,s,n=null,o=null,t=a,h=0;h<this.vertices.length;h++)i=this.vertices[h],s=r.dot(i,t),(null===n||s>n)&&(n=s),(null===o||s<o)&&(o=s);if(o>n){var l=o;o=n,n=l}r.set(e,o,n)},s.prototype.projectOntoWorldAxis=function(t,e,i,s){var n=h;this.projectOntoLocalAxis(t,s),0!==i?r.rotate(n,t,i):n=t;var o=r.dot(e,n);r.set(s,s[0]+o,s[1]+o)},s.prototype.updateTriangles=function(){this.triangles.length=0;for(var t=[],e=0;e<this.vertices.length;e++){var i=this.vertices[e];t.push(i[0],i[1])}for(var s=o.Triangulate(t),e=0;e<s.length;e+=3){var n=s[e],r=s[e+1],a=s[e+2];this.triangles.push([n,r,a])}};var l=r.create(),c=r.create(),u=r.create(),d=r.create(),p=r.create();r.create(),r.create(),r.create(),r.create();s.prototype.updateCenterOfMass=function(){var t=this.triangles,e=this.vertices,i=this.centerOfMass,n=l,o=u,a=d,h=p,f=c;r.set(i,0,0);for(var g=0,m=0;m!==t.length;m++){var y=t[m],o=e[y[0]],a=e[y[1]],h=e[y[2]];r.centroid(n,o,a,h);var v=s.triangleArea(o,a,h);g+=v,r.scale(f,n,v),r.add(i,i,f)}r.scale(i,i,1/g)},s.prototype.computeMomentOfInertia=function(t){for(var e=0,i=0,s=this.vertices.length,n=s-1,o=0;o<s;n=o,o++){var a=this.vertices[n],h=this.vertices[o],l=Math.abs(r.crossLength(a,h));e+=l*(r.dot(h,h)+r.dot(h,a)+r.dot(a,a)),i+=l}return t/6*(e/i)},s.prototype.updateBoundingRadius=function(){for(var t=this.vertices,e=0,i=0;i!==t.length;i++){var s=r.squaredLength(t[i]);s>e&&(e=s)}this.boundingRadius=Math.sqrt(e)},s.triangleArea=function(t,e,i){return.5*((e[0]-t[0])*(i[1]-t[1])-(i[0]-t[0])*(e[1]-t[1]))},s.prototype.updateArea=function(){this.updateTriangles(),this.area=0;for(var t=this.triangles,e=this.vertices,i=0;i!==t.length;i++){var n=t[i],r=e[n[0]],o=e[n[1]],a=e[n[2]],h=s.triangleArea(r,o,a);this.area+=h}},s.prototype.computeAABB=function(t,e,i){t.setFromPoints(this.vertices,e,i,0)};var f=r.create(),g=r.create(),m=r.create();s.prototype.raycast=function(t,e,i,s){var n=f,o=g,a=m,h=this.vertices;r.toLocalFrame(n,e.from,i,s),r.toLocalFrame(o,e.to,i,s);for(var l=h.length,c=0;c<l&&!t.shouldStop(e);c++){var u=h[c],d=h[(c+1)%l],p=r.getLineSegmentsIntersectionFraction(n,o,u,d);p>=0&&(r.sub(a,d,u),r.rotate(a,a,-Math.PI/2+s),r.normalize(a,a),e.reportIntersection(t,p,a,c))}}},{"../math/polyk":29,"../math/vec2":30,"./Shape":45,"poly-decomp":5}],41:[function(t,e,i){function s(t){if(Array.isArray(arguments[0])){if(t={heights:arguments[0]},"object"==typeof arguments[1])for(var e in arguments[1])t[e]=arguments[1][e];console.warn("The Heightfield constructor signature has changed. Please use the following format: new Heightfield({ heights: [...], ... })")}t=t||{},this.heights=t.heights?t.heights.slice(0):[],this.maxValue=t.maxValue||null,this.minValue=t.minValue||null,this.elementWidth=t.elementWidth||.1,void 0!==t.maxValue&&void 0!==t.minValue||this.updateMaxMinValues(),t.type=n.HEIGHTFIELD,n.call(this,t)}var n=t("./Shape"),r=t("../math/vec2");t("../utils/Utils");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.updateMaxMinValues=function(){for(var t=this.heights,e=t[0],i=t[0],s=0;s!==t.length;s++){var n=t[s];n>e&&(e=n),n<i&&(i=n)}this.maxValue=e,this.minValue=i},s.prototype.computeMomentOfInertia=function(t){return Number.MAX_VALUE},s.prototype.updateBoundingRadius=function(){this.boundingRadius=Number.MAX_VALUE},s.prototype.updateArea=function(){for(var t=this.heights,e=0,i=0;i<t.length-1;i++)e+=(t[i]+t[i+1])/2*this.elementWidth;this.area=e};var o=[r.create(),r.create(),r.create(),r.create()];s.prototype.computeAABB=function(t,e,i){r.set(o[0],0,this.maxValue),r.set(o[1],this.elementWidth*this.heights.length,this.maxValue),r.set(o[2],this.elementWidth*this.heights.length,this.minValue),r.set(o[3],0,this.minValue),t.setFromPoints(o,e,i)},s.prototype.getLineSegment=function(t,e,i){var s=this.heights,n=this.elementWidth;r.set(t,i*n,s[i]),r.set(e,(i+1)*n,s[i+1])},s.prototype.getSegmentIndex=function(t){return Math.floor(t[0]/this.elementWidth)},s.prototype.getClampedSegmentIndex=function(t){var e=this.getSegmentIndex(t);return e=Math.min(this.heights.length,Math.max(e,0))};r.create();var a=r.create(),h=r.create(),l=r.create(),c=r.create(),u=r.create();r.fromValues(0,1);s.prototype.raycast=function(t,e,i,s){var n=e.from,o=e.to,d=(e.direction,a),p=h,f=l,g=c,m=u;r.toLocalFrame(g,n,i,s),r.toLocalFrame(m,o,i,s);var y=this.getClampedSegmentIndex(g),v=this.getClampedSegmentIndex(m);if(y>v){var x=y;y=v,v=x}for(var b=0;b<this.heights.length-1;b++){this.getLineSegment(p,f,b);var _=r.getLineSegmentsIntersectionFraction(g,m,p,f);if(_>=0&&(r.sub(d,f,p),r.rotate(d,d,s+Math.PI/2),r.normalize(d,d),e.reportIntersection(t,_,d,-1),t.shouldStop(e)))return}}},{"../math/vec2":30,"../utils/Utils":57,"./Shape":45}],42:[function(t,e,i){function s(t){"number"==typeof arguments[0]&&(t={length:arguments[0]},console.warn("The Line constructor signature has changed. Please use the following format: new Line({ length: 1, ... })")),t=t||{},this.length=t.length||1,t.type=n.LINE,n.call(this,t)}var n=t("./Shape"),r=t("../math/vec2");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.computeMomentOfInertia=function(t){return t*Math.pow(this.length,2)/12},s.prototype.updateBoundingRadius=function(){this.boundingRadius=this.length/2};var o=[r.create(),r.create()];s.prototype.computeAABB=function(t,e,i){var s=this.length/2;r.set(o[0],-s,0),r.set(o[1],s,0),t.setFromPoints(o,e,i,0)};r.create();var a=r.create(),h=r.create(),l=r.create(),c=r.fromValues(0,1);s.prototype.raycast=function(t,e,i,s){var n=e.from,o=e.to,u=h,d=l,p=this.length/2;r.set(u,-p,0),r.set(d,p,0),r.toGlobalFrame(u,u,i,s),r.toGlobalFrame(d,d,i,s);var f=r.getLineSegmentsIntersectionFraction(u,d,n,o);if(f>=0){var g=a;r.rotate(g,c,s),e.reportIntersection(t,f,g,-1)}}},{"../math/vec2":30,"./Shape":45}],43:[function(t,e,i){function s(t){(t=t||{}).type=n.PARTICLE,n.call(this,t)}var n=t("./Shape"),r=t("../math/vec2");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.computeMomentOfInertia=function(t){return 0},s.prototype.updateBoundingRadius=function(){this.boundingRadius=0},s.prototype.computeAABB=function(t,e,i){r.copy(t.lowerBound,e),r.copy(t.upperBound,e)}},{"../math/vec2":30,"./Shape":45}],44:[function(t,e,i){function s(t){(t=t||{}).type=n.PLANE,n.call(this,t)}var n=t("./Shape"),r=t("../math/vec2");t("../utils/Utils");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.computeMomentOfInertia=function(t){return 0},s.prototype.updateBoundingRadius=function(){this.boundingRadius=Number.MAX_VALUE},s.prototype.computeAABB=function(t,e,i){var s=i%(2*Math.PI),n=r.set,o=t.lowerBound,a=t.upperBound;n(o,-1e7,-1e7),n(a,1e7,1e7),0===s?a[1]=0:s===Math.PI/2?o[0]=0:s===Math.PI?o[1]=0:s===3*Math.PI/2&&(a[0]=0)},s.prototype.updateArea=function(){this.area=Number.MAX_VALUE};var o=r.create(),a=(r.create(),r.create(),r.create()),h=r.create();s.prototype.raycast=function(t,e,i,s){var n=e.from,l=e.to,c=e.direction,u=o,d=a,p=h;r.set(d,0,1),r.rotate(d,d,s),r.sub(p,n,i);var f=r.dot(p,d);if(r.sub(p,l,i),!(f*r.dot(p,d)>0||r.squaredDistance(n,l)<f*f)){var g=r.dot(d,c);r.sub(u,n,i);var m=-r.dot(d,u)/g/e.length;e.reportIntersection(t,m,d,-1)}}},{"../math/vec2":30,"../utils/Utils":57,"./Shape":45}],45:[function(t,e,i){function s(t){t=t||{},this.body=null,this.position=n.fromValues(0,0),t.position&&n.copy(this.position,t.position),this.angle=t.angle||0,this.type=t.type||0,this.id=s.idCounter++,this.boundingRadius=0,this.collisionGroup=void 0!==t.collisionGroup?t.collisionGroup:1,this.collisionResponse=void 0===t.collisionResponse||t.collisionResponse,this.collisionMask=void 0!==t.collisionMask?t.collisionMask:1,this.material=t.material||null,this.area=0,this.sensor=void 0!==t.sensor&&t.sensor,this.type&&this.updateBoundingRadius(),this.updateArea()}e.exports=s;var n=t("../math/vec2");s.idCounter=0,s.CIRCLE=1,s.PARTICLE=2,s.PLANE=4,s.CONVEX=8,s.LINE=16,s.BOX=32,s.CAPSULE=64,s.HEIGHTFIELD=128,s.prototype.computeMomentOfInertia=function(t){},s.prototype.updateBoundingRadius=function(){},s.prototype.updateArea=function(){},s.prototype.computeAABB=function(t,e,i){},s.prototype.raycast=function(t,e,i,s){}},{"../math/vec2":30}],46:[function(t,e,i){function s(t){o.call(this,t,o.GS),t=t||{},this.iterations=t.iterations||10,this.tolerance=t.tolerance||1e-7,this.arrayStep=30,this.lambda=new a.ARRAY_TYPE(this.arrayStep),this.Bs=new a.ARRAY_TYPE(this.arrayStep),this.invCs=new a.ARRAY_TYPE(this.arrayStep),this.useZeroRHS=!1,this.frictionIterations=void 0!==t.frictionIterations?0:t.frictionIterations,this.usedIterations=0}function n(t){for(var e=t.length;e--;)t[e]=0}var r=t("../math/vec2"),o=t("./Solver"),a=t("../utils/Utils"),h=t("../equations/FrictionEquation");e.exports=s,(s.prototype=new o).constructor=s,s.prototype.solve=function(t,e){this.sortEquations();var i=0,o=this.iterations,l=this.frictionIterations,c=this.equations,u=c.length,d=Math.pow(this.tolerance*u,2),p=e.bodies,f=e.bodies.length,g=(r.add,r.set,this.useZeroRHS),m=this.lambda;if(this.usedIterations=0,u)for(x=0;x!==f;x++)(T=p[x]).updateSolveMassProperties();m.length<u&&(m=this.lambda=new a.ARRAY_TYPE(u+this.arrayStep),this.Bs=new a.ARRAY_TYPE(u+this.arrayStep),this.invCs=new a.ARRAY_TYPE(u+this.arrayStep)),n(m);for(var y=this.invCs,v=this.Bs,m=this.lambda,x=0;x!==c.length;x++)((b=c[x]).timeStep!==t||b.needsUpdate)&&(b.timeStep=t,b.update()),v[x]=b.computeB(b.a,b.b,t),y[x]=b.computeInvC(b.epsilon);var b,_,w;if(0!==u){for(x=0;x!==f;x++){var T=p[x];T.resetConstraintVelocity()}if(l){for(i=0;i!==l;i++){for(_=0,w=0;w!==u;w++){b=c[w];A=s.iterateEquation(w,b,b.epsilon,v,y,m,g,t,i);_+=Math.abs(A)}if(this.usedIterations++,_*_<=d)break}for(s.updateMultipliers(c,m,1/t),w=0;w!==u;w++){var P=c[w];if(P instanceof h){for(var C=0,S=0;S!==P.contactEquations.length;S++)C+=P.contactEquations[S].multiplier;C*=P.frictionCoefficient/P.contactEquations.length,P.maxForce=C,P.minForce=-C}}}for(i=0;i!==o;i++){for(_=0,w=0;w!==u;w++){b=c[w];var A=s.iterateEquation(w,b,b.epsilon,v,y,m,g,t,i);_+=Math.abs(A)}if(this.usedIterations++,_*_<=d)break}for(x=0;x!==f;x++)p[x].addConstraintVelocity();s.updateMultipliers(c,m,1/t)}},s.updateMultipliers=function(t,e,i){for(var s=t.length;s--;)t[s].multiplier=e[s]*i},s.iterateEquation=function(t,e,i,s,n,r,o,a,h){var l=s[t],c=n[t],u=r[t],d=e.computeGWlambda(),p=e.maxForce,f=e.minForce;o&&(l=0);var g=c*(l-d-i*u),m=u+g;return m<f*a?g=f*a-u:m>p*a&&(g=p*a-u),r[t]+=g,e.addToWlambda(g),g}},{"../equations/FrictionEquation":23,"../math/vec2":30,"../utils/Utils":57,"./Solver":47}],47:[function(t,e,i){function s(t,e){t=t||{},n.call(this),this.type=e,this.equations=[],this.equationSortFunction=t.equationSortFunction||!1}t("../utils/Utils");var n=t("../events/EventEmitter");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.solve=function(t,e){throw new Error("Solver.solve should be implemented by subclasses!")};var r={bodies:[]};s.prototype.solveIsland=function(t,e){this.removeAllEquations(),e.equations.length&&(this.addEquations(e.equations),r.bodies.length=0,e.getBodies(r.bodies),r.bodies.length&&this.solve(t,r))},s.prototype.sortEquations=function(){this.equationSortFunction&&this.equations.sort(this.equationSortFunction)},s.prototype.addEquation=function(t){t.enabled&&this.equations.push(t)},s.prototype.addEquations=function(t){for(var e=0,i=t.length;e!==i;e++){var s=t[e];s.enabled&&this.equations.push(s)}},s.prototype.removeEquation=function(t){var e=this.equations.indexOf(t);-1!==e&&this.equations.splice(e,1)},s.prototype.removeAllEquations=function(){this.equations.length=0},s.GS=1,s.ISLAND=2},{"../events/EventEmitter":26,"../utils/Utils":57}],48:[function(t,e,i){function s(){r.apply(this,arguments)}var n=t("../equations/ContactEquation"),r=t("./Pool");e.exports=s,(s.prototype=new r).constructor=s,s.prototype.create=function(){return new n},s.prototype.destroy=function(t){return t.bodyA=t.bodyB=null,this}},{"../equations/ContactEquation":21,"./Pool":55}],49:[function(t,e,i){function s(){r.apply(this,arguments)}var n=t("../equations/FrictionEquation"),r=t("./Pool");e.exports=s,(s.prototype=new r).constructor=s,s.prototype.create=function(){return new n},s.prototype.destroy=function(t){return t.bodyA=t.bodyB=null,this}},{"../equations/FrictionEquation":23,"./Pool":55}],50:[function(t,e,i){function s(){r.apply(this,arguments)}var n=t("../world/IslandNode"),r=t("./Pool");e.exports=s,(s.prototype=new r).constructor=s,s.prototype.create=function(){return new n},s.prototype.destroy=function(t){return t.reset(),this}},{"../world/IslandNode":60,"./Pool":55}],51:[function(t,e,i){function s(){r.apply(this,arguments)}var n=t("../world/Island"),r=t("./Pool");e.exports=s,(s.prototype=new r).constructor=s,s.prototype.create=function(){return new n},s.prototype.destroy=function(t){return t.reset(),this}},{"../world/Island":58,"./Pool":55}],52:[function(t,e,i){function s(){this.overlappingShapesLastState=new n,this.overlappingShapesCurrentState=new n,this.recordPool=new r({size:16}),this.tmpDict=new n,this.tmpArray1=[]}var n=t("./TupleDictionary"),r=(t("./OverlapKeeperRecord"),t("./OverlapKeeperRecordPool"));t("./Utils");e.exports=s,s.prototype.tick=function(){for(var t=this.overlappingShapesLastState,e=this.overlappingShapesCurrentState,i=t.keys.length;i--;){var s=t.keys[i],n=t.getByKey(s);e.getByKey(s);n&&this.recordPool.release(n)}t.reset(),t.copy(e),e.reset()},s.prototype.setOverlapping=function(t,e,i,s){this.overlappingShapesLastState;var n=this.overlappingShapesCurrentState;if(!n.get(e.id,s.id)){var r=this.recordPool.get();r.set(t,e,i,s),n.set(e.id,s.id,r)}},s.prototype.getNewOverlaps=function(t){return this.getDiff(this.overlappingShapesLastState,this.overlappingShapesCurrentState,t)},s.prototype.getEndOverlaps=function(t){return this.getDiff(this.overlappingShapesCurrentState,this.overlappingShapesLastState,t)},s.prototype.bodiesAreOverlapping=function(t,e){for(var i=this.overlappingShapesCurrentState,s=i.keys.length;s--;){var n=i.keys[s],r=i.data[n];if(r.bodyA===t&&r.bodyB===e||r.bodyA===e&&r.bodyB===t)return!0}return!1},s.prototype.getDiff=function(t,e,i){var s=t,n=e;(i=i||[]).length=0;for(var r=n.keys.length;r--;){var o=n.keys[r],a=n.data[o];if(!a)throw new Error("Key "+o+" had no data!");s.data[o]||i.push(a)}return i},s.prototype.isNewOverlap=function(t,e){var i=0|t.id,s=0|e.id,n=this.overlappingShapesLastState,r=this.overlappingShapesCurrentState;return!n.get(i,s)&&!!r.get(i,s)},s.prototype.getNewBodyOverlaps=function(t){this.tmpArray1.length=0;var e=this.getNewOverlaps(this.tmpArray1);return this.getBodyDiff(e,t)},s.prototype.getEndBodyOverlaps=function(t){this.tmpArray1.length=0;var e=this.getEndOverlaps(this.tmpArray1);return this.getBodyDiff(e,t)},s.prototype.getBodyDiff=function(t,e){e=e||[];for(var i=this.tmpDict,s=t.length;s--;){var n=t[s];i.set(0|n.bodyA.id,0|n.bodyB.id,n)}for(s=i.keys.length;s--;)(n=i.getByKey(i.keys[s]))&&e.push(n.bodyA,n.bodyB);return i.reset(),e}},{"./OverlapKeeperRecord":53,"./OverlapKeeperRecordPool":54,"./TupleDictionary":56,"./Utils":57}],53:[function(t,e,i){function s(t,e,i,s){this.shapeA=e,this.shapeB=s,this.bodyA=t,this.bodyB=i}e.exports=s,s.prototype.set=function(t,e,i,n){s.call(this,t,e,i,n)}},{}],54:[function(t,e,i){function s(){r.apply(this,arguments)}var n=t("./OverlapKeeperRecord"),r=t("./Pool");e.exports=s,(s.prototype=new r).constructor=s,s.prototype.create=function(){return new n},s.prototype.destroy=function(t){return t.bodyA=t.bodyB=t.shapeA=t.shapeB=null,this}},{"./OverlapKeeperRecord":53,"./Pool":55}],55:[function(t,e,i){function s(t){t=t||{},this.objects=[],void 0!==t.size&&this.resize(t.size)}e.exports=s,s.prototype.resize=function(t){for(var e=this.objects;e.length>t;)e.pop();for(;e.length<t;)e.push(this.create());return this},s.prototype.get=function(){var t=this.objects;return t.length?t.pop():this.create()},s.prototype.release=function(t){return this.destroy(t),this.objects.push(t),this}},{}],56:[function(t,e,i){function s(){this.data={},this.keys=[]}var n=t("./Utils");e.exports=s,s.prototype.getKey=function(t,e){return t|=0,e|=0,(0|t)==(0|e)?-1:0|((0|t)>(0|e)?t<<16|65535&e:e<<16|65535&t)},s.prototype.getByKey=function(t){return t|=0,this.data[t]},s.prototype.get=function(t,e){return this.data[this.getKey(t,e)]},s.prototype.set=function(t,e,i){if(!i)throw new Error("No data!");var s=this.getKey(t,e);return this.data[s]||this.keys.push(s),this.data[s]=i,s},s.prototype.reset=function(){for(var t=this.data,e=this.keys,i=e.length;i--;)delete t[e[i]];e.length=0},s.prototype.copy=function(t){this.reset(),n.appendArray(this.keys,t.keys);for(var e=t.keys.length;e--;){var i=t.keys[e];this.data[i]=t.data[i]}}},{"./Utils":57}],57:[function(t,e,i){function s(){}e.exports=s,s.appendArray=function(t,e){if(e.length<15e4)t.push.apply(t,e);else for(var i=0,s=e.length;i!==s;++i)t.push(e[i])},s.splice=function(t,e,i){i=i||1;for(var s=e,n=t.length-i;s<n;s++)t[s]=t[s+i];t.length=n},s.ARRAY_TYPE="undefined"!=typeof P2_ARRAY_TYPE?P2_ARRAY_TYPE:"undefined"!=typeof Float32Array?Float32Array:Array,s.extend=function(t,e){for(var i in e)t[i]=e[i]},s.defaults=function(t,e){t=t||{};for(var i in e)i in t||(t[i]=e[i]);return t}},{}],58:[function(t,e,i){function s(){this.equations=[],this.bodies=[]}var n=t("../objects/Body");e.exports=s,s.prototype.reset=function(){this.equations.length=this.bodies.length=0};var r=[];s.prototype.getBodies=function(t){var e=t||[],i=this.equations;r.length=0;for(var s=0;s!==i.length;s++){var n=i[s];-1===r.indexOf(n.bodyA.id)&&(e.push(n.bodyA),r.push(n.bodyA.id)),-1===r.indexOf(n.bodyB.id)&&(e.push(n.bodyB),r.push(n.bodyB.id))}return e},s.prototype.wantsToSleep=function(){for(var t=0;t<this.bodies.length;t++){var e=this.bodies[t];if(e.type===n.DYNAMIC&&!e.wantsToSleep)return!1}return!0},s.prototype.sleep=function(){for(var t=0;t<this.bodies.length;t++)this.bodies[t].sleep();return!0}},{"../objects/Body":31}],59:[function(t,e,i){function s(t){this.nodePool=new n({size:16}),this.islandPool=new r({size:8}),this.equations=[],this.islands=[],this.nodes=[],this.queue=[]}t("../math/vec2"),t("./Island"),t("./IslandNode");var n=t("./../utils/IslandNodePool"),r=t("./../utils/IslandPool"),o=t("../objects/Body");e.exports=s,s.getUnvisitedNode=function(t){for(var e=t.length,i=0;i!==e;i++){var s=t[i];if(!s.visited&&s.body.type===o.DYNAMIC)return s}return!1},s.prototype.visit=function(t,e,i){e.push(t.body);for(var s=t.equations.length,n=0;n!==s;n++){var r=t.equations[n];-1===i.indexOf(r)&&i.push(r)}},s.prototype.bfs=function(t,e,i){var n=this.queue;for(n.length=0,n.push(t),t.visited=!0,this.visit(t,e,i);n.length;)for(var r,a=n.pop();r=s.getUnvisitedNode(a.neighbors);)r.visited=!0,this.visit(r,e,i),r.body.type===o.DYNAMIC&&n.push(r)},s.prototype.split=function(t){for(var e=t.bodies,i=this.nodes,n=this.equations;i.length;)this.nodePool.release(i.pop());for(h=0;h!==e.length;h++){var r=this.nodePool.get();r.body=e[h],i.push(r)}for(var o=0;o!==n.length;o++){var a=n[o],h=e.indexOf(a.bodyA),l=e.indexOf(a.bodyB),c=i[h],u=i[l];c.neighbors.push(u),u.neighbors.push(c),c.equations.push(a),u.equations.push(a)}for(var d=this.islands,h=0;h<d.length;h++)this.islandPool.release(d[h]);d.length=0;for(var p;p=s.getUnvisitedNode(i);){var f=this.islandPool.get();this.bfs(p,f.bodies,f.equations),d.push(f)}return d}},{"../math/vec2":30,"../objects/Body":31,"./../utils/IslandNodePool":50,"./../utils/IslandPool":51,"./Island":58,"./IslandNode":60}],60:[function(t,e,i){function s(t){this.body=t,this.neighbors=[],this.equations=[],this.visited=!1}e.exports=s,s.prototype.reset=function(){this.equations.length=0,this.neighbors.length=0,this.visited=!1,this.body=null}},{}],61:[function(t,e,i){function s(t){u.apply(this),t=t||{},this.springs=[],this.bodies=[],this.disabledBodyCollisionPairs=[],this.solver=t.solver||new n,this.narrowphase=new y(this),this.islandManager=new b,this.gravity=r.fromValues(0,-9.78),t.gravity&&r.copy(this.gravity,t.gravity),this.frictionGravity=r.length(this.gravity)||10,this.useWorldGravityAsFrictionGravity=!0,this.useFrictionGravityOnZeroGravity=!0,this.broadphase=t.broadphase||new m,this.broadphase.setWorld(this),this.constraints=[],this.defaultMaterial=new p,this.defaultContactMaterial=new f(this.defaultMaterial,this.defaultMaterial),this.lastTimeStep=1/60,this.applySpringForces=!0,this.applyDamping=!0,this.applyGravity=!0,this.solveConstraints=!0,this.contactMaterials=[],this.time=0,this.accumulator=0,this.stepping=!1,this.bodiesToBeRemoved=[],this.islandSplit=void 0===t.islandSplit||!!t.islandSplit,this.emitImpactEvent=!0,this._constraintIdCounter=0,this._bodyIdCounter=0,this.postStepEvent={type:"postStep"},this.addBodyEvent={type:"addBody",body:null},this.removeBodyEvent={type:"removeBody",body:null},this.addSpringEvent={type:"addSpring",spring:null},this.impactEvent={type:"impact",bodyA:null,bodyB:null,shapeA:null,shapeB:null,contactEquation:null},this.postBroadphaseEvent={type:"postBroadphase",pairs:null},this.sleepMode=s.NO_SLEEPING,this.beginContactEvent={type:"beginContact",shapeA:null,shapeB:null,bodyA:null,bodyB:null,contactEquations:[]},this.endContactEvent={type:"endContact",shapeA:null,shapeB:null,bodyA:null,bodyB:null},this.preSolveEvent={type:"preSolve",contactEquations:null,frictionEquations:null},this.overlappingShapesLastState={keys:[]},this.overlappingShapesCurrentState={keys:[]},this.overlapKeeper=new x}var n=t("../solver/GSSolver"),r=(t("../solver/Solver"),t("../collision/Ray"),t("../math/vec2")),o=t("../shapes/Circle"),a=t("../shapes/Convex"),h=(t("../shapes/Line"),t("../shapes/Plane")),l=t("../shapes/Capsule"),c=t("../shapes/Particle"),u=t("../events/EventEmitter"),d=t("../objects/Body"),p=(t("../shapes/Shape"),t("../objects/LinearSpring"),t("../material/Material")),f=t("../material/ContactMaterial"),g=(t("../constraints/DistanceConstraint"),t("../constraints/Constraint"),t("../constraints/LockConstraint"),t("../constraints/RevoluteConstraint"),t("../constraints/PrismaticConstraint"),t("../constraints/GearConstraint"),t("../../package.json"),t("../collision/Broadphase"),t("../collision/AABB")),m=t("../collision/SAPBroadphase"),y=t("../collision/Narrowphase"),v=t("../utils/Utils"),x=t("../utils/OverlapKeeper"),b=t("./IslandManager");t("../objects/RotationalSpring");e.exports=s,s.prototype=new Object(u.prototype),s.prototype.constructor=s,s.NO_SLEEPING=1,s.BODY_SLEEPING=2,s.ISLAND_SLEEPING=4,s.prototype.addConstraint=function(t){this.constraints.push(t)},s.prototype.addContactMaterial=function(t){this.contactMaterials.push(t)},s.prototype.removeContactMaterial=function(t){var e=this.contactMaterials.indexOf(t);-1!==e&&v.splice(this.contactMaterials,e,1)},s.prototype.getContactMaterial=function(t,e){for(var i=this.contactMaterials,s=0,n=i.length;s!==n;s++){var r=i[s];if(r.materialA.id===t.id&&r.materialB.id===e.id||r.materialA.id===e.id&&r.materialB.id===t.id)return r}return!1},s.prototype.removeConstraint=function(t){var e=this.constraints.indexOf(t);-1!==e&&v.splice(this.constraints,e,1)};r.create(),r.create(),r.create(),r.create(),r.create(),r.create();var _=r.create(),w=r.fromValues(0,0),T=r.fromValues(0,0);r.fromValues(0,0),r.fromValues(0,0);s.prototype.step=function(t,e,i){if(i=i||10,0===(e=e||0))this.internalStep(t),this.time+=t;else{this.accumulator+=e;for(var s=0;this.accumulator>=t&&s<i;)this.internalStep(t),this.time+=t,this.accumulator-=t,s++;for(var n=this.accumulator%t/t,o=0;o!==this.bodies.length;o++){var a=this.bodies[o];r.lerp(a.interpolatedPosition,a.previousPosition,a.position,n),a.interpolatedAngle=a.previousAngle+n*(a.angle-a.previousAngle)}}};var P=[];s.prototype.internalStep=function(t){this.stepping=!0;var e=this.springs.length,i=this.springs,n=this.bodies,o=this.gravity,a=this.solver,h=this.bodies.length,l=this.broadphase,c=this.narrowphase,u=this.constraints,p=_,f=(r.scale,r.add),g=(r.rotate,this.islandManager);if(this.overlapKeeper.tick(),this.lastTimeStep=t,this.useWorldGravityAsFrictionGravity){var m=r.length(this.gravity);0===m&&this.useFrictionGravityOnZeroGravity||(this.frictionGravity=m)}if(this.applyGravity)for(T=0;T!==h;T++){var y=(x=n[T]).force;x.type===d.DYNAMIC&&x.sleepState!==d.SLEEPING&&(r.scale(p,o,x.mass*x.gravityScale),f(y,y,p))}if(this.applySpringForces)for(T=0;T!==e;T++)i[T].applyForce();if(this.applyDamping)for(T=0;T!==h;T++){var x=n[T];x.type===d.DYNAMIC&&x.applyDamping(t)}for(var b=l.getCollisionPairs(this),w=this.disabledBodyCollisionPairs,T=w.length-2;T>=0;T-=2)for(S=b.length-2;S>=0;S-=2)(w[T]===b[S]&&w[T+1]===b[S+1]||w[T+1]===b[S]&&w[T]===b[S+1])&&b.splice(S,2);H=u.length;for(T=0;T!==H;T++){var C=u[T];if(!C.collideConnected)for(var S=b.length-2;S>=0;S-=2)(C.bodyA===b[S]&&C.bodyB===b[S+1]||C.bodyB===b[S]&&C.bodyA===b[S+1])&&b.splice(S,2)}this.postBroadphaseEvent.pairs=b,this.emit(this.postBroadphaseEvent),this.postBroadphaseEvent.pairs=null,c.reset(this);for(var T=0,A=b.length;T!==A;T+=2)for(var E=b[T],M=b[T+1],R=0,L=E.shapes.length;R!==L;R++)for(var B=E.shapes[R],I=B.position,O=B.angle,k=0,F=M.shapes.length;k!==F;k++){var D=M.shapes[k],U=D.position,G=D.angle,N=this.defaultContactMaterial;if(B.material&&D.material){var X=this.getContactMaterial(B.material,D.material);X&&(N=X)}this.runNarrowphase(c,E,B,I,O,M,D,U,G,N,this.frictionGravity)}for(T=0;T!==h;T++)(q=n[T])._wakeUpAfterNarrowphase&&(q.wakeUp(),q._wakeUpAfterNarrowphase=!1);if(this.has("endContact")){this.overlapKeeper.getEndOverlaps(P);for(var W=this.endContactEvent,k=P.length;k--;){var j=P[k];W.shapeA=j.shapeA,W.shapeB=j.shapeB,W.bodyA=j.bodyA,W.bodyB=j.bodyB,this.emit(W)}P.length=0}var V=this.preSolveEvent;V.contactEquations=c.contactEquations,V.frictionEquations=c.frictionEquations,this.emit(V),V.contactEquations=V.frictionEquations=null;var H=u.length;for(T=0;T!==H;T++)u[T].update();if(c.contactEquations.length||c.frictionEquations.length||H)if(this.islandSplit){for(g.equations.length=0,v.appendArray(g.equations,c.contactEquations),v.appendArray(g.equations,c.frictionEquations),T=0;T!==H;T++)v.appendArray(g.equations,u[T].equations);g.split(this);for(T=0;T!==g.islands.length;T++)(K=g.islands[T]).equations.length&&a.solveIsland(t,K)}else{for(a.addEquations(c.contactEquations),a.addEquations(c.frictionEquations),T=0;T!==H;T++)a.addEquations(u[T].equations);this.solveConstraints&&a.solve(t,this),a.removeAllEquations()}for(T=0;T!==h;T++){var q=n[T];q.integrate(t)}for(T=0;T!==h;T++)n[T].setZeroForce();if(this.emitImpactEvent&&this.has("impact"))for(var Y=this.impactEvent,T=0;T!==c.contactEquations.length;T++){var z=c.contactEquations[T];z.firstImpact&&(Y.bodyA=z.bodyA,Y.bodyB=z.bodyB,Y.shapeA=z.shapeA,Y.shapeB=z.shapeB,Y.contactEquation=z,this.emit(Y))}if(this.sleepMode===s.BODY_SLEEPING)for(T=0;T!==h;T++)n[T].sleepTick(this.time,!1,t);else if(this.sleepMode===s.ISLAND_SLEEPING&&this.islandSplit){for(T=0;T!==h;T++)n[T].sleepTick(this.time,!0,t);for(T=0;T<this.islandManager.islands.length;T++){var K=this.islandManager.islands[T];K.wantsToSleep()&&K.sleep()}}this.stepping=!1;for(var J=this.bodiesToBeRemoved,T=0;T!==J.length;T++)this.removeBody(J[T]);J.length=0,this.emit(this.postStepEvent)},s.prototype.runNarrowphase=function(t,e,i,s,n,o,a,h,l,c,u){if(0!=(i.collisionGroup&a.collisionMask)&&0!=(a.collisionGroup&i.collisionMask)){r.rotate(w,s,e.angle),r.rotate(T,h,o.angle),r.add(w,w,e.position),r.add(T,T,o.position);var p=n+e.angle,f=l+o.angle;t.enableFriction=c.friction>0,t.frictionCoefficient=c.friction;var g;g=e.type===d.STATIC||e.type===d.KINEMATIC?o.mass:o.type===d.STATIC||o.type===d.KINEMATIC?e.mass:e.mass*o.mass/(e.mass+o.mass),t.slipForce=c.friction*u*g,t.restitution=c.restitution,t.surfaceVelocity=c.surfaceVelocity,t.frictionStiffness=c.frictionStiffness,t.frictionRelaxation=c.frictionRelaxation,t.stiffness=c.stiffness,t.relaxation=c.relaxation,t.contactSkinSize=c.contactSkinSize,t.enabledEquations=e.collisionResponse&&o.collisionResponse&&i.collisionResponse&&a.collisionResponse;var m=t[i.type|a.type],y=0;if(m){var v=i.sensor||a.sensor,x=t.frictionEquations.length;y=i.type<a.type?m.call(t,e,i,w,p,o,a,T,f,v):m.call(t,o,a,T,f,e,i,w,p,v);var b=t.frictionEquations.length-x;if(y){if(e.allowSleep&&e.type===d.DYNAMIC&&e.sleepState===d.SLEEPING&&o.sleepState===d.AWAKE&&o.type!==d.STATIC&&r.squaredLength(o.velocity)+Math.pow(o.angularVelocity,2)>=2*Math.pow(o.sleepSpeedLimit,2)&&(e._wakeUpAfterNarrowphase=!0),o.allowSleep&&o.type===d.DYNAMIC&&o.sleepState===d.SLEEPING&&e.sleepState===d.AWAKE&&e.type!==d.STATIC&&r.squaredLength(e.velocity)+Math.pow(e.angularVelocity,2)>=2*Math.pow(e.sleepSpeedLimit,2)&&(o._wakeUpAfterNarrowphase=!0),this.overlapKeeper.setOverlapping(e,i,o,a),this.has("beginContact")&&this.overlapKeeper.isNewOverlap(i,a)){var _=this.beginContactEvent;if(_.shapeA=i,_.shapeB=a,_.bodyA=e,_.bodyB=o,_.contactEquations.length=0,"number"==typeof y)for(P=t.contactEquations.length-y;P<t.contactEquations.length;P++)_.contactEquations.push(t.contactEquations[P]);this.emit(_)}if("number"==typeof y&&b>1)for(var P=t.frictionEquations.length-b;P<t.frictionEquations.length;P++){var C=t.frictionEquations[P];C.setSlipForce(C.getSlipForce()/b)}}}}},s.prototype.addSpring=function(t){this.springs.push(t);var e=this.addSpringEvent;e.spring=t,this.emit(e),e.spring=null},s.prototype.removeSpring=function(t){var e=this.springs.indexOf(t);-1!==e&&v.splice(this.springs,e,1)},s.prototype.addBody=function(t){if(-1===this.bodies.indexOf(t)){this.bodies.push(t),t.world=this;var e=this.addBodyEvent;e.body=t,this.emit(e),e.body=null}},s.prototype.removeBody=function(t){if(this.stepping)this.bodiesToBeRemoved.push(t);else{t.world=null;var e=this.bodies.indexOf(t);-1!==e&&(v.splice(this.bodies,e,1),this.removeBodyEvent.body=t,t.resetConstraintVelocity(),this.emit(this.removeBodyEvent),this.removeBodyEvent.body=null)}},s.prototype.getBodyById=function(t){for(var e=this.bodies,i=0;i<e.length;i++){var s=e[i];if(s.id===t)return s}return!1},s.prototype.disableBodyCollision=function(t,e){this.disabledBodyCollisionPairs.push(t,e)},s.prototype.enableBodyCollision=function(t,e){for(var i=this.disabledBodyCollisionPairs,s=0;s<i.length;s+=2)if(i[s]===t&&i[s+1]===e||i[s+1]===t&&i[s]===e)return void i.splice(s,2)},s.prototype.clear=function(){this.time=0,this.solver&&this.solver.equations.length&&this.solver.removeAllEquations();for(var t=this.constraints,e=t.length-1;e>=0;e--)this.removeConstraint(t[e]);for(var i=this.bodies,e=i.length-1;e>=0;e--)this.removeBody(i[e]);for(var n=this.springs,e=n.length-1;e>=0;e--)this.removeSpring(n[e]);for(var r=this.contactMaterials,e=r.length-1;e>=0;e--)this.removeContactMaterial(r[e]);s.apply(this)};var C=r.create(),S=(r.fromValues(0,0),r.fromValues(0,0));s.prototype.hitTest=function(t,e,i){i=i||0;var s=new d({position:t}),n=new c,u=t,p=C,f=S;s.addShape(n);for(var g=this.narrowphase,m=[],y=0,v=e.length;y!==v;y++)for(var x=e[y],b=0,_=x.shapes.length;b!==_;b++){var w=x.shapes[b];r.rotate(p,w.position,x.angle),r.add(p,p,x.position);var T=w.angle+x.angle;(w instanceof o&&g.circleParticle(x,w,p,T,s,n,u,0,!0)||w instanceof a&&g.particleConvex(s,n,u,0,x,w,p,T,!0)||w instanceof h&&g.particlePlane(s,n,u,0,x,w,p,T,!0)||w instanceof l&&g.particleCapsule(s,n,u,0,x,w,p,T,!0)||w instanceof c&&r.squaredLength(r.sub(f,p,t))<i*i)&&m.push(x)}return m},s.prototype.setGlobalStiffness=function(t){for(var e=this.constraints,i=0;i!==e.length;i++)for(var s=e[i],n=0;n!==s.equations.length;n++){var r=s.equations[n];r.stiffness=t,r.needsUpdate=!0}for(var o=this.contactMaterials,i=0;i!==o.length;i++)(s=o[i]).stiffness=s.frictionStiffness=t;(s=this.defaultContactMaterial).stiffness=s.frictionStiffness=t},s.prototype.setGlobalRelaxation=function(t){for(n=0;n!==this.constraints.length;n++)for(var e=this.constraints[n],i=0;i!==e.equations.length;i++){var s=e.equations[i];s.relaxation=t,s.needsUpdate=!0}for(var n=0;n!==this.contactMaterials.length;n++)(e=this.contactMaterials[n]).relaxation=e.frictionRelaxation=t;(e=this.defaultContactMaterial).relaxation=e.frictionRelaxation=t};var A=new g,E=[];s.prototype.raycast=function(t,e){return e.getAABB(A),this.broadphase.aabbQuery(this,A,E),e.intersectBodies(t,E),E.length=0,t.hasHit()}},{"../../package.json":6,"../collision/AABB":7,"../collision/Broadphase":8,"../collision/Narrowphase":10,"../collision/Ray":11,"../collision/SAPBroadphase":13,"../constraints/Constraint":14,"../constraints/DistanceConstraint":15,"../constraints/GearConstraint":16,"../constraints/LockConstraint":17,"../constraints/PrismaticConstraint":18,"../constraints/RevoluteConstraint":19,"../events/EventEmitter":26,"../material/ContactMaterial":27,"../material/Material":28,"../math/vec2":30,"../objects/Body":31,"../objects/LinearSpring":32,"../objects/RotationalSpring":33,"../shapes/Capsule":38,"../shapes/Circle":39,"../shapes/Convex":40,"../shapes/Line":42,"../shapes/Particle":43,"../shapes/Plane":44,"../shapes/Shape":45,"../solver/GSSolver":46,"../solver/Solver":47,"../utils/OverlapKeeper":52,"../utils/Utils":57,"./IslandManager":59}]},{},[36])(36)}),function(){function t(t,e,i,n){var r=t.createTexture();return t.bindTexture(t.TEXTURE_2D,r),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,n===s.scaleModes.LINEAR?t.LINEAR:t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,n===s.scaleModes.LINEAR?t.LINEAR:t.NEAREST),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,e,i,0,t.RGBA,t.UNSIGNED_BYTE,null),r}function e(e,i,s,r,o){var a=e.createFramebuffer(),h=e.createRenderbuffer(),l=null,c=0;return e.activeTexture(e.TEXTURE0+o),e.bindFramebuffer(e.FRAMEBUFFER,a),e.bindRenderbuffer(e.RENDERBUFFER,h),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,this.renderBuffer),l=t(e,i,s,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,l,0),(c=e.checkFramebufferStatus(e.FRAMEBUFFER))!==e.FRAMEBUFFER_COMPLETE&&console.error("Incomplete GL framebuffer. ",n[c]),a.width=i,a.height=s,a.targetTexture=l,a.renderBuffer=h,a}var i=this,s=s||{};s.DisplayObject=function(){this.position=new s.Point(0,0),this.scale=new s.Point(1,1),this.pivot=new s.Point(0,0),this.rotation=0,this.alpha=1,this.visible=!0,this.hitArea=null,this.renderable=!1,this.parent=null,this.worldAlpha=1,this.worldTransform=new Phaser.Matrix,this.worldPosition=new s.Point(0,0),this.worldScale=new s.Point(1,1),this.worldRotation=0,this.filterArea=null,this._sr=0,this._cr=1,this._bounds=new s.Rectangle(0,0,0,0),this._currentBounds=null,this._mask=null,this._cacheAsBitmap=!1,this._cacheIsDirty=!1},s.DisplayObject.prototype={constructor:s.DisplayObject,destroy:function(){if(this.children){for(var t=this.children.length;t--;)this.children[t].destroy();this.children=[]}this.hitArea=null,this.parent=null,this.worldTransform=null,this.filterArea=null,this.renderable=!1,this._bounds=null,this._currentBounds=null,this._mask=null,this._destroyCachedSprite(),this._destroyTintedTexture()},updateTransform:function(t){if(!t&&!this.parent&&!this.game)return this;var e=this.parent;t?e=t:this.parent||(e=this.game.world);var i,s,n,r,o,a,h=e.worldTransform,l=this.worldTransform;this.rotation%Phaser.Math.PI2?(this.rotation!==this.rotationCache&&(this.rotationCache=this.rotation,this._sr=Math.sin(this.rotation),this._cr=Math.cos(this.rotation)),i=this._cr*this.scale.x,s=this._sr*this.scale.x,n=-this._sr*this.scale.y,r=this._cr*this.scale.y,o=this.position.x,a=this.position.y,(this.pivot.x||this.pivot.y)&&(o-=this.pivot.x*i+this.pivot.y*n,a-=this.pivot.x*s+this.pivot.y*r),l.a=i*h.a+s*h.c,l.b=i*h.b+s*h.d,l.c=n*h.a+r*h.c,l.d=n*h.b+r*h.d,l.tx=o*h.a+a*h.c+h.tx,l.ty=o*h.b+a*h.d+h.ty):(i=this.scale.x,s=0,n=0,r=this.scale.y,o=this.position.x-this.pivot.x*i,a=this.position.y-this.pivot.y*r,l.a=i*h.a,l.b=i*h.b,l.c=r*h.c,l.d=r*h.d,l.tx=o*h.a+a*h.c+h.tx,l.ty=o*h.b+a*h.d+h.ty),i=l.a,s=l.b,n=l.c;var c=i*(r=l.d)-s*n;if(i||s){var u=Math.sqrt(i*i+s*s);this.worldRotation=s>0?Math.acos(i/u):-Math.acos(i/u),this.worldScale.x=u,this.worldScale.y=c/u}else if(n||r){var d=Math.sqrt(n*n+r*r);this.worldRotation=Phaser.Math.HALF_PI-(r>0?Math.acos(-n/d):-Math.acos(n/d)),this.worldScale.x=c/d,this.worldScale.y=d}else this.worldScale.x=0,this.worldScale.y=0;return this.worldAlpha=this.alpha*e.worldAlpha,this.worldPosition.x=l.tx,this.worldPosition.y=l.ty,this._currentBounds=null,this.transformCallback&&this.transformCallback.call(this.transformCallbackContext,l,h),this},preUpdate:function(){},generateTexture:function(t,e,i){var n=this.getLocalBounds(),r=new Phaser.RenderTexture(this.game,0|n.width,0|n.height,i,e,t);return s.DisplayObject._tempMatrix.tx=-n.x,s.DisplayObject._tempMatrix.ty=-n.y,r.render(this,s.DisplayObject._tempMatrix),r},updateCache:function(){return this._generateCachedSprite(),this},toGlobal:function(t){return this.updateTransform(),this.worldTransform.apply(t)},toLocal:function(t,e){return e&&(t=e.toGlobal(t)),this.updateTransform(),this.worldTransform.applyInverse(t)},_renderCachedSprite:function(t){this._cachedSprite.worldAlpha=this.worldAlpha,t.gl?s.Sprite.prototype._renderWebGL.call(this._cachedSprite,t):s.Sprite.prototype._renderCanvas.call(this._cachedSprite,t)},_generateCachedSprite:function(){this._cacheAsBitmap=!1;var t=this.getLocalBounds();if(t.width=Math.max(1,Math.ceil(t.width)),t.height=Math.max(1,Math.ceil(t.height)),this.updateTransform(),this._cachedSprite)this._cachedSprite.texture.resize(t.width,t.height);else{var e=0;this.texture&&this.texture.baseTexture&&s._enableMultiTextureToggle&&(e=this.texture.baseTexture.textureIndex);var i=new Phaser.RenderTexture(this.game,t.width,t.height,void 0,void 0,void 0,void 0,e);this._cachedSprite=new s.Sprite(i),this._cachedSprite.worldTransform=this.worldTransform}var n=this._filters;this._filters=null,this._cachedSprite.filters=n,s.DisplayObject._tempMatrix.tx=-t.x,s.DisplayObject._tempMatrix.ty=-t.y,this._cachedSprite.texture.render(this,s.DisplayObject._tempMatrix,!0),this._cachedSprite.anchor.x=-t.x/t.width,this._cachedSprite.anchor.y=-t.y/t.height,this._filters=n,this._cacheAsBitmap=!0},_destroyCachedSprite:function(){this._cachedSprite&&(this._cachedSprite.texture.destroy(!0),this._cachedSprite=null)},_destroyTintedTexture:function(){this.tintedTexture&&(Phaser.CanvasPool.removeByCanvas(this.tintedTexture),this.tintedTexture=null)}},s.DisplayObject.prototype.displayObjectUpdateTransform=s.DisplayObject.prototype.updateTransform,Object.defineProperties(s.DisplayObject.prototype,{x:{get:function(){return this.position.x},set:function(t){this.position.x=t}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t}},worldVisible:{get:function(){if(this.visible){var t=this.parent;if(!t)return this.visible;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}return!1}},mask:{get:function(){return this._mask},set:function(t){this._mask&&(this._mask.isMask=!1),this._mask=t,t&&(this._mask.isMask=!0)}},filters:{get:function(){return this._filters},set:function(t){if(Array.isArray(t)){for(var e=[],i=0;i<t.length;i++)for(var n=t[i].passes,r=0;r<n.length;r++)e.push(n[r]);this._filterBlock={target:this,filterPasses:e}}this._filters=t,this.blendMode&&this.blendMode===s.blendModes.MULTIPLY&&(this.blendMode=s.blendModes.NORMAL)}},cacheAsBitmap:{get:function(){return this._cacheAsBitmap},set:function(t){this._cacheAsBitmap!==t&&(t?this._generateCachedSprite():this._destroyCachedSprite(),this._cacheAsBitmap=t)}}}),s.DisplayObjectContainer=function(){s.DisplayObject.call(this),this.children=[],this.ignoreChildInput=!1},s.DisplayObjectContainer.prototype=Object.create(s.DisplayObject.prototype),s.DisplayObjectContainer.prototype.constructor=s.DisplayObjectContainer,s.DisplayObjectContainer.prototype.addChild=function(t){return this.addChildAt(t,this.children.length)},s.DisplayObjectContainer.prototype.addChildAt=function(t,e){if(e>=0&&e<=this.children.length)return t.parent&&t.parent.removeChild(t),t.parent=this,this.children.splice(e,0,t),t;throw new Error(t+"addChildAt: The index "+e+" supplied is out of bounds "+this.children.length)},s.DisplayObjectContainer.prototype.swapChildren=function(t,e){if(t!==e){var i=this.getChildIndex(t),s=this.getChildIndex(e);if(i<0||s<0)throw new Error("swapChildren: Both the supplied DisplayObjects must be a child of the caller.");this.children[i]=e,this.children[s]=t}},s.DisplayObjectContainer.prototype.getChildIndex=function(t){var e=this.children.indexOf(t);if(-1===e)throw new Error("The supplied DisplayObject must be a child of the caller");return e},s.DisplayObjectContainer.prototype.setChildIndex=function(t,e){if(e<0||e>=this.children.length)throw new Error("The supplied index is out of bounds");var i=this.getChildIndex(t);this.children.splice(i,1),this.children.splice(e,0,t)},s.DisplayObjectContainer.prototype.getChildAt=function(t){if(t<0||t>=this.children.length)throw new Error("getChildAt: Supplied index "+t+" does not exist in the child list, or the supplied DisplayObject must be a child of the caller");return this.children[t]},s.DisplayObjectContainer.prototype.removeChild=function(t){var e=this.children.indexOf(t);if(-1!==e)return this.removeChildAt(e)},s.DisplayObjectContainer.prototype.removeChildAt=function(t){var e=this.getChildAt(t);return e&&(e.parent=void 0,this.children.splice(t,1)),e},s.DisplayObjectContainer.prototype.bringChildToTop=function(t){if(t.parent===this)return this.setChildIndex(t,this.children.length-1)},s.DisplayObjectContainer.prototype.sendChildToBack=function(t){if(t.parent===this)return this.setChildIndex(t,0)},s.DisplayObjectContainer.prototype.removeChildren=function(t,e){void 0===t&&(t=0),void 0===e&&(e=this.children.length);var i=e-t;if(i>0&&i<=e){for(var s=this.children.splice(t,i),n=0;n<s.length;n++)s[n].parent=void 0;return s}if(0===i&&0===this.children.length)return[];throw new Error("removeChildren: Range Error, numeric values are outside the acceptable range")},s.DisplayObjectContainer.prototype.updateTransform=function(){if(this.visible&&(this.displayObjectUpdateTransform(),!this._cacheAsBitmap))for(var t=0;t<this.children.length;t++)this.children[t].updateTransform()},s.DisplayObjectContainer.prototype.displayObjectContainerUpdateTransform=s.DisplayObjectContainer.prototype.updateTransform,s.DisplayObjectContainer.prototype.getBounds=function(t){var e=t&&t instanceof s.DisplayObject,i=!0;e?i=t instanceof s.DisplayObjectContainer&&t.contains(this):t=this;var n;if(e){var r=t.worldTransform;for(t.worldTransform=Phaser.identityMatrix,n=0;n<t.children.length;n++)t.children[n].updateTransform()}var o,a,h,l=1/0,c=1/0,u=-1/0,d=-1/0,p=!1;for(n=0;n<this.children.length;n++)this.children[n].visible&&(p=!0,l=l<(o=this.children[n].getBounds()).x?l:o.x,c=c<o.y?c:o.y,a=o.width+o.x,h=o.height+o.y,u=u>a?u:a,d=d>h?d:h);var f=this._bounds;if(!p){var g=(f=new s.Rectangle).x,m=f.width+f.x,y=f.y,v=f.height+f.y,x=this.worldTransform,b=x.a,_=x.b,w=x.c,T=x.d,P=x.tx,C=x.ty,S=b*m+w*v+P,A=T*v+_*m+C,E=b*g+w*v+P,M=T*v+_*g+C,R=b*g+w*y+P,L=T*y+_*g+C,B=b*m+w*y+P,I=T*y+_*m+C;u=S,d=A,c=A,l=B<(l=R<(l=E<(l=S)?E:l)?R:l)?B:l,c=I<(c=L<(c=M<c?M:c)?L:c)?I:c,u=B>(u=R>(u=E>u?E:u)?R:u)?B:u,d=I>(d=L>(d=M>d?M:d)?L:d)?I:d}if(f.x=l,f.y=c,f.width=u-l,f.height=d-c,e)for(t.worldTransform=r,n=0;n<t.children.length;n++)t.children[n].updateTransform();if(!i){var O=t.getBounds();f.x-=O.x,f.y-=O.y}return f},s.DisplayObjectContainer.prototype.getLocalBounds=function(){return this.getBounds(this)},s.DisplayObjectContainer.prototype.contains=function(t){return!!t&&(t===this||this.contains(t.parent))},s.DisplayObjectContainer.prototype._renderWebGL=function(t){if(this.visible&&!(this.alpha<=0))if(this._cacheAsBitmap)this._renderCachedSprite(t);else{var e;if(this._mask||this._filters){for(this._filters&&(t.spriteBatch.flush(),t.filterManager.pushFilter(this._filterBlock)),this._mask&&(t.spriteBatch.stop(),t.maskManager.pushMask(this.mask,t),t.spriteBatch.start()),e=0;e<this.children.length;e++)this.children[e]._renderWebGL(t);t.spriteBatch.stop(),this._mask&&t.maskManager.popMask(this._mask,t),this._filters&&t.filterManager.popFilter(),t.spriteBatch.start()}else for(e=0;e<this.children.length;e++)this.children[e]._renderWebGL(t)}},s.DisplayObjectContainer.prototype._renderCanvas=function(t){if(!1!==this.visible&&0!==this.alpha)if(this._cacheAsBitmap)this._renderCachedSprite(t);else{this._mask&&t.maskManager.pushMask(this._mask,t);for(var e=0;e<this.children.length;e++)this.children[e]._renderCanvas(t);this._mask&&t.maskManager.popMask(t)}},Object.defineProperty(s.DisplayObjectContainer.prototype,"width",{get:function(){return this.getLocalBounds().width*this.scale.x},set:function(t){var e=this.getLocalBounds().width;this.scale.x=0!==e?t/e:1,this._width=t}}),Object.defineProperty(s.DisplayObjectContainer.prototype,"height",{get:function(){return this.getLocalBounds().height*this.scale.y},set:function(t){var e=this.getLocalBounds().height;this.scale.y=0!==e?t/e:1,this._height=t}}),s.Sprite=function(t){s.DisplayObjectContainer.call(this),this.anchor=new s.Point(s.Sprite.defaultAnchor.x,s.Sprite.defaultAnchor.y),this.texture=t||s.Texture.emptyTexture,this._width=0,this._height=0,this.tint=16777215,this.cachedTint=-1,this.tintedTexture=null,this.blendMode=s.blendModes.NORMAL,this.shader=null,this.exists=!0,this.texture.baseTexture.hasLoaded&&this.onTextureUpdate(),this.renderable=!0},s.Sprite.defaultAnchor={x:0,y:0},s.Sprite.prototype=Object.create(s.DisplayObjectContainer.prototype),s.Sprite.prototype.constructor=s.Sprite,Object.defineProperty(s.Sprite.prototype,"width",{get:function(){return this.scale.x*this.texture.frame.width},set:function(t){this.scale.x=t/this.texture.frame.width,this._width=t}}),Object.defineProperty(s.Sprite.prototype,"height",{get:function(){return this.scale.y*this.texture.frame.height},set:function(t){this.scale.y=t/this.texture.frame.height,this._height=t}}),s.Sprite.prototype.setTexture=function(t,e){e&&this.texture.baseTexture.destroy(),this.texture.baseTexture.skipRender=!1,this.texture=t,this.texture.valid=!0,this.cachedTint=-1},s.Sprite.prototype.onTextureUpdate=function(){this._width&&(this.scale.x=this._width/this.texture.frame.width),this._height&&(this.scale.y=this._height/this.texture.frame.height)},s.Sprite.prototype.getBounds=function(t){var e=this.texture.frame.width,i=this.texture.frame.height,s=e*(1-this.anchor.x),n=e*-this.anchor.x,r=i*(1-this.anchor.y),o=i*-this.anchor.y,a=t||this.worldTransform,h=a.a,l=a.b,c=a.c,u=a.d,d=a.tx,p=a.ty,f=-1/0,g=-1/0,m=1/0,y=1/0;if(0===l&&0===c){if(h<0){h*=-1;v=s;s=-n,n=-v}if(u<0){u*=-1;var v=r;r=-o,o=-v}m=h*n+d,f=h*s+d,y=u*o+p,g=u*r+p}else{var x=h*n+c*o+d,b=u*o+l*n+p,_=h*s+c*o+d,w=u*o+l*s+p,T=h*s+c*r+d,P=u*r+l*s+p,C=h*n+c*r+d,S=u*r+l*n+p;m=C<(m=T<(m=_<(m=x<m?x:m)?_:m)?T:m)?C:m,y=S<(y=P<(y=w<(y=b<y?b:y)?w:y)?P:y)?S:y,f=C>(f=T>(f=_>(f=x>f?x:f)?_:f)?T:f)?C:f,g=S>(g=P>(g=w>(g=b>g?b:g)?w:g)?P:g)?S:g}var A=this._bounds;return A.x=m,A.width=f-m,A.y=y,A.height=g-y,this._currentBounds=A,A},s.Sprite.prototype.getLocalBounds=function(){var t=this.worldTransform;this.worldTransform=Phaser.identityMatrix;for(var e=0;e<this.children.length;e++)this.children[e].updateTransform();var i=this.getBounds();for(this.worldTransform=t,e=0;e<this.children.length;e++)this.children[e].updateTransform();return i},s.Sprite.prototype._renderWebGL=function(t,e){if(this.visible&&!(this.alpha<=0)&&this.renderable){var i=this.worldTransform;if(e&&(i=e),this._mask||this._filters){var s=t.spriteBatch;this._filters&&(s.flush(),t.filterManager.pushFilter(this._filterBlock)),this._mask&&(s.stop(),t.maskManager.pushMask(this.mask,t),s.start()),s.render(this);for(n=0;n<this.children.length;n++)this.children[n]._renderWebGL(t);s.stop(),this._mask&&t.maskManager.popMask(this._mask,t),this._filters&&t.filterManager.popFilter(),s.start()}else{t.spriteBatch.render(this);for(var n=0;n<this.children.length;n++)this.children[n]._renderWebGL(t,i)}}},s.Sprite.prototype._renderCanvas=function(t,e){if(!(!this.visible||0===this.alpha||!this.renderable||this.texture.crop.width<1||this.texture.crop.height<1)){var i=this.worldTransform;if(e&&(i=e),this.blendMode!==t.currentBlendMode&&(t.currentBlendMode=this.blendMode,t.context.globalCompositeOperation=s.blendModesCanvas[t.currentBlendMode]),this._mask&&t.maskManager.pushMask(this._mask,t),this.texture.valid){var n=this.texture.baseTexture.resolution/t.resolution;t.context.globalAlpha=this.worldAlpha,t.smoothProperty&&t.scaleMode!==this.texture.baseTexture.scaleMode&&(t.scaleMode=this.texture.baseTexture.scaleMode,t.context[t.smoothProperty]=t.scaleMode===s.scaleModes.LINEAR);var r=this.texture.trim?this.texture.trim.x-this.anchor.x*this.texture.trim.width:this.anchor.x*-this.texture.frame.width,o=this.texture.trim?this.texture.trim.y-this.anchor.y*this.texture.trim.height:this.anchor.y*-this.texture.frame.height,a=i.tx*t.resolution+t.shakeX,h=i.ty*t.resolution+t.shakeY,l=this.texture.crop.width,c=this.texture.crop.height;if(this.texture.rotated){var u=i.a,d=i.b,p=i.c,f=i.d,g=l;a=i.c*c+a,h=i.d*c+h,i.a=6.123233995736766e-17*u-p,i.b=6.123233995736766e-17*d-f,i.c=u+6.123233995736766e-17*p,i.d=d+6.123233995736766e-17*f,l=c,c=g}if(t.roundPixels?(t.context.setTransform(i.a,i.b,i.c,i.d,0|a,0|h),r|=0,o|=0):t.context.setTransform(i.a,i.b,i.c,i.d,a,h),r/=n,o/=n,l|=0,c|=0,l&&c){if(16777215!==this.tint)(this.texture.requiresReTint||this.cachedTint!==this.tint)&&(this.tintedTexture=s.CanvasTinter.getTintedTexture(this,this.tint),this.cachedTint=this.tint,this.texture.requiresReTint=!1),t.context.drawImage(this.tintedTexture,0,0,l,c,r,o,l/n,c/n);else{var m=this.texture.crop.x,y=this.texture.crop.y;t.context.drawImage(this.texture.baseTexture.source,m,y,l,c,r,o,l/n,c/n)}for(v=0;v<this.children.length;v++)this.children[v]._renderCanvas(t);this._mask&&t.maskManager.popMask(t)}}else{for(var v=0;v<this.children.length;v++)this.children[v]._renderCanvas(t);this._mask&&t.maskManager.popMask(t)}}},s.initDefaultShaders=function(){},s.CompileVertexShader=function(t,e){return s._CompileShader(t,e,t.VERTEX_SHADER)},s.CompileFragmentShader=function(t,e){return s._CompileShader(t,e,t.FRAGMENT_SHADER)},s._CompileShader=function(t,e,i){var s=e;Array.isArray(e)&&(s=e.join("\n"));var n=t.createShader(i);return t.shaderSource(n,s),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS)?n:(window.console.log(t.getShaderInfoLog(n)),null)},s.compileProgram=function(t,e,i){var n=s.CompileFragmentShader(t,i),r=s.CompileVertexShader(t,e),o=t.createProgram();return t.attachShader(o,r),t.attachShader(o,n),t.linkProgram(o),t.getProgramParameter(o,t.LINK_STATUS)||(window.console.log(t.getProgramInfoLog(o)),window.console.log("Could not initialise shaders")),o},s.PixiShader=function(t){this._UID=Phaser._UID++,this.gl=t,this.program=null,this.fragmentSrc=null,this.textureCount=0,this.firstRun=!0,this.dirty=!0,this.attributes=[],this.init()},s.PixiShader.prototype.constructor=s.PixiShader,s.PixiShader.prototype.initMultitexShader=function(){var t=this.gl;this.MAX_TEXTURES=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);for(var e="\tif (vTextureIndex == 0.0) { gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;return;}\n",i=1;i<this.MAX_TEXTURES;++i)e+="\tif (vTextureIndex == "+i+".0) {gl_FragColor = texture2D(uSamplerArray["+i+"], vTextureCoord) * vColor;return;}\n";this.fragmentSrc=["// PixiShader Fragment Shader.","precision lowp float;","bool isnan( float val ) { return ( val < 0.0 || 0.0 < val || val == 0.0 ) ? false : true; }","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","uniform sampler2D uSamplerArray["+this.MAX_TEXTURES+"];","const vec4 BLUE = vec4(1.0, 0.0, 1.0, 1.0);","const vec4 RED = vec4(1.0, 0.0, 0.0, 1.0);","void main(void) {",e," if(vTextureIndex >= "+this.MAX_TEXTURES+".0) { gl_FragColor = BLUE;return;}"," if(isnan(vTextureIndex)) { gl_FragColor = RED;return;}","}"];var n=s.compileProgram(t,this.vertexSrc||s.PixiShader.defaultVertexSrc,this.fragmentSrc);t.useProgram(n),this.uSamplerArray=t.getUniformLocation(n,"uSamplerArray[0]"),this.projectionVector=t.getUniformLocation(n,"projectionVector"),this.offsetVector=t.getUniformLocation(n,"offsetVector"),this.dimensions=t.getUniformLocation(n,"dimensions"),this.aVertexPosition=t.getAttribLocation(n,"aVertexPosition"),this.aTextureCoord=t.getAttribLocation(n,"aTextureCoord"),this.colorAttribute=t.getAttribLocation(n,"aColor"),this.aTextureIndex=t.getAttribLocation(n,"aTextureIndex");var r=[],o=t.createTexture();t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,o),t.texImage2D(t.TEXTURE_2D,0,t.RGB,1,1,0,t.RGB,t.UNSIGNED_BYTE,null);for(var a=0;a<this.MAX_TEXTURES;++a)t.activeTexture(t.TEXTURE0+a),t.bindTexture(t.TEXTURE_2D,o),r.push(a);t.activeTexture(t.TEXTURE0),t.uniform1iv(this.uSamplerArray,r),-1===this.colorAttribute&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aTextureCoord,this.colorAttribute,this.aTextureIndex];for(var h in this.uniforms)this.uniforms[h].uniformLocation=t.getUniformLocation(n,h);this.initUniforms(),this.program=n},s.PixiShader.prototype.initDefaultShader=function(){null===this.fragmentSrc&&(this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"]);var t=this.gl,e=s.compileProgram(t,this.vertexSrc||s.PixiShader.defaultVertexSrc,this.fragmentSrc);t.useProgram(e),this.uSampler=t.getUniformLocation(e,"uSampler"),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.dimensions=t.getUniformLocation(e,"dimensions"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.aTextureCoord=t.getAttribLocation(e,"aTextureCoord"),this.colorAttribute=t.getAttribLocation(e,"aColor"),this.aTextureIndex=t.getAttribLocation(e,"aTextureIndex"),-1===this.colorAttribute&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aTextureCoord,this.colorAttribute,this.aTextureIndex];for(var i in this.uniforms)this.uniforms[i].uniformLocation=t.getUniformLocation(e,i);this.initUniforms(),this.program=e},s.PixiShader.prototype.init=function(t){s._enableMultiTextureToggle&&!t?this.initMultitexShader():this.initDefaultShader()},s.PixiShader.prototype.initUniforms=function(){this.textureCount=1;var t,e=this.gl;for(var i in this.uniforms){var s=(t=this.uniforms[i]).type;"sampler2D"===s?(t._init=!1,null!==t.value&&this.initSampler2D(t)):"mat2"===s||"mat3"===s||"mat4"===s?(t.glMatrix=!0,t.glValueLength=1,"mat2"===s?t.glFunc=e.uniformMatrix2fv:"mat3"===s?t.glFunc=e.uniformMatrix3fv:"mat4"===s&&(t.glFunc=e.uniformMatrix4fv)):(t.glFunc=e["uniform"+s],t.glValueLength="2f"===s||"2i"===s?2:"3f"===s||"3i"===s?3:"4f"===s||"4i"===s?4:1)}},s.PixiShader.prototype.initSampler2D=function(t){if(t.value&&t.value.baseTexture&&t.value.baseTexture.hasLoaded){var e=this.gl;if(e.activeTexture(e.TEXTURE0+this.textureCount),e.bindTexture(e.TEXTURE_2D,t.value.baseTexture._glTextures[e.id]),t.textureData){var i=t.textureData,s=i.magFilter?i.magFilter:e.LINEAR,n=i.minFilter?i.minFilter:e.LINEAR,r=i.wrapS?i.wrapS:e.CLAMP_TO_EDGE,o=i.wrapT?i.wrapT:e.CLAMP_TO_EDGE,a=i.luminance?e.LUMINANCE:e.RGBA;if(i.repeat&&(r=e.REPEAT,o=e.REPEAT),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!!i.flipY),i.width){var h=i.width?i.width:512,l=i.height?i.height:2,c=i.border?i.border:0;e.texImage2D(e.TEXTURE_2D,0,a,h,l,c,a,e.UNSIGNED_BYTE,null)}else e.texImage2D(e.TEXTURE_2D,0,a,e.RGBA,e.UNSIGNED_BYTE,t.value.baseTexture.source);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,s),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,n),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,r),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,o)}e.uniform1i(t.uniformLocation,this.textureCount),t._init=!0,this.textureCount++}},s.PixiShader.prototype.syncUniforms=function(){this.textureCount=1;var t,e=this.gl;for(var i in this.uniforms)1===(t=this.uniforms[i]).glValueLength?!0===t.glMatrix?t.glFunc.call(e,t.uniformLocation,t.transpose,t.value):t.glFunc.call(e,t.uniformLocation,t.value):2===t.glValueLength?t.glFunc.call(e,t.uniformLocation,t.value.x,t.value.y):3===t.glValueLength?t.glFunc.call(e,t.uniformLocation,t.value.x,t.value.y,t.value.z):4===t.glValueLength?t.glFunc.call(e,t.uniformLocation,t.value.x,t.value.y,t.value.z,t.value.w):"sampler2D"===t.type&&(t._init?(e.activeTexture(e["TEXTURE"+this.textureCount]),t.value.baseTexture._dirty[e.id]?s.instances[e.id].updateTexture(t.value.baseTexture):e.bindTexture(e.TEXTURE_2D,t.value.baseTexture._glTextures[e.id]),e.uniform1i(t.uniformLocation,this.textureCount),this.textureCount++):this.initSampler2D(t))},s.PixiShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},s.PixiShader.defaultVertexSrc=["// PixiShader Vertex Shader","// With multi-texture rendering","attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute vec4 aColor;","attribute float aTextureIndex;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {"," if (aTextureIndex > 0.0) gl_Position = vec4(0.0);"," gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = vec4(aColor.rgb * aColor.a, aColor.a);"," vTextureIndex = aTextureIndex;","}"],s.PixiFastShader=function(t){if(this._UID=Phaser._UID++,this.gl=t,this.program=null,s._enableMultiTextureToggle){var t=this.gl;this.MAX_TEXTURES=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);for(var e="\tif (vTextureIndex == 0.0) { gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;return;}\n",i=1;i<this.MAX_TEXTURES;++i)e+="\tif (vTextureIndex == "+i+".0) { gl_FragColor = texture2D(uSamplerArray["+i+"], vTextureCoord) * vColor;return;}\n";this.fragmentSrc=["// PixiFastShader Fragment Shader.","precision lowp float;","bool isnan( float val ) { return ( val < 0.0 || 0.0 < val || val == 0.0 ) ? false : true; }","varying vec2 vTextureCoord;","varying float vColor;","varying float vTextureIndex;","uniform sampler2D uSamplerArray["+this.MAX_TEXTURES+"];","const vec4 BLUE = vec4(1.0, 0.0, 1.0, 1.0);","const vec4 RED = vec4(1.0, 0.0, 0.0, 1.0);","void main(void) {",e," if(vTextureIndex >= "+this.MAX_TEXTURES+".0) { gl_FragColor = BLUE;return;}"," if(isnan(vTextureIndex)) {gl_FragColor = RED;return;}","}"]}else this.fragmentSrc=["// PixiFastShader Fragment Shader.","precision lowp float;","varying vec2 vTextureCoord;","varying float vColor;","varying float vTextureIndex;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;","}"];this.vertexSrc=["// PixiFastShader Vertex Shader.","attribute vec2 aVertexPosition;","attribute vec2 aPositionCoord;","attribute vec2 aScale;","attribute float aRotation;","attribute vec2 aTextureCoord;","attribute float aColor;","attribute float aTextureIndex;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform mat3 uMatrix;","varying vec2 vTextureCoord;","varying float vColor;","varying float vTextureIndex;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {"," vec2 v;"," vec2 sv = aVertexPosition * aScale;"," v.x = (sv.x) * cos(aRotation) - (sv.y) * sin(aRotation);"," v.y = (sv.x) * sin(aRotation) + (sv.y) * cos(aRotation);"," v = ( uMatrix * vec3(v + aPositionCoord , 1.0) ).xy ;"," gl_Position = vec4( ( v / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vTextureIndex = aTextureIndex;"," vColor = aColor;","}"],this.textureCount=0,this.init()},s.PixiFastShader.prototype.constructor=s.PixiFastShader,s.PixiFastShader.prototype.init=function(){var t=this.gl,e=s.compileProgram(t,this.vertexSrc,this.fragmentSrc);if(t.useProgram(e),this.uSampler=s._enableMultiTextureToggle?t.getUniformLocation(e,"uSamplerArray[0]"):t.getUniformLocation(e,"uSampler"),s._enableMultiTextureToggle){var i=[],n=t.createTexture();t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,n),t.texImage2D(t.TEXTURE_2D,0,t.RGB,1,1,0,t.RGB,t.UNSIGNED_BYTE,null);for(var r=0;r<this.MAX_TEXTURES;++r)t.activeTexture(t.TEXTURE0+r),t.bindTexture(t.TEXTURE_2D,n),i.push(r);t.activeTexture(t.TEXTURE0),t.uniform1iv(this.uSampler,i)}this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.dimensions=t.getUniformLocation(e,"dimensions"),this.uMatrix=t.getUniformLocation(e,"uMatrix"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.aPositionCoord=t.getAttribLocation(e,"aPositionCoord"),this.aScale=t.getAttribLocation(e,"aScale"),this.aRotation=t.getAttribLocation(e,"aRotation"),this.aTextureCoord=t.getAttribLocation(e,"aTextureCoord"),this.colorAttribute=t.getAttribLocation(e,"aColor"),this.aTextureIndex=t.getAttribLocation(e,"aTextureIndex"),-1===this.colorAttribute&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aPositionCoord,this.aScale,this.aRotation,this.aTextureCoord,this.colorAttribute,this.aTextureIndex],this.program=e},s.PixiFastShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},s.StripShader=function(t){if(this._UID=Phaser._UID++,this.gl=t,this.program=null,s._enableMultiTextureToggle){var t=this.gl;this.MAX_TEXTURES=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);for(var e="\tif (vTextureIndex == 0.0) { gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord);return;}\n",i=1;i<this.MAX_TEXTURES;++i)e+="\tif (vTextureIndex == "+i+".0) { gl_FragColor = texture2D(uSamplerArray["+i+"], vTextureCoord) ;return;}\n";this.fragmentSrc=["//StripShader Fragment Shader.","precision mediump float;","bool isnan( float val ) { return ( val < 0.0 || 0.0 < val || val == 0.0 ) ? false : true; }","varying vec2 vTextureCoord;","varying float vTextureIndex;","uniform float alpha;","uniform sampler2D uSamplerArray["+this.MAX_TEXTURES+"];","const vec4 BLUE = vec4(1.0, 0.0, 1.0, 1.0);","const vec4 RED = vec4(1.0, 0.0, 0.0, 1.0);","void main(void) {",e," if(vTextureIndex >= "+this.MAX_TEXTURES+".0) { gl_FragColor = BLUE;return;}"," if(isnan(vTextureIndex)) {gl_FragColor = RED;return;}","}"]}else this.fragmentSrc=["//StripShader Fragment Shader.","precision mediump float;","varying vec2 vTextureCoord;","varying float vTextureIndex;","uniform float alpha;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord);","}"];this.vertexSrc=["//StripShader Vertex Shader.","attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute float aTextureIndex;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","varying float vTextureIndex;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vTextureIndex = aTextureIndex;","}"],this.init()},s.StripShader.prototype.constructor=s.StripShader,s.StripShader.prototype.init=function(){var t=this.gl,e=s.compileProgram(t,this.vertexSrc,this.fragmentSrc);if(t.useProgram(e),this.uSampler=s._enableMultiTextureToggle?t.getUniformLocation(e,"uSamplerArray[0]"):t.getUniformLocation(e,"uSampler"),s._enableMultiTextureToggle){var i=[],n=t.createTexture();t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,n),t.texImage2D(t.TEXTURE_2D,0,t.RGB,1,1,0,t.RGB,t.UNSIGNED_BYTE,null);for(var r=0;r<this.MAX_TEXTURES;++r)t.activeTexture(t.TEXTURE0+r),t.bindTexture(t.TEXTURE_2D,n),i.push(r);t.activeTexture(t.TEXTURE0),t.uniform1iv(this.uSampler,i)}this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.colorAttribute=t.getAttribLocation(e,"aColor"),this.aTextureIndex=t.getAttribLocation(e,"aTextureIndex"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.aTextureCoord=t.getAttribLocation(e,"aTextureCoord"),this.attributes=[this.aVertexPosition,this.aTextureCoord,this.aTextureIndex],this.translationMatrix=t.getUniformLocation(e,"translationMatrix"),this.alpha=t.getUniformLocation(e,"alpha"),this.program=e},s.StripShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attribute=null},s.PrimitiveShader=function(t){this._UID=Phaser._UID++,this.gl=t,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {"," gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec4 aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform float alpha;","uniform float flipY;","uniform vec3 tint;","varying vec4 vColor;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);"," vColor = aColor * vec4(tint * alpha, alpha);","}"],this.init()},s.PrimitiveShader.prototype.constructor=s.PrimitiveShader,s.PrimitiveShader.prototype.init=function(){var t=this.gl,e=s.compileProgram(t,this.vertexSrc,this.fragmentSrc);t.useProgram(e),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.tintColor=t.getUniformLocation(e,"tint"),this.flipY=t.getUniformLocation(e,"flipY"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.colorAttribute=t.getAttribLocation(e,"aColor"),this.attributes=[this.aVertexPosition,this.colorAttribute],this.translationMatrix=t.getUniformLocation(e,"translationMatrix"),this.alpha=t.getUniformLocation(e,"alpha"),this.program=e},s.PrimitiveShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},s.ComplexPrimitiveShader=function(t){this._UID=Phaser._UID++,this.gl=t,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {"," gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform vec3 tint;","uniform float alpha;","uniform vec3 color;","uniform float flipY;","varying vec4 vColor;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);"," vColor = vec4(color * alpha * tint, alpha);","}"],this.init()},s.ComplexPrimitiveShader.prototype.constructor=s.ComplexPrimitiveShader,s.ComplexPrimitiveShader.prototype.init=function(){var t=this.gl,e=s.compileProgram(t,this.vertexSrc,this.fragmentSrc);t.useProgram(e),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.tintColor=t.getUniformLocation(e,"tint"),this.color=t.getUniformLocation(e,"color"),this.flipY=t.getUniformLocation(e,"flipY"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.attributes=[this.aVertexPosition,this.colorAttribute],this.translationMatrix=t.getUniformLocation(e,"translationMatrix"),this.alpha=t.getUniformLocation(e,"alpha"),this.program=e},s.ComplexPrimitiveShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attribute=null},s.glContexts=[],s.instances=[],s._enableMultiTextureToggle=!1,s.WebGLRenderer=function(t,e){this.game=t,s.defaultRenderer||(s.defaultRenderer=this),this.extensions={},this.type=Phaser.WEBGL,this.resolution=t.resolution,this.transparent=t.transparent,this.autoResize=!1,this.preserveDrawingBuffer=t.preserveDrawingBuffer,this.clearBeforeRender=t.clearBeforeRender,this.powerPreference=t.powerPreference,this.width=t.width,this.height=t.height,this.view=t.canvas,this._contextOptions={alpha:this.transparent,antialias:t.antialias,failIfMajorPerformanceCaveat:e.failIfMajorPerformanceCaveat,premultipliedAlpha:this.transparent&&"notMultiplied"!==this.transparent,stencil:!0,preserveDrawingBuffer:this.preserveDrawingBuffer,powerPreference:t.powerPreference},this.projection=new s.Point,this.offset=new s.Point,this.shaderManager=new s.WebGLShaderManager,this.spriteBatch=new s.WebGLSpriteBatch(t),this.maskManager=new s.WebGLMaskManager,this.filterManager=new s.WebGLFilterManager,this.stencilManager=new s.WebGLStencilManager,this.blendModeManager=new s.WebGLBlendModeManager,this.renderSession={},this.currentBatchedTextures=[],this.renderSession.game=this.game,this.renderSession.gl=this.gl,this.renderSession.drawCount=0,this.renderSession.shaderManager=this.shaderManager,this.renderSession.maskManager=this.maskManager,this.renderSession.filterManager=this.filterManager,this.renderSession.blendModeManager=this.blendModeManager,this.renderSession.spriteBatch=this.spriteBatch,this.renderSession.stencilManager=this.stencilManager,this.renderSession.renderer=this,this.renderSession.resolution=this.resolution,this.renderSession.roundPixels=e.roundPixels||!1,this.renderSession.maxTextureAvailableSpace=null,this.initContext(),this.mapBlendModes()},s.WebGLRenderer.prototype.constructor=s.WebGLRenderer,s.WebGLRenderer.prototype.initContext=function(){var t=this.view.getContext("webgl",this._contextOptions)||this.view.getContext("experimental-webgl",this._contextOptions);if(this.gl=t,!t)throw new Error("This browser does not support webGL. Try using the canvas renderer");this.maxTextures=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.maxTextureSize=this.gl.getParameter(t.MAX_TEXTURE_SIZE),this.glContextId=t.id=s.WebGLRenderer.glContextId++,s.glContexts[this.glContextId]=t,s.instances[this.glContextId]=this,t.disable(t.DEPTH_TEST),t.disable(t.CULL_FACE),t.enable(t.BLEND),this.shaderManager.setContext(t),this.spriteBatch.setContext(t),this.maskManager.setContext(t),this.filterManager.setContext(t),this.blendModeManager.setContext(t),this.stencilManager.setContext(t),this.renderSession.gl=this.gl,this.resize(this.width,this.height),this.extensions.compression={};var e=t.getExtension("WEBGL_compressed_texture_etc1")||t.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),i=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),n=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");e&&(this.extensions.compression.ETC1=e),i&&(this.extensions.compression.PVRTC=i),n&&(this.extensions.compression.S3TC=n)},s.WebGLRenderer.prototype.setTexturePriority=function(t){if(s._enableMultiTextureToggle){for(var e=function(t){return--t,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t},i=this.gl,n=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),r=i.getParameter(i.MAX_TEXTURE_SIZE),o=this.game.cache._cache.image,a=null,h=0;h<this.currentBatchedTextures.length;h++)(a=this.currentBatchedTextures[h])in o?o[a].base.textureIndex=0:console.warn('setTexturePriority: There is no image "%s" in the image cache.',a);var l=r-e(Math.max(this.width,this.height));this.currentBatchedTextures.length=0;for(var c=0;c<t.length;++c)if((a=t[c])in o){var u=o[a].base;(l-=e(Math.max(u.width,u.height)))<=0?(u.textureIndex=0,console.warn('setTexturePriority: Image "%s" was given textureIndex=0 because there is no available texture space (%s).',a,l)):u.textureIndex=1+c%(n-1),this.currentBatchedTextures.push(a)}else console.warn('setTexturePriority: There is no image "%s" in the image cache.',a);return this.renderSession.maxTextureAvailableSpace=l,this.currentBatchedTextures}console.warn("setTexturePriority error: Multi Texture support hasn't been enabled in the Phaser Game Config.")},s.WebGLRenderer.prototype.render=function(t){if(!this.contextLost){var e=this.gl;e.viewport(0,0,this.width,this.height),e.bindFramebuffer(e.FRAMEBUFFER,null),this.game.clearBeforeRender&&(e.clearColor(t._bgColor.r,t._bgColor.g,t._bgColor.b,t._bgColor.a),e.clear(e.COLOR_BUFFER_BIT)),this.offset.x=this.game.camera._shake.x,this.offset.y=this.game.camera._shake.y,this.renderDisplayObject(t,this.projection)}},s.WebGLRenderer.prototype.renderDisplayObject=function(t,e,i,n){this.renderSession.blendModeManager.setBlendMode(s.blendModes.NORMAL),this.renderSession.drawCount=0,this.renderSession.flipY=i?-1:1,this.renderSession.projection=e,this.renderSession.offset=this.offset,this.spriteBatch.begin(this.renderSession),this.filterManager.begin(this.renderSession,i),t._renderWebGL(this.renderSession,n),this.spriteBatch.end()},s.WebGLRenderer.prototype.resize=function(t,e){this.width=t*this.resolution,this.height=e*this.resolution,this.view.width=this.width,this.view.height=this.height,this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px"),this.gl.viewport(0,0,this.width,this.height),this.projection.x=this.width/2/this.resolution,this.projection.y=-this.height/2/this.resolution},s.WebGLRenderer.prototype.updateCompressedTexture=function(t){if(!t.hasLoaded)return!1;var e=this.gl,i=t.source;return t._glTextures[e.id]||(t._glTextures[e.id]=e.createTexture()),e.activeTexture(e.TEXTURE0+t.textureIndex),e.bindTexture(e.TEXTURE_2D,t._glTextures[e.id]),e.compressedTexImage2D(e.TEXTURE_2D,0,i.glExtensionFormat,i.width,i.height,0,i.textureData),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t.scaleMode===s.scaleModes.LINEAR?e.LINEAR:e.NEAREST),t.mipmap&&Phaser.Math.isPowerOfTwo(t.width,t.height)?(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t.scaleMode===s.scaleModes.LINEAR?e.LINEAR_MIPMAP_LINEAR:e.NEAREST_MIPMAP_NEAREST),e.generateMipmap(e.TEXTURE_2D)):e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t.scaleMode===s.scaleModes.LINEAR?e.LINEAR:e.NEAREST),t._powerOf2?(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT)):(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)),t._dirty[e.id]=!1,!0},s.WebGLRenderer.prototype.updateTexture=function(t){if(!t.hasLoaded||!t.source)return!1;if(t.source.compressionAlgorithm)return this.updateCompressedTexture(t);var e=this.gl;return t._glTextures[e.id]||(t._glTextures[e.id]=e.createTexture()),e.activeTexture(e.TEXTURE0+t.textureIndex),e.bindTexture(e.TEXTURE_2D,t._glTextures[e.id]),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultipliedAlpha),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t.source),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t.scaleMode===s.scaleModes.LINEAR?e.LINEAR:e.NEAREST),t.mipmap&&Phaser.Math.isPowerOfTwo(t.width,t.height)?(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t.scaleMode===s.scaleModes.LINEAR?e.LINEAR_MIPMAP_LINEAR:e.NEAREST_MIPMAP_NEAREST),e.generateMipmap(e.TEXTURE_2D)):e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t.scaleMode===s.scaleModes.LINEAR?e.LINEAR:e.NEAREST),t._powerOf2?(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT)):(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)),t._dirty[e.id]=!1,!0},s.WebGLRenderer.prototype.destroy=function(){s.glContexts[this.glContextId]=null,this.projection=null,this.offset=null,this.shaderManager.destroy(),this.spriteBatch.destroy(),this.maskManager.destroy(),this.filterManager.destroy(),this.shaderManager=null,this.spriteBatch=null,this.maskManager=null,this.filterManager=null,this.gl=null,this.renderSession=null,Phaser.CanvasPool.remove(this),s.instances[this.glContextId]=null,s.WebGLRenderer.glContextId--},s.WebGLRenderer.prototype.mapBlendModes=function(){var t=this.gl;if(!s.blendModesWebGL){var e=[],i=s.blendModes;e[i.NORMAL]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.ADD]=[t.SRC_ALPHA,t.DST_ALPHA],e[i.MULTIPLY]=[t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA],e[i.SCREEN]=[t.SRC_ALPHA,t.ONE],e[i.OVERLAY]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.DARKEN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.LIGHTEN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.COLOR_DODGE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.COLOR_BURN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.HARD_LIGHT]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.SOFT_LIGHT]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.DIFFERENCE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.EXCLUSION]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.HUE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.SATURATION]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.COLOR]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.LUMINOSITY]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],s.blendModesWebGL=e}},s.WebGLRenderer.prototype.getMaxTextureUnit=function(){var t=this.gl;return t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS)},s.enableMultiTexture=function(){s._enableMultiTextureToggle=!0},s.WebGLRenderer.glContextId=0,s.WebGLRenderer.textureArray=[],s.WebGLBlendModeManager=function(){this.currentBlendMode=99999},s.WebGLBlendModeManager.prototype.constructor=s.WebGLBlendModeManager,s.WebGLBlendModeManager.prototype.setContext=function(t){this.gl=t},s.WebGLBlendModeManager.prototype.setBlendMode=function(t){if(this.currentBlendMode===t)return!1;this.currentBlendMode=t;var e=s.blendModesWebGL[this.currentBlendMode];return e&&this.gl.blendFunc(e[0],e[1]),!0},s.WebGLBlendModeManager.prototype.destroy=function(){this.gl=null},s.WebGLMaskManager=function(){},s.WebGLMaskManager.prototype.constructor=s.WebGLMaskManager,s.WebGLMaskManager.prototype.setContext=function(t){this.gl=t},s.WebGLMaskManager.prototype.pushMask=function(t,e){var i=e.gl;t.dirty&&s.WebGLGraphics.updateGraphics(t,i),void 0!==t._webGL[i.id]&&void 0!==t._webGL[i.id].data&&0!==t._webGL[i.id].data.length&&e.stencilManager.pushStencil(t,t._webGL[i.id].data[0],e)},s.WebGLMaskManager.prototype.popMask=function(t,e){var i=this.gl;void 0!==t._webGL[i.id]&&void 0!==t._webGL[i.id].data&&0!==t._webGL[i.id].data.length&&e.stencilManager.popStencil(t,t._webGL[i.id].data[0],e)},s.WebGLMaskManager.prototype.destroy=function(){this.gl=null},s.WebGLStencilManager=function(){this.stencilStack=[],this.reverse=!0,this.count=0},s.WebGLStencilManager.prototype.setContext=function(t){this.gl=t},s.WebGLStencilManager.prototype.pushStencil=function(t,e,i){var s=this.gl;this.bindGraphics(t,e,i),0===this.stencilStack.length&&(s.enable(s.STENCIL_TEST),s.clear(s.STENCIL_BUFFER_BIT),this.reverse=!0,this.count=0),this.stencilStack.push(e);var n=this.count;s.colorMask(!1,!1,!1,!1),s.stencilFunc(s.ALWAYS,0,255),s.stencilOp(s.KEEP,s.KEEP,s.INVERT),1===e.mode?(s.drawElements(s.TRIANGLE_FAN,e.indices.length-4,s.UNSIGNED_SHORT,0),this.reverse?(s.stencilFunc(s.EQUAL,255-n,255),s.stencilOp(s.KEEP,s.KEEP,s.DECR)):(s.stencilFunc(s.EQUAL,n,255),s.stencilOp(s.KEEP,s.KEEP,s.INCR)),s.drawElements(s.TRIANGLE_FAN,4,s.UNSIGNED_SHORT,2*(e.indices.length-4)),this.reverse?s.stencilFunc(s.EQUAL,255-(n+1),255):s.stencilFunc(s.EQUAL,n+1,255),this.reverse=!this.reverse):(this.reverse?(s.stencilFunc(s.EQUAL,n,255),s.stencilOp(s.KEEP,s.KEEP,s.INCR)):(s.stencilFunc(s.EQUAL,255-n,255),s.stencilOp(s.KEEP,s.KEEP,s.DECR)),s.drawElements(s.TRIANGLE_STRIP,e.indices.length,s.UNSIGNED_SHORT,0),this.reverse?s.stencilFunc(s.EQUAL,n+1,255):s.stencilFunc(s.EQUAL,255-(n+1),255)),s.colorMask(!0,!0,!0,!0),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),this.count++},s.WebGLStencilManager.prototype.bindGraphics=function(t,e,i){this._currentGraphics=t;var s,n=this.gl,r=i.projection,o=i.offset;1===e.mode?(s=i.shaderManager.complexPrimitiveShader,i.shaderManager.setShader(s),n.uniform1f(s.flipY,i.flipY),n.uniformMatrix3fv(s.translationMatrix,!1,t.worldTransform.toArray(!0)),n.uniform2f(s.projectionVector,r.x,-r.y),n.uniform2f(s.offsetVector,-o.x,-o.y),n.uniform3fv(s.tintColor,Phaser.Color.hexToRGBArray(t.tint)),n.uniform3fv(s.color,e.color),n.uniform1f(s.alpha,t.worldAlpha*e.alpha),n.bindBuffer(n.ARRAY_BUFFER,e.buffer),n.vertexAttribPointer(s.aVertexPosition,2,n.FLOAT,!1,8,0),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.indexBuffer)):(s=i.shaderManager.primitiveShader,i.shaderManager.setShader(s),n.uniformMatrix3fv(s.translationMatrix,!1,t.worldTransform.toArray(!0)),n.uniform1f(s.flipY,i.flipY),n.uniform2f(s.projectionVector,r.x,-r.y),n.uniform2f(s.offsetVector,-o.x,-o.y),n.uniform3fv(s.tintColor,Phaser.Color.hexToRGBArray(t.tint)),n.uniform1f(s.alpha,t.worldAlpha),n.bindBuffer(n.ARRAY_BUFFER,e.buffer),n.vertexAttribPointer(s.aVertexPosition,2,n.FLOAT,!1,24,0),n.vertexAttribPointer(s.colorAttribute,4,n.FLOAT,!1,24,8),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.indexBuffer))},s.WebGLStencilManager.prototype.popStencil=function(t,e,i){var s=this.gl;if(this.stencilStack.pop(),this.count--,0===this.stencilStack.length)s.disable(s.STENCIL_TEST);else{var n=this.count;this.bindGraphics(t,e,i),s.colorMask(!1,!1,!1,!1),1===e.mode?(this.reverse=!this.reverse,this.reverse?(s.stencilFunc(s.EQUAL,255-(n+1),255),s.stencilOp(s.KEEP,s.KEEP,s.INCR)):(s.stencilFunc(s.EQUAL,n+1,255),s.stencilOp(s.KEEP,s.KEEP,s.DECR)),s.drawElements(s.TRIANGLE_FAN,4,s.UNSIGNED_SHORT,2*(e.indices.length-4)),s.stencilFunc(s.ALWAYS,0,255),s.stencilOp(s.KEEP,s.KEEP,s.INVERT),s.drawElements(s.TRIANGLE_FAN,e.indices.length-4,s.UNSIGNED_SHORT,0),this.reverse?s.stencilFunc(s.EQUAL,n,255):s.stencilFunc(s.EQUAL,255-n,255)):(this.reverse?(s.stencilFunc(s.EQUAL,n+1,255),s.stencilOp(s.KEEP,s.KEEP,s.DECR)):(s.stencilFunc(s.EQUAL,255-(n+1),255),s.stencilOp(s.KEEP,s.KEEP,s.INCR)),s.drawElements(s.TRIANGLE_STRIP,e.indices.length,s.UNSIGNED_SHORT,0),this.reverse?s.stencilFunc(s.EQUAL,n,255):s.stencilFunc(s.EQUAL,255-n,255)),s.colorMask(!0,!0,!0,!0),s.stencilOp(s.KEEP,s.KEEP,s.KEEP)}},s.WebGLStencilManager.prototype.destroy=function(){this.stencilStack=null,this.gl=null},s.WebGLShaderManager=function(){this.maxAttibs=10,this.attribState=[],this.tempAttribState=[];for(var t=0;t<this.maxAttibs;t++)this.attribState[t]=!1;this.stack=[]},s.WebGLShaderManager.prototype.constructor=s.WebGLShaderManager,s.WebGLShaderManager.prototype.setContext=function(t){this.gl=t,this.primitiveShader=new s.PrimitiveShader(t),this.complexPrimitiveShader=new s.ComplexPrimitiveShader(t),this.defaultShader=new s.PixiShader(t),this.fastShader=new s.PixiFastShader(t),this.stripShader=new s.StripShader(t),this.creatureShader=s.CreatureShader?new s.CreatureShader(t):null,this.setShader(this.defaultShader)},s.WebGLShaderManager.prototype.setAttribs=function(t){var e;for(e=0;e<this.tempAttribState.length;e++)this.tempAttribState[e]=!1;for(e=0;e<t.length;e++){var i=t[e];this.tempAttribState[i]=!0}var s=this.gl;for(e=0;e<this.attribState.length;e++)this.attribState[e]!==this.tempAttribState[e]&&(this.attribState[e]=this.tempAttribState[e],this.tempAttribState[e]?s.enableVertexAttribArray(e):s.disableVertexAttribArray(e))},s.WebGLShaderManager.prototype.setShader=function(t){return this._currentId!==t._UID&&(this._currentId=t._UID,this.currentShader=t,this.gl.useProgram(t.program),this.setAttribs(t.attributes),!0)},s.WebGLShaderManager.prototype.destroy=function(){this.attribState=null,this.tempAttribState=null,this.primitiveShader.destroy(),this.complexPrimitiveShader.destroy(),this.defaultShader.destroy(),this.fastShader.destroy(),this.stripShader.destroy(),this.creatureShader&&this.creatureShader.destroy(),this.gl=null},s.WebGLSpriteBatch=function(t){this.game=t,this.vertSize=5,this.size=2e3,this.vertexSize=24;var e=this.vertexSize*this.size*4,i=6*this.size;this.vertices=new ArrayBuffer(e),this.positions=new Float32Array(this.vertices),this.colors=new Uint32Array(this.vertices),this.indices=new Uint16Array(i),this.lastIndexCount=0;for(var s=0,n=0;s<i;s+=6,n+=4)this.indices[s+0]=n+0,this.indices[s+1]=n+1,this.indices[s+2]=n+2,this.indices[s+3]=n+0,this.indices[s+4]=n+2,this.indices[s+5]=n+3;this.drawing=!1,this.currentBatchSize=0,this.currentBaseTexture=null,this.dirty=!0,this.textures=[],this.blendModes=[],this.shaders=[],this.sprites=[],this.defaultShader=null},s.WebGLSpriteBatch.prototype.setContext=function(t){if(this.MAX_TEXTURES=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.gl=t,s._enableMultiTextureToggle){for(var e="\tif (vTextureIndex == 0.0) {gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;return;}\n",i=1;i<this.MAX_TEXTURES;++i)e+="\tif (vTextureIndex == "+i+".0) {gl_FragColor = texture2D(uSamplerArray["+i+"], vTextureCoord) * vColor;return;}\n";this.defaultShader=new Phaser.Filter(this.game,void 0,["//WebGLSpriteBatch Fragment Shader.","precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","uniform sampler2D uSamplerArray["+this.MAX_TEXTURES+"];","void main(void) {",e,"\tgl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;","}"])}else this.defaultShader=new Phaser.Filter(this.game,void 0,["//WebGLSpriteBatch Fragment Shader.","precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;","}"]);this.vertexBuffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.indices,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertices,t.DYNAMIC_DRAW),this.currentBlendMode=99999;var n=new s.PixiShader(t);n.fragmentSrc=this.defaultShader.fragmentSrc,n.uniforms={},n.init(),this.defaultShader.shaders[t.id]=n},s.WebGLSpriteBatch.prototype.begin=function(t){this.renderSession=t,this.shader=this.renderSession.shaderManager.defaultShader,this.start()},s.WebGLSpriteBatch.prototype.end=function(){this.flush()},s.WebGLSpriteBatch.prototype.render=function(t,e){var i=t.texture,s=t.worldTransform;e&&(s=e),this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=i.baseTexture);var n=i._uvs;if(n){var r,o,a,h,l=t.anchor.x,c=t.anchor.y;if(i.trim){var u=i.trim;r=(o=u.x-l*u.width)+i.crop.width,a=(h=u.y-c*u.height)+i.crop.height}else r=i.frame.width*(1-l),o=i.frame.width*-l,a=i.frame.height*(1-c),h=i.frame.height*-c;var d=this.currentBatchSize*this.vertexSize,p=i.baseTexture.resolution,f=i.baseTexture.textureIndex,g=s.a/p,m=s.b/p,y=s.c/p,v=s.d/p,x=s.tx,b=s.ty,_=i.crop.height;if(i.rotated){var w=s.a,T=s.b,P=s.c,C=s.d,S=o,A=r;x=s.c*_+x,b=s.d*_+b,g=6.123233995736766e-17*w-P,m=6.123233995736766e-17*T-C,y=w+6.123233995736766e-17*P,v=T+6.123233995736766e-17*C,i._updateUvsInverted(),r=a,o=h,a=A,h=S}var E=this.colors,M=this.positions,R=t.tint,L=(R>>16)+(65280&R)+((255&R)<<16)+(255*t.worldAlpha<<24);this.renderSession.roundPixels?(M[d++]=g*o+y*h+x|0,M[d++]=v*h+m*o+b|0,M[d++]=n.x0,M[d++]=n.y0,E[d++]=L,M[d++]=f,M[d++]=g*r+y*h+x|0,M[d++]=v*h+m*r+b|0,M[d++]=n.x1,M[d++]=n.y1,E[d++]=L,M[d++]=f,M[d++]=g*r+y*a+x|0,M[d++]=v*a+m*r+b|0,M[d++]=n.x2,M[d++]=n.y2,E[d++]=L,M[d++]=f,M[d++]=g*o+y*a+x|0,M[d++]=v*a+m*o+b|0,M[d++]=n.x3,M[d++]=n.y3,E[d++]=L,M[d++]=f):(M[d++]=g*o+y*h+x,M[d++]=v*h+m*o+b,M[d++]=n.x0,M[d++]=n.y0,E[d++]=L,M[d++]=f,M[d++]=g*r+y*h+x,M[d++]=v*h+m*r+b,M[d++]=n.x1,M[d++]=n.y1,E[d++]=L,M[d++]=f,M[d++]=g*r+y*a+x,M[d++]=v*a+m*r+b,M[d++]=n.x2,M[d++]=n.y2,E[d++]=L,M[d++]=f,M[d++]=g*o+y*a+x,M[d++]=v*a+m*o+b,M[d++]=n.x3,M[d++]=n.y3,E[d++]=L,M[d++]=f),this.sprites[this.currentBatchSize++]=t}},s.WebGLSpriteBatch.prototype.renderTilingSprite=function(t){var e=t.tilingTexture,i=t.texture.baseTexture.textureIndex;this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=e.baseTexture),t._uvs||(t._uvs=new s.TextureUvs);var n=t._uvs,r=e.baseTexture.width,o=e.baseTexture.height;t.tilePosition.x%=r*t.tileScaleOffset.x,t.tilePosition.y%=o*t.tileScaleOffset.y;var a=t.tilePosition.x/(r*t.tileScaleOffset.x),h=t.tilePosition.y/(o*t.tileScaleOffset.y),l=t.width/r/(t.tileScale.x*t.tileScaleOffset.x),c=t.height/o/(t.tileScale.y*t.tileScaleOffset.y);n.x0=0-a,n.y0=0-h,n.x1=1*l-a,n.y1=0-h,n.x2=1*l-a,n.y2=1*c-h,n.x3=0-a,n.y3=1*c-h;var u=t.tint,d=(u>>16)+(65280&u)+((255&u)<<16)+(255*t.worldAlpha<<24),p=this.positions,f=this.colors,g=t.width,m=t.height,y=t.anchor.x,v=t.anchor.y,x=g*(1-y),b=g*-y,_=m*(1-v),w=m*-v,T=this.currentBatchSize*this.vertexSize,P=e.baseTexture.resolution,C=t.worldTransform,S=C.a/P,A=C.b/P,E=C.c/P,M=C.d/P,R=C.tx,L=C.ty;p[T++]=S*b+E*w+R,p[T++]=M*w+A*b+L,p[T++]=n.x0,p[T++]=n.y0,f[T++]=d,p[T++]=i,p[T++]=S*x+E*w+R,p[T++]=M*w+A*x+L,p[T++]=n.x1,p[T++]=n.y1,f[T++]=d,p[T++]=i,p[T++]=S*x+E*_+R,p[T++]=M*_+A*x+L,p[T++]=n.x2,p[T++]=n.y2,f[T++]=d,p[T++]=i,p[T++]=S*b+E*_+R,p[T++]=M*_+A*b+L,p[T++]=n.x3,p[T++]=n.y3,f[T++]=d,p[T++]=i,this.sprites[this.currentBatchSize++]=t},s.WebGLSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var t,e=this.gl;if(this.dirty){this.dirty=!1,t=this.defaultShader.shaders[e.id],e.activeTexture(e.TEXTURE0),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var i=this.vertexSize;e.vertexAttribPointer(t.aVertexPosition,2,e.FLOAT,!1,i,0),e.vertexAttribPointer(t.aTextureCoord,2,e.FLOAT,!1,i,8),e.vertexAttribPointer(t.colorAttribute,4,e.UNSIGNED_BYTE,!0,i,16),e.vertexAttribPointer(t.aTextureIndex,1,e.FLOAT,!1,i,20)}if(this.currentBatchSize>.5*this.size)e.bufferSubData(e.ARRAY_BUFFER,0,this.vertices);else{e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer);var n=this.positions.subarray(0,this.currentBatchSize*this.vertexSize);e.bufferSubData(e.ARRAY_BUFFER,0,n)}for(var r,o,a,h,l=0,c=0,u=null,d=this.renderSession.blendModeManager.currentBlendMode,p=null,f=!1,g=!1,m=0,y=this.currentBatchSize;m<y;m++){r=(h=this.sprites[m]).tilingTexture?h.tilingTexture.baseTexture:h.texture.baseTexture,f=d!==(o=h.blendMode),g=p!==(a=h.shader||this.defaultShader);var v=r.skipRender;if(v&&h.children.length>0&&(v=!1),(u!==r&&!v||f||g)&&(this.renderBatch(u,l,c),c=m,l=0,u=r,f&&(d=o,this.renderSession.blendModeManager.setBlendMode(d)),g)){(t=(p=a).shaders[e.id])||((t=new s.PixiShader(e)).fragmentSrc=p.fragmentSrc,t.uniforms=p.uniforms,t.init(),p.shaders[e.id]=t),this.renderSession.shaderManager.setShader(t),t.dirty&&t.syncUniforms();var x=this.renderSession.projection;e.uniform2f(t.projectionVector,x.x,x.y);var b=this.renderSession.offset;e.uniform2f(t.offsetVector,b.x,b.y)}l++}this.renderBatch(u,l,c),this.currentBatchSize=0}},s.WebGLSpriteBatch.prototype.renderBatch=function(t,e,i){if(0!==e){var s=this.gl;if(t._dirty[s.id]){if(!this.renderSession.renderer.updateTexture(t))return}else s.bindTexture(s.TEXTURE_2D,t._glTextures[s.id]);s.drawElements(s.TRIANGLES,6*e,s.UNSIGNED_SHORT,6*i*2),this.renderSession.drawCount++}},s.WebGLSpriteBatch.prototype.stop=function(){this.flush(),this.dirty=!0},s.WebGLSpriteBatch.prototype.start=function(){this.dirty=!0},s.WebGLSpriteBatch.prototype.destroy=function(){this.vertices=null,this.indices=null,this.gl.deleteBuffer(this.vertexBuffer),this.gl.deleteBuffer(this.indexBuffer),this.currentBaseTexture=null,this.gl=null},s.WebGLFastSpriteBatch=function(t){this.vertSize=11,this.maxSize=6e3,this.size=this.maxSize;var e=4*this.size*this.vertSize,i=6*this.maxSize;this.vertices=new Float32Array(e),this.indices=new Uint16Array(i),this.vertexBuffer=null,this.indexBuffer=null,this.lastIndexCount=0;for(var s=0,n=0;s<i;s+=6,n+=4)this.indices[s+0]=n+0,this.indices[s+1]=n+1,this.indices[s+2]=n+2,this.indices[s+3]=n+0,this.indices[s+4]=n+2,this.indices[s+5]=n+3;this.drawing=!1,this.currentBatchSize=0,this.currentBaseTexture=null,this.currentBlendMode=0,this.renderSession=null,this.shader=null,this.matrix=null,this.setContext(t)},s.WebGLFastSpriteBatch.prototype.constructor=s.WebGLFastSpriteBatch,s.WebGLFastSpriteBatch.prototype.setContext=function(t){this.gl=t,this.vertexBuffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.indices,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertices,t.DYNAMIC_DRAW)},s.WebGLFastSpriteBatch.prototype.begin=function(t,e){this.renderSession=e,this.shader=this.renderSession.shaderManager.fastShader,this.matrix=t.worldTransform.toArray(!0),this.start()},s.WebGLFastSpriteBatch.prototype.end=function(){this.flush()},s.WebGLFastSpriteBatch.prototype.render=function(t){var e=t.children,i=e[0];if(i.texture._uvs){this.currentBaseTexture=i.texture.baseTexture,i.blendMode!==this.renderSession.blendModeManager.currentBlendMode&&(this.flush(),this.renderSession.blendModeManager.setBlendMode(i.blendMode));var n=this.currentBaseTexture.textureIndex,r=this.gl;r.activeTexture(r.TEXTURE0+n),r.bindTexture(r.TEXTURE_2D,this.currentBaseTexture._glTextures[r.id]),s.WebGLRenderer.textureArray[n]=this.currentBaseTexture;for(var o=0,a=e.length;o<a;o++)this.renderSprite(e[o]);this.flush()}},s.WebGLFastSpriteBatch.prototype.renderSprite=function(t){var e=t.texture.baseTexture,i=this.gl,n=t.texture.baseTexture.textureIndex;if((s.WebGLRenderer.textureArray[n]==e||!e._glTextures[i.id]||t.texture.baseTexture.skipRender||(this.flush(),i.activeTexture(i.TEXTURE0+n),i.bindTexture(i.TEXTURE_2D,e._glTextures[i.id]),s.WebGLRenderer.textureArray[n]=e,t.texture._uvs))&&t.visible){var r,o,a,h,l,c,u,d,p=this.vertices;if(r=t.texture._uvs,o=t.texture.frame.width,a=t.texture.frame.height,t.texture.trim){var f=t.texture.trim;h=(l=f.x-t.anchor.x*f.width)+t.texture.crop.width,c=(u=f.y-t.anchor.y*f.height)+t.texture.crop.height}else h=o*(1-t.anchor.x),l=o*-t.anchor.x,c=a*(1-t.anchor.y),u=a*-t.anchor.y;d=4*this.currentBatchSize*this.vertSize,p[d++]=l,p[d++]=u,p[d++]=t.position.x,p[d++]=t.position.y,p[d++]=t.scale.x,p[d++]=t.scale.y,p[d++]=t.rotation,p[d++]=r.x0,p[d++]=r.y1,p[d++]=t.alpha,p[d++]=n,p[d++]=h,p[d++]=u,p[d++]=t.position.x,p[d++]=t.position.y,p[d++]=t.scale.x,p[d++]=t.scale.y,p[d++]=t.rotation,p[d++]=r.x1,p[d++]=r.y1,p[d++]=t.alpha,p[d++]=n,p[d++]=h,p[d++]=c,p[d++]=t.position.x,p[d++]=t.position.y,p[d++]=t.scale.x,p[d++]=t.scale.y,p[d++]=t.rotation,p[d++]=r.x2,p[d++]=r.y2,p[d++]=t.alpha,p[d++]=n,p[d++]=l,p[d++]=c,p[d++]=t.position.x,p[d++]=t.position.y,p[d++]=t.scale.x,p[d++]=t.scale.y,p[d++]=t.rotation,p[d++]=r.x3,p[d++]=r.y3,p[d++]=t.alpha,p[d++]=n,++this.currentBatchSize>=this.size&&this.flush()}},s.WebGLFastSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var t=this.gl;if(this.currentBaseTexture._glTextures[t.id]){if(this.currentBatchSize>.5*this.size)t.bufferSubData(t.ARRAY_BUFFER,0,this.vertices);else{var e=this.vertices.subarray(0,4*this.currentBatchSize*this.vertSize);t.bufferSubData(t.ARRAY_BUFFER,0,e)}t.drawElements(t.TRIANGLES,6*this.currentBatchSize,t.UNSIGNED_SHORT,0),this.currentBatchSize=0,this.renderSession.drawCount++}else this.renderSession.renderer.updateTexture(this.currentBaseTexture,t)}},s.WebGLFastSpriteBatch.prototype.stop=function(){this.flush()},s.WebGLFastSpriteBatch.prototype.start=function(){var t=this.gl;t.activeTexture(t.TEXTURE0),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var e=this.renderSession.projection;t.uniform2f(this.shader.projectionVector,e.x,e.y),t.uniformMatrix3fv(this.shader.uMatrix,!1,this.matrix);var i=4*this.vertSize;t.vertexAttribPointer(this.shader.aVertexPosition,2,t.FLOAT,!1,i,0),t.vertexAttribPointer(this.shader.aPositionCoord,2,t.FLOAT,!1,i,8),t.vertexAttribPointer(this.shader.aScale,2,t.FLOAT,!1,i,16),t.vertexAttribPointer(this.shader.aRotation,1,t.FLOAT,!1,i,24),t.vertexAttribPointer(this.shader.aTextureCoord,2,t.FLOAT,!1,i,28),t.vertexAttribPointer(this.shader.colorAttribute,1,t.FLOAT,!1,i,36),t.vertexAttribPointer(this.shader.aTextureIndex,1,t.FLOAT,!1,i,40)},s.WebGLFilterManager=function(){this.filterStack=[],this.offsetX=0,this.offsetY=0},s.WebGLFilterManager.prototype.constructor=s.WebGLFilterManager,s.WebGLFilterManager.prototype.setContext=function(t){this.gl=t,this.texturePool=[],this.initShaderBuffers()},s.WebGLFilterManager.prototype.begin=function(t,e){this.renderSession=t,this.defaultShader=t.shaderManager.defaultShader;var i=this.renderSession.projection;this.width=2*i.x,this.height=2*-i.y,this.buffer=e},s.WebGLFilterManager.prototype.pushFilter=function(t){var e=this.gl,i=this.renderSession.projection,n=this.renderSession.offset;t._filterArea=t.target.filterArea||t.target.getBounds(),t._previous_stencil_mgr=this.renderSession.stencilManager,this.renderSession.stencilManager=new s.WebGLStencilManager,this.renderSession.stencilManager.setContext(e),e.disable(e.STENCIL_TEST),this.filterStack.push(t);var r=t.filterPasses[0];this.offsetX+=t._filterArea.x,this.offsetY+=t._filterArea.y;var o=this.texturePool.pop();o?o.resize(this.width*this.renderSession.resolution,this.height*this.renderSession.resolution):o=new s.FilterTexture(this.gl,this.width*this.renderSession.resolution,this.height*this.renderSession.resolution),e.bindTexture(e.TEXTURE_2D,o.texture);var a=t._filterArea,h=r.padding;a.x-=h,a.y-=h,a.width+=2*h,a.height+=2*h,a.x<0&&(a.x=0),a.width>this.width&&(a.width=this.width),a.y<0&&(a.y=0),a.height>this.height&&(a.height=this.height),e.bindFramebuffer(e.FRAMEBUFFER,o.frameBuffer),e.viewport(0,0,a.width*this.renderSession.resolution,a.height*this.renderSession.resolution),i.x=a.width/2,i.y=-a.height/2,n.x=-a.x,n.y=-a.y,e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),t._glFilterTexture=o},s.WebGLFilterManager.prototype.popFilter=function(){var t=this.gl,e=this.filterStack.pop(),i=e._filterArea,n=e._glFilterTexture,r=this.renderSession.projection,o=this.renderSession.offset;if(e.filterPasses.length>1){t.viewport(0,0,i.width*this.renderSession.resolution,i.height*this.renderSession.resolution),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=0,this.vertexArray[1]=i.height,this.vertexArray[2]=i.width,this.vertexArray[3]=i.height,this.vertexArray[4]=0,this.vertexArray[5]=0,this.vertexArray[6]=i.width,this.vertexArray[7]=0,t.bufferSubData(t.ARRAY_BUFFER,0,this.vertexArray),t.bindBuffer(t.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=i.width/this.width,this.uvArray[5]=i.height/this.height,this.uvArray[6]=i.width/this.width,this.uvArray[7]=i.height/this.height,t.bufferSubData(t.ARRAY_BUFFER,0,this.uvArray);var a=n,h=this.texturePool.pop();h||(h=new s.FilterTexture(this.gl,this.width*this.renderSession.resolution,this.height*this.renderSession.resolution)),h.resize(this.width*this.renderSession.resolution,this.height*this.renderSession.resolution),t.bindFramebuffer(t.FRAMEBUFFER,h.frameBuffer),t.clear(t.COLOR_BUFFER_BIT),t.disable(t.BLEND);for(var l=0;l<e.filterPasses.length-1;l++){var c=e.filterPasses[l];t.bindFramebuffer(t.FRAMEBUFFER,h.frameBuffer),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,a.texture),this.applyFilterPass(c,i,i.width,i.height);var u=a;a=h,h=u}t.enable(t.BLEND),n=a,this.texturePool.push(h)}var d=e.filterPasses[e.filterPasses.length-1];this.offsetX-=i.x,this.offsetY-=i.y;var p=this.width,f=this.height,g=0,m=0,y=this.buffer;if(0===this.filterStack.length)t.colorMask(!0,!0,!0,!0);else{var v=this.filterStack[this.filterStack.length-1];p=(i=v._filterArea).width,f=i.height,g=i.x,m=i.y,y=v._glFilterTexture.frameBuffer}r.x=p/2,r.y=-f/2,o.x=g,o.y=m;var x=(i=e._filterArea).x-g,b=i.y-m;t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=x,this.vertexArray[1]=b+i.height,this.vertexArray[2]=x+i.width,this.vertexArray[3]=b+i.height,this.vertexArray[4]=x,this.vertexArray[5]=b,this.vertexArray[6]=x+i.width,this.vertexArray[7]=b,t.bufferSubData(t.ARRAY_BUFFER,0,this.vertexArray),t.bindBuffer(t.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=i.width/this.width,this.uvArray[5]=i.height/this.height,this.uvArray[6]=i.width/this.width,this.uvArray[7]=i.height/this.height,t.bufferSubData(t.ARRAY_BUFFER,0,this.uvArray),t.viewport(0,0,p*this.renderSession.resolution,f*this.renderSession.resolution),t.bindFramebuffer(t.FRAMEBUFFER,y),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,n.texture),this.renderSession.stencilManager&&this.renderSession.stencilManager.destroy(),this.renderSession.stencilManager=e._previous_stencil_mgr,e._previous_stencil_mgr=null,this.renderSession.stencilManager.count>0?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.applyFilterPass(d,i,p,f),this.texturePool.push(n),e._glFilterTexture=null},s.WebGLFilterManager.prototype.applyFilterPass=function(t,e,i,n){var r=this.gl,o=t.shaders[r.id];o||((o=new s.PixiShader(r)).fragmentSrc=t.fragmentSrc,o.uniforms=t.uniforms,o.init(!0),t.shaders[r.id]=o),this.renderSession.shaderManager.setShader(o),r.uniform2f(o.projectionVector,i/2,-n/2),r.uniform2f(o.offsetVector,0,0),t.uniforms.dimensions&&(t.uniforms.dimensions.value[0]=this.width,t.uniforms.dimensions.value[1]=this.height,t.uniforms.dimensions.value[2]=this.vertexArray[0],t.uniforms.dimensions.value[3]=this.vertexArray[5]),o.syncUniforms(),r.bindBuffer(r.ARRAY_BUFFER,this.vertexBuffer),r.vertexAttribPointer(o.aVertexPosition,2,r.FLOAT,!1,0,0),r.bindBuffer(r.ARRAY_BUFFER,this.uvBuffer),r.vertexAttribPointer(o.aTextureCoord,2,r.FLOAT,!1,0,0),r.bindBuffer(r.ARRAY_BUFFER,this.colorBuffer),r.vertexAttribPointer(o.colorAttribute,2,r.FLOAT,!1,0,0),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,this.indexBuffer),r.drawElements(r.TRIANGLES,6,r.UNSIGNED_SHORT,0),this.renderSession.drawCount++},s.WebGLFilterManager.prototype.initShaderBuffers=function(){var t=this.gl;this.vertexBuffer=t.createBuffer(),this.uvBuffer=t.createBuffer(),this.colorBuffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),this.vertexArray=new Float32Array([0,0,1,0,0,1,1,1]),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertexArray,t.STATIC_DRAW),this.uvArray=new Float32Array([0,0,1,0,0,1,1,1]),t.bindBuffer(t.ARRAY_BUFFER,this.uvBuffer),t.bufferData(t.ARRAY_BUFFER,this.uvArray,t.STATIC_DRAW),this.colorArray=new Float32Array([1,16777215,1,16777215,1,16777215,1,16777215]),t.bindBuffer(t.ARRAY_BUFFER,this.colorBuffer),t.bufferData(t.ARRAY_BUFFER,this.colorArray,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,new Uint16Array([0,1,2,1,3,2]),t.STATIC_DRAW)},s.WebGLFilterManager.prototype.destroy=function(){var t=this.gl;this.filterStack=null,this.offsetX=0,this.offsetY=0;for(var e=0;e<this.texturePool.length;e++)this.texturePool[e].destroy();this.texturePool=null,t.deleteBuffer(this.vertexBuffer),t.deleteBuffer(this.uvBuffer),t.deleteBuffer(this.colorBuffer),t.deleteBuffer(this.indexBuffer)};var n={36054:"Incomplete attachment",36055:"Missing attachment",36057:"Incomplete dimensions",36061:"Framebuffer unsupported"};return s.FilterTexture=function(t,i,n,r,o){o="number"==typeof o?o:0,this.gl=t,this.frameBuffer=e(t,i,n,r||s.scaleModes.DEFAULT,o),this.texture=this.frameBuffer.targetTexture,this.width=i,this.height=n,this.renderBuffer=this.frameBuffer.renderBuffer},s.FilterTexture.prototype.constructor=s.FilterTexture,s.FilterTexture.prototype.clear=function(){var t=this.gl;t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT)},s.FilterTexture.prototype.resize=function(t,e){if(this.width!==t||this.height!==e){this.width=t,this.height=e;var i=this.gl;i.bindTexture(i.TEXTURE_2D,this.texture),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,t,e,0,i.RGBA,i.UNSIGNED_BYTE,null),i.bindRenderbuffer(i.RENDERBUFFER,this.renderBuffer),i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,t,e)}},s.FilterTexture.prototype.destroy=function(){var t=this.gl;t.deleteFramebuffer(this.frameBuffer),t.deleteTexture(this.texture),this.frameBuffer=null,this.texture=null},s.CanvasBuffer=function(t,e){this.width=t,this.height=e,this.canvas=Phaser.CanvasPool.create(this,this.width,this.height),this.context=this.canvas.getContext("2d"),this.canvas.width=t,this.canvas.height=e},s.CanvasBuffer.prototype.constructor=s.CanvasBuffer,s.CanvasBuffer.prototype.clear=function(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.width,this.height)},s.CanvasBuffer.prototype.resize=function(t,e){this.width=this.canvas.width=t,this.height=this.canvas.height=e},s.CanvasBuffer.prototype.destroy=function(){Phaser.CanvasPool.remove(this)},s.CanvasMaskManager=function(){},s.CanvasMaskManager.prototype.constructor=s.CanvasMaskManager,s.CanvasMaskManager.prototype.pushMask=function(t,e){var i=e.context;i.save();var n=t.alpha,r=t.worldTransform,o=e.resolution;i.setTransform(r.a*o,r.b*o,r.c*o,r.d*o,r.tx*o,r.ty*o),s.CanvasGraphics.renderGraphicsMask(t,i),i.clip(),t.worldAlpha=n},s.CanvasMaskManager.prototype.popMask=function(t){t.context.restore()},s.CanvasTinter=function(){},s.CanvasTinter.getTintedTexture=function(t,e){var i=t.tintedTexture||Phaser.CanvasPool.create(this);return s.CanvasTinter.tintMethod(t.texture,e,i),i},s.CanvasTinter.tintWithMultiply=function(t,e,i){var s=i.getContext("2d"),n=t.crop,r=n.width,o=n.height;t.rotated&&(r=o,o=n.width),i.width===r&&i.height===o||(i.width=r,i.height=o),s.clearRect(0,0,r,o),s.fillStyle="#"+("00000"+(0|e).toString(16)).substr(-6),s.fillRect(0,0,r,o),s.globalCompositeOperation="multiply",s.drawImage(t.baseTexture.source,n.x,n.y,r,o,0,0,r,o),s.globalCompositeOperation="destination-atop",s.drawImage(t.baseTexture.source,n.x,n.y,r,o,0,0,r,o)},s.CanvasTinter.tintWithPerPixel=function(t,e,i){var n=i.getContext("2d"),r=t.crop,o=r.width,a=r.height;t.rotated&&(o=a,a=r.width),i.width===o&&i.height===a||(i.width=o,i.height=a),n.globalCompositeOperation="copy",n.drawImage(t.baseTexture.source,r.x,r.y,o,a,0,0,o,a);for(var h=Phaser.Color.hexToRGBArray(e),l=h[0],c=h[1],u=h[2],d=n.getImageData(0,0,o,a),p=d.data,f=0;f<p.length;f+=4)if(p[f+0]*=l,p[f+1]*=c,p[f+2]*=u,!s.CanvasTinter.canHandleAlpha){var g=p[f+3];p[f+0]/=255/g,p[f+1]/=255/g,p[f+2]/=255/g}n.putImageData(d,0,0)},s.CanvasRenderer=function(t,e){if(this.game=t,s.defaultRenderer||(s.defaultRenderer=this),this.type=Phaser.CANVAS,this.resolution=t.resolution,this.clearBeforeRender=t.clearBeforeRender,this.transparent=t.transparent,this.autoResize=!1,this.width=t.width*this.resolution,this.height=t.height*this.resolution,this.view=t.canvas,this.context=this.view.getContext("2d",{alpha:this.transparent}),!this.context)throw new Error("Failed to create a Canvas 2d context.");this.refresh=!0,this.count=0,this.maskManager=new s.CanvasMaskManager,this.renderSession={context:this.context,maskManager:this.maskManager,scaleMode:null,smoothProperty:Phaser.Canvas.getSmoothingPrefix(this.context),roundPixels:e.roundPixels||!1},this.mapBlendModes(),this.resize(this.width,this.height)},s.CanvasRenderer.prototype.constructor=s.CanvasRenderer,s.CanvasRenderer.prototype.render=function(t){this.context.setTransform(1,0,0,1,0,0),this.context.globalAlpha=1,this.renderSession.currentBlendMode=0,this.renderSession.shakeX=this.game.camera._shake.x,this.renderSession.shakeY=this.game.camera._shake.y,this.context.globalCompositeOperation="source-over",navigator.isCocoonJS&&this.view.screencanvas&&(this.context.fillStyle="black",this.context.clear()),this.clearBeforeRender&&(this.transparent?this.context.clearRect(0,0,this.width,this.height):t._bgColor&&(this.context.fillStyle=t._bgColor.rgba,this.context.fillRect(0,0,this.width,this.height))),this.renderDisplayObject(t)},s.CanvasRenderer.prototype.setTexturePriority=function(){},s.CanvasRenderer.prototype.destroy=function(t){void 0===t&&(t=!0),t&&this.view.parent&&this.view.parent.removeChild(this.view),this.view=null,this.context=null,this.maskManager=null,this.renderSession=null},s.CanvasRenderer.prototype.resize=function(t,e){this.width=t*this.resolution,this.height=e*this.resolution,this.view.width=this.width,this.view.height=this.height,this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px"),this.renderSession.smoothProperty&&(this.context[this.renderSession.smoothProperty]=this.renderSession.scaleMode===s.scaleModes.LINEAR)},s.CanvasRenderer.prototype.renderDisplayObject=function(t,e,i){this.renderSession.context=e||this.context,this.renderSession.resolution=this.resolution,t._renderCanvas(this.renderSession,i)},s.CanvasRenderer.prototype.mapBlendModes=function(){if(!s.blendModesCanvas){var t=[],e=s.blendModes,i=this.game.device.canUseMultiply;t[e.NORMAL]="source-over",t[e.ADD]="lighter",t[e.MULTIPLY]=i?"multiply":"source-over",t[e.SCREEN]=i?"screen":"source-over",t[e.OVERLAY]=i?"overlay":"source-over",t[e.DARKEN]=i?"darken":"source-over",t[e.LIGHTEN]=i?"lighten":"source-over",t[e.COLOR_DODGE]=i?"color-dodge":"source-over",t[e.COLOR_BURN]=i?"color-burn":"source-over",t[e.HARD_LIGHT]=i?"hard-light":"source-over",t[e.SOFT_LIGHT]=i?"soft-light":"source-over",t[e.DIFFERENCE]=i?"difference":"source-over",t[e.EXCLUSION]=i?"exclusion":"source-over",t[e.HUE]=i?"hue":"source-over",t[e.SATURATION]=i?"saturation":"source-over",t[e.COLOR]=i?"color":"source-over",t[e.LUMINOSITY]=i?"luminosity":"source-over",s.blendModesCanvas=t}},s.BaseTexture=function(t,e,i){this.resolution=i||1,this.width=100,this.height=100,this.scaleMode=e||s.scaleModes.DEFAULT,this.hasLoaded=!1,this.source=t,this.premultipliedAlpha=!0,this._glTextures=[],this.mipmap=!1,this.textureIndex=0,this._dirty=[!0,!0,!0,!0],t&&((this.source.complete||this.source.getContext)&&this.source.width&&this.source.height&&(this.hasLoaded=!0,this.width=this.source.naturalWidth||this.source.width,this.height=this.source.naturalHeight||this.source.height,this.dirty()),this.skipRender=!1,this._powerOf2=!1)},s.BaseTexture.prototype.constructor=s.BaseTexture,s.BaseTexture.prototype.forceLoaded=function(t,e){this.hasLoaded=!0,this.width=t,this.height=e,this.dirty()},s.BaseTexture.prototype.destroy=function(){this.source&&Phaser.CanvasPool.removeByCanvas(this.source),this.source=null,this.unloadFromGPU()},s.BaseTexture.prototype.dirty=function(){for(var t=0;t<this._glTextures.length;t++)this._dirty[t]=!0},s.BaseTexture.prototype.unloadFromGPU=function(){this.dirty();for(var t=this._glTextures.length-1;t>=0;t--){var e=this._glTextures[t],i=s.glContexts[t];i&&e&&i.deleteTexture(e)}this._glTextures.length=0,this.dirty()},s.BaseTexture.fromCanvas=function(t,e,i){return 0===t.width&&(t.width=1),0===t.height&&(t.height=1),i=i||1,new s.BaseTexture(t,e,i)},s.TextureSilentFail=!1,s.Texture=function(t,e,i,n){this.noFrame=!1,e||(this.noFrame=!0,e=new s.Rectangle(0,0,1,1)),t instanceof s.Texture&&(t=t.baseTexture),this.baseTexture=t,this.frame=e,this.trim=n,this.valid=!1,this.isTiling=!1,this.requiresUpdate=!1,this.requiresReTint=!1,this._uvs=null,this.width=0,this.height=0,this.crop=i||new s.Rectangle(0,0,1,1),this.rotated=!1,t.hasLoaded&&(this.noFrame&&(e=new s.Rectangle(0,0,t.width,t.height)),this.setFrame(e))},s.Texture.prototype.constructor=s.Texture,s.Texture.prototype.onBaseTextureLoaded=function(){var t=this.baseTexture;this.noFrame&&(this.frame=new s.Rectangle(0,0,t.width,t.height)),this.setFrame(this.frame)},s.Texture.prototype.destroy=function(t){t&&this.baseTexture.destroy(),this.valid=!1},s.Texture.prototype.setFrame=function(t){if(this.noFrame=!1,this.frame=t,this.width=t.width,this.height=t.height,this.crop.x=t.x,this.crop.y=t.y,this.crop.width=t.width,this.crop.height=t.height,this.trim||!(t.x+t.width>this.baseTexture.width||t.y+t.height>this.baseTexture.height))this.valid=t&&t.width&&t.height&&this.baseTexture.source&&this.baseTexture.hasLoaded,this.trim&&(this.width=this.trim.width,this.height=this.trim.height,this.frame.width=this.trim.width,this.frame.height=this.trim.height),this.valid&&this._updateUvs();else{if(!s.TextureSilentFail)throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);this.valid=!1}},s.Texture.prototype._updateUvs=function(){this._uvs||(this._uvs=new s.TextureUvs);var t=this.crop,e=this.baseTexture.width,i=this.baseTexture.height;this._uvs.x0=t.x/e,this._uvs.y0=t.y/i,this._uvs.x1=(t.x+t.width)/e,this._uvs.y1=t.y/i,this._uvs.x2=(t.x+t.width)/e,this._uvs.y2=(t.y+t.height)/i,this._uvs.x3=t.x/e,this._uvs.y3=(t.y+t.height)/i},s.Texture.prototype._updateUvsInverted=function(){this._uvs||(this._uvs=new s.TextureUvs);var t=this.crop,e=this.baseTexture.width,i=this.baseTexture.height;this._uvs.x0=t.x/e,this._uvs.y0=t.y/i,this._uvs.x1=(t.x+t.height)/e,this._uvs.y1=t.y/i,this._uvs.x2=(t.x+t.height)/e,this._uvs.y2=(t.y+t.width)/i,this._uvs.x3=t.x/e,this._uvs.y3=(t.y+t.width)/i},s.Texture.fromCanvas=function(t,e){var i=s.BaseTexture.fromCanvas(t,e);return new s.Texture(i)},s.TextureUvs=function(){this.x0=0,this.y0=0,this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.x3=0,this.y3=0},"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=s),exports.PIXI=s):"undefined"!=typeof define&&define.amd?define("PIXI",i.PIXI=s):i.PIXI=s,s}.call(this),function(){var t=this,e=e||{VERSION:"2.14.0",GAMES:[],AUTO:0,CANVAS:1,WEBGL:2,HEADLESS:3,WEBGL_MULTI:4,NONE:0,LEFT:1,RIGHT:2,UP:3,DOWN:4,SPRITE:0,BUTTON:1,IMAGE:2,GRAPHICS:3,TEXT:4,TILESPRITE:5,BITMAPTEXT:6,GROUP:7,RENDERTEXTURE:8,TILEMAP:9,TILEMAPLAYER:10,EMITTER:11,POLYGON:12,BITMAPDATA:13,CANVAS_FILTER:14,WEBGL_FILTER:15,ELLIPSE:16,SPRITEBATCH:17,RETROFONT:18,POINTER:19,ROPE:20,CIRCLE:21,RECTANGLE:22,LINE:23,MATRIX:24,POINT:25,ROUNDEDRECTANGLE:26,CREATURE:27,VIDEO:28,PENDING_ATLAS:-1,HORIZONTAL:0,VERTICAL:1,LANDSCAPE:0,PORTRAIT:1,ANGLE_UP:270,ANGLE_DOWN:90,ANGLE_LEFT:180,ANGLE_RIGHT:0,ANGLE_NORTH_EAST:315,ANGLE_NORTH_WEST:225,ANGLE_SOUTH_EAST:45,ANGLE_SOUTH_WEST:135,TOP_LEFT:0,TOP_CENTER:1,TOP_RIGHT:2,LEFT_TOP:3,LEFT_CENTER:4,LEFT_BOTTOM:5,CENTER:6,RIGHT_TOP:7,RIGHT_CENTER:8,RIGHT_BOTTOM:9,BOTTOM_LEFT:10,BOTTOM_CENTER:11,BOTTOM_RIGHT:12,blendModes:{NORMAL:0,ADD:1,MULTIPLY:2,SCREEN:3,OVERLAY:4,DARKEN:5,LIGHTEN:6,COLOR_DODGE:7,COLOR_BURN:8,HARD_LIGHT:9,SOFT_LIGHT:10,DIFFERENCE:11,EXCLUSION:12,HUE:13,SATURATION:14,COLOR:15,LUMINOSITY:16},scaleModes:{DEFAULT:0,LINEAR:0,NEAREST:1},PIXI:PIXI||{},_UID:0};if("undefined"!=typeof AudioBufferSourceNode&&(AudioBufferSourceNode.prototype.start||(AudioBufferSourceNode.prototype.start=AudioBufferSourceNode.prototype.noteGrainOn),AudioBufferSourceNode.prototype.stop||(AudioBufferSourceNode.prototype.stop=AudioBufferSourceNode.prototype.noteOff)),Math.trunc||(Math.trunc=function(t){return t<0?Math.ceil(t):Math.floor(t)}),Function.prototype.bind||(Function.prototype.bind=function(){var t=Array.prototype.slice;return function(e){function i(){var r=n.concat(t.call(arguments));s.apply(this instanceof i?this:e,r)}var s=this,n=t.call(arguments,1);if("function"!=typeof s)throw new TypeError;return i.prototype=function t(e){if(e&&(t.prototype=e),!(this instanceof t))return new t}(s.prototype),i}}()),Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),Array.prototype.forEach||(Array.prototype.forEach=function(t){"use strict";if(void 0===this||null===this)throw new TypeError;var e=Object(this),i=e.length>>>0;if("function"!=typeof t)throw new TypeError;for(var s=arguments.length>=2?arguments[1]:void 0,n=0;n<i;n++)n in e&&t.call(s,e[n],n,e)}),"function"!=typeof window.Uint32Array&&"object"!=typeof window.Uint32Array){var i=function(t){var e=new Array;window[t]=function(t){if("number"==typeof t){Array.call(this,t),this.length=t;for(e=0;e<this.length;e++)this[e]=0}else{Array.call(this,t.length),this.length=t.length;for(var e=0;e<this.length;e++)this[e]=t[e]}},window[t].prototype=e,window[t].constructor=window[t]};i("Float32Array"),i("Uint32Array"),i("Uint16Array"),i("Int16Array"),i("ArrayBuffer")}window.console||(window.console={},window.console.log=window.console.assert=function(){},window.console.warn=window.console.assert=function(){}),Object.assign||(Object.assign=function(t,e){"use strict";if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(t),s=Object.prototype.hasOwnProperty,n=1;n<arguments.length;n++){var r=arguments[n];if(null!=r)for(var o in r)s.call(r,o)&&(i[o]=r[o])}return i}),e.Utils={defaults:function(t,e){for(var i=Object.keys(e),s=0,n=i.length;s<n;s++){var r=i[s];void 0===t[r]&&(t[r]=e[r])}return t},reverseString:function(t){return t.split("").reverse().join("")},getProperty:function(t,e){var i=e.split(".");switch(i.length){case 1:return t[e];case 2:return t[i[0]][i[1]];case 3:return t[i[0]][i[1]][i[2]];case 4:return t[i[0]][i[1]][i[2]][i[3]];default:return this._getProperty(t,e)}},setProperties:function(t,e){for(var i in e)this.setProperty(t,i,e[i]);return t},setProperty:function(t,e,i){var s=e.split(".");switch(s.length){case 1:t[e]=i;break;case 2:t[s[0]][s[1]]=i;break;case 3:t[s[0]][s[1]][s[2]]=i;break;case 4:t[s[0]][s[1]][s[2]][s[3]]=i;break;default:this._setProperty(t,e,i)}},_getProperty:function(t,e){for(var i=e.split("."),s=i.length,n=0,r=t;n<s;){var o=i[n];if(null==r)return;r=r[o],n++}return r},_setProperty:function(t,e,i){var s=e.split("."),n=s.length,r=0,o=t,a=s[0];if(1===n)t[e]=i;else{for(;r<n-1;)o=o[a],a=s[++r];o[a]=i}return t},chanceRoll:function(t){return void 0===t&&(t=50),t>0&&100*Math.random()<=t},randomChoice:function(t,e){return Math.random()<.5?t:e},parseDimension:function(t,e){var i=0,s=0;return"string"==typeof t?"%"===t.substr(-1)?(i=parseInt(t,10)/100,s=0===e?window.innerWidth*i:window.innerHeight*i):s=parseInt(t,10):s=t,s},pad:function(t,e,i,s){if(void 0===e)var e=0;if(void 0===i)var i=" ";if(void 0===s)var s=3;var n=0;if(e+1>=(t=t.toString()).length)switch(s){case 1:t=new Array(e+1-t.length).join(i)+t;break;case 3:var r=Math.ceil((n=e-t.length)/2),o=n-r;t=new Array(o+1).join(i)+t+new Array(r+1).join(i);break;default:t+=new Array(e+1-t.length).join(i)}return t},isPlainObject:function(t){if("object"!=typeof t||t.nodeType||t===t.window)return!1;try{if(t.constructor&&!{}.hasOwnProperty.call(t.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}return!0},extend:function(){var t,i,s,n,r,o,a=arguments[0]||{},h=1,l=arguments.length,c=!1;for("boolean"==typeof a&&(c=a,a=arguments[1]||{},h=2),l===h&&(a=this,--h);h<l;h++)if(null!=(t=arguments[h]))for(i in t)s=a[i],a!==(n=t[i])&&(c&&n&&(e.Utils.isPlainObject(n)||(r=Array.isArray(n)))?(r?(r=!1,o=s&&Array.isArray(s)?s:[]):o=s&&e.Utils.isPlainObject(s)?s:{},a[i]=e.Utils.extend(c,o,n)):void 0!==n&&(a[i]=n));return a},mixinPrototype:function(t,e,i){void 0===i&&(i=!1);for(var s=Object.keys(e),n=0;n<s.length;n++){var r=s[n],o=e[r];!i&&r in t||(!o||"function"!=typeof o.get&&"function"!=typeof o.set?t[r]=o:"function"==typeof o.clone?t[r]=o.clone():Object.defineProperty(t,r,o))}},mixin:function(t,i){if(!t||"object"!=typeof t)return i;for(var s in t){var n=t[s];if(!n.childNodes&&!n.cloneNode){var r=typeof t[s];t[s]&&"object"===r?typeof i[s]===r?i[s]=e.Utils.mixin(t[s],i[s]):i[s]=e.Utils.mixin(t[s],new n.constructor):i[s]=t[s]}}return i}},e.Circle=function(t,i,s){t=t||0,i=i||0,s=s||0,this.x=t,this.y=i,this._diameter=s,this._radius=0,s>0&&(this._radius=.5*s),this.type=e.CIRCLE},e.Circle.prototype={circumference:function(){return Math.PI*this._radius*2},random:function(t){void 0===t&&(t=new e.Point);var i=2*Math.PI*Math.random(),s=Math.random()+Math.random(),n=s>1?2-s:s,r=n*Math.cos(i),o=n*Math.sin(i);return t.x=this.x+r*this.radius,t.y=this.y+o*this.radius,t},getBounds:function(){return new e.Rectangle(this.x-this.radius,this.y-this.radius,this.diameter,this.diameter)},setTo:function(t,e,i){return this.x=t,this.y=e,this._diameter=i,this._radius=.5*i,this},copyFrom:function(t){return this.setTo(t.x,t.y,t.diameter)},copyTo:function(t){return t.x=this.x,t.y=this.y,t.diameter=this._diameter,t},distance:function(t,i){var s=e.Math.distance(this.x,this.y,t.x,t.y);return i?Math.round(s):s},clone:function(t){return void 0===t||null===t?t=new e.Circle(this.x,this.y,this.diameter):t.setTo(this.x,this.y,this.diameter),t},contains:function(t,i){return e.Circle.contains(this,t,i)},circumferencePoint:function(t,i,s){return e.Circle.circumferencePoint(this,t,i,s)},sample:function(t,i,s,n,r){t||(t=60),null==i&&(i=0),null==s&&(s=e.Math.PI2),r||(r=[]);for(var o=0;o<t;)this.circumferencePoint(e.Math.linear(i,s,o/t),n,r[o]||(r[o]=new e.Point)),o+=1;return r},offset:function(t,e){return this.x+=t,this.y+=e,this},offsetPoint:function(t){return this.offset(t.x,t.y)},toString:function(){return"[{Phaser.Circle (x="+this.x+" y="+this.y+" diameter="+this.diameter+" radius="+this.radius+")}]"}},e.Circle.prototype.constructor=e.Circle,Object.defineProperty(e.Circle.prototype,"diameter",{get:function(){return this._diameter},set:function(t){t>0&&(this._diameter=t,this._radius=.5*t)}}),Object.defineProperty(e.Circle.prototype,"radius",{get:function(){return this._radius},set:function(t){t>0&&(this._radius=t,this._diameter=2*t)}}),Object.defineProperty(e.Circle.prototype,"left",{get:function(){return this.x-this._radius},set:function(t){t>this.x?(this._radius=0,this._diameter=0):this.radius=this.x-t}}),Object.defineProperty(e.Circle.prototype,"right",{get:function(){return this.x+this._radius},set:function(t){t<this.x?(this._radius=0,this._diameter=0):this.radius=t-this.x}}),Object.defineProperty(e.Circle.prototype,"top",{get:function(){return this.y-this._radius},set:function(t){t>this.y?(this._radius=0,this._diameter=0):this.radius=this.y-t}}),Object.defineProperty(e.Circle.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(t){t<this.y?(this._radius=0,this._diameter=0):this.radius=t-this.y}}),Object.defineProperty(e.Circle.prototype,"area",{get:function(){return this._radius>0?Math.PI*this._radius*this._radius:0}}),Object.defineProperty(e.Circle.prototype,"empty",{get:function(){return 0===this._diameter},set:function(t){!0===t&&this.setTo(0,0,0)}}),e.Circle.contains=function(t,e,i){return t.radius>0&&e>=t.left&&e<=t.right&&i>=t.top&&i<=t.bottom&&(t.x-e)*(t.x-e)+(t.y-i)*(t.y-i)<=t.radius*t.radius},e.Circle.equals=function(t,e){return t.x===e.x&&t.y===e.y&&t.diameter===e.diameter},e.Circle.intersects=function(t,i){return e.Math.distance(t.x,t.y,i.x,i.y)<=t.radius+i.radius},e.Circle.circumferencePoint=function(t,i,s,n){return void 0===s&&(s=!1),void 0===n&&(n=new e.Point),!0===s&&(i=e.Math.degToRad(i)),n.x=t.x+t.radius*Math.cos(i),n.y=t.y+t.radius*Math.sin(i),n},e.Circle.intersectsRectangle=function(t,e){var i=Math.abs(t.x-e.x-e.halfWidth);if(i>e.halfWidth+t.radius)return!1;var s=Math.abs(t.y-e.y-e.halfHeight);if(s>e.halfHeight+t.radius)return!1;if(i<=e.halfWidth||s<=e.halfHeight)return!0;var n=i-e.halfWidth,r=s-e.halfHeight;return n*n+r*r<=t.radius*t.radius},e.Circle.intersectsLine=function(t,i,s){var n=t.x,r=t.y,o=(i.end.y-i.start.y)/(i.end.x-i.start.x),a=i.end.y-o*i.end.x,h=t.radius,l=t.radius,c=a+o*n,u=(n*(l*l)-o*(h*h)*(a-r)+h*l*Math.sqrt(h*h*(o*o)+l*l-c*c-r*r+2*c*r))/(h*h*(o*o)+l*l),d=(n*(l*l)-o*(h*h)*(a-r)-h*l*Math.sqrt(h*h*(o*o)+l*l-c*c-r*r+2*c*r))/(h*h*(o*o)+l*l),p=o*u+a,f=o*d+a,g=new e.Point(u,p),m=new e.Point(d,f),y=i.pointOnSegment(g.x,g.y,.01),v=i.pointOnSegment(m.x,m.y,.01);return y&&v?!s||[g,m]:y?!s||[g]:v?!s||[m]:!!s&&[]},PIXI.Circle=e.Circle,e.Ellipse=function(t,i,s,n){t=t||0,i=i||0,s=s||0,n=n||0,this.x=t,this.y=i,this.width=s,this.height=n,this.type=e.ELLIPSE},e.Ellipse.prototype={setTo:function(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this},getBounds:function(){return new e.Rectangle(this.x-this.width,this.y-this.height,this.width,this.height)},copyFrom:function(t){return this.setTo(t.x,t.y,t.width,t.height)},copyTo:function(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t},clone:function(t){return void 0===t||null===t?t=new e.Ellipse(this.x,this.y,this.width,this.height):t.setTo(this.x,this.y,this.width,this.height),t},contains:function(t,i){return e.Ellipse.contains(this,t,i)},random:function(t){void 0===t&&(t=new e.Point);var i=Math.random()*Math.PI*2,s=Math.sqrt(Math.random());return t.x=this.centerX+.5*s*Math.cos(i)*this.width,t.y=this.centerY+.5*s*Math.sin(i)*this.height,t},toString:function(){return"[{Phaser.Ellipse (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+")}]"}},e.Ellipse.prototype.constructor=e.Ellipse,Object.defineProperty(e.Ellipse.prototype,"left",{get:function(){return this.x},set:function(t){this.x=t}}),Object.defineProperty(e.Ellipse.prototype,"right",{get:function(){return this.x+this.width},set:function(t){t<this.x?this.width=0:this.width=t-this.x}}),Object.defineProperty(e.Ellipse.prototype,"top",{get:function(){return this.y},set:function(t){this.y=t}}),Object.defineProperty(e.Ellipse.prototype,"bottom",{get:function(){return this.y+this.height},set:function(t){t<this.y?this.height=0:this.height=t-this.y}}),Object.defineProperty(e.Ellipse.prototype,"centerX",{get:function(){return this.x+.5*this.width}}),Object.defineProperty(e.Ellipse.prototype,"centerY",{get:function(){return this.y+.5*this.height}}),Object.defineProperty(e.Ellipse.prototype,"empty",{get:function(){return 0===this.width||0===this.height},set:function(t){!0===t&&this.setTo(0,0,0,0)}}),e.Ellipse.contains=function(t,e,i){if(t.width<=0||t.height<=0)return!1;var s=(e-t.x)/t.width-.5,n=(i-t.y)/t.height-.5;return s*=s,n*=n,s+n<.25},e.Ellipse.intersectsLine=function(t,i,s){var n=t.x,r=t.y,o=(i.end.y-i.start.y)/(i.end.x-i.start.x),a=i.end.y-o*i.end.x,h=t.width/2,l=t.height/2,c=a+o*n,u=(n*(l*l)-o*(h*h)*(a-r)+h*l*Math.sqrt(h*h*(o*o)+l*l-c*c-r*r+2*c*r))/(h*h*(o*o)+l*l),d=(n*(l*l)-o*(h*h)*(a-r)-h*l*Math.sqrt(h*h*(o*o)+l*l-c*c-r*r+2*c*r))/(h*h*(o*o)+l*l),p=o*u+a,f=o*d+a,g=new e.Point(u,p),m=new e.Point(d,f),y=i.pointOnSegment(g.x,g.y,.01),v=i.pointOnSegment(m.x,m.y,.01);return y&&v?!s||[g,m]:y?!s||[g]:v?!s||[m]:!!s&&[]},PIXI.Ellipse=e.Ellipse,e.Line=function(t,i,s,n){t=t||0,i=i||0,s=s||0,n=n||0,this.start=new e.Point(t,i),this.end=new e.Point(s,n),this.type=e.LINE},e.Line.prototype={setTo:function(t,e,i,s){return this.start.setTo(t,e),this.end.setTo(i,s),this},fromPoints:function(t,e){return this.setTo(t.x,t.y,e.x,e.y),this},fromSprite:function(t,e,i){return void 0===i&&(i=!1),i?this.setTo(t.centerX,t.centerY,e.centerX,e.centerY):this.fromPoints(t,e)},fromAngle:function(t,e,i,s){return this.start.setTo(t,e),this.end.setTo(t+Math.cos(i)*s,e+Math.sin(i)*s),this},rotate:function(t,e){var i=(this.start.x+this.end.x)/2,s=(this.start.y+this.end.y)/2;return this.start.rotate(i,s,t,e),this.end.rotate(i,s,t,e),this},rotateAround:function(t,e,i,s){return this.start.rotate(t,e,i,s),this.end.rotate(t,e,i,s),this},intersects:function(t,i,s){return e.Line.intersectsPoints(this.start,this.end,t.start,t.end,i,s)},reflect:function(t){return e.Line.reflect(this,t)},midPoint:function(t){return void 0===t&&(t=new e.Point),t.x=(this.start.x+this.end.x)/2,t.y=(this.start.y+this.end.y)/2,t},centerOn:function(t,e){var i=t-(this.start.x+this.end.x)/2,s=e-(this.start.y+this.end.y)/2;this.start.add(i,s),this.end.add(i,s)},pointOnLine:function(t,i,s){return e.Math.fuzzyEqual((t-this.start.x)*(this.end.y-this.start.y),(this.end.x-this.start.x)*(i-this.start.y),s||0)},pointOnSegment:function(t,e,i){var s=Math.min(this.start.x,this.end.x),n=Math.max(this.start.x,this.end.x),r=Math.min(this.start.y,this.end.y),o=Math.max(this.start.y,this.end.y);return this.pointOnLine(t,e,i)&&t>=s&&t<=n&&e>=r&&e<=o},random:function(t){void 0===t&&(t=new e.Point);var i=Math.random();return t.x=this.start.x+i*(this.end.x-this.start.x),t.y=this.start.y+i*(this.end.y-this.start.y),t},coordinatesOnLine:function(t,e){void 0===t&&(t=1),void 0===e&&(e=[]);var i=Math.round(this.start.x),s=Math.round(this.start.y),n=Math.round(this.end.x),r=Math.round(this.end.y),o=Math.abs(n-i),a=Math.abs(r-s),h=i<n?1:-1,l=s<r?1:-1,c=o-a;e.push([i,s]);for(var u=1;i!==n||s!==r;){var d=c<<1;d>-a&&(c-=a,i+=h),d<o&&(c+=o,s+=l),u%t==0&&e.push([i,s]),u++}return e},clone:function(t){return void 0===t||null===t?t=new e.Line(this.start.x,this.start.y,this.end.x,this.end.y):t.setTo(this.start.x,this.start.y,this.end.x,this.end.y),t}},Object.defineProperty(e.Line.prototype,"length",{get:function(){return Math.sqrt((this.end.x-this.start.x)*(this.end.x-this.start.x)+(this.end.y-this.start.y)*(this.end.y-this.start.y))}}),Object.defineProperty(e.Line.prototype,"angle",{get:function(){return e.Point.angle(this.end,this.start)}}),Object.defineProperty(e.Line.prototype,"slope",{get:function(){return(this.end.y-this.start.y)/(this.end.x-this.start.x)}}),Object.defineProperty(e.Line.prototype,"perpSlope",{get:function(){return-(this.end.x-this.start.x)/(this.end.y-this.start.y)}}),Object.defineProperty(e.Line.prototype,"x",{get:function(){return Math.min(this.start.x,this.end.x)}}),Object.defineProperty(e.Line.prototype,"y",{get:function(){return Math.min(this.start.y,this.end.y)}}),Object.defineProperty(e.Line.prototype,"left",{get:function(){return Math.min(this.start.x,this.end.x)}}),Object.defineProperty(e.Line.prototype,"right",{get:function(){return Math.max(this.start.x,this.end.x)}}),Object.defineProperty(e.Line.prototype,"top",{get:function(){return Math.min(this.start.y,this.end.y)}}),Object.defineProperty(e.Line.prototype,"bottom",{get:function(){return Math.max(this.start.y,this.end.y)}}),Object.defineProperty(e.Line.prototype,"width",{get:function(){return Math.abs(this.start.x-this.end.x)}}),Object.defineProperty(e.Line.prototype,"height",{get:function(){return Math.abs(this.start.y-this.end.y)}}),Object.defineProperty(e.Line.prototype,"normalX",{get:function(){return Math.cos(this.angle-1.5707963267948966)}}),Object.defineProperty(e.Line.prototype,"normalY",{get:function(){return Math.sin(this.angle-1.5707963267948966)}}),Object.defineProperty(e.Line.prototype,"normalAngle",{get:function(){return e.Math.wrap(this.angle-1.5707963267948966,-Math.PI,Math.PI)}}),e.Line.intersectsPoints=function(t,i,s,n,r,o){void 0===r&&(r=!0),void 0===o&&(o=new e.Point);var a=i.y-t.y,h=n.y-s.y,l=t.x-i.x,c=s.x-n.x,u=i.x*t.y-t.x*i.y,d=n.x*s.y-s.x*n.y,p=a*c-h*l;if(0===p)return null;if(o.x=(l*d-c*u)/p,o.y=(h*u-a*d)/p,r){var f=(n.y-s.y)*(i.x-t.x)-(n.x-s.x)*(i.y-t.y),g=((n.x-s.x)*(t.y-s.y)-(n.y-s.y)*(t.x-s.x))/f,m=((i.x-t.x)*(t.y-s.y)-(i.y-t.y)*(t.x-s.x))/f;return g>=0&&g<=1&&m>=0&&m<=1?o:null}return o},e.Line.intersects=function(t,i,s,n){return e.Line.intersectsPoints(t.start,t.end,i.start,i.end,s,n)},e.Line.intersectsRectangle=function(t,e){if(0===t.length||e.empty)return!1;var i=t.start.x,s=t.start.y,n=t.end.x,r=t.end.y,o=e.x,a=e.y,h=e.right,l=e.bottom,c=0;if(i>=o&&i<=h&&s>=a&&s<=l||n>=o&&n<=h&&r>=a&&r<=l)return!0;if(i<o&&n>=o){if((c=s+(r-s)*(o-i)/(n-i))>a&&c<=l)return!0}else if(i>h&&n<=h&&(c=s+(r-s)*(h-i)/(n-i))>=a&&c<=l)return!0;if(s<a&&r>=a){if((c=i+(n-i)*(a-s)/(r-s))>=o&&c<=h)return!0}else if(s>l&&r<=l&&(c=i+(n-i)*(l-s)/(r-s))>=o&&c<=h)return!0;return!1},e.Line.intersectionWithRectangle=function(t,i,s){var n=e.Line.intersectionWithRectangle;s||(s=new e.Point),n.edges||(n.edges=[new e.Line,new e.Line,new e.Line,new e.Line]),n.edgeIntersection||(n.edgeIntersection=new e.Point);var r=n.edges,o=n.edgeIntersection.set(0),a=i.x,h=i.y,l=i.right,c=i.bottom,u=1/0;r[0].setTo(a,h,l,h),r[1].setTo(a,c,l,c),r[2].setTo(a,h,a,c),r[3].setTo(l,h,l,c);for(var d,p=0;d=r[p];p++)if(t.intersects(d,!0,o)){var f=t.start.distance(o);f<u&&(u=f,s.copyFrom(o))}return null!=f?s:null},e.Line.reflect=function(t,e){return 2*e.normalAngle-3.141592653589793-t.angle},e.Matrix=function(t,i,s,n,r,o){void 0!==t&&null!==t||(t=1),void 0!==i&&null!==i||(i=0),void 0!==s&&null!==s||(s=0),void 0!==n&&null!==n||(n=1),void 0!==r&&null!==r||(r=0),void 0!==o&&null!==o||(o=0),this.a=t,this.b=i,this.c=s,this.d=n,this.tx=r,this.ty=o,this.type=e.MATRIX},e.Matrix.prototype={fromArray:function(t){return this.setTo(t[0],t[1],t[3],t[4],t[2],t[5])},setTo:function(t,e,i,s,n,r){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=r,this},clone:function(t){return void 0===t||null===t?t=new e.Matrix(this.a,this.b,this.c,this.d,this.tx,this.ty):(t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty),t},copyTo:function(t){return t.copyFrom(this),t},copyFrom:function(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this},toArray:function(t,e){return void 0===e&&(e=new Float32Array(9)),t?(e[0]=this.a,e[1]=this.b,e[2]=0,e[3]=this.c,e[4]=this.d,e[5]=0,e[6]=this.tx,e[7]=this.ty,e[8]=1):(e[0]=this.a,e[1]=this.c,e[2]=this.tx,e[3]=this.b,e[4]=this.d,e[5]=this.ty,e[6]=0,e[7]=0,e[8]=1),e},apply:function(t,i){return void 0===i&&(i=new e.Point),i.x=this.a*t.x+this.c*t.y+this.tx,i.y=this.b*t.x+this.d*t.y+this.ty,i},applyInverse:function(t,i){void 0===i&&(i=new e.Point);var s=1/(this.a*this.d+this.c*-this.b),n=t.x,r=t.y;return i.x=this.d*s*n+-this.c*s*r+(this.ty*this.c-this.tx*this.d)*s,i.y=this.a*s*r+-this.b*s*n+(-this.ty*this.a+this.tx*this.b)*s,i},translate:function(t,e){return this.tx+=t,this.ty+=e,this},scale:function(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this},rotate:function(t){var e=Math.cos(t),i=Math.sin(t),s=this.a,n=this.c,r=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=r*e-this.ty*i,this.ty=r*i+this.ty*e,this},append:function(t){var e=this.a,i=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this},identity:function(){return this.setTo(1,0,0,1,0,0)}},e.identityMatrix=new e.Matrix,e.Point=function(t,i){t=t||0,i=i||0,this.x=t,this.y=i,this.type=e.POINT},e.Point.prototype={copyFrom:function(t){return this.setTo(t.x,t.y)},invert:function(){return this.setTo(this.y,this.x)},setTo:function(t,i){return e.Point.set(this,t,i)},set:function(t,i){return e.Point.set(this,t,i)},setToPolar:function(t,i,s){return null==i&&(i=1),s&&(t=e.Math.degToRad(t)),this.setTo(Math.cos(t)*i,Math.sin(t)*i)},add:function(t,e){return this.x+=t,this.y+=e,this},subtract:function(t,e){return this.x-=t,this.y-=e,this},multiply:function(t,e){return this.x*=t,this.y*=e,this},divide:function(t,e){return this.x/=t,this.y/=e,this},clampX:function(t,i){return this.x=e.Math.clamp(this.x,t,i),this},clampY:function(t,i){return this.y=e.Math.clamp(this.y,t,i),this},clamp:function(t,i){return this.x=e.Math.clamp(this.x,t,i),this.y=e.Math.clamp(this.y,t,i),this},clip:function(t){var e=t.left,i=t.top,s=t.right,n=t.bottom;return this.x<e?this.x=e:this.x>s&&(this.x=s),this.y<i?this.y=i:this.y>n&&(this.y=n),this},clone:function(t){return void 0===t||null===t?t=new e.Point(this.x,this.y):t.setTo(this.x,this.y),t},copyTo:function(t){return t.x=this.x,t.y=this.y,t},distance:function(t,i){return e.Point.distance(this,t,i)},equals:function(t){return t.x===this.x&&t.y===this.y},equalsXY:function(t,e){return this.x===t&&this.y===e},fuzzyEquals:function(t,i){return e.Point.fuzzyEquals(this,t,i)},fuzzyEqualsXY:function(t,i,s){return e.Point.fuzzyEqualsXY(this,t,i,s)},angle:function(t,e){return this.angleXY(t.x,t.y,e)},angleXY:function(t,i,s){var n=Math.atan2(i-this.y,t-this.x);return s?e.Math.radToDeg(n):n},atan:function(t){var i=Math.atan2(this.y,this.x);return t?e.Math.radToDeg(i):i},rotate:function(t,i,s,n,r){return e.Point.rotate(this,t,i,s,n,r)},getMagnitude:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},getMagnitudeSq:function(){return this.x*this.x+this.y*this.y},setMagnitude:function(t){return this.normalize().multiply(t,t)},normalize:function(){if(!this.isZero()){var t=this.getMagnitude();this.x/=t,this.y/=t}return this},limit:function(t){return this.getMagnitudeSq()>t*t&&this.setMagnitude(t),this},expand:function(t){return this.getMagnitudeSq()<t*t&&this.setMagnitude(t),this},isZero:function(){return 0===this.x&&0===this.y},dot:function(t){return this.x*t.x+this.y*t.y},cross:function(t){return this.x*t.y-this.y*t.x},perp:function(){return this.setTo(-this.y,this.x)},rperp:function(){return this.setTo(this.y,-this.x)},normalRightHand:function(){return this.setTo(-1*this.y,this.x)},floor:function(){return this.setTo(Math.floor(this.x),Math.floor(this.y))},ceil:function(){return this.setTo(Math.ceil(this.x),Math.ceil(this.y))},round:function(){return this.setTo(Math.round(this.x),Math.round(this.y))},toString:function(){return"[{Point (x="+this.x+" y="+this.y+")}]"}},e.Point.prototype.constructor=e.Point,e.Point.add=function(t,i,s){return void 0===s&&(s=new e.Point),s.x=t.x+i.x,s.y=t.y+i.y,s},e.Point.subtract=function(t,i,s){return void 0===s&&(s=new e.Point),s.x=t.x-i.x,s.y=t.y-i.y,s},e.Point.multiply=function(t,i,s){return void 0===s&&(s=new e.Point),s.x=t.x*i.x,s.y=t.y*i.y,s},e.Point.divide=function(t,i,s){return void 0===s&&(s=new e.Point),s.x=t.x/i.x,s.y=t.y/i.y,s},e.Point.equals=function(t,e){return t.x===e.x&&t.y===e.y},e.Point.equalsXY=function(t,e,i){return t.x===e&&t.y===i},e.Point.fuzzyEquals=function(t,i,s){return e.Math.fuzzyEqual(t.x,i.x,s)&&e.Math.fuzzyEqual(t.y,i.y,s)},e.Point.fuzzyEqualsXY=function(t,i,s,n){return e.Math.fuzzyEqual(t.x,i,n)&&e.Math.fuzzyEqual(t.y,s,n)},e.Point.angle=function(t,e){return Math.atan2(t.y-e.y,t.x-e.x)},e.Point.negative=function(t,i){return void 0===i&&(i=new e.Point),i.setTo(-t.x,-t.y)},e.Point.multiplyAdd=function(t,i,s,n){return void 0===n&&(n=new e.Point),n.setTo(t.x+i.x*s,t.y+i.y*s)},e.Point.interpolate=function(t,i,s,n){return void 0===n&&(n=new e.Point),n.setTo(t.x+(i.x-t.x)*s,t.y+(i.y-t.y)*s)},e.Point.perp=function(t,i){return void 0===i&&(i=new e.Point),i.setTo(-t.y,t.x)},e.Point.rperp=function(t,i){return void 0===i&&(i=new e.Point),i.setTo(t.y,-t.x)},e.Point.distance=function(t,i,s){var n=e.Math.distance(t.x,t.y,i.x,i.y);return s?Math.round(n):n},e.Point.project=function(t,i,s){void 0===s&&(s=new e.Point);var n=t.dot(i)/i.getMagnitudeSq();return 0!==n&&s.setTo(n*i.x,n*i.y),s},e.Point.projectUnit=function(t,i,s){void 0===s&&(s=new e.Point);var n=t.dot(i);return 0!==n&&s.setTo(n*i.x,n*i.y),s},e.Point.normalRightHand=function(t,i){return void 0===i&&(i=new e.Point),i.setTo(-1*t.y,t.x)},e.Point.normalize=function(t,i){void 0===i&&(i=new e.Point);var s=t.getMagnitude();return 0!==s&&i.setTo(t.x/s,t.y/s),i},e.Point.rotate=function(t,i,s,n,r,o){if(r&&(n=e.Math.degToRad(n)),void 0===o){t.subtract(i,s);var a=Math.sin(n),h=Math.cos(n),l=h*t.x-a*t.y,c=a*t.x+h*t.y;t.x=l+i,t.y=c+s}else{var u=n+Math.atan2(t.y-s,t.x-i);t.x=i+o*Math.cos(u),t.y=s+o*Math.sin(u)}return t},e.Point.centroid=function(t,i){if(void 0===i&&(i=new e.Point),"[object Array]"!==Object.prototype.toString.call(t))throw new Error("Phaser.Point. Parameter 'points' must be an array");var s=t.length;if(s<1)throw new Error("Phaser.Point. Parameter 'points' array must not be empty");if(1===s)return i.copyFrom(t[0]),i;for(var n=0;n<s;n++)e.Point.add(i,t[n],i);return i.divide(s,s),i},e.Point.parse=function(t,i,s){i=i||"x",s=s||"y";var n=new e.Point;return t[i]&&(n.x=parseFloat(t[i])),t[s]&&(n.y=parseFloat(t[s])),n},e.Point.trunc=function(t){return t.x=e.Math.trunc(t.x),t.y=e.Math.trunc(t.y),t},e.Point.isPoint=function(t){return null!=t&&"number"==typeof t.x&&"number"==typeof t.y},e.Point.set=function(t,e,i){return t.x=e||0,t.y=i||(0!==i?t.x:0),t},e.Point.sortClockwise=function(t,e){e||(e=this.centroid(t));var i=e.x,s=e.y;return t.sort(function(t,e){if(t.x-i>=0&&e.x-i<0)return-1;if(t.x-i<0&&e.x-i>=0)return 1;if(t.x-i==0&&e.x-i==0)return t.y-s>=0||e.y-s>=0?t.y>e.y?1:-1:e.y>t.y?1:-1;var n=(t.x-i)*-(e.y-s)-(e.x-i)*-(t.y-s);return n<0?-1:n>0?1:(t.x-i)*(t.x-i)+(t.y-s)*(t.y-s)>(e.x-i)*(e.x-i)+(e.y-s)*(e.y-s)?-1:1})},PIXI.Point=e.Point,e.Polygon=function(){this.area=0,this._points=[],arguments.length>0&&this.setTo.apply(this,arguments),this.closed=!0,this.flattened=!1,this.type=e.POLYGON},e.Polygon.prototype={toNumberArray:function(t){void 0===t&&(t=[]);for(var e=0;e<this._points.length;e++)"number"==typeof this._points[e]?(t.push(this._points[e]),t.push(this._points[e+1]),e++):(t.push(this._points[e].x),t.push(this._points[e].y));return t},flatten:function(){return this._points=this.toNumberArray(),this.flattened=!0,this},clone:function(t){var i=this._points.slice();return void 0===t||null===t?t=new e.Polygon(i):t.setTo(i),t},contains:function(t,e){var i=!1;if(this.flattened)for(var s=-2,n=this._points.length-2;(s+=2)<this._points.length;n=s){var r=this._points[s],o=this._points[s+1],a=this._points[n],h=this._points[n+1];(o<=e&&e<h||h<=e&&e<o)&&t<(a-r)*(e-o)/(h-o)+r&&(i=!i)}else for(var s=-1,n=this._points.length-1;++s<this._points.length;n=s){var r=this._points[s].x,o=this._points[s].y,a=this._points[n].x,h=this._points[n].y;(o<=e&&e<h||h<=e&&e<o)&&t<(a-r)*(e-o)/(h-o)+r&&(i=!i)}return i},setTo:function(t){if(this.area=0,this._points=[],arguments.length>0){Array.isArray(t)||(t=Array.prototype.slice.call(arguments));for(var e=Number.MAX_VALUE,i=0,s=t.length;i<s;i++){if("number"==typeof t[i]){n=new PIXI.Point(t[i],t[i+1]);i++}else if(Array.isArray(t[i]))n=new PIXI.Point(t[i][0],t[i][1]);else var n=new PIXI.Point(t[i].x,t[i].y);this._points.push(n),n.y<e&&(e=n.y)}this.calculateArea(e)}return this},calculateArea:function(t){for(var e,i,s,n,r=0,o=this._points.length;r<o;r++)e=this._points[r],i=r===o-1?this._points[0]:this._points[r+1],s=(e.y-t+(i.y-t))/2,n=e.x-i.x,this.area+=s*n;return this.area}},e.Polygon.prototype.constructor=e.Polygon,Object.defineProperty(e.Polygon.prototype,"points",{get:function(){return this._points}}),PIXI.Polygon=e.Polygon,e.Rectangle=function(t,i,s,n){t=t||0,i=i||0,s=s||0,n=n||0,this.x=t,this.y=i,this.width=s,this.height=n,this.type=e.RECTANGLE},e.Rectangle.prototype={offset:function(t,e){return this.x+=t,this.y+=e,this},offsetPoint:function(t){return this.offset(t.x,t.y)},setTo:function(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this},scale:function(t,e){return void 0===e&&(e=t),this.width*=t,this.height*=e,this},centerOn:function(t,e){return this.centerX=t,this.centerY=e,this},floor:function(){this.x=Math.floor(this.x),this.y=Math.floor(this.y)},floorAll:function(){this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.width=Math.floor(this.width),this.height=Math.floor(this.height)},ceil:function(){this.x=Math.ceil(this.x),this.y=Math.ceil(this.y)},ceilAll:function(){this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.width=Math.ceil(this.width),this.height=Math.ceil(this.height)},copyFrom:function(t){return this.setTo(t.x,t.y,t.width,t.height)},copyFromBounds:function(t){return this.setTo(t.left,t.top,t.width,t.height)},copyTo:function(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t},inflate:function(t,i){return e.Rectangle.inflate(this,t,i)},size:function(t){return e.Rectangle.size(this,t)},resize:function(t,e){return this.width=t,this.height=e,this},clone:function(t){return e.Rectangle.clone(this,t)},contains:function(t,i){return e.Rectangle.contains(this,t,i)},containsRect:function(t){return e.Rectangle.containsRect(t,this)},equals:function(t){return e.Rectangle.equals(this,t)},intersection:function(t,i){return e.Rectangle.intersection(this,t,i)},intersects:function(t){return e.Rectangle.intersects(this,t)},intersectsRaw:function(t,i,s,n,r){return e.Rectangle.intersectsRaw(this,t,i,s,n,r)},union:function(t,i){return e.Rectangle.union(this,t,i)},random:function(t){return void 0===t&&(t=new e.Point),t.x=this.randomX,t.y=this.randomY,t},getPoint:function(t,i){switch(void 0===i&&(i=new e.Point),t){default:case e.TOP_LEFT:return i.set(this.x,this.y);case e.TOP_CENTER:return i.set(this.centerX,this.y);case e.TOP_RIGHT:return i.set(this.right,this.y);case e.LEFT_CENTER:return i.set(this.x,this.centerY);case e.CENTER:return i.set(this.centerX,this.centerY);case e.RIGHT_CENTER:return i.set(this.right,this.centerY);case e.BOTTOM_LEFT:return i.set(this.x,this.bottom);case e.BOTTOM_CENTER:return i.set(this.centerX,this.bottom);case e.BOTTOM_RIGHT:return i.set(this.right,this.bottom)}},sides:function(t,i,s,n){arguments.length||(t=new e.Line,i=new e.Line,s=new e.Line,n=new e.Line);var r=this.x,o=this.y,a=this.right,h=this.bottom;return t.setTo(r,o,a,o),i.setTo(a,o,a,h),s.setTo(r,h,a,h),n.setTo(r,o,r,h),arguments.length?null:[t,i,s,n]},toString:function(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" empty="+this.empty+")}]"}},Object.defineProperty(e.Rectangle.prototype,"halfWidth",{get:function(){return Math.round(this.width/2)}}),Object.defineProperty(e.Rectangle.prototype,"halfHeight",{get:function(){return Math.round(this.height/2)}}),Object.defineProperty(e.Rectangle.prototype,"bottom",{get:function(){return this.y+this.height},set:function(t){t<=this.y?this.height=0:this.height=t-this.y}}),Object.defineProperty(e.Rectangle.prototype,"bottomLeft",{get:function(){return new e.Point(this.x,this.bottom)},set:function(t){this.x=t.x,this.bottom=t.y}}),Object.defineProperty(e.Rectangle.prototype,"bottomRight",{get:function(){return new e.Point(this.right,this.bottom)},set:function(t){this.right=t.x,this.bottom=t.y}}),Object.defineProperty(e.Rectangle.prototype,"left",{get:function(){return this.x},set:function(t){t>=this.right?this.width=0:this.width=this.right-t,this.x=t}}),Object.defineProperty(e.Rectangle.prototype,"right",{get:function(){return this.x+this.width},set:function(t){t<=this.x?this.width=0:this.width=t-this.x}}),Object.defineProperty(e.Rectangle.prototype,"volume",{get:function(){return this.width*this.height}}),Object.defineProperty(e.Rectangle.prototype,"perimeter",{get:function(){return 2*this.width+2*this.height}}),Object.defineProperty(e.Rectangle.prototype,"centerX",{get:function(){return this.x+this.halfWidth},set:function(t){this.x=t-this.halfWidth}}),Object.defineProperty(e.Rectangle.prototype,"centerY",{get:function(){return this.y+this.halfHeight},set:function(t){this.y=t-this.halfHeight}}),Object.defineProperty(e.Rectangle.prototype,"randomX",{get:function(){return this.x+Math.random()*this.width}}),Object.defineProperty(e.Rectangle.prototype,"randomY",{get:function(){return this.y+Math.random()*this.height}}),Object.defineProperty(e.Rectangle.prototype,"top",{get:function(){return this.y},set:function(t){t>=this.bottom?(this.height=0,this.y=t):this.height=this.bottom-t}}),Object.defineProperty(e.Rectangle.prototype,"topLeft",{get:function(){return new e.Point(this.x,this.y)},set:function(t){this.x=t.x,this.y=t.y}}),Object.defineProperty(e.Rectangle.prototype,"topRight",{get:function(){return new e.Point(this.x+this.width,this.y)},set:function(t){this.right=t.x,this.y=t.y}}),Object.defineProperty(e.Rectangle.prototype,"empty",{get:function(){return!this.width||!this.height},set:function(t){!0===t&&this.setTo(0,0,0,0)}}),e.Rectangle.prototype.constructor=e.Rectangle,e.Rectangle.inflate=function(t,e,i){return t.x-=e,t.width+=2*e,t.y-=i,t.height+=2*i,t},e.Rectangle.inflatePoint=function(t,i){return e.Rectangle.inflate(t,i.x,i.y)},e.Rectangle.size=function(t,i){return void 0===i||null===i?i=new e.Point(t.width,t.height):i.setTo(t.width,t.height),i},e.Rectangle.clone=function(t,i){return void 0===i||null===i?i=new e.Rectangle(t.x,t.y,t.width,t.height):i.setTo(t.x,t.y,t.width,t.height),i},e.Rectangle.createFromBounds=function(t,i){return void 0!==i&&null!==i||(i=new e.Rectangle(t.x,t.y,t.width,t.height)),i.copyFromBounds(t)},e.Rectangle.contains=function(t,e,i){return!(t.width<=0||t.height<=0)&&(e>=t.x&&e<t.right&&i>=t.y&&i<t.bottom)},e.Rectangle.containsRaw=function(t,e,i,s,n,r){return n>=t&&n<t+i&&r>=e&&r<e+s},e.Rectangle.containsPoint=function(t,i){return e.Rectangle.contains(t,i.x,i.y)},e.Rectangle.containsRect=function(t,e){return!(t.volume>e.volume)&&(t.x>=e.x&&t.y>=e.y&&t.right<e.right&&t.bottom<e.bottom)},e.Rectangle.equals=function(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height},e.Rectangle.sameDimensions=function(t,e){return t.width===e.width&&t.height===e.height},e.Rectangle.intersection=function(t,i,s){return void 0===s&&(s=new e.Rectangle),e.Rectangle.intersects(t,i)&&(s.x=Math.max(t.x,i.x),s.y=Math.max(t.y,i.y),s.width=Math.min(t.right,i.right)-s.x,s.height=Math.min(t.bottom,i.bottom)-s.y),s},e.Rectangle.intersects=function(t,e){return!(t.width<=0||t.height<=0||e.width<=0||e.height<=0)&&!(t.right<e.x||t.bottom<e.y||t.x>e.right||t.y>e.bottom)},e.Rectangle.intersectsRaw=function(t,e,i,s,n,r){return void 0===r&&(r=0),!(e>t.right+r||i<t.left-r||s>t.bottom+r||n<t.top-r)},e.Rectangle.union=function(t,i,s){return void 0===s&&(s=new e.Rectangle),s.setTo(Math.min(t.x,i.x),Math.min(t.y,i.y),Math.max(t.right,i.right)-Math.min(t.left,i.left),Math.max(t.bottom,i.bottom)-Math.min(t.top,i.top))},e.Rectangle.aabb=function(t,i){void 0===i&&(i=new e.Rectangle);var s=Number.NEGATIVE_INFINITY,n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;return t.forEach(function(t){t.x>s&&(s=t.x),t.x<n&&(n=t.x),t.y>r&&(r=t.y),t.y<o&&(o=t.y)}),i.setTo(n,o,s-n,r-o),i},PIXI.Rectangle=e.Rectangle,e.EmptyRectangle=new e.Rectangle(0,0,0,0),e.RoundedRectangle=function(t,i,s,n,r){void 0===t&&(t=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=0),void 0===r&&(r=20),this.x=t,this.y=i,this.width=s,this.height=n,this.radius=r||20,this.type=e.ROUNDEDRECTANGLE},e.RoundedRectangle.prototype={clone:function(){return new e.RoundedRectangle(this.x,this.y,this.width,this.height,this.radius)},contains:function(t,e){if(this.width<=0||this.height<=0)return!1;var i=this.x;if(t>=i&&t<=i+this.width){var s=this.y;if(e>=s&&e<=s+this.height)return!0}return!1}},e.RoundedRectangle.prototype.constructor=e.RoundedRectangle,PIXI.RoundedRectangle=e.RoundedRectangle,e.Camera=function(t,i,s,n,r,o){this.game=t,this.world=t.world,this.id=0,this.view=new e.Rectangle(s,n,r,o),this.bounds=new e.Rectangle(s,n,r,o),this.deadzone=null,this.visible=!0,this.roundPx=!0,this.atLimit={x:!1,y:!1},this.target=null,this.displayObject=null,this.scale=null,this.totalInView=0,this.lerp=new e.Point(1,1),this.onShakeComplete=new e.Signal,this.onFlashComplete=new e.Signal,this.onFadeComplete=new e.Signal,this.fx=null,this._targetPosition=new e.Point,this._edge=0,this._position=new e.Point,this._shake={intensity:0,duration:0,horizontal:!1,vertical:!1,shakeBounds:!0,x:0,y:0},this._fxDuration=0,this._fxType=0,this._fixedView=new e.Rectangle},e.Camera.FOLLOW_LOCKON=0,e.Camera.FOLLOW_PLATFORMER=1,e.Camera.FOLLOW_TOPDOWN=2,e.Camera.FOLLOW_TOPDOWN_TIGHT=3,e.Camera.SHAKE_BOTH=4,e.Camera.SHAKE_HORIZONTAL=5,e.Camera.SHAKE_VERTICAL=6,e.Camera.ENABLE_FX=!0,e.Camera.prototype={boot:function(){this.displayObject=this.game.world,this.scale=this.game.world.scale,this.game.camera=this,e.Graphics&&e.Camera.ENABLE_FX&&(this.fx=new e.Graphics(this.game),this.game.stage.addChild(this.fx))},preUpdate:function(){this.totalInView=0},follow:function(t,i,s,n){void 0===i&&(i=e.Camera.FOLLOW_LOCKON),void 0===s&&(s=1),void 0===n&&(n=1),this.target=t,this.lerp.set(s,n);var r;switch(i){case e.Camera.FOLLOW_PLATFORMER:var o=this.width/8,a=this.height/3;this.deadzone=new e.Rectangle((this.width-o)/2,(this.height-a)/2-.25*a,o,a);break;case e.Camera.FOLLOW_TOPDOWN:r=Math.max(this.width,this.height)/4,this.deadzone=new e.Rectangle((this.width-r)/2,(this.height-r)/2,r,r);break;case e.Camera.FOLLOW_TOPDOWN_TIGHT:r=Math.max(this.width,this.height)/8,this.deadzone=new e.Rectangle((this.width-r)/2,(this.height-r)/2,r,r);break;case e.Camera.FOLLOW_LOCKON:default:this.deadzone=null}},unfollow:function(){this.target=null},focusOn:function(t){this.setPosition(Math.round(t.x-this.view.halfWidth),Math.round(t.y-this.view.halfHeight))},focusOnXY:function(t,e){this.setPosition(Math.round(t-this.view.halfWidth),Math.round(e-this.view.halfHeight))},shake:function(t,i,s,n,r){return void 0===t&&(t=.05),void 0===i&&(i=500),void 0===s&&(s=!0),void 0===n&&(n=e.Camera.SHAKE_BOTH),void 0===r&&(r=!0),!(!s&&this._shake.duration>0)&&(this._shake.intensity=t,this._shake.duration=i,this._shake.shakeBounds=r,this._shake.x=0,this._shake.y=0,this._shake.horizontal=n===e.Camera.SHAKE_BOTH||n===e.Camera.SHAKE_HORIZONTAL,this._shake.vertical=n===e.Camera.SHAKE_BOTH||n===e.Camera.SHAKE_VERTICAL,!0)},flash:function(t,e,i,s){return void 0===t&&(t=16777215),void 0===e&&(e=500),void 0===i&&(i=!1),void 0===s&&(s=1),!(!this.fx||!i&&this._fxDuration>0)&&(this.fx.clear(),this.fx.beginFill(t,s),this.fx.drawRect(0,0,this.width,this.height),this.fx.endFill(),this.fx.alpha=1,this._fxDuration=e,this._fxType=0,!0)},fade:function(t,e,i,s){return void 0===t&&(t=0),void 0===e&&(e=500),void 0===i&&(i=!1),void 0===s&&(s=1),!(!this.fx||!i&&this._fxDuration>0)&&(this.fx.clear(),this.fx.beginFill(t,s),this.fx.drawRect(0,0,this.width,this.height),this.fx.endFill(),this.fx.alpha=0,this._fxDuration=e,this._fxType=1,!0)},update:function(){this._fxDuration>0&&this.updateFX(),this._shake.duration>0&&this.updateShake(),this.bounds&&this.checkBounds(),this.roundPx&&(this.view.floor(),this._shake.x=Math.floor(this._shake.x),this._shake.y=Math.floor(this._shake.y)),this.displayObject.position.x=-this.view.x,this.displayObject.position.y=-this.view.y},updateFX:function(){0===this._fxType?(this.fx.alpha-=this.game.time.elapsedMS/this._fxDuration,this.fx.alpha<=0&&(this._fxDuration=0,this.fx.alpha=0,this.onFlashComplete.dispatch())):(this.fx.alpha+=this.game.time.elapsedMS/this._fxDuration,this.fx.alpha>=1&&(this._fxDuration=0,this.fx.alpha=1,this.onFadeComplete.dispatch()))},updateShake:function(){this._shake.duration-=this.game.time.elapsedMS,this._shake.duration<=0?(this.onShakeComplete.dispatch(),this._shake.x=0,this._shake.y=0):(this._shake.horizontal&&(this._shake.x=this.game.rnd.frac()*this._shake.intensity*this.view.width*2-this._shake.intensity*this.view.width),this._shake.vertical&&(this._shake.y=this.game.rnd.frac()*this._shake.intensity*this.view.height*2-this._shake.intensity*this.view.height))},updateTarget:function(){this._targetPosition.x=this.view.x+this.target.worldPosition.x,this._targetPosition.y=this.view.y+this.target.worldPosition.y,this.deadzone?(this._edge=this._targetPosition.x-this.view.x,this._edge<this.deadzone.left?this.view.x=this.game.math.linear(this.view.x,this._targetPosition.x-this.deadzone.left,this.lerp.x):this._edge>this.deadzone.right&&(this.view.x=this.game.math.linear(this.view.x,this._targetPosition.x-this.deadzone.right,this.lerp.x)),this._edge=this._targetPosition.y-this.view.y,this._edge<this.deadzone.top?this.view.y=this.game.math.linear(this.view.y,this._targetPosition.y-this.deadzone.top,this.lerp.y):this._edge>this.deadzone.bottom&&(this.view.y=this.game.math.linear(this.view.y,this._targetPosition.y-this.deadzone.bottom,this.lerp.y))):(this.view.x=this.game.math.linear(this.view.x,this._targetPosition.x-this.view.halfWidth,this.lerp.x),this.view.y=this.game.math.linear(this.view.y,this._targetPosition.y-this.view.halfHeight,this.lerp.y)),this.bounds&&this.checkBounds(),this.roundPx&&this.view.floor(),this.displayObject.position.x=-this.view.x,this.displayObject.position.y=-this.view.y},setBoundsToWorld:function(){this.bounds&&this.bounds.copyFrom(this.game.world.bounds)},checkBounds:function(){this.atLimit.x=!1,this.atLimit.y=!1;var t=this.view.x+this._shake.x,e=this.view.right+this._shake.x,i=this.view.y+this._shake.y,s=this.view.bottom+this._shake.y;t<=this.bounds.x*this.scale.x?(this.atLimit.x=!0,this.view.x=this.bounds.x*this.scale.x,this._shake.shakeBounds||(this._shake.x=0)):e>=this.bounds.right*this.scale.x&&(this.atLimit.x=!0,this.view.x=this.bounds.right*this.scale.x-this.width,this._shake.shakeBounds||(this._shake.x=0)),i<=this.bounds.top*this.scale.y?(this.atLimit.y=!0,this.view.y=this.bounds.top*this.scale.y,this._shake.shakeBounds||(this._shake.y=0)):s>=this.bounds.bottom*this.scale.y&&(this.atLimit.y=!0,this.view.y=this.bounds.bottom*this.scale.y-this.height,this._shake.shakeBounds||(this._shake.y=0))},setPosition:function(t,e){this.view.x=t,this.view.y=e,this.bounds&&this.checkBounds()},setSize:function(t,e){this.view.width=t,this.view.height=e},reset:function(){this.target=null,this.view.x=0,this.view.y=0,this._shake.duration=0,this._shake.x=0,this._shake.y=0,this.resetFX()},resetFX:function(){this.fx&&(this.fx.clear(),this.fx.alpha=0),this._fxDuration=0}},e.Camera.prototype.constructor=e.Camera,Object.defineProperty(e.Camera.prototype,"x",{get:function(){return this.view.x},set:function(t){this.view.x=t,this.bounds&&this.checkBounds()}}),Object.defineProperty(e.Camera.prototype,"y",{get:function(){return this.view.y},set:function(t){this.view.y=t,this.bounds&&this.checkBounds()}}),Object.defineProperty(e.Camera.prototype,"position",{get:function(){return this._position.set(this.view.x,this.view.y),this._position},set:function(t){void 0!==t.x&&(this.view.x=t.x),void 0!==t.y&&(this.view.y=t.y),this.bounds&&this.checkBounds()}}),Object.defineProperty(e.Camera.prototype,"width",{get:function(){return this.view.width},set:function(t){this.view.width=t}}),Object.defineProperty(e.Camera.prototype,"height",{get:function(){return this.view.height},set:function(t){this.view.height=t}}),Object.defineProperty(e.Camera.prototype,"shakeIntensity",{get:function(){return this._shake.intensity},set:function(t){this._shake.intensity=t}}),Object.defineProperty(e.Camera.prototype,"fixedView",{get:function(){return this._fixedView.setTo(0,0,this.view.width,this.view.height),this._fixedView}}),Object.defineProperty(e.Camera.prototype,"centerX",{get:function(){return this.x+.5*this.width}}),Object.defineProperty(e.Camera.prototype,"centerY",{get:function(){return this.y+.5*this.height}}),e.State=function(){this.game=null,this.key="",this.add=null,this.make=null,this.camera=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.sound=null,this.scale=null,this.stage=null,this.state=null,this.time=null,this.tweens=null,this.world=null,this.particles=null,this.physics=null,this.rnd=null},e.State.prototype={init:function(){},preload:function(){},loadUpdate:function(){},loadRender:function(){},create:function(){},update:function(){},postUpdate:function(){},preRender:function(){},render:function(){},resize:function(){},paused:function(){},resumed:function(){},pauseUpdate:function(){},shutdown:function(){}},e.State.prototype.constructor=e.State,e.StateManager=function(t,i){this.game=t,this.states={},this._pendingState=null,void 0!==i&&null!==i&&(this._pendingState=i),this._clearWorld=!1,this._clearCache=!1,this._created=!1,this._args=[],this.current="",this.onStateChange=new e.Signal,this.onInitCallback=null,this.onPreloadCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onRenderCallback=null,this.onResizeCallback=null,this.onPreRenderCallback=null,this.onLoadUpdateCallback=null,this.onLoadRenderCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null,this.onShutDownCallback=null},e.StateManager.prototype={boot:function(){this.game.onPause.add(this.pause,this),this.game.onResume.add(this.resume,this),null!==this._pendingState&&"string"!=typeof this._pendingState&&this.add("default",this._pendingState,!0)},add:function(t,i,s){void 0===s&&(s=!1);var n;return i instanceof e.State?n=i:"object"==typeof i?(n=i).game=this.game:"function"==typeof i&&(n=new i(this.game)),this.states[t]=n,s&&(this.game.isBooted?this.start(t):this._pendingState=t),n},remove:function(t){this.current===t&&(this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onLoadRenderCallback=null,this.onLoadUpdateCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onPreRenderCallback=null,this.onRenderCallback=null,this.onResizeCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null),delete this.states[t]},start:function(t,e,i){void 0===e&&(e=!0),void 0===i&&(i=!1),this.checkState(t)&&(this._pendingState=t,this._clearWorld=e,this._clearCache=i,arguments.length>3&&(this._args=Array.prototype.splice.call(arguments,3)))},restart:function(t,e){void 0===t&&(t=!0),void 0===e&&(e=!1),this._pendingState=this.current,this._clearWorld=t,this._clearCache=e,arguments.length>2&&(this._args=Array.prototype.slice.call(arguments,2))},dummy:function(){},preUpdate:function(){if(this._pendingState&&this.game.isBooted){var t=this.current;if(this.clearCurrentState(),this.setCurrentState(this._pendingState),this.onStateChange.dispatch(this.current,t),this.current!==this._pendingState)return;this._pendingState=null,this.onPreloadCallback?(this.game.load.reset(!0),this.onPreloadCallback.call(this.callbackContext,this.game),0===this.game.load.totalQueuedFiles()&&0===this.game.load.totalQueuedPacks()?this.loadComplete():this.game.load.start()):this.loadComplete()}},clearCurrentState:function(){this.current&&(this.onShutDownCallback&&this.onShutDownCallback.call(this.callbackContext,this.game),this.game.tweens.removeAll(),this.game.camera.reset(),this.game.input.reset(!0),this.game.physics.clear(),this.game.time.removeAll(),this.game.scale.reset(this._clearWorld),this.game.debug&&this.game.debug.reset(),this._clearWorld&&(this.game.world.shutdown(),this._clearCache&&this.game.cache.destroy()))},checkState:function(t){var e=this.states[t];return e?!!(e.preload||e.create||e.update||e.render)||(console.warn("Invalid Phaser State object given. Must contain at least one of the required functions: preload, create, update or render"),!1):(console.warn("Phaser.StateManager - No state found with the key: "+t),!1)},link:function(t){var e=this.states[t];e.game=this.game,e.add=this.game.add,e.make=this.game.make,e.camera=this.game.camera,e.cache=this.game.cache,e.input=this.game.input,e.load=this.game.load,e.math=this.game.math,e.sound=this.game.sound,e.scale=this.game.scale,e.state=this,e.stage=this.game.stage,e.time=this.game.time,e.tweens=this.game.tweens,e.world=this.game.world,e.particles=this.game.particles,e.rnd=this.game.rnd,e.physics=this.game.physics,e.key=t},unlink:function(t){var e=this.states[t];e&&(e.game=null,e.add=null,e.make=null,e.camera=null,e.cache=null,e.input=null,e.load=null,e.math=null,e.sound=null,e.scale=null,e.state=null,e.stage=null,e.time=null,e.tweens=null,e.world=null,e.particles=null,e.rnd=null,e.physics=null)},setCurrentState:function(t){var e=this.states[t];this.callbackContext=e,this.link(t),this.onInitCallback=e.init||this.dummy,this.onPreloadCallback=e.preload||null,this.onLoadRenderCallback=e.loadRender||null,this.onLoadUpdateCallback=e.loadUpdate||null,this.onCreateCallback=e.create||null,this.onUpdateCallback=e.update||null,this.onPostUpdateCallback=e.postUpdate||null,this.onPreRenderCallback=e.preRender||null,this.onRenderCallback=e.render||null,this.onResizeCallback=e.resize||null,this.onPausedCallback=e.paused||null,this.onResumedCallback=e.resumed||null,this.onPauseUpdateCallback=e.pauseUpdate||null,this.onShutDownCallback=e.shutdown||this.dummy,""!==this.current&&this.game.physics.reset(),this.current=t,this._created=!1,this.onInitCallback.apply(this.callbackContext,this._args),t===this._pendingState&&(this._args=[]),this.game._kickstart=!0},getCurrentState:function(){return this.states[this.current]},loadComplete:function(){!1===this._created&&this.onCreateCallback?(this._created=!0,this.onCreateCallback.call(this.callbackContext,this.game)):this._created=!0},loadUpdate:function(){!1===this._created&&this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game)},pause:function(){this._created&&this.onPausedCallback&&this.onPausedCallback.call(this.callbackContext,this.game)},resume:function(){this._created&&this.onResumedCallback&&this.onResumedCallback.call(this.callbackContext,this.game)},update:function(){this._created?this.onUpdateCallback&&this.onUpdateCallback.call(this.callbackContext,this.game):this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game)},postUpdate:function(){this._created&&this.onPostUpdateCallback&&this.onPostUpdateCallback.call(this.callbackContext,this.game)},pauseUpdate:function(){this._created?this.onPauseUpdateCallback&&this.onPauseUpdateCallback.call(this.callbackContext,this.game):this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game)},preRender:function(t){this._created&&this.onPreRenderCallback&&this.onPreRenderCallback.call(this.callbackContext,this.game,t)},resize:function(t,e){this.onResizeCallback&&this.onResizeCallback.call(this.callbackContext,t,e)},render:function(){this._created?this.onRenderCallback&&(this.game.renderType===e.CANVAS?(this.game.context.save(),this.game.context.setTransform(1,0,0,1,0,0),this.onRenderCallback.call(this.callbackContext,this.game),this.game.context.restore()):this.onRenderCallback.call(this.callbackContext,this.game)):this.onLoadRenderCallback&&this.onLoadRenderCallback.call(this.callbackContext,this.game)},destroy:function(){this._clearWorld=!0,this._clearCache=!0,this.clearCurrentState(),this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onLoadRenderCallback=null,this.onLoadUpdateCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onPostUpdateCallback=null,this.onRenderCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null,this.game=null,this.states={},this._pendingState=null,this.current=""}},e.StateManager.prototype.constructor=e.StateManager,Object.defineProperty(e.StateManager.prototype,"created",{get:function(){return this._created}}),e.Signal=function(){},e.Signal.prototype={_bindings:null,_prevParams:null,memorize:!1,_shouldPropagate:!0,active:!0,_boundDispatch:!1,validateListener:function(t,e){if("function"!=typeof t)throw new Error("Phaser.Signal: listener is a required param of {fn}() and should be a Function.".replace("{fn}",e))},_registerListener:function(t,i,s,n,r){var o,a=this._indexOfListener(t,s);if(-1!==a){if((o=this._bindings[a]).isOnce()!==i)throw new Error("You cannot add"+(i?"":"Once")+"() then add"+(i?"Once":"")+"() the same listener without removing the relationship first.")}else o=new e.SignalBinding(this,t,i,s,n,r),this._addBinding(o);return this.memorize&&this._prevParams&&o.execute(this._prevParams),o},_addBinding:function(t){this._bindings||(this._bindings=[]);var e=this._bindings.length;do{e--}while(this._bindings[e]&&t._priority<=this._bindings[e]._priority);this._bindings.splice(e+1,0,t)},_indexOfListener:function(t,e){if(!this._bindings)return-1;void 0===e&&(e=null);for(var i,s=this._bindings.length;s--;)if((i=this._bindings[s])._listener===t&&i.context===e)return s;return-1},has:function(t,e){return-1!==this._indexOfListener(t,e)},add:function(t,e,i){this.validateListener(t,"add");var s=[];if(arguments.length>3)for(var n=3;n<arguments.length;n++)s.push(arguments[n]);return this._registerListener(t,!1,e,i,s)},addOnce:function(t,e,i){this.validateListener(t,"addOnce");var s=[];if(arguments.length>3)for(var n=3;n<arguments.length;n++)s.push(arguments[n]);return this._registerListener(t,!0,e,i,s)},remove:function(t,e){this.validateListener(t,"remove");var i=this._indexOfListener(t,e);return-1!==i&&(this._bindings[i]._destroy(),this._bindings.splice(i,1)),t},removeAll:function(t){if(void 0===t&&(t=null),this._bindings){for(var e=this._bindings.length;e--;)t?this._bindings[e].context===t&&(this._bindings[e]._destroy(),this._bindings.splice(e,1)):this._bindings[e]._destroy();t||(this._bindings.length=0)}},getNumListeners:function(){return this._bindings?this._bindings.length:0},halt:function(){this._shouldPropagate=!1},dispatch:function(){if(this.active&&(this._bindings||this.memorize)){var t=Array.prototype.slice.call(arguments);this.memorize&&(this._prevParams=t);var e=this._bindings?this._bindings.length:0;if(e){var i=this._bindings.slice();this._shouldPropagate=!0;do{e--}while(i[e]&&this._shouldPropagate&&!1!==i[e].execute(t))}}},forget:function(){this._prevParams&&(this._prevParams=null)},dispose:function(){this.removeAll(),this._bindings=null,this._prevParams&&(this._prevParams=null)},toString:function(){return"[Phaser.Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}},Object.defineProperty(e.Signal.prototype,"boundDispatch",{get:function(){var t=this;return this._boundDispatch||(this._boundDispatch=function(){return t.dispatch.apply(t,arguments)})}}),e.Signal.prototype.constructor=e.Signal,e.SignalBinding=function(t,e,i,s,n,r){this._listener=e,i&&(this._isOnce=!0),null!=s&&(this.context=s),this._signal=t,n&&(this._priority=n),r&&r.length&&(this._args=r)},e.SignalBinding.prototype={context:null,_isOnce:!1,_priority:0,_args:null,callCount:0,active:!0,params:null,execute:function(t){var e,i;return this.active&&this._listener&&(i=this.params?this.params.concat(t):t,this._args&&(i=i.concat(this._args)),e=this._listener.apply(this.context,i),this.callCount++,this._isOnce&&this.detach()),e},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal,delete this._listener,delete this.context},toString:function(){return"[Phaser.SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}},e.SignalBinding.prototype.constructor=e.SignalBinding,e.Filter=function(t,i,s){this.game=t,this.type=e.WEBGL_FILTER,this.passes=[this],this.shaders=[],this.dirty=!0,this.padding=0,this.prevPoint=new e.Point;var n=new Date;if(this.uniforms={resolution:{type:"2f",value:{x:256,y:256}},time:{type:"1f",value:0},mouse:{type:"2f",value:{x:0,y:0}},date:{type:"4fv",value:[n.getFullYear(),n.getMonth(),n.getDate(),60*n.getHours()*60+60*n.getMinutes()+n.getSeconds()]},sampleRate:{type:"1f",value:44100},iChannel0:{type:"sampler2D",value:null,textureData:{repeat:!0}},iChannel1:{type:"sampler2D",value:null,textureData:{repeat:!0}},iChannel2:{type:"sampler2D",value:null,textureData:{repeat:!0}},iChannel3:{type:"sampler2D",value:null,textureData:{repeat:!0}}},i)for(var r in i)this.uniforms[r]=i[r];"string"==typeof s&&(s=s.split("\n")),this.fragmentSrc=s||[]},e.Filter.prototype={init:function(){},setResolution:function(t,e){this.uniforms.resolution.value.x=t,this.uniforms.resolution.value.y=e},update:function(t){if(t){var e=t.x/this.game.width,i=1-t.y/this.game.height;e===this.prevPoint.x&&i===this.prevPoint.y||(this.uniforms.mouse.value.x=e.toFixed(2),this.uniforms.mouse.value.y=i.toFixed(2),this.prevPoint.set(e,i))}this.uniforms.time.value=this.game.time.totalElapsedSeconds()},addToWorld:function(t,i,s,n,r,o){void 0===r&&(r=0),void 0===o&&(o=0),void 0!==s&&null!==s?this.width=s:s=this.width,void 0!==n&&null!==n?this.height=n:n=this.height;var a=this.game.add.image(t,i,e.Cache.DEFAULT);return a.width=s,a.height=n,a.anchor.set(r,o),a.filters=[this],a},syncUniforms:function(){for(var t=0;t<this.shaders.length;t++)this.shaders[t].dirty=!0},destroy:function(){this.passes.length=0,this.shaders.length=0,this.fragmentSrc.length=0,this.game=null,this.uniforms=null,this.prevPoint=null}},e.Filter.prototype.constructor=e.Filter,Object.defineProperty(e.Filter.prototype,"width",{get:function(){return this.uniforms.resolution.value.x},set:function(t){this.uniforms.resolution.value.x=t}}),Object.defineProperty(e.Filter.prototype,"height",{get:function(){return this.uniforms.resolution.value.y},set:function(t){this.uniforms.resolution.value.y=t}}),e.Plugin=function(t,e){void 0===e&&(e=null),this.game=t,this.parent=e,this.active=!1,this.visible=!1,this.hasPreUpdate=!1,this.hasUpdate=!1,this.hasPostUpdate=!1,this.hasRender=!1,this.hasPostRender=!1},e.Plugin.prototype={preUpdate:function(){},update:function(){},render:function(){},postRender:function(){},destroy:function(){this.game=null,this.parent=null,this.active=!1,this.visible=!1}},e.Plugin.prototype.constructor=e.Plugin,e.PluginManager=function(t){this.game=t,this.plugins=[],this._len=0,this._i=0},e.PluginManager.prototype={add:function(t){var e=Array.prototype.slice.call(arguments,1),i=!1;return"function"==typeof t?t=new t(this.game,this):(t.game=this.game,t.parent=this),"function"==typeof t.preUpdate&&(t.hasPreUpdate=!0,i=!0),"function"==typeof t.update&&(t.hasUpdate=!0,i=!0),"function"==typeof t.postUpdate&&(t.hasPostUpdate=!0,i=!0),"function"==typeof t.render&&(t.hasRender=!0,i=!0),"function"==typeof t.postRender&&(t.hasPostRender=!0,i=!0),i?((t.hasPreUpdate||t.hasUpdate||t.hasPostUpdate)&&(t.active=!0),(t.hasRender||t.hasPostRender)&&(t.visible=!0),this._len=this.plugins.push(t),"function"==typeof t.init&&t.init.apply(t,e),t):null},remove:function(t,e){for(void 0===e&&(e=!0),this._i=this._len;this._i--;)if(this.plugins[this._i]===t)return e&&t.destroy(),this.plugins.splice(this._i,1),void this._len--},removeAll:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].destroy();this.plugins.length=0,this._len=0},preUpdate:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].active&&this.plugins[this._i].hasPreUpdate&&this.plugins[this._i].preUpdate()},update:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].active&&this.plugins[this._i].hasUpdate&&this.plugins[this._i].update()},postUpdate:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].active&&this.plugins[this._i].hasPostUpdate&&this.plugins[this._i].postUpdate()},render:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].visible&&this.plugins[this._i].hasRender&&this.plugins[this._i].render()},postRender:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].visible&&this.plugins[this._i].hasPostRender&&this.plugins[this._i].postRender()},destroy:function(){this.removeAll(),this.game=null}},e.PluginManager.prototype.constructor=e.PluginManager,e.Stage=function(t){this.game=t,PIXI.DisplayObjectContainer.call(this),this.name="_stage_root",this.disableVisibilityChange=!1,this.exists=!0,this.worldTransform=new e.Matrix,this.stage=this,this.currentRenderOrderID=0,this._hiddenVar="hidden",this._onChange=null,this._bgColor={r:0,g:0,b:0,a:0,color:0,rgba:"#000000"},this.game.transparent||(this._bgColor.a=1),t.config&&this.parseConfig(t.config)},e.Stage.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),e.Stage.prototype.constructor=e.Stage,e.Stage.prototype.parseConfig=function(t){t.disableVisibilityChange&&(this.disableVisibilityChange=t.disableVisibilityChange),t.backgroundColor&&this.setBackgroundColor(t.backgroundColor)},e.Stage.prototype.boot=function(){e.DOM.getOffset(this.game.canvas,this.offset),e.Canvas.setUserSelect(this.game.canvas,"none"),e.Canvas.setTouchAction(this.game.canvas,"none"),this.checkVisibility()},e.Stage.prototype.preUpdate=function(){this.currentRenderOrderID=0;for(var t=0;t<this.children.length;){var e=this.children[t];e.preUpdate(),this===e.parent&&t++}},e.Stage.prototype.update=function(){for(var t=this.children.length;t--;)this.children[t].update()},e.Stage.prototype.postUpdate=function(){this.game.camera.update(),this.game.camera.target&&(this.game.camera.target.postUpdate(),this.updateTransform(),this.game.camera.updateTarget());for(var t=0;t<this.children.length;t++)this.children[t].postUpdate();this.updateTransform()},e.Stage.prototype.updateTransform=function(){this.worldAlpha=1;for(var t=0;t<this.children.length;t++)this.children[t].updateTransform()},e.Stage.prototype.checkVisibility=function(){void 0!==document.hidden?this._hiddenVar="visibilitychange":void 0!==document.webkitHidden?this._hiddenVar="webkitvisibilitychange":void 0!==document.mozHidden?this._hiddenVar="mozvisibilitychange":void 0!==document.msHidden?this._hiddenVar="msvisibilitychange":this._hiddenVar=null;var t=this;this._onChange=function(e){return t.visibilityChange(e)},this._onChangePause=function(){return t._onChange({type:"pause"})},this._onChangeResume=function(){return t._onChange({type:"resume"})},this._onClick=function(e){void 0===document.hasFocus||document.hasFocus()||t.visibilityChange(e)},this._hiddenVar&&document.addEventListener(this._hiddenVar,this._onChange,!1),window.onblur=this._onChange,window.onfocus=this._onChange,window.onpagehide=this._onChange,window.onpageshow=this._onChange,window.addEventListener("click",this._onClick),this.game.device.cocoonJSApp&&CocoonJS.App&&(CocoonJS.App.onSuspended&&CocoonJS.App.onSuspended.addEventListener(this._onChangePause),CocoonJS.App.onActivated&&CocoonJS.App.onActivated.addEventListener(this._onChangeResume),CocoonJS.App.on&&(CocoonJS.App.on("activated",this._onChangeResume),CocoonJS.App.on("suspended",this._onChangePause)))},e.Stage.prototype.visibilityChange=function(t){switch(t.type){case"blur":case"pagehide":return void this.game.focusLoss(t);case"click":case"focus":case"pageshow":return void this.game.focusGain(t)}this.disableVisibilityChange||(document.hidden||document.mozHidden||document.msHidden||document.webkitHidden||"pause"===t.type?this.game.gamePaused(t):this.game.gameResumed(t))},e.Stage.prototype.setBackgroundColor=function(t){this.game.transparent||(e.Color.valueToColor(t,this._bgColor),e.Color.updateColor(this._bgColor),this._bgColor.r/=255,this._bgColor.g/=255,this._bgColor.b/=255,this._bgColor.a=1)},e.Stage.prototype.destroy=function(){this._hiddenVar&&document.removeEventListener(this._hiddenVar,this._onChange,!1),window.onpagehide=null,window.onpageshow=null,window.onblur=null,window.onfocus=null,window.removeEventListener("click",this._onClick)},e.Stage.prototype.add=function(t,e,i){return t.parent===this?t:(t.body&&t.parent&&t.parent.hash&&t.parent.removeFromHash(t),void 0===i?this.addChild(t):this.addChildAt(t,i),t)},Object.defineProperty(e.Stage.prototype,"backgroundColor",{get:function(){return this._bgColor.color},set:function(t){this.setBackgroundColor(t)}}),Object.defineProperty(e.Stage.prototype,"smoothed",{get:function(){return PIXI.scaleModes.DEFAULT===PIXI.scaleModes.LINEAR},set:function(t){PIXI.scaleModes.DEFAULT=t?PIXI.scaleModes.LINEAR:PIXI.scaleModes.NEAREST}}),e.Group=function(t,i,s,n,r,o){void 0===n&&(n=!1),void 0===r&&(r=!1),void 0===o&&(o=e.Physics.ARCADE),this.game=t,void 0===i&&(i=t.world),this.name=s||"group",this.z=0,PIXI.DisplayObjectContainer.call(this),n?(this.game.stage.addChild(this),this.z=this.game.stage.children.length):i&&(i.addChild(this),this.z=i.children.length),this.type=e.GROUP,this.physicsType=e.GROUP,this.alive=!0,this.exists=!0,this.ignoreDestroy=!1,this.pendingDestroy=!1,this.classType=e.Sprite,this.cursor=null,this.inputEnableChildren=!1,this.updateOnlyExistingChildren=!1,this.onChildInputDown=new e.Signal,this.onChildInputUp=new e.Signal,this.onChildInputOver=new e.Signal,this.onChildInputOut=new e.Signal,this.enableBody=r,this.enableBodyDebug=!1,this.physicsBodyType=o,this.physicsSortDirection=null,this.onDestroy=new e.Signal,this.cursorIndex=0,this.fixedToCamera=!1,this.cameraOffset=new e.Point,this.hash=[],this._sortProperty="z"},e.Group.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),e.Group.prototype.constructor=e.Group,e.Group.RETURN_NONE=0,e.Group.RETURN_TOTAL=1,e.Group.RETURN_CHILD=2,e.Group.RETURN_ALL=3,e.Group.SORT_ASCENDING=-1,e.Group.SORT_DESCENDING=1,e.Group.prototype.add=function(t,e,i){return void 0===e&&(e=!1),t.parent===this?t:(t.body&&t.parent&&t.parent.hash&&t.parent.removeFromHash(t),void 0===i?(t.z=this.children.length,this.addChild(t)):(this.addChildAt(t,i),this.updateZ()),this.enableBody&&t.hasOwnProperty("body")&&null===t.body?this.game.physics.enable(t,this.physicsBodyType):t.body&&this.addToHash(t),!this.inputEnableChildren||t.input&&!t.inputEnabled||(t.inputEnabled=!0),!e&&t.events&&t.events.onAddedToGroup$dispatch(t,this),null===this.cursor&&(this.cursor=t),t)},e.Group.prototype.addAt=function(t,e,i){return this.add(t,i,e)},e.Group.prototype.addToHash=function(t){return t.parent===this&&-1===this.hash.indexOf(t)&&(this.hash.push(t),!0)},e.Group.prototype.removeFromHash=function(t){if(t){var e=this.hash.indexOf(t);if(-1!==e)return this.hash.splice(e,1),!0}return!1},e.Group.prototype.addMultiple=function(t,i){if(t instanceof e.Group)t.moveAll(this,i);else if(Array.isArray(t))for(var s=0;s<t.length;s++)this.add(t[s],i);return t},e.Group.prototype.getAt=function(t){return t<0||t>=this.children.length?-1:this.getChildAt(t)},e.Group.prototype.create=function(t,e,i,s,n,r){void 0===n&&(n=!0);var o=new this.classType(this.game,t,e,i,s);return o.exists=n,o.visible=n,o.alive=n,this.add(o,!1,r)},e.Group.prototype.createMultiple=function(t,e,i,s,n,r){void 0===i&&(i=0),void 0===s&&(s=!1),Array.isArray(e)||(e=[e]),Array.isArray(i)||(i=[i]);var o=this,a=[];return e.forEach(function(e){i.forEach(function(i){for(var h=0;h<t;h++){var l=o.create(0,0,e,i,s);n&&n.call(r||l,l,h),a.push(l)}})}),a},e.Group.prototype.updateZ=function(){for(var t=this.children.length;t--;)this.children[t].z=t},e.Group.prototype.align=function(t,i,s,n,r,o){if(void 0===r&&(r=e.TOP_LEFT),void 0===o&&(o=0),0===this.children.length||o>this.children.length||-1===t&&-1===i)return!1;for(var a=new e.Rectangle(0,0,s,n),h=t*s,l=i*n,c=o;c<this.children.length;c++){var u=this.children[c];if(u.alignIn)if(u.alignIn(a,r),-1===t)a.y+=n,a.y===l&&(a.x+=s,a.y=0);else if(-1===i)a.x+=s,a.x===h&&(a.x=0,a.y+=n);else if(a.x+=s,a.x===h&&(a.x=0,a.y+=n,a.y===l))return!0}return!0},e.Group.prototype.resetCursor=function(t){if(void 0===t&&(t=0),t>this.children.length-1&&(t=0),this.cursor)return this.cursorIndex=t,this.cursor=this.children[this.cursorIndex],this.cursor},e.Group.prototype.next=function(){if(this.cursor)return this.cursorIndex>=this.children.length-1?this.cursorIndex=0:this.cursorIndex++,this.cursor=this.children[this.cursorIndex],this.cursor},e.Group.prototype.previous=function(){if(this.cursor)return 0===this.cursorIndex?this.cursorIndex=this.children.length-1:this.cursorIndex--,this.cursor=this.children[this.cursorIndex],this.cursor},e.Group.prototype.swap=function(t,e){this.swapChildren(t,e),this.updateZ()},e.Group.prototype.bringToTop=function(t){return t.parent===this&&this.getIndex(t)<this.children.length&&(this.remove(t,!1,!0),this.add(t,!0)),t},e.Group.prototype.bringChildToTop=e.Group.prototype.bringToTop,e.Group.prototype.sendToBack=function(t){return t.parent===this&&this.getIndex(t)>0&&(this.remove(t,!1,!0),this.addAt(t,0,!0)),t},e.Group.prototype.sendChildToBack=e.Group.prototype.sendToBack,e.Group.prototype.moveUp=function(t){if(t.parent===this&&this.getIndex(t)<this.children.length-1){var e=this.getIndex(t),i=this.getAt(e+1);i&&this.swap(t,i)}return t},e.Group.prototype.moveDown=function(t){if(t.parent===this&&this.getIndex(t)>0){var e=this.getIndex(t),i=this.getAt(e-1);i&&this.swap(t,i)}return t},e.Group.prototype.xy=function(t,e,i){if(t<0||t>this.children.length)return-1;this.getChildAt(t).x=e,this.getChildAt(t).y=i},e.Group.prototype.reverse=function(){this.children.reverse(),this.updateZ()},e.Group.prototype.getIndex=function(t){return this.children.indexOf(t)},e.Group.prototype.getByName=function(t){return this.getFirst("name",t)},e.Group.prototype.replace=function(t,i){var s=this.getIndex(t);if(-1!==s)return i.parent&&(i.parent instanceof e.Group?i.parent.remove(i):i.parent.removeChild(i)),this.remove(t),this.addAt(i,s),t},e.Group.prototype.hasProperty=function(t,e){var i=e.length;return 1===i&&e[0]in t||(2===i&&e[0]in t&&e[1]in t[e[0]]||(3===i&&e[0]in t&&e[1]in t[e[0]]&&e[2]in t[e[0]][e[1]]||4===i&&e[0]in t&&e[1]in t[e[0]]&&e[2]in t[e[0]][e[1]]&&e[3]in t[e[0]][e[1]][e[2]]))},e.Group.prototype.setProperty=function(t,e,i,s,n){if(void 0===n&&(n=!1),s=s||0,!this.hasProperty(t,e)&&(!n||s>0))return!1;var r=e.length;return 1===r?0===s?t[e[0]]=i:1===s?t[e[0]]+=i:2===s?t[e[0]]-=i:3===s?t[e[0]]*=i:4===s&&(t[e[0]]/=i):2===r?0===s?t[e[0]][e[1]]=i:1===s?t[e[0]][e[1]]+=i:2===s?t[e[0]][e[1]]-=i:3===s?t[e[0]][e[1]]*=i:4===s&&(t[e[0]][e[1]]/=i):3===r?0===s?t[e[0]][e[1]][e[2]]=i:1===s?t[e[0]][e[1]][e[2]]+=i:2===s?t[e[0]][e[1]][e[2]]-=i:3===s?t[e[0]][e[1]][e[2]]*=i:4===s&&(t[e[0]][e[1]][e[2]]/=i):4===r&&(0===s?t[e[0]][e[1]][e[2]][e[3]]=i:1===s?t[e[0]][e[1]][e[2]][e[3]]+=i:2===s?t[e[0]][e[1]][e[2]][e[3]]-=i:3===s?t[e[0]][e[1]][e[2]][e[3]]*=i:4===s&&(t[e[0]][e[1]][e[2]][e[3]]/=i)),!0},e.Group.prototype.checkProperty=function(t,i,s,n){if(void 0===n&&(n=!1),this!==t.parent)return!1;var r=e.Utils.getProperty(t,i);return!(void 0===r&&n||r!==s)},e.Group.prototype.set=function(t,e,i,s,n,r,o){if(void 0===o&&(o=!1),e=e.split("."),void 0===s&&(s=!1),void 0===n&&(n=!1),(!1===s||s&&t.alive)&&(!1===n||n&&t.visible))return this.setProperty(t,e,i,r,o)},e.Group.prototype.setAll=function(t,e,i,s,n,r){void 0===i&&(i=!1),void 0===s&&(s=!1),void 0===r&&(r=!1),t=t.split("."),n=n||0;for(var o=this.children.length,a=0;a<o;a++){var h=this.children[a];i&&!h.alive||s&&!h.visible||this.setProperty(h,t,e,n,r)}},e.Group.prototype.setAllChildren=function(t,i,s,n,r,o){void 0===s&&(s=!1),void 0===n&&(n=!1),void 0===o&&(o=!1),r=r||0;for(var a=this.children.length,h=0;h<a;h++){var l=this.children[h];s&&!l.alive||n&&!l.visible||(l instanceof e.Group?l.setAllChildren(t,i,s,n,r,o):this.setProperty(l,t.split("."),i,r,o))}},e.Group.prototype.checkAll=function(t,e,i,s,n){void 0===i&&(i=!1),void 0===s&&(s=!1),void 0===n&&(n=!1);for(var r=0;r<this.children.length;r++){var o=this.children[r];if((!i||o.alive)&&(!s||o.visible)&&!this.checkProperty(o,t,e,n))return!1}return!0},e.Group.prototype.checkAny=function(t,e,i,s){void 0===i&&(i=!1),void 0===s&&(s=!1);for(var n=0;n<this.children.length;n++){var r=this.children[n];if((!i||r.alive)&&(!s||r.visible)&&this.checkProperty(r,t,e))return!0}return!1},e.Group.prototype.addAll=function(t,e,i,s){this.setAll(t,e,i,s,1)},e.Group.prototype.subAll=function(t,e,i,s){this.setAll(t,e,i,s,2)},e.Group.prototype.multiplyAll=function(t,e,i,s){this.setAll(t,e,i,s,3)},e.Group.prototype.divideAll=function(t,e,i,s){this.setAll(t,e,i,s,4)},e.Group.prototype.kill=function(){this.alive=!1,this.exists=!1,this.visible=!1},e.Group.prototype.killAll=function(){this.callAllExists("kill",!0)},e.Group.prototype.revive=function(){this.alive=!0,this.exists=!0,this.visible=!0},e.Group.prototype.reviveAll=function(){this.callAllExists("revive",!1)},e.Group.prototype.resetAll=function(t,e,i,s,n){this.forEach(this.resetChild,this,n,t,e,i,s)},e.Group.prototype.callAllExists=function(t,e){var i;if(arguments.length>2){i=[];for(s=2;s<arguments.length;s++)i.push(arguments[s])}for(var s=0;s<this.children.length;s++){var n=this.children[s];n.exists===e&&n[t]&&n[t].apply(n,i)}},e.Group.prototype.callbackFromArray=function(t,e,i){if(1===i){if(t[e[0]])return t[e[0]]}else if(2===i){if(t[e[0]][e[1]])return t[e[0]][e[1]]}else if(3===i){if(t[e[0]][e[1]][e[2]])return t[e[0]][e[1]][e[2]]}else if(4===i){if(t[e[0]][e[1]][e[2]][e[3]])return t[e[0]][e[1]][e[2]][e[3]]}else if(t[e])return t[e];return!1},e.Group.prototype.callAll=function(t,e){if(void 0!==t){var i=(t=t.split(".")).length;if(void 0===e||null===e||""===e)e=null;else if("string"==typeof e)var s=(e=e.split(".")).length;var n;if(arguments.length>2){n=[];for(a=2;a<arguments.length;a++)n.push(arguments[a])}for(var r=null,o=null,a=0;a<this.children.length;a++){var h=this.children[a];r=this.callbackFromArray(h,t,i),e&&r?(o=this.callbackFromArray(h,e,s),r.apply(o,n)):r&&r.apply(h,n)}}},e.Group.prototype.preUpdate=function(){if(this.pendingDestroy)return this.destroy(),!1;if(!this.exists||!this.parent.exists)return this.renderOrderID=-1,!1;for(var t=0;t<this.children.length;){var e=this.children[t];e.preUpdate(),this===e.parent&&t++}return!0},e.Group.prototype.update=function(){for(var t=this.children.length;t--;){var e=this.children.length;t>=e&&(t=e-1);var i=this.children[t];this.updateOnlyExistingChildren&&!i.exists||i.update()}},e.Group.prototype.postUpdate=function(){this.fixedToCamera&&(this.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y);for(var t=0;t<this.children.length;t++)this.children[t].postUpdate()},e.Group.prototype.filter=function(t,i){for(var s=-1,n=this.children.length,r=[];++s<n;){var o=this.children[s];(!i||i&&o.exists)&&t(o,s,this.children)&&r.push(o)}return new e.ArraySet(r)},e.Group.prototype.forEach=function(t,e,i){if(void 0===i&&(i=!1),arguments.length<=3)for(n=0;n<this.children.length;n++){r=this.children[n];i&&!r.exists||t.call(e,r)}else{for(var s=[null],n=3;n<arguments.length;n++)s.push(arguments[n]);for(n=0;n<this.children.length;n++){var r=this.children[n];i&&!r.exists||(s[0]=r,t.apply(e,s))}}},e.Group.prototype.forEachExists=function(t,i){var s;if(arguments.length>2){s=[null];for(var n=2;n<arguments.length;n++)s.push(arguments[n])}this.iterate("exists",!0,e.Group.RETURN_TOTAL,t,i,s)},e.Group.prototype.forEachAlive=function(t,i){var s;if(arguments.length>2){s=[null];for(var n=2;n<arguments.length;n++)s.push(arguments[n])}this.iterate("alive",!0,e.Group.RETURN_TOTAL,t,i,s)},e.Group.prototype.forEachDead=function(t,i){var s;if(arguments.length>2){s=[null];for(var n=2;n<arguments.length;n++)s.push(arguments[n])}this.iterate("alive",!1,e.Group.RETURN_TOTAL,t,i,s)},e.Group.prototype.sort=function(t,i){this.children.length<2||(void 0===t&&(t="z"),void 0===i&&(i=e.Group.SORT_ASCENDING),this._sortProperty=t,i===e.Group.SORT_ASCENDING?this.children.sort(this.ascendingSortHandler.bind(this)):this.children.sort(this.descendingSortHandler.bind(this)),this.updateZ())},e.Group.prototype.customSort=function(t,e){this.children.length<2||(this.children.sort(t.bind(e)),this.updateZ())},e.Group.prototype.ascendingSortHandler=function(t,e){return t[this._sortProperty]<e[this._sortProperty]?-1:t[this._sortProperty]>e[this._sortProperty]?1:t.z<e.z?-1:1},e.Group.prototype.descendingSortHandler=function(t,e){return t[this._sortProperty]<e[this._sortProperty]?1:t[this._sortProperty]>e[this._sortProperty]?-1:0},e.Group.prototype.iterate=function(t,i,s,n,r,o){if(0===this.children.length){if(s===e.Group.RETURN_TOTAL)return 0;if(s===e.Group.RETURN_ALL)return[]}var a=0;if(s===e.Group.RETURN_ALL)var h=[];for(var l=0;l<this.children.length;l++)if(this.children[l][t]===i){if(a++,n&&(o?(o[0]=this.children[l],n.apply(r,o)):n.call(r,this.children[l])),s===e.Group.RETURN_CHILD)return this.children[l];s===e.Group.RETURN_ALL&&h.push(this.children[l])}return s===e.Group.RETURN_TOTAL?a:s===e.Group.RETURN_ALL?h:null},e.Group.prototype.getFirst=function(t,i){return this.iterate(t,i,e.Group.RETURN_CHILD)},e.Group.prototype.getFirstExists=function(t,e,i,s,n,r){void 0===e&&(e=!1),"boolean"!=typeof t&&(t=!0);var o=this.getFirst("exists",t);return null===o&&e?this.create(i,s,n,r):this.resetChild(o,i,s,n,r)},e.Group.prototype.getFirstAlive=function(t,e,i,s,n){void 0===t&&(t=!1);var r=this.getFirst("alive",!0);return null===r&&t?this.create(e,i,s,n):this.resetChild(r,e,i,s,n)},e.Group.prototype.getFirstDead=function(t,e,i,s,n){void 0===t&&(t=!1);var r=this.getFirst("alive",!1);return null===r&&t?this.create(e,i,s,n):this.resetChild(r,e,i,s,n)},e.Group.prototype.resetChild=function(t,e,i,s,n){return null===t?null:(void 0===e&&(e=null),void 0===i&&(i=null),null!==e&&null!==i&&t.reset(e,i),void 0!==s&&t.loadTexture(s,n),t)},e.Group.prototype.getTop=function(){if(this.children.length>0)return this.children[this.children.length-1]},e.Group.prototype.getBottom=function(){if(this.children.length>0)return this.children[0]},e.Group.prototype.getClosestTo=function(t,i,s){for(var n=Number.MAX_VALUE,r=0,o=null,a=0;a<this.children.length;a++){var h=this.children[a];h.exists&&(r=Math.abs(e.Point.distance(t,h)))<n&&(!i||i.call(s,h,r))&&(n=r,o=h)}return o},e.Group.prototype.getFurthestFrom=function(t,i,s){for(var n=0,r=0,o=null,a=0;a<this.children.length;a++){var h=this.children[a];h.exists&&(r=Math.abs(e.Point.distance(t,h)))>n&&(!i||i.call(s,h,r))&&(n=r,o=h)}return o},e.Group.prototype.count=function(t,i){return this.iterate(t,i,e.Group.RETURN_TOTAL)},e.Group.prototype.countLiving=function(){return this.count("alive",!0)},e.Group.prototype.countDead=function(){return this.count("alive",!1)},e.Group.prototype.getRandom=function(t,i){return void 0===t&&(t=0),void 0===i&&(i=this.children.length),0===i?null:e.ArrayUtils.getRandomItem(this.children,t,i)},e.Group.prototype.getRandomExists=function(t,e){var i=this.getAll("exists",!0,t,e);return this.game.rnd.pick(i)},e.Group.prototype.getAll=function(t,e,i,s){void 0===i&&(i=0),void 0===s&&(s=this.children.length);for(var n=[],r=i;r<s;r++){var o=this.children[r];t?o[t]===e&&n.push(o):n.push(o)}return n},e.Group.prototype.remove=function(t,e,i){if(void 0===e&&(e=!1),void 0===i&&(i=!1),0===this.children.length||-1===this.children.indexOf(t))return!1;i||!t.events||t.destroyPhase||t.events.onRemovedFromGroup$dispatch(t,this);var s=this.removeChild(t);return this.removeFromHash(t),this.updateZ(),this.cursor===t&&this.next(),e&&s&&s.destroy(!0),!0},e.Group.prototype.moveAll=function(t,i){if(void 0===i&&(i=!1),this.children.length>0&&t instanceof e.Group){do{t.add(this.children[0],i)}while(this.children.length>0);this.hash=[],this.cursor=null}return t},e.Group.prototype.removeAll=function(t,e,i){if(void 0===t&&(t=!1),void 0===e&&(e=!1),void 0===i&&(i=!1),0!==this.children.length){do{!e&&this.children[0].events&&this.children[0].events.onRemovedFromGroup$dispatch(this.children[0],this);var s=this.removeChild(this.children[0]);this.removeFromHash(s),t&&s&&s.destroy(!0,i)}while(this.children.length>0);this.hash=[],this.cursor=null}},e.Group.prototype.removeBetween=function(t,e,i,s){if(void 0===e&&(e=this.children.length-1),void 0===i&&(i=!1),void 0===s&&(s=!1),0!==this.children.length){if(t>e||t<0||e>this.children.length)return!1;for(var n=e;n>=t;){!s&&this.children[n].events&&this.children[n].events.onRemovedFromGroup$dispatch(this.children[n],this);var r=this.removeChild(this.children[n]);this.removeFromHash(r),i&&r&&r.destroy(!0),this.cursor===this.children[n]&&(this.cursor=null),n--}this.updateZ()}},e.Group.prototype.scatter=function(t,e){null==t&&(t=this.game.world.bounds),this.forEach(function(e){e.position.set(t.randomX,t.randomY)},null,e)},e.Group.prototype.shuffle=function(){e.ArrayUtils.shuffle(this.children),this.updateZ()},e.Group.prototype.destroy=function(t,e){null===this.game||this.ignoreDestroy||(void 0===t&&(t=!0),void 0===e&&(e=!1),this.onDestroy.dispatch(this,t,e),this.removeAll(t),this.cursor=null,this.filters=null,this.pendingDestroy=!1,e||(this.parent&&this.parent.removeChild(this),this.game=null,this.exists=!1))},Object.defineProperty(e.Group.prototype,"total",{get:function(){return this.iterate("exists",!0,e.Group.RETURN_TOTAL)}}),Object.defineProperty(e.Group.prototype,"length",{get:function(){return this.children.length}}),Object.defineProperty(e.Group.prototype,"angle",{get:function(){return e.Math.radToDeg(this.rotation)},set:function(t){this.rotation=e.Math.degToRad(t)}}),Object.defineProperty(e.Group.prototype,"centerX",{get:function(){return this.getBounds(this.parent).centerX},set:function(t){var e=this.getBounds(this.parent),i=this.x-e.x;this.x=t+i-e.halfWidth}}),Object.defineProperty(e.Group.prototype,"centerY",{get:function(){return this.getBounds(this.parent).centerY},set:function(t){var e=this.getBounds(this.parent),i=this.y-e.y;this.y=t+i-e.halfHeight}}),Object.defineProperty(e.Group.prototype,"left",{get:function(){return this.getBounds(this.parent).left},set:function(t){var e=this.getBounds(this.parent),i=this.x-e.x;this.x=t+i}}),Object.defineProperty(e.Group.prototype,"right",{get:function(){return this.getBounds(this.parent).right},set:function(t){var e=this.getBounds(this.parent),i=this.x-e.x;this.x=t+i-e.width}}),Object.defineProperty(e.Group.prototype,"top",{get:function(){return this.getBounds(this.parent).top},set:function(t){var e=this.getBounds(this.parent),i=this.y-e.y;this.y=t+i}}),Object.defineProperty(e.Group.prototype,"bottom",{get:function(){return this.getBounds(this.parent).bottom},set:function(t){var e=this.getBounds(this.parent),i=this.y-e.y;this.y=t+i-e.height}}),e.World=function(t){e.Group.call(this,t,null,"__world",!1),this.bounds=new e.Rectangle(0,0,t.width,t.height),this.camera=null,this._definedSize=!1,this._width=t.width,this._height=t.height,this.game.state.onStateChange.add(this.stateChange,this)},e.World.prototype=Object.create(e.Group.prototype),e.World.prototype.constructor=e.World,e.World.prototype.boot=function(){this.camera=new e.Camera(this.game,0,0,0,this.game.width,this.game.height),this.game.stage.addChild(this),this.camera.boot()},e.World.prototype.stateChange=function(){this.x=0,this.y=0,this.camera.reset()},e.World.prototype.setBounds=function(t,e,i,s){this._definedSize=!0,this._width=i,this._height=s,this.bounds.setTo(t,e,i,s),this.x=t,this.y=e,this.camera.bounds&&this.camera.bounds.setTo(t,e,Math.max(i,this.game.width),Math.max(s,this.game.height)),this.game.physics.setBoundsToWorld()},e.World.prototype.resize=function(t,e){this._definedSize&&(t<this._width&&(t=this._width),e<this._height&&(e=this._height)),this.bounds.width=t,this.bounds.height=e,this.game.camera.setBoundsToWorld(),this.game.physics.setBoundsToWorld()},e.World.prototype.shutdown=function(){this.destroy(!0,!0)},e.World.prototype.wrap=function(t,e,i,s,n){void 0===e&&(e=0),void 0===i&&(i=!1),void 0===s&&(s=!0),void 0===n&&(n=!0),i?(t.getBounds(),s&&(t.x+t._currentBounds.width<this.bounds.x?t.x=this.bounds.right:t.x>this.bounds.right&&(t.x=this.bounds.left)),n&&(t.y+t._currentBounds.height<this.bounds.top?t.y=this.bounds.bottom:t.y>this.bounds.bottom&&(t.y=this.bounds.top))):(s&&t.x+e<this.bounds.x?t.x=this.bounds.right+e:s&&t.x-e>this.bounds.right&&(t.x=this.bounds.left-e),n&&t.y+e<this.bounds.top?t.y=this.bounds.bottom+e:n&&t.y-e>this.bounds.bottom&&(t.y=this.bounds.top-e))},e.World.prototype.wrapAll=function(t,e,i,s,n,r){t.forEach(this.wrap,this,e,i,s,n,r)},Object.defineProperty(e.World.prototype,"width",{get:function(){return this.bounds.width},set:function(t){t<this.game.width&&(t=this.game.width),this.bounds.width=t,this._width=t,this._definedSize=!0}}),Object.defineProperty(e.World.prototype,"height",{get:function(){return this.bounds.height},set:function(t){t<this.game.height&&(t=this.game.height),this.bounds.height=t,this._height=t,this._definedSize=!0}}),Object.defineProperty(e.World.prototype,"centerX",{get:function(){return this.bounds.halfWidth+this.bounds.x}}),Object.defineProperty(e.World.prototype,"centerY",{get:function(){return this.bounds.halfHeight+this.bounds.y}}),Object.defineProperty(e.World.prototype,"randomX",{get:function(){return this.bounds.x<0?this.game.rnd.between(this.bounds.x,this.bounds.width-Math.abs(this.bounds.x)):this.game.rnd.between(this.bounds.x,this.bounds.width)}}),Object.defineProperty(e.World.prototype,"randomY",{get:function(){return this.bounds.y<0?this.game.rnd.between(this.bounds.y,this.bounds.height-Math.abs(this.bounds.y)):this.game.rnd.between(this.bounds.y,this.bounds.height)}}),e.Game=function(t,i,s,n,r,o,a,h){return this.id=e.GAMES.push(this)-1,this.config=null,this.physicsConfig=h,this.parent="",this.width=800,this.height=600,this.resolution=1,this._width=800,this._height=600,this.transparent=!1,this.antialias=!0,this.multiTexture=!1,this.preserveDrawingBuffer=!1,this.clearBeforeRender=!0,this.renderer=null,this.renderType=e.AUTO,this.state=null,this.isBooted=!1,this.isRunning=!1,this.raf=null,this.add=null,this.make=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.net=null,this.scale=null,this.sound=null,this.stage=null,this.time=null,this.tweens=null,this.world=null,this.physics=null,this.plugins=null,this.rnd=null,this.device=e.Device,this.camera=null,this.canvas=null,this.context=null,this.debug=null,this.particles=null,this.create=null,this.lockRender=!1,this.pendingDestroy=!1,this.stepping=!1,this.pendingStep=!1,this.stepCount=0,this.onPause=null,this.onResume=null,this.onBlur=null,this.onFocus=null,this._paused=!1,this._codePaused=!1,this.currentUpdateID=0,this.updatesThisFrame=1,this.rendersThisFrame=1,this._deltaTime=0,this._lastCount=0,this._spiraling=0,this._kickstart=!0,this.fpsProblemNotifier=new e.Signal,this.forceSingleUpdate=!0,this.forceSingleRender=!0,this.dropFrames=!1,this.powerPreference="default",this._nextFpsNotification=0,1===arguments.length&&"object"==typeof arguments[0]?this.parseConfig(arguments[0]):(this.config={enableDebug:!0},void 0!==t&&(this._width=t),void 0!==i&&(this._height=i),void 0!==s&&(this.renderType=s),void 0!==n&&(this.parent=n),void 0!==o&&(this.transparent=o),void 0!==a&&(this.antialias=a),this.rnd=new e.RandomDataGenerator([(Date.now()*Math.random()).toString()]),this.state=new e.StateManager(this,r)),this.device.whenReady(this.boot,this),this},e.Game.prototype={parseConfig:function(t){this.config=t,void 0===t.enableDebug&&(this.config.enableDebug=!0),t.width&&(this._width=t.width),t.height&&(this._height=t.height),t.renderer&&(this.renderType=t.renderer),t.parent&&(this.parent=t.parent),void 0!==t.transparent&&(this.transparent=t.transparent),void 0!==t.antialias&&(this.antialias=t.antialias),void 0!==t.clearBeforeRender&&(this.clearBeforeRender=t.clearBeforeRender),void 0!==t.multiTexture&&(this.multiTexture=t.multiTexture),t.resolution&&(this.resolution=t.resolution),void 0!==t.preserveDrawingBuffer&&(this.preserveDrawingBuffer=t.preserveDrawingBuffer),void 0!==t.powerPreference&&(this.powerPreference=t.powerPreference),t.physicsConfig&&(this.physicsConfig=t.physicsConfig);var i=[(Date.now()*Math.random()).toString()];t.seed&&(i=t.seed),this.rnd=new e.RandomDataGenerator(i);var s=null;t.state&&(s=t.state),this.state=new e.StateManager(this,s)},boot:function(){if(!this.isBooted){if(this.onPause=new e.Signal,this.onResume=new e.Signal,this.onBlur=new e.Signal,this.onFocus=new e.Signal,this.isBooted=!0,PIXI.game=this,this.math=e.Math,this.scale=new e.ScaleManager(this,this._width,this._height),this.stage=new e.Stage(this),this.setUpRenderer(),this.world=new e.World(this),this.add=new e.GameObjectFactory(this),this.make=new e.GameObjectCreator(this),this.cache=new e.Cache(this),this.load=new e.Loader(this),this.time=new e.Time(this),this.tweens=new e.TweenManager(this),this.input=new e.Input(this),this.sound=new e.SoundManager(this),this.physics=new e.Physics(this,this.physicsConfig),this.particles=new e.Particles(this),this.create=new e.Create(this),this.plugins=new e.PluginManager(this),this.net=new e.Net(this),this.time.boot(),this.stage.boot(),this.world.boot(),this.scale.boot(),this.input.boot(this.config),this.sound.boot(),this.state.boot(),this.config.enableDebug)this.debug=new e.Utils.Debug(this),this.debug.boot();else{var t=function(){};this.debug={preUpdate:t,update:t,reset:t,destroy:t,isDisabled:!0}}this.showDebugHeader(),this.isRunning=!0,this.config&&this.config.forceSetTimeOut?this.raf=new e.RequestAnimationFrame(this,this.config.forceSetTimeOut):this.raf=new e.RequestAnimationFrame(this,!1),this._kickstart=!0,this.focusWindow(),this.config.disableStart||(this.cache.isReady?this.raf.start():this.cache.onReady.addOnce(function(){this.raf.start()},this))}},showDebugHeader:function(){if(!window.PhaserGlobal||!window.PhaserGlobal.hideBanner){var t=e.VERSION,i="Canvas",s="HTML Audio",n=1;if(this.renderType===e.WEBGL?(i="WebGL",n++):this.renderType===e.HEADLESS&&(i="Headless"),this.device.webAudio&&(s="WebAudio",n++),this.device.ie)window.console&&console.log("Phaser v"+t+" | Pixi.js | "+i+" | "+s+" | http://phaser.io");else{for(var r=["%c %c %c Phaser CE v"+t+" | Pixi.js | "+i+" | "+s+" %c %c %c http://phaser.io %c♥%c♥%c♥","background: #fb8cb3","background: #d44a52","color: #ffffff; background: #871905;","background: #d44a52","background: #fb8cb3","background: #ffffff"],o=0;o<3;o++)o<n?r.push("color: #ff2424; background: #fff"):r.push("color: #959595; background: #fff");console.log.apply(console,r)}}},setUpRenderer:function(){if(!this.device.canvas)throw new Error("Phaser.Game - Cannot create Canvas 2d context, aborting.");if(this.config.canvas?this.canvas=this.config.canvas:this.canvas=e.Canvas.create(this,this.width,this.height,this.config.canvasID,!0),this.config.canvasStyle?this.canvas.style=this.config.canvasStyle:this.canvas.style["-webkit-full-screen"]="width: 100%; height: 100%",this.config.crisp&&e.Canvas.setImageRenderingCrisp(this.canvas),this.renderType===e.WEBGL||this.renderType===e.WEBGL_MULTI||this.renderType===e.AUTO&&this.device.webGL){(this.multiTexture||this.renderType===e.WEBGL_MULTI)&&(PIXI.enableMultiTexture(),this.multiTexture=!0);try{this.renderer=new PIXI.WebGLRenderer(this,this.config),this.renderType=e.WEBGL,this.context=null,this.canvas.addEventListener("webglcontextlost",this.contextLost.bind(this),!1),this.canvas.addEventListener("webglcontextrestored",this.contextRestored.bind(this),!1)}catch(t){if(PIXI.defaultRenderer=null,this.renderer=null,this.multiTexture=!1,PIXI._enableMultiTextureToggle=!1,this.renderType===e.WEBGL)throw t}}this.renderer||(this.renderer=new PIXI.CanvasRenderer(this,this.config),this.context=this.renderer.context,this.renderType===e.AUTO&&(this.renderType=e.CANVAS)),this.device.cocoonJS&&(this.canvas.screencanvas=this.renderType===e.CANVAS),this.renderType!==e.HEADLESS&&(this.stage.smoothed=this.antialias,e.Canvas.addToDOM(this.canvas,this.parent,!1),e.Canvas.setTouchAction(this.canvas))},contextLost:function(t){t.preventDefault(),this.renderer.contextLost=!0},contextRestored:function(){this.renderer.initContext(),this.cache.clearGLTextures(),this.renderer.contextLost=!1},update:function(t){if(this.pendingDestroy)this.destroy();else{if(this.time.update(t),this._kickstart)return this.updateLogic(this.time.desiredFpsMult),this.updateRender(this.time.slowMotion*this.time.desiredFps),void(this._kickstart=!1);if(this._spiraling>1&&!this.forceSingleUpdate)this.time.time>this._nextFpsNotification&&(this._nextFpsNotification=this.time.time+1e4,this.fpsProblemNotifier.dispatch()),this._deltaTime=0,this._spiraling=0,this.dropFrames?this.rendersThisFrame=0:(this.updateRender(this.time.slowMotion*this.time.desiredFps),this.rendersThisFrame=1);else{var i=1e3*this.time.slowMotion/this.time.desiredFps;this._deltaTime+=Math.max(Math.min(3*i,this.time.elapsed),0);var s=0;for(this.updatesThisFrame=Math.floor(this._deltaTime/i),this.forceSingleUpdate&&(this.updatesThisFrame=Math.min(1,this.updatesThisFrame)),this.forceSingleRender?this.rendersThisFrame=1:this.rendersThisFrame=Math.min(1,this.updatesThisFrame);this._deltaTime>=i&&(this._deltaTime-=i,this.currentUpdateID=s,this.updateLogic(this.time.desiredFpsMult),s++,!this.forceSingleUpdate||1!==s);)this.time.refresh();s>this._lastCount?this._spiraling++:s<this._lastCount&&(this._spiraling=0),this._lastCount=s,this.rendersThisFrame>0&&this.updateRender(this._deltaTime/i)}this.renderer.type===e.WEBGL&&this.renderer.gl.flush()}},updateLogic:function(t){this._paused||this.pendingStep?(this.scale.pauseUpdate(),this.state.pauseUpdate(t),this.debug.preUpdate(),this.input.pauseUpdate()):(this.stepping&&(this.pendingStep=!0),this.time.countUpdate(),this.scale.preUpdate(),this.debug.preUpdate(),this.camera.preUpdate(),this.physics.preUpdate(),this.state.preUpdate(t),this.plugins.preUpdate(t),this.stage.preUpdate(),this.state.update(),this.stage.update(),this.tweens.update(),this.sound.update(),this.input.update(),this.physics.update(),this.plugins.update(),this.stage.postUpdate(),this.state.postUpdate(),this.plugins.postUpdate()),this.stage.updateTransform()},updateRender:function(t){this.lockRender||this.renderType===e.HEADLESS||(this.time.countRender(),this.state.preRender(t),this.renderer.render(this.stage),this.plugins.render(t),this.state.render(t),this.plugins.postRender(t))},enableStep:function(){this.stepping=!0,this.pendingStep=!1,this.stepCount=0},disableStep:function(){this.stepping=!1,this.pendingStep=!1},step:function(){this.pendingStep=!1,this.stepCount++},destroy:function(){this.raf.stop(),this.debug.destroy(),this.state.destroy(),this.sound.destroy(),this.scale.destroy(),this.stage.destroy(),this.input.destroy(),this.physics.destroy(),this.plugins.destroy(),this.tweens.destroy(),this.debug=null,this.state=null,this.sound=null,this.scale=null,this.stage=null,this.input=null,this.physics=null,this.plugins=null,this.tweens=null,this.cache=null,this.load=null,this.time=null,this.world=null,this.isBooted=!1,this.renderer.destroy(!1),e.Canvas.removeFromDOM(this.canvas),PIXI.game===this&&(PIXI.game=null),PIXI.defaultRenderer=null,e.GAMES[this.id]=null},gamePaused:function(t){this._paused||(this._paused=!0,this.time.gamePaused(),this.sound.muteOnPause&&this.sound.setMute(),this.onPause.dispatch(t),this.device.cordova&&this.device.iOS&&(this.lockRender=!0))},gameResumed:function(t){this._paused&&!this._codePaused&&(this._paused=!1,this.time.gameResumed(),this.input.reset(),this.sound.muteOnPause&&this.sound.unsetMute(),this.onResume.dispatch(t),this.device.cordova&&this.device.iOS&&(this.lockRender=!1))},focusLoss:function(t){this.onBlur.dispatch(t),this.stage.disableVisibilityChange||this.gamePaused(t)},focusGain:function(t){this.focusWindow(),this.onFocus.dispatch(t),this.stage.disableVisibilityChange||this.gameResumed(t)},focusWindow:function(){window.focus&&(!window.PhaserGlobal||window.PhaserGlobal&&!window.PhaserGlobal.stopFocus)&&window.focus()}},e.Game.prototype.constructor=e.Game,Object.defineProperty(e.Game.prototype,"paused",{get:function(){return this._paused},set:function(t){!0===t?(!1===this._paused&&(this._paused=!0,this.sound.muteOnPause&&this.sound.setMute(),this.time.gamePaused(),this.onPause.dispatch(this)),this._codePaused=!0):(this._paused&&(this._paused=!1,this.input.reset(),this.sound.unsetMute(),this.time.gameResumed(),this.onResume.dispatch(this)),this._codePaused=!1)}}),e.Input=function(t){this.game=t,this.hitCanvas=null,this.hitContext=null,this.moveCallbacks=[],this.customCandidateHandler=null,this.customCandidateHandlerContext=null,this.pollRate=0,this.enabled=!0,this.multiInputOverride=e.Input.MOUSE_TOUCH_COMBINE,this.position=null,this.speed=null,this.circle=null,this.scale=null,this.maxPointers=-1,this.tapRate=200,this.doubleTapRate=300,this.holdRate=2e3,this.justPressedRate=200,this.justReleasedRate=200,this.recordPointerHistory=!1,this.recordRate=100,this.recordLimit=100,this.touchLockCallbacks=[],this.pointer1=null,this.pointer2=null,this.pointer3=null,this.pointer4=null,this.pointer5=null,this.pointer6=null,this.pointer7=null,this.pointer8=null,this.pointer9=null,this.pointer10=null,this.pointers=[],this.activePointer=null,this.mousePointer=null,this.mouse=null,this.keyboard=null,this.touch=null,this.mspointer=null,this.gamepad=null,this.resetLocked=!1,this.onDown=null,this.onUp=null,this.onTap=null,this.onHold=null,this.minPriorityID=0,this.interactiveItems=new e.ArraySet,this._localPoint=new e.Point,this._pollCounter=0,this._oldPosition=null,this._x=0,this._y=0},e.Input.MOUSE_OVERRIDES_TOUCH=0,e.Input.TOUCH_OVERRIDES_MOUSE=1,e.Input.MOUSE_TOUCH_COMBINE=2,e.Input.MAX_POINTERS=10,e.Input.prototype={boot:function(t){"maxPointers"in t&&(this.maxPointers=t.maxPointers),this.mousePointer=new e.Pointer(this.game,0,e.PointerMode.CURSOR),this.addPointer(),this.addPointer(),this.mouse=new e.Mouse(this.game),this.touch=new e.Touch(this.game),this.mspointer=new e.MSPointer(this.game),this.mouseWheel=new e.MouseWheel(this.game),this.pointerLock=new e.PointerLock(this.game),e.Keyboard&&(this.keyboard=new e.Keyboard(this.game)),e.Gamepad&&(this.gamepad=new e.Gamepad(this.game)),this.onDown=new e.Signal,this.onUp=new e.Signal,this.onTap=new e.Signal,this.onHold=new e.Signal,this.scale=new e.Point(1,1),this.speed=new e.Point,this.position=new e.Point,this._oldPosition=new e.Point,this.circle=new e.Circle(0,0,45),this.activePointer=this.mousePointer,this.hitCanvas=e.CanvasPool.create(this,1,1),this.hitContext=this.hitCanvas.getContext("2d"),this.game.device.mspointer&&!1!==t.mspointer?this.mspointer.start():this.game.device.touch&&!1!==t.touch&&this.touch.start(),this.mspointer.active||!1===t.mouse||this.mouse.start(),this.mousePointer.active=!0,!1!==t.mouseWheel&&this.mouseWheel.start(),!1!==t.pointerLock&&this.pointerLock.start(),this.keyboard&&!1!==t.keyboard&&this.keyboard.start();var i=this;this._onClickTrampoline=function(t){i.onClickTrampoline(t)},this.game.canvas.addEventListener("click",this._onClickTrampoline,!1)},destroy:function(){this.mouse.stop(),this.mouseWheel.stop(),this.touch.stop(),this.mspointer.stop(),this.pointerLock.stop(),this.keyboard&&this.keyboard.stop(),this.gamepad&&this.gamepad.stop(),this.moveCallbacks=[],e.CanvasPool.remove(this),this.game.canvas.removeEventListener("click",this._onClickTrampoline)},setInteractiveCandidateHandler:function(t,e){this.customCandidateHandler=t,this.customCandidateHandlerContext=e},addMoveCallback:function(t,e){this.moveCallbacks.push({callback:t,context:e})},addTouchLockCallback:function(t,e,i){void 0===i&&(i=!1),this.touchLockCallbacks.push({callback:t,context:e,onEnd:i})},removeTouchLockCallback:function(t,e){for(var i=this.touchLockCallbacks.length;i--;)if(this.touchLockCallbacks[i].callback===t&&this.touchLockCallbacks[i].context===e)return this.touchLockCallbacks.splice(i,1),!0;return!1},executeTouchLockCallbacks:function(t,e){for(var i=this.touchLockCallbacks.length;i--;){var s=this.touchLockCallbacks[i];s.onEnd===t&&s.callback.call(s.context,this,e)&&this.touchLockCallbacks.splice(i,1)}},deleteMoveCallback:function(t,e){for(var i=this.moveCallbacks.length;i--;)if(this.moveCallbacks[i].callback===t&&this.moveCallbacks[i].context===e)return void this.moveCallbacks.splice(i,1)},addPointer:function(){if(this.pointers.length>=e.Input.MAX_POINTERS)return console.warn("Phaser.Input.addPointer: Maximum limit of "+e.Input.MAX_POINTERS+" pointers reached."),null;var t=this.pointers.length+1,i=new e.Pointer(this.game,t,e.PointerMode.CONTACT);return this.pointers.push(i),this["pointer"+t]=i,i},update:function(){if(this.keyboard&&this.keyboard.update(),this.pollRate>0&&this._pollCounter<this.pollRate)this._pollCounter++;else{this.speed.x=this.position.x-this._oldPosition.x,this.speed.y=this.position.y-this._oldPosition.y,this._oldPosition.copyFrom(this.position),this.mousePointer.update(),this.gamepad&&this.gamepad.active&&this.gamepad.update();for(var t=0;t<this.pointers.length;t++)this.pointers[t].update();this._pollCounter=0}},pauseUpdate:function(){this.gamepad&&this.gamepad.active&&this.gamepad.update()},reset:function(t){if(this.game.isBooted&&!this.resetLocked){void 0===t&&(t=!1),this.mousePointer.reset(),this.keyboard&&this.keyboard.reset(t);for(var i=0;i<this.pointers.length;i++)this.pointers[i].reset();"none"!==this.game.canvas.style.cursor&&(this.game.canvas.style.cursor=""),t&&(this.onDown.dispose(),this.onUp.dispose(),this.onTap.dispose(),this.onHold.dispose(),this.onDown=new e.Signal,this.onUp=new e.Signal,this.onTap=new e.Signal,this.onHold=new e.Signal,this.moveCallbacks=[]),this._pollCounter=0}},resetSpeed:function(t,e){this._oldPosition.setTo(t,e),this.speed.setTo(0,0)},startPointer:function(t){if(this.maxPointers>=0&&this.countActivePointers(this.maxPointers)>=this.maxPointers)return null;if(!this.pointer1.active)return this.pointer1.start(t);if(!this.pointer2.active)return this.pointer2.start(t);for(var e=2;e<this.pointers.length;e++){var i=this.pointers[e];if(!i.active)return i.start(t)}return null},updatePointer:function(t){if(this.pointer1.active&&this.pointer1.identifier===t.identifier)return this.pointer1.move(t);if(this.pointer2.active&&this.pointer2.identifier===t.identifier)return this.pointer2.move(t);for(var e=2;e<this.pointers.length;e++){var i=this.pointers[e];if(i.active&&i.identifier===t.identifier)return i.move(t)}return null},stopPointer:function(t){if(this.pointer1.active&&this.pointer1.identifier===t.identifier)return this.pointer1.stop(t);if(this.pointer2.active&&this.pointer2.identifier===t.identifier)return this.pointer2.stop(t);for(var e=2;e<this.pointers.length;e++){var i=this.pointers[e];if(i.active&&i.identifier===t.identifier)return i.stop(t)}return null},countActivePointers:function(t){void 0===t&&(t=this.pointers.length);for(var e=t,i=0;i<this.pointers.length&&e>0;i++)this.pointers[i].active&&e--;return t-e},getPointer:function(t){void 0===t&&(t=!1);for(var e=0;e<this.pointers.length;e++){var i=this.pointers[e];if(i.active===t)return i}return null},getPointerFromIdentifier:function(t){for(var e=0;e<this.pointers.length;e++){var i=this.pointers[e];if(i.identifier===t)return i}return null},getPointerFromId:function(t){for(var e=0;e<this.pointers.length;e++){var i=this.pointers[e];if(i.pointerId===t)return i}return null},getLocalPosition:function(t,i,s){void 0===s&&(s=new e.Point);var n=t.worldTransform,r=1/(n.a*n.d+n.c*-n.b);return s.setTo(n.d*r*i.x+-n.c*r*i.y+(n.ty*n.c-n.tx*n.d)*r,n.a*r*i.y+-n.b*r*i.x+(-n.ty*n.a+n.tx*n.b)*r)},hitTest:function(t,i,s){if(!t.worldVisible)return!1;if(this.getLocalPosition(t,i,this._localPoint),s.copyFrom(this._localPoint),t.hitArea&&t.hitArea.contains)return t.hitArea.contains(this._localPoint.x,this._localPoint.y);if(e.Creature&&t instanceof e.Creature){var n=Math.abs(t.width),r=Math.abs(t.height),o=t.x-n*t.anchorX;if(this.game.camera.x+i.x>=o&&this.game.camera.x+i.x<o+n){a=t.y-r*t.anchorY;if(this.game.camera.y+i.y>=a&&this.game.camera.y+i.y<a+r)return!0}}else if(t instanceof e.TileSprite){var n=t.width,r=t.height,o=-n*t.anchor.x;if(this._localPoint.x>=o&&this._localPoint.x<o+n){a=-r*t.anchor.y;if(this._localPoint.y>=a&&this._localPoint.y<a+r)return!0}}else if(t instanceof PIXI.Sprite){var n=t.texture.frame.width/t.texture.baseTexture.resolution,r=t.texture.frame.height/t.texture.baseTexture.resolution,o=-n*t.anchor.x;if(this._localPoint.x>=o&&this._localPoint.x<o+n){var a=-r*t.anchor.y;if(this._localPoint.y>=a&&this._localPoint.y<a+r)return!0}}else if(t instanceof e.Graphics)for(l=0;l<t.graphicsData.length;l++){var h=t.graphicsData[l];if(h.fill&&(h.shape&&h.shape.contains(this._localPoint.x,this._localPoint.y)))return!0}for(var l=0;l<t.children.length;l++)if(this.hitTest(t.children[l],i,s))return!0;return!1},onClickTrampoline:function(){this.activePointer.processClickTrampolines()},callAll:function(t,e){for(var i=this.interactiveItems.list,s=i.length;s--;){var n=i[s];n&&n.enabled&&n[t](e)}}},e.Input.prototype.constructor=e.Input,Object.defineProperty(e.Input.prototype,"x",{get:function(){return this._x},set:function(t){this._x=Math.floor(t)}}),Object.defineProperty(e.Input.prototype,"y",{get:function(){return this._y},set:function(t){this._y=Math.floor(t)}}),Object.defineProperty(e.Input.prototype,"pollLocked",{get:function(){return this.pollRate>0&&this._pollCounter<this.pollRate}}),Object.defineProperty(e.Input.prototype,"totalInactivePointers",{get:function(){return this.pointers.length-this.countActivePointers()}}),Object.defineProperty(e.Input.prototype,"totalActivePointers",{get:function(){return this.countActivePointers()}}),Object.defineProperty(e.Input.prototype,"worldX",{get:function(){return this.game.camera.view.x+this.x}}),Object.defineProperty(e.Input.prototype,"worldY",{get:function(){return this.game.camera.view.y+this.y}}),e.Mouse=function(t){this.game=t,this.input=t.input,this.callbackContext=this.game,this.mouseDownCallback=null,this.mouseUpCallback=null,this.mouseOutCallback=null,this.mouseOverCallback=null,this.capture=!1,this.active=!1,this.enabled=!0,this.stopOnGameOut=!1,this.event=null,this._onMouseDown=null,this._onMouseMove=null,this._onMouseUp=null,this._onMouseOut=null,this._onMouseOver=null},e.Mouse.NO_BUTTON=-1,e.Mouse.LEFT_BUTTON=0,e.Mouse.MIDDLE_BUTTON=1,e.Mouse.RIGHT_BUTTON=2,e.Mouse.BACK_BUTTON=3,e.Mouse.FORWARD_BUTTON=4,e.Mouse.prototype={start:function(){var t=this.game.device;if(t.isAndroidStockBrowser()&&this.input.touch.active)return!1;if(null!==this._onMouseDown)return!1;var e=this;this._onMouseDown=function(t){return e.onMouseDown(t)},this._onMouseMove=function(t){return e.onMouseMove(t)},this._onMouseUp=function(t){return e.onMouseUp(t)},this._onMouseUpGlobal=function(t){return e.onMouseUpGlobal(t)},this._onMouseOutGlobal=function(t){return e.onMouseOutGlobal(t)},this._onMouseOut=function(t){return e.onMouseOut(t)},this._onMouseOver=function(t){return e.onMouseOver(t)};var i=this.game.canvas;return i.addEventListener("mousedown",this._onMouseDown,!0),i.addEventListener("mousemove",this._onMouseMove,!0),i.addEventListener("mouseup",this._onMouseUp,!0),t.cocoonJS||(window.addEventListener("mouseup",this._onMouseUpGlobal,!0),window.addEventListener("mouseout",this._onMouseOutGlobal,!0),i.addEventListener("mouseover",this._onMouseOver,!0),i.addEventListener("mouseout",this._onMouseOut,!0)),this.active=!0,!0},onMouseDown:function(t){this.event=t,this.capture&&t.preventDefault(),this.mouseDownCallback&&this.mouseDownCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=0,this.input.mousePointer.start(t))},onMouseMove:function(t){this.event=t,this.capture&&t.preventDefault(),this.mouseMoveCallback&&this.mouseMoveCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=0,this.input.mousePointer.move(t))},onMouseUp:function(t){this.event=t,this.capture&&t.preventDefault(),this.mouseUpCallback&&this.mouseUpCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=0,this.input.mousePointer.stop(t))},onMouseUpGlobal:function(t){this.input.mousePointer.withinGame||(this.mouseUpCallback&&this.mouseUpCallback.call(this.callbackContext,t),t.identifier=0,this.input.mousePointer.stop(t))},onMouseOutGlobal:function(t){this.event=t,this.capture&&t.preventDefault(),this.input.mousePointer.withinGame=!1,this.input.enabled&&this.enabled&&(this.input.mousePointer.stop(t),this.input.mousePointer.resetButtons())},onMouseOut:function(t){this.event=t,this.capture&&t.preventDefault(),this.input.mousePointer.withinGame=!1,this.mouseOutCallback&&this.mouseOutCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(this.input.mousePointer.updateButtons(t),this.stopOnGameOut&&(t.identifier=0,this.input.mousePointer.stop(t),this.input.callAll("_pointerOutHandler",this.input.mousePointer)))},onMouseOver:function(t){this.event=t,this.capture&&t.preventDefault(),this.input.mousePointer.withinGame=!0,this.mouseOverCallback&&this.mouseOverCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&this.input.mousePointer.updateButtons(t)},stop:function(){var t=this.game.canvas;t.removeEventListener("mousedown",this._onMouseDown,!0),t.removeEventListener("mousemove",this._onMouseMove,!0),t.removeEventListener("mouseup",this._onMouseUp,!0),t.removeEventListener("mouseover",this._onMouseOver,!0),t.removeEventListener("mouseout",this._onMouseOut,!0),window.removeEventListener("mouseup",this._onMouseUpGlobal,!0),window.removeEventListener("mouseout",this._onMouseOutGlobal,!0),this.active=!1}},e.Mouse.prototype.constructor=e.Mouse,e.MouseWheel=function(t){this.game=t,this.input=t.input,this.element=t.canvas,this.preventDefault=!0,this.active=!1,this.callback=null,this.callbackContext=t,this.delta=0,this.wheelEventName=t.device.wheelEvent,this.boundOnWheelHandler=this.onWheelHandler.bind(this),this.eventProxy=null},e.MouseWheel.UP=1,e.MouseWheel.DOWN=-1,e.MouseWheel.prototype.start=function(){return!(!this.wheelEventName||this.active)&&(this.element.addEventListener(this.wheelEventName,this.boundOnWheelHandler,!0),"mousewheel"===this.wheelEventName?this.eventProxy=new e.WheelEventProxy(-.025,1):"DOMMouseScroll"===this.wheelEventName&&(this.eventProxy=new e.WheelEventProxy(1,1)),this.active=!0,!0)},e.MouseWheel.prototype.stop=function(){this.active&&(this.element.removeEventListener(this.wheelEventName,this.boundOnWheelHandler,!0),this.active=!1)},e.MouseWheel.prototype.onWheelHandler=function(t){this.eventProxy&&(t=this.eventProxy.bindEvent(t)),this.preventDefault&&t.preventDefault(),this.delta=e.Math.clamp(-t.deltaY,-1,1),this.callback&&this.callback.call(this.callbackContext,t)},e.MSPointer=function(t){this.game=t,this.input=t.input,this.callbackContext=this.game,this.pointerDownCallback=null,this.pointerMoveCallback=null,this.pointerUpCallback=null,this.pointerOutCallback=null,this.pointerOverCallback=null,this.capture=!1,this.event=null,this.active=!1,this.enabled=!0,this.stopOnGameOut=!1,this._onMSPointerDown=null,this._onMSPointerMove=null,this._onMSPointerUp=null,this._onMSPointerUpGlobal=null,this._onMSPointerOut=null,this._onMSPointerOver=null},e.MSPointer.prototype={start:function(){if(!this.game.device.mspointer)return!1;if(null!==this._onMSPointerDown)return!1;var t=this;this._onMSPointerDown=function(e){return t.onPointerDown(e)},this._onMSPointerMove=function(e){return t.onPointerMove(e)},this._onMSPointerUp=function(e){return t.onPointerUp(e)},this._onMSPointerUpGlobal=function(e){return t.onPointerUpGlobal(e)},this._onMSPointerOut=function(e){return t.onPointerOut(e)},this._onMSPointerOver=function(e){return t.onPointerOver(e)};var e=this.game.canvas;return e.addEventListener("MSPointerDown",this._onMSPointerDown,!1),e.addEventListener("MSPointerMove",this._onMSPointerMove,!1),e.addEventListener("MSPointerUp",this._onMSPointerUp,!1),e.addEventListener("pointerdown",this._onMSPointerDown,!1),e.addEventListener("pointermove",this._onMSPointerMove,!1),e.addEventListener("pointerup",this._onMSPointerUp,!1),e.style["-ms-content-zooming"]="none",e.style["-ms-touch-action"]="none",this.game.device.cocoonJS||(window.addEventListener("MSPointerUp",this._onMSPointerUpGlobal,!0),e.addEventListener("MSPointerOver",this._onMSPointerOver,!0),e.addEventListener("MSPointerOut",this._onMSPointerOut,!0),window.addEventListener("pointerup",this._onMSPointerUpGlobal,!0),e.addEventListener("pointerover",this._onMSPointerOver,!0),e.addEventListener("pointerout",this._onMSPointerOut,!0)),this.active=!0,!0},onPointerDown:function(t){this.game.input.executeTouchLockCallbacks(!1,t),this.event=t,this.capture&&t.preventDefault(),this.pointerDownCallback&&this.pointerDownCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=t.pointerId,"mouse"===t.pointerType||4===t.pointerType?this.input.mousePointer.start(t):this.input.startPointer(t))},onPointerMove:function(t){this.event=t,this.capture&&t.preventDefault(),this.pointerMoveCallback&&this.pointerMoveCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=t.pointerId,"mouse"===t.pointerType||4===t.pointerType?this.input.mousePointer.move(t):this.input.updatePointer(t))},onPointerUp:function(t){this.game.input.executeTouchLockCallbacks(!0,t),this.event=t,this.capture&&t.preventDefault(),this.pointerUpCallback&&this.pointerUpCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=t.pointerId,"mouse"===t.pointerType||4===t.pointerType?this.input.mousePointer.stop(t):this.input.stopPointer(t))},onPointerUpGlobal:function(t){if(t.identifier=t.pointerId,"mouse"!==t.pointerType&&4!==t.pointerType||this.input.mousePointer.withinGame){var e=this.input.getPointerFromIdentifier(t.identifier);e&&e.withinGame&&this.onPointerUp(t)}else this.onPointerUp(t)},onPointerOut:function(t){if(this.event=t,this.capture&&t.preventDefault(),t.identifier=t.pointerId,"mouse"===t.pointerType||4===t.pointerType)this.input.mousePointer.withinGame=!1;else{var e=this.input.getPointerFromIdentifier(t.identifier);e&&(e.withinGame=!1)}this.pointerOutCallback&&this.pointerOutCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&this.stopOnGameOut&&(t.identifier=0,e||(e=this.input.mousePointer),e.stop(t),this.input.callAll("_pointerOutHandler",e))},onPointerOver:function(t){if(this.event=t,this.capture&&t.preventDefault(),t.identifier=t.pointerId,"mouse"===t.pointerType||4===t.pointerType)this.input.mousePointer.withinGame=!0;else{var e=this.input.getPointerFromIdentifier(t.identifier);e&&(e.withinGame=!0)}this.pointerOverCallback&&this.pointerOverCallback.call(this.callbackContext,t)},stop:function(){var t=this.game.canvas;t.removeEventListener("MSPointerDown",this._onMSPointerDown,!1),t.removeEventListener("MSPointerMove",this._onMSPointerMove,!1),t.removeEventListener("MSPointerUp",this._onMSPointerUp,!1),t.removeEventListener("pointerdown",this._onMSPointerDown,!1),t.removeEventListener("pointermove",this._onMSPointerMove,!1),t.removeEventListener("pointerup",this._onMSPointerUp,!1),window.removeEventListener("MSPointerUp",this._onMSPointerUpGlobal,!0),t.removeEventListener("MSPointerOver",this._onMSPointerOver,!0),t.removeEventListener("MSPointerOut",this._onMSPointerOut,!0),window.removeEventListener("pointerup",this._onMSPointerUpGlobal,!0),t.removeEventListener("pointerover",this._onMSPointerOver,!0),t.removeEventListener("pointerout",this._onMSPointerOut,!0),this.active=!1}},e.MSPointer.prototype.constructor=e.MSPointer,e.DeviceButton=function(t,i){this.parent=t,this.game=t.game,this.event=null,this.isDown=!1,this.isUp=!0,this.timeDown=0,this.timeUp=0,this.repeats=0,this.altKey=!1,this.shiftKey=!1,this.ctrlKey=!1,this.value=0,this.buttonCode=i,this.onDown=new e.Signal,this.onUp=new e.Signal,this.onFloat=new e.Signal},e.DeviceButton.prototype={start:function(t,e){this.isDown||(this.isDown=!0,this.isUp=!1,this.timeDown=this.game.time.time,this.repeats=0,this.event=t,this.value=e,t&&(this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.ctrlKey=t.ctrlKey),this.onDown.dispatch(this,e))},stop:function(t,e){this.isUp||(this.isDown=!1,this.isUp=!0,this.timeUp=this.game.time.time,this.event=t,this.value=e,t&&(this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.ctrlKey=t.ctrlKey),this.onUp.dispatch(this,e))},startStop:function(t,e,i){t?this.start(e,i):this.stop(e,i)},padFloat:function(t){this.isDown=!1,this.isUp=!1,this.value=t,this.onFloat.dispatch(this,t)},justPressed:function(t){return t=t||250,this.isDown&&this.timeDown+t>this.game.time.time},justReleased:function(t){return t=t||250,this.isUp&&this.timeUp+t>this.game.time.time},reset:function(){this.isDown=!1,this.isUp=!0,this.timeDown=this.game.time.time,this.repeats=0,this.altKey=!1,this.shiftKey=!1,this.ctrlKey=!1},destroy:function(){this.onDown.dispose(),this.onUp.dispose(),this.onFloat.dispose(),this.parent=null,this.game=null}},e.DeviceButton.prototype.constructor=e.DeviceButton,Object.defineProperty(e.DeviceButton.prototype,"duration",{get:function(){return this.isUp?-1:this.game.time.time-this.timeDown}}),e.Pointer=function(t,i,s){this.game=t,this.id=i,this.type=e.POINTER,this.exists=!0,this.identifier=0,this.pointerId=null,this.pointerMode=s||e.PointerMode.CURSOR|e.PointerMode.CONTACT,this.target=null,this.button=null,this.leftButton=new e.DeviceButton(this,e.Pointer.LEFT_BUTTON),this.middleButton=new e.DeviceButton(this,e.Pointer.MIDDLE_BUTTON),this.rightButton=new e.DeviceButton(this,e.Pointer.RIGHT_BUTTON),this.backButton=new e.DeviceButton(this,e.Pointer.BACK_BUTTON),this.forwardButton=new e.DeviceButton(this,e.Pointer.FORWARD_BUTTON),this.eraserButton=new e.DeviceButton(this,e.Pointer.ERASER_BUTTON),this._holdSent=!1,this._history=[],this._nextDrop=0,this._stateReset=!1,this.withinGame=!1,this.clientX=-1,this.clientY=-1,this.pageX=-1,this.pageY=-1,this.screenX=-1,this.screenY=-1,this.rawMovementX=0,this.rawMovementY=0,this.movementX=0,this.movementY=0,this.x=-1,this.y=-1,this.isMouse=0===i,this.isDown=!1,this.isUp=!0,this.timeDown=0,this.timeUp=0,this.previousTapTime=0,this.totalTouches=0,this.msSinceLastClick=Number.MAX_VALUE,this.targetObject=null,this.interactiveCandidates=[],this.active=!1,this.dirty=!1,this.position=new e.Point,this.positionDown=new e.Point,this.positionUp=new e.Point,this.circle=new e.Circle(0,0,44),this._clickTrampolines=null,this._trampolineTargetObject=null},e.Pointer.NO_BUTTON=0,e.Pointer.LEFT_BUTTON=1,e.Pointer.RIGHT_BUTTON=2,e.Pointer.MIDDLE_BUTTON=4,e.Pointer.BACK_BUTTON=8,e.Pointer.FORWARD_BUTTON=16,e.Pointer.ERASER_BUTTON=32,e.Pointer.prototype={resetButtons:function(){this.isDown=!1,this.isUp=!0,this.isMouse&&(this.leftButton.reset(),this.middleButton.reset(),this.rightButton.reset(),this.backButton.reset(),this.forwardButton.reset(),this.eraserButton.reset())},processButtonsDown:function(t,i){switch(t){case e.Mouse.LEFT_BUTTON:this.leftButton.start(i);break;case e.Mouse.RIGHT_BUTTON:this.rightButton.start(i);break;case e.Mouse.MIDDLE_BUTTON:this.middleButton.start(i);break;case e.Mouse.BACK_BUTTON:this.backButton.start(i);break;case e.Mouse.FORWARD_BUTTON:this.forwardButton.start(i)}},processButtonsUp:function(t,i){switch(t){case e.Mouse.LEFT_BUTTON:this.leftButton.stop(i);break;case e.Mouse.RIGHT_BUTTON:this.rightButton.stop(i);break;case e.Mouse.MIDDLE_BUTTON:this.middleButton.stop(i);break;case e.Mouse.BACK_BUTTON:this.backButton.stop(i);break;case e.Mouse.FORWARD_BUTTON:this.forwardButton.stop(i)}},processButtonsUpDown:function(t,i){var s=i.type.toLowerCase().substr(-4),n="down"===s,r="move"===s;void 0!==t?(n&&1===t&&i.ctrlKey&&(t=2),this.leftButton.startStop(e.Pointer.LEFT_BUTTON&t,i),this.rightButton.startStop(e.Pointer.RIGHT_BUTTON&t,i),this.middleButton.startStop(e.Pointer.MIDDLE_BUTTON&t,i),this.backButton.startStop(e.Pointer.BACK_BUTTON&t,i),this.forwardButton.startStop(e.Pointer.FORWARD_BUTTON&t,i),this.eraserButton.startStop(e.Pointer.ERASER_BUTTON&t,i)):void 0!==i.button?n&&i.ctrlKey&&0===i.button?this.rightButton.start(i):n?this.processButtonsDown(i.button,i):r||this.processButtonsUp(i.button,i):n?i.ctrlKey?this.rightButton.start(i):this.leftButton.start(i):(this.leftButton.stop(i),this.rightButton.stop(i))},updateButtons:function(t){this.button=t.button,this.processButtonsUpDown(t.buttons,t),this.isUp=!0,this.isDown=!1,(this.leftButton.isDown||this.rightButton.isDown||this.middleButton.isDown||this.backButton.isDown||this.forwardButton.isDown||this.eraserButton.isDown)&&(this.isUp=!1,this.isDown=!0)},start:function(t){var i=this.game.input;return t.pointerId&&(this.pointerId=t.pointerId),this.identifier=t.identifier,this.target=t.target,this.isMouse?this.updateButtons(t):(this.isDown=!0,this.isUp=!1),this.active=!0,this.withinGame=!0,this.dirty=!1,this._history=[],this._clickTrampolines=null,this._trampolineTargetObject=null,this.msSinceLastClick=this.game.time.time-this.timeDown,this.timeDown=this.game.time.time,this._holdSent=!1,this.move(t,!0),this.positionDown.setTo(this.x,this.y),(i.multiInputOverride===e.Input.MOUSE_OVERRIDES_TOUCH||i.multiInputOverride===e.Input.MOUSE_TOUCH_COMBINE||i.multiInputOverride===e.Input.TOUCH_OVERRIDES_MOUSE&&0===i.totalActivePointers)&&(i.x=this.x,i.y=this.y,i.position.setTo(this.x,this.y),i.onDown.dispatch(this,t),i.resetSpeed(this.x,this.y)),this._stateReset=!1,this.totalTouches++,null!==this.targetObject&&this.targetObject._touchedHandler(this),this},update:function(){var t=this.game.input;this.active&&(this.dirty&&(t.interactiveItems.total>0&&this.processInteractiveObjects(!1),this.dirty=!1),!1===this._holdSent&&this.duration>=t.holdRate&&((t.multiInputOverride===e.Input.MOUSE_OVERRIDES_TOUCH||t.multiInputOverride===e.Input.MOUSE_TOUCH_COMBINE||t.multiInputOverride===e.Input.TOUCH_OVERRIDES_MOUSE&&0===t.totalActivePointers)&&t.onHold.dispatch(this),this._holdSent=!0),t.recordPointerHistory&&this.game.time.time>=this._nextDrop&&(this._nextDrop=this.game.time.time+t.recordRate,this._history.push({x:this.position.x,y:this.position.y}),this._history.length>t.recordLimit&&this._history.shift()))},move:function(t,i){var s=this.game.input;if(!s.pollLocked){void 0===i&&(i=!1),void 0!==t.button&&(this.button=t.button),this.isMouse&&this.updateButtons(t),this.clientX=t.clientX,this.clientY=t.clientY,this.pageX=t.pageX,this.pageY=t.pageY,this.screenX=t.screenX,this.screenY=t.screenY,this.isMouse&&s.pointerLock.locked&&!i&&(this.rawMovementX=t.movementX||t.mozMovementX||t.webkitMovementX||0,this.rawMovementY=t.movementY||t.mozMovementY||t.webkitMovementY||0,this.movementX+=this.rawMovementX,this.movementY+=this.rawMovementY),this.x=(this.pageX-this.game.scale.offset.x)*s.scale.x,this.y=(this.pageY-this.game.scale.offset.y)*s.scale.y,this.position.setTo(this.x,this.y),this.circle.x=this.x,this.circle.y=this.y,(s.multiInputOverride===e.Input.MOUSE_OVERRIDES_TOUCH||s.multiInputOverride===e.Input.MOUSE_TOUCH_COMBINE||s.multiInputOverride===e.Input.TOUCH_OVERRIDES_MOUSE&&0===s.totalActivePointers)&&(s.activePointer=this,s.x=this.x,s.y=this.y,s.position.setTo(s.x,s.y),s.circle.x=s.x,s.circle.y=s.y),this.withinGame=this.game.scale.bounds.contains(this.pageX,this.pageY);for(var n=s.moveCallbacks.length;n--;)s.moveCallbacks[n].callback.call(s.moveCallbacks[n].context,this,this.x,this.y,i,t);return null===this.targetObject||this.game.paused&&!this.targetObject.noPause||!0!==this.targetObject.isDragged?s.interactiveItems.total>0&&this.processInteractiveObjects(i):!1===this.targetObject.update(this)&&(this.targetObject=null),this}},processInteractiveObjects:function(t){var e=0,i=-1,s=null,n=this.game.input.interactiveItems.first;for(this.interactiveCandidates=[];n;)n.checked=!1,!n.validForInput(i,e,!1)||this.game.paused&&!n.sprite.noPause||(n.checked=!0,(t&&n.checkPointerDown(this,!0)||!t&&n.checkPointerOver(this,!0))&&(e=n.sprite.renderOrderID,i=n.priorityID,s=n,this.interactiveCandidates.push(n))),n=this.game.input.interactiveItems.next;for(n=this.game.input.interactiveItems.first;n;)!n.checked&&n.validForInput(i,e,!0)&&(t&&n.checkPointerDown(this,!1)||!t&&n.checkPointerOver(this,!1))&&(e=n.sprite.renderOrderID,i=n.priorityID,s=n,this.interactiveCandidates.push(n)),n=this.game.input.interactiveItems.next;return this.game.input.customCandidateHandler&&(s=this.game.input.customCandidateHandler.call(this.game.input.customCandidateHandlerContext,this,this.interactiveCandidates,s)),this.swapTarget(s,!1),null!==this.targetObject},swapTarget:function(t,e){void 0===e&&(e=!1),null===t?this.targetObject&&(this.targetObject._pointerOutHandler(this,e),this.targetObject=null):null===this.targetObject?(this.targetObject=t,t._pointerOverHandler(this,e)):this.targetObject===t?!1===t.update(this)&&(this.targetObject=null):(this.targetObject._pointerOutHandler(this,e),this.targetObject=t,this.targetObject._pointerOverHandler(this,e))},leave:function(t){this.withinGame=!1,this.move(t,!1)},stop:function(t){var i=this.game.input;{if(!this._stateReset||!this.withinGame){if(this.timeUp=this.game.time.time,(i.multiInputOverride===e.Input.MOUSE_OVERRIDES_TOUCH||i.multiInputOverride===e.Input.MOUSE_TOUCH_COMBINE||i.multiInputOverride===e.Input.TOUCH_OVERRIDES_MOUSE&&0===i.totalActivePointers)&&(i.onUp.dispatch(this,t),this.duration>=0&&this.duration<=i.tapRate)){var s=this.timeUp-this.previousTapTime<i.doubleTapRate;i.onTap.dispatch(this,s,t),this.previousTapTime=this.timeUp}return this.isMouse?this.updateButtons(t):(this.isDown=!1,this.isUp=!0),this.id>0&&(this.active=!1),this.withinGame=this.game.scale.bounds.contains(t.pageX,t.pageY),this.pointerId=null,this.identifier=null,this.positionUp.setTo(this.x,this.y),!1===this.isMouse&&i.currentPointers--,i.callAll("_releasedHandler",this),this._clickTrampolines&&(this._trampolineTargetObject=this.targetObject),this.targetObject=null,this}t.preventDefault()}},justPressed:function(t){return t=t||this.game.input.justPressedRate,!0===this.isDown&&this.timeDown+t>this.game.time.time},justReleased:function(t){return t=t||this.game.input.justReleasedRate,this.isUp&&this.timeUp+t>this.game.time.time},addClickTrampoline:function(t,e,i,s){if(this.isDown){for(var n=this._clickTrampolines=this._clickTrampolines||[],r=0;r<n.length;r++)if(n[r].name===t){n.splice(r,1);break}n.push({name:t,targetObject:this.targetObject,callback:e,callbackContext:i,callbackArgs:s})}},processClickTrampolines:function(){var t=this._clickTrampolines;if(t){for(var e=0;e<t.length;e++){var i=t[e];i.targetObject===this._trampolineTargetObject&&i.callback.apply(i.callbackContext,i.callbackArgs)}this._clickTrampolines=null,this._trampolineTargetObject=null}},reset:function(){!1===this.isMouse&&(this.active=!1),this.pointerId=null,this.identifier=null,this.dirty=!1,this.totalTouches=0,this._holdSent=!1,this._history.length=0,this._stateReset=!0,this.resetButtons(),this.targetObject&&this.targetObject._releasedHandler(this),this.targetObject=null},resetMovement:function(){this.movementX=0,this.movementY=0}},e.Pointer.prototype.constructor=e.Pointer,Object.defineProperty(e.Pointer.prototype,"duration",{get:function(){return this.isUp?-1:this.game.time.time-this.timeDown}}),Object.defineProperty(e.Pointer.prototype,"worldX",{get:function(){return this.game.world.camera.x+this.x}}),Object.defineProperty(e.Pointer.prototype,"worldY",{get:function(){return this.game.world.camera.y+this.y}}),e.PointerMode={CURSOR:1,CONTACT:2},e.PointerModes={},e.PointerModes[e.PointerMode.CURSOR]="CURSOR",e.PointerModes[e.PointerMode.CONTACT]="CONTACT",e.Touch=function(t){this.game=t,this.active=!1,this.enabled=!0,this.callbackContext=this.game,this.touchStartCallback=null,this.touchMoveCallback=null,this.touchEndCallback=null,this.touchEnterCallback=null,this.touchLeaveCallback=null,this.touchCancelCallback=null,this.preventDefault=!0,this.event=null,this._onTouchStart=null,this._onTouchMove=null,this._onTouchEnd=null,this._onTouchEnter=null,this._onTouchLeave=null,this._onTouchCancel=null,this._onTouchMove=null},e.Touch.prototype={start:function(){if(!this.game.device.touch)return!1;if(null!==this._onTouchStart)return!1;var t=this;return this._onTouchStart=function(e){return t.onTouchStart(e)},this._onTouchMove=function(e){return t.onTouchMove(e)},this._onTouchEnd=function(e){return t.onTouchEnd(e)},this._onTouchEnter=function(e){return t.onTouchEnter(e)},this._onTouchLeave=function(e){return t.onTouchLeave(e)},this._onTouchCancel=function(e){return t.onTouchCancel(e)},this.game.canvas.addEventListener("touchstart",this._onTouchStart,!1),this.game.canvas.addEventListener("touchmove",this._onTouchMove,!1),this.game.canvas.addEventListener("touchend",this._onTouchEnd,!1),this.game.canvas.addEventListener("touchcancel",this._onTouchCancel,!1),this.game.device.cocoonJS||(this.game.canvas.addEventListener("touchenter",this._onTouchEnter,!1),this.game.canvas.addEventListener("touchleave",this._onTouchLeave,!1)),this.active=!0,!0},consumeDocumentTouches:function(){this._documentTouchMove=function(t){t.preventDefault()},document.addEventListener("touchmove",this._documentTouchMove,!1)},onTouchStart:function(t){if(this.game.input.executeTouchLockCallbacks(!1,t),this.event=t,this.game.input.enabled&&this.enabled){this.touchStartCallback&&this.touchStartCallback.call(this.callbackContext,t),this.preventDefault&&t.preventDefault();for(var e=0;e<t.changedTouches.length;e++)this.game.input.startPointer(t.changedTouches[e])}},onTouchCancel:function(t){if(this.event=t,this.touchCancelCallback&&this.touchCancelCallback.call(this.callbackContext,t),this.game.input.enabled&&this.enabled){this.preventDefault&&t.preventDefault();for(var e=0;e<t.changedTouches.length;e++)this.game.input.stopPointer(t.changedTouches[e])}},onTouchEnter:function(t){this.event=t,this.touchEnterCallback&&this.touchEnterCallback.call(this.callbackContext,t),this.game.input.enabled&&this.enabled&&this.preventDefault&&t.preventDefault()},onTouchLeave:function(t){this.event=t,this.touchLeaveCallback&&this.touchLeaveCallback.call(this.callbackContext,t),this.preventDefault&&t.preventDefault()},onTouchMove:function(t){this.event=t,this.touchMoveCallback&&this.touchMoveCallback.call(this.callbackContext,t),this.preventDefault&&t.preventDefault();for(var e=0;e<t.changedTouches.length;e++)this.game.input.updatePointer(t.changedTouches[e])},onTouchEnd:function(t){this.game.input.executeTouchLockCallbacks(!0,t),this.event=t,this.touchEndCallback&&this.touchEndCallback.call(this.callbackContext,t),this.preventDefault&&t.preventDefault();for(var e=0;e<t.changedTouches.length;e++)this.game.input.stopPointer(t.changedTouches[e])},stop:function(){this.game.device.touch&&(this.game.canvas.removeEventListener("touchstart",this._onTouchStart),this.game.canvas.removeEventListener("touchmove",this._onTouchMove),this.game.canvas.removeEventListener("touchend",this._onTouchEnd),this.game.canvas.removeEventListener("touchenter",this._onTouchEnter),this.game.canvas.removeEventListener("touchleave",this._onTouchLeave),this.game.canvas.removeEventListener("touchcancel",this._onTouchCancel),this.active=!1)}},e.Touch.prototype.constructor=e.Touch,e.InputHandler=function(t){this.sprite=t,this.game=t.game,this.enabled=!1,this.checked=!1,this.priorityID=0,this.useHandCursor=!1,this._setHandCursor=!1,this.isDragged=!1,this.allowHorizontalDrag=!0,this.allowVerticalDrag=!0,this.bringToTop=!1,this.snapOffset=null,this.snapOnDrag=!1,this.snapOnRelease=!1,this.snapX=0,this.snapY=0,this.snapOffsetX=0,this.snapOffsetY=0,this.pixelPerfectOver=!1,this.pixelPerfectClick=!1,this.pixelPerfectAlpha=255,this.draggable=!1,this.boundsRect=null,this.boundsSprite=null,this.scaleLayer=!1,this.dragOffset=new e.Point,this.dragFromCenter=!1,this.dragStopBlocksInputUp=!1,this.dragStartPoint=new e.Point,this.dragDistanceThreshold=0,this.dragTimeThreshold=0,this.downPoint=new e.Point,this.snapPoint=new e.Point,this._dragPoint=new e.Point,this._dragPhase=!1,this._pendingDrag=!1,this._dragTimePass=!1,this._dragDistancePass=!1,this._wasEnabled=!1,this._tempPoint=new e.Point,this._pointerData=[],this._pointerData.push({id:0,x:0,y:0,camX:0,camY:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1})},e.InputHandler.prototype={start:function(t,i){if(t=t||0,void 0===i&&(i=!1),!1===this.enabled){this.game.input.interactiveItems.add(this),this.useHandCursor=i,this.priorityID=t;for(var s=0;s<10;s++)this._pointerData[s]={id:s,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1};this.snapOffset=new e.Point,this.enabled=!0,this._wasEnabled=!0}return this.sprite.events.onAddedToGroup.add(this.addedToGroup,this),this.sprite.events.onRemovedFromGroup.add(this.removedFromGroup,this),this.sprite},addedToGroup:function(){this._dragPhase||this._wasEnabled&&!this.enabled&&this.start()},removedFromGroup:function(){this._dragPhase||(this.enabled?(this._wasEnabled=!0,this.stop()):this._wasEnabled=!1)},reset:function(){this.enabled=!1;for(var t=0;t<10;t++)this._pointerData[t]={id:t,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1}},stop:function(){!1!==this.enabled&&(this.enabled=!1,this.game.input.interactiveItems.remove(this))},destroy:function(){this.sprite&&(this._setHandCursor&&(this.game.canvas.style.cursor="",this._setHandCursor=!1),this.enabled=!1,this.game.input.interactiveItems.remove(this),this._pointerData.length=0,this.boundsRect=null,this.boundsSprite=null,this.sprite=null)},validForInput:function(t,e,i){return void 0===i&&(i=!0),!(!this.enabled||0===this.sprite.scale.x||0===this.sprite.scale.y||this.priorityID<this.game.input.minPriorityID||this.sprite.parent&&this.sprite.parent.ignoreChildInput)&&(!(!i&&(this.pixelPerfectClick||this.pixelPerfectOver))&&(this.priorityID>t||this.priorityID===t&&this.sprite.renderOrderID>e))},isPixelPerfect:function(){return this.pixelPerfectClick||this.pixelPerfectOver},pointerX:function(t){return t=t||0,this._pointerData[t].x},pointerY:function(t){return t=t||0,this._pointerData[t].y},pointerDown:function(t){return t=t||0,this._pointerData[t].isDown},pointerUp:function(t){return t=t||0,this._pointerData[t].isUp},pointerTimeDown:function(t){return t=t||0,this._pointerData[t].timeDown},pointerTimeUp:function(t){return t=t||0,this._pointerData[t].timeUp},pointerOver:function(t){if(!this.enabled)return!1;if(void 0===t){for(var e=0;e<10;e++)if(this._pointerData[e].isOver)return!0;return!1}return this._pointerData[t].isOver},pointerOut:function(t){if(!this.enabled)return!1;if(void 0!==t)return this._pointerData[t].isOut;for(var e=0;e<10;e++)if(this._pointerData[e].isOut)return!0},pointerTimeOver:function(t){return t=t||0,this._pointerData[t].timeOver},pointerTimeOut:function(t){return t=t||0,this._pointerData[t].timeOut},pointerDragged:function(t){return t=t||0,this._pointerData[t].isDragged},checkPointerDown:function(t,e){return!!(t.isDown&&this.enabled&&this.sprite&&this.sprite.parent&&this.sprite.visible&&this.sprite.parent.visible&&0!==this.sprite.worldScale.x&&0!==this.sprite.worldScale.y)&&(!!this.game.input.hitTest(this.sprite,t,this._tempPoint)&&(void 0===e&&(e=!1),!(!e&&this.pixelPerfectClick)||this.checkPixel(this._tempPoint.x,this._tempPoint.y)))},checkPointerOver:function(t,e){return!!(this.enabled&&this.sprite&&this.sprite.parent&&this.sprite.visible&&this.sprite.parent.visible&&0!==this.sprite.worldScale.x&&0!==this.sprite.worldScale.y)&&(!!this.game.input.hitTest(this.sprite,t,this._tempPoint)&&(void 0===e&&(e=!1),!(!e&&this.pixelPerfectOver)||this.checkPixel(this._tempPoint.x,this._tempPoint.y)))},checkPixel:function(t,e,i){if(this.sprite.texture.baseTexture.source){if(null===t&&null===e){this.game.input.getLocalPosition(this.sprite,i,this._tempPoint);var t=this._tempPoint.x,e=this._tempPoint.y}if(0!==this.sprite.anchor.x&&(t-=-this.sprite.texture.frame.width*this.sprite.anchor.x),0!==this.sprite.anchor.y&&(e-=-this.sprite.texture.frame.height*this.sprite.anchor.y),t+=this.sprite.texture.frame.x,e+=this.sprite.texture.frame.y,this.sprite.texture.trim&&(t-=this.sprite.texture.trim.x,e-=this.sprite.texture.trim.y,t<this.sprite.texture.crop.x||t>this.sprite.texture.crop.right||e<this.sprite.texture.crop.y||e>this.sprite.texture.crop.bottom))return this._dx=t,this._dy=e,!1;if(this._dx=t,this._dy=e,this.game.input.hitContext.clearRect(0,0,1,1),this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source,t,e,1,1,0,0,1,1),this.game.input.hitContext.getImageData(0,0,1,1).data[3]>=this.pixelPerfectAlpha)return!0}return!1},update:function(t){if(null!==this.sprite&&void 0!==this.sprite.parent)return this.enabled&&this.sprite.visible&&this.sprite.parent.visible?this._pendingDrag?(this._dragDistancePass||(this._dragDistancePass=e.Math.distance(t.x,t.y,this.downPoint.x,this.downPoint.y)>=this.dragDistanceThreshold),this._dragDistancePass&&this._dragTimePass&&this.startDrag(t),!0):this.draggable&&this._draggedPointerID===t.id?this.updateDrag(t,!1):this._pointerData[t.id].isOver?this.checkPointerOver(t)?(this._pointerData[t.id].x=t.x-this.sprite.x,this._pointerData[t.id].y=t.y-this.sprite.y,!0):(this._pointerOutHandler(t),!1):void 0:(this._pointerOutHandler(t),!1)},_pointerOverHandler:function(t,e){if(null!==this.sprite){var i=this._pointerData[t.id];if(!1===i.isOver||t.dirty){var s=!1===i.isOver;i.isOver=!0,i.isOut=!1,i.timeOver=this.game.time.time,i.x=t.x-this.sprite.x,i.y=t.y-this.sprite.y,this.useHandCursor&&!1===i.isDragged&&(this.game.canvas.style.cursor="pointer",this._setHandCursor=!0),!e&&s&&this.sprite&&this.sprite.events&&this.sprite.events.onInputOver$dispatch(this.sprite,t),this.sprite.parent&&this.sprite.parent.onChildInputOver&&this.sprite.parent.onChildInputOver.dispatch(this.sprite,t)}}},_pointerOutHandler:function(t,e){if(null!==this.sprite){var i=this._pointerData[t.id];i.isOver=!1,i.isOut=!0,i.timeOut=this.game.time.time,this.useHandCursor&&!1===i.isDragged&&(this.game.canvas.style.cursor="",this._setHandCursor=!1),!e&&this.sprite&&this.sprite.events&&(this.sprite.events.onInputOut$dispatch(this.sprite,t),this.sprite&&this.sprite.parent&&this.sprite.parent.onChildInputOut&&this.sprite.parent.onChildInputOut.dispatch(this.sprite,t))}},_touchedHandler:function(t){if(null!==this.sprite){var e=this._pointerData[t.id];if(!e.isDown&&e.isOver){if(this.pixelPerfectClick&&!this.checkPixel(null,null,t))return;if(e.isDown=!0,e.isUp=!1,e.timeDown=this.game.time.time,this.downPoint.set(t.x,t.y),t.dirty=!0,this.sprite&&this.sprite.events&&(this.sprite.events.onInputDown$dispatch(this.sprite,t),this.sprite&&this.sprite.parent&&this.sprite.parent.onChildInputDown&&this.sprite.parent.onChildInputDown.dispatch(this.sprite,t),null===this.sprite))return;this.draggable&&!1===this.isDragged&&(0===this.dragTimeThreshold&&0===this.dragDistanceThreshold?this.startDrag(t):(this._pendingDrag=!0,this._dragDistancePass=0===this.dragDistanceThreshold,this.dragTimeThreshold>0?(this._dragTimePass=!1,this.game.time.events.add(this.dragTimeThreshold,this.dragTimeElapsed,this,t)):this._dragTimePass=!0)),this.bringToTop&&this.sprite.bringToTop()}}},dragTimeElapsed:function(t){this._dragTimePass=!0,this._pendingDrag&&this.sprite&&this._dragDistancePass&&this.startDrag(t)},_releasedHandler:function(t){if(null!==this.sprite){var e=this._pointerData[t.id];if(e.isDown&&t.isUp){e.isDown=!1,e.isUp=!0,e.timeUp=this.game.time.time,e.downDuration=e.timeUp-e.timeDown;var i=this.checkPointerOver(t);this.sprite&&this.sprite.events&&(this.dragStopBlocksInputUp&&(!this.dragStopBlocksInputUp||this.draggable&&this.isDragged&&this._draggedPointerID===t.id)||this.sprite.events.onInputUp$dispatch(this.sprite,t,i),this.sprite&&this.sprite.parent&&this.sprite.parent.onChildInputUp&&this.sprite.parent.onChildInputUp.dispatch(this.sprite,t,i),i&&(i=this.checkPointerOver(t))),e.isOver=i,!i&&this.useHandCursor&&(this.game.canvas.style.cursor="default",this._setHandCursor=!1),t.dirty=!0,this._pendingDrag=!1,this.draggable&&this.isDragged&&this._draggedPointerID===t.id&&this.stopDrag(t)}}},updateDrag:function(t,e){var i=this.game.camera,s=this.dragOffset,n=this._dragPoint,r=this._pointerData[t.id],o=this.snapPoint,a=this.sprite;if(void 0===e&&(e=!1),t.isUp)return this.stopDrag(t),!1;var h=this.globalToLocal(t);if(a.fixedToCamera)var l=i.scale.x*h.x+n.x+s.x,c=i.scale.y*h.y+n.y+s.y;else var l=h.x+n.x+s.x,c=h.y+n.y+s.y;if(a.fixedToCamera){var u=a.cameraOffset,d=u.x,p=u.y;this.allowHorizontalDrag&&(u.x=l-i.x),this.allowVerticalDrag&&(u.y=c-i.y),this.boundsRect&&this.checkBoundsRect(),this.boundsSprite&&this.checkBoundsSprite(),this.snapOnDrag&&(u.x=Math.round((u.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,u.y=Math.round((u.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY,o.set(u.x,u.y));var f=u.x-d,g=u.y-p}else{var m=i.x-r.camX,y=i.y-r.camY,d=a.x,p=a.y;this.allowHorizontalDrag&&(a.x=l+m),this.allowVerticalDrag&&(a.y=c+y),this.boundsRect&&this.checkBoundsRect(),this.boundsSprite&&this.checkBoundsSprite(),this.snapOnDrag&&(a.x=Math.round((a.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,a.y=Math.round((a.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY,o.set(a.x,a.y));var f=a.x-d,g=a.y-p}return this.sprite.events.onDragUpdate.dispatch(a,t,l,c,o,e,f,g),!0},justOver:function(t,e){return t=t||0,e=e||500,this._pointerData[t].isOver&&this.overDuration(t)<e},justOut:function(t,e){return t=t||0,e=e||500,this._pointerData[t].isOut&&this.game.time.time-this._pointerData[t].timeOut<e},justPressed:function(t,e){return t=t||0,e=e||500,this._pointerData[t].isDown&&this.downDuration(t)<e},justReleased:function(t,e){return t=t||0,e=e||500,this._pointerData[t].isUp&&this.game.time.time-this._pointerData[t].timeUp<e},overDuration:function(t){return t=t||0,this._pointerData[t].isOver?this.game.time.time-this._pointerData[t].timeOver:-1},downDuration:function(t){return t=t||0,this._pointerData[t].isDown?this.game.time.time-this._pointerData[t].timeDown:-1},enableDrag:function(t,i,s,n,r,o){void 0===t&&(t=!1),void 0===i&&(i=!1),void 0===s&&(s=!1),void 0===n&&(n=255),void 0===r&&(r=null),void 0===o&&(o=null),this._dragPoint=new e.Point,this.draggable=!0,this.bringToTop=i,this.dragOffset=new e.Point,this.dragFromCenter=t,this.pixelPerfectClick=s,this.pixelPerfectAlpha=n,r&&(this.boundsRect=r),o&&(this.boundsSprite=o)},disableDrag:function(){if(this._pointerData)for(var t=0;t<10;t++)this._pointerData[t].isDragged=!1;this.draggable=!1,this.isDragged=!1,this._draggedPointerID=-1,this._pendingDrag=!1},startDrag:function(t){var i=this.sprite.x,s=this.sprite.y,n=this.globalToLocal(t);if(this.isDragged=!0,this._draggedPointerID=t.id,this._pointerData[t.id].camX=this.game.camera.x,this._pointerData[t.id].camY=this.game.camera.y,this._pointerData[t.id].isDragged=!0,this.sprite.fixedToCamera){if(this.dragFromCenter){var r=this.sprite.getBounds(),o=this.globalToLocal(new e.Point(r.centerX,r.centerY));this.sprite.cameraOffset.x=n.x+(this.sprite.cameraOffset.x-o.x),this.sprite.cameraOffset.y=n.y+(this.sprite.cameraOffset.y-o.y)}this._dragPoint.setTo(this.sprite.cameraOffset.x-t.x,this.sprite.cameraOffset.y-t.y)}else{if(this.dragFromCenter){var r=this.sprite.getBounds(),o=this.globalToLocal(new e.Point(r.centerX,r.centerY));this.sprite.x=n.x+(this.sprite.x-o.x),this.sprite.y=n.y+(this.sprite.y-o.y)}this._dragPoint.setTo(this.sprite.x-n.x,this.sprite.y-n.y)}this.updateDrag(t,!0),this.bringToTop&&(this._dragPhase=!0,this.sprite.bringToTop()),this.dragStartPoint.set(i,s),this.sprite.events.onDragStart$dispatch(this.sprite,t,i,s),this._pendingDrag=!1},globalToLocalX:function(t){return this.scaleLayer&&(t-=this.game.scale.grid.boundsFluid.x,t*=this.game.scale.grid.scaleFluidInversed.x),t},globalToLocalY:function(t){return this.scaleLayer&&(t-=this.game.scale.grid.boundsFluid.y,t*=this.game.scale.grid.scaleFluidInversed.y),t},globalToLocal:function(t){return this.sprite.parent?this.game.input.getLocalPosition(this.sprite.parent,{x:t.x,y:t.y}):t},stopDrag:function(t){this.isDragged=!1,this._draggedPointerID=-1,this._pointerData[t.id].isDragged=!1,this._dragPhase=!1,this._pendingDrag=!1,this.snapOnRelease&&(this.sprite.fixedToCamera?(this.sprite.cameraOffset.x=Math.round((this.sprite.cameraOffset.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.cameraOffset.y=Math.round((this.sprite.cameraOffset.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY):(this.sprite.x=Math.round((this.sprite.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.y=Math.round((this.sprite.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY)),this.sprite.events.onDragStop$dispatch(this.sprite,t),!1===this.checkPointerOver(t)&&this._pointerOutHandler(t)},setDragLock:function(t,e){void 0===t&&(t=!0),void 0===e&&(e=!0),this.allowHorizontalDrag=t,this.allowVerticalDrag=e},enableSnap:function(t,e,i,s,n,r){void 0===i&&(i=!0),void 0===s&&(s=!1),void 0===n&&(n=0),void 0===r&&(r=0),this.snapX=t,this.snapY=e,this.snapOffsetX=n,this.snapOffsetY=r,this.snapOnDrag=i,this.snapOnRelease=s},disableSnap:function(){this.snapOnDrag=!1,this.snapOnRelease=!1},checkBoundsRect:function(){this.sprite.fixedToCamera?(this.sprite.cameraOffset.x<this.boundsRect.left?this.sprite.cameraOffset.x=this.boundsRect.left:this.sprite.cameraOffset.x+this.sprite.width>this.boundsRect.right&&(this.sprite.cameraOffset.x=this.boundsRect.right-this.sprite.width),this.sprite.cameraOffset.y<this.boundsRect.top?this.sprite.cameraOffset.y=this.boundsRect.top:this.sprite.cameraOffset.y+this.sprite.height>this.boundsRect.bottom&&(this.sprite.cameraOffset.y=this.boundsRect.bottom-this.sprite.height)):(this.sprite.left<this.boundsRect.left?this.sprite.x=this.boundsRect.x+this.sprite.offsetX:this.sprite.right>this.boundsRect.right&&(this.sprite.x=this.boundsRect.right-(this.sprite.width-this.sprite.offsetX)),this.sprite.top<this.boundsRect.top?this.sprite.y=this.boundsRect.top+this.sprite.offsetY:this.sprite.bottom>this.boundsRect.bottom&&(this.sprite.y=this.boundsRect.bottom-(this.sprite.height-this.sprite.offsetY)))},checkBoundsSprite:function(){this.sprite.fixedToCamera&&this.boundsSprite.fixedToCamera?(this.sprite.cameraOffset.x<this.boundsSprite.cameraOffset.x?this.sprite.cameraOffset.x=this.boundsSprite.cameraOffset.x:this.sprite.cameraOffset.x+this.sprite.width>this.boundsSprite.cameraOffset.x+this.boundsSprite.width&&(this.sprite.cameraOffset.x=this.boundsSprite.cameraOffset.x+this.boundsSprite.width-this.sprite.width),this.sprite.cameraOffset.y<this.boundsSprite.cameraOffset.y?this.sprite.cameraOffset.y=this.boundsSprite.cameraOffset.y:this.sprite.cameraOffset.y+this.sprite.height>this.boundsSprite.cameraOffset.y+this.boundsSprite.height&&(this.sprite.cameraOffset.y=this.boundsSprite.cameraOffset.y+this.boundsSprite.height-this.sprite.height)):(this.sprite.left<this.boundsSprite.left?this.sprite.x=this.boundsSprite.left+this.sprite.offsetX:this.sprite.right>this.boundsSprite.right&&(this.sprite.x=this.boundsSprite.right-(this.sprite.width-this.sprite.offsetX)),this.sprite.top<this.boundsSprite.top?this.sprite.y=this.boundsSprite.top+this.sprite.offsetY:this.sprite.bottom>this.boundsSprite.bottom&&(this.sprite.y=this.boundsSprite.bottom-(this.sprite.height-this.sprite.offsetY)))}},e.InputHandler.prototype.constructor=e.InputHandler,e.PointerLock=function(t){this.game=t,this.input=t.input,this.element=t.canvas,this.active=!1,this.locked=!1,this.onChange=new e.Signal,this.onError=new e.Signal,this.boundOnChangeHandler=this.onChangeHandler.bind(this),this.boundOnErrorHandler=this.onErrorHandler.bind(this);var i=t.device;this.pointerLockElement=i.pointerLockElement,this.pointerlockchange=i.pointerlockchange,this.pointerlockerror=i.pointerlockerror},e.PointerLock.prototype.start=function(){return!(!this.game.device.pointerLock||this.active)&&(this.element.requestPointerLock||(this.element.requestPointerLock=this.element.mozRequestPointerLock||this.element.webkitRequestPointerLock),document.exitPointerLock||(document.exitPointerLock=document.mozExitPointerLock||document.webkitExitPointerLock),document.addEventListener(this.pointerlockchange,this.boundOnChangeHandler,!0),document.addEventListener(this.pointerlockerror,this.boundOnErrorHandler,!0),this.active=!0,!0)},e.PointerLock.prototype.stop=function(){this.active&&(document.removeEventListener(this.pointerlockchange,this.boundOnChangeHandler,!0),document.removeEventListener(this.pointerlockerror,this.boundOnErrorHandler,!0),this.active=!1)},e.PointerLock.prototype.request=function(){this.active&&!this.locked&&this.element.requestPointerLock()},e.PointerLock.prototype.exit=function(){document.exitPointerLock()},e.PointerLock.prototype.onChangeHandler=function(t){this.locked=document[this.pointerLockElement]===this.element,this.onChange.dispatch(this.locked,t)},e.PointerLock.prototype.onErrorHandler=function(t){this.onError.dispatch(t)},e.Gamepad=function(t){this.game=t,this._gamepadIndexMap={},this._rawPads=[],this._active=!1,this.enabled=!0,this._gamepadSupportAvailable=!!navigator.webkitGetGamepads||!!navigator.webkitGamepads||-1!==navigator.userAgent.indexOf("Firefox/")||!!navigator.getGamepads,this._prevRawGamepadTypes=[],this._prevTimestamps=[],this.callbackContext=this,this.onConnectCallback=null,this.onDisconnectCallback=null,this.onDownCallback=null,this.onUpCallback=null,this.onAxisCallback=null,this.onFloatCallback=null,this._ongamepadconnected=null,this._gamepaddisconnected=null,this._gamepads=[new e.SinglePad(t,this),new e.SinglePad(t,this),new e.SinglePad(t,this),new e.SinglePad(t,this)]},e.Gamepad.prototype={addCallbacks:function(t,e){void 0!==e&&(this.onConnectCallback="function"==typeof e.onConnect?e.onConnect:this.onConnectCallback,this.onDisconnectCallback="function"==typeof e.onDisconnect?e.onDisconnect:this.onDisconnectCallback,this.onDownCallback="function"==typeof e.onDown?e.onDown:this.onDownCallback,this.onUpCallback="function"==typeof e.onUp?e.onUp:this.onUpCallback,this.onAxisCallback="function"==typeof e.onAxis?e.onAxis:this.onAxisCallback,this.onFloatCallback="function"==typeof e.onFloat?e.onFloat:this.onFloatCallback,this.callbackContext=t)},start:function(){if(!this._active){this._active=!0;var t=this;this._onGamepadConnected=function(e){return t.onGamepadConnected(e)},this._onGamepadDisconnected=function(e){return t.onGamepadDisconnected(e)},window.addEventListener("gamepadconnected",this._onGamepadConnected,!1),window.addEventListener("gamepaddisconnected",this._onGamepadDisconnected,!1)}},onGamepadConnected:function(t){var e=t.gamepad;this._rawPads.push(e),this._gamepads[e.index].connect(e)},onGamepadDisconnected:function(t){var e=t.gamepad;for(var i in this._rawPads)this._rawPads[i].index===e.index&&this._rawPads.splice(i,1);this._gamepads[e.index].disconnect()},update:function(){this._pollGamepads(),this.pad1.pollStatus(),this.pad2.pollStatus(),this.pad3.pollStatus(),this.pad4.pollStatus()},_pollGamepads:function(){if(this._active){if(navigator.getGamepads)t=navigator.getGamepads();else if(navigator.webkitGetGamepads)t=navigator.webkitGetGamepads();else if(navigator.webkitGamepads)var t=navigator.webkitGamepads();if(t){this._rawPads=[];for(var e=!1,i=0;i<t.length&&(typeof t[i]!==this._prevRawGamepadTypes[i]&&(e=!0,this._prevRawGamepadTypes[i]=typeof t[i]),t[i]&&this._rawPads.push(t[i]),3!==i);i++);for(var s=0;s<this._gamepads.length;s++)this._gamepads[s]._rawPad=this._rawPads[s];if(e){for(var n,r={rawIndices:{},padIndices:{}},o=0;o<this._gamepads.length;o++)if((n=this._gamepads[o]).connected)for(var a=0;a<this._rawPads.length;a++)this._rawPads[a].index===n.index&&(r.rawIndices[n.index]=!0,r.padIndices[o]=!0);for(var h=0;h<this._gamepads.length;h++)if(n=this._gamepads[h],!r.padIndices[h]){this._rawPads.length<1&&n.disconnect();for(var l=0;l<this._rawPads.length&&!r.padIndices[h];l++){var c=this._rawPads[l];if(c){if(r.rawIndices[c.index]){n.disconnect();continue}n.connect(c),r.rawIndices[c.index]=!0,r.padIndices[h]=!0}else n.disconnect()}}}}}},setDeadZones:function(t){for(var e=0;e<this._gamepads.length;e++)this._gamepads[e].deadZone=t},stop:function(){this._active=!1,window.removeEventListener("gamepadconnected",this._onGamepadConnected),window.removeEventListener("gamepaddisconnected",this._onGamepadDisconnected)},reset:function(){this.update();for(var t=0;t<this._gamepads.length;t++)this._gamepads[t].reset()},justPressed:function(t,e){for(var i=0;i<this._gamepads.length;i++)if(!0===this._gamepads[i].justPressed(t,e))return!0;return!1},justReleased:function(t,e){for(var i=0;i<this._gamepads.length;i++)if(!0===this._gamepads[i].justReleased(t,e))return!0;return!1},isDown:function(t){for(var e=0;e<this._gamepads.length;e++)if(!0===this._gamepads[e].isDown(t))return!0;return!1},destroy:function(){this.stop();for(var t=0;t<this._gamepads.length;t++)this._gamepads[t].destroy()}},e.Gamepad.prototype.constructor=e.Gamepad,Object.defineProperty(e.Gamepad.prototype,"active",{get:function(){return this._active}}),Object.defineProperty(e.Gamepad.prototype,"supported",{get:function(){return this._gamepadSupportAvailable}}),Object.defineProperty(e.Gamepad.prototype,"padsConnected",{get:function(){return this._rawPads.length}}),Object.defineProperty(e.Gamepad.prototype,"pad1",{get:function(){return this._gamepads[0]}}),Object.defineProperty(e.Gamepad.prototype,"pad2",{get:function(){return this._gamepads[1]}}),Object.defineProperty(e.Gamepad.prototype,"pad3",{get:function(){return this._gamepads[2]}}),Object.defineProperty(e.Gamepad.prototype,"pad4",{get:function(){return this._gamepads[3]}}),e.Gamepad.BUTTON_0=0,e.Gamepad.BUTTON_1=1,e.Gamepad.BUTTON_2=2,e.Gamepad.BUTTON_3=3,e.Gamepad.BUTTON_4=4,e.Gamepad.BUTTON_5=5,e.Gamepad.BUTTON_6=6,e.Gamepad.BUTTON_7=7,e.Gamepad.BUTTON_8=8,e.Gamepad.BUTTON_9=9,e.Gamepad.BUTTON_10=10,e.Gamepad.BUTTON_11=11,e.Gamepad.BUTTON_12=12,e.Gamepad.BUTTON_13=13,e.Gamepad.BUTTON_14=14,e.Gamepad.BUTTON_15=15,e.Gamepad.AXIS_0=0,e.Gamepad.AXIS_1=1,e.Gamepad.AXIS_2=2,e.Gamepad.AXIS_3=3,e.Gamepad.AXIS_4=4,e.Gamepad.AXIS_5=5,e.Gamepad.AXIS_6=6,e.Gamepad.AXIS_7=7,e.Gamepad.AXIS_8=8,e.Gamepad.AXIS_9=9,e.Gamepad.XBOX360_A=0,e.Gamepad.XBOX360_B=1,e.Gamepad.XBOX360_X=2,e.Gamepad.XBOX360_Y=3,e.Gamepad.XBOX360_LEFT_BUMPER=4,e.Gamepad.XBOX360_RIGHT_BUMPER=5,e.Gamepad.XBOX360_LEFT_TRIGGER=6,e.Gamepad.XBOX360_RIGHT_TRIGGER=7,e.Gamepad.XBOX360_BACK=8,e.Gamepad.XBOX360_START=9,e.Gamepad.XBOX360_STICK_LEFT_BUTTON=10,e.Gamepad.XBOX360_STICK_RIGHT_BUTTON=11,e.Gamepad.XBOX360_DPAD_LEFT=14,e.Gamepad.XBOX360_DPAD_RIGHT=15,e.Gamepad.XBOX360_DPAD_UP=12,e.Gamepad.XBOX360_DPAD_DOWN=13,e.Gamepad.XBOX360_STICK_LEFT_X=0,e.Gamepad.XBOX360_STICK_LEFT_Y=1,e.Gamepad.XBOX360_STICK_RIGHT_X=2,e.Gamepad.XBOX360_STICK_RIGHT_Y=3,e.Gamepad.PS3XC_X=0,e.Gamepad.PS3XC_CIRCLE=1,e.Gamepad.PS3XC_SQUARE=2,e.Gamepad.PS3XC_TRIANGLE=3,e.Gamepad.PS3XC_L1=4,e.Gamepad.PS3XC_R1=5,e.Gamepad.PS3XC_L2=6,e.Gamepad.PS3XC_R2=7,e.Gamepad.PS3XC_SELECT=8,e.Gamepad.PS3XC_START=9,e.Gamepad.PS3XC_STICK_LEFT_BUTTON=10,e.Gamepad.PS3XC_STICK_RIGHT_BUTTON=11,e.Gamepad.PS3XC_DPAD_UP=12,e.Gamepad.PS3XC_DPAD_DOWN=13,e.Gamepad.PS3XC_DPAD_LEFT=14,e.Gamepad.PS3XC_DPAD_RIGHT=15,e.Gamepad.PS3XC_STICK_LEFT_X=0,e.Gamepad.PS3XC_STICK_LEFT_Y=1,e.Gamepad.PS3XC_STICK_RIGHT_X=2,e.Gamepad.PS3XC_STICK_RIGHT_Y=3,e.SinglePad=function(t,e){this.game=t,this.index=null,this.connected=!1,this.callbackContext=this,this.onConnectCallback=null,this.onDisconnectCallback=null,this.onDownCallback=null,this.onUpCallback=null,this.onAxisCallback=null,this.onFloatCallback=null,this.deadZone=.26,this._padParent=e,this._rawPad=null,this._prevTimestamp=null,this._buttons=[],this._buttonsLen=0,this._axes=[],this._axesLen=0},e.SinglePad.prototype={addCallbacks:function(t,e){void 0!==e&&(this.onConnectCallback="function"==typeof e.onConnect?e.onConnect:this.onConnectCallback,this.onDisconnectCallback="function"==typeof e.onDisconnect?e.onDisconnect:this.onDisconnectCallback,this.onDownCallback="function"==typeof e.onDown?e.onDown:this.onDownCallback,this.onUpCallback="function"==typeof e.onUp?e.onUp:this.onUpCallback,this.onAxisCallback="function"==typeof e.onAxis?e.onAxis:this.onAxisCallback,this.onFloatCallback="function"==typeof e.onFloat?e.onFloat:this.onFloatCallback,this.callbackContext=t)},getButton:function(t){return this._buttons[t]?this._buttons[t]:null},pollStatus:function(){if(this.connected&&this.game.input.enabled&&this.game.input.gamepad.enabled&&this._rawPad&&(!this._rawPad.timestamp||this._rawPad.timestamp!==this._prevTimestamp)){for(var t=0;t<this._buttonsLen;t++){var e=isNaN(this._rawPad.buttons[t])?this._rawPad.buttons[t].value:this._rawPad.buttons[t];e!==this._buttons[t].value&&(1===e?this.processButtonDown(t,e):0===e?this.processButtonUp(t,e):this.processButtonFloat(t,e))}for(var i=0;i<this._axesLen;i++){var s=this._rawPad.axes[i];s>0&&s>this.deadZone||s<0&&s<-this.deadZone?this.processAxisChange(i,s):this.processAxisChange(i,0)}this._prevTimestamp=this._rawPad.timestamp}},connect:function(t){var i=!this.connected;this.connected=!0,this.index=t.index,this._rawPad=t,this._buttons=[],this._buttonsLen=t.buttons.length,this._axes=[],this._axesLen=t.axes.length;for(var s=0;s<this._axesLen;s++)this._axes[s]=t.axes[s];for(var n in t.buttons)n=parseInt(n,10),this._buttons[n]=new e.DeviceButton(this,n);i&&this._padParent.onConnectCallback&&this._padParent.onConnectCallback.call(this._padParent.callbackContext,this.index),i&&this.onConnectCallback&&this.onConnectCallback.call(this.callbackContext)},disconnect:function(){var t=this.connected,e=this.index;this.connected=!1,this.index=null,this._rawPad=void 0;for(var i=0;i<this._buttonsLen;i++)this._buttons[i].destroy();this._buttons=[],this._buttonsLen=0,this._axes=[],this._axesLen=0,t&&this._padParent.onDisconnectCallback&&this._padParent.onDisconnectCallback.call(this._padParent.callbackContext,e),t&&this.onDisconnectCallback&&this.onDisconnectCallback.call(this.callbackContext)},destroy:function(){this._rawPad=void 0;for(var t=0;t<this._buttonsLen;t++)this._buttons[t].destroy();this._buttons=[],this._buttonsLen=0,this._axes=[],this._axesLen=0,this.onConnectCallback=null,this.onDisconnectCallback=null,this.onDownCallback=null,this.onUpCallback=null,this.onAxisCallback=null,this.onFloatCallback=null},processAxisChange:function(t,e){this._axes[t]!==e&&(this._axes[t]=e,this._padParent.onAxisCallback&&this._padParent.onAxisCallback.call(this._padParent.callbackContext,this,t,e),this.onAxisCallback&&this.onAxisCallback.call(this.callbackContext,this,t,e))},processButtonDown:function(t,e){this._buttons[t]&&this._buttons[t].start(null,e),this._padParent.onDownCallback&&this._padParent.onDownCallback.call(this._padParent.callbackContext,t,e,this.index),this.onDownCallback&&this.onDownCallback.call(this.callbackContext,t,e)},processButtonUp:function(t,e){this._padParent.onUpCallback&&this._padParent.onUpCallback.call(this._padParent.callbackContext,t,e,this.index),this.onUpCallback&&this.onUpCallback.call(this.callbackContext,t,e),this._buttons[t]&&this._buttons[t].stop(null,e)},processButtonFloat:function(t,e){this._padParent.onFloatCallback&&this._padParent.onFloatCallback.call(this._padParent.callbackContext,t,e,this.index),this.onFloatCallback&&this.onFloatCallback.call(this.callbackContext,t,e),this._buttons[t]&&this._buttons[t].padFloat(e)},axis:function(t){return!!this._axes[t]&&this._axes[t]},isDown:function(t){return!!this._buttons[t]&&this._buttons[t].isDown},isUp:function(t){return!!this._buttons[t]&&this._buttons[t].isUp},justReleased:function(t,e){if(this._buttons[t])return this._buttons[t].justReleased(e)},justPressed:function(t,e){if(this._buttons[t])return this._buttons[t].justPressed(e)},buttonValue:function(t){return this._buttons[t]?this._buttons[t].value:null},reset:function(){for(var t=0;t<this._axes.length;t++)this._axes[t]=0}},e.SinglePad.prototype.constructor=e.SinglePad,e.Key=function(t,i){this.game=t,this._enabled=!0,this.event=null,this.isDown=!1,this.isUp=!0,this.altKey=!1,this.ctrlKey=!1,this.shiftKey=!1,this.timeDown=0,this.duration=0,this.timeUp=-2500,this.durationUp=-2500,this.repeats=0,this.keyCode=i,this.onDown=new e.Signal,this.onHoldCallback=null,this.onHoldContext=null,this.onUp=new e.Signal,this._justDown=!1,this._justUp=!1},e.Key.prototype={update:function(){this._enabled&&(this.isDown?(this.duration=this.game.time.time-this.timeDown,this.repeats++,this.onHoldCallback&&this.onHoldCallback.call(this.onHoldContext,this)):this.durationUp=this.game.time.time-this.timeUp)},processKeyDown:function(t){this._enabled&&(this.event=t,this.isDown||(this.altKey=t.altKey,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.isDown=!0,this.isUp=!1,this.timeDown=this.game.time.time,this.duration=0,this.durationUp=this.game.time.time-this.timeUp,this.repeats=0,this._justDown=!0,this.onDown.dispatch(this)))},processKeyUp:function(t){this._enabled&&(this.event=t,this.isUp||(this.isDown=!1,this.isUp=!0,this.timeUp=this.game.time.time,this.duration=this.game.time.time-this.timeDown,this.durationUp=0,this._justUp=!0,this.onUp.dispatch(this)))},reset:function(t){void 0===t&&(t=!0),this.isDown=!1,this.isUp=!0,this.timeUp=this.game.time.time,this.duration=0,this.durationUp=-2500,this._enabled=!0,this._justDown=!1,this._justUp=!1,t&&(this.onDown.removeAll(),this.onUp.removeAll(),this.onHoldCallback=null,this.onHoldContext=null)},downDuration:function(t){return void 0===t&&(t=50),this.isDown&&this.duration<t},upDuration:function(t){return void 0===t&&(t=50),!this.isDown&&this.game.time.time-this.timeUp<t},justPressed:function(){return this.isDown&&0===this.duration},justReleased:function(){return!this.isDown&&0===this.durationUp}},Object.defineProperty(e.Key.prototype,"justDown",{get:function(){var t=this._justDown;return this._justDown=!1,t}}),Object.defineProperty(e.Key.prototype,"justUp",{get:function(){var t=this._justUp;return this._justUp=!1,t}}),Object.defineProperty(e.Key.prototype,"enabled",{get:function(){return this._enabled},set:function(t){(t=!!t)!==this._enabled&&(t||this.reset(!1),this._enabled=t)}}),e.Key.prototype.constructor=e.Key,e.Keyboard=function(t){this.game=t,this.active=!1,this.enabled=!0,this.event=null,this.pressEvent=null,this.callbackContext=this,this.onDownCallback=null,this.onPressCallback=null,this.onUpCallback=null,this._keys=[],this._capture=[],this._onKeyDown=null,this._onKeyPress=null,this._onKeyUp=null,this._i=0,this._k=0},e.Keyboard.prototype={addCallbacks:function(t,e,i,s){this.callbackContext=t,void 0!==e&&null!==e&&(this.onDownCallback=e),void 0!==i&&null!==i&&(this.onUpCallback=i),void 0!==s&&null!==s&&(this.onPressCallback=s)},removeCallbacks:function(){this.callbackContext=this,this.onDownCallback=null,this.onUpCallback=null,this.onPressCallback=null},addKey:function(t){return this._keys[t]||(this._keys[t]=new e.Key(this.game,t),this.addKeyCapture(t)),this._keys[t]},addKeys:function(t){var e={};for(var i in t)e[i]=this.addKey(t[i]);return e},removeKey:function(t){this._keys[t]&&(this._keys[t]=null,this.removeKeyCapture(t))},createCursorKeys:function(){return this.addKeys({up:e.KeyCode.UP,down:e.KeyCode.DOWN,left:e.KeyCode.LEFT,right:e.KeyCode.RIGHT})},start:function(){if(this.game.device.cocoonJS)return!1;if(this.active)return!1;var t=this;return this._onKeyDown=function(e){return t.processKeyDown(e)},this._onKeyUp=function(e){return t.processKeyUp(e)},this._onKeyPress=function(e){return t.processKeyPress(e)},window.addEventListener("keydown",this._onKeyDown,!1),window.addEventListener("keyup",this._onKeyUp,!1),window.addEventListener("keypress",this._onKeyPress,!1),this.active=!0,!0},stop:function(){window.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("keyup",this._onKeyUp),window.removeEventListener("keypress",this._onKeyPress),this._onKeyDown=null,this._onKeyUp=null,this._onKeyPress=null,this.active=!1},destroy:function(){this.stop(),this.clearCaptures(),this._keys.length=0,this._i=0},addKeyCapture:function(t){if("object"==typeof t)for(var e in t)this._capture[t[e]]=!0;else this._capture[t]=!0},removeKeyCapture:function(t){delete this._capture[t]},clearCaptures:function(){this._capture={}},update:function(){for(this._i=this._keys.length;this._i--;)this._keys[this._i]&&this._keys[this._i].update()},processKeyDown:function(t){if(this.event=t,this.game.input.enabled&&this.enabled){var i=t.keyCode;this._capture[i]&&t.preventDefault(),this._keys[i]||(this._keys[i]=new e.Key(this.game,i)),this._keys[i].processKeyDown(t),this._k=i,this.onDownCallback&&this.onDownCallback.call(this.callbackContext,t)}},processKeyPress:function(t){this.pressEvent=t,this.game.input.enabled&&this.enabled&&this.onPressCallback&&this.onPressCallback.call(this.callbackContext,String.fromCharCode(t.charCode),t)},processKeyUp:function(t){if(this.event=t,this.game.input.enabled&&this.enabled){var i=t.keyCode;this._capture[i]&&t.preventDefault(),this._keys[i]||(this._keys[i]=new e.Key(this.game,i)),this._keys[i].processKeyUp(t),this.onUpCallback&&this.onUpCallback.call(this.callbackContext,t)}},reset:function(t){void 0===t&&(t=!0),this.event=null;for(var e=this._keys.length;e--;)this._keys[e]&&this._keys[e].reset(t)},downDuration:function(t,e){return this._keys[t]?this._keys[t].downDuration(e):null},upDuration:function(t,e){return this._keys[t]?this._keys[t].upDuration(e):null},justPressed:function(t){return this._keys[t]?this._keys[t].justPressed():null},justReleased:function(t){return this._keys[t]?this._keys[t].justReleased():null},isDown:function(t){return this._keys[t]?this._keys[t].isDown:null}},Object.defineProperty(e.Keyboard.prototype,"lastChar",{get:function(){return this.event&&32===this.event.charCode?"":this.pressEvent?String.fromCharCode(this.pressEvent.charCode):null}}),Object.defineProperty(e.Keyboard.prototype,"lastKey",{get:function(){return this._keys[this._k]}}),e.Keyboard.prototype.constructor=e.Keyboard,e.KeyCode={A:"A".charCodeAt(0),B:"B".charCodeAt(0),C:"C".charCodeAt(0),D:"D".charCodeAt(0),E:"E".charCodeAt(0),F:"F".charCodeAt(0),G:"G".charCodeAt(0),H:"H".charCodeAt(0),I:"I".charCodeAt(0),J:"J".charCodeAt(0),K:"K".charCodeAt(0),L:"L".charCodeAt(0),M:"M".charCodeAt(0),N:"N".charCodeAt(0),O:"O".charCodeAt(0),P:"P".charCodeAt(0),Q:"Q".charCodeAt(0),R:"R".charCodeAt(0),S:"S".charCodeAt(0),T:"T".charCodeAt(0),U:"U".charCodeAt(0),V:"V".charCodeAt(0),W:"W".charCodeAt(0),X:"X".charCodeAt(0),Y:"Y".charCodeAt(0),Z:"Z".charCodeAt(0),ZERO:"0".charCodeAt(0),ONE:"1".charCodeAt(0),TWO:"2".charCodeAt(0),THREE:"3".charCodeAt(0),FOUR:"4".charCodeAt(0),FIVE:"5".charCodeAt(0),SIX:"6".charCodeAt(0),SEVEN:"7".charCodeAt(0),EIGHT:"8".charCodeAt(0),NINE:"9".charCodeAt(0),NUMPAD_0:96,NUMPAD_1:97,NUMPAD_2:98,NUMPAD_3:99,NUMPAD_4:100,NUMPAD_5:101,NUMPAD_6:102,NUMPAD_7:103,NUMPAD_8:104,NUMPAD_9:105,NUMPAD_MULTIPLY:106,NUMPAD_ADD:107,NUMPAD_ENTER:108,NUMPAD_SUBTRACT:109,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,F13:124,F14:125,F15:126,COLON:186,EQUALS:187,COMMA:188,UNDERSCORE:189,PERIOD:190,QUESTION_MARK:191,TILDE:192,OPEN_BRACKET:219,BACKWARD_SLASH:220,CLOSED_BRACKET:221,QUOTES:222,BACKSPACE:8,TAB:9,CLEAR:12,ENTER:13,SHIFT:16,CONTROL:17,ALT:18,CAPS_LOCK:20,ESC:27,SPACEBAR:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PLUS:43,MINUS:44,INSERT:45,DELETE:46,HELP:47,NUM_LOCK:144};for(var s in e.KeyCode)e.KeyCode.hasOwnProperty(s)&&!s.match(/[a-z]/)&&(e.Keyboard[s]=e.KeyCode[s]);e.Component=function(){},e.Component.Angle=function(){},e.Component.Angle.prototype={angle:{get:function(){return e.Math.wrapAngle(e.Math.radToDeg(this.rotation))},set:function(t){this.rotation=e.Math.degToRad(e.Math.wrapAngle(t))}}},e.Component.Animation=function(){},e.Component.Animation.prototype={play:function(t,e,i,s){if(this.animations)return this.animations.play(t,e,i,s)}},e.Component.AutoCull=function(){},e.Component.AutoCull.prototype={autoCull:!1,inCamera:{get:function(){return this.autoCull||this.checkWorldBounds||(this._bounds.copyFrom(this.getBounds()),this._bounds.x+=this.game.camera.view.x,this._bounds.y+=this.game.camera.view.y),this.game.world.camera.view.intersects(this._bounds)}}},e.Component.Bounds=function(){},e.Component.Bounds.prototype={offsetX:{get:function(){return this.anchor.x*this.width}},offsetY:{get:function(){return this.anchor.y*this.height}},centerX:{get:function(){return this.x-this.offsetX+.5*this.width},set:function(t){this.x=t+this.offsetX-.5*this.width}},centerY:{get:function(){return this.y-this.offsetY+.5*this.height},set:function(t){this.y=t+this.offsetY-.5*this.height}},left:{get:function(){return this.x-this.offsetX},set:function(t){this.x=t+this.offsetX}},right:{get:function(){return this.x+this.width-this.offsetX},set:function(t){this.x=t-this.width+this.offsetX}},top:{get:function(){return this.y-this.offsetY},set:function(t){this.y=t+this.offsetY}},bottom:{get:function(){return this.y+this.height-this.offsetY},set:function(t){this.y=t-this.height+this.offsetY}},alignIn:function(t,i,s,n){switch(void 0===s&&(s=0),void 0===n&&(n=0),i){default:case e.TOP_LEFT:this.left=t.left-s,this.top=t.top-n;break;case e.TOP_CENTER:this.centerX=t.centerX+s,this.top=t.top-n;break;case e.TOP_RIGHT:this.right=t.right+s,this.top=t.top-n;break;case e.LEFT_CENTER:this.left=t.left-s,this.centerY=t.centerY+n;break;case e.CENTER:this.centerX=t.centerX+s,this.centerY=t.centerY+n;break;case e.RIGHT_CENTER:this.right=t.right+s,this.centerY=t.centerY+n;break;case e.BOTTOM_LEFT:this.left=t.left-s,this.bottom=t.bottom+n;break;case e.BOTTOM_CENTER:this.centerX=t.centerX+s,this.bottom=t.bottom+n;break;case e.BOTTOM_RIGHT:this.right=t.right+s,this.bottom=t.bottom+n}return this},alignTo:function(t,i,s,n){switch(void 0===s&&(s=0),void 0===n&&(n=0),i){default:case e.TOP_LEFT:this.left=t.left-s,this.bottom=t.top-n;break;case e.TOP_CENTER:this.centerX=t.centerX+s,this.bottom=t.top-n;break;case e.TOP_RIGHT:this.right=t.right+s,this.bottom=t.top-n;break;case e.LEFT_TOP:this.right=t.left-s,this.top=t.top-n;break;case e.LEFT_CENTER:this.right=t.left-s,this.centerY=t.centerY+n;break;case e.LEFT_BOTTOM:this.right=t.left-s,this.bottom=t.bottom+n;break;case e.RIGHT_TOP:this.left=t.right+s,this.top=t.top-n;break;case e.RIGHT_CENTER:this.left=t.right+s,this.centerY=t.centerY+n;break;case e.RIGHT_BOTTOM:this.left=t.right+s,this.bottom=t.bottom+n;break;case e.BOTTOM_LEFT:this.left=t.left-s,this.top=t.bottom+n;break;case e.BOTTOM_CENTER:this.centerX=t.centerX+s,this.top=t.bottom+n;break;case e.BOTTOM_RIGHT:this.right=t.right+s,this.top=t.bottom+n}return this}},e.Group.prototype.alignIn=e.Component.Bounds.prototype.alignIn,e.Group.prototype.alignTo=e.Component.Bounds.prototype.alignTo,e.Component.BringToTop=function(){},e.Component.BringToTop.prototype.bringToTop=function(){return this.parent&&this.parent.bringChildToTop&&this.parent.bringChildToTop(this),this},e.Component.BringToTop.prototype.sendToBack=function(){return this.parent&&this.parent.sendChildToBack&&this.parent.sendChildToBack(this),this},e.Component.BringToTop.prototype.moveUp=function(){return this.parent&&this.parent.moveUp(this),this},e.Component.BringToTop.prototype.moveDown=function(){return this.parent&&this.parent.moveDown(this),this},e.Component.Core=function(){},e.Component.Core.skipTypeChecks=!1,e.Component.Core.install=function(t){e.Utils.mixinPrototype(this,e.Component.Core.prototype),this.components={};for(var i=0;i<t.length;i++){var s=t[i],n=!1;"Destroy"===s&&(n=!0),e.Utils.mixinPrototype(this,e.Component[s].prototype,n),this.components[s]=!0}},e.Component.Core.init=function(t,i,s,n,r){if(!e.Component.Core.skipTypeChecks){if(!(t instanceof e.Game))throw new Error("The value passed as the `game` argument ("+t+") is not an instance of Phaser.Game.");"number"!=typeof i&&(console.warn("The `x` argument value (%s) should be a number.",i),i=0),"number"!=typeof s&&(console.warn("The `y` argument value (%s) should be a number.",s),s=0)}this.game=t,this.key=n,this.data={},this.position.set(i,s),this.world=new e.Point(i,s),this.previousPosition=new e.Point(i,s),this.events=new e.Events(this),this._bounds=new e.Rectangle,this.components.PhysicsBody&&(this.body=this.body),this.components.Animation&&(this.animations=new e.AnimationManager(this)),this.components.LoadTexture&&null!==n&&this.loadTexture(n,r),this.components.FixedToCamera&&(this.cameraOffset=new e.Point(i,s))},e.Component.Core.preUpdate=function(){return this.pendingDestroy?(this.destroy(),!1):(this.previousPosition.set(this.world.x,this.world.y),this.previousRotation=this.rotation,this.exists&&this.parent.exists?(this.world.setTo(this.game.camera.x+this.worldTransform.tx,this.game.camera.y+this.worldTransform.ty),this.visible&&(this.renderOrderID=this.game.stage.currentRenderOrderID++),this.animations&&this.animations.update(),this.body&&this.body.preUpdate(),this.preUpdateChildren(),!0):(this.renderOrderID=-1,!1))},e.Component.Core.prototype={game:null,name:"",data:{},components:{},z:0,events:void 0,animations:void 0,key:"",world:null,debug:!1,previousPosition:null,previousRotation:0,renderOrderID:0,fresh:!0,pendingDestroy:!1,_bounds:null,_exists:!0,exists:{get:function(){return this._exists},set:function(t){t?(this._exists=!0,this.body&&this.body.type===e.Physics.P2JS&&this.body.addToWorld(),this.visible=!0):(this._exists=!1,this.body&&this.body.type===e.Physics.P2JS&&this.body.removeFromWorld(),this.visible=!1)}},preUpdateChildren:function(){for(var t=0;t<this.children.length;){var e=this.children[t];e.preUpdate(),this===e.parent&&t++}},update:function(){},postUpdate:function(){this.customRender&&this.key.render(),this.components.PhysicsBody&&e.Component.PhysicsBody.postUpdate.call(this),this.components.FixedToCamera&&e.Component.FixedToCamera.postUpdate.call(this);for(var t=0;t<this.children.length;t++)this.children[t].postUpdate()}},e.Component.Crop=function(){},e.Component.Crop.prototype={cropRect:null,_crop:null,crop:function(t,i){void 0===i&&(i=!1),t?(i&&null!==this.cropRect?this.cropRect.setTo(t.x,t.y,t.width,t.height):i&&null===this.cropRect?this.cropRect=new e.Rectangle(t.x,t.y,t.width,t.height):this.cropRect=t,this.updateCrop()):(this._crop=null,this.cropRect=null,this.resetFrame())},updateCrop:function(){if(this.cropRect){var t=this.texture.crop.x,i=this.texture.crop.y,s=this.texture.crop.width,n=this.texture.crop.height;this._crop=e.Rectangle.clone(this.cropRect,this._crop),this._crop.x+=this._frame.x,this._crop.y+=this._frame.y;var r=Math.max(this._frame.x,this._crop.x),o=Math.max(this._frame.y,this._crop.y),a=Math.min(this._frame.right,this._crop.right)-r,h=Math.min(this._frame.bottom,this._crop.bottom)-o;this.texture.crop.x=r,this.texture.crop.y=o,this.texture.crop.width=a,this.texture.crop.height=h,this.texture.frame.width=Math.min(a,this.cropRect.width),this.texture.frame.height=Math.min(h,this.cropRect.height),this.texture.width=this.texture.frame.width,this.texture.height=this.texture.frame.height,this.texture._updateUvs(),16777215===this.tint||t===r&&i===o&&s===a&&n===h||(this.texture.requiresReTint=!0)}}},e.Component.Delta=function(){},e.Component.Delta.prototype={deltaX:{get:function(){return this.world.x-this.previousPosition.x}},deltaY:{get:function(){return this.world.y-this.previousPosition.y}},deltaZ:{get:function(){return this.rotation-this.previousRotation}}},e.Component.Destroy=function(){},e.Component.Destroy.prototype={destroyPhase:!1,destroy:function(t,i){if(null!==this.game&&!this.destroyPhase){void 0===t&&(t=!0),void 0===i&&(i=!1),this.destroyPhase=!0,this.events&&this.events.onDestroy$dispatch(this),this.parent&&(this.parent instanceof e.Group?this.parent.remove(this):this.parent.removeChild(this)),this.input&&this.input.destroy(),this.animations&&this.animations.destroy(),this.body&&this.body.destroy(),this.events&&this.events.destroy(),this.game.tweens.removeFrom(this);var s=this.children.length;if(t)for(;s--;)this.children[s].destroy(t);else for(;s--;)this.removeChild(this.children[s]);this._crop&&(this._crop=null,this.cropRect=null),this._frame&&(this._frame=null),e.Video&&this.key instanceof e.Video&&this.key.onChangeSource.remove(this.resizeFrame,this),e.BitmapText&&this._glyphs&&(this._glyphs=[]),this.alive=!1,this.exists=!1,this.visible=!1,this.filters=null,this.mask=null,this.game=null,this.data={},this.renderable=!1,this.transformCallback&&(this.transformCallback=null,this.transformCallbackContext=null),this.hitArea=null,this.parent=null,this.stage=null,this.worldTransform=null,this.filterArea=null,this._bounds=null,this._currentBounds=null,this._mask=null,this._destroyCachedSprite(),this._destroyTintedTexture(),i&&this.texture.destroy(!0),this.destroyPhase=!1,this.pendingDestroy=!1}}},e.Events=function(t){this.parent=t},e.Events.prototype={destroy:function(){this._parent=null,this._onDestroy&&this._onDestroy.dispose(),this._onAddedToGroup&&this._onAddedToGroup.dispose(),this._onRemovedFromGroup&&this._onRemovedFromGroup.dispose(),this._onKilled&&this._onKilled.dispose(),this._onRevived&&this._onRevived.dispose(),this._onEnterBounds&&this._onEnterBounds.dispose(),this._onOutOfBounds&&this._onOutOfBounds.dispose(),this._onInputOver&&this._onInputOver.dispose(),this._onInputOut&&this._onInputOut.dispose(),this._onInputDown&&this._onInputDown.dispose(),this._onInputUp&&this._onInputUp.dispose(),this._onDragStart&&this._onDragStart.dispose(),this._onDragUpdate&&this._onDragUpdate.dispose(),this._onDragStop&&this._onDragStop.dispose(),this._onAnimationStart&&this._onAnimationStart.dispose(),this._onAnimationComplete&&this._onAnimationComplete.dispose(),this._onAnimationLoop&&this._onAnimationLoop.dispose()},onAddedToGroup:null,onRemovedFromGroup:null,onDestroy:null,onKilled:null,onRevived:null,onOutOfBounds:null,onEnterBounds:null,onInputOver:null,onInputOut:null,onInputDown:null,onInputUp:null,onDragStart:null,onDragUpdate:null,onDragStop:null,onAnimationStart:null,onAnimationComplete:null,onAnimationLoop:null},e.Events.prototype.constructor=e.Events;for(var n in e.Events.prototype)e.Events.prototype.hasOwnProperty(n)&&0===n.indexOf("on")&&null===e.Events.prototype[n]&&function(t,i){"use strict";Object.defineProperty(e.Events.prototype,t,{get:function(){return this[i]||(this[i]=new e.Signal)}}),e.Events.prototype[t+"$dispatch"]=function(){return this[i]?this[i].dispatch.apply(this[i],arguments):null}}(n,"_"+n);e.Component.FixedToCamera=function(){},e.Component.FixedToCamera.postUpdate=function(){this.fixedToCamera&&(this.position.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.position.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y)},e.Component.FixedToCamera.prototype={_fixedToCamera:!1,fixedToCamera:{get:function(){return this._fixedToCamera},set:function(t){t?(this._fixedToCamera=!0,this.cameraOffset.set(this.x,this.y)):this._fixedToCamera=!1}},cameraOffset:new e.Point},e.Component.Health=function(){},e.Component.Health.prototype={health:1,maxHealth:100,damage:function(t){return this.alive&&(this.health-=t,this.health<=0&&this.kill()),this},setHealth:function(t){return this.health=t,this.health>this.maxHealth&&(this.health=this.maxHealth),this},heal:function(t){return this.alive&&(this.health+=t,this.health>this.maxHealth&&(this.health=this.maxHealth)),this}},e.Component.InCamera=function(){},e.Component.InCamera.prototype={inCamera:{get:function(){return this.game.world.camera.view.intersects(this._bounds)}}},e.Component.InputEnabled=function(){},e.Component.InputEnabled.prototype={input:null,inputEnabled:{get:function(){return this.input&&this.input.enabled},set:function(t){t?null===this.input?(this.input=new e.InputHandler(this),this.input.start()):this.input&&!this.input.enabled&&this.input.start():this.input&&this.input.enabled&&this.input.stop()}}},e.Component.InWorld=function(){},e.Component.InWorld.preUpdate=function(){if(this.pendingDestroy)return this.destroy(),!1;if(this.autoCull||this.checkWorldBounds){if(this._bounds.copyFrom(this.getBounds()),this._bounds.x+=this.game.camera.view.x,this._bounds.y+=this.game.camera.view.y,this.autoCull)if(this.game.world.camera.view.intersects(this._bounds))this.renderable=!0,this.game.world.camera.totalInView++;else if(this.renderable=!1,this.outOfCameraBoundsKill)return this.kill(),!1;if(this.checkWorldBounds)if(this._outOfBoundsFired&&this.game.world.bounds.intersects(this._bounds))this._outOfBoundsFired=!1,this.events.onEnterBounds$dispatch(this);else if(!this._outOfBoundsFired&&!this.game.world.bounds.intersects(this._bounds)&&(this._outOfBoundsFired=!0,this.events.onOutOfBounds$dispatch(this),this.outOfBoundsKill))return this.kill(),!1}return!0},e.Component.InWorld.prototype={checkWorldBounds:!1,outOfBoundsKill:!1,outOfCameraBoundsKill:!1,_outOfBoundsFired:!1,inWorld:{get:function(){return this.game.world.bounds.intersects(this.getBounds())}}},e.Component.LifeSpan=function(){},e.Component.LifeSpan.preUpdate=function(){return this.pendingDestroy?(this.destroy(),!1):!(this.lifespan>0&&(this.lifespan-=this.game.time.physicsElapsedMS,this.lifespan<=0))||(this.kill(),!1)},e.Component.LifeSpan.prototype={alive:!0,lifespan:0,revive:function(t){return void 0===t&&(t=100),this.alive=!0,this.exists=!0,this.visible=!0,"function"==typeof this.setHealth&&this.setHealth(t),this.events&&this.events.onRevived$dispatch(this),this},kill:function(){return this.alive=!1,this.exists=!1,this.visible=!1,this.events&&this.events.onKilled$dispatch(this),this}},e.Component.LoadTexture=function(){},e.Component.LoadTexture.prototype={customRender:!1,_frame:null,loadTexture:function(t,i,s){t===e.PENDING_ATLAS?(t=i,i=0):i=i||0,(s||void 0===s)&&this.animations&&this.animations.stop(),this.key=t,this.customRender=!1;var n=this.game.cache,r=!0,o=this.texture.baseTexture.scaleMode===PIXI.scaleModes.LINEAR;if(e.RenderTexture&&t instanceof e.RenderTexture)this.key=t.key,this.setTexture(t);else if(e.BitmapData&&t instanceof e.BitmapData)this.customRender=!0,this.setTexture(t.texture),r=n.hasFrameData(t.key,e.Cache.BITMAPDATA)?!this.animations.loadFrameData(n.getFrameData(t.key,e.Cache.BITMAPDATA),i):!this.animations.loadFrameData(t.frameData,0);else if(e.Video&&t instanceof e.Video){this.customRender=!0;var a=t.texture.valid;this.setTexture(t.texture),this.setFrame(t.texture.frame.clone()),t.onChangeSource.add(this.resizeFrame,this),this.texture.valid=a}else if(e.Tilemap&&t instanceof e.TilemapLayer)this.setTexture(PIXI.Texture.fromCanvas(t.canvas));else if(t instanceof PIXI.Texture)o=t.baseTexture.scaleMode===PIXI.scaleModes.LINEAR,this.setTexture(t);else{var h=n.getImage(t,!0);this.key=h.key,this.setTexture(new PIXI.Texture(h.base)),this.texture.baseTexture.skipRender="__default"===t,r=!this.animations.loadFrameData(h.frameData,i)}r&&(this._frame=e.Rectangle.clone(this.texture.frame)),o||(this.texture.baseTexture.scaleMode=1)},setFrame:function(t){this._frame=t,this.texture.frame.x=t.x,this.texture.frame.y=t.y,this.texture.frame.width=t.width,this.texture.frame.height=t.height,this.texture.crop.x=t.x,this.texture.crop.y=t.y,this.texture.crop.width=t.width,this.texture.crop.height=t.height,t.trimmed?(this.texture.trim?(this.texture.trim.x=t.spriteSourceSizeX,this.texture.trim.y=t.spriteSourceSizeY,this.texture.trim.width=t.sourceSizeW,this.texture.trim.height=t.sourceSizeH):this.texture.trim={x:t.spriteSourceSizeX,y:t.spriteSourceSizeY,width:t.sourceSizeW,height:t.sourceSizeH},this.texture.width=t.sourceSizeW,this.texture.height=t.sourceSizeH,this.texture.frame.width=t.sourceSizeW,this.texture.frame.height=t.sourceSizeH):!t.trimmed&&this.texture.trim&&(this.texture.trim=null),t.rotated&&(this.texture.rotated=!0),this.cropRect&&this.updateCrop(),this.texture.requiresReTint=!0,this.texture._updateUvs(),this.tilingTexture&&(this.refreshTexture=!0)},resizeFrame:function(t,e,i){this.texture.frame.resize(e,i),this.texture.setFrame(this.texture.frame)},resetFrame:function(){this._frame&&this.setFrame(this._frame)},frame:{get:function(){return this.animations.frame},set:function(t){this.animations.frame=t}},frameName:{get:function(){return this.animations.frameName},set:function(t){this.animations.frameName=t}}},e.Component.Overlap=function(){},e.Component.Overlap.prototype={overlap:function(t){return e.Rectangle.intersects(this.getBounds(),t.getBounds())}},e.Component.PhysicsBody=function(){},e.Component.PhysicsBody.preUpdate=function(){return this.pendingDestroy?(this.destroy(),!1):this.fresh&&this.exists?(this.world.setTo(this.parent.position.x+this.position.x,this.parent.position.y+this.position.y),this.worldTransform.tx=this.world.x,this.worldTransform.ty=this.world.y,this.previousPosition.set(this.world.x,this.world.y),this.previousRotation=this.rotation,this.body&&this.body.preUpdate(),this.fresh=!1,this.preUpdateChildren(),!1):(this.previousPosition.set(this.world.x,this.world.y),this.previousRotation=this.rotation,!(!this._exists||!this.parent.exists)||(this.renderOrderID=-1,!1))},e.Component.PhysicsBody.postUpdate=function(){this.exists&&this.body&&this.body.postUpdate()},e.Component.PhysicsBody.prototype={body:null,x:{get:function(){return this.position.x},set:function(t){this.position.x=t,this.body&&!this.body.dirty&&(this.body._reset=!0)}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t,this.body&&!this.body.dirty&&(this.body._reset=!0)}}},e.Component.Reset=function(){},e.Component.Reset.prototype.reset=function(t,e,i){return void 0===i&&(i=1),this.world.set(t,e),this.position.set(t,e),this.fresh=!0,this.exists=!0,this.visible=!0,this.renderable=!0,this.components.InWorld&&(this._outOfBoundsFired=!1),this.components.LifeSpan&&(this.alive=!0,this.health=i),this.components.PhysicsBody&&this.body&&this.body.reset(t,e,!1,!1),this},e.Component.ScaleMinMax=function(){},e.Component.ScaleMinMax.prototype={transformCallback:null,transformCallbackContext:this,scaleMin:null,scaleMax:null,checkTransform:function(t){this.scaleMin&&(t.a<this.scaleMin.x&&(t.a=this.scaleMin.x),t.d<this.scaleMin.y&&(t.d=this.scaleMin.y)),this.scaleMax&&(t.a>this.scaleMax.x&&(t.a=this.scaleMax.x),t.d>this.scaleMax.y&&(t.d=this.scaleMax.y))},setScaleMinMax:function(t,i,s,n){void 0===i?i=s=n=t:void 0===s&&(s=n=i,i=t),null===t?this.scaleMin=null:this.scaleMin?this.scaleMin.set(t,i):this.scaleMin=new e.Point(t,i),null===s?this.scaleMax=null:this.scaleMax?this.scaleMax.set(s,n):this.scaleMax=new e.Point(s,n),null===this.scaleMin?this.transformCallback=null:(this.transformCallback=this.checkTransform,this.transformCallbackContext=this)}},e.Component.Smoothed=function(){},e.Component.Smoothed.prototype={smoothed:{get:function(){return!this.texture.baseTexture.scaleMode},set:function(t){t?this.texture&&0!==this.texture.baseTexture.scaleMode&&(this.texture.baseTexture.scaleMode=0,this.texture.baseTexture.dirty()):this.texture&&1!==this.texture.baseTexture.scaleMode&&(this.texture.baseTexture.scaleMode=1,this.texture.baseTexture.dirty())}}},e.GameObjectFactory=function(t){this.game=t,this.world=this.game.world},e.GameObjectFactory.prototype={existing:function(t){return this.world.add(t)},weapon:function(t,i,s,n,r){var o=this.game.plugins.add(e.Weapon);return r&&(o.bulletClass=r),o.createBullets(t,i,s,n),o},image:function(t,i,s,n,r){return void 0===r&&(r=this.world),r.add(new e.Image(this.game,t,i,s,n))},sprite:function(t,i,s,n,r){return void 0===r&&(r=this.world),r.add(new e.Sprite(this.game,t,i,s,n))},creature:function(t,i,s,n,r,o,a){void 0===r&&(r=this.world);var h=new e.Creature(this.game,t,i,s,n,o,a);return r.add(h),h},tween:function(t){return this.game.tweens.create(t)},group:function(t,i,s,n,r){return new e.Group(this.game,t,i,s,n,r)},physicsGroup:function(t,i,s,n){return new e.Group(this.game,i,s,n,!0,t)},spriteBatch:function(t,i,s){return void 0===t&&(t=null),void 0===i&&(i="group"),void 0===s&&(s=!1),new e.SpriteBatch(this.game,t,i,s)},audio:function(t,e,i,s){return this.game.sound.add(t,e,i,s)},sound:function(t,e,i,s){return this.game.sound.add(t,e,i,s)},audioSprite:function(t){return this.game.sound.addSprite(t)},tileSprite:function(t,i,s,n,r,o,a){return void 0===a&&(a=this.world),a.add(new e.TileSprite(this.game,t,i,s,n,r,o))},rope:function(t,i,s,n,r,o){return void 0===o&&(o=this.world),o.add(new e.Rope(this.game,t,i,s,n,r))},text:function(t,i,s,n,r){return void 0===r&&(r=this.world),r.add(new e.Text(this.game,t,i,s,n))},button:function(t,i,s,n,r,o,a,h,l,c){return void 0===c&&(c=this.world),c.add(new e.Button(this.game,t,i,s,n,r,o,a,h,l))},graphics:function(t,i,s){return void 0===s&&(s=this.world),s.add(new e.Graphics(this.game,t,i))},emitter:function(t,i,s){return this.game.particles.add(new e.Particles.Arcade.Emitter(this.game,t,i,s))},retroFont:function(t,i,s,n,r,o,a,h,l){return new e.RetroFont(this.game,t,i,s,n,r,o,a,h,l)},bitmapText:function(t,i,s,n,r,o){return void 0===o&&(o=this.world),o.add(new e.BitmapText(this.game,t,i,s,n,r))},tilemap:function(t,i,s,n,r){return new e.Tilemap(this.game,t,i,s,n,r)},renderTexture:function(t,i,s,n){void 0!==s&&""!==s||(s=this.game.rnd.uuid()),void 0===n&&(n=!1);var r=new e.RenderTexture(this.game,t,i,s);return n&&this.game.cache.addRenderTexture(s,r),r},video:function(t,i){return new e.Video(this.game,t,i)},bitmapData:function(t,i,s,n){void 0===n&&(n=!1),void 0!==s&&""!==s||(s=this.game.rnd.uuid());var r=new e.BitmapData(this.game,s,t,i);return n&&this.game.cache.addBitmapData(s,r),r},filter:function(t){var i=Array.prototype.slice.call(arguments,1);return(t=new e.Filter[t](this.game)).init.apply(t,i),t},plugin:function(){return this.game.plugins.add.apply(this.game.plugins,arguments)}},e.GameObjectFactory.prototype.constructor=e.GameObjectFactory,e.GameObjectCreator=function(t){this.game=t,this.world=this.game.world},e.GameObjectCreator.prototype={image:function(t,i,s,n){return new e.Image(this.game,t,i,s,n)},sprite:function(t,i,s,n){return new e.Sprite(this.game,t,i,s,n)},tween:function(t){return new e.Tween(t,this.game,this.game.tweens)},group:function(t,i,s,n,r){return new e.Group(this.game,t||null,i,s,n,r)},spriteBatch:function(t,i,s){return void 0===i&&(i="group"),void 0===s&&(s=!1),new e.SpriteBatch(this.game,t,i,s)},audio:function(t,e,i,s){return this.game.sound.add(t,e,i,s)},audioSprite:function(t){return this.game.sound.addSprite(t)},sound:function(t,e,i,s){return this.game.sound.add(t,e,i,s)},tileSprite:function(t,i,s,n,r,o){return new e.TileSprite(this.game,t,i,s,n,r,o)},rope:function(t,i,s,n,r){return new e.Rope(this.game,t,i,s,n,r)},text:function(t,i,s,n){return new e.Text(this.game,t,i,s,n)},button:function(t,i,s,n,r,o,a,h,l){return new e.Button(this.game,t,i,s,n,r,o,a,h,l)},graphics:function(t,i){return new e.Graphics(this.game,t,i)},emitter:function(t,i,s){return new e.Particles.Arcade.Emitter(this.game,t,i,s)},retroFont:function(t,i,s,n,r,o,a,h,l){return new e.RetroFont(this.game,t,i,s,n,r,o,a,h,l)},bitmapText:function(t,i,s,n,r,o){return new e.BitmapText(this.game,t,i,s,n,r,o)},tilemap:function(t,i,s,n,r){return new e.Tilemap(this.game,t,i,s,n,r)},renderTexture:function(t,i,s,n){void 0!==s&&""!==s||(s=this.game.rnd.uuid()),void 0===n&&(n=!1);var r=new e.RenderTexture(this.game,t,i,s);return n&&this.game.cache.addRenderTexture(s,r),r},bitmapData:function(t,i,s,n){void 0===n&&(n=!1),void 0!==s&&""!==s||(s=this.game.rnd.uuid());var r=new e.BitmapData(this.game,s,t,i);return n&&this.game.cache.addBitmapData(s,r),r},filter:function(t){var i=Array.prototype.slice.call(arguments,1);return(t=new e.Filter[t](this.game)).init.apply(t,i),t}},e.GameObjectCreator.prototype.constructor=e.GameObjectCreator,e.Sprite=function(t,i,s,n,r){i=i||0,s=s||0,n=n||null,r=r||null,this.type=e.SPRITE,this.physicsType=e.SPRITE,PIXI.Sprite.call(this,e.Cache.DEFAULT),e.Component.Core.init.call(this,t,i,s,n,r)},e.Sprite.prototype=Object.create(PIXI.Sprite.prototype),e.Sprite.prototype.constructor=e.Sprite,e.Component.Core.install.call(e.Sprite.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Delta","Destroy","FixedToCamera","Health","InCamera","InputEnabled","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","ScaleMinMax","Smoothed"]),e.Sprite.prototype.preUpdatePhysics=e.Component.PhysicsBody.preUpdate,e.Sprite.prototype.preUpdateLifeSpan=e.Component.LifeSpan.preUpdate,e.Sprite.prototype.preUpdateInWorld=e.Component.InWorld.preUpdate,e.Sprite.prototype.preUpdateCore=e.Component.Core.preUpdate,e.Sprite.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},e.Image=function(t,i,s,n,r){i=i||0,s=s||0,n=n||null,r=r||null,this.type=e.IMAGE,PIXI.Sprite.call(this,e.Cache.DEFAULT),e.Component.Core.init.call(this,t,i,s,n,r)},e.Image.prototype=Object.create(PIXI.Sprite.prototype),e.Image.prototype.constructor=e.Image,e.Component.Core.install.call(e.Image.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Destroy","FixedToCamera","InputEnabled","LifeSpan","LoadTexture","Overlap","Reset","ScaleMinMax","Smoothed"]),e.Image.prototype.preUpdateLifeSpan=e.Component.LifeSpan.preUpdate,e.Image.prototype.preUpdateInWorld=e.Component.InWorld.preUpdate,e.Image.prototype.preUpdateCore=e.Component.Core.preUpdate,e.Image.prototype.preUpdate=function(){return!(!this.preUpdateInWorld()||!this.preUpdateLifeSpan())&&this.preUpdateCore()},e.Button=function(t,i,s,n,r,o,a,h,l,c){i=i||0,s=s||0,n=n||null,r=r||null,o=o||this,e.Image.call(this,t,i,s,n,h),this.type=e.BUTTON,this.physicsType=e.SPRITE,this._onOverFrame=null,this._onOutFrame=null,this._onDownFrame=null,this._onUpFrame=null,this.onOverSound=null,this.onOutSound=null,this.onDownSound=null,this.onUpSound=null,this.onOverSoundMarker="",this.onOutSoundMarker="",this.onDownSoundMarker="",this.onUpSoundMarker="",this.onInputOver=new e.Signal,this.onInputOut=new e.Signal,this.onInputDown=new e.Signal,this.onInputUp=new e.Signal,this.onOverMouseOnly=!0,this.justReleasedPreventsOver=e.PointerMode.CONTACT,this.freezeFrames=!1,this.forceOut=!1,this.inputEnabled=!0,this.input.start(0,!0),this.input.useHandCursor=!0,this.setFrames(a,h,l,c),null!==r&&this.onInputUp.add(r,o),this.events.onInputOver.add(this.onInputOverHandler,this),this.events.onInputOut.add(this.onInputOutHandler,this),this.events.onInputDown.add(this.onInputDownHandler,this),this.events.onInputUp.add(this.onInputUpHandler,this)},e.Button.prototype=Object.create(e.Image.prototype),e.Button.prototype.constructor=e.Button;return e.Button.prototype.clearFrames=function(){this.setFrames(null,null,null,null)},e.Button.prototype.setStateFrame=function(t,e,i){var s="_on"+t+"Frame";null!==e?(this[s]=e,i&&this.changeStateFrame(t)):this[s]=null},e.Button.prototype.changeStateFrame=function(t){if(this.freezeFrames)return!1;var e=this["_on"+t+"Frame"];return"string"==typeof e?(this.frameName=e,!0):"number"==typeof e&&(this.frame=e,!0)},e.Button.prototype.setFrames=function(t,e,i,s){this.setStateFrame("Over",t,this.input.pointerOver()),this.setStateFrame("Out",e,!this.input.pointerOver()),this.setStateFrame("Down",i,this.input.pointerDown()),this.setStateFrame("Up",s,this.input.pointerUp())},e.Button.prototype.setStateSound=function(t,i,s){var n="on"+t+"Sound",r="on"+t+"SoundMarker";i instanceof e.Sound||i instanceof e.AudioSprite?(this[n]=i,this[r]="string"==typeof s?s:""):(this[n]=null,this[r]="")},e.Button.prototype.playStateSound=function(t){var e=this["on"+t+"Sound"];if(e){var i=this["on"+t+"SoundMarker"];return e.play(i),!0}return!1},e.Button.prototype.setSounds=function(t,e,i,s,n,r,o,a){this.setStateSound("Over",t,e),this.setStateSound("Out",n,r),this.setStateSound("Down",i,s),this.setStateSound("Up",o,a)},e.Button.prototype.setOverSound=function(t,e){this.setStateSound("Over",t,e)},e.Button.prototype.setOutSound=function(t,e){this.setStateSound("Out",t,e)},e.Button.prototype.setDownSound=function(t,e){this.setStateSound("Down",t,e)},e.Button.prototype.setUpSound=function(t,e){this.setStateSound("Up",t,e)},e.Button.prototype.onInputOverHandler=function(t,e){e.justReleased()&&(this.justReleasedPreventsOver&e.pointerMode)===e.pointerMode||(this.changeStateFrame("Over"),this.onOverMouseOnly&&!e.isMouse||(this.playStateSound("Over"),this.onInputOver&&this.onInputOver.dispatch(this,e)))},e.Button.prototype.onInputOutHandler=function(t,e){this.changeStateFrame("Out"),this.playStateSound("Out"),this.onInputOut&&this.onInputOut.dispatch(this,e)},e.Button.prototype.onInputDownHandler=function(t,e){this.changeStateFrame("Down"),this.playStateSound("Down"),this.onInputDown&&this.onInputDown.dispatch(this,e)},e.Button.prototype.onInputUpHandler=function(t,e,i){this.playStateSound("Up"),this.onInputUp&&this.onInputUp.dispatch(this,e,i),this.freezeFrames||(!0===this.forceOut||(this.forceOut&e.pointerMode)===e.pointerMode?this.changeStateFrame("Out"):this.changeStateFrame("Up")||(i?this.changeStateFrame("Over"):this.changeStateFrame("Out")))},e.SpriteBatch=function(t,i,s,n){void 0!==i&&null!==i||(i=t.world),e.Group.call(this,t,i,s,n),this.type=e.SPRITEBATCH,this.fastSpriteBatch=null,this.ready=!1},e.SpriteBatch.prototype=Object.create(e.Group.prototype),e.SpriteBatch.prototype.constructor=e.SpriteBatch,e.SpriteBatch.prototype._renderWebGL=function(t){!this.visible||this.alpha<=0||!this.children.length||(this.ready||(this.fastSpriteBatch=new PIXI.WebGLFastSpriteBatch(t.gl),this.ready=!0),this.fastSpriteBatch.gl!==t.gl&&this.fastSpriteBatch.setContext(t.gl),t.spriteBatch.stop(),t.shaderManager.setShader(t.shaderManager.fastShader),this.fastSpriteBatch.begin(this,t),this.fastSpriteBatch.render(this),t.spriteBatch.start())},e.SpriteBatch.prototype._renderCanvas=function(t){if(this.visible&&!(this.alpha<=0)&&this.children.length){var e=t.context;e.globalAlpha=this.worldAlpha,this.displayObjectUpdateTransform();for(var i=this.worldTransform,s=!0,n=0;n<this.children.length;n++){var r=this.children[n];if(r.visible){var o=r.texture,a=o.frame;if(e.globalAlpha=this.worldAlpha*r.alpha,r.rotation%(2*Math.PI)==0)s&&(e.setTransform(i.a,i.b,i.c,i.d,i.tx,i.ty),s=!1),e.drawImage(o.baseTexture.source,a.x,a.y,a.width,a.height,r.anchor.x*(-a.width*r.scale.x)+r.position.x+.5+t.shakeX|0,r.anchor.y*(-a.height*r.scale.y)+r.position.y+.5+t.shakeY|0,a.width*r.scale.x,a.height*r.scale.y);else{s||(s=!0),r.displayObjectUpdateTransform();var h=r.worldTransform,l=h.tx*t.resolution+t.shakeX,c=h.ty*t.resolution+t.shakeY;t.roundPixels?e.setTransform(h.a,h.b,h.c,h.d,0|l,0|c):e.setTransform(h.a,h.b,h.c,h.d,l,c),e.drawImage(o.baseTexture.source,a.x,a.y,a.width,a.height,r.anchor.x*-a.width+.5|0,r.anchor.y*-a.height+.5|0,a.width,a.height)}}}}},e.BitmapData=function(t,i,s,n,r){void 0!==s&&0!==s||(s=256),void 0!==n&&0!==n||(n=256),void 0===r&&(r=!1),this.game=t,this.key=i,this.width=s,this.height=n,this.canvas=e.Canvas.create(this,s,n,null,r),this.context=this.canvas.getContext("2d",{alpha:!0}),this.ctx=this.context,this.smoothProperty=t.renderType===e.CANVAS?t.renderer.renderSession.smoothProperty:e.Canvas.getSmoothingPrefix(this.context),this.imageData=this.context.getImageData(0,0,s,n),this.data=null,this.imageData&&(this.data=this.imageData.data),this.pixels=null,this.data&&(this.imageData.data.buffer?(this.buffer=this.imageData.data.buffer,this.pixels=new Uint32Array(this.buffer)):window.ArrayBuffer?(this.buffer=new ArrayBuffer(this.imageData.data.length),this.pixels=new Uint32Array(this.buffer)):this.pixels=this.imageData.data),this.baseTexture=new PIXI.BaseTexture(this.canvas,null,this.game.resolution),this.texture=new PIXI.Texture(this.baseTexture),this.frameData=new e.FrameData,this.textureFrame=this.frameData.addFrame(new e.Frame(0,0,0,s,n,"bitmapData")),this.texture.frame=this.textureFrame,this.type=e.BITMAPDATA,this.disableTextureUpload=!1,this.dirty=!1,this.cls=this.clear,this._image=null,this._pos=new e.Point,this._size=new e.Point,this._scale=new e.Point,this._rotate=0,this._alpha={prev:1,current:1},this._anchor=new e.Point,this._tempR=0,this._tempG=0,this._tempB=0,this._circle=new e.Circle,this._swapCanvas=void 0},e.BitmapData.prototype={move:function(t,e,i){return 0!==t&&this.moveH(t,i),0!==e&&this.moveV(e,i),this},moveH:function(t,i){void 0===i&&(i=!0),void 0===this._swapCanvas&&(this._swapCanvas=e.CanvasPool.create(this,this.width,this.height));var s=this._swapCanvas.getContext("2d"),n=this.height,r=this.canvas;if(s.clearRect(0,0,this.width,this.height),t<0){t=Math.abs(t);o=this.width-t;i&&s.drawImage(r,0,0,t,n,o,0,t,n),s.drawImage(r,t,0,o,n,0,0,o,n)}else{var o=this.width-t;i&&s.drawImage(r,o,0,t,n,0,0,t,n),s.drawImage(r,0,0,o,n,t,0,o,n)}return this.clear(),this.copy(this._swapCanvas)},moveV:function(t,i){void 0===i&&(i=!0),void 0===this._swapCanvas&&(this._swapCanvas=e.CanvasPool.create(this,this.width,this.height));var s=this._swapCanvas.getContext("2d"),n=this.width,r=this.canvas;if(s.clearRect(0,0,this.width,this.height),t<0){t=Math.abs(t);o=this.height-t;i&&s.drawImage(r,0,0,n,t,0,o,n,t),s.drawImage(r,0,t,n,o,0,0,n,o)}else{var o=this.height-t;i&&s.drawImage(r,0,o,n,t,0,0,n,t),s.drawImage(r,0,0,n,o,0,t,n,o)}return this.clear(),this.copy(this._swapCanvas)},add:function(t){if(Array.isArray(t))for(var e=0;e<t.length;e++)t[e].loadTexture&&t[e].loadTexture(this);else t.loadTexture(this);return this},load:function(t){if("string"==typeof t&&(t=this.game.cache.getImage(t)),t)return this.resize(t.width,t.height),this.cls(),this.draw(t),this.update(),this},clear:function(t,e,i,s){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.width),void 0===s&&(s=this.height),this.context.clearRect(t,e,i,s),this.dirty=!0,this},fill:function(t,e,i,s){return void 0===s&&(s=1),this.context.fillStyle="rgba("+t+","+e+","+i+","+s+")",this.context.fillRect(0,0,this.width,this.height),this.dirty=!0,this},generateTexture:function(t,e,i){var s=this.game.cache,n=new Image;if(e&&(n.onload=function(){var r=s.addImage(t,"",n),o=new PIXI.Texture(r.base);e.call(i||null,o),n.onload=null}),n.src=this.canvas.toDataURL("image/png"),!e){var r=s.addImage(t,"",n);return new PIXI.Texture(r.base)}return null},resize:function(t,e){return t===this.width&&e===this.height||(this.width=t,this.height=e,this.canvas.width=t,this.canvas.height=e,void 0!==this._swapCanvas&&(this._swapCanvas.width=t,this._swapCanvas.height=e),this.baseTexture.width=t,this.baseTexture.height=e,this.textureFrame.width=t,this.textureFrame.height=e,this.texture.width=t,this.texture.height=e,this.texture.crop.width=t,this.texture.crop.height=e,this.update(),this.dirty=!0),this},update:function(t,e,i,s){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=Math.max(1,this.width)),void 0===s&&(s=Math.max(1,this.height)),this.imageData=this.context.getImageData(t,e,i,s),this.data=this.imageData.data,this.imageData.data.buffer?(this.buffer=this.imageData.data.buffer,this.pixels=new Uint32Array(this.buffer)):window.ArrayBuffer?(this.buffer=new ArrayBuffer(this.imageData.data.length),this.pixels=new Uint32Array(this.buffer)):this.pixels=this.imageData.data,this},processPixelRGB:function(t,i,s,n,r,o){void 0===s&&(s=0),void 0===n&&(n=0),void 0===r&&(r=this.width),void 0===o&&(o=this.height);for(var a=s+r,h=n+o,l=e.Color.createColor(),c={r:0,g:0,b:0,a:0},u=!1,d=n;d<h;d++)for(var p=s;p<a;p++)e.Color.unpackPixel(this.getPixel32(p,d),l),!1!==(c=t.call(i,l,p,d))&&null!==c&&void 0!==c&&(this.setPixel32(p,d,c.r,c.g,c.b,c.a,!1),u=!0);return u&&(this.context.putImageData(this.imageData,0,0),this.dirty=!0),this},processPixel:function(t,e,i,s,n,r){void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=this.width),void 0===r&&(r=this.height);for(var o=i+n,a=s+r,h=0,l=0,c=!1,u=s;u<a;u++)for(var d=i;d<o;d++)h=this.getPixel32(d,u),(l=t.call(e,h,d,u))!==h&&(this.pixels[u*this.width+d]=l,c=!0);return c&&(this.context.putImageData(this.imageData,0,0),this.dirty=!0),this},replaceRGB:function(t,i,s,n,r,o,a,h,l){var c=0,u=0,d=this.width,p=this.height,f=e.Color.packPixel(t,i,s,n);void 0!==l&&l instanceof e.Rectangle&&(c=l.x,u=l.y,d=l.width,p=l.height);for(var g=0;g<p;g++)for(var m=0;m<d;m++)this.getPixel32(c+m,u+g)===f&&this.setPixel32(c+m,u+g,r,o,a,h,!1);return this.context.putImageData(this.imageData,0,0),this.dirty=!0,this},setHSL:function(t,i,s,n){var r=t||0===t,o=i||0===i,a=s||0===s;if(r||o||a){void 0===n&&(n=new e.Rectangle(0,0,this.width,this.height));for(var h=e.Color.createColor(),l=n.y;l<n.bottom;l++)for(var c=n.x;c<n.right;c++)e.Color.unpackPixel(this.getPixel32(c,l),h,!0),r&&(h.h=t),o&&(h.s=i),a&&(h.l=s),e.Color.HSLtoRGB(h.h,h.s,h.l,h),this.setPixel32(c,l,h.r,h.g,h.b,h.a,!1);return this.context.putImageData(this.imageData,0,0),this.dirty=!0,this}},shiftHSL:function(t,i,s,n){if(void 0!==t&&null!==t||(t=!1),void 0!==i&&null!==i||(i=!1),void 0!==s&&null!==s||(s=!1),t||i||s){void 0===n&&(n=new e.Rectangle(0,0,this.width,this.height));for(var r=e.Color.createColor(),o=n.y;o<n.bottom;o++)for(var a=n.x;a<n.right;a++)e.Color.unpackPixel(this.getPixel32(a,o),r,!0),t&&(r.h=this.game.math.wrap(r.h+t,0,1)),i&&(r.s=this.game.math.clamp(r.s+i,0,1)),s&&(r.l=this.game.math.clamp(r.l+s,0,1)),e.Color.HSLtoRGB(r.h,r.s,r.l,r),this.setPixel32(a,o,r.r,r.g,r.b,r.a,!1);return this.context.putImageData(this.imageData,0,0),this.dirty=!0,this}},setPixel32:function(t,i,s,n,r,o,a){return void 0===a&&(a=!0),t>=0&&t<=this.width&&i>=0&&i<=this.height&&(e.Device.LITTLE_ENDIAN?this.pixels[i*this.width+t]=o<<24|r<<16|n<<8|s:this.pixels[i*this.width+t]=s<<24|n<<16|r<<8|o,a&&(this.context.putImageData(this.imageData,0,0),this.dirty=!0)),this},setPixel:function(t,e,i,s,n,r){return this.setPixel32(t,e,i,s,n,255,r)},getPixel:function(t,i,s){s||(s=e.Color.createColor());var n=~~(t+i*this.width);return n*=4,s.r=this.data[n],s.g=this.data[++n],s.b=this.data[++n],s.a=this.data[++n],s},getPixel32:function(t,e){if(t>=0&&t<=this.width&&e>=0&&e<=this.height)return this.pixels[e*this.width+t]},getPixelRGB:function(t,i,s,n,r){return e.Color.unpackPixel(this.getPixel32(t,i),s,n,r)},getPixels:function(t){return this.context.getImageData(t.x,t.y,t.width,t.height)},getFirstPixel:function(t){void 0===t&&(t=0);var i=e.Color.createColor(),s=0,n=0,r=1,o=!1;1===t?(r=-1,n=this.height):3===t&&(r=-1,s=this.width);do{e.Color.unpackPixel(this.getPixel32(s,n),i),0===t||1===t?++s===this.width&&(s=0,((n+=r)>=this.height||n<=0)&&(o=!0)):2!==t&&3!==t||++n===this.height&&(n=0,((s+=r)>=this.width||s<=0)&&(o=!0))}while(0===i.a&&!o);return i.x=s,i.y=n,i},getBounds:function(t){return void 0===t&&(t=new e.Rectangle),t.x=this.getFirstPixel(2).x,t.x===this.width?t.setTo(0,0,0,0):(t.y=this.getFirstPixel(0).y,t.width=this.getFirstPixel(3).x-t.x+1,t.height=this.getFirstPixel(1).y-t.y+1,t)},addToWorld:function(t,e,i,s,n,r){n=n||1,r=r||1;var o=this.game.add.image(t,e,this);return o.anchor.set(i,s),o.scale.set(n,r),o},copy:function(t,i,s,n,r,o,a,h,l,c,u,d,p,f,g,m,y){if(void 0!==t&&null!==t||(t=this),t instanceof e.RenderTexture&&(t=t.getCanvas()),this._image=t,t instanceof e.Sprite||t instanceof e.Image||t instanceof e.Text||t instanceof PIXI.Sprite)this._pos.set(t.texture.crop.x,t.texture.crop.y),this._size.set(t.texture.crop.width,t.texture.crop.height),this._scale.set(t.scale.x,t.scale.y),this._anchor.set(t.anchor.x,t.anchor.y),this._rotate=t.rotation,this._alpha.current=t.alpha,t.texture instanceof e.RenderTexture?this._image=t.texture.getCanvas():this._image=t.texture.baseTexture.source,void 0!==o&&null!==o||(o=t.x),void 0!==a&&null!==a||(a=t.y),t.texture.trim&&(o+=t.texture.trim.x-t.anchor.x*t.texture.trim.width,a+=t.texture.trim.y-t.anchor.y*t.texture.trim.height),16777215!==t.tint&&(t.cachedTint!==t.tint&&(t.cachedTint=t.tint,t.tintedTexture=PIXI.CanvasTinter.getTintedTexture(t,t.tint)),this._image=t.tintedTexture,this._pos.set(0));else{if(this._pos.set(0),this._scale.set(1),this._anchor.set(0),this._rotate=0,this._alpha.current=1,t instanceof e.BitmapData)this._image=t.canvas;else if("string"==typeof t){if(null===(t=this.game.cache.getImage(t)))return this;this._image=t}this._size.set(this._image.width,this._image.height)}if(void 0!==i&&null!==i||(i=0),void 0!==s&&null!==s||(s=0),n&&(this._size.x=n),r&&(this._size.y=r),void 0!==o&&null!==o||(o=i),void 0!==a&&null!==a||(a=s),void 0!==h&&null!==h||(h=this._size.x),void 0!==l&&null!==l||(l=this._size.y),"number"==typeof c&&(this._rotate=c),"number"==typeof u&&(this._anchor.x=u),"number"==typeof d&&(this._anchor.y=d),"number"==typeof p&&(this._scale.x=p),"number"==typeof f&&(this._scale.y=f),"number"==typeof g&&(this._alpha.current=g),void 0===m&&(m=null),void 0===y&&(y=!1),this._alpha.current<=0||0===this._scale.x||0===this._scale.y||0===this._size.x||0===this._size.y)return this;var v=this.context;return this._alpha.prev=v.globalAlpha,v.save(),v.globalAlpha=this._alpha.current,m&&(this.op=m),y&&(o|=0,a|=0),v.translate(o,a),v.scale(this._scale.x,this._scale.y),v.rotate(this._rotate),v.drawImage(this._image,this._pos.x+i,this._pos.y+s,this._size.x,this._size.y,-h*this._anchor.x,-l*this._anchor.y,h,l),v.restore(),v.globalAlpha=this._alpha.prev,this.dirty=!0,this},copyTransform:function(t,i,s){if(void 0===i&&(i=null),void 0===s&&(s=!1),!t.hasOwnProperty("worldTransform")||!t.worldVisible||0===t.worldAlpha)return this;var n=t.worldTransform;if(this._pos.set(t.texture.crop.x,t.texture.crop.y),this._size.set(t.texture.crop.width,t.texture.crop.height),0===n.a||0===n.d||0===this._size.x||0===this._size.y)return this;t.texture instanceof e.RenderTexture?this._image=t.texture.getCanvas():this._image=t.texture.baseTexture.source;var r=n.tx,o=n.ty;t.texture.trim&&(r+=t.texture.trim.x-t.anchor.x*t.texture.trim.width,o+=t.texture.trim.y-t.anchor.y*t.texture.trim.height),16777215!==t.tint&&(t.cachedTint!==t.tint&&(t.cachedTint=t.tint,t.tintedTexture=PIXI.CanvasTinter.getTintedTexture(t,t.tint)),this._image=t.tintedTexture,this._pos.set(0)),s&&(r|=0,o|=0);var a=this.context;return this._alpha.prev=a.globalAlpha,a.save(),a.globalAlpha=this._alpha.current,i&&(this.op=i),a[this.smoothProperty]=t.texture.baseTexture.scaleMode===PIXI.scaleModes.LINEAR,a.setTransform(n.a,n.b,n.c,n.d,r,o),a.drawImage(this._image,this._pos.x,this._pos.y,this._size.x,this._size.y,-this._size.x*t.anchor.x,-this._size.y*t.anchor.y,this._size.x,this._size.y),a.restore(),a.globalAlpha=this._alpha.prev,this.dirty=!0,this},copyRect:function(t,e,i,s,n,r,o){return this.copy(t,e.x,e.y,e.width,e.height,i,s,e.width,e.height,0,0,0,1,1,n,r,o)},draw:function(t,e,i,s,n,r,o){return this.copy(t,null,null,null,null,e,i,s,n,null,null,null,null,null,null,r,o)},drawGroup:function(t,e,i){return t.total>0&&t.forEachExists(this.drawGroupProxy,this,e,i),this},drawGroupProxy:function(t,i,s){if(t.hasOwnProperty("texture")&&this.copyTransform(t,i,s),t.type===e.GROUP&&t.exists)this.drawGroup(t,i,s);else if(t.hasOwnProperty("children")&&t.children.length>0)for(var n=0;n<t.children.length;n++)t.children[n].exists&&this.copyTransform(t.children[n],i,s)},drawFull:function(t,i,s){if(!1===t.worldVisible||0===t.worldAlpha||t.hasOwnProperty("exists")&&!1===t.exists)return this;if(t.type!==e.GROUP&&t.type!==e.EMITTER&&t.type!==e.BITMAPTEXT)if(t.type===e.GRAPHICS){var n=t.getBounds();this.ctx.save(),this.ctx.translate(n.x,n.y),PIXI.CanvasGraphics.renderGraphics(t,this.ctx),this.ctx.restore()}else this.copy(t,null,null,null,null,t.worldPosition.x,t.worldPosition.y,null,null,t.worldRotation,null,null,t.worldScale.x,t.worldScale.y,t.worldAlpha,i,s);if(t.children)for(var r=0;r<t.children.length;r++)this.drawFull(t.children[r],i,s);return this},shadow:function(t,e,i,s){var n=this.context;return void 0===t||null===t?n.shadowColor="rgba(0,0,0,0)":(n.shadowColor=t,n.shadowBlur=0===e?0:e||5,n.shadowOffsetX=0===i?0:i||10,n.shadowOffsetY=0===s?0:s||10),this},alphaMask:function(t,e,i,s){return void 0===s||null===s?this.draw(e).blendSourceAtop():this.draw(e,s.x,s.y,s.width,s.height).blendSourceAtop(),void 0===i||null===i?this.draw(t).blendReset():this.draw(t,i.x,i.y,i.width,i.height).blendReset(),this},extract:function(t,e,i,s,n,r,o,a,h){return void 0===n&&(n=255),void 0===r&&(r=!1),void 0===o&&(o=e),void 0===a&&(a=i),void 0===h&&(h=s),r&&t.resize(this.width,this.height),this.processPixelRGB(function(r,l,c){return r.r===e&&r.g===i&&r.b===s&&t.setPixel32(l,c,o,a,h,n,!1),!1},this),t.context.putImageData(t.imageData,0,0),t.dirty=!0,t},rect:function(t,e,i,s,n){return void 0!==n&&(this.context.fillStyle=n),this.context.fillRect(t,e,i,s),this},text:function(t,e,i,s,n,r){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s="14px Courier"),void 0===n&&(n="rgb(255,255,255)"),void 0===r&&(r=!0);var o=this.context,a=o.font;return o.font=s,r&&(o.fillStyle="rgb(0,0,0)",o.fillText(t,e+1,i+1)),o.fillStyle=n,o.fillText(t,e,i),o.font=a,this},circle:function(t,e,i,s){var n=this.context;return void 0!==s&&(n.fillStyle=s),n.beginPath(),n.arc(t,e,i,0,2*Math.PI,!1),n.closePath(),n.fill(),this},line:function(t,e,i,s,n,r){void 0===n&&(n="#fff"),void 0===r&&(r=1);var o=this.context;return o.beginPath(),o.moveTo(t,e),o.lineTo(i,s),o.lineWidth=r,o.strokeStyle=n,o.stroke(),o.closePath(),this},polygon:function(t,e,i,s){void 0===s&&(s="#fff"),void 0===i&&(i=0);var n=this.context;e&&(n.fillStyle=e),i&&(n.lineWidth=i,n.strokeStyle=s),n.beginPath(),n.moveTo(t[0].x,t[0].y);for(var r=1,o=t.length;r<o;r++){var a=t[r];n.lineTo(a.x,a.y)}return n.closePath(),e&&n.fill(),i&&n.stroke(),this},textureLine:function(t,i,s){if(void 0===s&&(s="repeat-x"),"string"!=typeof i||(i=this.game.cache.getImage(i))){var n=t.length;"no-repeat"===s&&n>i.width&&(n=i.width);var r=this.context;return r.fillStyle=r.createPattern(i,s),this._circle=new e.Circle(t.start.x,t.start.y,i.height),this._circle.circumferencePoint(t.angle-1.5707963267948966,!1,this._pos),r.save(),r.translate(this._pos.x,this._pos.y),r.rotate(t.angle),r.fillRect(0,0,n,i.height),r.restore(),this.dirty=!0,this}},render:function(){return!this.disableTextureUpload&&this.dirty&&(this.baseTexture.dirty(),this.dirty=!1),this},destroy:function(){this.frameData.destroy(),this.texture.destroy(!0),e.CanvasPool.remove(this)},blendReset:function(){return this.op="source-over",this},blendSourceOver:function(){return this.op="source-over",this},blendSourceIn:function(){return this.op="source-in",this},blendSourceOut:function(){return this.op="source-out",this},blendSourceAtop:function(){return this.op="source-atop",this},blendDestinationOver:function(){return this.op="destination-over",this},blendDestinationIn:function(){return this.op="destination-in",this},blendDestinationOut:function(){return this.op="destination-out",this},blendDestinationAtop:function(){return this.op="destination-atop",this},blendXor:function(){return this.op="xor",this},blendAdd:function(){return this.op="lighter",this},blendMultiply:function(){return this.op="multiply",this},blendScreen:function(){return this.op="screen",this},blendOverlay:function(){return this.op="overlay",this},blendDarken:function(){return this.op="darken",this},blendLighten:function(){return this.op="lighten",this},blendColorDodge:function(){return this.op="color-dodge",this},blendColorBurn:function(){return this.op="color-burn",this},blendHardLight:function(){return this.op="hard-light",this},blendSoftLight:function(){return this.op="soft-light",this},blendDifference:function(){return this.op="difference",this},blendExclusion:function(){return this.op="exclusion",this},blendHue:function(){return this.op="hue",this},blendSaturation:function(){return this.op="saturation",this},blendColor:function(){return this.op="color",this},blendLuminosity:function(){return this.op="luminosity",this},copyBitmapData:function(t,e,i){t.update();for(var s,n=0;n<t.height;n++){s=(i+n)*this.width+e;for(var r=0;r<t.width;r++)this.pixels[s+r]=t.pixels[n*t.width+r]}return this}},Object.defineProperty(e.BitmapData.prototype,"smoothed",{get:function(){return e.Canvas.getSmoothingEnabled(this.context)},set:function(t){e.Canvas.setSmoothingEnabled(this.context,t)}}),Object.defineProperty(e.BitmapData.prototype,"op",{get:function(){return this.context.globalCompositeOperation},set:function(t){this.context.globalCompositeOperation=t}}),e.BitmapData.getTransform=function(t,e,i,s,n,r){return"number"!=typeof t&&(t=0),"number"!=typeof e&&(e=0),"number"!=typeof i&&(i=1),"number"!=typeof s&&(s=1),"number"!=typeof n&&(n=0),"number"!=typeof r&&(r=0),{sx:i,sy:s,scaleX:i,scaleY:s,skewX:n,skewY:r,translateX:t,translateY:e,tx:t,ty:e}},e.BitmapData.prototype.constructor=e.BitmapData,e.EarCut={},e.EarCut.Triangulate=function(t,i,s){s=s||2;var n=i&&i.length,r=n?i[0]*s:t.length,o=e.EarCut.linkedList(t,0,r,s,!0),a=[];if(!o)return a;var h,l,c,u,d,p,f;if(n&&(o=e.EarCut.eliminateHoles(t,i,o,s)),t.length>80*s){h=c=t[0],l=u=t[1];for(var g=s;g<r;g+=s)d=t[g],p=t[g+1],d<h&&(h=d),p<l&&(l=p),d>c&&(c=d),p>u&&(u=p);f=Math.max(c-h,u-l)}return e.EarCut.earcutLinked(o,a,s,h,l,f),a},e.EarCut.linkedList=function(t,i,s,n,r){var o,a,h,l=0;for(o=i,a=s-n;o<s;o+=n)l+=(t[a]-t[o])*(t[o+1]+t[a+1]),a=o;if(r===l>0)for(o=i;o<s;o+=n)h=e.EarCut.insertNode(o,t[o],t[o+1],h);else for(o=s-n;o>=i;o-=n)h=e.EarCut.insertNode(o,t[o],t[o+1],h);return h},e.EarCut.filterPoints=function(t,i){if(!t)return t;i||(i=t);var s,n=t;do{if(s=!1,n.steiner||!e.EarCut.equals(n,n.next)&&0!==e.EarCut.area(n.prev,n,n.next))n=n.next;else{if(e.EarCut.removeNode(n),(n=i=n.prev)===n.next)return null;s=!0}}while(s||n!==i);return i},e.EarCut.earcutLinked=function(t,i,s,n,r,o,a){if(t){!a&&o&&e.EarCut.indexCurve(t,n,r,o);for(var h,l,c=t;t.prev!==t.next;)if(h=t.prev,l=t.next,o?e.EarCut.isEarHashed(t,n,r,o):e.EarCut.isEar(t))i.push(h.i/s),i.push(t.i/s),i.push(l.i/s),e.EarCut.removeNode(t),t=l.next,c=l.next;else if((t=l)===c){a?1===a?(t=e.EarCut.cureLocalIntersections(t,i,s),e.EarCut.earcutLinked(t,i,s,n,r,o,2)):2===a&&e.EarCut.splitEarcut(t,i,s,n,r,o):e.EarCut.earcutLinked(e.EarCut.filterPoints(t),i,s,n,r,o,1);break}}},e.EarCut.isEar=function(t){var i=t.prev,s=t,n=t.next;if(e.EarCut.area(i,s,n)>=0)return!1;for(var r=t.next.next;r!==t.prev;){if(e.EarCut.pointInTriangle(i.x,i.y,s.x,s.y,n.x,n.y,r.x,r.y)&&e.EarCut.area(r.prev,r,r.next)>=0)return!1;r=r.next}return!0},e.EarCut.isEarHashed=function(t,i,s,n){var r=t.prev,o=t,a=t.next;if(e.EarCut.area(r,o,a)>=0)return!1;for(var h=r.x<o.x?r.x<a.x?r.x:a.x:o.x<a.x?o.x:a.x,l=r.y<o.y?r.y<a.y?r.y:a.y:o.y<a.y?o.y:a.y,c=r.x>o.x?r.x>a.x?r.x:a.x:o.x>a.x?o.x:a.x,u=r.y>o.y?r.y>a.y?r.y:a.y:o.y>a.y?o.y:a.y,d=e.EarCut.zOrder(h,l,i,s,n),p=e.EarCut.zOrder(c,u,i,s,n),f=t.nextZ;f&&f.z<=p;){if(f!==t.prev&&f!==t.next&&e.EarCut.pointInTriangle(r.x,r.y,o.x,o.y,a.x,a.y,f.x,f.y)&&e.EarCut.area(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(f=t.prevZ;f&&f.z>=d;){if(f!==t.prev&&f!==t.next&&e.EarCut.pointInTriangle(r.x,r.y,o.x,o.y,a.x,a.y,f.x,f.y)&&e.EarCut.area(f.prev,f,f.next)>=0)return!1;f=f.prevZ}return!0},e.EarCut.cureLocalIntersections=function(t,i,s){var n=t;do{var r=n.prev,o=n.next.next;e.EarCut.intersects(r,n,n.next,o)&&e.EarCut.locallyInside(r,o)&&e.EarCut.locallyInside(o,r)&&(i.push(r.i/s),i.push(n.i/s),i.push(o.i/s),e.EarCut.removeNode(n),e.EarCut.removeNode(n.next),n=t=o),n=n.next}while(n!==t);return n},e.EarCut.splitEarcut=function(t,i,s,n,r,o){var a=t;do{for(var h=a.next.next;h!==a.prev;){if(a.i!==h.i&&e.EarCut.isValidDiagonal(a,h)){var l=e.EarCut.splitPolygon(a,h);return a=e.EarCut.filterPoints(a,a.next),l=e.EarCut.filterPoints(l,l.next),e.EarCut.earcutLinked(a,i,s,n,r,o),void e.EarCut.earcutLinked(l,i,s,n,r,o)}h=h.next}a=a.next}while(a!==t)},e.EarCut.eliminateHoles=function(t,i,s,n){var r,o,a,h,l,c=[];for(r=0,o=i.length;r<o;r++)a=i[r]*n,h=r<o-1?i[r+1]*n:t.length,(l=e.EarCut.linkedList(t,a,h,n,!1))===l.next&&(l.steiner=!0),c.push(e.EarCut.getLeftmost(l));for(c.sort(e.EarCut.compareX),r=0;r<c.length;r++)e.EarCut.eliminateHole(c[r],s),s=e.EarCut.filterPoints(s,s.next);return s},e.EarCut.compareX=function(t,e){return t.x-e.x},e.EarCut.eliminateHole=function(t,i){if(i=e.EarCut.findHoleBridge(t,i)){var s=e.EarCut.splitPolygon(i,t);e.EarCut.filterPoints(s,s.next)}},e.EarCut.findHoleBridge=function(t,i){var s,n=i,r=t.x,o=t.y,a=-1/0;do{if(o<=n.y&&o>=n.next.y){var h=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);h<=r&&h>a&&(a=h,s=n.x<n.next.x?n:n.next)}n=n.next}while(n!==i);if(!s)return null;if(t.x===s.x)return s.prev;var l,c=s,u=1/0;for(n=s.next;n!==c;)r>=n.x&&n.x>=s.x&&e.EarCut.pointInTriangle(o<s.y?r:a,o,s.x,s.y,o<s.y?a:r,o,n.x,n.y)&&((l=Math.abs(o-n.y)/(r-n.x))<u||l===u&&n.x>s.x)&&e.EarCut.locallyInside(n,t)&&(s=n,u=l),n=n.next;return s},e.EarCut.indexCurve=function(t,i,s,n){var r=t;do{null===r.z&&(r.z=e.EarCut.zOrder(r.x,r.y,i,s,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,e.EarCut.sortLinked(r)},e.EarCut.sortLinked=function(t){var e,i,s,n,r,o,a,h,l=1;do{for(i=t,t=null,r=null,o=0;i;){for(o++,s=i,a=0,e=0;e<l&&(a++,s=s.nextZ);e++);for(h=l;a>0||h>0&&s;)0===a?(n=s,s=s.nextZ,h--):0!==h&&s?i.z<=s.z?(n=i,i=i.nextZ,a--):(n=s,s=s.nextZ,h--):(n=i,i=i.nextZ,a--),r?r.nextZ=n:t=n,n.prevZ=r,r=n;i=s}r.nextZ=null,l*=2}while(o>1);return t},e.EarCut.zOrder=function(t,e,i,s,n){return t=32767*(t-i)/n,e=32767*(e-s)/n,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1},e.EarCut.getLeftmost=function(t){var e=t,i=t;do{e.x<i.x&&(i=e),e=e.next}while(e!==t);return i},e.EarCut.pointInTriangle=function(t,e,i,s,n,r,o,a){return(n-o)*(e-a)-(t-o)*(r-a)>=0&&(t-o)*(s-a)-(i-o)*(e-a)>=0&&(i-o)*(r-a)-(n-o)*(s-a)>=0},e.EarCut.isValidDiagonal=function(t,i){return e.EarCut.equals(t,i)||t.next.i!==i.i&&t.prev.i!==i.i&&!e.EarCut.intersectsPolygon(t,i)&&e.EarCut.locallyInside(t,i)&&e.EarCut.locallyInside(i,t)&&e.EarCut.middleInside(t,i)},e.EarCut.area=function(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)},e.EarCut.equals=function(t,e){return t.x===e.x&&t.y===e.y},e.EarCut.intersects=function(t,i,s,n){return e.EarCut.area(t,i,s)>0!=e.EarCut.area(t,i,n)>0&&e.EarCut.area(s,n,t)>0!=e.EarCut.area(s,n,i)>0},e.EarCut.intersectsPolygon=function(t,i){var s=t;do{if(s.i!==t.i&&s.next.i!==t.i&&s.i!==i.i&&s.next.i!==i.i&&e.EarCut.intersects(s,s.next,t,i))return!0;s=s.next}while(s!==t);return!1},e.EarCut.locallyInside=function(t,i){return e.EarCut.area(t.prev,t,t.next)<0?e.EarCut.area(t,i,t.next)>=0&&e.EarCut.area(t,t.prev,i)>=0:e.EarCut.area(t,i,t.prev)<0||e.EarCut.area(t,t.next,i)<0},e.EarCut.middleInside=function(t,e){var i=t,s=!1,n=(t.x+e.x)/2,r=(t.y+e.y)/2;do{i.y>r!=i.next.y>r&&n<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(s=!s),i=i.next}while(i!==t);return s},e.EarCut.splitPolygon=function(t,i){var s=new e.EarCut.Node(t.i,t.x,t.y),n=new e.EarCut.Node(i.i,i.x,i.y),r=t.next,o=i.prev;return t.next=i,i.prev=t,s.next=r,r.prev=s,n.next=s,s.prev=n,o.next=n,n.prev=o,n},e.EarCut.insertNode=function(t,i,s,n){var r=new e.EarCut.Node(t,i,s);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r},e.EarCut.removeNode=function(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)},e.EarCut.Node=function(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1},PIXI.WebGLGraphics=function(){},PIXI.WebGLGraphics.stencilBufferLimit=6,PIXI.WebGLGraphics.renderGraphics=function(t,i){var s,n=i.gl,r=i.projection,o=i.offset,a=i.shaderManager.primitiveShader;t.dirty&&PIXI.WebGLGraphics.updateGraphics(t,n);var h=t._webGL[n.id];if(h)for(var l=0;l<h.data.length;l++)1===h.data[l].mode?(s=h.data[l],i.stencilManager.pushStencil(t,s,i),n.drawElements(n.TRIANGLE_FAN,4,n.UNSIGNED_SHORT,2*(s.indices.length-4)),i.stencilManager.popStencil(t,s,i)):(s=h.data[l],i.shaderManager.setShader(a),a=i.shaderManager.primitiveShader,n.uniformMatrix3fv(a.translationMatrix,!1,t.worldTransform.toArray(!0)),n.uniform1f(a.flipY,1),n.uniform2f(a.projectionVector,r.x,-r.y),n.uniform2f(a.offsetVector,-o.x,-o.y),n.uniform3fv(a.tintColor,e.Color.hexToRGBArray(t.tint)),n.uniform1f(a.alpha,t.worldAlpha),n.bindBuffer(n.ARRAY_BUFFER,s.buffer),n.vertexAttribPointer(a.aVertexPosition,2,n.FLOAT,!1,24,0),n.vertexAttribPointer(a.colorAttribute,4,n.FLOAT,!1,24,8),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,s.indexBuffer),n.drawElements(n.TRIANGLE_STRIP,s.indices.length,n.UNSIGNED_SHORT,0))},PIXI.WebGLGraphics.updateGraphics=function(t,i){var s=t._webGL[i.id];s||(s=t._webGL[i.id]={lastIndex:0,data:[],gl:i}),t.dirty=!1;var n;if(t.clearDirty){for(t.clearDirty=!1,n=0;n<s.data.length;n++){var r=s.data[n];r.reset(),PIXI.WebGLGraphics.graphicsDataPool.push(r)}s.data=[],s.lastIndex=0}var o;for(n=s.lastIndex;n<t.graphicsData.length;n++){var a=t.graphicsData[n];a.type===e.POLYGON?(a.points=a.shape.points.slice(),a.shape.closed&&(a.points[0]===a.points[a.points.length-2]&&a.points[1]===a.points[a.points.length-1]||a.points.push(a.points[0],a.points[1])),a.fill&&a.points.length>=PIXI.WebGLGraphics.stencilBufferLimit&&(a.points.length<2*PIXI.WebGLGraphics.stencilBufferLimit?(o=PIXI.WebGLGraphics.switchMode(s,0),PIXI.WebGLGraphics.buildPoly(a,o)||(o=PIXI.WebGLGraphics.switchMode(s,1),PIXI.WebGLGraphics.buildComplexPoly(a,o))):(o=PIXI.WebGLGraphics.switchMode(s,1),PIXI.WebGLGraphics.buildComplexPoly(a,o))),a.lineWidth>0&&(o=PIXI.WebGLGraphics.switchMode(s,0),PIXI.WebGLGraphics.buildLine(a,o))):(o=PIXI.WebGLGraphics.switchMode(s,0),a.type===e.RECTANGLE?PIXI.WebGLGraphics.buildRectangle(a,o):a.type===e.CIRCLE||a.type===e.ELLIPSE?PIXI.WebGLGraphics.buildCircle(a,o):a.type===e.ROUNDEDRECTANGLE&&PIXI.WebGLGraphics.buildRoundedRectangle(a,o)),s.lastIndex++}for(n=0;n<s.data.length;n++)(o=s.data[n]).dirty&&o.upload()},PIXI.WebGLGraphics.switchMode=function(t,e){var i;return t.data.length?(i=t.data[t.data.length-1]).mode===e&&1!==e||((i=PIXI.WebGLGraphics.graphicsDataPool.pop()||new PIXI.WebGLGraphicsData(t.gl)).mode=e,t.data.push(i)):((i=PIXI.WebGLGraphics.graphicsDataPool.pop()||new PIXI.WebGLGraphicsData(t.gl)).mode=e,t.data.push(i)),i.dirty=!0,i},PIXI.WebGLGraphics.buildRectangle=function(t,i){var s=t.shape,n=s.x,r=s.y,o=s.width,a=s.height;if(t.fill){var h=e.Color.hexToRGBArray(t.fillColor),l=t.fillAlpha,c=h[0]*l,u=h[1]*l,d=h[2]*l,p=i.points,f=i.indices,g=p.length/6;p.push(n,r),p.push(c,u,d,l),p.push(n+o,r),p.push(c,u,d,l),p.push(n,r+a),p.push(c,u,d,l),p.push(n+o,r+a),p.push(c,u,d,l),f.push(g,g,g+1,g+2,g+3,g+3)}if(t.lineWidth){var m=t.points;t.points=[n,r,n+o,r,n+o,r+a,n,r+a,n,r],PIXI.WebGLGraphics.buildLine(t,i),t.points=m}},PIXI.WebGLGraphics.buildRoundedRectangle=function(t,i){var s=t.shape,n=s.x,r=s.y,o=s.width,a=s.height,h=s.radius,l=[];if(l.push(n,r+h),l=l.concat(PIXI.WebGLGraphics.quadraticBezierCurve(n,r+a-h,n,r+a,n+h,r+a)),l=l.concat(PIXI.WebGLGraphics.quadraticBezierCurve(n+o-h,r+a,n+o,r+a,n+o,r+a-h)),l=l.concat(PIXI.WebGLGraphics.quadraticBezierCurve(n+o,r+h,n+o,r,n+o-h,r)),l=l.concat(PIXI.WebGLGraphics.quadraticBezierCurve(n+h,r,n,r,n,r+h)),t.fill){var c=e.Color.hexToRGBArray(t.fillColor),u=t.fillAlpha,d=c[0]*u,p=c[1]*u,f=c[2]*u,g=i.points,m=i.indices,y=g.length/6,v=e.EarCut.Triangulate(l,null,2),x=0;for(x=0;x<v.length;x+=3)m.push(v[x]+y),m.push(v[x]+y),m.push(v[x+1]+y),m.push(v[x+2]+y),m.push(v[x+2]+y);for(x=0;x<l.length;x++)g.push(l[x],l[++x],d,p,f,u)}if(t.lineWidth){var b=t.points;t.points=l,PIXI.WebGLGraphics.buildLine(t,i),t.points=b}},PIXI.WebGLGraphics.quadraticBezierCurve=function(t,e,i,s,n,r){function o(t,e,i){return t+(e-t)*i}for(var a,h,l,c,u,d,p=[],f=0,g=0;g<=20;g++)a=o(t,i,f=g/20),h=o(e,s,f),l=o(i,n,f),c=o(s,r,f),u=o(a,l,f),d=o(h,c,f),p.push(u,d);return p},PIXI.WebGLGraphics.buildCircle=function(t,i){var s,n,r=t.shape,o=r.x,a=r.y;t.type===e.CIRCLE?(s=r.radius,n=r.radius):(s=r.width,n=r.height);var h=2*Math.PI/40,l=0;if(t.fill){var c=e.Color.hexToRGBArray(t.fillColor),u=t.fillAlpha,d=c[0]*u,p=c[1]*u,f=c[2]*u,g=i.points,m=i.indices,y=g.length/6;for(m.push(y),l=0;l<41;l++)g.push(o,a,d,p,f,u),g.push(o+Math.sin(h*l)*s,a+Math.cos(h*l)*n,d,p,f,u),m.push(y++,y++);m.push(y-1)}if(t.lineWidth){var v=t.points;for(t.points=[],l=0;l<41;l++)t.points.push(o+Math.sin(h*l)*s,a+Math.cos(h*l)*n);PIXI.WebGLGraphics.buildLine(t,i),t.points=v}},PIXI.WebGLGraphics.buildLine=function(t,i){var s=0,n=t.points;if(0!==n.length){if(t.lineWidth%2)for(s=0;s<n.length;s++)n[s]+=.5;var r=new PIXI.Point(n[0],n[1]),o=new PIXI.Point(n[n.length-2],n[n.length-1]);if(r.x===o.x&&r.y===o.y){(n=n.slice()).pop(),n.pop();var a=(o=new PIXI.Point(n[n.length-2],n[n.length-1])).x+.5*(r.x-o.x),h=o.y+.5*(r.y-o.y);n.unshift(a,h),n.push(a,h)}var l,c,u,d,p,f,g,m,y,v,x,b,_,w,T,P,C,S,A,E,M,R,L=i.points,B=i.indices,I=n.length/2,O=n.length,k=L.length/6,F=t.lineWidth/2,D=e.Color.hexToRGBArray(t.lineColor),U=t.lineAlpha,G=D[0]*U,N=D[1]*U,X=D[2]*U;for(u=n[0],d=n[1],p=n[2],y=-(d-(f=n[3])),v=u-p,y/=R=Math.sqrt(y*y+v*v),v/=R,y*=F,v*=F,L.push(u-y,d-v,G,N,X,U),L.push(u+y,d+v,G,N,X,U),s=1;s<I-1;s++)u=n[2*(s-1)],d=n[2*(s-1)+1],p=n[2*s],f=n[2*s+1],g=n[2*(s+1)],m=n[2*(s+1)+1],y=-(d-f),v=u-p,y/=R=Math.sqrt(y*y+v*v),v/=R,y*=F,v*=F,x=-(f-m),b=p-g,x/=R=Math.sqrt(x*x+b*b),b/=R,C=(-y+u)*(-v+f)-(-y+p)*(-v+d),E=(-(x*=F)+g)*(-(b*=F)+f)-(-x+p)*(-b+m),M=(T=-v+d-(-v+f))*(A=-x+p-(-x+g))-(S=-b+m-(-b+f))*(P=-y+p-(-y+u)),Math.abs(M)<.1?(M+=10.1,L.push(p-y,f-v,G,N,X,U),L.push(p+y,f+v,G,N,X,U)):((l=(P*E-A*C)/M)-p)*(l-p)+((c=(S*C-T*E)/M)-f)+(c-f)>19600?(_=y-x,w=v-b,_/=R=Math.sqrt(_*_+w*w),w/=R,_*=F,w*=F,L.push(p-_,f-w),L.push(G,N,X,U),L.push(p+_,f+w),L.push(G,N,X,U),L.push(p-_,f-w),L.push(G,N,X,U),O++):(L.push(l,c),L.push(G,N,X,U),L.push(p-(l-p),f-(c-f)),L.push(G,N,X,U));for(u=n[2*(I-2)],d=n[2*(I-2)+1],p=n[2*(I-1)],y=-(d-(f=n[2*(I-1)+1])),v=u-p,y/=R=Math.sqrt(y*y+v*v),v/=R,y*=F,v*=F,L.push(p-y,f-v),L.push(G,N,X,U),L.push(p+y,f+v),L.push(G,N,X,U),B.push(k),s=0;s<O;s++)B.push(k++);B.push(k-1)}},PIXI.WebGLGraphics.buildComplexPoly=function(t,i){var s=t.points.slice();if(!(s.length<6)){var n=i.indices;i.points=s,i.alpha=t.fillAlpha,i.color=e.Color.hexToRGBArray(t.fillColor);for(var r,o,a=1/0,h=-1/0,l=1/0,c=-1/0,u=0;u<s.length;u+=2)r=s[u],o=s[u+1],a=r<a?r:a,h=r>h?r:h,l=o<l?o:l,c=o>c?o:c;s.push(a,l,h,l,h,c,a,c);var d=s.length/2;for(u=0;u<d;u++)n.push(u)}},PIXI.WebGLGraphics.buildPoly=function(t,i){var s=t.points;if(!(s.length<6)){var n=i.points,r=i.indices,o=s.length/2,a=e.Color.hexToRGBArray(t.fillColor),h=t.fillAlpha,l=a[0]*h,c=a[1]*h,u=a[2]*h,d=e.EarCut.Triangulate(s,null,2);if(!d)return!1;var p=n.length/6,f=0;for(f=0;f<d.length;f+=3)r.push(d[f]+p),r.push(d[f]+p),r.push(d[f+1]+p),r.push(d[f+2]+p),r.push(d[f+2]+p);for(f=0;f<o;f++)n.push(s[2*f],s[2*f+1],l,c,u,h);return!0}},PIXI.WebGLGraphics.graphicsDataPool=[],PIXI.WebGLGraphicsData=function(t){this.gl=t,this.color=[0,0,0],this.points=[],this.indices=[],this.buffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),this.mode=1,this.alpha=1,this.dirty=!0},PIXI.WebGLGraphicsData.prototype.reset=function(){this.points=[],this.indices=[]},PIXI.WebGLGraphicsData.prototype.upload=function(){var t=this.gl;this.glPoints=new Float32Array(this.points),t.bindBuffer(t.ARRAY_BUFFER,this.buffer),t.bufferData(t.ARRAY_BUFFER,this.glPoints,t.STATIC_DRAW),this.glIndicies=new Uint16Array(this.indices),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.glIndicies,t.STATIC_DRAW),this.dirty=!1},PIXI.CanvasGraphics=function(){},PIXI.CanvasGraphics.renderGraphics=function(t,i){var s=t.worldAlpha;t.dirty&&(this.updateGraphicsTint(t),t.dirty=!1);for(var n=0;n<t.graphicsData.length;n++){var r=t.graphicsData[n],o=r.shape,a=r._fillTint,h=r._lineTint;if(i.lineWidth=r.lineWidth,r.type===e.POLYGON){i.beginPath();var l=o.points;i.moveTo(l[0],l[1]);for(var c=1;c<l.length/2;c++)i.lineTo(l[2*c],l[2*c+1]);o.closed&&i.lineTo(l[0],l[1]),l[0]===l[l.length-2]&&l[1]===l[l.length-1]&&i.closePath(),r.fill&&(i.globalAlpha=r.fillAlpha*s,i.fillStyle="#"+("00000"+(0|a).toString(16)).substr(-6),i.fill()),r.lineWidth&&(i.globalAlpha=r.lineAlpha*s,i.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),i.stroke())}else if(r.type===e.RECTANGLE)(r.fillColor||0===r.fillColor)&&(i.globalAlpha=r.fillAlpha*s,i.fillStyle="#"+("00000"+(0|a).toString(16)).substr(-6),i.fillRect(o.x,o.y,o.width,o.height)),r.lineWidth&&(i.globalAlpha=r.lineAlpha*s,i.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),i.strokeRect(o.x,o.y,o.width,o.height));else if(r.type===e.CIRCLE)i.beginPath(),i.arc(o.x,o.y,o.radius,0,2*Math.PI),i.closePath(),r.fill&&(i.globalAlpha=r.fillAlpha*s,i.fillStyle="#"+("00000"+(0|a).toString(16)).substr(-6),i.fill()),r.lineWidth&&(i.globalAlpha=r.lineAlpha*s,i.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),i.stroke());else if(r.type===e.ELLIPSE){var u=2*o.width,d=2*o.height,p=o.x-u/2,f=o.y-d/2;i.beginPath();var g=u/2*.5522848,m=d/2*.5522848,y=p+u,v=f+d,x=p+u/2,b=f+d/2;i.moveTo(p,b),i.bezierCurveTo(p,b-m,x-g,f,x,f),i.bezierCurveTo(x+g,f,y,b-m,y,b),i.bezierCurveTo(y,b+m,x+g,v,x,v),i.bezierCurveTo(x-g,v,p,b+m,p,b),i.closePath(),r.fill&&(i.globalAlpha=r.fillAlpha*s,i.fillStyle="#"+("00000"+(0|a).toString(16)).substr(-6),i.fill()),r.lineWidth&&(i.globalAlpha=r.lineAlpha*s,i.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),i.stroke())}else if(r.type===e.ROUNDEDRECTANGLE){var _=o.x,w=o.y,T=o.width,P=o.height,C=o.radius,S=Math.min(T,P)/2|0;C=C>S?S:C,i.beginPath(),i.moveTo(_,w+C),i.lineTo(_,w+P-C),i.quadraticCurveTo(_,w+P,_+C,w+P),i.lineTo(_+T-C,w+P),i.quadraticCurveTo(_+T,w+P,_+T,w+P-C),i.lineTo(_+T,w+C),i.quadraticCurveTo(_+T,w,_+T-C,w),i.lineTo(_+C,w),i.quadraticCurveTo(_,w,_,w+C),i.closePath(),(r.fillColor||0===r.fillColor)&&(i.globalAlpha=r.fillAlpha*s,i.fillStyle="#"+("00000"+(0|a).toString(16)).substr(-6),i.fill()),r.lineWidth&&(i.globalAlpha=r.lineAlpha*s,i.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),i.stroke())}}},PIXI.CanvasGraphics.renderGraphicsMask=function(t,i){var s=t.graphicsData.length;if(0!==s){i.beginPath();for(var n=0;n<s;n++){var r=t.graphicsData[n],o=r.shape;if(r.type===e.POLYGON){var a=o.points;i.moveTo(a[0],a[1]);for(var h=1;h<a.length/2;h++)i.lineTo(a[2*h],a[2*h+1]);a[0]===a[a.length-2]&&a[1]===a[a.length-1]&&i.closePath()}else if(r.type===e.RECTANGLE)i.rect(o.x,o.y,o.width,o.height),i.closePath();else if(r.type===e.CIRCLE)i.arc(o.x,o.y,o.radius,0,2*Math.PI),i.closePath();else if(r.type===e.ELLIPSE){var l=2*o.width,c=2*o.height,u=o.x-l/2,d=o.y-c/2,p=l/2*.5522848,f=c/2*.5522848,g=u+l,m=d+c,y=u+l/2,v=d+c/2;i.moveTo(u,v),i.bezierCurveTo(u,v-f,y-p,d,y,d),i.bezierCurveTo(y+p,d,g,v-f,g,v),i.bezierCurveTo(g,v+f,y+p,m,y,m),i.bezierCurveTo(y-p,m,u,v+f,u,v),i.closePath()}else if(r.type===e.ROUNDEDRECTANGLE){var x=o.x,b=o.y,_=o.width,w=o.height,T=o.radius,P=Math.min(_,w)/2|0;T=T>P?P:T,i.moveTo(x,b+T),i.lineTo(x,b+w-T),i.quadraticCurveTo(x,b+w,x+T,b+w),i.lineTo(x+_-T,b+w),i.quadraticCurveTo(x+_,b+w,x+_,b+w-T),i.lineTo(x+_,b+T),i.quadraticCurveTo(x+_,b,x+_-T,b),i.lineTo(x+T,b),i.quadraticCurveTo(x,b,x,b+T),i.closePath()}}}},PIXI.CanvasGraphics.updateGraphicsTint=function(t){if(16777215!==t.tint)for(var e=(t.tint>>16&255)/255,i=(t.tint>>8&255)/255,s=(255&t.tint)/255,n=0;n<t.graphicsData.length;n++){var r=t.graphicsData[n],o=0|r.fillColor,a=0|r.lineColor;r._fillTint=((o>>16&255)/255*e*255<<16)+((o>>8&255)/255*i*255<<8)+(255&o)/255*s*255,r._lineTint=((a>>16&255)/255*e*255<<16)+((a>>8&255)/255*i*255<<8)+(255&a)/255*s*255}},e.GraphicsData=function(t,e,i,s,n,r,o){this.lineWidth=t,this.lineColor=e,this.lineAlpha=i,this._lineTint=e,this.fillColor=s,this.fillAlpha=n,this._fillTint=s,this.fill=r,this.shape=o,this.type=o.type},e.GraphicsData.prototype.constructor=e.GraphicsData,e.GraphicsData.prototype.clone=function(){return new e.GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.fill,this.shape)},e.Graphics=function(t,i,s){void 0===i&&(i=0),void 0===s&&(s=0),this.type=e.GRAPHICS,this.physicsType=e.SPRITE,this.anchor=new e.Point,PIXI.DisplayObjectContainer.call(this),this.renderable=!0,this.fillAlpha=1,this.lineWidth=0,this.lineColor=0,this.graphicsData=[],this.tint=16777215,this.blendMode=PIXI.blendModes.NORMAL,this.currentPath=null,this._webGL=[],this.isMask=!1,this.boundsPadding=0,this._localBounds=new e.Rectangle(0,0,1,1),this.dirty=!0,this._boundsDirty=!1,this.webGLDirty=!1,this.cachedSpriteDirty=!1,e.Component.Core.init.call(this,t,i,s,"",null)},e.Graphics.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),e.Graphics.prototype.constructor=e.Graphics,e.Component.Core.install.call(e.Graphics.prototype,["Angle","AutoCull","Bounds","Destroy","FixedToCamera","InputEnabled","InWorld","LifeSpan","PhysicsBody","Reset"]),e.Graphics.prototype.preUpdatePhysics=e.Component.PhysicsBody.preUpdate,e.Graphics.prototype.preUpdateLifeSpan=e.Component.LifeSpan.preUpdate,e.Graphics.prototype.preUpdateInWorld=e.Component.InWorld.preUpdate,e.Graphics.prototype.preUpdateCore=e.Component.Core.preUpdate,e.Graphics.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},e.Graphics.prototype.postUpdate=function(){e.Component.PhysicsBody.postUpdate.call(this),e.Component.FixedToCamera.postUpdate.call(this),this._boundsDirty&&(this.updateLocalBounds(),this._boundsDirty=!1);for(var t=0;t<this.children.length;t++)this.children[t].postUpdate()},e.Graphics.prototype.destroy=function(t){this.clear(),e.Component.Destroy.prototype.destroy.call(this,t)},e.Graphics.prototype.drawTriangle=function(t,i){void 0===i&&(i=!1);var s=new e.Polygon(t);if(i){var n=new e.Point(this.game.camera.x-t[0].x,this.game.camera.y-t[0].y),r=new e.Point(t[1].x-t[0].x,t[1].y-t[0].y),o=new e.Point(t[1].x-t[2].x,t[1].y-t[2].y).cross(r);n.dot(o)>0&&this.drawPolygon(s)}else this.drawPolygon(s)},e.Graphics.prototype.drawTriangles=function(t,i,s){void 0===s&&(s=!1);var n,r=new e.Point,o=new e.Point,a=new e.Point,h=[];if(i)if(t[0]instanceof e.Point)for(n=0;n<i.length/3;n++)h.push(t[i[3*n]]),h.push(t[i[3*n+1]]),h.push(t[i[3*n+2]]),3===h.length&&(this.drawTriangle(h,s),h=[]);else for(n=0;n<i.length;n++)r.x=t[2*i[n]],r.y=t[2*i[n]+1],h.push(r.copyTo({})),3===h.length&&(this.drawTriangle(h,s),h=[]);else if(t[0]instanceof e.Point)for(n=0;n<t.length/3;n++)this.drawTriangle([t[3*n],t[3*n+1],t[3*n+2]],s);else for(n=0;n<t.length/6;n++)r.x=t[6*n+0],r.y=t[6*n+1],o.x=t[6*n+2],o.y=t[6*n+3],a.x=t[6*n+4],a.y=t[6*n+5],this.drawTriangle([r,o,a],s)},e.Graphics.prototype.lineStyle=function(t,i,s){return this.lineWidth=t||0,this.lineColor=i||0,this.lineAlpha=void 0===s?1:s,this.currentPath&&(this.currentPath.shape.points.length?this.drawShape(new e.Polygon(this.currentPath.shape.points.slice(-2))):(this.currentPath.lineWidth=this.lineWidth,this.currentPath.lineColor=this.lineColor,this.currentPath.lineAlpha=this.lineAlpha)),this},e.Graphics.prototype.moveTo=function(t,i){return this.drawShape(new e.Polygon([t,i])),this},e.Graphics.prototype.lineTo=function(t,e){return this.currentPath||this.moveTo(0,0),this.currentPath.shape.points.push(t,e),this.dirty=!0,this._boundsDirty=!0,this},e.Graphics.prototype.quadraticCurveTo=function(t,e,i,s){this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);var n,r,o=this.currentPath.shape.points;0===o.length&&this.moveTo(0,0);for(var a=o[o.length-2],h=o[o.length-1],l=0,c=1;c<=20;++c)n=a+(t-a)*(l=c/20),r=h+(e-h)*l,o.push(n+(t+(i-t)*l-n)*l,r+(e+(s-e)*l-r)*l);return this.dirty=!0,this._boundsDirty=!0,this},e.Graphics.prototype.bezierCurveTo=function(t,e,i,s,n,r){this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);for(var o,a,h,l,c,u=this.currentPath.shape.points,d=u[u.length-2],p=u[u.length-1],f=0,g=1;g<=20;++g)h=(a=(o=1-(f=g/20))*o)*o,c=(l=f*f)*f,u.push(h*d+3*a*f*t+3*o*l*i+c*n,h*p+3*a*f*e+3*o*l*s+c*r);return this.dirty=!0,this._boundsDirty=!0,this},e.Graphics.prototype.arcTo=function(t,e,i,s,n){this.currentPath?0===this.currentPath.shape.points.length&&this.currentPath.shape.points.push(t,e):this.moveTo(t,e);var r=this.currentPath.shape.points,o=r[r.length-2],a=r[r.length-1]-e,h=o-t,l=s-e,c=i-t,u=Math.abs(a*c-h*l);if(u<1e-8||0===n)r[r.length-2]===t&&r[r.length-1]===e||r.push(t,e);else{var d=a*a+h*h,p=l*l+c*c,f=a*l+h*c,g=n*Math.sqrt(d)/u,m=n*Math.sqrt(p)/u,y=g*f/d,v=m*f/p,x=g*c+m*h,b=g*l+m*a,_=h*(m+y),w=a*(m+y),T=c*(g+v),P=l*(g+v),C=Math.atan2(w-b,_-x),S=Math.atan2(P-b,T-x);this.arc(x+t,b+e,n,C,S,h*l>c*a)}return this.dirty=!0,this._boundsDirty=!0,this},e.Graphics.prototype.arc=function(t,e,i,s,n,r,o){if(s===n)return this;void 0===r&&(r=!1),void 0===o&&(o=40),!r&&n<=s?n+=2*Math.PI:r&&s<=n&&(s+=2*Math.PI);var a=r?-1*(s-n):n-s,h=Math.ceil(Math.abs(a)/(2*Math.PI))*o;if(0===a)return this;var l=t+Math.cos(s)*i,c=e+Math.sin(s)*i;r&&this.filling?this.moveTo(t,e):this.moveTo(l,c);for(var u=this.currentPath.shape.points,d=a/(2*h),p=2*d,f=Math.cos(d),g=Math.sin(d),m=h-1,y=m%1/m,v=0;v<=m;v++){var x=d+s+p*(v+y*v),b=Math.cos(x),_=-Math.sin(x);u.push((f*b+g*_)*i+t,(f*-_+g*b)*i+e)}return this.dirty=!0,this._boundsDirty=!0,this},e.Graphics.prototype.beginFill=function(t,e){return this.filling=!0,this.fillColor=t||0,this.fillAlpha=void 0===e?1:e,this.currentPath&&this.currentPath.shape.points.length<=2&&(this.currentPath.fill=this.filling,this.currentPath.fillColor=this.fillColor,this.currentPath.fillAlpha=this.fillAlpha),this},e.Graphics.prototype.endFill=function(){return this.filling=!1,this.fillColor=null,this.fillAlpha=1,this},e.Graphics.prototype.drawRect=function(t,i,s,n){return this.drawShape(new e.Rectangle(t,i,s,n)),this},e.Graphics.prototype.drawRoundedRect=function(t,i,s,n,r){return this.drawShape(new e.RoundedRectangle(t,i,s,n,r)),this},e.Graphics.prototype.drawCircle=function(t,i,s){return this.drawShape(new e.Circle(t,i,s)),this},e.Graphics.prototype.drawEllipse=function(t,i,s,n){return this.drawShape({x:t,y:i,width:s,height:n,type:e.ELLIPSE}),this},e.Graphics.prototype.drawPolygon=function(t){t instanceof e.Polygon&&(t=t.points);var i=t;if(!Array.isArray(i)){i=new Array(arguments.length);for(var s=0;s<i.length;++s)i[s]=arguments[s]}return this.drawShape(new e.Polygon(i)),this},e.Graphics.prototype.clear=function(){return this.lineWidth=0,this.filling=!1,this.dirty=!0,this._boundsDirty=!0,this.clearDirty=!0,this.graphicsData=[],this.updateLocalBounds(),this},e.Graphics.prototype.generateTexture=function(t,e,i){void 0===t&&(t=1),void 0===e&&(e=PIXI.scaleModes.DEFAULT),void 0===i&&(i=0);var s=this.getBounds();s.width+=i,s.height+=i;var n=new PIXI.CanvasBuffer(s.width*t,s.height*t),r=PIXI.Texture.fromCanvas(n.canvas,e);return r.baseTexture.resolution=t,n.context.scale(t,t),n.context.translate(-s.x,-s.y),PIXI.CanvasGraphics.renderGraphics(this,n.context),r},e.Graphics.prototype._renderWebGL=function(t){if(!1!==this.visible&&0!==this.alpha&&!0!==this.isMask){if(this._cacheAsBitmap)return(this.dirty||this.cachedSpriteDirty)&&(this._generateCachedSprite(),this.updateCachedSpriteTexture(),this.cachedSpriteDirty=!1,this.dirty=!1),this._cachedSprite.worldAlpha=this.worldAlpha,void PIXI.Sprite.prototype._renderWebGL.call(this._cachedSprite,t);if(t.spriteBatch.stop(),t.blendModeManager.setBlendMode(this.blendMode),this._mask&&t.maskManager.pushMask(this._mask,t),this._filters&&t.filterManager.pushFilter(this._filterBlock),this.blendMode!==t.spriteBatch.currentBlendMode){t.spriteBatch.currentBlendMode=this.blendMode;var e=PIXI.blendModesWebGL[t.spriteBatch.currentBlendMode];t.spriteBatch.gl.blendFunc(e[0],e[1])}if(this.webGLDirty&&(this.dirty=!0,this.webGLDirty=!1),PIXI.WebGLGraphics.renderGraphics(this,t),this.children.length){t.spriteBatch.start();for(var i=0;i<this.children.length;i++)this.children[i]._renderWebGL(t);t.spriteBatch.stop()}this._filters&&t.filterManager.popFilter(),this._mask&&t.maskManager.popMask(this.mask,t),t.drawCount++,t.spriteBatch.start()}},e.Graphics.prototype._renderCanvas=function(t){if(!1!==this.visible&&0!==this.alpha&&!0!==this.isMask){if(this._prevTint!==this.tint&&(this.dirty=!0,this._prevTint=this.tint),this._cacheAsBitmap)return(this.dirty||this.cachedSpriteDirty)&&(this._generateCachedSprite(),this.updateCachedSpriteTexture(),this.cachedSpriteDirty=!1,this.dirty=!1),this._cachedSprite.alpha=this.alpha,void PIXI.Sprite.prototype._renderCanvas.call(this._cachedSprite,t);var e=t.context,i=this.worldTransform;this.blendMode!==t.currentBlendMode&&(t.currentBlendMode=this.blendMode,e.globalCompositeOperation=PIXI.blendModesCanvas[t.currentBlendMode]),this._mask&&t.maskManager.pushMask(this._mask,t);var s=t.resolution,n=i.tx*t.resolution+t.shakeX,r=i.ty*t.resolution+t.shakeY;e.setTransform(i.a*s,i.b*s,i.c*s,i.d*s,n,r),PIXI.CanvasGraphics.renderGraphics(this,e);for(var o=0;o<this.children.length;o++)this.children[o]._renderCanvas(t);this._mask&&t.maskManager.popMask(t)}},e.Graphics.prototype.getBounds=function(t){if(this._currentBounds)return this._currentBounds;if(this.isMask)return e.EmptyRectangle;this.dirty&&(this.updateLocalBounds(),this.webGLDirty=!0,this.cachedSpriteDirty=!0,this.dirty=!1);var i=this._localBounds,s=i.x,n=i.width+i.x,r=i.y,o=i.height+i.y,a=t||this.worldTransform,h=a.a,l=a.b,c=a.c,u=a.d,d=a.tx,p=a.ty,f=h*n+c*o+d,g=u*o+l*n+p,m=h*s+c*o+d,y=u*o+l*s+p,v=h*s+c*r+d,x=u*r+l*s+p,b=h*n+c*r+d,_=u*r+l*n+p,w=f,T=g,P=f,C=g;return P=m<P?m:P,P=v<P?v:P,P=b<P?b:P,C=y<C?y:C,C=x<C?x:C,C=_<C?_:C,w=m>w?m:w,w=v>w?v:w,w=b>w?b:w,T=y>T?y:T,T=x>T?x:T,T=_>T?_:T,this._bounds.x=P,this._bounds.width=w-P,this._bounds.y=C,this._bounds.height=T-C,this._currentBounds=this._bounds,this._currentBounds},e.Graphics.prototype.getLocalBounds=function(){var t=this.worldTransform;this.worldTransform=e.identityMatrix;for(var i=0;i<this.children.length;i++)this.children[i].updateTransform();var s=this.getBounds();for(this.worldTransform=t,i=0;i<this.children.length;i++)this.children[i].updateTransform();return s},e.Graphics.prototype.containsPoint=function(t,i){void 0===i&&(i=new e.Point),this.worldTransform.applyInverse(t,i);for(var s=this.graphicsData,n=0;n<s.length;n++){var r=s[n];if(r.fill&&(r.shape&&r.shape.contains(i.x,i.y)))return!0}return!1},e.Graphics.prototype.getVisualBounds=function(t){return this._boundsDirty&&(this.updateLocalBounds(),this._boundsDirty=!1),this._localBounds.clone(t)},e.Graphics.prototype.updateLocalBounds=function(){var t=1/0,i=-1/0,s=1/0,n=-1/0;if(this.graphicsData.length)for(var r,o,a,h,l,c,u=0;u<this.graphicsData.length;u++){var d=this.graphicsData[u],p=d.type,f=d.lineWidth;if(r=d.shape,p===e.RECTANGLE||p===e.ROUNDEDRECTANGLE)a=r.x-f/2,h=r.y-f/2,l=r.width+f,c=r.height+f,t=a<t?a:t,i=a+l>i?a+l:i,s=h<s?h:s,n=h+c>n?h+c:n;else if(p===e.CIRCLE)a=r.x,h=r.y,l=r.radius+f/2,c=r.radius+f/2,t=a-l<t?a-l:t,i=a+l>i?a+l:i,s=h-c<s?h-c:s,n=h+c>n?h+c:n;else if(p===e.ELLIPSE)a=r.x,h=r.y,l=r.width+f/2,c=r.height+f/2,t=a-l<t?a-l:t,i=a+l>i?a+l:i,s=h-c<s?h-c:s,n=h+c>n?h+c:n;else{o=r.points;for(var g=0;g<o.length;g++)o[g]instanceof e.Point?(a=o[g].x,h=o[g].y):(a=o[g],h=o[g+1],g<o.length-1&&g++),t=a-f<t?a-f:t,i=a+f>i?a+f:i,s=h-f<s?h-f:s,n=h+f>n?h+f:n}}else t=0,i=0,s=0,n=0;var m=this.boundsPadding;this._localBounds.x=t-m,this._localBounds.width=i-t+2*m,this._localBounds.y=s-m,this._localBounds.height=n-s+2*m},e.Graphics.prototype._generateCachedSprite=function(){var t=this.getLocalBounds();if(this._cachedSprite)this._cachedSprite.buffer.resize(t.width,t.height);else{var e=new PIXI.CanvasBuffer(t.width,t.height),i=PIXI.Texture.fromCanvas(e.canvas);this._cachedSprite=new PIXI.Sprite(i),this._cachedSprite.buffer=e,this._cachedSprite.worldTransform=this.worldTransform}this._cachedSprite.anchor.x=-t.x/t.width,this._cachedSprite.anchor.y=-t.y/t.height,this._cachedSprite.buffer.context.translate(-t.x,-t.y),this.worldAlpha=1,PIXI.CanvasGraphics.renderGraphics(this,this._cachedSprite.buffer.context),this._cachedSprite.alpha=this.alpha},e.Graphics.prototype.updateCachedSpriteTexture=function(){var t=this._cachedSprite,e=t.texture,i=t.buffer.canvas;e.baseTexture.width=i.width,e.baseTexture.height=i.height,e.crop.width=e.frame.width=i.width,e.crop.height=e.frame.height=i.height,t._width=i.width,t._height=i.height,e.baseTexture.dirty()},e.Graphics.prototype.destroyCachedSprite=function(){this._cachedSprite.texture.destroy(!0),this._cachedSprite=null},e.Graphics.prototype.drawShape=function(t){this.currentPath&&this.currentPath.shape.points.length<=2&&this.graphicsData.pop(),this.currentPath=null,t instanceof e.Polygon&&(t=t.clone()).flatten();var i=new e.GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.filling,t);return this.graphicsData.push(i),i.type===e.POLYGON&&(i.shape.closed=this.filling,this.currentPath=i),this.dirty=!0,this._boundsDirty=!0,i},Object.defineProperty(e.Graphics.prototype,"cacheAsBitmap",{get:function(){return this._cacheAsBitmap},set:function(t){this._cacheAsBitmap=t,this._cacheAsBitmap?this._generateCachedSprite():this.destroyCachedSprite(),this.dirty=!0,this.webGLDirty=!0}}),e.RenderTexture=function(t,i,s,n,r,o,a,h){if(void 0===i&&(i=100),void 0===s&&(s=100),void 0===n&&(n=""),void 0===r&&(r=e.scaleModes.DEFAULT),void 0===o&&(o=1),void 0===a&&(a=PIXI.defaultRenderer),void 0===h&&(h=0),this.game=t,this.key=n,this.type=e.RENDERTEXTURE,this._tempMatrix=new e.Matrix,this.width=i,this.height=s,this.resolution=o,this.frame=new e.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution),this.crop=this.frame.clone(),this.baseTexture=new PIXI.BaseTexture,this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution,this.baseTexture._glTextures=[],this.baseTexture.resolution=this.resolution,this.baseTexture.scaleMode=r,this.baseTexture.hasLoaded=!0,PIXI.Texture.call(this,this.baseTexture,this.frame.clone()),this.renderer=a,this.renderer.type===e.WEBGL){var l=this.renderer.gl;this.baseTexture.textureIndex=h,this.baseTexture._dirty[l.id]=!1,this.textureBuffer=new PIXI.FilterTexture(l,this.width,this.height,this.baseTexture.scaleMode,h),this.baseTexture._glTextures[l.id]=this.textureBuffer.texture,this.projection=new e.Point(.5*this.width,.5*-this.height)}else this.textureBuffer=new PIXI.CanvasBuffer(this.width*this.resolution,this.height*this.resolution),this.baseTexture.source=this.textureBuffer.canvas;this.valid=!0,this.tempMatrix=new e.Matrix,this._updateUvs()},e.RenderTexture.prototype=Object.create(PIXI.Texture.prototype),e.RenderTexture.prototype.constructor=e.RenderTexture,e.RenderTexture.prototype.renderXY=function(t,i,s,n){t.updateTransform(),this._tempMatrix.copyFrom(t.worldTransform),this._tempMatrix.tx=i,this._tempMatrix.ty=s,this.renderer.type===e.WEBGL?this._renderWebGL(t,this._tempMatrix,n):this._renderCanvas(t,this._tempMatrix,n)},e.RenderTexture.prototype.renderRawXY=function(t,i,s,n){this._tempMatrix.identity().translate(i,s),this.renderer.type===e.WEBGL?this._renderWebGL(t,this._tempMatrix,n):this._renderCanvas(t,this._tempMatrix,n)},e.RenderTexture.prototype.render=function(t,i,s){void 0===i||null===i?this._tempMatrix.copyFrom(t.worldTransform):this._tempMatrix.copyFrom(i),this.renderer.type===e.WEBGL?this._renderWebGL(t,this._tempMatrix,s):this._renderCanvas(t,this._tempMatrix,s)},e.RenderTexture.prototype.resize=function(t,i,s){t===this.width&&i===this.height||(this.valid=t>0&&i>0,this.width=t,this.height=i,this.frame.width=this.crop.width=t*this.resolution,this.frame.height=this.crop.height=i*this.resolution,s&&(this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution),this.renderer.type===e.WEBGL&&(this.projection.x=this.width/2,this.projection.y=-this.height/2),this.valid&&this.textureBuffer.resize(this.width,this.height))},e.RenderTexture.prototype.clear=function(){this.valid&&(this.renderer.type===e.WEBGL&&this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER,this.textureBuffer.frameBuffer),this.textureBuffer.clear())},e.RenderTexture.prototype._renderWebGL=function(t,e,i){if(this.valid&&0!==t.alpha){var s=t.worldTransform;s.identity(),s.translate(0,2*this.projection.y),e&&s.append(e),s.scale(1,-1);for(var n=0;n<t.children.length;n++)t.children[n].updateTransform();var r=this.renderer.gl;r.viewport(0,0,this.width*this.resolution,this.height*this.resolution),r.bindFramebuffer(r.FRAMEBUFFER,this.textureBuffer.frameBuffer),i&&this.textureBuffer.clear(),this.renderer.spriteBatch.dirty=!0,this.renderer.renderDisplayObject(t,this.projection,this.textureBuffer.frameBuffer,e),this.renderer.spriteBatch.dirty=!0,r.bindFramebuffer(r.FRAMEBUFFER,null)}},e.RenderTexture.prototype._renderCanvas=function(t,e,i){if(this.valid&&0!==t.alpha){var s=t.worldTransform;s.identity(),e&&s.append(e);for(var n=0;n<t.children.length;n++)t.children[n].updateTransform();i&&this.textureBuffer.clear();var r=this.renderer.resolution;this.renderer.resolution=this.resolution,this.renderer.renderDisplayObject(t,this.textureBuffer.context,e),this.renderer.resolution=r}},e.RenderTexture.prototype.getImage=function(){var t=new Image;return t.src=this.getBase64(),t},e.RenderTexture.prototype.getBase64=function(){return this.getCanvas().toDataURL()},e.RenderTexture.prototype.getCanvas=function(){if(this.renderer.type===e.WEBGL){var t=this.renderer.gl,i=this.textureBuffer.width,s=this.textureBuffer.height,n=new Uint8Array(4*i*s);t.bindFramebuffer(t.FRAMEBUFFER,this.textureBuffer.frameBuffer),t.readPixels(0,0,i,s,t.RGBA,t.UNSIGNED_BYTE,n),t.bindFramebuffer(t.FRAMEBUFFER,null);var r=new PIXI.CanvasBuffer(i,s),o=r.context.getImageData(0,0,i,s);return o.data.set(n),r.context.putImageData(o,0,0),r.canvas}return this.textureBuffer.canvas},e.Text=function(t,i,s,n,r){i=i||0,s=s||0,n=void 0===n||null===n?"":n.toString(),this.canvas=e.CanvasPool.create(this),e.Sprite.call(this,t,i,s,PIXI.Texture.fromCanvas(this.canvas)),this.type=e.TEXT,this.physicsType=e.SPRITE,this.padding=new e.Point,this.textBounds=null,this.context=this.canvas.getContext("2d"),this.colors=[],this.strokeColors=[],this.fontStyles=[],this.fontWeights=[],this.autoRound=!1,this.useAdvancedWrap=!1,this.splitRegExp=/(?:\r\n|\r|\n)/,this.characterLimitSize=-1,this.characterLimitSuffix="",this._testString="|MÉq",this._res=t.renderer.resolution,this._text=n,this._fontComponents=null,this._lineSpacing=0,this._charCount=0,this._width=0,this._height=0,this.style={},this.setStyle(r||{}),""!==n&&this.updateText()},e.Text.prototype=Object.create(e.Sprite.prototype),e.Text.prototype.constructor=e.Text,e.Text.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},e.Text.prototype.update=function(){},e.Text.prototype.destroy=function(t){this.texture.destroy(!0),e.Component.Destroy.prototype.destroy.call(this,t)},e.Text.prototype.setShadow=function(t,e,i,s,n,r){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i="rgba(0, 0, 0, 1)"),void 0===s&&(s=0),void 0===n&&(n=!0),void 0===r&&(r=!0),this.style.shadowOffsetX=t,this.style.shadowOffsetY=e,this.style.shadowColor=i,this.style.shadowBlur=s,this.style.shadowStroke=n,this.style.shadowFill=r,this.dirty=!0,this},e.Text.prototype.setStyle=function(t,e){void 0===e&&(e=!1);var i=Object.assign({},t);i.font=t.font||"bold 20pt Arial",i.backgroundColor=t.backgroundColor||null,i.fill=t.fill||"black",i.align=(t.align||"left").toLowerCase(),i.boundsAlignH=(t.boundsAlignH||"left").toLowerCase(),i.boundsAlignV=(t.boundsAlignV||"top").toLowerCase(),i.stroke=t.stroke||"black",i.strokeThickness=Number(t.strokeThickness)||0,i.wordWrap=t.wordWrap||!1,i.wordWrapWidth=t.wordWrapWidth||100,i.maxLines=t.maxLines||0,i.shadowOffsetX=t.shadowOffsetX||0,i.shadowOffsetY=t.shadowOffsetY||0,i.shadowColor=t.shadowColor||"rgba(0,0,0,0)",i.shadowBlur=t.shadowBlur||0,i.tabs=t.tabs||0;var s=this.fontToComponents(i.font);return i.fontStyle&&(s.fontStyle=i.fontStyle),i.fontVariant&&(s.fontVariant=i.fontVariant),i.fontWeight&&(s.fontWeight=i.fontWeight),i.fontSize&&("number"==typeof i.fontSize&&(i.fontSize=i.fontSize+"px"),s.fontSize=i.fontSize),this._fontComponents=s,i.font=this.componentsToFont(this._fontComponents),this.style=i,this.dirty=!0,e&&this.updateText(),this},e.Text.prototype.updateText=function(){this.texture.baseTexture.resolution=this._res,this.context.font=this.style.font;var t=this.text;this.characterLimitSize>-1&&this.characterLimitSize<t.length&&(t=this.text.substring(0,this.characterLimitSize)+this.characterLimitSuffix),this.style.wordWrap&&(t=this.runWordWrap(this.text));var e=t.split(this.splitRegExp),i=this.style.tabs,s=[],n=0,r=this.determineFontProperties(this.style.font),o=e.length;this.style.maxLines>0&&this.style.maxLines<e.length&&(o=this.style.maxLines),this._charCount=0;for(var a=0;a<o;a++){if(0===i){l=this.style.strokeThickness+this.padding.x;this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?l+=this.measureLine(e[a]):l+=this.context.measureText(e[a]).width,this.style.wordWrap&&(l-=this.context.measureText(" ").width)}else{var h=e[a].split(/(?:\t)/),l=this.padding.x+this.style.strokeThickness;if(Array.isArray(i))for(var c=0,u=0;u<h.length;u++){var d=0;d=this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?this.measureLine(h[u]):Math.ceil(this.context.measureText(h[u]).width),u>0&&(c+=i[u-1]),l=c+d}else for(u=0;u<h.length;u++)this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?l+=this.measureLine(h[u]):l+=Math.ceil(this.context.measureText(h[u]).width),l+=this.game.math.snapToCeil(l,i)-l}s[a]=Math.ceil(l),n=Math.max(n,s[a])}this.canvas.width=n*this._res;var p=r.fontSize+this.style.strokeThickness+this.padding.y,f=p*o,g=this._lineSpacing;g<0&&Math.abs(g)>p&&(g=-p),0!==g&&(f+=g>0?g*e.length:g*(e.length-1)),this.canvas.height=f*this._res,this.context.scale(this._res,this._res),navigator.isCocoonJS&&this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.style.backgroundColor&&(this.context.fillStyle=this.style.backgroundColor,this.context.fillRect(0,0,this.canvas.width,this.canvas.height)),this.context.fillStyle=this.style.fill,this.context.font=this.style.font,this.context.strokeStyle=this.style.stroke,this.context.textBaseline="alphabetic",this.context.lineWidth=this.style.strokeThickness,this.context.lineCap="round",this.context.lineJoin="round";var m,y;for(this._charCount=0,a=0;a<o;a++)m=this.style.strokeThickness/2,y=this.style.strokeThickness/2+a*p+r.ascent,a>0&&(y+=g*a),"right"===this.style.align?m+=n-s[a]:"center"===this.style.align&&(m+=(n-s[a])/2),this.autoRound&&(m=Math.round(m),y=Math.round(y)),this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?this.updateLine(e[a],m,y):(this.style.stroke&&this.style.strokeThickness&&(this.updateShadow(this.style.shadowStroke),0===i?this.context.strokeText(e[a],m,y):this.renderTabLine(e[a],m,y,!1)),this.style.fill&&(this.updateShadow(this.style.shadowFill),0===i?this.context.fillText(e[a],m,y):this.renderTabLine(e[a],m,y,!0)));this.updateTexture(),this.dirty=!1},e.Text.prototype.renderTabLine=function(t,e,i,s){var n=t.split(/(?:\t)/),r=this.style.tabs,o=0;if(Array.isArray(r))for(var a=0,h=0;h<n.length;h++)h>0&&(a+=r[h-1]),o=e+a,s?this.context.fillText(n[h],o,i):this.context.strokeText(n[h],o,i);else for(h=0;h<n.length;h++){var l=Math.ceil(this.context.measureText(n[h]).width);o=this.game.math.snapToCeil(e,r),s?this.context.fillText(n[h],o,i):this.context.strokeText(n[h],o,i),e=o+l}},e.Text.prototype.updateShadow=function(t){t?(this.context.shadowOffsetX=this.style.shadowOffsetX,this.context.shadowOffsetY=this.style.shadowOffsetY,this.context.shadowColor=this.style.shadowColor,this.context.shadowBlur=this.style.shadowBlur):(this.context.shadowOffsetX=0,this.context.shadowOffsetY=0,this.context.shadowColor=0,this.context.shadowBlur=0)},e.Text.prototype.measureLine=function(t){for(var e=0,i=0;i<t.length;i++){var s=t[i];if(this.fontWeights.length>0||this.fontStyles.length>0){var n=this.fontToComponents(this.context.font);this.fontStyles[this._charCount]&&(n.fontStyle=this.fontStyles[this._charCount]),this.fontWeights[this._charCount]&&(n.fontWeight=this.fontWeights[this._charCount]),this.context.font=this.componentsToFont(n)}this.style.stroke&&this.style.strokeThickness&&(this.strokeColors[this._charCount]&&(this.context.strokeStyle=this.strokeColors[this._charCount]),this.updateShadow(this.style.shadowStroke)),this.style.fill&&(this.colors[this._charCount]&&(this.context.fillStyle=this.colors[this._charCount]),this.updateShadow(this.style.shadowFill)),e+=this.context.measureText(s).width,this._charCount++}return Math.ceil(e)},e.Text.prototype.updateLine=function(t,e,i){for(var s=0;s<t.length;s++){var n=t[s];if(this.fontWeights.length>0||this.fontStyles.length>0){var r=this.fontToComponents(this.context.font);this.fontStyles[this._charCount]&&(r.fontStyle=this.fontStyles[this._charCount]),this.fontWeights[this._charCount]&&(r.fontWeight=this.fontWeights[this._charCount]),this.context.font=this.componentsToFont(r)}this.style.stroke&&this.style.strokeThickness&&(this.strokeColors[this._charCount]&&(this.context.strokeStyle=this.strokeColors[this._charCount]),this.updateShadow(this.style.shadowStroke),this.context.strokeText(n,e,i)),this.style.fill&&(this.colors[this._charCount]&&(this.context.fillStyle=this.colors[this._charCount]),this.updateShadow(this.style.shadowFill),this.context.fillText(n,e,i)),e+=this.context.measureText(n).width,this._charCount++}},e.Text.prototype.clearColors=function(){return this.colors=[],this.strokeColors=[],this.dirty=!0,this},e.Text.prototype.clearFontValues=function(){return this.fontStyles=[],this.fontWeights=[],this.dirty=!0,this},e.Text.prototype.addColor=function(t,e){return this.colors[e]=t,this.dirty=!0,this},e.Text.prototype.addStrokeColor=function(t,e){return this.strokeColors[e]=t,this.dirty=!0,this},e.Text.prototype.addFontStyle=function(t,e){return this.fontStyles[e]=t,this.dirty=!0,this},e.Text.prototype.addFontWeight=function(t,e){return this.fontWeights[e]=t,this.dirty=!0,this},e.Text.prototype.precalculateWordWrap=function(t){return this.texture.baseTexture.resolution=this._res,this.context.font=this.style.font,this.runWordWrap(t).split(/(?:\r\n|\r|\n)/)},e.Text.prototype.runWordWrap=function(t){return this.useAdvancedWrap?this.advancedWordWrap(t):this.basicWordWrap(t)},e.Text.prototype.advancedWordWrap=function(t){for(var e=this.context,i=this.style.wordWrapWidth,s="",n=t.replace(/ +/gi," ").split(/\r?\n/gi),r=n.length,o=0;o<r;o++){var a=n[o],h="";if(a=a.replace(/^ *|\s*$/gi,""),e.measureText(a).width<i)s+=a+"\n";else{for(var l=i,c=a.split(" "),u=0;u<c.length;u++){var d=c[u],p=d+" ",f=e.measureText(p).width;if(f>l){if(0===u){for(var g=p;g.length&&(g=g.slice(0,-1),!((f=e.measureText(g).width)<=l)););if(!g.length)throw new Error("This text's wordWrapWidth setting is less than a single character!");var m=d.substr(g.length);c[u]=m,h+=g}var y=c[u].length?u:u+1,v=c.slice(y).join(" ").replace(/[ \n]*$/gi,"");n[o+1]=v+" "+(n[o+1]||""),r=n.length;break}h+=p,l-=f}s+=h.replace(/[ \n]*$/gi,"")+"\n"}}return s=s.replace(/[\s|\n]*$/gi,"")},e.Text.prototype.basicWordWrap=function(t){for(var e="",i=t.split("\n"),s=0;s<i.length;s++){for(var n=this.style.wordWrapWidth,r=i[s].split(" "),o=0;o<r.length;o++){var a=this.context.measureText(r[o]).width,h=a+this.context.measureText(" ").width;h>n?(o>0&&(e+="\n"),e+=r[o]+" ",n=this.style.wordWrapWidth-a):(n-=h,e+=r[o]+" ")}s<i.length-1&&(e+="\n")}return e},e.Text.prototype.updateFont=function(t){var e=this.componentsToFont(t);this.style.font!==e&&(this.style.font=e,this.dirty=!0,this.parent&&this.updateTransform())},e.Text.prototype.fontToComponents=function(t){var e=t.match(/^\s*(?:\b(normal|italic|oblique|inherit)?\b)\s*(?:\b(normal|small-caps|inherit)?\b)\s*(?:\b(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit)?\b)\s*(?:\b(xx-small|x-small|small|medium|large|x-large|xx-large|larger|smaller|0|\d*(?:[.]\d*)?(?:%|[a-z]{2,5}))?\b)\s*(.*)\s*$/);if(e){var i=e[5].trim();return/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(i)||/['",]/.exec(i)||(i="'"+i+"'"),{font:t,fontStyle:e[1]||"normal",fontVariant:e[2]||"normal",fontWeight:e[3]||"normal",fontSize:e[4]||"medium",fontFamily:i}}return console.warn("Phaser.Text - unparsable CSS font: "+t),{font:t}},e.Text.prototype.componentsToFont=function(t){var e,i=[];return(e=t.fontStyle)&&"normal"!==e&&i.push(e),(e=t.fontVariant)&&"normal"!==e&&i.push(e),(e=t.fontWeight)&&"normal"!==e&&i.push(e),(e=t.fontSize)&&"medium"!==e&&i.push(e),(e=t.fontFamily)&&i.push(e),i.length||i.push(t.font),i.join(" ")},e.Text.prototype.setText=function(t,e){return void 0===e&&(e=!1),(t=t.toString()||"")===this._text?this:(this.text=t,e?this.updateText():this.dirty=!0,this)},e.Text.prototype.parseList=function(t){if(!Array.isArray(t))return this;for(var e="",i=0;i<t.length;i++)Array.isArray(t[i])?(e+=t[i].join("\t"),i<t.length-1&&(e+="\n")):(e+=t[i],i<t.length-1&&(e+="\t"));return this.text=e,this.dirty=!0,this},e.Text.prototype.setTextBounds=function(t,i,s,n){return void 0===t?this.textBounds=null:(this.textBounds?this.textBounds.setTo(t,i,s,n):this.textBounds=new e.Rectangle(t,i,s,n),this.style.wordWrapWidth>s&&(this.style.wordWrapWidth=s)),this.updateTexture(),this},e.Text.prototype.updateTexture=function(){var t=this.texture.baseTexture,e=this.texture.crop,i=this.texture.frame,s=this.canvas.width,n=this.canvas.height;if(t.width=s,t.height=n,e.width=s,e.height=n,i.width=s,i.height=n,this.texture.width=s,this.texture.height=n,this._width=s,this._height=n,this.textBounds){var r=this.textBounds.x,o=this.textBounds.y;"right"===this.style.boundsAlignH?r+=this.textBounds.width-this.canvas.width/this.resolution:"center"===this.style.boundsAlignH&&(r+=this.textBounds.halfWidth-this.canvas.width/this.resolution/2),"bottom"===this.style.boundsAlignV?o+=this.textBounds.height-this.canvas.height/this.resolution:"middle"===this.style.boundsAlignV&&(o+=this.textBounds.halfHeight-this.canvas.height/this.resolution/2),this.pivot.x=-r,this.pivot.y=-o}this.renderable=0!==s&&0!==n,this.texture.requiresReTint=!0,this.texture.baseTexture.dirty()},e.Text.prototype._renderWebGL=function(t){this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype._renderWebGL.call(this,t)},e.Text.prototype._renderCanvas=function(t){this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype._renderCanvas.call(this,t)},e.Text.prototype.determineFontProperties=function(t){var i=e.Text.fontPropertiesCache[t],s=this.testString||"|MÉq";if(!i){i={};var n=e.Text.fontPropertiesCanvas,r=e.Text.fontPropertiesContext;r.font=t;var o=Math.ceil(r.measureText(s).width),a=Math.ceil(r.measureText(s).width),h=2*a;if(a=1.4*a|0,n.width=o,n.height=h,r.fillStyle="#f00",r.fillRect(0,0,o,h),r.font=t,r.textBaseline="alphabetic",r.fillStyle="#000",r.fillText(s,0,a),!r.getImageData(0,0,o,h))return i.ascent=a,i.descent=a+6,i.fontSize=i.ascent+i.descent,e.Text.fontPropertiesCache[t]=i,i;var l,c,u=r.getImageData(0,0,o,h).data,d=u.length,p=4*o,f=0,g=!1;for(l=0;l<a;l++){for(c=0;c<p;c+=4)if(255!==u[f+c]){g=!0;break}if(g)break;f+=p}for(i.ascent=a-l,f=d-p,g=!1,l=h;l>a;l--){for(c=0;c<p;c+=4)if(255!==u[f+c]){g=!0;break}if(g)break;f-=p}i.descent=l-a,i.descent+=6,i.fontSize=i.ascent+i.descent,e.Text.fontPropertiesCache[t]=i}return i},e.Text.prototype.getBounds=function(t){return this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype.getBounds.call(this,t)},e.Text.prototype.setCharacterLimit=function(t,e){this.characterLimitSuffix=void 0===e?"":e,this.characterLimitSize=t,this.updateText()},Object.defineProperty(e.Text.prototype,"text",{get:function(){return this._text},set:function(t){t!==this._text&&(this._text=t.toString()||"",this.dirty=!0,this.parent&&this.updateTransform())}}),Object.defineProperty(e.Text.prototype,"cssFont",{get:function(){return this.componentsToFont(this._fontComponents)},set:function(t){t=t||"bold 20pt Arial",this._fontComponents=this.fontToComponents(t),this.updateFont(this._fontComponents)}}),Object.defineProperty(e.Text.prototype,"font",{get:function(){return this._fontComponents.fontFamily},set:function(t){t=(t=t||"Arial").trim(),/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(t)||/['",]/.exec(t)||(t="'"+t+"'"),this._fontComponents.fontFamily=t,this.updateFont(this._fontComponents)}}),Object.defineProperty(e.Text.prototype,"fontSize",{get:function(){var t=this._fontComponents.fontSize;return t&&/(?:^0$|px$)/.exec(t)?parseInt(t,10):t},set:function(t){"number"==typeof(t=t||"0")&&(t+="px"),this._fontComponents.fontSize=t,this.updateFont(this._fontComponents)}}),Object.defineProperty(e.Text.prototype,"fontWeight",{get:function(){return this._fontComponents.fontWeight||"normal"},set:function(t){t=t||"normal",this._fontComponents.fontWeight=t,this.updateFont(this._fontComponents)}}),Object.defineProperty(e.Text.prototype,"fontStyle",{get:function(){return this._fontComponents.fontStyle||"normal"},set:function(t){t=t||"normal",this._fontComponents.fontStyle=t,this.updateFont(this._fontComponents)}}),Object.defineProperty(e.Text.prototype,"fontVariant",{get:function(){return this._fontComponents.fontVariant||"normal"},set:function(t){t=t||"normal",this._fontComponents.fontVariant=t,this.updateFont(this._fontComponents)}}),Object.defineProperty(e.Text.prototype,"fill",{get:function(){return this.style.fill},set:function(t){t!==this.style.fill&&(this.style.fill=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"align",{get:function(){return this.style.align},set:function(t){(t=t.toLowerCase())!==this.style.align&&(this.style.align=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"resolution",{get:function(){return this._res},set:function(t){t!==this._res&&(this._res=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"tabs",{get:function(){return this.style.tabs},set:function(t){t!==this.style.tabs&&(this.style.tabs=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"boundsAlignH",{get:function(){return this.style.boundsAlignH},set:function(t){(t=t.toLowerCase())!==this.style.boundsAlignH&&(this.style.boundsAlignH=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"boundsAlignV",{get:function(){return this.style.boundsAlignV},set:function(t){(t=t.toLowerCase())!==this.style.boundsAlignV&&(this.style.boundsAlignV=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"stroke",{get:function(){return this.style.stroke},set:function(t){t!==this.style.stroke&&(this.style.stroke=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"strokeThickness",{get:function(){return this.style.strokeThickness},set:function(t){t!==this.style.strokeThickness&&(this.style.strokeThickness=Number(t),this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"wordWrap",{get:function(){return this.style.wordWrap},set:function(t){t!==this.style.wordWrap&&(this.style.wordWrap=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"wordWrapWidth",{get:function(){return this.style.wordWrapWidth},set:function(t){t!==this.style.wordWrapWidth&&(this.style.wordWrapWidth=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"lineSpacing",{get:function(){return this._lineSpacing},set:function(t){t!==this._lineSpacing&&(this._lineSpacing=parseFloat(t),this.dirty=!0,this.parent&&this.updateTransform())}}),Object.defineProperty(e.Text.prototype,"shadowOffsetX",{get:function(){return this.style.shadowOffsetX},set:function(t){t!==this.style.shadowOffsetX&&(this.style.shadowOffsetX=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"shadowOffsetY",{get:function(){return this.style.shadowOffsetY},set:function(t){t!==this.style.shadowOffsetY&&(this.style.shadowOffsetY=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"shadowColor",{get:function(){return this.style.shadowColor},set:function(t){t!==this.style.shadowColor&&(this.style.shadowColor=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"shadowBlur",{get:function(){return this.style.shadowBlur},set:function(t){t!==this.style.shadowBlur&&(this.style.shadowBlur=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"shadowStroke",{get:function(){return this.style.shadowStroke},set:function(t){t!==this.style.shadowStroke&&(this.style.shadowStroke=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"shadowFill",{get:function(){return this.style.shadowFill},set:function(t){t!==this.style.shadowFill&&(this.style.shadowFill=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"width",{get:function(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.x*(this.texture.frame.width/this.resolution)},set:function(t){this.scale.x=t/this.texture.frame.width,this._width=t}}),Object.defineProperty(e.Text.prototype,"height",{get:function(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.y*(this.texture.frame.height/this.resolution)},set:function(t){this.scale.y=t/this.texture.frame.height,this._height=t}}),Object.defineProperty(e.Text.prototype,"testString",{get:function(){return this._testString},set:function(t){this._testString=t,this.updateText()}}),e.Text.fontPropertiesCache={},e.Text.fontPropertiesCanvas=document.createElement("canvas"),e.Text.fontPropertiesContext=e.Text.fontPropertiesCanvas.getContext("2d"),e.BitmapText=function(t,i,s,n,r,o,a){i=i||0,s=s||0,n=n||"",r=r||"",o=o||32,a=a||"left",PIXI.DisplayObjectContainer.call(this),this.type=e.BITMAPTEXT,this.physicsType=e.SPRITE,this.textWidth=0,this.textHeight=0,this.anchor=new e.Point,this._prevAnchor=new e.Point,this._glyphs=[],this._maxWidth=0,this._text=r.toString()||"",this._data=t.cache.getBitmapFont(n),this._font=n,this._fontSize=o,this._align=a,this._letterSpacing=0,this._tint=16777215,this.updateText(),this.dirty=!1,e.Component.Core.init.call(this,t,i,s,"",null)},e.BitmapText.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),e.BitmapText.prototype.constructor=e.BitmapText,e.Component.Core.install.call(e.BitmapText.prototype,["Angle","AutoCull","Bounds","Destroy","FixedToCamera","InputEnabled","InWorld","LifeSpan","PhysicsBody","Reset"]),e.BitmapText.prototype.preUpdatePhysics=e.Component.PhysicsBody.preUpdate,e.BitmapText.prototype.preUpdateLifeSpan=e.Component.LifeSpan.preUpdate,e.BitmapText.prototype.preUpdateInWorld=e.Component.InWorld.preUpdate,e.BitmapText.prototype.preUpdateCore=e.Component.Core.preUpdate,e.BitmapText.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},e.BitmapText.prototype.postUpdate=function(){e.Component.PhysicsBody.postUpdate.call(this),e.Component.FixedToCamera.postUpdate.call(this),this.body&&this.body.type===e.Physics.ARCADE&&(this.textWidth===this.body.sourceWidth&&this.textHeight===this.body.sourceHeight||this.body.setSize(this.textWidth,this.textHeight))},e.BitmapText.prototype.setText=function(t){this.text=t},e.BitmapText.prototype.scanLine=function(t,e,i){for(var s=0,n=0,r=-1,o=0,a=null,h=this._maxWidth>0?this._maxWidth:null,l=[],c=0;c<i.length;c++){var u=c===i.length-1;if(/(?:\r\n|\r|\n)/.test(i.charAt(c)))return{width:n,text:i.substr(0,c),end:u,chars:l};var d=i.charCodeAt(c),p=t.chars[d],f=0;void 0===p&&(d=32,p=t.chars[d]);var g=a&&p.kerning[a]?p.kerning[a]:0;if(/(\s)/.test(i.charAt(c))&&(r=c,o=n),f=(g+p.texture.width+p.xOffset)*e,h&&n+f>=h&&r>-1)return{width:o||n,text:i.substr(0,c-(c-r)),end:!1,chars:l};n+=(p.xAdvance+g+this.letterSpacing)*e,l.push(s+(p.xOffset+g+this.letterSpacing)*e),s+=(p.xAdvance+g+this.letterSpacing)*e,a=d}return{width:n,text:i,end:u,chars:l}},e.BitmapText.prototype.cleanText=function(t,e){void 0===e&&(e="");var i=this._data.font;if(!i)return"";for(var s=/\r\n|\n\r|\n|\r/g,n=t.replace(s,"\n").split("\n"),r=0;r<n.length;r++){for(var o="",a=n[r],h=0;h<a.length;h++)o=i.chars[a.charCodeAt(h)]?o.concat(a[h]):o.concat(e);n[r]=o}return n.join("\n")},e.BitmapText.prototype.updateText=function(){var t=this._data.font;if(t){var e=this.text,i=this._fontSize/t.size,s=[],n=0;this.textWidth=0;do{(c=this.scanLine(t,i,e)).y=n,s.push(c),c.width>this.textWidth&&(this.textWidth=c.width),n+=t.lineHeight*i,e=e.substr(c.text.length+1)}while(!1===c.end);this.textHeight=n;for(var r=0,o=0,a=this.textWidth*this.anchor.x,h=this.textHeight*this.anchor.y,l=0;l<s.length;l++){var c=s[l];"right"===this._align?o=this.textWidth-c.width:"center"===this._align&&(o=(this.textWidth-c.width)/2);for(var u=0;u<c.text.length;u++){var d=c.text.charCodeAt(u),p=t.chars[d];void 0===p&&(d=32,p=t.chars[d]);var f=this._glyphs[r];f?f.texture=p.texture:((f=new PIXI.Sprite(p.texture)).name=c.text[u],this._glyphs.push(f)),f.position.x=c.chars[u]+o-a,f.position.y=c.y+p.yOffset*i-h,f.scale.set(i),f.tint=this.tint,f.texture.requiresReTint=!0,f.cachedTint=16777215,f.parent||this.addChild(f),r++}}for(l=r;l<this._glyphs.length;l++)this.removeChild(this._glyphs[l])}},e.BitmapText.prototype.purgeGlyphs=function(){for(var t=this._glyphs.length,e=[],i=0;i<this._glyphs.length;i++)this._glyphs[i].parent!==this?this._glyphs[i].destroy():e.push(this._glyphs[i]);return this._glyphs=[],this._glyphs=e,this.updateText(),t-e.length},e.BitmapText.prototype.updateTransform=function(){!this.dirty&&this.anchor.equals(this._prevAnchor)||(this.updateText(),this.dirty=!1,this._prevAnchor.copyFrom(this.anchor)),PIXI.DisplayObjectContainer.prototype.updateTransform.call(this)},Object.defineProperty(e.BitmapText.prototype,"letterSpacing",{get:function(){return this._letterSpacing},set:function(t){"number"==typeof t&&(this._letterSpacing=t,this.updateText())}}),Object.defineProperty(e.BitmapText.prototype,"align",{get:function(){return this._align},set:function(t){t===this._align||"left"!==t&&"center"!==t&&"right"!==t||(this._align=t,this.updateText())}}),Object.defineProperty(e.BitmapText.prototype,"tint",{get:function(){return this._tint},set:function(t){t!==this._tint&&(this._tint=t,this.updateText())}}),Object.defineProperty(e.BitmapText.prototype,"font",{get:function(){return this._font},set:function(t){t!==this._font&&(this._font=t.trim(),this._data=this.game.cache.getBitmapFont(this._font),this.updateText())}}),Object.defineProperty(e.BitmapText.prototype,"fontSize",{get:function(){return this._fontSize},set:function(t){(t=parseInt(t,10))!==this._fontSize&&t>0&&(this._fontSize=t,this.updateText())}}),Object.defineProperty(e.BitmapText.prototype,"text",{get:function(){return this._text},set:function(t){t!==this._text&&(this._text=t.toString()||"",this.updateText())}}),Object.defineProperty(e.BitmapText.prototype,"maxWidth",{get:function(){return this._maxWidth},set:function(t){t!==this._maxWidth&&(this._maxWidth=t,this.updateText())}}),Object.defineProperty(e.BitmapText.prototype,"smoothed",{get:function(){return!this._data.base.scaleMode},set:function(t){this._data.base.scaleMode=t?0:1,this._data.base.dirty()}}),e.RetroFont=function(t,i,s,n,r,o,a,h,l,c){if(!t.cache.checkImageKey(i))return!1;void 0!==o&&null!==o||(o=t.cache.getImage(i).width/s),this.characterWidth=s,this.characterHeight=n,this.characterSpacingX=a||0,this.characterSpacingY=h||0,this.characterPerRow=o,this.offsetX=l||0,this.offsetY=c||0,this.align="left",this.multiLine=!1,this.autoUpperCase=!0,this.customSpacingX=0,this.customSpacingY=0,this.fixedWidth=0,this.fontSet=t.cache.getImage(i),this._text="",this.grabData=[],this.frameData=new e.FrameData;for(var u=this.offsetX,d=this.offsetY,p=0,f=0;f<r.length;f++){var g=this.frameData.addFrame(new e.Frame(f,u,d,this.characterWidth,this.characterHeight));this.grabData[r.charCodeAt(f)]=g.index,++p===this.characterPerRow?(p=0,u=this.offsetX,d+=this.characterHeight+this.characterSpacingY):u+=this.characterWidth+this.characterSpacingX}t.cache.updateFrameData(i,this.frameData),this.stamp=new e.Image(t,0,0,i,0),e.RenderTexture.call(this,t,100,100,"",e.scaleModes.NEAREST),this.type=e.RETROFONT},e.RetroFont.prototype=Object.create(e.RenderTexture.prototype),e.RetroFont.prototype.constructor=e.RetroFont,e.RetroFont.ALIGN_LEFT="left",e.RetroFont.ALIGN_RIGHT="right",e.RetroFont.ALIGN_CENTER="center",e.RetroFont.TEXT_SET1=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",e.RetroFont.TEXT_SET2=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ",e.RetroFont.TEXT_SET3="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ",e.RetroFont.TEXT_SET4="ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789",e.RetroFont.TEXT_SET5="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789",e.RetroFont.TEXT_SET6="ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ",e.RetroFont.TEXT_SET7="AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39",e.RetroFont.TEXT_SET8="0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ",e.RetroFont.TEXT_SET9="ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!",e.RetroFont.TEXT_SET10="ABCDEFGHIJKLMNOPQRSTUVWXYZ",e.RetroFont.TEXT_SET11="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789",e.RetroFont.prototype.setFixedWidth=function(t,e){void 0===e&&(e="left"),this.fixedWidth=t,this.align=e},e.RetroFont.prototype.setText=function(t,e,i,s,n,r){this.multiLine=e||!1,this.customSpacingX=i||0,this.customSpacingY=s||0,this.align=n||"left",this.autoUpperCase=!r,t.length>0&&(this.text=t)},e.RetroFont.prototype.buildRetroFontText=function(){var t=0,i=0;if(this.clear(),this.multiLine){var s=this._text.split("\n");this.fixedWidth>0?this.resize(this.fixedWidth,s.length*(this.characterHeight+this.customSpacingY)-this.customSpacingY,!0):this.resize(this.getLongestLine()*(this.characterWidth+this.customSpacingX),s.length*(this.characterHeight+this.customSpacingY)-this.customSpacingY,!0);for(var n=0;n<s.length;n++)t=0,this.align===e.RetroFont.ALIGN_RIGHT?t=this.width-s[n].length*(this.characterWidth+this.customSpacingX):this.align===e.RetroFont.ALIGN_CENTER&&(t=this.width/2-s[n].length*(this.characterWidth+this.customSpacingX)/2,t+=this.customSpacingX/2),t<0&&(t=0),this.pasteLine(s[n],t,i,this.customSpacingX),i+=this.characterHeight+this.customSpacingY}else this.fixedWidth>0?this.resize(this.fixedWidth,this.characterHeight,!0):this.resize(this._text.length*(this.characterWidth+this.customSpacingX),this.characterHeight,!0),t=0,this.align===e.RetroFont.ALIGN_RIGHT?t=this.width-this._text.length*(this.characterWidth+this.customSpacingX):this.align===e.RetroFont.ALIGN_CENTER&&(t=this.width/2-this._text.length*(this.characterWidth+this.customSpacingX)/2,t+=this.customSpacingX/2),t<0&&(t=0),this.pasteLine(this._text,t,0,this.customSpacingX);this.requiresReTint=!0},e.RetroFont.prototype.pasteLine=function(t,e,i,s){for(var n=0;n<t.length;n++)if(" "===t.charAt(n))e+=this.characterWidth+s;else if(this.grabData[t.charCodeAt(n)]>=0&&(this.stamp.frame=this.grabData[t.charCodeAt(n)],this.renderXY(this.stamp,e,i,!1),(e+=this.characterWidth+s)>this.width))break},e.RetroFont.prototype.getLongestLine=function(){var t=0;if(this._text.length>0)for(var e=this._text.split("\n"),i=0;i<e.length;i++)e[i].length>t&&(t=e[i].length);return t},e.RetroFont.prototype.removeUnsupportedCharacters=function(t){for(var e="",i=0;i<this._text.length;i++){var s=this._text[i],n=s.charCodeAt(0);(this.grabData[n]>=0||!t&&"\n"===s)&&(e=e.concat(s))}return e},e.RetroFont.prototype.updateOffset=function(t,e){if(this.offsetX!==t||this.offsetY!==e){for(var i=t-this.offsetX,s=e-this.offsetY,n=this.game.cache.getFrameData(this.stamp.key).getFrames(),r=n.length;r--;)n[r].x+=i,n[r].y+=s;this.buildRetroFontText()}},Object.defineProperty(e.RetroFont.prototype,"text",{get:function(){return this._text},set:function(t){var e;(e=this.autoUpperCase?t.toUpperCase():t)!==this._text&&(this._text=e,this.removeUnsupportedCharacters(this.multiLine),this.buildRetroFontText())}}),Object.defineProperty(e.RetroFont.prototype,"smoothed",{get:function(){return this.stamp.smoothed},set:function(t){this.stamp.smoothed=t,this.buildRetroFontText()}}),e.Rope=function(t,i,s,n,r,o){this.points=o||[],this._hasUpdateAnimation=!1,this._updateAnimationCallback=null,i=i||0,s=s||0,n=n||null,r=r||null,this.type=e.ROPE,PIXI.DisplayObjectContainer.call(this),this.texture=e.Cache.DEFAULT,this.uvs=new Float32Array([0,1,1,1,1,0,0,1]),this.vertices=new Float32Array([0,0,100,0,100,100,0,100]),this.colors=new Float32Array([1,1,1,1]),this.indices=new Uint16Array([0,1,2,3]),o&&(this.vertices=new Float32Array(4*o.length),this.uvs=new Float32Array(4*o.length),this.colors=new Float32Array(2*o.length),this.indices=new Uint16Array(2*o.length)),this.dirty=!0,this.canvasPadding=0,this.drawMode=e.Rope.TRIANGLE_STRIP,e.Component.Core.init.call(this,t,i,s,n,r),this.refresh()},e.Rope.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),e.Rope.prototype.constructor=e.Rope,e.Component.Core.install.call(e.Rope.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Delta","Destroy","FixedToCamera","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","ScaleMinMax","Smoothed"]),e.Rope.prototype.preUpdatePhysics=e.Component.PhysicsBody.preUpdate,e.Rope.prototype.preUpdateLifeSpan=e.Component.LifeSpan.preUpdate,e.Rope.prototype.preUpdateInWorld=e.Component.InWorld.preUpdate,e.Rope.prototype.preUpdateCore=e.Component.Core.preUpdate,e.Rope.TRIANGLE_STRIP=0,e.Rope.TRIANGLES=1,e.Rope.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},e.Rope.prototype.update=function(){this._hasUpdateAnimation&&this.updateAnimation.call(this)},e.Rope.prototype.reset=function(t,i){return e.Component.Reset.prototype.reset.call(this,t,i),this},e.Rope.prototype.refresh=function(){var t=this.points;if(!(t.length<1)){var e=this.uvs,i=this.indices,s=this.colors;this.count-=.2;for(var n=t.length,r=0,o=0,a=0;a<n;a++)o=a/(n-1),e[r=4*a]=o,e[r+1]=0,e[r+2]=o,e[r+3]=1,s[r=2*a]=1,s[r+1]=1,i[r=2*a]=r,i[r+1]=r+1}},e.Rope.prototype.updateTransform=function(){var t=this.points;if(!(t.length<1)){var e,i=t[0],s={x:0,y:0};this.count-=.2;for(var n,r,o,a,h=this.vertices,l=t.length,c=this.texture.height/2,u=0;u<l;u++)n=t[u],r=4*u,e=u<l-1?t[u+1]:n,s.y=-(e.x-i.x),s.x=e.y-i.y,o=Math.sqrt(s.x*s.x+s.y*s.y),a=c,s.x/=o,s.y/=o,s.x*=a,s.y*=a,h[r]=n.x+s.x,h[r+1]=n.y+s.y,h[r+2]=n.x-s.x,h[r+3]=n.y-s.y,i=n;PIXI.DisplayObjectContainer.prototype.updateTransform.call(this)}},e.Rope.prototype.setTexture=function(t){this.texture=t},e.Rope.prototype._renderWebGL=function(t){!this.visible||this.alpha<=0||(t.spriteBatch.stop(),this._vertexBuffer||this._initWebGL(t),t.shaderManager.setShader(t.shaderManager.stripShader),this._renderStrip(t),t.spriteBatch.start())},e.Rope.prototype._initWebGL=function(t){var e=t.gl;this._vertexBuffer=e.createBuffer(),this._indexBuffer=e.createBuffer(),this._uvBuffer=e.createBuffer(),this._colorBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this._vertexBuffer),e.bufferData(e.ARRAY_BUFFER,this.vertices,e.DYNAMIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,this._uvBuffer),e.bufferData(e.ARRAY_BUFFER,this.uvs,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,this._colorBuffer),e.bufferData(e.ARRAY_BUFFER,this.colors,e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this._indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.indices,e.STATIC_DRAW)},e.Rope.prototype._renderStrip=function(t){var i=t.gl,s=t.projection,n=t.offset,r=t.shaderManager.stripShader,o=this.drawMode===e.Rope.TRIANGLE_STRIP?i.TRIANGLE_STRIP:i.TRIANGLES;t.blendModeManager.setBlendMode(this.blendMode),i.uniformMatrix3fv(r.translationMatrix,!1,this.worldTransform.toArray(!0)),i.uniform2f(r.projectionVector,s.x,-s.y),i.uniform2f(r.offsetVector,-n.x,-n.y),i.uniform1f(r.alpha,this.worldAlpha),this.dirty?(this.dirty=!1,i.bindBuffer(i.ARRAY_BUFFER,this._vertexBuffer),i.bufferData(i.ARRAY_BUFFER,this.vertices,i.STATIC_DRAW),i.vertexAttribPointer(r.aVertexPosition,2,i.FLOAT,!1,0,0),i.bindBuffer(i.ARRAY_BUFFER,this._uvBuffer),i.bufferData(i.ARRAY_BUFFER,this.uvs,i.STATIC_DRAW),i.vertexAttribPointer(r.aTextureCoord,2,i.FLOAT,!1,0,0),i.activeTexture(i.TEXTURE0),this.texture.baseTexture._dirty[i.id]?t.renderer.updateTexture(this.texture.baseTexture):i.bindTexture(i.TEXTURE_2D,this.texture.baseTexture._glTextures[i.id]),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,this._indexBuffer),i.bufferData(i.ELEMENT_ARRAY_BUFFER,this.indices,i.STATIC_DRAW)):(i.bindBuffer(i.ARRAY_BUFFER,this._vertexBuffer),i.bufferSubData(i.ARRAY_BUFFER,0,this.vertices),i.vertexAttribPointer(r.aVertexPosition,2,i.FLOAT,!1,0,0),i.bindBuffer(i.ARRAY_BUFFER,this._uvBuffer),i.vertexAttribPointer(r.aTextureCoord,2,i.FLOAT,!1,0,0),i.activeTexture(i.TEXTURE0),this.texture.baseTexture._dirty[i.id]?t.renderer.updateTexture(this.texture.baseTexture):i.bindTexture(i.TEXTURE_2D,this.texture.baseTexture._glTextures[i.id]),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,this._indexBuffer)),i.drawElements(o,this.indices.length,i.UNSIGNED_SHORT,0)},e.Rope.prototype._renderCanvas=function(t){var i=t.context,s=this.worldTransform,n=s.tx*t.resolution+t.shakeX,r=s.ty*t.resolution+t.shakeY;t.roundPixels?i.setTransform(s.a,s.b,s.c,s.d,0|n,0|r):i.setTransform(s.a,s.b,s.c,s.d,n,r),this.drawMode===e.Rope.TRIANGLE_STRIP?this._renderCanvasTriangleStrip(i):this._renderCanvasTriangles(i)},e.Rope.prototype._renderCanvasTriangleStrip=function(t){var e=this.vertices,i=this.uvs,s=e.length/2;this.count++;for(var n=0;n<s-2;n++){var r=2*n;this._renderCanvasDrawTriangle(t,e,i,r,r+2,r+4)}},e.Rope.prototype._renderCanvasTriangles=function(t){var e=this.vertices,i=this.uvs,s=this.indices,n=s.length;this.count++;for(var r=0;r<n;r+=3){var o=2*s[r],a=2*s[r+1],h=2*s[r+2];this._renderCanvasDrawTriangle(t,e,i,o,a,h)}},e.Rope.prototype._renderCanvasDrawTriangle=function(t,e,i,s,n,r){var o=this.texture.baseTexture.source,a=this.texture.width,h=this.texture.height,l=e[s],c=e[n],u=e[r],d=e[s+1],p=e[n+1],f=e[r+1],g=i[s]*a,m=i[n]*a,y=i[r]*a,v=i[s+1]*h,x=i[n+1]*h,b=i[r+1]*h;if(this.canvasPadding>0){var _=this.canvasPadding/this.worldTransform.a,w=this.canvasPadding/this.worldTransform.d,T=(l+c+u)/3,P=(d+p+f)/3,C=l-T,S=d-P,A=Math.sqrt(C*C+S*S);l=T+C/A*(A+_),d=P+S/A*(A+w),S=p-P,c=T+(C=c-T)/(A=Math.sqrt(C*C+S*S))*(A+_),p=P+S/A*(A+w),S=f-P,u=T+(C=u-T)/(A=Math.sqrt(C*C+S*S))*(A+_),f=P+S/A*(A+w)}t.save(),t.beginPath(),t.moveTo(l,d),t.lineTo(c,p),t.lineTo(u,f),t.closePath(),t.clip();var E=g*x+v*y+m*b-x*y-v*m-g*b,M=l*x+v*u+c*b-x*u-v*c-l*b,R=g*c+l*y+m*u-c*y-l*m-g*u,L=g*x*u+v*c*y+l*m*b-l*x*y-v*m*u-g*c*b,B=d*x+v*f+p*b-x*f-v*p-d*b,I=g*p+d*y+m*f-p*y-d*m-g*f,O=g*x*f+v*p*y+d*m*b-d*x*y-v*m*f-g*p*b;t.transform(M/E,B/E,R/E,I/E,L/E,O/E),t.drawImage(o,0,0),t.restore()},e.Rope.prototype.renderStripFlat=function(t){var e=this.context,i=t.vertices,s=i.length/2;this.count++,e.beginPath();for(var n=1;n<s-2;n++){var r=2*n,o=i[r],a=i[r+2],h=i[r+4],l=i[r+1],c=i[r+3],u=i[r+5];e.moveTo(o,l),e.lineTo(a,c),e.lineTo(h,u)}e.fillStyle="#FF0000",e.fill(),e.closePath()},e.Rope.prototype.getBounds=function(t){for(var i=t||this.worldTransform,s=i.a,n=i.b,r=i.c,o=i.d,a=i.tx,h=i.ty,l=-1/0,c=-1/0,u=1/0,d=1/0,p=this.vertices,f=0;f<p.length;f+=2){var g=p[f],m=p[f+1],y=s*g+r*m+a,v=o*m+n*g+h;u=y<u?y:u,d=v<d?v:d,l=y>l?y:l,c=v>c?v:c}if(u===-1/0||c===1/0)return e.EmptyRectangle;var x=this._bounds;return x.x=u,x.width=l-u,x.y=d,x.height=c-d,this._currentBounds=x,x},Object.defineProperty(e.Rope.prototype,"updateAnimation",{get:function(){return this._updateAnimation},set:function(t){t&&"function"==typeof t?(this._hasUpdateAnimation=!0,this._updateAnimation=t):(this._hasUpdateAnimation=!1,this._updateAnimation=null)}}),Object.defineProperty(e.Rope.prototype,"segments",{get:function(){for(var t,i,s,n,r,o,a,h,l=[],c=0;c<this.points.length;c++)t=4*c,i=this.vertices[t]*this.scale.x,s=this.vertices[t+1]*this.scale.y,n=this.vertices[t+4]*this.scale.x,r=this.vertices[t+3]*this.scale.y,o=e.Math.difference(i,n),a=e.Math.difference(s,r),i+=this.world.x,s+=this.world.y,h=new e.Rectangle(i,s,o,a),l.push(h);return l}}),e.TileSprite=function(t,i,s,n,r,o,a){i=i||0,s=s||0,n=n||256,r=r||256,o=o||null,a=a||null,PIXI.Sprite.call(this,new PIXI.Texture(e.Cache.DEFAULT.baseTexture),n,r),this.type=e.TILESPRITE,this.physicsType=e.SPRITE,this._scroll=new e.Point,this.tileScale=new e.Point(1,1),this.tileScaleOffset=new e.Point(1,1),this.tilePosition=new e.Point,this.textureDebug=!1,this.canvasBuffer=null,this.tilingTexture=null,this.tilePattern=null,this.refreshTexture=!0,this.frameWidth=0,this.frameHeight=0,this._width=n,this._height=r,e.Component.Core.init.call(this,t,i,s,o,a)},e.TileSprite.prototype=Object.create(PIXI.Sprite.prototype),e.TileSprite.prototype.constructor=e.TileSprite,e.Component.Core.install.call(e.TileSprite.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Destroy","FixedToCamera","Health","InCamera","InputEnabled","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","Smoothed"]),e.TileSprite.prototype.preUpdatePhysics=e.Component.PhysicsBody.preUpdate,e.TileSprite.prototype.preUpdateLifeSpan=e.Component.LifeSpan.preUpdate,e.TileSprite.prototype.preUpdateInWorld=e.Component.InWorld.preUpdate,e.TileSprite.prototype.preUpdateCore=e.Component.Core.preUpdate,e.TileSprite.prototype.preUpdate=function(){return 0!==this._scroll.x&&(this.tilePosition.x+=this._scroll.x*this.game.time.physicsElapsed),0!==this._scroll.y&&(this.tilePosition.y+=this._scroll.y*this.game.time.physicsElapsed),!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},e.TileSprite.prototype.autoScroll=function(t,e){return this._scroll.set(t,e),this},e.TileSprite.prototype.stopScroll=function(){return this._scroll.set(0,0),this},e.TileSprite.prototype.destroy=function(t){e.Component.Destroy.prototype.destroy.call(this,t),PIXI.Sprite.prototype.destroy.call(this),this.canvasBuffer&&(this.canvasBuffer.destroy(),this.canvasBuffer=null),this.tileScale=null,this.tileScaleOffset=null,this.tilePosition=null,this.tilingTexture&&(this.tilingTexture.destroy(!0),this.tilingTexture=null)},e.TileSprite.prototype.reset=function(t,i){return e.Component.Reset.prototype.reset.call(this,t,i),this.tilePosition.x=0,this.tilePosition.y=0,this},e.TileSprite.prototype.setTexture=function(t){return this.texture!==t&&(this.texture=t,this.refreshTexture=!0,this.cachedTint=16777215),this},e.TileSprite.prototype._renderWebGL=function(t){if(this.visible&&this.renderable&&0!==this.alpha){if(this._mask&&(t.spriteBatch.stop(),t.maskManager.pushMask(this.mask,t),t.spriteBatch.start()),this._filters&&(t.spriteBatch.flush(),t.filterManager.pushFilter(this._filterBlock)),this.refreshTexture){if(this.generateTilingTexture(!0,t),!this.tilingTexture)return;this.tilingTexture.needsUpdate&&(this.tilingTexture.baseTexture.textureIndex=this.texture.baseTexture.textureIndex,t.renderer.updateTexture(this.tilingTexture.baseTexture),this.tilingTexture.needsUpdate=!1)}t.spriteBatch.renderTilingSprite(this);for(var e=0;e<this.children.length;e++)this.children[e]._renderWebGL(t);var i=!1;this._filters&&(i=!0,t.spriteBatch.stop(),t.filterManager.popFilter()),this._mask&&(i||t.spriteBatch.stop(),t.maskManager.popMask(this._mask,t)),i&&t.spriteBatch.start()}},e.TileSprite.prototype._renderCanvas=function(t){if(this.visible&&this.renderable&&0!==this.alpha){var e=t.context;this._mask&&t.maskManager.pushMask(this._mask,t),e.globalAlpha=this.worldAlpha;var i=this.worldTransform,s=t.resolution,n=i.tx*s+t.shakeX,r=i.ty*s+t.shakeY;if(e.setTransform(i.a*s,i.b*s,i.c*s,i.d*s,n,r),16777215===this.tint||!this.texture.requiresReTint&&this.cachedTint===this.tint||(this.tintedTexture=PIXI.CanvasTinter.getTintedTexture(this,this.tint),this.cachedTint=this.tint,this.texture.requiresReTint=!1,this.refreshTexture=!0),this.refreshTexture){if(this.generateTilingTexture(!1,t),!this.tilingTexture)return;this.tilePattern=e.createPattern(this.tilingTexture.baseTexture.source,"repeat")}var o=t.currentBlendMode;this.blendMode!==t.currentBlendMode&&(t.currentBlendMode=this.blendMode,e.globalCompositeOperation=PIXI.blendModesCanvas[t.currentBlendMode]);var a=this.tilePosition,h=this.tileScale;a.x%=this.tilingTexture.baseTexture.width,a.y%=this.tilingTexture.baseTexture.height,e.scale(h.x,h.y),e.translate(a.x+this.anchor.x*-this._width,a.y+this.anchor.y*-this._height),e.fillStyle=this.tilePattern,n=-a.x,r=-a.y;var l=this._width/h.x,c=this._height/h.y;t.roundPixels&&(n|=0,r|=0,l|=0,c|=0),e.fillRect(n,r,l,c),e.scale(1/h.x,1/h.y),e.translate(-a.x+this.anchor.x*this._width,-a.y+this.anchor.y*this._height),this._mask&&t.maskManager.popMask(t);for(var u=0;u<this.children.length;u++)this.children[u]._renderCanvas(t);o!==this.blendMode&&(t.currentBlendMode=o,e.globalCompositeOperation=PIXI.blendModesCanvas[o])}},e.TileSprite.prototype.onTextureUpdate=function(){},e.TileSprite.prototype.generateTilingTexture=function(t){if(this.texture.baseTexture.hasLoaded){var i=this.texture,s=i.frame,n=this._frame.sourceSizeW||this._frame.width,r=this._frame.sourceSizeH||this._frame.height,o=0,a=0;this._frame.trimmed&&(o=this._frame.spriteSourceSizeX,a=this._frame.spriteSourceSizeY),t&&(n=e.Math.getNextPowerOfTwo(n),r=e.Math.getNextPowerOfTwo(r)),this.canvasBuffer?(this.canvasBuffer.resize(n,r),this.tilingTexture.baseTexture.width=n,this.tilingTexture.baseTexture.height=r,this.tilingTexture.needsUpdate=!0):(this.canvasBuffer=new PIXI.CanvasBuffer(n,r),this.tilingTexture=PIXI.Texture.fromCanvas(this.canvasBuffer.canvas),this.tilingTexture.isTiling=!0,this.tilingTexture.needsUpdate=!0),this.textureDebug&&(this.canvasBuffer.context.strokeStyle="#00ff00",this.canvasBuffer.context.strokeRect(0,0,n,r));var h=i.crop.width,l=i.crop.height;h===n&&l===r||(h=n,l=r);var c=this.tintedTexture?this.tintedTexture:i.baseTexture.source;this.canvasBuffer.context.drawImage(c,i.crop.x,i.crop.y,i.crop.width,i.crop.height,o,a,h,l),this.tileScaleOffset.x=s.width/n,this.tileScaleOffset.y=s.height/r,this.refreshTexture=!1,this.tilingTexture.baseTexture._powerOf2=!0}},e.TileSprite.prototype.getBounds=function(){var t=this._width,e=this._height,i=t*(1-this.anchor.x),s=t*-this.anchor.x,n=e*(1-this.anchor.y),r=e*-this.anchor.y,o=this.worldTransform,a=o.a,h=o.b,l=o.c,c=o.d,u=o.tx,d=o.ty,p=a*s+l*r+u,f=c*r+h*s+d,g=a*i+l*r+u,m=c*r+h*i+d,y=a*i+l*n+u,v=c*n+h*i+d,x=a*s+l*n+u,b=c*n+h*s+d,_=-1/0,w=-1/0,T=1/0,P=1/0;T=x<(T=y<(T=g<(T=p<T?p:T)?g:T)?y:T)?x:T,P=b<(P=v<(P=m<(P=f<P?f:P)?m:P)?v:P)?b:P,_=x>(_=y>(_=g>(_=p>_?p:_)?g:_)?y:_)?x:_,w=b>(w=v>(w=m>(w=f>w?f:w)?m:w)?v:w)?b:w;var C=this._bounds;return C.x=T,C.width=_-T,C.y=P,C.height=w-P,this._currentBounds=C,C},Object.defineProperty(e.TileSprite.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t}}),Object.defineProperty(e.TileSprite.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t}}),e.CanvasPool={create:function(t,i,s){var n,r=e.CanvasPool.getFirst();if(-1===r){var o={parent:t,canvas:document.createElement("canvas")};e.CanvasPool.pool.push(o),n=o.canvas}else e.CanvasPool.pool[r].parent=t,n=e.CanvasPool.pool[r].canvas;return void 0!==i&&(n.width=i,n.height=s),n},getFirst:function(){for(var t=e.CanvasPool.pool,i=0;i<t.length;i++)if(!t[i].parent)return i;return-1},remove:function(t){for(var i=e.CanvasPool.pool,s=0;s<i.length;s++)i[s].parent===t&&(i[s].parent=null,i[s].canvas.width=1,i[s].canvas.height=1)},removeByCanvas:function(t){for(var i=e.CanvasPool.pool,s=0;s<i.length;s++)i[s].canvas===t&&(i[s].parent=null,i[s].canvas.width=1,i[s].canvas.height=1)},getTotal:function(){for(var t=e.CanvasPool.pool,i=0,s=0;s<t.length;s++)t[s].parent&&i++;return i},getFree:function(){for(var t=e.CanvasPool.pool,i=0,s=0;s<t.length;s++)t[s].parent||i++;return i},log:function(){console.log("CanvasPool: %s used, %s free, %s total",e.CanvasPool.getTotal(),e.CanvasPool.getFree(),e.CanvasPool.pool.length)}},e.CanvasPool.pool=[],Object.defineProperty(e.CanvasPool,"length",{get:function(){return this.pool.length}}),e.Device=function(){this.deviceReadyAt=0,this.initialized=!1,this.desktop=!1,this.iOS=!1,this.iOSVersion=0,this.cocoonJS=!1,this.cocoonJSApp=!1,this.cordova=!1,this.node=!1,this.nodeWebkit=!1,this.electron=!1,this.ejecta=!1,this.crosswalk=!1,this.android=!1,this.chromeOS=!1,this.linux=!1,this.macOS=!1,this.windows=!1,this.windowsPhone=!1,this.canvas=!1,this.canvasBitBltShift=null,this.canHandleAlpha=!1,this.canUseMultiply=!1,this.webGL=!1,this.file=!1,this.fileSystem=!1,this.localStorage=!1,this.worker=!1,this.css3D=!1,this.pointerLock=!1,this.typedArray=!1,this.vibration=!1,this.getUserMedia=!0,this.quirksMode=!1,this.touch=!1,this.mspointer=!1,this.wheelEvent=null,this.arora=!1,this.chrome=!1,this.chromeVersion=0,this.epiphany=!1,this.firefox=!1,this.firefoxVersion=0,this.ie=!1,this.ieVersion=0,this.trident=!1,this.tridentVersion=0,this.edge=!1,this.mobileSafari=!1,this.midori=!1,this.opera=!1,this.safari=!1,this.safariVersion=0,this.webApp=!1,this.silk=!1,this.audioData=!1,this.webAudio=!1,this.ogg=!1,this.opus=!1,this.mp3=!1,this.wav=!1,this.m4a=!1,this.webm=!1,this.dolby=!1,this.oggVideo=!1,this.h264Video=!1,this.mp4Video=!1,this.webmVideo=!1,this.vp9Video=!1,this.hlsVideo=!1,this.iPhone=!1,this.iPhone4=!1,this.iPad=!1,this.pixelRatio=0,this.littleEndian=!1,this.LITTLE_ENDIAN=!1,this.support32bit=!1,this.fullscreen=!1,this.requestFullscreen="",this.cancelFullscreen="",this.fullscreenKeyboard=!1},e.Device=new e.Device,e.Device.onInitialized=new e.Signal,e.Device.whenReady=function(t,e,i){var s=this._readyCheck;if(this.deviceReadyAt||!s)t.call(e,this);else if(s._monitor||i)s._queue=s._queue||[],s._queue.push([t,e]);else{s._monitor=s.bind(this),s._queue=s._queue||[],s._queue.push([t,e]);var n=void 0!==window.cordova,r=navigator.isCocoonJS;"complete"===document.readyState||"interactive"===document.readyState?window.setTimeout(s._monitor,0):n&&!r?document.addEventListener("deviceready",s._monitor,!1):(document.addEventListener("DOMContentLoaded",s._monitor,!1),window.addEventListener("load",s._monitor,!1))}},e.Device._readyCheck=function(){var t=this._readyCheck;if(document.body){if(!this.deviceReadyAt){this.deviceReadyAt=Date.now(),document.removeEventListener("deviceready",t._monitor),document.removeEventListener("DOMContentLoaded",t._monitor),window.removeEventListener("load",t._monitor),this._initialize(),this.initialized=!0,this.onInitialized.dispatch(this);for(var e;e=t._queue.shift();){var i=e[0],s=e[1];i.call(s,this)}this._readyCheck=null,this._initialize=null,this.onInitialized=null}}else window.setTimeout(t._monitor,20)},e.Device._initialize=function(){function t(){var t=new ArrayBuffer(4),e=new Uint8Array(t),i=new Uint32Array(t);return e[0]=161,e[1]=178,e[2]=195,e[3]=212,3569595041===i[0]||2712847316!==i[0]&&null}function i(){if(void 0===Uint8ClampedArray)return!1;var t=e.CanvasPool.create(this,1,1).getContext("2d");if(!t)return!1;var i=t.createImageData(1,1);return e.CanvasPool.remove(this),i.data instanceof Uint8ClampedArray}var s=this;!function(){var t=navigator.userAgent;/Playstation Vita/.test(t)?s.vita=!0:/Kindle/.test(t)||/\bKF[A-Z][A-Z]+/.test(t)||/Silk.*Mobile Safari/.test(t)?s.kindle=!0:/Android/.test(t)?s.android=!0:/CrOS/.test(t)?s.chromeOS=!0:/iP[ao]d|iPhone/i.test(t)?(s.iOS=!0,navigator.appVersion.match(/OS (\d+)/),s.iOSVersion=parseInt(RegExp.$1,10)):/Linux/.test(t)?s.linux=!0:/Mac OS/.test(t)?s.macOS=!0:/Windows/.test(t)&&(s.windows=!0),(/Windows Phone/i.test(t)||/IEMobile/i.test(t))&&(s.android=!1,s.iOS=!1,s.macOS=!1,s.windows=!0,s.windowsPhone=!0);var e=/Silk/.test(t);(s.windows||s.macOS||s.linux&&!e||s.chromeOS)&&(s.desktop=!0),(s.windowsPhone||/Windows NT/i.test(t)&&/Touch/i.test(t))&&(s.desktop=!1)}(),function(){var t=navigator.userAgent;if(/Arora/.test(t)?s.arora=!0:/Edge\/\d+/.test(t)?s.edge=!0:/Chrome\/(\d+)/.test(t)&&!s.windowsPhone?(s.chrome=!0,s.chromeVersion=parseInt(RegExp.$1,10)):/Epiphany/.test(t)?s.epiphany=!0:/Firefox\D+(\d+)/.test(t)?(s.firefox=!0,s.firefoxVersion=parseInt(RegExp.$1,10)):/AppleWebKit/.test(t)&&s.iOS?s.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(t)?(s.ie=!0,s.ieVersion=parseInt(RegExp.$1,10)):/Midori/.test(t)?s.midori=!0:/Opera/.test(t)?s.opera=!0:/Safari\/(\d+)/.test(t)&&!s.windowsPhone?(s.safari=!0,/Version\/(\d+)\./.test(t)&&(s.safariVersion=parseInt(RegExp.$1,10))):/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(t)&&(s.ie=!0,s.trident=!0,s.tridentVersion=parseInt(RegExp.$1,10),s.ieVersion=parseInt(RegExp.$3,10)),/Silk/.test(t)&&(s.silk=!0),navigator.standalone&&(s.webApp=!0),void 0!==window.cordova&&(s.cordova=!0),"undefined"!=typeof process&&"undefined"!=typeof require&&(s.node=!0),s.node&&"object"==typeof process.versions&&(s.nodeWebkit=!!process.versions["node-webkit"],s.electron=!!process.versions.electron),navigator.isCocoonJS&&(s.cocoonJS=!0),s.cocoonJS)try{s.cocoonJSApp="undefined"!=typeof CocoonJS}catch(t){s.cocoonJSApp=!1}void 0!==window.ejecta&&(s.ejecta=!0),/Crosswalk/.test(t)&&(s.crosswalk=!0)}(),function(){s.audioData=!!window.Audio,s.webAudio=!(!window.AudioContext&&!window.webkitAudioContext);var t=document.createElement("audio");try{if(t.canPlayType&&(t.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(s.ogg=!0),(t.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,"")||t.canPlayType("audio/opus;").replace(/^no$/,""))&&(s.opus=!0),t.canPlayType("audio/mpeg;").replace(/^no$/,"")&&(s.mp3=!0),t.canPlayType('audio/wav; codecs="1"').replace(/^no$/,"")&&(s.wav=!0),(t.canPlayType("audio/x-m4a;")||t.canPlayType("audio/aac;").replace(/^no$/,""))&&(s.m4a=!0),t.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")&&(s.webm=!0),""!==t.canPlayType('audio/mp4;codecs="ec-3"')))if(s.edge)s.dolby=!0;else if(s.safari&&s.safariVersion>=9&&/Mac OS X (\d+)_(\d+)/.test(navigator.userAgent)){var e=parseInt(RegExp.$1,10),i=parseInt(RegExp.$2,10);(10===e&&i>=11||e>10)&&(s.dolby=!0)}}catch(t){}}(),function(){var t=document.createElement("video");try{t.canPlayType&&(t.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,"")&&(s.oggVideo=!0),t.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,"")&&(s.h264Video=!0,s.mp4Video=!0),t.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")&&(s.webmVideo=!0),t.canPlayType('video/webm; codecs="vp9"').replace(/^no$/,"")&&(s.vp9Video=!0),t.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(/^no$/,"")&&(s.hlsVideo=!0))}catch(t){}}(),function(){var t,e=document.createElement("p"),i={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"};document.body.insertBefore(e,null);for(var n in i)void 0!==e.style[n]&&(e.style[n]="translate3d(1px,1px,1px)",t=window.getComputedStyle(e).getPropertyValue(i[n]));document.body.removeChild(e),s.css3D=void 0!==t&&t.length>0&&"none"!==t}(),s.pixelRatio=window.devicePixelRatio||1,s.iPhone=-1!==navigator.userAgent.toLowerCase().indexOf("iphone"),s.iPhone4=2===s.pixelRatio&&s.iPhone,s.iPad=-1!==navigator.userAgent.toLowerCase().indexOf("ipad"),"undefined"!=typeof Int8Array?s.typedArray=!0:s.typedArray=!1,"undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint32Array&&(s.littleEndian=t(),s.LITTLE_ENDIAN=s.littleEndian),s.support32bit="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof Int32Array&&null!==s.littleEndian&&i(),navigator.vibrate=navigator.vibrate||navigator.webkitVibrate||navigator.mozVibrate||navigator.msVibrate,navigator.vibrate&&(s.vibration=!0),function(){s.canvas=!!window.CanvasRenderingContext2D||s.cocoonJS;try{s.localStorage=!!localStorage.getItem}catch(t){s.localStorage=!1}s.file=!!(window.File&&window.FileReader&&window.FileList&&window.Blob),s.fileSystem=!!window.requestFileSystem,s.webGL=!!window.WebGLRenderingContext,s.worker=!!window.Worker,s.pointerLockElement="pointerLockElement"in document&&"pointerLockElement"||"mozPointerLockElement"in document&&"mozPointerLockElement"||"webkitPointerLockElement"in document&&"webkitPointerLockElement",s.pointerlockchange="onpointerlockchange"in document&&"pointerlockchange"||"onmozpointerlockchange"in document&&"mozpointerlockchange"||"onwebkitpointerlockchange"in document&&"webkitpointerlockchange",s.pointerlockerror="onpointerlockerror"in document&&"pointerlockerror"||"onmozpointerlockerror"in document&&"mozpointerlockerror"||"onwebkitpointerlockerror"in document&&"webkitpointerlockerror",s.pointerLock=!!s.pointerLockElement,s.quirksMode="CSS1Compat"!==document.compatMode,navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia||navigator.oGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,s.getUserMedia=s.getUserMedia&&!!navigator.getUserMedia&&!!window.URL,s.firefox&&s.firefoxVersion<21&&(s.getUserMedia=!1),!s.iOS&&(s.ie||s.firefox||s.chrome)&&(s.canvasBitBltShift=!0),(s.safari||s.mobileSafari)&&(s.canvasBitBltShift=!1)}(),function(){var t=e.CanvasPool.create(this,6,1),i=t.getContext("2d");i.fillStyle="rgba(10, 20, 30, 0.5)",i.fillRect(0,0,1,1);var n=i.getImageData(0,0,1,1);if(n){i.putImageData(n,1,0);var r=i.getImageData(1,0,1,1);s.canHandleAlpha=r.data[0]===n.data[0]&&r.data[1]===n.data[1]&&r.data[2]===n.data[2]&&r.data[3]===n.data[3]}i.globalCompositeOperation="multiply",s.canUseMultiply="multiply"===i.globalCompositeOperation,e.CanvasPool.removeByCanvas(t),PIXI.CanvasTinter.tintMethod=s.canUseMultiply?PIXI.CanvasTinter.tintWithMultiply:PIXI.CanvasTinter.tintWithPerPixel}(),function(){for(var t=["requestFullscreen","requestFullScreen","webkitRequestFullscreen","webkitRequestFullScreen","msRequestFullscreen","msRequestFullScreen","mozRequestFullScreen","mozRequestFullscreen"],e=document.createElement("div"),i=0;i<t.length;i++)if(e[t[i]]){s.fullscreen=!0,s.requestFullscreen=t[i];break}var n=["cancelFullScreen","exitFullscreen","webkitCancelFullScreen","webkitExitFullscreen","msCancelFullScreen","msExitFullscreen","mozCancelFullScreen","mozExitFullscreen"];if(s.fullscreen)for(i=0;i<n.length;i++)if(document[n[i]]){s.cancelFullscreen=n[i];break}window.Element&&Element.ALLOW_KEYBOARD_INPUT&&(s.fullscreenKeyboard=!0)}(),("ontouchstart"in document.documentElement||window.navigator.maxTouchPoints&&window.navigator.maxTouchPoints>=1)&&(s.touch=!0),(window.PointerEvent||window.MSPointerEvent||window.navigator.msPointerEnabled||window.navigator.pointerEnabled)&&(s.mspointer=!0),s.cocoonJS||("onwheel"in window||s.ie&&"WheelEvent"in window?s.wheelEvent="wheel":"onmousewheel"in window?s.wheelEvent="mousewheel":s.firefox&&"MouseScrollEvent"in window&&(s.wheelEvent="DOMMouseScroll"))},e.Device.canPlayAudio=function(t){return!("mp3"!==t||!this.mp3)||(!("ogg"!==t||!this.ogg&&!this.opus)||(!("m4a"!==t||!this.m4a)||(!("opus"!==t||!this.opus)||(!("wav"!==t||!this.wav)||(!("webm"!==t||!this.webm)||!("mp4"!==t||!this.dolby))))))},e.Device.canPlayVideo=function(t){return!("webm"!==t||!this.webmVideo&&!this.vp9Video)||(!("mp4"!==t||!this.mp4Video&&!this.h264Video)||(!("ogg"!==t&&"ogv"!==t||!this.oggVideo)||!("mpeg"!==t||!this.hlsVideo)))},e.Device.needsTouchUnlock=function(){return!!(!this.cocoonJS&&(this.iOS||this.android)||window.PhaserGlobal&&window.PhaserGlobal.fakeiOSTouchLock)},e.Device.isAndroidStockBrowser=function(){var t=window.navigator.userAgent.match(/Android.*AppleWebKit\/([\d.]+)/);return t&&t[1]<537},e.Canvas={create:function(t,i,s,n,r){i=i||256,s=s||256;var o=r?document.createElement("canvas"):e.CanvasPool.create(t,i,s);return"string"==typeof n&&""!==n&&(o.id=n),o.width=i,o.height=s,o.style.display="block",o},setBackgroundColor:function(t,e){return e=e||"rgb(0,0,0)",t.style.backgroundColor=e,t},setTouchAction:function(t,e){return e=e||"none",t.style.msTouchAction=e,t.style["ms-touch-action"]=e,t.style["touch-action"]=e,t},setUserSelect:function(t,e){return e=e||"none",t.style["-webkit-touch-callout"]=e,t.style["-webkit-user-select"]=e,t.style["-khtml-user-select"]=e,t.style["-moz-user-select"]=e,t.style["-ms-user-select"]=e,t.style["user-select"]=e,t.style["-webkit-tap-highlight-color"]="rgba(0, 0, 0, 0)",t},addToDOM:function(t,e,i){var s;return void 0===i&&(i=!0),e&&("string"==typeof e?s=document.getElementById(e):"object"==typeof e&&1===e.nodeType&&(s=e)),s||(s=document.body),i&&s.style&&(s.style.overflow="hidden"),s.appendChild(t),t},removeFromDOM:function(t){t.parentNode&&t.parentNode.removeChild(t)},setTransform:function(t,e,i,s,n,r,o){return t.setTransform(s,r,o,n,e,i),t},setSmoothingEnabled:function(t,i){var s=e.Canvas.getSmoothingPrefix(t);return s&&(t[s]=i),t},getSmoothingPrefix:function(t){var e=["i","webkitI","msI","mozI","oI"];for(var i in e){var s=e[i]+"mageSmoothingEnabled";if(s in t)return s}return null},getSmoothingEnabled:function(t){var i=e.Canvas.getSmoothingPrefix(t);if(i)return t[i]},setImageRenderingCrisp:function(t){for(var e=["-webkit-optimize-contrast","-moz-crisp-edges","crisp-edges","pixelated"],i=0;i<e.length;i++)t.style["image-rendering"]=e[i];return t.style.msInterpolationMode="nearest-neighbor",t},setImageRenderingBicubic:function(t){return t.style["image-rendering"]="auto",t.style.msInterpolationMode="bicubic",t}},e.RequestAnimationFrame=function(t,e){void 0===e&&(e=!1),this.game=t,this.isRunning=!1,this.forceSetTimeOut=e;for(var i=["ms","moz","webkit","o"],s=0;s<i.length&&!window.requestAnimationFrame;s++)window.requestAnimationFrame=window[i[s]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[i[s]+"CancelAnimationFrame"]||window[i[s]+"CancelRequestAnimationFrame"];this._isSetTimeOut=!1,this._onLoop=null,this._timeOutID=null},e.RequestAnimationFrame.prototype={start:function(){this.isRunning=!0;var t=this;!window.requestAnimationFrame||this.forceSetTimeOut?(this._isSetTimeOut=!0,this._onLoop=function(){return t.updateSetTimeout()},this._timeOutID=window.setTimeout(this._onLoop,0)):(this._isSetTimeOut=!1,this._onLoop=function(e){return t.updateRAF(e)},this._timeOutID=window.requestAnimationFrame(this._onLoop))},updateRAF:function(t){this.isRunning&&(this.game.update(Math.floor(t)),this._timeOutID=window.requestAnimationFrame(this._onLoop))},updateSetTimeout:function(){this.isRunning&&(this.game.update(Date.now()),this._timeOutID=window.setTimeout(this._onLoop,this.game.time.timeToCall))},stop:function(){this._isSetTimeOut?clearTimeout(this._timeOutID):window.cancelAnimationFrame(this._timeOutID),this.isRunning=!1},isSetTimeOut:function(){return this._isSetTimeOut},isRAF:function(){return!1===this._isSetTimeOut}},e.RequestAnimationFrame.prototype.constructor=e.RequestAnimationFrame,e.Math={PI2:2*Math.PI,HALF_PI:.5*Math.PI,DEG_TO_RAD:Math.PI/180,RAD_TO_DEG:180/Math.PI,degToRad:function(t){return t*e.Math.DEG_TO_RAD},radToDeg:function(t){return t*e.Math.RAD_TO_DEG},getNextPowerOfTwo:function(t){if(t>0&&0==(t&t-1))return t;for(var e=1;e<t;)e<<=1;return e},isPowerOfTwo:function(t,e){return t>0&&0==(t&t-1)&&e>0&&0==(e&e-1)},random:function(t,e){if(void 0===t&&(t=0),void 0===e&&(e=1),t===e)return t;if(t>e){var i=t;t=e,e=i}return Math.random()*(e-t)+t},between:function(t,e){if(void 0===t&&(t=0),void 0===e&&(e=1),t===e)return t;if(t>e){var i=t;t=e,e=i}return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t},fuzzyEqual:function(t,e,i){return void 0===i&&(i=1e-4),Math.abs(t-e)<i},fuzzyLessThan:function(t,e,i){return void 0===i&&(i=1e-4),t<e+i},fuzzyGreaterThan:function(t,e,i){return void 0===i&&(i=1e-4),t>e-i},fuzzyCeil:function(t,e){return void 0===e&&(e=1e-4),Math.ceil(t-e)},fuzzyFloor:function(t,e){return void 0===e&&(e=1e-4),Math.floor(t+e)},average:function(){for(var t=0,e=arguments.length,i=0;i<e;i++)t+=+arguments[i];return t/e},shear:function(t){return t%1},snapTo:function(t,e,i){return void 0===i&&(i=0),0===e?t:(t-=i,t=e*Math.round(t/e),i+t)},snapToFloor:function(t,e,i){return void 0===i&&(i=0),0===e?t:(t-=i,t=e*Math.floor(t/e),i+t)},snapToCeil:function(t,e,i){return void 0===i&&(i=0),0===e?t:(t-=i,t=e*Math.ceil(t/e),i+t)},roundTo:function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var s=Math.pow(i,-e);return Math.round(t*s)/s},floorTo:function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var s=Math.pow(i,-e);return Math.floor(t*s)/s},ceilTo:function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var s=Math.pow(i,-e);return Math.ceil(t*s)/s},trunc:function(t){return isFinite(t)?t-t%1||(t<0?-0:0===t?t:0):t},rotateToAngle:function(t,i,s){return void 0===s&&(s=.05),t===i?t:(Math.abs(i-t)<=s||Math.abs(i-t)>=e.Math.PI2-s?t=i:(Math.abs(i-t)>Math.PI&&(i<t?i+=e.Math.PI2:i-=e.Math.PI2),i>t?t+=s:i<t&&(t-=s)),t)},getShortestAngle:function(t,e){var i=e-t;return 0===i?0:i-360*Math.floor((i- -180)/360)},angleBetween:function(t,e,i,s){return Math.atan2(s-e,i-t)},angleBetweenY:function(t,e,i,s){return Math.atan2(i-t,s-e)},angleBetweenPoints:function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)},angleBetweenPointsY:function(t,e){return Math.atan2(e.x-t.x,e.y-t.y)},reverseAngle:function(t){return this.normalizeAngle(t+Math.PI,!0)},normalizeAngle:function(t){return(t%=2*Math.PI)>=0?t:t+2*Math.PI},maxAdd:function(t,e,i){return Math.min(t+e,i)},minSub:function(t,e,i){return Math.max(t-e,i)},wrap:function(t,e,i){var s=i-e;if(s<=0)return 0;var n=(t-e)%s;return n<0&&(n+=s),n+e},wrapValue:function(t,e,i){return t=Math.abs(t),e=Math.abs(e),i=Math.abs(i),(t+e)%i},isOdd:function(t){return!!(1&t)},isEven:function(t){return!(1&t)},min:function(){if(1===arguments.length&&"object"==typeof arguments[0])t=arguments[0];else var t=arguments;for(var e=1,i=0,s=t.length;e<s;e++)t[e]<t[i]&&(i=e);return t[i]},max:function(){if(1===arguments.length&&"object"==typeof arguments[0])t=arguments[0];else var t=arguments;for(var e=1,i=0,s=t.length;e<s;e++)t[e]>t[i]&&(i=e);return t[i]},minProperty:function(t){if(2===arguments.length&&"object"==typeof arguments[1])e=arguments[1];else var e=arguments.slice(1);for(var i=1,s=0,n=e.length;i<n;i++)e[i][t]<e[s][t]&&(s=i);return e[s][t]},maxProperty:function(t){if(2===arguments.length&&"object"==typeof arguments[1])e=arguments[1];else var e=arguments.slice(1);for(var i=1,s=0,n=e.length;i<n;i++)e[i][t]>e[s][t]&&(s=i);return e[s][t]},wrapAngle:function(t,e){return e?this.wrap(t,-Math.PI,Math.PI):this.wrap(t,-180,180)},linearInterpolation:function(t,e){var i=t.length-1,s=i*e,n=Math.floor(s);return e<0?this.linear(t[0],t[1],s):e>1?this.linear(t[i],t[i-1],i-s):this.linear(t[n],t[n+1>i?i:n+1],s-n)},bezierInterpolation:function(t,e){for(var i=0,s=t.length-1,n=0;n<=s;n++)i+=Math.pow(1-e,s-n)*Math.pow(e,n)*t[n]*this.bernstein(s,n);return i},catmullRomInterpolation:function(t,e){var i=t.length-1,s=i*e,n=Math.floor(s);return t[0]===t[i]?(e<0&&(n=Math.floor(s=i*(1+e))),this.catmullRom(t[(n-1+i)%i],t[n],t[(n+1)%i],t[(n+2)%i],s-n)):e<0?t[0]-(this.catmullRom(t[0],t[0],t[1],t[1],-s)-t[0]):e>1?t[i]-(this.catmullRom(t[i],t[i],t[i-1],t[i-1],s-i)-t[i]):this.catmullRom(t[n?n-1:0],t[n],t[i<n+1?i:n+1],t[i<n+2?i:n+2],s-n)},linear:function(t,e,i){return(e-t)*i+t},bernstein:function(t,e){return this.factorial(t)/this.factorial(e)/this.factorial(t-e)},factorial:function(t){if(0===t)return 1;for(var e=t;--t;)e*=t;return e},catmullRom:function(t,e,i,s,n){var r=.5*(i-t),o=.5*(s-e),a=n*n;return(2*e-2*i+r+o)*(n*a)+(-3*e+3*i-2*r-o)*a+r*n+e},difference:function(t,e){return Math.abs(t-e)},roundAwayFromZero:function(t){return t>0?Math.ceil(t):Math.floor(t)},sinCosGenerator:function(t,e,i,s){void 0===e&&(e=1),void 0===i&&(i=1),void 0===s&&(s=1);for(var n=e,r=i,o=s*Math.PI/t,a=[],h=[],l=0;l<t;l++)n+=(r-=n*o)*o,a[l]=r,h[l]=n;return{sin:h,cos:a,length:t}},hypot:function(t,e){return Math.sqrt(t*t+e*e)},distance:function(t,e,i,s){var n=t-i,r=e-s;return Math.sqrt(n*n+r*r)},distanceSq:function(t,e,i,s){var n=t-i,r=e-s;return n*n+r*r},distancePow:function(t,e,i,s,n){return void 0===n&&(n=2),Math.sqrt(Math.pow(i-t,n)+Math.pow(s-e,n))},clamp:function(t,e,i){return t<e?e:i<t?i:t},clampBottom:function(t,e){return t<e?e:t},within:function(t,e,i){return Math.abs(t-e)<=i},mapLinear:function(t,e,i,s,n){return s+(t-e)*(n-s)/(i-e)},smoothstep:function(t,e,i){return(t=Math.max(0,Math.min(1,(t-e)/(i-e))))*t*(3-2*t)},smootherstep:function(t,e,i){return(t=Math.max(0,Math.min(1,(t-e)/(i-e))))*t*t*(t*(6*t-15)+10)},sign:function(t){return t<0?-1:t>0?1:0},percent:function(t,e,i){return void 0===i&&(i=0),t>e||i>e?1:t<i||i>t?0:(t-i)/e}},e.RandomDataGenerator=function(t){void 0===t&&(t=[]),this.c=1,this.s0=0,this.s1=0,this.s2=0,"string"==typeof t?this.state(t):this.sow(t)},e.RandomDataGenerator.prototype={rnd:function(){var t=2091639*this.s0+2.3283064365386963e-10*this.c;return this.c=0|t,this.s0=this.s1,this.s1=this.s2,this.s2=t-this.c,this.s2},sow:function(t){if(this.s0=this.hash(" "),this.s1=this.hash(this.s0),this.s2=this.hash(this.s1),this.c=1,t)for(var e=0;e<t.length&&null!=t[e];e++){var i=t[e];this.s0-=this.hash(i),this.s0+=~~(this.s0<0),this.s1-=this.hash(i),this.s1+=~~(this.s1<0),this.s2-=this.hash(i),this.s2+=~~(this.s2<0)}},hash:function(t){var e,i,s;for(s=4022871197,t=t.toString(),i=0;i<t.length;i++)e=.02519603282416938*(s+=t.charCodeAt(i)),e-=s=e>>>0,s=(e*=s)>>>0,s+=4294967296*(e-=s);return 2.3283064365386963e-10*(s>>>0)},integer:function(){return 4294967296*this.rnd.apply(this)},frac:function(){return this.rnd.apply(this)+1.1102230246251565e-16*(2097152*this.rnd.apply(this)|0)},real:function(){return this.integer()+this.frac()},integerInRange:function(t,e){return Math.floor(this.realInRange(0,e-t+1)+t)},between:function(t,e){return this.integerInRange(t,e)},realInRange:function(t,e){return this.frac()*(e-t)+t},normal:function(){return 1-2*this.frac()},uuid:function(){var t="",e="";for(e=t="";t++<36;e+=~t%5|3*t&4?(15^t?8^this.frac()*(20^t?16:4):4).toString(16):"-");return e},pick:function(t){return t[this.integerInRange(0,t.length-1)]},sign:function(){return this.pick([-1,1])},weightedPick:function(t){return t[~~(Math.pow(this.frac(),2)*(t.length-1)+.5)]},timestamp:function(t,e){return this.realInRange(t||9466848e5,e||1577862e6)},angle:function(){return this.integerInRange(-180,180)},state:function(t){return"string"==typeof t&&t.match(/^!rnd/)&&(t=t.split(","),this.c=parseFloat(t[1]),this.s0=parseFloat(t[2]),this.s1=parseFloat(t[3]),this.s2=parseFloat(t[4])),["!rnd",this.c,this.s0,this.s1,this.s2].join(",")}},e.RandomDataGenerator.prototype.constructor=e.RandomDataGenerator,e.QuadTree=function(t,e,i,s,n,r,o){this.maxObjects=10,this.maxLevels=4,this.level=0,this.bounds={},this.objects=[],this.nodes=[],this._empty=[],this.reset(t,e,i,s,n,r,o)},e.QuadTree.prototype={reset:function(t,e,i,s,n,r,o){this.maxObjects=n||10,this.maxLevels=r||4,this.level=o||0,this.bounds={x:Math.round(t),y:Math.round(e),width:i,height:s,subWidth:Math.floor(i/2),subHeight:Math.floor(s/2),right:Math.round(t)+Math.floor(i/2),bottom:Math.round(e)+Math.floor(s/2)},this.objects.length=0,this.nodes.length=0},populate:function(t){t.forEach(this.populateHandler,this,!0)},populateHandler:function(t){t.body&&t.exists&&this.insert(t.body)},split:function(){this.nodes[0]=new e.QuadTree(this.bounds.right,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[1]=new e.QuadTree(this.bounds.x,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[2]=new e.QuadTree(this.bounds.x,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[3]=new e.QuadTree(this.bounds.right,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1)},insert:function(t){var e,i=0;if(null==this.nodes[0]||-1===(e=this.getIndex(t))){if(this.objects.push(t),this.objects.length>this.maxObjects&&this.level<this.maxLevels)for(null==this.nodes[0]&&this.split();i<this.objects.length;)-1!==(e=this.getIndex(this.objects[i]))?this.nodes[e].insert(this.objects.splice(i,1)[0]):i++}else this.nodes[e].insert(t)},getIndex:function(t){var e=-1;return t.x<this.bounds.right&&t.right<this.bounds.right?t.y<this.bounds.bottom&&t.bottom<this.bounds.bottom?e=1:t.y>this.bounds.bottom&&(e=2):t.x>this.bounds.right&&(t.y<this.bounds.bottom&&t.bottom<this.bounds.bottom?e=0:t.y>this.bounds.bottom&&(e=3)),e},retrieve:function(t){if(t instanceof e.Rectangle)var i=this.objects,s=this.getIndex(t);else{if(!t.body)return this._empty;var i=this.objects,s=this.getIndex(t.body)}return this.nodes[0]&&(i=-1!==s?i.concat(this.nodes[s].retrieve(t)):(i=(i=(i=i.concat(this.nodes[0].retrieve(t))).concat(this.nodes[1].retrieve(t))).concat(this.nodes[2].retrieve(t))).concat(this.nodes[3].retrieve(t))),i},clear:function(){this.objects.length=0;for(var t=this.nodes.length;t--;)this.nodes[t].clear(),this.nodes.splice(t,1);this.nodes.length=0}},e.QuadTree.prototype.constructor=e.QuadTree,e.Net=function(t){this.game=t},e.Net.prototype={getHostName:function(){return window.location&&window.location.hostname?window.location.hostname:null},checkDomainName:function(t){return-1!==window.location.hostname.indexOf(t)},updateQueryString:function(t,e,i,s){void 0===i&&(i=!1),void 0!==s&&""!==s||(s=window.location.href);var n="",r=new RegExp("([?|&])"+t+"=.*?(&|#|$)(.*)","gi");if(r.test(s))n=void 0!==e&&null!==e?s.replace(r,"$1"+t+"="+e+"$2$3"):s.replace(r,"$1$3").replace(/(&|\?)$/,"");else if(void 0!==e&&null!==e){var o=-1!==s.indexOf("?")?"&":"?",a=s.split("#");s=a[0]+o+t+"="+e,a[1]&&(s+="#"+a[1]),n=s}else n=s;if(!i)return n;window.location.href=n},getQueryString:function(t){void 0===t&&(t="");var e={},i=location.search.substring(1).split("&");for(var s in i){var n=i[s].split("=");if(n.length>1){if(t&&t===this.decodeURI(n[0]))return this.decodeURI(n[1]);e[this.decodeURI(n[0])]=this.decodeURI(n[1])}}return e},decodeURI:function(t){return decodeURIComponent(t.replace(/\+/g," "))}},e.Net.prototype.constructor=e.Net,e.TweenManager=function(t){this.game=t,this.frameBased=!1,this._tweens=[],this._add=[],this.easeMap={Power0:e.Easing.Power0,Power1:e.Easing.Power1,Power2:e.Easing.Power2,Power3:e.Easing.Power3,Power4:e.Easing.Power4,Linear:e.Easing.Linear.None,Quad:e.Easing.Quadratic.Out,Cubic:e.Easing.Cubic.Out,Quart:e.Easing.Quartic.Out,Quint:e.Easing.Quintic.Out,Sine:e.Easing.Sinusoidal.Out,Expo:e.Easing.Exponential.Out,Circ:e.Easing.Circular.Out,Elastic:e.Easing.Elastic.Out,Back:e.Easing.Back.Out,Bounce:e.Easing.Bounce.Out,"Quad.easeIn":e.Easing.Quadratic.In,"Cubic.easeIn":e.Easing.Cubic.In,"Quart.easeIn":e.Easing.Quartic.In,"Quint.easeIn":e.Easing.Quintic.In,"Sine.easeIn":e.Easing.Sinusoidal.In,"Expo.easeIn":e.Easing.Exponential.In,"Circ.easeIn":e.Easing.Circular.In,"Elastic.easeIn":e.Easing.Elastic.In,"Back.easeIn":e.Easing.Back.In,"Bounce.easeIn":e.Easing.Bounce.In,"Quad.easeOut":e.Easing.Quadratic.Out,"Cubic.easeOut":e.Easing.Cubic.Out,"Quart.easeOut":e.Easing.Quartic.Out,"Quint.easeOut":e.Easing.Quintic.Out,"Sine.easeOut":e.Easing.Sinusoidal.Out,"Expo.easeOut":e.Easing.Exponential.Out,"Circ.easeOut":e.Easing.Circular.Out,"Elastic.easeOut":e.Easing.Elastic.Out,"Back.easeOut":e.Easing.Back.Out,"Bounce.easeOut":e.Easing.Bounce.Out,"Quad.easeInOut":e.Easing.Quadratic.InOut,"Cubic.easeInOut":e.Easing.Cubic.InOut,"Quart.easeInOut":e.Easing.Quartic.InOut,"Quint.easeInOut":e.Easing.Quintic.InOut,"Sine.easeInOut":e.Easing.Sinusoidal.InOut,"Expo.easeInOut":e.Easing.Exponential.InOut,"Circ.easeInOut":e.Easing.Circular.InOut,"Elastic.easeInOut":e.Easing.Elastic.InOut,"Back.easeInOut":e.Easing.Back.InOut,"Bounce.easeInOut":e.Easing.Bounce.InOut},this.game.onPause.add(this._pauseAll,this),this.game.onResume.add(this._resumeAll,this)},e.TweenManager.prototype={getAll:function(){return this._tweens},removeAll:function(){for(var t=0;t<this._tweens.length;t++)this._tweens[t].pendingDelete=!0;this._add=[]},removeFrom:function(t,i){void 0===i&&(i=!0);if(Array.isArray(t))for(s=0,n=t.length;s<n;s++)this.removeFrom(t[s]);else if(t.type===e.GROUP&&i)for(var s=0,n=t.children.length;s<n;s++)this.removeFrom(t.children[s]);else{for(s=0,n=this._tweens.length;s<n;s++)t===this._tweens[s].target&&this.remove(this._tweens[s]);for(s=0,n=this._add.length;s<n;s++)t===this._add[s].target&&this.remove(this._add[s])}},add:function(t){t._manager=this,this._add.push(t)},create:function(t){return new e.Tween(t,this.game,this)},remove:function(t){var e=this._tweens.indexOf(t);-1!==e?this._tweens[e].pendingDelete=!0:-1!==(e=this._add.indexOf(t))&&(this._add[e].pendingDelete=!0)},update:function(){var t=this._add.length,e=this._tweens.length;if(0===e&&0===t)return!1;for(var i=0;i<e;)this._tweens[i].update(this.game.time.time)?i++:(this._tweens.splice(i,1),e--);return t>0&&(this._tweens=this._tweens.concat(this._add),this._add.length=0),!0},isTweening:function(t,e){return e||(e=!1),this._tweens.some(function(i){return i.target===t&&(!e||i.isRunning&&!i.pendingDelete)})},_pauseAll:function(){for(var t=this._tweens.length-1;t>=0;t--)this._tweens[t]._pause()},_resumeAll:function(){for(var t=this._tweens.length-1;t>=0;t--)this._tweens[t]._resume()},pauseAll:function(){for(var t=this._tweens.length-1;t>=0;t--)this._tweens[t].pause()},resumeAll:function(){for(var t=this._tweens.length-1;t>=0;t--)this._tweens[t].resume(!0)},destroy:function(){this.game.onPause.remove(this._pauseAll,this),this.game.onResume.remove(this._resumeAll,this),this.game=null,this._add=null,this._tweens=null}},e.TweenManager.prototype.constructor=e.TweenManager,e.Tween=function(t,i,s){this.game=i,this.target=t,this.manager=s,this.timeline=[],this.reverse=!1,this.timeScale=1,this.repeatCounter=0,this.pendingDelete=!1,this.onStart=new e.Signal,this.onLoop=new e.Signal,this.onRepeat=new e.Signal,this.onChildComplete=new e.Signal,this.onComplete=new e.Signal,this.isRunning=!1,this.current=0,this.properties={},this.chainedTween=null,this.isPaused=!1,this.frameBased=s.frameBased,this._onUpdateCallback=null,this._onUpdateCallbackContext=null,this._pausedTime=0,this._codePaused=!1,this._hasStarted=!1},e.Tween.updateColor=function(t){e.Color.updateColor(t.target)},e.Tween.prototype={to:function(t,i,s,n,r,o,a){return(void 0===i||i<=0)&&(i=1e3),void 0!==s&&null!==s||(s=e.Easing.Default),void 0===n&&(n=!1),void 0===r&&(r=0),void 0===o&&(o=0),void 0===a&&(a=!1),"string"==typeof s&&this.manager.easeMap[s]&&(s=this.manager.easeMap[s]),this.isRunning?(console.warn("Phaser.Tween.to cannot be called after Tween.start"),this):(this.timeline.push(new e.TweenData(this).to(t,i,s,r,o,a)),n&&this.start(),this)},from:function(t,i,s,n,r,o,a){return void 0===i&&(i=1e3),void 0!==s&&null!==s||(s=e.Easing.Default),void 0===n&&(n=!1),void 0===r&&(r=0),void 0===o&&(o=0),void 0===a&&(a=!1),"string"==typeof s&&this.manager.easeMap[s]&&(s=this.manager.easeMap[s]),this.isRunning?(console.warn("Phaser.Tween.from cannot be called after Tween.start"),this):(this.timeline.push(new e.TweenData(this).from(t,i,s,r,o,a)),n&&this.start(),this)},start:function(t){if(void 0===t&&(t=0),this.pendingDelete)return console.warn("Phaser.Tween.start cannot be called after Tween.stop"),this;if(null===this.game||null===this.target||0===this.timeline.length||this.isRunning)return this;for(i=0;i<this.timeline.length;i++)for(var e in this.timeline[i].vEnd)this.properties[e]=this.target[e]||0,Array.isArray(this.properties[e])||(this.properties[e]*=1);for(var i=0;i<this.timeline.length;i++)this.timeline[i].loadValues();return this.manager.add(this),this.isRunning=!0,(t<0||t>this.timeline.length-1)&&(t=0),this.current=t,this.timeline[this.current].start(),this},stop:function(t){return void 0===t&&(t=!1),this.isRunning=!1,this._onUpdateCallback=null,this._onUpdateCallbackContext=null,t&&(this.onComplete.dispatch(this.target,this),this._hasStarted=!1,this.chainedTween&&this.chainedTween.start()),this.manager.remove(this),this},updateTweenData:function(t,e,i){if(0===this.timeline.length)return this;if(void 0===i&&(i=0),-1===i)for(var s=0;s<this.timeline.length;s++)this.timeline[s][t]=e;else this.timeline[i][t]=e;return this},delay:function(t,e){return this.updateTweenData("delay",t,e)},repeat:function(t,e,i){return void 0===e&&(e=0),this.updateTweenData("repeatCounter",t,i),this.updateTweenData("repeatTotal",t,i),this.updateTweenData("repeatDelay",e,i)},repeatDelay:function(t,e){return this.updateTweenData("repeatDelay",t,e)},yoyo:function(t,e,i){return void 0===e&&(e=0),this.updateTweenData("yoyo",t,i),this.updateTweenData("yoyoDelay",e,i)},yoyoDelay:function(t,e){return this.updateTweenData("yoyoDelay",t,e)},easing:function(t,e){return"string"==typeof t&&this.manager.easeMap[t]&&(t=this.manager.easeMap[t]),this.updateTweenData("easingFunction",t,e)},interpolation:function(t,i,s){return void 0===i&&(i=e.Math),this.updateTweenData("interpolationFunction",t,s),this.updateTweenData("interpolationContext",i,s)},repeatAll:function(t){return void 0===t&&(t=0),this.repeatCounter=t,this},chain:function(){for(var t=arguments.length;t--;)t>0?arguments[t-1].chainedTween=arguments[t]:this.chainedTween=arguments[t];return this},loop:function(t){return void 0===t&&(t=!0),this.repeatCounter=t?-1:0,this},onUpdateCallback:function(t,e){return this._onUpdateCallback=t,this._onUpdateCallbackContext=e,this},pause:function(){this.isPaused=!0,this._codePaused=!0,this._pausedTime=this.game.time.time},_pause:function(){this._codePaused||(this.isPaused=!0,this._pausedTime=this.game.time.time)},resume:function(){if(this.isPaused){this.isPaused=!1,this._codePaused=!1;for(var t=0;t<this.timeline.length;t++)this.timeline[t].isRunning||(this.timeline[t].startTime+=this.game.time.time-this._pausedTime)}},_resume:function(){this._codePaused||this.resume()},update:function(t){if(this.pendingDelete||!this.target)return!1;if(this.isPaused)return!0;var i=this.timeline[this.current].update(t);if(i===e.TweenData.PENDING)return!0;if(i===e.TweenData.RUNNING)return this._hasStarted||(this.onStart.dispatch(this.target,this),this._hasStarted=!0),null!==this._onUpdateCallback&&this._onUpdateCallback.call(this._onUpdateCallbackContext,this,this.timeline[this.current].value,this.timeline[this.current]),this.isRunning;if(i===e.TweenData.LOOPED)return-1===this.timeline[this.current].repeatCounter?this.onLoop.dispatch(this.target,this):this.onRepeat.dispatch(this.target,this),!0;if(i===e.TweenData.COMPLETE){var s=!1;return this.reverse?--this.current<0&&(this.current=this.timeline.length-1,s=!0):++this.current===this.timeline.length&&(this.current=0,s=!0),s?-1===this.repeatCounter?(this.timeline[this.current].start(),this.onLoop.dispatch(this.target,this),!0):this.repeatCounter>0?(this.repeatCounter--,this.timeline[this.current].start(),this.onRepeat.dispatch(this.target,this),!0):(this.isRunning=!1,this.onComplete.dispatch(this.target,this),this._hasStarted=!1,this.chainedTween&&this.chainedTween.start(),!1):(this.onChildComplete.dispatch(this.target,this),this.timeline[this.current].start(),!0)}},generateData:function(t,e){if(null===this.game||null===this.target)return null;void 0===t&&(t=60),void 0===e&&(e=[]);for(s=0;s<this.timeline.length;s++)for(var i in this.timeline[s].vEnd)this.properties[i]=this.target[i]||0,Array.isArray(this.properties[i])||(this.properties[i]*=1);for(s=0;s<this.timeline.length;s++)this.timeline[s].loadValues();for(var s=0;s<this.timeline.length;s++)e=e.concat(this.timeline[s].generateData(t));return e}},Object.defineProperty(e.Tween.prototype,"totalDuration",{get:function(){for(var t=0,e=0;e<this.timeline.length;e++)t+=this.timeline[e].duration;return t}}),e.Tween.prototype.constructor=e.Tween,e.TweenData=function(t){this.parent=t,this.game=t.game,this.vStart={},this.vStartCache={},this.vEnd={},this.vEndCache={},this.duration=1e3,this.percent=0,this.value=0,this.repeatCounter=0,this.repeatDelay=0,this.repeatTotal=0,this.interpolate=!1,this.yoyo=!1,this.yoyoDelay=0,this.inReverse=!1,this.delay=0,this.dt=0,this.startTime=null,this.easingFunction=e.Easing.Default,this.interpolationFunction=e.Math.linearInterpolation,this.interpolationContext=e.Math,this.isRunning=!1,this.isFrom=!1},e.TweenData.PENDING=0,e.TweenData.RUNNING=1,e.TweenData.LOOPED=2,e.TweenData.COMPLETE=3,e.TweenData.prototype={to:function(t,e,i,s,n,r){return this.vEnd=t,this.duration=e,this.easingFunction=i,this.delay=s,this.repeatTotal=n,this.yoyo=r,this.isFrom=!1,this},from:function(t,e,i,s,n,r){return this.vEnd=t,this.duration=e,this.easingFunction=i,this.delay=s,this.repeatTotal=n,this.yoyo=r,this.isFrom=!0,this},start:function(){if(this.startTime=this.game.time.time+this.delay,this.parent.reverse?this.dt=this.duration:this.dt=0,this.delay>0?this.isRunning=!1:this.isRunning=!0,this.isFrom)for(var t in this.vStartCache)this.vStart[t]=this.vEndCache[t],this.vEnd[t]=this.vStartCache[t],this.parent.target[t]=this.vStart[t];return this.value=0,this.repeatCounter=this.repeatTotal,this},loadValues:function(){for(var t in this.parent.properties){if(this.vStart[t]=this.parent.properties[t],Array.isArray(this.vEnd[t])){if(0===this.vEnd[t].length)continue;0===this.percent&&(this.vEnd[t]=[this.vStart[t]].concat(this.vEnd[t]))}void 0!==this.vEnd[t]?("string"==typeof this.vEnd[t]&&(this.vEnd[t]=this.vStart[t]+parseFloat(this.vEnd[t])),this.parent.properties[t]=this.vEnd[t]):this.vEnd[t]=this.vStart[t],this.vStartCache[t]=this.vStart[t],this.vEndCache[t]=this.vEnd[t]}return this},update:function(t){if(this.isRunning){if(t<this.startTime)return e.TweenData.RUNNING}else{if(!(t>=this.startTime))return e.TweenData.PENDING;this.isRunning=!0}var i=this.parent.frameBased?this.game.time.physicsElapsedMS:this.game.time.elapsedMS;this.parent.reverse?(this.dt-=i*this.parent.timeScale,this.dt=Math.max(this.dt,0)):(this.dt+=i*this.parent.timeScale,this.dt=Math.min(this.dt,this.duration)),this.percent=this.dt/this.duration,this.value=this.easingFunction(this.percent);for(var s in this.vEnd){var n=this.vStart[s],r=this.vEnd[s];Array.isArray(r)?this.parent.target[s]=this.interpolationFunction.call(this.interpolationContext,r,this.value):this.parent.target[s]=n+(r-n)*this.value}return!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent?this.repeat():e.TweenData.RUNNING},generateData:function(t){this.parent.reverse?this.dt=this.duration:this.dt=0;var e=[],i=!1,s=1/t*1e3;do{this.parent.reverse?(this.dt-=s,this.dt=Math.max(this.dt,0)):(this.dt+=s,this.dt=Math.min(this.dt,this.duration)),this.percent=this.dt/this.duration,this.value=this.easingFunction(this.percent);var n={};for(var r in this.vEnd){var o=this.vStart[r],a=this.vEnd[r];Array.isArray(a)?n[r]=this.interpolationFunction.call(this.interpolationContext,a,this.value):n[r]=o+(a-o)*this.value}e.push(n),(!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent)&&(i=!0)}while(!i);if(this.yoyo){var h=e.slice();h.reverse(),e=e.concat(h)}return e},repeat:function(){if(this.yoyo){if(this.inReverse&&0===this.repeatCounter){for(var t in this.vStartCache)this.vStart[t]=this.vStartCache[t],this.vEnd[t]=this.vEndCache[t];return this.inReverse=!1,e.TweenData.COMPLETE}this.inReverse=!this.inReverse}else if(0===this.repeatCounter)return e.TweenData.COMPLETE;if(this.inReverse)for(var t in this.vStartCache)this.vStart[t]=this.vEndCache[t],this.vEnd[t]=this.vStartCache[t];else{for(var t in this.vStartCache)this.vStart[t]=this.vStartCache[t],this.vEnd[t]=this.vEndCache[t];this.repeatCounter>0&&this.repeatCounter--}return this.startTime=this.game.time.time,this.yoyo&&this.inReverse?this.startTime+=this.yoyoDelay:this.inReverse||(this.startTime+=this.repeatDelay),this.parent.reverse?this.dt=this.duration:this.dt=0,e.TweenData.LOOPED}},e.TweenData.prototype.constructor=e.TweenData,e.Easing={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 0===t?0:1===t?1:1-Math.cos(t*Math.PI/2)},Out:function(t){return 0===t?0:1===t?1:Math.sin(t*Math.PI/2)},InOut:function(t){return 0===t?0:1===t?1:.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:(.1,-1*Math.pow(2,10*(t-=1))*Math.sin((t-.1)*(2*Math.PI)/.4))},Out:function(t){return 0===t?0:1===t?1:(.1,1*Math.pow(2,-10*t)*Math.sin((t-.1)*(2*Math.PI)/.4)+1)},InOut:function(t){return 0===t?0:1===t?1:(.1,(t*=2)<1?1*Math.pow(2,10*(t-=1))*Math.sin((t-.1)*(2*Math.PI)/.4)*-.5:1*Math.pow(2,-10*(t-=1))*Math.sin((t-.1)*(2*Math.PI)/.4)*.5+1)}},Back:{In:function(t){var e=1.70158;return t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:function(t){return 1-e.Easing.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*e.Easing.Bounce.In(2*t):.5*e.Easing.Bounce.Out(2*t-1)+.5}}},e.Easing.Default=e.Easing.Linear.None,e.Easing.Power0=e.Easing.Linear.None,e.Easing.Power1=e.Easing.Quadratic.Out,e.Easing.Power2=e.Easing.Cubic.Out,e.Easing.Power3=e.Easing.Quartic.Out,e.Easing.Power4=e.Easing.Quintic.Out,e.Time=function(t){this.game=t,this.time=0,this.prevTime=0,this.now=0,this.elapsed=0,this.elapsedMS=0,this.physicsElapsed=1/60,this.physicsElapsedMS=1/60*1e3,this.desiredFpsMult=1/60,this._desiredFps=60,this.suggestedFps=this.desiredFps,this.slowMotion=1,this.advancedTiming=!1,this.frames=0,this.updates=0,this.renders=0,this.fps=0,this.ups=0,this.rps=0,this.fpsMin=1e3,this.fpsMax=0,this.msMin=1e3,this.msMax=0,this.pauseDuration=0,this.timeToCall=0,this.timeExpected=0,this.events=new e.Timer(this.game,!1),this._frameCount=0,this._elapsedAccumulator=0,this._started=0,this._timeLastSecond=0,this._pauseStarted=0,this._justResumed=!1,this._timers=[]},e.Time.prototype={boot:function(){this._started=Date.now(),this.time=Date.now(),this.events.start(),this.timeExpected=this.time},add:function(t){return this._timers.push(t),t},create:function(t){void 0===t&&(t=!0);var i=new e.Timer(this.game,t);return this._timers.push(i),i},removeAll:function(){for(var t=0;t<this._timers.length;t++)this._timers[t].destroy();this._timers=[],this.events.removeAll()},refresh:function(){var t=this.time;this.time=Date.now(),this.elapsedMS=this.time-t},update:function(t){var e=this.time;this.time=Date.now(),this.elapsedMS=this.time-e,this.prevTime=this.now,this.now=t,this.elapsed=this.now-this.prevTime,this.game.raf._isSetTimeOut&&(this.timeToCall=Math.floor(Math.max(0,1e3/this._desiredFps-(this.timeExpected-t))),this.timeExpected=t+this.timeToCall),this.advancedTiming&&this.updateAdvancedTiming(),this.game.paused||(this.events.update(this.time),this._timers.length&&this.updateTimers())},updateTimers:function(){for(var t=0,e=this._timers.length;t<e;)this._timers[t].update(this.time)?t++:(this._timers.splice(t,1),e--)},updateAdvancedTiming:function(){if(this._frameCount++,this._elapsedAccumulator+=this.elapsed,this._frameCount>=2*this._desiredFps&&(this.suggestedFps=5*Math.floor(200/(this._elapsedAccumulator/this._frameCount)),this._frameCount=0,this._elapsedAccumulator=0),this.msMin=Math.min(this.msMin,this.elapsed),this.msMax=Math.max(this.msMax,this.elapsed),this.frames++,this.now>this._timeLastSecond+1e3){var t=this.now-this._timeLastSecond;this.fps=Math.round(1e3*this.frames/t),this.ups=Math.round(1e3*this.updates/t),this.rps=Math.round(1e3*this.renders/t),this.fpsMin=Math.min(this.fpsMin,this.fps),this.fpsMax=Math.max(this.fpsMax,this.fps),this._timeLastSecond=this.now,this.frames=0,this.updates=0,this.renders=0}},countUpdate:function(){this.advancedTiming&&this.updates++},countRender:function(){this.advancedTiming&&this.renders++},gamePaused:function(){this._pauseStarted=Date.now(),this.events.pause();for(var t=this._timers.length;t--;)this._timers[t]._pause()},gameResumed:function(){this.time=Date.now(),this.pauseDuration=this.time-this._pauseStarted,this.events.resume();for(var t=this._timers.length;t--;)this._timers[t]._resume()},totalElapsedSeconds:function(){return.001*(this.time-this._started)},elapsedSince:function(t){return this.time-t},elapsedSecondsSince:function(t){return.001*(this.time-t)},reset:function(){this._started=this.time,this.removeAll()}},Object.defineProperty(e.Time.prototype,"desiredFps",{get:function(){return this._desiredFps},set:function(t){this._desiredFps=t,this.physicsElapsed=1/t,this.physicsElapsedMS=1e3*this.physicsElapsed,this.desiredFpsMult=1/t}}),e.Time.prototype.constructor=e.Time,e.Timer=function(t,i){void 0===i&&(i=!0),this.game=t,this.running=!1,this.autoDestroy=i,this.expired=!1,this.elapsed=0,this.events=[],this.onComplete=new e.Signal,this.nextTick=0,this.timeCap=1e3,this.paused=!1,this._codePaused=!1,this._started=0,this._pauseStarted=0,this._pauseTotal=0,this._now=Date.now(),this._len=0,this._marked=0,this._i=0,this._diff=0,this._newTick=0},e.Timer.MINUTE=6e4,e.Timer.SECOND=1e3,e.Timer.HALF=500,e.Timer.QUARTER=250,e.Timer.prototype={create:function(t,i,s,n,r,o){var a=t=Math.round(t);0===this._now?a+=this.game.time.time:a+=this._now;var h=new e.TimerEvent(this,t,a,s,i,n,r,o);return this.events.push(h),this.order(),this.expired=!1,h},add:function(t,e,i){return this.create(t,!1,0,e,i,Array.prototype.slice.call(arguments,3))},repeat:function(t,e,i,s){return this.create(t,!1,e,i,s,Array.prototype.slice.call(arguments,4))},loop:function(t,e,i){return this.create(t,!0,0,e,i,Array.prototype.slice.call(arguments,3))},start:function(t){if(!this.running){this._started=this.game.time.time+(t||0),this.running=!0;for(var e=0;e<this.events.length;e++)this.events[e].tick=this.events[e].delay+this._started}},stop:function(t){this.running=!1,void 0===t&&(t=!0),t&&(this.events.length=0)},remove:function(t){for(var e=0;e<this.events.length;e++)if(this.events[e]===t)return this.events[e].pendingDelete=!0,!0;return!1},order:function(){this.events.length>0&&(this.events.sort(this.sortHandler),this.nextTick=this.events[0].tick)},sortHandler:function(t,e){return t.tick<e.tick?-1:t.tick>e.tick?1:0},clearPendingEvents:function(){for(this._i=this.events.length;this._i--;)this.events[this._i].pendingDelete&&this.events.splice(this._i,1);this._len=this.events.length,this._i=0},update:function(t){if(this.paused)return!0;if(this.elapsed=t-this._now,this._now=t,this.elapsed>this.timeCap&&this.adjustEvents(t-this.elapsed),this._marked=0,this.clearPendingEvents(),this.running&&this._now>=this.nextTick&&this._len>0){for(;this._i<this._len&&this.running;){var e=this.events[this._i];if(!(this._now>=e.tick)||e.pendingDelete)break;this._newTick=this._now+e.delay-(this._now-e.tick),this._newTick<0&&(this._newTick=this._now+e.delay),!0===e.loop?(e.tick=this._newTick,e.callback.apply(e.callbackContext,e.args)):e.repeatCount>0?(e.repeatCount--,e.tick=this._newTick,e.callback.apply(e.callbackContext,e.args)):(this._marked++,e.pendingDelete=!0,e.callback.apply(e.callbackContext,e.args)),this._i++}this.events.length>this._marked?this.order():(this.expired=!0,this.onComplete.dispatch(this))}return!this.expired||!this.autoDestroy},pause:function(){this.running&&(this._codePaused=!0,this.paused||(this._pauseStarted=this.game.time.time,this.paused=!0))},_pause:function(){!this.paused&&this.running&&(this._pauseStarted=this.game.time.time,this.paused=!0)},adjustEvents:function(t){for(var e=0;e<this.events.length;e++)if(!this.events[e].pendingDelete){var i=this.events[e].tick-t;i<0&&(i=0),this.events[e].tick=this._now+i}var s=this.nextTick-t;this.nextTick=s<0?this._now:this._now+s},resume:function(){if(this.paused){var t=this.game.time.time;this._pauseTotal+=t-this._now,this._now=t,this.adjustEvents(this._pauseStarted),this.paused=!1,this._codePaused=!1}},_resume:function(){this._codePaused||this.resume()},removeAll:function(){this.onComplete.removeAll(),this.events.length=0,this._len=0,this._i=0},destroy:function(){this.onComplete.removeAll(),this.running=!1,this.expired=!0,this.events=[],this._len=0,this._i=0}},Object.defineProperty(e.Timer.prototype,"next",{get:function(){return this.nextTick}}),Object.defineProperty(e.Timer.prototype,"duration",{get:function(){return this.running&&this.nextTick>this._now?this.nextTick-this._now:0}}),Object.defineProperty(e.Timer.prototype,"length",{get:function(){return this.events.length}}),Object.defineProperty(e.Timer.prototype,"ms",{get:function(){return this.running?this._now-this._started-this._pauseTotal:0}}),Object.defineProperty(e.Timer.prototype,"seconds",{get:function(){return this.running?.001*this.ms:0}}),e.Timer.prototype.constructor=e.Timer,e.TimerEvent=function(t,e,i,s,n,r,o,a){this.timer=t,this.delay=e,this.tick=i,this.repeatCount=s-1,this.loop=n,this.callback=r,this.callbackContext=o,this.args=a,this.pendingDelete=!1},e.TimerEvent.prototype.constructor=e.TimerEvent,e.AnimationManager=function(t){this.sprite=t,this.game=t.game,this.currentFrame=null,this.currentAnim=null,this.updateIfVisible=!0,this.isLoaded=!1,this._frameData=null,this._anims={},this._outputFrames=[]},e.AnimationManager.prototype={loadFrameData:function(t,e){if(void 0===t)return!1;if(this.isLoaded)for(var i in this._anims)this._anims[i].updateFrameData(t);return this._frameData=t,void 0===e||null===e?this.frame=0:"string"==typeof e?this.frameName=e:this.frame=e,this.isLoaded=!0,!0},copyFrameData:function(t,e){if(this._frameData=t.clone(),this.isLoaded)for(var i in this._anims)this._anims[i].updateFrameData(this._frameData);return void 0===e||null===e?this.frame=0:"string"==typeof e?this.frameName=e:this.frame=e,this.isLoaded=!0,!0},add:function(t,i,s,n,r){return i=i||[],s=s||60,void 0===n&&(n=!1),void 0===r&&(r=!(!i||"number"!=typeof i[0])),this._outputFrames=[],this._frameData.getFrameIndexes(i,r,this._outputFrames),this._anims[t]=new e.Animation(this.game,this.sprite,t,this._frameData,this._outputFrames,s,n),this.currentAnim=this._anims[t],this.sprite.tilingTexture&&(this.sprite.refreshTexture=!0),this._anims[t]},validateFrames:function(t,e){void 0===e&&(e=!0);for(var i=0;i<t.length;i++)if(!0===e){if(t[i]>this._frameData.total)return!1}else if(!1===this._frameData.checkFrameName(t[i]))return!1;return!0},play:function(t,e,i,s){if(this._anims[t])return this.currentAnim===this._anims[t]?!1===this.currentAnim.isPlaying?(this.currentAnim.paused=!1,this.currentAnim.play(e,i,s)):this.currentAnim:(this.currentAnim&&this.currentAnim.isPlaying&&this.currentAnim.stop(),this.currentAnim=this._anims[t],this.currentAnim.paused=!1,this.currentFrame=this.currentAnim.currentFrame,this.currentAnim.play(e,i,s))},stop:function(t,e){void 0===e&&(e=!1),!this.currentAnim||"string"==typeof t&&t!==this.currentAnim.name||this.currentAnim.stop(e)},update:function(){return!(this.updateIfVisible&&!this.sprite.visible)&&(!(!this.currentAnim||!this.currentAnim.update())&&(this.currentFrame=this.currentAnim.currentFrame,!0))},next:function(t){this.currentAnim&&(this.currentAnim.next(t),this.currentFrame=this.currentAnim.currentFrame)},previous:function(t){this.currentAnim&&(this.currentAnim.previous(t),this.currentFrame=this.currentAnim.currentFrame)},getAnimation:function(t){return"string"==typeof t&&this._anims[t]?this._anims[t]:null},refreshFrame:function(){},destroy:function(){t=null;for(var t in this._anims)this._anims.hasOwnProperty(t)&&this._anims[t].destroy();this._anims={},this._outputFrames=[],this._frameData=null,this.currentAnim=null,this.currentFrame=null,this.sprite=null,this.game=null}},e.AnimationManager.prototype.constructor=e.AnimationManager,Object.defineProperty(e.AnimationManager.prototype,"frameData",{get:function(){return this._frameData}}),Object.defineProperty(e.AnimationManager.prototype,"frameTotal",{get:function(){return this._frameData.total}}),Object.defineProperty(e.AnimationManager.prototype,"paused",{get:function(){return this.currentAnim.isPaused},set:function(t){this.currentAnim.paused=t}}),Object.defineProperty(e.AnimationManager.prototype,"name",{get:function(){return this.currentAnim?this.currentAnim.name:void 0}}),Object.defineProperty(e.AnimationManager.prototype,"frame",{get:function(){return this.currentFrame?this.currentFrame.index:void 0},set:function(t){var e;"number"==typeof t&&this._frameData&&(e=this._frameData.getFrame(t))&&(this.currentFrame=e,this.sprite.setFrame(this.currentFrame))}}),Object.defineProperty(e.AnimationManager.prototype,"frameName",{get:function(){return this.currentFrame?this.currentFrame.name:void 0},set:function(t){var e;"string"==typeof t&&this._frameData&&(e=this._frameData.getFrameByName(t))?(this.currentFrame=e,this._frameIndex=this.currentFrame.index,this.sprite.setFrame(this.currentFrame)):console.warn("Cannot set frameName: "+t)}}),e.Animation=function(t,i,s,n,r,o,a){void 0===a&&(a=!1),this.game=t,this._parent=i,this._frameData=n,this.name=s,this._frames=[],this._frames=this._frames.concat(r),this.delay=1e3/o,this.loop=a,this.loopCount=0,this.killOnComplete=!1,this.isFinished=!1,this.isPlaying=!1,this.isPaused=!1,this._pauseStartTime=0,this._frameIndex=0,this._frameDiff=0,this._frameSkip=1,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.onStart=new e.Signal,this.onUpdate=null,this.onComplete=new e.Signal,this.onLoop=new e.Signal,this.isReversed=!1,this.game.onPause.add(this.onPause,this),this.game.onResume.add(this.onResume,this)},e.Animation.prototype={play:function(t,e,i){return"number"==typeof t&&(this.delay=1e3/t),"boolean"==typeof e&&(this.loop=e),void 0!==i&&(this.killOnComplete=i),this.isPlaying=!0,this.isFinished=!1,this.paused=!1,this.loopCount=0,this._timeLastFrame=this.game.time.time,this._timeNextFrame=this.game.time.time+this.delay,this._frameIndex=this.isReversed?this._frames.length-1:0,this.updateCurrentFrame(!1,!0),this._parent.events.onAnimationStart$dispatch(this._parent,this),this.onStart.dispatch(this._parent,this),this._parent.animations.currentAnim=this,this._parent.animations.currentFrame=this.currentFrame,this},restart:function(){this.isPlaying=!0,this.isFinished=!1,this.paused=!1,this.loopCount=0,this._timeLastFrame=this.game.time.time,this._timeNextFrame=this.game.time.time+this.delay,this._frameIndex=0,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this._parent.setFrame(this.currentFrame),this._parent.animations.currentAnim=this,this._parent.animations.currentFrame=this.currentFrame,this.onStart.dispatch(this._parent,this)},reverse:function(){return this.reversed=!this.reversed,this},reverseOnce:function(){return this.onComplete.addOnce(this.reverse,this),this.reverse()},setFrame:function(t,e){var i;if(void 0===e&&(e=!1),"string"==typeof t)for(s=0;s<this._frames.length;s++)this._frameData.getFrame(this._frames[s]).name===t&&(i=s);else if("number"==typeof t)if(e)i=t;else for(var s=0;s<this._frames.length;s++)this._frames[s]===t&&(i=s);if(i){var n=this.isReversed?-1:1;this._frameIndex=i-n,this._timeNextFrame=this.game.time.time,this.update()}},stop:function(t,e){void 0===t&&(t=!1),void 0===e&&(e=!1),this.isPlaying=!1,this.isFinished=!0,this.paused=!1,t&&(this.currentFrame=this._frameData.getFrame(this._frames[0]),this._parent.setFrame(this.currentFrame)),e&&(this._parent.events.onAnimationComplete$dispatch(this._parent,this),this.onComplete.dispatch(this._parent,this))},onPause:function(){this.isPlaying&&(this._frameDiff=this._timeNextFrame-this.game.time.time)},onResume:function(){this.isPlaying&&(this._timeNextFrame=this.game.time.time+this._frameDiff)},update:function(){if(this.isPaused)return!1;var t=this.game.time.time,e=t-this._timeNextFrame;return!!(this.isPlaying&&e>=0)&&(this._frameSkip=1,this._frameDiff=e,this._timeLastFrame=t,this._frameDiff>this.delay&&(this._frameSkip=Math.floor(this._frameDiff/this.delay),this._frameDiff-=this._frameSkip*this.delay),this._timeNextFrame=t+(this.delay-this._frameDiff),this.isReversed?this._frameIndex-=this._frameSkip:this._frameIndex+=this._frameSkip,!this.isReversed&&this._frameIndex>=this._frames.length||this.isReversed&&this._frameIndex<=-1?this.loop?(this._frameIndex=Math.abs(this._frameIndex)%this._frames.length,this.isReversed&&(this._frameIndex=this._frames.length-1-this._frameIndex),this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&this._parent.setFrame(this.currentFrame),this.loopCount++,this._parent.events.onAnimationLoop$dispatch(this._parent,this),this.onLoop.dispatch(this._parent,this),!this.onUpdate||(this.onUpdate.dispatch(this,this.currentFrame),!!this._frameData)):(this.complete(),!1):this.updateCurrentFrame(!0))},updateCurrentFrame:function(t,e){if(void 0===e&&(e=!1),!this._frameData)return!1;var i=this.currentFrame.index;return this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&(e||i!==this.currentFrame.index)&&this._parent.setFrame(this.currentFrame),!this.onUpdate||!t||(this.onUpdate.dispatch(this,this.currentFrame),!!this._frameData)},next:function(t){void 0===t&&(t=1);var e=this._frameIndex+t;e>=this._frames.length&&(this.loop?e%=this._frames.length:e=this._frames.length-1),e!==this._frameIndex&&(this._frameIndex=e,this.updateCurrentFrame(!0))},previous:function(t){void 0===t&&(t=1);var e=this._frameIndex-t;e<0&&(this.loop?e=this._frames.length+e:e++),e!==this._frameIndex&&(this._frameIndex=e,this.updateCurrentFrame(!0))},updateFrameData:function(t){this._frameData=t,this.currentFrame=this._frameData?this._frameData.getFrame(this._frames[this._frameIndex%this._frames.length]):null},destroy:function(){this._frameData&&(this.game.onPause.remove(this.onPause,this),this.game.onResume.remove(this.onResume,this),this.game=null,this._parent=null,this._frames=null,this._frameData=null,this.currentFrame=null,this.isPlaying=!1,this.onStart.dispose(),this.onLoop.dispose(),this.onComplete.dispose(),this.onUpdate&&this.onUpdate.dispose())},complete:function(){this._frameIndex=this._frames.length-1,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.updateCurrentFrame(!1),this.isPlaying=!1,this.isFinished=!0,this.paused=!1,this._parent.events.onAnimationComplete$dispatch(this._parent,this),this.onComplete.dispatch(this._parent,this),this.killOnComplete&&this._parent.kill()}},e.Animation.prototype.constructor=e.Animation,Object.defineProperty(e.Animation.prototype,"paused",{get:function(){return this.isPaused},set:function(t){this.isPaused=t,t?this._pauseStartTime=this.game.time.time:this.isPlaying&&(this._timeNextFrame=this.game.time.time+this.delay)}}),Object.defineProperty(e.Animation.prototype,"reversed",{get:function(){return this.isReversed},set:function(t){this.isReversed=t}}),Object.defineProperty(e.Animation.prototype,"frameTotal",{get:function(){return this._frames.length}}),Object.defineProperty(e.Animation.prototype,"frame",{get:function(){return null!==this.currentFrame?this.currentFrame.index:this._frameIndex},set:function(t){this.currentFrame=this._frameData.getFrame(this._frames[t]),null!==this.currentFrame&&(this._frameIndex=t,this._parent.setFrame(this.currentFrame),this.onUpdate&&this.onUpdate.dispatch(this,this.currentFrame))}}),Object.defineProperty(e.Animation.prototype,"speed",{get:function(){return 1e3/this.delay},set:function(t){t>0&&(this.delay=1e3/t)}}),Object.defineProperty(e.Animation.prototype,"enableUpdate",{get:function(){return null!==this.onUpdate},set:function(t){t&&null===this.onUpdate?this.onUpdate=new e.Signal:t||null===this.onUpdate||(this.onUpdate.dispose(),this.onUpdate=null)}}),e.Animation.generateFrameNames=function(t,i,s,n,r){void 0===n&&(n="");var o=[],a="";if(i<s)for(h=i;h<=s;h++)a=t+(a="number"==typeof r?e.Utils.pad(h.toString(),r,"0",1):h.toString())+n,o.push(a);else for(var h=i;h>=s;h--)a=t+(a="number"==typeof r?e.Utils.pad(h.toString(),r,"0",1):h.toString())+n,o.push(a);return o},e.Frame=function(t,i,s,n,r,o){this.index=t,this.x=i,this.y=s,this.width=n,this.height=r,0!==this.width&&0!==this.height||console.warn('Phaser.Frame: Frame "'+this.name+'" has a width or height of zero'),this.name=o,this.centerX=Math.floor(n/2),this.centerY=Math.floor(r/2),this.distance=e.Math.distance(0,0,n,r),this.rotated=!1,this.trimmed=!1,this.sourceSizeW=n,this.sourceSizeH=r,this.spriteSourceSizeX=0,this.spriteSourceSizeY=0,this.spriteSourceSizeW=0,this.spriteSourceSizeH=0,this.right=this.x+this.width,this.bottom=this.y+this.height},e.Frame.prototype={resize:function(t,i){this.width=t,this.height=i,this.centerX=Math.floor(t/2),this.centerY=Math.floor(i/2),this.distance=e.Math.distance(0,0,t,i),this.sourceSizeW=t,this.sourceSizeH=i,this.right=this.x+t,this.bottom=this.y+i},setTrim:function(t,e,i,s,n,r,o){this.trimmed=t,t&&(this.sourceSizeW=e,this.sourceSizeH=i,this.centerX=Math.floor(e/2),this.centerY=Math.floor(i/2),this.spriteSourceSizeX=s,this.spriteSourceSizeY=n,this.spriteSourceSizeW=r,this.spriteSourceSizeH=o)},clone:function(){var t=new e.Frame(this.index,this.x,this.y,this.width,this.height,this.name);for(var i in this)this.hasOwnProperty(i)&&(t[i]=this[i]);return t},getRect:function(t){return void 0===t?t=new e.Rectangle(this.x,this.y,this.width,this.height):t.setTo(this.x,this.y,this.width,this.height),t}},e.Frame.prototype.constructor=e.Frame,e.FrameData=function(){this._frames=[],this._frameNames=[]},e.FrameData.prototype={addFrame:function(t){return t.index=this._frames.length,this._frames.push(t),""!==t.name&&(this._frameNames[t.name]=t.index),t},getFrame:function(t){return t>=this._frames.length&&(t=0),this._frames[t]},getFrameByName:function(t){return"number"==typeof this._frameNames[t]?this._frames[this._frameNames[t]]:null},checkFrameName:function(t){return null!=this._frameNames[t]},clone:function(){for(var t=new e.FrameData,i=0;i<this._frames.length;i++)t._frames.push(this._frames[i].clone());for(var s in this._frameNames)this._frameNames.hasOwnProperty(s)&&(t._frameNames[s]=this._frameNames[s]);return t},getFrameRange:function(t,e,i){void 0===i&&(i=[]);for(var s=t;s<=e;s++)i.push(this._frames[s]);return i},getFrames:function(t,e,i){if(void 0===e&&(e=!0),void 0===i&&(i=[]),void 0===t||0===t.length)for(s=0;s<this._frames.length;s++)i.push(this._frames[s]);else for(var s=0;s<t.length;s++)e?i.push(this.getFrame(t[s])):i.push(this.getFrameByName(t[s]));return i},getFrameIndexes:function(t,e,i){if(void 0===e&&(e=!0),void 0===i&&(i=[]),void 0===t||0===t.length)for(s=0;s<this._frames.length;s++)i.push(this._frames[s].index);else for(var s=0;s<t.length;s++)e&&this._frames[t[s]]?i.push(this._frames[t[s]].index):this.getFrameByName(t[s])&&i.push(this.getFrameByName(t[s]).index);return i},destroy:function(){this._frames=null,this._frameNames=null}},e.FrameData.prototype.constructor=e.FrameData,Object.defineProperty(e.FrameData.prototype,"total",{get:function(){return this._frames.length}}),e.AnimationParser={spriteSheet:function(t,i,s,n,r,o,a,h){void 0===r&&(r=-1),void 0===o&&(o=0),void 0===a&&(a=0),void 0===h&&(h=0);var l=i;if("string"==typeof i?l=t.cache.getImage(i):i=l.name,null===l)return null;if(s<=0||n<=0)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' frameWidth (%s) or frameHeight (%s) must be positive",i,s,n),null;var c=l.width,u=l.height;if(0===c||0===u)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' width (%s) or height (%s) is zero",i,c,u),null;if(c<s||u<n)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' width (%s) or height (%s) is less than the given frameWidth (%s) or frameHeight (%s)",i,c,u,s,n),null;var d=Math.floor((c-o)/(s+a)),p=Math.floor((u-o)/(n+a)),f=d*p,g=f,m=f-1,y=0,v=m;if(h>f||h<-f)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' skipFrames = %s is larger than the frame total %s",i,h,f),null;if(r>-1&&(v=(f=r)-1),d<1&&console.warn("Phaser.AnimationParser.spriteSheet: image '%s' has width %d, but it should be at least %d (frameWidth=%s, margin=%s, spacing=%s)",i,c,s+o+a,s,o,a),p<1&&console.warn("Phaser.AnimationParser.spriteSheet: image '%s' has height %d, but it should be at least %d (frameHeight=%s, margin=%s, spacing=%s)",i,u,n+o+a,n,o,a),0===g)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' zero frames were produced",i),null;if(h>0?v=(y=h)+(f=Math.min(f,g-h))-1:h<0&&(y=(v=m+h)-(f=Math.min(f,g+h))+1),y<0)return console.warn("First frame index %s is outside of range [0, %d]",y,m),null;if(v>m)return console.warn("Last frame index %s is outside of range [0, %d]",v,m),null;for(var x=new e.FrameData,b=o,_=o,w=0,T=0;T<g&&!(T>v);T++)T>=y&&x.addFrame(new e.Frame(w++,b,_,s,n,"")),(b+=s+a)+s>c&&(b=o,_+=n+a);return x},JSONData:function(t,i){if(!i.frames)return console.warn("Phaser.AnimationParser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array"),void console.log(i);for(var s,n=new e.FrameData,r=i.frames,o=0;o<r.length;o++)s=n.addFrame(new e.Frame(o,r[o].frame.x,r[o].frame.y,r[o].frame.w,r[o].frame.h,r[o].filename)),r[o].trimmed&&s.setTrim(r[o].trimmed,r[o].sourceSize.w,r[o].sourceSize.h,r[o].spriteSourceSize.x,r[o].spriteSourceSize.y,r[o].spriteSourceSize.w,r[o].spriteSourceSize.h),r[o].rotated&&(s.rotated=!0);return n},JSONDataPyxel:function(t,i){if(["layers","tilewidth","tileheight","tileswide","tileshigh"].forEach(function(t){if(!i[t])return console.warn('Phaser.AnimationParser.JSONDataPyxel: Invalid Pyxel Tilemap JSON given, missing "'+t+'" key.'),void console.log(i)}),1!==i.layers.length)return console.warn("Phaser.AnimationParser.JSONDataPyxel: Too many layers, this parser only supports flat Tilemaps."),void console.log(i);for(var s=new e.FrameData,n=i.tileheight,r=i.tilewidth,o=i.layers[0].tiles,a=0;a<o.length;a++)s.addFrame(new e.Frame(a,o[a].x,o[a].y,r,n,"frame_"+a)).setTrim(!1);return s},JSONDataHash:function(t,i){if(!i.frames)return console.warn("Phaser.AnimationParser.JSONDataHash: Invalid Texture Atlas JSON given, missing 'frames' object"),void console.log(i);var s,n=new e.FrameData,r=i.frames,o=0;for(var a in r)s=n.addFrame(new e.Frame(o,r[a].frame.x,r[a].frame.y,r[a].frame.w,r[a].frame.h,a)),r[a].trimmed&&s.setTrim(r[a].trimmed,r[a].sourceSize.w,r[a].sourceSize.h,r[a].spriteSourceSize.x,r[a].spriteSourceSize.y,r[a].spriteSourceSize.w,r[a].spriteSourceSize.h),r[a].rotated&&(s.rotated=!0),o++;return n},XMLData:function(t,i){if(i.getElementsByTagName("TextureAtlas")){for(var s,n,r,o,a,h,l,c,u,d,p,f=new e.FrameData,g=i.getElementsByTagName("SubTexture"),m=0;m<g.length;m++)n=(r=g[m].attributes).name.value,o=parseInt(r.x.value,10),a=parseInt(r.y.value,10),h=parseInt(r.width.value,10),l=parseInt(r.height.value,10),c=null,u=null,r.frameX&&(c=Math.abs(parseInt(r.frameX.value,10)),u=Math.abs(parseInt(r.frameY.value,10)),d=parseInt(r.frameWidth.value,10),p=parseInt(r.frameHeight.value,10)),s=f.addFrame(new e.Frame(m,o,a,h,l,n)),null===c&&null===u||s.setTrim(!0,h,l,c,u,d,p);return f}console.warn("Phaser.AnimationParser.XMLData: Invalid Texture Atlas XML given, missing <TextureAtlas> tag")}},e.Cache=function(t){this.game=t,this.autoResolveURL=!1,this._cache={canvas:{},image:{},texture:{},sound:{},video:{},text:{},json:{},xml:{},physics:{},tilemap:{},binary:{},bitmapData:{},bitmapFont:{},shader:{},renderTexture:{},compressedTexture:{}},this._urlMap={},this._urlResolver=new Image,this._urlTemp=null,this.onSoundUnlock=new e.Signal,this._cacheMap=[],this._cacheMap[e.Cache.CANVAS]=this._cache.canvas,this._cacheMap[e.Cache.IMAGE]=this._cache.image,this._cacheMap[e.Cache.TEXTURE]=this._cache.texture,this._cacheMap[e.Cache.SOUND]=this._cache.sound,this._cacheMap[e.Cache.TEXT]=this._cache.text,this._cacheMap[e.Cache.PHYSICS]=this._cache.physics,this._cacheMap[e.Cache.TILEMAP]=this._cache.tilemap,this._cacheMap[e.Cache.BINARY]=this._cache.binary,this._cacheMap[e.Cache.BITMAPDATA]=this._cache.bitmapData,this._cacheMap[e.Cache.BITMAPFONT]=this._cache.bitmapFont,this._cacheMap[e.Cache.JSON]=this._cache.json,this._cacheMap[e.Cache.XML]=this._cache.xml,this._cacheMap[e.Cache.VIDEO]=this._cache.video,this._cacheMap[e.Cache.SHADER]=this._cache.shader,this._cacheMap[e.Cache.RENDER_TEXTURE]=this._cache.renderTexture,this._pendingCount=0,this.onReady=new e.Signal,this._addImages()},e.Cache.CANVAS=1,e.Cache.IMAGE=2,e.Cache.TEXTURE=3,e.Cache.SOUND=4,e.Cache.TEXT=5,e.Cache.PHYSICS=6,e.Cache.TILEMAP=7,e.Cache.BINARY=8,e.Cache.BITMAPDATA=9,e.Cache.BITMAPFONT=10,e.Cache.JSON=11,e.Cache.XML=12,e.Cache.VIDEO=13,e.Cache.SHADER=14,e.Cache.RENDER_TEXTURE=15,e.Cache.DEFAULT=null,e.Cache.DEFAULT_KEY="__default",e.Cache.DEFAULT_SRC="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==",e.Cache.MISSING=null,e.Cache.MISSING_KEY="__missing",e.Cache.MISSING_SRC="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==",e.Cache.READY_TIMEOUT=1e3,e.Cache.prototype={addCompressedTextureMetaData:function(t,i,s,n){this.checkImageKey(t)&&this.removeImage(t);var r=s in e.LoaderParser?e.LoaderParser[s](n):n,o={key:t,url:i,data:r,base:new PIXI.BaseTexture(r,null,this.game.resolution),frame:new e.Frame(0,0,0,r.width,r.height,t),frameData:new e.FrameData,fileFormat:s};return o.frameData.addFrame(new e.Frame(0,0,0,r.width,r.height,i)),this._cache.image[t]=o,this._resolveURL(i,o),o},addCanvas:function(t,e,i){void 0===i&&(i=e.getContext("2d")),this._cache.canvas[t]={canvas:e,context:i}},addImage:function(t,i,s){this.checkImageKey(t)&&this.removeImage(t),!1===s.complete&&console.warn('Phaser.Cache.addImage: Image "%s" is not complete',t);var n={key:t,url:i,data:s,base:new PIXI.BaseTexture(s,null,this.game.resolution),frame:new e.Frame(0,0,0,s.width,s.height,t),frameData:new e.FrameData};return n.frameData.addFrame(new e.Frame(0,0,0,s.width,s.height,i)),this._cache.image[t]=n,this._resolveURL(i,n),"__default"===t?e.Cache.DEFAULT=new PIXI.Texture(n.base):"__missing"===t&&(e.Cache.MISSING=new PIXI.Texture(n.base)),n},addImageAsync:function(t,e,i){var s=this,n=new Image;n.onload=function(){i.call(this,s.addImage(t,null,n)),s._removePending(),n.onload=null},this._addPending(),n.src=e},addDefaultImage:function(){this.addImageAsync(e.Cache.DEFAULT_KEY,e.Cache.DEFAULT_SRC,function(t){t.base.skipRender=!0,e.Cache.DEFAULT=new PIXI.Texture(t.base)})},addMissingImage:function(){this.addImageAsync(e.Cache.MISSING_KEY,e.Cache.MISSING_SRC,function(t){e.Cache.MISSING=new PIXI.Texture(t.base)})},addSound:function(t,e,i,s,n){void 0===s&&(s=!0,n=!1),void 0===n&&(s=!1,n=!0);var r=!1;n&&(r=!0),this._cache.sound[t]={url:e,data:i,isDecoding:!1,decoded:r,webAudio:s,audioTag:n,locked:this.game.sound.touchLocked},this._resolveURL(e,this._cache.sound[t])},addText:function(t,e,i){this._cache.text[t]={url:e,data:i},this._resolveURL(e,this._cache.text[t])},addPhysicsData:function(t,e,i,s){this._cache.physics[t]={url:e,data:i,format:s},this._resolveURL(e,this._cache.physics[t])},addTilemap:function(t,e,i,s){this._cache.tilemap[t]={url:e,data:i,format:s},this._resolveURL(e,this._cache.tilemap[t])},addBinary:function(t,e){this._cache.binary[t]=e},addBitmapData:function(t,i,s){return i.key=t,void 0===s&&(s=new e.FrameData).addFrame(i.textureFrame),this._cache.bitmapData[t]={data:i,frameData:s},i},addBitmapFont:function(t,i,s,n,r,o,a){var h={url:i,data:s,font:null,base:new PIXI.BaseTexture(s,null,this.game.resolution)};void 0===o&&(o=0),void 0===a&&(a=0),h.font="json"===r?e.LoaderParser.jsonBitmapFont(n,h.base,o,a,!1,this.game.resolution):e.LoaderParser.xmlBitmapFont(n,h.base,o,a,!1,this.game.resolution),this._cache.bitmapFont[t]=h,this._resolveURL(i,h)},addBitmapFontFromAtlas:function(t,i,s,n,r,o,a){var h=this.getFrameByName(i,s);if(h){var l={font:null,base:this.getBaseTexture(i),frame:h};void 0===o&&(o=0),void 0===a&&(a=0);var c;"json"===r?(c=this.getJSON(n),l.font=e.LoaderParser.jsonBitmapFont(c,l.base,o,a,h,this.game.resolution)):(c=this.getXML(n),l.font=e.LoaderParser.xmlBitmapFont(c,l.base,o,a,h,this.game.resolution)),this._cache.bitmapFont[t]=l}},addJSON:function(t,e,i){this._cache.json[t]={url:e,data:i},this._resolveURL(e,this._cache.json[t])},addXML:function(t,e,i){this._cache.xml[t]={url:e,data:i},this._resolveURL(e,this._cache.xml[t])},addVideo:function(t,e,i,s){this._cache.video[t]={url:e,data:i,isBlob:s,locked:!0},this._resolveURL(e,this._cache.video[t])},addShader:function(t,e,i){this._cache.shader[t]={url:e,data:i},this._resolveURL(e,this._cache.shader[t])},addRenderTexture:function(t,i){this._cache.renderTexture[t]={texture:i,frame:new e.Frame(0,0,0,i.width,i.height,"","")}},addSpriteSheet:function(t,i,s,n,r,o,a,h,l){void 0===o&&(o=-1),void 0===a&&(a=0),void 0===h&&(h=0);var c={key:t,url:i,data:s,frameWidth:n,frameHeight:r,margin:a,spacing:h,base:new PIXI.BaseTexture(s,null,this.game.resolution),frameData:e.AnimationParser.spriteSheet(this.game,s,n,r,o,a,h,l)};this._cache.image[t]=c,this._resolveURL(i,c)},addTextureAtlas:function(t,i,s,n,r){var o={key:t,url:i,data:s,base:new PIXI.BaseTexture(s,null,this.game.resolution)};r===e.Loader.TEXTURE_ATLAS_XML_STARLING?o.frameData=e.AnimationParser.XMLData(this.game,n,t):r===e.Loader.TEXTURE_ATLAS_JSON_PYXEL?o.frameData=e.AnimationParser.JSONDataPyxel(this.game,n,t):Array.isArray(n.frames)?o.frameData=e.AnimationParser.JSONData(this.game,n,t):o.frameData=e.AnimationParser.JSONDataHash(this.game,n,t),this._cache.image[t]=o,this._resolveURL(i,o)},reloadSound:function(t){var e=this,i=this.getSound(t);i&&(i.data.src=i.url,i.data.addEventListener("canplaythrough",function(){return e.reloadSoundComplete(t)},!1),i.data.load())},reloadSoundComplete:function(t){var e=this.getSound(t);e&&(e.locked=!1,this.onSoundUnlock.dispatch(t))},updateSound:function(t,e,i){var s=this.getSound(t);s&&(s[e]=i)},decodedSound:function(t,e){var i=this.getSound(t);i.data=e,i.decoded=!0,i.isDecoding=!1},isSoundDecoded:function(t){var i=this.getItem(t,e.Cache.SOUND,"isSoundDecoded");if(i)return i.decoded},isSoundReady:function(t){var i=this.getItem(t,e.Cache.SOUND,"isSoundDecoded");if(i)return i.decoded&&!this.game.sound.touchLocked},checkKey:function(t,e){return!!this._cacheMap[t][e]},checkURL:function(t){return!!this._urlMap[this._resolveURL(t)]},checkCanvasKey:function(t){return this.checkKey(e.Cache.CANVAS,t)},checkImageKey:function(t){return this.checkKey(e.Cache.IMAGE,t)},checkTextureKey:function(t){return this.checkKey(e.Cache.TEXTURE,t)},checkSoundKey:function(t){return this.checkKey(e.Cache.SOUND,t)},checkTextKey:function(t){return this.checkKey(e.Cache.TEXT,t)},checkPhysicsKey:function(t){return this.checkKey(e.Cache.PHYSICS,t)},checkTilemapKey:function(t){return this.checkKey(e.Cache.TILEMAP,t)},checkBinaryKey:function(t){return this.checkKey(e.Cache.BINARY,t)},checkBitmapDataKey:function(t){return this.checkKey(e.Cache.BITMAPDATA,t)},checkBitmapFontKey:function(t){return this.checkKey(e.Cache.BITMAPFONT,t)},checkJSONKey:function(t){return this.checkKey(e.Cache.JSON,t)},checkXMLKey:function(t){return this.checkKey(e.Cache.XML,t)},checkVideoKey:function(t){return this.checkKey(e.Cache.VIDEO,t)},checkShaderKey:function(t){return this.checkKey(e.Cache.SHADER,t)},checkRenderTextureKey:function(t){return this.checkKey(e.Cache.RENDER_TEXTURE,t)},getItem:function(t,e,i,s){return this.checkKey(e,t)?void 0===s?this._cacheMap[e][t]:this._cacheMap[e][t][s]:(i&&console.warn("Phaser.Cache."+i+': Key "'+t+'" not found in Cache.'),null)},getCanvas:function(t){return this.getItem(t,e.Cache.CANVAS,"getCanvas","canvas")},getImage:function(t,i){void 0!==t&&null!==t||(t="__default"),void 0===i&&(i=!1);var s=this.getItem(t,e.Cache.IMAGE,"getImage");return null===s&&(s=this.getItem("__missing",e.Cache.IMAGE,"getImage")),i?s:s.data},getTextureFrame:function(t){return this.getItem(t,e.Cache.TEXTURE,"getTextureFrame","frame")},getSound:function(t){return this.getItem(t,e.Cache.SOUND,"getSound")},getSoundData:function(t){return this.getItem(t,e.Cache.SOUND,"getSoundData","data")},getText:function(t){return this.getItem(t,e.Cache.TEXT,"getText","data")},getPhysicsData:function(t,i,s){var n=this.getItem(t,e.Cache.PHYSICS,"getPhysicsData","data");if(null===n||void 0===i||null===i)return n;if(n[i]){var r=n[i];if(!r||!s)return r;for(var o in r)if((o=r[o]).fixtureKey===s)return o;console.warn('Phaser.Cache.getPhysicsData: Could not find given fixtureKey: "'+s+" in "+t+'"')}else console.warn('Phaser.Cache.getPhysicsData: Invalid key/object: "'+t+" / "+i+'"');return null},getTilemapData:function(t){return this.getItem(t,e.Cache.TILEMAP,"getTilemapData")},getBinary:function(t){return this.getItem(t,e.Cache.BINARY,"getBinary")},getBitmapData:function(t){return this.getItem(t,e.Cache.BITMAPDATA,"getBitmapData","data")},getBitmapFont:function(t){return this.getItem(t,e.Cache.BITMAPFONT,"getBitmapFont")},getJSON:function(t,i){var s=this.getItem(t,e.Cache.JSON,"getJSON","data");return s?i?e.Utils.extend(!0,Array.isArray(s)?[]:{},s):s:null},getXML:function(t){return this.getItem(t,e.Cache.XML,"getXML","data")},getVideo:function(t){return this.getItem(t,e.Cache.VIDEO,"getVideo")},getShader:function(t){return this.getItem(t,e.Cache.SHADER,"getShader","data")},getRenderTexture:function(t){return this.getItem(t,e.Cache.RENDER_TEXTURE,"getRenderTexture")},getBaseTexture:function(t,i){return void 0===i&&(i=e.Cache.IMAGE),this.getItem(t,i,"getBaseTexture","base")},getFrame:function(t,i){return void 0===i&&(i=e.Cache.IMAGE),this.getItem(t,i,"getFrame","frame")},getFrameCount:function(t,e){var i=this.getFrameData(t,e);return i?i.total:0},getFrameData:function(t,i){return void 0===i&&(i=e.Cache.IMAGE),this.getItem(t,i,"getFrameData","frameData")},hasFrameData:function(t,i){return void 0===i&&(i=e.Cache.IMAGE),null!==this.getItem(t,i,"","frameData")},updateFrameData:function(t,i,s){void 0===s&&(s=e.Cache.IMAGE),this._cacheMap[s][t]&&(this._cacheMap[s][t].frameData=i)},getFrameByIndex:function(t,e,i){var s=this.getFrameData(t,i);return s?s.getFrame(e):null},getFrameByName:function(t,e,i){var s=this.getFrameData(t,i);return s?s.getFrameByName(e):null},getURL:function(t){return(t=this._resolveURL(t))?this._urlMap[t]:(console.warn('Phaser.Cache.getUrl: Invalid url: "'+t+'" or Cache.autoResolveURL was false'),null)},getKeys:function(t){void 0===t&&(t=e.Cache.IMAGE);var i=[];if(this._cacheMap[t])for(var s in this._cacheMap[t])"__default"!==s&&"__missing"!==s&&i.push(s);return i},removeCanvas:function(t){delete this._cache.canvas[t]},removeImage:function(t,e){void 0===e&&(e=!0);var i=this.getImage(t,!0);e&&i.base&&i.base.destroy(),delete this._cache.image[t]},removeSound:function(t){delete this._cache.sound[t]},removeText:function(t){delete this._cache.text[t]},removePhysics:function(t){delete this._cache.physics[t]},removeTilemap:function(t){delete this._cache.tilemap[t]},removeBinary:function(t){delete this._cache.binary[t]},removeBitmapData:function(t){delete this._cache.bitmapData[t]},removeBitmapFont:function(t){delete this._cache.bitmapFont[t]},removeJSON:function(t){delete this._cache.json[t]},removeXML:function(t){delete this._cache.xml[t]},removeVideo:function(t){delete this._cache.video[t]},removeShader:function(t){delete this._cache.shader[t]},removeRenderTexture:function(t){delete this._cache.renderTexture[t]},removeSpriteSheet:function(t){delete this._cache.spriteSheet[t]},removeTextureAtlas:function(t){delete this._cache.image[t]},clearGLTextures:function(){for(var t in this._cache.image)this._cache.image[t].base._glTextures=[]},_resolveURL:function(t,e){return this.autoResolveURL?(this._urlResolver.src=this.game.load.baseURL+t,this._urlTemp=this._urlResolver.src,this._urlResolver.src="",e&&(this._urlMap[this._urlTemp]=e),this._urlTemp):null},destroy:function(){for(var t=0;t<this._cacheMap.length;t++){var e=this._cacheMap[t];for(var i in e)"__default"!==i&&"__missing"!==i&&(this.destroyItem(e[i]),delete e[i])}this._urlMap=null,this._urlResolver=null,this._urlTemp=null},destroyItem:function(t){t.destroy?t.destroy():(t.base&&t.base.destroy&&t.base.destroy(),t.data&&t.data.destroy&&t.data.destroy(),t.frameData&&t.frameData.destroy&&t.frameData.destroy(),t.texture&&t.texture.destroy&&t.texture.destroy(!0))},_addImages:function(){this._pendingCount=0,this.addDefaultImage(),this.addMissingImage();var t=this,i=e.Cache.READY_TIMEOUT;e.Cache.READY_TIMEOUT>0?setTimeout(function(){t.isReady||(console.warn("Phaser.Cache: Still waiting for images after %s ms.",i),t._ready())},e.Cache.READY_TIMEOUT):this._ready()},_addPending:function(){this._pendingCount+=1},_removePending:function(){this._pendingCount-=1,this._checkReady()},_checkReady:function(){this.isReady&&this._ready()},_ready:function(){this._pendingCount=0,this.onReady.dispatch(this)}},e.Cache.prototype.constructor=e.Cache,Object.defineProperty(e.Cache.prototype,"isReady",{get:function(){return this._pendingCount<=0}}),e.Loader=function(t){this.game=t,this.cache=t.cache,this.resetLocked=!1,this.isLoading=!1,this.hasLoaded=!1,this.preloadSprite=null,this.crossOrigin=!1,this.baseURL="",this.path="",this.headers={requestedWith:!1,json:"application/json",xml:"application/xml"},this.onLoadStart=new e.Signal,this.onBeforeLoadComplete=new e.Signal,this.onLoadComplete=new e.Signal,this.onPackComplete=new e.Signal,this.onFileStart=new e.Signal,this.onFileComplete=new e.Signal,this.onFileError=new e.Signal,this.enableParallel=!0,this.maxParallelDownloads=4,this._withSyncPointDepth=0,this._fileList=[],this._flightQueue=[],this._processingHead=0,this._fileLoadStarted=!1,this._totalPackCount=0,this._totalFileCount=0,this._loadedPackCount=0,this._loadedFileCount=0},e.Loader.TEXTURE_ATLAS_JSON_ARRAY=0,e.Loader.TEXTURE_ATLAS_JSON_HASH=1,e.Loader.TEXTURE_ATLAS_XML_STARLING=2,e.Loader.PHYSICS_LIME_CORONA_JSON=3,e.Loader.PHYSICS_PHASER_JSON=4,e.Loader.TEXTURE_ATLAS_JSON_PYXEL=5,e.Loader.prototype={setPreloadSprite:function(t,i){i=i||0,this.preloadSprite={sprite:t,direction:i,width:t.width,height:t.height,rect:null},this.preloadSprite.rect=0===i?new e.Rectangle(0,0,1,t.height):new e.Rectangle(0,0,t.width,1),t.crop(this.preloadSprite.rect),t.visible=!0},resize:function(){this.preloadSprite&&this.preloadSprite.height!==this.preloadSprite.sprite.height&&(this.preloadSprite.rect.height=this.preloadSprite.sprite.height)},checkKeyExists:function(t,e){return this.getAssetIndex(t,e)>-1},getAssetIndex:function(t,e){for(var i=-1,s=0;s<this._fileList.length;s++){var n=this._fileList[s];if(n.type===t&&n.key===e&&(i=s,!n.loaded&&!n.loading))break}return i},getAsset:function(t,e){var i=this.getAssetIndex(t,e);return i>-1&&{index:i,file:this._fileList[i]}},reset:function(t,e){void 0===e&&(e=!1),this.resetLocked||(t&&(this.preloadSprite=null),this.isLoading=!1,this._processingHead=0,this._fileList.length=0,this._flightQueue.length=0,this._fileLoadStarted=!1,this._totalFileCount=0,this._totalPackCount=0,this._loadedPackCount=0,this._loadedFileCount=0,e&&(this.onLoadStart.removeAll(),this.onLoadComplete.removeAll(),this.onPackComplete.removeAll(),this.onFileStart.removeAll(),this.onFileComplete.removeAll(),this.onFileError.removeAll()))},addToFileList:function(t,e,i,s,n,r){if(void 0===n&&(n=!1),void 0===e||""===e)return console.warn("Phaser.Loader: Invalid or no key given of type "+t),this;if(void 0===i||null===i){if(!r)return console.warn("Phaser.Loader: No URL given for file type: "+t+" key: "+e),this;i=e+r}var o={type:t,key:e,path:this.path,url:i,syncPoint:this._withSyncPointDepth>0,data:null,loading:!1,loaded:!1,error:!1};if(s)for(var a in s)o[a]=s[a];var h=this.getAssetIndex(t,e);if(n&&h>-1){var l=this._fileList[h];l.loading||l.loaded?(this._fileList.push(o),this._totalFileCount++):this._fileList[h]=o}else-1===h&&(this._fileList.push(o),this._totalFileCount++);return this},replaceInFileList:function(t,e,i,s){return this.addToFileList(t,e,i,s,!0)},pack:function(t,e,i,s){if(void 0===e&&(e=null),void 0===i&&(i=null),void 0===s&&(s=null),!e&&!i)return console.warn("Phaser.Loader.pack - Both url and data are null. One must be set."),this;var n={type:"packfile",key:t,url:e,path:this.path,syncPoint:!0,data:null,loading:!1,loaded:!1,error:!1,callbackContext:s};i&&("string"==typeof i&&(i=JSON.parse(i)),n.data=i||{},n.loaded=!0);for(var r=0;r<this._fileList.length+1;r++){var o=this._fileList[r];if(!o||!o.loaded&&!o.loading&&"packfile"!==o.type){this._fileList.splice(r,0,n),this._totalPackCount++;break}}return this},image:function(t,e,i){return"object"==typeof e?this.texture(t,e,i):this.addToFileList("image",t,e,void 0,i,".png")},imageFromBitmapData:function(t,e,i){return this.image(t,e.canvas.toDataURL("image/png"),i)},imageFromGrid:function(t,e,i,s,n,r){return this.imageFromBitmapData(t,this.game.create.grid(t,e,i,s,n,r,!1))},imageFromTexture:function(t,e,i,s,n){return this.imageFromBitmapData(t,this.game.create.texture(t,e,i,s,n,!1))},texture:function(t,i,s){if(this.game.renderType===e.WEBGL){var n,r=this.game.renderer.extensions.compression;for(n in i)if(n.toUpperCase()in r)return this.addToFileList("texture",t,i[n],void 0,s,".pvr")}return i.truecolor&&this.addToFileList("image",t,i.truecolor,void 0,s,".png"),this},images:function(t,e){if(Array.isArray(e))for(i=0;i<t.length;i++)this.image(t[i],e[i]);else for(var i=0;i<t.length;i++)this.image(t[i]);return this},text:function(t,e,i){return this.addToFileList("text",t,e,void 0,i,".txt")},json:function(t,e,i){return this.addToFileList("json",t,e,void 0,i,".json")},shader:function(t,e,i){return this.addToFileList("shader",t,e,void 0,i,".frag")},xml:function(t,e,i){return this.addToFileList("xml",t,e,void 0,i,".xml")},script:function(t,e,i,s){return void 0===i&&(i=!1),!1!==i&&void 0===s&&(s=this),this.addToFileList("script",t,e,{syncPoint:!0,callback:i,callbackContext:s},!1,".js")},binary:function(t,e,i,s){return void 0===i&&(i=!1),!1!==i&&void 0===s&&(s=i),this.addToFileList("binary",t,e,{callback:i,callbackContext:s},!1,".bin")},spritesheet:function(t,e,i,s,n,r,o,a){return void 0===n&&(n=-1),void 0===r&&(r=0),void 0===o&&(o=0),void 0===a&&(a=0),this.addToFileList("spritesheet",t,e,{frameWidth:i,frameHeight:s,frameMax:n,margin:r,spacing:o,skipFrames:a},!1,".png")},audio:function(t,e,i){return this.game.sound.noAudio?this:(void 0===i&&(i=!0),"string"==typeof e&&(e=[e]),this.addToFileList("audio",t,e,{buffer:null,autoDecode:i}))},audioSprite:function(t,e,i,s,n){return this.game.sound.noAudio?this:(void 0===i&&(i=null),void 0===s&&(s=null),void 0===n&&(n=!0),this.audio(t,e,n),i?this.json(t+"-audioatlas",i):s?("string"==typeof s&&(s=JSON.parse(s)),this.cache.addJSON(t+"-audioatlas","",s)):console.warn("Phaser.Loader.audiosprite - You must specify either a jsonURL or provide a jsonData object"),this)},audiosprite:function(t,e,i,s,n){return this.audioSprite(t,e,i,s,n)},video:function(t,e,i,s){return void 0===i&&(i=this.game.device.firefox?"loadeddata":"canplaythrough"),void 0===s&&(s=!1),"string"==typeof e&&(e=[e]),this.addToFileList("video",t,e,{buffer:null,asBlob:s,loadEvent:i})},tilemap:function(t,i,s,n){if(void 0===i&&(i=null),void 0===s&&(s=null),void 0===n&&(n=e.Tilemap.CSV),i||s||(i=n===e.Tilemap.CSV?t+".csv":t+".json"),s){switch(n){case e.Tilemap.CSV:break;case e.Tilemap.TILED_JSON:"string"==typeof s&&(s=JSON.parse(s))}this.cache.addTilemap(t,null,s,n)}else this.addToFileList("tilemap",t,i,{format:n});return this},tilemapCSV:function(t,i,s){return this.tilemap(t,i,s,e.Tilemap.CSV)},tilemapTiledJSON:function(t,i,s){return this.tilemap(t,i,s,e.Tilemap.TILED_JSON)},physics:function(t,i,s,n){return void 0===i&&(i=null),void 0===s&&(s=null),void 0===n&&(n=e.Physics.LIME_CORONA_JSON),i||s||(i=t+".json"),s?("string"==typeof s&&(s=JSON.parse(s)),this.cache.addPhysicsData(t,null,s,n)):this.addToFileList("physics",t,i,{format:n}),this},bitmapFont:function(t,e,i,s,n,r){if(void 0!==e&&null!==e||(e=t+".png"),void 0===i&&(i=null),void 0===s&&(s=null),null===i&&null===s&&(i=t+".xml"),void 0===n&&(n=0),void 0===r&&(r=0),i)this.addToFileList("bitmapfont",t,e,{atlasURL:i,xSpacing:n,ySpacing:r});else if("string"==typeof s){var o,a;try{o=JSON.parse(s)}catch(t){a=this.parseXml(s)}if(!a&&!o)throw new Error("Phaser.Loader. Invalid Bitmap Font atlas given");this.addToFileList("bitmapfont",t,e,{atlasURL:null,atlasData:o||a,atlasType:o?"json":"xml",xSpacing:n,ySpacing:r})}return this},atlasJSONArray:function(t,i,s,n){return this.atlas(t,i,s,n,e.Loader.TEXTURE_ATLAS_JSON_ARRAY)},atlasJSONHash:function(t,i,s,n){return this.atlas(t,i,s,n,e.Loader.TEXTURE_ATLAS_JSON_HASH)},atlasXML:function(t,i,s,n){return void 0===s&&(s=null),void 0===n&&(n=null),s||n||(s=t+".xml"),this.atlas(t,i,s,n,e.Loader.TEXTURE_ATLAS_XML_STARLING)},atlas:function(t,i,s,n,r){if(void 0!==i&&null!==i||(i=t+".png"),void 0===s&&(s=null),void 0===n&&(n=null),void 0===r&&(r=e.Loader.TEXTURE_ATLAS_JSON_ARRAY),s||n||(s=r===e.Loader.TEXTURE_ATLAS_XML_STARLING?t+".xml":t+".json"),s)this.addToFileList("textureatlas",t,i,{atlasURL:s,format:r});else{switch(r){case e.Loader.TEXTURE_ATLAS_JSON_ARRAY:"string"==typeof n&&(n=JSON.parse(n));break;case e.Loader.TEXTURE_ATLAS_XML_STARLING:if("string"==typeof n){var o=this.parseXml(n);if(!o)throw new Error("Phaser.Loader. Invalid Texture Atlas XML given");n=o}}this.addToFileList("textureatlas",t,i,{atlasURL:null,atlasData:n,format:r})}return this},withSyncPoint:function(t,e){this._withSyncPointDepth++;try{t.call(e||this,this)}finally{this._withSyncPointDepth--}return this},addSyncPoint:function(t,e){var i=this.getAsset(t,e);return i&&(i.file.syncPoint=!0),this},removeFile:function(t,e){var i=this.getAsset(t,e);i&&(i.loaded||i.loading||this._fileList.splice(i.index,1))},removeAll:function(){this._fileList.length=0,this._flightQueue.length=0},start:function(){this.isLoading||(this.hasLoaded=!1,this.isLoading=!0,this.updateProgress(),this.processLoadQueue())},processLoadQueue:function(){if(!this.isLoading)return console.warn("Phaser.Loader - active loading canceled / reset"),void this.finishedLoading(!0);for(i=0;i<this._flightQueue.length;i++)((s=this._flightQueue[i]).loaded||s.error)&&(this._flightQueue.splice(i,1),i--,s.loading=!1,s.requestUrl=null,s.requestObject=null,s.error&&this.onFileError.dispatch(s.key,s),"packfile"!==s.type?(this._loadedFileCount++,this.onFileComplete.dispatch(this.progress,s.key,!s.error,this._loadedFileCount,this._totalFileCount)):"packfile"===s.type&&s.error&&(this._loadedPackCount++,this.onPackComplete.dispatch(s.key,!s.error,this._loadedPackCount,this._totalPackCount)));for(var t=!1,e=this.enableParallel?Math.max(1,this.maxParallelDownloads):1,i=this._processingHead;i<this._fileList.length;i++){var s=this._fileList[i];if("packfile"===s.type&&!s.error&&s.loaded&&i===this._processingHead&&(this.processPack(s),this._loadedPackCount++,this.onPackComplete.dispatch(s.key,!s.error,this._loadedPackCount,this._totalPackCount)),s.loaded||s.error?i===this._processingHead&&(this._processingHead=i+1):!s.loading&&this._flightQueue.length<e&&("packfile"!==s.type||s.data?t||(this._fileLoadStarted||(this._fileLoadStarted=!0,this.onLoadStart.dispatch()),this._flightQueue.push(s),s.loading=!0,this.onFileStart.dispatch(this.progress,s.key,s.url),this.loadFile(s)):(this._flightQueue.push(s),s.loading=!0,this.loadFile(s))),!s.loaded&&s.syncPoint&&(t=!0),this._flightQueue.length>=e||t&&this._loadedPackCount===this._totalPackCount)break}if(this.updateProgress(),this._processingHead>=this._fileList.length)this.finishedLoading();else if(!this._flightQueue.length){console.warn("Phaser.Loader - aborting: processing queue empty, loading may have stalled");var n=this;setTimeout(function(){n.finishedLoading(!0)},2e3)}},finishedLoading:function(t){this.hasLoaded||(this.hasLoaded=!0,this.isLoading=!1,t||this._fileLoadStarted||(this._fileLoadStarted=!0,this.onLoadStart.dispatch()),this.game.state.loadUpdate(),this.onBeforeLoadComplete.dispatch(),this.reset(),this.onLoadComplete.dispatch(),this.game.state&&this.game.state.loadComplete())},asyncComplete:function(t,e){void 0===e&&(e=""),t.loaded=!0,t.error=!!e,e&&(t.errorMessage=e,console.warn("Phaser.Loader - "+t.type+"["+t.key+"]: "+e)),this.processLoadQueue()},processPack:function(t){var i=t.data[t.key];if(i)for(var s=0;s<i.length;s++){var n=i[s];switch(n.type){case"image":this.image(n.key,n.url,n.overwrite);break;case"text":this.text(n.key,n.url,n.overwrite);break;case"json":this.json(n.key,n.url,n.overwrite);break;case"xml":this.xml(n.key,n.url,n.overwrite);break;case"script":this.script(n.key,n.url,n.callback,t.callbackContext||this);break;case"binary":this.binary(n.key,n.url,n.callback,t.callbackContext||this);break;case"spritesheet":this.spritesheet(n.key,n.url,n.frameWidth,n.frameHeight,n.frameMax,n.margin,n.spacing,n.skipFrames);break;case"video":this.video(n.key,n.urls);break;case"audio":this.audio(n.key,n.urls,n.autoDecode);break;case"audiosprite":this.audiosprite(n.key,n.urls,n.jsonURL,n.jsonData,n.autoDecode);break;case"tilemap":this.tilemap(n.key,n.url,n.data,e.Tilemap[n.format]);break;case"physics":this.physics(n.key,n.url,n.data,e.Loader[n.format]);break;case"bitmapFont":this.bitmapFont(n.key,n.textureURL,n.atlasURL,n.atlasData,n.xSpacing,n.ySpacing);break;case"atlasJSONArray":this.atlasJSONArray(n.key,n.textureURL,n.atlasURL,n.atlasData);break;case"atlasJSONHash":this.atlasJSONHash(n.key,n.textureURL,n.atlasURL,n.atlasData);break;case"atlasXML":this.atlasXML(n.key,n.textureURL,n.atlasURL,n.atlasData);break;case"atlas":this.atlas(n.key,n.textureURL,n.atlasURL,n.atlasData,e.Loader[n.format]);break;case"shader":this.shader(n.key,n.url,n.overwrite)}}else console.warn("Phaser.Loader - "+t.key+": pack has data, but not for pack key")},transformUrl:function(t,e){return!!t&&(t.match(/^(?:blob:|data:|http:\/\/|https:\/\/|\/\/)/)?t:this.baseURL+e.path+t)},loadFile:function(t){switch(t.type){case"packfile":this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.fileComplete);break;case"image":case"spritesheet":case"textureatlas":case"bitmapfont":this.loadImageTag(t);break;case"audio":t.url=this.getAudioURL(t.url),t.url?this.game.sound.usingWebAudio?this.xhrLoad(t,this.transformUrl(t.url,t),"arraybuffer",this.fileComplete):this.game.sound.usingAudioTag&&this.loadAudioTag(t):this.fileError(t,null,"No supported audio URL specified or device does not have audio playback support");break;case"video":t.url=this.getVideoURL(t.url),t.url?t.asBlob?this.xhrLoad(t,this.transformUrl(t.url,t),"blob",this.fileComplete):this.loadVideoTag(t):this.fileError(t,null,"No supported video URL specified or device does not have video playback support");break;case"json":this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.jsonLoadComplete);break;case"xml":this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.xmlLoadComplete);break;case"tilemap":t.format===e.Tilemap.TILED_JSON?this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.jsonLoadComplete):t.format===e.Tilemap.CSV?this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.csvLoadComplete):this.asyncComplete(t,"invalid Tilemap format: "+t.format);break;case"text":case"script":case"shader":case"physics":this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.fileComplete);break;case"texture":"truecolor"===t.key.split("_").pop()?this.loadImageTag(t):this.xhrLoad(t,this.transformUrl(t.url,t),"arraybuffer",this.fileComplete);break;case"binary":this.xhrLoad(t,this.transformUrl(t.url,t),"arraybuffer",this.fileComplete)}},loadImageTag:function(t){var e=this;t.data=new Image,t.data.name=t.key,this.crossOrigin&&(t.data.crossOrigin=this.crossOrigin),t.data.onload=function(){t.data.onload&&(t.data.onload=null,t.data.onerror=null,e.fileComplete(t))},t.data.onerror=function(){t.data.onload&&(t.data.onload=null,t.data.onerror=null,e.fileError(t))},t.data.src=this.transformUrl(t.url,t),!this.game.device.firefox&&t.data.complete&&t.data.width&&t.data.height&&(t.data.onload=null,t.data.onerror=null,this.fileComplete(t))},loadVideoTag:function(t){var i=this;t.data=document.createElement("video"),t.data.name=t.key,t.data.controls=!1,t.data.autoplay=!1,t.data.playsInline=!0;var s=function(){t.data.removeEventListener(t.loadEvent,s,!1),t.data.onerror=null,t.data.canplay=!0,e.GAMES[i.game.id].load.fileComplete(t)};t.data.onerror=function(){t.data.removeEventListener(t.loadEvent,s,!1),t.data.onerror=null,t.data.canplay=!1,i.fileError(t)},t.data.addEventListener(t.loadEvent,s,!1),t.data.src=this.transformUrl(t.url,t),t.data.load()},loadAudioTag:function(t){var e=this;if(this.game.sound.touchLocked)t.data=new Audio,t.data.name=t.key,t.data.preload="auto",t.data.src=this.transformUrl(t.url,t),this.fileComplete(t);else{t.data=new Audio,t.data.name=t.key;var i=function(){t.data.removeEventListener("canplaythrough",i,!1),t.data.onerror=null,e.fileComplete(t)};t.data.onerror=function(){t.data.removeEventListener("canplaythrough",i,!1),t.data.onerror=null,e.fileError(t)},t.data.preload="auto",t.data.src=this.transformUrl(t.url,t),t.data.addEventListener("canplaythrough",i,!1),t.data.load()}},xhrLoad:function(t,e,i,s,n){var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType=i,!1!==this.headers.requestedWith&&r.setRequestHeader("X-Requested-With",this.headers.requestedWith),this.headers[t.type]&&r.setRequestHeader("Accept",this.headers[t.type]),n=n||this.fileError;var o=this;r.onload=function(){try{return 4===r.readyState&&r.status>=400&&r.status<=599?n.call(o,t,r):s.call(o,t,r)}catch(e){o.hasLoaded?window.console&&console.error(e):o.asyncComplete(t,e.message||"Exception")}},r.onerror=function(){try{return n.call(o,t,r)}catch(e){o.hasLoaded?window.console&&console.error(e):o.asyncComplete(t,e.message||"Exception")}},t.requestObject=r,t.requestUrl=e,r.send()},getVideoURL:function(t){for(var e=0;e<t.length;e++){var i,s=t[e];if(s.uri){if(i=s.type,s=s.uri,this.game.device.canPlayVideo(i))return s}else{if(0===s.indexOf("blob:")||0===s.indexOf("data:"))return s;if(s.indexOf("?")>=0&&(s=s.substr(0,s.indexOf("?"))),i=s.substr((Math.max(0,s.lastIndexOf("."))||1/0)+1).toLowerCase(),this.game.device.canPlayVideo(i))return t[e]}}return null},getAudioURL:function(t){if(this.game.sound.noAudio)return null;for(var e=0;e<t.length;e++){var i,s=t[e];if(s.uri){if(i=s.type,s=s.uri,this.game.device.canPlayAudio(i))return s}else{if(0===s.indexOf("blob:")||0===s.indexOf("data:"))return s;if(s.indexOf("?")>=0&&(s=s.substr(0,s.indexOf("?"))),i=s.substr((Math.max(0,s.lastIndexOf("."))||1/0)+1).toLowerCase(),this.game.device.canPlayAudio(i))return t[e]}}return null},fileError:function(t,e,i){var s="error loading asset from URL "+(t.requestUrl||this.transformUrl(t.url,t));!i&&e&&(i=e.status),i&&(s=s+" ("+i+")"),this.asyncComplete(t,s)},fileComplete:function(t,i){var s=!0;switch(t.type){case"packfile":r=JSON.parse(i.responseText);t.data=r||{};break;case"texture":var n=/\.([^.]+)$/.exec(t.url.split("?",1)[0])[1].toLowerCase();null!==t.data?this.cache.addCompressedTextureMetaData(t.key,t.url,n,t.data):this.cache.addCompressedTextureMetaData(t.key,t.url,n,i.response);break;case"image":this.cache.addImage(t.key,t.url,t.data);break;case"spritesheet":this.cache.addSpriteSheet(t.key,t.url,t.data,t.frameWidth,t.frameHeight,t.frameMax,t.margin,t.spacing,t.skipFrames);break;case"textureatlas":if(null==t.atlasURL)this.cache.addTextureAtlas(t.key,t.url,t.data,t.atlasData,t.format);else if(s=!1,t.format===e.Loader.TEXTURE_ATLAS_JSON_ARRAY||t.format===e.Loader.TEXTURE_ATLAS_JSON_HASH||t.format===e.Loader.TEXTURE_ATLAS_JSON_PYXEL)this.xhrLoad(t,this.transformUrl(t.atlasURL,t),"text",this.jsonLoadComplete);else{if(t.format!==e.Loader.TEXTURE_ATLAS_XML_STARLING)throw new Error("Phaser.Loader. Invalid Texture Atlas format: "+t.format);this.xhrLoad(t,this.transformUrl(t.atlasURL,t),"text",this.xmlLoadComplete)}break;case"bitmapfont":t.atlasURL?(s=!1,this.xhrLoad(t,this.transformUrl(t.atlasURL,t),"text",function(t,e){var i;try{i=JSON.parse(e.responseText)}catch(t){}i?(t.atlasType="json",this.jsonLoadComplete(t,e)):(t.atlasType="xml",this.xmlLoadComplete(t,e))})):this.cache.addBitmapFont(t.key,t.url,t.data,t.atlasData,t.atlasType,t.xSpacing,t.ySpacing);break;case"video":if(t.asBlob)try{t.data=i.response}catch(e){throw new Error("Phaser.Loader. Unable to parse video file as Blob: "+t.key)}this.cache.addVideo(t.key,t.url,t.data,t.asBlob);break;case"audio":this.game.sound.usingWebAudio?(t.data=i.response,this.cache.addSound(t.key,t.url,t.data,!0,!1),t.autoDecode&&this.game.sound.decode(t.key)):this.cache.addSound(t.key,t.url,t.data,!1,!0);break;case"text":t.data=i.responseText,this.cache.addText(t.key,t.url,t.data);break;case"shader":t.data=i.responseText,this.cache.addShader(t.key,t.url,t.data);break;case"physics":var r=JSON.parse(i.responseText);this.cache.addPhysicsData(t.key,t.url,r,t.format);break;case"script":t.data=document.createElement("script"),t.data.language="javascript",t.data.type="text/javascript",t.data.defer=!1,t.data.text=i.responseText,document.head.appendChild(t.data),t.callback&&(t.data=t.callback.call(t.callbackContext,t.key,i.responseText));break;case"binary":t.callback?t.data=t.callback.call(t.callbackContext,t.key,i.response):t.data=i.response,this.cache.addBinary(t.key,t.data)}s&&this.asyncComplete(t)},jsonLoadComplete:function(t,e){var i=JSON.parse(e.responseText);"tilemap"===t.type?this.cache.addTilemap(t.key,t.url,i,t.format):"bitmapfont"===t.type?this.cache.addBitmapFont(t.key,t.url,t.data,i,t.atlasType,t.xSpacing,t.ySpacing):"json"===t.type?this.cache.addJSON(t.key,t.url,i):this.cache.addTextureAtlas(t.key,t.url,t.data,i,t.format),this.asyncComplete(t)},csvLoadComplete:function(t,e){var i=e.responseText;this.cache.addTilemap(t.key,t.url,i,t.format),this.asyncComplete(t)},xmlLoadComplete:function(t,e){var i=e.responseText,s=this.parseXml(i);if(!s){var n=e.responseType||e.contentType;return console.warn("Phaser.Loader - "+t.key+": invalid XML ("+n+")"),void this.asyncComplete(t,"invalid XML")}"bitmapfont"===t.type?this.cache.addBitmapFont(t.key,t.url,t.data,s,t.atlasType,t.xSpacing,t.ySpacing):"textureatlas"===t.type?this.cache.addTextureAtlas(t.key,t.url,t.data,s,t.format):"xml"===t.type&&this.cache.addXML(t.key,t.url,s),this.asyncComplete(t)},parseXml:function(t){var e;try{if(window.DOMParser){var i=new DOMParser;e=i.parseFromString(t,"text/xml")}else(e=new ActiveXObject("Microsoft.XMLDOM")).async="false",e.loadXML(t)}catch(t){e=null}return e&&e.documentElement&&!e.getElementsByTagName("parsererror").length?e:null},updateProgress:function(){this.preloadSprite&&(0===this.preloadSprite.direction?this.preloadSprite.rect.width=Math.floor(this.preloadSprite.width/100*this.progress):this.preloadSprite.rect.height=Math.floor(this.preloadSprite.height/100*this.progress),this.preloadSprite.sprite?this.preloadSprite.sprite.updateCrop():this.preloadSprite=null)},totalLoadedFiles:function(){return this._loadedFileCount},totalQueuedFiles:function(){return this._totalFileCount-this._loadedFileCount},totalLoadedPacks:function(){return this._totalPackCount},totalQueuedPacks:function(){return this._totalPackCount-this._loadedPackCount}},Object.defineProperty(e.Loader.prototype,"progressFloat",{get:function(){var t=this._loadedFileCount/this._totalFileCount*100;return e.Math.clamp(t||0,0,100)}}),Object.defineProperty(e.Loader.prototype,"progress",{get:function(){return Math.round(this.progressFloat)}}),e.Loader.prototype.constructor=e.Loader,e.LoaderParser={bitmapFont:function(t,e,i,s,n,r){return this.xmlBitmapFont(t,e,i,s,n,r)},xmlBitmapFont:function(t,e,i,s,n,r){null==r&&(r=1);var o={},a=t.getElementsByTagName("info")[0],h=t.getElementsByTagName("common")[0];o.font=a.getAttribute("face"),o.size=parseInt(a.getAttribute("size"),10),o.lineHeight=parseInt(h.getAttribute("lineHeight"),10)+s,o.chars={};for(var l=t.getElementsByTagName("char"),c=n?n.x:0,u=n?n.y:0,d=0;d<l.length;d++){var p=parseInt(l[d].getAttribute("id"),10),f=o.chars[p]={x:parseInt(l[d].getAttribute("x"),10),y:parseInt(l[d].getAttribute("y"),10),width:parseInt(l[d].getAttribute("width"),10),height:parseInt(l[d].getAttribute("height"),10),xOffset:parseInt(l[d].getAttribute("xoffset"),10)/r,yOffset:parseInt(l[d].getAttribute("yoffset"),10)/r,xAdvance:(parseInt(l[d].getAttribute("xadvance"),10)+i)/r,kerning:{}};if(n&&n.trimmed){if(f.x+f.width>n.spriteSourceSizeX+n.spriteSourceSizeW&&(f.width-=f.x+f.width-n.spriteSourceSizeX-n.spriteSourceSizeW),f.y+f.height>n.spriteSourceSizeY+n.spriteSourceSizeH&&(f.height-=f.y+f.height-n.spriteSourceSizeY-n.spriteSourceSizeH),f.x<n.spriteSourceSizeX){g=n.spriteSourceSizeX-f.x;f.x=0,f.width-=g,f.xOffset+=g}if(f.y<n.spriteSourceSizeY){var g=n.spriteSourceSizeY-f.y;f.y=0,f.height-=g,f.yOffset+=g}}f.x+=c,f.y+=u}var m=t.getElementsByTagName("kerning");for(d=0;d<m.length;d++){var y=parseInt(m[d].getAttribute("first"),10),v=parseInt(m[d].getAttribute("second"),10),x=parseInt(m[d].getAttribute("amount"),10)/r;o.chars[v]&&(o.chars[v].kerning[y]=x)}return this.finalizeBitmapFont(e,o)},jsonBitmapFont:function(t,e,i,s,n,r){null==r&&(r=1);var o={font:t.font.info._face,size:parseInt(t.font.info._size,10),lineHeight:parseInt(t.font.common._lineHeight,10)+s,chars:{}},a=n?n.x:0,h=n?n.y:0;return t.font.chars.char.forEach(function(t){var e=parseInt(t._id,10),s=o.chars[e]={x:parseInt(t._x,10),y:parseInt(t._y,10),width:parseInt(t._width,10),height:parseInt(t._height,10),xOffset:parseInt(t._xoffset,10)/r,yOffset:parseInt(t._yoffset,10)/r,xAdvance:(parseInt(t._xadvance,10)+i)/r,kerning:{}};if(n&&n.trimmed){if(s.x+s.width>n.spriteSourceSizeX+n.spriteSourceSizeW&&(s.width-=s.x+s.width-n.spriteSourceSizeX-n.spriteSourceSizeW),s.y+s.height>n.spriteSourceSizeY+n.spriteSourceSizeH&&(s.height-=s.y+s.height-n.spriteSourceSizeY-n.spriteSourceSizeH),s.x<n.spriteSourceSizeX){l=n.spriteSourceSizeX-s.x;s.x=0,s.width-=l,s.xOffset+=l}if(s.y<n.spriteSourceSizeY){var l=n.spriteSourceSizeY-s.y;s.y=0,s.height-=l,s.yOffset+=l}}s.x+=a,s.y+=h}),t.font.kernings&&t.font.kernings.kerning&&t.font.kernings.kerning.forEach(function(t){o.chars[t._second]&&(o.chars[t._second].kerning[t._first]=parseInt(t._amount,10)/r)}),this.finalizeBitmapFont(e,o)},finalizeBitmapFont:function(t,i){return Object.keys(i.chars).forEach(function(s){var n=i.chars[s];n.texture=new PIXI.Texture(t,new e.Rectangle(n.x,n.y,n.width,n.height))}),i},pvr:function(t){var e,i=new Uint32Array(t.slice(0,52)),s=new Uint8Array(t),n=null,r=i[3]<<32|i[2],o=0;if(55727696===i[0]&&[0,1,2,3,6,7,9,11].indexOf(r)>=0){switch(r>=0&&r<=3?e="PVRTC":r>=7&&r<=11?e="S3TC":6===r&&(e="ETC1"),r){case 0:o=35841;break;case 1:o=35843;break;case 2:o=35840;break;case 3:o=35842;break;case 6:o=36196;break;case 7:o=33777;break;case 9:o=33778;break;case 11:o=33779;break;default:o=-1}n={complete:!0,fileFormat:"PVR",compressionAlgorithm:e,flags:i[1],pixelFormat:r,colorSpace:i[4],channelType:i[5],height:i[6],width:i[7],depth:i[8],numberOfSurfaces:i[9],numberOfFaces:i[10],numberOfMipmaps:i[11],metaDataSize:i[12],textureData:s.subarray(52+i[12],s.byteLength),glExtensionFormat:o}}return n},dds:function(t){var e=new Uint8Array(t),i=new Uint32Array(t),s=null;return 68===e[0]&&68===e[1]&&83===e[2]&&32===e[3]&&("DX10"===(s={complete:!0,fileFormat:"DDS",compressionAlgorithm:"S3TC",size:i[1],flags:i[2],height:i[3],width:i[4],pitch:i[5],depth:i[6],mipmapCount:i[7],formatSize:i[19],formatFlag:i[19],formatFourCC:[String.fromCharCode(e[84]),String.fromCharCode(e[85]),String.fromCharCode(e[86]),String.fromCharCode(e[87])].join(""),formatBitCount:i[21],formatRBitMask:i[22],formatGBitMask:i[23],formatBBitMask:i[24],formatABitMask:i[25],caps1:i[26],caps2:i[27],caps3:i[28],caps4:i[29],reserved2:i[30],DXGIFormat:null,resourceDimension:null,miscFlag:null,arraySize:null,textureData:e.subarray(i[1]+4,e.byteLength)}).formatFourCC?(s.DXGIFormat=i[31],s.resourceDimension=i[32],s.miscFlag=i[33],s.arraySize=i[34],s.miscFlag=i[35]):"DXT5"===s.formatFourCC?s.glExtensionFormat=33779:"DXT3"===s.formatFourCC&&(s.glExtensionFormat=33778)),s},ktx:function(t){var e=new Uint8Array(t),i=new Uint32Array(t),s=null,n=16+i[15]/4|0,r=i[n],o=i[7],a=0;if(171===e[0]&&75===e[1]&&84===e[2]&&88===e[3]&&32===e[4]&&49===e[5]&&49===e[6]&&187===e[7]&&13===e[8]&&10===e[9]&&26===e[10]&&10===e[11]&&[36196,35840,35841,35842,35843,33776,33777,33778,33779].indexOf(o)>=0){switch(o){case 36196:a="ETC1";break;case 35840:case 35841:case 35842:case 35843:a="PVRTC";break;case 33776:case 33777:case 33778:case 33779:a="S3TC"}s={complete:!0,fileFormat:"KTX",compressionAlgorithm:a,endianness:i[3],glType:i[4],glTypeSize:i[5],glFormat:i[6],glInternalFormat:i[7],glBaseInternalFormat:i[8],width:i[9],height:i[10],pixelDepth:i[11],numberOfArrayElements:i[12],numberOfFaces:i[13],numberOfMipmapLevels:i[14],bytesOfKeyValueData:i[15],keyAndValueByteSize:i[16],imageSize:r,textureData:e.subarray(4*(n+1),r+100)}}return s},pkm:function(t){var e=new Uint8Array(t),i=null;return 80===e[0]&&75===e[1]&&77===e[2]&&32===e[3]&&(i={complete:!0,fileFormat:"PKM",compressionAlgorithm:"ETC1",format:65535&(e[6]<<8|e[7]),width:65535&(e[8]<<8|e[9]),height:65535&(e[10]<<8|e[11]),originalWidth:65535&(e[12]<<8|e[13]),originalHeight:65535&(e[14]<<8|e[15]),textureData:e.subarray(16,e.length)}),i}},e.AudioSprite=function(t,e){this.game=t,this.key=e,this.config=this.game.cache.getJSON(e+"-audioatlas"),this.autoplayKey=null,this.autoplay=!1,this.sounds={};for(var i in this.config.spritemap){var s=this.config.spritemap[i],n=this.game.add.sound(this.key);n.addMarker(i,s.start,s.end-s.start,null,s.loop),this.sounds[i]=n}this.config.autoplay&&(this.autoplayKey=this.config.autoplay,this.play(this.autoplayKey),this.autoplay=this.sounds[this.autoplayKey])},e.AudioSprite.prototype={play:function(t,e){return void 0===e&&(e=1),this.sounds[t].play(t,null,e)},stop:function(t){if(t)this.sounds[t].stop();else for(var e in this.sounds)this.sounds[e].stop()},get:function(t){return this.sounds[t]}},e.AudioSprite.prototype.constructor=e.AudioSprite,e.Sound=function(t,i,s,n,r){void 0===s&&(s=1),void 0===n&&(n=!1),void 0===r&&(r=t.sound.connectToMaster),this.game=t,this.name=i,this.key=i,this.loop=n,this.markers={},this.context=null,this.autoplay=!1,this.totalDuration=0,this.startTime=0,this.currentTime=0,this.duration=0,this.durationMS=0,this.position=0,this.stopTime=0,this.paused=!1,this.pausedPosition=0,this.pausedTime=0,this.isPlaying=!1,this.currentMarker="",this.fadeTween=null,this.pendingPlayback=!1,this.override=!1,this.allowMultiple=!1,this.playOnce=!1,this.usingWebAudio=this.game.sound.usingWebAudio,this.usingAudioTag=this.game.sound.usingAudioTag,this.externalNode=null,this.masterGainNode=null,this.gainNode=null,this._sound=null,this._globalVolume=1,this._markedToDelete=!1,this._pendingStart=!1,this._removeFromSoundManager=!1,this._sourceId=0,this.usingWebAudio?(this.context=this.game.sound.context,this.masterGainNode=this.game.sound.masterGain,void 0===this.context.createGain?this.gainNode=this.context.createGainNode():this.gainNode=this.context.createGain(),this.gainNode.gain.value=s,r&&this.gainNode.connect(this.masterGainNode)):this.usingAudioTag&&(this.game.cache.getSound(i)&&this.game.cache.isSoundReady(i)?(this._sound=this.game.cache.getSoundData(i),this.totalDuration=0,this._sound.duration&&(this.totalDuration=this._sound.duration)):this.game.cache.onSoundUnlock.add(this.soundHasUnlocked,this)),this.onDecoded=new e.Signal,this.onPlay=new e.Signal,this.onPause=new e.Signal,this.onResume=new e.Signal,this.onLoop=new e.Signal,this.onStop=new e.Signal,this.onMute=new e.Signal,this.onMarkerComplete=new e.Signal,this.onFadeComplete=new e.Signal,this._volume=s,this._buffer=null,this._muted=!1,this._tempMarker=0,this._tempPosition=0,this._tempVolume=0,this._tempPause=0,this._muteVolume=0,this._tempLoop=0,this._paused=!1,this._onDecodedEventDispatched=!1},e.Sound.prototype={soundHasUnlocked:function(t){t===this.key&&(this._sound=this.game.cache.getSoundData(this.key),this.totalDuration=this._sound.duration)},addMarker:function(t,e,i,s,n){void 0!==i&&null!==i||(i=1),void 0!==s&&null!==s||(s=1),void 0===n&&(n=!1),this.markers[t]={name:t,start:e,stop:e+i,volume:s,duration:i,durationMS:1e3*i,loop:n}},removeMarker:function(t){delete this.markers[t]},onEndedHandler:function(){this._removeOnEndedHandler(),this.isPlaying=!1,this.currentTime=this.durationMS,this.stop(),this.playOnce&&(this._markedToDelete=!0,this._removeFromSoundManager=!0),this._markedToDelete&&(this._disconnectSource(),this._removeFromSoundManager?this.game.sound.remove(this):(this.markers={},this.context=null,this._buffer=null,this.externalNode=null,this.onDecoded.dispose(),this.onPlay.dispose(),this.onPause.dispose(),this.onResume.dispose(),this.onLoop.dispose(),this.onStop.dispose(),this.onMute.dispose(),this.onMarkerComplete.dispose()))},update:function(){if(this.game.cache.checkSoundKey(this.key)){this.isDecoded&&!this._onDecodedEventDispatched&&(this.onDecoded.dispatch(this),this._onDecodedEventDispatched=!0),this.pendingPlayback&&this.game.cache.isSoundReady(this.key)&&(this.pendingPlayback=!1,this.play(this._tempMarker,this._tempPosition,this._tempVolume,this._tempLoop));var t=this.game.time.time;if(this.isPlaying){if(this._pendingStart){var e=this._sound.currentTime;if(!(e>((this.paused?this._tempPause:0)||this.position||0)))return;this._pendingStart=!1,this.startTime=t-1e3*e,this.stopTime=this.startTime+this.durationMS}this.currentTime=t-this.startTime,this.currentTime>=this.durationMS&&(this.usingWebAudio?this.loop?(this.onLoop.dispatch(this),this.isPlaying=!1,""===this.currentMarker?(this.currentTime=0,this.startTime=t,this.isPlaying=!0):(this.onMarkerComplete.dispatch(this.currentMarker,this),this.play(this.currentMarker,0,this.volume,!0,!0,!1))):""!==this.currentMarker&&this.stop():this.loop?(this.onLoop.dispatch(this),""===this.currentMarker&&(this.currentTime=0,this.startTime=t),this.isPlaying=!1,this.play(this.currentMarker,0,this.volume,!0,!0,!1)):this.stop())}}else this.destroy()},loopFull:function(t){return this.play(null,0,t,!0)},play:function(t,e,i,s,n,r){if(void 0!==t&&!1!==t&&null!==t||(t=""),void 0===n&&(n=!0),void 0===r&&(r=!0),this.isPlaying&&!this.allowMultiple&&!n&&!this.override)return this;if(this._sound&&this.isPlaying&&!this.allowMultiple&&(this.override||n)&&(this.usingWebAudio?this._stopSourceAndDisconnect():this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0),this.isPlaying=!1),""===t&&Object.keys(this.markers).length>0)return this;if(""!==t){if(!this.markers[t])return console.warn("Phaser.Sound.play: audio marker "+t+" doesn't exist"),this;this.currentMarker=t,this.position=this.markers[t].start,this.volume=this.markers[t].volume,this.loop=this.markers[t].loop,this.duration=this.markers[t].duration,this.durationMS=this.markers[t].durationMS,void 0!==i&&(this.volume=i),void 0!==s&&(this.loop=s),this._tempMarker=t,this._tempPosition=this.position,this._tempVolume=this.volume,this._tempLoop=this.loop}else e=e||0,void 0===i&&(i=this._volume),void 0===s&&(s=this.loop),this.position=Math.max(0,e),this.volume=i,this.loop=s,this.duration=0,this.durationMS=0,this._tempMarker=t,this._tempPosition=e,this._tempVolume=i,this._tempLoop=s;return this.usingWebAudio?this.game.cache.isSoundDecoded(this.key)?(this._createSourceAndConnect(),this.loop&&""===t&&(this._sound.loop=!0),this.loop||""!==t||this._addOnEndedHandler(),this.totalDuration=this._sound.buffer.duration,0===this.duration&&(this.duration=this.totalDuration,this.durationMS=Math.ceil(1e3*this.totalDuration)),this.loop&&""===t?this._startSource(0,0):this._startSource(0,this.position,this.duration),this.isPlaying=!0,this.paused=!1,this.startTime=this.game.time.time,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,r&&this.onPlay.dispatch(this)):(this.pendingPlayback=!0,this.game.cache.getSound(this.key)&&!1===this.game.cache.getSound(this.key).isDecoding&&this.game.sound.decode(this.key,this)):this.game.cache.getSound(this.key)&&this.game.cache.getSound(this.key).locked?(this.game.cache.reloadSound(this.key),this.pendingPlayback=!0):this._sound&&(this.game.device.cocoonJS||4===this._sound.readyState)?(this._sound.play(),this._sound.loop=this.loop,this.totalDuration=this._sound.duration,0===this.duration&&(this.duration=this.totalDuration,this.durationMS=1e3*this.totalDuration),this._globalVolume=this.game.sound.volume,this._sound.currentTime=this.position,this._sound.muted=this._muted,this._muted||this.game.sound.mute?this._sound.volume=0:this._sound.volume=this._volume*this._globalVolume,this._pendingStart=!this.currentMarker,this.isPlaying=!0,this.paused=!1,this._tempPause=0,this.startTime=this.game.time.time,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,r&&this.onPlay.dispatch(this)):this.pendingPlayback=!0,this.playOnce&&(this.loop&&console.warn("Phaser.Sound.play: audio clip "+this.name+" cannot be deleted while looping."),this._markedToDelete=!0,this._removeFromSoundManager=!0),this},restart:function(t,e,i,s){t=t||"",e=e||0,i=i||1,void 0===s&&(s=!1),this.play(t,e,i,s,!0)},pause:function(){this.isPlaying&&(this.paused=!0,this.pausedPosition=this.currentTime,this.pausedTime=this.game.time.time,this._tempPause=this._sound.currentTime,this.onPause.dispatch(this),this.stop())},resume:function(){if(this.paused){if(this.usingWebAudio){var t=Math.max(0,this.position+this.pausedPosition/1e3);this._createSourceAndConnect(),""===this.currentMarker&&(this.loop?this._sound.loop=!0:this._addOnEndedHandler());var e=this.duration-this.pausedPosition/1e3;this.loop&&""===this.currentMarker?this._startSource(0,t):this._startSource(0,t,e)}else this._pendingStart=!this.currentMarker,this._sound.currentTime=this._tempPause,this._tempPause=0,this._sound.play();this.isPlaying=!0,this.paused=!1,this.startTime+=this.game.time.time-this.pausedTime,this.onResume.dispatch(this)}},stop:function(){if(this.isPlaying&&this._sound&&(this.usingWebAudio?this._stopSourceAndDisconnect():this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0)),this.pendingPlayback=!1,this.isPlaying=!1,!this.paused){var t=this.currentMarker;""!==this.currentMarker&&this.onMarkerComplete.dispatch(this.currentMarker,this),this.currentMarker="",null!==this.fadeTween&&this.fadeTween.stop(),this.onStop.dispatch(this,t)}},fadeIn:function(t,e,i){void 0===e&&(e=!1),void 0===i&&(i=this.currentMarker),this.paused||(this.play(i,0,0,e),this.fadeTo(t,1))},fadeOut:function(t){this.fadeTo(t,0)},fadeTo:function(t,i){this.isPlaying&&!this.paused&&i!==this.volume&&(void 0===t&&(t=1e3),void 0!==i?(this.fadeTween=this.game.add.tween(this).to({volume:i},t,e.Easing.Linear.None,!0),this.fadeTween.onComplete.add(this.fadeComplete,this)):console.warn("Phaser.Sound.fadeTo: No Volume Specified."))},fadeComplete:function(){this.onFadeComplete.dispatch(this,this.volume),0===this.volume&&this.stop()},updateGlobalVolume:function(t){this.usingAudioTag&&this._sound&&(this._globalVolume=t,this._sound.volume=this._globalVolume*this._volume)},destroy:function(t){void 0===t&&(t=!0),this._markedToDelete=!0,this._removeFromSoundManager=t,this.stop(),t?this.game.sound.remove(this):(this.markers={},this.context=null,this._buffer=null,this.externalNode=null,this.onDecoded.dispose(),this.onPlay.dispose(),this.onPause.dispose(),this.onResume.dispose(),this.onLoop.dispose(),this.onStop.dispose(),this.onMute.dispose(),this.onMarkerComplete.dispose())},_createSourceAndConnect:function(){this._sound=this.context.createBufferSource(),this._sound.connect(this.externalNode||this.gainNode),this._buffer=this.game.cache.getSoundData(this.key),this._sound.buffer=this._buffer,this._sourceId++},_disconnectSource:function(){this._sound.disconnect(this.externalNode||this.gainNode)},_startSource:function(t,e,i){void 0===i?this._sound.start(t||0,e||0):this._sound.start(t||0,e||0,i)},_stopSourceAndDisconnect:function(){this._removeOnEndedHandler();try{this._sound.stop(0)}catch(t){}this._disconnectSource(),this._sound=null},_addOnEndedHandler:function(){this._sound.onended=this.onEndedHandler.bind(this)},_removeOnEndedHandler:function(){this._sound.onended=null}},e.Sound.prototype.constructor=e.Sound,Object.defineProperty(e.Sound.prototype,"isDecoding",{get:function(){return this.game.cache.getSound(this.key).isDecoding}}),Object.defineProperty(e.Sound.prototype,"isDecoded",{get:function(){return this.game.cache.isSoundDecoded(this.key)}}),Object.defineProperty(e.Sound.prototype,"mute",{get:function(){return this._muted||this.game.sound.mute},set:function(t){(t=t||!1)!==this._muted&&(t?(this._muted=!0,this._muteVolume=this._tempVolume,this.usingWebAudio?this.gainNode.gain.value=0:this.usingAudioTag&&this._sound&&(this._sound.volume=0)):(this._muted=!1,this.usingWebAudio?this.gainNode.gain.value=this._muteVolume:this.usingAudioTag&&this._sound&&(this._sound.volume=this._muteVolume)),this.onMute.dispatch(this))}}),Object.defineProperty(e.Sound.prototype,"volume",{get:function(){return this._volume},set:function(t){this.usingAudioTag&&(t=this.game.math.clamp(t,0,1)),this._muted?this._muteVolume=t:(this._tempVolume=t,this._volume=t,this.usingWebAudio?this.gainNode.gain.value=t:this.usingAudioTag&&this._sound&&(this._sound.volume=this._globalVolume*t))}}),Object.defineProperty(e.Sound.prototype,"sourceId",{get:function(){return this._sound?this._sourceId:null}}),e.SoundManager=function(t){this.game=t,this.onSoundDecode=new e.Signal,this.onVolumeChange=new e.Signal,this.onMute=new e.Signal,this.onUnMute=new e.Signal,this.onTouchUnlock=new e.Signal,this.context=null,this.baseLatency=null,this.usingWebAudio=!1,this.usingAudioTag=!1,this.noAudio=!1,this.connectToMaster=!0,this.touchLocked=!1,this.channels=32,this.muteOnPause=!0,this._codeMuted=!1,this._muted=!1,this._unlockSource=null,this._volume=1,this._sounds=[],this._watchList=new e.ArraySet,this._watching=!1,this._watchCallback=null,this._watchContext=null,this._resumeWebAudioOnClick=this._resumeWebAudioOnClick.bind(this)},e.SoundManager.prototype={boot:function(){var t=this.game.device,e=window.PhaserGlobal;if(t.iOS&&!1===t.webAudio&&(this.channels=1),e){if(!0===e.disableAudio)return this.noAudio=!0,void(this.touchLocked=!1);if(!0===e.disableWebAudio)return this.usingAudioTag=!0,void(this.touchLocked=!1)}if(e&&e.audioContext)this.context=e.audioContext;else{var i=window.AudioContext||window.webkitAudioContext;if(i)try{this.context=new i}catch(t){this.context=null,this.usingWebAudio=!1,this.touchLocked=!1,console.warn(t)}}if(null===this.context){if(void 0===window.Audio)return void(this.noAudio=!0);this.usingAudioTag=!0}else this.usingWebAudio=!0,this.baseLatency=this.context.baseLatency||256/(this.context.sampleRate||44100),void 0===this.context.createGain?this.masterGain=this.context.createGainNode():this.masterGain=this.context.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this.context.destination),"suspended"===this.context.state&&this.game.canvas.addEventListener("click",this._resumeWebAudioOnClick);this.noAudio||t.needsTouchUnlock()&&this.setTouchLock(),this.usingWebAudio&&t.chrome&&t.chromeVersion<=65&&console.log('A "GainNode.gain.value setter smoothing is deprecated" notice in Chrome is normal. <https://github.com/photonstorm/phaser-ce/issues/385>')},setTouchLock:function(){this.noAudio||window.PhaserGlobal&&!0===window.PhaserGlobal.disableAudio||(this.game.input.addTouchLockCallback(this.unlock,this,!0),this.touchLocked=!0)},setTouchUnlock:function(){this.touchLocked=!1,this._unlockSource=null,this.onTouchUnlock.dispatch()},resumeWebAudio:function(){if(this.usingWebAudio&&"suspended"===this.context.state)return this.context.resume()},unlock:function(){if(this.noAudio||!this.touchLocked||null!==this._unlockSource)return!0;if(this.usingAudioTag)this.setTouchUnlock();else if(this.usingWebAudio){var t=this.context.createBuffer(1,1,22050);this._unlockSource=this.context.createBufferSource(),this._unlockSource.buffer=t,this._unlockSource.connect(this.context.destination);var e=this;this._unlockSource.onended=function(){e.setTouchUnlock(),e.resumeWebAudio()},void 0===this._unlockSource.start?this._unlockSource.noteOn(0):this._unlockSource.start(0),this.resumeWebAudio()}return!0},stopAll:function(){if(!this.noAudio)for(var t=0;t<this._sounds.length;t++)this._sounds[t]&&this._sounds[t].stop()},pauseAll:function(){if(!this.noAudio)for(var t=0;t<this._sounds.length;t++)this._sounds[t]&&this._sounds[t].pause()},resumeAll:function(){if(!this.noAudio)for(var t=0;t<this._sounds.length;t++)this._sounds[t]&&this._sounds[t].resume()},decode:function(t,e){e=e||null;var i=this.game.cache.getSoundData(t);if(i&&!1===this.game.cache.isSoundDecoded(t)){this.game.cache.updateSound(t,"isDecoding",!0);var s=this;try{this.context.decodeAudioData(i,function(i){i&&(s.game.cache.decodedSound(t,i),s.onSoundDecode.dispatch(t,e))})}catch(t){}}},setDecodedCallback:function(t,i,s){"string"==typeof t&&(t=[t]),this._watchList.reset();for(var n=0;n<t.length;n++)t[n]instanceof e.Sound?this.game.cache.isSoundDecoded(t[n].key)||this._watchList.add(t[n].key):this.game.cache.isSoundDecoded(t[n])||this._watchList.add(t[n]);0===this._watchList.total?(this._watching=!1,i.call(s)):(this._watching=!0,this._watchCallback=i,this._watchContext=s)},update:function(){if(!this.noAudio){for(var t=0;t<this._sounds.length;t++)this._sounds[t].update();if(this._watching){for(var e=this._watchList.first;e;)this.game.cache.isSoundDecoded(e)&&this._watchList.remove(e),e=this._watchList.next;0===this._watchList.total&&(this._watching=!1,this._watchCallback.call(this._watchContext))}}},add:function(t,i,s,n){void 0===i&&(i=1),void 0===s&&(s=!1),void 0===n&&(n=this.connectToMaster);var r=new e.Sound(this.game,t,i,s,n);return this._sounds.push(r),r},addSprite:function(t){return new e.AudioSprite(this.game,t)},remove:function(t){for(var e=this._sounds.length;e--;)if(this._sounds[e]===t)return this._sounds[e].destroy(!1),this._sounds.splice(e,1),!0;return!1},removeAll:function(){this.stopAll();for(var t=0;t<this._sounds.length;t++)this._sounds[t]&&this._sounds[t].destroy();this._sounds.length=0},removeByKey:function(t){for(var e=this._sounds.length,i=0;e--;)this._sounds[e].key===t&&(this._sounds[e].destroy(!1),this._sounds.splice(e,1),i++);return i},play:function(t,e,i){if(!this.noAudio){var s=this.add(t,e,i);return s.play(),s}},setMute:function(){if(!this._muted){this._muted=!0,this.usingWebAudio&&(this._muteVolume=this.masterGain.gain.value,this.masterGain.gain.value=0);for(var t=0;t<this._sounds.length;t++)this._sounds[t].usingAudioTag&&(this._sounds[t].mute=!0);this.onMute.dispatch()}},unsetMute:function(){if(this._muted&&!this._codeMuted){this._muted=!1,this.usingWebAudio&&(this.masterGain.gain.value=this._muteVolume);for(var t=0;t<this._sounds.length;t++)this._sounds[t].usingAudioTag&&(this._sounds[t].mute=!1);this.onUnMute.dispatch()}},destroy:function(){this.removeAll(),this.onSoundDecode.dispose(),this.game.canvas.removeEventListener("click",this._resumeWebAudioOnClick),this.context&&(window.PhaserGlobal?window.PhaserGlobal.audioContext=this.context:this.context.close&&this.context.close())},_resumeWebAudioOnClick:function(){this.resumeWebAudio(),this.game.canvas.removeEventListener("click",this._resumeWebAudioOnClick)}},e.SoundManager.prototype.constructor=e.SoundManager,Object.defineProperty(e.SoundManager.prototype,"mute",{get:function(){return this._muted},set:function(t){if(t=t||!1){if(this._muted)return;this._codeMuted=!0,this.setMute()}else{if(!this._muted)return;this._codeMuted=!1,this.unsetMute()}}}),Object.defineProperty(e.SoundManager.prototype,"volume",{get:function(){return this._volume},set:function(t){if(t<0?t=0:t>1&&(t=1),this._volume!==t){if(this._volume=t,this.usingWebAudio)this.masterGain.gain.value=t;else for(var e=0;e<this._sounds.length;e++)this._sounds[e].usingAudioTag&&this._sounds[e].updateGlobalVolume(t);this.onVolumeChange.dispatch(t)}}}),e.ScaleManager=function(t,i,s){this.game=t,this.dom=e.DOM,this.grid=null,this.width=0,this.height=0,this.minWidth=null,this.maxWidth=null,this.minHeight=null,this.maxHeight=null,this.offset=new e.Point,this.forceLandscape=!1,this.forcePortrait=!1,this.incorrectOrientation=!1,this._pageAlignHorizontally=!1,this._pageAlignVertically=!1,this.onOrientationChange=new e.Signal,this.enterIncorrectOrientation=new e.Signal,this.leaveIncorrectOrientation=new e.Signal,this.hasPhaserSetFullScreen=!1,this.fullScreenTarget=null,this._createdFullScreenTarget=null,this.onFullScreenInit=new e.Signal,this.onFullScreenChange=new e.Signal,this.onFullScreenError=new e.Signal,this.screenOrientation=this.dom.getScreenOrientation(),this.scaleFactor=new e.Point(1,1),this.scaleFactorInversed=new e.Point(1,1),this.margin={left:0,top:0,right:0,bottom:0,x:0,y:0},this.bounds=new e.Rectangle,this.aspectRatio=0,this.sourceAspectRatio=0,this.event=null,this.windowConstraints={right:"layout",bottom:""},this.compatibility={supportsFullScreen:!1,orientationFallback:null,noMargins:!1,scrollTo:null,forceMinimumDocumentHeight:!1,canExpandParent:!0,clickTrampoline:""},this._scaleMode=e.ScaleManager.NO_SCALE,this._fullScreenScaleMode=e.ScaleManager.NO_SCALE,this.parentIsWindow=!1,this.parentNode=null,this.parentScaleFactor=new e.Point(1,1),this.trackParentInterval=2e3,this.onSizeChange=new e.Signal,this.onResize=null,this.onResizeContext=null,this._pendingScaleMode=null,this._fullScreenRestore=null,this._gameSize=new e.Rectangle,this._userScaleFactor=new e.Point(1,1),this._userScaleTrim=new e.Point(0,0),this._lastUpdate=0,this._updateThrottle=0,this._updateThrottleReset=100,this._parentBounds=new e.Rectangle,this._tempBounds=new e.Rectangle,this._lastReportedCanvasSize=new e.Rectangle,this._lastReportedGameSize=new e.Rectangle,this._booted=!1,t.config&&this.parseConfig(t.config),this.setupScale(i,s)},e.ScaleManager.EXACT_FIT=0,e.ScaleManager.NO_SCALE=1,e.ScaleManager.SHOW_ALL=2,e.ScaleManager.RESIZE=3,e.ScaleManager.USER_SCALE=4,e.ScaleManager.MODES=["EXACT_FIT","NO_SCALE","SHOW_ALL","RESIZE","USER_SCALE"],e.ScaleManager.prototype={boot:function(){var t=this.compatibility;t.supportsFullScreen=this.game.device.fullscreen&&!this.game.device.cocoonJS,this.game.device.iPad||this.game.device.webApp||this.game.device.desktop||(this.game.device.android&&!this.game.device.chrome?t.scrollTo=new e.Point(0,1):t.scrollTo=new e.Point(0,0)),this.game.device.desktop?(t.orientationFallback="screen",t.clickTrampoline="when-not-mouse"):(t.orientationFallback="",t.clickTrampoline="");var i=this;this._orientationChange=function(t){return i.orientationChange(t)},this._windowResize=function(t){return i.windowResize(t)},window.addEventListener("orientationchange",this._orientationChange,!1),window.addEventListener("resize",this._windowResize,!1),this.compatibility.supportsFullScreen&&(this._fullScreenChange=function(t){return i.fullScreenChange(t)},this._fullScreenError=function(t){return i.fullScreenError(t)},document.addEventListener("webkitfullscreenchange",this._fullScreenChange,!1),document.addEventListener("mozfullscreenchange",this._fullScreenChange,!1),document.addEventListener("MSFullscreenChange",this._fullScreenChange,!1),document.addEventListener("fullscreenchange",this._fullScreenChange,!1),document.addEventListener("webkitfullscreenerror",this._fullScreenError,!1),document.addEventListener("mozfullscreenerror",this._fullScreenError,!1),document.addEventListener("MSFullscreenError",this._fullScreenError,!1),document.addEventListener("fullscreenerror",this._fullScreenError,!1)),this.game.onResume.add(this._gameResumed,this),this.dom.getOffset(this.game.canvas,this.offset),this.bounds.setTo(this.offset.x,this.offset.y,this.width,this.height),this.setGameSize(this.game.width,this.game.height),this.screenOrientation=this.dom.getScreenOrientation(this.compatibility.orientationFallback),e.FlexGrid&&(this.grid=new e.FlexGrid(this,this.width,this.height)),this._booted=!0,null!==this._pendingScaleMode&&(this.scaleMode=this._pendingScaleMode,this._pendingScaleMode=null)},parseConfig:function(t){void 0!==t.scaleMode&&(this._booted?this.scaleMode=t.scaleMode:this._pendingScaleMode=t.scaleMode),void 0!==t.fullScreenScaleMode&&(this.fullScreenScaleMode=t.fullScreenScaleMode),t.fullScreenTarget&&(this.fullScreenTarget=t.fullScreenTarget),this.pageAlignHorizontally=t.alignH||!1,this.pageAlignVertically=t.alignV||!1,t.scaleH&&t.scaleV&&this.setUserScale(t.scaleH,t.scaleV,t.trimH,t.trimV)},setupScale:function(t,i){var s,n=new e.Rectangle;""!==this.game.parent&&("string"==typeof this.game.parent?s=document.getElementById(this.game.parent):this.game.parent&&1===this.game.parent.nodeType&&(s=this.game.parent)),s?(this.parentNode=s,this.parentIsWindow=!1,this.getParentBounds(this._parentBounds,this.parentNode),n.width=this._parentBounds.width,n.height=this._parentBounds.height,this.offset.set(this._parentBounds.x,this._parentBounds.y)):(this.parentNode=null,this.parentIsWindow=!0,n.width=this.dom.visualBounds.width,n.height=this.dom.visualBounds.height,this.offset.set(0,0));var r=0,o=0;"number"==typeof t?r=t:(this.parentScaleFactor.x=parseInt(t,10)/100,r=n.width*this.parentScaleFactor.x),"number"==typeof i?o=i:(this.parentScaleFactor.y=parseInt(i,10)/100,o=n.height*this.parentScaleFactor.y),r=Math.floor(r),o=Math.floor(o),this._gameSize.setTo(0,0,r,o),this.updateDimensions(r,o,!1)},_gameResumed:function(){this.queueUpdate(!0)},setGameSize:function(t,i){this._gameSize.setTo(0,0,t,i),this.currentScaleMode!==e.ScaleManager.RESIZE&&this.updateDimensions(t,i,!0),this.queueUpdate(!0)},setUserScale:function(t,e,i,s,n,r){this._userScaleFactor.setTo(t,e),this._userScaleTrim.setTo(0|i,0|s),void 0===n&&(n=!0),void 0===r&&(r=!0),n&&this.queueUpdate(r)},setResizeCallback:function(t,e){this.onResize=t,this.onResizeContext=e},signalSizeChange:function(){if(!e.Rectangle.sameDimensions(this,this._lastReportedCanvasSize)||!e.Rectangle.sameDimensions(this.game,this._lastReportedGameSize)){var t=this.width,i=this.height;this._lastReportedCanvasSize.setTo(0,0,t,i),this._lastReportedGameSize.setTo(0,0,this.game.width,this.game.height),this.grid&&this.grid.onResize(t,i),this.onSizeChange.dispatch(this,t,i),this.currentScaleMode===e.ScaleManager.RESIZE&&(this.game.state.resize(t,i),this.game.load.resize(t,i))}},setMinMax:function(t,e,i,s){this.minWidth=t,this.minHeight=e,void 0!==i&&(this.maxWidth=i),void 0!==s&&(this.maxHeight=s)},preUpdate:function(){if(!(this.game.time.time<this._lastUpdate+this._updateThrottle)){var t=this._updateThrottle;this._updateThrottleReset=t>=400?0:100,this.dom.getOffset(this.game.canvas,this.offset);var i=this._parentBounds.width,s=this._parentBounds.height,n=this.getParentBounds(this._parentBounds),r=n.width!==i||n.height!==s,o=this.updateOrientationState();(r||o)&&(this.onResize&&this.onResize.call(this.onResizeContext,this,n),this.updateLayout(),this.signalSizeChange());var a=2*this._updateThrottle;this._updateThrottle<t&&(a=Math.min(t,this._updateThrottleReset)),this._updateThrottle=e.Math.clamp(a,25,this.trackParentInterval),this._lastUpdate=this.game.time.time}},pauseUpdate:function(){this.preUpdate(),this._updateThrottle=this.trackParentInterval},updateDimensions:function(t,e,i){this.width=t*this.parentScaleFactor.x,this.height=e*this.parentScaleFactor.y,this.game.width=this.width,this.game.height=this.height,this.sourceAspectRatio=this.width/this.height,this.updateScalingAndBounds(),i&&(this.game.renderer.resize(this.width,this.height),this.game.camera.setSize(this.width,this.height),this.game.world.resize(this.width,this.height))},updateScalingAndBounds:function(){this.scaleFactor.x=this.game.width/this.width,this.scaleFactor.y=this.game.height/this.height,this.scaleFactorInversed.x=this.width/this.game.width,this.scaleFactorInversed.y=this.height/this.game.height,this.aspectRatio=this.width/this.height,this.game.canvas&&this.dom.getOffset(this.game.canvas,this.offset),this.bounds.setTo(this.offset.x,this.offset.y,this.width,this.height),this.game.input&&this.game.input.scale&&this.game.input.scale.setTo(this.scaleFactor.x,this.scaleFactor.y)},forceOrientation:function(t,e){void 0===e&&(e=!1),!0!==t||!0!==e?(this.forceLandscape=t,this.forcePortrait=e,this.queueUpdate(!0)):console.warn("Phaser.ScaleManager: forceLandscape and forcePortrait cannot both be true.")},classifyOrientation:function(t){return"portrait-primary"===t||"portrait-secondary"===t?"portrait":"landscape-primary"===t||"landscape-secondary"===t?"landscape":null},updateOrientationState:function(){var t=this.screenOrientation,e=this.incorrectOrientation;this.screenOrientation=this.dom.getScreenOrientation(this.compatibility.orientationFallback),this.incorrectOrientation=this.forceLandscape&&!this.isLandscape||this.forcePortrait&&!this.isPortrait;var i=t!==this.screenOrientation,s=e!==this.incorrectOrientation;return s&&(this.incorrectOrientation?this.enterIncorrectOrientation.dispatch():this.leaveIncorrectOrientation.dispatch()),(i||s)&&this.onOrientationChange.dispatch(this,t,e),i||s},orientationChange:function(t){this.event=t,this.queueUpdate(!0)},windowResize:function(t){this.event=t,this.queueUpdate(!0)},scrollTop:function(){var t=this.compatibility.scrollTo;t&&window.scrollTo(t.x,t.y)},refresh:function(){this.scrollTop(),this.queueUpdate(!0)},updateLayout:function(){var t=this.currentScaleMode;if(t!==e.ScaleManager.RESIZE){if(this.scrollTop(),this.compatibility.forceMinimumDocumentHeight&&(document.documentElement.style.minHeight=window.innerHeight+"px"),this.incorrectOrientation?this.setMaximum():t===e.ScaleManager.EXACT_FIT?this.setExactFit():t===e.ScaleManager.SHOW_ALL?!this.isFullScreen&&this.boundingParent&&this.compatibility.canExpandParent?(this.setShowAll(!0),this.resetCanvas(),this.setShowAll()):this.setShowAll():t===e.ScaleManager.NO_SCALE?(this.width=this.game.width,this.height=this.game.height):t===e.ScaleManager.USER_SCALE&&(this.width=this.game.width*this._userScaleFactor.x-this._userScaleTrim.x,this.height=this.game.height*this._userScaleFactor.y-this._userScaleTrim.y),!this.compatibility.canExpandParent&&(t===e.ScaleManager.SHOW_ALL||t===e.ScaleManager.USER_SCALE)){var i=this.getParentBounds(this._tempBounds);this.width=Math.min(this.width,i.width),this.height=Math.min(this.height,i.height)}this.width=0|this.width,this.height=0|this.height,this.reflowCanvas()}else this.reflowGame()},getParentBounds:function(t,i){var s=t||new e.Rectangle,n=i||this.boundingParent,r=this.dom.visualBounds,o=this.dom.layoutBounds;if(n){var a=n.getBoundingClientRect(),h=n.offsetParent?n.offsetParent.getBoundingClientRect():n.getBoundingClientRect();s.setTo(a.left-h.left,a.top-h.top,a.width,a.height);var l=this.windowConstraints;if(l.right){c="layout"===l.right?o:r;s.right=Math.min(s.right,c.width)}if(l.bottom){var c="layout"===l.bottom?o:r;s.bottom=Math.min(s.bottom,c.height)}}else s.setTo(0,0,r.width,r.height);return s.setTo(Math.round(s.x),Math.round(s.y),Math.round(s.width),Math.round(s.height)),s},align:function(t,e){null!=t&&(this.pageAlignHorizontally=t),null!=e&&(this.pageAlignVertically=e)},alignCanvas:function(t,e){var i=this.getParentBounds(this._tempBounds),s=this.game.canvas,n=this.margin;if(t){n.left=n.right=0;h=s.getBoundingClientRect();if(this.width<i.width&&!this.incorrectOrientation){var r=h.left-i.x,o=i.width/2-this.width/2,a=(o=Math.max(o,0))-r;n.left=Math.round(a)}s.style.marginLeft=n.left+"px",0!==n.left&&(n.right=-(i.width-h.width-n.left),s.style.marginRight=n.right+"px")}if(e){n.top=n.bottom=0;var h=s.getBoundingClientRect();if(this.height<i.height&&!this.incorrectOrientation){var r=h.top-i.y,o=i.height/2-this.height/2,a=(o=Math.max(o,0))-r;n.top=Math.round(a)}s.style.marginTop=n.top+"px",0!==n.top&&(n.bottom=-(i.height-h.height-n.top),s.style.marginBottom=n.bottom+"px")}n.x=n.left,n.y=n.top},reflowGame:function(){this.resetCanvas("","");var t=this.getParentBounds(this._tempBounds);this.updateDimensions(t.width,t.height,!0)},reflowCanvas:function(){this.incorrectOrientation||(this.width=e.Math.clamp(this.width,this.minWidth||0,this.maxWidth||this.width),this.height=e.Math.clamp(this.height,this.minHeight||0,this.maxHeight||this.height)),this.resetCanvas(),this.compatibility.noMargins||(this.isFullScreen&&this._createdFullScreenTarget?this.alignCanvas(!0,!0):this.alignCanvas(this.pageAlignHorizontally,this.pageAlignVertically)),this.updateScalingAndBounds()},resetCanvas:function(t,e){void 0===t&&(t=this.width+"px"),void 0===e&&(e=this.height+"px");var i=this.game.canvas;this.compatibility.noMargins||(i.style.marginLeft="",i.style.marginTop="",i.style.marginRight="",i.style.marginBottom=""),i.style.width=t,i.style.height=e},queueUpdate:function(t){t&&(this._parentBounds.width=0,this._parentBounds.height=0),this._updateThrottle=this._updateThrottleReset},reset:function(t){t&&this.grid&&this.grid.reset()},setMaximum:function(){this.width=this.dom.visualBounds.width,this.height=this.dom.visualBounds.height},setShowAll:function(t){var e,i=this.getParentBounds(this._tempBounds),s=i.width,n=i.height;e=t?Math.max(n/this.game.height,s/this.game.width):Math.min(n/this.game.height,s/this.game.width),this.width=Math.round(this.game.width*e),this.height=Math.round(this.game.height*e)},setExactFit:function(){var t=this.getParentBounds(this._tempBounds);this.width=t.width,this.height=t.height,this.isFullScreen||(this.maxWidth&&(this.width=Math.min(this.width,this.maxWidth)),this.maxHeight&&(this.height=Math.min(this.height,this.maxHeight)))},createFullScreenTarget:function(){var t=document.createElement("div");return t.style.margin="0",t.style.padding="0",t.style.background="#000",t},startFullScreen:function(t,i,s){if(this.isFullScreen)return!1;{if(this.compatibility.supportsFullScreen){if("when-not-mouse"===this.compatibility.clickTrampoline){var n=this.game.input;if(n.activePointer&&n.activePointer!==n.mousePointer&&(i||!1!==i))return void n.activePointer.addClickTrampoline("startFullScreen",this.startFullScreen,this,[t,!1])}void 0!==t&&this.game.renderType===e.CANVAS&&(this.game.stage.smoothed=t);var r=this.fullScreenTarget;r||(this.cleanupCreatedTarget(),this._createdFullScreenTarget=this.createFullScreenTarget(),r=this._createdFullScreenTarget);var o={targetElement:r};if(this.hasPhaserSetFullScreen=!0,this.onFullScreenInit.dispatch(this,o),this._createdFullScreenTarget){var a=this.game.canvas;a.parentNode.insertBefore(r,a),r.appendChild(a)}return void 0===s&&(s={navigationUI:"hide"}),this.game.device.fullscreenKeyboard?r[this.game.device.requestFullscreen](Element.ALLOW_KEYBOARD_INPUT):r[this.game.device.requestFullscreen](s),!0}var h=this;setTimeout(function(){h.fullScreenError()},10)}},stopFullScreen:function(){return!(!this.isFullScreen||!this.compatibility.supportsFullScreen)&&(this.hasPhaserSetFullScreen=!1,document[this.game.device.cancelFullscreen](),!0)},cleanupCreatedTarget:function(){var t=this._createdFullScreenTarget;if(t&&t.parentNode){var e=t.parentNode;e.insertBefore(this.game.canvas,t),e.removeChild(t)}this._createdFullScreenTarget=null},prepScreenMode:function(t){var i=!!this._createdFullScreenTarget,s=this._createdFullScreenTarget||this.fullScreenTarget;t?(i||this.fullScreenScaleMode===e.ScaleManager.EXACT_FIT)&&s!==this.game.canvas&&(this._fullScreenRestore={targetWidth:s.style.width,targetHeight:s.style.height},s.style.width="100%",s.style.height="100%"):(this._fullScreenRestore&&(s.style.width=this._fullScreenRestore.targetWidth,s.style.height=this._fullScreenRestore.targetHeight,this._fullScreenRestore=null),this.updateDimensions(this._gameSize.width,this._gameSize.height,!0),this.resetCanvas())},fullScreenChange:function(t){this.event=t,this.isFullScreen?(this.prepScreenMode(!0),this.updateLayout(),this.queueUpdate(!0)):(this.prepScreenMode(!1),this.cleanupCreatedTarget(),this.updateLayout(),this.queueUpdate(!0)),this.onFullScreenChange.dispatch(this,this.width,this.height)},fullScreenError:function(t){this.event=t,this.cleanupCreatedTarget(),console.warn("Phaser.ScaleManager: requestFullscreen failed or device does not support the Fullscreen API"),this.onFullScreenError.dispatch(this)},scaleSprite:function(t,e,i,s){if(void 0===e&&(e=this.width),void 0===i&&(i=this.height),void 0===s&&(s=!1),!t||!t.scale)return t;if(t.scale.x=1,t.scale.y=1,t.width<=0||t.height<=0||e<=0||i<=0)return t;var n=e,r=t.height*e/t.width,o=t.width*i/t.height,a=i,h=o>e;return(h=h?s:!s)?(t.width=Math.floor(n),t.height=Math.floor(r)):(t.width=Math.floor(o),t.height=Math.floor(a)),t},destroy:function(){this.game.onResume.remove(this._gameResumed,this),window.removeEventListener("orientationchange",this._orientationChange,!1),window.removeEventListener("resize",this._windowResize,!1),this.compatibility.supportsFullScreen&&(document.removeEventListener("webkitfullscreenchange",this._fullScreenChange,!1),document.removeEventListener("mozfullscreenchange",this._fullScreenChange,!1),document.removeEventListener("MSFullscreenChange",this._fullScreenChange,!1),document.removeEventListener("fullscreenchange",this._fullScreenChange,!1),document.removeEventListener("webkitfullscreenerror",this._fullScreenError,!1),document.removeEventListener("mozfullscreenerror",this._fullScreenError,!1),document.removeEventListener("MSFullscreenError",this._fullScreenError,!1),document.removeEventListener("fullscreenerror",this._fullScreenError,!1))}},e.ScaleManager.prototype.constructor=e.ScaleManager,Object.defineProperty(e.ScaleManager.prototype,"boundingParent",{get:function(){return this.parentIsWindow||this.isFullScreen&&this.hasPhaserSetFullScreen&&!this._createdFullScreenTarget?null:this.game.canvas&&this.game.canvas.parentNode||null}}),Object.defineProperty(e.ScaleManager.prototype,"scaleMode",{get:function(){return this._scaleMode},set:function(t){return t!==this._scaleMode&&(this.isFullScreen||(this.updateDimensions(this._gameSize.width,this._gameSize.height,!0),this.queueUpdate(!0)),this._scaleMode=t),this._scaleMode}}),Object.defineProperty(e.ScaleManager.prototype,"fullScreenScaleMode",{get:function(){return this._fullScreenScaleMode},set:function(t){return t!==this._fullScreenScaleMode&&(this.isFullScreen?(this.prepScreenMode(!1),this._fullScreenScaleMode=t,this.prepScreenMode(!0),this.queueUpdate(!0)):this._fullScreenScaleMode=t),this._fullScreenScaleMode}}),Object.defineProperty(e.ScaleManager.prototype,"currentScaleMode",{get:function(){return this.isFullScreen?this._fullScreenScaleMode:this._scaleMode}}),Object.defineProperty(e.ScaleManager.prototype,"pageAlignHorizontally",{get:function(){return this._pageAlignHorizontally},set:function(t){t!==this._pageAlignHorizontally&&(this._pageAlignHorizontally=t,this.queueUpdate(!0))}}),Object.defineProperty(e.ScaleManager.prototype,"pageAlignVertically",{get:function(){return this._pageAlignVertically},set:function(t){t!==this._pageAlignVertically&&(this._pageAlignVertically=t,this.queueUpdate(!0))}}),Object.defineProperty(e.ScaleManager.prototype,"isFullScreen",{get:function(){return!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)}}),Object.defineProperty(e.ScaleManager.prototype,"isPortrait",{get:function(){return"portrait"===this.classifyOrientation(this.screenOrientation)}}),Object.defineProperty(e.ScaleManager.prototype,"isLandscape",{get:function(){return"landscape"===this.classifyOrientation(this.screenOrientation)}}),Object.defineProperty(e.ScaleManager.prototype,"isGamePortrait",{get:function(){return this.height>this.width}}),Object.defineProperty(e.ScaleManager.prototype,"isGameLandscape",{get:function(){return this.width>this.height}}),e.Utils.Debug=function(t){this.game=t,this.sprite=null,this.bmd=null,this.canvas=null,this.context=null,this.font="14px monospace",this.columnWidth=100,this.lineHeight=16,this.lineWidth=1,this.renderShadow=!0,this.currentColor=null,this.currentX=0,this.currentY=0,this.currentAlpha=1,this.dirty=!1,this.isDisabled=!1,this._line=null,this._rect=null},e.Utils.Debug.GEOM_AUTO=0,e.Utils.Debug.GEOM_RECTANGLE=1,e.Utils.Debug.GEOM_CIRCLE=2,e.Utils.Debug.GEOM_POINT=3,e.Utils.Debug.GEOM_LINE=4,e.Utils.Debug.GEOM_ELLIPSE=5,e.Utils.Debug.prototype={boot:function(){this.game.renderType===e.CANVAS?this.context=this.game.context:(this.bmd=new e.BitmapData(this.game,"__DEBUG",this.game.width,this.game.height,!0),this.sprite=this.game.make.image(0,0,this.bmd),this.game.stage.addChild(this.sprite),this.game.scale.onSizeChange.add(this.resize,this),this.canvas=e.CanvasPool.create(this,this.game.width,this.game.height),this.context=this.canvas.getContext("2d")),this._line=new e.Line,this._rect=new e.Rectangle},resize:function(){this.bmd.resize(this.game.width,this.game.height),this.canvas.width=this.game.width,this.canvas.height=this.game.height},preUpdate:function(){this.dirty&&this.sprite&&(this.bmd.clear(),this.bmd.draw(this.canvas,0,0),this.context.clearRect(0,0,this.game.width,this.game.height),this.dirty=!1)},reset:function(){this.context&&this.context.clearRect(0,0,this.game.width,this.game.height),this.sprite&&this.bmd.clear()},start:function(t,e,i,s){"number"!=typeof t&&(t=0),"number"!=typeof e&&(e=0),i=i||"rgb(255,255,255)",void 0===s&&(s=0),this.currentX=t,this.currentY=e,this.currentColor=i,this.columnWidth=s,this.dirty=!0,this.context.save(),this.context.setTransform(1,0,0,1,0,0),this.context.strokeStyle=i,this.context.fillStyle=i,this.context.font=this.font,this.context.globalAlpha=this.currentAlpha},stop:function(){this.context.restore()},line:function(){for(var t=this.currentX,e=0;e<arguments.length;e++)this.renderShadow&&(this.context.fillStyle="rgb(0,0,0)",this.context.fillText(arguments[e],t+1,this.currentY+1),this.context.fillStyle=this.currentColor),this.context.fillText(arguments[e],t,this.currentY),t+=this.columnWidth;this.currentY+=this.lineHeight},sound:function(t,e,i){var s=this.game.sound;this.start(t,e,i),s.noAudio?this.line("Audio is disabled"):(this.line("Volume: "+s.volume.toFixed(2)+(s.mute?" (Mute)":"")),this.line("Mute on pause: "+s.muteOnPause),this.line("Using: "+(s.usingWebAudio?"Web Audio - "+s.context.state:"Audio Tag")),this.line("Touch locked: "+s.touchLocked),this.line("Sounds: "+s._sounds.length)),this.stop()},soundInfo:function(t,e,i,s){if(this.start(e,i,s),this.line("Sound: "+t.key+" Touch locked: "+t.game.sound.touchLocked),this.line("Is Ready?: "+this.game.cache.isSoundReady(t.key)+" Pending Playback: "+t.pendingPlayback),this.line("Decoded: "+t.isDecoded+" Decoding: "+t.isDecoding),this.line("Playing: "+t.isPlaying+" Loop: "+t.loop),this.line("Time: "+(t.currentTime/1e3).toFixed(3)+"s Total: "+t.totalDuration.toFixed(3)+"s"),this.line("Volume: "+t.volume.toFixed(2)+(t.mute?" (Mute)":"")),this.line("Using: "+(t.usingWebAudio?"Web Audio":"Audio Tag")),t.usingWebAudio&&this.line(" Source: "+(t.sourceId||"none")),t.usingAudioTag&&t._sound){var n=t._sound;this.line(" currentSrc: "+n.currentSrc),this.line(" currentTime: "+n.currentTime),this.line(" duration: "+n.duration),this.line(" ended: "+n.ended),this.line(" loop: "+n.loop),this.line(" muted: "+n.muted),this.line(" paused: "+n.paused)}""!==t.currentMarker&&(this.line("Marker: "+t.currentMarker+" Duration: "+t.duration.toFixed(3)+"s ("+t.durationMS+"ms)"),this.line("Start: "+t.markers[t.currentMarker].start.toFixed(3)+" Stop: "+t.markers[t.currentMarker].stop.toFixed(3)),this.line("Position: "+t.position.toFixed(3))),this.stop()},camera:function(t,e,i){var s=t.deadzone,n=t.target,r=t.view;s&&(this._rect.setTo(r.x+s.x,r.y+s.y,s.width,s.height),this.rectangle(this._rect,e,i)),n&&(this._line.setTo(r.centerX,r.centerY,n.x,n.y),this.geom(this._line,e,i),this.geom(n,e,!1,3))},cameraInfo:function(t,e,i,s){var n=t.bounds,r=t.deadzone,o=t.target,a=t.view;this.start(e,i,s),this.line("Camera ("+t.width+" x "+t.height+")"),this.line("x: "+t.x+" y: "+t.y),this.line("Bounds: "+(n?"x: "+n.x+" y: "+n.y+" w: "+n.width+" h: "+n.height:"none")),this.line("View: x: "+a.x+" y: "+a.y+" w: "+a.width+" h: "+a.height),this.line("Center: x: "+t.centerX+" y: "+t.centerY),this.line("Deadzone: "+(r?"x: "+r.x+" y: "+r.y+" w: "+r.width+" h: "+r.height:r)),this.line("Total in view: "+t.totalInView),this.line("At limit: x: "+t.atLimit.x+" y: "+t.atLimit.y),this.line("Target: "+(o?o.name||o:"none")),this.stop()},timer:function(t,e,i,s){this.start(e,i,s),this.line("Timer (running: "+t.running+" expired: "+t.expired+")"),this.line("Next Tick: "+t.next+" Duration: "+t.duration),this.line("Paused: "+t.paused+" Length: "+t.length),this.stop()},pointer:function(t,e,i,s,n,r){if(null!=t&&(void 0===e&&(e=!1),i=i||"rgba(0,255,0,0.5)",s=s||"rgba(255,255,0,0.5)",r=r||"rgba(255,0,0,0.5)",!0!==e||!0!==t.isUp)){this.start(t.x,t.y-150,n),this.context.beginPath(),this.context.arc(t.x,t.y,t.circle.radius,0,2*Math.PI),t.active?this.context.fillStyle=t.isDown?i:s:this.context.fillStyle=r,this.context.fill(),this.context.closePath(),this.context.beginPath(),this.context.moveTo(t.positionDown.x,t.positionDown.y),this.context.lineTo(t.position.x,t.position.y),this.context.lineWidth=2,this.context.stroke(),this.context.closePath();var o=t.movementX,a=t.movementY;(o||a)&&(this.context.beginPath(),this.context.moveTo(o+t.position.x,a+t.position.y),this.context.lineTo(t.position.x,t.position.y),this.context.lineWidth=2,this.context.stroke(),this.context.closePath()),this.line("ID: "+t.id+" Active: "+t.active),this.line("World X: "+t.worldX.toFixed(1)+" World Y: "+t.worldY.toFixed(1)),this.line("Screen X: "+t.x.toFixed(1)+" Screen Y: "+t.y.toFixed(1)+" In: "+t.withinGame),this.line("Movement: X: "+o+" Y: "+a),this.line("Duration: "+t.duration+" ms"),this.line("is Down: "+t.isDown+" is Up: "+t.isUp),t.isMouse&&this.line("Buttons: "+this._pointerButtonIcon(t.leftButton)+" "+this._pointerButtonIcon(t.middleButton)+" "+this._pointerButtonIcon(t.rightButton)),this.stop()}},_pointerButtonIcon:function(t){return t.isDown?"x":t.isUp?"o":"-"},spriteInputInfo:function(t,e,i,s){this.start(e,i,s),this.line("Sprite Input: ("+t.width+" x "+t.height+")"),this.line("x: "+t.input.pointerX().toFixed(1)+" y: "+t.input.pointerY().toFixed(1)),this.line("over: "+t.input.pointerOver()+" duration: "+t.input.overDuration().toFixed(0)),this.line("down: "+t.input.pointerDown()+" duration: "+t.input.downDuration().toFixed(0)),this.line("just over: "+t.input.justOver()+" just out: "+t.input.justOut()),this.stop()},key:function(t,e,i,s){this.start(e,i,s,150),this.line("Key:",t.keyCode,"isDown:",t.isDown),this.line("justDown:",t.justDown,"justUp:",t.justUp),this.line("Time Down:",t.timeDown.toFixed(0),"duration:",t.duration.toFixed(0)),this.stop()},inputInfo:function(t,i,s,n){var r=this.game.input;if(void 0===n&&(n=!0),this.start(t,i,s),this.line("Input"),this.line("X: "+r.x+" Y: "+r.y),this.line("World X: "+r.worldX+" World Y: "+r.worldY),this.line("Scale X: "+r.scale.x.toFixed(2)+" Scale Y: "+r.scale.x.toFixed(2)),this.line("Screen X: "+r.activePointer.screenX.toFixed(1)+" Screen Y: "+r.activePointer.screenY.toFixed(1)),n){this.line("Sources:"),this.line(" "+this._inputHandler(r.mouse,"mouse")),this.line(" "+this._inputHandler(r.mspointer,"mspointer")),this.line(" "+this._inputHandler(r.touch,"touch"));var o=r.pointers,a=r.mousePointer,h=e.PointerModes;this.line("Pointers: (Max: "+r.maxPointers+")"),this.line(" "+(a.isDown?"x":"o")+" "+h[a.pointerMode]+" "+a.identifier);for(var l=0;l<o.length;l++){var c=o[l];this.line(" "+(c.active?"+":"-")+" "+h[c.pointerMode]+" "+c.identifier)}this.stop()}else this.stop()},_inputHandler:function(t,e){return this._inputHandlerStatusIcon(t)+" "+e+" "+this._inputHandlerCaptureIcon(t)},_inputHandlerStatusIcon:function(t){return t.active?t.enabled?"+":"-":" "},_inputHandlerCaptureIcon:function(t){return t.active&&(t.capture||t.preventDefault)?"*":" "},spriteBounds:function(t,e,i){var s=t.getBounds();s.x+=this.game.camera.x,s.y+=this.game.camera.y,this.rectangle(s,e,i)},ropeSegments:function(t,e,i){var s=this;t.segments.forEach(function(t){s.rectangle(t,e,i)},this)},spriteInfo:function(t,e,i,s){this.start(e,i,s),this.line("Sprite: "+(t.name||"")+" ("+t.width+" x "+t.height+") anchor: "+t.anchor.x+" x "+t.anchor.y),this.line("x: "+t.x.toFixed(1)+" y: "+t.y.toFixed(1)),this.line("angle: "+t.angle.toFixed(1)+" rotation: "+t.rotation.toFixed(1)),this.line("visible: "+t.visible+" in camera: "+t.inCamera),this.line("bounds x: "+t._bounds.x.toFixed(1)+" y: "+t._bounds.y.toFixed(1)+" w: "+t._bounds.width.toFixed(1)+" h: "+t._bounds.height.toFixed(1)),this.line("parent: "+(t.parent?t.parent.name||"(DisplayObject)":"(none)")),this.stop()},spriteCoords:function(t,e,i,s){this.start(e,i,s,100),t.name&&this.line(t.name),this.line("x:",t.x.toFixed(2),"y:",t.y.toFixed(2)),this.line("pos x:",t.position.x.toFixed(2),"pos y:",t.position.y.toFixed(2)),this.line("world x:",t.world.x.toFixed(2),"world y:",t.world.y.toFixed(2)),this.stop()},lineInfo:function(t,e,i,s){this.start(e,i,s,80),this.line("start.x:",t.start.x.toFixed(2),"start.y:",t.start.y.toFixed(2)),this.line("end.x:",t.end.x.toFixed(2),"end.y:",t.end.y.toFixed(2)),this.line("length:",t.length.toFixed(2),"angle:",t.angle),this.stop()},pixel:function(t,e,i,s){s=s||2,this.start(),this.context.fillStyle=i,this.context.fillRect(t,e,s,s),this.stop()},geom:function(t,i,s,n){void 0===s&&(s=!0),void 0===n&&(n=0),i=i||"rgba(0,255,0,0.4)",this.start(),this.context.fillStyle=i,this.context.strokeStyle=i,this.context.lineWidth=this.lineWidth;var r=e.Utils.Debug;n===r.GEOM_RECTANGLE||t instanceof e.Rectangle?s?this.context.fillRect(t.x-this.game.camera.x,t.y-this.game.camera.y,t.width,t.height):this.context.strokeRect(t.x-this.game.camera.x,t.y-this.game.camera.y,t.width,t.height):n===r.GEOM_CIRCLE||t instanceof e.Circle?(this.context.beginPath(),this.context.arc(t.x-this.game.camera.x,t.y-this.game.camera.y,t.radius,0,2*Math.PI,!1),this.context.closePath(),s?this.context.fill():this.context.stroke()):n===r.GEOM_POINT||t instanceof e.Point?this.context.fillRect(t.x-this.game.camera.x,t.y-this.game.camera.y,4,4):n===r.GEOM_LINE||t instanceof e.Line?(this.context.beginPath(),this.context.moveTo(t.start.x+.5-this.game.camera.x,t.start.y+.5-this.game.camera.y),this.context.lineTo(t.end.x+.5-this.game.camera.x,t.end.y+.5-this.game.camera.y),this.context.closePath(),this.context.stroke()):(n===r.GEOM_ELLIPSE||t instanceof e.Ellipse)&&(this.context.beginPath(),this.context.ellipse(t.centerX-this.game.camera.x,t.centerY-this.game.camera.y,t.width/2,t.height/2,0,2*Math.PI,!1),this.context.closePath(),s?this.context.fill():this.context.stroke()),this.stop()},rectangle:function(t,e,i){void 0===i&&(i=!0),e=e||"rgba(0, 255, 0, 0.4)",this.start(),i?(this.context.fillStyle=e,this.context.fillRect(t.x-this.game.camera.x,t.y-this.game.camera.y,t.width,t.height)):(this.context.lineWidth=this.lineWidth,this.context.strokeStyle=e,this.context.strokeRect(t.x-this.game.camera.x,t.y-this.game.camera.y,t.width,t.height)),this.stop()},text:function(t,e,i,s,n){s=s||"rgb(255,255,255)",n=n||this.font,this.start(),this.context.font=n,this.renderShadow&&(this.context.fillStyle="rgb(0,0,0)",this.context.fillText(t,e+1,i+1)),this.context.fillStyle=s,this.context.fillText(t,e,i),this.stop()},quadTree:function(t,e){e=e||"rgba(255,0,0,0.3)",this.start();var i=t.bounds;if(0===t.nodes.length){this.context.strokeStyle=e,this.context.strokeRect(i.x,i.y,i.width,i.height),this.text("size: "+t.objects.length,i.x+4,i.y+16,"rgb(0,200,0)","12px Courier"),this.context.strokeStyle="rgb(0,255,0)";for(s=0;s<t.objects.length;s++)this.context.strokeRect(t.objects[s].x,t.objects[s].y,t.objects[s].width,t.objects[s].height)}else for(var s=0;s<t.nodes.length;s++)this.quadTree(t.nodes[s]);this.stop()},body:function(t,i,s){t.body&&(this.start(),t.body.type===e.Physics.ARCADE?e.Physics.Arcade.Body.render(this.context,t.body,i,s,this.lineWidth):t.body.type===e.Physics.NINJA?e.Physics.Ninja.Body.render(this.context,t.body,i,s):t.body.type===e.Physics.BOX2D&&e.Physics.Box2D.renderBody(this.context,t.body,i),this.stop())},bodyInfo:function(t,i,s,n){t.body&&(this.start(i,s,n,210),t.body.type===e.Physics.ARCADE?e.Physics.Arcade.Body.renderBodyInfo(this,t.body):t.body.type===e.Physics.BOX2D&&this.game.physics.box2d.renderBodyInfo(this,t.body),this.stop())},box2dWorld:function(){this.start(),this.context.translate(-this.game.camera.view.x,-this.game.camera.view.y,0),this.game.physics.box2d.renderDebugDraw(this.context),this.stop()},box2dBody:function(t,i){this.start(),e.Physics.Box2D.renderBody(this.context,t,i),this.stop()},displayList:function(t){if(void 0===t&&(t=this.game.world),t.hasOwnProperty("renderOrderID")?console.log("["+t.renderOrderID+"]",t):console.log("[]",t),t.children&&t.children.length>0)for(var e=0;e<t.children.length;e++)this.game.debug.displayList(t.children[e])},renderer:function(t,e,i){var s=this.game.renderer,n=s.renderSession;if(this.start(t,e,i),this.line((s.gl?"WebGL":"Canvas")+" Renderer ("+s.width+" x "+s.height+")"),this.line("autoResize: "+s.autoResize),this.line("clearBeforeRender: "+s.clearBeforeRender),this.line("resolution: "+s.resolution),this.line("transparent: "+s.transparent),this.line("renderSession:"),s.gl){this.line(" currentBatchedTextures: ("+s.currentBatchedTextures.length+")");for(var r=0;r<s.currentBatchedTextures.length;r++)this.line(" "+s.currentBatchedTextures[r]);this.line(" drawCount: "+n.drawCount),this.line(" maxTextures: "+s.maxTextures),this.line(" maxTextureSize: "+s.maxTextureSize),this.line(" maxTextureAvailableSpace: "+n.maxTextureAvailableSpace),this.line(" roundPixels: "+n.roundPixels)}else this.line(" roundPixels: "+n.roundPixels),this.line(" scaleMode: "+(0===n.scaleMode?"LINEAR":1===n.scaleMode?"NEAREST":n.scaleMode));this.stop()},canvasPool:function(t,i,s,n){var r=e.CanvasPool;this.start(t,i,s,n||100),this.line("Canvas Pool"),this.line("Used:",r.getTotal()),this.line("Free:",r.getFree()),this.line("Total:",r.length),this.stop()},physicsGroup:function(t,e,i,s){t.forEach(this.body,this,s,e,i)},phaser:function(t,i,s){this.text("Phaser v"+e.VERSION+" "+(this.game.renderType===e.WEBGL?"WebGL":"Canvas")+" "+(this.game.device.webAudio?"WebAudio":"HTML Audio"),t,i,s,this.font)},scale:function(t,i,s){this.start(t,i,s);var n=this.game.scale,r=n.scaleFactorInversed,o=n._parentBounds,t=" x ";this.line("Game: "+this.game.width+t+this.game.height),this.line("Canvas: "+n.width+t+n.height+" ("+r.x.toFixed(2)+t+r.y.toFixed(2)+") ["+n.aspectRatio.toFixed(2)+"]"),this.line("Mode: "+e.ScaleManager.MODES[n.currentScaleMode]+(n.currentScaleMode===e.ScaleManager.USER_SCALE?" ("+n._userScaleFactor.x+t+n._userScaleFactor.y+")":"")),this.line("Parent: "+(n.parentIsWindow?"window":n.parentNode)+(o.empty?"":" ("+o.width+t+o.height+")")),this.line("Screen: "+n.classifyOrientation(n.screenOrientation)+(n.incorrectOrientation?" (incorrect)":"")),this.stop()},loader:function(t,i,s,n){var r=e.Utils.pad;this.start(i,s,n),t.hasLoaded?this.line("Complete"+(t.resetLocked?" [locked]":"")):t.isLoading?this.line("Loading"):this.line("Not started"),t.hasLoaded&&!t.resetLocked||(this.line("Progress: "+r(t.progress,3)+"%"),this.line("Files: "+t._loadedFileCount+" of "+t._totalFileCount),this.line("Packs: "+t._loadedPackCount+" of "+t._loadedPackCount)),this.stop()},device:function(t,e,i){var s=this.game.device;this.start(t,e,i),this.line("Device"),this.line("Pointer Events: "+s.mspointer),this.line("Touch: "+s.touch),this.line("Web Audio: "+s.webAudio),this.line("WebGL: "+s.webGL),this.stop()},destroy:function(){e.CanvasPool.remove(this)}},e.Utils.Debug.prototype.constructor=e.Utils.Debug,e.DOM={getOffset:function(t,i){i=i||new e.Point;var s=t.getBoundingClientRect(),n=e.DOM.scrollY,r=e.DOM.scrollX,o=document.documentElement.clientTop,a=document.documentElement.clientLeft;return i.x=s.left+r-a,i.y=s.top+n-o,i},getBounds:function(t,e){return void 0===e&&(e=0),!(!(t=t&&!t.nodeType?t[0]:t)||1!==t.nodeType)&&this.calibrate(t.getBoundingClientRect(),e)},calibrate:function(t,e){e=+e||0;var i={width:0,height:0,left:0,right:0,top:0,bottom:0};return i.width=(i.right=t.right+e)-(i.left=t.left-e),i.height=(i.bottom=t.bottom+e)-(i.top=t.top-e),i},getAspectRatio:function(t){var e=(t=null==t?this.visualBounds:1===t.nodeType?this.getBounds(t):t).width,i=t.height;return"function"==typeof e&&(e=e.call(t)),"function"==typeof i&&(i=i.call(t)),e/i},inLayoutViewport:function(t,e){var i=this.getBounds(t,e);return!!i&&i.bottom>=0&&i.right>=0&&i.top<=this.layoutBounds.width&&i.left<=this.layoutBounds.height},getScreenOrientation:function(t){var e=window.screen,i=e.orientation||e.mozOrientation||e.msOrientation;if(i&&"string"==typeof i.type)return i.type;if("string"==typeof i)return i;var s="portrait-primary",n="landscape-primary";if("screen"===t)return e.height>e.width?s:n;if("viewport"===t)return this.visualBounds.height>this.visualBounds.width?s:n;if("window.orientation"===t&&"number"==typeof window.orientation)return 0===window.orientation||180===window.orientation?s:n;if(window.matchMedia){if(window.matchMedia("(orientation: portrait)").matches)return s;if(window.matchMedia("(orientation: landscape)").matches)return n}return this.visualBounds.height>this.visualBounds.width?s:n},visualBounds:new e.Rectangle,layoutBounds:new e.Rectangle,documentBounds:new e.Rectangle},e.Device.whenReady(function(t){var i=window&&"pageXOffset"in window?function(){return window.pageXOffset}:function(){return document.documentElement.scrollLeft},s=window&&"pageYOffset"in window?function(){return window.pageYOffset}:function(){return document.documentElement.scrollTop};if(Object.defineProperty(e.DOM,"scrollX",{get:i}),Object.defineProperty(e.DOM,"scrollY",{get:s}),Object.defineProperty(e.DOM.visualBounds,"x",{get:i}),Object.defineProperty(e.DOM.visualBounds,"y",{get:s}),Object.defineProperty(e.DOM.layoutBounds,"x",{value:0}),Object.defineProperty(e.DOM.layoutBounds,"y",{value:0}),t.desktop&&document.documentElement.clientWidth<=window.innerWidth&&document.documentElement.clientHeight<=window.innerHeight){var n=function(){return Math.max(window.innerWidth,document.documentElement.clientWidth)},r=function(){return Math.max(window.innerHeight,document.documentElement.clientHeight)};Object.defineProperty(e.DOM.visualBounds,"width",{get:n}),Object.defineProperty(e.DOM.visualBounds,"height",{get:r}),Object.defineProperty(e.DOM.layoutBounds,"width",{get:n}),Object.defineProperty(e.DOM.layoutBounds,"height",{get:r})}else Object.defineProperty(e.DOM.visualBounds,"width",{get:function(){return window.innerWidth}}),Object.defineProperty(e.DOM.visualBounds,"height",{get:function(){return window.innerHeight}}),Object.defineProperty(e.DOM.layoutBounds,"width",{get:function(){var t=document.documentElement.clientWidth,e=window.innerWidth;return t<e?e:t}}),Object.defineProperty(e.DOM.layoutBounds,"height",{get:function(){var t=document.documentElement.clientHeight,e=window.innerHeight;return t<e?e:t}});Object.defineProperty(e.DOM.documentBounds,"x",{value:0}),Object.defineProperty(e.DOM.documentBounds,"y",{value:0}),Object.defineProperty(e.DOM.documentBounds,"width",{get:function(){var t=document.documentElement;return Math.max(t.clientWidth,t.offsetWidth,t.scrollWidth)}}),Object.defineProperty(e.DOM.documentBounds,"height",{get:function(){var t=document.documentElement;return Math.max(t.clientHeight,t.offsetHeight,t.scrollHeight)}})},null,!0),e.ArraySet=function(t){this.position=0,this.list=t||[]},e.ArraySet.prototype={add:function(t){return this.exists(t)||this.list.push(t),t},getIndex:function(t){return this.list.indexOf(t)},getByKey:function(t,e){for(var i=this.list.length;i--;)if(this.list[i][t]===e)return this.list[i];return null},exists:function(t){return this.list.indexOf(t)>-1},reset:function(){this.list.length=0},remove:function(t){var e=this.list.indexOf(t);if(e>-1)return this.list.splice(e,1),t},setAll:function(t,e){for(var i=this.list.length;i--;)this.list[i]&&(this.list[i][t]=e)},callAll:function(t){for(var e=Array.prototype.slice.call(arguments,1),i=this.list.length;i--;)this.list[i]&&this.list[i][t]&&this.list[i][t].apply(this.list[i],e)},removeAll:function(t){void 0===t&&(t=!1);for(var e=this.list.length;e--;)if(this.list[e]){var i=this.remove(this.list[e]);t&&i.destroy()}this.position=0,this.list=[]}},Object.defineProperty(e.ArraySet.prototype,"total",{get:function(){return this.list.length}}),Object.defineProperty(e.ArraySet.prototype,"first",{get:function(){return this.position=0,this.list.length>0?this.list[0]:null}}),Object.defineProperty(e.ArraySet.prototype,"next",{get:function(){return this.position<this.list.length?(this.position++,this.list[this.position]):null}}),e.ArraySet.prototype.constructor=e.ArraySet,e.ArrayUtils={getRandomItem:function(t,e,i){if(null===t)return null;void 0===e&&(e=0),void 0===i&&(i=t.length);var s=e+Math.floor(Math.random()*i);return void 0===t[s]?null:t[s]},removeRandomItem:function(t,e,i){if(null==t)return null;void 0===e&&(e=0),void 0===i&&(i=t.length);var s=e+Math.floor(Math.random()*i);if(s<t.length){var n=t.splice(s,1);return void 0===n[0]?null:n[0]}return null},remove:function(t,e,i){var s=t.length;if(!(e>=s||0===i)){null==i&&(i=1);for(var n=s-i,r=e;r<n;++r)t[r]=t[r+i];t.length=n}},shuffle:function(t){for(var e=t.length-1;e>0;e--){var i=Math.floor(Math.random()*(e+1)),s=t[e];t[e]=t[i],t[i]=s}return t},transposeMatrix:function(t){for(var e=t.length,i=t[0].length,s=new Array(i),n=0;n<i;n++){s[n]=new Array(e);for(var r=e-1;r>-1;r--)s[n][r]=t[r][n]}return s},rotateMatrix:function(t,i){if("string"!=typeof i&&(i=(i%360+360)%360),90===i||-270===i||"rotateLeft"===i)t=(t=e.ArrayUtils.transposeMatrix(t)).reverse();else if(-90===i||270===i||"rotateRight"===i)t=t.reverse(),t=e.ArrayUtils.transposeMatrix(t);else if(180===Math.abs(i)||"rotate180"===i){for(var s=0;s<t.length;s++)t[s].reverse();t=t.reverse()}return t},findClosest:function(t,e){if(!e.length)return NaN;if(1===e.length||t<e[0])return e[0];for(var i=1;e[i]<t;)i++;var s=e[i-1],n=i<e.length?e[i]:Number.POSITIVE_INFINITY;return n-t<=t-s?n:s},rotateRight:function(t){var e=t.pop();return t.unshift(e),e},rotateLeft:function(t){var e=t.shift();return t.push(e),e},numberArray:function(t,e){void 0!==e&&null!==e||(e=t,t=0);for(var i=[],s=t;s<=e;s++)i.push(s);return i},numberArrayStep:function(t,i,s){void 0!==t&&null!==t||(t=0),void 0!==i&&null!==i||(i=t,t=0),void 0===s&&(s=1);for(var n=[],r=Math.max(e.Math.roundAwayFromZero((i-t)/(s||1)),0),o=0;o<r;o++)n.push(t),t+=s;return n}},e.LinkedList=function(){this.next=null,this.prev=null,this.first=null,this.last=null,this.total=0},e.LinkedList.prototype={add:function(t){return 0===this.total&&null===this.first&&null===this.last?(this.first=t,this.last=t,this.next=t,t.prev=this,this.total++,t):(this.last.next=t,t.prev=this.last,this.last=t,this.total++,t)},reset:function(){this.first=null,this.last=null,this.next=null,this.prev=null,this.total=0},remove:function(t){if(1===this.total)return this.reset(),void(t.next=t.prev=null);t===this.first?this.first=this.first.next:t===this.last&&(this.last=this.last.prev),t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),t.next=t.prev=null,null===this.first&&(this.last=null),this.total--},callAll:function(t){if(this.first&&this.last){var e=this.first;do{e&&e[t]&&e[t].call(e),e=e.next}while(e!==this.last.next)}}},e.LinkedList.prototype.constructor=e.LinkedList,e.Create=function(t){this.game=t,this.bmd=null,this.canvas=null,this.ctx=null,this.palettes=[{0:"#000",1:"#9D9D9D",2:"#FFF",3:"#BE2633",4:"#E06F8B",5:"#493C2B",6:"#A46422",7:"#EB8931",8:"#F7E26B",9:"#2F484E",A:"#44891A",B:"#A3CE27",C:"#1B2632",D:"#005784",E:"#31A2F2",F:"#B2DCEF"},{0:"#000",1:"#191028",2:"#46af45",3:"#a1d685",4:"#453e78",5:"#7664fe",6:"#833129",7:"#9ec2e8",8:"#dc534b",9:"#e18d79",A:"#d6b97b",B:"#e9d8a1",C:"#216c4b",D:"#d365c8",E:"#afaab9",F:"#f5f4eb"},{0:"#000",1:"#2234d1",2:"#0c7e45",3:"#44aacc",4:"#8a3622",5:"#5c2e78",6:"#aa5c3d",7:"#b5b5b5",8:"#5e606e",9:"#4c81fb",A:"#6cd947",B:"#7be2f9",C:"#eb8a60",D:"#e23d69",E:"#ffd93f",F:"#fff"},{0:"#000",1:"#fff",2:"#8b4131",3:"#7bbdc5",4:"#8b41ac",5:"#6aac41",6:"#3931a4",7:"#d5de73",8:"#945a20",9:"#5a4100",A:"#bd736a",B:"#525252",C:"#838383",D:"#acee8b",E:"#7b73de",F:"#acacac"},{0:"#000",1:"#191028",2:"#46af45",3:"#a1d685",4:"#453e78",5:"#7664fe",6:"#833129",7:"#9ec2e8",8:"#dc534b",9:"#e18d79",A:"#d6b97b",B:"#e9d8a1",C:"#216c4b",D:"#d365c8",E:"#afaab9",F:"#fff"}]},e.Create.PALETTE_ARNE=0,e.Create.PALETTE_JMP=1,e.Create.PALETTE_CGA=2,e.Create.PALETTE_C64=3,e.Create.PALETTE_JAPANESE_MACHINE=4,e.Create.prototype={texture:function(t,e,i,s,n,r,o,a){void 0===i&&(i=8),void 0===s&&(s=i),void 0===n&&(n=0),void 0===r&&(r=!0);var h=e[0].length*i,l=e.length*s;null===this.bmd&&(this.bmd=this.game.make.bitmapData(),this.canvas=this.bmd.canvas,this.ctx=this.bmd.context),this.bmd.resize(h,l),this.bmd.clear();for(var c=0;c<e.length;c++)for(var u=e[c],d=0;d<u.length;d++){var p=u[d];"."!==p&&" "!==p&&(this.ctx.fillStyle=this.palettes[n][p],this.ctx.fillRect(d*i,c*s,i,s))}return r?this.bmd.generateTexture(t,o,a):this.copy()},grid:function(t,e,i,s,n,r,o,a,h){void 0===o&&(o=!0),null===this.bmd&&(this.bmd=this.game.make.bitmapData(),this.canvas=this.bmd.canvas,this.ctx=this.bmd.context),this.bmd.resize(e,i),this.ctx.fillStyle=r;for(var l=0;l<i;l+=n)this.ctx.fillRect(0,l,e,1);for(var c=0;c<e;c+=s)this.ctx.fillRect(c,0,1,i);return o?this.bmd.generateTexture(t,a,h):this.copy()},copy:function(t,e,i,s,n,r,o){return null==t&&(t=this.game.make.bitmapData()),t.resize(this.bmd.width,this.bmd.height),t.draw(this.bmd,e,i,s,n,r,o)}},e.Create.prototype.constructor=e.Create,e.FlexGrid=function(t,i,s){this.game=t.game,this.manager=t,this.width=i,this.height=s,this.boundsCustom=new e.Rectangle(0,0,i,s),this.boundsFluid=new e.Rectangle(0,0,i,s),this.boundsFull=new e.Rectangle(0,0,i,s),this.boundsNone=new e.Rectangle(0,0,i,s),this.positionCustom=new e.Point(0,0),this.positionFluid=new e.Point(0,0),this.positionFull=new e.Point(0,0),this.positionNone=new e.Point(0,0),this.scaleCustom=new e.Point(1,1),this.scaleFluid=new e.Point(1,1),this.scaleFluidInversed=new e.Point(1,1),this.scaleFull=new e.Point(1,1),this.scaleNone=new e.Point(1,1),this.customWidth=0,this.customHeight=0,this.customOffsetX=0,this.customOffsetY=0,this.ratioH=i/s,this.ratioV=s/i,this.multiplier=0,this.layers=[]},e.FlexGrid.prototype={setSize:function(t,i){this.width=t,this.height=i,this.ratioH=t/i,this.ratioV=i/t,this.scaleNone=new e.Point(1,1),this.boundsNone.width=this.width,this.boundsNone.height=this.height,this.refresh()},createCustomLayer:function(t,i,s,n){void 0===n&&(n=!0),this.customWidth=t,this.customHeight=i,this.boundsCustom.width=t,this.boundsCustom.height=i;var r=new e.FlexLayer(this,this.positionCustom,this.boundsCustom,this.scaleCustom);return n&&this.game.world.add(r),this.layers.push(r),s&&r.addMultiple(s),r},createFluidLayer:function(t,i){void 0===i&&(i=!0);var s=new e.FlexLayer(this,this.positionFluid,this.boundsFluid,this.scaleFluid);return i&&this.game.world.add(s),this.layers.push(s),t&&s.addMultiple(t),s},createFullLayer:function(t){var i=new e.FlexLayer(this,this.positionFull,this.boundsFull,this.scaleFluid);return this.game.world.add(i),this.layers.push(i),void 0!==t&&i.addMultiple(t),i},createFixedLayer:function(t){var i=new e.FlexLayer(this,this.positionNone,this.boundsNone,this.scaleNone);return this.game.world.add(i),this.layers.push(i),void 0!==t&&i.addMultiple(t),i},reset:function(){for(var t=this.layers.length;t--;)this.layers[t].persist||(this.layers[t].position=null,this.layers[t].scale=null,this.layers.slice(t,1))},onResize:function(t,e){this.ratioH=t/e,this.ratioV=e/t,this.refresh(t,e)},refresh:function(){this.multiplier=Math.min(this.manager.height/this.height,this.manager.width/this.width),this.boundsFluid.width=Math.round(this.width*this.multiplier),this.boundsFluid.height=Math.round(this.height*this.multiplier),this.scaleFluid.set(this.boundsFluid.width/this.width,this.boundsFluid.height/this.height),this.scaleFluidInversed.set(this.width/this.boundsFluid.width,this.height/this.boundsFluid.height),this.scaleFull.set(this.boundsFull.width/this.width,this.boundsFull.height/this.height),this.boundsFull.width=Math.round(this.manager.width*this.scaleFluidInversed.x),this.boundsFull.height=Math.round(this.manager.height*this.scaleFluidInversed.y),this.boundsFluid.centerOn(this.manager.bounds.centerX,this.manager.bounds.centerY),this.boundsNone.centerOn(this.manager.bounds.centerX,this.manager.bounds.centerY),this.positionFluid.set(this.boundsFluid.x,this.boundsFluid.y),this.positionNone.set(this.boundsNone.x,this.boundsNone.y)},fitSprite:function(t){this.manager.scaleSprite(t),t.x=this.manager.bounds.centerX,t.y=this.manager.bounds.centerY},debug:function(){this.game.debug.text(this.boundsFluid.width+" x "+this.boundsFluid.height,this.boundsFluid.x+4,this.boundsFluid.y+16),this.game.debug.geom(this.boundsFluid,"rgba(255,0,0,0.9",!1)}},e.FlexGrid.prototype.constructor=e.FlexGrid,e.FlexLayer=function(t,i,s,n){e.Group.call(this,t.game,null,"__flexLayer"+t.game.rnd.uuid(),!1),this.manager=t.manager,this.grid=t,this.persist=!1,this.position=i,this.bounds=s,this.scale=n,this.topLeft=s.topLeft,this.topMiddle=new e.Point(s.halfWidth,0),this.topRight=s.topRight,this.bottomLeft=s.bottomLeft,this.bottomMiddle=new e.Point(s.halfWidth,s.bottom),this.bottomRight=s.bottomRight},e.FlexLayer.prototype=Object.create(e.Group.prototype),e.FlexLayer.prototype.constructor=e.FlexLayer,e.FlexLayer.prototype.resize=function(){},e.FlexLayer.prototype.debug=function(){this.game.debug.text(this.bounds.width+" x "+this.bounds.height,this.bounds.x+4,this.bounds.y+16),this.game.debug.geom(this.bounds,"rgba(0,0,255,0.9",!1),this.game.debug.geom(this.topLeft,"rgba(255,255,255,0.9"),this.game.debug.geom(this.topMiddle,"rgba(255,255,255,0.9"),this.game.debug.geom(this.topRight,"rgba(255,255,255,0.9")},e.Color={RED:16711680,ORANGE:16750848,YELLOW:16776960,GREEN:65280,AQUA:65535,BLUE:255,VIOLET:16711935,WHITE:16777215,BLACK:0,GRAY:6710886,packPixel:function(t,i,s,n){return e.Device.LITTLE_ENDIAN?(n<<24|s<<16|i<<8|t)>>>0:(t<<24|i<<16|s<<8|n)>>>0},unpackPixel:function(t,i,s,n){return void 0!==i&&null!==i||(i=e.Color.createColor()),void 0!==s&&null!==s||(s=!1),void 0!==n&&null!==n||(n=!1),e.Device.LITTLE_ENDIAN?(i.a=(4278190080&t)>>>24,i.b=(16711680&t)>>>16,i.g=(65280&t)>>>8,i.r=255&t):(i.r=(4278190080&t)>>>24,i.g=(16711680&t)>>>16,i.b=(65280&t)>>>8,i.a=255&t),i.color=t,i.rgba="rgba("+i.r+","+i.g+","+i.b+","+i.a/255+")",s&&e.Color.RGBtoHSL(i.r,i.g,i.b,i),n&&e.Color.RGBtoHSV(i.r,i.g,i.b,i),i},fromRGBA:function(t,i){return i||(i=e.Color.createColor()),i.r=(4278190080&t)>>>24,i.g=(16711680&t)>>>16,i.b=(65280&t)>>>8,i.a=255&t,i.rgba="rgba("+i.r+","+i.g+","+i.b+","+i.a+")",i},toRGBA:function(t,e,i,s){return t<<24|e<<16|i<<8|s},toABGR:function(t,e,i,s){return(s<<24|i<<16|e<<8|t)>>>0},hexToRGBArray:function(t){return[(t>>16&255)/255,(t>>8&255)/255,(255&t)/255]},RGBArrayToHex:function(t){return(255*t[0]<<16)+(255*t[1]<<8)+255*t[2]},RGBtoHSL:function(t,i,s,n){n||(n=e.Color.createColor(t,i,s,1)),t/=255,i/=255,s/=255;var r=Math.min(t,i,s),o=Math.max(t,i,s);if(n.h=0,n.s=0,n.l=(o+r)/2,o!==r){var a=o-r;n.s=n.l>.5?a/(2-o-r):a/(o+r),o===t?n.h=(i-s)/a+(i<s?6:0):o===i?n.h=(s-t)/a+2:o===s&&(n.h=(t-i)/a+4),n.h/=6}return n},HSLtoRGB:function(t,i,s,n){if(n?(n.r=s,n.g=s,n.b=s):n=e.Color.createColor(s,s,s),0!==i){var r=s<.5?s*(1+i):s+i-s*i,o=2*s-r;n.r=e.Color.hueToColor(o,r,t+1/3),n.g=e.Color.hueToColor(o,r,t),n.b=e.Color.hueToColor(o,r,t-1/3)}return n.r=Math.floor(255*n.r|0),n.g=Math.floor(255*n.g|0),n.b=Math.floor(255*n.b|0),e.Color.updateColor(n),n},RGBtoHSV:function(t,i,s,n){n||(n=e.Color.createColor(t,i,s,255)),t/=255,i/=255,s/=255;var r=Math.min(t,i,s),o=Math.max(t,i,s),a=o-r;return n.h=0,n.s=0===o?0:a/o,n.v=o,o!==r&&(o===t?n.h=(i-s)/a+(i<s?6:0):o===i?n.h=(s-t)/a+2:o===s&&(n.h=(t-i)/a+4),n.h/=6),n},HSVtoRGB:function(t,i,s,n){void 0===n&&(n=e.Color.createColor(0,0,0,1,t,i,0,s));var r,o,a,h=Math.floor(6*t),l=6*t-h,c=s*(1-i),u=s*(1-l*i),d=s*(1-(1-l)*i);switch(h%6){case 0:r=s,o=d,a=c;break;case 1:r=u,o=s,a=c;break;case 2:r=c,o=s,a=d;break;case 3:r=c,o=u,a=s;break;case 4:r=d,o=c,a=s;break;case 5:r=s,o=c,a=u}return n.r=Math.floor(255*r),n.g=Math.floor(255*o),n.b=Math.floor(255*a),e.Color.updateColor(n),n},hueToColor:function(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t},createColor:function(t,i,s,n,r,o,a,h){var l={r:t||0,g:i||0,b:s||0,a:n||1,h:r||0,s:o||0,l:a||0,v:h||0,color:0,color32:0,rgba:""};return e.Color.updateColor(l)},updateColor:function(t){return t.rgba="rgba("+t.r.toFixed()+","+t.g.toFixed()+","+t.b.toFixed()+","+t.a.toString()+")",t.color=e.Color.getColor(t.r,t.g,t.b),t.color32=e.Color.getColor32(255*t.a,t.r,t.g,t.b),t},getColor32:function(t,e,i,s){return t<<24|e<<16|i<<8|s},getColor:function(t,e,i){return t<<16|e<<8|i},RGBtoString:function(t,i,s,n,r){return void 0===n&&(n=255),void 0===r&&(r="#"),"#"===r?"#"+((1<<24)+(t<<16)+(i<<8)+s).toString(16).slice(1):"0x"+e.Color.componentToHex(n)+e.Color.componentToHex(t)+e.Color.componentToHex(i)+e.Color.componentToHex(s)},hexToRGB:function(t){var i=e.Color.hexToColor(t);if(i)return e.Color.getColor32(i.a,i.r,i.g,i.b)},hexToColor:function(t,i){t=t.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i,function(t,e,i,s){return e+e+i+i+s+s});var s=/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);if(s){var n=parseInt(s[1],16),r=parseInt(s[2],16),o=parseInt(s[3],16);i?(i.r=n,i.g=r,i.b=o):i=e.Color.createColor(n,r,o)}return i},webToColor:function(t,i){i||(i=e.Color.createColor());var s=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(t);return s&&(i.r=~~Number(s[1]),i.g=~~Number(s[2]),i.b=~~Number(s[3]),i.a=void 0!==s[4]?Number(s[4]):1,e.Color.updateColor(i)),i},valueToColor:function(t,i){if(i||(i=e.Color.createColor()),"string"==typeof t)return 0===t.indexOf("rgb")?e.Color.webToColor(t,i):(i.a=1,e.Color.hexToColor(t,i));if("number"==typeof t){var s=e.Color.getRGB(t);return i.r=s.r,i.g=s.g,i.b=s.b,i.a=s.a/255,i}return i},componentToHex:function(t){var e=t.toString(16);return 1===e.length?"0"+e:e},HSVColorWheel:function(t,i){void 0===t&&(t=1),void 0===i&&(i=1);for(var s=[],n=0;n<=359;n++)s.push(e.Color.HSVtoRGB(n/359,t,i));return s},HSLColorWheel:function(t,i){void 0===t&&(t=.5),void 0===i&&(i=.5);for(var s=[],n=0;n<=359;n++)s.push(e.Color.HSLtoRGB(n/359,t,i));return s},interpolateColor:function(t,i,s,n,r,o){void 0===r&&(r=255),void 0===o&&(o=0);var a=e.Color.getRGB(t),h=e.Color.getRGB(i);if(0===o)var l=(h.red-a.red)*n/s+a.red,c=(h.green-a.green)*n/s+a.green,u=(h.blue-a.blue)*n/s+a.blue;if(1===o){var d,p=e.Color.RGBtoHSV(a.r,a.g,a.b),f=e.Color.RGBtoHSV(h.r,h.g,h.b),g=f.h-p.h;if(p.h>f.h){var m=f.h;f.h=p.h,p.h=m,g=-g,n=s-n}g>.5&&(p.h=p.h+1,d=((f.h-p.h)*n/s+p.h)%1),g<=.5&&(d=(f.h-p.h)*n/s+p.h);var y=(f.s-p.s)*n/s+p.s,v=(f.v-p.v)*n/s+p.v,x=e.Color.HSVtoRGB(d,y,v,x),l=x.r,c=x.g,u=x.b}return e.Color.getColor32(r,l,c,u)},interpolateColorWithRGB:function(t,i,s,n,r,o){var a=e.Color.getRGB(t),h=(i-a.red)*o/r+a.red,l=(s-a.green)*o/r+a.green,c=(n-a.blue)*o/r+a.blue;return e.Color.getColor(h,l,c)},interpolateRGB:function(t,i,s,n,r,o,a,h){var l=(n-t)*h/a+t,c=(r-i)*h/a+i,u=(o-s)*h/a+s;return e.Color.getColor(l,c,u)},linear:function(t,e,i){return this.interpolateColor(t,e,1,i)},linearInterpolation:function(t,i){var s=e.Math.linear(0,t.length-1,i),n=t[Math.floor(s)],r=t[Math.ceil(s)];return this.linear(n,r,s%1)},getRandomColor:function(t,i,s){if(void 0===t&&(t=0),void 0===i&&(i=255),void 0===s&&(s=255),i>255||t>i)return e.Color.getColor(255,255,255);var n=t+Math.round(Math.random()*(i-t)),r=t+Math.round(Math.random()*(i-t)),o=t+Math.round(Math.random()*(i-t));return e.Color.getColor32(s,n,r,o)},getRGB:function(t){return t>16777215?{alpha:t>>>24,red:t>>16&255,green:t>>8&255,blue:255&t,a:t>>>24,r:t>>16&255,g:t>>8&255,b:255&t}:{alpha:255,red:t>>16&255,green:t>>8&255,blue:255&t,a:255,r:t>>16&255,g:t>>8&255,b:255&t}},getWebRGB:function(t){if("object"==typeof t)return"rgba("+t.r.toString()+","+t.g.toString()+","+t.b.toString()+","+(t.a/255).toString()+")";var i=e.Color.getRGB(t);return"rgba("+i.r.toString()+","+i.g.toString()+","+i.b.toString()+","+(i.a/255).toString()+")"},getAlpha:function(t){return t>>>24},getAlphaFloat:function(t){return(t>>>24)/255},getRed:function(t){return t>>16&255},getGreen:function(t){return t>>8&255},getBlue:function(t){return 255&t},blendNormal:function(t){return t},blendLighten:function(t,e){return e>t?e:t},blendDarken:function(t,e){return e>t?t:e},blendMultiply:function(t,e){return t*e/255},blendAverage:function(t,e){return(t+e)/2},blendAdd:function(t,e){return Math.min(255,t+e)},blendSubtract:function(t,e){return Math.max(0,t+e-255)},blendDifference:function(t,e){return Math.abs(t-e)},blendNegation:function(t,e){return 255-Math.abs(255-t-e)},blendScreen:function(t,e){return 255-((255-t)*(255-e)>>8)},blendExclusion:function(t,e){return t+e-2*t*e/255},blendOverlay:function(t,e){return e<128?2*t*e/255:255-2*(255-t)*(255-e)/255},blendSoftLight:function(t,e){return e<128?2*(64+(t>>1))*(e/255):255-2*(255-(64+(t>>1)))*(255-e)/255},blendHardLight:function(t,i){return e.Color.blendOverlay(i,t)},blendColorDodge:function(t,e){return 255===e?e:Math.min(255,(t<<8)/(255-e))},blendColorBurn:function(t,e){return 0===e?e:Math.max(0,255-(255-t<<8)/e)},blendLinearDodge:function(t,i){return e.Color.blendAdd(t,i)},blendLinearBurn:function(t,i){return e.Color.blendSubtract(t,i)},blendLinearLight:function(t,i){return i<128?e.Color.blendLinearBurn(t,2*i):e.Color.blendLinearDodge(t,2*(i-128))},blendVividLight:function(t,i){return i<128?e.Color.blendColorBurn(t,2*i):e.Color.blendColorDodge(t,2*(i-128))},blendPinLight:function(t,i){return i<128?e.Color.blendDarken(t,2*i):e.Color.blendLighten(t,2*(i-128))},blendHardMix:function(t,i){return e.Color.blendVividLight(t,i)<128?0:255},blendReflect:function(t,e){return 255===e?e:Math.min(255,t*t/(255-e))},blendGlow:function(t,i){return e.Color.blendReflect(i,t)},blendPhoenix:function(t,e){return Math.min(t,e)-Math.max(t,e)+255}},e.Physics=function(t,e){e=e||{},this.game=t,this.config=e,this.arcade=null,this.p2=null,this.ninja=null,this.box2d=null,this.chipmunk=null,this.matter=null,this.parseConfig()},e.Physics.ARCADE=0,e.Physics.P2JS=1,e.Physics.NINJA=2,e.Physics.BOX2D=3,e.Physics.CHIPMUNK=4,e.Physics.MATTERJS=5,e.Physics.prototype={parseConfig:function(){this.config.hasOwnProperty("arcade")&&!0!==this.config.arcade||!e.Physics.hasOwnProperty("Arcade")||(this.arcade=new e.Physics.Arcade(this.game)),this.config.hasOwnProperty("ninja")&&!0===this.config.ninja&&e.Physics.hasOwnProperty("Ninja")&&(this.ninja=new e.Physics.Ninja(this.game)),this.config.hasOwnProperty("p2")&&!0===this.config.p2&&e.Physics.hasOwnProperty("P2")&&(this.p2=new e.Physics.P2(this.game,this.config)),this.config.hasOwnProperty("box2d")&&!0===this.config.box2d&&e.Physics.hasOwnProperty("BOX2D")&&(this.box2d=new e.Physics.Box2D(this.game,this.config)),this.config.hasOwnProperty("matter")&&!0===this.config.matter&&e.Physics.hasOwnProperty("Matter")&&(this.matter=new e.Physics.Matter(this.game,this.config))},startSystem:function(t){t===e.Physics.ARCADE?this.arcade=new e.Physics.Arcade(this.game):t===e.Physics.P2JS?null===this.p2?this.p2=new e.Physics.P2(this.game,this.config):this.p2.reset():t===e.Physics.NINJA?this.ninja=new e.Physics.Ninja(this.game):t===e.Physics.BOX2D?null===this.box2d?this.box2d=new e.Physics.Box2D(this.game,this.config):this.box2d.reset():t===e.Physics.MATTERJS&&(null===this.matter?this.matter=new e.Physics.Matter(this.game,this.config):this.matter.reset())},enable:function(t,i,s){void 0===i&&(i=e.Physics.ARCADE),void 0===s&&(s=!1),i===e.Physics.ARCADE?this.arcade.enable(t):i===e.Physics.P2JS&&this.p2?this.p2.enable(t,s):i===e.Physics.NINJA&&this.ninja?this.ninja.enableAABB(t):i===e.Physics.BOX2D&&this.box2d?this.box2d.enable(t):i===e.Physics.MATTERJS&&this.matter?this.matter.enable(t):console.warn(t.key+" is attempting to enable a physics body using an unknown physics system.")},preUpdate:function(){this.p2&&this.p2.preUpdate(),this.box2d&&this.box2d.preUpdate(),this.matter&&this.matter.preUpdate()},update:function(){this.p2&&this.p2.update(),this.box2d&&this.box2d.update(),this.matter&&this.matter.update()},setBoundsToWorld:function(){this.arcade&&this.arcade.setBoundsToWorld(),this.ninja&&this.ninja.setBoundsToWorld(),this.p2&&this.p2.setBoundsToWorld(),this.box2d&&this.box2d.setBoundsToWorld(),this.matter&&this.matter.setBoundsToWorld()},clear:function(){this.p2&&this.p2.clear(),this.box2d&&this.box2d.clear(),this.matter&&this.matter.clear()},reset:function(){this.p2&&this.p2.reset(),this.box2d&&this.box2d.reset(),this.matter&&this.matter.reset()},destroy:function(){this.p2&&this.p2.destroy(),this.box2d&&this.box2d.destroy(),this.matter&&this.matter.destroy(),this.arcade=null,this.ninja=null,this.p2=null,this.box2d=null,this.matter=null}},e.Physics.prototype.constructor=e.Physics,e.Physics.Arcade=function(t){this.game=t,this.gravity=new e.Point,this.bounds=new e.Rectangle(0,0,t.world.width,t.world.height),this.checkCollision={up:!0,down:!0,left:!0,right:!0},this.maxObjects=10,this.maxLevels=4,this.OVERLAP_BIAS=4,this.forceX=!1,this.sortDirection=e.Physics.Arcade.LEFT_RIGHT,this.skipQuadTree=!0,this.isPaused=!1,this.quadTree=new e.QuadTree(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels),this._total=0,this.setBoundsToWorld()},e.Physics.Arcade.prototype.constructor=e.Physics.Arcade,e.Physics.Arcade.SORT_NONE=0,e.Physics.Arcade.LEFT_RIGHT=1,e.Physics.Arcade.RIGHT_LEFT=2,e.Physics.Arcade.TOP_BOTTOM=3,e.Physics.Arcade.BOTTOM_TOP=4,e.Physics.Arcade.prototype={setBounds:function(t,e,i,s){this.bounds.setTo(t,e,i,s)},setBoundsToWorld:function(){this.bounds.copyFrom(this.game.world.bounds)},enable:function(t,i){void 0===i&&(i=!0);var s=1;if(Array.isArray(t))for(s=t.length;s--;)t[s]instanceof e.Group?this.enable(t[s].children,i):(this.enableBody(t[s]),i&&t[s].hasOwnProperty("children")&&t[s].children.length>0&&this.enable(t[s],!0));else t instanceof e.Group?this.enable(t.children,i):(this.enableBody(t),i&&t.hasOwnProperty("children")&&t.children.length>0&&this.enable(t.children,!0))},enableBody:function(t){t.hasOwnProperty("body")&&null===t.body&&(t.body=new e.Physics.Arcade.Body(t),t.parent&&t.parent instanceof e.Group&&t.parent.addToHash(t))},updateMotion:function(t){if(t.allowRotation){var e=this.computeVelocity(0,t,t.angularVelocity,t.angularAcceleration,t.angularDrag,t.maxAngular)-t.angularVelocity;t.angularVelocity+=e,t.rotation+=t.angularVelocity*this.game.time.physicsElapsed}t.velocity.x=this.computeVelocity(1,t,t.velocity.x,t.acceleration.x,t.drag.x,t.maxVelocity.x),t.velocity.y=this.computeVelocity(2,t,t.velocity.y,t.acceleration.y,t.drag.y,t.maxVelocity.y)},computeVelocity:function(t,e,i,s,n,r){return void 0===r&&(r=1e4),1===t&&e.allowGravity?i+=(this.gravity.x+e.gravity.x)*this.game.time.physicsElapsed:2===t&&e.allowGravity&&(i+=(this.gravity.y+e.gravity.y)*this.game.time.physicsElapsed),s?i+=s*this.game.time.physicsElapsed:n&&e.allowDrag&&(i-(n*=this.game.time.physicsElapsed)>0?i-=n:i+n<0?i+=n:i=0),i>r?i=r:i<-r&&(i=-r),i},overlap:function(t,e,i,s,n){return i=i||null,s=s||null,n=n||i,this._total=0,this.collideObjects(t,e,i,s,n,!0),this._total>0},collide:function(t,e,i,s,n){return i=i||null,s=s||null,n=n||i,this._total=0,this.collideObjects(t,e,i,s,n,!1),this._total>0},sortLeftRight:function(t,e){return t.body&&e.body?t.body.x-e.body.x:0},sortRightLeft:function(t,e){return t.body&&e.body?e.body.x-t.body.x:0},sortTopBottom:function(t,e){return t.body&&e.body?t.body.y-e.body.y:0},sortBottomTop:function(t,e){return t.body&&e.body?e.body.y-t.body.y:0},sort:function(t,i){null!==t.physicsSortDirection?i=t.physicsSortDirection:void 0===i&&(i=this.sortDirection),i===e.Physics.Arcade.LEFT_RIGHT?t.hash.sort(this.sortLeftRight):i===e.Physics.Arcade.RIGHT_LEFT?t.hash.sort(this.sortRightLeft):i===e.Physics.Arcade.TOP_BOTTOM?t.hash.sort(this.sortTopBottom):i===e.Physics.Arcade.BOTTOM_TOP&&t.hash.sort(this.sortBottomTop)},collideObjects:function(t,e,i,s,n,r){if(!Array.isArray(t)&&Array.isArray(e))for(o=0;o<e.length;o++)e[o]&&this.collideHandler(t,e[o],i,s,n,r);else if(Array.isArray(t)&&!Array.isArray(e))for(o=0;o<t.length;o++)t[o]&&this.collideHandler(t[o],e,i,s,n,r);else if(Array.isArray(t)&&Array.isArray(e)){for(var o=0;o<t.length;o++)if(t[o])for(var a=0;a<e.length;a++)e[a]&&this.collideHandler(t[o],e[a],i,s,n,r)}else this.collideHandler(t,e,i,s,n,r)},collideHandler:function(t,i,s,n,r,o){if(void 0===i&&t.physicsType===e.GROUP)return this.sort(t),void this.collideGroupVsSelf(t,s,n,r,o);t&&i&&t.exists&&i.exists&&(this.sortDirection!==e.Physics.Arcade.SORT_NONE&&(t.physicsType===e.GROUP&&this.sort(t),i.physicsType===e.GROUP&&this.sort(i)),t.physicsType===e.SPRITE?i.physicsType===e.SPRITE?this.collideSpriteVsSprite(t,i,s,n,r,o):i.physicsType===e.GROUP?this.collideSpriteVsGroup(t,i,s,n,r,o):i.physicsType===e.TILEMAPLAYER&&this.collideSpriteVsTilemapLayer(t,i,s,n,r,o):t.physicsType===e.GROUP?i.physicsType===e.SPRITE?this.collideSpriteVsGroup(i,t,s,n,r,o):i.physicsType===e.GROUP?this.collideGroupVsGroup(t,i,s,n,r,o):i.physicsType===e.TILEMAPLAYER&&this.collideGroupVsTilemapLayer(t,i,s,n,r,o):t.physicsType===e.TILEMAPLAYER&&(i.physicsType===e.SPRITE?this.collideSpriteVsTilemapLayer(i,t,s,n,r,o):i.physicsType===e.GROUP&&this.collideGroupVsTilemapLayer(i,t,s,n,r,o)))},collideSpriteVsSprite:function(t,e,i,s,n,r){return!(!t.body||!e.body)&&(this.separate(t.body,e.body,s,n,r)&&(i&&i.call(n,t,e),this._total++),!0)},collideSpriteVsGroup:function(t,i,s,n,r,o){if(0!==i.length&&t.body)if(this.skipQuadTree||t.body.skipQuadTree)for(var a={},h=0;h<i.hash.length;h++){var l=i.hash[h];if(l&&l.exists&&l.body){if(a=l.body.getBounds(a),this.sortDirection===e.Physics.Arcade.LEFT_RIGHT){if(t.body.right<a.x)break;if(a.right<t.body.x)continue}else if(this.sortDirection===e.Physics.Arcade.RIGHT_LEFT){if(t.body.x>a.right)break;if(a.x>t.body.right)continue}else if(this.sortDirection===e.Physics.Arcade.TOP_BOTTOM){if(t.body.bottom<a.y)break;if(a.bottom<t.body.y)continue}else if(this.sortDirection===e.Physics.Arcade.BOTTOM_TOP){if(t.body.y>a.bottom)break;if(a.y>t.body.bottom)continue}this.collideSpriteVsSprite(t,l,s,n,r,o)}}else{this.quadTree.clear(),this.quadTree.reset(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels),this.quadTree.populate(i);for(var c=this.quadTree.retrieve(t),h=0;h<c.length;h++)this.separate(t.body,c[h],n,r,o)&&(s&&s.call(r,t,c[h].sprite),this._total++)}},collideGroupVsSelf:function(t,i,s,n,r){if(0!==t.length)for(var o=0;o<t.hash.length;o++){var a={},h=t.hash[o];if(h&&h.exists&&h.body){a=h.body.getBounds(a);for(var l=o+1;l<t.hash.length;l++){var c={},u=t.hash[l];if(u&&u.exists&&u.body){if(c=u.body.getBounds(c),this.sortDirection===e.Physics.Arcade.LEFT_RIGHT){if(a.right<c.x)break;if(c.right<a.x)continue}else if(this.sortDirection===e.Physics.Arcade.RIGHT_LEFT){if(a.x>c.right)continue;if(c.x>a.right)break}else if(this.sortDirection===e.Physics.Arcade.TOP_BOTTOM){if(a.bottom<c.y)continue;if(c.bottom<a.y)break}else if(this.sortDirection===e.Physics.Arcade.BOTTOM_TOP){if(a.y>c.bottom)continue;if(c.y>h.body.bottom)break}this.collideSpriteVsSprite(h,u,i,s,n,r)}}}}},collideGroupVsGroup:function(t,i,s,n,r,o){if(0!==t.length&&0!==i.length)for(var a=0;a<t.children.length;a++)t.children[a].exists&&(t.children[a].physicsType===e.GROUP?this.collideGroupVsGroup(t.children[a],i,s,n,r,o):this.collideSpriteVsGroup(t.children[a],i,s,n,r,o))},separate:function(t,e,i,s,n){if(!t.enable||!e.enable||t.checkCollision.none||e.checkCollision.none||!this.intersects(t,e))return!1;if(i&&!1===i.call(s,t.sprite,e.sprite))return!1;if(t.isCircle&&e.isCircle)return this.separateCircle(t,e,n);if(t.isCircle!==e.isCircle){var r=t.isCircle?e:t,o=t.isCircle?t:e,a={x:r.x,y:r.y,right:r.right,bottom:r.bottom},h=o.center;if((h.y<a.y||h.y>a.bottom)&&(h.x<a.x||h.x>a.right))return this.separateCircle(t,e,n)}var l=!1,c=!1;this.forceX||Math.abs(this.gravity.y+t.gravity.y)<Math.abs(this.gravity.x+t.gravity.x)?(l=this.separateX(t,e,n),this.intersects(t,e)&&(c=this.separateY(t,e,n))):(c=this.separateY(t,e,n),this.intersects(t,e)&&(l=this.separateX(t,e,n)));var u=l||c;return u&&(n?(t.onOverlap&&t.onOverlap.dispatch(t.sprite,e.sprite),e.onOverlap&&e.onOverlap.dispatch(e.sprite,t.sprite)):(t.onCollide&&t.onCollide.dispatch(t.sprite,e.sprite),e.onCollide&&e.onCollide.dispatch(e.sprite,t.sprite))),u},intersects:function(t,i){return t!==i&&(t.isCircle?i.isCircle?e.Math.distance(t.center.x,t.center.y,i.center.x,i.center.y)<=t.halfWidth+i.halfWidth:this.circleBodyIntersects(t,i):i.isCircle?this.circleBodyIntersects(i,t):!(t.right<=i.position.x)&&(!(t.bottom<=i.position.y)&&(!(t.position.x>=i.right)&&!(t.position.y>=i.bottom))))},circleBodyIntersects:function(t,i){var s=e.Math.clamp(t.center.x,i.left,i.right),n=e.Math.clamp(t.center.y,i.top,i.bottom);return(t.center.x-s)*(t.center.x-s)+(t.center.y-n)*(t.center.y-n)<=t.halfWidth*t.halfWidth},separateCircle:function(t,i,s){this.getOverlapX(t,i),this.getOverlapY(t,i);var n=i.center.x-t.center.x,r=i.center.y-t.center.y,o=Math.atan2(r,n),a=0;if(t.isCircle!==i.isCircle){var h={x:i.isCircle?t.position.x:i.position.x,y:i.isCircle?t.position.y:i.position.y,right:i.isCircle?t.right:i.right,bottom:i.isCircle?t.bottom:i.bottom},l={x:t.isCircle?t.center.x:i.center.x,y:t.isCircle?t.center.y:i.center.y,radius:t.isCircle?t.halfWidth:i.halfWidth};l.y<h.y?l.x<h.x?a=e.Math.distance(l.x,l.y,h.x,h.y)-l.radius:l.x>h.right&&(a=e.Math.distance(l.x,l.y,h.right,h.y)-l.radius):l.y>h.bottom&&(l.x<h.x?a=e.Math.distance(l.x,l.y,h.x,h.bottom)-l.radius:l.x>h.right&&(a=e.Math.distance(l.x,l.y,h.right,h.bottom)-l.radius)),a*=-1}else a=t.halfWidth+i.halfWidth-e.Math.distance(t.center.x,t.center.y,i.center.x,i.center.y);if(s||0===a||t.immovable&&i.immovable||t.customSeparateX||i.customSeparateX)return 0!==a&&(t.onOverlap&&t.onOverlap.dispatch(t.sprite,i.sprite),i.onOverlap&&i.onOverlap.dispatch(i.sprite,t.sprite)),0!==a;var c={x:t.velocity.x*Math.cos(o)+t.velocity.y*Math.sin(o),y:-t.velocity.x*Math.sin(o)+t.velocity.y*Math.cos(o)},u={x:i.velocity.x*Math.cos(o)+i.velocity.y*Math.sin(o),y:-i.velocity.x*Math.sin(o)+i.velocity.y*Math.cos(o)},d=((t.mass-i.mass)*c.x+2*i.mass*u.x)/(t.mass+i.mass),p=(2*t.mass*c.x+(i.mass-t.mass)*u.x)/(t.mass+i.mass);return t.immovable||(t.velocity.x=(d*Math.cos(o)-c.y*Math.sin(o))*t.bounce.x,t.velocity.y=(c.y*Math.cos(o)+d*Math.sin(o))*t.bounce.y),i.immovable||(i.velocity.x=(p*Math.cos(o)-u.y*Math.sin(o))*i.bounce.x,i.velocity.y=(u.y*Math.cos(o)+p*Math.sin(o))*i.bounce.y),Math.abs(o)<Math.PI/2?t.velocity.x>0&&!t.immovable&&i.velocity.x>t.velocity.x?t.velocity.x*=-1:i.velocity.x<0&&!i.immovable&&t.velocity.x<i.velocity.x?i.velocity.x*=-1:t.velocity.y>0&&!t.immovable&&i.velocity.y>t.velocity.y?t.velocity.y*=-1:i.velocity.y<0&&!i.immovable&&t.velocity.y<i.velocity.y&&(i.velocity.y*=-1):Math.abs(o)>Math.PI/2&&(t.velocity.x<0&&!t.immovable&&i.velocity.x<t.velocity.x?t.velocity.x*=-1:i.velocity.x>0&&!i.immovable&&t.velocity.x>i.velocity.x?i.velocity.x*=-1:t.velocity.y<0&&!t.immovable&&i.velocity.y<t.velocity.y?t.velocity.y*=-1:i.velocity.y>0&&!i.immovable&&t.velocity.x>i.velocity.y&&(i.velocity.y*=-1)),t.immovable||(t.x+=t.velocity.x*this.game.time.physicsElapsed-a*Math.cos(o),t.y+=t.velocity.y*this.game.time.physicsElapsed-a*Math.sin(o)),i.immovable||(i.x+=i.velocity.x*this.game.time.physicsElapsed+a*Math.cos(o),i.y+=i.velocity.y*this.game.time.physicsElapsed+a*Math.sin(o)),t.onCollide&&t.onCollide.dispatch(t.sprite,i.sprite),i.onCollide&&i.onCollide.dispatch(i.sprite,t.sprite),!0},getOverlapX:function(t,e,i){var s=0,n=t.deltaAbsX()+e.deltaAbsX()+this.OVERLAP_BIAS;return 0===t.deltaX()&&0===e.deltaX()?(t.embedded=!0,e.embedded=!0):t.deltaX()>e.deltaX()?(s=t.right-e.x)>n&&!i||!1===t.checkCollision.right||!1===e.checkCollision.left?s=0:(t.touching.none=!1,t.touching.right=!0,e.touching.none=!1,e.touching.left=!0):t.deltaX()<e.deltaX()&&(-(s=t.x-e.width-e.x)>n&&!i||!1===t.checkCollision.left||!1===e.checkCollision.right?s=0:(t.touching.none=!1,t.touching.left=!0,e.touching.none=!1,e.touching.right=!0)),t.overlapX=s,e.overlapX=s,s},getOverlapY:function(t,e,i){var s=0,n=t.deltaAbsY()+e.deltaAbsY()+this.OVERLAP_BIAS;return 0===t.deltaY()&&0===e.deltaY()?(t.embedded=!0,e.embedded=!0):t.deltaY()>e.deltaY()?(s=t.bottom-e.y)>n&&!i||!1===t.checkCollision.down||!1===e.checkCollision.up?s=0:(t.touching.none=!1,t.touching.down=!0,e.touching.none=!1,e.touching.up=!0):t.deltaY()<e.deltaY()&&(-(s=t.y-e.bottom)>n&&!i||!1===t.checkCollision.up||!1===e.checkCollision.down?s=0:(t.touching.none=!1,t.touching.up=!0,e.touching.none=!1,e.touching.down=!0)),t.overlapY=s,e.overlapY=s,s},separateX:function(t,e,i){var s=this.getOverlapX(t,e,i);if(i||0===s||t.immovable&&e.immovable||t.customSeparateX||e.customSeparateX)return 0!==s||t.embedded&&e.embedded;var n=t.velocity.x,r=e.velocity.x;if(t.immovable||e.immovable)t.immovable?(e.x+=s,e.velocity.x=n-r*e.bounce.x,t.moves&&(e.y+=(t.y-t.prev.y)*t.friction.y)):(t.x-=s,t.velocity.x=r-n*t.bounce.x,e.moves&&(t.y+=(e.y-e.prev.y)*e.friction.y));else{s*=.5,t.x-=s,e.x+=s;var o=Math.sqrt(r*r*e.mass/t.mass)*(r>0?1:-1),a=Math.sqrt(n*n*t.mass/e.mass)*(n>0?1:-1),h=.5*(o+a);o-=h,a-=h,t.velocity.x=h+o*t.bounce.x,e.velocity.x=h+a*e.bounce.x}return!0},separateY:function(t,e,i){var s=this.getOverlapY(t,e,i);if(i||0===s||t.immovable&&e.immovable||t.customSeparateY||e.customSeparateY)return 0!==s||t.embedded&&e.embedded;var n=t.velocity.y,r=e.velocity.y;if(t.immovable||e.immovable)t.immovable?(e.y+=s,e.velocity.y=n-r*e.bounce.y,t.moves&&(e.x+=(t.x-t.prev.x)*t.friction.x)):(t.y-=s,t.velocity.y=r-n*t.bounce.y,e.moves&&(t.x+=(e.x-e.prev.x)*e.friction.x));else{s*=.5,t.y-=s,e.y+=s;var o=Math.sqrt(r*r*e.mass/t.mass)*(r>0?1:-1),a=Math.sqrt(n*n*t.mass/e.mass)*(n>0?1:-1),h=.5*(o+a);o-=h,a-=h,t.velocity.y=h+o*t.bounce.y,e.velocity.y=h+a*e.bounce.y}return!0},getObjectsUnderPointer:function(t,e,i,s){if(0!==e.length&&t.exists)return this.getObjectsAtLocation(t.x,t.y,e,i,s,t)},getObjectsAtLocation:function(t,i,s,n,r,o){this.quadTree.clear(),this.quadTree.reset(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels),this.quadTree.populate(s);for(var a=new e.Rectangle(t,i,1,1),h=[],l=this.quadTree.retrieve(a),c=0;c<l.length;c++)l[c].hitTest(t,i)&&(n&&n.call(r,o,l[c].sprite),h.push(l[c].sprite));return h},moveToObject:function(t,i,s,n){void 0===s&&(s=60),void 0===n&&(n=0);var r=e.Point.angle(i,t);return n>0&&(s=this.distanceBetween(t,i)/(n/1e3)),t.body.velocity.setToPolar(r,s),r},moveToPointer:function(t,e,i,s){void 0===e&&(e=60),i=i||this.game.input.activePointer,void 0===s&&(s=0);var n=this.angleToPointer(t,i);return s>0&&(e=this.distanceToPointer(t,i)/(s/1e3)),t.body.velocity.setToPolar(n,e),n},moveToXY:function(t,e,i,s,n){void 0===s&&(s=60),void 0===n&&(n=0);var r=Math.atan2(i-t.y,e-t.x);return n>0&&(s=this.distanceToXY(t,e,i)/(n/1e3)),t.body.velocity.setToPolar(r,s),r},velocityFromAngle:function(t,i,s){return void 0===i&&(i=60),(s=s||new e.Point).setToPolar(t,i,!0)},velocityFromRotation:function(t,i,s){return void 0===i&&(i=60),(s=s||new e.Point).setToPolar(t,i)},accelerationFromRotation:function(t,i,s){return void 0===i&&(i=60),(s=s||new e.Point).setToPolar(t,i)},accelerateToObject:function(t,e,i,s,n){void 0===i&&(i=60),void 0===s&&(s=1e3),void 0===n&&(n=1e3);var r=this.angleBetween(t,e);return t.body.acceleration.setToPolar(r,i),t.body.maxVelocity.setTo(s,n),r},accelerateToPointer:function(t,e,i,s,n){void 0===i&&(i=60),void 0===e&&(e=this.game.input.activePointer),void 0===s&&(s=1e3),void 0===n&&(n=1e3);var r=this.angleToPointer(t,e);return t.body.acceleration.setToPolar(r,i),t.body.maxVelocity.setTo(s,n),r},accelerateToXY:function(t,e,i,s,n,r){void 0===s&&(s=60),void 0===n&&(n=1e3),void 0===r&&(r=1e3);var o=this.angleToXY(t,e,i);return t.body.acceleration.setTo(o,s),t.body.maxVelocity.setTo(n,r),o},distanceBetween:function(t,e,i,s){void 0===i&&(i=!1);var n,r;return s?(n=t.centerX-e.centerX,r=t.centerY-e.centerY):i?(n=t.world.x-e.world.x,r=t.world.y-e.world.y):(n=t.x-e.x,r=t.y-e.y),Math.sqrt(n*n+r*r)},distanceToXY:function(t,e,i,s){void 0===s&&(s=!1);var n=s?t.world.x-e:t.x-e,r=s?t.world.y-i:t.y-i;return Math.sqrt(n*n+r*r)},distanceToPointer:function(t,e,i){void 0===e&&(e=this.game.input.activePointer),void 0===i&&(i=!1);var s=i?t.world.x-e.worldX:t.x-e.worldX,n=i?t.world.y-e.worldY:t.y-e.worldY;return Math.sqrt(s*s+n*n)},closest:function(t,e,i,s){for(var n=1/0,r=null,o=0,a=e.length;o<a;o++){var h=e[o],l=this.distanceBetween(t,h,i,s);l<n&&(r=h,n=l)}return r},farthest:function(t,e,i,s){for(var n=-1,r=null,o=0,a=e.length;o<a;o++){var h=e[o],l=this.distanceBetween(t,h,i,s);l>n&&(r=h,n=l)}return r},angleBetween:function(t,i,s){return void 0===s&&(s=!1),s?e.Point.angle(i.world,t.world):e.Point.angle(i,t)},angleBetweenCenters:function(t,e){var i=e.centerX-t.centerX,s=e.centerY-t.centerY;return Math.atan2(s,i)},angleToXY:function(t,e,i,s){return void 0===s&&(s=!1),s?Math.atan2(i-t.world.y,e-t.world.x):Math.atan2(i-t.y,e-t.x)},angleToPointer:function(t,e,i){return void 0===e&&(e=this.game.input.activePointer),void 0===i&&(i=!1),i?Math.atan2(e.worldY-t.world.y,e.worldX-t.world.x):Math.atan2(e.worldY-t.y,e.worldX-t.x)},worldAngleToPointer:function(t,e){return this.angleToPointer(t,e,!0)}},e.Physics.Arcade.Body=function(t){this.sprite=t,this.game=t.game,this.type=e.Physics.ARCADE,this.enable=!0,this.isCircle=!1,this.radius=0,this.offset=new e.Point,this.position=new e.Point(t.x,t.y),this.prev=new e.Point(this.position.x,this.position.y),this.allowRotation=!0,this.rotation=t.angle,this.preRotation=t.angle,this.width=t.width,this.height=t.height,this.sourceWidth=t.width,this.sourceHeight=t.height,t.texture&&(this.sourceWidth=t.texture.frame.width,this.sourceHeight=t.texture.frame.height),this.halfWidth=Math.abs(t.width/2),this.halfHeight=Math.abs(t.height/2),this.center=new e.Point(t.x+this.halfWidth,t.y+this.halfHeight),this.velocity=new e.Point,this.newVelocity=new e.Point,this.deltaMax=new e.Point,this.acceleration=new e.Point,this.allowDrag=!0,this.drag=new e.Point,this.allowGravity=!0,this.gravity=new e.Point,this.bounce=new e.Point,this.worldBounce=null,this.onWorldBounds=null,this.onCollide=null,this.onOverlap=null,this.maxVelocity=new e.Point(1e4,1e4),this.friction=new e.Point(1,0),this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e3,this.mass=1,this.angle=0,this.speed=0,this.facing=e.NONE,this.immovable=!1,this.moves=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.overlapR=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision={none:!1,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.blocked={none:!0,up:!1,down:!1,left:!1,right:!1},this.tilePadding=new e.Point,this.dirty=!1,this.skipQuadTree=!1,this.syncBounds=!1,this.isMoving=!1,this.stopVelocityOnCollide=!0,this.moveTimer=0,this.moveDistance=0,this.moveDuration=0,this.moveTarget=null,this.moveEnd=null,this.onMoveComplete=new e.Signal,this.movementCallback=null,this.movementCallbackContext=null,this._reset=!0,this._sx=t.scale.x,this._sy=t.scale.y,this._dx=0,this._dy=0},e.Physics.Arcade.Body.prototype={updateBounds:function(){if(this.syncBounds){var t=this.sprite.getBounds();t.ceilAll(),t.width===this.width&&t.height===this.height||(this.width=t.width,this.height=t.height,this._reset=!0)}else{var e=Math.abs(this.sprite.scale.x),i=Math.abs(this.sprite.scale.y);e===this._sx&&i===this._sy||(this.width=this.sourceWidth*e,this.height=this.sourceHeight*i,this._sx=e,this._sy=i,this._reset=!0)}this._reset&&(this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.updateCenter())},updateCenter:function(){this.center.setTo(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},preUpdate:function(){this.enable&&!this.game.physics.arcade.isPaused&&(this.dirty=!0,this.wasTouching.none=this.touching.none,this.wasTouching.up=this.touching.up,this.wasTouching.down=this.touching.down,this.wasTouching.left=this.touching.left,this.wasTouching.right=this.touching.right,this.touching.none=!0,this.touching.up=!1,this.touching.down=!1,this.touching.left=!1,this.touching.right=!1,this.blocked.none=!0,this.blocked.up=!1,this.blocked.down=!1,this.blocked.left=!1,this.blocked.right=!1,this.overlapR=0,this.overlapX=0,this.overlapY=0,this.embedded=!1,this.updateBounds(),this.position.x=this.sprite.world.x-this.sprite.anchor.x*this.sprite.width+this.sprite.scale.x*this.offset.x,this.position.x-=this.sprite.scale.x<0?this.width:0,this.position.y=this.sprite.world.y-this.sprite.anchor.y*this.sprite.height+this.sprite.scale.y*this.offset.y,this.position.y-=this.sprite.scale.y<0?this.height:0,this.updateCenter(),this.rotation=this.sprite.angle,this.preRotation=this.rotation,(this._reset||this.sprite.fresh)&&(this.prev.x=this.position.x,this.prev.y=this.position.y),this.moves&&(this.game.physics.arcade.updateMotion(this),this.newVelocity.set(this.velocity.x*this.game.time.physicsElapsed,this.velocity.y*this.game.time.physicsElapsed),this.position.x+=this.newVelocity.x,this.position.y+=this.newVelocity.y,this.updateCenter(),this.position.x===this.prev.x&&this.position.y===this.prev.y||(this.angle=this.velocity.atan()),this.speed=Math.sqrt(this.velocity.x*this.velocity.x+this.velocity.y*this.velocity.y),this.collideWorldBounds&&this.checkWorldBounds()&&this.onWorldBounds&&this.onWorldBounds.dispatch(this.sprite,this.blocked.up,this.blocked.down,this.blocked.left,this.blocked.right)),this._dx=this.deltaX(),this._dy=this.deltaY(),this._reset=!1)},updateMovement:function(){var t=0,e=0!==this.overlapX||0!==this.overlapY;if(this.moveDuration>0?(this.moveTimer+=this.game.time.elapsedMS,t=this.moveTimer/this.moveDuration):(this.moveTarget.end.set(this.position.x,this.position.y),t=this.moveTarget.length/this.moveDistance),this.movementCallback)var i=this.movementCallback.call(this.movementCallbackContext,this,this.velocity,t);return!(e||t>=1||void 0!==i&&!0!==i)||(this.stopMovement(t>=1||this.stopVelocityOnCollide&&e),!1)},stopMovement:function(t){this.isMoving&&(this.isMoving=!1,t&&this.velocity.set(0),this.onMoveComplete.dispatch(this.sprite,0!==this.overlapX||0!==this.overlapY))},postUpdate:function(){this.enable&&this.dirty&&(this.isMoving&&this.updateMovement(),this.dirty=!1,this.deltaX()<0?this.facing=e.LEFT:this.deltaX()>0&&(this.facing=e.RIGHT),this.deltaY()<0?this.facing=e.UP:this.deltaY()>0&&(this.facing=e.DOWN),this.moves&&(this._dx=this.deltaX(),this._dy=this.deltaY(),0!==this.deltaMax.x&&0!==this._dx&&(this._dx<0&&this._dx<-this.deltaMax.x?this._dx=-this.deltaMax.x:this._dx>0&&this._dx>this.deltaMax.x&&(this._dx=this.deltaMax.x)),0!==this.deltaMax.y&&0!==this._dy&&(this._dy<0&&this._dy<-this.deltaMax.y?this._dy=-this.deltaMax.y:this._dy>0&&this._dy>this.deltaMax.y&&(this._dy=this.deltaMax.y)),this.sprite.position.x+=this._dx,this.sprite.position.y+=this._dy,this._reset=!0),this.updateCenter(),this.allowRotation&&(this.sprite.angle+=this.deltaZ()),this.prev.x=this.position.x,this.prev.y=this.position.y)},checkWorldBounds:function(){var t=this.position,e=this.game.physics.arcade.bounds,i=this.game.physics.arcade.checkCollision,s=this.worldBounce?-this.worldBounce.x:-this.bounce.x,n=this.worldBounce?-this.worldBounce.y:-this.bounce.y;return t.x<e.x&&i.left?(t.x=e.x,this.velocity.x*=s,this.blocked.left=!0,this.blocked.none=!1):this.right>e.right&&i.right&&(t.x=e.right-this.width,this.velocity.x*=s,this.blocked.right=!0,this.blocked.none=!1),t.y<e.y&&i.up?(t.y=e.y,this.velocity.y*=n,this.blocked.up=!0,this.blocked.none=!1):this.bottom>e.bottom&&i.down&&(t.y=e.bottom-this.height,this.velocity.y*=n,this.blocked.down=!0,this.blocked.none=!1),!this.blocked.none},moveFrom:function(t,e,i){if(void 0===e&&(e=this.speed),0===e)return!1;var s;return void 0===i?(s=this.angle,i=this.game.math.radToDeg(s)):s=this.game.math.degToRad(i),this.moveTimer=0,this.moveDuration=t,0===i||180===i?this.velocity.set(Math.cos(s)*e,0):90===i||270===i?this.velocity.set(0,Math.sin(s)*e):this.velocity.setToPolar(s,e),this.isMoving=!0,!0},moveTo:function(t,i,s){var n=i/(t/1e3);if(0===n)return!1;var r;return void 0===s?(r=this.angle,s=this.game.math.radToDeg(r)):r=this.game.math.degToRad(s),i=Math.abs(i),this.moveDuration=0,this.moveDistance=i,null===this.moveTarget&&(this.moveTarget=new e.Line,this.moveEnd=new e.Point),this.moveTarget.fromAngle(this.x,this.y,r,i),this.moveEnd.set(this.moveTarget.end.x,this.moveTarget.end.y),this.moveTarget.setTo(this.x,this.y,this.x,this.y),0===s||180===s?this.velocity.set(Math.cos(r)*n,0):90===s||270===s?this.velocity.set(0,Math.sin(r)*n):this.velocity.setToPolar(r,n),this.isMoving=!0,!0},setSize:function(t,e,i,s){void 0===i&&(i=this.offset.x),void 0===s&&(s=this.offset.y),this.sourceWidth=t,this.sourceHeight=e,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.setTo(i,s),this.updateCenter(),this.isCircle=!1,this.radius=0},setCircle:function(t,e,i){void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),t>0?(this.isCircle=!0,this.radius=t,this.sourceWidth=2*t,this.sourceHeight=2*t,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.setTo(e,i),this.updateCenter()):this.isCircle=!1},reset:function(t,e){this.stop(),this.position.x=t-this.sprite.anchor.x*this.sprite.width+this.sprite.scale.x*this.offset.x,this.position.x-=this.sprite.scale.x<0?this.width:0,this.position.y=e-this.sprite.anchor.y*this.sprite.height+this.sprite.scale.y*this.offset.y,this.position.y-=this.sprite.scale.y<0?this.height:0,this.prev.x=this.position.x,this.prev.y=this.position.y,this.rotation=this.sprite.angle,this.preRotation=this.rotation,this.updateBounds(),this.updateCenter()},stop:function(){this.velocity.set(0),this.acceleration.set(0),this.speed=0,this.angularVelocity=0,this.angularAcceleration=0},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,i){return this.isCircle?e.Circle.contains(this,t,i):e.Rectangle.contains(this,t,i)},onFloor:function(){return this.blocked.down},onCeiling:function(){return this.blocked.up},onWall:function(){return this.blocked.left||this.blocked.right},deltaAbsX:function(){return this.deltaX()>0?this.deltaX():-this.deltaX()},deltaAbsY:function(){return this.deltaY()>0?this.deltaY():-this.deltaY()},deltaX:function(){return this.position.x-this.prev.x},deltaY:function(){return this.position.y-this.prev.y},deltaZ:function(){return this.rotation-this.preRotation},destroy:function(){this.sprite.parent&&this.sprite.parent instanceof e.Group&&this.sprite.parent.removeFromHash(this.sprite),this.sprite.body=null,this.sprite=null}},Object.defineProperty(e.Physics.Arcade.Body.prototype,"left",{get:function(){return this.position.x}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"right",{get:function(){return this.position.x+this.width}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"top",{get:function(){return this.position.y}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"bottom",{get:function(){return this.position.y+this.height}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"x",{get:function(){return this.position.x},set:function(t){this.position.x=t}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"y",{get:function(){return this.position.y},set:function(t){this.position.y=t}}),e.Physics.Arcade.Body.render=function(t,e,i,s,n){void 0===s&&(s=!0),i=i||"rgba(0,255,0,0.4)",t.fillStyle=i,t.strokeStyle=i,t.lineWidth=n||1,e.isCircle?(t.beginPath(),t.arc(e.center.x-e.game.camera.x,e.center.y-e.game.camera.y,e.halfWidth,0,2*Math.PI),s?t.fill():t.stroke()):s?t.fillRect(e.position.x-e.game.camera.x,e.position.y-e.game.camera.y,e.width,e.height):t.strokeRect(e.position.x-e.game.camera.x,e.position.y-e.game.camera.y,e.width,e.height)},e.Physics.Arcade.Body.renderBodyInfo=function(t,e){t.line("x: "+e.x.toFixed(2),"y: "+e.y.toFixed(2),"width: "+e.width,"height: "+e.height),t.line("velocity x: "+e.velocity.x.toFixed(2),"y: "+e.velocity.y.toFixed(2),"deltaX: "+e._dx.toFixed(2),"deltaY: "+e._dy.toFixed(2)),t.line("acceleration x: "+e.acceleration.x.toFixed(2),"y: "+e.acceleration.y.toFixed(2),"speed: "+e.speed.toFixed(2),"angle: "+e.angle.toFixed(2)),t.line("gravity x: "+e.gravity.x,"y: "+e.gravity.y,"bounce x: "+e.bounce.x.toFixed(2),"y: "+e.bounce.y.toFixed(2)),t.line("touching left: "+e.touching.left,"right: "+e.touching.right,"up: "+e.touching.up,"down: "+e.touching.down),t.line("blocked left: "+e.blocked.left,"right: "+e.blocked.right,"up: "+e.blocked.up,"down: "+e.blocked.down)},e.Physics.Arcade.Body.prototype.constructor=e.Physics.Arcade.Body,e.Physics.Arcade.TilemapCollision=function(){},e.Physics.Arcade.TilemapCollision.prototype={TILE_BIAS:16,collideSpriteVsTilemapLayer:function(t,e,i,s,n,r){if(t.body){var o=e.getTiles(t.body.position.x-t.body.tilePadding.x-e.getTileOffsetX(),t.body.position.y-t.body.tilePadding.y-e.getTileOffsetY(),t.body.width+t.body.tilePadding.x,t.body.height+t.body.tilePadding.y,!1,!1);if(0!==o.length)for(var a=0;a<o.length;a++)s?s.call(n,t,o[a])&&this.separateTile(a,t.body,o[a],e,r)&&(this._total++,i&&i.call(n,t,o[a])):this.separateTile(a,t.body,o[a],e,r)&&(this._total++,i&&i.call(n,t,o[a]))}},collideGroupVsTilemapLayer:function(t,e,i,s,n,r){if(0!==t.length)for(var o=0;o<t.children.length;o++)t.children[o].exists&&this.collideSpriteVsTilemapLayer(t.children[o],e,i,s,n,r)},separateTile:function(t,e,i,s,n){if(!e.enable)return!1;var r=s.getTileOffsetX(),o=s.getTileOffsetY();if(!i.intersects(e.position.x-r,e.position.y-o,e.right-r,e.bottom-o))return!1;if(n)return!0;if(i.collisionCallback&&!i.collisionCallback.call(i.collisionCallbackContext,e.sprite,i))return!1;if(void 0!==i.layer.callbacks&&i.layer.callbacks[i.index]&&!i.layer.callbacks[i.index].callback.call(i.layer.callbacks[i.index].callbackContext,e.sprite,i))return!1;if(!(i.faceLeft||i.faceRight||i.faceTop||i.faceBottom))return!1;var a=0,h=0,l=0,c=1;if(e.deltaAbsX()>e.deltaAbsY()?l=-1:e.deltaAbsX()<e.deltaAbsY()&&(c=-1),0!==e.deltaX()&&0!==e.deltaY()&&(i.faceLeft||i.faceRight)&&(i.faceTop||i.faceBottom)&&(l=Math.min(Math.abs(e.position.x-r-i.right),Math.abs(e.right-r-i.left)),c=Math.min(Math.abs(e.position.y-o-i.bottom),Math.abs(e.bottom-o-i.top))),l<c){if((i.faceLeft||i.faceRight)&&0!==(a=this.tileCheckX(e,i,s))&&!i.intersects(e.position.x-r,e.position.y-o,e.right-r,e.bottom-o))return!0;(i.faceTop||i.faceBottom)&&(h=this.tileCheckY(e,i,s))}else{if((i.faceTop||i.faceBottom)&&0!==(h=this.tileCheckY(e,i,s))&&!i.intersects(e.position.x-r,e.position.y-o,e.right-r,e.bottom-o))return!0;(i.faceLeft||i.faceRight)&&(a=this.tileCheckX(e,i,s))}return 0!==a||0!==h},tileCheckX:function(t,e,i){var s=0,n=i.getTileOffsetX();return t.deltaX()<0&&!t.blocked.left&&e.collideRight&&t.checkCollision.left?e.faceRight&&t.x-n<e.right&&(s=t.x-n-e.right)<-this.TILE_BIAS&&(s=0):t.deltaX()>0&&!t.blocked.right&&e.collideLeft&&t.checkCollision.right&&e.faceLeft&&t.right-n>e.left&&(s=t.right-n-e.left)>this.TILE_BIAS&&(s=0),0!==s&&(t.customSeparateX?t.overlapX=s:this.processTileSeparationX(t,s)),s},tileCheckY:function(t,e,i){var s=0,n=i.getTileOffsetY();return t.deltaY()<0&&!t.blocked.up&&e.collideDown&&t.checkCollision.up?e.faceBottom&&t.y-n<e.bottom&&(s=t.y-n-e.bottom)<-this.TILE_BIAS&&(s=0):t.deltaY()>0&&!t.blocked.down&&e.collideUp&&t.checkCollision.down&&e.faceTop&&t.bottom-n>e.top&&(s=t.bottom-n-e.top)>this.TILE_BIAS&&(s=0),0!==s&&(t.customSeparateY?t.overlapY=s:this.processTileSeparationY(t,s)),s},processTileSeparationX:function(t,e){e<0?(t.blocked.left=!0,t.blocked.none=!1):e>0&&(t.blocked.right=!0,t.blocked.none=!1),t.position.x-=e,0===t.bounce.x?t.velocity.x=0:t.velocity.x=-t.velocity.x*t.bounce.x},processTileSeparationY:function(t,e){e<0?(t.blocked.up=!0,t.blocked.none=!1):e>0&&(t.blocked.down=!0,t.blocked.none=!1),t.position.y-=e,0===t.bounce.y?t.velocity.y=0:t.velocity.y=-t.velocity.y*t.bounce.y}},e.Utils.mixinPrototype(e.Physics.Arcade.prototype,e.Physics.Arcade.TilemapCollision.prototype),p2.Body.prototype.parent=null,p2.Spring.prototype.parent=null,e.Physics.P2=function(t,i){this.game=t,void 0===i?i={gravity:[0,0],broadphase:new p2.SAPBroadphase}:(i.hasOwnProperty("gravity")||(i.gravity=[0,0]),i.hasOwnProperty("broadphase")||(i.broadphase=new p2.SAPBroadphase)),this.config=i,this.world=new p2.World(this.config),this.frameRate=1/60,this.useElapsedTime=!1,this.paused=!1,this.materials=[],this.gravity=new e.Physics.P2.InversePointProxy(this,this.world.gravity),this.walls={left:null,right:null,top:null,bottom:null},this.onBodyAdded=new e.Signal,this.onBodyRemoved=new e.Signal,this.onSpringAdded=new e.Signal,this.onSpringRemoved=new e.Signal,this.onConstraintAdded=new e.Signal,this.onConstraintRemoved=new e.Signal,this.onContactMaterialAdded=new e.Signal,this.onContactMaterialRemoved=new e.Signal,this.postBroadphaseCallback=null,this.callbackContext=null,this.onBeginContact=new e.Signal,this.onEndContact=new e.Signal,i.hasOwnProperty("mpx")&&i.hasOwnProperty("pxm")&&i.hasOwnProperty("mpxi")&&i.hasOwnProperty("pxmi")&&(this.mpx=i.mpx,this.mpxi=i.mpxi,this.pxm=i.pxm,this.pxmi=i.pxmi),this.world.on("beginContact",this.beginContactHandler,this),this.world.on("endContact",this.endContactHandler,this),this.collisionGroups=[],this.nothingCollisionGroup=new e.Physics.P2.CollisionGroup(1),this.boundsCollisionGroup=new e.Physics.P2.CollisionGroup(2),this.everythingCollisionGroup=new e.Physics.P2.CollisionGroup(2147483648),this.boundsCollidesWith=[],this._toRemove=[],this._collisionGroupID=2,this._boundsLeft=!0,this._boundsRight=!0,this._boundsTop=!0,this._boundsBottom=!0,this._boundsOwnGroup=!1,this.setBoundsToWorld(!0,!0,!0,!0,!1)},e.Physics.P2.prototype={removeBodyNextStep:function(t){this._toRemove.push(t)},preUpdate:function(){for(var t=this._toRemove.length;t--;)this.removeBody(this._toRemove[t]);this._toRemove.length=0},enable:function(t,i,s){void 0===i&&(i=!1),void 0===s&&(s=!0);var n=1;if(Array.isArray(t))for(n=t.length;n--;)t[n]instanceof e.Group?this.enable(t[n].children,i,s):(this.enableBody(t[n],i),s&&t[n].hasOwnProperty("children")&&t[n].children.length>0&&this.enable(t[n],i,!0));else t instanceof e.Group?this.enable(t.children,i,s):(this.enableBody(t,i),s&&t.hasOwnProperty("children")&&t.children.length>0&&this.enable(t.children,i,!0))},enableBody:function(t,i){t.hasOwnProperty("body")&&null===t.body&&(t.body=new e.Physics.P2.Body(this.game,t,t.x,t.y,1),t.body.debug=i,void 0!==t.anchor&&t.anchor.set(.5))},setImpactEvents:function(t){t?this.world.on("impact",this.impactHandler,this):this.world.off("impact",this.impactHandler,this)},setPostBroadphaseCallback:function(t,e){this.postBroadphaseCallback=t,this.callbackContext=e,null!==t?this.world.on("postBroadphase",this.postBroadphaseHandler,this):this.world.off("postBroadphase",this.postBroadphaseHandler,this)},postBroadphaseHandler:function(t){if(this.postBroadphaseCallback&&0!==t.pairs.length)for(var e=t.pairs.length-2;e>=0;e-=2)t.pairs[e].parent&&t.pairs[e+1].parent&&!this.postBroadphaseCallback.call(this.callbackContext,t.pairs[e].parent,t.pairs[e+1].parent)&&t.pairs.splice(e,2)},impactHandler:function(t){if(t.bodyA.parent&&t.bodyB.parent){var e=t.bodyA.parent,i=t.bodyB.parent;e._bodyCallbacks[t.bodyB.id]&&e._bodyCallbacks[t.bodyB.id].call(e._bodyCallbackContext[t.bodyB.id],e,i,t.shapeA,t.shapeB),i._bodyCallbacks[t.bodyA.id]&&i._bodyCallbacks[t.bodyA.id].call(i._bodyCallbackContext[t.bodyA.id],i,e,t.shapeB,t.shapeA),e._groupCallbacks[t.shapeB.collisionGroup]&&e._groupCallbacks[t.shapeB.collisionGroup].call(e._groupCallbackContext[t.shapeB.collisionGroup],e,i,t.shapeA,t.shapeB),i._groupCallbacks[t.shapeA.collisionGroup]&&i._groupCallbacks[t.shapeA.collisionGroup].call(i._groupCallbackContext[t.shapeA.collisionGroup],i,e,t.shapeB,t.shapeA)}},beginContactHandler:function(t){t.bodyA&&t.bodyB&&(this.onBeginContact.dispatch(t.bodyA,t.bodyB,t.shapeA,t.shapeB,t.contactEquations),t.bodyA.parent&&t.bodyA.parent.onBeginContact.dispatch(t.bodyB.parent,t.bodyB,t.shapeA,t.shapeB,t.contactEquations),t.bodyB.parent&&t.bodyB.parent.onBeginContact.dispatch(t.bodyA.parent,t.bodyA,t.shapeB,t.shapeA,t.contactEquations))},endContactHandler:function(t){t.bodyA&&t.bodyB&&(this.onEndContact.dispatch(t.bodyA,t.bodyB,t.shapeA,t.shapeB),t.bodyA.parent&&t.bodyA.parent.onEndContact.dispatch(t.bodyB.parent,t.bodyB,t.shapeA,t.shapeB),t.bodyB.parent&&t.bodyB.parent.onEndContact.dispatch(t.bodyA.parent,t.bodyA,t.shapeB,t.shapeA))},setBoundsToWorld:function(t,e,i,s,n){this.setBounds(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,t,e,i,s,n)},setWorldMaterial:function(t,e,i,s,n){void 0===e&&(e=!0),void 0===i&&(i=!0),void 0===s&&(s=!0),void 0===n&&(n=!0),e&&this.walls.left&&(this.walls.left.shapes[0].material=t),i&&this.walls.right&&(this.walls.right.shapes[0].material=t),s&&this.walls.top&&(this.walls.top.shapes[0].material=t),n&&this.walls.bottom&&(this.walls.bottom.shapes[0].material=t)},updateBoundsCollisionGroup:function(t){void 0===t&&(t=!0);var e=t?this.boundsCollisionGroup.mask:this.everythingCollisionGroup.mask;this.walls.left&&(this.walls.left.shapes[0].collisionGroup=e),this.walls.right&&(this.walls.right.shapes[0].collisionGroup=e),this.walls.top&&(this.walls.top.shapes[0].collisionGroup=e),this.walls.bottom&&(this.walls.bottom.shapes[0].collisionGroup=e),this._boundsOwnGroup=t},setBounds:function(t,e,i,s,n,r,o,a,h){void 0===n&&(n=this._boundsLeft),void 0===r&&(r=this._boundsRight),void 0===o&&(o=this._boundsTop),void 0===a&&(a=this._boundsBottom),void 0===h&&(h=this._boundsOwnGroup),this.setupWall(n,"left",t,e,1.5707963267948966,h),this.setupWall(r,"right",t+i,e,-1.5707963267948966,h),this.setupWall(o,"top",t,e,-3.141592653589793,h),this.setupWall(a,"bottom",t,e+s,0,h),this._boundsLeft=n,this._boundsRight=r,this._boundsTop=o,this._boundsBottom=a,this._boundsOwnGroup=h},setupWall:function(t,e,i,s,n,r){t?(this.walls[e]?this.walls[e].position=[this.pxmi(i),this.pxmi(s)]:(this.walls[e]=new p2.Body({mass:0,position:[this.pxmi(i),this.pxmi(s)],angle:n}),this.walls[e].addShape(new p2.Plane),this.world.addBody(this.walls[e])),r&&(this.walls[e].shapes[0].collisionGroup=this.boundsCollisionGroup.mask)):this.walls[e]&&(this.world.removeBody(this.walls[e]),this.walls[e]=null)},pause:function(){this.paused=!0},resume:function(){this.paused=!1},update:function(){this.paused||(this.useElapsedTime?this.world.step(this.game.time.physicsElapsed):this.world.step(this.frameRate))},reset:function(){this.world.on("beginContact",this.beginContactHandler,this),this.world.on("endContact",this.endContactHandler,this),this.nothingCollisionGroup=new e.Physics.P2.CollisionGroup(1),this.boundsCollisionGroup=new e.Physics.P2.CollisionGroup(2),this.everythingCollisionGroup=new e.Physics.P2.CollisionGroup(2147483648),this._collisionGroupID=2,this.setBoundsToWorld(!0,!0,!0,!0,!1)},clear:function(){this.world.time=0,this.world.fixedStepTime=0,this.world.solver&&this.world.solver.equations.length&&this.world.solver.removeAllEquations();for(var t=this.world.constraints,e=t.length-1;e>=0;e--)this.world.removeConstraint(t[e]);for(var i=this.world.bodies,e=i.length-1;e>=0;e--)this.world.removeBody(i[e]);for(var s=this.world.springs,e=s.length-1;e>=0;e--)this.world.removeSpring(s[e]);for(var n=this.world.contactMaterials,e=n.length-1;e>=0;e--)this.world.removeContactMaterial(n[e]);this.world.off("beginContact",this.beginContactHandler,this),this.world.off("endContact",this.endContactHandler,this),this.postBroadphaseCallback=null,this.callbackContext=null,this.impactCallback=null,this.collisionGroups=[],this._toRemove=[],this.boundsCollidesWith=[],this.walls={left:null,right:null,top:null,bottom:null}},destroy:function(){this.clear(),this.game=null},addBody:function(t){return!t.data.world&&(this.world.addBody(t.data),this.onBodyAdded.dispatch(t),!0)},removeBody:function(t){return t.data.world===this.world&&(this.world.removeBody(t.data),this.onBodyRemoved.dispatch(t)),t},addSpring:function(t){return t instanceof e.Physics.P2.Spring||t instanceof e.Physics.P2.RotationalSpring?this.world.addSpring(t.data):this.world.addSpring(t),this.onSpringAdded.dispatch(t),t},removeSpring:function(t){return t instanceof e.Physics.P2.Spring||t instanceof e.Physics.P2.RotationalSpring?this.world.removeSpring(t.data):this.world.removeSpring(t),this.onSpringRemoved.dispatch(t),t},createDistanceConstraint:function(t,i,s,n,r,o){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addConstraint(new e.Physics.P2.DistanceConstraint(this,t,i,s,n,r,o));console.warn("Cannot create Constraint, invalid body objects given")},createGearConstraint:function(t,i,s,n){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addConstraint(new e.Physics.P2.GearConstraint(this,t,i,s,n));console.warn("Cannot create Constraint, invalid body objects given")},createRevoluteConstraint:function(t,i,s,n,r,o){if(t=this.getBody(t),s=this.getBody(s),t&&s)return this.addConstraint(new e.Physics.P2.RevoluteConstraint(this,t,i,s,n,r,o));console.warn("Cannot create Constraint, invalid body objects given")},createLockConstraint:function(t,i,s,n,r){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addConstraint(new e.Physics.P2.LockConstraint(this,t,i,s,n,r));console.warn("Cannot create Constraint, invalid body objects given")},createPrismaticConstraint:function(t,i,s,n,r,o,a){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addConstraint(new e.Physics.P2.PrismaticConstraint(this,t,i,s,n,r,o,a));console.warn("Cannot create Constraint, invalid body objects given")},addConstraint:function(t){return this.world.addConstraint(t),this.onConstraintAdded.dispatch(t),t},removeConstraint:function(t){return this.world.removeConstraint(t),this.onConstraintRemoved.dispatch(t),t},addContactMaterial:function(t){return this.world.addContactMaterial(t),this.onContactMaterialAdded.dispatch(t),t},removeContactMaterial:function(t){return this.world.removeContactMaterial(t),this.onContactMaterialRemoved.dispatch(t),t},getContactMaterial:function(t,e){return this.world.getContactMaterial(t,e)},setMaterial:function(t,e){for(var i=e.length;i--;)e[i].setMaterial(t)},createMaterial:function(t,i){t=t||"";var s=new e.Physics.P2.Material(t);return this.materials.push(s),void 0!==i&&i.setMaterial(s),s},createContactMaterial:function(t,i,s){void 0===t&&(t=this.createMaterial()),void 0===i&&(i=this.createMaterial());var n=new e.Physics.P2.ContactMaterial(t,i,s);return this.addContactMaterial(n)},getBodies:function(){for(var t=[],e=this.world.bodies.length;e--;)t.push(this.world.bodies[e].parent);return t},getBody:function(t){return t instanceof p2.Body?t:t instanceof e.Physics.P2.Body?t.data:t.body&&t.body.type===e.Physics.P2JS?t.body.data:null},getSprings:function(){for(var t=[],e=this.world.springs.length;e--;)t.push(this.world.springs[e].parent);return t},getConstraints:function(){for(var t=[],e=this.world.constraints.length;e--;)t.push(this.world.constraints[e]);return t},hitTest:function(t,i,s,n){void 0===i&&(i=this.world.bodies),void 0===s&&(s=5),void 0===n&&(n=!1);for(var r=[this.pxmi(t.x),this.pxmi(t.y)],o=[],a=i.length;a--;)i[a]instanceof e.Physics.P2.Body&&(!n||i[a].data.type!==p2.Body.STATIC)?o.push(i[a].data):i[a]instanceof p2.Body&&i[a].parent&&(!n||i[a].type!==p2.Body.STATIC)?o.push(i[a]):i[a]instanceof e.Sprite&&i[a].hasOwnProperty("body")&&(!n||i[a].body.data.type!==p2.Body.STATIC)&&o.push(i[a].body.data);return this.world.hitTest(r,o,s)},toJSON:function(){return this.world.toJSON()},createCollisionGroup:function(t){var i=Math.pow(2,this._collisionGroupID);this.walls.left&&(this.walls.left.shapes[0].collisionMask=this.walls.left.shapes[0].collisionMask|i),this.walls.right&&(this.walls.right.shapes[0].collisionMask=this.walls.right.shapes[0].collisionMask|i),this.walls.top&&(this.walls.top.shapes[0].collisionMask=this.walls.top.shapes[0].collisionMask|i),this.walls.bottom&&(this.walls.bottom.shapes[0].collisionMask=this.walls.bottom.shapes[0].collisionMask|i),this._collisionGroupID++;var s=new e.Physics.P2.CollisionGroup(i);return this.collisionGroups.push(s),t&&this.setCollisionGroup(t,s),s},setCollisionGroup:function(t,i){if(t instanceof e.Group)for(var s=0;s<t.total;s++)t.children[s].body&&t.children[s].body.type===e.Physics.P2JS&&t.children[s].body.setCollisionGroup(i);else t.body.setCollisionGroup(i)},createSpring:function(t,i,s,n,r,o,a,h,l){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addSpring(new e.Physics.P2.Spring(this,t,i,s,n,r,o,a,h,l));console.warn("Cannot create Spring, invalid body objects given")},createRotationalSpring:function(t,i,s,n,r){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addSpring(new e.Physics.P2.RotationalSpring(this,t,i,s,n,r));console.warn("Cannot create Rotational Spring, invalid body objects given")},createBody:function(t,i,s,n,r,o){void 0===n&&(n=!1);var a=new e.Physics.P2.Body(this.game,null,t,i,s);return!(o&&!a.addPolygon(r,o))&&(n&&this.world.addBody(a.data),a)},createParticle:function(t,i,s,n,r,o){void 0===n&&(n=!1);var a=new e.Physics.P2.Body(this.game,null,t,i,s);return!(o&&!a.addPolygon(r,o))&&(n&&this.world.addBody(a.data),a)},convertCollisionObjects:function(t,e,i){void 0===i&&(i=!0);for(var s=[],n=0,r=t.collision[e].length;n<r;n++){var o=t.collision[e][n],a=o.polyline||o.polygon;if(a)var h=this.createBody(o.x,o.y,0,i,{},a);else o.rectangle&&(h=this.createBody(o.x,o.y,0,i)).addRectangle(o.width,o.height,o.width/2,o.height/2);h&&s.push(h)}return s},clearTilemapLayerBodies:function(t,e){e=t.getLayer(e);for(var i=t.layers[e].bodies.length;i--;)t.layers[e].bodies[i].destroy();t.layers[e].bodies.length=0},convertTilemap:function(t,e,i,s){e=t.getLayer(e),void 0===i&&(i=!0),void 0===s&&(s=!0),this.clearTilemapLayerBodies(t,e);for(var n=0,r=0,o=0,a=0,h=t.layers[e].height;a<h;a++){n=0;for(var l=0,c=t.layers[e].width;l<c;l++){var u=t.layers[e].data[a][l];if(u&&u.index>-1&&u.collides)if(s){var d=t.getTileRight(e,l,a);0===n&&(r=u.x*u.width,o=u.y*u.height,n=u.width),d&&d.collides?n+=u.width:((p=this.createBody(r,o,0,!1)).addRectangle(n,u.height,n/2,u.height/2,0),i&&this.addBody(p),t.layers[e].bodies.push(p),n=0)}else{var p=this.createBody(u.x*u.width,u.y*u.height,0,!1);p.addRectangle(u.width,u.height,u.width/2,u.height/2,0),i&&this.addBody(p),t.layers[e].bodies.push(p)}}}return t.layers[e].bodies},mpx:function(t){return t*=20},pxm:function(t){return.05*t},mpxi:function(t){return t*=-20},pxmi:function(t){return-.05*t}},Object.defineProperty(e.Physics.P2.prototype,"friction",{get:function(){return this.world.defaultContactMaterial.friction},set:function(t){this.world.defaultContactMaterial.friction=t}}),Object.defineProperty(e.Physics.P2.prototype,"restitution",{get:function(){return this.world.defaultContactMaterial.restitution},set:function(t){this.world.defaultContactMaterial.restitution=t}}),Object.defineProperty(e.Physics.P2.prototype,"contactMaterial",{get:function(){return this.world.defaultContactMaterial},set:function(t){this.world.defaultContactMaterial=t}}),Object.defineProperty(e.Physics.P2.prototype,"applySpringForces",{get:function(){return this.world.applySpringForces},set:function(t){this.world.applySpringForces=t}}),Object.defineProperty(e.Physics.P2.prototype,"applyDamping",{get:function(){return this.world.applyDamping},set:function(t){this.world.applyDamping=t}}),Object.defineProperty(e.Physics.P2.prototype,"applyGravity",{get:function(){return this.world.applyGravity},set:function(t){this.world.applyGravity=t}}),Object.defineProperty(e.Physics.P2.prototype,"solveConstraints",{get:function(){return this.world.solveConstraints},set:function(t){this.world.solveConstraints=t}}),Object.defineProperty(e.Physics.P2.prototype,"time",{get:function(){return this.world.time}}),Object.defineProperty(e.Physics.P2.prototype,"emitImpactEvent",{get:function(){return this.world.emitImpactEvent},set:function(t){this.world.emitImpactEvent=t}}),Object.defineProperty(e.Physics.P2.prototype,"sleepMode",{get:function(){return this.world.sleepMode},set:function(t){this.world.sleepMode=t}}),Object.defineProperty(e.Physics.P2.prototype,"total",{get:function(){return this.world.bodies.length}}),e.Physics.P2.FixtureList=function(t){Array.isArray(t)||(t=[t]),this.rawList=t,this.init(),this.parse(this.rawList)},e.Physics.P2.FixtureList.prototype={init:function(){this.namedFixtures={},this.groupedFixtures=[],this.allFixtures=[]},setCategory:function(t,e){this.getFixtures(e).forEach(function(e){e.collisionGroup=t})},setMask:function(t,e){this.getFixtures(e).forEach(function(e){e.collisionMask=t})},setSensor:function(t,e){this.getFixtures(e).forEach(function(e){e.sensor=t})},setMaterial:function(t,e){this.getFixtures(e).forEach(function(e){e.material=t})},getFixtures:function(t){var e=[];if(t){t instanceof Array||(t=[t]);var i=this;return t.forEach(function(t){i.namedFixtures[t]&&e.push(i.namedFixtures[t])}),this.flatten(e)}return this.allFixtures},getFixtureByKey:function(t){return this.namedFixtures[t]},getGroup:function(t){return this.groupedFixtures[t]},parse:function(){var t,e,i,s;i=this.rawList,s=[];for(t in i)e=i[t],isNaN(t-0)?this.namedFixtures[t]=this.flatten(e):(this.groupedFixtures[t]=this.groupedFixtures[t]||[],this.groupedFixtures[t]=this.groupedFixtures[t].concat(e)),s.push(this.allFixtures=this.flatten(this.groupedFixtures))},flatten:function(t){var e,i;return e=[],i=arguments.callee,t.forEach(function(t){return Array.prototype.push.apply(e,Array.isArray(t)?i(t):[t])}),e}},e.Physics.P2.PointProxy=function(t,e){this.world=t,this.destination=e},e.Physics.P2.PointProxy.prototype.constructor=e.Physics.P2.PointProxy,Object.defineProperty(e.Physics.P2.PointProxy.prototype,"x",{get:function(){return this.world.mpx(this.destination[0])},set:function(t){this.destination[0]=this.world.pxm(t)}}),Object.defineProperty(e.Physics.P2.PointProxy.prototype,"y",{get:function(){return this.world.mpx(this.destination[1])},set:function(t){this.destination[1]=this.world.pxm(t)}}),Object.defineProperty(e.Physics.P2.PointProxy.prototype,"mx",{get:function(){return this.destination[0]},set:function(t){this.destination[0]=t}}),Object.defineProperty(e.Physics.P2.PointProxy.prototype,"my",{get:function(){return this.destination[1]},set:function(t){this.destination[1]=t}}),e.Physics.P2.InversePointProxy=function(t,e){this.world=t,this.destination=e},e.Physics.P2.InversePointProxy.prototype.constructor=e.Physics.P2.InversePointProxy,Object.defineProperty(e.Physics.P2.InversePointProxy.prototype,"x",{get:function(){return this.world.mpxi(this.destination[0])},set:function(t){this.destination[0]=this.world.pxmi(t)}}),Object.defineProperty(e.Physics.P2.InversePointProxy.prototype,"y",{get:function(){return this.world.mpxi(this.destination[1])},set:function(t){this.destination[1]=this.world.pxmi(t)}}),Object.defineProperty(e.Physics.P2.InversePointProxy.prototype,"mx",{get:function(){return this.destination[0]},set:function(t){this.destination[0]=-t}}),Object.defineProperty(e.Physics.P2.InversePointProxy.prototype,"my",{get:function(){return this.destination[1]},set:function(t){this.destination[1]=-t}}),e.Physics.P2.Body=function(t,i,s,n,r){i=i||null,s=s||0,n=n||0,void 0===r&&(r=1),this.game=t,this.world=t.physics.p2,this.sprite=i,this.type=e.Physics.P2JS,this.offset=new e.Point,this.data=new p2.Body({position:[this.world.pxmi(s),this.world.pxmi(n)],mass:r}),this.data.parent=this,this.velocity=new e.Physics.P2.InversePointProxy(this.world,this.data.velocity),this.force=new e.Physics.P2.InversePointProxy(this.world,this.data.force),this.gravity=new e.Point,this.onBeginContact=new e.Signal,this.onEndContact=new e.Signal,this.collidesWith=[],this.removeNextStep=!1,this.debugBody=null,this.dirty=!1,this._collideWorldBounds=!0,this._bodyCallbacks={},this._bodyCallbackContext={},this._groupCallbacks={},this._groupCallbackContext={},this._reset=!1,i&&(this.setRectangleFromSprite(i),i.exists&&this.game.physics.p2.addBody(this))},e.Physics.P2.Body.prototype={createBodyCallback:function(t,e,i){var s=-1;t.id?s=t.id:t.body&&(s=t.body.id),s>-1&&(null===e?(delete this._bodyCallbacks[s],delete this._bodyCallbackContext[s]):(this._bodyCallbacks[s]=e,this._bodyCallbackContext[s]=i))},createGroupCallback:function(t,e,i){null===e?(delete this._groupCallbacks[t.mask],delete this._groupCallbackContext[t.mask]):(this._groupCallbacks[t.mask]=e,this._groupCallbackContext[t.mask]=i)},getCollisionMask:function(){var t=0;this._collideWorldBounds&&(t=this.game.physics.p2.boundsCollisionGroup.mask);for(var e=0;e<this.collidesWith.length;e++)t|=this.collidesWith[e].mask;return t},updateCollisionMask:function(t){var e=this.getCollisionMask();if(void 0===t)for(var i=this.data.shapes.length-1;i>=0;i--)this.data.shapes[i].collisionMask=e;else t.collisionMask=e},setCollisionGroup:function(t,e){var i=this.getCollisionMask();if(void 0===e)for(var s=this.data.shapes.length-1;s>=0;s--)this.data.shapes[s].collisionGroup=t.mask,this.data.shapes[s].collisionMask=i;else e.collisionGroup=t.mask,e.collisionMask=i},clearCollision:function(t,e,i){if(void 0===t&&(t=!0),void 0===e&&(e=!0),void 0===i)for(var s=this.data.shapes.length-1;s>=0;s--)t&&(this.data.shapes[s].collisionGroup=null),e&&(this.data.shapes[s].collisionMask=null);else t&&(i.collisionGroup=null),e&&(i.collisionMask=null);t&&(this.collidesWith.length=0)},removeCollisionGroup:function(t,e,i){void 0===e&&(e=!0);var s;if(Array.isArray(t))for(r=0;r<t.length;r++)(s=this.collidesWith.indexOf(t[r]))>-1&&(this.collidesWith.splice(s,1),e&&(delete this._groupCallbacks[t.mask],delete this._groupCallbackContext[t.mask]));else(s=this.collidesWith.indexOf(t))>-1&&(this.collidesWith.splice(s,1),e&&(delete this._groupCallbacks[t.mask],delete this._groupCallbackContext[t.mask]));var n=this.getCollisionMask();if(void 0===i)for(var r=this.data.shapes.length-1;r>=0;r--)this.data.shapes[r].collisionMask=n;else i.collisionMask=n},collides:function(t,e,i,s){if(Array.isArray(t))for(r=0;r<t.length;r++)-1===this.collidesWith.indexOf(t[r])&&(this.collidesWith.push(t[r]),e&&this.createGroupCallback(t[r],e,i));else-1===this.collidesWith.indexOf(t)&&(this.collidesWith.push(t),e&&this.createGroupCallback(t,e,i));var n=this.getCollisionMask();if(void 0===s)for(var r=this.data.shapes.length-1;r>=0;r--)this.data.shapes[r].collisionMask=n;else s.collisionMask=n},adjustCenterOfMass:function(){this.data.adjustCenterOfMass(),this.shapeChanged()},getVelocityAtPoint:function(t,e){return this.data.getVelocityAtPoint(t,e)},applyDamping:function(t){this.data.applyDamping(t)},applyImpulse:function(t,e,i){this.data.applyImpulse(t,[this.world.pxmi(e),this.world.pxmi(i)])},applyImpulseLocal:function(t,e,i){this.data.applyImpulseLocal(t,[this.world.pxmi(e),this.world.pxmi(i)])},applyForce:function(t,e,i){this.data.applyForce(t,[this.world.pxmi(e),this.world.pxmi(i)])},setZeroForce:function(){this.data.setZeroForce()},setZeroRotation:function(){this.data.angularVelocity=0},setZeroVelocity:function(){this.data.velocity[0]=0,this.data.velocity[1]=0},setZeroDamping:function(){this.data.damping=0,this.data.angularDamping=0},toLocalFrame:function(t,e){return this.data.toLocalFrame(t,e)},toWorldFrame:function(t,e){return this.data.toWorldFrame(t,e)},rotateLeft:function(t){this.data.angularVelocity=this.world.pxm(-t)},rotateRight:function(t){this.data.angularVelocity=this.world.pxm(t)},moveForward:function(t){var e=this.world.pxmi(-t),i=this.data.angle+Math.PI/2;this.data.velocity[0]=e*Math.cos(i),this.data.velocity[1]=e*Math.sin(i)},moveBackward:function(t){var e=this.world.pxmi(-t),i=this.data.angle+Math.PI/2;this.data.velocity[0]=-e*Math.cos(i),this.data.velocity[1]=-e*Math.sin(i)},thrust:function(t){var e=this.world.pxmi(-t),i=this.data.angle+Math.PI/2;this.data.force[0]+=e*Math.cos(i),this.data.force[1]+=e*Math.sin(i)},thrustLeft:function(t){var e=this.world.pxmi(-t),i=this.data.angle;this.data.force[0]+=e*Math.cos(i),this.data.force[1]+=e*Math.sin(i)},thrustRight:function(t){var e=this.world.pxmi(-t),i=this.data.angle;this.data.force[0]-=e*Math.cos(i),this.data.force[1]-=e*Math.sin(i)},reverse:function(t){var e=this.world.pxmi(-t),i=this.data.angle+Math.PI/2;this.data.force[0]-=e*Math.cos(i),this.data.force[1]-=e*Math.sin(i)},moveLeft:function(t){this.data.velocity[0]=this.world.pxmi(-t)},moveRight:function(t){this.data.velocity[0]=this.world.pxmi(t)},moveUp:function(t){this.data.velocity[1]=this.world.pxmi(-t)},moveDown:function(t){this.data.velocity[1]=this.world.pxmi(t)},preUpdate:function(){this.dirty=!0,this.removeNextStep&&(this.removeFromWorld(),this.removeNextStep=!1)},postUpdate:function(){this.sprite.x=this.world.mpxi(this.data.position[0])+this.offset.x,this.sprite.y=this.world.mpxi(this.data.position[1])+this.offset.y,this.fixedRotation||(this.sprite.rotation=this.data.angle),this.debugBody&&this.debugBody.updateSpriteTransform(),this.dirty=!1},reset:function(t,e,i,s){void 0===i&&(i=!1),void 0===s&&(s=!1),this.setZeroForce(),this.setZeroVelocity(),this.setZeroRotation(),i&&this.setZeroDamping(),s&&(this.mass=1),this.x=t,this.y=e},addToWorld:function(){if(this.game.physics.p2._toRemove)for(var t=0;t<this.game.physics.p2._toRemove.length;t++)this.game.physics.p2._toRemove[t]===this&&this.game.physics.p2._toRemove.splice(t,1);this.data.world!==this.game.physics.p2.world&&this.game.physics.p2.addBody(this)},removeFromWorld:function(){this.data.world===this.game.physics.p2.world&&this.game.physics.p2.removeBodyNextStep(this)},destroy:function(){this.removeFromWorld(),this.clearShapes(),this._bodyCallbacks={},this._bodyCallbackContext={},this._groupCallbacks={},this._groupCallbackContext={},this.debugBody&&this.debugBody.destroy(!0,!0),this.debugBody=null,this.sprite&&(this.sprite.body=null,this.sprite=null)},clearShapes:function(){for(var t=this.data.shapes.length;t--;)this.data.removeShape(this.data.shapes[t]);this.shapeChanged()},addShape:function(t,e,i,s){return void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),this.data.addShape(t,[this.world.pxmi(e),this.world.pxmi(i)],s),this.shapeChanged(),t},addCircle:function(t,e,i,s){var n=new p2.Circle({radius:this.world.pxm(t)});return this.addShape(n,e,i,s)},addRectangle:function(t,e,i,s,n){var r=new p2.Box({width:this.world.pxm(t),height:this.world.pxm(e)});return this.addShape(r,i,s,n)},addPlane:function(t,e,i){var s=new p2.Plane;return this.addShape(s,t,e,i)},addParticle:function(t,e,i){var s=new p2.Particle;return this.addShape(s,t,e,i)},addLine:function(t,e,i,s){var n=new p2.Line({length:this.world.pxm(t)});return this.addShape(n,e,i,s)},addCapsule:function(t,e,i,s,n){var r=new p2.Capsule({length:this.world.pxm(t),radius:this.world.pxm(e)});return this.addShape(r,i,s,n)},addPolygon:function(t,e){t=t||{},Array.isArray(e)||(e=Array.prototype.slice.call(arguments,1));var i=[];if(1===e.length&&Array.isArray(e[0]))i=e[0].slice(0);else if(Array.isArray(e[0]))i=e.slice();else if("number"==typeof e[0])for(var s=0,n=e.length;s<n;s+=2)i.push([e[s],e[s+1]]);var r=i.length-1;i[r][0]===i[0][0]&&i[r][1]===i[0][1]&&i.pop();for(var o=0;o<i.length;o++)i[o][0]=this.world.pxmi(i[o][0]),i[o][1]=this.world.pxmi(i[o][1]);var a=this.data.fromPolygon(i,t);return this.shapeChanged(),a},removeShape:function(t){var e=this.data.removeShape(t);return this.shapeChanged(),e},setCircle:function(t,e,i,s){return this.clearShapes(),this.addCircle(t,e,i,s)},setRectangle:function(t,e,i,s,n){return void 0===t&&(t=16),void 0===e&&(e=16),this.clearShapes(),this.addRectangle(t,e,i,s,n)},setRectangleFromSprite:function(t){return void 0===t&&(t=this.sprite),this.clearShapes(),this.addRectangle(t.width,t.height,0,0,t.rotation)},setMaterial:function(t,e){if(void 0===e)for(var i=this.data.shapes.length-1;i>=0;i--)this.data.shapes[i].material=t;else e.material=t},shapeChanged:function(){this.debugBody&&this.debugBody.draw()},addPhaserPolygon:function(t,e){for(var i=this.game.cache.getPhysicsData(t,e),s=[],n=0;n<i.length;n++){var r=i[n],o=this.addFixture(r);s[r.filter.group]=s[r.filter.group]||[],s[r.filter.group]=s[r.filter.group].concat(o),r.fixtureKey&&(s[r.fixtureKey]=o)}return this.data.aabbNeedsUpdate=!0,this.shapeChanged(),s},addFixture:function(t){var e=[];if(t.circle){(l=new p2.Circle({radius:this.world.pxm(t.circle.radius)})).collisionGroup=t.filter.categoryBits,l.collisionMask=t.filter.maskBits,l.sensor=t.isSensor;var i=p2.vec2.create();i[0]=this.world.pxmi(t.circle.position[0]-this.sprite.width/2),i[1]=this.world.pxmi(t.circle.position[1]-this.sprite.height/2),this.data.addShape(l,i),e.push(l)}else for(var s=t.polygons,n=p2.vec2.create(),r=0;r<s.length;r++){for(var o=s[r],a=[],h=0;h<o.length;h+=2)a.push([this.world.pxmi(o[h]),this.world.pxmi(o[h+1])]);for(var l=new p2.Convex({vertices:a}),c=0;c!==l.vertices.length;c++){var u=l.vertices[c];p2.vec2.sub(u,u,l.centerOfMass)}p2.vec2.scale(n,l.centerOfMass,1),n[0]-=this.world.pxmi(this.sprite.width/2),n[1]-=this.world.pxmi(this.sprite.height/2),l.updateTriangles(),l.updateCenterOfMass(),l.updateBoundingRadius(),l.collisionGroup=t.filter.categoryBits,l.collisionMask=t.filter.maskBits,l.sensor=t.isSensor,this.data.addShape(l,n),e.push(l)}return e},loadPolygon:function(t,e,i){if(null===t)s=e;else var s=this.game.cache.getPhysicsData(t,e);"number"!=typeof i&&(i=1);for(var n=p2.vec2.create(),r=0;r<s.length;r++){for(var o=[],a=0;a<s[r].shape.length;a+=2)o.push([this.world.pxmi(s[r].shape[a]*i),this.world.pxmi(s[r].shape[a+1]*i)]);for(var h=new p2.Convex({vertices:o}),l=0;l!==h.vertices.length;l++){var c=h.vertices[l];p2.vec2.sub(c,c,h.centerOfMass)}p2.vec2.scale(n,h.centerOfMass,1),n[0]-=this.world.pxmi(this.sprite.width/2),n[1]-=this.world.pxmi(this.sprite.height/2),h.updateTriangles(),h.updateCenterOfMass(),h.updateBoundingRadius(),this.data.addShape(h,n)}return this.data.aabbNeedsUpdate=!0,this.shapeChanged(),!0}},e.Physics.P2.Body.prototype.constructor=e.Physics.P2.Body,e.Physics.P2.Body.DYNAMIC=1,e.Physics.P2.Body.STATIC=2,e.Physics.P2.Body.KINEMATIC=4,Object.defineProperty(e.Physics.P2.Body.prototype,"static",{get:function(){return this.data.type===e.Physics.P2.Body.STATIC},set:function(t){t&&this.data.type!==e.Physics.P2.Body.STATIC?(this.data.type=e.Physics.P2.Body.STATIC,this.mass=0):t||this.data.type!==e.Physics.P2.Body.STATIC||(this.data.type=e.Physics.P2.Body.DYNAMIC,this.mass=1)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"dynamic",{get:function(){return this.data.type===e.Physics.P2.Body.DYNAMIC},set:function(t){t&&this.data.type!==e.Physics.P2.Body.DYNAMIC?(this.data.type=e.Physics.P2.Body.DYNAMIC,this.mass=1):t||this.data.type!==e.Physics.P2.Body.DYNAMIC||(this.data.type=e.Physics.P2.Body.STATIC,this.mass=0)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"kinematic",{get:function(){return this.data.type===e.Physics.P2.Body.KINEMATIC},set:function(t){t&&this.data.type!==e.Physics.P2.Body.KINEMATIC?(this.data.type=e.Physics.P2.Body.KINEMATIC,this.mass=4):t||this.data.type!==e.Physics.P2.Body.KINEMATIC||(this.data.type=e.Physics.P2.Body.STATIC,this.mass=0)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"allowSleep",{get:function(){return this.data.allowSleep},set:function(t){t!==this.data.allowSleep&&(this.data.allowSleep=t)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"angle",{get:function(){return e.Math.wrapAngle(e.Math.radToDeg(this.data.angle))},set:function(t){this.data.angle=e.Math.degToRad(e.Math.wrapAngle(t))}}),Object.defineProperty(e.Physics.P2.Body.prototype,"angularDamping",{get:function(){return this.data.angularDamping},set:function(t){this.data.angularDamping=t}}),Object.defineProperty(e.Physics.P2.Body.prototype,"angularForce",{get:function(){return this.data.angularForce},set:function(t){this.data.angularForce=t}}),Object.defineProperty(e.Physics.P2.Body.prototype,"angularVelocity",{get:function(){return this.data.angularVelocity},set:function(t){this.data.angularVelocity=t}}),Object.defineProperty(e.Physics.P2.Body.prototype,"damping",{get:function(){return this.data.damping},set:function(t){this.data.damping=t}}),Object.defineProperty(e.Physics.P2.Body.prototype,"fixedRotation",{get:function(){return this.data.fixedRotation},set:function(t){t!==this.data.fixedRotation&&(this.data.fixedRotation=t)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"inertia",{get:function(){return this.data.inertia},set:function(t){this.data.inertia=t}}),Object.defineProperty(e.Physics.P2.Body.prototype,"mass",{get:function(){return this.data.mass},set:function(t){t!==this.data.mass&&(this.data.mass=t,this.data.updateMassProperties())}}),Object.defineProperty(e.Physics.P2.Body.prototype,"motionState",{get:function(){return this.data.type},set:function(t){t!==this.data.type&&(this.data.type=t)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"rotation",{get:function(){return this.data.angle},set:function(t){this.data.angle=t}}),Object.defineProperty(e.Physics.P2.Body.prototype,"sleepSpeedLimit",{get:function(){return this.data.sleepSpeedLimit},set:function(t){this.data.sleepSpeedLimit=t}}),Object.defineProperty(e.Physics.P2.Body.prototype,"x",{get:function(){return this.world.mpxi(this.data.position[0])},set:function(t){this.data.position[0]=this.world.pxmi(t)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"y",{get:function(){return this.world.mpxi(this.data.position[1])},set:function(t){this.data.position[1]=this.world.pxmi(t)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"id",{get:function(){return this.data.id}}),Object.defineProperty(e.Physics.P2.Body.prototype,"debug",{get:function(){return null!==this.debugBody},set:function(t){t&&!this.debugBody?this.debugBody=new e.Physics.P2.BodyDebug(this.game,this.data):!t&&this.debugBody&&(this.debugBody.destroy(),this.debugBody=null)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"collideWorldBounds",{get:function(){return this._collideWorldBounds},set:function(t){t&&!this._collideWorldBounds?(this._collideWorldBounds=!0,this.updateCollisionMask()):!t&&this._collideWorldBounds&&(this._collideWorldBounds=!1,this.updateCollisionMask())}}),e.Physics.P2.BodyDebug=function(t,i,s){e.Group.call(this,t);var n={pixelsPerLengthUnit:t.physics.p2.mpx(1),debugPolygons:!1,lineWidth:1,alpha:.5};this.settings=Object.assign(n,s),this.ppu=this.settings.pixelsPerLengthUnit,this.ppu=-1*this.ppu,this.body=i,this.canvas=new e.Graphics(t),this.canvas.alpha=this.settings.alpha,this.add(this.canvas),this.draw(),this.updateSpriteTransform()},e.Physics.P2.BodyDebug.prototype=Object.create(e.Group.prototype),e.Physics.P2.BodyDebug.prototype.constructor=e.Physics.P2.BodyDebug,Object.assign(e.Physics.P2.BodyDebug.prototype,{updateSpriteTransform:function(){this.position.x=this.body.position[0]*this.ppu,this.position.y=this.body.position[1]*this.ppu,this.rotation=this.body.angle},draw:function(){var t,e,i,s,n,r,o,a,h,l,c,u,d,p;if(o=this.body,(h=this.canvas).clear(),i=parseInt(this.randomPastelHex(),16),16711680,r=this.lineWidth,o instanceof p2.Body&&o.shapes.length){var f=o.shapes.length;for(s=0;s!==f;){if(e=o.shapes[s],a=e.position||0,t=e.angle||0,e instanceof p2.Circle)this.drawCircle(h,a[0]*this.ppu,a[1]*this.ppu,t,e.radius*this.ppu,i,r);else if(e instanceof p2.Capsule)this.drawCapsule(h,a[0]*this.ppu,a[1]*this.ppu,t,e.length*this.ppu,e.radius*this.ppu,16711680,i,r);else if(e instanceof p2.Plane)this.drawPlane(h,a[0]*this.ppu,-a[1]*this.ppu,i,16711680,5*r,10*r,10*r,100*this.ppu,t);else if(e instanceof p2.Line)this.drawLine(h,e.length*this.ppu,16711680,r);else if(e instanceof p2.Box)this.drawRectangle(h,a[0]*this.ppu,a[1]*this.ppu,t,e.width*this.ppu,e.height*this.ppu,16711680,i,r);else if(e instanceof p2.Convex){for(c=[],u=p2.vec2.create(),n=d=0,p=e.vertices.length;p>=0?d<p:d>p;n=p>=0?++d:--d)l=e.vertices[n],p2.vec2.rotate(u,l,t),c.push([(u[0]+a[0])*this.ppu,-(u[1]+a[1])*this.ppu]);this.drawConvex(h,c,e.triangles,16711680,i,r,this.settings.debugPolygons,[a[0]*this.ppu,-a[1]*this.ppu])}s++}}},drawRectangle:function(t,e,i,s,n,r,o,a,h){void 0===h&&(h=1),void 0===o&&(o=0),t.lineStyle(h,o,1),t.beginFill(a),t.drawRect(e-n/2,i-r/2,n,r)},drawCircle:function(t,e,i,s,n,r,o){void 0===o&&(o=1),void 0===r&&(r=16777215),t.lineStyle(o,0,1),t.beginFill(r,1),t.drawCircle(e,i,2*-n),t.endFill(),t.moveTo(e,i),t.lineTo(e+n*Math.cos(-s),i+n*Math.sin(-s))},drawLine:function(t,e,i,s){void 0===s&&(s=1),void 0===i&&(i=0),t.lineStyle(5*s,i,1),t.moveTo(-e/2,0),t.lineTo(e/2,0)},drawConvex:function(t,e,i,s,n,r,o,a){var h,l,c,u,d,p,f,g,m,y,v;if(void 0===r&&(r=1),void 0===s&&(s=0),o){for(h=[16711680,65280,255],l=0;l!==e.length+1;)u=e[l%e.length],d=e[(l+1)%e.length],f=u[0],y=u[1],g=d[0],v=d[1],t.lineStyle(r,h[l%h.length],1),t.moveTo(f,-y),t.lineTo(g,-v),t.drawCircle(f,-y,2*r),l++;return t.lineStyle(r,0,1),t.drawCircle(a[0],a[1],2*r)}for(t.lineStyle(r,s,1),t.beginFill(n),l=0;l!==e.length;)p=(c=e[l])[0],m=c[1],0===l?t.moveTo(p,-m):t.lineTo(p,-m),l++;if(t.endFill(),e.length>2)return t.moveTo(e[e.length-1][0],-e[e.length-1][1]),t.lineTo(e[0][0],-e[0][1])},drawPath:function(t,e,i,s,n){var r,o,a,h,l,c,u,d,p,f,g;for(void 0===n&&(n=1),void 0===i&&(i=0),t.lineStyle(n,i,1),"number"==typeof s&&t.beginFill(s),o=null,a=null,r=0;r<e.length;)f=(p=e[r])[0],g=p[1],f===o&&g===a||(0===r?t.moveTo(f,g):(h=o,l=a,c=f,u=g,d=e[(r+1)%e.length][0],0!==(c-h)*(e[(r+1)%e.length][1]-l)-(d-h)*(u-l)&&t.lineTo(f,g)),o=f,a=g),r++;"number"==typeof s&&t.endFill(),e.length>2&&"number"==typeof s&&(t.moveTo(e[e.length-1][0],e[e.length-1][1]),t.lineTo(e[0][0],e[0][1]))},drawPlane:function(t,e,i,s,n,r,o,a,h,l){var c,u;void 0===r&&(r=1),void 0===s&&(s=16777215),t.lineStyle(r,n,11),t.beginFill(s),t.moveTo(e,-i),c=e+Math.cos(l)*this.game.width,u=i+Math.sin(l)*this.game.height,t.lineTo(c,-u),t.moveTo(e,-i),c=e+Math.cos(l)*-this.game.width,u=i+Math.sin(l)*-this.game.height,t.lineTo(c,-u)},drawCapsule:function(t,e,i,s,n,r,o,a,h){void 0===h&&(h=1),void 0===o&&(o=0),t.lineStyle(h,o,1);var l=Math.cos(s),c=Math.sin(s);t.beginFill(a,1),t.drawCircle(-n/2*l+e,-n/2*c+i,2*-r),t.drawCircle(n/2*l+e,n/2*c+i,2*-r),t.endFill(),t.lineStyle(h,o,0),t.beginFill(a,1),t.moveTo(-n/2*l+r*c+e,-n/2*c+r*l+i),t.lineTo(n/2*l+r*c+e,n/2*c+r*l+i),t.lineTo(n/2*l-r*c+e,n/2*c-r*l+i),t.lineTo(-n/2*l-r*c+e,-n/2*c-r*l+i),t.endFill(),t.lineStyle(h,o,1),t.moveTo(-n/2*l+r*c+e,-n/2*c+r*l+i),t.lineTo(n/2*l+r*c+e,n/2*c+r*l+i),t.moveTo(-n/2*l-r*c+e,-n/2*c-r*l+i),t.lineTo(n/2*l-r*c+e,n/2*c-r*l+i)},randomPastelHex:function(){var t,e,i,s;return i=[255,255,255],s=Math.floor(256*Math.random()),e=Math.floor(256*Math.random()),t=Math.floor(256*Math.random()),s=Math.floor((s+3*i[0])/4),e=Math.floor((e+3*i[1])/4),t=Math.floor((t+3*i[2])/4),this.rgbToHex(s,e,t)},rgbToHex:function(t,e,i){return this.componentToHex(t)+this.componentToHex(e)+this.componentToHex(i)},componentToHex:function(t){var e;return 2===(e=t.toString(16)).length?e:e+"0"}}),e.Physics.P2.Spring=function(t,e,i,s,n,r,o,a,h,l){this.game=t.game,this.world=t,void 0===s&&(s=1),void 0===n&&(n=100),void 0===r&&(r=1);var c={restLength:s=t.pxm(s),stiffness:n,damping:r};void 0!==o&&null!==o&&(c.worldAnchorA=[t.pxm(o[0]),t.pxm(o[1])]),void 0!==a&&null!==a&&(c.worldAnchorB=[t.pxm(a[0]),t.pxm(a[1])]),void 0!==h&&null!==h&&(c.localAnchorA=[t.pxm(h[0]),t.pxm(h[1])]),void 0!==l&&null!==l&&(c.localAnchorB=[t.pxm(l[0]),t.pxm(l[1])]),this.data=new p2.LinearSpring(e,i,c),this.data.parent=this},e.Physics.P2.Spring.prototype.constructor=e.Physics.P2.Spring,e.Physics.P2.RotationalSpring=function(t,e,i,s,n,r){this.game=t.game,this.world=t,void 0===s&&(s=null),void 0===n&&(n=100),void 0===r&&(r=1),s&&(s=t.pxm(s));var o={restAngle:s,stiffness:n,damping:r};this.data=new p2.RotationalSpring(e,i,o),this.data.parent=this},e.Physics.P2.Spring.prototype.constructor=e.Physics.P2.Spring,e.Physics.P2.Material=function(t){this.name=t,p2.Material.call(this)},e.Physics.P2.Material.prototype=Object.create(p2.Material.prototype),e.Physics.P2.Material.prototype.constructor=e.Physics.P2.Material,e.Physics.P2.ContactMaterial=function(t,e,i){p2.ContactMaterial.call(this,t,e,i)},e.Physics.P2.ContactMaterial.prototype=Object.create(p2.ContactMaterial.prototype),e.Physics.P2.ContactMaterial.prototype.constructor=e.Physics.P2.ContactMaterial,e.Physics.P2.CollisionGroup=function(t){this.mask=t},e.Physics.P2.DistanceConstraint=function(t,e,i,s,n,r,o){void 0===s&&(s=100),void 0===n&&(n=[0,0]),void 0===r&&(r=[0,0]),void 0===o&&(o=Number.MAX_VALUE),this.game=t.game,this.world=t;var a={distance:s=t.pxm(s),localAnchorA:n=[t.pxmi(n[0]),t.pxmi(n[1])],localAnchorB:r=[t.pxmi(r[0]),t.pxmi(r[1])],maxForce:o};p2.DistanceConstraint.call(this,e,i,a)},e.Physics.P2.DistanceConstraint.prototype=Object.create(p2.DistanceConstraint.prototype),e.Physics.P2.DistanceConstraint.prototype.constructor=e.Physics.P2.DistanceConstraint,e.Physics.P2.GearConstraint=function(t,e,i,s,n){void 0===s&&(s=0),void 0===n&&(n=1),this.game=t.game,this.world=t;var r={angle:s,ratio:n};p2.GearConstraint.call(this,e,i,r)},e.Physics.P2.GearConstraint.prototype=Object.create(p2.GearConstraint.prototype),e.Physics.P2.GearConstraint.prototype.constructor=e.Physics.P2.GearConstraint,e.Physics.P2.LockConstraint=function(t,e,i,s,n,r){void 0===s&&(s=[0,0]),void 0===n&&(n=0),void 0===r&&(r=Number.MAX_VALUE),this.game=t.game,this.world=t;var o={localOffsetB:s=[t.pxm(s[0]),t.pxm(s[1])],localAngleB:n,maxForce:r};p2.LockConstraint.call(this,e,i,o)},e.Physics.P2.LockConstraint.prototype=Object.create(p2.LockConstraint.prototype),e.Physics.P2.LockConstraint.prototype.constructor=e.Physics.P2.LockConstraint,e.Physics.P2.PrismaticConstraint=function(t,e,i,s,n,r,o,a){void 0===s&&(s=!0),void 0===n&&(n=[0,0]),void 0===r&&(r=[0,0]),void 0===o&&(o=[0,0]),void 0===a&&(a=Number.MAX_VALUE),this.game=t.game,this.world=t;var h={localAnchorA:n=[t.pxmi(n[0]),t.pxmi(n[1])],localAnchorB:r=[t.pxmi(r[0]),t.pxmi(r[1])],localAxisA:o,maxForce:a,disableRotationalLock:!s};p2.PrismaticConstraint.call(this,e,i,h)},e.Physics.P2.PrismaticConstraint.prototype=Object.create(p2.PrismaticConstraint.prototype),e.Physics.P2.PrismaticConstraint.prototype.constructor=e.Physics.P2.PrismaticConstraint,e.Physics.P2.RevoluteConstraint=function(t,e,i,s,n,r,o){void 0===r&&(r=Number.MAX_VALUE),void 0===o&&(o=null),this.game=t.game,this.world=t,i=[t.pxmi(i[0]),t.pxmi(i[1])],n=[t.pxmi(n[0]),t.pxmi(n[1])],o&&(o=[t.pxmi(o[0]),t.pxmi(o[1])]);var a={worldPivot:o,localPivotA:i,localPivotB:n,maxForce:r};p2.RevoluteConstraint.call(this,e,s,a)},e.Physics.P2.RevoluteConstraint.prototype=Object.create(p2.RevoluteConstraint.prototype),e.Physics.P2.RevoluteConstraint.prototype.constructor=e.Physics.P2.RevoluteConstraint,e.ImageCollection=function(t,e,i,s,n,r,o){(void 0===i||i<=0)&&(i=32),(void 0===s||s<=0)&&(s=32),void 0===n&&(n=0),void 0===r&&(r=0),this.name=t,this.firstgid=0|e,this.imageWidth=0|i,this.imageHeight=0|s,this.imageMargin=0|n,this.imageSpacing=0|r,this.properties=o||{},this.images=[],this.total=0},e.ImageCollection.prototype={containsImageIndex:function(t){return t>=this.firstgid&&t<this.firstgid+this.total},addImage:function(t,e){this.images.push({gid:t,image:e}),this.total++}},e.ImageCollection.prototype.constructor=e.ImageCollection,e.Tile=function(t,e,i,s,n,r){this.layer=t,this.index=e,this.x=i,this.y=s,this.rotation=0,this.flipped=!1,this.worldX=i*n,this.worldY=s*r,this.width=n,this.height=r,this.centerX=Math.abs(n/2),this.centerY=Math.abs(r/2),this.alpha=1,this.properties={},this.scanned=!1,this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.collisionCallback=null,this.collisionCallbackContext=this,this.debug=!1},e.Tile.prototype={containsPoint:function(t,e){return!(t<this.worldX||e<this.worldY||t>this.right||e>this.bottom)},intersects:function(t,e,i,s){return!(i<=this.worldX)&&(!(s<=this.worldY)&&(!(t>=this.worldX+this.width)&&!(e>=this.worldY+this.height)))},setCollisionCallback:function(t,e){this.collisionCallback=t,this.collisionCallbackContext=e},destroy:function(){this.collisionCallback=null,this.collisionCallbackContext=null,this.properties=null},setCollision:function(t,e,i,s){this.collideLeft=t,this.collideRight=e,this.collideUp=i,this.collideDown=s,this.faceLeft=t,this.faceRight=e,this.faceTop=i,this.faceBottom=s},resetCollision:function(){this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1},isInteresting:function(t,e){return t&&e?this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.faceTop||this.faceBottom||this.faceLeft||this.faceRight||this.collisionCallback:t?this.collideLeft||this.collideRight||this.collideUp||this.collideDown:!!e&&(this.faceTop||this.faceBottom||this.faceLeft||this.faceRight)},copy:function(t){this.index=t.index,this.alpha=t.alpha,this.properties=t.properties,this.collideUp=t.collideUp,this.collideDown=t.collideDown,this.collideLeft=t.collideLeft,this.collideRight=t.collideRight,this.collisionCallback=t.collisionCallback,this.collisionCallbackContext=t.collisionCallbackContext}},e.Tile.prototype.constructor=e.Tile,Object.defineProperty(e.Tile.prototype,"collides",{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown}}),Object.defineProperty(e.Tile.prototype,"canCollide",{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.collisionCallback}}),Object.defineProperty(e.Tile.prototype,"left",{get:function(){return this.worldX}}),Object.defineProperty(e.Tile.prototype,"right",{get:function(){return this.worldX+this.width}}),Object.defineProperty(e.Tile.prototype,"top",{get:function(){return this.worldY}}),Object.defineProperty(e.Tile.prototype,"bottom",{get:function(){return this.worldY+this.height}}),e.Tilemap=function(t,i,s,n,r,o){this.game=t,this.key=i;var a=e.TilemapParser.parse(this.game,i,s,n,r,o);null!==a&&(this.width=a.width,this.height=a.height,this.tileWidth=a.tileWidth,this.tileHeight=a.tileHeight,this.orientation=a.orientation,this.format=a.format,this.version=a.version,this.properties=a.properties,this.widthInPixels=a.widthInPixels,this.heightInPixels=a.heightInPixels,this.layers=a.layers,this.tilesets=a.tilesets,this.imagecollections=a.imagecollections,this.tiles=a.tiles,this.objects=a.objects,this.collideIndexes=[],this.collision=a.collision,this.images=a.images,this.enableDebug=!1,this.currentLayer=0,this.debugMap=[],this._results=[],this._tempA=0,this._tempB=0)},e.Tilemap.CSV=0,e.Tilemap.TILED_JSON=1,e.Tilemap.NORTH=0,e.Tilemap.EAST=1,e.Tilemap.SOUTH=2,e.Tilemap.WEST=3,e.Tilemap.prototype={create:function(t,e,i,s,n,r){return void 0===r&&(r=this.game.world),this.width=e,this.height=i,this.setTileSize(s,n),this.layers.length=0,this.createBlankLayer(t,e,i,s,n,r)},setTileSize:function(t,e){this.tileWidth=t,this.tileHeight=e,this.widthInPixels=this.width*t,this.heightInPixels=this.height*e},addTilesetImage:function(t,i,s,n,r,o,a){if(void 0===t)return null;void 0===s&&(s=this.tileWidth),void 0===n&&(n=this.tileHeight),void 0===r&&(r=0),void 0===o&&(o=0),void 0===a&&(a=0),0===s&&(s=32),0===n&&(n=32);var h=null;if(void 0!==i&&null!==i||(i=t),i instanceof e.BitmapData)h=i.canvas;else{if(!this.game.cache.checkImageKey(i))return console.warn('Phaser.Tilemap.addTilesetImage: Invalid image key given: "'+i+'"'),null;h=this.game.cache.getImage(i)}var l=this.getTilesetIndex(t);if(null===l&&this.format===e.Tilemap.TILED_JSON)return console.warn('Phaser.Tilemap.addTilesetImage: No data found in the JSON matching the tileset name: "'+t+'"'),console.log("Tilesets: ",this.tilesets),null;if(this.tilesets[l])return this.tilesets[l].setImage(h),this.tilesets[l];var c=new e.Tileset(t,a,s,n,r,o,{});c.setImage(h),this.tilesets.push(c);for(var u=this.tilesets.length-1,d=r,p=r,f=0,g=0,m=0,y=a;y<a+c.total&&(this.tiles[y]=[d,p,u],d+=s+o,++f!==c.total)&&(++g!==c.columns||(d=r,p+=n+o,g=0,++m!==c.rows));y++);return c},createFromObjects:function(t,i,s,n,r,o,a,h,l,c){if(void 0===r&&(r=!0),void 0===o&&(o=!1),void 0===a&&(a=this.game.world),void 0===h&&(h=e.Sprite),void 0===l&&(l=!0),void 0===c&&(c=!0),!this.objects[t])return console.warn("Tilemap.createFromObjects: Invalid objectgroup name given: "+t),void console.log("Objects: ",this.objects);for(var u=0;u<this.objects[t].length;u++){var d=!1,p=this.objects[t][u];if(void 0!==p.gid&&"number"==typeof i&&p.gid===i?d=!0:void 0!==p.id&&"number"==typeof i&&p.id===i?d=!0:void 0!==p.name&&"string"==typeof i&&p.name===i&&(d=!0),d){var f=new h(this.game,parseFloat(p.x),parseFloat(p.y),s,n);f.name=p.name,f.autoCull=o,f.exists=r,f.visible=p.visible,c&&(p.width&&(f.width=p.width),p.height&&(f.height=p.height)),p.rotation&&(f.angle=p.rotation),l&&(f.y-=f.height),a.add(f);for(var g in p.properties)a.set(f,g,p.properties[g],!1,!1,0,!0)}}},createFromTiles:function(t,i,s,n,r,o){"number"==typeof t&&(t=[t]),void 0===i||null===i?i=[]:"number"==typeof i&&(i=[i]),n=this.getLayer(n),void 0===r&&(r=this.game.world),void 0===o&&(o={}),void 0===o.customClass&&(o.customClass=e.Sprite),void 0===o.adjustY&&(o.adjustY=!0);var a=this.layers[n].width,h=this.layers[n].height;if(this.copy(0,0,a,h,n),this._results.length<2)return 0;for(var l,c=0,u=1,d=this._results.length;u<d;u++)if(-1!==t.indexOf(this._results[u].index)){l=new o.customClass(this.game,this._results[u].worldX,this._results[u].worldY,s);for(var p in o)l[p]=o[p];r.add(l),c++}if(1===i.length)for(u=0;u<t.length;u++)this.replace(t[u],i[0],0,0,a,h,n);else if(i.length>1)for(u=0;u<t.length;u++)this.replace(t[u],i[u],0,0,a,h,n);return c},createLayer:function(t,i,s,n){void 0===i&&(i=this.game.width),void 0===s&&(s=this.game.height),void 0===n&&(n=this.game.world);var r=t;if("string"==typeof t&&(r=this.getLayerIndex(t)),null===r||r>this.layers.length)return console.warn('Tilemap.createLayer: Invalid layer ID given: "'+t+'"'),void console.log("Layers: ",this.layers);void 0===i||i<=0?i=Math.min(this.game.width,this.layers[r].widthInPixels):i>this.game.width&&(i=this.game.width),void 0===s||s<=0?s=Math.min(this.game.height,this.layers[r].heightInPixels):s>this.game.height&&(s=this.game.height),this.enableDebug&&(console.group("Tilemap.createLayer"),console.log("Name:",this.layers[r].name),console.log("Size:",i,"x",s),console.log("Tileset:",this.tilesets[0].name,"index:",r));var o=n.add(new e.TilemapLayer(this.game,this,r,i,s));return this.enableDebug&&console.groupEnd(),o},createBlankLayer:function(t,i,s,n,r,o){void 0===o&&(o=this.game.world);{if(null===this.getLayerIndex(t)){for(var a,h={name:t,x:0,y:0,width:i,height:s,widthInPixels:i*n,heightInPixels:s*r,alpha:1,visible:!0,properties:{},indexes:[],callbacks:[],bodies:[],data:null},l=[],c=0;c<s;c++){a=[];for(var u=0;u<i;u++)a.push(new e.Tile(h,-1,u,c,n,r));l.push(a)}h.data=l,this.layers.push(h),this.currentLayer=this.layers.length-1;var d=h.widthInPixels,p=h.heightInPixels;return d>this.game.width&&(d=this.game.width),p>this.game.height&&(p=this.game.height),(l=new e.TilemapLayer(this.game,this,this.layers.length-1,d,p)).name=t,o.add(l)}console.warn("Tilemap.createBlankLayer: Layer with matching name already exists: "+t)}},getIndex:function(t,e){for(var i=0;i<t.length;i++)if(t[i].name===e)return i;return null},getLayerIndex:function(t){return this.getIndex(this.layers,t)},getTilesetIndex:function(t){return this.getIndex(this.tilesets,t)},getImageIndex:function(t){return this.getIndex(this.images,t)},setTileIndexCallback:function(t,e,i,s){if(s=this.getLayer(s),"number"==typeof t)null===e?delete this.layers[s].callbacks[t]:this.layers[s].callbacks[t]={callback:e,callbackContext:i};else for(var n=0,r=t.length;n<r;n++)null===e?delete this.layers[s].callbacks[t[n]]:this.layers[s].callbacks[t[n]]={callback:e,callbackContext:i}},setTileLocationCallback:function(t,e,i,s,n,r,o){if(o=this.getLayer(o),this.copy(t,e,i,s,o),!(this._results.length<2))for(var a=1;a<this._results.length;a++)this._results[a].setCollisionCallback(n,r)},setCollision:function(t,e,i,s){if(void 0===e&&(e=!0),void 0===s&&(s=!0),i=this.getLayer(i),"number"==typeof t)return this.setCollisionByIndex(t,e,i,!0);if(Array.isArray(t)){for(var n=0;n<t.length;n++)this.setCollisionByIndex(t[n],e,i,!1);s&&this.calculateFaces(i)}},setCollisionBetween:function(t,e,i,s,n){if(void 0===i&&(i=!0),void 0===n&&(n=!0),s=this.getLayer(s),!(t>e)){for(var r=t;r<=e;r++)this.setCollisionByIndex(r,i,s,!1);n&&this.calculateFaces(s)}},setCollisionByExclusion:function(t,e,i,s){void 0===e&&(e=!0),void 0===s&&(s=!0),i=this.getLayer(i);for(var n=0,r=this.tiles.length;n<r;n++)-1===t.indexOf(n)&&this.setCollisionByIndex(n,e,i,!1);s&&this.calculateFaces(i)},setCollisionByIndex:function(t,e,i,s){if(void 0===e&&(e=!0),void 0===i&&(i=this.currentLayer),void 0===s&&(s=!0),e)this.collideIndexes.push(t);else{var n=this.collideIndexes.indexOf(t);n>-1&&this.collideIndexes.splice(n,1)}for(var r=0;r<this.layers[i].height;r++)for(var o=0;o<this.layers[i].width;o++){var a=this.layers[i].data[r][o];a&&a.index===t&&(e?a.setCollision(!0,!0,!0,!0):a.resetCollision(),a.faceTop=e,a.faceBottom=e,a.faceLeft=e,a.faceRight=e)}return s&&this.calculateFaces(i),i},getLayer:function(t){if(void 0===t)t=this.currentLayer;else if("string"==typeof t){var i=t;null===(t=this.getLayerIndex(t))&&console.warn("No such layer name: "+i)}else t instanceof e.TilemapLayer&&(t=t.index);return t},setPreventRecalculate:function(t){if(!0===t&&!0!==this.preventingRecalculate&&(this.preventingRecalculate=!0,this.needToRecalculate={}),!1===t&&!0===this.preventingRecalculate){this.preventingRecalculate=!1;for(var e in this.needToRecalculate)this.calculateFaces(e);this.needToRecalculate=!1}},calculateFaces:function(t){if(this.preventingRecalculate)this.needToRecalculate[t]=!0;else for(var e=null,i=null,s=null,n=null,r=0,o=this.layers[t].height;r<o;r++)for(var a=0,h=this.layers[t].width;a<h;a++){var l=this.layers[t].data[r][a];l&&(e=this.getTileAbove(t,a,r),i=this.getTileBelow(t,a,r),s=this.getTileLeft(t,a,r),n=this.getTileRight(t,a,r),l.collides&&(l.faceTop=!0,l.faceBottom=!0,l.faceLeft=!0,l.faceRight=!0),e&&e.collides&&(l.faceTop=!1),i&&i.collides&&(l.faceBottom=!1),s&&s.collides&&(l.faceLeft=!1),n&&n.collides&&(l.faceRight=!1))}},getTileAbove:function(t,e,i){return i>0?this.layers[t].data[i-1][e]:null},getTileBelow:function(t,e,i){return i<this.layers[t].height-1?this.layers[t].data[i+1][e]:null},getTileLeft:function(t,e,i){return e>0?this.layers[t].data[i][e-1]:null},getTileRight:function(t,e,i){return e<this.layers[t].width-1?this.layers[t].data[i][e+1]:null},setLayer:function(t){t=this.getLayer(t),this.layers[t]&&(this.currentLayer=t)},hasTile:function(t,e,i){return i=this.getLayer(i),void 0!==this.layers[i].data[e]&&void 0!==this.layers[i].data[e][t]&&this.layers[i].data[e][t].index>-1},removeTile:function(t,i,s){if(s=this.getLayer(s),t>=0&&t<this.layers[s].width&&i>=0&&i<this.layers[s].height&&this.hasTile(t,i,s)){var n=this.layers[s].data[i][t];return this.layers[s].data[i][t]=new e.Tile(this.layers[s],-1,t,i,this.tileWidth,this.tileHeight),this.layers[s].dirty=!0,this.calculateFaces(s),n}},removeTileWorldXY:function(t,e,i,s,n){return n=this.getLayer(n),t=this.game.math.snapToFloor(t,i)/i,e=this.game.math.snapToFloor(e,s)/s,this.removeTile(t,e,n)},putTile:function(t,i,s,n){if(null===t)return this.removeTile(i,s,n);if(n=this.getLayer(n),i>=0&&i<this.layers[n].width&&s>=0&&s<this.layers[n].height){var r;return t instanceof e.Tile?(r=t.index,this.hasTile(i,s,n)?this.layers[n].data[s][i].copy(t):this.layers[n].data[s][i]=new e.Tile(n,r,i,s,t.width,t.height)):(r=t,this.hasTile(i,s,n)?this.layers[n].data[s][i].index=r:this.layers[n].data[s][i]=new e.Tile(this.layers[n],r,i,s,this.tileWidth,this.tileHeight)),this.collideIndexes.indexOf(r)>-1?this.layers[n].data[s][i].setCollision(!0,!0,!0,!0):this.layers[n].data[s][i].resetCollision(),this.layers[n].dirty=!0,this.calculateFaces(n),this.layers[n].data[s][i]}return null},putTileWorldXY:function(t,e,i,s,n,r){return r=this.getLayer(r),e=this.game.math.snapToFloor(e,s)/s,i=this.game.math.snapToFloor(i,n)/n,this.putTile(t,e,i,r)},searchTileIndex:function(t,e,i,s){void 0===e&&(e=0),void 0===i&&(i=!1),s=this.getLayer(s);var n=0;if(i){for(r=this.layers[s].height-1;r>=0;r--)for(o=this.layers[s].width-1;o>=0;o--)if(this.layers[s].data[r][o].index===t){if(n===e)return this.layers[s].data[r][o];n++}}else for(var r=0;r<this.layers[s].height;r++)for(var o=0;o<this.layers[s].width;o++)if(this.layers[s].data[r][o].index===t){if(n===e)return this.layers[s].data[r][o];n++}return null},getTile:function(t,e,i,s){return void 0===s&&(s=!1),i=this.getLayer(i),t>=0&&t<this.layers[i].width&&e>=0&&e<this.layers[i].height?-1===this.layers[i].data[e][t].index?s?this.layers[i].data[e][t]:null:this.layers[i].data[e][t]:null},getTileWorldXY:function(t,e,i,s,n,r){return void 0===i&&(i=this.tileWidth),void 0===s&&(s=this.tileHeight),n=this.getLayer(n),t=this.game.math.snapToFloor(t,i)/i,e=this.game.math.snapToFloor(e,s)/s,this.getTile(t,e,n,r)},copy:function(t,e,i,s,n){n=this.getLayer(n);{if(this.layers[n]){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.layers[n].width),void 0===s&&(s=this.layers[n].height),t<0&&(t=0),e<0&&(e=0),i>this.layers[n].width&&(i=this.layers[n].width),s>this.layers[n].height&&(s=this.layers[n].height),this._results.length=0,this._results.push({x:t,y:e,width:i,height:s,layer:n});for(var r=e;r<e+s;r++)for(var o=t;o<t+i;o++)this._results.push(this.layers[n].data[r][o]);return this._results}this._results.length=0}},paste:function(t,e,i,s){if(void 0===t&&(t=0),void 0===e&&(e=0),s=this.getLayer(s),i&&!(i.length<2)){for(var n=t-i[1].x,r=e-i[1].y,o=1;o<i.length;o++)this.layers[s].data[r+i[o].y][n+i[o].x].copy(i[o]);this.layers[s].dirty=!0,this.calculateFaces(s)}},swap:function(t,e,i,s,n,r,o){o=this.getLayer(o),this.copy(i,s,n,r,o),this._results.length<2||(this._tempA=t,this._tempB=e,this._results.forEach(this.swapHandler,this),this.paste(i,s,this._results,o))},swapHandler:function(t){t.index===this._tempA?t.index=this._tempB:t.index===this._tempB&&(t.index=this._tempA)},forEach:function(t,e,i,s,n,r,o){o=this.getLayer(o),this.copy(i,s,n,r,o),this._results.length<2||(this._results.forEach(t,e),this.paste(i,s,this._results,o))},replace:function(t,e,i,s,n,r,o){if(o=this.getLayer(o),this.copy(i,s,n,r,o),!(this._results.length<2)){for(var a=1;a<this._results.length;a++)this._results[a].index===t&&(this._results[a].index=e);this.paste(i,s,this._results,o)}},random:function(t,e,i,s,n){if(n=this.getLayer(n),this.copy(t,e,i,s,n),!(this._results.length<2)){for(var r=[],o=1;o<this._results.length;o++)if(this._results[o].index){var a=this._results[o].index;-1===r.indexOf(a)&&r.push(a)}for(var h=1;h<this._results.length;h++)this._results[h].index=this.game.rnd.pick(r);this.paste(t,e,this._results,n)}},shuffle:function(t,i,s,n,r){if(r=this.getLayer(r),this.copy(t,i,s,n,r),!(this._results.length<2)){for(var o=[],a=1;a<this._results.length;a++)this._results[a].index&&o.push(this._results[a].index);e.ArrayUtils.shuffle(o);for(var h=1;h<this._results.length;h++)this._results[h].index=o[h-1];this.paste(t,i,this._results,r)}},fill:function(t,e,i,s,n,r){if(r=this.getLayer(r),this.copy(e,i,s,n,r),!(this._results.length<2)){for(var o=1;o<this._results.length;o++)this._results[o].index=t;this.paste(e,i,this._results,r)}},removeAllLayers:function(){this.layers.length=0,this.currentLayer=0},dump:function(){for(var t="",e=[""],i=0;i<this.layers[this.currentLayer].height;i++){for(var s=0;s<this.layers[this.currentLayer].width;s++)t+="%c ",this.layers[this.currentLayer].data[i][s]>1?this.debugMap[this.layers[this.currentLayer].data[i][s]]?e.push("background: "+this.debugMap[this.layers[this.currentLayer].data[i][s]]):e.push("background: #ffffff"):e.push("background: rgb(0, 0, 0)");t+="\n"}e[0]=t,console.log.apply(console,e)},destroy:function(){this.removeAllLayers(),this.data=[],this.game=null}},e.Tilemap.prototype.constructor=e.Tilemap,Object.defineProperty(e.Tilemap.prototype,"layer",{get:function(){return this.layers[this.currentLayer]},set:function(t){t!==this.currentLayer&&this.setLayer(t)}}),e.TilemapLayer=function(t,i,s,n,r){n|=0,r|=0,e.Sprite.call(this,t,0,0),this.map=i,this.index=s,this.layer=i.layers[s],this.canvas=e.CanvasPool.create(this,n,r),this.context=this.canvas.getContext("2d"),this.setTexture(new PIXI.Texture(new PIXI.BaseTexture(this.canvas,null,this.game.resolution))),this.type=e.TILEMAPLAYER,this.physicsType=e.TILEMAPLAYER,this.renderSettings={enableScrollDelta:!0,overdrawRatio:.2,copyCanvas:null},this.debug=!1,this.exists=!0,this.debugSettings={missingImageFill:"rgb(255,255,255)",debuggedTileOverfill:"rgba(0,255,0,0.4)",forceFullRedraw:!0,debugAlpha:.5,facingEdgeStroke:"rgba(0,255,0,1)",collidingTileOverfill:"rgba(0,255,0,0.2)"},this.scrollFactorX=1,this.scrollFactorY=1,this.dirty=!0,this.rayStepRate=4,this._wrap=!1,this._mc={scrollX:0,scrollY:0,renderWidth:0,renderHeight:0,tileWidth:i.tileWidth,tileHeight:i.tileHeight,cw:i.tileWidth,ch:i.tileHeight,tilesets:[]},this._scrollX=0,this._scrollY=0,this.tileOffset=new e.Point(this.layer.offsetX||0,this.layer.offsetY||0),this._results=[],t.device.canvasBitBltShift||(this.renderSettings.copyCanvas=e.TilemapLayer.ensureSharedCopyCanvas()),this.fixedToCamera=!0},e.TilemapLayer.prototype=Object.create(e.Sprite.prototype),e.TilemapLayer.prototype.constructor=e.TilemapLayer,e.TilemapLayer.prototype.preUpdateCore=e.Component.Core.preUpdate,e.TilemapLayer.sharedCopyCanvas=null,e.TilemapLayer.ensureSharedCopyCanvas=function(){return this.sharedCopyCanvas||(this.sharedCopyCanvas=e.CanvasPool.create(this,2,2)),this.sharedCopyCanvas},e.TilemapLayer.prototype.preUpdate=function(){return this.preUpdateCore()},e.TilemapLayer.prototype.postUpdate=function(){this.fixedToCamera&&(this.position.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.position.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y),this._scrollX=(this.game.camera.view.x-this.tileOffset.x)*this.scrollFactorX/this.scale.x,this._scrollY=(this.game.camera.view.y-this.tileOffset.y)*this.scrollFactorY/this.scale.y},e.TilemapLayer.prototype._renderCanvas=function(t){this.fixedToCamera&&(this.position.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.position.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y),this._scrollX=(this.game.camera.view.x-this.tileOffset.x)*this.scrollFactorX/this.scale.x,this._scrollY=(this.game.camera.view.y-this.tileOffset.y)*this.scrollFactorY/this.scale.y,this.render(),PIXI.Sprite.prototype._renderCanvas.call(this,t)},e.TilemapLayer.prototype._renderWebGL=function(t){this.fixedToCamera&&(this.position.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.position.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y),this._scrollX=(this.game.camera.view.x-this.tileOffset.x)*this.scrollFactorX/this.scale.x,this._scrollY=(this.game.camera.view.y-this.tileOffset.y)*this.scrollFactorY/this.scale.y,this.render(),PIXI.Sprite.prototype._renderWebGL.call(this,t)},e.TilemapLayer.prototype.destroy=function(){e.CanvasPool.remove(this),e.Component.Destroy.prototype.destroy.call(this)},e.TilemapLayer.prototype.resize=function(t,e){this.canvas.width=t,this.canvas.height=e,this.texture.frame.resize(t,e),this.texture.width=t,this.texture.height=e,this.texture.crop.width=t,this.texture.crop.height=e,this.texture.baseTexture.width=t,this.texture.baseTexture.height=e,this.texture.baseTexture.dirty(),this.texture.requiresUpdate=!0,this.texture._updateUvs(),this.dirty=!0},e.TilemapLayer.prototype.resizeWorld=function(){this.game.world.setBounds(0,0,this.layer.widthInPixels*this.scale.x,this.layer.heightInPixels*this.scale.y)},e.TilemapLayer.prototype.getTileOffsetX=function(){return this.tileOffset.x||(this.fixedToCamera?0:this.position.x)},e.TilemapLayer.prototype.getTileOffsetY=function(){return this.tileOffset.y||(this.fixedToCamera?0:this.position.y)},e.TilemapLayer.prototype._fixX=function(t){return 1===this.scrollFactorX||0===this.scrollFactorX&&0===this.position.x?t:0===this.scrollFactorX&&0!==this.position.x?t-this.position.x:this._scrollX+(t-this._scrollX/this.scrollFactorX)},e.TilemapLayer.prototype._unfixX=function(t){return 1===this.scrollFactorX?t:this._scrollX/this.scrollFactorX+(t-this._scrollX)},e.TilemapLayer.prototype._fixY=function(t){return 1===this.scrollFactorY||0===this.scrollFactorY&&0===this.position.y?t:0===this.scrollFactorY&&0!==this.position.y?t-this.position.y:this._scrollY+(t-this._scrollY/this.scrollFactorY)},e.TilemapLayer.prototype._unfixY=function(t){return 1===this.scrollFactorY?t:this._scrollY/this.scrollFactorY+(t-this._scrollY)},e.TilemapLayer.prototype.getTileX=function(t){return Math.floor(this._fixX(t)/this._mc.tileWidth)},e.TilemapLayer.prototype.getTileY=function(t){return Math.floor(this._fixY(t)/this._mc.tileHeight)},e.TilemapLayer.prototype.getTileXY=function(t,e,i){return i.x=this.getTileX(t),i.y=this.getTileY(e),i},e.TilemapLayer.prototype.getRayCastTiles=function(t,e,i,s){e||(e=this.rayStepRate),void 0===i&&(i=!1),void 0===s&&(s=!1);var n=this.getTiles(t.x,t.y,t.width,t.height,i,s);if(0===n.length)return[];for(var r=t.coordinatesOnLine(e),o=[],a=0;a<n.length;a++)for(var h=0;h<r.length;h++){var l=n[a],c=r[h];if(l.containsPoint(c[0],c[1])){o.push(l);break}}return o},e.TilemapLayer.prototype.getTiles=function(t,e,i,s,n,r){void 0===n&&(n=!1),void 0===r&&(r=!1);var o=!(n||r);t=this._fixX(t),e=this._fixY(e);for(var a=Math.floor(t/(this._mc.cw*this.scale.x)),h=Math.floor(e/(this._mc.ch*this.scale.y)),l=Math.ceil((t+i)/(this._mc.cw*this.scale.x))-a,c=Math.ceil((e+s)/(this._mc.ch*this.scale.y))-h;this._results.length;)this._results.pop();for(var u=h;u<h+c;u++)for(var d=a;d<a+l;d++){var p=this.layer.data[u];p&&p[d]&&(o||p[d].isInteresting(n,r))&&this._results.push(p[d])}return this._results.slice()},e.TilemapLayer.prototype.resolveTileset=function(t){var e=this._mc.tilesets;if(t<2e3)for(;e.length<t;)e.push(void 0);var i=this.map.tiles[t]&&this.map.tiles[t][2];if(null!==i){var s=this.map.tilesets[i];if(s&&s.containsTileIndex(t))return e[t]=s}return e[t]=null},e.TilemapLayer.prototype.resetTilesetCache=function(){for(var t=this._mc.tilesets;t.length;)t.pop()},e.TilemapLayer.prototype.setScale=function(t,e){t=t||1,e=e||t;for(var i=0;i<this.layer.data.length;i++)for(var s=this.layer.data[i],n=0;n<s.length;n++){var r=s[n];r.width=this.map.tileWidth*t,r.height=this.map.tileHeight*e,r.worldX=r.x*r.width,r.worldY=r.y*r.height}this.scale.setTo(t,e)},e.TilemapLayer.prototype.shiftCanvas=function(t,e,i){var s=t.canvas,n=s.width-Math.abs(e),r=s.height-Math.abs(i),o=0,a=0,h=e,l=i;e<0&&(o=-e,h=0),i<0&&(a=-i,l=0);var c=this.renderSettings.copyCanvas;if(c){(c.width<n||c.height<r)&&(c.width=n,c.height=r);var u=c.getContext("2d");u.clearRect(0,0,n,r),u.drawImage(s,o,a,n,r,0,0,n,r),t.clearRect(h,l,n,r),t.drawImage(c,0,0,n,r,h,l,n,r)}else t.save(),t.globalCompositeOperation="copy",t.drawImage(s,o,a,n,r,h,l,n,r),t.restore()},e.TilemapLayer.prototype.renderRegion=function(t,e,i,s,n,r){var o=this.context,a=this.layer.width,h=this.layer.height,l=this._mc.tileWidth,c=this._mc.tileHeight,u=this._mc.tilesets,d=NaN;this._wrap||(i<=n&&(i=Math.max(0,i),n=Math.min(a-1,n)),s<=r&&(s=Math.max(0,s),r=Math.min(h-1,r)));var p,f,g,m,y,v,x=i*l-t,b=(i+(1<<20)*a)%a;for(m=(s+(1<<20)*h)%h,v=r-s,f=s*c-e;v>=0;m++,v--,f+=c){m>=h&&(m-=h);var _=this.layer.data[m];for(g=b,y=n-i,p=x;y>=0;g++,y--,p+=l){g>=a&&(g-=a);var w=_[g];if(w&&!(w.index<0)){var T=w.index,P=u[T];void 0===P&&(P=this.resolveTileset(T)),w.alpha===d||this.debug||(o.globalAlpha=w.alpha,d=w.alpha),P?w.rotation||w.flipped?(o.save(),o.translate(p+w.centerX,f+w.centerY),o.rotate(w.rotation),w.flipped&&o.scale(-1,1),P.draw(o,-w.centerX,-w.centerY,T),o.restore()):P.draw(o,p,f,T):this.debugSettings.missingImageFill&&(o.fillStyle=this.debugSettings.missingImageFill,o.fillRect(p,f,l,c)),w.debug&&this.debugSettings.debuggedTileOverfill&&(o.fillStyle=this.debugSettings.debuggedTileOverfill,o.fillRect(p,f,l,c))}}}},e.TilemapLayer.prototype.renderDeltaScroll=function(t,e){var i=this._mc.scrollX,s=this._mc.scrollY,n=this.canvas.width,r=this.canvas.height,o=this._mc.tileWidth,a=this._mc.tileHeight,h=0,l=-o,c=0,u=-a;if(t<0?(h=n+t,l=n-1):t>0&&(l=t),e<0?(c=r+e,u=r-1):e>0&&(u=e),this.shiftCanvas(this.context,t,e),h=Math.floor((h+i)/o),l=Math.floor((l+i)/o),c=Math.floor((c+s)/a),u=Math.floor((u+s)/a),h<=l){this.context.clearRect(h*o-i,0,(l-h+1)*o,r);var d=Math.floor((0+s)/a),p=Math.floor((r-1+s)/a);this.renderRegion(i,s,h,d,l,p)}if(c<=u){this.context.clearRect(0,c*a-s,n,(u-c+1)*a);var f=Math.floor((0+i)/o),g=Math.floor((n-1+i)/o);this.renderRegion(i,s,f,c,g,u)}},e.TilemapLayer.prototype.renderFull=function(){var t=this._mc.scrollX,e=this._mc.scrollY,i=this.canvas.width,s=this.canvas.height,n=this._mc.tileWidth,r=this._mc.tileHeight,o=Math.floor(t/n),a=Math.floor((i-1+t)/n),h=Math.floor(e/r),l=Math.floor((s-1+e)/r);this.context.clearRect(0,0,i,s),this.renderRegion(t,e,o,h,a,l)},e.TilemapLayer.prototype.render=function(){var t=!1;if(this.visible){(this.dirty||this.layer.dirty)&&(this.layer.dirty=!1,t=!0);var e=this.canvas.width,i=this.canvas.height,s=0|this._scrollX,n=0|this._scrollY,r=this._mc,o=r.scrollX-s,a=r.scrollY-n;if(t||0!==o||0!==a||r.renderWidth!==e||r.renderHeight!==i)return this.context.save(),r.scrollX=s,r.scrollY=n,r.renderWidth===e&&r.renderHeight===i||(r.renderWidth=e,r.renderHeight=i),this.debug&&(this.context.globalAlpha=this.debugSettings.debugAlpha,this.debugSettings.forceFullRedraw&&(t=!0)),!t&&this.renderSettings.enableScrollDelta&&Math.abs(o)+Math.abs(a)<Math.min(e,i)?this.renderDeltaScroll(o,a):this.renderFull(),this.debug&&(this.context.globalAlpha=1,this.renderDebug()),this.texture.baseTexture.dirty(),this.dirty=!1,this.context.restore(),!0}},e.TilemapLayer.prototype.renderDebug=function(){var t,e,i,s,n,r,o=this._mc.scrollX,a=this._mc.scrollY,h=this.context,l=this.canvas.width,c=this.canvas.height,u=this.layer.width,d=this.layer.height,p=this._mc.tileWidth,f=this._mc.tileHeight,g=Math.floor(o/p),m=Math.floor((l-1+o)/p),y=Math.floor(a/f),v=Math.floor((c-1+a)/f),x=g*p-o,b=y*f-a,_=(g+(1<<20)*u)%u,w=(y+(1<<20)*d)%d;for(h.strokeStyle=this.debugSettings.facingEdgeStroke,s=w,r=v-y,e=b;r>=0;s++,r--,e+=f){s>=d&&(s-=d);var T=this.layer.data[s];for(i=_,n=m-g,t=x;n>=0;i++,n--,t+=p){i>=u&&(i-=u);var P=T[i];!P||P.index<0||!P.collides||(this.debugSettings.collidingTileOverfill&&(h.fillStyle=this.debugSettings.collidingTileOverfill,h.fillRect(t,e,this._mc.cw,this._mc.ch)),this.debugSettings.facingEdgeStroke&&(h.beginPath(),P.faceTop&&(h.moveTo(t,e),h.lineTo(t+this._mc.cw,e)),P.faceBottom&&(h.moveTo(t,e+this._mc.ch),h.lineTo(t+this._mc.cw,e+this._mc.ch)),P.faceLeft&&(h.moveTo(t,e),h.lineTo(t,e+this._mc.ch)),P.faceRight&&(h.moveTo(t+this._mc.cw,e),h.lineTo(t+this._mc.cw,e+this._mc.ch)),h.closePath(),h.stroke()))}}},Object.defineProperty(e.TilemapLayer.prototype,"wrap",{get:function(){return this._wrap},set:function(t){this._wrap=t,this.dirty=!0}}),Object.defineProperty(e.TilemapLayer.prototype,"scrollX",{get:function(){return this._scrollX},set:function(t){this._scrollX=t}}),Object.defineProperty(e.TilemapLayer.prototype,"scrollY",{get:function(){return this._scrollY},set:function(t){this._scrollY=t}}),Object.defineProperty(e.TilemapLayer.prototype,"collisionWidth",{get:function(){return this._mc.cw},set:function(t){this._mc.cw=0|t,this.dirty=!0}}),Object.defineProperty(e.TilemapLayer.prototype,"collisionHeight",{get:function(){return this._mc.ch},set:function(t){this._mc.ch=0|t,this.dirty=!0}}),e.TilemapParser={INSERT_NULL:!1,parse:function(t,i,s,n,r,o){if(void 0===s&&(s=32),void 0===n&&(n=32),void 0===r&&(r=10),void 0===o&&(o=10),void 0===i)return this.getEmptyData();if(null===i)return this.getEmptyData(s,n,r,o);var a=t.cache.getTilemapData(i);if(a){if(a.format===e.Tilemap.CSV)return this.parseCSV(i,a.data,s,n);if(!a.format||a.format===e.Tilemap.TILED_JSON)return this.parseTiledJSON(a.data)}else console.warn('No map data found for key "%s"',i)},parseCSV:function(t,i,s,n){for(var r=this.getEmptyData(),o=[],a=(i=i.trim()).split("\n"),h=a.length,l=0,c=0;c<a.length;c++){o[c]=[];for(var u=a[c].split(","),d=0;d<u.length;d++)o[c][d]=new e.Tile(r.layers[0],parseInt(u[d],10),d,c,s,n);0===l&&(l=u.length)}return r.format=e.Tilemap.CSV,r.name=t,r.width=l,r.height=h,r.tileWidth=s,r.tileHeight=n,r.widthInPixels=l*s,r.heightInPixels=h*n,r.layers[0].width=l,r.layers[0].height=h,r.layers[0].widthInPixels=r.widthInPixels,r.layers[0].heightInPixels=r.heightInPixels,r.layers[0].data=o,r},getEmptyData:function(t,e,i,s){return{width:void 0!==i&&null!==i?i:0,height:void 0!==s&&null!==s?s:0,tileWidth:void 0!==t&&null!==t?t:0,tileHeight:void 0!==e&&null!==e?e:0,orientation:"orthogonal",version:"1",properties:{},widthInPixels:0,heightInPixels:0,layers:[{name:"layer",x:0,y:0,width:0,height:0,widthInPixels:0,heightInPixels:0,alpha:1,visible:!0,properties:{},indexes:[],callbacks:[],bodies:[],data:[]}],images:[],objects:{},collision:{},tilesets:[],tiles:[]}},_slice:function(t,e){var i={};for(var s in e){var n=e[s];void 0!==t[n]&&(i[n]=t[n])}return i},parseObjectGroup:function(t,e,i,s,n){var s=s||t.name,n=n||{x:0,y:0},r=this._slice;s||console.warn("No name found for objectGroup",t),void 0!==n.x&&void 0!==n.y||console.warn("Malformed xy properties in relativePosition",n),e[s]=e[s]||[],i[s]=i[s]||[];for(var o=0,a=t.objects.length;o<a;o++){var h=t.objects[o];if(h.gid){l={gid:h.gid,name:h.name,type:h.type||"",x:h.x+n.x,y:h.y+n.y,width:h.width,height:h.height,visible:h.visible,properties:h.properties};h.rotation&&(l.rotation=h.rotation),e[s].push(l)}else if(h.polyline){var l={name:h.name,type:h.type,x:h.x+n.x,y:h.y+n.y,width:h.width,height:h.height,visible:h.visible,properties:h.properties};h.rotation&&(l.rotation=h.rotation),l.polyline=[];for(c=0;c<h.polyline.length;c++)l.polyline.push([h.polyline[c].x,h.polyline[c].y]);i[s].push(l),e[s].push(l)}else if(h.polygon){(l=r(h,["name","type","x","y","visible","rotation","properties"])).x+=n.x,l.y+=n.y,l.polygon=[];for(var c=0;c<h.polygon.length;c++)l.polygon.push([h.polygon[c].x,h.polygon[c].y]);i[s].push(l),e[s].push(l)}else h.ellipse?((l=r(h,["name","type","ellipse","x","y","width","height","visible","rotation","properties"])).x+=n.x,l.y+=n.y,i[s].push(l),e[s].push(l)):((l=r(h,["name","type","x","y","width","height","visible","rotation","properties"])).x+=n.x,l.y+=n.y,l.rectangle=!0,i[s].push(l),e[s].push(l))}return{objectsCollection:e,collisionCollection:i}},parseTiledJSON:function(t){if("orthogonal"!==t.orientation)return console.warn('Phaser CE supports only orthogonal maps. This map\'s orientation is "%s".',t.orientation),null;t.version>1.1&&console.warn('Some features in this Tiled JSON map (version %s) may not work in Phaser CE. Enable the json1 plugin and reexport the map in "Tiled 1.1" format. https://github.com/photonstorm/phaser-ce/issues/623',t.version);for(var i={width:t.width,height:t.height,tileWidth:t.tilewidth,tileHeight:t.tileheight,orientation:t.orientation,format:e.Tilemap.TILED_JSON,version:t.version,properties:t.properties,widthInPixels:t.width*t.tilewidth,heightInPixels:t.height*t.tileheight},s=[],n=0;n<t.layers.length;n++)if("tilelayer"===t.layers[n].type){var r=t.layers[n];if(!r.compression&&r.encoding&&"base64"===r.encoding){for(var o=window.atob(r.data),a=o.length,h=new Array(a),l=0;l<a;l+=4)h[l/4]=(o.charCodeAt(l)|o.charCodeAt(l+1)<<8|o.charCodeAt(l+2)<<16|o.charCodeAt(l+3)<<24)>>>0;r.data=h,delete r.encoding}else if(r.compression){console.warn('Layer compression is unsupported, skipping layer "%s".',r.name);continue}k={name:r.name,x:r.x,y:r.y,width:r.width,height:r.height,widthInPixels:r.width*t.tilewidth,heightInPixels:r.height*t.tileheight,alpha:r.opacity,offsetX:r.offsetx,offsetY:r.offsety,visible:r.visible,properties:{},indexes:[],callbacks:[],bodies:[]};r.properties&&(k.properties=r.properties);for(var c,u,d,p=0,f=[],g=[],m=0,a=r.data.length;m<a;m++){if(c=0,u=!1,A=r.data[m],d=0,A>536870912)switch(A>2147483648&&(A-=2147483648,d+=4),A>1073741824&&(A-=1073741824,d+=2),A>536870912&&(A-=536870912,d+=1),d){case 5:c=Math.PI/2;break;case 6:c=Math.PI;break;case 3:c=3*Math.PI/2;break;case 4:c=0,u=!0;break;case 7:c=Math.PI/2,u=!0;break;case 2:c=Math.PI,u=!0;break;case 1:c=3*Math.PI/2,u=!0}A>0?((F=new e.Tile(k,A,p,g.length,t.tilewidth,t.tileheight)).rotation=c,F.flipped=u,0!==d&&(F.flippedVal=d),f.push(F)):e.TilemapParser.INSERT_NULL?f.push(null):f.push(new e.Tile(k,-1,p,g.length,t.tilewidth,t.tileheight)),++p===r.width&&(g.push(f),p=0,f=[])}k.data=g,s.push(k)}i.layers=s;for(var y=[],n=0;n<t.layers.length;n++)if("imagelayer"===t.layers[n].type){var v=t.layers[n],x={name:v.name,image:v.image,x:v.x,y:v.y,alpha:v.opacity,visible:v.visible,properties:{}};v.properties&&(x.properties=v.properties),y.push(x)}i.images=y;for(var b=[],_={},w=[],T=null,n=0;n<t.tilesets.length;n++){if((U=t.tilesets[n]).source)console.warn("Phaser CE can't load external tilesets (%s). Embed the tileset and then export the map again. https://github.com/photonstorm/phaser-ce/issues/273",U.source);else if(U.image){var P=new e.Tileset(U.name,U.firstgid,U.tilewidth,U.tileheight,U.margin,U.spacing,U.properties);U.tileproperties&&(P.tileProperties=U.tileproperties),P.updateTileData(U.imagewidth,U.imageheight),b.push(P)}else{if(!U.tiles)throw new Error("Tileset "+U.name+" has no `image` or `tiles` property.");var C=new e.ImageCollection(U.name,U.firstgid,U.tilewidth,U.tileheight,U.margin,U.spacing,U.properties);for(var S in U.tiles){var x=U.tiles[S].image,A=U.firstgid+parseInt(S,10);C.addImage(A,x)}w.push(C)}for(var S in U.tiles)(R=U.tiles[S].objectgroup)&&(_[parseInt(S,10)+U.firstgid]=R);T&&(T.lastgid=U.firstgid-1),T=U}if(0===b.length&&0===w.length)throw new Error("This tilemap has no tilesets.");i.tilesets=b,i.imagecollections=w;for(var E={},M={},n=0;n<t.layers.length;n++)if("objectgroup"===t.layers[n].type){var R=t.layers[n];this.parseObjectGroup(R,E,M)}i.objects=E,i.collision=M,i.tiles=[];for(n=0;n<i.tilesets.length;n++)for(var p=(U=i.tilesets[n]).tileMargin,L=U.tileMargin,B=0,I=0,O=0,m=U.firstgid;m<U.firstgid+U.total&&(i.tiles[m]=[p,L,n],p+=U.tileWidth+U.tileSpacing,++B!==U.total)&&(++I!==U.columns||(p=U.tileMargin,L+=U.tileHeight+U.tileSpacing,I=0,++O!==U.rows));m++);for(var k,F,D,U,n=0;n<i.layers.length;n++){M[(k=i.layers[n]).name]=[],U=null;for(l=0;l<k.data.length;l++){f=k.data[l];for(var G=0;G<f.length;G++)null===(F=f[G])||F.index<0||(D=i.tiles[F.index][2],(U=i.tilesets[D]).tileProperties&&U.tileProperties[F.index-U.firstgid]&&(F.properties=e.Utils.mixin(U.tileProperties[F.index-U.firstgid],F.properties)),(R=_[F.index])&&this.parseObjectGroup(R,i.objects,i.collision,F.layer.name,{x:F.worldX+R.x,y:F.worldY+R.y}))}}return i}},e.Tileset=function(t,e,i,s,n,r,o){(void 0===i||i<=0)&&(i=32),(void 0===s||s<=0)&&(s=32),void 0===n&&(n=0),void 0===r&&(r=0),this.name=t,this.firstgid=0|e,this.tileWidth=0|i,this.tileHeight=0|s,this.tileMargin=0|n,this.tileSpacing=0|r,this.properties=o||{},this.image=null,this.rows=0,this.columns=0,this.total=0,this.drawCoords=[]},e.Tileset.prototype={draw:function(t,e,i,s){var n=s-this.firstgid<<1;n>=0&&n+1<this.drawCoords.length&&t.drawImage(this.image,this.drawCoords[n],this.drawCoords[n+1],this.tileWidth,this.tileHeight,e,i,this.tileWidth,this.tileHeight)},containsTileIndex:function(t){return t>=this.firstgid&&t<this.firstgid+this.total},setImage:function(t){this.image=t,this.updateTileData(t.width,t.height)},setSpacing:function(t,e){this.tileMargin=0|t,this.tileSpacing=0|e,this.image&&this.updateTileData(this.image.width,this.image.height)},updateTileData:function(t,e){var i=(e-2*this.tileMargin+this.tileSpacing)/(this.tileHeight+this.tileSpacing),s=(t-2*this.tileMargin+this.tileSpacing)/(this.tileWidth+this.tileSpacing);i%1==0&&s%1==0||console.warn("Phaser.Tileset - '%s' image tile area (%s x %s) is not a whole multiple of tile size (%s x %s + %s + %s)",this.name,t,e,this.tileWidth,this.tileHeight,this.tileMargin,this.tileSpacing),i=Math.floor(i),s=Math.floor(s),(this.rows&&this.rows!==i||this.columns&&this.columns!==s)&&console.warn("Phaser.Tileset - Tile layout from image '%s' (%s rows by %s columns) differs from tileset '%s' (%s rows by %s columns)",this.image.name,s,i,this.name,this.columns,this.rows),this.rows=i,this.columns=s,this.total=i*s,this.drawCoords.length=0;for(var n=this.tileMargin,r=this.tileMargin,o=0;o<this.rows;o++){for(var a=0;a<this.columns;a++)this.drawCoords.push(n),this.drawCoords.push(r),n+=this.tileWidth+this.tileSpacing;n=this.tileMargin,r+=this.tileHeight+this.tileSpacing}}},e.Tileset.prototype.constructor=e.Tileset,e.Particle=function(t,i,s,n,r){e.Sprite.call(this,t,i,s,n,r),this.autoScale=!1,this.scaleData=null,this._s=0,this.autoAlpha=!1,this.alphaData=null,this._a=0},e.Particle.prototype=Object.create(e.Sprite.prototype),e.Particle.prototype.constructor=e.Particle,e.Particle.prototype.update=function(){this.autoScale&&(--this._s?this.scale.set(this.scaleData[this._s].x,this.scaleData[this._s].y):this.autoScale=!1),this.autoAlpha&&(--this._a?this.alpha=this.alphaData[this._a].v:this.autoAlpha=!1)},e.Particle.prototype.onEmit=function(){},e.Particle.prototype.setAlphaData=function(t){this.alphaData=t,this._a=t.length-1,this.alpha=this.alphaData[this._a].v,this.autoAlpha=!0},e.Particle.prototype.setScaleData=function(t){this.scaleData=t,this._s=t.length-1,this.scale.set(this.scaleData[this._s].x,this.scaleData[this._s].y),this.autoScale=!0},e.Particle.prototype.reset=function(t,i,s){return e.Component.Reset.prototype.reset.call(this,t,i,s),this.alpha=1,this.scale.set(1),this.autoScale=!1,this.autoAlpha=!1,this},e.Particles=function(t){this.game=t,this.emitters={},this.ID=0},e.Particles.prototype={add:function(t){return this.emitters[t.id]=t,t},remove:function(t){delete this.emitters[t.id]}},e.Particles.prototype.constructor=e.Particles,e.Particles.Arcade={},e.Particles.Arcade.Emitter=function(t,i,s,n){this.maxParticles=n||50,e.Group.call(this,t),this._id=this.game.particles.ID++,this.name="emitter"+this.id,this.type=e.EMITTER,this.physicsType=e.GROUP,this.area=new e.Rectangle(i,s,1,1),this.minAngle=null,this.maxAngle=null,this.minSpeed=0,this.maxSpeed=100,this.minParticleSpeed=new e.Point(-100,-100),this.maxParticleSpeed=new e.Point(100,100),this.minParticleScale=1,this.maxParticleScale=1,this.scaleData=null,this.minRotation=-360,this.maxRotation=360,this.minParticleAlpha=1,this.maxParticleAlpha=1,this.alphaData=null,this.particleClass=e.Particle,this.particleDrag=new e.Point,this.angularDrag=0,this.frequency=100,this.lifespan=2e3,this.bounce=new e.Point,this.on=!1,this.particleAnchor=new e.Point(.5,.5),this.blendMode=e.blendModes.NORMAL,this.emitX=i,this.emitY=s,this.autoScale=!1,this.autoAlpha=!1,this.particleBringToTop=!1,this.particleSendToBack=!1,this.counts={emitted:0,failed:0,totalEmitted:0,totalFailed:0},this._gravity=new e.Point(0,100),this._minParticleScale=new e.Point(1,1),this._maxParticleScale=new e.Point(1,1),this._total=0,this._timer=0,this._counter=0,this._flowQuantity=0,this._flowTotal=0,this._explode=!0,this._frames=null},e.Particles.Arcade.Emitter.prototype=Object.create(e.Group.prototype),e.Particles.Arcade.Emitter.prototype.constructor=e.Particles.Arcade.Emitter,e.Particles.Arcade.Emitter.prototype.update=function(){if(this.counts.emitted=0,this.counts.failed=0,this.on&&this.game.time.time>=this._timer)if(this._timer=this.game.time.time+this.frequency*this.game.time.slowMotion,0!==this._flowTotal)if(this._flowQuantity>0){for(t=0;t<this._flowQuantity;t++)if(this.emitParticle()&&(this._counter++,-1!==this._flowTotal&&this._counter>=this._flowTotal)){this.on=!1;break}}else this.emitParticle()&&(this._counter++,-1!==this._flowTotal&&this._counter>=this._flowTotal&&(this.on=!1));else this.emitParticle()&&(this._counter++,this._total>0&&this._counter>=this._total&&(this.on=!1));for(var t=this.children.length;t--;)this.children[t].exists&&this.children[t].update()},e.Particles.Arcade.Emitter.prototype.makeParticles=function(t,e,i,s,n,r){void 0===e&&(e=0),void 0===i&&(i=this.maxParticles),void 0===s&&(s=!1),void 0===n&&(n=!1),void 0===r&&(r=null);var o,a=0,h=t,l=e;for(this._frames=e,i>this.maxParticles&&(this.maxParticles=i);a<i;)Array.isArray(t)&&(h=this.game.rnd.pick(t)),Array.isArray(e)&&(l=this.game.rnd.pick(e)),o=new this.particleClass(this.game,0,0,h,l,r),this.game.physics.arcade.enable(o,!1),o.body.checkCollision.none=!s,o.body.collideWorldBounds=n,o.body.skipQuadTree=!0,o.exists=!1,o.visible=!1,o.anchor.copyFrom(this.particleAnchor),this.add(o),a++;return this},e.Particles.Arcade.Emitter.prototype.kill=function(){return this.on=!1,this.alive=!1,this.exists=!1,this},e.Particles.Arcade.Emitter.prototype.revive=function(){return this.alive=!0,this.exists=!0,this},e.Particles.Arcade.Emitter.prototype.explode=function(t,e){return void 0===e&&(e=this.maxParticles),this._flowTotal=0,this.start(!0,t,0,e,!1),this},e.Particles.Arcade.Emitter.prototype.flow=function(t,e,i,s,n){return void 0!==e&&null!==e||(e=250),void 0!==i&&0!==i||(i=1),void 0===s&&(s=-1),void 0===n&&(n=!0),i>this.maxParticles&&(i=this.maxParticles),this._counter=0,this._flowQuantity=i,this._flowTotal=s,n?(this.start(!0,t,e,i),this._counter+=i,this.on=!0,this._timer=this.game.time.time+e*this.game.time.slowMotion):this.start(!1,t,e,i),this},e.Particles.Arcade.Emitter.prototype.start=function(t,e,i,s,n){if(void 0===t&&(t=!0),void 0===e&&(e=0),void 0!==i&&null!==i||(i=250),void 0===s&&(s=0),void 0===n&&(n=!1),s>this.maxParticles&&(s=this.maxParticles),this.revive(),this.visible=!0,this.lifespan=e,this.frequency=i,t||n)for(var r=0;r<s;r++)this.emitParticle();else this.on=!0,this._total=s,this._counter=0,this._timer=this.game.time.time+i*this.game.time.slowMotion;return this},e.Particles.Arcade.Emitter.prototype.emitParticle=function(t,e,i,s){void 0===t&&(t=null),void 0===e&&(e=null);var n=this.getNextParticle();if(null===n)return this.counts.failed++,this.counts.totalFailed++,!1;this.counts.emitted++,this.counts.totalEmitted++;var r=this.game.rnd;void 0!==i&&void 0!==s?n.loadTexture(i,s):void 0!==i&&(n.loadTexture(i),n.frame=Array.isArray(this._frames)?r.pick(this._frames):this._frames);var o=this.emitX,a=this.emitY;return null!==t?o=t:this.width>1&&(o=r.between(this.left,this.right)),null!==e?a=e:this.height>1&&(a=r.between(this.top,this.bottom)),this.resetParticle(n,o,a),!0},e.Particles.Arcade.Emitter.prototype.getNextParticle=function(){for(var t=this.length;t--;){var e=this.next();if(!e.exists)return e}return null},e.Particles.Arcade.Emitter.prototype.resetParticle=function(t,e,i){var s=this.game.rnd;t.reset(e,i),t.angle=0,t.lifespan=this.lifespan,this.particleBringToTop?this.bringToTop(t):this.particleSendToBack&&this.sendToBack(t),this.autoScale?t.setScaleData(this.scaleData):1!==this.minParticleScale||1!==this.maxParticleScale?t.scale.set(s.realInRange(this.minParticleScale,this.maxParticleScale)):this._minParticleScale.x!==this._maxParticleScale.x||this._minParticleScale.y!==this._maxParticleScale.y?t.scale.set(s.realInRange(this._minParticleScale.x,this._maxParticleScale.x),s.realInRange(this._minParticleScale.y,this._maxParticleScale.y)):t.scale.set(this._minParticleScale.x,this._minParticleScale.y),this.autoAlpha?t.setAlphaData(this.alphaData):t.alpha=s.realInRange(this.minParticleAlpha,this.maxParticleAlpha),t.blendMode=this.blendMode;var n=t.body;n.updateBounds(),n.bounce.copyFrom(this.bounce),n.drag.copyFrom(this.particleDrag),null!=this.minAngle&&null!=this.maxAngle?this.game.physics.arcade.velocityFromAngle(this.minAngle===this.maxAngle?this.minAngle:s.between(this.minAngle,this.maxAngle),this.minSpeed===this.maxSpeed?this.minSpeed:s.between(this.minSpeed,this.maxSpeed),n.velocity):(n.velocity.x=s.between(this.minParticleSpeed.x,this.maxParticleSpeed.x),n.velocity.y=s.between(this.minParticleSpeed.y,this.maxParticleSpeed.y)),n.angularVelocity=s.between(this.minRotation,this.maxRotation),n.gravity.copyFrom(this.gravity),n.angularDrag=this.angularDrag,t.onEmit()},e.Particles.Arcade.Emitter.prototype.destroy=function(){this.game.particles.remove(this),e.Group.prototype.destroy.call(this,!0,!1)},e.Particles.Arcade.Emitter.prototype.setSize=function(t,e){return this.area.width=t,this.area.height=e,this},e.Particles.Arcade.Emitter.prototype.setXSpeed=function(t,e){return t=t||0,e=e||0,this.minParticleSpeed.x=t,this.maxParticleSpeed.x=e,this},e.Particles.Arcade.Emitter.prototype.setYSpeed=function(t,e){return t=t||0,e=e||0,this.minParticleSpeed.y=t,this.maxParticleSpeed.y=e,this},e.Particles.Arcade.Emitter.prototype.setRotation=function(t,e){return t=t||0,e=e||0,this.minRotation=t,this.maxRotation=e,this},e.Particles.Arcade.Emitter.prototype.setAlpha=function(t,i,s,n,r){if(void 0===t&&(t=1),void 0===i&&(i=1),void 0===s&&(s=0),void 0===n&&(n=e.Easing.Linear.None),void 0===r&&(r=!1),this.minParticleAlpha=t,this.maxParticleAlpha=i,this.autoAlpha=!1,s>0&&t!==i){var o={v:t},a=this.game.make.tween(o).to({v:i},s,n);a.yoyo(r),this.alphaData=a.generateData(60),this.alphaData.reverse(),this.autoAlpha=!0}return this},e.Particles.Arcade.Emitter.prototype.setScale=function(t,i,s,n,r,o,a){if(void 0===t&&(t=1),void 0===i&&(i=1),void 0===s&&(s=1),void 0===n&&(n=1),void 0===r&&(r=0),void 0===o&&(o=e.Easing.Linear.None),void 0===a&&(a=!1),this.minParticleScale=1,this.maxParticleScale=1,this._minParticleScale.set(t,s),this._maxParticleScale.set(i,n),this.autoScale=!1,r>0&&(t!==i||s!==n)){var h={x:t,y:s},l=this.game.make.tween(h).to({x:i,y:n},r,o);l.yoyo(a),this.scaleData=l.generateData(60),this.scaleData.reverse(),this.autoScale=!0}return this},e.Particles.Arcade.Emitter.prototype.setAngle=function(t,e,i,s){return this.minAngle=t,this.maxAngle=e,null!=i&&(this.minSpeed=i),null!=s&&(this.maxSpeed=s),this},e.Particles.Arcade.Emitter.prototype.at=function(t){return t.center?(this.emitX=t.center.x,this.emitY=t.center.y):(this.emitX=t.world.x+t.anchor.x*t.width,this.emitY=t.world.y+t.anchor.y*t.height),this},Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"gravity",{get:function(){return this._gravity},set:function(t){"number"==typeof t?this._gravity.y=t:this._gravity=t}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"id",{get:function(){return this._id}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"width",{get:function(){return this.area.width},set:function(t){this.area.width=t}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"height",{get:function(){return this.area.height},set:function(t){this.area.height=t}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"x",{get:function(){return this.emitX},set:function(t){this.emitX=t}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"y",{get:function(){return this.emitY},set:function(t){this.emitY=t}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"left",{get:function(){return Math.floor(this.x-this.area.width/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"right",{get:function(){return Math.floor(this.x+this.area.width/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"top",{get:function(){return Math.floor(this.y-this.area.height/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"bottom",{get:function(){return Math.floor(this.y+this.area.height/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"output",{get:function(){return 1e3*this._flowQuantity/this.frequency}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"lifespanOutput",{get:function(){return(0===this.lifespan?1/0:this.lifespan)*this._flowQuantity/this.frequency}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"remainder",{get:function(){return this.maxParticles-this.lifespanOutput}}),e.Weapon=function(t,i){e.Plugin.call(this,t,i),this.bullets=null,this.autoExpandBulletsGroup=!1,this.autofire=!1,this.shots=0,this.fireLimit=0,this.fireRate=100,this.fireRateVariance=0,this.fireFrom=new e.Rectangle(0,0,1,1),this.fireAngle=e.ANGLE_UP,this.bulletInheritSpriteSpeed=!1,this.bulletAnimation="",this.bulletFrameRandom=!1,this.bulletFrameCycle=!1,this.bulletWorldWrap=!1,this.bulletWorldWrapPadding=0,this.bulletAngleOffset=0,this.bulletAngleVariance=0,this.bulletSpeed=200,this.bulletSpeedVariance=0,this.bulletLifespan=0,this.bulletKillDistance=0,this.bulletGravity=new e.Point(0,0),this.bulletRotateToVelocity=!1,this.bulletKey="",this.bulletFrame="",this._bulletClass=e.Bullet,this._bulletCollideWorldBounds=!1,this._bulletKillType=e.Weapon.KILL_WORLD_BOUNDS,this._data={customBody:!1,width:0,height:0,offsetX:0,offsetY:0},this.bounds=new e.Rectangle,this.bulletBounds=t.world.bounds,this.bulletFrames=[],this.bulletFrameIndex=0,this.anims={},this.onFire=new e.Signal,this.onKill=new e.Signal,this.onFireLimit=new e.Signal,this.trackedSprite=null,this.trackedPointer=null,this.multiFire=!1,this._hasFired=!1,this.trackRotation=!1,this.trackOffset=new e.Point,this._nextFire=0,this._tempNextFire=0,this._rotatedPoint=new e.Point},e.Weapon.prototype=Object.create(e.Plugin.prototype),e.Weapon.prototype.constructor=e.Weapon,e.Weapon.KILL_NEVER=0,e.Weapon.KILL_LIFESPAN=1,e.Weapon.KILL_DISTANCE=2,e.Weapon.KILL_WEAPON_BOUNDS=3,e.Weapon.KILL_CAMERA_BOUNDS=4,e.Weapon.KILL_WORLD_BOUNDS=5,e.Weapon.KILL_STATIC_BOUNDS=6,e.Weapon.prototype.createBullets=function(t,i,s,n){return void 0===t&&(t=1),void 0===n&&(n=this.game.world),this.bullets&&!this.bullets.game&&(this.bullets=null),this.bullets||(this.bullets=this.game.add.physicsGroup(e.Physics.ARCADE,n),this.bullets.classType=this._bulletClass),0!==t&&(-1===t&&(this.autoExpandBulletsGroup=!0,t=1),this.bullets.createMultiple(t,i,s),this.bullets.setAll("data.bulletManager",this),this.bulletKey=i,this.bulletFrame=s),this},e.Weapon.prototype.forEach=function(t,e){return this.bullets.forEachExists(t,e,arguments),this},e.Weapon.prototype.pauseAll=function(){return this.bullets.setAll("body.enable",!1),this},e.Weapon.prototype.resumeAll=function(){return this.bullets.setAll("body.enable",!0),this},e.Weapon.prototype.killAll=function(){return this.bullets.callAllExists("kill",!0),this.bullets.setAll("body.enable",!0),this},e.Weapon.prototype.resetShots=function(t){return this.shots=0,void 0!==t&&(this.fireLimit=t),this},e.Weapon.prototype.destroy=function(){this.parent.remove(this,!1),this.bullets.destroy(),this.game=null,this.parent=null,this.active=!1,this.visible=!1},e.Weapon.prototype.update=function(){this._bulletKillType===e.Weapon.KILL_WEAPON_BOUNDS&&(this.trackedSprite?(this.trackedSprite.updateTransform(),this.bounds.centerOn(this.trackedSprite.worldPosition.x,this.trackedSprite.worldPosition.y)):this.trackedPointer&&this.bounds.centerOn(this.trackedPointer.worldX,this.trackedPointer.worldY)),this.autofire&&this.fire()},e.Weapon.prototype.postRender=function(){this.multiFire&&this._hasFired&&(this._hasFired=!1,this._nextFire=this._tempNextFire)},e.Weapon.prototype.trackSprite=function(t,e,i,s){return void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=!1),this.trackedPointer=null,this.trackedSprite=t,this.trackRotation=s,this.trackOffset.set(e,i),this},e.Weapon.prototype.trackPointer=function(t,e,i){return void 0===t&&(t=this.game.input.activePointer),void 0===e&&(e=0),void 0===i&&(i=0),this.trackedPointer=t,this.trackedSprite=null,this.trackRotation=!1,this.trackOffset.set(e,i),this},e.Weapon.prototype.fireMany=function(t,e){this.multiFire=!0;var i=[],s=this;return e||this.trackedSprite||this.trackedPointer?t.forEach(function(t){i.push(s.fire(e,null,null,t.x,t.y))}):t.forEach(function(t){i.push(s.fire(t))}),i},e.Weapon.prototype.fireOffset=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.fire(null,null,null,t,e)},e.Weapon.prototype.fire=function(t,i,s,n,r){if(void 0===i&&(i=null),void 0===s&&(s=null),this.game.time.now<this._nextFire||this.fireLimit>0&&this.shots===this.fireLimit)return null;var o=this.bulletSpeed;0!==this.bulletSpeedVariance&&(o+=e.Math.between(-this.bulletSpeedVariance,this.bulletSpeedVariance)),t?this.fireFrom.width>1?this.fireFrom.centerOn(t.x,t.y):(this.fireFrom.x=t.x,this.fireFrom.y=t.y):this.trackedSprite?(this.trackRotation?(this._rotatedPoint.set(this.trackedSprite.world.x+this.trackOffset.x,this.trackedSprite.world.y+this.trackOffset.y),this._rotatedPoint.rotate(this.trackedSprite.world.x,this.trackedSprite.world.y,this.trackedSprite.worldRotation),this.fireFrom.width>1?this.fireFrom.centerOn(this._rotatedPoint.x,this._rotatedPoint.y):(this.fireFrom.x=this._rotatedPoint.x,this.fireFrom.y=this._rotatedPoint.y)):this.fireFrom.width>1?this.fireFrom.centerOn(this.trackedSprite.world.x+this.trackOffset.x,this.trackedSprite.world.y+this.trackOffset.y):(this.fireFrom.x=this.trackedSprite.world.x+this.trackOffset.x,this.fireFrom.y=this.trackedSprite.world.y+this.trackOffset.y),this.bulletInheritSpriteSpeed&&(o+=this.trackedSprite.body.speed)):this.trackedPointer&&(this.fireFrom.width>1?this.fireFrom.centerOn(this.trackedPointer.world.x+this.trackOffset.x,this.trackedPointer.world.y+this.trackOffset.y):(this.fireFrom.x=this.trackedPointer.world.x+this.trackOffset.x,this.fireFrom.y=this.trackedPointer.world.y+this.trackOffset.y)),void 0!==n&&(this.fireFrom.x+=n),void 0!==r&&(this.fireFrom.y+=r);var a=this.fireFrom.width>1?this.fireFrom.randomX:this.fireFrom.x,h=this.fireFrom.height>1?this.fireFrom.randomY:this.fireFrom.y,l=this.trackRotation?this.trackedSprite.angle:this.fireAngle;null!==i&&null!==s&&(l=this.game.math.radToDeg(Math.atan2(s-h,i-a))),0!==this.bulletAngleVariance&&(l+=e.Math.between(-this.bulletAngleVariance,this.bulletAngleVariance));var c=0,u=0;0===l||180===l?c=Math.cos(this.game.math.degToRad(l))*o:90===l||270===l?u=Math.sin(this.game.math.degToRad(l))*o:(c=Math.cos(this.game.math.degToRad(l))*o,u=Math.sin(this.game.math.degToRad(l))*o);var d=null;if(this.autoExpandBulletsGroup?(d=this.bullets.getFirstExists(!1,!0,a,h,this.bulletKey,this.bulletFrame)).data.bulletManager=this:d=this.bullets.getFirstExists(!1),d){if(d.reset(a,h),d.data.fromX=a,d.data.fromY=h,d.data.killType=this.bulletKillType,d.data.killDistance=this.bulletKillDistance,d.data.rotateToVelocity=this.bulletRotateToVelocity,this.bulletKillType===e.Weapon.KILL_LIFESPAN&&(d.lifespan=this.bulletLifespan),d.angle=l+this.bulletAngleOffset,""!==this.bulletAnimation){if(null===d.animations.getAnimation(this.bulletAnimation)){var p=this.anims[this.bulletAnimation];d.animations.add(p.name,p.frames,p.frameRate,p.loop,p.useNumericIndex)}d.animations.play(this.bulletAnimation)}else this.bulletFrameCycle?(d.frame=this.bulletFrames[this.bulletFrameIndex],++this.bulletFrameIndex>=this.bulletFrames.length&&(this.bulletFrameIndex=0)):this.bulletFrameRandom&&(d.frame=this.bulletFrames[Math.floor(Math.random()*this.bulletFrames.length)]);d.data.bodyDirty&&(this._data.customBody&&d.body.setSize(this._data.width,this._data.height,this._data.offsetX,this._data.offsetY),d.body.collideWorldBounds=this.bulletCollideWorldBounds,d.data.bodyDirty=!1),d.body.velocity.set(c,u),d.body.gravity.set(this.bulletGravity.x,this.bulletGravity.y);var f=0;if(0!==this.bulletSpeedVariance){var g=this.fireRate;(g+=e.Math.between(-this.fireRateVariance,this.fireRateVariance))<0&&(g=0),f=this.game.time.now+g}else f=this.game.time.now+this.fireRate;this.multiFire?this._hasFired||(this._hasFired=!0,this._tempNextFire=f,this.shots++):(this._nextFire=f,this.shots++),this.onFire.dispatch(d,this,o),this.fireLimit>0&&this.shots===this.fireLimit&&this.onFireLimit.dispatch(this,this.fireLimit)}return d},e.Weapon.prototype.fireAtPointer=function(t){return void 0===t&&(t=this.game.input.activePointer),this.fire(null,t.worldX,t.worldY)},e.Weapon.prototype.fireAtSprite=function(t){return this.fire(null,t.world.x,t.world.y)},e.Weapon.prototype.fireAtXY=function(t,e){return this.fire(null,t,e)},e.Weapon.prototype.setBulletBodyOffset=function(t,e,i,s){return void 0===i&&(i=0),void 0===s&&(s=0),this._data.customBody=!0,this._data.width=t,this._data.height=e,this._data.offsetX=i,this._data.offsetY=s,this.bullets.callAll("body.setSize","body",t,e,i,s),this.bullets.setAll("data.bodyDirty",!1),this},e.Weapon.prototype.setBulletFrames=function(t,i,s,n){return void 0===s&&(s=!0),void 0===n&&(n=!1),this.bulletFrames=e.ArrayUtils.numberArray(t,i),this.bulletFrameIndex=0,this.bulletFrameCycle=s,this.bulletFrameRandom=n,this},e.Weapon.prototype.addBulletAnimation=function(t,e,i,s,n){return this.anims[t]={name:t,frames:e,frameRate:i,loop:s,useNumericIndex:n},this.bullets.callAll("animations.add","animations",t,e,i,s,n),this.bulletAnimation=t,this},e.Weapon.prototype.debug=function(t,e,i){void 0===t&&(t=16),void 0===e&&(e=32),void 0===i&&(i=!1),this.game.debug.text("Weapon Plugin",t,e),this.game.debug.text("Bullets Alive: "+this.bullets.total+" - Total: "+this.bullets.length,t,e+24),i&&this.bullets.forEachExists(this.game.debug.body,this.game.debug,"rgba(255, 0, 255, 0.8)")},Object.defineProperty(e.Weapon.prototype,"bulletClass",{get:function(){return this._bulletClass},set:function(t){this._bulletClass=t,this.bullets&&(this.bullets.classType=this._bulletClass)}}),Object.defineProperty(e.Weapon.prototype,"bulletKillType",{get:function(){return this._bulletKillType},set:function(t){switch(t){case e.Weapon.KILL_STATIC_BOUNDS:case e.Weapon.KILL_WEAPON_BOUNDS:this.bulletBounds=this.bounds;break;case e.Weapon.KILL_CAMERA_BOUNDS:this.bulletBounds=this.game.camera.view;break;case e.Weapon.KILL_WORLD_BOUNDS:this.bulletBounds=this.game.world.bounds}this._bulletKillType=t}}),Object.defineProperty(e.Weapon.prototype,"bulletCollideWorldBounds",{get:function(){return this._bulletCollideWorldBounds},set:function(t){this._bulletCollideWorldBounds=t,this.bullets.setAll("body.collideWorldBounds",t),this.bullets.setAll("data.bodyDirty",!1)}}),Object.defineProperty(e.Weapon.prototype,"x",{get:function(){return this.fireFrom.x},set:function(t){this.fireFrom.x=t}}),Object.defineProperty(e.Weapon.prototype,"y",{get:function(){return this.fireFrom.y},set:function(t){this.fireFrom.y=t}}),e.Bullet=function(t,i,s,n,r){e.Sprite.call(this,t,i,s,n,r),this.anchor.set(.5),this.data={bulletManager:null,fromX:0,fromY:0,bodyDirty:!0,rotateToVelocity:!1,killType:0,killDistance:0}},e.Bullet.prototype=Object.create(e.Sprite.prototype),e.Bullet.prototype.constructor=e.Bullet,e.Bullet.prototype.kill=function(){return this.alive=!1,this.exists=!1,this.visible=!1,this.data.bulletManager.onKill.dispatch(this),this},e.Bullet.prototype.update=function(){this.exists&&(this.data.killType>e.Weapon.KILL_LIFESPAN&&(this.data.killType===e.Weapon.KILL_DISTANCE?this.game.physics.arcade.distanceToXY(this,this.data.fromX,this.data.fromY,!0)>this.data.killDistance&&this.kill():this.data.bulletManager.bulletBounds.intersects(this)||this.kill()),this.data.rotateToVelocity&&(this.rotation=this.body.velocity.atan()),this.data.bulletManager.bulletWorldWrap&&this.game.world.wrap(this,this.data.bulletManager.bulletWorldWrapPadding))},e.Video=function(t,i,s){if(void 0===i&&(i=null),void 0===s&&(s=null),this.game=t,this.key=i,this.width=0,this.height=0,this.type=e.VIDEO,this.disableTextureUpload=!1,this.touchLocked=!1,this.onPlay=new e.Signal,this.onChangeSource=new e.Signal,this.onComplete=new e.Signal,this.onAccess=new e.Signal,this.onError=new e.Signal,this.onTimeout=new e.Signal,this.onTouchUnlock=new e.Signal,this.playWhenUnlocked=!0,this.timeout=15e3,this._timeOutID=null,this.video=null,this.videoStream=null,this.isStreaming=!1,this.retryLimit=20,this.retry=0,this.retryInterval=500,this._retryID=null,this._codeMuted=!1,this._muted=!1,this._codePaused=!1,this._paused=!1,this._pending=!1,this._pendingChangeSource=!1,this._autoplay=!1,this._endCallback=null,this._playCallback=null,i&&this.game.cache.checkVideoKey(i)){var n=this.game.cache.getVideo(i);n.isBlob?this.createVideoFromBlob(n.data):this.video=n.data,this.width=this.video.videoWidth,this.height=this.video.videoHeight}else s&&this.createVideoFromURL(s,!1);this.video&&!s?(this.baseTexture=new PIXI.BaseTexture(this.video,null,this.game.resolution),this.baseTexture.forceLoaded(this.width,this.height)):(this.baseTexture=new PIXI.BaseTexture(e.Cache.DEFAULT.baseTexture.source,null,this.game.resolution),this.baseTexture.forceLoaded(this.width,this.height)),this.texture=new PIXI.Texture(this.baseTexture),this.textureFrame=new e.Frame(0,0,0,this.width,this.height,"video"),this.texture.setFrame(this.textureFrame),this.texture.valid=!1,null!==i&&this.video&&(this.texture.valid=this.video.canplay),this.snapshot=null,e.BitmapData&&(this.snapshot=new e.BitmapData(this.game,"",this.width,this.height)),this.game.device.needsTouchUnlock()?this.setTouchLock():n&&(n.locked=!1)},e.Video.prototype={connectToMediaStream:function(t,e){return t&&e&&(this.video=t,this.videoStream=e,this.isStreaming=!0,this.baseTexture.source=this.video,this.updateTexture(null,this.video.videoWidth,this.video.videoHeight),this.onAccess.dispatch(this)),this},startMediaStream:function(t,e,i){if(void 0===t&&(t=!1),void 0===e&&(e=null),void 0===i&&(i=null),!this.game.device.getUserMedia)return this.onError.dispatch(this,"No getUserMedia"),!1;null!==this.videoStream&&(this.videoStream.active?this.videoStream.active=!1:this.videoStream.stop()),this.removeVideoElement(),this.video=document.createElement("video"),this.video.setAttribute("autoplay","autoplay"),this.video.setAttribute("playsinline","playsinline"),null!==e&&(this.video.width=e),null!==i&&(this.video.height=i),this._timeOutID=window.setTimeout(this.getUserMediaTimeout.bind(this),this.timeout);try{navigator.getUserMedia({audio:t,video:!0},this.getUserMediaSuccess.bind(this),this.getUserMediaError.bind(this))}catch(t){this.getUserMediaError(t)}return this},getUserMediaTimeout:function(){clearTimeout(this._timeOutID),this.onTimeout.dispatch(this)},getUserMediaError:function(t){clearTimeout(this._timeOutID),this.onError.dispatch(this,t)},getUserMediaSuccess:function(t){clearTimeout(this._timeOutID),this.videoStream=t,void 0!==this.video.mozSrcObject?this.video.mozSrcObject=t:void 0!==this.video.srcObject?this.video.srcObject=t:this.video.src=window.URL&&window.URL.createObjectURL(t)||t;var e=this;this.video.onloadeddata=function(){function t(){if(i>0)if(e.video.videoWidth>0){var s=e.video.videoWidth,n=e.video.videoHeight;isNaN(e.video.videoHeight)&&(n=s/(4/3)),e.video.play(),e.isStreaming=!0,e.baseTexture.source=e.video,e.updateTexture(null,s,n),e.onAccess.dispatch(e)}else window.setTimeout(t,500);else console.warn("Unable to connect to video stream. Webcam error?");i--}var i=10;t()}},createVideoFromBlob:function(t){var e=this;return this.video=document.createElement("video"),this.video.controls=!1,this.video.setAttribute("autoplay","autoplay"),this.video.setAttribute("playsinline","playsinline"),this.video.addEventListener("loadeddata",function(t){e.updateTexture(t)},!0),this.video.src=window.URL.createObjectURL(t),this.video.canplay=!0,this},createVideoFromURL:function(t,e){return void 0===e&&(e=!1),this.texture&&(this.texture.valid=!1),this.video=document.createElement("video"),this.video.controls=!1,e&&this.video.setAttribute("autoplay","autoplay"),this.video.setAttribute("playsinline","playsinline"),this.video.src=t,this.video.canplay=!0,this.video.load(),this.retry=this.retryLimit,this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval),this.key=t,this},updateTexture:function(t,e,i){var s=!1;void 0!==e&&null!==e||(e=this.video.videoWidth,s=!0),void 0!==i&&null!==i||(i=this.video.videoHeight),this.width=e,this.height=i,this.baseTexture.source!==this.video&&(this.baseTexture.source=this.video),this.baseTexture.forceLoaded(e,i),this.texture.frame.resize(e,i),this.texture.width=e,this.texture.height=i,this.texture.valid=!0,this.snapshot&&this.snapshot.resize(e,i),s&&null!==this.key&&(this.onChangeSource.dispatch(this,e,i),this._autoplay&&(this.video.play(),this.onPlay.dispatch(this,this.loop,this.playbackRate)))},complete:function(){this.onComplete.dispatch(this)},play:function(t,e){return this._pendingChangeSource?this:(void 0===t&&(t=!1),void 0===e&&(e=1),this.game.sound.onMute&&(this.game.sound.onMute.add(this.setMute,this),this.game.sound.onUnMute.add(this.unsetMute,this),this.game.sound.mute&&this.setMute()),this.game.onPause.add(this.setPause,this),this.game.onResume.add(this.setResume,this),this._endCallback=this.complete.bind(this),this.video.addEventListener("ended",this._endCallback,!0),this.video.addEventListener("webkitendfullscreen",this._endCallback,!0),this.video.loop=t?"loop":"",this.video.playbackRate=e,this.touchLocked?this._pending=!0:(this._pending=!1,null!==this.key&&(4!==this.video.readyState?(this.retry=this.retryLimit,this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval)):(this._playCallback=this.playHandler.bind(this),this.video.addEventListener("playing",this._playCallback,!0))),this.video.play(),this.onPlay.dispatch(this,t,e)),this)},playHandler:function(){this.video.removeEventListener("playing",this._playCallback,!0),this.updateTexture()},stop:function(){return this.game.sound.onMute&&(this.game.sound.onMute.remove(this.setMute,this),this.game.sound.onUnMute.remove(this.unsetMute,this)),this.game.onPause.remove(this.setPause,this),this.game.onResume.remove(this.setResume,this),this.isStreaming?(this.video.mozSrcObject?(this.video.mozSrcObject.stop(),this.video.src=null):this.video.srcObject?(this.video.srcObject.stop(),this.video.src=null):(this.video.src="",this.videoStream.active?this.videoStream.active=!1:this.videoStream.getTracks?this.videoStream.getTracks().forEach(function(t){t.stop()}):this.videoStream.stop()),this.videoStream=null,this.isStreaming=!1):(this.video.removeEventListener("ended",this._endCallback,!0),this.video.removeEventListener("webkitendfullscreen",this._endCallback,!0),this.video.removeEventListener("playing",this._playCallback,!0),this.touchLocked?this._pending=!1:this.video.pause()),this},add:function(t){if(Array.isArray(t))for(var e=0;e<t.length;e++)t[e].loadTexture&&t[e].loadTexture(this);else t.loadTexture(this);return this},addToWorld:function(t,e,i,s,n,r){n=n||1,r=r||1;var o=this.game.add.image(t,e,this);return o.anchor.set(i,s),o.scale.set(n,r),o},render:function(){!this.disableTextureUpload&&this.playing&&this.baseTexture.dirty()},setMute:function(){this._muted||(this._muted=!0,this.video.muted=!0)},unsetMute:function(){this._muted&&!this._codeMuted&&(this._muted=!1,this.video.muted=!1)},setPause:function(){this._paused||this.touchLocked||(this._paused=!0,this.video.pause())},setResume:function(){!this._paused||this._codePaused||this.touchLocked||(this._paused=!1,this.video.ended||this.video.play())},changeSource:function(t,e){return void 0===e&&(e=!0),this.texture.valid=!1,this.video.pause(),this._pendingChangeSource=!0,this.retry=this.retryLimit,this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval),this.video.src=t,this.video.load(),this._autoplay=e,e||(this.paused=!0),this},checkVideoProgress:function(){4===this.video.readyState?(this._pendingChangeSource=!1,this.updateTexture()):--this.retry>0?this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval):console.warn("Phaser.Video: Unable to start downloading video in time",this.isStreaming)},setTouchLock:function(){this.game.input.addTouchLockCallback(this.unlock,this,!0),this.touchLocked=!0},unlock:function(){if(this.touchLocked=!1,this.playWhenUnlocked&&(this.video.play(),this.onPlay.dispatch(this,this.loop,this.playbackRate)),this.key){var t=this.game.cache.getVideo(this.key);t&&!t.isBlob&&(t.locked=!1)}return this.onTouchUnlock.dispatch(this),!0},grab:function(t,e,i){if(void 0===t&&(t=!1),void 0===e&&(e=1),void 0===i&&(i=null),null!==this.snapshot)return t&&this.snapshot.cls(),this.snapshot.copy(this.video,0,0,this.width,this.height,0,0,this.width,this.height,0,0,0,1,1,e,i),this.snapshot;console.warn("Video.grab cannot run because Phaser.BitmapData is unavailable")},removeVideoElement:function(){if(this.video){for(this.video.parentNode&&this.video.parentNode.removeChild(this.video);this.video.hasChildNodes();)this.video.removeChild(this.video.firstChild);this.video.removeAttribute("autoplay"),this.video.removeAttribute("src"),this.video=null}},destroy:function(){this.stop(),this.removeVideoElement(),this.touchLocked&&this.game.input.removeTouchLockCallback(this.unlock,this),this._retryID&&window.clearTimeout(this._retryID)}},Object.defineProperty(e.Video.prototype,"currentTime",{get:function(){return this.video?this.video.currentTime:0},set:function(t){this.video.currentTime=t}}),Object.defineProperty(e.Video.prototype,"duration",{get:function(){return this.video?this.video.duration:0}}),Object.defineProperty(e.Video.prototype,"progress",{get:function(){return this.video?this.video.currentTime/this.video.duration:0}}),Object.defineProperty(e.Video.prototype,"mute",{get:function(){return this._muted},set:function(t){if(t=t||null){if(this._muted)return;this._codeMuted=!0,this.setMute()}else{if(!this._muted)return;this._codeMuted=!1,this.unsetMute()}}}),Object.defineProperty(e.Video.prototype,"paused",{get:function(){return this._paused},set:function(t){if(t=t||null,!this.touchLocked)if(t){if(this._paused)return;this._codePaused=!0,this.setPause()}else{if(!this._paused)return;this._codePaused=!1,this.setResume()}}}),Object.defineProperty(e.Video.prototype,"volume",{get:function(){return this.video?this.video.volume:1},set:function(t){t<0?t=0:t>1&&(t=1),this.video&&(this.video.volume=t)}}),Object.defineProperty(e.Video.prototype,"playbackRate",{get:function(){return this.video?this.video.playbackRate:1},set:function(t){this.video&&(this.video.playbackRate=t)}}),Object.defineProperty(e.Video.prototype,"loop",{get:function(){return!!this.video&&this.video.loop},set:function(t){t&&this.video?this.video.loop="loop":this.video&&(this.video.loop="")}}),Object.defineProperty(e.Video.prototype,"playing",{get:function(){return!!this.video&&!(this.video.paused&&this.video.ended)}}),e.Video.prototype.constructor=e.Video,void 0===PIXI.blendModes&&(PIXI.blendModes=e.blendModes),void 0===PIXI.scaleModes&&(PIXI.scaleModes=e.scaleModes),void 0===PIXI.Texture.emptyTexture&&(PIXI.Texture.emptyTexture=new PIXI.Texture(new PIXI.BaseTexture)),void 0===PIXI.DisplayObject._tempMatrix&&(PIXI.DisplayObject._tempMatrix=new e.Matrix),PIXI.TextureSilentFail=!0,PIXI.canUseNewCanvasBlendModes=function(){return e.Device.canUseMultiply},"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=e),exports.Phaser=e):"undefined"!=typeof define&&define.amd?define("Phaser",t.Phaser=e):t.Phaser=e,e}.call(this); +!function(a){if("object"==typeof exports)module.exports=a();else if("function"==typeof define,1){var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.p2=a()}else define(a)}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){function d(){}var e=a("./Scalar");b.exports=d,d.lineInt=function(a,b,c){c=c||0;var d,f,g,h,i,j,k,l=[0,0];return d=a[1][1]-a[0][1],f=a[0][0]-a[1][0],g=d*a[0][0]+f*a[0][1],h=b[1][1]-b[0][1],i=b[0][0]-b[1][0],j=h*b[0][0]+i*b[0][1],k=d*i-h*f,e.eq(k,0,c)||(l[0]=(i*g-f*j)/k,l[1]=(d*j-h*g)/k),l},d.segmentsIntersect=function(a,b,c,d){var e=b[0]-a[0],f=b[1]-a[1],g=d[0]-c[0],h=d[1]-c[1];if(g*f-h*e==0)return!1;var i=(e*(c[1]-a[1])+f*(a[0]-c[0]))/(g*f-h*e),j=(g*(a[1]-c[1])+h*(c[0]-a[0]))/(h*e-g*f);return i>=0&&1>=i&&j>=0&&1>=j}},{"./Scalar":4}],2:[function(a,b,c){function d(){}b.exports=d,d.area=function(a,b,c){return(b[0]-a[0])*(c[1]-a[1])-(c[0]-a[0])*(b[1]-a[1])},d.left=function(a,b,c){return d.area(a,b,c)>0},d.leftOn=function(a,b,c){return d.area(a,b,c)>=0},d.right=function(a,b,c){return d.area(a,b,c)<0},d.rightOn=function(a,b,c){return d.area(a,b,c)<=0};var e=[],f=[];d.collinear=function(a,b,c,g){if(g){var h=e,i=f;h[0]=b[0]-a[0],h[1]=b[1]-a[1],i[0]=c[0]-b[0],i[1]=c[1]-b[1];var j=h[0]*i[0]+h[1]*i[1],k=Math.sqrt(h[0]*h[0]+h[1]*h[1]),l=Math.sqrt(i[0]*i[0]+i[1]*i[1]),m=Math.acos(j/(k*l));return g>m}return 0==d.area(a,b,c)},d.sqdist=function(a,b){var c=b[0]-a[0],d=b[1]-a[1];return c*c+d*d}},{}],3:[function(a,b,c){function d(){this.vertices=[]}function e(a,b,c,d,e){e=e||0;var f=b[1]-a[1],g=a[0]-b[0],i=f*a[0]+g*a[1],j=d[1]-c[1],k=c[0]-d[0],l=j*c[0]+k*c[1],m=f*k-j*g;return h.eq(m,0,e)?[0,0]:[(k*i-g*l)/m,(f*l-j*i)/m]}var f=a("./Line"),g=a("./Point"),h=a("./Scalar");b.exports=d,d.prototype.at=function(a){var b=this.vertices,c=b.length;return b[0>a?a%c+c:a%c]},d.prototype.first=function(){return this.vertices[0]},d.prototype.last=function(){return this.vertices[this.vertices.length-1]},d.prototype.clear=function(){this.vertices.length=0},d.prototype.append=function(a,b,c){if("undefined"==typeof b)throw new Error("From is not given!");if("undefined"==typeof c)throw new Error("To is not given!");if(b>c-1)throw new Error("lol1");if(c>a.vertices.length)throw new Error("lol2");if(0>b)throw new Error("lol3");for(var d=b;c>d;d++)this.vertices.push(a.vertices[d])},d.prototype.makeCCW=function(){for(var a=0,b=this.vertices,c=1;c<this.vertices.length;++c)(b[c][1]<b[a][1]||b[c][1]==b[a][1]&&b[c][0]>b[a][0])&&(a=c);g.left(this.at(a-1),this.at(a),this.at(a+1))||this.reverse()},d.prototype.reverse=function(){for(var a=[],b=0,c=this.vertices.length;b!==c;b++)a.push(this.vertices.pop());this.vertices=a},d.prototype.isReflex=function(a){return g.right(this.at(a-1),this.at(a),this.at(a+1))};var i=[],j=[];d.prototype.canSee=function(a,b){var c,d,e=i,h=j;if(g.leftOn(this.at(a+1),this.at(a),this.at(b))&&g.rightOn(this.at(a-1),this.at(a),this.at(b)))return!1;d=g.sqdist(this.at(a),this.at(b));for(var k=0;k!==this.vertices.length;++k)if((k+1)%this.vertices.length!==a&&k!==a&&g.leftOn(this.at(a),this.at(b),this.at(k+1))&&g.rightOn(this.at(a),this.at(b),this.at(k))&&(e[0]=this.at(a),e[1]=this.at(b),h[0]=this.at(k),h[1]=this.at(k+1),c=f.lineInt(e,h),g.sqdist(this.at(a),c)<d))return!1;return!0},d.prototype.copy=function(a,b,c){var e=c||new d;if(e.clear(),b>a)for(var f=a;b>=f;f++)e.vertices.push(this.vertices[f]);else{for(var f=0;b>=f;f++)e.vertices.push(this.vertices[f]);for(var f=a;f<this.vertices.length;f++)e.vertices.push(this.vertices[f])}return e},d.prototype.getCutEdges=function(){for(var a=[],b=[],c=[],e=new d,f=Number.MAX_VALUE,g=0;g<this.vertices.length;++g)if(this.isReflex(g))for(var h=0;h<this.vertices.length;++h)if(this.canSee(g,h)){b=this.copy(g,h,e).getCutEdges(),c=this.copy(h,g,e).getCutEdges();for(var i=0;i<c.length;i++)b.push(c[i]);b.length<f&&(a=b,f=b.length,a.push([this.at(g),this.at(h)]))}return a},d.prototype.decomp=function(){var a=this.getCutEdges();return a.length>0?this.slice(a):[this]},d.prototype.slice=function(a){if(0==a.length)return[this];if(a instanceof Array&&a.length&&a[0]instanceof Array&&2==a[0].length&&a[0][0]instanceof Array){for(var b=[this],c=0;c<a.length;c++)for(var d=a[c],e=0;e<b.length;e++){var f=b[e],g=f.slice(d);if(g){b.splice(e,1),b.push(g[0],g[1]);break}}return b}var d=a,c=this.vertices.indexOf(d[0]),e=this.vertices.indexOf(d[1]);return-1!=c&&-1!=e?[this.copy(c,e),this.copy(e,c)]:!1},d.prototype.isSimple=function(){for(var a=this.vertices,b=0;b<a.length-1;b++)for(var c=0;b-1>c;c++)if(f.segmentsIntersect(a[b],a[b+1],a[c],a[c+1]))return!1;for(var b=1;b<a.length-2;b++)if(f.segmentsIntersect(a[0],a[a.length-1],a[b],a[b+1]))return!1;return!0},d.prototype.quickDecomp=function(a,b,c,f,h,i){h=h||100,i=i||0,f=f||25,a="undefined"!=typeof a?a:[],b=b||[],c=c||[];var j=[0,0],k=[0,0],l=[0,0],m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=new d,u=new d,v=this,w=this.vertices;if(w.length<3)return a;if(i++,i>h)return console.warn("quickDecomp: max level ("+h+") reached."),a;for(var x=0;x<this.vertices.length;++x)if(v.isReflex(x)){b.push(v.vertices[x]),m=n=Number.MAX_VALUE;for(var y=0;y<this.vertices.length;++y)g.left(v.at(x-1),v.at(x),v.at(y))&&g.rightOn(v.at(x-1),v.at(x),v.at(y-1))&&(l=e(v.at(x-1),v.at(x),v.at(y),v.at(y-1)),g.right(v.at(x+1),v.at(x),l)&&(o=g.sqdist(v.vertices[x],l),n>o&&(n=o,k=l,r=y))),g.left(v.at(x+1),v.at(x),v.at(y+1))&&g.rightOn(v.at(x+1),v.at(x),v.at(y))&&(l=e(v.at(x+1),v.at(x),v.at(y),v.at(y+1)),g.left(v.at(x-1),v.at(x),l)&&(o=g.sqdist(v.vertices[x],l),m>o&&(m=o,j=l,q=y)));if(r==(q+1)%this.vertices.length)l[0]=(k[0]+j[0])/2,l[1]=(k[1]+j[1])/2,c.push(l),q>x?(t.append(v,x,q+1),t.vertices.push(l),u.vertices.push(l),0!=r&&u.append(v,r,v.vertices.length),u.append(v,0,x+1)):(0!=x&&t.append(v,x,v.vertices.length),t.append(v,0,q+1),t.vertices.push(l),u.vertices.push(l),u.append(v,r,x+1));else{if(r>q&&(q+=this.vertices.length),p=Number.MAX_VALUE,r>q)return a;for(var y=r;q>=y;++y)g.leftOn(v.at(x-1),v.at(x),v.at(y))&&g.rightOn(v.at(x+1),v.at(x),v.at(y))&&(o=g.sqdist(v.at(x),v.at(y)),p>o&&(p=o,s=y%this.vertices.length));s>x?(t.append(v,x,s+1),0!=s&&u.append(v,s,w.length),u.append(v,0,x+1)):(0!=x&&t.append(v,x,w.length),t.append(v,0,s+1),u.append(v,s,x+1))}return t.vertices.length<u.vertices.length?(t.quickDecomp(a,b,c,f,h,i),u.quickDecomp(a,b,c,f,h,i)):(u.quickDecomp(a,b,c,f,h,i),t.quickDecomp(a,b,c,f,h,i)),a}return a.push(this),a},d.prototype.removeCollinearPoints=function(a){for(var b=0,c=this.vertices.length-1;this.vertices.length>3&&c>=0;--c)g.collinear(this.at(c-1),this.at(c),this.at(c+1),a)&&(this.vertices.splice(c%this.vertices.length,1),c--,b++);return b}},{"./Line":1,"./Point":2,"./Scalar":4}],4:[function(a,b,c){function d(){}b.exports=d,d.eq=function(a,b,c){return c=c||0,Math.abs(a-b)<c}},{}],5:[function(a,b,c){b.exports={Polygon:a("./Polygon"),Point:a("./Point")}},{"./Point":2,"./Polygon":3}],6:[function(a,b,c){b.exports={name:"p2",version:"0.7.0",description:"A JavaScript 2D physics engine.",author:"Stefan Hedman <schteppe@gmail.com> (http://steffe.se)",keywords:["p2.js","p2","physics","engine","2d"],main:"./src/p2.js",engines:{node:"*"},repository:{type:"git",url:"https://github.com/schteppe/p2.js.git"},bugs:{url:"https://github.com/schteppe/p2.js/issues"},licenses:[{type:"MIT"}],devDependencies:{grunt:"^0.4.5","grunt-contrib-jshint":"^0.11.2","grunt-contrib-nodeunit":"^0.4.1","grunt-contrib-uglify":"~0.4.0","grunt-contrib-watch":"~0.5.0","grunt-browserify":"~2.0.1","grunt-contrib-concat":"^0.4.0"},dependencies:{"poly-decomp":"0.1.0"}}},{}],7:[function(a,b,c){function d(a){this.lowerBound=e.create(),a&&a.lowerBound&&e.copy(this.lowerBound,a.lowerBound),this.upperBound=e.create(),a&&a.upperBound&&e.copy(this.upperBound,a.upperBound)}var e=a("../math/vec2");a("../utils/Utils");b.exports=d;var f=e.create();d.prototype.setFromPoints=function(a,b,c,d){var g=this.lowerBound,h=this.upperBound;"number"!=typeof c&&(c=0),0!==c?e.rotate(g,a[0],c):e.copy(g,a[0]),e.copy(h,g);for(var i=Math.cos(c),j=Math.sin(c),k=1;k<a.length;k++){var l=a[k];if(0!==c){var m=l[0],n=l[1];f[0]=i*m-j*n,f[1]=j*m+i*n,l=f}for(var o=0;2>o;o++)l[o]>h[o]&&(h[o]=l[o]),l[o]<g[o]&&(g[o]=l[o])}b&&(e.add(this.lowerBound,this.lowerBound,b),e.add(this.upperBound,this.upperBound,b)),d&&(this.lowerBound[0]-=d,this.lowerBound[1]-=d,this.upperBound[0]+=d,this.upperBound[1]+=d)},d.prototype.copy=function(a){e.copy(this.lowerBound,a.lowerBound),e.copy(this.upperBound,a.upperBound)},d.prototype.extend=function(a){for(var b=2;b--;){var c=a.lowerBound[b];this.lowerBound[b]>c&&(this.lowerBound[b]=c);var d=a.upperBound[b];this.upperBound[b]<d&&(this.upperBound[b]=d)}},d.prototype.overlaps=function(a){var b=this.lowerBound,c=this.upperBound,d=a.lowerBound,e=a.upperBound;return(d[0]<=c[0]&&c[0]<=e[0]||b[0]<=e[0]&&e[0]<=c[0])&&(d[1]<=c[1]&&c[1]<=e[1]||b[1]<=e[1]&&e[1]<=c[1])},d.prototype.containsPoint=function(a){var b=this.lowerBound,c=this.upperBound;return b[0]<=a[0]&&a[0]<=c[0]&&b[1]<=a[1]&&a[1]<=c[1]},d.prototype.overlapsRay=function(a){var b=1/a.direction[0],c=1/a.direction[1],d=(this.lowerBound[0]-a.from[0])*b,e=(this.upperBound[0]-a.from[0])*b,f=(this.lowerBound[1]-a.from[1])*c,g=(this.upperBound[1]-a.from[1])*c,h=Math.max(Math.max(Math.min(d,e),Math.min(f,g))),i=Math.min(Math.min(Math.max(d,e),Math.max(f,g)));return 0>i?-1:h>i?-1:h}},{"../math/vec2":30,"../utils/Utils":57}],8:[function(a,b,c){function d(a){this.type=a,this.result=[],this.world=null,this.boundingVolumeType=d.AABB}var e=a("../math/vec2"),f=a("../objects/Body");b.exports=d,d.AABB=1,d.BOUNDING_CIRCLE=2,d.prototype.setWorld=function(a){this.world=a},d.prototype.getCollisionPairs=function(a){};var g=e.create();d.boundingRadiusCheck=function(a,b){e.sub(g,a.position,b.position);var c=e.squaredLength(g),d=a.boundingRadius+b.boundingRadius;return d*d>=c},d.aabbCheck=function(a,b){return a.getAABB().overlaps(b.getAABB())},d.prototype.boundingVolumeCheck=function(a,b){var c;switch(this.boundingVolumeType){case d.BOUNDING_CIRCLE:c=d.boundingRadiusCheck(a,b);break;case d.AABB:c=d.aabbCheck(a,b);break;default:throw new Error("Bounding volume type not recognized: "+this.boundingVolumeType)}return c},d.canCollide=function(a,b){var c=f.KINEMATIC,d=f.STATIC;return a.type===d&&b.type===d?!1:a.type===c&&b.type===d||a.type===d&&b.type===c?!1:a.type===c&&b.type===c?!1:a.sleepState===f.SLEEPING&&b.sleepState===f.SLEEPING?!1:a.sleepState===f.SLEEPING&&b.type===d||b.sleepState===f.SLEEPING&&a.type===d?!1:!0},d.NAIVE=1,d.SAP=2},{"../math/vec2":30,"../objects/Body":31}],9:[function(a,b,c){function d(){e.call(this,e.NAIVE)}var e=(a("../shapes/Circle"),a("../shapes/Plane"),a("../shapes/Shape"),a("../shapes/Particle"),a("../collision/Broadphase"));a("../math/vec2");b.exports=d,d.prototype=new e,d.prototype.constructor=d,d.prototype.getCollisionPairs=function(a){var b=a.bodies,c=this.result;c.length=0;for(var d=0,f=b.length;d!==f;d++)for(var g=b[d],h=0;d>h;h++){var i=b[h];e.canCollide(g,i)&&this.boundingVolumeCheck(g,i)&&c.push(g,i)}return c},d.prototype.aabbQuery=function(a,b,c){c=c||[];for(var d=a.bodies,e=0;e<d.length;e++){var f=d[e];f.aabbNeedsUpdate&&f.updateAABB(),f.aabb.overlaps(b)&&c.push(f)}return c}},{"../collision/Broadphase":8,"../math/vec2":30,"../shapes/Circle":39,"../shapes/Particle":43,"../shapes/Plane":44,"../shapes/Shape":45}],10:[function(a,b,c){function d(){this.contactEquations=[],this.frictionEquations=[],this.enableFriction=!0,this.enabledEquations=!0,this.slipForce=10,this.frictionCoefficient=.3,this.surfaceVelocity=0,this.contactEquationPool=new k({size:32}),this.frictionEquationPool=new l({size:64}),this.restitution=0,this.stiffness=n.DEFAULT_STIFFNESS,this.relaxation=n.DEFAULT_RELAXATION,this.frictionStiffness=n.DEFAULT_STIFFNESS,this.frictionRelaxation=n.DEFAULT_RELAXATION,this.enableFrictionReduction=!0,this.collidingBodiesLastStep=new m,this.contactSkinSize=.01}function e(a,b){g.set(a.vertices[0],.5*-b.length,-b.radius),g.set(a.vertices[1],.5*b.length,-b.radius),g.set(a.vertices[2],.5*b.length,b.radius),g.set(a.vertices[3],.5*-b.length,b.radius)}function f(a,b,c,d){for(var e=T,f=U,j=V,k=W,l=a,m=b.vertices,n=null,o=0;o!==m.length+1;o++){var p=m[o%m.length],q=m[(o+1)%m.length];g.rotate(e,p,d),g.rotate(f,q,d),i(e,e,c),i(f,f,c),h(j,e,l),h(k,f,l);var r=g.crossLength(j,k);if(null===n&&(n=r),0>=r*n)return!1;n=r}return!0}var g=a("../math/vec2"),h=g.sub,i=g.add,j=g.dot,k=(a("../utils/Utils"),a("../utils/ContactEquationPool")),l=a("../utils/FrictionEquationPool"),m=a("../utils/TupleDictionary"),n=a("../equations/Equation"),o=(a("../equations/ContactEquation"),a("../equations/FrictionEquation"),a("../shapes/Circle")),p=a("../shapes/Convex"),q=a("../shapes/Shape"),r=(a("../objects/Body"),a("../shapes/Box"));b.exports=d;var s=g.fromValues(0,1),t=g.fromValues(0,0),u=g.fromValues(0,0),v=g.fromValues(0,0),w=g.fromValues(0,0),x=g.fromValues(0,0),y=g.fromValues(0,0),z=g.fromValues(0,0),A=g.fromValues(0,0),B=g.fromValues(0,0),C=g.fromValues(0,0),D=g.fromValues(0,0),E=g.fromValues(0,0),F=g.fromValues(0,0),G=g.fromValues(0,0),H=g.fromValues(0,0),I=g.fromValues(0,0),J=g.fromValues(0,0),K=g.fromValues(0,0),L=[],M=g.create(),N=g.create();d.prototype.bodiesOverlap=function(a,b){for(var c=M,d=N,e=0,f=a.shapes.length;e!==f;e++){var g=a.shapes[e];a.toWorldFrame(c,g.position);for(var h=0,i=b.shapes.length;h!==i;h++){var j=b.shapes[h];if(b.toWorldFrame(d,j.position),this[g.type|j.type](a,g,c,g.angle+a.angle,b,j,d,j.angle+b.angle,!0))return!0}}return!1},d.prototype.collidedLastStep=function(a,b){var c=0|a.id,d=0|b.id;return!!this.collidingBodiesLastStep.get(c,d)},d.prototype.reset=function(){this.collidingBodiesLastStep.reset();for(var a=this.contactEquations,b=a.length;b--;){var c=a[b],d=c.bodyA.id,e=c.bodyB.id;this.collidingBodiesLastStep.set(d,e,!0)}for(var f=this.contactEquations,g=this.frictionEquations,h=0;h<f.length;h++)this.contactEquationPool.release(f[h]);for(var h=0;h<g.length;h++)this.frictionEquationPool.release(g[h]);this.contactEquations.length=this.frictionEquations.length=0},d.prototype.createContactEquation=function(a,b,c,d){var e=this.contactEquationPool.get();return e.bodyA=a,e.bodyB=b,e.shapeA=c,e.shapeB=d,e.restitution=this.restitution,e.firstImpact=!this.collidedLastStep(a,b),e.stiffness=this.stiffness,e.relaxation=this.relaxation,e.needsUpdate=!0,e.enabled=this.enabledEquations,e.offset=this.contactSkinSize,e},d.prototype.createFrictionEquation=function(a,b,c,d){var e=this.frictionEquationPool.get();return e.bodyA=a,e.bodyB=b,e.shapeA=c,e.shapeB=d,e.setSlipForce(this.slipForce),e.frictionCoefficient=this.frictionCoefficient,e.relativeVelocity=this.surfaceVelocity,e.enabled=this.enabledEquations,e.needsUpdate=!0,e.stiffness=this.frictionStiffness,e.relaxation=this.frictionRelaxation,e.contactEquations.length=0,e},d.prototype.createFrictionFromContact=function(a){var b=this.createFrictionEquation(a.bodyA,a.bodyB,a.shapeA,a.shapeB);return g.copy(b.contactPointA,a.contactPointA),g.copy(b.contactPointB,a.contactPointB),g.rotate90cw(b.t,a.normalA),b.contactEquations.push(a),b},d.prototype.createFrictionFromAverage=function(a){var b=this.contactEquations[this.contactEquations.length-1],c=this.createFrictionEquation(b.bodyA,b.bodyB,b.shapeA,b.shapeB),d=b.bodyA;b.bodyB;g.set(c.contactPointA,0,0),g.set(c.contactPointB,0,0),g.set(c.t,0,0);for(var e=0;e!==a;e++)b=this.contactEquations[this.contactEquations.length-1-e],b.bodyA===d?(g.add(c.t,c.t,b.normalA),g.add(c.contactPointA,c.contactPointA,b.contactPointA),g.add(c.contactPointB,c.contactPointB,b.contactPointB)):(g.sub(c.t,c.t,b.normalA),g.add(c.contactPointA,c.contactPointA,b.contactPointB),g.add(c.contactPointB,c.contactPointB,b.contactPointA)),c.contactEquations.push(b);var f=1/a;return g.scale(c.contactPointA,c.contactPointA,f),g.scale(c.contactPointB,c.contactPointB,f),g.normalize(c.t,c.t),g.rotate90cw(c.t,c.t),c},d.prototype[q.LINE|q.CONVEX]=d.prototype.convexLine=function(a,b,c,d,e,f,g,h,i){return i?!1:0},d.prototype[q.LINE|q.BOX]=d.prototype.lineBox=function(a,b,c,d,e,f,g,h,i){return i?!1:0};var O=new r({width:1,height:1}),P=g.create();d.prototype[q.CAPSULE|q.CONVEX]=d.prototype[q.CAPSULE|q.BOX]=d.prototype.convexCapsule=function(a,b,c,d,f,h,i,j,k){var l=P;g.set(l,h.length/2,0),g.rotate(l,l,j),g.add(l,l,i);var m=this.circleConvex(f,h,l,j,a,b,c,d,k,h.radius);g.set(l,-h.length/2,0),g.rotate(l,l,j),g.add(l,l,i);var n=this.circleConvex(f,h,l,j,a,b,c,d,k,h.radius);if(k&&(m||n))return!0;var o=O;e(o,h);var p=this.convexConvex(a,b,c,d,f,o,i,j,k);return p+m+n},d.prototype[q.CAPSULE|q.LINE]=d.prototype.lineCapsule=function(a,b,c,d,e,f,g,h,i){return i?!1:0};var Q=g.create(),R=g.create(),S=new r({width:1,height:1});d.prototype[q.CAPSULE|q.CAPSULE]=d.prototype.capsuleCapsule=function(a,b,c,d,f,h,i,j,k){for(var l,m=Q,n=R,o=0,p=0;2>p;p++){g.set(m,(0===p?-1:1)*b.length/2,0),g.rotate(m,m,d),g.add(m,m,c);for(var q=0;2>q;q++){g.set(n,(0===q?-1:1)*h.length/2,0),g.rotate(n,n,j),g.add(n,n,i),this.enableFrictionReduction&&(l=this.enableFriction,this.enableFriction=!1);var r=this.circleCircle(a,b,m,d,f,h,n,j,k,b.radius,h.radius);if(this.enableFrictionReduction&&(this.enableFriction=l),k&&r)return!0;o+=r}}this.enableFrictionReduction&&(l=this.enableFriction,this.enableFriction=!1);var s=S;e(s,b);var t=this.convexCapsule(a,s,c,d,f,h,i,j,k);if(this.enableFrictionReduction&&(this.enableFriction=l),k&&t)return!0;if(o+=t,this.enableFrictionReduction){var l=this.enableFriction;this.enableFriction=!1}e(s,h);var u=this.convexCapsule(f,s,i,j,a,b,c,d,k);return this.enableFrictionReduction&&(this.enableFriction=l),k&&u?!0:(o+=u,this.enableFrictionReduction&&o&&this.enableFriction&&this.frictionEquations.push(this.createFrictionFromAverage(o)),o)},d.prototype[q.LINE|q.LINE]=d.prototype.lineLine=function(a,b,c,d,e,f,g,h,i){return i?!1:0},d.prototype[q.PLANE|q.LINE]=d.prototype.planeLine=function(a,b,c,d,e,f,k,l,m){var n=t,o=u,p=v,q=w,r=x,C=y,D=z,E=A,F=B,G=L,H=0;g.set(n,-f.length/2,0),g.set(o,f.length/2,0),g.rotate(p,n,l),g.rotate(q,o,l),i(p,p,k),i(q,q,k),g.copy(n,p),g.copy(o,q),h(r,o,n),g.normalize(C,r),g.rotate90cw(F,C),g.rotate(E,s,d),G[0]=n,G[1]=o;for(var I=0;I<G.length;I++){var J=G[I];h(D,J,c);var K=j(D,E);if(0>K){if(m)return!0;var M=this.createContactEquation(a,e,b,f);H++,g.copy(M.normalA,E),g.normalize(M.normalA,M.normalA),g.scale(D,E,K),h(M.contactPointA,J,D),h(M.contactPointA,M.contactPointA,a.position),h(M.contactPointB,J,k),i(M.contactPointB,M.contactPointB,k),h(M.contactPointB,M.contactPointB,e.position),this.contactEquations.push(M),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(M))}}return m?!1:(this.enableFrictionReduction||H&&this.enableFriction&&this.frictionEquations.push(this.createFrictionFromAverage(H)),H)},d.prototype[q.PARTICLE|q.CAPSULE]=d.prototype.particleCapsule=function(a,b,c,d,e,f,g,h,i){return this.circleLine(a,b,c,d,e,f,g,h,i,f.radius,0)},d.prototype[q.CIRCLE|q.LINE]=d.prototype.circleLine=function(a,b,c,d,e,f,k,l,m,n,o){var n=n||0,o="undefined"!=typeof o?o:b.radius,p=t,q=u,r=v,s=w,H=x,I=y,J=z,K=A,M=B,N=C,O=D,P=E,Q=F,R=G,S=L;g.set(K,-f.length/2,0),g.set(M,f.length/2,0),g.rotate(N,K,l),g.rotate(O,M,l),i(N,N,k),i(O,O,k),g.copy(K,N),g.copy(M,O),h(I,M,K),g.normalize(J,I),g.rotate90cw(H,J),h(P,c,K);var T=j(P,H);h(s,K,k),h(Q,c,k);var U=o+n;if(Math.abs(T)<U){g.scale(p,H,T),h(r,c,p),g.scale(q,H,j(H,Q)),g.normalize(q,q),g.scale(q,q,n),i(r,r,q);var V=j(J,r),W=j(J,K),X=j(J,M);if(V>W&&X>V){if(m)return!0;var Y=this.createContactEquation(a,e,b,f);return g.scale(Y.normalA,p,-1),g.normalize(Y.normalA,Y.normalA),g.scale(Y.contactPointA,Y.normalA,o),i(Y.contactPointA,Y.contactPointA,c),h(Y.contactPointA,Y.contactPointA,a.position),h(Y.contactPointB,r,k),i(Y.contactPointB,Y.contactPointB,k),h(Y.contactPointB,Y.contactPointB,e.position),this.contactEquations.push(Y),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(Y)),1}}S[0]=K,S[1]=M;for(var Z=0;Z<S.length;Z++){var $=S[Z];if(h(P,$,c),g.squaredLength(P)<Math.pow(U,2)){if(m)return!0;var Y=this.createContactEquation(a,e,b,f);return g.copy(Y.normalA,P),g.normalize(Y.normalA,Y.normalA),g.scale(Y.contactPointA,Y.normalA,o),i(Y.contactPointA,Y.contactPointA,c),h(Y.contactPointA,Y.contactPointA,a.position),h(Y.contactPointB,$,k),g.scale(R,Y.normalA,-n),i(Y.contactPointB,Y.contactPointB,R),i(Y.contactPointB,Y.contactPointB,k),h(Y.contactPointB,Y.contactPointB,e.position),this.contactEquations.push(Y),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(Y)),1}}return 0},d.prototype[q.CIRCLE|q.CAPSULE]=d.prototype.circleCapsule=function(a,b,c,d,e,f,g,h,i){return this.circleLine(a,b,c,d,e,f,g,h,i,f.radius)},d.prototype[q.CIRCLE|q.CONVEX]=d.prototype[q.CIRCLE|q.BOX]=d.prototype.circleConvex=function(a,b,c,d,e,j,k,l,m,n){for(var n="number"==typeof n?n:b.radius,o=t,p=u,q=v,r=w,s=x,y=C,z=D,A=F,B=G,E=H,J=I,K=!1,L=Number.MAX_VALUE,M=j.vertices,N=0;N!==M.length+1;N++){var O=M[N%M.length],P=M[(N+1)%M.length];if(g.rotate(o,O,l),g.rotate(p,P,l),i(o,o,k),i(p,p,k),h(q,p,o),g.normalize(r,q),g.rotate90cw(s,r),g.scale(B,s,-b.radius),i(B,B,c),f(B,j,k,l)){g.sub(E,o,B);var Q=Math.abs(g.dot(E,s));L>Q&&(g.copy(J,B),L=Q,g.scale(A,s,Q),g.add(A,A,B),K=!0)}}if(K){if(m)return!0;var R=this.createContactEquation(a,e,b,j);return g.sub(R.normalA,J,c),g.normalize(R.normalA,R.normalA),g.scale(R.contactPointA,R.normalA,n),i(R.contactPointA,R.contactPointA,c),h(R.contactPointA,R.contactPointA,a.position),h(R.contactPointB,A,k),i(R.contactPointB,R.contactPointB,k),h(R.contactPointB,R.contactPointB,e.position),this.contactEquations.push(R),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(R)),1}if(n>0)for(var N=0;N<M.length;N++){var S=M[N];if(g.rotate(z,S,l),i(z,z,k),h(y,z,c),g.squaredLength(y)<Math.pow(n,2)){if(m)return!0;var R=this.createContactEquation(a,e,b,j);return g.copy(R.normalA,y),g.normalize(R.normalA,R.normalA),g.scale(R.contactPointA,R.normalA,n),i(R.contactPointA,R.contactPointA,c),h(R.contactPointA,R.contactPointA,a.position),h(R.contactPointB,z,k),i(R.contactPointB,R.contactPointB,k),h(R.contactPointB,R.contactPointB,e.position),this.contactEquations.push(R),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(R)),1}}return 0};var T=g.create(),U=g.create(),V=g.create(),W=g.create();d.prototype[q.PARTICLE|q.CONVEX]=d.prototype[q.PARTICLE|q.BOX]=d.prototype.particleConvex=function(a,b,c,d,e,k,l,m,n){var o=t,p=u,q=v,r=w,s=x,A=y,B=z,D=C,E=F,G=J,H=K,I=Number.MAX_VALUE,L=!1,M=k.vertices;if(!f(c,k,l,m))return 0;if(n)return!0;for(var N=0;N!==M.length+1;N++){var O=M[N%M.length],P=M[(N+1)%M.length];g.rotate(o,O,m),g.rotate(p,P,m),i(o,o,l),i(p,p,l),h(q,p,o),g.normalize(r,q),g.rotate90cw(s,r),h(D,c,o);j(D,s);h(A,o,l),h(B,c,l),g.sub(G,o,c);var Q=Math.abs(g.dot(G,s));I>Q&&(I=Q,g.scale(E,s,Q),g.add(E,E,c),g.copy(H,s),L=!0)}if(L){var R=this.createContactEquation(a,e,b,k);return g.scale(R.normalA,H,-1),g.normalize(R.normalA,R.normalA),g.set(R.contactPointA,0,0),i(R.contactPointA,R.contactPointA,c),h(R.contactPointA,R.contactPointA,a.position),h(R.contactPointB,E,l),i(R.contactPointB,R.contactPointB,l),h(R.contactPointB,R.contactPointB,e.position),this.contactEquations.push(R),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(R)),1}return 0},d.prototype[q.CIRCLE]=d.prototype.circleCircle=function(a,b,c,d,e,f,j,k,l,m,n){var o=t,m=m||b.radius,n=n||f.radius;h(o,c,j);var p=m+n;if(g.squaredLength(o)>Math.pow(p,2))return 0;if(l)return!0;var q=this.createContactEquation(a,e,b,f);return h(q.normalA,j,c),g.normalize(q.normalA,q.normalA),g.scale(q.contactPointA,q.normalA,m),g.scale(q.contactPointB,q.normalA,-n),i(q.contactPointA,q.contactPointA,c),h(q.contactPointA,q.contactPointA,a.position),i(q.contactPointB,q.contactPointB,j),h(q.contactPointB,q.contactPointB,e.position),this.contactEquations.push(q),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(q)),1},d.prototype[q.PLANE|q.CONVEX]=d.prototype[q.PLANE|q.BOX]=d.prototype.planeConvex=function(a,b,c,d,e,f,k,l,m){var n=t,o=u,p=v,q=0;g.rotate(o,s,d);for(var r=0;r!==f.vertices.length;r++){var w=f.vertices[r];if(g.rotate(n,w,l),i(n,n,k),h(p,n,c),j(p,o)<=0){if(m)return!0;q++;var x=this.createContactEquation(a,e,b,f);h(p,n,c),g.copy(x.normalA,o);var y=j(p,x.normalA);g.scale(p,x.normalA,y),h(x.contactPointB,n,e.position),h(x.contactPointA,n,p),h(x.contactPointA,x.contactPointA,a.position),this.contactEquations.push(x),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(x))}}return this.enableFrictionReduction&&this.enableFriction&&q&&this.frictionEquations.push(this.createFrictionFromAverage(q)),q},d.prototype[q.PARTICLE|q.PLANE]=d.prototype.particlePlane=function(a,b,c,d,e,f,i,k,l){var m=t,n=u;k=k||0,h(m,c,i),g.rotate(n,s,k);var o=j(m,n);if(o>0)return 0;if(l)return!0;var p=this.createContactEquation(e,a,f,b);return g.copy(p.normalA,n),g.scale(m,p.normalA,o),h(p.contactPointA,c,m),h(p.contactPointA,p.contactPointA,e.position),h(p.contactPointB,c,a.position),this.contactEquations.push(p),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(p)),1},d.prototype[q.CIRCLE|q.PARTICLE]=d.prototype.circleParticle=function(a,b,c,d,e,f,j,k,l){var m=t;if(h(m,j,c),g.squaredLength(m)>Math.pow(b.radius,2))return 0;if(l)return!0;var n=this.createContactEquation(a,e,b,f);return g.copy(n.normalA,m),g.normalize(n.normalA,n.normalA),g.scale(n.contactPointA,n.normalA,b.radius),i(n.contactPointA,n.contactPointA,c),h(n.contactPointA,n.contactPointA,a.position),h(n.contactPointB,j,e.position),this.contactEquations.push(n),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(n)),1};var X=new o({radius:1}),Y=g.create(),Z=g.create();g.create();d.prototype[q.PLANE|q.CAPSULE]=d.prototype.planeCapsule=function(a,b,c,d,e,f,h,j,k){var l=Y,m=Z,n=X;g.set(l,-f.length/2,0),g.rotate(l,l,j),i(l,l,h),g.set(m,f.length/2,0),g.rotate(m,m,j),i(m,m,h),n.radius=f.radius;var o;this.enableFrictionReduction&&(o=this.enableFriction,this.enableFriction=!1);var p=this.circlePlane(e,n,l,0,a,b,c,d,k),q=this.circlePlane(e,n,m,0,a,b,c,d,k);if(this.enableFrictionReduction&&(this.enableFriction=o),k)return p||q;var r=p+q;return this.enableFrictionReduction&&r&&this.frictionEquations.push(this.createFrictionFromAverage(r)),r},d.prototype[q.CIRCLE|q.PLANE]=d.prototype.circlePlane=function(a,b,c,d,e,f,k,l,m){var n=a,o=b,p=c,q=e,r=k,w=l;w=w||0;var x=t,y=u,z=v;h(x,p,r),g.rotate(y,s,w);var A=j(y,x);if(A>o.radius)return 0;if(m)return!0;var B=this.createContactEquation(q,n,f,b);return g.copy(B.normalA,y),g.scale(B.contactPointB,B.normalA,-o.radius),i(B.contactPointB,B.contactPointB,p),h(B.contactPointB,B.contactPointB,n.position),g.scale(z,B.normalA,A),h(B.contactPointA,x,z),i(B.contactPointA,B.contactPointA,r),h(B.contactPointA,B.contactPointA,q.position),this.contactEquations.push(B),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(B)),1},d.prototype[q.CONVEX]=d.prototype[q.CONVEX|q.BOX]=d.prototype[q.BOX]=d.prototype.convexConvex=function(a,b,c,e,f,k,l,m,n,o){var p=t,q=u,r=v,s=w,y=x,C=z,D=A,E=B,F=0,o="number"==typeof o?o:0,G=d.findSeparatingAxis(b,c,e,k,l,m,p);if(!G)return 0;h(D,l,c),j(p,D)>0&&g.scale(p,p,-1);var H=d.getClosestEdge(b,e,p,!0),I=d.getClosestEdge(k,m,p);if(-1===H||-1===I)return 0;for(var J=0;2>J;J++){var K=H,L=I,M=b,N=k,O=c,P=l,Q=e,R=m,S=a,T=f;if(0===J){var U;U=K,K=L,L=U,U=M,M=N,N=U,U=O,O=P,P=U,U=Q,Q=R,R=U,U=S,S=T,T=U}for(var V=L;L+2>V;V++){var W=N.vertices[(V+N.vertices.length)%N.vertices.length];g.rotate(q,W,R),i(q,q,P);for(var X=0,Y=K-1;K+2>Y;Y++){var Z=M.vertices[(Y+M.vertices.length)%M.vertices.length],$=M.vertices[(Y+1+M.vertices.length)%M.vertices.length];g.rotate(r,Z,Q),g.rotate(s,$,Q),i(r,r,O),i(s,s,O),h(y,s,r),g.rotate90cw(E,y),g.normalize(E,E),h(D,q,r);var _=j(E,D);(Y===K&&o>=_||Y!==K&&0>=_)&&X++}if(X>=3){if(n)return!0;var aa=this.createContactEquation(S,T,M,N);F++;var Z=M.vertices[K%M.vertices.length],$=M.vertices[(K+1)%M.vertices.length];g.rotate(r,Z,Q),g.rotate(s,$,Q),i(r,r,O),i(s,s,O),h(y,s,r),g.rotate90cw(aa.normalA,y),g.normalize(aa.normalA,aa.normalA),h(D,q,r);var _=j(aa.normalA,D);g.scale(C,aa.normalA,_),h(aa.contactPointA,q,O),h(aa.contactPointA,aa.contactPointA,C),i(aa.contactPointA,aa.contactPointA,O),h(aa.contactPointA,aa.contactPointA,S.position),h(aa.contactPointB,q,P),i(aa.contactPointB,aa.contactPointB,P),h(aa.contactPointB,aa.contactPointB,T.position),this.contactEquations.push(aa),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(aa))}}}return this.enableFrictionReduction&&this.enableFriction&&F&&this.frictionEquations.push(this.createFrictionFromAverage(F)),F};var $=g.fromValues(0,0);d.projectConvexOntoAxis=function(a,b,c,d,e){var f,h,i=null,k=null,l=$;g.rotate(l,d,-c);for(var m=0;m<a.vertices.length;m++)f=a.vertices[m],h=j(f,l),(null===i||h>i)&&(i=h),(null===k||k>h)&&(k=h);if(k>i){var n=k;k=i,i=n}var o=j(b,d);g.set(e,k+o,i+o)};var _=g.fromValues(0,0),aa=g.fromValues(0,0),ba=g.fromValues(0,0),ca=g.fromValues(0,0),da=g.fromValues(0,0),ea=g.fromValues(0,0);d.findSeparatingAxis=function(a,b,c,e,f,i,j){var k=null,l=!1,m=!1,n=_,o=aa,p=ba,q=ca,s=da,t=ea;if(a instanceof r&&e instanceof r)for(var u=0;2!==u;u++){var v=a,w=c;1===u&&(v=e,w=i);for(var x=0;2!==x;x++){0===x?g.set(q,0,1):1===x&&g.set(q,1,0),0!==w&&g.rotate(q,q,w),d.projectConvexOntoAxis(a,b,c,q,s),d.projectConvexOntoAxis(e,f,i,q,t);var y=s,z=t,A=!1;s[0]>t[0]&&(z=s,y=t,A=!0);var B=z[0]-y[1];l=0>=B,(null===k||B>k)&&(g.copy(j,q),k=B,m=l)}}else for(var u=0;2!==u;u++){var v=a,w=c;1===u&&(v=e,w=i);for(var x=0;x!==v.vertices.length;x++){g.rotate(o,v.vertices[x],w),g.rotate(p,v.vertices[(x+1)%v.vertices.length],w),h(n,p,o),g.rotate90cw(q,n),g.normalize(q,q),d.projectConvexOntoAxis(a,b,c,q,s),d.projectConvexOntoAxis(e,f,i,q,t);var y=s,z=t,A=!1;s[0]>t[0]&&(z=s,y=t,A=!0);var B=z[0]-y[1];l=0>=B,(null===k||B>k)&&(g.copy(j,q),k=B,m=l)}}return m};var fa=g.fromValues(0,0),ga=g.fromValues(0,0),ha=g.fromValues(0,0);d.getClosestEdge=function(a,b,c,d){var e=fa,f=ga,i=ha;g.rotate(e,c,-b),d&&g.scale(e,e,-1);for(var k=-1,l=a.vertices.length,m=-1,n=0;n!==l;n++){h(f,a.vertices[(n+1)%l],a.vertices[n%l]),g.rotate90cw(i,f),g.normalize(i,i);var o=j(i,e);(-1===k||o>m)&&(k=n%l,m=o)}return k};var ia=g.create(),ja=g.create(),ka=g.create(),la=g.create(),ma=g.create(),na=g.create(),oa=g.create();d.prototype[q.CIRCLE|q.HEIGHTFIELD]=d.prototype.circleHeightfield=function(a,b,c,d,e,f,j,k,l,m){var n=f.heights,m=m||b.radius,o=f.elementWidth,p=ja,q=ia,r=ma,s=oa,t=na,u=ka,v=la,w=Math.floor((c[0]-m-j[0])/o),x=Math.ceil((c[0]+m-j[0])/o);0>w&&(w=0),x>=n.length&&(x=n.length-1);for(var y=n[w],z=n[x],A=w;x>A;A++)n[A]<z&&(z=n[A]),n[A]>y&&(y=n[A]);if(c[1]-m>y)return l?!1:0;for(var B=!1,A=w;x>A;A++){g.set(u,A*o,n[A]),g.set(v,(A+1)*o,n[A+1]),g.add(u,u,j),g.add(v,v,j),g.sub(t,v,u),g.rotate(t,t,Math.PI/2),g.normalize(t,t),g.scale(q,t,-m),g.add(q,q,c),g.sub(p,q,u);var C=g.dot(p,t);if(q[0]>=u[0]&&q[0]<v[0]&&0>=C){if(l)return!0;B=!0,g.scale(p,t,-C),g.add(r,q,p),g.copy(s,t);var D=this.createContactEquation(e,a,f,b);g.copy(D.normalA,s),g.scale(D.contactPointB,D.normalA,-m),i(D.contactPointB,D.contactPointB,c),h(D.contactPointB,D.contactPointB,a.position),g.copy(D.contactPointA,r),g.sub(D.contactPointA,D.contactPointA,e.position),this.contactEquations.push(D),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(D))}}if(B=!1,m>0)for(var A=w;x>=A;A++)if(g.set(u,A*o,n[A]),g.add(u,u,j),g.sub(p,c,u),g.squaredLength(p)<Math.pow(m,2)){ +if(l)return!0;B=!0;var D=this.createContactEquation(e,a,f,b);g.copy(D.normalA,p),g.normalize(D.normalA,D.normalA),g.scale(D.contactPointB,D.normalA,-m),i(D.contactPointB,D.contactPointB,c),h(D.contactPointB,D.contactPointB,a.position),h(D.contactPointA,u,j),i(D.contactPointA,D.contactPointA,j),h(D.contactPointA,D.contactPointA,e.position),this.contactEquations.push(D),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(D))}return B?1:0};var pa=g.create(),qa=g.create(),ra=g.create(),sa=new p({vertices:[g.create(),g.create(),g.create(),g.create()]});d.prototype[q.BOX|q.HEIGHTFIELD]=d.prototype[q.CONVEX|q.HEIGHTFIELD]=d.prototype.convexHeightfield=function(a,b,c,d,e,f,h,i,j){var k=f.heights,l=f.elementWidth,m=pa,n=qa,o=ra,p=sa,q=Math.floor((a.aabb.lowerBound[0]-h[0])/l),r=Math.ceil((a.aabb.upperBound[0]-h[0])/l);0>q&&(q=0),r>=k.length&&(r=k.length-1);for(var s=k[q],t=k[r],u=q;r>u;u++)k[u]<t&&(t=k[u]),k[u]>s&&(s=k[u]);if(a.aabb.lowerBound[1]>s)return j?!1:0;for(var v=0,u=q;r>u;u++){g.set(m,u*l,k[u]),g.set(n,(u+1)*l,k[u+1]),g.add(m,m,h),g.add(n,n,h);var w=100;g.set(o,.5*(n[0]+m[0]),.5*(n[1]+m[1]-w)),g.sub(p.vertices[0],n,o),g.sub(p.vertices[1],m,o),g.copy(p.vertices[2],p.vertices[1]),g.copy(p.vertices[3],p.vertices[0]),p.vertices[2][1]-=w,p.vertices[3][1]-=w,v+=this.convexConvex(a,b,c,d,e,p,o,0,j)}return v}},{"../equations/ContactEquation":21,"../equations/Equation":22,"../equations/FrictionEquation":23,"../math/vec2":30,"../objects/Body":31,"../shapes/Box":37,"../shapes/Circle":39,"../shapes/Convex":40,"../shapes/Shape":45,"../utils/ContactEquationPool":48,"../utils/FrictionEquationPool":49,"../utils/TupleDictionary":56,"../utils/Utils":57}],11:[function(a,b,c){function d(a){a=a||{},this.from=a.from?f.fromValues(a.from[0],a.from[1]):f.create(),this.to=a.to?f.fromValues(a.to[0],a.to[1]):f.create(),this.checkCollisionResponse=void 0!==a.checkCollisionResponse?a.checkCollisionResponse:!0,this.skipBackfaces=!!a.skipBackfaces,this.collisionMask=void 0!==a.collisionMask?a.collisionMask:-1,this.collisionGroup=void 0!==a.collisionGroup?a.collisionGroup:-1,this.mode=void 0!==a.mode?a.mode:d.ANY,this.callback=a.callback||function(a){},this.direction=f.create(),this.length=1,this.update()}function e(a,b,c){f.sub(h,c,a);var d=f.dot(h,b);return f.scale(i,b,d),f.add(i,i,a),f.squaredDistance(c,i)}b.exports=d;var f=a("../math/vec2");a("../collision/RaycastResult"),a("../shapes/Shape"),a("../collision/AABB");d.prototype.constructor=d,d.CLOSEST=1,d.ANY=2,d.ALL=4,d.prototype.update=function(){var a=this.direction;f.sub(a,this.to,this.from),this.length=f.length(a),f.normalize(a,a)},d.prototype.intersectBodies=function(a,b){for(var c=0,d=b.length;!a.shouldStop(this)&&d>c;c++){var e=b[c],f=e.getAABB();(f.overlapsRay(this)>=0||f.containsPoint(this.from))&&this.intersectBody(a,e)}};var g=f.create();d.prototype.intersectBody=function(a,b){var c=this.checkCollisionResponse;if(!c||b.collisionResponse)for(var d=g,e=0,h=b.shapes.length;h>e;e++){var i=b.shapes[e];if((!c||i.collisionResponse)&&0!==(this.collisionGroup&i.collisionMask)&&0!==(i.collisionGroup&this.collisionMask)){f.rotate(d,i.position,b.angle),f.add(d,d,b.position);var j=i.angle+b.angle;if(this.intersectShape(a,i,j,d,b),a.shouldStop(this))break}}},d.prototype.intersectShape=function(a,b,c,d,f){var g=this.from,h=e(g,this.direction,d);h>b.boundingRadius*b.boundingRadius||(this._currentBody=f,this._currentShape=b,b.raycast(a,this,d,c),this._currentBody=this._currentShape=null)},d.prototype.getAABB=function(a){var b=this.to,c=this.from;f.set(a.lowerBound,Math.min(b[0],c[0]),Math.min(b[1],c[1])),f.set(a.upperBound,Math.max(b[0],c[0]),Math.max(b[1],c[1]))};f.create();d.prototype.reportIntersection=function(a,b,c,e){var g=(this.from,this.to,this._currentShape),h=this._currentBody;if(!(this.skipBackfaces&&f.dot(c,this.direction)>0))switch(this.mode){case d.ALL:a.set(c,g,h,b,e),this.callback(a);break;case d.CLOSEST:(b<a.fraction||!a.hasHit())&&a.set(c,g,h,b,e);break;case d.ANY:a.set(c,g,h,b,e)}};var h=f.create(),i=f.create()},{"../collision/AABB":7,"../collision/RaycastResult":12,"../math/vec2":30,"../shapes/Shape":45}],12:[function(a,b,c){function d(){this.normal=e.create(),this.shape=null,this.body=null,this.faceIndex=-1,this.fraction=-1,this.isStopped=!1}var e=a("../math/vec2"),f=a("../collision/Ray");b.exports=d,d.prototype.reset=function(){e.set(this.normal,0,0),this.shape=null,this.body=null,this.faceIndex=-1,this.fraction=-1,this.isStopped=!1},d.prototype.getHitDistance=function(a){return e.distance(a.from,a.to)*this.fraction},d.prototype.hasHit=function(){return-1!==this.fraction},d.prototype.getHitPoint=function(a,b){e.lerp(a,b.from,b.to,this.fraction)},d.prototype.stop=function(){this.isStopped=!0},d.prototype.shouldStop=function(a){return this.isStopped||-1!==this.fraction&&a.mode===f.ANY},d.prototype.set=function(a,b,c,d,f){e.copy(this.normal,a),this.shape=b,this.body=c,this.fraction=d,this.faceIndex=f}},{"../collision/Ray":11,"../math/vec2":30}],13:[function(a,b,c){function d(){f.call(this,f.SAP),this.axisList=[],this.axisIndex=0;var a=this;this._addBodyHandler=function(b){a.axisList.push(b.body)},this._removeBodyHandler=function(b){var c=a.axisList.indexOf(b.body);-1!==c&&a.axisList.splice(c,1)}}var e=a("../utils/Utils"),f=a("../collision/Broadphase");b.exports=d,d.prototype=new f,d.prototype.constructor=d,d.prototype.setWorld=function(a){this.axisList.length=0,e.appendArray(this.axisList,a.bodies),a.off("addBody",this._addBodyHandler).off("removeBody",this._removeBodyHandler),a.on("addBody",this._addBodyHandler).on("removeBody",this._removeBodyHandler),this.world=a},d.sortAxisList=function(a,b){b=0|b;for(var c=1,d=a.length;d>c;c++){for(var e=a[c],f=c-1;f>=0&&!(a[f].aabb.lowerBound[b]<=e.aabb.lowerBound[b]);f--)a[f+1]=a[f];a[f+1]=e}return a},d.prototype.sortList=function(){var a=this.axisList,b=this.axisIndex;d.sortAxisList(a,b)},d.prototype.getCollisionPairs=function(a){var b=this.axisList,c=this.result,d=this.axisIndex;c.length=0;for(var e=b.length;e--;){var g=b[e];g.aabbNeedsUpdate&&g.updateAABB()}this.sortList();for(var h=0,i=0|b.length;h!==i;h++)for(var j=b[h],k=h+1;i>k;k++){var l=b[k],m=l.aabb.lowerBound[d]<=j.aabb.upperBound[d];if(!m)break;f.canCollide(j,l)&&this.boundingVolumeCheck(j,l)&&c.push(j,l)}return c},d.prototype.aabbQuery=function(a,b,c){c=c||[],this.sortList();var d=this.axisIndex,e="x";1===d&&(e="y"),2===d&&(e="z");for(var f=this.axisList,g=(b.lowerBound[e],b.upperBound[e],0);g<f.length;g++){var h=f[g];h.aabbNeedsUpdate&&h.updateAABB(),h.aabb.overlaps(b)&&c.push(h)}return c}},{"../collision/Broadphase":8,"../utils/Utils":57}],14:[function(a,b,c){function d(a,b,c,d){this.type=c,d=e.defaults(d,{collideConnected:!0,wakeUpBodies:!0}),this.equations=[],this.bodyA=a,this.bodyB=b,this.collideConnected=d.collideConnected,d.wakeUpBodies&&(a&&a.wakeUp(),b&&b.wakeUp())}b.exports=d;var e=a("../utils/Utils");d.prototype.update=function(){throw new Error("method update() not implmemented in this Constraint subclass!")},d.DISTANCE=1,d.GEAR=2,d.LOCK=3,d.PRISMATIC=4,d.REVOLUTE=5,d.prototype.setStiffness=function(a){for(var b=this.equations,c=0;c!==b.length;c++){var d=b[c];d.stiffness=a,d.needsUpdate=!0}},d.prototype.setRelaxation=function(a){for(var b=this.equations,c=0;c!==b.length;c++){var d=b[c];d.relaxation=a,d.needsUpdate=!0}}},{"../utils/Utils":57}],15:[function(a,b,c){function d(a,b,c){c=h.defaults(c,{localAnchorA:[0,0],localAnchorB:[0,0]}),e.call(this,a,b,e.DISTANCE,c),this.localAnchorA=g.fromValues(c.localAnchorA[0],c.localAnchorA[1]),this.localAnchorB=g.fromValues(c.localAnchorB[0],c.localAnchorB[1]);var d=this.localAnchorA,i=this.localAnchorB;if(this.distance=0,"number"==typeof c.distance)this.distance=c.distance;else{var j=g.create(),k=g.create(),l=g.create();g.rotate(j,d,a.angle),g.rotate(k,i,b.angle),g.add(l,b.position,k),g.sub(l,l,j),g.sub(l,l,a.position),this.distance=g.length(l)}var m;m="undefined"==typeof c.maxForce?Number.MAX_VALUE:c.maxForce;var n=new f(a,b,-m,m);this.equations=[n],this.maxForce=m;var l=g.create(),o=g.create(),p=g.create(),q=this;n.computeGq=function(){var a=this.bodyA,b=this.bodyB,c=a.position,e=b.position;return g.rotate(o,d,a.angle),g.rotate(p,i,b.angle),g.add(l,e,p),g.sub(l,l,o),g.sub(l,l,c),g.length(l)-q.distance},this.setMaxForce(m),this.upperLimitEnabled=!1,this.upperLimit=1,this.lowerLimitEnabled=!1,this.lowerLimit=0,this.position=0}var e=a("./Constraint"),f=a("../equations/Equation"),g=a("../math/vec2"),h=a("../utils/Utils");b.exports=d,d.prototype=new e,d.prototype.constructor=d;var i=g.create(),j=g.create(),k=g.create();d.prototype.update=function(){var a=this.equations[0],b=this.bodyA,c=this.bodyB,d=(this.distance,b.position),e=c.position,f=this.equations[0],h=a.G;g.rotate(j,this.localAnchorA,b.angle),g.rotate(k,this.localAnchorB,c.angle),g.add(i,e,k),g.sub(i,i,j),g.sub(i,i,d),this.position=g.length(i);var l=!1;if(this.upperLimitEnabled&&this.position>this.upperLimit&&(f.maxForce=0,f.minForce=-this.maxForce,this.distance=this.upperLimit,l=!0),this.lowerLimitEnabled&&this.position<this.lowerLimit&&(f.maxForce=this.maxForce,f.minForce=0,this.distance=this.lowerLimit,l=!0),(this.lowerLimitEnabled||this.upperLimitEnabled)&&!l)return void(f.enabled=!1);f.enabled=!0,g.normalize(i,i);var m=g.crossLength(j,i),n=g.crossLength(k,i);h[0]=-i[0],h[1]=-i[1],h[2]=-m,h[3]=i[0],h[4]=i[1],h[5]=n},d.prototype.setMaxForce=function(a){var b=this.equations[0];b.minForce=-a,b.maxForce=a},d.prototype.getMaxForce=function(){var a=this.equations[0];return a.maxForce}},{"../equations/Equation":22,"../math/vec2":30,"../utils/Utils":57,"./Constraint":14}],16:[function(a,b,c){function d(a,b,c){c=c||{},e.call(this,a,b,e.GEAR,c),this.ratio=void 0!==c.ratio?c.ratio:1,this.angle=void 0!==c.angle?c.angle:b.angle-this.ratio*a.angle,c.angle=this.angle,c.ratio=this.ratio,this.equations=[new f(a,b,c)],void 0!==c.maxTorque&&this.setMaxTorque(c.maxTorque)}var e=a("./Constraint"),f=(a("../equations/Equation"),a("../equations/AngleLockEquation"));a("../math/vec2");b.exports=d,d.prototype=new e,d.prototype.constructor=d,d.prototype.update=function(){var a=this.equations[0];a.ratio!==this.ratio&&a.setRatio(this.ratio),a.angle=this.angle},d.prototype.setMaxTorque=function(a){this.equations[0].setMaxTorque(a)},d.prototype.getMaxTorque=function(a){return this.equations[0].maxForce}},{"../equations/AngleLockEquation":20,"../equations/Equation":22,"../math/vec2":30,"./Constraint":14}],17:[function(a,b,c){function d(a,b,c){c=c||{},e.call(this,a,b,e.LOCK,c);var d="undefined"==typeof c.maxForce?Number.MAX_VALUE:c.maxForce,h=(c.localAngleB||0,new g(a,b,-d,d)),i=new g(a,b,-d,d),j=new g(a,b,-d,d),k=f.create(),l=f.create(),m=this;h.computeGq=function(){return f.rotate(k,m.localOffsetB,a.angle),f.sub(l,b.position,a.position),f.sub(l,l,k),l[0]},i.computeGq=function(){return f.rotate(k,m.localOffsetB,a.angle),f.sub(l,b.position,a.position),f.sub(l,l,k),l[1]};var n=f.create(),o=f.create();j.computeGq=function(){return f.rotate(n,m.localOffsetB,b.angle-m.localAngleB),f.scale(n,n,-1),f.sub(l,a.position,b.position),f.add(l,l,n),f.rotate(o,n,-Math.PI/2),f.normalize(o,o),f.dot(l,o)},this.localOffsetB=f.create(),c.localOffsetB?f.copy(this.localOffsetB,c.localOffsetB):(f.sub(this.localOffsetB,b.position,a.position),f.rotate(this.localOffsetB,this.localOffsetB,-a.angle)),this.localAngleB=0,"number"==typeof c.localAngleB?this.localAngleB=c.localAngleB:this.localAngleB=b.angle-a.angle,this.equations.push(h,i,j),this.setMaxForce(d)}var e=a("./Constraint"),f=a("../math/vec2"),g=a("../equations/Equation");b.exports=d,d.prototype=new e,d.prototype.constructor=d,d.prototype.setMaxForce=function(a){for(var b=this.equations,c=0;c<this.equations.length;c++)b[c].maxForce=a,b[c].minForce=-a},d.prototype.getMaxForce=function(){return this.equations[0].maxForce};var h=f.create(),i=f.create(),j=f.create(),k=f.fromValues(1,0),l=f.fromValues(0,1);d.prototype.update=function(){var a=this.equations[0],b=this.equations[1],c=this.equations[2],d=this.bodyA,e=this.bodyB;f.rotate(h,this.localOffsetB,d.angle),f.rotate(i,this.localOffsetB,e.angle-this.localAngleB),f.scale(i,i,-1),f.rotate(j,i,Math.PI/2),f.normalize(j,j),a.G[0]=-1,a.G[1]=0,a.G[2]=-f.crossLength(h,k),a.G[3]=1,b.G[0]=0,b.G[1]=-1,b.G[2]=-f.crossLength(h,l),b.G[4]=1,c.G[0]=-j[0],c.G[1]=-j[1],c.G[3]=j[0],c.G[4]=j[1],c.G[5]=f.crossLength(i,j)}},{"../equations/Equation":22,"../math/vec2":30,"./Constraint":14}],18:[function(a,b,c){function d(a,b,c){c=c||{},e.call(this,a,b,e.PRISMATIC,c);var d=h.fromValues(0,0),j=h.fromValues(1,0),k=h.fromValues(0,0);c.localAnchorA&&h.copy(d,c.localAnchorA),c.localAxisA&&h.copy(j,c.localAxisA),c.localAnchorB&&h.copy(k,c.localAnchorB),this.localAnchorA=d,this.localAnchorB=k,this.localAxisA=j;var l=this.maxForce="undefined"!=typeof c.maxForce?c.maxForce:Number.MAX_VALUE,m=new g(a,b,-l,l),n=new h.create,o=new h.create,p=new h.create,q=new h.create;if(m.computeGq=function(){return h.dot(p,q)},m.updateJacobian=function(){var c=this.G,e=a.position,f=b.position;h.rotate(n,d,a.angle),h.rotate(o,k,b.angle),h.add(p,f,o),h.sub(p,p,e),h.sub(p,p,n),h.rotate(q,j,a.angle+Math.PI/2),c[0]=-q[0],c[1]=-q[1],c[2]=-h.crossLength(n,q)+h.crossLength(q,p),c[3]=q[0],c[4]=q[1],c[5]=h.crossLength(o,q)},this.equations.push(m),!c.disableRotationalLock){var r=new i(a,b,-l,l);this.equations.push(r)}this.position=0,this.velocity=0,this.lowerLimitEnabled="undefined"!=typeof c.lowerLimit?!0:!1,this.upperLimitEnabled="undefined"!=typeof c.upperLimit?!0:!1,this.lowerLimit="undefined"!=typeof c.lowerLimit?c.lowerLimit:0,this.upperLimit="undefined"!=typeof c.upperLimit?c.upperLimit:1,this.upperLimitEquation=new f(a,b),this.lowerLimitEquation=new f(a,b),this.upperLimitEquation.minForce=this.lowerLimitEquation.minForce=0,this.upperLimitEquation.maxForce=this.lowerLimitEquation.maxForce=l,this.motorEquation=new g(a,b),this.motorEnabled=!1,this.motorSpeed=0;var s=this,t=this.motorEquation;t.computeGW;t.computeGq=function(){return 0},t.computeGW=function(){var a=this.G,b=this.bodyA,c=this.bodyB,d=b.velocity,e=c.velocity,f=b.angularVelocity,g=c.angularVelocity;return this.gmult(a,d,f,e,g)+s.motorSpeed}}var e=a("./Constraint"),f=a("../equations/ContactEquation"),g=a("../equations/Equation"),h=a("../math/vec2"),i=a("../equations/RotationalLockEquation");b.exports=d,d.prototype=new e,d.prototype.constructor=d;var j=h.create(),k=h.create(),l=h.create(),m=h.create(),n=h.create(),o=h.create();d.prototype.update=function(){var a=this.equations,b=a[0],c=this.upperLimit,d=this.lowerLimit,e=this.upperLimitEquation,f=this.lowerLimitEquation,g=this.bodyA,i=this.bodyB,p=this.localAxisA,q=this.localAnchorA,r=this.localAnchorB;b.updateJacobian(),h.rotate(j,p,g.angle),h.rotate(m,q,g.angle),h.add(k,m,g.position),h.rotate(n,r,i.angle),h.add(l,n,i.position);var s=this.position=h.dot(l,j)-h.dot(k,j);if(this.motorEnabled){var t=this.motorEquation.G;t[0]=j[0],t[1]=j[1],t[2]=h.crossLength(j,n),t[3]=-j[0],t[4]=-j[1],t[5]=-h.crossLength(j,m)}if(this.upperLimitEnabled&&s>c)h.scale(e.normalA,j,-1),h.sub(e.contactPointA,k,g.position),h.sub(e.contactPointB,l,i.position),h.scale(o,j,c),h.add(e.contactPointA,e.contactPointA,o),-1===a.indexOf(e)&&a.push(e);else{var u=a.indexOf(e);-1!==u&&a.splice(u,1)}if(this.lowerLimitEnabled&&d>s)h.scale(f.normalA,j,1),h.sub(f.contactPointA,k,g.position),h.sub(f.contactPointB,l,i.position),h.scale(o,j,d),h.sub(f.contactPointB,f.contactPointB,o),-1===a.indexOf(f)&&a.push(f);else{var u=a.indexOf(f);-1!==u&&a.splice(u,1)}},d.prototype.enableMotor=function(){this.motorEnabled||(this.equations.push(this.motorEquation),this.motorEnabled=!0)},d.prototype.disableMotor=function(){if(this.motorEnabled){var a=this.equations.indexOf(this.motorEquation);this.equations.splice(a,1),this.motorEnabled=!1}},d.prototype.setLimits=function(a,b){"number"==typeof a?(this.lowerLimit=a,this.lowerLimitEnabled=!0):(this.lowerLimit=a,this.lowerLimitEnabled=!1),"number"==typeof b?(this.upperLimit=b,this.upperLimitEnabled=!0):(this.upperLimit=b,this.upperLimitEnabled=!1)}},{"../equations/ContactEquation":21,"../equations/Equation":22,"../equations/RotationalLockEquation":24,"../math/vec2":30,"./Constraint":14}],19:[function(a,b,c){function d(a,b,c){c=c||{},e.call(this,a,b,e.REVOLUTE,c);var d=this.maxForce="undefined"!=typeof c.maxForce?c.maxForce:Number.MAX_VALUE;this.pivotA=i.create(),this.pivotB=i.create(),c.worldPivot?(i.sub(this.pivotA,c.worldPivot,a.position),i.sub(this.pivotB,c.worldPivot,b.position),i.rotate(this.pivotA,this.pivotA,-a.angle),i.rotate(this.pivotB,this.pivotB,-b.angle)):(i.copy(this.pivotA,c.localPivotA),i.copy(this.pivotB,c.localPivotB));var o=this.equations=[new f(a,b,-d,d),new f(a,b,-d,d)],p=o[0],q=o[1],r=this;p.computeGq=function(){return i.rotate(j,r.pivotA,a.angle),i.rotate(k,r.pivotB,b.angle),i.add(n,b.position,k),i.sub(n,n,a.position),i.sub(n,n,j),i.dot(n,l)},q.computeGq=function(){return i.rotate(j,r.pivotA,a.angle),i.rotate(k,r.pivotB,b.angle),i.add(n,b.position,k),i.sub(n,n,a.position),i.sub(n,n,j),i.dot(n,m)},q.minForce=p.minForce=-d,q.maxForce=p.maxForce=d,this.motorEquation=new g(a,b),this.motorEnabled=!1,this.angle=0,this.lowerLimitEnabled=!1,this.upperLimitEnabled=!1,this.lowerLimit=0,this.upperLimit=0,this.upperLimitEquation=new h(a,b),this.lowerLimitEquation=new h(a,b),this.upperLimitEquation.minForce=0,this.lowerLimitEquation.maxForce=0}var e=a("./Constraint"),f=a("../equations/Equation"),g=a("../equations/RotationalVelocityEquation"),h=a("../equations/RotationalLockEquation"),i=a("../math/vec2");b.exports=d;var j=i.create(),k=i.create(),l=i.fromValues(1,0),m=i.fromValues(0,1),n=i.create();d.prototype=new e,d.prototype.constructor=d,d.prototype.setLimits=function(a,b){"number"==typeof a?(this.lowerLimit=a,this.lowerLimitEnabled=!0):(this.lowerLimit=a,this.lowerLimitEnabled=!1),"number"==typeof b?(this.upperLimit=b,this.upperLimitEnabled=!0):(this.upperLimit=b,this.upperLimitEnabled=!1)},d.prototype.update=function(){var a=this.bodyA,b=this.bodyB,c=this.pivotA,d=this.pivotB,e=this.equations,f=(e[0],e[1],e[0]),g=e[1],h=this.upperLimit,n=this.lowerLimit,o=this.upperLimitEquation,p=this.lowerLimitEquation,q=this.angle=b.angle-a.angle;if(this.upperLimitEnabled&&q>h)o.angle=h,-1===e.indexOf(o)&&e.push(o);else{var r=e.indexOf(o);-1!==r&&e.splice(r,1)}if(this.lowerLimitEnabled&&n>q)p.angle=n,-1===e.indexOf(p)&&e.push(p);else{var r=e.indexOf(p);-1!==r&&e.splice(r,1)}i.rotate(j,c,a.angle),i.rotate(k,d,b.angle),f.G[0]=-1,f.G[1]=0,f.G[2]=-i.crossLength(j,l),f.G[3]=1,f.G[4]=0,f.G[5]=i.crossLength(k,l),g.G[0]=0,g.G[1]=-1,g.G[2]=-i.crossLength(j,m),g.G[3]=0,g.G[4]=1,g.G[5]=i.crossLength(k,m)},d.prototype.enableMotor=function(){this.motorEnabled||(this.equations.push(this.motorEquation),this.motorEnabled=!0)},d.prototype.disableMotor=function(){if(this.motorEnabled){var a=this.equations.indexOf(this.motorEquation);this.equations.splice(a,1),this.motorEnabled=!1}},d.prototype.motorIsEnabled=function(){return!!this.motorEnabled},d.prototype.setMotorSpeed=function(a){if(this.motorEnabled){var b=this.equations.indexOf(this.motorEquation);this.equations[b].relativeVelocity=a}},d.prototype.getMotorSpeed=function(){return this.motorEnabled?this.motorEquation.relativeVelocity:!1}},{"../equations/Equation":22,"../equations/RotationalLockEquation":24,"../equations/RotationalVelocityEquation":25,"../math/vec2":30,"./Constraint":14}],20:[function(a,b,c){function d(a,b,c){c=c||{},e.call(this,a,b,-Number.MAX_VALUE,Number.MAX_VALUE),this.angle=c.angle||0,this.ratio="number"==typeof c.ratio?c.ratio:1,this.setRatio(this.ratio)}var e=a("./Equation");a("../math/vec2");b.exports=d,d.prototype=new e,d.prototype.constructor=d,d.prototype.computeGq=function(){return this.ratio*this.bodyA.angle-this.bodyB.angle+this.angle},d.prototype.setRatio=function(a){var b=this.G;b[2]=a,b[5]=-1,this.ratio=a},d.prototype.setMaxTorque=function(a){this.maxForce=a,this.minForce=-a}},{"../math/vec2":30,"./Equation":22}],21:[function(a,b,c){function d(a,b){e.call(this,a,b,0,Number.MAX_VALUE),this.contactPointA=f.create(),this.penetrationVec=f.create(),this.contactPointB=f.create(),this.normalA=f.create(),this.restitution=0,this.firstImpact=!1,this.shapeA=null,this.shapeB=null}var e=a("./Equation"),f=a("../math/vec2");b.exports=d,d.prototype=new e,d.prototype.constructor=d,d.prototype.computeB=function(a,b,c){var d=this.bodyA,e=this.bodyB,g=this.contactPointA,h=this.contactPointB,i=d.position,j=e.position,k=this.penetrationVec,l=this.normalA,m=this.G,n=f.crossLength(g,l),o=f.crossLength(h,l);m[0]=-l[0],m[1]=-l[1],m[2]=-n,m[3]=l[0],m[4]=l[1],m[5]=o,f.add(k,j,h),f.sub(k,k,i),f.sub(k,k,g);var p,q;this.firstImpact&&0!==this.restitution?(q=0,p=1/b*(1+this.restitution)*this.computeGW()):(q=f.dot(l,k)+this.offset,p=this.computeGW());var r=this.computeGiMf(),s=-q*a-p*b-c*r;return s}},{"../math/vec2":30,"./Equation":22}],22:[function(a,b,c){function d(a,b,c,e){this.minForce="undefined"==typeof c?-Number.MAX_VALUE:c,this.maxForce="undefined"==typeof e?Number.MAX_VALUE:e,this.bodyA=a,this.bodyB=b,this.stiffness=d.DEFAULT_STIFFNESS,this.relaxation=d.DEFAULT_RELAXATION,this.G=new f.ARRAY_TYPE(6);for(var g=0;6>g;g++)this.G[g]=0;this.offset=0,this.a=0,this.b=0,this.epsilon=0,this.timeStep=1/60,this.needsUpdate=!0,this.multiplier=0,this.relativeVelocity=0,this.enabled=!0}b.exports=d;var e=a("../math/vec2"),f=a("../utils/Utils");a("../objects/Body");d.prototype.constructor=d,d.DEFAULT_STIFFNESS=1e6,d.DEFAULT_RELAXATION=4,d.prototype.update=function(){var a=this.stiffness,b=this.relaxation,c=this.timeStep;this.a=4/(c*(1+4*b)),this.b=4*b/(1+4*b),this.epsilon=4/(c*c*a*(1+4*b)),this.needsUpdate=!1},d.prototype.gmult=function(a,b,c,d,e){return a[0]*b[0]+a[1]*b[1]+a[2]*c+a[3]*d[0]+a[4]*d[1]+a[5]*e},d.prototype.computeB=function(a,b,c){var d=this.computeGW(),e=this.computeGq(),f=this.computeGiMf();return-e*a-d*b-f*c};var g=e.create(),h=e.create();d.prototype.computeGq=function(){var a=this.G,b=this.bodyA,c=this.bodyB,d=(b.position,c.position,b.angle),e=c.angle;return this.gmult(a,g,d,h,e)+this.offset},d.prototype.computeGW=function(){var a=this.G,b=this.bodyA,c=this.bodyB,d=b.velocity,e=c.velocity,f=b.angularVelocity,g=c.angularVelocity;return this.gmult(a,d,f,e,g)+this.relativeVelocity},d.prototype.computeGWlambda=function(){var a=this.G,b=this.bodyA,c=this.bodyB,d=b.vlambda,e=c.vlambda,f=b.wlambda,g=c.wlambda;return this.gmult(a,d,f,e,g)};var i=e.create(),j=e.create();d.prototype.computeGiMf=function(){var a=this.bodyA,b=this.bodyB,c=a.force,d=a.angularForce,f=b.force,g=b.angularForce,h=a.invMassSolve,k=b.invMassSolve,l=a.invInertiaSolve,m=b.invInertiaSolve,n=this.G;return e.scale(i,c,h),e.multiply(i,a.massMultiplier,i),e.scale(j,f,k),e.multiply(j,b.massMultiplier,j),this.gmult(n,i,d*l,j,g*m)},d.prototype.computeGiMGt=function(){var a=this.bodyA,b=this.bodyB,c=a.invMassSolve,d=b.invMassSolve,e=a.invInertiaSolve,f=b.invInertiaSolve,g=this.G;return g[0]*g[0]*c*a.massMultiplier[0]+g[1]*g[1]*c*a.massMultiplier[1]+g[2]*g[2]*e+g[3]*g[3]*d*b.massMultiplier[0]+g[4]*g[4]*d*b.massMultiplier[1]+g[5]*g[5]*f};var k=e.create(),l=e.create(),m=e.create();e.create(),e.create(),e.create();d.prototype.addToWlambda=function(a){var b=this.bodyA,c=this.bodyB,d=k,f=l,g=m,h=b.invMassSolve,i=c.invMassSolve,j=b.invInertiaSolve,n=c.invInertiaSolve,o=this.G;f[0]=o[0],f[1]=o[1],g[0]=o[3],g[1]=o[4],e.scale(d,f,h*a),e.multiply(d,d,b.massMultiplier),e.add(b.vlambda,b.vlambda,d),b.wlambda+=j*o[2]*a,e.scale(d,g,i*a),e.multiply(d,d,c.massMultiplier),e.add(c.vlambda,c.vlambda,d),c.wlambda+=n*o[5]*a},d.prototype.computeInvC=function(a){return 1/(this.computeGiMGt()+a)}},{"../math/vec2":30,"../objects/Body":31,"../utils/Utils":57}],23:[function(a,b,c){function d(a,b,c){f.call(this,a,b,-c,c),this.contactPointA=e.create(),this.contactPointB=e.create(),this.t=e.create(),this.contactEquations=[],this.shapeA=null,this.shapeB=null,this.frictionCoefficient=.3}var e=a("../math/vec2"),f=a("./Equation");a("../utils/Utils");b.exports=d,d.prototype=new f,d.prototype.constructor=d,d.prototype.setSlipForce=function(a){this.maxForce=a,this.minForce=-a},d.prototype.getSlipForce=function(){return this.maxForce},d.prototype.computeB=function(a,b,c){var d=(this.bodyA,this.bodyB,this.contactPointA),f=this.contactPointB,g=this.t,h=this.G;h[0]=-g[0],h[1]=-g[1],h[2]=-e.crossLength(d,g),h[3]=g[0],h[4]=g[1],h[5]=e.crossLength(f,g);var i=this.computeGW(),j=this.computeGiMf(),k=-i*b-c*j;return k}},{"../math/vec2":30,"../utils/Utils":57,"./Equation":22}],24:[function(a,b,c){function d(a,b,c){c=c||{},e.call(this,a,b,-Number.MAX_VALUE,Number.MAX_VALUE),this.angle=c.angle||0;var d=this.G;d[2]=1,d[5]=-1}var e=a("./Equation"),f=a("../math/vec2");b.exports=d,d.prototype=new e,d.prototype.constructor=d;var g=f.create(),h=f.create(),i=f.fromValues(1,0),j=f.fromValues(0,1);d.prototype.computeGq=function(){return f.rotate(g,i,this.bodyA.angle+this.angle),f.rotate(h,j,this.bodyB.angle),f.dot(g,h)}},{"../math/vec2":30,"./Equation":22}],25:[function(a,b,c){function d(a,b){e.call(this,a,b,-Number.MAX_VALUE,Number.MAX_VALUE),this.relativeVelocity=1,this.ratio=1}var e=a("./Equation");a("../math/vec2");b.exports=d,d.prototype=new e,d.prototype.constructor=d,d.prototype.computeB=function(a,b,c){var d=this.G;d[2]=-1,d[5]=this.ratio;var e=this.computeGiMf(),f=this.computeGW(),g=-f*b-c*e;return g}},{"../math/vec2":30,"./Equation":22}],26:[function(a,b,c){var d=function(){};b.exports=d,d.prototype={constructor:d,on:function(a,b,c){b.context=c||this,void 0===this._listeners&&(this._listeners={});var d=this._listeners;return void 0===d[a]&&(d[a]=[]),-1===d[a].indexOf(b)&&d[a].push(b),this},has:function(a,b){if(void 0===this._listeners)return!1;var c=this._listeners;if(b){if(void 0!==c[a]&&-1!==c[a].indexOf(b))return!0}else if(void 0!==c[a])return!0;return!1},off:function(a,b){if(void 0===this._listeners)return this;var c=this._listeners,d=c[a].indexOf(b);return-1!==d&&c[a].splice(d,1),this},emit:function(a){if(void 0===this._listeners)return this;var b=this._listeners,c=b[a.type];if(void 0!==c){a.target=this;for(var d=0,e=c.length;e>d;d++){var f=c[d];f.call(f.context,a)}}return this}}},{}],27:[function(a,b,c){function d(a,b,c){if(c=c||{},!(a instanceof e&&b instanceof e))throw new Error("First two arguments must be Material instances.");this.id=d.idCounter++,this.materialA=a,this.materialB=b,this.friction="undefined"!=typeof c.friction?Number(c.friction):.3,this.restitution="undefined"!=typeof c.restitution?Number(c.restitution):0,this.stiffness="undefined"!=typeof c.stiffness?Number(c.stiffness):f.DEFAULT_STIFFNESS,this.relaxation="undefined"!=typeof c.relaxation?Number(c.relaxation):f.DEFAULT_RELAXATION,this.frictionStiffness="undefined"!=typeof c.frictionStiffness?Number(c.frictionStiffness):f.DEFAULT_STIFFNESS,this.frictionRelaxation="undefined"!=typeof c.frictionRelaxation?Number(c.frictionRelaxation):f.DEFAULT_RELAXATION,this.surfaceVelocity="undefined"!=typeof c.surfaceVelocity?Number(c.surfaceVelocity):0,this.contactSkinSize=.005}var e=a("./Material"),f=a("../equations/Equation");b.exports=d,d.idCounter=0},{"../equations/Equation":22,"./Material":28}],28:[function(a,b,c){function d(a){this.id=a||d.idCounter++}b.exports=d,d.idCounter=0},{}],29:[function(a,b,c){var d={};d.GetArea=function(a){if(a.length<6)return 0;for(var b=a.length-2,c=0,d=0;b>d;d+=2)c+=(a[d+2]-a[d])*(a[d+1]+a[d+3]);return c+=(a[0]-a[b])*(a[b+1]+a[1]),.5*-c},d.Triangulate=function(a){var b=a.length>>1;if(3>b)return[];for(var c=[],e=[],f=0;b>f;f++)e.push(f);for(var f=0,g=b;g>3;){var h=e[(f+0)%g],i=e[(f+1)%g],j=e[(f+2)%g],k=a[2*h],l=a[2*h+1],m=a[2*i],n=a[2*i+1],o=a[2*j],p=a[2*j+1],q=!1;if(d._convex(k,l,m,n,o,p)){q=!0;for(var r=0;g>r;r++){var s=e[r];if(s!=h&&s!=i&&s!=j&&d._PointInTriangle(a[2*s],a[2*s+1],k,l,m,n,o,p)){q=!1;break}}}if(q)c.push(h,i,j),e.splice((f+1)%g,1),g--,f=0;else if(f++>3*g)break}return c.push(e[0],e[1],e[2]),c},d._PointInTriangle=function(a,b,c,d,e,f,g,h){var i=g-c,j=h-d,k=e-c,l=f-d,m=a-c,n=b-d,o=i*i+j*j,p=i*k+j*l,q=i*m+j*n,r=k*k+l*l,s=k*m+l*n,t=1/(o*r-p*p),u=(r*q-p*s)*t,v=(o*s-p*q)*t;return u>=0&&v>=0&&1>u+v},d._convex=function(a,b,c,d,e,f){return(b-d)*(e-c)+(c-a)*(f-d)>=0},b.exports=d},{}],30:[function(a,b,c){var d=b.exports={},e=a("../utils/Utils");d.crossLength=function(a,b){return a[0]*b[1]-a[1]*b[0]},d.crossVZ=function(a,b,c){return d.rotate(a,b,-Math.PI/2),d.scale(a,a,c),a},d.crossZV=function(a,b,c){return d.rotate(a,c,Math.PI/2),d.scale(a,a,b),a},d.rotate=function(a,b,c){if(0!==c){var d=Math.cos(c),e=Math.sin(c),f=b[0],g=b[1];a[0]=d*f-e*g,a[1]=e*f+d*g}else a[0]=b[0],a[1]=b[1]},d.rotate90cw=function(a,b){var c=b[0],d=b[1];a[0]=d,a[1]=-c},d.toLocalFrame=function(a,b,c,e){d.copy(a,b),d.sub(a,a,c),d.rotate(a,a,-e)},d.toGlobalFrame=function(a,b,c,e){d.copy(a,b),d.rotate(a,a,e),d.add(a,a,c)},d.vectorToLocalFrame=function(a,b,c){d.rotate(a,b,-c)},d.vectorToGlobalFrame=function(a,b,c){d.rotate(a,b,c)},d.centroid=function(a,b,c,e){return d.add(a,b,c),d.add(a,a,e),d.scale(a,a,1/3),a},d.create=function(){var a=new e.ARRAY_TYPE(2);return a[0]=0,a[1]=0,a},d.clone=function(a){var b=new e.ARRAY_TYPE(2);return b[0]=a[0],b[1]=a[1],b},d.fromValues=function(a,b){var c=new e.ARRAY_TYPE(2);return c[0]=a,c[1]=b,c},d.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a},d.set=function(a,b,c){return a[0]=b,a[1]=c,a},d.add=function(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a},d.subtract=function(a,b,c){return a[0]=b[0]-c[0],a[1]=b[1]-c[1],a},d.sub=d.subtract,d.multiply=function(a,b,c){return a[0]=b[0]*c[0],a[1]=b[1]*c[1],a},d.mul=d.multiply,d.divide=function(a,b,c){return a[0]=b[0]/c[0],a[1]=b[1]/c[1],a},d.div=d.divide,d.scale=function(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a},d.distance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1];return Math.sqrt(c*c+d*d)},d.dist=d.distance,d.squaredDistance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1];return c*c+d*d},d.sqrDist=d.squaredDistance,d.length=function(a){var b=a[0],c=a[1];return Math.sqrt(b*b+c*c)},d.len=d.length,d.squaredLength=function(a){var b=a[0],c=a[1];return b*b+c*c},d.sqrLen=d.squaredLength,d.negate=function(a,b){return a[0]=-b[0],a[1]=-b[1],a},d.normalize=function(a,b){var c=b[0],d=b[1],e=c*c+d*d;return e>0&&(e=1/Math.sqrt(e),a[0]=b[0]*e,a[1]=b[1]*e),a},d.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]},d.str=function(a){return"vec2("+a[0]+", "+a[1]+")"},d.lerp=function(a,b,c,d){var e=b[0],f=b[1];return a[0]=e+d*(c[0]-e),a[1]=f+d*(c[1]-f),a},d.reflect=function(a,b,c){var d=b[0]*c[0]+b[1]*c[1];a[0]=b[0]-2*c[0]*d,a[1]=b[1]-2*c[1]*d},d.getLineSegmentsIntersection=function(a,b,c,e,f){var g=d.getLineSegmentsIntersectionFraction(b,c,e,f);return 0>g?!1:(a[0]=b[0]+g*(c[0]-b[0]),a[1]=b[1]+g*(c[1]-b[1]),!0)},d.getLineSegmentsIntersectionFraction=function(a,b,c,d){var e,f,g=b[0]-a[0],h=b[1]-a[1],i=d[0]-c[0],j=d[1]-c[1];return e=(-h*(a[0]-c[0])+g*(a[1]-c[1]))/(-i*h+g*j),f=(i*(a[1]-c[1])-j*(a[0]-c[0]))/(-i*h+g*j),e>=0&&1>=e&&f>=0&&1>=f?f:-1}},{"../utils/Utils":57}],31:[function(a,b,c){function d(a){a=a||{},k.call(this),this.id=a.id||++d._idCounter,this.world=null,this.shapes=[],this.mass=a.mass||0,this.invMass=0,this.inertia=0,this.invInertia=0,this.invMassSolve=0,this.invInertiaSolve=0,this.fixedRotation=!!a.fixedRotation,this.fixedX=!!a.fixedX,this.fixedY=!!a.fixedY,this.massMultiplier=e.create(),this.position=e.fromValues(0,0),a.position&&e.copy(this.position,a.position),this.interpolatedPosition=e.fromValues(0,0),this.interpolatedAngle=0,this.previousPosition=e.fromValues(0,0),this.previousAngle=0,this.velocity=e.fromValues(0,0),a.velocity&&e.copy(this.velocity,a.velocity),this.vlambda=e.fromValues(0,0),this.wlambda=0,this.angle=a.angle||0,this.angularVelocity=a.angularVelocity||0,this.force=e.create(),a.force&&e.copy(this.force,a.force),this.angularForce=a.angularForce||0,this.damping="number"==typeof a.damping?a.damping:.1,this.angularDamping="number"==typeof a.angularDamping?a.angularDamping:.1,this.type=d.STATIC,"undefined"!=typeof a.type?this.type=a.type:a.mass?this.type=d.DYNAMIC:this.type=d.STATIC,this.boundingRadius=0,this.aabb=new j,this.aabbNeedsUpdate=!0, +this.allowSleep=void 0!==a.allowSleep?a.allowSleep:!0,this.wantsToSleep=!1,this.sleepState=d.AWAKE,this.sleepSpeedLimit=void 0!==a.sleepSpeedLimit?a.sleepSpeedLimit:.2,this.sleepTimeLimit=void 0!==a.sleepTimeLimit?a.sleepTimeLimit:1,this.gravityScale=void 0!==a.gravityScale?a.gravityScale:1,this.collisionResponse=void 0!==a.collisionResponse?a.collisionResponse:!0,this.idleTime=0,this.timeLastSleepy=0,this.ccdSpeedThreshold=void 0!==a.ccdSpeedThreshold?a.ccdSpeedThreshold:-1,this.ccdIterations=void 0!==a.ccdIterations?a.ccdIterations:10,this.concavePath=null,this._wakeUpAfterNarrowphase=!1,this.updateMassProperties()}var e=a("../math/vec2"),f=a("poly-decomp"),g=a("../shapes/Convex"),h=a("../collision/RaycastResult"),i=a("../collision/Ray"),j=a("../collision/AABB"),k=a("../events/EventEmitter");b.exports=d,d.prototype=new k,d.prototype.constructor=d,d._idCounter=0,d.prototype.updateSolveMassProperties=function(){this.sleepState===d.SLEEPING||this.type===d.KINEMATIC?(this.invMassSolve=0,this.invInertiaSolve=0):(this.invMassSolve=this.invMass,this.invInertiaSolve=this.invInertia)},d.prototype.setDensity=function(a){var b=this.getArea();this.mass=b*a,this.updateMassProperties()},d.prototype.getArea=function(){for(var a=0,b=0;b<this.shapes.length;b++)a+=this.shapes[b].area;return a},d.prototype.getAABB=function(){return this.aabbNeedsUpdate&&this.updateAABB(),this.aabb};var l=new j,m=e.create();d.prototype.updateAABB=function(){for(var a=this.shapes,b=a.length,c=m,d=this.angle,f=0;f!==b;f++){var g=a[f],h=g.angle+d;e.rotate(c,g.position,d),e.add(c,c,this.position),g.computeAABB(l,c,h),0===f?this.aabb.copy(l):this.aabb.extend(l)}this.aabbNeedsUpdate=!1},d.prototype.updateBoundingRadius=function(){for(var a=this.shapes,b=a.length,c=0,d=0;d!==b;d++){var f=a[d],g=e.length(f.position),h=f.boundingRadius;g+h>c&&(c=g+h)}this.boundingRadius=c},d.prototype.addShape=function(a,b,c){if(a.body)throw new Error("A shape can only be added to one body.");a.body=this,b?e.copy(a.position,b):e.set(a.position,0,0),a.angle=c||0,this.shapes.push(a),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0},d.prototype.removeShape=function(a){var b=this.shapes.indexOf(a);return-1!==b?(this.shapes.splice(b,1),this.aabbNeedsUpdate=!0,a.body=null,!0):!1},d.prototype.updateMassProperties=function(){if(this.type===d.STATIC||this.type===d.KINEMATIC)this.mass=Number.MAX_VALUE,this.invMass=0,this.inertia=Number.MAX_VALUE,this.invInertia=0;else{var a=this.shapes,b=a.length,c=this.mass/b,f=0;if(this.fixedRotation)this.inertia=Number.MAX_VALUE,this.invInertia=0;else{for(var g=0;b>g;g++){var h=a[g],i=e.squaredLength(h.position),j=h.computeMomentOfInertia(c);f+=j+c*i}this.inertia=f,this.invInertia=f>0?1/f:0}this.invMass=1/this.mass,e.set(this.massMultiplier,this.fixedX?0:1,this.fixedY?0:1)}};e.create();d.prototype.applyForce=function(a,b){if(e.add(this.force,this.force,a),b){var c=e.crossLength(b,a);this.angularForce+=c}};var n=e.create(),o=e.create(),p=e.create();d.prototype.applyForceLocal=function(a,b){b=b||p;var c=n,d=o;this.vectorToWorldFrame(c,a),this.vectorToWorldFrame(d,b),this.applyForce(c,d)};var q=e.create();d.prototype.applyImpulse=function(a,b){if(this.type===d.DYNAMIC){var c=q;if(e.scale(c,a,this.invMass),e.multiply(c,this.massMultiplier,c),e.add(this.velocity,c,this.velocity),b){var f=e.crossLength(b,a);f*=this.invInertia,this.angularVelocity+=f}}};var r=e.create(),s=e.create(),t=e.create();d.prototype.applyImpulseLocal=function(a,b){b=b||t;var c=r,d=s;this.vectorToWorldFrame(c,a),this.vectorToWorldFrame(d,b),this.applyImpulse(c,d)},d.prototype.toLocalFrame=function(a,b){e.toLocalFrame(a,b,this.position,this.angle)},d.prototype.toWorldFrame=function(a,b){e.toGlobalFrame(a,b,this.position,this.angle)},d.prototype.vectorToLocalFrame=function(a,b){e.vectorToLocalFrame(a,b,this.angle)},d.prototype.vectorToWorldFrame=function(a,b){e.vectorToGlobalFrame(a,b,this.angle)},d.prototype.fromPolygon=function(a,b){b=b||{};for(var c=this.shapes.length;c>=0;--c)this.removeShape(this.shapes[c]);var d=new f.Polygon;if(d.vertices=a,d.makeCCW(),"number"==typeof b.removeCollinearPoints&&d.removeCollinearPoints(b.removeCollinearPoints),"undefined"==typeof b.skipSimpleCheck&&!d.isSimple())return!1;this.concavePath=d.vertices.slice(0);for(var c=0;c<this.concavePath.length;c++){var h=[0,0];e.copy(h,this.concavePath[c]),this.concavePath[c]=h}var i;i=b.optimalDecomp?d.decomp():d.quickDecomp();for(var j=e.create(),c=0;c!==i.length;c++){for(var k=new g({vertices:i[c].vertices}),l=0;l!==k.vertices.length;l++){var h=k.vertices[l];e.sub(h,h,k.centerOfMass)}e.scale(j,k.centerOfMass,1),k.updateTriangles(),k.updateCenterOfMass(),k.updateBoundingRadius(),this.addShape(k,j)}return this.adjustCenterOfMass(),this.aabbNeedsUpdate=!0,!0};var u=(e.fromValues(0,0),e.fromValues(0,0)),v=e.fromValues(0,0),w=e.fromValues(0,0);d.prototype.adjustCenterOfMass=function(){var a=u,b=v,c=w,d=0;e.set(b,0,0);for(var f=0;f!==this.shapes.length;f++){var g=this.shapes[f];e.scale(a,g.position,g.area),e.add(b,b,a),d+=g.area}e.scale(c,b,1/d);for(var f=0;f!==this.shapes.length;f++){var g=this.shapes[f];e.sub(g.position,g.position,c)}e.add(this.position,this.position,c);for(var f=0;this.concavePath&&f<this.concavePath.length;f++)e.sub(this.concavePath[f],this.concavePath[f],c);this.updateMassProperties(),this.updateBoundingRadius()},d.prototype.setZeroForce=function(){e.set(this.force,0,0),this.angularForce=0},d.prototype.resetConstraintVelocity=function(){var a=this,b=a.vlambda;e.set(b,0,0),a.wlambda=0},d.prototype.addConstraintVelocity=function(){var a=this,b=a.velocity;e.add(b,b,a.vlambda),a.angularVelocity+=a.wlambda},d.prototype.applyDamping=function(a){if(this.type===d.DYNAMIC){var b=this.velocity;e.scale(b,b,Math.pow(1-this.damping,a)),this.angularVelocity*=Math.pow(1-this.angularDamping,a)}},d.prototype.wakeUp=function(){var a=this.sleepState;this.sleepState=d.AWAKE,this.idleTime=0,a!==d.AWAKE&&this.emit(d.wakeUpEvent)},d.prototype.sleep=function(){this.sleepState=d.SLEEPING,this.angularVelocity=0,this.angularForce=0,e.set(this.velocity,0,0),e.set(this.force,0,0),this.emit(d.sleepEvent)},d.prototype.sleepTick=function(a,b,c){if(this.allowSleep&&this.type!==d.SLEEPING){this.wantsToSleep=!1;var f=(this.sleepState,e.squaredLength(this.velocity)+Math.pow(this.angularVelocity,2)),g=Math.pow(this.sleepSpeedLimit,2);f>=g?(this.idleTime=0,this.sleepState=d.AWAKE):(this.idleTime+=c,this.sleepState=d.SLEEPY),this.idleTime>this.sleepTimeLimit&&(b?this.wantsToSleep=!0:this.sleep())}},d.prototype.overlaps=function(a){return this.world.overlapKeeper.bodiesAreOverlapping(this,a)};var x=e.create(),y=e.create();d.prototype.integrate=function(a){var b=this.invMass,c=this.force,d=this.position,f=this.velocity;e.copy(this.previousPosition,this.position),this.previousAngle=this.angle,this.fixedRotation||(this.angularVelocity+=this.angularForce*this.invInertia*a),e.scale(x,c,a*b),e.multiply(x,this.massMultiplier,x),e.add(f,x,f),this.integrateToTimeOfImpact(a)||(e.scale(y,f,a),e.add(d,d,y),this.fixedRotation||(this.angle+=this.angularVelocity*a)),this.aabbNeedsUpdate=!0};var z=new h,A=new i({mode:i.ALL}),B=e.create(),C=e.create(),D=e.create(),E=e.create();d.prototype.integrateToTimeOfImpact=function(a){if(this.ccdSpeedThreshold<0||e.squaredLength(this.velocity)<Math.pow(this.ccdSpeedThreshold,2))return!1;e.normalize(B,this.velocity),e.scale(C,this.velocity,a),e.add(C,C,this.position),e.sub(D,C,this.position);var b,c=this.angularVelocity*a,d=e.length(D),f=1,g=this;if(z.reset(),A.callback=function(a){a.body!==g&&(b=a.body,a.getHitPoint(C,A),e.sub(D,C,g.position),f=e.length(D)/d,a.stop())},e.copy(A.from,this.position),e.copy(A.to,C),A.update(),this.world.raycast(z,A),!b)return!1;var h=this.angle;e.copy(E,this.position);for(var i=0,j=0,k=0,l=f;l>=j&&i<this.ccdIterations;){i++,k=(l-j)/2,e.scale(y,D,f),e.add(this.position,E,y),this.angle=h+c*f,this.updateAABB();var m=this.aabb.overlaps(b.aabb)&&this.world.narrowphase.bodiesOverlap(this,b);m?j=k:l=k}return f=k,e.copy(this.position,E),this.angle=h,e.scale(y,D,f),e.add(this.position,this.position,y),this.fixedRotation||(this.angle+=c*f),!0},d.prototype.getVelocityAtPoint=function(a,b){return e.crossVZ(a,b,this.angularVelocity),e.subtract(a,this.velocity,a),a},d.sleepyEvent={type:"sleepy"},d.sleepEvent={type:"sleep"},d.wakeUpEvent={type:"wakeup"},d.DYNAMIC=1,d.STATIC=2,d.KINEMATIC=4,d.AWAKE=0,d.SLEEPY=1,d.SLEEPING=2},{"../collision/AABB":7,"../collision/Ray":11,"../collision/RaycastResult":12,"../events/EventEmitter":26,"../math/vec2":30,"../shapes/Convex":40,"poly-decomp":5}],32:[function(a,b,c){function d(a,b,c){c=c||{},f.call(this,a,b,c),this.localAnchorA=e.fromValues(0,0),this.localAnchorB=e.fromValues(0,0),c.localAnchorA&&e.copy(this.localAnchorA,c.localAnchorA),c.localAnchorB&&e.copy(this.localAnchorB,c.localAnchorB),c.worldAnchorA&&this.setWorldAnchorA(c.worldAnchorA),c.worldAnchorB&&this.setWorldAnchorB(c.worldAnchorB);var d=e.create(),g=e.create();this.getWorldAnchorA(d),this.getWorldAnchorB(g);var h=e.distance(d,g);this.restLength="number"==typeof c.restLength?c.restLength:h}var e=a("../math/vec2"),f=a("./Spring");a("../utils/Utils");b.exports=d,d.prototype=new f,d.prototype.constructor=d,d.prototype.setWorldAnchorA=function(a){this.bodyA.toLocalFrame(this.localAnchorA,a)},d.prototype.setWorldAnchorB=function(a){this.bodyB.toLocalFrame(this.localAnchorB,a)},d.prototype.getWorldAnchorA=function(a){this.bodyA.toWorldFrame(a,this.localAnchorA)},d.prototype.getWorldAnchorB=function(a){this.bodyB.toWorldFrame(a,this.localAnchorB)};var g=e.create(),h=e.create(),i=e.create(),j=e.create(),k=e.create(),l=e.create(),m=e.create(),n=e.create(),o=e.create();d.prototype.applyForce=function(){var a=this.stiffness,b=this.damping,c=this.restLength,d=this.bodyA,f=this.bodyB,p=g,q=h,r=i,s=j,t=o,u=k,v=l,w=m,x=n;this.getWorldAnchorA(u),this.getWorldAnchorB(v),e.sub(w,u,d.position),e.sub(x,v,f.position),e.sub(p,v,u);var y=e.len(p);e.normalize(q,p),e.sub(r,f.velocity,d.velocity),e.crossZV(t,f.angularVelocity,x),e.add(r,r,t),e.crossZV(t,d.angularVelocity,w),e.sub(r,r,t),e.scale(s,q,-a*(y-c)-b*e.dot(r,q)),e.sub(d.force,d.force,s),e.add(f.force,f.force,s);var z=e.crossLength(w,s),A=e.crossLength(x,s);d.angularForce-=z,f.angularForce+=A}},{"../math/vec2":30,"../utils/Utils":57,"./Spring":34}],33:[function(a,b,c){function d(a,b,c){c=c||{},e.call(this,a,b,c),this.restAngle="number"==typeof c.restAngle?c.restAngle:b.angle-a.angle}var e=(a("../math/vec2"),a("./Spring"));b.exports=d,d.prototype=new e,d.prototype.constructor=d,d.prototype.applyForce=function(){var a=this.stiffness,b=this.damping,c=this.restAngle,d=this.bodyA,e=this.bodyB,f=e.angle-d.angle,g=e.angularVelocity-d.angularVelocity,h=-a*(f-c)-b*g*0;d.angularForce-=h,e.angularForce+=h}},{"../math/vec2":30,"./Spring":34}],34:[function(a,b,c){function d(a,b,c){c=e.defaults(c,{stiffness:100,damping:1}),this.stiffness=c.stiffness,this.damping=c.damping,this.bodyA=a,this.bodyB=b}var e=(a("../math/vec2"),a("../utils/Utils"));b.exports=d,d.prototype.applyForce=function(){}},{"../math/vec2":30,"../utils/Utils":57}],35:[function(a,b,c){function d(a,b){b=b||{},this.chassisBody=a,this.wheels=[],this.groundBody=new i({mass:0}),this.world=null;var c=this;this.preStepCallback=function(){c.update()}}function e(a,b){b=b||{},this.vehicle=a,this.forwardEquation=new h(a.chassisBody,a.groundBody),this.sideEquation=new h(a.chassisBody,a.groundBody),this.steerValue=0,this.engineForce=0,this.setSideFriction(void 0!==b.sideFriction?b.sideFriction:5),this.localForwardVector=f.fromValues(0,1),b.localForwardVector&&f.copy(this.localForwardVector,b.localForwardVector),this.localPosition=f.fromValues(0,0),b.localPosition&&f.copy(this.localPosition,b.localPosition),g.apply(this,a.chassisBody,a.groundBody),this.equations.push(this.forwardEquation,this.sideEquation),this.setBrakeForce(0)}var f=a("../math/vec2"),g=(a("../utils/Utils"),a("../constraints/Constraint")),h=a("../equations/FrictionEquation"),i=a("../objects/Body");b.exports=d,d.prototype.addToWorld=function(a){this.world=a,a.addBody(this.groundBody),a.on("preStep",this.preStepCallback);for(var b=0;b<this.wheels.length;b++){var c=this.wheels[b];a.addConstraint(c)}},d.prototype.removeFromWorld=function(){var a=this.world;a.removeBody(this.groundBody),a.off("preStep",this.preStepCallback);for(var b=0;b<this.wheels.length;b++){var c=this.wheels[b];a.removeConstraint(c)}this.world=null},d.prototype.addWheel=function(a){var b=new e(this,a);return this.wheels.push(b),b},d.prototype.update=function(){for(var a=0;a<this.wheels.length;a++)this.wheels[a].update()},e.prototype=new g,e.prototype.setBrakeForce=function(a){this.forwardEquation.setSlipForce(a)},e.prototype.setSideFriction=function(a){this.sideEquation.setSlipForce(a)};var j=f.create(),k=f.create();e.prototype.getSpeed=function(){return this.vehicle.chassisBody.vectorToWorldFrame(k,this.localForwardVector),this.vehicle.chassisBody.getVelocityAtPoint(j,k),f.dot(j,k)};var l=f.create();e.prototype.update=function(){this.vehicle.chassisBody.vectorToWorldFrame(this.forwardEquation.t,this.localForwardVector),f.rotate(this.sideEquation.t,this.localForwardVector,Math.PI/2),this.vehicle.chassisBody.vectorToWorldFrame(this.sideEquation.t,this.sideEquation.t),f.rotate(this.forwardEquation.t,this.forwardEquation.t,this.steerValue),f.rotate(this.sideEquation.t,this.sideEquation.t,this.steerValue),this.vehicle.chassisBody.toWorldFrame(this.forwardEquation.contactPointB,this.localPosition),f.copy(this.sideEquation.contactPointB,this.forwardEquation.contactPointB),this.vehicle.chassisBody.vectorToWorldFrame(this.forwardEquation.contactPointA,this.localPosition),f.copy(this.sideEquation.contactPointA,this.forwardEquation.contactPointA),f.normalize(l,this.forwardEquation.t),f.scale(l,l,this.engineForce),this.vehicle.chassisBody.applyForce(l,this.forwardEquation.contactPointA)}},{"../constraints/Constraint":14,"../equations/FrictionEquation":23,"../math/vec2":30,"../objects/Body":31,"../utils/Utils":57}],36:[function(a,b,c){var d=b.exports={AABB:a("./collision/AABB"),AngleLockEquation:a("./equations/AngleLockEquation"),Body:a("./objects/Body"),Broadphase:a("./collision/Broadphase"),Capsule:a("./shapes/Capsule"),Circle:a("./shapes/Circle"),Constraint:a("./constraints/Constraint"),ContactEquation:a("./equations/ContactEquation"),ContactEquationPool:a("./utils/ContactEquationPool"),ContactMaterial:a("./material/ContactMaterial"),Convex:a("./shapes/Convex"),DistanceConstraint:a("./constraints/DistanceConstraint"),Equation:a("./equations/Equation"),EventEmitter:a("./events/EventEmitter"),FrictionEquation:a("./equations/FrictionEquation"),FrictionEquationPool:a("./utils/FrictionEquationPool"),GearConstraint:a("./constraints/GearConstraint"),GSSolver:a("./solver/GSSolver"),Heightfield:a("./shapes/Heightfield"),Line:a("./shapes/Line"),LockConstraint:a("./constraints/LockConstraint"),Material:a("./material/Material"),Narrowphase:a("./collision/Narrowphase"),NaiveBroadphase:a("./collision/NaiveBroadphase"),Particle:a("./shapes/Particle"),Plane:a("./shapes/Plane"),Pool:a("./utils/Pool"),RevoluteConstraint:a("./constraints/RevoluteConstraint"),PrismaticConstraint:a("./constraints/PrismaticConstraint"),Ray:a("./collision/Ray"),RaycastResult:a("./collision/RaycastResult"),Box:a("./shapes/Box"),RotationalVelocityEquation:a("./equations/RotationalVelocityEquation"),SAPBroadphase:a("./collision/SAPBroadphase"),Shape:a("./shapes/Shape"),Solver:a("./solver/Solver"),Spring:a("./objects/Spring"),TopDownVehicle:a("./objects/TopDownVehicle"),LinearSpring:a("./objects/LinearSpring"),RotationalSpring:a("./objects/RotationalSpring"),Utils:a("./utils/Utils"),World:a("./world/World"),vec2:a("./math/vec2"),version:a("../package.json").version};Object.defineProperty(d,"Rectangle",{get:function(){return console.warn("The Rectangle class has been renamed to Box."),this.Box}})},{"../package.json":6,"./collision/AABB":7,"./collision/Broadphase":8,"./collision/NaiveBroadphase":9,"./collision/Narrowphase":10,"./collision/Ray":11,"./collision/RaycastResult":12,"./collision/SAPBroadphase":13,"./constraints/Constraint":14,"./constraints/DistanceConstraint":15,"./constraints/GearConstraint":16,"./constraints/LockConstraint":17,"./constraints/PrismaticConstraint":18,"./constraints/RevoluteConstraint":19,"./equations/AngleLockEquation":20,"./equations/ContactEquation":21,"./equations/Equation":22,"./equations/FrictionEquation":23,"./equations/RotationalVelocityEquation":25,"./events/EventEmitter":26,"./material/ContactMaterial":27,"./material/Material":28,"./math/vec2":30,"./objects/Body":31,"./objects/LinearSpring":32,"./objects/RotationalSpring":33,"./objects/Spring":34,"./objects/TopDownVehicle":35,"./shapes/Box":37,"./shapes/Capsule":38,"./shapes/Circle":39,"./shapes/Convex":40,"./shapes/Heightfield":41,"./shapes/Line":42,"./shapes/Particle":43,"./shapes/Plane":44,"./shapes/Shape":45,"./solver/GSSolver":46,"./solver/Solver":47,"./utils/ContactEquationPool":48,"./utils/FrictionEquationPool":49,"./utils/Pool":55,"./utils/Utils":57,"./world/World":61}],37:[function(a,b,c){function d(a){"number"==typeof arguments[0]&&"number"==typeof arguments[1]&&(a={width:arguments[0],height:arguments[1]},console.warn("The Rectangle has been renamed to Box and its constructor signature has changed. Please use the following format: new Box({ width: 1, height: 1, ... })")),a=a||{};var b=this.width=a.width||1,c=this.height=a.height||1,d=[e.fromValues(-b/2,-c/2),e.fromValues(b/2,-c/2),e.fromValues(b/2,c/2),e.fromValues(-b/2,c/2)],h=[e.fromValues(1,0),e.fromValues(0,1)];a.vertices=d,a.axes=h,a.type=f.BOX,g.call(this,a)}var e=a("../math/vec2"),f=a("./Shape"),g=a("./Convex");b.exports=d,d.prototype=new g,d.prototype.constructor=d,d.prototype.computeMomentOfInertia=function(a){var b=this.width,c=this.height;return a*(c*c+b*b)/12},d.prototype.updateBoundingRadius=function(){var a=this.width,b=this.height;this.boundingRadius=Math.sqrt(a*a+b*b)/2};e.create(),e.create(),e.create(),e.create();d.prototype.computeAABB=function(a,b,c){a.setFromPoints(this.vertices,b,c,0)},d.prototype.updateArea=function(){this.area=this.width*this.height}},{"../math/vec2":30,"./Convex":40,"./Shape":45}],38:[function(a,b,c){function d(a){"number"==typeof arguments[0]&&"number"==typeof arguments[1]&&(a={length:arguments[0],radius:arguments[1]},console.warn("The Capsule constructor signature has changed. Please use the following format: new Capsule({ radius: 1, length: 1 })")),a=a||{},this.length=a.length||1,this.radius=a.radius||1,a.type=e.CAPSULE,e.call(this,a)}var e=a("./Shape"),f=a("../math/vec2");b.exports=d,d.prototype=new e,d.prototype.constructor=d,d.prototype.computeMomentOfInertia=function(a){var b=this.radius,c=this.length+b,d=2*b;return a*(d*d+c*c)/12},d.prototype.updateBoundingRadius=function(){this.boundingRadius=this.radius+this.length/2},d.prototype.updateArea=function(){this.area=Math.PI*this.radius*this.radius+2*this.radius*this.length};var g=f.create();d.prototype.computeAABB=function(a,b,c){var d=this.radius;f.set(g,this.length/2,0),0!==c&&f.rotate(g,g,c),f.set(a.upperBound,Math.max(g[0]+d,-g[0]+d),Math.max(g[1]+d,-g[1]+d)),f.set(a.lowerBound,Math.min(g[0]-d,-g[0]-d),Math.min(g[1]-d,-g[1]-d)),f.add(a.lowerBound,a.lowerBound,b),f.add(a.upperBound,a.upperBound,b)};var h=f.create(),i=f.create(),j=f.create(),k=f.create(),l=f.fromValues(0,1);d.prototype.raycast=function(a,b,c,d){for(var e=b.from,g=b.to,m=(b.direction,h),n=i,o=j,p=k,q=this.length/2,r=0;2>r;r++){var s=this.radius*(2*r-1);f.set(o,-q,s),f.set(p,q,s),f.toGlobalFrame(o,o,c,d),f.toGlobalFrame(p,p,c,d);var t=f.getLineSegmentsIntersectionFraction(e,g,o,p);if(t>=0&&(f.rotate(n,l,d),f.scale(n,n,2*r-1),b.reportIntersection(a,t,n,-1),a.shouldStop(b)))return}for(var u=Math.pow(this.radius,2)+Math.pow(q,2),r=0;2>r;r++){f.set(o,q*(2*r-1),0),f.toGlobalFrame(o,o,c,d);var v=Math.pow(g[0]-e[0],2)+Math.pow(g[1]-e[1],2),w=2*((g[0]-e[0])*(e[0]-o[0])+(g[1]-e[1])*(e[1]-o[1])),x=Math.pow(e[0]-o[0],2)+Math.pow(e[1]-o[1],2)-Math.pow(this.radius,2),t=Math.pow(w,2)-4*v*x;if(!(0>t))if(0===t){if(f.lerp(m,e,g,t),f.squaredDistance(m,c)>u&&(f.sub(n,m,o),f.normalize(n,n),b.reportIntersection(a,t,n,-1),a.shouldStop(b)))return}else{var y=Math.sqrt(t),z=1/(2*v),A=(-w-y)*z,B=(-w+y)*z;if(A>=0&&1>=A&&(f.lerp(m,e,g,A),f.squaredDistance(m,c)>u&&(f.sub(n,m,o),f.normalize(n,n),b.reportIntersection(a,A,n,-1),a.shouldStop(b))))return;if(B>=0&&1>=B&&(f.lerp(m,e,g,B),f.squaredDistance(m,c)>u&&(f.sub(n,m,o),f.normalize(n,n),b.reportIntersection(a,B,n,-1),a.shouldStop(b))))return}}}},{"../math/vec2":30,"./Shape":45}],39:[function(a,b,c){function d(a){"number"==typeof arguments[0]&&(a={radius:arguments[0]},console.warn("The Circle constructor signature has changed. Please use the following format: new Circle({ radius: 1 })")),a=a||{},this.radius=a.radius||1,a.type=e.CIRCLE,e.call(this,a)}var e=a("./Shape"),f=a("../math/vec2");b.exports=d,d.prototype=new e,d.prototype.constructor=d,d.prototype.computeMomentOfInertia=function(a){var b=this.radius;return a*b*b/2},d.prototype.updateBoundingRadius=function(){this.boundingRadius=this.radius},d.prototype.updateArea=function(){this.area=Math.PI*this.radius*this.radius},d.prototype.computeAABB=function(a,b,c){var d=this.radius;f.set(a.upperBound,d,d),f.set(a.lowerBound,-d,-d),b&&(f.add(a.lowerBound,a.lowerBound,b),f.add(a.upperBound,a.upperBound,b))};var g=f.create(),h=f.create();d.prototype.raycast=function(a,b,c,d){var e=b.from,i=b.to,j=this.radius,k=Math.pow(i[0]-e[0],2)+Math.pow(i[1]-e[1],2),l=2*((i[0]-e[0])*(e[0]-c[0])+(i[1]-e[1])*(e[1]-c[1])),m=Math.pow(e[0]-c[0],2)+Math.pow(e[1]-c[1],2)-Math.pow(j,2),n=Math.pow(l,2)-4*k*m,o=g,p=h;if(!(0>n))if(0===n)f.lerp(o,e,i,n),f.sub(p,o,c),f.normalize(p,p),b.reportIntersection(a,n,p,-1);else{var q=Math.sqrt(n),r=1/(2*k),s=(-l-q)*r,t=(-l+q)*r;if(s>=0&&1>=s&&(f.lerp(o,e,i,s),f.sub(p,o,c),f.normalize(p,p),b.reportIntersection(a,s,p,-1),a.shouldStop(b)))return;t>=0&&1>=t&&(f.lerp(o,e,i,t),f.sub(p,o,c),f.normalize(p,p),b.reportIntersection(a,t,p,-1))}}},{"../math/vec2":30,"./Shape":45}],40:[function(a,b,c){function d(a){Array.isArray(arguments[0])&&(a={vertices:arguments[0],axes:arguments[1]},console.warn("The Convex constructor signature has changed. Please use the following format: new Convex({ vertices: [...], ... })")),a=a||{},this.vertices=[];for(var b=void 0!==a.vertices?a.vertices:[],c=0;c<b.length;c++){var d=f.create();f.copy(d,b[c]),this.vertices.push(d)}if(this.axes=[],a.axes)for(var c=0;c<a.axes.length;c++){var g=f.create();f.copy(g,a.axes[c]),this.axes.push(g)}else for(var c=0;c<this.vertices.length;c++){var h=this.vertices[c],i=this.vertices[(c+1)%this.vertices.length],j=f.create();f.sub(j,i,h),f.rotate90cw(j,j),f.normalize(j,j),this.axes.push(j)}if(this.centerOfMass=f.fromValues(0,0),this.triangles=[],this.vertices.length&&(this.updateTriangles(),this.updateCenterOfMass()),this.boundingRadius=0,a.type=e.CONVEX,e.call(this,a),this.updateBoundingRadius(),this.updateArea(),this.area<0)throw new Error("Convex vertices must be given in conter-clockwise winding.")}var e=a("./Shape"),f=a("../math/vec2"),g=a("../math/polyk");a("poly-decomp");b.exports=d,d.prototype=new e,d.prototype.constructor=d;var h=f.create(),i=f.create();d.prototype.projectOntoLocalAxis=function(a,b){for(var c,d,e=null,g=null,a=h,i=0;i<this.vertices.length;i++)c=this.vertices[i],d=f.dot(c,a),(null===e||d>e)&&(e=d),(null===g||g>d)&&(g=d);if(g>e){var j=g;g=e,e=j}f.set(b,g,e)},d.prototype.projectOntoWorldAxis=function(a,b,c,d){var e=i;this.projectOntoLocalAxis(a,d),0!==c?f.rotate(e,a,c):e=a;var g=f.dot(b,e);f.set(d,d[0]+g,d[1]+g)},d.prototype.updateTriangles=function(){this.triangles.length=0;for(var a=[],b=0;b<this.vertices.length;b++){var c=this.vertices[b];a.push(c[0],c[1])}for(var d=g.Triangulate(a),b=0;b<d.length;b+=3){var e=d[b],f=d[b+1],h=d[b+2];this.triangles.push([e,f,h])}};var j=f.create(),k=f.create(),l=f.create(),m=f.create(),n=f.create();f.create(),f.create(),f.create(),f.create();d.prototype.updateCenterOfMass=function(){var a=this.triangles,b=this.vertices,c=this.centerOfMass,e=j,g=l,h=m,i=n,o=k;f.set(c,0,0);for(var p=0,q=0;q!==a.length;q++){var r=a[q],g=b[r[0]],h=b[r[1]],i=b[r[2]];f.centroid(e,g,h,i);var s=d.triangleArea(g,h,i);p+=s,f.scale(o,e,s),f.add(c,c,o)}f.scale(c,c,1/p)},d.prototype.computeMomentOfInertia=function(a){for(var b=0,c=0,d=this.vertices.length,e=d-1,g=0;d>g;e=g,g++){var h=this.vertices[e],i=this.vertices[g],j=Math.abs(f.crossLength(h,i)),k=f.dot(i,i)+f.dot(i,h)+f.dot(h,h);b+=j*k,c+=j}return a/6*(b/c)},d.prototype.updateBoundingRadius=function(){for(var a=this.vertices,b=0,c=0;c!==a.length;c++){var d=f.squaredLength(a[c]);d>b&&(b=d)}this.boundingRadius=Math.sqrt(b)},d.triangleArea=function(a,b,c){return.5*((b[0]-a[0])*(c[1]-a[1])-(c[0]-a[0])*(b[1]-a[1]))},d.prototype.updateArea=function(){this.updateTriangles(),this.area=0;for(var a=this.triangles,b=this.vertices,c=0;c!==a.length;c++){var e=a[c],f=b[e[0]],g=b[e[1]],h=b[e[2]],i=d.triangleArea(f,g,h);this.area+=i}},d.prototype.computeAABB=function(a,b,c){a.setFromPoints(this.vertices,b,c,0)};var o=f.create(),p=f.create(),q=f.create();d.prototype.raycast=function(a,b,c,d){var e=o,g=p,h=q,i=this.vertices;f.toLocalFrame(e,b.from,c,d),f.toLocalFrame(g,b.to,c,d);for(var j=i.length,k=0;j>k&&!a.shouldStop(b);k++){var l=i[k],m=i[(k+1)%j],n=f.getLineSegmentsIntersectionFraction(e,g,l,m);n>=0&&(f.sub(h,m,l),f.rotate(h,h,-Math.PI/2+d),f.normalize(h,h),b.reportIntersection(a,n,h,k))}}},{"../math/polyk":29,"../math/vec2":30,"./Shape":45,"poly-decomp":5}],41:[function(a,b,c){function d(a){if(Array.isArray(arguments[0])){if(a={heights:arguments[0]},"object"==typeof arguments[1])for(var b in arguments[1])a[b]=arguments[1][b];console.warn("The Heightfield constructor signature has changed. Please use the following format: new Heightfield({ heights: [...], ... })")}a=a||{},this.heights=a.heights?a.heights.slice(0):[],this.maxValue=a.maxValue||null,this.minValue=a.minValue||null,this.elementWidth=a.elementWidth||.1,(void 0===a.maxValue||void 0===a.minValue)&&this.updateMaxMinValues(),a.type=e.HEIGHTFIELD,e.call(this,a)}var e=a("./Shape"),f=a("../math/vec2");a("../utils/Utils");b.exports=d,d.prototype=new e,d.prototype.constructor=d,d.prototype.updateMaxMinValues=function(){for(var a=this.heights,b=a[0],c=a[0],d=0;d!==a.length;d++){var e=a[d];e>b&&(b=e),c>e&&(c=e)}this.maxValue=b,this.minValue=c},d.prototype.computeMomentOfInertia=function(a){return Number.MAX_VALUE},d.prototype.updateBoundingRadius=function(){this.boundingRadius=Number.MAX_VALUE},d.prototype.updateArea=function(){for(var a=this.heights,b=0,c=0;c<a.length-1;c++)b+=(a[c]+a[c+1])/2*this.elementWidth;this.area=b};var g=[f.create(),f.create(),f.create(),f.create()];d.prototype.computeAABB=function(a,b,c){f.set(g[0],0,this.maxValue),f.set(g[1],this.elementWidth*this.heights.length,this.maxValue),f.set(g[2],this.elementWidth*this.heights.length,this.minValue),f.set(g[3],0,this.minValue),a.setFromPoints(g,b,c)},d.prototype.getLineSegment=function(a,b,c){var d=this.heights,e=this.elementWidth;f.set(a,c*e,d[c]),f.set(b,(c+1)*e,d[c+1])},d.prototype.getSegmentIndex=function(a){return Math.floor(a[0]/this.elementWidth)},d.prototype.getClampedSegmentIndex=function(a){var b=this.getSegmentIndex(a);return b=Math.min(this.heights.length,Math.max(b,0))};var h=(f.create(),f.create()),i=f.create(),j=f.create(),k=f.create(),l=f.create();f.fromValues(0,1);d.prototype.raycast=function(a,b,c,d){var e=b.from,g=b.to,m=(b.direction,h),n=i,o=j,p=k,q=l;f.toLocalFrame(p,e,c,d),f.toLocalFrame(q,g,c,d);var r=this.getClampedSegmentIndex(p),s=this.getClampedSegmentIndex(q);if(r>s){var t=r;r=s,s=t}for(var u=0;u<this.heights.length-1;u++){this.getLineSegment(n,o,u);var v=f.getLineSegmentsIntersectionFraction(p,q,n,o);if(v>=0&&(f.sub(m,o,n),f.rotate(m,m,d+Math.PI/2),f.normalize(m,m),b.reportIntersection(a,v,m,-1),a.shouldStop(b)))return}}},{"../math/vec2":30,"../utils/Utils":57,"./Shape":45}],42:[function(a,b,c){function d(a){"number"==typeof arguments[0]&&(a={length:arguments[0]},console.warn("The Line constructor signature has changed. Please use the following format: new Line({ length: 1, ... })")),a=a||{},this.length=a.length||1,a.type=e.LINE,e.call(this,a)}var e=a("./Shape"),f=a("../math/vec2");b.exports=d,d.prototype=new e,d.prototype.constructor=d,d.prototype.computeMomentOfInertia=function(a){return a*Math.pow(this.length,2)/12},d.prototype.updateBoundingRadius=function(){this.boundingRadius=this.length/2};var g=[f.create(),f.create()];d.prototype.computeAABB=function(a,b,c){var d=this.length/2;f.set(g[0],-d,0),f.set(g[1],d,0),a.setFromPoints(g,b,c,0)};var h=(f.create(),f.create()),i=f.create(),j=f.create(),k=f.fromValues(0,1);d.prototype.raycast=function(a,b,c,d){var e=b.from,g=b.to,l=i,m=j,n=this.length/2;f.set(l,-n,0),f.set(m,n,0),f.toGlobalFrame(l,l,c,d),f.toGlobalFrame(m,m,c,d);var o=f.getLineSegmentsIntersectionFraction(l,m,e,g);if(o>=0){var p=h;f.rotate(p,k,d),b.reportIntersection(a,o,p,-1)}}},{"../math/vec2":30,"./Shape":45}],43:[function(a,b,c){function d(a){a=a||{},a.type=e.PARTICLE,e.call(this,a)}var e=a("./Shape"),f=a("../math/vec2");b.exports=d,d.prototype=new e,d.prototype.constructor=d,d.prototype.computeMomentOfInertia=function(a){return 0},d.prototype.updateBoundingRadius=function(){this.boundingRadius=0},d.prototype.computeAABB=function(a,b,c){f.copy(a.lowerBound,b),f.copy(a.upperBound,b)}},{"../math/vec2":30,"./Shape":45}],44:[function(a,b,c){function d(a){a=a||{},a.type=e.PLANE,e.call(this,a)}var e=a("./Shape"),f=a("../math/vec2");a("../utils/Utils");b.exports=d,d.prototype=new e,d.prototype.constructor=d,d.prototype.computeMomentOfInertia=function(a){return 0},d.prototype.updateBoundingRadius=function(){this.boundingRadius=Number.MAX_VALUE},d.prototype.computeAABB=function(a,b,c){var d=c%(2*Math.PI),e=f.set,g=Number.MAX_VALUE,h=a.lowerBound,i=a.upperBound;0===d?(e(h,-g,-g),e(i,g,0)):d===Math.PI/2?(e(h,0,-g),e(i,g,g)):d===Math.PI?(e(h,-g,0),e(i,g,g)):d===3*Math.PI/2?(e(h,-g,-g),e(i,0,g)):(e(h,-g,-g),e(i,g,g)),f.add(h,h,b),f.add(i,i,b)},d.prototype.updateArea=function(){this.area=Number.MAX_VALUE};var g=f.create(),h=(f.create(),f.create(),f.create()),i=f.create();d.prototype.raycast=function(a,b,c,d){var e=b.from,j=b.to,k=b.direction,l=g,m=h,n=i;f.set(m,0,1),f.rotate(m,m,d),f.sub(n,e,c);var o=f.dot(n,m);f.sub(n,j,c);var p=f.dot(n,m);if(!(o*p>0||f.squaredDistance(e,j)<o*o)){var q=f.dot(m,k);f.sub(l,e,c);var r=-f.dot(m,l)/q/b.length;b.reportIntersection(a,r,m,-1)}}},{"../math/vec2":30,"../utils/Utils":57,"./Shape":45}],45:[function(a,b,c){function d(a){a=a||{},this.body=null,this.position=e.fromValues(0,0),a.position&&e.copy(this.position,a.position),this.angle=a.angle||0,this.type=a.type||0,this.id=d.idCounter++,this.boundingRadius=0,this.collisionGroup=void 0!==a.collisionGroup?a.collisionGroup:1,this.collisionResponse=void 0!==a.collisionResponse?a.collisionResponse:!0,this.collisionMask=void 0!==a.collisionMask?a.collisionMask:1,this.material=a.material||null,this.area=0,this.sensor=void 0!==a.sensor?a.sensor:!1,this.type&&this.updateBoundingRadius(),this.updateArea()}b.exports=d;var e=a("../math/vec2");d.idCounter=0,d.CIRCLE=1,d.PARTICLE=2,d.PLANE=4,d.CONVEX=8,d.LINE=16,d.BOX=32,Object.defineProperty(d,"RECTANGLE",{get:function(){return console.warn("Shape.RECTANGLE is deprecated, use Shape.BOX instead."),d.BOX}}),d.CAPSULE=64,d.HEIGHTFIELD=128,d.prototype.computeMomentOfInertia=function(a){},d.prototype.updateBoundingRadius=function(){},d.prototype.updateArea=function(){},d.prototype.computeAABB=function(a,b,c){},d.prototype.raycast=function(a,b,c,d){}},{"../math/vec2":30}],46:[function(a,b,c){function d(a){g.call(this,a,g.GS),a=a||{},this.iterations=a.iterations||10,this.tolerance=a.tolerance||1e-7,this.arrayStep=30,this.lambda=new h.ARRAY_TYPE(this.arrayStep),this.Bs=new h.ARRAY_TYPE(this.arrayStep),this.invCs=new h.ARRAY_TYPE(this.arrayStep),this.useZeroRHS=!1,this.frictionIterations=0,this.usedIterations=0; +}function e(a){for(var b=a.length;b--;)a[b]=0}var f=a("../math/vec2"),g=a("./Solver"),h=a("../utils/Utils"),i=a("../equations/FrictionEquation");b.exports=d,d.prototype=new g,d.prototype.constructor=d,d.prototype.solve=function(a,b){this.sortEquations();var c=0,g=this.iterations,j=this.frictionIterations,k=this.equations,l=k.length,m=Math.pow(this.tolerance*l,2),n=b.bodies,o=b.bodies.length,p=(f.add,f.set,this.useZeroRHS),q=this.lambda;if(this.usedIterations=0,l)for(var r=0;r!==o;r++){var s=n[r];s.updateSolveMassProperties()}q.length<l&&(q=this.lambda=new h.ARRAY_TYPE(l+this.arrayStep),this.Bs=new h.ARRAY_TYPE(l+this.arrayStep),this.invCs=new h.ARRAY_TYPE(l+this.arrayStep)),e(q);for(var t=this.invCs,u=this.Bs,q=this.lambda,r=0;r!==k.length;r++){var v=k[r];(v.timeStep!==a||v.needsUpdate)&&(v.timeStep=a,v.update()),u[r]=v.computeB(v.a,v.b,a),t[r]=v.computeInvC(v.epsilon)}var v,w,r,x;if(0!==l){for(r=0;r!==o;r++){var s=n[r];s.resetConstraintVelocity()}if(j){for(c=0;c!==j;c++){for(w=0,x=0;x!==l;x++){v=k[x];var y=d.iterateEquation(x,v,v.epsilon,u,t,q,p,a,c);w+=Math.abs(y)}if(this.usedIterations++,m>=w*w)break}for(d.updateMultipliers(k,q,1/a),x=0;x!==l;x++){var z=k[x];if(z instanceof i){for(var A=0,B=0;B!==z.contactEquations.length;B++)A+=z.contactEquations[B].multiplier;A*=z.frictionCoefficient/z.contactEquations.length,z.maxForce=A,z.minForce=-A}}}for(c=0;c!==g;c++){for(w=0,x=0;x!==l;x++){v=k[x];var y=d.iterateEquation(x,v,v.epsilon,u,t,q,p,a,c);w+=Math.abs(y)}if(this.usedIterations++,m>=w*w)break}for(r=0;r!==o;r++)n[r].addConstraintVelocity();d.updateMultipliers(k,q,1/a)}},d.updateMultipliers=function(a,b,c){for(var d=a.length;d--;)a[d].multiplier=b[d]*c},d.iterateEquation=function(a,b,c,d,e,f,g,h,i){var j=d[a],k=e[a],l=f[a],m=b.computeGWlambda(),n=b.maxForce,o=b.minForce;g&&(j=0);var p=k*(j-m-c*l),q=l+p;return o*h>q?p=o*h-l:q>n*h&&(p=n*h-l),f[a]+=p,b.addToWlambda(p),p}},{"../equations/FrictionEquation":23,"../math/vec2":30,"../utils/Utils":57,"./Solver":47}],47:[function(a,b,c){function d(a,b){a=a||{},e.call(this),this.type=b,this.equations=[],this.equationSortFunction=a.equationSortFunction||!1}var e=(a("../utils/Utils"),a("../events/EventEmitter"));b.exports=d,d.prototype=new e,d.prototype.constructor=d,d.prototype.solve=function(a,b){throw new Error("Solver.solve should be implemented by subclasses!")};var f={bodies:[]};d.prototype.solveIsland=function(a,b){this.removeAllEquations(),b.equations.length&&(this.addEquations(b.equations),f.bodies.length=0,b.getBodies(f.bodies),f.bodies.length&&this.solve(a,f))},d.prototype.sortEquations=function(){this.equationSortFunction&&this.equations.sort(this.equationSortFunction)},d.prototype.addEquation=function(a){a.enabled&&this.equations.push(a)},d.prototype.addEquations=function(a){for(var b=0,c=a.length;b!==c;b++){var d=a[b];d.enabled&&this.equations.push(d)}},d.prototype.removeEquation=function(a){var b=this.equations.indexOf(a);-1!==b&&this.equations.splice(b,1)},d.prototype.removeAllEquations=function(){this.equations.length=0},d.GS=1,d.ISLAND=2},{"../events/EventEmitter":26,"../utils/Utils":57}],48:[function(a,b,c){function d(){f.apply(this,arguments)}var e=a("../equations/ContactEquation"),f=a("./Pool");b.exports=d,d.prototype=new f,d.prototype.constructor=d,d.prototype.create=function(){return new e},d.prototype.destroy=function(a){return a.bodyA=a.bodyB=null,this}},{"../equations/ContactEquation":21,"./Pool":55}],49:[function(a,b,c){function d(){f.apply(this,arguments)}var e=a("../equations/FrictionEquation"),f=a("./Pool");b.exports=d,d.prototype=new f,d.prototype.constructor=d,d.prototype.create=function(){return new e},d.prototype.destroy=function(a){return a.bodyA=a.bodyB=null,this}},{"../equations/FrictionEquation":23,"./Pool":55}],50:[function(a,b,c){function d(){f.apply(this,arguments)}var e=a("../world/IslandNode"),f=a("./Pool");b.exports=d,d.prototype=new f,d.prototype.constructor=d,d.prototype.create=function(){return new e},d.prototype.destroy=function(a){return a.reset(),this}},{"../world/IslandNode":60,"./Pool":55}],51:[function(a,b,c){function d(){f.apply(this,arguments)}var e=a("../world/Island"),f=a("./Pool");b.exports=d,d.prototype=new f,d.prototype.constructor=d,d.prototype.create=function(){return new e},d.prototype.destroy=function(a){return a.reset(),this}},{"../world/Island":58,"./Pool":55}],52:[function(a,b,c){function d(){this.overlappingShapesLastState=new e,this.overlappingShapesCurrentState=new e,this.recordPool=new f({size:16}),this.tmpDict=new e,this.tmpArray1=[]}var e=a("./TupleDictionary"),f=(a("./OverlapKeeperRecord"),a("./OverlapKeeperRecordPool"));a("./Utils");b.exports=d,d.prototype.tick=function(){for(var a=this.overlappingShapesLastState,b=this.overlappingShapesCurrentState,c=a.keys.length;c--;){var d=a.keys[c],e=a.getByKey(d);b.getByKey(d);e&&this.recordPool.release(e)}a.reset(),a.copy(b),b.reset()},d.prototype.setOverlapping=function(a,b,c,d){var e=(this.overlappingShapesLastState,this.overlappingShapesCurrentState);if(!e.get(b.id,d.id)){var f=this.recordPool.get();f.set(a,b,c,d),e.set(b.id,d.id,f)}},d.prototype.getNewOverlaps=function(a){return this.getDiff(this.overlappingShapesLastState,this.overlappingShapesCurrentState,a)},d.prototype.getEndOverlaps=function(a){return this.getDiff(this.overlappingShapesCurrentState,this.overlappingShapesLastState,a)},d.prototype.bodiesAreOverlapping=function(a,b){for(var c=this.overlappingShapesCurrentState,d=c.keys.length;d--;){var e=c.keys[d],f=c.data[e];if(f.bodyA===a&&f.bodyB===b||f.bodyA===b&&f.bodyB===a)return!0}return!1},d.prototype.getDiff=function(a,b,c){var c=c||[],d=a,e=b;c.length=0;for(var f=e.keys.length;f--;){var g=e.keys[f],h=e.data[g];if(!h)throw new Error("Key "+g+" had no data!");var i=d.data[g];i||c.push(h)}return c},d.prototype.isNewOverlap=function(a,b){var c=0|a.id,d=0|b.id,e=this.overlappingShapesLastState,f=this.overlappingShapesCurrentState;return!e.get(c,d)&&!!f.get(c,d)},d.prototype.getNewBodyOverlaps=function(a){this.tmpArray1.length=0;var b=this.getNewOverlaps(this.tmpArray1);return this.getBodyDiff(b,a)},d.prototype.getEndBodyOverlaps=function(a){this.tmpArray1.length=0;var b=this.getEndOverlaps(this.tmpArray1);return this.getBodyDiff(b,a)},d.prototype.getBodyDiff=function(a,b){b=b||[];for(var c=this.tmpDict,d=a.length;d--;){var e=a[d];c.set(0|e.bodyA.id,0|e.bodyB.id,e)}for(d=c.keys.length;d--;){var e=c.getByKey(c.keys[d]);e&&b.push(e.bodyA,e.bodyB)}return c.reset(),b}},{"./OverlapKeeperRecord":53,"./OverlapKeeperRecordPool":54,"./TupleDictionary":56,"./Utils":57}],53:[function(a,b,c){function d(a,b,c,d){this.shapeA=b,this.shapeB=d,this.bodyA=a,this.bodyB=c}b.exports=d,d.prototype.set=function(a,b,c,e){d.call(this,a,b,c,e)}},{}],54:[function(a,b,c){function d(){f.apply(this,arguments)}var e=a("./OverlapKeeperRecord"),f=a("./Pool");b.exports=d,d.prototype=new f,d.prototype.constructor=d,d.prototype.create=function(){return new e},d.prototype.destroy=function(a){return a.bodyA=a.bodyB=a.shapeA=a.shapeB=null,this}},{"./OverlapKeeperRecord":53,"./Pool":55}],55:[function(a,b,c){function d(a){a=a||{},this.objects=[],void 0!==a.size&&this.resize(a.size)}b.exports=d,d.prototype.resize=function(a){for(var b=this.objects;b.length>a;)b.pop();for(;b.length<a;)b.push(this.create());return this},d.prototype.get=function(){var a=this.objects;return a.length?a.pop():this.create()},d.prototype.release=function(a){return this.destroy(a),this.objects.push(a),this}},{}],56:[function(a,b,c){function d(){this.data={},this.keys=[]}var e=a("./Utils");b.exports=d,d.prototype.getKey=function(a,b){return a=0|a,b=0|b,(0|a)===(0|b)?-1:0|((0|a)>(0|b)?a<<16|65535&b:b<<16|65535&a)},d.prototype.getByKey=function(a){return a=0|a,this.data[a]},d.prototype.get=function(a,b){return this.data[this.getKey(a,b)]},d.prototype.set=function(a,b,c){if(!c)throw new Error("No data!");var d=this.getKey(a,b);return this.data[d]||this.keys.push(d),this.data[d]=c,d},d.prototype.reset=function(){for(var a=this.data,b=this.keys,c=b.length;c--;)delete a[b[c]];b.length=0},d.prototype.copy=function(a){this.reset(),e.appendArray(this.keys,a.keys);for(var b=a.keys.length;b--;){var c=a.keys[b];this.data[c]=a.data[c]}}},{"./Utils":57}],57:[function(a,b,c){function d(){}b.exports=d,d.appendArray=function(a,b){if(b.length<15e4)a.push.apply(a,b);else for(var c=0,d=b.length;c!==d;++c)a.push(b[c])},d.splice=function(a,b,c){c=c||1;for(var d=b,e=a.length-c;e>d;d++)a[d]=a[d+c];a.length=e},"undefined"!=typeof P2_ARRAY_TYPE?d.ARRAY_TYPE=P2_ARRAY_TYPE:"undefined"!=typeof Float32Array?d.ARRAY_TYPE=Float32Array:d.ARRAY_TYPE=Array,d.extend=function(a,b){for(var c in b)a[c]=b[c]},d.defaults=function(a,b){a=a||{};for(var c in b)c in a||(a[c]=b[c]);return a}},{}],58:[function(a,b,c){function d(){this.equations=[],this.bodies=[]}var e=a("../objects/Body");b.exports=d,d.prototype.reset=function(){this.equations.length=this.bodies.length=0};var f=[];d.prototype.getBodies=function(a){var b=a||[],c=this.equations;f.length=0;for(var d=0;d!==c.length;d++){var e=c[d];-1===f.indexOf(e.bodyA.id)&&(b.push(e.bodyA),f.push(e.bodyA.id)),-1===f.indexOf(e.bodyB.id)&&(b.push(e.bodyB),f.push(e.bodyB.id))}return b},d.prototype.wantsToSleep=function(){for(var a=0;a<this.bodies.length;a++){var b=this.bodies[a];if(b.type===e.DYNAMIC&&!b.wantsToSleep)return!1}return!0},d.prototype.sleep=function(){for(var a=0;a<this.bodies.length;a++){var b=this.bodies[a];b.sleep()}return!0}},{"../objects/Body":31}],59:[function(a,b,c){function d(a){this.nodePool=new e({size:16}),this.islandPool=new f({size:8}),this.equations=[],this.islands=[],this.nodes=[],this.queue=[]}var e=(a("../math/vec2"),a("./Island"),a("./IslandNode"),a("./../utils/IslandNodePool")),f=a("./../utils/IslandPool"),g=a("../objects/Body");b.exports=d,d.getUnvisitedNode=function(a){for(var b=a.length,c=0;c!==b;c++){var d=a[c];if(!d.visited&&d.body.type===g.DYNAMIC)return d}return!1},d.prototype.visit=function(a,b,c){b.push(a.body);for(var d=a.equations.length,e=0;e!==d;e++){var f=a.equations[e];-1===c.indexOf(f)&&c.push(f)}},d.prototype.bfs=function(a,b,c){var e=this.queue;for(e.length=0,e.push(a),a.visited=!0,this.visit(a,b,c);e.length;)for(var f,h=e.pop();f=d.getUnvisitedNode(h.neighbors);)f.visited=!0,this.visit(f,b,c),f.body.type===g.DYNAMIC&&e.push(f)},d.prototype.split=function(a){for(var b=a.bodies,c=this.nodes,e=this.equations;c.length;)this.nodePool.release(c.pop());for(var f=0;f!==b.length;f++){var g=this.nodePool.get();g.body=b[f],c.push(g)}for(var h=0;h!==e.length;h++){var i=e[h],f=b.indexOf(i.bodyA),j=b.indexOf(i.bodyB),k=c[f],l=c[j];k.neighbors.push(l),l.neighbors.push(k),k.equations.push(i),l.equations.push(i)}for(var m=this.islands,f=0;f<m.length;f++)this.islandPool.release(m[f]);m.length=0;for(var n;n=d.getUnvisitedNode(c);){var o=this.islandPool.get();this.bfs(n,o.bodies,o.equations),m.push(o)}return m}},{"../math/vec2":30,"../objects/Body":31,"./../utils/IslandNodePool":50,"./../utils/IslandPool":51,"./Island":58,"./IslandNode":60}],60:[function(a,b,c){function d(a){this.body=a,this.neighbors=[],this.equations=[],this.visited=!1}b.exports=d,d.prototype.reset=function(){this.equations.length=0,this.neighbors.length=0,this.visited=!1,this.body=null}},{}],61:[function(a,b,c){function d(a){l.apply(this),a=a||{},this.springs=[],this.bodies=[],this.disabledBodyCollisionPairs=[],this.solver=a.solver||new e,this.narrowphase=new r(this),this.islandManager=new u,this.gravity=f.fromValues(0,-9.78),a.gravity&&f.copy(this.gravity,a.gravity),this.frictionGravity=f.length(this.gravity)||10,this.useWorldGravityAsFrictionGravity=!0,this.useFrictionGravityOnZeroGravity=!0,this.broadphase=a.broadphase||new q,this.broadphase.setWorld(this),this.constraints=[],this.defaultMaterial=new n,this.defaultContactMaterial=new o(this.defaultMaterial,this.defaultMaterial),this.lastTimeStep=1/60,this.applySpringForces=!0,this.applyDamping=!0,this.applyGravity=!0,this.solveConstraints=!0,this.contactMaterials=[],this.time=0,this.accumulator=0,this.stepping=!1,this.bodiesToBeRemoved=[],this.islandSplit="undefined"!=typeof a.islandSplit?!!a.islandSplit:!0,this.emitImpactEvent=!0,this._constraintIdCounter=0,this._bodyIdCounter=0,this.postStepEvent={type:"postStep"},this.addBodyEvent={type:"addBody",body:null},this.removeBodyEvent={type:"removeBody",body:null},this.addSpringEvent={type:"addSpring",spring:null},this.impactEvent={type:"impact",bodyA:null,bodyB:null,shapeA:null,shapeB:null,contactEquation:null},this.postBroadphaseEvent={type:"postBroadphase",pairs:null},this.sleepMode=d.NO_SLEEPING,this.beginContactEvent={type:"beginContact",shapeA:null,shapeB:null,bodyA:null,bodyB:null,contactEquations:[]},this.endContactEvent={type:"endContact",shapeA:null,shapeB:null,bodyA:null,bodyB:null},this.preSolveEvent={type:"preSolve",contactEquations:null,frictionEquations:null},this.overlappingShapesLastState={keys:[]},this.overlappingShapesCurrentState={keys:[]},this.overlapKeeper=new t}var e=a("../solver/GSSolver"),f=(a("../solver/Solver"),a("../collision/Ray"),a("../math/vec2")),g=a("../shapes/Circle"),h=a("../shapes/Convex"),i=(a("../shapes/Line"),a("../shapes/Plane")),j=a("../shapes/Capsule"),k=a("../shapes/Particle"),l=a("../events/EventEmitter"),m=a("../objects/Body"),n=(a("../shapes/Shape"),a("../objects/LinearSpring"),a("../material/Material")),o=a("../material/ContactMaterial"),p=(a("../constraints/DistanceConstraint"),a("../constraints/Constraint"),a("../constraints/LockConstraint"),a("../constraints/RevoluteConstraint"),a("../constraints/PrismaticConstraint"),a("../constraints/GearConstraint"),a("../../package.json"),a("../collision/Broadphase"),a("../collision/AABB")),q=a("../collision/SAPBroadphase"),r=a("../collision/Narrowphase"),s=a("../utils/Utils"),t=a("../utils/OverlapKeeper"),u=a("./IslandManager");a("../objects/RotationalSpring");b.exports=d,d.prototype=new Object(l.prototype),d.prototype.constructor=d,d.NO_SLEEPING=1,d.BODY_SLEEPING=2,d.ISLAND_SLEEPING=4,d.prototype.addConstraint=function(a){this.constraints.push(a)},d.prototype.addContactMaterial=function(a){this.contactMaterials.push(a)},d.prototype.removeContactMaterial=function(a){var b=this.contactMaterials.indexOf(a);-1!==b&&s.splice(this.contactMaterials,b,1)},d.prototype.getContactMaterial=function(a,b){for(var c=this.contactMaterials,d=0,e=c.length;d!==e;d++){var f=c[d];if(f.materialA.id===a.id&&f.materialB.id===b.id||f.materialA.id===b.id&&f.materialB.id===a.id)return f}return!1},d.prototype.removeConstraint=function(a){var b=this.constraints.indexOf(a);-1!==b&&s.splice(this.constraints,b,1)};var v=(f.create(),f.create(),f.create(),f.create(),f.create(),f.create(),f.create()),w=f.fromValues(0,0),x=f.fromValues(0,0);f.fromValues(0,0),f.fromValues(0,0);d.prototype.step=function(a,b,c){if(c=c||10,b=b||0,0===b)this.internalStep(a),this.time+=a;else{this.accumulator+=b;for(var d=0;this.accumulator>=a&&c>d;)this.internalStep(a),this.time+=a,this.accumulator-=a,d++;for(var e=this.accumulator%a/a,g=0;g!==this.bodies.length;g++){var h=this.bodies[g];f.lerp(h.interpolatedPosition,h.previousPosition,h.position,e),h.interpolatedAngle=h.previousAngle+e*(h.angle-h.previousAngle)}}};var y=[];d.prototype.internalStep=function(a){this.stepping=!0;var b=this.springs.length,c=this.springs,e=this.bodies,g=this.gravity,h=this.solver,i=this.bodies.length,j=this.broadphase,k=this.narrowphase,l=this.constraints,n=v,o=(f.scale,f.add),p=(f.rotate,this.islandManager);if(this.overlapKeeper.tick(),this.lastTimeStep=a,this.useWorldGravityAsFrictionGravity){var q=f.length(this.gravity);0===q&&this.useFrictionGravityOnZeroGravity||(this.frictionGravity=q)}if(this.applyGravity)for(var r=0;r!==i;r++){var t=e[r],u=t.force;t.type===m.DYNAMIC&&t.sleepState!==m.SLEEPING&&(f.scale(n,g,t.mass*t.gravityScale),o(u,u,n))}if(this.applySpringForces)for(var r=0;r!==b;r++){var w=c[r];w.applyForce()}if(this.applyDamping)for(var r=0;r!==i;r++){var t=e[r];t.type===m.DYNAMIC&&t.applyDamping(a)}for(var x=j.getCollisionPairs(this),z=this.disabledBodyCollisionPairs,r=z.length-2;r>=0;r-=2)for(var A=x.length-2;A>=0;A-=2)(z[r]===x[A]&&z[r+1]===x[A+1]||z[r+1]===x[A]&&z[r]===x[A+1])&&x.splice(A,2);var B=l.length;for(r=0;r!==B;r++){var C=l[r];if(!C.collideConnected)for(var A=x.length-2;A>=0;A-=2)(C.bodyA===x[A]&&C.bodyB===x[A+1]||C.bodyB===x[A]&&C.bodyA===x[A+1])&&x.splice(A,2)}this.postBroadphaseEvent.pairs=x,this.emit(this.postBroadphaseEvent),this.postBroadphaseEvent.pairs=null,k.reset(this);for(var r=0,D=x.length;r!==D;r+=2)for(var E=x[r],F=x[r+1],G=0,H=E.shapes.length;G!==H;G++)for(var I=E.shapes[G],J=I.position,K=I.angle,L=0,M=F.shapes.length;L!==M;L++){var N=F.shapes[L],O=N.position,P=N.angle,Q=this.defaultContactMaterial;if(I.material&&N.material){var R=this.getContactMaterial(I.material,N.material);R&&(Q=R)}this.runNarrowphase(k,E,I,J,K,F,N,O,P,Q,this.frictionGravity)}for(var r=0;r!==i;r++){var S=e[r];S._wakeUpAfterNarrowphase&&(S.wakeUp(),S._wakeUpAfterNarrowphase=!1)}if(this.has("endContact")){this.overlapKeeper.getEndOverlaps(y);for(var T=this.endContactEvent,L=y.length;L--;){var U=y[L];T.shapeA=U.shapeA,T.shapeB=U.shapeB,T.bodyA=U.bodyA,T.bodyB=U.bodyB,this.emit(T)}y.length=0}var V=this.preSolveEvent;V.contactEquations=k.contactEquations,V.frictionEquations=k.frictionEquations,this.emit(V),V.contactEquations=V.frictionEquations=null;var B=l.length;for(r=0;r!==B;r++)l[r].update();if(k.contactEquations.length||k.frictionEquations.length||B)if(this.islandSplit){for(p.equations.length=0,s.appendArray(p.equations,k.contactEquations),s.appendArray(p.equations,k.frictionEquations),r=0;r!==B;r++)s.appendArray(p.equations,l[r].equations);p.split(this);for(var r=0;r!==p.islands.length;r++){var W=p.islands[r];W.equations.length&&h.solveIsland(a,W)}}else{for(h.addEquations(k.contactEquations),h.addEquations(k.frictionEquations),r=0;r!==B;r++)h.addEquations(l[r].equations);this.solveConstraints&&h.solve(a,this),h.removeAllEquations()}for(var r=0;r!==i;r++){var S=e[r];S.integrate(a)}for(var r=0;r!==i;r++)e[r].setZeroForce();if(this.emitImpactEvent&&this.has("impact"))for(var X=this.impactEvent,r=0;r!==k.contactEquations.length;r++){var Y=k.contactEquations[r];Y.firstImpact&&(X.bodyA=Y.bodyA,X.bodyB=Y.bodyB,X.shapeA=Y.shapeA,X.shapeB=Y.shapeB,X.contactEquation=Y,this.emit(X))}if(this.sleepMode===d.BODY_SLEEPING)for(r=0;r!==i;r++)e[r].sleepTick(this.time,!1,a);else if(this.sleepMode===d.ISLAND_SLEEPING&&this.islandSplit){for(r=0;r!==i;r++)e[r].sleepTick(this.time,!0,a);for(var r=0;r<this.islandManager.islands.length;r++){var W=this.islandManager.islands[r];W.wantsToSleep()&&W.sleep()}}this.stepping=!1;for(var Z=this.bodiesToBeRemoved,r=0;r!==Z.length;r++)this.removeBody(Z[r]);Z.length=0,this.emit(this.postStepEvent)},d.prototype.runNarrowphase=function(a,b,c,d,e,g,h,i,j,k,l){if(0!==(c.collisionGroup&h.collisionMask)&&0!==(h.collisionGroup&c.collisionMask)){f.rotate(w,d,b.angle),f.rotate(x,i,g.angle),f.add(w,w,b.position),f.add(x,x,g.position);var n=e+b.angle,o=j+g.angle;a.enableFriction=k.friction>0,a.frictionCoefficient=k.friction;var p;p=b.type===m.STATIC||b.type===m.KINEMATIC?g.mass:g.type===m.STATIC||g.type===m.KINEMATIC?b.mass:b.mass*g.mass/(b.mass+g.mass),a.slipForce=k.friction*l*p,a.restitution=k.restitution,a.surfaceVelocity=k.surfaceVelocity,a.frictionStiffness=k.frictionStiffness,a.frictionRelaxation=k.frictionRelaxation,a.stiffness=k.stiffness,a.relaxation=k.relaxation,a.contactSkinSize=k.contactSkinSize,a.enabledEquations=b.collisionResponse&&g.collisionResponse&&c.collisionResponse&&h.collisionResponse;var q=a[c.type|h.type],r=0;if(q){var s=c.sensor||h.sensor,t=a.frictionEquations.length;r=c.type<h.type?q.call(a,b,c,w,n,g,h,x,o,s):q.call(a,g,h,x,o,b,c,w,n,s);var u=a.frictionEquations.length-t;if(r){if(b.allowSleep&&b.type===m.DYNAMIC&&b.sleepState===m.SLEEPING&&g.sleepState===m.AWAKE&&g.type!==m.STATIC){var v=f.squaredLength(g.velocity)+Math.pow(g.angularVelocity,2),y=Math.pow(g.sleepSpeedLimit,2);v>=2*y&&(b._wakeUpAfterNarrowphase=!0)}if(g.allowSleep&&g.type===m.DYNAMIC&&g.sleepState===m.SLEEPING&&b.sleepState===m.AWAKE&&b.type!==m.STATIC){var z=f.squaredLength(b.velocity)+Math.pow(b.angularVelocity,2),A=Math.pow(b.sleepSpeedLimit,2);z>=2*A&&(g._wakeUpAfterNarrowphase=!0)}if(this.overlapKeeper.setOverlapping(b,c,g,h),this.has("beginContact")&&this.overlapKeeper.isNewOverlap(c,h)){var B=this.beginContactEvent;if(B.shapeA=c,B.shapeB=h,B.bodyA=b,B.bodyB=g,B.contactEquations.length=0,"number"==typeof r)for(var C=a.contactEquations.length-r;C<a.contactEquations.length;C++)B.contactEquations.push(a.contactEquations[C]);this.emit(B)}if("number"==typeof r&&u>1)for(var C=a.frictionEquations.length-u;C<a.frictionEquations.length;C++){var D=a.frictionEquations[C];D.setSlipForce(D.getSlipForce()/u)}}}}},d.prototype.addSpring=function(a){this.springs.push(a);var b=this.addSpringEvent;b.spring=a,this.emit(b),b.spring=null},d.prototype.removeSpring=function(a){var b=this.springs.indexOf(a);-1!==b&&s.splice(this.springs,b,1)},d.prototype.addBody=function(a){if(-1===this.bodies.indexOf(a)){this.bodies.push(a),a.world=this;var b=this.addBodyEvent;b.body=a,this.emit(b),b.body=null}},d.prototype.removeBody=function(a){if(this.stepping)this.bodiesToBeRemoved.push(a);else{a.world=null;var b=this.bodies.indexOf(a);-1!==b&&(s.splice(this.bodies,b,1),this.removeBodyEvent.body=a,a.resetConstraintVelocity(),this.emit(this.removeBodyEvent),this.removeBodyEvent.body=null)}},d.prototype.getBodyById=function(a){for(var b=this.bodies,c=0;c<b.length;c++){var d=b[c];if(d.id===a)return d}return!1},d.prototype.disableBodyCollision=function(a,b){this.disabledBodyCollisionPairs.push(a,b)},d.prototype.enableBodyCollision=function(a,b){for(var c=this.disabledBodyCollisionPairs,d=0;d<c.length;d+=2)if(c[d]===a&&c[d+1]===b||c[d+1]===a&&c[d]===b)return void c.splice(d,2)},d.prototype.clear=function(){this.time=0,this.solver&&this.solver.equations.length&&this.solver.removeAllEquations();for(var a=this.constraints,b=a.length-1;b>=0;b--)this.removeConstraint(a[b]);for(var c=this.bodies,b=c.length-1;b>=0;b--)this.removeBody(c[b]);for(var e=this.springs,b=e.length-1;b>=0;b--)this.removeSpring(e[b]);for(var f=this.contactMaterials,b=f.length-1;b>=0;b--)this.removeContactMaterial(f[b]);d.apply(this)};var z=f.create(),A=(f.fromValues(0,0),f.fromValues(0,0));d.prototype.hitTest=function(a,b,c){c=c||0;var d=new m({position:a}),e=new k,l=a,n=0,o=z,p=A;d.addShape(e);for(var q=this.narrowphase,r=[],s=0,t=b.length;s!==t;s++)for(var u=b[s],v=0,w=u.shapes.length;v!==w;v++){var x=u.shapes[v];f.rotate(o,x.position,u.angle),f.add(o,o,u.position);var y=x.angle+u.angle;(x instanceof g&&q.circleParticle(u,x,o,y,d,e,l,n,!0)||x instanceof h&&q.particleConvex(d,e,l,n,u,x,o,y,!0)||x instanceof i&&q.particlePlane(d,e,l,n,u,x,o,y,!0)||x instanceof j&&q.particleCapsule(d,e,l,n,u,x,o,y,!0)||x instanceof k&&f.squaredLength(f.sub(p,o,a))<c*c)&&r.push(u)}return r},d.prototype.setGlobalStiffness=function(a){for(var b=this.constraints,c=0;c!==b.length;c++)for(var d=b[c],e=0;e!==d.equations.length;e++){var f=d.equations[e];f.stiffness=a,f.needsUpdate=!0}for(var g=this.contactMaterials,c=0;c!==g.length;c++){var d=g[c];d.stiffness=d.frictionStiffness=a}var d=this.defaultContactMaterial;d.stiffness=d.frictionStiffness=a},d.prototype.setGlobalRelaxation=function(a){for(var b=0;b!==this.constraints.length;b++)for(var c=this.constraints[b],d=0;d!==c.equations.length;d++){var e=c.equations[d];e.relaxation=a,e.needsUpdate=!0}for(var b=0;b!==this.contactMaterials.length;b++){var c=this.contactMaterials[b];c.relaxation=c.frictionRelaxation=a}var c=this.defaultContactMaterial;c.relaxation=c.frictionRelaxation=a};var B=new p,C=[];d.prototype.raycast=function(a,b){return b.getAABB(B),this.broadphase.aabbQuery(this,B,C),b.intersectBodies(a,C),C.length=0,a.hasHit()}},{"../../package.json":6,"../collision/AABB":7,"../collision/Broadphase":8,"../collision/Narrowphase":10,"../collision/Ray":11,"../collision/SAPBroadphase":13,"../constraints/Constraint":14,"../constraints/DistanceConstraint":15,"../constraints/GearConstraint":16,"../constraints/LockConstraint":17,"../constraints/PrismaticConstraint":18,"../constraints/RevoluteConstraint":19,"../events/EventEmitter":26,"../material/ContactMaterial":27,"../material/Material":28,"../math/vec2":30,"../objects/Body":31,"../objects/LinearSpring":32,"../objects/RotationalSpring":33,"../shapes/Capsule":38,"../shapes/Circle":39,"../shapes/Convex":40,"../shapes/Line":42,"../shapes/Particle":43,"../shapes/Plane":44,"../shapes/Shape":45,"../solver/GSSolver":46,"../solver/Solver":47,"../utils/OverlapKeeper":52,"../utils/Utils":57,"./IslandManager":59}]},{},[36])(36)}),function(){var a=this,b=b||{};return b.game=null,b.WEBGL_RENDERER=0,b.CANVAS_RENDERER=1,b.VERSION="v2.2.9",b._UID=0,"undefined"!=typeof Float32Array?(b.Float32Array=Float32Array,b.Uint16Array=Uint16Array,b.Uint32Array=Uint32Array,b.ArrayBuffer=ArrayBuffer):(b.Float32Array=Array,b.Uint16Array=Array),b.PI_2=2*Math.PI,b.RAD_TO_DEG=180/Math.PI,b.DEG_TO_RAD=Math.PI/180,b.RETINA_PREFIX="@2x",b.DisplayObject=function(){this.position=new b.Point(0,0),this.scale=new b.Point(1,1),this.pivot=new b.Point(0,0),this.rotation=0,this.alpha=1,this.visible=!0,this.hitArea=null,this.renderable=!1,this.parent=null,this.stage=null,this.worldAlpha=1,this.worldTransform=new b.Matrix,this.worldPosition=new b.Point(0,0),this.worldScale=new b.Point(1,1),this.worldRotation=0,this._sr=0,this._cr=1,this.filterArea=null,this._bounds=new b.Rectangle(0,0,1,1),this._currentBounds=null,this._mask=null,this._cacheAsBitmap=!1,this._cacheIsDirty=!1},b.DisplayObject.prototype.constructor=b.DisplayObject,b.DisplayObject.prototype.destroy=function(){if(this.children){for(var a=this.children.length;a--;)this.children[a].destroy();this.children=[]}this.hitArea=null,this.parent=null,this.stage=null,this.worldTransform=null,this.filterArea=null,this._bounds=null,this._currentBounds=null,this._mask=null,this.renderable=!1,this._destroyCachedSprite()},Object.defineProperty(b.DisplayObject.prototype,"worldVisible",{get:function(){var a=this;do{if(!a.visible)return!1;a=a.parent}while(a);return!0}}),Object.defineProperty(b.DisplayObject.prototype,"mask",{get:function(){return this._mask},set:function(a){this._mask&&(this._mask.isMask=!1),this._mask=a,this._mask&&(this._mask.isMask=!0)}}),Object.defineProperty(b.DisplayObject.prototype,"filters",{get:function(){return this._filters},set:function(a){if(a){for(var c=[],d=0;d<a.length;d++)for(var e=a[d].passes,f=0;f<e.length;f++)c.push(e[f]);this._filterBlock={target:this,filterPasses:c}}this._filters=a,this.blendMode&&this.blendMode===b.blendModes.MULTIPLY&&(this.blendMode=b.blendModes.NORMAL)}}),Object.defineProperty(b.DisplayObject.prototype,"cacheAsBitmap",{get:function(){return this._cacheAsBitmap},set:function(a){this._cacheAsBitmap!==a&&(a?this._generateCachedSprite():this._destroyCachedSprite(),this._cacheAsBitmap=a)}}),b.DisplayObject.prototype.updateTransform=function(a){if(a||this.parent||this.game){var c=this.parent;a?c=a:this.parent||(c=this.game.world);var d,e,f,g,h,i,j=c.worldTransform,k=this.worldTransform;this.rotation%b.PI_2?(this.rotation!==this.rotationCache&&(this.rotationCache=this.rotation,this._sr=Math.sin(this.rotation),this._cr=Math.cos(this.rotation)),d=this._cr*this.scale.x,e=this._sr*this.scale.x,f=-this._sr*this.scale.y,g=this._cr*this.scale.y,h=this.position.x,i=this.position.y,(this.pivot.x||this.pivot.y)&&(h-=this.pivot.x*d+this.pivot.y*f,i-=this.pivot.x*e+this.pivot.y*g),k.a=d*j.a+e*j.c,k.b=d*j.b+e*j.d,k.c=f*j.a+g*j.c,k.d=f*j.b+g*j.d,k.tx=h*j.a+i*j.c+j.tx,k.ty=h*j.b+i*j.d+j.ty):(d=this.scale.x,g=this.scale.y,h=this.position.x-this.pivot.x*d,i=this.position.y-this.pivot.y*g,k.a=d*j.a,k.b=d*j.b,k.c=g*j.c,k.d=g*j.d,k.tx=h*j.a+i*j.c+j.tx,k.ty=h*j.b+i*j.d+j.ty),this.worldAlpha=this.alpha*c.worldAlpha,this.worldPosition.set(k.tx,k.ty),this.worldScale.set(Math.sqrt(k.a*k.a+k.b*k.b),Math.sqrt(k.c*k.c+k.d*k.d)),this.worldRotation=Math.atan2(-k.c,k.d),this._currentBounds=null,this.transformCallback&&this.transformCallback.call(this.transformCallbackContext,k,j)}},b.DisplayObject.prototype.displayObjectUpdateTransform=b.DisplayObject.prototype.updateTransform,b.DisplayObject.prototype.getBounds=function(a){return a=a,b.EmptyRectangle},b.DisplayObject.prototype.getLocalBounds=function(){return this.getBounds(b.identityMatrix)},b.DisplayObject.prototype.setStageReference=function(a){this.stage=a},b.DisplayObject.prototype.preUpdate=function(){},b.DisplayObject.prototype.generateTexture=function(a,c,d){var e=this.getLocalBounds(),f=new b.RenderTexture(0|e.width,0|e.height,d,c,a);return b.DisplayObject._tempMatrix.tx=-e.x,b.DisplayObject._tempMatrix.ty=-e.y,f.render(this,b.DisplayObject._tempMatrix),f},b.DisplayObject.prototype.updateCache=function(){this._generateCachedSprite()},b.DisplayObject.prototype.toGlobal=function(a){return this.displayObjectUpdateTransform(),this.worldTransform.apply(a)},b.DisplayObject.prototype.toLocal=function(a,b){return b&&(a=b.toGlobal(a)),this.displayObjectUpdateTransform(),this.worldTransform.applyInverse(a)},b.DisplayObject.prototype._renderCachedSprite=function(a){this._cachedSprite.worldAlpha=this.worldAlpha,a.gl?b.Sprite.prototype._renderWebGL.call(this._cachedSprite,a):b.Sprite.prototype._renderCanvas.call(this._cachedSprite,a)},b.DisplayObject.prototype._generateCachedSprite=function(){this._cacheAsBitmap=!1;var a=this.getLocalBounds();if(this.updateTransform(),this._cachedSprite)this._cachedSprite.texture.resize(1|a.width,1|a.height);else{var c=new b.RenderTexture(1|a.width,1|a.height);this._cachedSprite=new b.Sprite(c),this._cachedSprite.worldTransform=this.worldTransform}var d=this._filters;this._filters=null,this._cachedSprite.filters=d,b.DisplayObject._tempMatrix.tx=-a.x,b.DisplayObject._tempMatrix.ty=-a.y,this._cachedSprite.texture.render(this,b.DisplayObject._tempMatrix,!0),this._cachedSprite.anchor.x=-(a.x/a.width),this._cachedSprite.anchor.y=-(a.y/a.height),this._filters=d,this._cacheAsBitmap=!0},b.DisplayObject.prototype._destroyCachedSprite=function(){this._cachedSprite&&(this._cachedSprite.texture.destroy(!0),this._cachedSprite=null)},b.DisplayObject.prototype._renderWebGL=function(a){a=a},b.DisplayObject.prototype._renderCanvas=function(a){a=a},Object.defineProperty(b.DisplayObject.prototype,"x",{get:function(){return this.position.x},set:function(a){this.position.x=a}}),Object.defineProperty(b.DisplayObject.prototype,"y",{get:function(){return this.position.y},set:function(a){this.position.y=a}}),b.DisplayObjectContainer=function(){b.DisplayObject.call(this),this.children=[]},b.DisplayObjectContainer.prototype=Object.create(b.DisplayObject.prototype),b.DisplayObjectContainer.prototype.constructor=b.DisplayObjectContainer,Object.defineProperty(b.DisplayObjectContainer.prototype,"width",{get:function(){return this.scale.x*this.getLocalBounds().width},set:function(a){var b=this.getLocalBounds().width;0!==b?this.scale.x=a/b:this.scale.x=1,this._width=a}}),Object.defineProperty(b.DisplayObjectContainer.prototype,"height",{get:function(){return this.scale.y*this.getLocalBounds().height},set:function(a){var b=this.getLocalBounds().height;0!==b?this.scale.y=a/b:this.scale.y=1,this._height=a}}),b.DisplayObjectContainer.prototype.addChild=function(a){return this.addChildAt(a,this.children.length)},b.DisplayObjectContainer.prototype.addChildAt=function(a,b){if(b>=0&&b<=this.children.length)return a.parent&&a.parent.removeChild(a),a.parent=this,this.children.splice(b,0,a),this.stage&&a.setStageReference(this.stage),a;throw new Error(a+"addChildAt: The index "+b+" supplied is out of bounds "+this.children.length)},b.DisplayObjectContainer.prototype.swapChildren=function(a,b){if(a!==b){var c=this.getChildIndex(a),d=this.getChildIndex(b);if(0>c||0>d)throw new Error("swapChildren: Both the supplied DisplayObjects must be a child of the caller.");this.children[c]=b,this.children[d]=a}},b.DisplayObjectContainer.prototype.getChildIndex=function(a){var b=this.children.indexOf(a);if(-1===b)throw new Error("The supplied DisplayObject must be a child of the caller"); +return b},b.DisplayObjectContainer.prototype.setChildIndex=function(a,b){if(0>b||b>=this.children.length)throw new Error("The supplied index is out of bounds");var c=this.getChildIndex(a);this.children.splice(c,1),this.children.splice(b,0,a)},b.DisplayObjectContainer.prototype.getChildAt=function(a){if(0>a||a>=this.children.length)throw new Error("getChildAt: Supplied index "+a+" does not exist in the child list, or the supplied DisplayObject must be a child of the caller");return this.children[a]},b.DisplayObjectContainer.prototype.removeChild=function(a){var b=this.children.indexOf(a);if(-1!==b)return this.removeChildAt(b)},b.DisplayObjectContainer.prototype.removeChildAt=function(a){var b=this.getChildAt(a);return this.stage&&b.removeStageReference(),b.parent=void 0,this.children.splice(a,1),b},b.DisplayObjectContainer.prototype.removeChildren=function(a,b){var c=a||0,d="number"==typeof b?b:this.children.length,e=d-c;if(e>0&&d>=e){for(var f=this.children.splice(c,e),g=0;g<f.length;g++){var h=f[g];this.stage&&h.removeStageReference(),h.parent=void 0}return f}if(0===e&&0===this.children.length)return[];throw new Error("removeChildren: Range Error, numeric values are outside the acceptable range")},b.DisplayObjectContainer.prototype.updateTransform=function(){if(this.visible&&(this.displayObjectUpdateTransform(),!this._cacheAsBitmap))for(var a=0;a<this.children.length;a++)this.children[a].updateTransform()},b.DisplayObjectContainer.prototype.displayObjectContainerUpdateTransform=b.DisplayObjectContainer.prototype.updateTransform,b.DisplayObjectContainer.prototype.getBounds=function(){if(0===this.children.length)return b.EmptyRectangle;for(var a,c,d,e=1/0,f=1/0,g=-(1/0),h=-(1/0),i=!1,j=0,k=this.children.length;k>j;j++){var l=this.children[j];l.visible&&(i=!0,a=this.children[j].getBounds(),e=e<a.x?e:a.x,f=f<a.y?f:a.y,c=a.width+a.x,d=a.height+a.y,g=g>c?g:c,h=h>d?h:d)}if(!i)return b.EmptyRectangle;var m=this._bounds;return m.x=e,m.y=f,m.width=g-e,m.height=h-f,m},b.DisplayObjectContainer.prototype.getLocalBounds=function(){var a=this.worldTransform;this.worldTransform=b.identityMatrix;for(var c=0,d=this.children.length;d>c;c++)this.children[c].updateTransform();var e=this.getBounds();return this.worldTransform=a,e},b.DisplayObjectContainer.prototype.setStageReference=function(a){this.stage=a;for(var b=0;b<this.children.length;b++)this.children[b].setStageReference(a)},b.DisplayObjectContainer.prototype.removeStageReference=function(){for(var a=0;a<this.children.length;a++)this.children[a].removeStageReference();this.stage=null},b.DisplayObjectContainer.prototype._renderWebGL=function(a){if(this.visible&&!(this.alpha<=0)){if(this._cacheAsBitmap)return void this._renderCachedSprite(a);var b;if(this._mask||this._filters){for(this._filters&&(a.spriteBatch.flush(),a.filterManager.pushFilter(this._filterBlock)),this._mask&&(a.spriteBatch.stop(),a.maskManager.pushMask(this.mask,a),a.spriteBatch.start()),b=0;b<this.children.length;b++)this.children[b]._renderWebGL(a);a.spriteBatch.stop(),this._mask&&a.maskManager.popMask(this._mask,a),this._filters&&a.filterManager.popFilter(),a.spriteBatch.start()}else for(b=0;b<this.children.length;b++)this.children[b]._renderWebGL(a)}},b.DisplayObjectContainer.prototype._renderCanvas=function(a){if(this.visible!==!1&&0!==this.alpha){if(this._cacheAsBitmap)return void this._renderCachedSprite(a);this._mask&&a.maskManager.pushMask(this._mask,a);for(var b=0;b<this.children.length;b++)this.children[b]._renderCanvas(a);this._mask&&a.maskManager.popMask(a)}},b.Sprite=function(a){b.DisplayObjectContainer.call(this),this.anchor=new b.Point,this.texture=a||b.Texture.emptyTexture,this._width=0,this._height=0,this.tint=16777215,this.cachedTint=-1,this.tintedTexture=null,this.blendMode=b.blendModes.NORMAL,this.shader=null,this.texture.baseTexture.hasLoaded&&this.onTextureUpdate(),this.renderable=!0},b.Sprite.prototype=Object.create(b.DisplayObjectContainer.prototype),b.Sprite.prototype.constructor=b.Sprite,Object.defineProperty(b.Sprite.prototype,"width",{get:function(){return this.scale.x*this.texture.frame.width},set:function(a){this.scale.x=a/this.texture.frame.width,this._width=a}}),Object.defineProperty(b.Sprite.prototype,"height",{get:function(){return this.scale.y*this.texture.frame.height},set:function(a){this.scale.y=a/this.texture.frame.height,this._height=a}}),b.Sprite.prototype.setTexture=function(a,b){void 0!==b&&this.texture.baseTexture.destroy(),this.texture=a,this.texture.valid=!0},b.Sprite.prototype.onTextureUpdate=function(){this._width&&(this.scale.x=this._width/this.texture.frame.width),this._height&&(this.scale.y=this._height/this.texture.frame.height)},b.Sprite.prototype.getBounds=function(a){var b=this.texture.frame.width,c=this.texture.frame.height,d=b*(1-this.anchor.x),e=b*-this.anchor.x,f=c*(1-this.anchor.y),g=c*-this.anchor.y,h=a||this.worldTransform,i=h.a,j=h.b,k=h.c,l=h.d,m=h.tx,n=h.ty,o=-(1/0),p=-(1/0),q=1/0,r=1/0;if(0===j&&0===k){if(0>i){i*=-1;var s=d;d=-e,e=-s}if(0>l){l*=-1;var s=f;f=-g,g=-s}q=i*e+m,o=i*d+m,r=l*g+n,p=l*f+n}else{var t=i*e+k*g+m,u=l*g+j*e+n,v=i*d+k*g+m,w=l*g+j*d+n,x=i*d+k*f+m,y=l*f+j*d+n,z=i*e+k*f+m,A=l*f+j*e+n;q=q>t?t:q,q=q>v?v:q,q=q>x?x:q,q=q>z?z:q,r=r>u?u:r,r=r>w?w:r,r=r>y?y:r,r=r>A?A:r,o=t>o?t:o,o=v>o?v:o,o=x>o?x:o,o=z>o?z:o,p=u>p?u:p,p=w>p?w:p,p=y>p?y:p,p=A>p?A:p}var B=this._bounds;return B.x=q,B.width=o-q,B.y=r,B.height=p-r,this._currentBounds=B,B},b.Sprite.prototype._renderWebGL=function(a,b){if(this.visible&&!(this.alpha<=0)&&this.renderable){var c=this.worldTransform;if(b&&(c=b),this._mask||this._filters){var d=a.spriteBatch;this._filters&&(d.flush(),a.filterManager.pushFilter(this._filterBlock)),this._mask&&(d.stop(),a.maskManager.pushMask(this.mask,a),d.start()),d.render(this);for(var e=0;e<this.children.length;e++)this.children[e]._renderWebGL(a);d.stop(),this._mask&&a.maskManager.popMask(this._mask,a),this._filters&&a.filterManager.popFilter(),d.start()}else{a.spriteBatch.render(this);for(var e=0;e<this.children.length;e++)this.children[e]._renderWebGL(a,c)}}},b.Sprite.prototype._renderCanvas=function(a,c){if(!(!this.visible||0===this.alpha||!this.renderable||this.texture.crop.width<=0||this.texture.crop.height<=0)){var d=this.worldTransform;if(c&&(d=c),this.blendMode!==a.currentBlendMode&&(a.currentBlendMode=this.blendMode,a.context.globalCompositeOperation=b.blendModesCanvas[a.currentBlendMode]),this._mask&&a.maskManager.pushMask(this._mask,a),this.texture.valid){var e=this.texture.baseTexture.resolution/a.resolution;a.context.globalAlpha=this.worldAlpha,a.smoothProperty&&a.scaleMode!==this.texture.baseTexture.scaleMode&&(a.scaleMode=this.texture.baseTexture.scaleMode,a.context[a.smoothProperty]=a.scaleMode===b.scaleModes.LINEAR);var f=this.texture.trim?this.texture.trim.x-this.anchor.x*this.texture.trim.width:this.anchor.x*-this.texture.frame.width,g=this.texture.trim?this.texture.trim.y-this.anchor.y*this.texture.trim.height:this.anchor.y*-this.texture.frame.height;a.roundPixels?(a.context.setTransform(d.a,d.b,d.c,d.d,d.tx*a.resolution|0,d.ty*a.resolution|0),f|=0,g|=0):a.context.setTransform(d.a,d.b,d.c,d.d,d.tx*a.resolution,d.ty*a.resolution);var h=this.texture.crop.width,i=this.texture.crop.height;if(f/=e,g/=e,16777215!==this.tint)(this.texture.requiresReTint||this.cachedTint!==this.tint)&&(this.tintedTexture=b.CanvasTinter.getTintedTexture(this,this.tint),this.cachedTint=this.tint),a.context.drawImage(this.tintedTexture,0,0,h,i,f,g,h/e,i/e);else{var j=this.texture.crop.x,k=this.texture.crop.y;a.context.drawImage(this.texture.baseTexture.source,j,k,h,i,f,g,h/e,i/e)}}for(var l=0;l<this.children.length;l++)this.children[l]._renderCanvas(a);this._mask&&a.maskManager.popMask(a)}},b.Sprite.fromFrame=function(a){var c=b.TextureCache[a];if(!c)throw new Error('The frameId "'+a+'" does not exist in the texture cache'+this);return new b.Sprite(c)},b.Sprite.fromImage=function(a,c,d){var e=b.Texture.fromImage(a,c,d);return new b.Sprite(e)},b.SpriteBatch=function(a){b.DisplayObjectContainer.call(this),this.textureThing=a,this.ready=!1},b.SpriteBatch.prototype=Object.create(b.DisplayObjectContainer.prototype),b.SpriteBatch.prototype.constructor=b.SpriteBatch,b.SpriteBatch.prototype.initWebGL=function(a){this.fastSpriteBatch=new b.WebGLFastSpriteBatch(a),this.ready=!0},b.SpriteBatch.prototype.updateTransform=function(){this.displayObjectUpdateTransform()},b.SpriteBatch.prototype._renderWebGL=function(a){!this.visible||this.alpha<=0||!this.children.length||(this.ready||this.initWebGL(a.gl),this.fastSpriteBatch.gl!==a.gl&&this.fastSpriteBatch.setContext(a.gl),a.spriteBatch.stop(),a.shaderManager.setShader(a.shaderManager.fastShader),this.fastSpriteBatch.begin(this,a),this.fastSpriteBatch.render(this),a.spriteBatch.start())},b.SpriteBatch.prototype._renderCanvas=function(a){if(this.visible&&!(this.alpha<=0)&&this.children.length){var b=a.context;b.globalAlpha=this.worldAlpha,this.displayObjectUpdateTransform();for(var c=this.worldTransform,d=!0,e=0;e<this.children.length;e++){var f=this.children[e];if(f.visible){var g=f.texture,h=g.frame;if(b.globalAlpha=this.worldAlpha*f.alpha,f.rotation%(2*Math.PI)===0)d&&(b.setTransform(c.a,c.b,c.c,c.d,c.tx,c.ty),d=!1),b.drawImage(g.baseTexture.source,h.x,h.y,h.width,h.height,f.anchor.x*(-h.width*f.scale.x)+f.position.x+.5|0,f.anchor.y*(-h.height*f.scale.y)+f.position.y+.5|0,h.width*f.scale.x,h.height*f.scale.y);else{d||(d=!0),f.displayObjectUpdateTransform();var i=f.worldTransform;a.roundPixels?b.setTransform(i.a,i.b,i.c,i.d,0|i.tx,0|i.ty):b.setTransform(i.a,i.b,i.c,i.d,i.tx,i.ty),b.drawImage(g.baseTexture.source,h.x,h.y,h.width,h.height,f.anchor.x*-h.width+.5|0,f.anchor.y*-h.height+.5|0,h.width,h.height)}}}}},b.hex2rgb=function(a){return[(a>>16&255)/255,(a>>8&255)/255,(255&a)/255]},b.rgb2hex=function(a){return(255*a[0]<<16)+(255*a[1]<<8)+255*a[2]},b.canUseNewCanvasBlendModes=function(){if(void 0===document)return!1;var a="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/",c="AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==",d=new Image;d.src=a+"AP804Oa6"+c;var e=new Image;e.src=a+"/wCKxvRF"+c;var f=b.CanvasPool.create(this,6,1),g=f.getContext("2d");if(g.globalCompositeOperation="multiply",g.drawImage(d,0,0),g.drawImage(e,2,0),!g.getImageData(2,0,1,1))return!1;var h=g.getImageData(2,0,1,1).data;return b.CanvasPool.remove(this),255===h[0]&&0===h[1]&&0===h[2]},b.getNextPowerOfTwo=function(a){if(a>0&&0===(a&a-1))return a;for(var b=1;a>b;)b<<=1;return b},b.isPowerOfTwo=function(a,b){return a>0&&0===(a&a-1)&&b>0&&0===(b&b-1)},b.CanvasPool={create:function(a,c,d){var e,f=b.CanvasPool.getFirst();if(-1===f){var g={parent:a,canvas:document.createElement("canvas")};b.CanvasPool.pool.push(g),e=g.canvas}else b.CanvasPool.pool[f].parent=a,e=b.CanvasPool.pool[f].canvas;return void 0!==c&&(e.width=c,e.height=d),e},getFirst:function(){for(var a=b.CanvasPool.pool,c=0;c<a.length;c++)if(null===a[c].parent)return c;return-1},remove:function(a){for(var c=b.CanvasPool.pool,d=0;d<c.length;d++)c[d].parent===a&&(c[d].parent=null)},removeByCanvas:function(a){for(var c=b.CanvasPool.pool,d=0;d<c.length;d++)c[d].canvas===a&&(c[d].parent=null)},getTotal:function(){for(var a=b.CanvasPool.pool,c=0,d=0;d<a.length;d++)null!==a[d].parent&&c++;return c},getFree:function(){for(var a=b.CanvasPool.pool,c=0,d=0;d<a.length;d++)null===a[d].parent&&c++;return c}},b.CanvasPool.pool=[],b.initDefaultShaders=function(){},b.CompileVertexShader=function(a,c){return b._CompileShader(a,c,a.VERTEX_SHADER)},b.CompileFragmentShader=function(a,c){return b._CompileShader(a,c,a.FRAGMENT_SHADER)},b._CompileShader=function(a,b,c){var d=b;Array.isArray(b)&&(d=b.join("\n"));var e=a.createShader(c);return a.shaderSource(e,d),a.compileShader(e),a.getShaderParameter(e,a.COMPILE_STATUS)?e:(window.console.log(a.getShaderInfoLog(e)),null)},b.compileProgram=function(a,c,d){var e=b.CompileFragmentShader(a,d),f=b.CompileVertexShader(a,c),g=a.createProgram();return a.attachShader(g,f),a.attachShader(g,e),a.linkProgram(g),a.getProgramParameter(g,a.LINK_STATUS)||window.console.log("Could not initialise shaders"),g},b.PixiShader=function(a){this._UID=b._UID++,this.gl=a,this.program=null,this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"],this.textureCount=0,this.firstRun=!0,this.dirty=!0,this.attributes=[],this.init()},b.PixiShader.prototype.constructor=b.PixiShader,b.PixiShader.prototype.init=function(){var a=this.gl,c=b.compileProgram(a,this.vertexSrc||b.PixiShader.defaultVertexSrc,this.fragmentSrc);a.useProgram(c),this.uSampler=a.getUniformLocation(c,"uSampler"),this.projectionVector=a.getUniformLocation(c,"projectionVector"),this.offsetVector=a.getUniformLocation(c,"offsetVector"),this.dimensions=a.getUniformLocation(c,"dimensions"),this.aVertexPosition=a.getAttribLocation(c,"aVertexPosition"),this.aTextureCoord=a.getAttribLocation(c,"aTextureCoord"),this.colorAttribute=a.getAttribLocation(c,"aColor"),-1===this.colorAttribute&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aTextureCoord,this.colorAttribute];for(var d in this.uniforms)this.uniforms[d].uniformLocation=a.getUniformLocation(c,d);this.initUniforms(),this.program=c},b.PixiShader.prototype.initUniforms=function(){this.textureCount=1;var a,b=this.gl;for(var c in this.uniforms){a=this.uniforms[c];var d=a.type;"sampler2D"===d?(a._init=!1,null!==a.value&&this.initSampler2D(a)):"mat2"===d||"mat3"===d||"mat4"===d?(a.glMatrix=!0,a.glValueLength=1,"mat2"===d?a.glFunc=b.uniformMatrix2fv:"mat3"===d?a.glFunc=b.uniformMatrix3fv:"mat4"===d&&(a.glFunc=b.uniformMatrix4fv)):(a.glFunc=b["uniform"+d],"2f"===d||"2i"===d?a.glValueLength=2:"3f"===d||"3i"===d?a.glValueLength=3:"4f"===d||"4i"===d?a.glValueLength=4:a.glValueLength=1)}},b.PixiShader.prototype.initSampler2D=function(a){if(a.value&&a.value.baseTexture&&a.value.baseTexture.hasLoaded){var b=this.gl;if(b.activeTexture(b["TEXTURE"+this.textureCount]),b.bindTexture(b.TEXTURE_2D,a.value.baseTexture._glTextures[b.id]),a.textureData){var c=a.textureData,d=c.magFilter?c.magFilter:b.LINEAR,e=c.minFilter?c.minFilter:b.LINEAR,f=c.wrapS?c.wrapS:b.CLAMP_TO_EDGE,g=c.wrapT?c.wrapT:b.CLAMP_TO_EDGE,h=c.luminance?b.LUMINANCE:b.RGBA;if(c.repeat&&(f=b.REPEAT,g=b.REPEAT),b.pixelStorei(b.UNPACK_FLIP_Y_WEBGL,!!c.flipY),c.width){var i=c.width?c.width:512,j=c.height?c.height:2,k=c.border?c.border:0;b.texImage2D(b.TEXTURE_2D,0,h,i,j,k,h,b.UNSIGNED_BYTE,null)}else b.texImage2D(b.TEXTURE_2D,0,h,b.RGBA,b.UNSIGNED_BYTE,a.value.baseTexture.source);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,d),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,e),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,f),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,g)}b.uniform1i(a.uniformLocation,this.textureCount),a._init=!0,this.textureCount++}},b.PixiShader.prototype.syncUniforms=function(){this.textureCount=1;var a,c=this.gl;for(var d in this.uniforms)a=this.uniforms[d],1===a.glValueLength?a.glMatrix===!0?a.glFunc.call(c,a.uniformLocation,a.transpose,a.value):a.glFunc.call(c,a.uniformLocation,a.value):2===a.glValueLength?a.glFunc.call(c,a.uniformLocation,a.value.x,a.value.y):3===a.glValueLength?a.glFunc.call(c,a.uniformLocation,a.value.x,a.value.y,a.value.z):4===a.glValueLength?a.glFunc.call(c,a.uniformLocation,a.value.x,a.value.y,a.value.z,a.value.w):"sampler2D"===a.type&&(a._init?(c.activeTexture(c["TEXTURE"+this.textureCount]),a.value.baseTexture._dirty[c.id]?b.instances[c.id].updateTexture(a.value.baseTexture):c.bindTexture(c.TEXTURE_2D,a.value.baseTexture._glTextures[c.id]),c.uniform1i(a.uniformLocation,this.textureCount),this.textureCount++):this.initSampler2D(a))},b.PixiShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},b.PixiShader.defaultVertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute vec4 aColor;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","varying vec4 vColor;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {"," gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = vec4(aColor.rgb * aColor.a, aColor.a);","}"],b.PixiFastShader=function(a){this._UID=b._UID++,this.gl=a,this.program=null,this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aPositionCoord;","attribute vec2 aScale;","attribute float aRotation;","attribute vec2 aTextureCoord;","attribute float aColor;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform mat3 uMatrix;","varying vec2 vTextureCoord;","varying float vColor;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {"," vec2 v;"," vec2 sv = aVertexPosition * aScale;"," v.x = (sv.x) * cos(aRotation) - (sv.y) * sin(aRotation);"," v.y = (sv.x) * sin(aRotation) + (sv.y) * cos(aRotation);"," v = ( uMatrix * vec3(v + aPositionCoord , 1.0) ).xy ;"," gl_Position = vec4( ( v / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = aColor;","}"],this.textureCount=0,this.init()},b.PixiFastShader.prototype.constructor=b.PixiFastShader,b.PixiFastShader.prototype.init=function(){var a=this.gl,c=b.compileProgram(a,this.vertexSrc,this.fragmentSrc);a.useProgram(c),this.uSampler=a.getUniformLocation(c,"uSampler"),this.projectionVector=a.getUniformLocation(c,"projectionVector"),this.offsetVector=a.getUniformLocation(c,"offsetVector"),this.dimensions=a.getUniformLocation(c,"dimensions"),this.uMatrix=a.getUniformLocation(c,"uMatrix"),this.aVertexPosition=a.getAttribLocation(c,"aVertexPosition"),this.aPositionCoord=a.getAttribLocation(c,"aPositionCoord"),this.aScale=a.getAttribLocation(c,"aScale"),this.aRotation=a.getAttribLocation(c,"aRotation"),this.aTextureCoord=a.getAttribLocation(c,"aTextureCoord"),this.colorAttribute=a.getAttribLocation(c,"aColor"),-1===this.colorAttribute&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aPositionCoord,this.aScale,this.aRotation,this.aTextureCoord,this.colorAttribute],this.program=c},b.PixiFastShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},b.StripShader=function(a){this._UID=b._UID++,this.gl=a,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","uniform float alpha;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * alpha;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);"," vTextureCoord = aTextureCoord;","}"],this.init()},b.StripShader.prototype.constructor=b.StripShader,b.StripShader.prototype.init=function(){var a=this.gl,c=b.compileProgram(a,this.vertexSrc,this.fragmentSrc);a.useProgram(c),this.uSampler=a.getUniformLocation(c,"uSampler"),this.projectionVector=a.getUniformLocation(c,"projectionVector"),this.offsetVector=a.getUniformLocation(c,"offsetVector"),this.colorAttribute=a.getAttribLocation(c,"aColor"),this.aVertexPosition=a.getAttribLocation(c,"aVertexPosition"),this.aTextureCoord=a.getAttribLocation(c,"aTextureCoord"),this.attributes=[this.aVertexPosition,this.aTextureCoord],this.translationMatrix=a.getUniformLocation(c,"translationMatrix"),this.alpha=a.getUniformLocation(c,"alpha"),this.program=c},b.StripShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attribute=null},b.PrimitiveShader=function(a){this._UID=b._UID++,this.gl=a,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {"," gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec4 aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform float alpha;","uniform float flipY;","uniform vec3 tint;","varying vec4 vColor;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);"," vColor = aColor * vec4(tint * alpha, alpha);","}"],this.init()},b.PrimitiveShader.prototype.constructor=b.PrimitiveShader,b.PrimitiveShader.prototype.init=function(){var a=this.gl,c=b.compileProgram(a,this.vertexSrc,this.fragmentSrc);a.useProgram(c),this.projectionVector=a.getUniformLocation(c,"projectionVector"),this.offsetVector=a.getUniformLocation(c,"offsetVector"),this.tintColor=a.getUniformLocation(c,"tint"),this.flipY=a.getUniformLocation(c,"flipY"),this.aVertexPosition=a.getAttribLocation(c,"aVertexPosition"),this.colorAttribute=a.getAttribLocation(c,"aColor"),this.attributes=[this.aVertexPosition,this.colorAttribute],this.translationMatrix=a.getUniformLocation(c,"translationMatrix"),this.alpha=a.getUniformLocation(c,"alpha"),this.program=c},b.PrimitiveShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},b.ComplexPrimitiveShader=function(a){this._UID=b._UID++,this.gl=a,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {"," gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform vec3 tint;","uniform float alpha;","uniform vec3 color;","uniform float flipY;","varying vec4 vColor;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);"," vColor = vec4(color * alpha * tint, alpha);","}"],this.init()},b.ComplexPrimitiveShader.prototype.constructor=b.ComplexPrimitiveShader,b.ComplexPrimitiveShader.prototype.init=function(){var a=this.gl,c=b.compileProgram(a,this.vertexSrc,this.fragmentSrc);a.useProgram(c),this.projectionVector=a.getUniformLocation(c,"projectionVector"),this.offsetVector=a.getUniformLocation(c,"offsetVector"),this.tintColor=a.getUniformLocation(c,"tint"),this.color=a.getUniformLocation(c,"color"),this.flipY=a.getUniformLocation(c,"flipY"),this.aVertexPosition=a.getAttribLocation(c,"aVertexPosition"),this.attributes=[this.aVertexPosition,this.colorAttribute],this.translationMatrix=a.getUniformLocation(c,"translationMatrix"),this.alpha=a.getUniformLocation(c,"alpha"),this.program=c},b.ComplexPrimitiveShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attribute=null},b.glContexts=[],b.instances=[],b.WebGLRenderer=function(a){this.game=a,b.defaultRenderer||(b.defaultRenderer=this),this.type=b.WEBGL_RENDERER,this.resolution=a.resolution,this.transparent=a.transparent,this.autoResize=!1,this.preserveDrawingBuffer=a.preserveDrawingBuffer,this.clearBeforeRender=a.clearBeforeRender,this.width=a.width,this.height=a.height,this.view=a.canvas,this._contextOptions={alpha:this.transparent,antialias:a.antialias,premultipliedAlpha:this.transparent&&"notMultiplied"!==this.transparent,stencil:!0,preserveDrawingBuffer:this.preserveDrawingBuffer},this.projection=new b.Point,this.offset=new b.Point,this.shaderManager=new b.WebGLShaderManager,this.spriteBatch=new b.WebGLSpriteBatch,this.maskManager=new b.WebGLMaskManager,this.filterManager=new b.WebGLFilterManager,this.stencilManager=new b.WebGLStencilManager,this.blendModeManager=new b.WebGLBlendModeManager,this.renderSession={},this.renderSession.game=this.game,this.renderSession.gl=this.gl,this.renderSession.drawCount=0,this.renderSession.shaderManager=this.shaderManager,this.renderSession.maskManager=this.maskManager,this.renderSession.filterManager=this.filterManager,this.renderSession.blendModeManager=this.blendModeManager,this.renderSession.spriteBatch=this.spriteBatch,this.renderSession.stencilManager=this.stencilManager,this.renderSession.renderer=this,this.renderSession.resolution=this.resolution,this.initContext(),this.mapBlendModes()},b.WebGLRenderer.prototype.constructor=b.WebGLRenderer,b.WebGLRenderer.prototype.initContext=function(){var a=this.view.getContext("webgl",this._contextOptions)||this.view.getContext("experimental-webgl",this._contextOptions);if(this.gl=a,!a)throw new Error("This browser does not support webGL. Try using the canvas renderer");this.glContextId=a.id=b.WebGLRenderer.glContextId++,b.glContexts[this.glContextId]=a,b.instances[this.glContextId]=this,a.disable(a.DEPTH_TEST),a.disable(a.CULL_FACE),a.enable(a.BLEND),this.shaderManager.setContext(a),this.spriteBatch.setContext(a),this.maskManager.setContext(a),this.filterManager.setContext(a),this.blendModeManager.setContext(a),this.stencilManager.setContext(a),this.renderSession.gl=this.gl,this.resize(this.width,this.height)},b.WebGLRenderer.prototype.render=function(a){if(!this.contextLost){a.updateTransform();var b=this.gl;b.viewport(0,0,this.width,this.height),b.bindFramebuffer(b.FRAMEBUFFER,null),this.game.clearBeforeRender&&(b.clearColor(a._bgColor.r,a._bgColor.g,a._bgColor.b,a._bgColor.a),b.clear(b.COLOR_BUFFER_BIT)),this.renderDisplayObject(a,this.projection)}},b.WebGLRenderer.prototype.renderDisplayObject=function(a,c,d,e){this.renderSession.blendModeManager.setBlendMode(b.blendModes.NORMAL),this.renderSession.drawCount=0,this.renderSession.flipY=d?-1:1,this.renderSession.projection=c,this.renderSession.offset=this.offset,this.spriteBatch.begin(this.renderSession),this.filterManager.begin(this.renderSession,d),a._renderWebGL(this.renderSession,e),this.spriteBatch.end()},b.WebGLRenderer.prototype.resize=function(a,b){this.width=a*this.resolution,this.height=b*this.resolution,this.view.width=this.width,this.view.height=this.height,this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px"),this.gl.viewport(0,0,this.width,this.height),this.projection.x=this.width/2/this.resolution,this.projection.y=-this.height/2/this.resolution},b.WebGLRenderer.prototype.updateTexture=function(a){if(!a.hasLoaded)return!1;var c=this.gl;return a._glTextures[c.id]||(a._glTextures[c.id]=c.createTexture()),c.bindTexture(c.TEXTURE_2D,a._glTextures[c.id]),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultipliedAlpha),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,a.source),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,a.scaleMode===b.scaleModes.LINEAR?c.LINEAR:c.NEAREST),a.mipmap&&b.isPowerOfTwo(a.width,a.height)?(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,a.scaleMode===b.scaleModes.LINEAR?c.LINEAR_MIPMAP_LINEAR:c.NEAREST_MIPMAP_NEAREST),c.generateMipmap(c.TEXTURE_2D)):c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,a.scaleMode===b.scaleModes.LINEAR?c.LINEAR:c.NEAREST),a._powerOf2?(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.REPEAT),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.REPEAT)):(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE)),a._dirty[c.id]=!1,!0},b.WebGLRenderer.prototype.destroy=function(){b.glContexts[this.glContextId]=null,this.projection=null,this.offset=null,this.shaderManager.destroy(),this.spriteBatch.destroy(),this.maskManager.destroy(),this.filterManager.destroy(),this.shaderManager=null,this.spriteBatch=null,this.maskManager=null,this.filterManager=null,this.gl=null,this.renderSession=null,b.CanvasPool.remove(this),b.instances[this.glContextId]=null,b.WebGLRenderer.glContextId--},b.WebGLRenderer.prototype.mapBlendModes=function(){var a=this.gl;if(!b.blendModesWebGL){var c=[],d=b.blendModes;c[d.NORMAL]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.ADD]=[a.SRC_ALPHA,a.DST_ALPHA],c[d.MULTIPLY]=[a.DST_COLOR,a.ONE_MINUS_SRC_ALPHA],c[d.SCREEN]=[a.SRC_ALPHA,a.ONE],c[d.OVERLAY]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.DARKEN]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.LIGHTEN]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.COLOR_DODGE]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.COLOR_BURN]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.HARD_LIGHT]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.SOFT_LIGHT]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.DIFFERENCE]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.EXCLUSION]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.HUE]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.SATURATION]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.COLOR]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.LUMINOSITY]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL=c}},b.WebGLRenderer.glContextId=0,b.WebGLBlendModeManager=function(){this.currentBlendMode=99999},b.WebGLBlendModeManager.prototype.constructor=b.WebGLBlendModeManager,b.WebGLBlendModeManager.prototype.setContext=function(a){this.gl=a},b.WebGLBlendModeManager.prototype.setBlendMode=function(a){if(this.currentBlendMode===a)return!1;this.currentBlendMode=a;var c=b.blendModesWebGL[this.currentBlendMode];return c&&this.gl.blendFunc(c[0],c[1]),!0},b.WebGLBlendModeManager.prototype.destroy=function(){this.gl=null},b.WebGLMaskManager=function(){},b.WebGLMaskManager.prototype.constructor=b.WebGLMaskManager,b.WebGLMaskManager.prototype.setContext=function(a){this.gl=a},b.WebGLMaskManager.prototype.pushMask=function(a,c){var d=c.gl;a.dirty&&b.WebGLGraphics.updateGraphics(a,d),a._webGL[d.id].data.length&&c.stencilManager.pushStencil(a,a._webGL[d.id].data[0],c)},b.WebGLMaskManager.prototype.popMask=function(a,b){var c=this.gl;b.stencilManager.popStencil(a,a._webGL[c.id].data[0],b)},b.WebGLMaskManager.prototype.destroy=function(){this.gl=null},b.WebGLStencilManager=function(){this.stencilStack=[],this.reverse=!0,this.count=0},b.WebGLStencilManager.prototype.setContext=function(a){this.gl=a},b.WebGLStencilManager.prototype.pushStencil=function(a,b,c){var d=this.gl;this.bindGraphics(a,b,c),0===this.stencilStack.length&&(d.enable(d.STENCIL_TEST),d.clear(d.STENCIL_BUFFER_BIT),this.reverse=!0,this.count=0),this.stencilStack.push(b);var e=this.count;d.colorMask(!1,!1,!1,!1),d.stencilFunc(d.ALWAYS,0,255),d.stencilOp(d.KEEP,d.KEEP,d.INVERT),1===b.mode?(d.drawElements(d.TRIANGLE_FAN,b.indices.length-4,d.UNSIGNED_SHORT,0),this.reverse?(d.stencilFunc(d.EQUAL,255-e,255),d.stencilOp(d.KEEP,d.KEEP,d.DECR)):(d.stencilFunc(d.EQUAL,e,255),d.stencilOp(d.KEEP,d.KEEP,d.INCR)),d.drawElements(d.TRIANGLE_FAN,4,d.UNSIGNED_SHORT,2*(b.indices.length-4)),this.reverse?d.stencilFunc(d.EQUAL,255-(e+1),255):d.stencilFunc(d.EQUAL,e+1,255),this.reverse=!this.reverse):(this.reverse?(d.stencilFunc(d.EQUAL,e,255),d.stencilOp(d.KEEP,d.KEEP,d.INCR)):(d.stencilFunc(d.EQUAL,255-e,255),d.stencilOp(d.KEEP,d.KEEP,d.DECR)),d.drawElements(d.TRIANGLE_STRIP,b.indices.length,d.UNSIGNED_SHORT,0),this.reverse?d.stencilFunc(d.EQUAL,e+1,255):d.stencilFunc(d.EQUAL,255-(e+1),255)),d.colorMask(!0,!0,!0,!0),d.stencilOp(d.KEEP,d.KEEP,d.KEEP),this.count++},b.WebGLStencilManager.prototype.bindGraphics=function(a,c,d){this._currentGraphics=a;var e,f=this.gl,g=d.projection,h=d.offset;1===c.mode?(e=d.shaderManager.complexPrimitiveShader,d.shaderManager.setShader(e),f.uniform1f(e.flipY,d.flipY),f.uniformMatrix3fv(e.translationMatrix,!1,a.worldTransform.toArray(!0)),f.uniform2f(e.projectionVector,g.x,-g.y),f.uniform2f(e.offsetVector,-h.x,-h.y),f.uniform3fv(e.tintColor,b.hex2rgb(a.tint)),f.uniform3fv(e.color,c.color),f.uniform1f(e.alpha,a.worldAlpha*c.alpha),f.bindBuffer(f.ARRAY_BUFFER,c.buffer), +f.vertexAttribPointer(e.aVertexPosition,2,f.FLOAT,!1,8,0),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,c.indexBuffer)):(e=d.shaderManager.primitiveShader,d.shaderManager.setShader(e),f.uniformMatrix3fv(e.translationMatrix,!1,a.worldTransform.toArray(!0)),f.uniform1f(e.flipY,d.flipY),f.uniform2f(e.projectionVector,g.x,-g.y),f.uniform2f(e.offsetVector,-h.x,-h.y),f.uniform3fv(e.tintColor,b.hex2rgb(a.tint)),f.uniform1f(e.alpha,a.worldAlpha),f.bindBuffer(f.ARRAY_BUFFER,c.buffer),f.vertexAttribPointer(e.aVertexPosition,2,f.FLOAT,!1,24,0),f.vertexAttribPointer(e.colorAttribute,4,f.FLOAT,!1,24,8),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,c.indexBuffer))},b.WebGLStencilManager.prototype.popStencil=function(a,b,c){var d=this.gl;if(this.stencilStack.pop(),this.count--,0===this.stencilStack.length)d.disable(d.STENCIL_TEST);else{var e=this.count;this.bindGraphics(a,b,c),d.colorMask(!1,!1,!1,!1),1===b.mode?(this.reverse=!this.reverse,this.reverse?(d.stencilFunc(d.EQUAL,255-(e+1),255),d.stencilOp(d.KEEP,d.KEEP,d.INCR)):(d.stencilFunc(d.EQUAL,e+1,255),d.stencilOp(d.KEEP,d.KEEP,d.DECR)),d.drawElements(d.TRIANGLE_FAN,4,d.UNSIGNED_SHORT,2*(b.indices.length-4)),d.stencilFunc(d.ALWAYS,0,255),d.stencilOp(d.KEEP,d.KEEP,d.INVERT),d.drawElements(d.TRIANGLE_FAN,b.indices.length-4,d.UNSIGNED_SHORT,0),this.reverse?d.stencilFunc(d.EQUAL,e,255):d.stencilFunc(d.EQUAL,255-e,255)):(this.reverse?(d.stencilFunc(d.EQUAL,e+1,255),d.stencilOp(d.KEEP,d.KEEP,d.DECR)):(d.stencilFunc(d.EQUAL,255-(e+1),255),d.stencilOp(d.KEEP,d.KEEP,d.INCR)),d.drawElements(d.TRIANGLE_STRIP,b.indices.length,d.UNSIGNED_SHORT,0),this.reverse?d.stencilFunc(d.EQUAL,e,255):d.stencilFunc(d.EQUAL,255-e,255)),d.colorMask(!0,!0,!0,!0),d.stencilOp(d.KEEP,d.KEEP,d.KEEP)}},b.WebGLStencilManager.prototype.destroy=function(){this.stencilStack=null,this.gl=null},b.WebGLShaderManager=function(){this.maxAttibs=10,this.attribState=[],this.tempAttribState=[];for(var a=0;a<this.maxAttibs;a++)this.attribState[a]=!1;this.stack=[]},b.WebGLShaderManager.prototype.constructor=b.WebGLShaderManager,b.WebGLShaderManager.prototype.setContext=function(a){this.gl=a,this.primitiveShader=new b.PrimitiveShader(a),this.complexPrimitiveShader=new b.ComplexPrimitiveShader(a),this.defaultShader=new b.PixiShader(a),this.fastShader=new b.PixiFastShader(a),this.stripShader=new b.StripShader(a),this.setShader(this.defaultShader)},b.WebGLShaderManager.prototype.setAttribs=function(a){var b;for(b=0;b<this.tempAttribState.length;b++)this.tempAttribState[b]=!1;for(b=0;b<a.length;b++){var c=a[b];this.tempAttribState[c]=!0}var d=this.gl;for(b=0;b<this.attribState.length;b++)this.attribState[b]!==this.tempAttribState[b]&&(this.attribState[b]=this.tempAttribState[b],this.tempAttribState[b]?d.enableVertexAttribArray(b):d.disableVertexAttribArray(b))},b.WebGLShaderManager.prototype.setShader=function(a){return this._currentId===a._UID?!1:(this._currentId=a._UID,this.currentShader=a,this.gl.useProgram(a.program),this.setAttribs(a.attributes),!0)},b.WebGLShaderManager.prototype.destroy=function(){this.attribState=null,this.tempAttribState=null,this.primitiveShader.destroy(),this.complexPrimitiveShader.destroy(),this.defaultShader.destroy(),this.fastShader.destroy(),this.stripShader.destroy(),this.gl=null},b.WebGLSpriteBatch=function(){this.vertSize=5,this.size=2e3;var a=4*this.size*4*this.vertSize,c=6*this.size;this.vertices=new b.ArrayBuffer(a),this.positions=new b.Float32Array(this.vertices),this.colors=new b.Uint32Array(this.vertices),this.indices=new b.Uint16Array(c),this.lastIndexCount=0;for(var d=0,e=0;c>d;d+=6,e+=4)this.indices[d+0]=e+0,this.indices[d+1]=e+1,this.indices[d+2]=e+2,this.indices[d+3]=e+0,this.indices[d+4]=e+2,this.indices[d+5]=e+3;this.drawing=!1,this.currentBatchSize=0,this.currentBaseTexture=null,this.dirty=!0,this.textures=[],this.blendModes=[],this.shaders=[],this.sprites=[],this.defaultShader=new b.AbstractFilter(["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"])},b.WebGLSpriteBatch.prototype.setContext=function(a){this.gl=a,this.vertexBuffer=a.createBuffer(),this.indexBuffer=a.createBuffer(),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,this.indices,a.STATIC_DRAW),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),a.bufferData(a.ARRAY_BUFFER,this.vertices,a.DYNAMIC_DRAW),this.currentBlendMode=99999;var c=new b.PixiShader(a);c.fragmentSrc=this.defaultShader.fragmentSrc,c.uniforms={},c.init(),this.defaultShader.shaders[a.id]=c},b.WebGLSpriteBatch.prototype.begin=function(a){this.renderSession=a,this.shader=this.renderSession.shaderManager.defaultShader,this.start()},b.WebGLSpriteBatch.prototype.end=function(){this.flush()},b.WebGLSpriteBatch.prototype.render=function(a,b){var c=a.texture,d=a.worldTransform;b&&(d=b),this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=c.baseTexture);var e=c._uvs;if(e){var f,g,h,i,j=a.anchor.x,k=a.anchor.y;if(c.trim){var l=c.trim;g=l.x-j*l.width,f=g+c.crop.width,i=l.y-k*l.height,h=i+c.crop.height}else f=c.frame.width*(1-j),g=c.frame.width*-j,h=c.frame.height*(1-k),i=c.frame.height*-k;var m=4*this.currentBatchSize*this.vertSize,n=c.baseTexture.resolution,o=d.a/n,p=d.b/n,q=d.c/n,r=d.d/n,s=d.tx,t=d.ty,u=this.colors,v=this.positions;this.renderSession.roundPixels?(v[m]=o*g+q*i+s|0,v[m+1]=r*i+p*g+t|0,v[m+5]=o*f+q*i+s|0,v[m+6]=r*i+p*f+t|0,v[m+10]=o*f+q*h+s|0,v[m+11]=r*h+p*f+t|0,v[m+15]=o*g+q*h+s|0,v[m+16]=r*h+p*g+t|0):(v[m]=o*g+q*i+s,v[m+1]=r*i+p*g+t,v[m+5]=o*f+q*i+s,v[m+6]=r*i+p*f+t,v[m+10]=o*f+q*h+s,v[m+11]=r*h+p*f+t,v[m+15]=o*g+q*h+s,v[m+16]=r*h+p*g+t),v[m+2]=e.x0,v[m+3]=e.y0,v[m+7]=e.x1,v[m+8]=e.y1,v[m+12]=e.x2,v[m+13]=e.y2,v[m+17]=e.x3,v[m+18]=e.y3;var w=a.tint;u[m+4]=u[m+9]=u[m+14]=u[m+19]=(w>>16)+(65280&w)+((255&w)<<16)+(255*a.worldAlpha<<24),this.sprites[this.currentBatchSize++]=a}},b.WebGLSpriteBatch.prototype.renderTilingSprite=function(a){var c=a.tilingTexture;this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=c.baseTexture),a._uvs||(a._uvs=new b.TextureUvs);var d=a._uvs,e=c.baseTexture.width,f=c.baseTexture.height;a.tilePosition.x%=e*a.tileScaleOffset.x,a.tilePosition.y%=f*a.tileScaleOffset.y;var g=a.tilePosition.x/(e*a.tileScaleOffset.x),h=a.tilePosition.y/(f*a.tileScaleOffset.y),i=a.width/e/(a.tileScale.x*a.tileScaleOffset.x),j=a.height/f/(a.tileScale.y*a.tileScaleOffset.y);d.x0=0-g,d.y0=0-h,d.x1=1*i-g,d.y1=0-h,d.x2=1*i-g,d.y2=1*j-h,d.x3=0-g,d.y3=1*j-h;var k=a.tint,l=(k>>16)+(65280&k)+((255&k)<<16)+(255*a.worldAlpha<<24),m=this.positions,n=this.colors,o=a.width,p=a.height,q=a.anchor.x,r=a.anchor.y,s=o*(1-q),t=o*-q,u=p*(1-r),v=p*-r,w=4*this.currentBatchSize*this.vertSize,x=c.baseTexture.resolution,y=a.worldTransform,z=y.a/x,A=y.b/x,B=y.c/x,C=y.d/x,D=y.tx,E=y.ty;m[w++]=z*t+B*v+D,m[w++]=C*v+A*t+E,m[w++]=d.x0,m[w++]=d.y0,n[w++]=l,m[w++]=z*s+B*v+D,m[w++]=C*v+A*s+E,m[w++]=d.x1,m[w++]=d.y1,n[w++]=l,m[w++]=z*s+B*u+D,m[w++]=C*u+A*s+E,m[w++]=d.x2,m[w++]=d.y2,n[w++]=l,m[w++]=z*t+B*u+D,m[w++]=C*u+A*t+E,m[w++]=d.x3,m[w++]=d.y3,n[w++]=l,this.sprites[this.currentBatchSize++]=a},b.WebGLSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var a,c=this.gl;if(this.dirty){this.dirty=!1,c.activeTexture(c.TEXTURE0),c.bindBuffer(c.ARRAY_BUFFER,this.vertexBuffer),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,this.indexBuffer),a=this.defaultShader.shaders[c.id];var d=4*this.vertSize;c.vertexAttribPointer(a.aVertexPosition,2,c.FLOAT,!1,d,0),c.vertexAttribPointer(a.aTextureCoord,2,c.FLOAT,!1,d,8),c.vertexAttribPointer(a.colorAttribute,4,c.UNSIGNED_BYTE,!0,d,16)}if(this.currentBatchSize>.5*this.size)c.bufferSubData(c.ARRAY_BUFFER,0,this.vertices);else{var e=this.positions.subarray(0,4*this.currentBatchSize*this.vertSize);c.bufferSubData(c.ARRAY_BUFFER,0,e)}for(var f,g,h,i,j=0,k=0,l=null,m=this.renderSession.blendModeManager.currentBlendMode,n=null,o=!1,p=!1,q=0,r=this.currentBatchSize;r>q;q++){if(i=this.sprites[q],f=i.tilingTexture?i.tilingTexture.baseTexture:i.texture.baseTexture,g=i.blendMode,h=i.shader||this.defaultShader,o=m!==g,p=n!==h,(l!==f&&!f.skipRender||o||p)&&(this.renderBatch(l,j,k),k=q,j=0,l=f,o&&(m=g,this.renderSession.blendModeManager.setBlendMode(m)),p)){n=h,a=n.shaders[c.id],a||(a=new b.PixiShader(c),a.fragmentSrc=n.fragmentSrc,a.uniforms=n.uniforms,a.init(),n.shaders[c.id]=a),this.renderSession.shaderManager.setShader(a),a.dirty&&a.syncUniforms();var s=this.renderSession.projection;c.uniform2f(a.projectionVector,s.x,s.y);var t=this.renderSession.offset;c.uniform2f(a.offsetVector,t.x,t.y)}j++}this.renderBatch(l,j,k),this.currentBatchSize=0}},b.WebGLSpriteBatch.prototype.renderBatch=function(a,b,c){if(0!==b){var d=this.gl;if(a._dirty[d.id]){if(!this.renderSession.renderer.updateTexture(a))return}else d.bindTexture(d.TEXTURE_2D,a._glTextures[d.id]);d.drawElements(d.TRIANGLES,6*b,d.UNSIGNED_SHORT,6*c*2),this.renderSession.drawCount++}},b.WebGLSpriteBatch.prototype.stop=function(){this.flush(),this.dirty=!0},b.WebGLSpriteBatch.prototype.start=function(){this.dirty=!0},b.WebGLSpriteBatch.prototype.destroy=function(){this.vertices=null,this.indices=null,this.gl.deleteBuffer(this.vertexBuffer),this.gl.deleteBuffer(this.indexBuffer),this.currentBaseTexture=null,this.gl=null},b.WebGLFastSpriteBatch=function(a){this.vertSize=10,this.maxSize=6e3,this.size=this.maxSize;var c=4*this.size*this.vertSize,d=6*this.maxSize;this.vertices=new b.Float32Array(c),this.indices=new b.Uint16Array(d),this.vertexBuffer=null,this.indexBuffer=null,this.lastIndexCount=0;for(var e=0,f=0;d>e;e+=6,f+=4)this.indices[e+0]=f+0,this.indices[e+1]=f+1,this.indices[e+2]=f+2,this.indices[e+3]=f+0,this.indices[e+4]=f+2,this.indices[e+5]=f+3;this.drawing=!1,this.currentBatchSize=0,this.currentBaseTexture=null,this.currentBlendMode=0,this.renderSession=null,this.shader=null,this.matrix=null,this.setContext(a)},b.WebGLFastSpriteBatch.prototype.constructor=b.WebGLFastSpriteBatch,b.WebGLFastSpriteBatch.prototype.setContext=function(a){this.gl=a,this.vertexBuffer=a.createBuffer(),this.indexBuffer=a.createBuffer(),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,this.indices,a.STATIC_DRAW),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),a.bufferData(a.ARRAY_BUFFER,this.vertices,a.DYNAMIC_DRAW)},b.WebGLFastSpriteBatch.prototype.begin=function(a,b){this.renderSession=b,this.shader=this.renderSession.shaderManager.fastShader,this.matrix=a.worldTransform.toArray(!0),this.start()},b.WebGLFastSpriteBatch.prototype.end=function(){this.flush()},b.WebGLFastSpriteBatch.prototype.render=function(a){var b=a.children,c=b[0];if(c.texture._uvs){this.currentBaseTexture=c.texture.baseTexture,c.blendMode!==this.renderSession.blendModeManager.currentBlendMode&&(this.flush(),this.renderSession.blendModeManager.setBlendMode(c.blendMode));for(var d=0,e=b.length;e>d;d++)this.renderSprite(b[d]);this.flush()}},b.WebGLFastSpriteBatch.prototype.renderSprite=function(a){if(a.visible&&(a.texture.baseTexture===this.currentBaseTexture||a.texture.baseTexture.skipRender||(this.flush(),this.currentBaseTexture=a.texture.baseTexture,a.texture._uvs))){var b,c,d,e,f,g,h,i,j=this.vertices;if(b=a.texture._uvs,c=a.texture.frame.width,d=a.texture.frame.height,a.texture.trim){var k=a.texture.trim;f=k.x-a.anchor.x*k.width,e=f+a.texture.crop.width,h=k.y-a.anchor.y*k.height,g=h+a.texture.crop.height}else e=a.texture.frame.width*(1-a.anchor.x),f=a.texture.frame.width*-a.anchor.x,g=a.texture.frame.height*(1-a.anchor.y),h=a.texture.frame.height*-a.anchor.y;i=4*this.currentBatchSize*this.vertSize,j[i++]=f,j[i++]=h,j[i++]=a.position.x,j[i++]=a.position.y,j[i++]=a.scale.x,j[i++]=a.scale.y,j[i++]=a.rotation,j[i++]=b.x0,j[i++]=b.y1,j[i++]=a.alpha,j[i++]=e,j[i++]=h,j[i++]=a.position.x,j[i++]=a.position.y,j[i++]=a.scale.x,j[i++]=a.scale.y,j[i++]=a.rotation,j[i++]=b.x1,j[i++]=b.y1,j[i++]=a.alpha,j[i++]=e,j[i++]=g,j[i++]=a.position.x,j[i++]=a.position.y,j[i++]=a.scale.x,j[i++]=a.scale.y,j[i++]=a.rotation,j[i++]=b.x2,j[i++]=b.y2,j[i++]=a.alpha,j[i++]=f,j[i++]=g,j[i++]=a.position.x,j[i++]=a.position.y,j[i++]=a.scale.x,j[i++]=a.scale.y,j[i++]=a.rotation,j[i++]=b.x3,j[i++]=b.y3,j[i++]=a.alpha,this.currentBatchSize++,this.currentBatchSize>=this.size&&this.flush()}},b.WebGLFastSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var a=this.gl;if(this.currentBaseTexture._glTextures[a.id]||this.renderSession.renderer.updateTexture(this.currentBaseTexture,a),a.bindTexture(a.TEXTURE_2D,this.currentBaseTexture._glTextures[a.id]),this.currentBatchSize>.5*this.size)a.bufferSubData(a.ARRAY_BUFFER,0,this.vertices);else{var b=this.vertices.subarray(0,4*this.currentBatchSize*this.vertSize);a.bufferSubData(a.ARRAY_BUFFER,0,b)}a.drawElements(a.TRIANGLES,6*this.currentBatchSize,a.UNSIGNED_SHORT,0),this.currentBatchSize=0,this.renderSession.drawCount++}},b.WebGLFastSpriteBatch.prototype.stop=function(){this.flush()},b.WebGLFastSpriteBatch.prototype.start=function(){var a=this.gl;a.activeTexture(a.TEXTURE0),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var b=this.renderSession.projection;a.uniform2f(this.shader.projectionVector,b.x,b.y),a.uniformMatrix3fv(this.shader.uMatrix,!1,this.matrix);var c=4*this.vertSize;a.vertexAttribPointer(this.shader.aVertexPosition,2,a.FLOAT,!1,c,0),a.vertexAttribPointer(this.shader.aPositionCoord,2,a.FLOAT,!1,c,8),a.vertexAttribPointer(this.shader.aScale,2,a.FLOAT,!1,c,16),a.vertexAttribPointer(this.shader.aRotation,1,a.FLOAT,!1,c,24),a.vertexAttribPointer(this.shader.aTextureCoord,2,a.FLOAT,!1,c,28),a.vertexAttribPointer(this.shader.colorAttribute,1,a.FLOAT,!1,c,36)},b.WebGLFilterManager=function(){this.filterStack=[],this.offsetX=0,this.offsetY=0},b.WebGLFilterManager.prototype.constructor=b.WebGLFilterManager,b.WebGLFilterManager.prototype.setContext=function(a){this.gl=a,this.texturePool=[],this.initShaderBuffers()},b.WebGLFilterManager.prototype.begin=function(a,b){this.renderSession=a,this.defaultShader=a.shaderManager.defaultShader;var c=this.renderSession.projection;this.width=2*c.x,this.height=2*-c.y,this.buffer=b},b.WebGLFilterManager.prototype.pushFilter=function(a){var c=this.gl,d=this.renderSession.projection,e=this.renderSession.offset;a._filterArea=a.target.filterArea||a.target.getBounds(),this.filterStack.push(a);var f=a.filterPasses[0];this.offsetX+=a._filterArea.x,this.offsetY+=a._filterArea.y;var g=this.texturePool.pop();g?g.resize(this.width,this.height):g=new b.FilterTexture(this.gl,this.width,this.height),c.bindTexture(c.TEXTURE_2D,g.texture);var h=a._filterArea,i=f.padding;h.x-=i,h.y-=i,h.width+=2*i,h.height+=2*i,h.x<0&&(h.x=0),h.width>this.width&&(h.width=this.width),h.y<0&&(h.y=0),h.height>this.height&&(h.height=this.height),c.bindFramebuffer(c.FRAMEBUFFER,g.frameBuffer),c.viewport(0,0,h.width,h.height),d.x=h.width/2,d.y=-h.height/2,e.x=-h.x,e.y=-h.y,c.colorMask(!0,!0,!0,!0),c.clearColor(0,0,0,0),c.clear(c.COLOR_BUFFER_BIT),a._glFilterTexture=g},b.WebGLFilterManager.prototype.popFilter=function(){var a=this.gl,c=this.filterStack.pop(),d=c._filterArea,e=c._glFilterTexture,f=this.renderSession.projection,g=this.renderSession.offset;if(c.filterPasses.length>1){a.viewport(0,0,d.width,d.height),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=0,this.vertexArray[1]=d.height,this.vertexArray[2]=d.width,this.vertexArray[3]=d.height,this.vertexArray[4]=0,this.vertexArray[5]=0,this.vertexArray[6]=d.width,this.vertexArray[7]=0,a.bufferSubData(a.ARRAY_BUFFER,0,this.vertexArray),a.bindBuffer(a.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=d.width/this.width,this.uvArray[5]=d.height/this.height,this.uvArray[6]=d.width/this.width,this.uvArray[7]=d.height/this.height,a.bufferSubData(a.ARRAY_BUFFER,0,this.uvArray);var h=e,i=this.texturePool.pop();i||(i=new b.FilterTexture(this.gl,this.width,this.height)),i.resize(this.width,this.height),a.bindFramebuffer(a.FRAMEBUFFER,i.frameBuffer),a.clear(a.COLOR_BUFFER_BIT),a.disable(a.BLEND);for(var j=0;j<c.filterPasses.length-1;j++){var k=c.filterPasses[j];a.bindFramebuffer(a.FRAMEBUFFER,i.frameBuffer),a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,h.texture),this.applyFilterPass(k,d,d.width,d.height);var l=h;h=i,i=l}a.enable(a.BLEND),e=h,this.texturePool.push(i)}var m=c.filterPasses[c.filterPasses.length-1];this.offsetX-=d.x,this.offsetY-=d.y;var n=this.width,o=this.height,p=0,q=0,r=this.buffer;if(0===this.filterStack.length)a.colorMask(!0,!0,!0,!0);else{var s=this.filterStack[this.filterStack.length-1];d=s._filterArea,n=d.width,o=d.height,p=d.x,q=d.y,r=s._glFilterTexture.frameBuffer}f.x=n/2,f.y=-o/2,g.x=p,g.y=q,d=c._filterArea;var t=d.x-p,u=d.y-q;a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=t,this.vertexArray[1]=u+d.height,this.vertexArray[2]=t+d.width,this.vertexArray[3]=u+d.height,this.vertexArray[4]=t,this.vertexArray[5]=u,this.vertexArray[6]=t+d.width,this.vertexArray[7]=u,a.bufferSubData(a.ARRAY_BUFFER,0,this.vertexArray),a.bindBuffer(a.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=d.width/this.width,this.uvArray[5]=d.height/this.height,this.uvArray[6]=d.width/this.width,this.uvArray[7]=d.height/this.height,a.bufferSubData(a.ARRAY_BUFFER,0,this.uvArray),a.viewport(0,0,n*this.renderSession.resolution,o*this.renderSession.resolution),a.bindFramebuffer(a.FRAMEBUFFER,r),a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,e.texture),this.applyFilterPass(m,d,n,o),this.texturePool.push(e),c._glFilterTexture=null},b.WebGLFilterManager.prototype.applyFilterPass=function(a,c,d,e){var f=this.gl,g=a.shaders[f.id];g||(g=new b.PixiShader(f),g.fragmentSrc=a.fragmentSrc,g.uniforms=a.uniforms,g.init(),a.shaders[f.id]=g),this.renderSession.shaderManager.setShader(g),f.uniform2f(g.projectionVector,d/2,-e/2),f.uniform2f(g.offsetVector,0,0),a.uniforms.dimensions&&(a.uniforms.dimensions.value[0]=this.width,a.uniforms.dimensions.value[1]=this.height,a.uniforms.dimensions.value[2]=this.vertexArray[0],a.uniforms.dimensions.value[3]=this.vertexArray[5]),g.syncUniforms(),f.bindBuffer(f.ARRAY_BUFFER,this.vertexBuffer),f.vertexAttribPointer(g.aVertexPosition,2,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,this.uvBuffer),f.vertexAttribPointer(g.aTextureCoord,2,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,this.colorBuffer),f.vertexAttribPointer(g.colorAttribute,2,f.FLOAT,!1,0,0),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,this.indexBuffer),f.drawElements(f.TRIANGLES,6,f.UNSIGNED_SHORT,0),this.renderSession.drawCount++},b.WebGLFilterManager.prototype.initShaderBuffers=function(){var a=this.gl;this.vertexBuffer=a.createBuffer(),this.uvBuffer=a.createBuffer(),this.colorBuffer=a.createBuffer(),this.indexBuffer=a.createBuffer(),this.vertexArray=new b.Float32Array([0,0,1,0,0,1,1,1]),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),a.bufferData(a.ARRAY_BUFFER,this.vertexArray,a.STATIC_DRAW),this.uvArray=new b.Float32Array([0,0,1,0,0,1,1,1]),a.bindBuffer(a.ARRAY_BUFFER,this.uvBuffer),a.bufferData(a.ARRAY_BUFFER,this.uvArray,a.STATIC_DRAW),this.colorArray=new b.Float32Array([1,16777215,1,16777215,1,16777215,1,16777215]),a.bindBuffer(a.ARRAY_BUFFER,this.colorBuffer),a.bufferData(a.ARRAY_BUFFER,this.colorArray,a.STATIC_DRAW),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,new Uint16Array([0,1,2,1,3,2]),a.STATIC_DRAW)},b.WebGLFilterManager.prototype.destroy=function(){var a=this.gl;this.filterStack=null,this.offsetX=0,this.offsetY=0;for(var b=0;b<this.texturePool.length;b++)this.texturePool[b].destroy();this.texturePool=null,a.deleteBuffer(this.vertexBuffer),a.deleteBuffer(this.uvBuffer),a.deleteBuffer(this.colorBuffer),a.deleteBuffer(this.indexBuffer)},b.FilterTexture=function(a,c,d,e){this.gl=a,this.frameBuffer=a.createFramebuffer(),this.texture=a.createTexture(),e=e||b.scaleModes.DEFAULT,a.bindTexture(a.TEXTURE_2D,this.texture),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,e===b.scaleModes.LINEAR?a.LINEAR:a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,e===b.scaleModes.LINEAR?a.LINEAR:a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.bindFramebuffer(a.FRAMEBUFFER,this.frameBuffer),a.bindFramebuffer(a.FRAMEBUFFER,this.frameBuffer),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,this.texture,0),this.renderBuffer=a.createRenderbuffer(),a.bindRenderbuffer(a.RENDERBUFFER,this.renderBuffer),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.DEPTH_STENCIL_ATTACHMENT,a.RENDERBUFFER,this.renderBuffer),this.resize(c,d)},b.FilterTexture.prototype.constructor=b.FilterTexture,b.FilterTexture.prototype.clear=function(){var a=this.gl;a.clearColor(0,0,0,0),a.clear(a.COLOR_BUFFER_BIT)},b.FilterTexture.prototype.resize=function(a,b){if(this.width!==a||this.height!==b){this.width=a,this.height=b;var c=this.gl;c.bindTexture(c.TEXTURE_2D,this.texture),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,a,b,0,c.RGBA,c.UNSIGNED_BYTE,null),c.bindRenderbuffer(c.RENDERBUFFER,this.renderBuffer),c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_STENCIL,a,b)}},b.FilterTexture.prototype.destroy=function(){var a=this.gl;a.deleteFramebuffer(this.frameBuffer),a.deleteTexture(this.texture),this.frameBuffer=null,this.texture=null},b.CanvasBuffer=function(a,c){this.width=a,this.height=c,this.canvas=b.CanvasPool.create(this,this.width,this.height),this.context=this.canvas.getContext("2d"),this.canvas.width=a,this.canvas.height=c},b.CanvasBuffer.prototype.constructor=b.CanvasBuffer,b.CanvasBuffer.prototype.clear=function(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.width,this.height)},b.CanvasBuffer.prototype.resize=function(a,b){this.width=this.canvas.width=a,this.height=this.canvas.height=b},b.CanvasBuffer.prototype.destroy=function(){b.CanvasPool.remove(this)},b.CanvasMaskManager=function(){},b.CanvasMaskManager.prototype.constructor=b.CanvasMaskManager,b.CanvasMaskManager.prototype.pushMask=function(a,c){var d=c.context;d.save();var e=a.alpha,f=a.worldTransform,g=c.resolution;d.setTransform(f.a*g,f.b*g,f.c*g,f.d*g,f.tx*g,f.ty*g),b.CanvasGraphics.renderGraphicsMask(a,d),d.clip(),a.worldAlpha=e},b.CanvasMaskManager.prototype.popMask=function(a){a.context.restore()},b.CanvasTinter=function(){},b.CanvasTinter.getTintedTexture=function(a,c){var d=a.tintedTexture||b.CanvasPool.create(this);return b.CanvasTinter.tintMethod(a.texture,c,d),d},b.CanvasTinter.tintWithMultiply=function(a,b,c){var d=c.getContext("2d"),e=a.crop;(c.width!==e.width||c.height!==e.height)&&(c.width=e.width,c.height=e.height),d.clearRect(0,0,e.width,e.height),d.fillStyle="#"+("00000"+(0|b).toString(16)).substr(-6),d.fillRect(0,0,e.width,e.height),d.globalCompositeOperation="multiply",d.drawImage(a.baseTexture.source,e.x,e.y,e.width,e.height,0,0,e.width,e.height),d.globalCompositeOperation="destination-atop",d.drawImage(a.baseTexture.source,e.x,e.y,e.width,e.height,0,0,e.width,e.height)},b.CanvasTinter.tintWithPerPixel=function(a,c,d){var e=d.getContext("2d"),f=a.crop;d.width=f.width,d.height=f.height,e.globalCompositeOperation="copy",e.drawImage(a.baseTexture.source,f.x,f.y,f.width,f.height,0,0,f.width,f.height);for(var g=b.hex2rgb(c),h=g[0],i=g[1],j=g[2],k=e.getImageData(0,0,f.width,f.height),l=k.data,m=0;m<l.length;m+=4)if(l[m+0]*=h,l[m+1]*=i,l[m+2]*=j,!b.CanvasTinter.canHandleAlpha){var n=l[m+3];l[m+0]/=255/n,l[m+1]/=255/n,l[m+2]/=255/n}e.putImageData(k,0,0)},b.CanvasTinter.checkInverseAlpha=function(){var a=new b.CanvasBuffer(2,1);a.context.fillStyle="rgba(10, 20, 30, 0.5)",a.context.fillRect(0,0,1,1);var c=a.context.getImageData(0,0,1,1);if(null===c)return!1;a.context.putImageData(c,1,0);var d=a.context.getImageData(1,0,1,1);return d.data[0]===c.data[0]&&d.data[1]===c.data[1]&&d.data[2]===c.data[2]&&d.data[3]===c.data[3]},b.CanvasTinter.canHandleAlpha=b.CanvasTinter.checkInverseAlpha(),b.CanvasTinter.canUseMultiply=b.canUseNewCanvasBlendModes(),b.CanvasTinter.tintMethod=b.CanvasTinter.canUseMultiply?b.CanvasTinter.tintWithMultiply:b.CanvasTinter.tintWithPerPixel,b.CanvasRenderer=function(a){this.game=a,b.defaultRenderer||(b.defaultRenderer=this),this.type=b.CANVAS_RENDERER,this.resolution=a.resolution,this.clearBeforeRender=a.clearBeforeRender,this.transparent=a.transparent,this.autoResize=!1,this.width=a.width*this.resolution,this.height=a.height*this.resolution,this.view=a.canvas,this.context=this.view.getContext("2d",{alpha:this.transparent}),this.refresh=!0,this.count=0,this.maskManager=new b.CanvasMaskManager,this.renderSession={context:this.context,maskManager:this.maskManager,scaleMode:null,smoothProperty:Phaser.Canvas.getSmoothingPrefix(this.context),roundPixels:!1},this.mapBlendModes(),this.resize(this.width,this.height)},b.CanvasRenderer.prototype.constructor=b.CanvasRenderer,b.CanvasRenderer.prototype.render=function(a){a.updateTransform(),this.context.setTransform(1,0,0,1,0,0),this.context.globalAlpha=1,this.renderSession.currentBlendMode=0,this.context.globalCompositeOperation="source-over",navigator.isCocoonJS&&this.view.screencanvas&&(this.context.fillStyle="black",this.context.clear()),this.clearBeforeRender&&(this.transparent?this.context.clearRect(0,0,this.width,this.height):(this.context.fillStyle=a._bgColor.rgba,this.context.fillRect(0,0,this.width,this.height))),this.renderDisplayObject(a)},b.CanvasRenderer.prototype.destroy=function(a){void 0===a&&(a=!0),a&&this.view.parent&&this.view.parent.removeChild(this.view),this.view=null,this.context=null,this.maskManager=null,this.renderSession=null},b.CanvasRenderer.prototype.resize=function(a,b){this.width=a*this.resolution,this.height=b*this.resolution,this.view.width=this.width,this.view.height=this.height,this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px")},b.CanvasRenderer.prototype.renderDisplayObject=function(a,b,c){this.renderSession.context=b||this.context,this.renderSession.resolution=this.resolution,a._renderCanvas(this.renderSession,c)},b.CanvasRenderer.prototype.mapBlendModes=function(){if(!b.blendModesCanvas){var a=[],c=b.blendModes,d=b.canUseNewCanvasBlendModes();a[c.NORMAL]="source-over",a[c.ADD]="lighter",a[c.MULTIPLY]=d?"multiply":"source-over",a[c.SCREEN]=d?"screen":"source-over",a[c.OVERLAY]=d?"overlay":"source-over",a[c.DARKEN]=d?"darken":"source-over",a[c.LIGHTEN]=d?"lighten":"source-over",a[c.COLOR_DODGE]=d?"color-dodge":"source-over",a[c.COLOR_BURN]=d?"color-burn":"source-over",a[c.HARD_LIGHT]=d?"hard-light":"source-over",a[c.SOFT_LIGHT]=d?"soft-light":"source-over",a[c.DIFFERENCE]=d?"difference":"source-over",a[c.EXCLUSION]=d?"exclusion":"source-over",a[c.HUE]=d?"hue":"source-over",a[c.SATURATION]=d?"saturation":"source-over",a[c.COLOR]=d?"color":"source-over",a[c.LUMINOSITY]=d?"luminosity":"source-over",b.blendModesCanvas=a}},b.BaseTextureCache={},b.BaseTextureCacheIdGenerator=0,b.BaseTexture=function(a,c){this.resolution=1,this.width=100,this.height=100,this.scaleMode=c||b.scaleModes.DEFAULT,this.hasLoaded=!1,this.source=a,this._UID=b._UID++,this.premultipliedAlpha=!0,this._glTextures=[],this.mipmap=!1,this._dirty=[!0,!0,!0,!0],a&&((this.source.complete||this.source.getContext)&&this.source.width&&this.source.height&&(this.hasLoaded=!0,this.width=this.source.naturalWidth||this.source.width,this.height=this.source.naturalHeight||this.source.height,this.dirty()),this.skipRender=!1,this.imageUrl=null,this._powerOf2=!1)},b.BaseTexture.prototype.constructor=b.BaseTexture,b.BaseTexture.prototype.forceLoaded=function(a,b){this.hasLoaded=!0,this.width=a,this.height=b,this.dirty()},b.BaseTexture.prototype.destroy=function(){this.imageUrl?(delete b.BaseTextureCache[this.imageUrl],delete b.TextureCache[this.imageUrl],this.imageUrl=null,navigator.isCocoonJS||(this.source.src="")):this.source&&this.source._pixiId&&(b.CanvasPool.removeByCanvas(this.source),delete b.BaseTextureCache[this.source._pixiId]),this.source=null,this.unloadFromGPU()},b.BaseTexture.prototype.updateSourceImage=function(a){this.hasLoaded=!1,this.source.src=null,this.source.src=a},b.BaseTexture.prototype.dirty=function(){for(var a=0;a<this._glTextures.length;a++)this._dirty[a]=!0},b.BaseTexture.prototype.unloadFromGPU=function(){this.dirty();for(var a=this._glTextures.length-1;a>=0;a--){var c=this._glTextures[a],d=b.glContexts[a];d&&c&&d.deleteTexture(c)}this._glTextures.length=0,this.dirty()},b.BaseTexture.fromImage=function(a,c,d){var e=b.BaseTextureCache[a];if(void 0===c&&-1===a.indexOf("data:")&&(c=!0),!e){var f=new Image;c&&(f.crossOrigin=""),f.src=a,e=new b.BaseTexture(f,d),e.imageUrl=a,b.BaseTextureCache[a]=e,-1!==a.indexOf(b.RETINA_PREFIX+".")&&(e.resolution=2)}return e},b.BaseTexture.fromCanvas=function(a,c){a._pixiId||(a._pixiId="canvas_"+b.TextureCacheIdGenerator++),0===a.width&&(a.width=1),0===a.height&&(a.height=1);var d=b.BaseTextureCache[a._pixiId];return d||(d=new b.BaseTexture(a,c),b.BaseTextureCache[a._pixiId]=d),d},b.TextureCache={},b.FrameCache={},b.TextureSilentFail=!1,b.TextureCacheIdGenerator=0,b.Texture=function(a,c,d,e){this.noFrame=!1,c||(this.noFrame=!0,c=new b.Rectangle(0,0,1,1)),a instanceof b.Texture&&(a=a.baseTexture),this.baseTexture=a,this.frame=c,this.trim=e,this.valid=!1,this.isTiling=!1,this.requiresUpdate=!1,this.requiresReTint=!1,this._uvs=null,this.width=0,this.height=0,this.crop=d||new b.Rectangle(0,0,1,1),a.hasLoaded&&(this.noFrame&&(c=new b.Rectangle(0,0,a.width,a.height)),this.setFrame(c))},b.Texture.prototype.constructor=b.Texture,b.Texture.prototype.onBaseTextureLoaded=function(){var a=this.baseTexture;this.noFrame&&(this.frame=new b.Rectangle(0,0,a.width,a.height)),this.setFrame(this.frame)},b.Texture.prototype.destroy=function(a){a&&this.baseTexture.destroy(),this.valid=!1},b.Texture.prototype.setFrame=function(a){if(this.noFrame=!1,this.frame=a,this.width=a.width,this.height=a.height,this.crop.x=a.x,this.crop.y=a.y,this.crop.width=a.width,this.crop.height=a.height,!this.trim&&(a.x+a.width>this.baseTexture.width||a.y+a.height>this.baseTexture.height)){if(!b.TextureSilentFail)throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);return void(this.valid=!1)}this.valid=a&&a.width&&a.height&&this.baseTexture.source&&this.baseTexture.hasLoaded,this.trim&&(this.width=this.trim.width,this.height=this.trim.height,this.frame.width=this.trim.width,this.frame.height=this.trim.height),this.valid&&this._updateUvs()},b.Texture.prototype._updateUvs=function(){this._uvs||(this._uvs=new b.TextureUvs);var a=this.crop,c=this.baseTexture.width,d=this.baseTexture.height;this._uvs.x0=a.x/c,this._uvs.y0=a.y/d,this._uvs.x1=(a.x+a.width)/c,this._uvs.y1=a.y/d,this._uvs.x2=(a.x+a.width)/c,this._uvs.y2=(a.y+a.height)/d,this._uvs.x3=a.x/c,this._uvs.y3=(a.y+a.height)/d},b.Texture.fromImage=function(a,c,d){var e=b.TextureCache[a];return e||(e=new b.Texture(b.BaseTexture.fromImage(a,c,d)),b.TextureCache[a]=e),e},b.Texture.fromFrame=function(a){var c=b.TextureCache[a];if(!c)throw new Error('The frameId "'+a+'" does not exist in the texture cache ');return c},b.Texture.fromCanvas=function(a,c){var d=b.BaseTexture.fromCanvas(a,c);return new b.Texture(d)},b.Texture.addTextureToCache=function(a,c){b.TextureCache[c]=a},b.Texture.removeTextureFromCache=function(a){var c=b.TextureCache[a];return delete b.TextureCache[a],delete b.BaseTextureCache[a],c},b.TextureUvs=function(){this.x0=0,this.y0=0,this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.x3=0,this.y3=0},b.RenderTexture=function(a,c,d,e,f){if(this.width=a||100,this.height=c||100,this.resolution=f||1,this.frame=new b.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution),this.crop=new b.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution),this.baseTexture=new b.BaseTexture,this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution,this.baseTexture._glTextures=[],this.baseTexture.resolution=this.resolution,this.baseTexture.scaleMode=e||b.scaleModes.DEFAULT,this.baseTexture.hasLoaded=!0, +b.Texture.call(this,this.baseTexture,new b.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution)),this.renderer=d||b.defaultRenderer,this.renderer.type===b.WEBGL_RENDERER){var g=this.renderer.gl;this.baseTexture._dirty[g.id]=!1,this.textureBuffer=new b.FilterTexture(g,this.width,this.height,this.baseTexture.scaleMode),this.baseTexture._glTextures[g.id]=this.textureBuffer.texture,this.render=this.renderWebGL,this.projection=new b.Point(.5*this.width,.5*-this.height)}else this.render=this.renderCanvas,this.textureBuffer=new b.CanvasBuffer(this.width*this.resolution,this.height*this.resolution),this.baseTexture.source=this.textureBuffer.canvas;this.valid=!0,this.tempMatrix=new Phaser.Matrix,this._updateUvs()},b.RenderTexture.prototype=Object.create(b.Texture.prototype),b.RenderTexture.prototype.constructor=b.RenderTexture,b.RenderTexture.prototype.resize=function(a,c,d){(a!==this.width||c!==this.height)&&(this.valid=a>0&&c>0,this.width=a,this.height=c,this.frame.width=this.crop.width=a*this.resolution,this.frame.height=this.crop.height=c*this.resolution,d&&(this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution),this.renderer.type===b.WEBGL_RENDERER&&(this.projection.x=this.width/2,this.projection.y=-this.height/2),this.valid&&this.textureBuffer.resize(this.width,this.height))},b.RenderTexture.prototype.clear=function(){this.valid&&(this.renderer.type===b.WEBGL_RENDERER&&this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER,this.textureBuffer.frameBuffer),this.textureBuffer.clear())},b.RenderTexture.prototype.renderWebGL=function(a,b,c){if(this.valid&&0!==a.alpha){var d=a.worldTransform;d.identity(),d.translate(0,2*this.projection.y),b&&d.append(b),d.scale(1,-1);for(var e=0;e<a.children.length;e++)a.children[e].updateTransform();var f=this.renderer.gl;f.viewport(0,0,this.width*this.resolution,this.height*this.resolution),f.bindFramebuffer(f.FRAMEBUFFER,this.textureBuffer.frameBuffer),c&&this.textureBuffer.clear(),this.renderer.spriteBatch.dirty=!0,this.renderer.renderDisplayObject(a,this.projection,this.textureBuffer.frameBuffer,b),this.renderer.spriteBatch.dirty=!0}},b.RenderTexture.prototype.renderCanvas=function(a,b,c){if(this.valid&&0!==a.alpha){var d=a.worldTransform;d.identity(),b&&d.append(b);for(var e=0;e<a.children.length;e++)a.children[e].updateTransform();c&&this.textureBuffer.clear();var f=this.renderer.resolution;this.renderer.resolution=this.resolution,this.renderer.renderDisplayObject(a,this.textureBuffer.context,b),this.renderer.resolution=f}},b.RenderTexture.prototype.getImage=function(){var a=new Image;return a.src=this.getBase64(),a},b.RenderTexture.prototype.getBase64=function(){return this.getCanvas().toDataURL()},b.RenderTexture.prototype.getCanvas=function(){if(this.renderer.type===b.WEBGL_RENDERER){var a=this.renderer.gl,c=this.textureBuffer.width,d=this.textureBuffer.height,e=new Uint8Array(4*c*d);a.bindFramebuffer(a.FRAMEBUFFER,this.textureBuffer.frameBuffer),a.readPixels(0,0,c,d,a.RGBA,a.UNSIGNED_BYTE,e),a.bindFramebuffer(a.FRAMEBUFFER,null);var f=new b.CanvasBuffer(c,d),g=f.context.getImageData(0,0,c,d);return g.data.set(e),f.context.putImageData(g,0,0),f.canvas}return this.textureBuffer.canvas},b.AbstractFilter=function(a,b){this.passes=[this],this.shaders=[],this.dirty=!0,this.padding=0,this.uniforms=b||{},this.fragmentSrc=a||[]},b.AbstractFilter.prototype.constructor=b.AbstractFilter,b.AbstractFilter.prototype.syncUniforms=function(){for(var a=0,b=this.shaders.length;b>a;a++)this.shaders[a].dirty=!0},b.Strip=function(a){b.DisplayObjectContainer.call(this),this.texture=a,this.uvs=new b.Float32Array([0,1,1,1,1,0,0,1]),this.vertices=new b.Float32Array([0,0,100,0,100,100,0,100]),this.colors=new b.Float32Array([1,1,1,1]),this.indices=new b.Uint16Array([0,1,2,3]),this.dirty=!0,this.blendMode=b.blendModes.NORMAL,this.canvasPadding=0,this.drawMode=b.Strip.DrawModes.TRIANGLE_STRIP},b.Strip.prototype=Object.create(b.DisplayObjectContainer.prototype),b.Strip.prototype.constructor=b.Strip,b.Strip.prototype._renderWebGL=function(a){!this.visible||this.alpha<=0||(a.spriteBatch.stop(),this._vertexBuffer||this._initWebGL(a),a.shaderManager.setShader(a.shaderManager.stripShader),this._renderStrip(a),a.spriteBatch.start())},b.Strip.prototype._initWebGL=function(a){var b=a.gl;this._vertexBuffer=b.createBuffer(),this._indexBuffer=b.createBuffer(),this._uvBuffer=b.createBuffer(),this._colorBuffer=b.createBuffer(),b.bindBuffer(b.ARRAY_BUFFER,this._vertexBuffer),b.bufferData(b.ARRAY_BUFFER,this.vertices,b.DYNAMIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,this._uvBuffer),b.bufferData(b.ARRAY_BUFFER,this.uvs,b.STATIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,this._colorBuffer),b.bufferData(b.ARRAY_BUFFER,this.colors,b.STATIC_DRAW),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,this._indexBuffer),b.bufferData(b.ELEMENT_ARRAY_BUFFER,this.indices,b.STATIC_DRAW)},b.Strip.prototype._renderStrip=function(a){var c=a.gl,d=a.projection,e=a.offset,f=a.shaderManager.stripShader,g=this.drawMode===b.Strip.DrawModes.TRIANGLE_STRIP?c.TRIANGLE_STRIP:c.TRIANGLES;a.blendModeManager.setBlendMode(this.blendMode),c.uniformMatrix3fv(f.translationMatrix,!1,this.worldTransform.toArray(!0)),c.uniform2f(f.projectionVector,d.x,-d.y),c.uniform2f(f.offsetVector,-e.x,-e.y),c.uniform1f(f.alpha,this.worldAlpha),this.dirty?(this.dirty=!1,c.bindBuffer(c.ARRAY_BUFFER,this._vertexBuffer),c.bufferData(c.ARRAY_BUFFER,this.vertices,c.STATIC_DRAW),c.vertexAttribPointer(f.aVertexPosition,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,this._uvBuffer),c.bufferData(c.ARRAY_BUFFER,this.uvs,c.STATIC_DRAW),c.vertexAttribPointer(f.aTextureCoord,2,c.FLOAT,!1,0,0),c.activeTexture(c.TEXTURE0),this.texture.baseTexture._dirty[c.id]?a.renderer.updateTexture(this.texture.baseTexture):c.bindTexture(c.TEXTURE_2D,this.texture.baseTexture._glTextures[c.id]),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,this._indexBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,this.indices,c.STATIC_DRAW)):(c.bindBuffer(c.ARRAY_BUFFER,this._vertexBuffer),c.bufferSubData(c.ARRAY_BUFFER,0,this.vertices),c.vertexAttribPointer(f.aVertexPosition,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,this._uvBuffer),c.vertexAttribPointer(f.aTextureCoord,2,c.FLOAT,!1,0,0),c.activeTexture(c.TEXTURE0),this.texture.baseTexture._dirty[c.id]?a.renderer.updateTexture(this.texture.baseTexture):c.bindTexture(c.TEXTURE_2D,this.texture.baseTexture._glTextures[c.id]),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,this._indexBuffer)),c.drawElements(g,this.indices.length,c.UNSIGNED_SHORT,0)},b.Strip.prototype._renderCanvas=function(a){var c=a.context,d=this.worldTransform;a.roundPixels?c.setTransform(d.a,d.b,d.c,d.d,0|d.tx,0|d.ty):c.setTransform(d.a,d.b,d.c,d.d,d.tx,d.ty),this.drawMode===b.Strip.DrawModes.TRIANGLE_STRIP?this._renderCanvasTriangleStrip(c):this._renderCanvasTriangles(c)},b.Strip.prototype._renderCanvasTriangleStrip=function(a){var b=this.vertices,c=this.uvs,d=b.length/2;this.count++;for(var e=0;d-2>e;e++){var f=2*e;this._renderCanvasDrawTriangle(a,b,c,f,f+2,f+4)}},b.Strip.prototype._renderCanvasTriangles=function(a){var b=this.vertices,c=this.uvs,d=this.indices,e=d.length;this.count++;for(var f=0;e>f;f+=3){var g=2*d[f],h=2*d[f+1],i=2*d[f+2];this._renderCanvasDrawTriangle(a,b,c,g,h,i)}},b.Strip.prototype._renderCanvasDrawTriangle=function(a,b,c,d,e,f){var g=this.texture.baseTexture.source,h=this.texture.width,i=this.texture.height,j=b[d],k=b[e],l=b[f],m=b[d+1],n=b[e+1],o=b[f+1],p=c[d]*h,q=c[e]*h,r=c[f]*h,s=c[d+1]*i,t=c[e+1]*i,u=c[f+1]*i;if(this.canvasPadding>0){var v=this.canvasPadding/this.worldTransform.a,w=this.canvasPadding/this.worldTransform.d,x=(j+k+l)/3,y=(m+n+o)/3,z=j-x,A=m-y,B=Math.sqrt(z*z+A*A);j=x+z/B*(B+v),m=y+A/B*(B+w),z=k-x,A=n-y,B=Math.sqrt(z*z+A*A),k=x+z/B*(B+v),n=y+A/B*(B+w),z=l-x,A=o-y,B=Math.sqrt(z*z+A*A),l=x+z/B*(B+v),o=y+A/B*(B+w)}a.save(),a.beginPath(),a.moveTo(j,m),a.lineTo(k,n),a.lineTo(l,o),a.closePath(),a.clip();var C=p*t+s*r+q*u-t*r-s*q-p*u,D=j*t+s*l+k*u-t*l-s*k-j*u,E=p*k+j*r+q*l-k*r-j*q-p*l,F=p*t*l+s*k*r+j*q*u-j*t*r-s*q*l-p*k*u,G=m*t+s*o+n*u-t*o-s*n-m*u,H=p*n+m*r+q*o-n*r-m*q-p*o,I=p*t*o+s*n*r+m*q*u-m*t*r-s*q*o-p*n*u;a.transform(D/C,G/C,E/C,H/C,F/C,I/C),a.drawImage(g,0,0),a.restore()},b.Strip.prototype.renderStripFlat=function(a){var b=this.context,c=a.vertices,d=c.length/2;this.count++,b.beginPath();for(var e=1;d-2>e;e++){var f=2*e,g=c[f],h=c[f+2],i=c[f+4],j=c[f+1],k=c[f+3],l=c[f+5];b.moveTo(g,j),b.lineTo(h,k),b.lineTo(i,l)}b.fillStyle="#FF0000",b.fill(),b.closePath()},b.Strip.prototype.onTextureUpdate=function(){this.updateFrame=!0},b.Strip.prototype.getBounds=function(a){for(var c=a||this.worldTransform,d=c.a,e=c.b,f=c.c,g=c.d,h=c.tx,i=c.ty,j=-(1/0),k=-(1/0),l=1/0,m=1/0,n=this.vertices,o=0,p=n.length;p>o;o+=2){var q=n[o],r=n[o+1],s=d*q+f*r+h,t=g*r+e*q+i;l=l>s?s:l,m=m>t?t:m,j=s>j?s:j,k=t>k?t:k}if(l===-(1/0)||k===1/0)return b.EmptyRectangle;var u=this._bounds;return u.x=l,u.width=j-l,u.y=m,u.height=k-m,this._currentBounds=u,u},b.Strip.DrawModes={TRIANGLE_STRIP:0,TRIANGLES:1},b.Rope=function(a,c){b.Strip.call(this,a),this.points=c,this.vertices=new b.Float32Array(4*c.length),this.uvs=new b.Float32Array(4*c.length),this.colors=new b.Float32Array(2*c.length),this.indices=new b.Uint16Array(2*c.length),this.refresh()},b.Rope.prototype=Object.create(b.Strip.prototype),b.Rope.prototype.constructor=b.Rope,b.Rope.prototype.refresh=function(){var a=this.points;if(!(a.length<1)){var b=this.uvs,c=a[0],d=this.indices,e=this.colors;this.count-=.2,b[0]=0,b[1]=0,b[2]=0,b[3]=1,e[0]=1,e[1]=1,d[0]=0,d[1]=1;for(var f,g,h,i=a.length,j=1;i>j;j++)f=a[j],g=4*j,h=j/(i-1),j%2?(b[g]=h,b[g+1]=0,b[g+2]=h,b[g+3]=1):(b[g]=h,b[g+1]=0,b[g+2]=h,b[g+3]=1),g=2*j,e[g]=1,e[g+1]=1,g=2*j,d[g]=g,d[g+1]=g+1,c=f}},b.Rope.prototype.updateTransform=function(){var a=this.points;if(!(a.length<1)){var c,d=a[0],e={x:0,y:0};this.count-=.2;for(var f,g,h,i,j,k=this.vertices,l=a.length,m=0;l>m;m++)f=a[m],g=4*m,c=m<a.length-1?a[m+1]:f,e.y=-(c.x-d.x),e.x=c.y-d.y,h=10*(1-m/(l-1)),h>1&&(h=1),i=Math.sqrt(e.x*e.x+e.y*e.y),j=this.texture.height/2,e.x/=i,e.y/=i,e.x*=j,e.y*=j,k[g]=f.x+e.x,k[g+1]=f.y+e.y,k[g+2]=f.x-e.x,k[g+3]=f.y-e.y,d=f;b.DisplayObjectContainer.prototype.updateTransform.call(this)}},b.Rope.prototype.setTexture=function(a){this.texture=a},b.TilingSprite=function(a,c,d){b.Sprite.call(this,a),this._width=c||128,this._height=d||128,this.tileScale=new b.Point(1,1),this.tileScaleOffset=new b.Point(1,1),this.tilePosition=new b.Point,this.renderable=!0,this.tint=16777215,this.textureDebug=!1,this.blendMode=b.blendModes.NORMAL,this.canvasBuffer=null,this.tilingTexture=null,this.tilePattern=null,this.refreshTexture=!0,this.frameWidth=0,this.frameHeight=0},b.TilingSprite.prototype=Object.create(b.Sprite.prototype),b.TilingSprite.prototype.constructor=b.TilingSprite,b.TilingSprite.prototype.setTexture=function(a){this.texture!==a&&(this.texture=a,this.refreshTexture=!0,this.cachedTint=16777215)},b.TilingSprite.prototype._renderWebGL=function(a){if(this.visible!==!1&&0!==this.alpha){if(this._mask&&(a.spriteBatch.stop(),a.maskManager.pushMask(this.mask,a),a.spriteBatch.start()),this._filters&&(a.spriteBatch.flush(),a.filterManager.pushFilter(this._filterBlock)),this.refreshTexture){if(this.generateTilingTexture(!0,a),!this.tilingTexture)return;this.tilingTexture.needsUpdate&&(a.renderer.updateTexture(this.tilingTexture.baseTexture),this.tilingTexture.needsUpdate=!1)}a.spriteBatch.renderTilingSprite(this);for(var b=0;b<this.children.length;b++)this.children[b]._renderWebGL(a);a.spriteBatch.stop(),this._filters&&a.filterManager.popFilter(),this._mask&&a.maskManager.popMask(this._mask,a),a.spriteBatch.start()}},b.TilingSprite.prototype._renderCanvas=function(a){if(this.visible!==!1&&0!==this.alpha){var c=a.context;this._mask&&a.maskManager.pushMask(this._mask,a),c.globalAlpha=this.worldAlpha;var d=this.worldTransform,e=a.resolution;if(c.setTransform(d.a*e,d.b*e,d.c*e,d.d*e,d.tx*e,d.ty*e),this.refreshTexture){if(this.generateTilingTexture(!1,a),!this.tilingTexture)return;this.tilePattern=c.createPattern(this.tilingTexture.baseTexture.source,"repeat")}var f=a.currentBlendMode;this.blendMode!==a.currentBlendMode&&(a.currentBlendMode=this.blendMode,c.globalCompositeOperation=b.blendModesCanvas[a.currentBlendMode]);var g=this.tilePosition,h=this.tileScale;g.x%=this.tilingTexture.baseTexture.width,g.y%=this.tilingTexture.baseTexture.height,c.scale(h.x,h.y),c.translate(g.x+this.anchor.x*-this._width,g.y+this.anchor.y*-this._height),c.fillStyle=this.tilePattern;var i=-g.x,j=-g.y,k=this._width/h.x,l=this._height/h.y;a.roundPixels&&(i|=0,j|=0,k|=0,l|=0),c.fillRect(i,j,k,l),c.scale(1/h.x,1/h.y),c.translate(-g.x+this.anchor.x*this._width,-g.y+this.anchor.y*this._height),this._mask&&a.maskManager.popMask(a);for(var m=0;m<this.children.length;m++)this.children[m]._renderCanvas(a);f!==this.blendMode&&(a.currentBlendMode=f,c.globalCompositeOperation=b.blendModesCanvas[f])}},b.TilingSprite.prototype.onTextureUpdate=function(){},b.TilingSprite.prototype.generateTilingTexture=function(a,c){if(this.texture.baseTexture.hasLoaded){var d=this.texture,e=d.frame,f=this._frame.sourceSizeW,g=this._frame.sourceSizeH,h=0,i=0;this._frame.trimmed&&(h=this._frame.spriteSourceSizeX,i=this._frame.spriteSourceSizeY),a&&(f=b.getNextPowerOfTwo(f),g=b.getNextPowerOfTwo(g)),this.canvasBuffer?(this.canvasBuffer.resize(f,g),this.tilingTexture.baseTexture.width=f,this.tilingTexture.baseTexture.height=g,this.tilingTexture.needsUpdate=!0):(this.canvasBuffer=new b.CanvasBuffer(f,g),this.tilingTexture=b.Texture.fromCanvas(this.canvasBuffer.canvas),this.tilingTexture.isTiling=!0,this.tilingTexture.needsUpdate=!0),this.textureDebug&&(this.canvasBuffer.context.strokeStyle="#00ff00",this.canvasBuffer.context.strokeRect(0,0,f,g));var j=d.crop.width,k=d.crop.height;(j!==f||k!==g)&&(j=f,k=g),this.canvasBuffer.context.drawImage(d.baseTexture.source,d.crop.x,d.crop.y,d.crop.width,d.crop.height,h,i,j,k),this.tileScaleOffset.x=e.width/f,this.tileScaleOffset.y=e.height/g,this.refreshTexture=!1,this.tilingTexture.baseTexture._powerOf2=!0}},b.TilingSprite.prototype.getBounds=function(){var a=this._width,b=this._height,c=a*(1-this.anchor.x),d=a*-this.anchor.x,e=b*(1-this.anchor.y),f=b*-this.anchor.y,g=this.worldTransform,h=g.a,i=g.b,j=g.c,k=g.d,l=g.tx,m=g.ty,n=h*d+j*f+l,o=k*f+i*d+m,p=h*c+j*f+l,q=k*f+i*c+m,r=h*c+j*e+l,s=k*e+i*c+m,t=h*d+j*e+l,u=k*e+i*d+m,v=-(1/0),w=-(1/0),x=1/0,y=1/0;x=x>n?n:x,x=x>p?p:x,x=x>r?r:x,x=x>t?t:x,y=y>o?o:y,y=y>q?q:y,y=y>s?s:y,y=y>u?u:y,v=n>v?n:v,v=p>v?p:v,v=r>v?r:v,v=t>v?t:v,w=o>w?o:w,w=q>w?q:w,w=s>w?s:w,w=u>w?u:w;var z=this._bounds;return z.x=x,z.width=v-x,z.y=y,z.height=w-y,this._currentBounds=z,z},b.TilingSprite.prototype.destroy=function(){b.Sprite.prototype.destroy.call(this),this.canvasBuffer&&(this.canvasBuffer.destroy(),this.canvasBuffer=null),this.tileScale=null,this.tileScaleOffset=null,this.tilePosition=null,this.tilingTexture&&(this.tilingTexture.destroy(!0),this.tilingTexture=null)},Object.defineProperty(b.TilingSprite.prototype,"width",{get:function(){return this._width},set:function(a){this._width=a}}),Object.defineProperty(b.TilingSprite.prototype,"height",{get:function(){return this._height},set:function(a){this._height=a}}),"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=b),exports.PIXI=b):"undefined"!=typeof define&&define.amd?define("PIXI",function(){return a.PIXI=b}()):a.PIXI=b,b}.call(this),function(){function a(a,b){this._scaleFactor=a,this._deltaMode=b,this.originalEvent=null}var b=this,c=c||{VERSION:"2.4.4",GAMES:[],AUTO:0,CANVAS:1,WEBGL:2,HEADLESS:3,NONE:0,LEFT:1,RIGHT:2,UP:3,DOWN:4,SPRITE:0,BUTTON:1,IMAGE:2,GRAPHICS:3,TEXT:4,TILESPRITE:5,BITMAPTEXT:6,GROUP:7,RENDERTEXTURE:8,TILEMAP:9,TILEMAPLAYER:10,EMITTER:11,POLYGON:12,BITMAPDATA:13,CANVAS_FILTER:14,WEBGL_FILTER:15,ELLIPSE:16,SPRITEBATCH:17,RETROFONT:18,POINTER:19,ROPE:20,CIRCLE:21,RECTANGLE:22,LINE:23,MATRIX:24,POINT:25,ROUNDEDRECTANGLE:26,CREATURE:27,VIDEO:28,blendModes:{NORMAL:0,ADD:1,MULTIPLY:2,SCREEN:3,OVERLAY:4,DARKEN:5,LIGHTEN:6,COLOR_DODGE:7,COLOR_BURN:8,HARD_LIGHT:9,SOFT_LIGHT:10,DIFFERENCE:11,EXCLUSION:12,HUE:13,SATURATION:14,COLOR:15,LUMINOSITY:16},scaleModes:{DEFAULT:0,LINEAR:0,NEAREST:1},PIXI:PIXI||{}};if(Math.trunc||(Math.trunc=function(a){return 0>a?Math.ceil(a):Math.floor(a)}),Function.prototype.bind||(Function.prototype.bind=function(){var a=Array.prototype.slice;return function(b){function c(){var f=e.concat(a.call(arguments));d.apply(this instanceof c?this:b,f)}var d=this,e=a.call(arguments,1);if("function"!=typeof d)throw new TypeError;return c.prototype=function f(a){return a&&(f.prototype=a),this instanceof f?void 0:new f}(d.prototype),c}}()),Array.isArray||(Array.isArray=function(a){return"[object Array]"==Object.prototype.toString.call(a)}),Array.prototype.forEach||(Array.prototype.forEach=function(a){"use strict";if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;for(var d=arguments.length>=2?arguments[1]:void 0,e=0;c>e;e++)e in b&&a.call(d,b[e],e,b)}),"function"!=typeof window.Uint32Array&&"object"!=typeof window.Uint32Array){var d=function(a){var b=new Array;window[a]=function(a){if("number"==typeof a){Array.call(this,a),this.length=a;for(var b=0;b<this.length;b++)this[b]=0}else{Array.call(this,a.length),this.length=a.length;for(var b=0;b<this.length;b++)this[b]=a[b]}},window[a].prototype=b,window[a].constructor=window[a]};d("Uint32Array"),d("Int16Array")}window.console||(window.console={},window.console.log=window.console.assert=function(){},window.console.warn=window.console.assert=function(){}),c.Utils={getProperty:function(a,b){for(var c=b.split("."),d=c.pop(),e=c.length,f=1,g=c[0];e>f&&(a=a[g]);)g=c[f],f++;return a?a[d]:null},setProperty:function(a,b,c){for(var d=b.split("."),e=d.pop(),f=d.length,g=1,h=d[0];f>g&&(a=a[h]);)h=d[g],g++;return a&&(a[e]=c),a},chanceRoll:function(a){return void 0===a&&(a=50),a>0&&100*Math.random()<=a},randomChoice:function(a,b){return Math.random()<.5?a:b},parseDimension:function(a,b){var c=0,d=0;return"string"==typeof a?"%"===a.substr(-1)?(c=parseInt(a,10)/100,d=0===b?window.innerWidth*c:window.innerHeight*c):d=parseInt(a,10):d=a,d},pad:function(a,b,c,d){if(void 0===b)var b=0;if(void 0===c)var c=" ";if(void 0===d)var d=3;var e=0;if(b+1>=a.length)switch(d){case 1:a=new Array(b+1-a.length).join(c)+a;break;case 3:var f=Math.ceil((e=b-a.length)/2),g=e-f;a=new Array(g+1).join(c)+a+new Array(f+1).join(c);break;default:a+=new Array(b+1-a.length).join(c)}return a},isPlainObject:function(a){if("object"!=typeof a||a.nodeType||a===a.window)return!1;try{if(a.constructor&&!{}.hasOwnProperty.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(b){return!1}return!0},extend:function(){var a,b,d,e,f,g,h=arguments[0]||{},i=1,j=arguments.length,k=!1;for("boolean"==typeof h&&(k=h,h=arguments[1]||{},i=2),j===i&&(h=this,--i);j>i;i++)if(null!=(a=arguments[i]))for(b in a)d=h[b],e=a[b],h!==e&&(k&&e&&(c.Utils.isPlainObject(e)||(f=Array.isArray(e)))?(f?(f=!1,g=d&&Array.isArray(d)?d:[]):g=d&&c.Utils.isPlainObject(d)?d:{},h[b]=c.Utils.extend(k,g,e)):void 0!==e&&(h[b]=e));return h},mixinPrototype:function(a,b,c){void 0===c&&(c=!1);for(var d=Object.keys(b),e=0;e<d.length;e++){var f=d[e],g=b[f];!c&&f in a||(!g||"function"!=typeof g.get&&"function"!=typeof g.set?a[f]=g:"function"==typeof g.clone?a[f]=g.clone():Object.defineProperty(a,f,g))}},mixin:function(a,b){if(!a||"object"!=typeof a)return b;for(var d in a){var e=a[d];if(!e.childNodes&&!e.cloneNode){var f=typeof a[d];a[d]&&"object"===f?typeof b[d]===f?b[d]=c.Utils.mixin(a[d],b[d]):b[d]=c.Utils.mixin(a[d],new e.constructor):b[d]=a[d]}}return b}},c.Circle=function(a,b,d){a=a||0,b=b||0,d=d||0,this.x=a,this.y=b,this._diameter=d,this._radius=0,d>0&&(this._radius=.5*d),this.type=c.CIRCLE},c.Circle.prototype={circumference:function(){return 2*(Math.PI*this._radius)},random:function(a){void 0===a&&(a=new c.Point);var b=2*Math.PI*Math.random(),d=Math.random()+Math.random(),e=d>1?2-d:d,f=e*Math.cos(b),g=e*Math.sin(b);return a.x=this.x+f*this.radius,a.y=this.y+g*this.radius,a},getBounds:function(){return new c.Rectangle(this.x-this.radius,this.y-this.radius,this.diameter,this.diameter)},setTo:function(a,b,c){return this.x=a,this.y=b,this._diameter=c,this._radius=.5*c,this},copyFrom:function(a){return this.setTo(a.x,a.y,a.diameter)},copyTo:function(a){return a.x=this.x,a.y=this.y,a.diameter=this._diameter,a},distance:function(a,b){var d=c.Math.distance(this.x,this.y,a.x,a.y);return b?Math.round(d):d},clone:function(a){return void 0===a||null===a?a=new c.Circle(this.x,this.y,this.diameter):a.setTo(this.x,this.y,this.diameter),a},contains:function(a,b){return c.Circle.contains(this,a,b)},circumferencePoint:function(a,b,d){return c.Circle.circumferencePoint(this,a,b,d)},offset:function(a,b){return this.x+=a,this.y+=b,this},offsetPoint:function(a){return this.offset(a.x,a.y)},toString:function(){return"[{Phaser.Circle (x="+this.x+" y="+this.y+" diameter="+this.diameter+" radius="+this.radius+")}]"}},c.Circle.prototype.constructor=c.Circle,Object.defineProperty(c.Circle.prototype,"diameter",{get:function(){return this._diameter},set:function(a){a>0&&(this._diameter=a,this._radius=.5*a)}}),Object.defineProperty(c.Circle.prototype,"radius",{get:function(){return this._radius},set:function(a){a>0&&(this._radius=a,this._diameter=2*a)}}),Object.defineProperty(c.Circle.prototype,"left",{get:function(){return this.x-this._radius},set:function(a){a>this.x?(this._radius=0,this._diameter=0):this.radius=this.x-a}}),Object.defineProperty(c.Circle.prototype,"right",{get:function(){return this.x+this._radius},set:function(a){a<this.x?(this._radius=0,this._diameter=0):this.radius=a-this.x}}),Object.defineProperty(c.Circle.prototype,"top",{get:function(){return this.y-this._radius},set:function(a){a>this.y?(this._radius=0,this._diameter=0):this.radius=this.y-a}}),Object.defineProperty(c.Circle.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(a){a<this.y?(this._radius=0,this._diameter=0):this.radius=a-this.y}}),Object.defineProperty(c.Circle.prototype,"area",{get:function(){return this._radius>0?Math.PI*this._radius*this._radius:0}}),Object.defineProperty(c.Circle.prototype,"empty",{get:function(){return 0===this._diameter},set:function(a){a===!0&&this.setTo(0,0,0)}}),c.Circle.contains=function(a,b,c){if(a.radius>0&&b>=a.left&&b<=a.right&&c>=a.top&&c<=a.bottom){var d=(a.x-b)*(a.x-b),e=(a.y-c)*(a.y-c);return d+e<=a.radius*a.radius}return!1},c.Circle.equals=function(a,b){return a.x==b.x&&a.y==b.y&&a.diameter==b.diameter},c.Circle.intersects=function(a,b){return c.Math.distance(a.x,a.y,b.x,b.y)<=a.radius+b.radius},c.Circle.circumferencePoint=function(a,b,d,e){return void 0===d&&(d=!1),void 0===e&&(e=new c.Point),d===!0&&(b=c.Math.degToRad(b)),e.x=a.x+a.radius*Math.cos(b),e.y=a.y+a.radius*Math.sin(b),e},c.Circle.intersectsRectangle=function(a,b){var c=Math.abs(a.x-b.x-b.halfWidth),d=b.halfWidth+a.radius;if(c>d)return!1;var e=Math.abs(a.y-b.y-b.halfHeight),f=b.halfHeight+a.radius;if(e>f)return!1;if(c<=b.halfWidth||e<=b.halfHeight)return!0;var g=c-b.halfWidth,h=e-b.halfHeight,i=g*g,j=h*h,k=a.radius*a.radius;return k>=i+j},PIXI.Circle=c.Circle,c.Ellipse=function(a,b,d,e){a=a||0,b=b||0,d=d||0,e=e||0,this.x=a,this.y=b,this.width=d,this.height=e,this.type=c.ELLIPSE},c.Ellipse.prototype={setTo:function(a,b,c,d){return this.x=a,this.y=b,this.width=c,this.height=d,this},getBounds:function(){return new c.Rectangle(this.x-this.width,this.y-this.height,this.width,this.height)},copyFrom:function(a){return this.setTo(a.x,a.y,a.width,a.height)},copyTo:function(a){return a.x=this.x,a.y=this.y,a.width=this.width,a.height=this.height,a},clone:function(a){return void 0===a||null===a?a=new c.Ellipse(this.x,this.y,this.width,this.height):a.setTo(this.x,this.y,this.width,this.height),a},contains:function(a,b){return c.Ellipse.contains(this,a,b)},random:function(a){void 0===a&&(a=new c.Point);var b=Math.random()*Math.PI*2,d=Math.random();return a.x=Math.sqrt(d)*Math.cos(b),a.y=Math.sqrt(d)*Math.sin(b),a.x=this.x+a.x*this.width/2,a.y=this.y+a.y*this.height/2,a},toString:function(){return"[{Phaser.Ellipse (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+")}]"}},c.Ellipse.prototype.constructor=c.Ellipse,Object.defineProperty(c.Ellipse.prototype,"left",{get:function(){return this.x},set:function(a){this.x=a}}),Object.defineProperty(c.Ellipse.prototype,"right",{get:function(){return this.x+this.width},set:function(a){a<this.x?this.width=0:this.width=a-this.x}}),Object.defineProperty(c.Ellipse.prototype,"top",{get:function(){return this.y},set:function(a){this.y=a}}),Object.defineProperty(c.Ellipse.prototype,"bottom",{get:function(){return this.y+this.height},set:function(a){a<this.y?this.height=0:this.height=a-this.y}}),Object.defineProperty(c.Ellipse.prototype,"empty",{get:function(){return 0===this.width||0===this.height},set:function(a){a===!0&&this.setTo(0,0,0,0)}}),c.Ellipse.contains=function(a,b,c){if(a.width<=0||a.height<=0)return!1;var d=(b-a.x)/a.width-.5,e=(c-a.y)/a.height-.5;return d*=d,e*=e,.25>d+e},PIXI.Ellipse=c.Ellipse,c.Line=function(a,b,d,e){a=a||0,b=b||0,d=d||0,e=e||0,this.start=new c.Point(a,b),this.end=new c.Point(d,e),this.type=c.LINE},c.Line.prototype={setTo:function(a,b,c,d){return this.start.setTo(a,b),this.end.setTo(c,d),this},fromSprite:function(a,b,c){return void 0===c&&(c=!1),c?this.setTo(a.center.x,a.center.y,b.center.x,b.center.y):this.setTo(a.x,a.y,b.x,b.y)},fromAngle:function(a,b,c,d){return this.start.setTo(a,b),this.end.setTo(a+Math.cos(c)*d,b+Math.sin(c)*d),this},rotate:function(a,b){var c=(this.start.x+this.end.x)/2,d=(this.start.y+this.end.y)/2;return this.start.rotate(c,d,a,b),this.end.rotate(c,d,a,b),this},rotateAround:function(a,b,c,d){return this.start.rotate(a,b,c,d),this.end.rotate(a,b,c,d),this},intersects:function(a,b,d){return c.Line.intersectsPoints(this.start,this.end,a.start,a.end,b,d)},reflect:function(a){return c.Line.reflect(this,a)},midPoint:function(a){return void 0===a&&(a=new c.Point),a.x=(this.start.x+this.end.x)/2,a.y=(this.start.y+this.end.y)/2,a},centerOn:function(a,b){var c=(this.start.x+this.end.x)/2,d=(this.start.y+this.end.y)/2,e=a-c,f=b-d;this.start.add(e,f),this.end.add(e,f)},pointOnLine:function(a,b){return(a-this.start.x)*(this.end.y-this.start.y)===(this.end.x-this.start.x)*(b-this.start.y)},pointOnSegment:function(a,b){var c=Math.min(this.start.x,this.end.x),d=Math.max(this.start.x,this.end.x),e=Math.min(this.start.y,this.end.y),f=Math.max(this.start.y,this.end.y);return this.pointOnLine(a,b)&&a>=c&&d>=a&&b>=e&&f>=b},random:function(a){void 0===a&&(a=new c.Point);var b=Math.random();return a.x=this.start.x+b*(this.end.x-this.start.x),a.y=this.start.y+b*(this.end.y-this.start.y),a},coordinatesOnLine:function(a,b){void 0===a&&(a=1),void 0===b&&(b=[]);var c=Math.round(this.start.x),d=Math.round(this.start.y),e=Math.round(this.end.x),f=Math.round(this.end.y),g=Math.abs(e-c),h=Math.abs(f-d),i=e>c?1:-1,j=f>d?1:-1,k=g-h;b.push([c,d]);for(var l=1;c!=e||d!=f;){var m=k<<1;m>-h&&(k-=h,c+=i),g>m&&(k+=g,d+=j),l%a===0&&b.push([c,d]),l++}return b},clone:function(a){return void 0===a||null===a?a=new c.Line(this.start.x,this.start.y,this.end.x,this.end.y):a.setTo(this.start.x,this.start.y,this.end.x,this.end.y),a}},Object.defineProperty(c.Line.prototype,"length",{get:function(){return Math.sqrt((this.end.x-this.start.x)*(this.end.x-this.start.x)+(this.end.y-this.start.y)*(this.end.y-this.start.y))}}),Object.defineProperty(c.Line.prototype,"angle",{get:function(){return Math.atan2(this.end.y-this.start.y,this.end.x-this.start.x)}}),Object.defineProperty(c.Line.prototype,"slope",{get:function(){return(this.end.y-this.start.y)/(this.end.x-this.start.x)}}),Object.defineProperty(c.Line.prototype,"perpSlope",{get:function(){return-((this.end.x-this.start.x)/(this.end.y-this.start.y))}}),Object.defineProperty(c.Line.prototype,"x",{get:function(){return Math.min(this.start.x,this.end.x)}}),Object.defineProperty(c.Line.prototype,"y",{get:function(){return Math.min(this.start.y,this.end.y)}}),Object.defineProperty(c.Line.prototype,"left",{get:function(){return Math.min(this.start.x,this.end.x)}}),Object.defineProperty(c.Line.prototype,"right",{get:function(){return Math.max(this.start.x,this.end.x)}}),Object.defineProperty(c.Line.prototype,"top",{get:function(){return Math.min(this.start.y,this.end.y)}}),Object.defineProperty(c.Line.prototype,"bottom",{get:function(){return Math.max(this.start.y,this.end.y)}}),Object.defineProperty(c.Line.prototype,"width",{get:function(){return Math.abs(this.start.x-this.end.x)}}),Object.defineProperty(c.Line.prototype,"height",{get:function(){return Math.abs(this.start.y-this.end.y)}}),Object.defineProperty(c.Line.prototype,"normalX",{get:function(){return Math.cos(this.angle-1.5707963267948966)}}),Object.defineProperty(c.Line.prototype,"normalY",{get:function(){return Math.sin(this.angle-1.5707963267948966)}}),Object.defineProperty(c.Line.prototype,"normalAngle",{get:function(){return c.Math.wrap(this.angle-1.5707963267948966,-Math.PI,Math.PI)}}),c.Line.intersectsPoints=function(a,b,d,e,f,g){void 0===f&&(f=!0),void 0===g&&(g=new c.Point);var h=b.y-a.y,i=e.y-d.y,j=a.x-b.x,k=d.x-e.x,l=b.x*a.y-a.x*b.y,m=e.x*d.y-d.x*e.y,n=h*k-i*j;if(0===n)return null;if(g.x=(j*m-k*l)/n,g.y=(i*l-h*m)/n,f){var o=(e.y-d.y)*(b.x-a.x)-(e.x-d.x)*(b.y-a.y),p=((e.x-d.x)*(a.y-d.y)-(e.y-d.y)*(a.x-d.x))/o,q=((b.x-a.x)*(a.y-d.y)-(b.y-a.y)*(a.x-d.x))/o;return p>=0&&1>=p&&q>=0&&1>=q?g:null}return g},c.Line.intersects=function(a,b,d,e){return c.Line.intersectsPoints(a.start,a.end,b.start,b.end,d,e)},c.Line.reflect=function(a,b){return 2*b.normalAngle-3.141592653589793-a.angle},c.Matrix=function(a,b,d,e,f,g){a=a||1,b=b||0,d=d||0,e=e||1,f=f||0,g=g||0,this.a=a,this.b=b,this.c=d,this.d=e,this.tx=f,this.ty=g,this.type=c.MATRIX},c.Matrix.prototype={fromArray:function(a){return this.setTo(a[0],a[1],a[3],a[4],a[2],a[5])},setTo:function(a,b,c,d,e,f){return this.a=a,this.b=b,this.c=c,this.d=d,this.tx=e,this.ty=f,this},clone:function(a){return void 0===a||null===a?a=new c.Matrix(this.a,this.b,this.c,this.d,this.tx,this.ty):(a.a=this.a,a.b=this.b,a.c=this.c,a.d=this.d,a.tx=this.tx,a.ty=this.ty),a},copyTo:function(a){return a.copyFrom(this),a},copyFrom:function(a){return this.a=a.a,this.b=a.b,this.c=a.c,this.d=a.d,this.tx=a.tx,this.ty=a.ty,this},toArray:function(a,b){return void 0===b&&(b=new PIXI.Float32Array(9)),a?(b[0]=this.a,b[1]=this.b,b[2]=0,b[3]=this.c,b[4]=this.d,b[5]=0,b[6]=this.tx,b[7]=this.ty,b[8]=1):(b[0]=this.a,b[1]=this.c,b[2]=this.tx,b[3]=this.b,b[4]=this.d,b[5]=this.ty,b[6]=0,b[7]=0,b[8]=1),b},apply:function(a,b){return void 0===b&&(b=new c.Point),b.x=this.a*a.x+this.c*a.y+this.tx,b.y=this.b*a.x+this.d*a.y+this.ty,b},applyInverse:function(a,b){void 0===b&&(b=new c.Point);var d=1/(this.a*this.d+this.c*-this.b),e=a.x,f=a.y;return b.x=this.d*d*e+-this.c*d*f+(this.ty*this.c-this.tx*this.d)*d,b.y=this.a*d*f+-this.b*d*e+(-this.ty*this.a+this.tx*this.b)*d,b},translate:function(a,b){return this.tx+=a,this.ty+=b,this},scale:function(a,b){return this.a*=a,this.d*=b,this.c*=a,this.b*=b,this.tx*=a,this.ty*=b,this},rotate:function(a){var b=Math.cos(a),c=Math.sin(a),d=this.a,e=this.c,f=this.tx;return this.a=d*b-this.b*c,this.b=d*c+this.b*b,this.c=e*b-this.d*c,this.d=e*c+this.d*b,this.tx=f*b-this.ty*c,this.ty=f*c+this.ty*b,this},append:function(a){var b=this.a,c=this.b,d=this.c,e=this.d;return this.a=a.a*b+a.b*d,this.b=a.a*c+a.b*e,this.c=a.c*b+a.d*d,this.d=a.c*c+a.d*e,this.tx=a.tx*b+a.ty*d+this.tx,this.ty=a.tx*c+a.ty*e+this.ty,this},identity:function(){return this.setTo(1,0,0,1,0,0)}},c.identityMatrix=new c.Matrix,PIXI.Matrix=c.Matrix,PIXI.identityMatrix=c.identityMatrix,c.Point=function(a,b){a=a||0,b=b||0,this.x=a,this.y=b,this.type=c.POINT},c.Point.prototype={copyFrom:function(a){return this.setTo(a.x,a.y)},invert:function(){return this.setTo(this.y,this.x)},setTo:function(a,b){return this.x=a||0,this.y=b||(0!==b?this.x:0), +this},set:function(a,b){return this.x=a||0,this.y=b||(0!==b?this.x:0),this},add:function(a,b){return this.x+=a,this.y+=b,this},subtract:function(a,b){return this.x-=a,this.y-=b,this},multiply:function(a,b){return this.x*=a,this.y*=b,this},divide:function(a,b){return this.x/=a,this.y/=b,this},clampX:function(a,b){return this.x=c.Math.clamp(this.x,a,b),this},clampY:function(a,b){return this.y=c.Math.clamp(this.y,a,b),this},clamp:function(a,b){return this.x=c.Math.clamp(this.x,a,b),this.y=c.Math.clamp(this.y,a,b),this},clone:function(a){return void 0===a||null===a?a=new c.Point(this.x,this.y):a.setTo(this.x,this.y),a},copyTo:function(a){return a.x=this.x,a.y=this.y,a},distance:function(a,b){return c.Point.distance(this,a,b)},equals:function(a){return a.x===this.x&&a.y===this.y},angle:function(a,b){return void 0===b&&(b=!1),b?c.Math.radToDeg(Math.atan2(a.y-this.y,a.x-this.x)):Math.atan2(a.y-this.y,a.x-this.x)},rotate:function(a,b,d,e,f){return c.Point.rotate(this,a,b,d,e,f)},getMagnitude:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},getMagnitudeSq:function(){return this.x*this.x+this.y*this.y},setMagnitude:function(a){return this.normalize().multiply(a,a)},normalize:function(){if(!this.isZero()){var a=this.getMagnitude();this.x/=a,this.y/=a}return this},isZero:function(){return 0===this.x&&0===this.y},dot:function(a){return this.x*a.x+this.y*a.y},cross:function(a){return this.x*a.y-this.y*a.x},perp:function(){return this.setTo(-this.y,this.x)},rperp:function(){return this.setTo(this.y,-this.x)},normalRightHand:function(){return this.setTo(-1*this.y,this.x)},floor:function(){return this.setTo(Math.floor(this.x),Math.floor(this.y))},ceil:function(){return this.setTo(Math.ceil(this.x),Math.ceil(this.y))},toString:function(){return"[{Point (x="+this.x+" y="+this.y+")}]"}},c.Point.prototype.constructor=c.Point,c.Point.add=function(a,b,d){return void 0===d&&(d=new c.Point),d.x=a.x+b.x,d.y=a.y+b.y,d},c.Point.subtract=function(a,b,d){return void 0===d&&(d=new c.Point),d.x=a.x-b.x,d.y=a.y-b.y,d},c.Point.multiply=function(a,b,d){return void 0===d&&(d=new c.Point),d.x=a.x*b.x,d.y=a.y*b.y,d},c.Point.divide=function(a,b,d){return void 0===d&&(d=new c.Point),d.x=a.x/b.x,d.y=a.y/b.y,d},c.Point.equals=function(a,b){return a.x===b.x&&a.y===b.y},c.Point.angle=function(a,b){return Math.atan2(a.y-b.y,a.x-b.x)},c.Point.negative=function(a,b){return void 0===b&&(b=new c.Point),b.setTo(-a.x,-a.y)},c.Point.multiplyAdd=function(a,b,d,e){return void 0===e&&(e=new c.Point),e.setTo(a.x+b.x*d,a.y+b.y*d)},c.Point.interpolate=function(a,b,d,e){return void 0===e&&(e=new c.Point),e.setTo(a.x+(b.x-a.x)*d,a.y+(b.y-a.y)*d)},c.Point.perp=function(a,b){return void 0===b&&(b=new c.Point),b.setTo(-a.y,a.x)},c.Point.rperp=function(a,b){return void 0===b&&(b=new c.Point),b.setTo(a.y,-a.x)},c.Point.distance=function(a,b,d){var e=c.Math.distance(a.x,a.y,b.x,b.y);return d?Math.round(e):e},c.Point.project=function(a,b,d){void 0===d&&(d=new c.Point);var e=a.dot(b)/b.getMagnitudeSq();return 0!==e&&d.setTo(e*b.x,e*b.y),d},c.Point.projectUnit=function(a,b,d){void 0===d&&(d=new c.Point);var e=a.dot(b);return 0!==e&&d.setTo(e*b.x,e*b.y),d},c.Point.normalRightHand=function(a,b){return void 0===b&&(b=new c.Point),b.setTo(-1*a.y,a.x)},c.Point.normalize=function(a,b){void 0===b&&(b=new c.Point);var d=a.getMagnitude();return 0!==d&&b.setTo(a.x/d,a.y/d),b},c.Point.rotate=function(a,b,d,e,f,g){if(f&&(e=c.Math.degToRad(e)),void 0===g){a.subtract(b,d);var h=Math.sin(e),i=Math.cos(e),j=i*a.x-h*a.y,k=h*a.x+i*a.y;a.x=j+b,a.y=k+d}else{var l=e+Math.atan2(a.y-d,a.x-b);a.x=b+g*Math.cos(l),a.y=d+g*Math.sin(l)}return a},c.Point.centroid=function(a,b){if(void 0===b&&(b=new c.Point),"[object Array]"!==Object.prototype.toString.call(a))throw new Error("Phaser.Point. Parameter 'points' must be an array");var d=a.length;if(1>d)throw new Error("Phaser.Point. Parameter 'points' array must not be empty");if(1===d)return b.copyFrom(a[0]),b;for(var e=0;d>e;e++)c.Point.add(b,a[e],b);return b.divide(d,d),b},c.Point.parse=function(a,b,d){b=b||"x",d=d||"y";var e=new c.Point;return a[b]&&(e.x=parseInt(a[b],10)),a[d]&&(e.y=parseInt(a[d],10)),e},PIXI.Point=c.Point,c.Polygon=function(){this.area=0,this._points=[],arguments.length>0&&this.setTo.apply(this,arguments),this.closed=!0,this.type=c.POLYGON},c.Polygon.prototype={toNumberArray:function(a){void 0===a&&(a=[]);for(var b=0;b<this._points.length;b++)"number"==typeof this._points[b]?(a.push(this._points[b]),a.push(this._points[b+1]),b++):(a.push(this._points[b].x),a.push(this._points[b].y));return a},flatten:function(){return this._points=this.toNumberArray(),this},clone:function(a){var b=this._points.slice();return void 0===a||null===a?a=new c.Polygon(b):a.setTo(b),a},contains:function(a,b){for(var c=this._points.length,d=!1,e=-1,f=c-1;++e<c;f=e){var g=this._points[e].x,h=this._points[e].y,i=this._points[f].x,j=this._points[f].y;(b>=h&&j>b||b>=j&&h>b)&&(i-g)*(b-h)/(j-h)+g>a&&(d=!d)}return d},setTo:function(a){if(this.area=0,this._points=[],arguments.length>0){Array.isArray(a)||(a=Array.prototype.slice.call(arguments));for(var b=Number.MAX_VALUE,c=0,d=a.length;d>c;c++){if("number"==typeof a[c]){var e=new PIXI.Point(a[c],a[c+1]);c++}else var e=new PIXI.Point(a[c].x,a[c].y);this._points.push(e),e.y<b&&(b=e.y)}this.calculateArea(b)}return this},calculateArea:function(a){for(var b,c,d,e,f=0,g=this._points.length;g>f;f++)b=this._points[f],c=f===g-1?this._points[0]:this._points[f+1],d=(b.y-a+(c.y-a))/2,e=b.x-c.x,this.area+=d*e;return this.area}},c.Polygon.prototype.constructor=c.Polygon,Object.defineProperty(c.Polygon.prototype,"points",{get:function(){return this._points},set:function(a){null!=a?this.setTo(a):this.setTo()}}),PIXI.Polygon=c.Polygon,c.Rectangle=function(a,b,d,e){a=a||0,b=b||0,d=d||0,e=e||0,this.x=a,this.y=b,this.width=d,this.height=e,this.type=c.RECTANGLE},c.Rectangle.prototype={offset:function(a,b){return this.x+=a,this.y+=b,this},offsetPoint:function(a){return this.offset(a.x,a.y)},setTo:function(a,b,c,d){return this.x=a,this.y=b,this.width=c,this.height=d,this},scale:function(a,b){return void 0===b&&(b=a),this.width*=a,this.height*=b,this},centerOn:function(a,b){return this.centerX=a,this.centerY=b,this},floor:function(){this.x=Math.floor(this.x),this.y=Math.floor(this.y)},floorAll:function(){this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.width=Math.floor(this.width),this.height=Math.floor(this.height)},ceil:function(){this.x=Math.ceil(this.x),this.y=Math.ceil(this.y)},ceilAll:function(){this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.width=Math.ceil(this.width),this.height=Math.ceil(this.height)},copyFrom:function(a){return this.setTo(a.x,a.y,a.width,a.height)},copyTo:function(a){return a.x=this.x,a.y=this.y,a.width=this.width,a.height=this.height,a},inflate:function(a,b){return c.Rectangle.inflate(this,a,b)},size:function(a){return c.Rectangle.size(this,a)},resize:function(a,b){return this.width=a,this.height=b,this},clone:function(a){return c.Rectangle.clone(this,a)},contains:function(a,b){return c.Rectangle.contains(this,a,b)},containsRect:function(a){return c.Rectangle.containsRect(a,this)},equals:function(a){return c.Rectangle.equals(this,a)},intersection:function(a,b){return c.Rectangle.intersection(this,a,b)},intersects:function(a){return c.Rectangle.intersects(this,a)},intersectsRaw:function(a,b,d,e,f){return c.Rectangle.intersectsRaw(this,a,b,d,e,f)},union:function(a,b){return c.Rectangle.union(this,a,b)},random:function(a){return void 0===a&&(a=new c.Point),a.x=this.randomX,a.y=this.randomY,a},toString:function(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" empty="+this.empty+")}]"}},Object.defineProperty(c.Rectangle.prototype,"halfWidth",{get:function(){return Math.round(this.width/2)}}),Object.defineProperty(c.Rectangle.prototype,"halfHeight",{get:function(){return Math.round(this.height/2)}}),Object.defineProperty(c.Rectangle.prototype,"bottom",{get:function(){return this.y+this.height},set:function(a){a<=this.y?this.height=0:this.height=a-this.y}}),Object.defineProperty(c.Rectangle.prototype,"bottomLeft",{get:function(){return new c.Point(this.x,this.bottom)},set:function(a){this.x=a.x,this.bottom=a.y}}),Object.defineProperty(c.Rectangle.prototype,"bottomRight",{get:function(){return new c.Point(this.right,this.bottom)},set:function(a){this.right=a.x,this.bottom=a.y}}),Object.defineProperty(c.Rectangle.prototype,"left",{get:function(){return this.x},set:function(a){a>=this.right?this.width=0:this.width=this.right-a,this.x=a}}),Object.defineProperty(c.Rectangle.prototype,"right",{get:function(){return this.x+this.width},set:function(a){a<=this.x?this.width=0:this.width=a-this.x}}),Object.defineProperty(c.Rectangle.prototype,"volume",{get:function(){return this.width*this.height}}),Object.defineProperty(c.Rectangle.prototype,"perimeter",{get:function(){return 2*this.width+2*this.height}}),Object.defineProperty(c.Rectangle.prototype,"centerX",{get:function(){return this.x+this.halfWidth},set:function(a){this.x=a-this.halfWidth}}),Object.defineProperty(c.Rectangle.prototype,"centerY",{get:function(){return this.y+this.halfHeight},set:function(a){this.y=a-this.halfHeight}}),Object.defineProperty(c.Rectangle.prototype,"randomX",{get:function(){return this.x+Math.random()*this.width}}),Object.defineProperty(c.Rectangle.prototype,"randomY",{get:function(){return this.y+Math.random()*this.height}}),Object.defineProperty(c.Rectangle.prototype,"top",{get:function(){return this.y},set:function(a){a>=this.bottom?(this.height=0,this.y=a):this.height=this.bottom-a}}),Object.defineProperty(c.Rectangle.prototype,"topLeft",{get:function(){return new c.Point(this.x,this.y)},set:function(a){this.x=a.x,this.y=a.y}}),Object.defineProperty(c.Rectangle.prototype,"topRight",{get:function(){return new c.Point(this.x+this.width,this.y)},set:function(a){this.right=a.x,this.y=a.y}}),Object.defineProperty(c.Rectangle.prototype,"empty",{get:function(){return!this.width||!this.height},set:function(a){a===!0&&this.setTo(0,0,0,0)}}),c.Rectangle.prototype.constructor=c.Rectangle,c.Rectangle.inflate=function(a,b,c){return a.x-=b,a.width+=2*b,a.y-=c,a.height+=2*c,a},c.Rectangle.inflatePoint=function(a,b){return c.Rectangle.inflate(a,b.x,b.y)},c.Rectangle.size=function(a,b){return void 0===b||null===b?b=new c.Point(a.width,a.height):b.setTo(a.width,a.height),b},c.Rectangle.clone=function(a,b){return void 0===b||null===b?b=new c.Rectangle(a.x,a.y,a.width,a.height):b.setTo(a.x,a.y,a.width,a.height),b},c.Rectangle.contains=function(a,b,c){return a.width<=0||a.height<=0?!1:b>=a.x&&b<a.right&&c>=a.y&&c<a.bottom},c.Rectangle.containsRaw=function(a,b,c,d,e,f){return e>=a&&a+c>e&&f>=b&&b+d>f},c.Rectangle.containsPoint=function(a,b){return c.Rectangle.contains(a,b.x,b.y)},c.Rectangle.containsRect=function(a,b){return a.volume>b.volume?!1:a.x>=b.x&&a.y>=b.y&&a.right<b.right&&a.bottom<b.bottom},c.Rectangle.equals=function(a,b){return a.x==b.x&&a.y==b.y&&a.width==b.width&&a.height==b.height},c.Rectangle.sameDimensions=function(a,b){return a.width===b.width&&a.height===b.height},c.Rectangle.intersection=function(a,b,d){return void 0===d&&(d=new c.Rectangle),c.Rectangle.intersects(a,b)&&(d.x=Math.max(a.x,b.x),d.y=Math.max(a.y,b.y),d.width=Math.min(a.right,b.right)-d.x,d.height=Math.min(a.bottom,b.bottom)-d.y),d},c.Rectangle.intersects=function(a,b){return a.width<=0||a.height<=0||b.width<=0||b.height<=0?!1:!(a.right<b.x||a.bottom<b.y||a.x>b.right||a.y>b.bottom)},c.Rectangle.intersectsRaw=function(a,b,c,d,e,f){return void 0===f&&(f=0),!(b>a.right+f||c<a.left-f||d>a.bottom+f||e<a.top-f)},c.Rectangle.union=function(a,b,d){return void 0===d&&(d=new c.Rectangle),d.setTo(Math.min(a.x,b.x),Math.min(a.y,b.y),Math.max(a.right,b.right)-Math.min(a.left,b.left),Math.max(a.bottom,b.bottom)-Math.min(a.top,b.top))},c.Rectangle.aabb=function(a,b){void 0===b&&(b=new c.Rectangle);var d=Number.MIN_VALUE,e=Number.MAX_VALUE,f=Number.MIN_VALUE,g=Number.MAX_VALUE;return a.forEach(function(a){a.x>d&&(d=a.x),a.x<e&&(e=a.x),a.y>f&&(f=a.y),a.y<g&&(g=a.y)}),b.setTo(e,g,d-e,f-g),b},PIXI.Rectangle=c.Rectangle,PIXI.EmptyRectangle=new c.Rectangle(0,0,0,0),c.RoundedRectangle=function(a,b,d,e,f){void 0===a&&(a=0),void 0===b&&(b=0),void 0===d&&(d=0),void 0===e&&(e=0),void 0===f&&(f=20),this.x=a,this.y=b,this.width=d,this.height=e,this.radius=f||20,this.type=c.ROUNDEDRECTANGLE},c.RoundedRectangle.prototype={clone:function(){return new c.RoundedRectangle(this.x,this.y,this.width,this.height,this.radius)},contains:function(a,b){if(this.width<=0||this.height<=0)return!1;var c=this.x;if(a>=c&&a<=c+this.width){var d=this.y;if(b>=d&&b<=d+this.height)return!0}return!1}},c.RoundedRectangle.prototype.constructor=c.RoundedRectangle,PIXI.RoundedRectangle=c.RoundedRectangle,c.Camera=function(a,b,d,e,f,g){this.game=a,this.world=a.world,this.id=0,this.view=new c.Rectangle(d,e,f,g),this.bounds=new c.Rectangle(d,e,f,g),this.deadzone=null,this.visible=!0,this.roundPx=!0,this.atLimit={x:!1,y:!1},this.target=null,this.displayObject=null,this.scale=null,this.totalInView=0,this._targetPosition=new c.Point,this._edge=0,this._position=new c.Point},c.Camera.FOLLOW_LOCKON=0,c.Camera.FOLLOW_PLATFORMER=1,c.Camera.FOLLOW_TOPDOWN=2,c.Camera.FOLLOW_TOPDOWN_TIGHT=3,c.Camera.prototype={preUpdate:function(){this.totalInView=0},follow:function(a,b){void 0===b&&(b=c.Camera.FOLLOW_LOCKON),this.target=a;var d;switch(b){case c.Camera.FOLLOW_PLATFORMER:var e=this.width/8,f=this.height/3;this.deadzone=new c.Rectangle((this.width-e)/2,(this.height-f)/2-.25*f,e,f);break;case c.Camera.FOLLOW_TOPDOWN:d=Math.max(this.width,this.height)/4,this.deadzone=new c.Rectangle((this.width-d)/2,(this.height-d)/2,d,d);break;case c.Camera.FOLLOW_TOPDOWN_TIGHT:d=Math.max(this.width,this.height)/8,this.deadzone=new c.Rectangle((this.width-d)/2,(this.height-d)/2,d,d);break;case c.Camera.FOLLOW_LOCKON:this.deadzone=null;break;default:this.deadzone=null}},unfollow:function(){this.target=null},focusOn:function(a){this.setPosition(Math.round(a.x-this.view.halfWidth),Math.round(a.y-this.view.halfHeight))},focusOnXY:function(a,b){this.setPosition(Math.round(a-this.view.halfWidth),Math.round(b-this.view.halfHeight))},update:function(){this.target&&this.updateTarget(),this.bounds&&this.checkBounds(),this.roundPx&&this.view.floor(),this.displayObject.position.x=-this.view.x,this.displayObject.position.y=-this.view.y},updateTarget:function(){this._targetPosition.copyFrom(this.target),this.target.parent&&this._targetPosition.multiply(this.target.parent.worldTransform.a,this.target.parent.worldTransform.d),this.deadzone?(this._edge=this._targetPosition.x-this.view.x,this._edge<this.deadzone.left?this.view.x=this._targetPosition.x-this.deadzone.left:this._edge>this.deadzone.right&&(this.view.x=this._targetPosition.x-this.deadzone.right),this._edge=this._targetPosition.y-this.view.y,this._edge<this.deadzone.top?this.view.y=this._targetPosition.y-this.deadzone.top:this._edge>this.deadzone.bottom&&(this.view.y=this._targetPosition.y-this.deadzone.bottom)):(this.view.x=this._targetPosition.x-this.view.halfWidth,this.view.y=this._targetPosition.y-this.view.halfHeight)},setBoundsToWorld:function(){this.bounds&&this.bounds.copyFrom(this.game.world.bounds)},checkBounds:function(){this.atLimit.x=!1,this.atLimit.y=!1,this.view.x<=this.bounds.x&&(this.atLimit.x=!0,this.view.x=this.bounds.x),this.view.right>=this.bounds.right&&(this.atLimit.x=!0,this.view.x=this.bounds.right-this.width),this.view.y<=this.bounds.top&&(this.atLimit.y=!0,this.view.y=this.bounds.top),this.view.bottom>=this.bounds.bottom&&(this.atLimit.y=!0,this.view.y=this.bounds.bottom-this.height)},setPosition:function(a,b){this.view.x=a,this.view.y=b,this.bounds&&this.checkBounds()},setSize:function(a,b){this.view.width=a,this.view.height=b},reset:function(){this.target=null,this.view.x=0,this.view.y=0}},c.Camera.prototype.constructor=c.Camera,Object.defineProperty(c.Camera.prototype,"x",{get:function(){return this.view.x},set:function(a){this.view.x=a,this.bounds&&this.checkBounds()}}),Object.defineProperty(c.Camera.prototype,"y",{get:function(){return this.view.y},set:function(a){this.view.y=a,this.bounds&&this.checkBounds()}}),Object.defineProperty(c.Camera.prototype,"position",{get:function(){return this._position.set(this.view.centerX,this.view.centerY),this._position},set:function(a){"undefined"!=typeof a.x&&(this.view.x=a.x),"undefined"!=typeof a.y&&(this.view.y=a.y),this.bounds&&this.checkBounds()}}),Object.defineProperty(c.Camera.prototype,"width",{get:function(){return this.view.width},set:function(a){this.view.width=a}}),Object.defineProperty(c.Camera.prototype,"height",{get:function(){return this.view.height},set:function(a){this.view.height=a}}),c.State=function(){this.game=null,this.key="",this.add=null,this.make=null,this.camera=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.sound=null,this.scale=null,this.stage=null,this.time=null,this.tweens=null,this.world=null,this.particles=null,this.physics=null,this.rnd=null},c.State.prototype={init:function(){},preload:function(){},loadUpdate:function(){},loadRender:function(){},create:function(){},update:function(){},preRender:function(){},render:function(){},resize:function(){},paused:function(){},resumed:function(){},pauseUpdate:function(){},shutdown:function(){}},c.State.prototype.constructor=c.State,c.StateManager=function(a,b){this.game=a,this.states={},this._pendingState=null,"undefined"!=typeof b&&null!==b&&(this._pendingState=b),this._clearWorld=!1,this._clearCache=!1,this._created=!1,this._args=[],this.current="",this.onStateChange=new c.Signal,this.onInitCallback=null,this.onPreloadCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onRenderCallback=null,this.onResizeCallback=null,this.onPreRenderCallback=null,this.onLoadUpdateCallback=null,this.onLoadRenderCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null,this.onShutDownCallback=null},c.StateManager.prototype={boot:function(){this.game.onPause.add(this.pause,this),this.game.onResume.add(this.resume,this),null!==this._pendingState&&"string"!=typeof this._pendingState&&this.add("default",this._pendingState,!0)},add:function(a,b,d){void 0===d&&(d=!1);var e;return b instanceof c.State?e=b:"object"==typeof b?(e=b,e.game=this.game):"function"==typeof b&&(e=new b(this.game)),this.states[a]=e,d&&(this.game.isBooted?this.start(a):this._pendingState=a),e},remove:function(a){this.current===a&&(this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onLoadRenderCallback=null,this.onLoadUpdateCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onPreRenderCallback=null,this.onRenderCallback=null,this.onResizeCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null),delete this.states[a]},start:function(a,b,c){void 0===b&&(b=!0),void 0===c&&(c=!1),this.checkState(a)&&(this._pendingState=a,this._clearWorld=b,this._clearCache=c,arguments.length>3&&(this._args=Array.prototype.splice.call(arguments,3)))},restart:function(a,b){void 0===a&&(a=!0),void 0===b&&(b=!1),this._pendingState=this.current,this._clearWorld=a,this._clearCache=b,arguments.length>2&&(this._args=Array.prototype.slice.call(arguments,2))},dummy:function(){},preUpdate:function(){if(this._pendingState&&this.game.isBooted){var a=this.current;if(this.clearCurrentState(),this.setCurrentState(this._pendingState),this.onStateChange.dispatch(this.current,a),this.current!==this._pendingState)return;this._pendingState=null,this.onPreloadCallback?(this.game.load.reset(!0),this.onPreloadCallback.call(this.callbackContext,this.game),0===this.game.load.totalQueuedFiles()&&0===this.game.load.totalQueuedPacks()?this.loadComplete():this.game.load.start()):this.loadComplete()}},clearCurrentState:function(){this.current&&(this.onShutDownCallback&&this.onShutDownCallback.call(this.callbackContext,this.game),this.game.tweens.removeAll(),this.game.camera.reset(),this.game.input.reset(!0),this.game.physics.clear(),this.game.time.removeAll(),this.game.scale.reset(this._clearWorld),this.game.debug&&this.game.debug.reset(),this._clearWorld&&(this.game.world.shutdown(),this._clearCache===!0&&this.game.cache.destroy()))},checkState:function(a){if(this.states[a]){var b=!1;return(this.states[a].preload||this.states[a].create||this.states[a].update||this.states[a].render)&&(b=!0),b===!1?(console.warn("Invalid Phaser State object given. Must contain at least a one of the required functions: preload, create, update or render"),!1):!0}return console.warn("Phaser.StateManager - No state found with the key: "+a),!1},link:function(a){this.states[a].game=this.game,this.states[a].add=this.game.add,this.states[a].make=this.game.make,this.states[a].camera=this.game.camera,this.states[a].cache=this.game.cache,this.states[a].input=this.game.input,this.states[a].load=this.game.load,this.states[a].math=this.game.math,this.states[a].sound=this.game.sound,this.states[a].scale=this.game.scale,this.states[a].state=this,this.states[a].stage=this.game.stage,this.states[a].time=this.game.time,this.states[a].tweens=this.game.tweens,this.states[a].world=this.game.world,this.states[a].particles=this.game.particles,this.states[a].rnd=this.game.rnd,this.states[a].physics=this.game.physics,this.states[a].key=a},unlink:function(a){this.states[a]&&(this.states[a].game=null,this.states[a].add=null,this.states[a].make=null,this.states[a].camera=null,this.states[a].cache=null,this.states[a].input=null,this.states[a].load=null,this.states[a].math=null,this.states[a].sound=null,this.states[a].scale=null,this.states[a].state=null,this.states[a].stage=null,this.states[a].time=null,this.states[a].tweens=null,this.states[a].world=null,this.states[a].particles=null,this.states[a].rnd=null,this.states[a].physics=null)},setCurrentState:function(a){this.callbackContext=this.states[a],this.link(a),this.onInitCallback=this.states[a].init||this.dummy,this.onPreloadCallback=this.states[a].preload||null,this.onLoadRenderCallback=this.states[a].loadRender||null,this.onLoadUpdateCallback=this.states[a].loadUpdate||null,this.onCreateCallback=this.states[a].create||null,this.onUpdateCallback=this.states[a].update||null,this.onPreRenderCallback=this.states[a].preRender||null,this.onRenderCallback=this.states[a].render||null,this.onResizeCallback=this.states[a].resize||null,this.onPausedCallback=this.states[a].paused||null,this.onResumedCallback=this.states[a].resumed||null,this.onPauseUpdateCallback=this.states[a].pauseUpdate||null,this.onShutDownCallback=this.states[a].shutdown||this.dummy,""!==this.current&&this.game.physics.reset(),this.current=a,this._created=!1,this.onInitCallback.apply(this.callbackContext,this._args),a===this._pendingState&&(this._args=[]),this.game._kickstart=!0},getCurrentState:function(){return this.states[this.current]},loadComplete:function(){this._created===!1&&this.onCreateCallback?(this._created=!0,this.onCreateCallback.call(this.callbackContext,this.game)):this._created=!0},pause:function(){this._created&&this.onPausedCallback&&this.onPausedCallback.call(this.callbackContext,this.game)},resume:function(){this._created&&this.onResumedCallback&&this.onResumedCallback.call(this.callbackContext,this.game)},update:function(){this._created?this.onUpdateCallback&&this.onUpdateCallback.call(this.callbackContext,this.game):this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game)},pauseUpdate:function(){this._created?this.onPauseUpdateCallback&&this.onPauseUpdateCallback.call(this.callbackContext,this.game):this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game)},preRender:function(a){this._created&&this.onPreRenderCallback&&this.onPreRenderCallback.call(this.callbackContext,this.game,a)},resize:function(a,b){this.onResizeCallback&&this.onResizeCallback.call(this.callbackContext,a,b)},render:function(){this._created?this.onRenderCallback&&(this.game.renderType===c.CANVAS?(this.game.context.save(),this.game.context.setTransform(1,0,0,1,0,0),this.onRenderCallback.call(this.callbackContext,this.game),this.game.context.restore()):this.onRenderCallback.call(this.callbackContext,this.game)):this.onLoadRenderCallback&&this.onLoadRenderCallback.call(this.callbackContext,this.game)},destroy:function(){this.clearCurrentState(),this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onLoadRenderCallback=null,this.onLoadUpdateCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onRenderCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null,this.game=null,this.states={},this._pendingState=null,this.current=""}},c.StateManager.prototype.constructor=c.StateManager,Object.defineProperty(c.StateManager.prototype,"created",{get:function(){return this._created}}),c.Signal=function(){},c.Signal.prototype={_bindings:null,_prevParams:null,memorize:!1,_shouldPropagate:!0,active:!0,_boundDispatch:!0,validateListener:function(a,b){if("function"!=typeof a)throw new Error("Phaser.Signal: listener is a required param of {fn}() and should be a Function.".replace("{fn}",b))},_registerListener:function(a,b,d,e,f){var g,h=this._indexOfListener(a,d);if(-1!==h){if(g=this._bindings[h],g.isOnce()!==b)throw new Error("You cannot add"+(b?"":"Once")+"() then add"+(b?"Once":"")+"() the same listener without removing the relationship first.")}else g=new c.SignalBinding(this,a,b,d,e,f),this._addBinding(g);return this.memorize&&this._prevParams&&g.execute(this._prevParams),g},_addBinding:function(a){this._bindings||(this._bindings=[]);var b=this._bindings.length;do b--;while(this._bindings[b]&&a._priority<=this._bindings[b]._priority);this._bindings.splice(b+1,0,a)},_indexOfListener:function(a,b){if(!this._bindings)return-1;void 0===b&&(b=null);for(var c,d=this._bindings.length;d--;)if(c=this._bindings[d],c._listener===a&&c.context===b)return d;return-1},has:function(a,b){return-1!==this._indexOfListener(a,b)},add:function(a,b,c){this.validateListener(a,"add");var d=[];if(arguments.length>3)for(var e=3;e<arguments.length;e++)d.push(arguments[e]);return this._registerListener(a,!1,b,c,d)},addOnce:function(a,b,c){this.validateListener(a,"addOnce");var d=[];if(arguments.length>3)for(var e=3;e<arguments.length;e++)d.push(arguments[e]);return this._registerListener(a,!0,b,c,d)},remove:function(a,b){this.validateListener(a,"remove");var c=this._indexOfListener(a,b);return-1!==c&&(this._bindings[c]._destroy(),this._bindings.splice(c,1)),a},removeAll:function(a){if(void 0===a&&(a=null),this._bindings){for(var b=this._bindings.length;b--;)a?this._bindings[b].context===a&&(this._bindings[b]._destroy(),this._bindings.splice(b,1)):this._bindings[b]._destroy();a||(this._bindings.length=0)}},getNumListeners:function(){return this._bindings?this._bindings.length:0},halt:function(){this._shouldPropagate=!1},dispatch:function(){if(this.active&&this._bindings){var a,b=Array.prototype.slice.call(arguments),c=this._bindings.length;if(this.memorize&&(this._prevParams=b),c){a=this._bindings.slice(),this._shouldPropagate=!0;do c--;while(a[c]&&this._shouldPropagate&&a[c].execute(b)!==!1)}}},forget:function(){this._prevParams&&(this._prevParams=null)},dispose:function(){this.removeAll(),this._bindings=null,this._prevParams&&(this._prevParams=null)},toString:function(){return"[Phaser.Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}},Object.defineProperty(c.Signal.prototype,"boundDispatch",{get:function(){var a=this;return this._boundDispatch||(this._boundDispatch=function(){return a.dispatch.apply(a,arguments)})}}),c.Signal.prototype.constructor=c.Signal,c.SignalBinding=function(a,b,c,d,e,f){this._listener=b,c&&(this._isOnce=!0),null!=d&&(this.context=d),this._signal=a,e&&(this._priority=e),f&&f.length&&(this._args=f)},c.SignalBinding.prototype={context:null,_isOnce:!1,_priority:0,_args:null,callCount:0,active:!0,params:null,execute:function(a){var b,c;return this.active&&this._listener&&(c=this.params?this.params.concat(a):a,this._args&&(c=c.concat(this._args)),b=this._listener.apply(this.context,c),this.callCount++,this._isOnce&&this.detach()),b},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal,delete this._listener,delete this.context},toString:function(){return"[Phaser.SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}},c.SignalBinding.prototype.constructor=c.SignalBinding,c.Filter=function(a,b,d){this.game=a,this.type=c.WEBGL_FILTER,this.passes=[this],this.shaders=[],this.dirty=!0,this.padding=0,this.prevPoint=new c.Point;var e=new Date;if(this.uniforms={resolution:{type:"2f",value:{x:256,y:256}},time:{type:"1f",value:0},mouse:{type:"2f",value:{x:0,y:0}},date:{type:"4fv",value:[e.getFullYear(),e.getMonth(),e.getDate(),60*e.getHours()*60+60*e.getMinutes()+e.getSeconds()]},sampleRate:{type:"1f",value:44100},iChannel0:{type:"sampler2D",value:null,textureData:{repeat:!0}},iChannel1:{type:"sampler2D",value:null,textureData:{repeat:!0}},iChannel2:{type:"sampler2D",value:null,textureData:{repeat:!0}},iChannel3:{type:"sampler2D",value:null,textureData:{repeat:!0}}},b)for(var f in b)this.uniforms[f]=b[f];this.fragmentSrc=d||""},c.Filter.prototype={init:function(){},setResolution:function(a,b){this.uniforms.resolution.value.x=a,this.uniforms.resolution.value.y=b},update:function(a){if("undefined"!=typeof a){var b=a.x/this.game.width,c=1-a.y/this.game.height;(b!==this.prevPoint.x||c!==this.prevPoint.y)&&(this.uniforms.mouse.value.x=b.toFixed(2),this.uniforms.mouse.value.y=c.toFixed(2),this.prevPoint.set(b,c))}this.uniforms.time.value=this.game.time.totalElapsedSeconds()},addToWorld:function(a,b,c,d,e,f){void 0===e&&(e=0),void 0===f&&(f=0),void 0!==c&&null!==c?this.width=c:c=this.width,void 0!==d&&null!==d?this.height=d:d=this.height;var g=this.game.add.image(a,b,"__default");return g.width=c,g.height=d,g.anchor.set(e,f),g.filters=[this],g},destroy:function(){this.game=null}},c.Filter.prototype.constructor=c.Filter,Object.defineProperty(c.Filter.prototype,"width",{get:function(){return this.uniforms.resolution.value.x},set:function(a){this.uniforms.resolution.value.x=a}}),Object.defineProperty(c.Filter.prototype,"height",{get:function(){return this.uniforms.resolution.value.y},set:function(a){this.uniforms.resolution.value.y=a}}),c.Plugin=function(a,b){void 0===b&&(b=null),this.game=a,this.parent=b,this.active=!1,this.visible=!1,this.hasPreUpdate=!1,this.hasUpdate=!1,this.hasPostUpdate=!1,this.hasRender=!1,this.hasPostRender=!1},c.Plugin.prototype={preUpdate:function(){},update:function(){},render:function(){},postRender:function(){},destroy:function(){this.game=null,this.parent=null,this.active=!1,this.visible=!1}},c.Plugin.prototype.constructor=c.Plugin,c.PluginManager=function(a){this.game=a,this.plugins=[],this._len=0,this._i=0},c.PluginManager.prototype={add:function(a){var b=Array.prototype.slice.call(arguments,1),c=!1;return"function"==typeof a?a=new a(this.game,this):(a.game=this.game,a.parent=this),"function"==typeof a.preUpdate&&(a.hasPreUpdate=!0,c=!0),"function"==typeof a.update&&(a.hasUpdate=!0,c=!0),"function"==typeof a.postUpdate&&(a.hasPostUpdate=!0,c=!0),"function"==typeof a.render&&(a.hasRender=!0,c=!0),"function"==typeof a.postRender&&(a.hasPostRender=!0,c=!0),c?((a.hasPreUpdate||a.hasUpdate||a.hasPostUpdate)&&(a.active=!0),(a.hasRender||a.hasPostRender)&&(a.visible=!0),this._len=this.plugins.push(a),"function"==typeof a.init&&a.init.apply(a,b),a):null},remove:function(a){for(this._i=this._len;this._i--;)if(this.plugins[this._i]===a)return a.destroy(), +this.plugins.splice(this._i,1),void this._len--},removeAll:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].destroy();this.plugins.length=0,this._len=0},preUpdate:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].active&&this.plugins[this._i].hasPreUpdate&&this.plugins[this._i].preUpdate()},update:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].active&&this.plugins[this._i].hasUpdate&&this.plugins[this._i].update()},postUpdate:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].active&&this.plugins[this._i].hasPostUpdate&&this.plugins[this._i].postUpdate()},render:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].visible&&this.plugins[this._i].hasRender&&this.plugins[this._i].render()},postRender:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].visible&&this.plugins[this._i].hasPostRender&&this.plugins[this._i].postRender()},destroy:function(){this.removeAll(),this.game=null}},c.PluginManager.prototype.constructor=c.PluginManager,c.Stage=function(a){this.game=a,PIXI.DisplayObjectContainer.call(this),this.name="_stage_root",this.disableVisibilityChange=!1,this.exists=!0,this.worldTransform=new PIXI.Matrix,this.stage=this,this.currentRenderOrderID=0,this._hiddenVar="hidden",this._onChange=null,this._bgColor={r:0,g:0,b:0,a:0,color:0,rgba:"#000000"},this.game.transparent||(this._bgColor.a=1),a.config&&this.parseConfig(a.config)},c.Stage.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),c.Stage.prototype.constructor=c.Stage,c.Stage.prototype.parseConfig=function(a){a.disableVisibilityChange&&(this.disableVisibilityChange=a.disableVisibilityChange),a.backgroundColor&&this.setBackgroundColor(a.backgroundColor)},c.Stage.prototype.boot=function(){c.DOM.getOffset(this.game.canvas,this.offset),c.Canvas.setUserSelect(this.game.canvas,"none"),c.Canvas.setTouchAction(this.game.canvas,"none"),this.checkVisibility()},c.Stage.prototype.preUpdate=function(){this.currentRenderOrderID=0;for(var a=0;a<this.children.length;a++)this.children[a].preUpdate()},c.Stage.prototype.update=function(){for(var a=this.children.length;a--;)this.children[a].update()},c.Stage.prototype.postUpdate=function(){if(this.game.world.camera.target){this.game.world.camera.target.postUpdate(),this.game.world.camera.update();for(var a=this.children.length;a--;)this.children[a]!==this.game.world.camera.target&&this.children[a].postUpdate()}else{this.game.world.camera.update();for(var a=this.children.length;a--;)this.children[a].postUpdate()}},c.Stage.prototype.updateTransform=function(){this.worldAlpha=1;for(var a=0;a<this.children.length;a++)this.children[a].updateTransform()},c.Stage.prototype.checkVisibility=function(){void 0!==document.webkitHidden?this._hiddenVar="webkitvisibilitychange":void 0!==document.mozHidden?this._hiddenVar="mozvisibilitychange":void 0!==document.msHidden?this._hiddenVar="msvisibilitychange":void 0!==document.hidden?this._hiddenVar="visibilitychange":this._hiddenVar=null;var a=this;this._onChange=function(b){return a.visibilityChange(b)},this._hiddenVar&&document.addEventListener(this._hiddenVar,this._onChange,!1),window.onblur=this._onChange,window.onfocus=this._onChange,window.onpagehide=this._onChange,window.onpageshow=this._onChange,this.game.device.cocoonJSApp&&(CocoonJS.App.onSuspended.addEventListener(function(){c.Stage.prototype.visibilityChange.call(a,{type:"pause"})}),CocoonJS.App.onActivated.addEventListener(function(){c.Stage.prototype.visibilityChange.call(a,{type:"resume"})}))},c.Stage.prototype.visibilityChange=function(a){return"pagehide"===a.type||"blur"===a.type||"pageshow"===a.type||"focus"===a.type?void("pagehide"===a.type||"blur"===a.type?this.game.focusLoss(a):("pageshow"===a.type||"focus"===a.type)&&this.game.focusGain(a)):void(this.disableVisibilityChange||(document.hidden||document.mozHidden||document.msHidden||document.webkitHidden||"pause"===a.type?this.game.gamePaused(a):this.game.gameResumed(a)))},c.Stage.prototype.setBackgroundColor=function(a){this.game.transparent||(c.Color.valueToColor(a,this._bgColor),c.Color.updateColor(this._bgColor),this._bgColor.r/=255,this._bgColor.g/=255,this._bgColor.b/=255,this._bgColor.a=1)},c.Stage.prototype.destroy=function(){this._hiddenVar&&document.removeEventListener(this._hiddenVar,this._onChange,!1),window.onpagehide=null,window.onpageshow=null,window.onblur=null,window.onfocus=null},Object.defineProperty(c.Stage.prototype,"backgroundColor",{get:function(){return this._bgColor.color},set:function(a){this.setBackgroundColor(a)}}),Object.defineProperty(c.Stage.prototype,"smoothed",{get:function(){return PIXI.scaleModes.DEFAULT===PIXI.scaleModes.LINEAR},set:function(a){a?PIXI.scaleModes.DEFAULT=PIXI.scaleModes.LINEAR:PIXI.scaleModes.DEFAULT=PIXI.scaleModes.NEAREST}}),c.Group=function(a,b,d,e,f,g){void 0===e&&(e=!1),void 0===f&&(f=!1),void 0===g&&(g=c.Physics.ARCADE),this.game=a,void 0===b&&(b=a.world),this.name=d||"group",this.z=0,PIXI.DisplayObjectContainer.call(this),e?(this.game.stage.addChild(this),this.z=this.game.stage.children.length):b&&(b.addChild(this),this.z=b.children.length),this.type=c.GROUP,this.physicsType=c.GROUP,this.alive=!0,this.exists=!0,this.ignoreDestroy=!1,this.pendingDestroy=!1,this.classType=c.Sprite,this.cursor=null,this.enableBody=f,this.enableBodyDebug=!1,this.physicsBodyType=g,this.physicsSortDirection=null,this.onDestroy=new c.Signal,this.cursorIndex=0,this.fixedToCamera=!1,this.cameraOffset=new c.Point,this.hash=[],this._sortProperty="z"},c.Group.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),c.Group.prototype.constructor=c.Group,c.Group.RETURN_NONE=0,c.Group.RETURN_TOTAL=1,c.Group.RETURN_CHILD=2,c.Group.SORT_ASCENDING=-1,c.Group.SORT_DESCENDING=1,c.Group.prototype.add=function(a,b){return void 0===b&&(b=!1),a.parent!==this&&(this.addChild(a),a.z=this.children.length,this.enableBody&&null===a.body?this.game.physics.enable(a,this.physicsBodyType):a.body&&this.addToHash(a),!b&&a.events&&a.events.onAddedToGroup$dispatch(a,this),null===this.cursor&&(this.cursor=a)),a},c.Group.prototype.addToHash=function(a){if(a.parent===this){var b=this.hash.indexOf(a);if(-1===b)return this.hash.push(a),!0}return!1},c.Group.prototype.removeFromHash=function(a){if(a){var b=this.hash.indexOf(a);if(-1!==b)return this.hash.splice(b,1),!0}return!1},c.Group.prototype.addMultiple=function(a,b){if(a instanceof c.Group)a.moveAll(this,b);else if(Array.isArray(a))for(var d=0;d<a.length;d++)this.add(a[d],b);return a},c.Group.prototype.addAt=function(a,b,c){return void 0===c&&(c=!1),a.parent!==this&&(this.addChildAt(a,b),this.updateZ(),this.enableBody&&null===a.body?this.game.physics.enable(a,this.physicsBodyType):a.body&&this.addToHash(a),!c&&a.events&&a.events.onAddedToGroup$dispatch(a,this),null===this.cursor&&(this.cursor=a)),a},c.Group.prototype.getAt=function(a){return 0>a||a>=this.children.length?-1:this.getChildAt(a)},c.Group.prototype.create=function(a,b,c,d,e){void 0===e&&(e=!0);var f=new this.classType(this.game,a,b,c,d);return f.exists=e,f.visible=e,f.alive=e,this.addChild(f),f.z=this.children.length,this.enableBody&&this.game.physics.enable(f,this.physicsBodyType,this.enableBodyDebug),f.events&&f.events.onAddedToGroup$dispatch(f,this),null===this.cursor&&(this.cursor=f),f},c.Group.prototype.createMultiple=function(a,b,c,d){void 0===d&&(d=!1);for(var e=0;a>e;e++)this.create(0,0,b,c,d)},c.Group.prototype.updateZ=function(){for(var a=this.children.length;a--;)this.children[a].z=a},c.Group.prototype.resetCursor=function(a){return void 0===a&&(a=0),a>this.children.length-1&&(a=0),this.cursor?(this.cursorIndex=a,this.cursor=this.children[this.cursorIndex],this.cursor):void 0},c.Group.prototype.next=function(){return this.cursor?(this.cursorIndex>=this.children.length-1?this.cursorIndex=0:this.cursorIndex++,this.cursor=this.children[this.cursorIndex],this.cursor):void 0},c.Group.prototype.previous=function(){return this.cursor?(0===this.cursorIndex?this.cursorIndex=this.children.length-1:this.cursorIndex--,this.cursor=this.children[this.cursorIndex],this.cursor):void 0},c.Group.prototype.swap=function(a,b){this.swapChildren(a,b),this.updateZ()},c.Group.prototype.bringToTop=function(a){return a.parent===this&&this.getIndex(a)<this.children.length&&(this.remove(a,!1,!0),this.add(a,!0)),a},c.Group.prototype.sendToBack=function(a){return a.parent===this&&this.getIndex(a)>0&&(this.remove(a,!1,!0),this.addAt(a,0,!0)),a},c.Group.prototype.moveUp=function(a){if(a.parent===this&&this.getIndex(a)<this.children.length-1){var b=this.getIndex(a),c=this.getAt(b+1);c&&this.swap(a,c)}return a},c.Group.prototype.moveDown=function(a){if(a.parent===this&&this.getIndex(a)>0){var b=this.getIndex(a),c=this.getAt(b-1);c&&this.swap(a,c)}return a},c.Group.prototype.xy=function(a,b,c){return 0>a||a>this.children.length?-1:(this.getChildAt(a).x=b,void(this.getChildAt(a).y=c))},c.Group.prototype.reverse=function(){this.children.reverse(),this.updateZ()},c.Group.prototype.getIndex=function(a){return this.children.indexOf(a)},c.Group.prototype.replace=function(a,b){var d=this.getIndex(a);return-1!==d?(b.parent&&(b.parent instanceof c.Group?b.parent.remove(b):b.parent.removeChild(b)),this.remove(a),this.addAt(b,d),a):void 0},c.Group.prototype.hasProperty=function(a,b){var c=b.length;return 1===c&&b[0]in a?!0:2===c&&b[0]in a&&b[1]in a[b[0]]?!0:3===c&&b[0]in a&&b[1]in a[b[0]]&&b[2]in a[b[0]][b[1]]?!0:4===c&&b[0]in a&&b[1]in a[b[0]]&&b[2]in a[b[0]][b[1]]&&b[3]in a[b[0]][b[1]][b[2]]?!0:!1},c.Group.prototype.setProperty=function(a,b,c,d,e){if(void 0===e&&(e=!1),d=d||0,!this.hasProperty(a,b)&&(!e||d>0))return!1;var f=b.length;return 1===f?0===d?a[b[0]]=c:1==d?a[b[0]]+=c:2==d?a[b[0]]-=c:3==d?a[b[0]]*=c:4==d&&(a[b[0]]/=c):2===f?0===d?a[b[0]][b[1]]=c:1==d?a[b[0]][b[1]]+=c:2==d?a[b[0]][b[1]]-=c:3==d?a[b[0]][b[1]]*=c:4==d&&(a[b[0]][b[1]]/=c):3===f?0===d?a[b[0]][b[1]][b[2]]=c:1==d?a[b[0]][b[1]][b[2]]+=c:2==d?a[b[0]][b[1]][b[2]]-=c:3==d?a[b[0]][b[1]][b[2]]*=c:4==d&&(a[b[0]][b[1]][b[2]]/=c):4===f&&(0===d?a[b[0]][b[1]][b[2]][b[3]]=c:1==d?a[b[0]][b[1]][b[2]][b[3]]+=c:2==d?a[b[0]][b[1]][b[2]][b[3]]-=c:3==d?a[b[0]][b[1]][b[2]][b[3]]*=c:4==d&&(a[b[0]][b[1]][b[2]][b[3]]/=c)),!0},c.Group.prototype.checkProperty=function(a,b,d,e){return void 0===e&&(e=!1),!c.Utils.getProperty(a,b)&&e?!1:c.Utils.getProperty(a,b)!==d?!1:!0},c.Group.prototype.set=function(a,b,c,d,e,f,g){return void 0===g&&(g=!1),b=b.split("."),void 0===d&&(d=!1),void 0===e&&(e=!1),(d===!1||d&&a.alive)&&(e===!1||e&&a.visible)?this.setProperty(a,b,c,f,g):void 0},c.Group.prototype.setAll=function(a,b,c,d,e,f){void 0===c&&(c=!1),void 0===d&&(d=!1),void 0===f&&(f=!1),a=a.split("."),e=e||0;for(var g=0;g<this.children.length;g++)(!c||c&&this.children[g].alive)&&(!d||d&&this.children[g].visible)&&this.setProperty(this.children[g],a,b,e,f)},c.Group.prototype.setAllChildren=function(a,b,d,e,f,g){void 0===d&&(d=!1),void 0===e&&(e=!1),void 0===g&&(g=!1),f=f||0;for(var h=0;h<this.children.length;h++)(!d||d&&this.children[h].alive)&&(!e||e&&this.children[h].visible)&&(this.children[h]instanceof c.Group?this.children[h].setAllChildren(a,b,d,e,f,g):this.setProperty(this.children[h],a.split("."),b,f,g))},c.Group.prototype.checkAll=function(a,b,c,d,e){void 0===c&&(c=!1),void 0===d&&(d=!1),void 0===e&&(e=!1);for(var f=0;f<this.children.length;f++)if((!c||c&&this.children[f].alive)&&(!d||d&&this.children[f].visible)&&!this.checkProperty(this.children[f],a,b,e))return!1;return!0},c.Group.prototype.addAll=function(a,b,c,d){this.setAll(a,b,c,d,1)},c.Group.prototype.subAll=function(a,b,c,d){this.setAll(a,b,c,d,2)},c.Group.prototype.multiplyAll=function(a,b,c,d){this.setAll(a,b,c,d,3)},c.Group.prototype.divideAll=function(a,b,c,d){this.setAll(a,b,c,d,4)},c.Group.prototype.callAllExists=function(a,b){var c;if(arguments.length>2){c=[];for(var d=2;d<arguments.length;d++)c.push(arguments[d])}for(var d=0;d<this.children.length;d++)this.children[d].exists===b&&this.children[d][a]&&this.children[d][a].apply(this.children[d],c)},c.Group.prototype.callbackFromArray=function(a,b,c){if(1==c){if(a[b[0]])return a[b[0]]}else if(2==c){if(a[b[0]][b[1]])return a[b[0]][b[1]]}else if(3==c){if(a[b[0]][b[1]][b[2]])return a[b[0]][b[1]][b[2]]}else if(4==c){if(a[b[0]][b[1]][b[2]][b[3]])return a[b[0]][b[1]][b[2]][b[3]]}else if(a[b])return a[b];return!1},c.Group.prototype.callAll=function(a,b){if(void 0!==a){a=a.split(".");var c=a.length;if(void 0===b||null===b||""===b)b=null;else if("string"==typeof b){b=b.split(".");var d=b.length}var e;if(arguments.length>2){e=[];for(var f=2;f<arguments.length;f++)e.push(arguments[f])}for(var g=null,h=null,f=0;f<this.children.length;f++)g=this.callbackFromArray(this.children[f],a,c),b&&g?(h=this.callbackFromArray(this.children[f],b,d),g&&g.apply(h,e)):g&&g.apply(this.children[f],e)}},c.Group.prototype.preUpdate=function(){if(this.pendingDestroy)return this.destroy(),!1;if(!this.exists||!this.parent.exists)return this.renderOrderID=-1,!1;for(var a=this.children.length;a--;)this.children[a].preUpdate();return!0},c.Group.prototype.update=function(){for(var a=this.children.length;a--;)this.children[a].update()},c.Group.prototype.postUpdate=function(){this.fixedToCamera&&(this.x=this.game.camera.view.x+this.cameraOffset.x,this.y=this.game.camera.view.y+this.cameraOffset.y);for(var a=this.children.length;a--;)this.children[a].postUpdate()},c.Group.prototype.filter=function(a,b){for(var d=-1,e=this.children.length,f=[];++d<e;){var g=this.children[d];(!b||b&&g.exists)&&a(g,d,this.children)&&f.push(g)}return new c.ArraySet(f)},c.Group.prototype.forEach=function(a,b,c){if(void 0===c&&(c=!1),arguments.length<=3)for(var d=0;d<this.children.length;d++)(!c||c&&this.children[d].exists)&&a.call(b,this.children[d]);else{for(var e=[null],d=3;d<arguments.length;d++)e.push(arguments[d]);for(var d=0;d<this.children.length;d++)(!c||c&&this.children[d].exists)&&(e[0]=this.children[d],a.apply(b,e))}},c.Group.prototype.forEachExists=function(a,b){var d;if(arguments.length>2){d=[null];for(var e=2;e<arguments.length;e++)d.push(arguments[e])}this.iterate("exists",!0,c.Group.RETURN_TOTAL,a,b,d)},c.Group.prototype.forEachAlive=function(a,b){var d;if(arguments.length>2){d=[null];for(var e=2;e<arguments.length;e++)d.push(arguments[e])}this.iterate("alive",!0,c.Group.RETURN_TOTAL,a,b,d)},c.Group.prototype.forEachDead=function(a,b){var d;if(arguments.length>2){d=[null];for(var e=2;e<arguments.length;e++)d.push(arguments[e])}this.iterate("alive",!1,c.Group.RETURN_TOTAL,a,b,d)},c.Group.prototype.sort=function(a,b){this.children.length<2||(void 0===a&&(a="z"),void 0===b&&(b=c.Group.SORT_ASCENDING),this._sortProperty=a,b===c.Group.SORT_ASCENDING?this.children.sort(this.ascendingSortHandler.bind(this)):this.children.sort(this.descendingSortHandler.bind(this)),this.updateZ())},c.Group.prototype.customSort=function(a,b){this.children.length<2||(this.children.sort(a.bind(b)),this.updateZ())},c.Group.prototype.ascendingSortHandler=function(a,b){return a[this._sortProperty]<b[this._sortProperty]?-1:a[this._sortProperty]>b[this._sortProperty]?1:a.z<b.z?-1:1},c.Group.prototype.descendingSortHandler=function(a,b){return a[this._sortProperty]<b[this._sortProperty]?1:a[this._sortProperty]>b[this._sortProperty]?-1:0},c.Group.prototype.iterate=function(a,b,d,e,f,g){if(d===c.Group.RETURN_TOTAL&&0===this.children.length)return 0;for(var h=0,i=0;i<this.children.length;i++)if(this.children[i][a]===b&&(h++,e&&(g?(g[0]=this.children[i],e.apply(f,g)):e.call(f,this.children[i])),d===c.Group.RETURN_CHILD))return this.children[i];return d===c.Group.RETURN_TOTAL?h:null},c.Group.prototype.getFirstExists=function(a,b,d,e,f,g){void 0===b&&(b=!1),"boolean"!=typeof a&&(a=!0);var h=this.iterate("exists",a,c.Group.RETURN_CHILD);return null===h&&b?this.create(d,e,f,g):this.resetChild(h,d,e,f,g)},c.Group.prototype.getFirstAlive=function(a,b,d,e,f){void 0===a&&(a=!1);var g=this.iterate("alive",!0,c.Group.RETURN_CHILD);return null===g&&a?this.create(b,d,e,f):this.resetChild(g,b,d,e,f)},c.Group.prototype.getFirstDead=function(a,b,d,e,f){void 0===a&&(a=!1);var g=this.iterate("alive",!1,c.Group.RETURN_CHILD);return null===g&&a?this.create(b,d,e,f):this.resetChild(g,b,d,e,f)},c.Group.prototype.resetChild=function(a,b,c,d,e){return null===a?null:(void 0===b&&(b=null),void 0===c&&(c=null),null!==b&&null!==c&&a.reset(b,c),void 0!==d&&a.loadTexture(d,e),a)},c.Group.prototype.getTop=function(){return this.children.length>0?this.children[this.children.length-1]:void 0},c.Group.prototype.getBottom=function(){return this.children.length>0?this.children[0]:void 0},c.Group.prototype.countLiving=function(){return this.iterate("alive",!0,c.Group.RETURN_TOTAL)},c.Group.prototype.countDead=function(){return this.iterate("alive",!1,c.Group.RETURN_TOTAL)},c.Group.prototype.getRandom=function(a,b){return 0===this.children.length?null:(a=a||0,b=b||this.children.length,c.ArrayUtils.getRandomItem(this.children,a,b))},c.Group.prototype.remove=function(a,b,c){if(void 0===b&&(b=!1),void 0===c&&(c=!1),0===this.children.length||-1===this.children.indexOf(a))return!1;c||!a.events||a.destroyPhase||a.events.onRemovedFromGroup$dispatch(a,this);var d=this.removeChild(a);return this.removeFromHash(a),this.updateZ(),this.cursor===a&&this.next(),b&&d&&d.destroy(!0),!0},c.Group.prototype.moveAll=function(a,b){if(void 0===b&&(b=!1),this.children.length>0&&a instanceof c.Group){do a.add(this.children[0],b);while(this.children.length>0);this.hash=[],this.cursor=null}return a},c.Group.prototype.removeAll=function(a,b){if(void 0===a&&(a=!1),void 0===b&&(b=!1),0!==this.children.length){do{!b&&this.children[0].events&&this.children[0].events.onRemovedFromGroup$dispatch(this.children[0],this);var c=this.removeChild(this.children[0]);this.removeFromHash(c),a&&c&&c.destroy(!0)}while(this.children.length>0);this.hash=[],this.cursor=null}},c.Group.prototype.removeBetween=function(a,b,c,d){if(void 0===b&&(b=this.children.length-1),void 0===c&&(c=!1),void 0===d&&(d=!1),0!==this.children.length){if(a>b||0>a||b>this.children.length)return!1;for(var e=b;e>=a;){!d&&this.children[e].events&&this.children[e].events.onRemovedFromGroup$dispatch(this.children[e],this);var f=this.removeChild(this.children[e]);this.removeFromHash(f),c&&f&&f.destroy(!0),this.cursor===this.children[e]&&(this.cursor=null),e--}this.updateZ()}},c.Group.prototype.destroy=function(a,b){null===this.game||this.ignoreDestroy||(void 0===a&&(a=!0),void 0===b&&(b=!1),this.onDestroy.dispatch(this,a,b),this.removeAll(a),this.cursor=null,this.filters=null,this.pendingDestroy=!1,b||(this.parent&&this.parent.removeChild(this),this.game=null,this.exists=!1))},Object.defineProperty(c.Group.prototype,"total",{get:function(){return this.iterate("exists",!0,c.Group.RETURN_TOTAL)}}),Object.defineProperty(c.Group.prototype,"length",{get:function(){return this.children.length}}),Object.defineProperty(c.Group.prototype,"angle",{get:function(){return c.Math.radToDeg(this.rotation)},set:function(a){this.rotation=c.Math.degToRad(a)}}),c.World=function(a){c.Group.call(this,a,null,"__world",!1),this.bounds=new c.Rectangle(0,0,a.width,a.height),this.camera=null,this._definedSize=!1,this._width=a.width,this._height=a.height,this.game.state.onStateChange.add(this.stateChange,this)},c.World.prototype=Object.create(c.Group.prototype),c.World.prototype.constructor=c.World,c.World.prototype.boot=function(){this.camera=new c.Camera(this.game,0,0,0,this.game.width,this.game.height),this.camera.displayObject=this,this.camera.scale=this.scale,this.game.camera=this.camera,this.game.stage.addChild(this)},c.World.prototype.stateChange=function(){this.x=0,this.y=0,this.camera.reset()},c.World.prototype.setBounds=function(a,b,c,d){this._definedSize=!0,this._width=c,this._height=d,this.bounds.setTo(a,b,c,d),this.x=a,this.y=b,this.camera.bounds&&this.camera.bounds.setTo(a,b,Math.max(c,this.game.width),Math.max(d,this.game.height)),this.game.physics.setBoundsToWorld()},c.World.prototype.resize=function(a,b){this._definedSize&&(a<this._width&&(a=this._width),b<this._height&&(b=this._height)),this.bounds.width=a,this.bounds.height=b,this.game.camera.setBoundsToWorld(),this.game.physics.setBoundsToWorld()},c.World.prototype.shutdown=function(){this.destroy(!0,!0)},c.World.prototype.wrap=function(a,b,c,d,e){void 0===b&&(b=0),void 0===c&&(c=!1),void 0===d&&(d=!0),void 0===e&&(e=!0),c?(a.getBounds(),d&&(a.x+a._currentBounds.width<this.bounds.x?a.x=this.bounds.right:a.x>this.bounds.right&&(a.x=this.bounds.left)),e&&(a.y+a._currentBounds.height<this.bounds.top?a.y=this.bounds.bottom:a.y>this.bounds.bottom&&(a.y=this.bounds.top))):(d&&a.x+b<this.bounds.x?a.x=this.bounds.right+b:d&&a.x-b>this.bounds.right&&(a.x=this.bounds.left-b),e&&a.y+b<this.bounds.top?a.y=this.bounds.bottom+b:e&&a.y-b>this.bounds.bottom&&(a.y=this.bounds.top-b))},Object.defineProperty(c.World.prototype,"width",{get:function(){return this.bounds.width},set:function(a){a<this.game.width&&(a=this.game.width),this.bounds.width=a,this._width=a,this._definedSize=!0}}),Object.defineProperty(c.World.prototype,"height",{get:function(){return this.bounds.height},set:function(a){a<this.game.height&&(a=this.game.height),this.bounds.height=a,this._height=a,this._definedSize=!0}}),Object.defineProperty(c.World.prototype,"centerX",{get:function(){return this.bounds.halfWidth}}),Object.defineProperty(c.World.prototype,"centerY",{get:function(){return this.bounds.halfHeight}}),Object.defineProperty(c.World.prototype,"randomX",{get:function(){return this.bounds.x<0?this.game.rnd.between(this.bounds.x,this.bounds.width-Math.abs(this.bounds.x)):this.game.rnd.between(this.bounds.x,this.bounds.width)}}),Object.defineProperty(c.World.prototype,"randomY",{get:function(){return this.bounds.y<0?this.game.rnd.between(this.bounds.y,this.bounds.height-Math.abs(this.bounds.y)):this.game.rnd.between(this.bounds.y,this.bounds.height)}}),c.Game=function(a,b,d,e,f,g,h,i){return this.id=c.GAMES.push(this)-1,this.config=null,this.physicsConfig=i,this.parent="",this.width=800,this.height=600,this.resolution=1,this._width=800,this._height=600,this.transparent=!1,this.antialias=!0,this.preserveDrawingBuffer=!1,this.clearBeforeRender=!0,this.renderer=null,this.renderType=c.AUTO,this.state=null,this.isBooted=!1,this.isRunning=!1,this.raf=null,this.add=null,this.make=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.net=null,this.scale=null,this.sound=null,this.stage=null,this.time=null,this.tweens=null,this.world=null,this.physics=null,this.plugins=null,this.rnd=null,this.device=c.Device,this.camera=null,this.canvas=null,this.context=null,this.debug=null,this.particles=null,this.create=null,this.lockRender=!1,this.stepping=!1,this.pendingStep=!1,this.stepCount=0,this.onPause=null,this.onResume=null,this.onBlur=null,this.onFocus=null,this._paused=!1,this._codePaused=!1,this.currentUpdateID=0,this.updatesThisFrame=1,this._deltaTime=0,this._lastCount=0,this._spiraling=0,this._kickstart=!0,this.fpsProblemNotifier=new c.Signal,this.forceSingleUpdate=!1,this._nextFpsNotification=0,1===arguments.length&&"object"==typeof arguments[0]?this.parseConfig(arguments[0]):(this.config={enableDebug:!0},"undefined"!=typeof a&&(this._width=a),"undefined"!=typeof b&&(this._height=b),"undefined"!=typeof d&&(this.renderType=d),"undefined"!=typeof e&&(this.parent=e),"undefined"!=typeof g&&(this.transparent=g),"undefined"!=typeof h&&(this.antialias=h),this.rnd=new c.RandomDataGenerator([(Date.now()*Math.random()).toString()]),this.state=new c.StateManager(this,f)),this.device.whenReady(this.boot,this),this},c.Game.prototype={parseConfig:function(a){this.config=a,void 0===a.enableDebug&&(this.config.enableDebug=!0),a.width&&(this._width=a.width),a.height&&(this._height=a.height),a.renderer&&(this.renderType=a.renderer),a.parent&&(this.parent=a.parent),a.transparent&&(this.transparent=a.transparent),a.antialias&&(this.antialias=a.antialias),a.resolution&&(this.resolution=a.resolution),a.preserveDrawingBuffer&&(this.preserveDrawingBuffer=a.preserveDrawingBuffer),a.physicsConfig&&(this.physicsConfig=a.physicsConfig);var b=[(Date.now()*Math.random()).toString()];a.seed&&(b=a.seed),this.rnd=new c.RandomDataGenerator(b);var d=null;a.state&&(d=a.state),this.state=new c.StateManager(this,d)},boot:function(){this.isBooted||(this.onPause=new c.Signal,this.onResume=new c.Signal,this.onBlur=new c.Signal,this.onFocus=new c.Signal,this.isBooted=!0,PIXI.game=this,this.math=c.Math,this.scale=new c.ScaleManager(this,this._width,this._height),this.stage=new c.Stage(this),this.setUpRenderer(),this.world=new c.World(this),this.add=new c.GameObjectFactory(this),this.make=new c.GameObjectCreator(this),this.cache=new c.Cache(this),this.load=new c.Loader(this),this.time=new c.Time(this),this.tweens=new c.TweenManager(this),this.input=new c.Input(this),this.sound=new c.SoundManager(this),this.physics=new c.Physics(this,this.physicsConfig),this.particles=new c.Particles(this),this.create=new c.Create(this),this.plugins=new c.PluginManager(this),this.net=new c.Net(this),this.time.boot(),this.stage.boot(),this.world.boot(),this.scale.boot(),this.input.boot(),this.sound.boot(),this.state.boot(),this.config.enableDebug?(this.debug=new c.Utils.Debug(this),this.debug.boot()):this.debug={preUpdate:function(){},update:function(){},reset:function(){}},this.showDebugHeader(),this.isRunning=!0,this.config&&this.config.forceSetTimeOut?this.raf=new c.RequestAnimationFrame(this,this.config.forceSetTimeOut):this.raf=new c.RequestAnimationFrame(this,!1),this._kickstart=!0,window.focus&&(!window.PhaserGlobal||window.PhaserGlobal&&!window.PhaserGlobal.stopFocus)&&window.focus(),this.raf.start())},showDebugHeader:function(){if(!window.PhaserGlobal||!window.PhaserGlobal.hideBanner){var a=c.VERSION,b="Canvas",d="HTML Audio",e=1;if(this.renderType===c.WEBGL?(b="WebGL",e++):this.renderType==c.HEADLESS&&(b="Headless"),this.device.webAudio&&(d="WebAudio",e++),this.device.chrome){for(var f=["%c %c %c Phaser v"+a+" | Pixi.js "+PIXI.VERSION+" | "+b+" | "+d+" %c %c %c http://phaser.io %c♥%c♥%c♥","background: #9854d8","background: #6c2ca7","color: #ffffff; background: #450f78;","background: #6c2ca7","background: #9854d8","background: #ffffff"],g=0;3>g;g++)e>g?f.push("color: #ff2424; background: #fff"):f.push("color: #959595; background: #fff");console.log.apply(console,f)}else window.console&&console.log("Phaser v"+a+" | Pixi.js "+PIXI.VERSION+" | "+b+" | "+d+" | http://phaser.io")}},setUpRenderer:function(){if(this.canvas=c.Canvas.create(this,this.width,this.height,this.config.canvasID,!0),this.config.canvasStyle?this.canvas.style=this.config.canvasStyle:this.canvas.style["-webkit-full-screen"]="width: 100%; height: 100%",this.renderType===c.HEADLESS||this.renderType===c.CANVAS||this.renderType===c.AUTO&&!this.device.webGL){if(!this.device.canvas)throw new Error("Phaser.Game - Cannot create Canvas or WebGL context, aborting.");this.renderType=c.CANVAS,this.renderer=new PIXI.CanvasRenderer(this),this.context=this.renderer.context}else this.renderType=c.WEBGL,this.renderer=new PIXI.WebGLRenderer(this),this.context=null,this.canvas.addEventListener("webglcontextlost",this.contextLost.bind(this),!1),this.canvas.addEventListener("webglcontextrestored",this.contextRestored.bind(this),!1);this.device.cocoonJS&&(this.canvas.screencanvas=this.renderType===c.CANVAS?!0:!1),this.renderType!==c.HEADLESS&&(this.stage.smoothed=this.antialias,c.Canvas.addToDOM(this.canvas,this.parent,!1),c.Canvas.setTouchAction(this.canvas))},contextLost:function(a){a.preventDefault(),this.renderer.contextLost=!0},contextRestored:function(){this.renderer.initContext(),this.cache.clearGLTextures(),this.renderer.contextLost=!1},update:function(a){if(this.time.update(a),this._kickstart)return this.updateLogic(this.time.desiredFpsMult),this.stage.updateTransform(),this.updateRender(this.time.slowMotion*this.time.desiredFps),void(this._kickstart=!1);if(this._spiraling>1&&!this.forceSingleUpdate)this.time.time>this._nextFpsNotification&&(this._nextFpsNotification=this.time.time+1e4,this.fpsProblemNotifier.dispatch()),this._deltaTime=0,this._spiraling=0,this.updateRender(this.time.slowMotion*this.time.desiredFps);else{var b=1e3*this.time.slowMotion/this.time.desiredFps;this._deltaTime+=Math.max(Math.min(3*b,this.time.elapsed),0);var c=0;for(this.updatesThisFrame=Math.floor(this._deltaTime/b),this.forceSingleUpdate&&(this.updatesThisFrame=Math.min(1,this.updatesThisFrame));this._deltaTime>=b&&(this._deltaTime-=b,this.currentUpdateID=c,this.updateLogic(this.time.desiredFpsMult),this.stage.updateTransform(),c++,!this.forceSingleUpdate||1!==c);)this.time.refresh();c>this._lastCount?this._spiraling++:c<this._lastCount&&(this._spiraling=0),this._lastCount=c,this.updateRender(this._deltaTime/b)}},updateLogic:function(a){this._paused||this.pendingStep?(this.scale.pauseUpdate(),this.state.pauseUpdate(),this.debug.preUpdate()):(this.stepping&&(this.pendingStep=!0),this.scale.preUpdate(),this.debug.preUpdate(),this.world.camera.preUpdate(),this.physics.preUpdate(),this.state.preUpdate(a),this.plugins.preUpdate(a),this.stage.preUpdate(),this.state.update(),this.stage.update(),this.tweens.update(),this.sound.update(),this.input.update(),this.physics.update(),this.particles.update(),this.plugins.update(),this.stage.postUpdate(),this.plugins.postUpdate())},updateRender:function(a){this.lockRender||(this.state.preRender(a),this.renderer.render(this.stage),this.plugins.render(a),this.state.render(a),this.plugins.postRender(a))},enableStep:function(){this.stepping=!0,this.pendingStep=!1,this.stepCount=0},disableStep:function(){this.stepping=!1,this.pendingStep=!1},step:function(){this.pendingStep=!1,this.stepCount++},destroy:function(){this.raf.stop(),this.state.destroy(),this.sound.destroy(),this.scale.destroy(),this.stage.destroy(),this.input.destroy(),this.physics.destroy(),this.state=null,this.cache=null,this.input=null,this.load=null,this.sound=null,this.stage=null,this.time=null,this.world=null,this.isBooted=!1,this.renderer.destroy(!1),c.Canvas.removeFromDOM(this.canvas),c.GAMES[this.id]=null},gamePaused:function(a){this._paused||(this._paused=!0,this.time.gamePaused(),this.sound.setMute(),this.onPause.dispatch(a),this.device.cordova&&this.device.iOS&&(this.lockRender=!0))},gameResumed:function(a){this._paused&&!this._codePaused&&(this._paused=!1,this.time.gameResumed(),this.input.reset(),this.sound.unsetMute(),this.onResume.dispatch(a),this.device.cordova&&this.device.iOS&&(this.lockRender=!1))},focusLoss:function(a){this.onBlur.dispatch(a),this.stage.disableVisibilityChange||this.gamePaused(a)},focusGain:function(a){this.onFocus.dispatch(a),this.stage.disableVisibilityChange||this.gameResumed(a)}},c.Game.prototype.constructor=c.Game,Object.defineProperty(c.Game.prototype,"paused",{get:function(){return this._paused},set:function(a){a===!0?(this._paused===!1&&(this._paused=!0,this.sound.setMute(),this.time.gamePaused(),this.onPause.dispatch(this)),this._codePaused=!0):(this._paused&&(this._paused=!1,this.input.reset(),this.sound.unsetMute(),this.time.gameResumed(),this.onResume.dispatch(this)),this._codePaused=!1)}}),c.Input=function(a){this.game=a,this.hitCanvas=null,this.hitContext=null,this.moveCallbacks=[],this.pollRate=0,this.enabled=!0,this.multiInputOverride=c.Input.MOUSE_TOUCH_COMBINE,this.position=null,this.speed=null,this.circle=null,this.scale=null,this.maxPointers=-1,this.tapRate=200,this.doubleTapRate=300,this.holdRate=2e3,this.justPressedRate=200,this.justReleasedRate=200,this.recordPointerHistory=!1,this.recordRate=100,this.recordLimit=100,this.pointer1=null,this.pointer2=null,this.pointer3=null,this.pointer4=null,this.pointer5=null,this.pointer6=null,this.pointer7=null,this.pointer8=null,this.pointer9=null,this.pointer10=null,this.pointers=[],this.activePointer=null,this.mousePointer=null,this.mouse=null,this.keyboard=null,this.touch=null,this.mspointer=null,this.gamepad=null,this.resetLocked=!1,this.onDown=null,this.onUp=null,this.onTap=null,this.onHold=null,this.minPriorityID=0, +this.interactiveItems=new c.ArraySet,this._localPoint=new c.Point,this._pollCounter=0,this._oldPosition=null,this._x=0,this._y=0},c.Input.MOUSE_OVERRIDES_TOUCH=0,c.Input.TOUCH_OVERRIDES_MOUSE=1,c.Input.MOUSE_TOUCH_COMBINE=2,c.Input.MAX_POINTERS=10,c.Input.prototype={boot:function(){this.mousePointer=new c.Pointer(this.game,0,c.PointerMode.CURSOR),this.addPointer(),this.addPointer(),this.mouse=new c.Mouse(this.game),this.touch=new c.Touch(this.game),this.mspointer=new c.MSPointer(this.game),c.Keyboard&&(this.keyboard=new c.Keyboard(this.game)),c.Gamepad&&(this.gamepad=new c.Gamepad(this.game)),this.onDown=new c.Signal,this.onUp=new c.Signal,this.onTap=new c.Signal,this.onHold=new c.Signal,this.scale=new c.Point(1,1),this.speed=new c.Point,this.position=new c.Point,this._oldPosition=new c.Point,this.circle=new c.Circle(0,0,44),this.activePointer=this.mousePointer,this.hitCanvas=PIXI.CanvasPool.create(this,1,1),this.hitContext=this.hitCanvas.getContext("2d"),this.mouse.start(),this.touch.start(),this.mspointer.start(),this.mousePointer.active=!0,this.keyboard&&this.keyboard.start();var a=this;this._onClickTrampoline=function(b){a.onClickTrampoline(b)},this.game.canvas.addEventListener("click",this._onClickTrampoline,!1)},destroy:function(){this.mouse.stop(),this.touch.stop(),this.mspointer.stop(),this.keyboard&&this.keyboard.stop(),this.gamepad&&this.gamepad.stop(),this.moveCallbacks=[],PIXI.CanvasPool.remove(this),this.game.canvas.removeEventListener("click",this._onClickTrampoline)},addMoveCallback:function(a,b){this.moveCallbacks.push({callback:a,context:b})},deleteMoveCallback:function(a,b){for(var c=this.moveCallbacks.length;c--;)if(this.moveCallbacks[c].callback===a&&this.moveCallbacks[c].context===b)return void this.moveCallbacks.splice(c,1)},addPointer:function(){if(this.pointers.length>=c.Input.MAX_POINTERS)return console.warn("Phaser.Input.addPointer: Maximum limit of "+c.Input.MAX_POINTERS+" pointers reached."),null;var a=this.pointers.length+1,b=new c.Pointer(this.game,a,c.PointerMode.TOUCH);return this.pointers.push(b),this["pointer"+a]=b,b},update:function(){if(this.keyboard&&this.keyboard.update(),this.pollRate>0&&this._pollCounter<this.pollRate)return void this._pollCounter++;this.speed.x=this.position.x-this._oldPosition.x,this.speed.y=this.position.y-this._oldPosition.y,this._oldPosition.copyFrom(this.position),this.mousePointer.update(),this.gamepad&&this.gamepad.active&&this.gamepad.update();for(var a=0;a<this.pointers.length;a++)this.pointers[a].update();this._pollCounter=0},reset:function(a){if(this.game.isBooted&&!this.resetLocked){void 0===a&&(a=!1),this.mousePointer.reset(),this.keyboard&&this.keyboard.reset(a),this.gamepad&&this.gamepad.reset();for(var b=0;b<this.pointers.length;b++)this.pointers[b].reset();"none"!==this.game.canvas.style.cursor&&(this.game.canvas.style.cursor="inherit"),a&&(this.onDown.dispose(),this.onUp.dispose(),this.onTap.dispose(),this.onHold.dispose(),this.onDown=new c.Signal,this.onUp=new c.Signal,this.onTap=new c.Signal,this.onHold=new c.Signal,this.moveCallbacks=[]),this._pollCounter=0}},resetSpeed:function(a,b){this._oldPosition.setTo(a,b),this.speed.setTo(0,0)},startPointer:function(a){if(this.maxPointers>=0&&this.countActivePointers(this.maxPointers)>=this.maxPointers)return null;if(!this.pointer1.active)return this.pointer1.start(a);if(!this.pointer2.active)return this.pointer2.start(a);for(var b=2;b<this.pointers.length;b++){var c=this.pointers[b];if(!c.active)return c.start(a)}return null},updatePointer:function(a){if(this.pointer1.active&&this.pointer1.identifier===a.identifier)return this.pointer1.move(a);if(this.pointer2.active&&this.pointer2.identifier===a.identifier)return this.pointer2.move(a);for(var b=2;b<this.pointers.length;b++){var c=this.pointers[b];if(c.active&&c.identifier===a.identifier)return c.move(a)}return null},stopPointer:function(a){if(this.pointer1.active&&this.pointer1.identifier===a.identifier)return this.pointer1.stop(a);if(this.pointer2.active&&this.pointer2.identifier===a.identifier)return this.pointer2.stop(a);for(var b=2;b<this.pointers.length;b++){var c=this.pointers[b];if(c.active&&c.identifier===a.identifier)return c.stop(a)}return null},countActivePointers:function(a){void 0===a&&(a=this.pointers.length);for(var b=a,c=0;c<this.pointers.length&&b>0;c++){var d=this.pointers[c];d.active&&b--}return a-b},getPointer:function(a){void 0===a&&(a=!1);for(var b=0;b<this.pointers.length;b++){var c=this.pointers[b];if(c.active===a)return c}return null},getPointerFromIdentifier:function(a){for(var b=0;b<this.pointers.length;b++){var c=this.pointers[b];if(c.identifier===a)return c}return null},getPointerFromId:function(a){for(var b=0;b<this.pointers.length;b++){var c=this.pointers[b];if(c.pointerId===a)return c}return null},getLocalPosition:function(a,b,d){void 0===d&&(d=new c.Point);var e=a.worldTransform,f=1/(e.a*e.d+e.c*-e.b);return d.setTo(e.d*f*b.x+-e.c*f*b.y+(e.ty*e.c-e.tx*e.d)*f,e.a*f*b.y+-e.b*f*b.x+(-e.ty*e.a+e.tx*e.b)*f)},hitTest:function(a,b,d){if(!a.worldVisible)return!1;if(this.getLocalPosition(a,b,this._localPoint),d.copyFrom(this._localPoint),a.hitArea&&a.hitArea.contains)return a.hitArea.contains(this._localPoint.x,this._localPoint.y);if(a instanceof c.TileSprite){var e=a.width,f=a.height,g=-e*a.anchor.x;if(this._localPoint.x>=g&&this._localPoint.x<g+e){var h=-f*a.anchor.y;if(this._localPoint.y>=h&&this._localPoint.y<h+f)return!0}}else if(a instanceof PIXI.Sprite){var e=a.texture.frame.width,f=a.texture.frame.height,g=-e*a.anchor.x;if(this._localPoint.x>=g&&this._localPoint.x<g+e){var h=-f*a.anchor.y;if(this._localPoint.y>=h&&this._localPoint.y<h+f)return!0}}else if(a instanceof c.Graphics)for(var i=0;i<a.graphicsData.length;i++){var j=a.graphicsData[i];if(j.fill&&j.shape&&j.shape.contains(this._localPoint.x,this._localPoint.y))return!0}for(var i=0,k=a.children.length;k>i;i++)if(this.hitTest(a.children[i],b,d))return!0;return!1},onClickTrampoline:function(){this.activePointer.processClickTrampolines()}},c.Input.prototype.constructor=c.Input,Object.defineProperty(c.Input.prototype,"x",{get:function(){return this._x},set:function(a){this._x=Math.floor(a)}}),Object.defineProperty(c.Input.prototype,"y",{get:function(){return this._y},set:function(a){this._y=Math.floor(a)}}),Object.defineProperty(c.Input.prototype,"pollLocked",{get:function(){return this.pollRate>0&&this._pollCounter<this.pollRate}}),Object.defineProperty(c.Input.prototype,"totalInactivePointers",{get:function(){return this.pointers.length-this.countActivePointers()}}),Object.defineProperty(c.Input.prototype,"totalActivePointers",{get:function(){return this.countActivePointers()}}),Object.defineProperty(c.Input.prototype,"worldX",{get:function(){return this.game.camera.view.x+this.x}}),Object.defineProperty(c.Input.prototype,"worldY",{get:function(){return this.game.camera.view.y+this.y}}),c.Mouse=function(a){this.game=a,this.input=a.input,this.callbackContext=this.game,this.mouseDownCallback=null,this.mouseUpCallback=null,this.mouseOutCallback=null,this.mouseOverCallback=null,this.mouseWheelCallback=null,this.capture=!1,this.button=-1,this.wheelDelta=0,this.enabled=!0,this.locked=!1,this.stopOnGameOut=!1,this.pointerLock=new c.Signal,this.event=null,this._onMouseDown=null,this._onMouseMove=null,this._onMouseUp=null,this._onMouseOut=null,this._onMouseOver=null,this._onMouseWheel=null,this._wheelEvent=null},c.Mouse.NO_BUTTON=-1,c.Mouse.LEFT_BUTTON=0,c.Mouse.MIDDLE_BUTTON=1,c.Mouse.RIGHT_BUTTON=2,c.Mouse.BACK_BUTTON=3,c.Mouse.FORWARD_BUTTON=4,c.Mouse.WHEEL_UP=1,c.Mouse.WHEEL_DOWN=-1,c.Mouse.prototype={start:function(){if((!this.game.device.android||this.game.device.chrome!==!1)&&null===this._onMouseDown){var b=this;this._onMouseDown=function(a){return b.onMouseDown(a)},this._onMouseMove=function(a){return b.onMouseMove(a)},this._onMouseUp=function(a){return b.onMouseUp(a)},this._onMouseUpGlobal=function(a){return b.onMouseUpGlobal(a)},this._onMouseOut=function(a){return b.onMouseOut(a)},this._onMouseOver=function(a){return b.onMouseOver(a)},this._onMouseWheel=function(a){return b.onMouseWheel(a)};var c=this.game.canvas;c.addEventListener("mousedown",this._onMouseDown,!0),c.addEventListener("mousemove",this._onMouseMove,!0),c.addEventListener("mouseup",this._onMouseUp,!0),this.game.device.cocoonJS||(window.addEventListener("mouseup",this._onMouseUpGlobal,!0),c.addEventListener("mouseover",this._onMouseOver,!0),c.addEventListener("mouseout",this._onMouseOut,!0));var d=this.game.device.wheelEvent;d&&(c.addEventListener(d,this._onMouseWheel,!0),"mousewheel"===d?this._wheelEvent=new a(-1/40,1):"DOMMouseScroll"===d&&(this._wheelEvent=new a(1,1)))}},onMouseDown:function(a){this.event=a,this.capture&&a.preventDefault(),this.mouseDownCallback&&this.mouseDownCallback.call(this.callbackContext,a),this.input.enabled&&this.enabled&&(a.identifier=0,this.input.mousePointer.start(a))},onMouseMove:function(a){this.event=a,this.capture&&a.preventDefault(),this.mouseMoveCallback&&this.mouseMoveCallback.call(this.callbackContext,a),this.input.enabled&&this.enabled&&(a.identifier=0,this.input.mousePointer.move(a))},onMouseUp:function(a){this.event=a,this.capture&&a.preventDefault(),this.mouseUpCallback&&this.mouseUpCallback.call(this.callbackContext,a),this.input.enabled&&this.enabled&&(a.identifier=0,this.input.mousePointer.stop(a))},onMouseUpGlobal:function(a){this.input.mousePointer.withinGame||(this.mouseUpCallback&&this.mouseUpCallback.call(this.callbackContext,a),a.identifier=0,this.input.mousePointer.stop(a))},onMouseOut:function(a){this.event=a,this.capture&&a.preventDefault(),this.input.mousePointer.withinGame=!1,this.mouseOutCallback&&this.mouseOutCallback.call(this.callbackContext,a),this.input.enabled&&this.enabled&&this.stopOnGameOut&&(a.identifier=0,this.input.mousePointer.stop(a))},onMouseOver:function(a){this.event=a,this.capture&&a.preventDefault(),this.input.mousePointer.withinGame=!0,this.mouseOverCallback&&this.mouseOverCallback.call(this.callbackContext,a)},onMouseWheel:function(a){this._wheelEvent&&(a=this._wheelEvent.bindEvent(a)),this.event=a,this.capture&&a.preventDefault(),this.wheelDelta=c.Math.clamp(-a.deltaY,-1,1),this.mouseWheelCallback&&this.mouseWheelCallback.call(this.callbackContext,a)},requestPointerLock:function(){if(this.game.device.pointerLock){var a=this.game.canvas;a.requestPointerLock=a.requestPointerLock||a.mozRequestPointerLock||a.webkitRequestPointerLock,a.requestPointerLock();var b=this;this._pointerLockChange=function(a){return b.pointerLockChange(a)},document.addEventListener("pointerlockchange",this._pointerLockChange,!0),document.addEventListener("mozpointerlockchange",this._pointerLockChange,!0),document.addEventListener("webkitpointerlockchange",this._pointerLockChange,!0)}},pointerLockChange:function(a){var b=this.game.canvas;document.pointerLockElement===b||document.mozPointerLockElement===b||document.webkitPointerLockElement===b?(this.locked=!0,this.pointerLock.dispatch(!0,a)):(this.locked=!1,this.pointerLock.dispatch(!1,a))},releasePointerLock:function(){document.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock,document.exitPointerLock(),document.removeEventListener("pointerlockchange",this._pointerLockChange,!0),document.removeEventListener("mozpointerlockchange",this._pointerLockChange,!0),document.removeEventListener("webkitpointerlockchange",this._pointerLockChange,!0)},stop:function(){var a=this.game.canvas;a.removeEventListener("mousedown",this._onMouseDown,!0),a.removeEventListener("mousemove",this._onMouseMove,!0),a.removeEventListener("mouseup",this._onMouseUp,!0),a.removeEventListener("mouseover",this._onMouseOver,!0),a.removeEventListener("mouseout",this._onMouseOut,!0);var b=this.game.device.wheelEvent;b&&a.removeEventListener(b,this._onMouseWheel,!0),window.removeEventListener("mouseup",this._onMouseUpGlobal,!0),document.removeEventListener("pointerlockchange",this._pointerLockChange,!0),document.removeEventListener("mozpointerlockchange",this._pointerLockChange,!0),document.removeEventListener("webkitpointerlockchange",this._pointerLockChange,!0)}},c.Mouse.prototype.constructor=c.Mouse,a.prototype={},a.prototype.constructor=a,a.prototype.bindEvent=function(b){if(!a._stubsGenerated&&b){var c=function(a){return function(){var b=this.originalEvent[a];return"function"!=typeof b?b:b.bind(this.originalEvent)}};for(var d in b)d in a.prototype||Object.defineProperty(a.prototype,d,{get:c(d)});a._stubsGenerated=!0}return this.originalEvent=b,this},Object.defineProperties(a.prototype,{type:{value:"wheel"},deltaMode:{get:function(){return this._deltaMode}},deltaY:{get:function(){return this._scaleFactor*(this.originalEvent.wheelDelta||this.originalEvent.detail)||0}},deltaX:{get:function(){return this._scaleFactor*this.originalEvent.wheelDeltaX||0}},deltaZ:{value:0}}),c.MSPointer=function(a){this.game=a,this.input=a.input,this.callbackContext=this.game,this.pointerDownCallback=null,this.pointerMoveCallback=null,this.pointerUpCallback=null,this.capture=!0,this.button=-1,this.event=null,this.enabled=!0,this._onMSPointerDown=null,this._onMSPointerMove=null,this._onMSPointerUp=null,this._onMSPointerUpGlobal=null,this._onMSPointerOut=null,this._onMSPointerOver=null},c.MSPointer.prototype={start:function(){if(null===this._onMSPointerDown){var a=this;if(this.game.device.mspointer){this._onMSPointerDown=function(b){return a.onPointerDown(b)},this._onMSPointerMove=function(b){return a.onPointerMove(b)},this._onMSPointerUp=function(b){return a.onPointerUp(b)},this._onMSPointerUpGlobal=function(b){return a.onPointerUpGlobal(b)},this._onMSPointerOut=function(b){return a.onPointerOut(b)},this._onMSPointerOver=function(b){return a.onPointerOver(b)};var b=this.game.canvas;b.addEventListener("MSPointerDown",this._onMSPointerDown,!1),b.addEventListener("MSPointerMove",this._onMSPointerMove,!1),b.addEventListener("MSPointerUp",this._onMSPointerUp,!1),b.addEventListener("pointerdown",this._onMSPointerDown,!1),b.addEventListener("pointermove",this._onMSPointerMove,!1),b.addEventListener("pointerup",this._onMSPointerUp,!1),b.style["-ms-content-zooming"]="none",b.style["-ms-touch-action"]="none",this.game.device.cocoonJS||(window.addEventListener("MSPointerUp",this._onMSPointerUpGlobal,!0),b.addEventListener("MSPointerOver",this._onMSPointerOver,!0),b.addEventListener("MSPointerOut",this._onMSPointerOut,!0),window.addEventListener("pointerup",this._onMSPointerUpGlobal,!0),b.addEventListener("pointerover",this._onMSPointerOver,!0),b.addEventListener("pointerout",this._onMSPointerOut,!0))}}},onPointerDown:function(a){this.event=a,this.capture&&a.preventDefault(),this.pointerDownCallback&&this.pointerDownCallback.call(this.callbackContext,a),this.input.enabled&&this.enabled&&(a.identifier=a.pointerId,"mouse"===a.pointerType||4===a.pointerType?this.input.mousePointer.start(a):this.input.startPointer(a))},onPointerMove:function(a){this.event=a,this.capture&&a.preventDefault(),this.pointerMoveCallback&&this.pointerMoveCallback.call(this.callbackContext,a),this.input.enabled&&this.enabled&&(a.identifier=a.pointerId,"mouse"===a.pointerType||4===a.pointerType?this.input.mousePointer.move(a):this.input.updatePointer(a))},onPointerUp:function(a){this.event=a,this.capture&&a.preventDefault(),this.pointerUpCallback&&this.pointerUpCallback.call(this.callbackContext,a),this.input.enabled&&this.enabled&&(a.identifier=a.pointerId,"mouse"===a.pointerType||4===a.pointerType?this.input.mousePointer.stop(a):this.input.stopPointer(a))},onPointerUpGlobal:function(a){if("mouse"!==a.pointerType&&4!==a.pointerType||this.input.mousePointer.withinGame){var b=this.input.getPointerFromIdentifier(a.identifier);b&&b.withinGame&&this.onPointerUp(a)}else this.onPointerUp(a)},onPointerOut:function(a){if(this.event=a,this.capture&&a.preventDefault(),"mouse"===a.pointerType||4===a.pointerType)this.input.mousePointer.withinGame=!1;else{var b=this.input.getPointerFromIdentifier(a.identifier);b&&(b.withinGame=!1)}this.input.mouse.mouseOutCallback&&this.input.mouse.mouseOutCallback.call(this.input.mouse.callbackContext,a),this.input.enabled&&this.enabled&&this.input.mouse.stopOnGameOut&&(a.identifier=0,b?b.stop(a):this.input.mousePointer.stop(a))},onPointerOver:function(a){if(this.event=a,this.capture&&a.preventDefault(),"mouse"===a.pointerType||4===a.pointerType)this.input.mousePointer.withinGame=!0;else{var b=this.input.getPointerFromIdentifier(a.identifier);b&&(b.withinGame=!0)}this.input.mouse.mouseOverCallback&&this.input.mouse.mouseOverCallback.call(this.input.mouse.callbackContext,a)},stop:function(){var a=this.game.canvas;a.removeEventListener("MSPointerDown",this._onMSPointerDown,!1),a.removeEventListener("MSPointerMove",this._onMSPointerMove,!1),a.removeEventListener("MSPointerUp",this._onMSPointerUp,!1),a.removeEventListener("pointerdown",this._onMSPointerDown,!1),a.removeEventListener("pointermove",this._onMSPointerMove,!1),a.removeEventListener("pointerup",this._onMSPointerUp,!1),window.removeEventListener("MSPointerUp",this._onMSPointerUpGlobal,!0),a.removeEventListener("MSPointerOver",this._onMSPointerOver,!0),a.removeEventListener("MSPointerOut",this._onMSPointerOut,!0),window.removeEventListener("pointerup",this._onMSPointerUpGlobal,!0),a.removeEventListener("pointerover",this._onMSPointerOver,!0),a.removeEventListener("pointerout",this._onMSPointerOut,!0)}},c.MSPointer.prototype.constructor=c.MSPointer,c.DeviceButton=function(a,b){this.parent=a,this.game=a.game,this.event=null,this.isDown=!1,this.isUp=!0,this.timeDown=0,this.timeUp=0,this.repeats=0,this.altKey=!1,this.shiftKey=!1,this.ctrlKey=!1,this.value=0,this.buttonCode=b,this.onDown=new c.Signal,this.onUp=new c.Signal,this.onFloat=new c.Signal},c.DeviceButton.prototype={start:function(a,b){this.isDown||(this.isDown=!0,this.isUp=!1,this.timeDown=this.game.time.time,this.repeats=0,this.event=a,this.value=b,a&&(this.altKey=a.altKey,this.shiftKey=a.shiftKey,this.ctrlKey=a.ctrlKey),this.onDown.dispatch(this,b))},stop:function(a,b){this.isUp||(this.isDown=!1,this.isUp=!0,this.timeUp=this.game.time.time,this.event=a,this.value=b,a&&(this.altKey=a.altKey,this.shiftKey=a.shiftKey,this.ctrlKey=a.ctrlKey),this.onUp.dispatch(this,b))},padFloat:function(a){this.value=a,this.onFloat.dispatch(this,a)},justPressed:function(a){return a=a||250,this.isDown&&this.timeDown+a>this.game.time.time},justReleased:function(a){return a=a||250,this.isUp&&this.timeUp+a>this.game.time.time},reset:function(){this.isDown=!1,this.isUp=!0,this.timeDown=this.game.time.time,this.repeats=0,this.altKey=!1,this.shiftKey=!1,this.ctrlKey=!1},destroy:function(){this.onDown.dispose(),this.onUp.dispose(),this.onFloat.dispose(),this.parent=null,this.game=null}},c.DeviceButton.prototype.constructor=c.DeviceButton,Object.defineProperty(c.DeviceButton.prototype,"duration",{get:function(){return this.isUp?-1:this.game.time.time-this.timeDown}}),c.Pointer=function(a,b,d){this.game=a,this.id=b,this.type=c.POINTER,this.exists=!0,this.identifier=0,this.pointerId=null,this.pointerMode=d||c.PointerMode.CURSOR|c.PointerMode.CONTACT,this.target=null,this.button=null,this.leftButton=new c.DeviceButton(this,c.Pointer.LEFT_BUTTON),this.middleButton=new c.DeviceButton(this,c.Pointer.MIDDLE_BUTTON),this.rightButton=new c.DeviceButton(this,c.Pointer.RIGHT_BUTTON),this.backButton=new c.DeviceButton(this,c.Pointer.BACK_BUTTON),this.forwardButton=new c.DeviceButton(this,c.Pointer.FORWARD_BUTTON),this.eraserButton=new c.DeviceButton(this,c.Pointer.ERASER_BUTTON),this._holdSent=!1,this._history=[],this._nextDrop=0,this._stateReset=!1,this.withinGame=!1,this.clientX=-1,this.clientY=-1,this.pageX=-1,this.pageY=-1,this.screenX=-1,this.screenY=-1,this.rawMovementX=0,this.rawMovementY=0,this.movementX=0,this.movementY=0,this.x=-1,this.y=-1,this.isMouse=0===b,this.isDown=!1,this.isUp=!0,this.timeDown=0,this.timeUp=0,this.previousTapTime=0,this.totalTouches=0,this.msSinceLastClick=Number.MAX_VALUE,this.targetObject=null,this.active=!1,this.dirty=!1,this.position=new c.Point,this.positionDown=new c.Point,this.positionUp=new c.Point,this.circle=new c.Circle(0,0,44),this._clickTrampolines=null,this._trampolineTargetObject=null},c.Pointer.NO_BUTTON=0,c.Pointer.LEFT_BUTTON=1,c.Pointer.RIGHT_BUTTON=2,c.Pointer.MIDDLE_BUTTON=4,c.Pointer.BACK_BUTTON=8,c.Pointer.FORWARD_BUTTON=16,c.Pointer.ERASER_BUTTON=32,c.Pointer.prototype={resetButtons:function(){this.isDown=!1,this.isUp=!0,this.isMouse&&(this.leftButton.reset(),this.middleButton.reset(),this.rightButton.reset(),this.backButton.reset(),this.forwardButton.reset(),this.eraserButton.reset())},processButtonsDown:function(a,b){c.Pointer.LEFT_BUTTON&a&&this.leftButton.start(b),c.Pointer.RIGHT_BUTTON&a&&this.rightButton.start(b),c.Pointer.MIDDLE_BUTTON&a&&this.middleButton.start(b),c.Pointer.BACK_BUTTON&a&&this.backButton.start(b),c.Pointer.FORWARD_BUTTON&a&&this.forwardButton.start(b),c.Pointer.ERASER_BUTTON&a&&this.eraserButton.start(b)},processButtonsUp:function(a,b){a===c.Mouse.LEFT_BUTTON&&this.leftButton.stop(b),a===c.Mouse.RIGHT_BUTTON&&this.rightButton.stop(b),a===c.Mouse.MIDDLE_BUTTON&&this.middleButton.stop(b),a===c.Mouse.BACK_BUTTON&&this.backButton.stop(b),a===c.Mouse.FORWARD_BUTTON&&this.forwardButton.stop(b),5===a&&this.eraserButton.stop(b)},updateButtons:function(a){this.button=a.button;var b="down"===a.type.toLowerCase().substr(-4);void 0!==a.buttons?b?this.processButtonsDown(a.buttons,a):this.processButtonsUp(a.button,a):b?this.leftButton.start(a):(this.leftButton.stop(a),this.rightButton.stop(a)),a.ctrlKey&&this.leftButton.isDown&&this.rightButton.start(a),this.isUp=!0,this.isDown=!1,(this.leftButton.isDown||this.rightButton.isDown||this.middleButton.isDown||this.backButton.isDown||this.forwardButton.isDown||this.eraserButton.isDown)&&(this.isUp=!1,this.isDown=!0)},start:function(a){var b=this.game.input;return a.pointerId&&(this.pointerId=a.pointerId),this.identifier=a.identifier,this.target=a.target,this.isMouse?this.updateButtons(a):(this.isDown=!0,this.isUp=!1),this.active=!0,this.withinGame=!0,this.dirty=!1,this._history=[],this._clickTrampolines=null,this._trampolineTargetObject=null,this.msSinceLastClick=this.game.time.time-this.timeDown,this.timeDown=this.game.time.time,this._holdSent=!1,this.move(a,!0),this.positionDown.setTo(this.x,this.y),(b.multiInputOverride===c.Input.MOUSE_OVERRIDES_TOUCH||b.multiInputOverride===c.Input.MOUSE_TOUCH_COMBINE||b.multiInputOverride===c.Input.TOUCH_OVERRIDES_MOUSE&&0===b.totalActivePointers)&&(b.x=this.x,b.y=this.y,b.position.setTo(this.x,this.y),b.onDown.dispatch(this,a),b.resetSpeed(this.x,this.y)),this._stateReset=!1,this.totalTouches++,null!==this.targetObject&&this.targetObject._touchedHandler(this),this},update:function(){var a=this.game.input;this.active&&(this.dirty&&(a.interactiveItems.total>0&&this.processInteractiveObjects(!1),this.dirty=!1),this._holdSent===!1&&this.duration>=a.holdRate&&((a.multiInputOverride===c.Input.MOUSE_OVERRIDES_TOUCH||a.multiInputOverride===c.Input.MOUSE_TOUCH_COMBINE||a.multiInputOverride===c.Input.TOUCH_OVERRIDES_MOUSE&&0===a.totalActivePointers)&&a.onHold.dispatch(this),this._holdSent=!0),a.recordPointerHistory&&this.game.time.time>=this._nextDrop&&(this._nextDrop=this.game.time.time+a.recordRate,this._history.push({x:this.position.x,y:this.position.y}),this._history.length>a.recordLimit&&this._history.shift()))},move:function(a,b){var d=this.game.input;if(!d.pollLocked){if(void 0===b&&(b=!1),void 0!==a.button&&(this.button=a.button),b&&this.isMouse&&this.updateButtons(a),this.clientX=a.clientX,this.clientY=a.clientY,this.pageX=a.pageX,this.pageY=a.pageY,this.screenX=a.screenX,this.screenY=a.screenY,this.isMouse&&d.mouse.locked&&!b&&(this.rawMovementX=a.movementX||a.mozMovementX||a.webkitMovementX||0,this.rawMovementY=a.movementY||a.mozMovementY||a.webkitMovementY||0,this.movementX+=this.rawMovementX,this.movementY+=this.rawMovementY),this.x=(this.pageX-this.game.scale.offset.x)*d.scale.x,this.y=(this.pageY-this.game.scale.offset.y)*d.scale.y,this.position.setTo(this.x,this.y),this.circle.x=this.x,this.circle.y=this.y,(d.multiInputOverride===c.Input.MOUSE_OVERRIDES_TOUCH||d.multiInputOverride===c.Input.MOUSE_TOUCH_COMBINE||d.multiInputOverride===c.Input.TOUCH_OVERRIDES_MOUSE&&0===d.totalActivePointers)&&(d.activePointer=this,d.x=this.x,d.y=this.y,d.position.setTo(d.x,d.y),d.circle.x=d.x,d.circle.y=d.y),this.withinGame=this.game.scale.bounds.contains(this.pageX,this.pageY),this.game.paused)return this;for(var e=d.moveCallbacks.length;e--;)d.moveCallbacks[e].callback.call(d.moveCallbacks[e].context,this,this.x,this.y,b);return null!==this.targetObject&&this.targetObject.isDragged===!0?this.targetObject.update(this)===!1&&(this.targetObject=null):d.interactiveItems.total>0&&this.processInteractiveObjects(b),this}},processInteractiveObjects:function(a){for(var b=Number.MAX_VALUE,c=-1,d=null,e=this.game.input.interactiveItems.first;e;)e.checked=!1,e.validForInput(c,b,!1)&&(e.checked=!0,(a&&e.checkPointerDown(this,!0)||!a&&e.checkPointerOver(this,!0))&&(b=e.sprite.renderOrderID,c=e.priorityID,d=e)),e=this.game.input.interactiveItems.next;for(var e=this.game.input.interactiveItems.first;e;)!e.checked&&e.validForInput(c,b,!0)&&(a&&e.checkPointerDown(this,!1)||!a&&e.checkPointerOver(this,!1))&&(b=e.sprite.renderOrderID,c=e.priorityID,d=e),e=this.game.input.interactiveItems.next;return null===d?this.targetObject&&(this.targetObject._pointerOutHandler(this),this.targetObject=null):null===this.targetObject?(this.targetObject=d,d._pointerOverHandler(this)):this.targetObject===d?d.update(this)===!1&&(this.targetObject=null):(this.targetObject._pointerOutHandler(this),this.targetObject=d,this.targetObject._pointerOverHandler(this)),null!==this.targetObject},leave:function(a){this.withinGame=!1,this.move(a,!1)},stop:function(a){var b=this.game.input;return this._stateReset&&this.withinGame?void a.preventDefault():(this.timeUp=this.game.time.time,(b.multiInputOverride===c.Input.MOUSE_OVERRIDES_TOUCH||b.multiInputOverride===c.Input.MOUSE_TOUCH_COMBINE||b.multiInputOverride===c.Input.TOUCH_OVERRIDES_MOUSE&&0===b.totalActivePointers)&&(b.onUp.dispatch(this,a),this.duration>=0&&this.duration<=b.tapRate&&(this.timeUp-this.previousTapTime<b.doubleTapRate?b.onTap.dispatch(this,!0):b.onTap.dispatch(this,!1),this.previousTapTime=this.timeUp)),this.isMouse?this.updateButtons(a):(this.isDown=!1,this.isUp=!0),this.id>0&&(this.active=!1),this.withinGame=this.game.scale.bounds.contains(a.pageX,a.pageY),this.pointerId=null,this.identifier=null,this.positionUp.setTo(this.x,this.y),this.isMouse===!1&&b.currentPointers--,b.interactiveItems.callAll("_releasedHandler",this),this._clickTrampolines&&(this._trampolineTargetObject=this.targetObject),this.targetObject=null,this)},justPressed:function(a){return a=a||this.game.input.justPressedRate,this.isDown===!0&&this.timeDown+a>this.game.time.time},justReleased:function(a){return a=a||this.game.input.justReleasedRate,this.isUp&&this.timeUp+a>this.game.time.time},addClickTrampoline:function(a,b,c,d){if(this.isDown){for(var e=this._clickTrampolines=this._clickTrampolines||[],f=0;f<e.length;f++)if(e[f].name===a){e.splice(f,1);break}e.push({name:a,targetObject:this.targetObject,callback:b,callbackContext:c,callbackArgs:d})}},processClickTrampolines:function(){var a=this._clickTrampolines;if(a){for(var b=0;b<a.length;b++){var c=a[b];c.targetObject===this._trampolineTargetObject&&c.callback.apply(c.callbackContext,c.callbackArgs)}this._clickTrampolines=null,this._trampolineTargetObject=null}},reset:function(){this.isMouse===!1&&(this.active=!1),this.pointerId=null,this.identifier=null,this.dirty=!1,this.totalTouches=0,this._holdSent=!1,this._history.length=0,this._stateReset=!0,this.resetButtons(),this.targetObject&&this.targetObject._releasedHandler(this),this.targetObject=null},resetMovement:function(){this.movementX=0,this.movementY=0}},c.Pointer.prototype.constructor=c.Pointer,Object.defineProperty(c.Pointer.prototype,"duration",{get:function(){return this.isUp?-1:this.game.time.time-this.timeDown}}),Object.defineProperty(c.Pointer.prototype,"worldX",{get:function(){return this.game.world.camera.x+this.x}}),Object.defineProperty(c.Pointer.prototype,"worldY",{get:function(){return this.game.world.camera.y+this.y}}),c.PointerMode={CURSOR:1,CONTACT:2},c.Touch=function(a){this.game=a,this.enabled=!0,this.touchLockCallbacks=[],this.callbackContext=this.game,this.touchStartCallback=null,this.touchMoveCallback=null,this.touchEndCallback=null,this.touchEnterCallback=null,this.touchLeaveCallback=null,this.touchCancelCallback=null,this.preventDefault=!0,this.event=null,this._onTouchStart=null,this._onTouchMove=null,this._onTouchEnd=null,this._onTouchEnter=null,this._onTouchLeave=null,this._onTouchCancel=null,this._onTouchMove=null},c.Touch.prototype={start:function(){if(null===this._onTouchStart){var a=this;this.game.device.touch&&(this._onTouchStart=function(b){return a.onTouchStart(b)},this._onTouchMove=function(b){return a.onTouchMove(b)},this._onTouchEnd=function(b){return a.onTouchEnd(b)},this._onTouchEnter=function(b){return a.onTouchEnter(b)},this._onTouchLeave=function(b){return a.onTouchLeave(b)},this._onTouchCancel=function(b){return a.onTouchCancel(b)},this.game.canvas.addEventListener("touchstart",this._onTouchStart,!1),this.game.canvas.addEventListener("touchmove",this._onTouchMove,!1),this.game.canvas.addEventListener("touchend",this._onTouchEnd,!1),this.game.canvas.addEventListener("touchcancel",this._onTouchCancel,!1),this.game.device.cocoonJS||(this.game.canvas.addEventListener("touchenter",this._onTouchEnter,!1),this.game.canvas.addEventListener("touchleave",this._onTouchLeave,!1)))}},consumeDocumentTouches:function(){this._documentTouchMove=function(a){a.preventDefault()},document.addEventListener("touchmove",this._documentTouchMove,!1)},addTouchLockCallback:function(a,b,c){void 0===c&&(c=!1),this.touchLockCallbacks.push({callback:a,context:b,onEnd:c})},removeTouchLockCallback:function(a,b){for(var c=this.touchLockCallbacks.length;c--;)if(this.touchLockCallbacks[c].callback===a&&this.touchLockCallbacks[c].context===b)return this.touchLockCallbacks.splice(c,1),!0;return!1},onTouchStart:function(a){for(var b=this.touchLockCallbacks.length;b--;){var c=this.touchLockCallbacks[b];!c.onEnd&&c.callback.call(c.context,this,a)&&this.touchLockCallbacks.splice(b,1)}if(this.event=a,this.game.input.enabled&&this.enabled){this.touchStartCallback&&this.touchStartCallback.call(this.callbackContext,a),this.preventDefault&&a.preventDefault();for(var b=0;b<a.changedTouches.length;b++)this.game.input.startPointer(a.changedTouches[b])}},onTouchCancel:function(a){if(this.event=a,this.touchCancelCallback&&this.touchCancelCallback.call(this.callbackContext,a),this.game.input.enabled&&this.enabled){this.preventDefault&&a.preventDefault();for(var b=0;b<a.changedTouches.length;b++)this.game.input.stopPointer(a.changedTouches[b])}},onTouchEnter:function(a){this.event=a,this.touchEnterCallback&&this.touchEnterCallback.call(this.callbackContext,a),this.game.input.enabled&&this.enabled&&this.preventDefault&&a.preventDefault()},onTouchLeave:function(a){this.event=a,this.touchLeaveCallback&&this.touchLeaveCallback.call(this.callbackContext,a),this.preventDefault&&a.preventDefault()},onTouchMove:function(a){this.event=a,this.touchMoveCallback&&this.touchMoveCallback.call(this.callbackContext,a),this.preventDefault&&a.preventDefault();for(var b=0;b<a.changedTouches.length;b++)this.game.input.updatePointer(a.changedTouches[b])},onTouchEnd:function(a){for(var b=this.touchLockCallbacks.length;b--;){var c=this.touchLockCallbacks[b];c.onEnd&&c.callback.call(c.context,this,a)&&this.touchLockCallbacks.splice(b,1)}this.event=a,this.touchEndCallback&&this.touchEndCallback.call(this.callbackContext,a),this.preventDefault&&a.preventDefault();for(var b=0;b<a.changedTouches.length;b++)this.game.input.stopPointer(a.changedTouches[b])},stop:function(){this.game.device.touch&&(this.game.canvas.removeEventListener("touchstart",this._onTouchStart), +this.game.canvas.removeEventListener("touchmove",this._onTouchMove),this.game.canvas.removeEventListener("touchend",this._onTouchEnd),this.game.canvas.removeEventListener("touchenter",this._onTouchEnter),this.game.canvas.removeEventListener("touchleave",this._onTouchLeave),this.game.canvas.removeEventListener("touchcancel",this._onTouchCancel))}},c.Touch.prototype.constructor=c.Touch,c.InputHandler=function(a){this.sprite=a,this.game=a.game,this.enabled=!1,this.checked=!1,this.priorityID=0,this.useHandCursor=!1,this._setHandCursor=!1,this.isDragged=!1,this.allowHorizontalDrag=!0,this.allowVerticalDrag=!0,this.bringToTop=!1,this.snapOffset=null,this.snapOnDrag=!1,this.snapOnRelease=!1,this.snapX=0,this.snapY=0,this.snapOffsetX=0,this.snapOffsetY=0,this.pixelPerfectOver=!1,this.pixelPerfectClick=!1,this.pixelPerfectAlpha=255,this.draggable=!1,this.boundsRect=null,this.boundsSprite=null,this.consumePointerEvent=!1,this.scaleLayer=!1,this.dragOffset=new c.Point,this.dragFromCenter=!1,this.dragStartPoint=new c.Point,this.snapPoint=new c.Point,this._dragPoint=new c.Point,this._dragPhase=!1,this._wasEnabled=!1,this._tempPoint=new c.Point,this._pointerData=[],this._pointerData.push({id:0,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1})},c.InputHandler.prototype={start:function(a,b){if(a=a||0,void 0===b&&(b=!1),this.enabled===!1){this.game.input.interactiveItems.add(this),this.useHandCursor=b,this.priorityID=a;for(var d=0;10>d;d++)this._pointerData[d]={id:d,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1};this.snapOffset=new c.Point,this.enabled=!0,this._wasEnabled=!0}return this.sprite.events.onAddedToGroup.add(this.addedToGroup,this),this.sprite.events.onRemovedFromGroup.add(this.removedFromGroup,this),this.flagged=!1,this.sprite},addedToGroup:function(){this._dragPhase||this._wasEnabled&&!this.enabled&&this.start()},removedFromGroup:function(){this._dragPhase||(this.enabled?(this._wasEnabled=!0,this.stop()):this._wasEnabled=!1)},reset:function(){this.enabled=!1,this.flagged=!1;for(var a=0;10>a;a++)this._pointerData[a]={id:a,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1}},stop:function(){this.enabled!==!1&&(this.enabled=!1,this.game.input.interactiveItems.remove(this))},destroy:function(){this.sprite&&(this._setHandCursor&&(this.game.canvas.style.cursor="default",this._setHandCursor=!1),this.enabled=!1,this.game.input.interactiveItems.remove(this),this._pointerData.length=0,this.boundsRect=null,this.boundsSprite=null,this.sprite=null)},validForInput:function(a,b,c){return void 0===c&&(c=!0),!this.enabled||0===this.sprite.scale.x||0===this.sprite.scale.y||this.priorityID<this.game.input.minPriorityID?!1:(c||!this.pixelPerfectClick&&!this.pixelPerfectOver)&&(this.priorityID>a||this.priorityID===a&&this.sprite.renderOrderID<b)?!0:!1},isPixelPerfect:function(){return this.pixelPerfectClick||this.pixelPerfectOver},pointerX:function(a){return a=a||0,this._pointerData[a].x},pointerY:function(a){return a=a||0,this._pointerData[a].y},pointerDown:function(a){return a=a||0,this._pointerData[a].isDown},pointerUp:function(a){return a=a||0,this._pointerData[a].isUp},pointerTimeDown:function(a){return a=a||0,this._pointerData[a].timeDown},pointerTimeUp:function(a){return a=a||0,this._pointerData[a].timeUp},pointerOver:function(a){if(!this.enabled)return!1;if(void 0!==a)return this._pointerData[a].isOver;for(var b=0;10>b;b++)if(this._pointerData[b].isOver)return!0},pointerOut:function(a){if(!this.enabled)return!1;if(void 0!==a)return this._pointerData[a].isOut;for(var b=0;10>b;b++)if(this._pointerData[b].isOut)return!0},pointerTimeOver:function(a){return a=a||0,this._pointerData[a].timeOver},pointerTimeOut:function(a){return a=a||0,this._pointerData[a].timeOut},pointerDragged:function(a){return a=a||0,this._pointerData[a].isDragged},checkPointerDown:function(a,b){return a.isDown&&this.enabled&&this.sprite&&this.sprite.parent&&this.sprite.visible&&this.sprite.parent.visible&&this.game.input.hitTest(this.sprite,a,this._tempPoint)?(void 0===b&&(b=!1),!b&&this.pixelPerfectClick?this.checkPixel(this._tempPoint.x,this._tempPoint.y):!0):!1},checkPointerOver:function(a,b){return this.enabled&&this.sprite&&this.sprite.parent&&this.sprite.visible&&this.sprite.parent.visible&&this.game.input.hitTest(this.sprite,a,this._tempPoint)?(void 0===b&&(b=!1),!b&&this.pixelPerfectOver?this.checkPixel(this._tempPoint.x,this._tempPoint.y):!0):!1},checkPixel:function(a,b,c){if(this.sprite.texture.baseTexture.source){if(null===a&&null===b){this.game.input.getLocalPosition(this.sprite,c,this._tempPoint);var a=this._tempPoint.x,b=this._tempPoint.y}if(0!==this.sprite.anchor.x&&(a-=-this.sprite.texture.frame.width*this.sprite.anchor.x),0!==this.sprite.anchor.y&&(b-=-this.sprite.texture.frame.height*this.sprite.anchor.y),a+=this.sprite.texture.frame.x,b+=this.sprite.texture.frame.y,this.sprite.texture.trim&&(a-=this.sprite.texture.trim.x,b-=this.sprite.texture.trim.y,a<this.sprite.texture.crop.x||a>this.sprite.texture.crop.right||b<this.sprite.texture.crop.y||b>this.sprite.texture.crop.bottom))return this._dx=a,this._dy=b,!1;this._dx=a,this._dy=b,this.game.input.hitContext.clearRect(0,0,1,1),this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source,a,b,1,1,0,0,1,1);var d=this.game.input.hitContext.getImageData(0,0,1,1);if(d.data[3]>=this.pixelPerfectAlpha)return!0}return!1},update:function(a){return null!==this.sprite&&void 0!==this.sprite.parent?this.enabled&&this.sprite.visible&&this.sprite.parent.visible?this.draggable&&this._draggedPointerID===a.id?this.updateDrag(a):this._pointerData[a.id].isOver?this.checkPointerOver(a)?(this._pointerData[a.id].x=a.x-this.sprite.x,this._pointerData[a.id].y=a.y-this.sprite.y,!0):(this._pointerOutHandler(a),!1):void 0:(this._pointerOutHandler(a),!1):void 0},_pointerOverHandler:function(a){if(null!==this.sprite){var b=this._pointerData[a.id];(b.isOver===!1||a.dirty)&&(b.isOver=!0,b.isOut=!1,b.timeOver=this.game.time.time,b.x=a.x-this.sprite.x,b.y=a.y-this.sprite.y,this.useHandCursor&&b.isDragged===!1&&(this.game.canvas.style.cursor="pointer",this._setHandCursor=!0),this.sprite&&this.sprite.events&&this.sprite.events.onInputOver$dispatch(this.sprite,a))}},_pointerOutHandler:function(a){if(null!==this.sprite){var b=this._pointerData[a.id];b.isOver=!1,b.isOut=!0,b.timeOut=this.game.time.time,this.useHandCursor&&b.isDragged===!1&&(this.game.canvas.style.cursor="default",this._setHandCursor=!1),this.sprite&&this.sprite.events&&this.sprite.events.onInputOut$dispatch(this.sprite,a)}},_touchedHandler:function(a){if(null!==this.sprite){var b=this._pointerData[a.id];if(!b.isDown&&b.isOver){if(this.pixelPerfectClick&&!this.checkPixel(null,null,a))return;b.isDown=!0,b.isUp=!1,b.timeDown=this.game.time.time,this.sprite&&this.sprite.events&&this.sprite.events.onInputDown$dispatch(this.sprite,a),a.dirty=!0,this.draggable&&this.isDragged===!1&&this.startDrag(a),this.bringToTop&&this.sprite.bringToTop()}return this.consumePointerEvent}},_releasedHandler:function(a){if(null!==this.sprite){var b=this._pointerData[a.id];if(b.isDown&&a.isUp){b.isDown=!1,b.isUp=!0,b.timeUp=this.game.time.time,b.downDuration=b.timeUp-b.timeDown;var c=this.checkPointerOver(a);this.sprite&&this.sprite.events&&(this.sprite.events.onInputUp$dispatch(this.sprite,a,c),c&&(c=this.checkPointerOver(a))),b.isOver=c,!c&&this.useHandCursor&&(this.game.canvas.style.cursor="default",this._setHandCursor=!1),a.dirty=!0,this.draggable&&this.isDragged&&this._draggedPointerID===a.id&&this.stopDrag(a)}}},updateDrag:function(a){if(a.isUp)return this.stopDrag(a),!1;var b=this.globalToLocalX(a.x)+this._dragPoint.x+this.dragOffset.x,c=this.globalToLocalY(a.y)+this._dragPoint.y+this.dragOffset.y;return this.sprite.fixedToCamera?(this.allowHorizontalDrag&&(this.sprite.cameraOffset.x=b),this.allowVerticalDrag&&(this.sprite.cameraOffset.y=c),this.boundsRect&&this.checkBoundsRect(),this.boundsSprite&&this.checkBoundsSprite(),this.snapOnDrag&&(this.sprite.cameraOffset.x=Math.round((this.sprite.cameraOffset.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.cameraOffset.y=Math.round((this.sprite.cameraOffset.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY,this.snapPoint.set(this.sprite.cameraOffset.x,this.sprite.cameraOffset.y))):(this.allowHorizontalDrag&&(this.sprite.x=b),this.allowVerticalDrag&&(this.sprite.y=c),this.boundsRect&&this.checkBoundsRect(),this.boundsSprite&&this.checkBoundsSprite(),this.snapOnDrag&&(this.sprite.x=Math.round((this.sprite.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.y=Math.round((this.sprite.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY,this.snapPoint.set(this.sprite.x,this.sprite.y))),this.sprite.events.onDragUpdate.dispatch(this.sprite,a,b,c,this.snapPoint),!0},justOver:function(a,b){return a=a||0,b=b||500,this._pointerData[a].isOver&&this.overDuration(a)<b},justOut:function(a,b){return a=a||0,b=b||500,this._pointerData[a].isOut&&this.game.time.time-this._pointerData[a].timeOut<b},justPressed:function(a,b){return a=a||0,b=b||500,this._pointerData[a].isDown&&this.downDuration(a)<b},justReleased:function(a,b){return a=a||0,b=b||500,this._pointerData[a].isUp&&this.game.time.time-this._pointerData[a].timeUp<b},overDuration:function(a){return a=a||0,this._pointerData[a].isOver?this.game.time.time-this._pointerData[a].timeOver:-1},downDuration:function(a){return a=a||0,this._pointerData[a].isDown?this.game.time.time-this._pointerData[a].timeDown:-1},enableDrag:function(a,b,d,e,f,g){void 0===a&&(a=!1),void 0===b&&(b=!1),void 0===d&&(d=!1),void 0===e&&(e=255),void 0===f&&(f=null),void 0===g&&(g=null),this._dragPoint=new c.Point,this.draggable=!0,this.bringToTop=b,this.dragOffset=new c.Point,this.dragFromCenter=a,this.pixelPerfectClick=d,this.pixelPerfectAlpha=e,f&&(this.boundsRect=f),g&&(this.boundsSprite=g)},disableDrag:function(){if(this._pointerData)for(var a=0;10>a;a++)this._pointerData[a].isDragged=!1;this.draggable=!1,this.isDragged=!1,this._draggedPointerID=-1},startDrag:function(a){var b=this.sprite.x,c=this.sprite.y;if(this.isDragged=!0,this._draggedPointerID=a.id,this._pointerData[a.id].isDragged=!0,this.sprite.fixedToCamera)this.dragFromCenter?(this.sprite.centerOn(a.x,a.y),this._dragPoint.setTo(this.sprite.cameraOffset.x-a.x,this.sprite.cameraOffset.y-a.y)):this._dragPoint.setTo(this.sprite.cameraOffset.x-a.x,this.sprite.cameraOffset.y-a.y);else{if(this.dragFromCenter){var d=this.sprite.getBounds();this.sprite.x=this.globalToLocalX(a.x)+(this.sprite.x-d.centerX),this.sprite.y=this.globalToLocalY(a.y)+(this.sprite.y-d.centerY)}this._dragPoint.setTo(this.sprite.x-this.globalToLocalX(a.x),this.sprite.y-this.globalToLocalY(a.y))}this.updateDrag(a),this.bringToTop&&(this._dragPhase=!0,this.sprite.bringToTop()),this.dragStartPoint.set(b,c),this.sprite.events.onDragStart$dispatch(this.sprite,a,b,c)},globalToLocalX:function(a){return this.scaleLayer&&(a-=this.game.scale.grid.boundsFluid.x,a*=this.game.scale.grid.scaleFluidInversed.x),a},globalToLocalY:function(a){return this.scaleLayer&&(a-=this.game.scale.grid.boundsFluid.y,a*=this.game.scale.grid.scaleFluidInversed.y),a},stopDrag:function(a){this.isDragged=!1,this._draggedPointerID=-1,this._pointerData[a.id].isDragged=!1,this._dragPhase=!1,this.snapOnRelease&&(this.sprite.fixedToCamera?(this.sprite.cameraOffset.x=Math.round((this.sprite.cameraOffset.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.cameraOffset.y=Math.round((this.sprite.cameraOffset.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY):(this.sprite.x=Math.round((this.sprite.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.y=Math.round((this.sprite.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY)),this.sprite.events.onDragStop$dispatch(this.sprite,a),this.checkPointerOver(a)===!1&&this._pointerOutHandler(a)},setDragLock:function(a,b){void 0===a&&(a=!0),void 0===b&&(b=!0),this.allowHorizontalDrag=a,this.allowVerticalDrag=b},enableSnap:function(a,b,c,d,e,f){void 0===c&&(c=!0),void 0===d&&(d=!1),void 0===e&&(e=0),void 0===f&&(f=0),this.snapX=a,this.snapY=b,this.snapOffsetX=e,this.snapOffsetY=f,this.snapOnDrag=c,this.snapOnRelease=d},disableSnap:function(){this.snapOnDrag=!1,this.snapOnRelease=!1},checkBoundsRect:function(){this.sprite.fixedToCamera?(this.sprite.cameraOffset.x<this.boundsRect.left?this.sprite.cameraOffset.x=this.boundsRect.left:this.sprite.cameraOffset.x+this.sprite.width>this.boundsRect.right&&(this.sprite.cameraOffset.x=this.boundsRect.right-this.sprite.width),this.sprite.cameraOffset.y<this.boundsRect.top?this.sprite.cameraOffset.y=this.boundsRect.top:this.sprite.cameraOffset.y+this.sprite.height>this.boundsRect.bottom&&(this.sprite.cameraOffset.y=this.boundsRect.bottom-this.sprite.height)):(this.sprite.left<this.boundsRect.left?this.sprite.x=this.boundsRect.x+this.sprite.offsetX:this.sprite.right>this.boundsRect.right&&(this.sprite.x=this.boundsRect.right-(this.sprite.width-this.sprite.offsetX)),this.sprite.top<this.boundsRect.top?this.sprite.y=this.boundsRect.top+this.sprite.offsetY:this.sprite.bottom>this.boundsRect.bottom&&(this.sprite.y=this.boundsRect.bottom-(this.sprite.height-this.sprite.offsetY)))},checkBoundsSprite:function(){this.sprite.fixedToCamera&&this.boundsSprite.fixedToCamera?(this.sprite.cameraOffset.x<this.boundsSprite.cameraOffset.x?this.sprite.cameraOffset.x=this.boundsSprite.cameraOffset.x:this.sprite.cameraOffset.x+this.sprite.width>this.boundsSprite.cameraOffset.x+this.boundsSprite.width&&(this.sprite.cameraOffset.x=this.boundsSprite.cameraOffset.x+this.boundsSprite.width-this.sprite.width),this.sprite.cameraOffset.y<this.boundsSprite.cameraOffset.y?this.sprite.cameraOffset.y=this.boundsSprite.cameraOffset.y:this.sprite.cameraOffset.y+this.sprite.height>this.boundsSprite.cameraOffset.y+this.boundsSprite.height&&(this.sprite.cameraOffset.y=this.boundsSprite.cameraOffset.y+this.boundsSprite.height-this.sprite.height)):(this.sprite.left<this.boundsSprite.left?this.sprite.x=this.boundsSprite.left+this.sprite.offsetX:this.sprite.right>this.boundsSprite.right&&(this.sprite.x=this.boundsSprite.right-(this.sprite.width-this.sprite.offsetX)),this.sprite.top<this.boundsSprite.top?this.sprite.y=this.boundsSprite.top+this.sprite.offsetY:this.sprite.bottom>this.boundsSprite.bottom&&(this.sprite.y=this.boundsSprite.bottom-(this.sprite.height-this.sprite.offsetY)))}},c.InputHandler.prototype.constructor=c.InputHandler,c.Gamepad=function(a){this.game=a,this._gamepadIndexMap={},this._rawPads=[],this._active=!1,this.enabled=!0,this._gamepadSupportAvailable=!!navigator.webkitGetGamepads||!!navigator.webkitGamepads||-1!=navigator.userAgent.indexOf("Firefox/")||!!navigator.getGamepads,this._prevRawGamepadTypes=[],this._prevTimestamps=[],this.callbackContext=this,this.onConnectCallback=null,this.onDisconnectCallback=null,this.onDownCallback=null,this.onUpCallback=null,this.onAxisCallback=null,this.onFloatCallback=null,this._ongamepadconnected=null,this._gamepaddisconnected=null,this._gamepads=[new c.SinglePad(a,this),new c.SinglePad(a,this),new c.SinglePad(a,this),new c.SinglePad(a,this)]},c.Gamepad.prototype={addCallbacks:function(a,b){"undefined"!=typeof b&&(this.onConnectCallback="function"==typeof b.onConnect?b.onConnect:this.onConnectCallback,this.onDisconnectCallback="function"==typeof b.onDisconnect?b.onDisconnect:this.onDisconnectCallback,this.onDownCallback="function"==typeof b.onDown?b.onDown:this.onDownCallback,this.onUpCallback="function"==typeof b.onUp?b.onUp:this.onUpCallback,this.onAxisCallback="function"==typeof b.onAxis?b.onAxis:this.onAxisCallback,this.onFloatCallback="function"==typeof b.onFloat?b.onFloat:this.onFloatCallback,this.callbackContext=a)},start:function(){if(!this._active){this._active=!0;var a=this;this._onGamepadConnected=function(b){return a.onGamepadConnected(b)},this._onGamepadDisconnected=function(b){return a.onGamepadDisconnected(b)},window.addEventListener("gamepadconnected",this._onGamepadConnected,!1),window.addEventListener("gamepaddisconnected",this._onGamepadDisconnected,!1)}},onGamepadConnected:function(a){var b=a.gamepad;this._rawPads.push(b),this._gamepads[b.index].connect(b)},onGamepadDisconnected:function(a){var b=a.gamepad;for(var c in this._rawPads)this._rawPads[c].index===b.index&&this._rawPads.splice(c,1);this._gamepads[b.index].disconnect()},update:function(){this._pollGamepads(),this.pad1.pollStatus(),this.pad2.pollStatus(),this.pad3.pollStatus(),this.pad4.pollStatus()},_pollGamepads:function(){if(navigator.getGamepads)var a=navigator.getGamepads();else if(navigator.webkitGetGamepads)var a=navigator.webkitGetGamepads();else if(navigator.webkitGamepads)var a=navigator.webkitGamepads();if(a){this._rawPads=[];for(var b=!1,c=0;c<a.length&&(typeof a[c]!==this._prevRawGamepadTypes[c]&&(b=!0,this._prevRawGamepadTypes[c]=typeof a[c]),a[c]&&this._rawPads.push(a[c]),3!==c);c++);if(b){for(var d,e={rawIndices:{},padIndices:{}},f=0;f<this._gamepads.length;f++)if(d=this._gamepads[f],d.connected)for(var g=0;g<this._rawPads.length;g++)this._rawPads[g].index===d.index&&(e.rawIndices[d.index]=!0,e.padIndices[f]=!0);for(var h=0;h<this._gamepads.length;h++)if(d=this._gamepads[h],!e.padIndices[h]){this._rawPads.length<1&&d.disconnect();for(var i=0;i<this._rawPads.length&&!e.padIndices[h];i++){var j=this._rawPads[i];if(j){if(e.rawIndices[j.index]){d.disconnect();continue}d.connect(j),e.rawIndices[j.index]=!0,e.padIndices[h]=!0}else d.disconnect()}}}}},setDeadZones:function(a){for(var b=0;b<this._gamepads.length;b++)this._gamepads[b].deadZone=a},stop:function(){this._active=!1,window.removeEventListener("gamepadconnected",this._onGamepadConnected),window.removeEventListener("gamepaddisconnected",this._onGamepadDisconnected)},reset:function(){this.update();for(var a=0;a<this._gamepads.length;a++)this._gamepads[a].reset()},justPressed:function(a,b){for(var c=0;c<this._gamepads.length;c++)if(this._gamepads[c].justPressed(a,b)===!0)return!0;return!1},justReleased:function(a,b){for(var c=0;c<this._gamepads.length;c++)if(this._gamepads[c].justReleased(a,b)===!0)return!0;return!1},isDown:function(a){for(var b=0;b<this._gamepads.length;b++)if(this._gamepads[b].isDown(a)===!0)return!0;return!1},destroy:function(){this.stop();for(var a=0;a<this._gamepads.length;a++)this._gamepads[a].destroy()}},c.Gamepad.prototype.constructor=c.Gamepad,Object.defineProperty(c.Gamepad.prototype,"active",{get:function(){return this._active}}),Object.defineProperty(c.Gamepad.prototype,"supported",{get:function(){return this._gamepadSupportAvailable}}),Object.defineProperty(c.Gamepad.prototype,"padsConnected",{get:function(){return this._rawPads.length}}),Object.defineProperty(c.Gamepad.prototype,"pad1",{get:function(){return this._gamepads[0]}}),Object.defineProperty(c.Gamepad.prototype,"pad2",{get:function(){return this._gamepads[1]}}),Object.defineProperty(c.Gamepad.prototype,"pad3",{get:function(){return this._gamepads[2]}}),Object.defineProperty(c.Gamepad.prototype,"pad4",{get:function(){return this._gamepads[3]}}),c.Gamepad.BUTTON_0=0,c.Gamepad.BUTTON_1=1,c.Gamepad.BUTTON_2=2,c.Gamepad.BUTTON_3=3,c.Gamepad.BUTTON_4=4,c.Gamepad.BUTTON_5=5,c.Gamepad.BUTTON_6=6,c.Gamepad.BUTTON_7=7,c.Gamepad.BUTTON_8=8,c.Gamepad.BUTTON_9=9,c.Gamepad.BUTTON_10=10,c.Gamepad.BUTTON_11=11,c.Gamepad.BUTTON_12=12,c.Gamepad.BUTTON_13=13,c.Gamepad.BUTTON_14=14,c.Gamepad.BUTTON_15=15,c.Gamepad.AXIS_0=0,c.Gamepad.AXIS_1=1,c.Gamepad.AXIS_2=2,c.Gamepad.AXIS_3=3,c.Gamepad.AXIS_4=4,c.Gamepad.AXIS_5=5,c.Gamepad.AXIS_6=6,c.Gamepad.AXIS_7=7,c.Gamepad.AXIS_8=8,c.Gamepad.AXIS_9=9,c.Gamepad.XBOX360_A=0,c.Gamepad.XBOX360_B=1,c.Gamepad.XBOX360_X=2,c.Gamepad.XBOX360_Y=3,c.Gamepad.XBOX360_LEFT_BUMPER=4,c.Gamepad.XBOX360_RIGHT_BUMPER=5,c.Gamepad.XBOX360_LEFT_TRIGGER=6,c.Gamepad.XBOX360_RIGHT_TRIGGER=7,c.Gamepad.XBOX360_BACK=8,c.Gamepad.XBOX360_START=9,c.Gamepad.XBOX360_STICK_LEFT_BUTTON=10,c.Gamepad.XBOX360_STICK_RIGHT_BUTTON=11,c.Gamepad.XBOX360_DPAD_LEFT=14,c.Gamepad.XBOX360_DPAD_RIGHT=15,c.Gamepad.XBOX360_DPAD_UP=12,c.Gamepad.XBOX360_DPAD_DOWN=13,c.Gamepad.XBOX360_STICK_LEFT_X=0,c.Gamepad.XBOX360_STICK_LEFT_Y=1,c.Gamepad.XBOX360_STICK_RIGHT_X=2,c.Gamepad.XBOX360_STICK_RIGHT_Y=3,c.Gamepad.PS3XC_X=0,c.Gamepad.PS3XC_CIRCLE=1,c.Gamepad.PS3XC_SQUARE=2,c.Gamepad.PS3XC_TRIANGLE=3,c.Gamepad.PS3XC_L1=4,c.Gamepad.PS3XC_R1=5,c.Gamepad.PS3XC_L2=6,c.Gamepad.PS3XC_R2=7,c.Gamepad.PS3XC_SELECT=8,c.Gamepad.PS3XC_START=9,c.Gamepad.PS3XC_STICK_LEFT_BUTTON=10,c.Gamepad.PS3XC_STICK_RIGHT_BUTTON=11,c.Gamepad.PS3XC_DPAD_UP=12,c.Gamepad.PS3XC_DPAD_DOWN=13,c.Gamepad.PS3XC_DPAD_LEFT=14,c.Gamepad.PS3XC_DPAD_RIGHT=15,c.Gamepad.PS3XC_STICK_LEFT_X=0,c.Gamepad.PS3XC_STICK_LEFT_Y=1,c.Gamepad.PS3XC_STICK_RIGHT_X=2,c.Gamepad.PS3XC_STICK_RIGHT_Y=3,c.SinglePad=function(a,b){this.game=a,this.index=null,this.connected=!1,this.callbackContext=this,this.onConnectCallback=null,this.onDisconnectCallback=null,this.onDownCallback=null,this.onUpCallback=null,this.onAxisCallback=null,this.onFloatCallback=null,this.deadZone=.26,this._padParent=b,this._rawPad=null,this._prevTimestamp=null,this._buttons=[],this._buttonsLen=0,this._axes=[],this._axesLen=0},c.SinglePad.prototype={addCallbacks:function(a,b){"undefined"!=typeof b&&(this.onConnectCallback="function"==typeof b.onConnect?b.onConnect:this.onConnectCallback,this.onDisconnectCallback="function"==typeof b.onDisconnect?b.onDisconnect:this.onDisconnectCallback,this.onDownCallback="function"==typeof b.onDown?b.onDown:this.onDownCallback,this.onUpCallback="function"==typeof b.onUp?b.onUp:this.onUpCallback,this.onAxisCallback="function"==typeof b.onAxis?b.onAxis:this.onAxisCallback,this.onFloatCallback="function"==typeof b.onFloat?b.onFloat:this.onFloatCallback)},getButton:function(a){return this._buttons[a]?this._buttons[a]:null},pollStatus:function(){if(this.connected&&this.game.input.enabled&&this.game.input.gamepad.enabled&&(!this._rawPad.timestamp||this._rawPad.timestamp!==this._prevTimestamp)){for(var a=0;a<this._buttonsLen;a++){var b=isNaN(this._rawPad.buttons[a])?this._rawPad.buttons[a].value:this._rawPad.buttons[a];b!==this._buttons[a].value&&(1===b?this.processButtonDown(a,b):0===b?this.processButtonUp(a,b):this.processButtonFloat(a,b))}for(var c=0;c<this._axesLen;c++){var d=this._rawPad.axes[c];d>0&&d>this.deadZone||0>d&&d<-this.deadZone?this.processAxisChange(c,d):this.processAxisChange(c,0)}this._prevTimestamp=this._rawPad.timestamp}},connect:function(a){var b=!this.connected;this.connected=!0,this.index=a.index,this._rawPad=a,this._buttons=[],this._buttonsLen=a.buttons.length,this._axes=[],this._axesLen=a.axes.length;for(var d=0;d<this._axesLen;d++)this._axes[d]=a.axes[d];for(var e in a.buttons)e=parseInt(e,10),this._buttons[e]=new c.DeviceButton(this,e);b&&this._padParent.onConnectCallback&&this._padParent.onConnectCallback.call(this._padParent.callbackContext,this.index),b&&this.onConnectCallback&&this.onConnectCallback.call(this.callbackContext)},disconnect:function(){var a=this.connected,b=this.index;this.connected=!1,this.index=null,this._rawPad=void 0;for(var c=0;c<this._buttonsLen;c++)this._buttons[c].destroy();this._buttons=[],this._buttonsLen=0,this._axes=[],this._axesLen=0,a&&this._padParent.onDisconnectCallback&&this._padParent.onDisconnectCallback.call(this._padParent.callbackContext,b),a&&this.onDisconnectCallback&&this.onDisconnectCallback.call(this.callbackContext)},destroy:function(){this._rawPad=void 0;for(var a=0;a<this._buttonsLen;a++)this._buttons[a].destroy();this._buttons=[],this._buttonsLen=0,this._axes=[],this._axesLen=0,this.onConnectCallback=null,this.onDisconnectCallback=null,this.onDownCallback=null,this.onUpCallback=null,this.onAxisCallback=null,this.onFloatCallback=null},processAxisChange:function(a,b){this._axes[a]!==b&&(this._axes[a]=b,this._padParent.onAxisCallback&&this._padParent.onAxisCallback.call(this._padParent.callbackContext,this,a,b),this.onAxisCallback&&this.onAxisCallback.call(this.callbackContext,this,a,b))},processButtonDown:function(a,b){this._padParent.onDownCallback&&this._padParent.onDownCallback.call(this._padParent.callbackContext,a,b,this.index),this.onDownCallback&&this.onDownCallback.call(this.callbackContext,a,b),this._buttons[a]&&this._buttons[a].start(null,b)},processButtonUp:function(a,b){this._padParent.onUpCallback&&this._padParent.onUpCallback.call(this._padParent.callbackContext,a,b,this.index),this.onUpCallback&&this.onUpCallback.call(this.callbackContext,a,b),this._buttons[a]&&this._buttons[a].stop(null,b)},processButtonFloat:function(a,b){this._padParent.onFloatCallback&&this._padParent.onFloatCallback.call(this._padParent.callbackContext,a,b,this.index),this.onFloatCallback&&this.onFloatCallback.call(this.callbackContext,a,b),this._buttons[a]&&this._buttons[a].padFloat(b)},axis:function(a){return this._axes[a]?this._axes[a]:!1},isDown:function(a){return this._buttons[a]?this._buttons[a].isDown:!1},isUp:function(a){return this._buttons[a]?this._buttons[a].isUp:!1},justReleased:function(a,b){return this._buttons[a]?this._buttons[a].justReleased(b):void 0},justPressed:function(a,b){return this._buttons[a]?this._buttons[a].justPressed(b):void 0},buttonValue:function(a){return this._buttons[a]?this._buttons[a].value:null},reset:function(){for(var a=0;a<this._axes.length;a++)this._axes[a]=0}},c.SinglePad.prototype.constructor=c.SinglePad,c.Key=function(a,b){this.game=a,this._enabled=!0,this.event=null,this.isDown=!1,this.isUp=!0,this.altKey=!1,this.ctrlKey=!1,this.shiftKey=!1,this.timeDown=0,this.duration=0,this.timeUp=-2500,this.repeats=0,this.keyCode=b,this.onDown=new c.Signal,this.onHoldCallback=null,this.onHoldContext=null,this.onUp=new c.Signal,this._justDown=!1,this._justUp=!1},c.Key.prototype={update:function(){this._enabled&&this.isDown&&(this.duration=this.game.time.time-this.timeDown,this.repeats++,this.onHoldCallback&&this.onHoldCallback.call(this.onHoldContext,this))},processKeyDown:function(a){this._enabled&&(this.event=a,this.isDown||(this.altKey=a.altKey,this.ctrlKey=a.ctrlKey,this.shiftKey=a.shiftKey,this.isDown=!0,this.isUp=!1,this.timeDown=this.game.time.time,this.duration=0,this.repeats=0,this._justDown=!0,this.onDown.dispatch(this)))},processKeyUp:function(a){this._enabled&&(this.event=a,this.isUp||(this.isDown=!1,this.isUp=!0,this.timeUp=this.game.time.time,this.duration=this.game.time.time-this.timeDown,this._justUp=!0,this.onUp.dispatch(this)))},reset:function(a){void 0===a&&(a=!0),this.isDown=!1,this.isUp=!0,this.timeUp=this.game.time.time,this.duration=0,this._enabled=!0,this._justDown=!1,this._justUp=!1,a&&(this.onDown.removeAll(),this.onUp.removeAll(),this.onHoldCallback=null,this.onHoldContext=null)},downDuration:function(a){return void 0===a&&(a=50),this.isDown&&this.duration<a},upDuration:function(a){return void 0===a&&(a=50),!this.isDown&&this.game.time.time-this.timeUp<a}},Object.defineProperty(c.Key.prototype,"justDown",{get:function(){var a=this._justDown;return this._justDown=!1,a}}),Object.defineProperty(c.Key.prototype,"justUp",{get:function(){var a=this._justUp;return this._justUp=!1,a}}),Object.defineProperty(c.Key.prototype,"enabled",{get:function(){return this._enabled},set:function(a){a=!!a,a!==this._enabled&&(a||this.reset(!1),this._enabled=a)}}),c.Key.prototype.constructor=c.Key,c.Keyboard=function(a){this.game=a,this.enabled=!0,this.event=null,this.pressEvent=null,this.callbackContext=this,this.onDownCallback=null,this.onPressCallback=null,this.onUpCallback=null,this._keys=[],this._capture=[],this._onKeyDown=null,this._onKeyPress=null,this._onKeyUp=null,this._i=0,this._k=0},c.Keyboard.prototype={addCallbacks:function(a,b,c,d){this.callbackContext=a,void 0!==b&&null!==b&&(this.onDownCallback=b),void 0!==c&&null!==c&&(this.onUpCallback=c),void 0!==d&&null!==d&&(this.onPressCallback=d)},addKey:function(a){return this._keys[a]||(this._keys[a]=new c.Key(this.game,a),this.addKeyCapture(a)),this._keys[a]},addKeys:function(a){var b={};for(var c in a)b[c]=this.addKey(a[c]);return b},removeKey:function(a){this._keys[a]&&(this._keys[a]=null,this.removeKeyCapture(a))},createCursorKeys:function(){return this.addKeys({up:c.KeyCode.UP,down:c.KeyCode.DOWN,left:c.KeyCode.LEFT,right:c.KeyCode.RIGHT})},start:function(){if(!this.game.device.cocoonJS&&null===this._onKeyDown){var a=this;this._onKeyDown=function(b){return a.processKeyDown(b)},this._onKeyUp=function(b){return a.processKeyUp(b)},this._onKeyPress=function(b){return a.processKeyPress(b)},window.addEventListener("keydown",this._onKeyDown,!1),window.addEventListener("keyup",this._onKeyUp,!1),window.addEventListener("keypress",this._onKeyPress,!1)}},stop:function(){window.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("keyup",this._onKeyUp),window.removeEventListener("keypress",this._onKeyPress),this._onKeyDown=null,this._onKeyUp=null,this._onKeyPress=null},destroy:function(){this.stop(),this.clearCaptures(),this._keys.length=0,this._i=0},addKeyCapture:function(a){if("object"==typeof a)for(var b in a)this._capture[a[b]]=!0;else this._capture[a]=!0},removeKeyCapture:function(a){delete this._capture[a]},clearCaptures:function(){this._capture={}},update:function(){for(this._i=this._keys.length;this._i--;)this._keys[this._i]&&this._keys[this._i].update()},processKeyDown:function(a){this.event=a,this.game.input.enabled&&this.enabled&&(this._capture[a.keyCode]&&a.preventDefault(),this._keys[a.keyCode]||(this._keys[a.keyCode]=new c.Key(this.game,a.keyCode)),this._keys[a.keyCode].processKeyDown(a),this._k=a.keyCode,this.onDownCallback&&this.onDownCallback.call(this.callbackContext,a))},processKeyPress:function(a){this.pressEvent=a,this.game.input.enabled&&this.enabled&&this.onPressCallback&&this.onPressCallback.call(this.callbackContext,String.fromCharCode(a.charCode),a)},processKeyUp:function(a){this.event=a,this.game.input.enabled&&this.enabled&&(this._capture[a.keyCode]&&a.preventDefault(),this._keys[a.keyCode]||(this._keys[a.keyCode]=new c.Key(this.game,a.keyCode)),this._keys[a.keyCode].processKeyUp(a),this.onUpCallback&&this.onUpCallback.call(this.callbackContext,a))},reset:function(a){void 0===a&&(a=!0),this.event=null;for(var b=this._keys.length;b--;)this._keys[b]&&this._keys[b].reset(a)},downDuration:function(a,b){return this._keys[a]?this._keys[a].downDuration(b):null},upDuration:function(a,b){return this._keys[a]?this._keys[a].upDuration(b):null},isDown:function(a){return this._keys[a]?this._keys[a].isDown:null}},Object.defineProperty(c.Keyboard.prototype,"lastChar",{get:function(){return 32===this.event.charCode?"":String.fromCharCode(this.pressEvent.charCode)}}),Object.defineProperty(c.Keyboard.prototype,"lastKey",{get:function(){return this._keys[this._k]}}),c.Keyboard.prototype.constructor=c.Keyboard,c.KeyCode={A:"A".charCodeAt(0),B:"B".charCodeAt(0),C:"C".charCodeAt(0),D:"D".charCodeAt(0),E:"E".charCodeAt(0),F:"F".charCodeAt(0),G:"G".charCodeAt(0),H:"H".charCodeAt(0),I:"I".charCodeAt(0),J:"J".charCodeAt(0),K:"K".charCodeAt(0),L:"L".charCodeAt(0),M:"M".charCodeAt(0),N:"N".charCodeAt(0),O:"O".charCodeAt(0),P:"P".charCodeAt(0),Q:"Q".charCodeAt(0),R:"R".charCodeAt(0),S:"S".charCodeAt(0),T:"T".charCodeAt(0),U:"U".charCodeAt(0),V:"V".charCodeAt(0),W:"W".charCodeAt(0),X:"X".charCodeAt(0),Y:"Y".charCodeAt(0),Z:"Z".charCodeAt(0),ZERO:"0".charCodeAt(0),ONE:"1".charCodeAt(0),TWO:"2".charCodeAt(0),THREE:"3".charCodeAt(0),FOUR:"4".charCodeAt(0),FIVE:"5".charCodeAt(0),SIX:"6".charCodeAt(0),SEVEN:"7".charCodeAt(0),EIGHT:"8".charCodeAt(0),NINE:"9".charCodeAt(0),NUMPAD_0:96,NUMPAD_1:97,NUMPAD_2:98,NUMPAD_3:99,NUMPAD_4:100,NUMPAD_5:101,NUMPAD_6:102,NUMPAD_7:103,NUMPAD_8:104,NUMPAD_9:105,NUMPAD_MULTIPLY:106,NUMPAD_ADD:107,NUMPAD_ENTER:108, +NUMPAD_SUBTRACT:109,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,F13:124,F14:125,F15:126,COLON:186,EQUALS:187,COMMA:188,UNDERSCORE:189,PERIOD:190,QUESTION_MARK:191,TILDE:192,OPEN_BRACKET:219,BACKWARD_SLASH:220,CLOSED_BRACKET:221,QUOTES:222,BACKSPACE:8,TAB:9,CLEAR:12,ENTER:13,SHIFT:16,CONTROL:17,ALT:18,CAPS_LOCK:20,ESC:27,SPACEBAR:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PLUS:43,MINUS:44,INSERT:45,DELETE:46,HELP:47,NUM_LOCK:144};for(var e in c.KeyCode)c.KeyCode.hasOwnProperty(e)&&!e.match(/[a-z]/)&&(c.Keyboard[e]=c.KeyCode[e]);c.Component=function(){},c.Component.Angle=function(){},c.Component.Angle.prototype={angle:{get:function(){return c.Math.wrapAngle(c.Math.radToDeg(this.rotation))},set:function(a){this.rotation=c.Math.degToRad(c.Math.wrapAngle(a))}}},c.Component.Animation=function(){},c.Component.Animation.prototype={play:function(a,b,c,d){return this.animations?this.animations.play(a,b,c,d):void 0}},c.Component.AutoCull=function(){},c.Component.AutoCull.prototype={autoCull:!1,inCamera:{get:function(){return this.autoCull||this.checkWorldBounds||(this._bounds.copyFrom(this.getBounds()),this._bounds.x+=this.game.camera.view.x,this._bounds.y+=this.game.camera.view.y),this.game.world.camera.view.intersects(this._bounds)}}},c.Component.Bounds=function(){},c.Component.Bounds.prototype={offsetX:{get:function(){return this.anchor.x*this.width}},offsetY:{get:function(){return this.anchor.y*this.height}},left:{get:function(){return this.x-this.offsetX}},right:{get:function(){return this.x+this.width-this.offsetX}},top:{get:function(){return this.y-this.offsetY}},bottom:{get:function(){return this.y+this.height-this.offsetY}}},c.Component.BringToTop=function(){},c.Component.BringToTop.prototype.bringToTop=function(){return this.parent&&this.parent.bringToTop(this),this},c.Component.BringToTop.prototype.sendToBack=function(){return this.parent&&this.parent.sendToBack(this),this},c.Component.BringToTop.prototype.moveUp=function(){return this.parent&&this.parent.moveUp(this),this},c.Component.BringToTop.prototype.moveDown=function(){return this.parent&&this.parent.moveDown(this),this},c.Component.Core=function(){},c.Component.Core.install=function(a){c.Utils.mixinPrototype(this,c.Component.Core.prototype),this.components={};for(var b=0;b<a.length;b++){var d=a[b],e=!1;"Destroy"===d&&(e=!0),c.Utils.mixinPrototype(this,c.Component[d].prototype,e),this.components[d]=!0}},c.Component.Core.init=function(a,b,d,e,f){this.game=a,this.key=e,this.position.set(b,d),this.world=new c.Point(b,d),this.previousPosition=new c.Point(b,d),this.events=new c.Events(this),this._bounds=new c.Rectangle,this.components.PhysicsBody&&(this.body=this.body),this.components.Animation&&(this.animations=new c.AnimationManager(this)),this.components.LoadTexture&&null!==e&&this.loadTexture(e,f),this.components.FixedToCamera&&(this.cameraOffset=new c.Point(b,d))},c.Component.Core.preUpdate=function(){if(this.pendingDestroy)return void this.destroy();if(this.previousPosition.set(this.world.x,this.world.y),this.previousRotation=this.rotation,!this.exists||!this.parent.exists)return this.renderOrderID=-1,!1;this.world.setTo(this.game.camera.x+this.worldTransform.tx,this.game.camera.y+this.worldTransform.ty),this.visible&&(this.renderOrderID=this.game.stage.currentRenderOrderID++),this.texture&&(this.texture.requiresReTint=!1),this.animations&&this.animations.update(),this.body&&this.body.preUpdate();for(var a=0;a<this.children.length;a++)this.children[a].preUpdate();return!0},c.Component.Core.prototype={game:null,name:"",components:{},z:0,events:void 0,animations:void 0,key:"",world:null,debug:!1,previousPosition:null,previousRotation:0,renderOrderID:0,fresh:!0,pendingDestroy:!1,_bounds:null,_exists:!0,exists:{get:function(){return this._exists},set:function(a){a?(this._exists=!0,this.body&&this.body.type===c.Physics.P2JS&&this.body.addToWorld(),this.visible=!0):(this._exists=!1,this.body&&this.body.type===c.Physics.P2JS&&this.body.removeFromWorld(),this.visible=!1)}},update:function(){},postUpdate:function(){this.customRender&&this.key.render(),this.components.PhysicsBody&&c.Component.PhysicsBody.postUpdate.call(this),this.components.FixedToCamera&&c.Component.FixedToCamera.postUpdate.call(this);for(var a=0;a<this.children.length;a++)this.children[a].postUpdate()}},c.Component.Crop=function(){},c.Component.Crop.prototype={cropRect:null,_crop:null,crop:function(a,b){void 0===b&&(b=!1),a?(b&&null!==this.cropRect?this.cropRect.setTo(a.x,a.y,a.width,a.height):b&&null===this.cropRect?this.cropRect=new c.Rectangle(a.x,a.y,a.width,a.height):this.cropRect=a,this.updateCrop()):(this._crop=null,this.cropRect=null,this.resetFrame())},updateCrop:function(){if(this.cropRect){this._crop=c.Rectangle.clone(this.cropRect,this._crop),this._crop.x+=this._frame.x,this._crop.y+=this._frame.y;var a=Math.max(this._frame.x,this._crop.x),b=Math.max(this._frame.y,this._crop.y),d=Math.min(this._frame.right,this._crop.right)-a,e=Math.min(this._frame.bottom,this._crop.bottom)-b;this.texture.crop.x=a,this.texture.crop.y=b,this.texture.crop.width=d,this.texture.crop.height=e,this.texture.frame.width=Math.min(d,this.cropRect.width),this.texture.frame.height=Math.min(e,this.cropRect.height),this.texture.width=this.texture.frame.width,this.texture.height=this.texture.frame.height,this.texture._updateUvs()}}},c.Component.Delta=function(){},c.Component.Delta.prototype={deltaX:{get:function(){return this.world.x-this.previousPosition.x}},deltaY:{get:function(){return this.world.y-this.previousPosition.y}},deltaZ:{get:function(){return this.rotation-this.previousRotation}}},c.Component.Destroy=function(){},c.Component.Destroy.prototype={destroyPhase:!1,destroy:function(a){if(null!==this.game&&!this.destroyPhase){void 0===a&&(a=!0),this.destroyPhase=!0,this.events&&this.events.onDestroy$dispatch(this),this.parent&&(this.parent instanceof c.Group?this.parent.remove(this):this.parent.removeChild(this)),this.input&&this.input.destroy(),this.animations&&this.animations.destroy(),this.body&&this.body.destroy(),this.events&&this.events.destroy();var b=this.children.length;if(a)for(;b--;)this.children[b].destroy(a);else for(;b--;)this.removeChild(this.children[b]);this._crop&&(this._crop=null),this._frame&&(this._frame=null),c.Video&&this.key instanceof c.Video&&this.key.onChangeSource.remove(this.resizeFrame,this),c.BitmapText&&this._glyphs&&(this._glyphs=[]),this.alive=!1,this.exists=!1,this.visible=!1,this.filters=null,this.mask=null,this.game=null,this.renderable=!1,this.transformCallback&&(this.transformCallback=null,this.transformCallbackContext=null),this.hitArea=null,this.parent=null,this.stage=null,this.worldTransform=null,this.filterArea=null,this._bounds=null,this._currentBounds=null,this._mask=null,this._destroyCachedSprite(),this.destroyPhase=!1,this.pendingDestroy=!1}}},c.Events=function(a){this.parent=a},c.Events.prototype={destroy:function(){this._parent=null,this._onDestroy&&this._onDestroy.dispose(),this._onAddedToGroup&&this._onAddedToGroup.dispose(),this._onRemovedFromGroup&&this._onRemovedFromGroup.dispose(),this._onRemovedFromWorld&&this._onRemovedFromWorld.dispose(),this._onKilled&&this._onKilled.dispose(),this._onRevived&&this._onRevived.dispose(),this._onEnterBounds&&this._onEnterBounds.dispose(),this._onOutOfBounds&&this._onOutOfBounds.dispose(),this._onInputOver&&this._onInputOver.dispose(),this._onInputOut&&this._onInputOut.dispose(),this._onInputDown&&this._onInputDown.dispose(),this._onInputUp&&this._onInputUp.dispose(),this._onDragStart&&this._onDragStart.dispose(),this._onDragUpdate&&this._onDragUpdate.dispose(),this._onDragStop&&this._onDragStop.dispose(),this._onAnimationStart&&this._onAnimationStart.dispose(),this._onAnimationComplete&&this._onAnimationComplete.dispose(),this._onAnimationLoop&&this._onAnimationLoop.dispose()},onAddedToGroup:null,onRemovedFromGroup:null,onRemovedFromWorld:null,onDestroy:null,onKilled:null,onRevived:null,onOutOfBounds:null,onEnterBounds:null,onInputOver:null,onInputOut:null,onInputDown:null,onInputUp:null,onDragStart:null,onDragUpdate:null,onDragStop:null,onAnimationStart:null,onAnimationComplete:null,onAnimationLoop:null},c.Events.prototype.constructor=c.Events;for(var f in c.Events.prototype)c.Events.prototype.hasOwnProperty(f)&&0===f.indexOf("on")&&null===c.Events.prototype[f]&&!function(a,b){"use strict";Object.defineProperty(c.Events.prototype,a,{get:function(){return this[b]||(this[b]=new c.Signal)}}),c.Events.prototype[a+"$dispatch"]=function(){return this[b]?this[b].dispatch.apply(this[b],arguments):null}}(f,"_"+f);c.Component.FixedToCamera=function(){},c.Component.FixedToCamera.postUpdate=function(){this.fixedToCamera&&(this.position.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.position.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y)},c.Component.FixedToCamera.prototype={_fixedToCamera:!1,fixedToCamera:{get:function(){return this._fixedToCamera},set:function(a){a?(this._fixedToCamera=!0,this.cameraOffset.set(this.x,this.y)):this._fixedToCamera=!1}},cameraOffset:new c.Point},c.Component.Health=function(){},c.Component.Health.prototype={health:1,maxHealth:100,damage:function(a){return this.alive&&(this.health-=a,this.health<=0&&this.kill()),this},heal:function(a){return this.alive&&(this.health+=a,this.health>this.maxHealth&&(this.health=this.maxHealth)),this}},c.Component.InCamera=function(){},c.Component.InCamera.prototype={inCamera:{get:function(){return this.game.world.camera.view.intersects(this._bounds)}}},c.Component.InputEnabled=function(){},c.Component.InputEnabled.prototype={input:null,inputEnabled:{get:function(){return this.input&&this.input.enabled},set:function(a){a?null===this.input?(this.input=new c.InputHandler(this),this.input.start()):this.input&&!this.input.enabled&&this.input.start():this.input&&this.input.enabled&&this.input.stop()}}},c.Component.InWorld=function(){},c.Component.InWorld.preUpdate=function(){if((this.autoCull||this.checkWorldBounds)&&(this._bounds.copyFrom(this.getBounds()),this._bounds.x+=this.game.camera.view.x,this._bounds.y+=this.game.camera.view.y,this.autoCull&&(this.game.world.camera.view.intersects(this._bounds)?(this.renderable=!0,this.game.world.camera.totalInView++):this.renderable=!1),this.checkWorldBounds))if(this._outOfBoundsFired&&this.game.world.bounds.intersects(this._bounds))this._outOfBoundsFired=!1,this.events.onEnterBounds$dispatch(this);else if(!this._outOfBoundsFired&&!this.game.world.bounds.intersects(this._bounds)&&(this._outOfBoundsFired=!0,this.events.onOutOfBounds$dispatch(this),this.outOfBoundsKill))return this.kill(),!1;return!0},c.Component.InWorld.prototype={checkWorldBounds:!1,outOfBoundsKill:!1,_outOfBoundsFired:!1,inWorld:{get:function(){return this.game.world.bounds.intersects(this.getBounds())}}},c.Component.LifeSpan=function(){},c.Component.LifeSpan.preUpdate=function(){return this.lifespan>0&&(this.lifespan-=this.game.time.physicsElapsedMS,this.lifespan<=0)?(this.kill(),!1):!0},c.Component.LifeSpan.prototype={alive:!0,lifespan:0,revive:function(a){return void 0===a&&(a=1),this.alive=!0,this.exists=!0,this.visible=!0,"function"==typeof this.heal&&this.heal(a),this.events&&this.events.onRevived$dispatch(this),this},kill:function(){return this.alive=!1,this.exists=!1,this.visible=!1,this.events&&this.events.onKilled$dispatch(this),this}},c.Component.LoadTexture=function(){},c.Component.LoadTexture.prototype={customRender:!1,_frame:null,loadTexture:function(a,b,d){b=b||0,(d||void 0===d)&&this.animations&&this.animations.stop(),this.key=a,this.customRender=!1;var e=this.game.cache,f=!0,g=!this.texture.baseTexture.scaleMode;if(c.RenderTexture&&a instanceof c.RenderTexture)this.key=a.key,this.setTexture(a);else if(c.BitmapData&&a instanceof c.BitmapData)this.customRender=!0,this.setTexture(a.texture),e.hasFrameData(a.key,c.Cache.BITMAPDATA)&&(f=!this.animations.loadFrameData(e.getFrameData(a.key,c.Cache.BITMAPDATA),b));else if(c.Video&&a instanceof c.Video){this.customRender=!0;var h=a.texture.valid;this.setTexture(a.texture),this.setFrame(a.texture.frame.clone()),a.onChangeSource.add(this.resizeFrame,this),this.texture.valid=h}else if(a instanceof PIXI.Texture)this.setTexture(a);else{var i=e.getImage(a,!0);this.key=i.key,this.setTexture(new PIXI.Texture(i.base)),f=!this.animations.loadFrameData(i.frameData,b)}f&&(this._frame=c.Rectangle.clone(this.texture.frame)),g||(this.texture.baseTexture.scaleMode=1)},setFrame:function(a){this._frame=a,this.texture.frame.x=a.x,this.texture.frame.y=a.y,this.texture.frame.width=a.width,this.texture.frame.height=a.height,this.texture.crop.x=a.x,this.texture.crop.y=a.y,this.texture.crop.width=a.width,this.texture.crop.height=a.height,a.trimmed?(this.texture.trim?(this.texture.trim.x=a.spriteSourceSizeX,this.texture.trim.y=a.spriteSourceSizeY,this.texture.trim.width=a.sourceSizeW,this.texture.trim.height=a.sourceSizeH):this.texture.trim={x:a.spriteSourceSizeX,y:a.spriteSourceSizeY,width:a.sourceSizeW,height:a.sourceSizeH},this.texture.width=a.sourceSizeW,this.texture.height=a.sourceSizeH,this.texture.frame.width=a.sourceSizeW,this.texture.frame.height=a.sourceSizeH):!a.trimmed&&this.texture.trim&&(this.texture.trim=null),this.cropRect&&this.updateCrop(),this.texture.requiresReTint=!0,this.texture._updateUvs(),this.tilingTexture&&(this.refreshTexture=!0)},resizeFrame:function(a,b,c){this.texture.frame.resize(b,c),this.texture.setFrame(this.texture.frame)},resetFrame:function(){this._frame&&this.setFrame(this._frame)},frame:{get:function(){return this.animations.frame},set:function(a){this.animations.frame=a}},frameName:{get:function(){return this.animations.frameName},set:function(a){this.animations.frameName=a}}},c.Component.Overlap=function(){},c.Component.Overlap.prototype={overlap:function(a){return c.Rectangle.intersects(this.getBounds(),a.getBounds())}},c.Component.PhysicsBody=function(){},c.Component.PhysicsBody.preUpdate=function(){return this.fresh&&this.exists?(this.world.setTo(this.parent.position.x+this.position.x,this.parent.position.y+this.position.y),this.worldTransform.tx=this.world.x,this.worldTransform.ty=this.world.y,this.previousPosition.set(this.world.x,this.world.y),this.previousRotation=this.rotation,this.body&&this.body.preUpdate(),this.fresh=!1,!1):(this.previousPosition.set(this.world.x,this.world.y),this.previousRotation=this.rotation,this._exists&&this.parent.exists?!0:(this.renderOrderID=-1,!1))},c.Component.PhysicsBody.postUpdate=function(){this.exists&&this.body&&this.body.postUpdate()},c.Component.PhysicsBody.prototype={body:null,x:{get:function(){return this.position.x},set:function(a){this.position.x=a,this.body&&!this.body.dirty&&(this.body._reset=!0)}},y:{get:function(){return this.position.y},set:function(a){this.position.y=a,this.body&&!this.body.dirty&&(this.body._reset=!0)}}},c.Component.Reset=function(){},c.Component.Reset.prototype.reset=function(a,b,c){return void 0===c&&(c=1),this.world.set(a,b),this.position.set(a,b),this.fresh=!0,this.exists=!0,this.visible=!0,this.renderable=!0,this.components.InWorld&&(this._outOfBoundsFired=!1),this.components.LifeSpan&&(this.alive=!0,this.health=c),this.components.PhysicsBody&&this.body&&this.body.reset(a,b,!1,!1),this},c.Component.ScaleMinMax=function(){},c.Component.ScaleMinMax.prototype={transformCallback:null,transformCallbackContext:this,scaleMin:null,scaleMax:null,checkTransform:function(a){this.scaleMin&&(a.a<this.scaleMin.x&&(a.a=this.scaleMin.x),a.d<this.scaleMin.y&&(a.d=this.scaleMin.y)),this.scaleMax&&(a.a>this.scaleMax.x&&(a.a=this.scaleMax.x),a.d>this.scaleMax.y&&(a.d=this.scaleMax.y))},setScaleMinMax:function(a,b,d,e){void 0===b?b=d=e=a:void 0===d&&(d=e=b,b=a),null===a?this.scaleMin=null:this.scaleMin?this.scaleMin.set(a,b):this.scaleMin=new c.Point(a,b),null===d?this.scaleMax=null:this.scaleMax?this.scaleMax.set(d,e):this.scaleMax=new c.Point(d,e),null===this.scaleMin?this.transformCallback=null:(this.transformCallback=this.checkTransform,this.transformCallbackContext=this)}},c.Component.Smoothed=function(){},c.Component.Smoothed.prototype={smoothed:{get:function(){return!this.texture.baseTexture.scaleMode},set:function(a){a?this.texture&&(this.texture.baseTexture.scaleMode=0):this.texture&&(this.texture.baseTexture.scaleMode=1)}}},c.GameObjectFactory=function(a){this.game=a,this.world=this.game.world},c.GameObjectFactory.prototype={existing:function(a){return this.world.add(a)},image:function(a,b,d,e,f){return void 0===f&&(f=this.world),f.add(new c.Image(this.game,a,b,d,e))},sprite:function(a,b,c,d,e){return void 0===e&&(e=this.world),e.create(a,b,c,d)},creature:function(a,b,d,e,f){void 0===f&&(f=this.world);var g=new c.Creature(this.game,a,b,d,e);return f.add(g),g},tween:function(a){return this.game.tweens.create(a)},group:function(a,b,d,e,f){return new c.Group(this.game,a,b,d,e,f)},physicsGroup:function(a,b,d,e){return new c.Group(this.game,b,d,e,!0,a)},spriteBatch:function(a,b,d){return void 0===a&&(a=null),void 0===b&&(b="group"),void 0===d&&(d=!1),new c.SpriteBatch(this.game,a,b,d)},audio:function(a,b,c,d){return this.game.sound.add(a,b,c,d)},sound:function(a,b,c,d){return this.game.sound.add(a,b,c,d)},audioSprite:function(a){return this.game.sound.addSprite(a)},tileSprite:function(a,b,d,e,f,g,h){return void 0===h&&(h=this.world),h.add(new c.TileSprite(this.game,a,b,d,e,f,g))},rope:function(a,b,d,e,f,g){return void 0===g&&(g=this.world),g.add(new c.Rope(this.game,a,b,d,e,f))},text:function(a,b,d,e,f){return void 0===f&&(f=this.world),f.add(new c.Text(this.game,a,b,d,e))},button:function(a,b,d,e,f,g,h,i,j,k){return void 0===k&&(k=this.world),k.add(new c.Button(this.game,a,b,d,e,f,g,h,i,j))},graphics:function(a,b,d){return void 0===d&&(d=this.world),d.add(new c.Graphics(this.game,a,b))},emitter:function(a,b,d){return this.game.particles.add(new c.Particles.Arcade.Emitter(this.game,a,b,d))},retroFont:function(a,b,d,e,f,g,h,i,j){return new c.RetroFont(this.game,a,b,d,e,f,g,h,i,j)},bitmapText:function(a,b,d,e,f,g){return void 0===g&&(g=this.world),g.add(new c.BitmapText(this.game,a,b,d,e,f))},tilemap:function(a,b,d,e,f){return new c.Tilemap(this.game,a,b,d,e,f)},renderTexture:function(a,b,d,e){(void 0===d||""===d)&&(d=this.game.rnd.uuid()),void 0===e&&(e=!1);var f=new c.RenderTexture(this.game,a,b,d);return e&&this.game.cache.addRenderTexture(d,f),f},video:function(a,b){return new c.Video(this.game,a,b)},bitmapData:function(a,b,d,e){void 0===e&&(e=!1),(void 0===d||""===d)&&(d=this.game.rnd.uuid());var f=new c.BitmapData(this.game,d,a,b);return e&&this.game.cache.addBitmapData(d,f),f},filter:function(a){var b=Array.prototype.slice.call(arguments,1),a=new c.Filter[a](this.game);return a.init.apply(a,b),a},plugin:function(a){return this.game.plugins.add(a)}},c.GameObjectFactory.prototype.constructor=c.GameObjectFactory,c.GameObjectCreator=function(a){this.game=a,this.world=this.game.world},c.GameObjectCreator.prototype={image:function(a,b,d,e){return new c.Image(this.game,a,b,d,e)},sprite:function(a,b,d,e){return new c.Sprite(this.game,a,b,d,e)},tween:function(a){return new c.Tween(a,this.game,this.game.tweens)},group:function(a,b,d,e,f){return new c.Group(this.game,a,b,d,e,f)},spriteBatch:function(a,b,d){return void 0===b&&(b="group"),void 0===d&&(d=!1),new c.SpriteBatch(this.game,a,b,d)},audio:function(a,b,c,d){return this.game.sound.add(a,b,c,d)},audioSprite:function(a){return this.game.sound.addSprite(a)},sound:function(a,b,c,d){return this.game.sound.add(a,b,c,d)},tileSprite:function(a,b,d,e,f,g){return new c.TileSprite(this.game,a,b,d,e,f,g)},rope:function(a,b,d,e,f){return new c.Rope(this.game,a,b,d,e,f)},text:function(a,b,d,e){return new c.Text(this.game,a,b,d,e)},button:function(a,b,d,e,f,g,h,i,j){return new c.Button(this.game,a,b,d,e,f,g,h,i,j)},graphics:function(a,b){return new c.Graphics(this.game,a,b)},emitter:function(a,b,d){return new c.Particles.Arcade.Emitter(this.game,a,b,d)},retroFont:function(a,b,d,e,f,g,h,i,j){return new c.RetroFont(this.game,a,b,d,e,f,g,h,i,j)},bitmapText:function(a,b,d,e,f,g){return new c.BitmapText(this.game,a,b,d,e,f,g)},tilemap:function(a,b,d,e,f){return new c.Tilemap(this.game,a,b,d,e,f)},renderTexture:function(a,b,d,e){(void 0===d||""===d)&&(d=this.game.rnd.uuid()),void 0===e&&(e=!1);var f=new c.RenderTexture(this.game,a,b,d);return e&&this.game.cache.addRenderTexture(d,f),f},bitmapData:function(a,b,d,e){void 0===e&&(e=!1),(void 0===d||""===d)&&(d=this.game.rnd.uuid());var f=new c.BitmapData(this.game,d,a,b);return e&&this.game.cache.addBitmapData(d,f),f},filter:function(a){var b=Array.prototype.slice.call(arguments,1),a=new c.Filter[a](this.game);return a.init.apply(a,b),a}},c.GameObjectCreator.prototype.constructor=c.GameObjectCreator,c.Sprite=function(a,b,d,e,f){b=b||0,d=d||0,e=e||null,f=f||null,this.type=c.SPRITE,this.physicsType=c.SPRITE,PIXI.Sprite.call(this,PIXI.TextureCache.__default),c.Component.Core.init.call(this,a,b,d,e,f)},c.Sprite.prototype=Object.create(PIXI.Sprite.prototype),c.Sprite.prototype.constructor=c.Sprite,c.Component.Core.install.call(c.Sprite.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Delta","Destroy","FixedToCamera","Health","InCamera","InputEnabled","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","ScaleMinMax","Smoothed"]),c.Sprite.prototype.preUpdatePhysics=c.Component.PhysicsBody.preUpdate,c.Sprite.prototype.preUpdateLifeSpan=c.Component.LifeSpan.preUpdate,c.Sprite.prototype.preUpdateInWorld=c.Component.InWorld.preUpdate,c.Sprite.prototype.preUpdateCore=c.Component.Core.preUpdate,c.Sprite.prototype.preUpdate=function(){return this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld()?this.preUpdateCore():!1},c.Image=function(a,b,d,e,f){b=b||0,d=d||0,e=e||null,f=f||null,this.type=c.IMAGE,PIXI.Sprite.call(this,PIXI.TextureCache.__default),c.Component.Core.init.call(this,a,b,d,e,f)},c.Image.prototype=Object.create(PIXI.Sprite.prototype),c.Image.prototype.constructor=c.Image,c.Component.Core.install.call(c.Image.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Destroy","FixedToCamera","InputEnabled","LifeSpan","LoadTexture","Overlap","Reset","Smoothed"]),c.Image.prototype.preUpdateInWorld=c.Component.InWorld.preUpdate,c.Image.prototype.preUpdateCore=c.Component.Core.preUpdate,c.Image.prototype.preUpdate=function(){return this.preUpdateInWorld()?this.preUpdateCore():!1},c.Button=function(a,b,d,e,f,g,h,i,j,k){b=b||0,d=d||0,e=e||null,f=f||null,g=g||this,c.Image.call(this,a,b,d,e,i),this.type=c.BUTTON,this.physicsType=c.SPRITE,this._onOverFrame=null,this._onOutFrame=null,this._onDownFrame=null,this._onUpFrame=null,this.onOverSound=null,this.onOutSound=null,this.onDownSound=null,this.onUpSound=null,this.onOverSoundMarker="",this.onOutSoundMarker="",this.onDownSoundMarker="",this.onUpSoundMarker="",this.onInputOver=new c.Signal,this.onInputOut=new c.Signal,this.onInputDown=new c.Signal,this.onInputUp=new c.Signal,this.onOverMouseOnly=!0,this.justReleasedPreventsOver=c.PointerMode.TOUCH,this.freezeFrames=!1,this.forceOut=!1,this.inputEnabled=!0,this.input.start(0,!0),this.input.useHandCursor=!0,this.setFrames(h,i,j,k),null!==f&&this.onInputUp.add(f,g),this.events.onInputOver.add(this.onInputOverHandler,this),this.events.onInputOut.add(this.onInputOutHandler,this),this.events.onInputDown.add(this.onInputDownHandler,this),this.events.onInputUp.add(this.onInputUpHandler,this),this.events.onRemovedFromWorld.add(this.removedFromWorld,this)},c.Button.prototype=Object.create(c.Image.prototype),c.Button.prototype.constructor=c.Button;var g="Over",h="Out",i="Down",j="Up";c.Button.prototype.clearFrames=function(){this.setFrames(null,null,null,null)},c.Button.prototype.removedFromWorld=function(){this.inputEnabled=!1},c.Button.prototype.setStateFrame=function(a,b,c){var d="_on"+a+"Frame";null!==b?(this[d]=b,c&&this.changeStateFrame(a)):this[d]=null},c.Button.prototype.changeStateFrame=function(a){if(this.freezeFrames)return!1;var b="_on"+a+"Frame",c=this[b];return"string"==typeof c?(this.frameName=c,!0):"number"==typeof c?(this.frame=c,!0):!1},c.Button.prototype.setFrames=function(a,b,c,d){this.setStateFrame(g,a,this.input.pointerOver()),this.setStateFrame(h,b,!this.input.pointerOver()),this.setStateFrame(i,c,this.input.pointerDown()),this.setStateFrame(j,d,this.input.pointerUp())},c.Button.prototype.setStateSound=function(a,b,d){var e="on"+a+"Sound",f="on"+a+"SoundMarker";b instanceof c.Sound||b instanceof c.AudioSprite?(this[e]=b,this[f]="string"==typeof d?d:""):(this[e]=null,this[f]="")},c.Button.prototype.playStateSound=function(a){var b="on"+a+"Sound",c=this[b];if(c){var d="on"+a+"SoundMarker",e=this[d];return c.play(e),!0}return!1},c.Button.prototype.setSounds=function(a,b,c,d,e,f,k,l){this.setStateSound(g,a,b),this.setStateSound(h,e,f),this.setStateSound(i,c,d),this.setStateSound(j,k,l)},c.Button.prototype.setOverSound=function(a,b){this.setStateSound(g,a,b)},c.Button.prototype.setOutSound=function(a,b){this.setStateSound(h,a,b)},c.Button.prototype.setDownSound=function(a,b){this.setStateSound(i,a,b)},c.Button.prototype.setUpSound=function(a,b){this.setStateSound(j,a,b)},c.Button.prototype.onInputOverHandler=function(a,b){b.justReleased()&&(this.justReleasedPreventsOver&b.pointerMode)===b.pointerMode||(this.changeStateFrame(g),(!this.onOverMouseOnly||b.isMouse)&&(this.playStateSound(g),this.onInputOver&&this.onInputOver.dispatch(this,b)))},c.Button.prototype.onInputOutHandler=function(a,b){this.changeStateFrame(h),this.playStateSound(h),this.onInputOut&&this.onInputOut.dispatch(this,b)},c.Button.prototype.onInputDownHandler=function(a,b){this.changeStateFrame(i),this.playStateSound(i),this.onInputDown&&this.onInputDown.dispatch(this,b)},c.Button.prototype.onInputUpHandler=function(a,b,c){if(this.playStateSound(j),this.onInputUp&&this.onInputUp.dispatch(this,b,c),!this.freezeFrames)if(this.forceOut===!0||(this.forceOut&b.pointerMode)===b.pointerMode)this.changeStateFrame(h);else{var d=this.changeStateFrame(j);d||(c?this.changeStateFrame(g):this.changeStateFrame(h))}},c.SpriteBatch=function(a,b,d,e){(void 0===b||null===b)&&(b=a.world),PIXI.SpriteBatch.call(this),c.Group.call(this,a,b,d,e),this.type=c.SPRITEBATCH},c.SpriteBatch.prototype=c.Utils.extend(!0,c.SpriteBatch.prototype,c.Group.prototype,PIXI.SpriteBatch.prototype),c.SpriteBatch.prototype.constructor=c.SpriteBatch,c.BitmapData=function(a,b,d,e){(void 0===d||0===d)&&(d=256),(void 0===e||0===e)&&(e=256),this.game=a,this.key=b,this.width=d,this.height=e,this.canvas=PIXI.CanvasPool.create(this,d,e),this.context=this.canvas.getContext("2d",{alpha:!0}),this.ctx=this.context,this.imageData=this.context.getImageData(0,0,d,e),this.data=null,this.imageData&&(this.data=this.imageData.data),this.pixels=null,this.data&&(this.imageData.data.buffer?(this.buffer=this.imageData.data.buffer,this.pixels=new Uint32Array(this.buffer)):window.ArrayBuffer?(this.buffer=new ArrayBuffer(this.imageData.data.length),this.pixels=new Uint32Array(this.buffer)):this.pixels=this.imageData.data),this.baseTexture=new PIXI.BaseTexture(this.canvas),this.texture=new PIXI.Texture(this.baseTexture),this.textureFrame=new c.Frame(0,0,0,d,e,"bitmapData"),this.texture.frame=this.textureFrame,this.type=c.BITMAPDATA,this.disableTextureUpload=!1,this.dirty=!1,this.cls=this.clear,this._image=null,this._pos=new c.Point,this._size=new c.Point,this._scale=new c.Point,this._rotate=0,this._alpha={prev:1,current:1},this._anchor=new c.Point,this._tempR=0,this._tempG=0,this._tempB=0,this._circle=new c.Circle,this._swapCanvas=PIXI.CanvasPool.create(this,d,e)},c.BitmapData.prototype={move:function(a,b,c){return 0!==a&&this.moveH(a,c),0!==b&&this.moveV(b,c),this},moveH:function(a,b){void 0===b&&(b=!0);var c=this._swapCanvas,d=c.getContext("2d"),e=this.height,f=this.canvas;if(d.clearRect(0,0,this.width,this.height),0>a){a=Math.abs(a);var g=this.width-a;b&&d.drawImage(f,0,0,a,e,g,0,a,e),d.drawImage(f,a,0,g,e,0,0,g,e)}else{var g=this.width-a;b&&d.drawImage(f,g,0,a,e,0,0,a,e),d.drawImage(f,0,0,g,e,a,0,g,e)}return this.clear(),this.copy(this._swapCanvas)},moveV:function(a,b){void 0===b&&(b=!0);var c=this._swapCanvas,d=c.getContext("2d"),e=this.width,f=this.canvas;if(d.clearRect(0,0,this.width,this.height),0>a){a=Math.abs(a);var g=this.height-a;b&&d.drawImage(f,0,0,e,a,0,g,e,a),d.drawImage(f,0,a,e,g,0,0,e,g)}else{var g=this.height-a;b&&d.drawImage(f,0,g,e,a,0,0,e,a),d.drawImage(f,0,0,e,g,0,a,e,g)}return this.clear(),this.copy(this._swapCanvas)},add:function(a){if(Array.isArray(a))for(var b=0;b<a.length;b++)a[b].loadTexture&&a[b].loadTexture(this);else a.loadTexture(this);return this},load:function(a){return"string"==typeof a&&(a=this.game.cache.getImage(a)),a?(this.resize(a.width,a.height),this.cls(),this.draw(a),this.update(),this):void 0},clear:function(a,b,c,d){return void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=this.width),void 0===d&&(d=this.height),this.context.clearRect(a,b,c,d),this.update(),this.dirty=!0,this},fill:function(a,b,c,d){return void 0===d&&(d=1),this.context.fillStyle="rgba("+a+","+b+","+c+","+d+")",this.context.fillRect(0,0,this.width,this.height),this.dirty=!0,this},generateTexture:function(a){var b=new Image;b.src=this.canvas.toDataURL("image/png");var c=this.game.cache.addImage(a,"",b);return new PIXI.Texture(c.base)},resize:function(a,b){return(a!==this.width||b!==this.height)&&(this.width=a,this.height=b,this.canvas.width=a,this.canvas.height=b,this._swapCanvas.width=a,this._swapCanvas.height=b,this.baseTexture.width=a,this.baseTexture.height=b,this.textureFrame.width=a,this.textureFrame.height=b,this.texture.width=a,this.texture.height=b,this.texture.crop.width=a,this.texture.crop.height=b,this.update(),this.dirty=!0),this},update:function(a,b,c,d){return void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=Math.max(1,this.width)),void 0===d&&(d=Math.max(1,this.height)),this.imageData=this.context.getImageData(a,b,c,d),this.data=this.imageData.data,this.imageData.data.buffer?(this.buffer=this.imageData.data.buffer,this.pixels=new Uint32Array(this.buffer)):window.ArrayBuffer?(this.buffer=new ArrayBuffer(this.imageData.data.length),this.pixels=new Uint32Array(this.buffer)):this.pixels=this.imageData.data,this},processPixelRGB:function(a,b,d,e,f,g){void 0===d&&(d=0),void 0===e&&(e=0),void 0===f&&(f=this.width),void 0===g&&(g=this.height);for(var h=d+f,i=e+g,j=c.Color.createColor(),k={r:0,g:0,b:0,a:0},l=!1,m=e;i>m;m++)for(var n=d;h>n;n++)c.Color.unpackPixel(this.getPixel32(n,m),j),k=a.call(b,j,n,m),k!==!1&&null!==k&&void 0!==k&&(this.setPixel32(n,m,k.r,k.g,k.b,k.a,!1),l=!0);return l&&(this.context.putImageData(this.imageData,0,0),this.dirty=!0),this},processPixel:function(a,b,c,d,e,f){void 0===c&&(c=0),void 0===d&&(d=0),void 0===e&&(e=this.width),void 0===f&&(f=this.height);for(var g=c+e,h=d+f,i=0,j=0,k=!1,l=d;h>l;l++)for(var m=c;g>m;m++)i=this.getPixel32(m,l),j=a.call(b,i,m,l),j!==i&&(this.pixels[l*this.width+m]=j,k=!0);return k&&(this.context.putImageData(this.imageData,0,0),this.dirty=!0),this},replaceRGB:function(a,b,d,e,f,g,h,i,j){var k=0,l=0,m=this.width,n=this.height,o=c.Color.packPixel(a,b,d,e);void 0!==j&&j instanceof c.Rectangle&&(k=j.x,l=j.y,m=j.width,n=j.height);for(var p=0;n>p;p++)for(var q=0;m>q;q++)this.getPixel32(k+q,l+p)===o&&this.setPixel32(k+q,l+p,f,g,h,i,!1);return this.context.putImageData(this.imageData,0,0),this.dirty=!0,this},setHSL:function(a,b,d,e){if((void 0===a||null===a)&&(a=!1),(void 0===b||null===b)&&(b=!1),(void 0===d||null===d)&&(d=!1),a||b||d){void 0===e&&(e=new c.Rectangle(0,0,this.width,this.height));for(var f=c.Color.createColor(),g=e.y;g<e.bottom;g++)for(var h=e.x;h<e.right;h++)c.Color.unpackPixel(this.getPixel32(h,g),f,!0),a&&(f.h=a),b&&(f.s=b),d&&(f.l=d),c.Color.HSLtoRGB(f.h,f.s,f.l,f),this.setPixel32(h,g,f.r,f.g,f.b,f.a,!1);return this.context.putImageData(this.imageData,0,0),this.dirty=!0,this}},shiftHSL:function(a,b,d,e){if((void 0===a||null===a)&&(a=!1), +(void 0===b||null===b)&&(b=!1),(void 0===d||null===d)&&(d=!1),a||b||d){void 0===e&&(e=new c.Rectangle(0,0,this.width,this.height));for(var f=c.Color.createColor(),g=e.y;g<e.bottom;g++)for(var h=e.x;h<e.right;h++)c.Color.unpackPixel(this.getPixel32(h,g),f,!0),a&&(f.h=this.game.math.wrap(f.h+a,0,1)),b&&(f.s=this.game.math.limitValue(f.s+b,0,1)),d&&(f.l=this.game.math.limitValue(f.l+d,0,1)),c.Color.HSLtoRGB(f.h,f.s,f.l,f),this.setPixel32(h,g,f.r,f.g,f.b,f.a,!1);return this.context.putImageData(this.imageData,0,0),this.dirty=!0,this}},setPixel32:function(a,b,d,e,f,g,h){return void 0===h&&(h=!0),a>=0&&a<=this.width&&b>=0&&b<=this.height&&(c.Device.LITTLE_ENDIAN?this.pixels[b*this.width+a]=g<<24|f<<16|e<<8|d:this.pixels[b*this.width+a]=d<<24|e<<16|f<<8|g,h&&(this.context.putImageData(this.imageData,0,0),this.dirty=!0)),this},setPixel:function(a,b,c,d,e,f){return this.setPixel32(a,b,c,d,e,255,f)},getPixel:function(a,b,d){d||(d=c.Color.createColor());var e=~~(a+b*this.width);return e*=4,d.r=this.data[e],d.g=this.data[++e],d.b=this.data[++e],d.a=this.data[++e],d},getPixel32:function(a,b){return a>=0&&a<=this.width&&b>=0&&b<=this.height?this.pixels[b*this.width+a]:void 0},getPixelRGB:function(a,b,d,e,f){return c.Color.unpackPixel(this.getPixel32(a,b),d,e,f)},getPixels:function(a){return this.context.getImageData(a.x,a.y,a.width,a.height)},getFirstPixel:function(a){void 0===a&&(a=0);var b=c.Color.createColor(),d=0,e=0,f=1,g=!1;1===a?(f=-1,e=this.height):3===a&&(f=-1,d=this.width);do c.Color.unpackPixel(this.getPixel32(d,e),b),0===a||1===a?(d++,d===this.width&&(d=0,e+=f,(e>=this.height||0>=e)&&(g=!0))):(2===a||3===a)&&(e++,e===this.height&&(e=0,d+=f,(d>=this.width||0>=d)&&(g=!0)));while(0===b.a&&!g);return b.x=d,b.y=e,b},getBounds:function(a){return void 0===a&&(a=new c.Rectangle),a.x=this.getFirstPixel(2).x,a.x===this.width?a.setTo(0,0,0,0):(a.y=this.getFirstPixel(0).y,a.width=this.getFirstPixel(3).x-a.x+1,a.height=this.getFirstPixel(1).y-a.y+1,a)},addToWorld:function(a,b,c,d,e,f){e=e||1,f=f||1;var g=this.game.add.image(a,b,this);return g.anchor.set(c,d),g.scale.set(e,f),g},copy:function(a,b,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r){if((void 0===a||null===a)&&(a=this),this._image=a,a instanceof c.Sprite||a instanceof c.Image||a instanceof c.Text||a instanceof PIXI.Sprite)this._pos.set(a.texture.crop.x,a.texture.crop.y),this._size.set(a.texture.crop.width,a.texture.crop.height),this._scale.set(a.scale.x,a.scale.y),this._anchor.set(a.anchor.x,a.anchor.y),this._rotate=a.rotation,this._alpha.current=a.alpha,this._image=a.texture.baseTexture.source,(void 0===g||null===g)&&(g=a.x),(void 0===h||null===h)&&(h=a.y),a.texture.trim&&(g+=a.texture.trim.x-a.anchor.x*a.texture.trim.width,h+=a.texture.trim.y-a.anchor.y*a.texture.trim.height),16777215!==a.tint&&(a.cachedTint!==a.tint&&(a.cachedTint=a.tint,a.tintedTexture=PIXI.CanvasTinter.getTintedTexture(a,a.tint)),this._image=a.tintedTexture);else{if(this._pos.set(0),this._scale.set(1),this._anchor.set(0),this._rotate=0,this._alpha.current=1,a instanceof c.BitmapData)this._image=a.canvas;else if("string"==typeof a){if(a=this.game.cache.getImage(a),null===a)return;this._image=a}this._size.set(this._image.width,this._image.height)}if((void 0===b||null===b)&&(b=0),(void 0===d||null===d)&&(d=0),e&&(this._size.x=e),f&&(this._size.y=f),(void 0===g||null===g)&&(g=b),(void 0===h||null===h)&&(h=d),(void 0===i||null===i)&&(i=this._size.x),(void 0===j||null===j)&&(j=this._size.y),"number"==typeof k&&(this._rotate=k),"number"==typeof l&&(this._anchor.x=l),"number"==typeof m&&(this._anchor.y=m),"number"==typeof n&&(this._scale.x=n),"number"==typeof o&&(this._scale.y=o),"number"==typeof p&&(this._alpha.current=p),void 0===q&&(q=null),void 0===r&&(r=!1),!(this._alpha.current<=0||0===this._scale.x||0===this._scale.y||0===this._size.x||0===this._size.y)){var s=this.context;return this._alpha.prev=s.globalAlpha,s.save(),s.globalAlpha=this._alpha.current,q&&(this.op=q),r&&(g|=0,h|=0),s.translate(g,h),s.scale(this._scale.x,this._scale.y),s.rotate(this._rotate),s.drawImage(this._image,this._pos.x+b,this._pos.y+d,this._size.x,this._size.y,-i*this._anchor.x,-j*this._anchor.y,i,j),s.restore(),s.globalAlpha=this._alpha.prev,this.dirty=!0,this}},copyRect:function(a,b,c,d,e,f,g){return this.copy(a,b.x,b.y,b.width,b.height,c,d,b.width,b.height,0,0,0,1,1,e,f,g)},draw:function(a,b,c,d,e,f,g){return this.copy(a,null,null,null,null,b,c,d,e,null,null,null,null,null,null,f,g)},drawGroup:function(a,b,c){return a.total>0&&a.forEachExists(this.copy,this,null,null,null,null,null,null,null,null,null,null,null,null,null,null,b,c),this},drawFull:function(a,b,d){if(a.worldVisible===!1||0===a.worldAlpha||a.hasOwnProperty("exists")&&a.exists===!1)return this;if(a.type!==c.GROUP&&a.type!==c.EMITTER&&a.type!==c.BITMAPTEXT)if(a.type===c.GRAPHICS){var e=a.getBounds();this.ctx.save(),this.ctx.translate(e.x,e.y),PIXI.CanvasGraphics.renderGraphics(a,this.ctx),this.ctx.restore()}else this.copy(a,null,null,null,null,a.worldPosition.x,a.worldPosition.y,null,null,a.worldRotation,null,null,a.worldScale.x,a.worldScale.y,a.worldAlpha,b,d);if(a.children)for(var f=0;f<a.children.length;f++)this.drawFull(a.children[f],b,d);return this},shadow:function(a,b,c,d){var e=this.context;void 0===a||null===a?e.shadowColor="rgba(0,0,0,0)":(e.shadowColor=a,e.shadowBlur=b||5,e.shadowOffsetX=c||10,e.shadowOffsetY=d||10)},alphaMask:function(a,b,c,d){return void 0===d||null===d?this.draw(b).blendSourceAtop():this.draw(b,d.x,d.y,d.width,d.height).blendSourceAtop(),void 0===c||null===c?this.draw(a).blendReset():this.draw(a,c.x,c.y,c.width,c.height).blendReset(),this},extract:function(a,b,c,d,e,f,g,h,i){return void 0===e&&(e=255),void 0===f&&(f=!1),void 0===g&&(g=b),void 0===h&&(h=c),void 0===i&&(i=d),f&&a.resize(this.width,this.height),this.processPixelRGB(function(f,j,k){return f.r===b&&f.g===c&&f.b===d&&a.setPixel32(j,k,g,h,i,e,!1),!1},this),a.context.putImageData(a.imageData,0,0),a.dirty=!0,a},rect:function(a,b,c,d,e){return"undefined"!=typeof e&&(this.context.fillStyle=e),this.context.fillRect(a,b,c,d),this},text:function(a,b,c,d,e,f){void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d="14px Courier"),void 0===e&&(e="rgb(255,255,255)"),void 0===f&&(f=!0);var g=this.context,h=g.font;g.font=d,f&&(g.fillStyle="rgb(0,0,0)",g.fillText(a,b+1,c+1)),g.fillStyle=e,g.fillText(a,b,c),g.font=h},circle:function(a,b,c,d){var e=this.context;return void 0!==d&&(e.fillStyle=d),e.beginPath(),e.arc(a,b,c,0,2*Math.PI,!1),e.closePath(),e.fill(),this},line:function(a,b,c,d,e,f){void 0===e&&(e="#fff"),void 0===f&&(f=1);var g=this.context;return g.beginPath(),g.moveTo(a,b),g.lineTo(c,d),g.lineWidth=f,g.strokeStyle=e,g.stroke(),g.closePath(),this},textureLine:function(a,b,d){if(void 0===d&&(d="repeat-x"),"string"!=typeof b||(b=this.game.cache.getImage(b))){var e=a.length;"no-repeat"===d&&e>b.width&&(e=b.width);var f=this.context;return f.fillStyle=f.createPattern(b,d),this._circle=new c.Circle(a.start.x,a.start.y,b.height),this._circle.circumferencePoint(a.angle-1.5707963267948966,!1,this._pos),f.save(),f.translate(this._pos.x,this._pos.y),f.rotate(a.angle),f.fillRect(0,0,e,b.height),f.restore(),this.dirty=!0,this}},render:function(){return!this.disableTextureUpload&&this.dirty&&(this.baseTexture.dirty(),this.dirty=!1),this},destroy:function(){PIXI.CanvasPool.remove(this)},blendReset:function(){return this.op="source-over",this},blendSourceOver:function(){return this.op="source-over",this},blendSourceIn:function(){return this.op="source-in",this},blendSourceOut:function(){return this.op="source-out",this},blendSourceAtop:function(){return this.op="source-atop",this},blendDestinationOver:function(){return this.op="destination-over",this},blendDestinationIn:function(){return this.op="destination-in",this},blendDestinationOut:function(){return this.op="destination-out",this},blendDestinationAtop:function(){return this.op="destination-atop",this},blendXor:function(){return this.op="xor",this},blendAdd:function(){return this.op="lighter",this},blendMultiply:function(){return this.op="multiply",this},blendScreen:function(){return this.op="screen",this},blendOverlay:function(){return this.op="overlay",this},blendDarken:function(){return this.op="darken",this},blendLighten:function(){return this.op="lighten",this},blendColorDodge:function(){return this.op="color-dodge",this},blendColorBurn:function(){return this.op="color-burn",this},blendHardLight:function(){return this.op="hard-light",this},blendSoftLight:function(){return this.op="soft-light",this},blendDifference:function(){return this.op="difference",this},blendExclusion:function(){return this.op="exclusion",this},blendHue:function(){return this.op="hue",this},blendSaturation:function(){return this.op="saturation",this},blendColor:function(){return this.op="color",this},blendLuminosity:function(){return this.op="luminosity",this}},Object.defineProperty(c.BitmapData.prototype,"smoothed",{get:function(){c.Canvas.getSmoothingEnabled(this.context)},set:function(a){c.Canvas.setSmoothingEnabled(this.context,a)}}),Object.defineProperty(c.BitmapData.prototype,"op",{get:function(){return this.context.globalCompositeOperation},set:function(a){this.context.globalCompositeOperation=a}}),c.BitmapData.getTransform=function(a,b,c,d,e,f){return"number"!=typeof a&&(a=0),"number"!=typeof b&&(b=0),"number"!=typeof c&&(c=1),"number"!=typeof d&&(d=1),"number"!=typeof e&&(e=0),"number"!=typeof f&&(f=0),{sx:c,sy:d,scaleX:c,scaleY:d,skewX:e,skewY:f,translateX:a,translateY:b,tx:a,ty:b}},c.BitmapData.prototype.constructor=c.BitmapData,PIXI.Graphics=function(){PIXI.DisplayObjectContainer.call(this),this.renderable=!0,this.fillAlpha=1,this.lineWidth=0,this.lineColor=0,this.graphicsData=[],this.tint=16777215,this.blendMode=PIXI.blendModes.NORMAL,this.currentPath=null,this._webGL=[],this.isMask=!1,this.boundsPadding=0,this._localBounds=new PIXI.Rectangle(0,0,1,1),this.dirty=!0,this.webGLDirty=!1,this.cachedSpriteDirty=!1},PIXI.Graphics.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),PIXI.Graphics.prototype.constructor=PIXI.Graphics,PIXI.Graphics.prototype.lineStyle=function(a,b,c){return this.lineWidth=a||0,this.lineColor=b||0,this.lineAlpha=void 0===c?1:c,this.currentPath&&(this.currentPath.shape.points.length?this.drawShape(new PIXI.Polygon(this.currentPath.shape.points.slice(-2))):(this.currentPath.lineWidth=this.lineWidth,this.currentPath.lineColor=this.lineColor,this.currentPath.lineAlpha=this.lineAlpha)),this},PIXI.Graphics.prototype.moveTo=function(a,b){return this.drawShape(new PIXI.Polygon([a,b])),this},PIXI.Graphics.prototype.lineTo=function(a,b){return this.currentPath||this.moveTo(0,0),this.currentPath.shape.points.push(a,b),this.dirty=!0,this},PIXI.Graphics.prototype.quadraticCurveTo=function(a,b,c,d){this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);var e,f,g=20,h=this.currentPath.shape.points;0===h.length&&this.moveTo(0,0);for(var i=h[h.length-2],j=h[h.length-1],k=0,l=1;g>=l;++l)k=l/g,e=i+(a-i)*k,f=j+(b-j)*k,h.push(e+(a+(c-a)*k-e)*k,f+(b+(d-b)*k-f)*k);return this.dirty=!0,this},PIXI.Graphics.prototype.bezierCurveTo=function(a,b,c,d,e,f){this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);for(var g,h,i,j,k,l=20,m=this.currentPath.shape.points,n=m[m.length-2],o=m[m.length-1],p=0,q=1;l>=q;++q)p=q/l,g=1-p,h=g*g,i=h*g,j=p*p,k=j*p,m.push(i*n+3*h*p*a+3*g*j*c+k*e,i*o+3*h*p*b+3*g*j*d+k*f);return this.dirty=!0,this},PIXI.Graphics.prototype.arcTo=function(a,b,c,d,e){this.currentPath?0===this.currentPath.shape.points.length&&this.currentPath.shape.points.push(a,b):this.moveTo(a,b);var f=this.currentPath.shape.points,g=f[f.length-2],h=f[f.length-1],i=h-b,j=g-a,k=d-b,l=c-a,m=Math.abs(i*l-j*k);if(1e-8>m||0===e)(f[f.length-2]!==a||f[f.length-1]!==b)&&f.push(a,b);else{var n=i*i+j*j,o=k*k+l*l,p=i*k+j*l,q=e*Math.sqrt(n)/m,r=e*Math.sqrt(o)/m,s=q*p/n,t=r*p/o,u=q*l+r*j,v=q*k+r*i,w=j*(r+s),x=i*(r+s),y=l*(q+t),z=k*(q+t),A=Math.atan2(x-v,w-u),B=Math.atan2(z-v,y-u);this.arc(u+a,v+b,e,A,B,j*k>l*i)}return this.dirty=!0,this},PIXI.Graphics.prototype.arc=function(a,b,c,d,e,f){if(d===e)return this;void 0===f&&(f=!1),!f&&d>=e?e+=2*Math.PI:f&&e>=d&&(d+=2*Math.PI);var g=f?-1*(d-e):e-d,h=40*Math.ceil(Math.abs(g)/(2*Math.PI));if(0===g)return this;var i=a+Math.cos(d)*c,j=b+Math.sin(d)*c;f&&this.filling?this.moveTo(a,b):this.moveTo(i,j);for(var k=this.currentPath.shape.points,l=g/(2*h),m=2*l,n=Math.cos(l),o=Math.sin(l),p=h-1,q=p%1/p,r=0;p>=r;r++){var s=r+q*r,t=l+d+m*s,u=Math.cos(t),v=-Math.sin(t);k.push((n*u+o*v)*c+a,(n*-v+o*u)*c+b)}return this.dirty=!0,this},PIXI.Graphics.prototype.beginFill=function(a,b){return this.filling=!0,this.fillColor=a||0,this.fillAlpha=void 0===b?1:b,this.currentPath&&this.currentPath.shape.points.length<=2&&(this.currentPath.fill=this.filling,this.currentPath.fillColor=this.fillColor,this.currentPath.fillAlpha=this.fillAlpha),this},PIXI.Graphics.prototype.endFill=function(){return this.filling=!1,this.fillColor=null,this.fillAlpha=1,this},PIXI.Graphics.prototype.drawRect=function(a,b,c,d){return this.drawShape(new PIXI.Rectangle(a,b,c,d)),this},PIXI.Graphics.prototype.drawRoundedRect=function(a,b,c,d,e){return this.drawShape(new PIXI.RoundedRectangle(a,b,c,d,e)),this},PIXI.Graphics.prototype.drawCircle=function(a,b,c){return this.drawShape(new PIXI.Circle(a,b,c)),this},PIXI.Graphics.prototype.drawEllipse=function(a,b,c,d){return this.drawShape(new PIXI.Ellipse(a,b,c,d)),this},PIXI.Graphics.prototype.drawPolygon=function(a){(a instanceof c.Polygon||a instanceof PIXI.Polygon)&&(a=a.points);var b=a;if(!Array.isArray(b)){b=new Array(arguments.length);for(var d=0;d<b.length;++d)b[d]=arguments[d]}return this.drawShape(new c.Polygon(b)),this},PIXI.Graphics.prototype.clear=function(){return this.lineWidth=0,this.filling=!1,this.dirty=!0,this.clearDirty=!0,this.graphicsData=[],this},PIXI.Graphics.prototype.generateTexture=function(a,b){a=a||1;var c=this.getBounds(),d=new PIXI.CanvasBuffer(c.width*a,c.height*a),e=PIXI.Texture.fromCanvas(d.canvas,b);return e.baseTexture.resolution=a,d.context.scale(a,a),d.context.translate(-c.x,-c.y),PIXI.CanvasGraphics.renderGraphics(this,d.context),e},PIXI.Graphics.prototype._renderWebGL=function(a){if(this.visible!==!1&&0!==this.alpha&&this.isMask!==!0){if(this._cacheAsBitmap)return(this.dirty||this.cachedSpriteDirty)&&(this._generateCachedSprite(),this.updateCachedSpriteTexture(),this.cachedSpriteDirty=!1,this.dirty=!1),this._cachedSprite.worldAlpha=this.worldAlpha,void PIXI.Sprite.prototype._renderWebGL.call(this._cachedSprite,a);if(a.spriteBatch.stop(),a.blendModeManager.setBlendMode(this.blendMode),this._mask&&a.maskManager.pushMask(this._mask,a),this._filters&&a.filterManager.pushFilter(this._filterBlock),this.blendMode!==a.spriteBatch.currentBlendMode){a.spriteBatch.currentBlendMode=this.blendMode;var b=PIXI.blendModesWebGL[a.spriteBatch.currentBlendMode];a.spriteBatch.gl.blendFunc(b[0],b[1])}if(this.webGLDirty&&(this.dirty=!0,this.webGLDirty=!1),PIXI.WebGLGraphics.renderGraphics(this,a),this.children.length){a.spriteBatch.start();for(var c=0;c<this.children.length;c++)this.children[c]._renderWebGL(a);a.spriteBatch.stop()}this._filters&&a.filterManager.popFilter(),this._mask&&a.maskManager.popMask(this.mask,a),a.drawCount++,a.spriteBatch.start()}},PIXI.Graphics.prototype._renderCanvas=function(a){if(this.visible!==!1&&0!==this.alpha&&this.isMask!==!0){if(this._prevTint!==this.tint&&(this.dirty=!0,this._prevTint=this.tint),this._cacheAsBitmap)return(this.dirty||this.cachedSpriteDirty)&&(this._generateCachedSprite(),this.updateCachedSpriteTexture(),this.cachedSpriteDirty=!1,this.dirty=!1),this._cachedSprite.alpha=this.alpha,void PIXI.Sprite.prototype._renderCanvas.call(this._cachedSprite,a);var b=a.context,c=this.worldTransform;this.blendMode!==a.currentBlendMode&&(a.currentBlendMode=this.blendMode,b.globalCompositeOperation=PIXI.blendModesCanvas[a.currentBlendMode]),this._mask&&a.maskManager.pushMask(this._mask,a);var d=a.resolution;b.setTransform(c.a*d,c.b*d,c.c*d,c.d*d,c.tx*d,c.ty*d),PIXI.CanvasGraphics.renderGraphics(this,b);for(var e=0;e<this.children.length;e++)this.children[e]._renderCanvas(a);this._mask&&a.maskManager.popMask(a)}},PIXI.Graphics.prototype.getBounds=function(a){if(!this._currentBounds){if(!this.renderable)return PIXI.EmptyRectangle;this.dirty&&(this.updateLocalBounds(),this.webGLDirty=!0,this.cachedSpriteDirty=!0,this.dirty=!1);var b=this._localBounds,c=b.x,d=b.width+b.x,e=b.y,f=b.height+b.y,g=a||this.worldTransform,h=g.a,i=g.b,j=g.c,k=g.d,l=g.tx,m=g.ty,n=h*d+j*f+l,o=k*f+i*d+m,p=h*c+j*f+l,q=k*f+i*c+m,r=h*c+j*e+l,s=k*e+i*c+m,t=h*d+j*e+l,u=k*e+i*d+m,v=n,w=o,x=n,y=o;x=x>p?p:x,x=x>r?r:x,x=x>t?t:x,y=y>q?q:y,y=y>s?s:y,y=y>u?u:y,v=p>v?p:v,v=r>v?r:v,v=t>v?t:v,w=q>w?q:w,w=s>w?s:w,w=u>w?u:w,this._bounds.x=x,this._bounds.width=v-x,this._bounds.y=y,this._bounds.height=w-y,this._currentBounds=this._bounds}return this._currentBounds},PIXI.Graphics.prototype.containsPoint=function(a){this.worldTransform.applyInverse(a,tempPoint);for(var b=this.graphicsData,c=0;c<b.length;c++){var d=b[c];if(d.fill&&d.shape&&d.shape.contains(tempPoint.x,tempPoint.y))return!0}return!1},PIXI.Graphics.prototype.updateLocalBounds=function(){var a=1/0,b=-(1/0),d=1/0,e=-(1/0);if(this.graphicsData.length)for(var f,g,h,i,j,k,l=0;l<this.graphicsData.length;l++){var m=this.graphicsData[l],n=m.type,o=m.lineWidth;if(f=m.shape,n===PIXI.Graphics.RECT||n===PIXI.Graphics.RREC)h=f.x-o/2,i=f.y-o/2,j=f.width+o,k=f.height+o,a=a>h?h:a,b=h+j>b?h+j:b,d=d>i?i:d,e=i+k>e?i+k:e;else if(n===PIXI.Graphics.CIRC)h=f.x,i=f.y,j=f.radius+o/2,k=f.radius+o/2,a=a>h-j?h-j:a,b=h+j>b?h+j:b,d=d>i-k?i-k:d,e=i+k>e?i+k:e;else if(n===PIXI.Graphics.ELIP)h=f.x,i=f.y,j=f.width+o/2,k=f.height+o/2,a=a>h-j?h-j:a,b=h+j>b?h+j:b,d=d>i-k?i-k:d,e=i+k>e?i+k:e;else{g=f.points;for(var p=0;p<g.length;p++)g[p]instanceof c.Point?(h=g[p].x,i=g[p].y):(h=g[p],i=g[p+1],p<g.length-1&&p++),a=a>h-o?h-o:a,b=h+o>b?h+o:b,d=d>i-o?i-o:d,e=i+o>e?i+o:e}}else a=0,b=0,d=0,e=0;var q=this.boundsPadding;this._localBounds.x=a-q,this._localBounds.width=b-a+2*q,this._localBounds.y=d-q,this._localBounds.height=e-d+2*q},PIXI.Graphics.prototype._generateCachedSprite=function(){var a=this.getLocalBounds();if(this._cachedSprite)this._cachedSprite.buffer.resize(a.width,a.height);else{var b=new PIXI.CanvasBuffer(a.width,a.height),c=PIXI.Texture.fromCanvas(b.canvas);this._cachedSprite=new PIXI.Sprite(c),this._cachedSprite.buffer=b,this._cachedSprite.worldTransform=this.worldTransform}this._cachedSprite.anchor.x=-(a.x/a.width),this._cachedSprite.anchor.y=-(a.y/a.height),this._cachedSprite.buffer.context.translate(-a.x,-a.y),this.worldAlpha=1,PIXI.CanvasGraphics.renderGraphics(this,this._cachedSprite.buffer.context),this._cachedSprite.alpha=this.alpha},PIXI.Graphics.prototype.updateCachedSpriteTexture=function(){var a=this._cachedSprite,b=a.texture,c=a.buffer.canvas;b.baseTexture.width=c.width,b.baseTexture.height=c.height,b.crop.width=b.frame.width=c.width,b.crop.height=b.frame.height=c.height,a._width=c.width,a._height=c.height,b.baseTexture.dirty()},PIXI.Graphics.prototype.destroyCachedSprite=function(){this._cachedSprite.texture.destroy(!0),this._cachedSprite=null},PIXI.Graphics.prototype.drawShape=function(a){this.currentPath&&this.currentPath.shape.points.length<=2&&this.graphicsData.pop(),this.currentPath=null,a instanceof c.Polygon&&(a=a.clone(),a.flatten());var b=new PIXI.GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.filling,a);return this.graphicsData.push(b),b.type===PIXI.Graphics.POLY&&(b.shape.closed=this.filling,this.currentPath=b),this.dirty=!0,b},Object.defineProperty(PIXI.Graphics.prototype,"cacheAsBitmap",{get:function(){return this._cacheAsBitmap},set:function(a){this._cacheAsBitmap=a,this._cacheAsBitmap?this._generateCachedSprite():(this.destroyCachedSprite(),this.dirty=!0)}}),PIXI.GraphicsData=function(a,b,c,d,e,f,g){this.lineWidth=a,this.lineColor=b,this.lineAlpha=c,this._lineTint=b,this.fillColor=d,this.fillAlpha=e,this._fillTint=d,this.fill=f,this.shape=g,this.type=g.type},PIXI.GraphicsData.prototype.constructor=PIXI.GraphicsData,PIXI.GraphicsData.prototype.clone=function(){return new GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.fill,this.shape)},PIXI.PolyK={},PIXI.PolyK.Triangulate=function(a){var b=!0,c=a.length>>1;if(3>c)return[];for(var d=[],e=[],f=0;c>f;f++)e.push(f);f=0;for(var g=c;g>3;){var h=e[(f+0)%g],i=e[(f+1)%g],j=e[(f+2)%g],k=a[2*h],l=a[2*h+1],m=a[2*i],n=a[2*i+1],o=a[2*j],p=a[2*j+1],q=!1;if(PIXI.PolyK._convex(k,l,m,n,o,p,b)){q=!0;for(var r=0;g>r;r++){var s=e[r];if(s!==h&&s!==i&&s!==j&&PIXI.PolyK._PointInTriangle(a[2*s],a[2*s+1],k,l,m,n,o,p)){q=!1;break}}}if(q)d.push(h,i,j),e.splice((f+1)%g,1),g--,f=0;else if(f++>3*g){if(!b)return null;for(d=[],e=[],f=0;c>f;f++)e.push(f);f=0,g=c,b=!1}}return d.push(e[0],e[1],e[2]),d},PIXI.PolyK._PointInTriangle=function(a,b,c,d,e,f,g,h){var i=g-c,j=h-d,k=e-c,l=f-d,m=a-c,n=b-d,o=i*i+j*j,p=i*k+j*l,q=i*m+j*n,r=k*k+l*l,s=k*m+l*n,t=1/(o*r-p*p),u=(r*q-p*s)*t,v=(o*s-p*q)*t;return u>=0&&v>=0&&1>u+v},PIXI.PolyK._convex=function(a,b,c,d,e,f,g){return(b-d)*(e-c)+(c-a)*(f-d)>=0===g},PIXI.WebGLGraphics=function(){},PIXI.WebGLGraphics.renderGraphics=function(a,b){var c,d=b.gl,e=b.projection,f=b.offset,g=b.shaderManager.primitiveShader;a.dirty&&PIXI.WebGLGraphics.updateGraphics(a,d);for(var h=a._webGL[d.id],i=0;i<h.data.length;i++)1===h.data[i].mode?(c=h.data[i],b.stencilManager.pushStencil(a,c,b),d.drawElements(d.TRIANGLE_FAN,4,d.UNSIGNED_SHORT,2*(c.indices.length-4)),b.stencilManager.popStencil(a,c,b)):(c=h.data[i],b.shaderManager.setShader(g),g=b.shaderManager.primitiveShader,d.uniformMatrix3fv(g.translationMatrix,!1,a.worldTransform.toArray(!0)),d.uniform1f(g.flipY,1),d.uniform2f(g.projectionVector,e.x,-e.y),d.uniform2f(g.offsetVector,-f.x,-f.y),d.uniform3fv(g.tintColor,PIXI.hex2rgb(a.tint)),d.uniform1f(g.alpha,a.worldAlpha),d.bindBuffer(d.ARRAY_BUFFER,c.buffer),d.vertexAttribPointer(g.aVertexPosition,2,d.FLOAT,!1,24,0),d.vertexAttribPointer(g.colorAttribute,4,d.FLOAT,!1,24,8),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,c.indexBuffer),d.drawElements(d.TRIANGLE_STRIP,c.indices.length,d.UNSIGNED_SHORT,0))},PIXI.WebGLGraphics.updateGraphics=function(a,b){var c=a._webGL[b.id];c||(c=a._webGL[b.id]={lastIndex:0,data:[],gl:b}),a.dirty=!1;var d;if(a.clearDirty){for(a.clearDirty=!1,d=0;d<c.data.length;d++){var e=c.data[d];e.reset(),PIXI.WebGLGraphics.graphicsDataPool.push(e)}c.data=[],c.lastIndex=0}var f;for(d=c.lastIndex;d<a.graphicsData.length;d++){var g=a.graphicsData[d];if(g.type===PIXI.Graphics.POLY){if(g.points=g.shape.points.slice(),g.shape.closed&&(g.points[0]!==g.points[g.points.length-2]||g.points[1]!==g.points[g.points.length-1])&&g.points.push(g.points[0],g.points[1]),g.fill&&g.points.length>=6)if(g.points.length<12){f=PIXI.WebGLGraphics.switchMode(c,0);var h=PIXI.WebGLGraphics.buildPoly(g,f);h||(f=PIXI.WebGLGraphics.switchMode(c,1),PIXI.WebGLGraphics.buildComplexPoly(g,f))}else f=PIXI.WebGLGraphics.switchMode(c,1),PIXI.WebGLGraphics.buildComplexPoly(g,f);g.lineWidth>0&&(f=PIXI.WebGLGraphics.switchMode(c,0),PIXI.WebGLGraphics.buildLine(g,f))}else f=PIXI.WebGLGraphics.switchMode(c,0),g.type===PIXI.Graphics.RECT?PIXI.WebGLGraphics.buildRectangle(g,f):g.type===PIXI.Graphics.CIRC||g.type===PIXI.Graphics.ELIP?PIXI.WebGLGraphics.buildCircle(g,f):g.type===PIXI.Graphics.RREC&&PIXI.WebGLGraphics.buildRoundedRectangle(g,f);c.lastIndex++}for(d=0;d<c.data.length;d++)f=c.data[d],f.dirty&&f.upload()},PIXI.WebGLGraphics.switchMode=function(a,b){var c;return a.data.length?(c=a.data[a.data.length-1],(c.mode!==b||1===b)&&(c=PIXI.WebGLGraphics.graphicsDataPool.pop()||new PIXI.WebGLGraphicsData(a.gl),c.mode=b,a.data.push(c))):(c=PIXI.WebGLGraphics.graphicsDataPool.pop()||new PIXI.WebGLGraphicsData(a.gl),c.mode=b,a.data.push(c)),c.dirty=!0,c},PIXI.WebGLGraphics.buildRectangle=function(a,b){var c=a.shape,d=c.x,e=c.y,f=c.width,g=c.height;if(a.fill){var h=PIXI.hex2rgb(a.fillColor),i=a.fillAlpha,j=h[0]*i,k=h[1]*i,l=h[2]*i,m=b.points,n=b.indices,o=m.length/6;m.push(d,e),m.push(j,k,l,i),m.push(d+f,e),m.push(j,k,l,i),m.push(d,e+g),m.push(j,k,l,i),m.push(d+f,e+g),m.push(j,k,l,i),n.push(o,o,o+1,o+2,o+3,o+3)}if(a.lineWidth){var p=a.points;a.points=[d,e,d+f,e,d+f,e+g,d,e+g,d,e],PIXI.WebGLGraphics.buildLine(a,b),a.points=p}},PIXI.WebGLGraphics.buildRoundedRectangle=function(a,b){var c=a.shape,d=c.x,e=c.y,f=c.width,g=c.height,h=c.radius,i=[];if(i.push(d,e+h),i=i.concat(PIXI.WebGLGraphics.quadraticBezierCurve(d,e+g-h,d,e+g,d+h,e+g)),i=i.concat(PIXI.WebGLGraphics.quadraticBezierCurve(d+f-h,e+g,d+f,e+g,d+f,e+g-h)),i=i.concat(PIXI.WebGLGraphics.quadraticBezierCurve(d+f,e+h,d+f,e,d+f-h,e)),i=i.concat(PIXI.WebGLGraphics.quadraticBezierCurve(d+h,e,d,e,d,e+h)),a.fill){var j=PIXI.hex2rgb(a.fillColor),k=a.fillAlpha,l=j[0]*k,m=j[1]*k,n=j[2]*k,o=b.points,p=b.indices,q=o.length/6,r=PIXI.PolyK.Triangulate(i),s=0;for(s=0;s<r.length;s+=3)p.push(r[s]+q),p.push(r[s]+q),p.push(r[s+1]+q),p.push(r[s+2]+q),p.push(r[s+2]+q);for(s=0;s<i.length;s++)o.push(i[s],i[++s],l,m,n,k)}if(a.lineWidth){var t=a.points;a.points=i,PIXI.WebGLGraphics.buildLine(a,b),a.points=t}},PIXI.WebGLGraphics.quadraticBezierCurve=function(a,b,c,d,e,f){function g(a,b,c){var d=b-a;return a+d*c}for(var h,i,j,k,l,m,n=20,o=[],p=0,q=0;n>=q;q++)p=q/n,h=g(a,c,p),i=g(b,d,p),j=g(c,e,p),k=g(d,f,p),l=g(h,j,p),m=g(i,k,p),o.push(l,m);return o},PIXI.WebGLGraphics.buildCircle=function(a,b){var c,d,e=a.shape,f=e.x,g=e.y;a.type===PIXI.Graphics.CIRC?(c=e.radius,d=e.radius):(c=e.width,d=e.height);var h=40,i=2*Math.PI/h,j=0;if(a.fill){var k=PIXI.hex2rgb(a.fillColor),l=a.fillAlpha,m=k[0]*l,n=k[1]*l,o=k[2]*l,p=b.points,q=b.indices,r=p.length/6;for(q.push(r),j=0;h+1>j;j++)p.push(f,g,m,n,o,l),p.push(f+Math.sin(i*j)*c,g+Math.cos(i*j)*d,m,n,o,l),q.push(r++,r++);q.push(r-1)}if(a.lineWidth){var s=a.points;for(a.points=[],j=0;h+1>j;j++)a.points.push(f+Math.sin(i*j)*c,g+Math.cos(i*j)*d);PIXI.WebGLGraphics.buildLine(a,b),a.points=s}},PIXI.WebGLGraphics.buildLine=function(a,b){var c=0,d=a.points;if(0!==d.length){if(a.lineWidth%2)for(c=0;c<d.length;c++)d[c]+=.5;var e=new PIXI.Point(d[0],d[1]),f=new PIXI.Point(d[d.length-2],d[d.length-1]);if(e.x===f.x&&e.y===f.y){d=d.slice(),d.pop(),d.pop(),f=new PIXI.Point(d[d.length-2],d[d.length-1]);var g=f.x+.5*(e.x-f.x),h=f.y+.5*(e.y-f.y);d.unshift(g,h),d.push(g,h)}var i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F=b.points,G=b.indices,H=d.length/2,I=d.length,J=F.length/6,K=a.lineWidth/2,L=PIXI.hex2rgb(a.lineColor),M=a.lineAlpha,N=L[0]*M,O=L[1]*M,P=L[2]*M;for(k=d[0],l=d[1],m=d[2],n=d[3],q=-(l-n),r=k-m,E=Math.sqrt(q*q+r*r),q/=E,r/=E,q*=K,r*=K,F.push(k-q,l-r,N,O,P,M),F.push(k+q,l+r,N,O,P,M),c=1;H-1>c;c++)k=d[2*(c-1)],l=d[2*(c-1)+1],m=d[2*c],n=d[2*c+1],o=d[2*(c+1)],p=d[2*(c+1)+1],q=-(l-n),r=k-m,E=Math.sqrt(q*q+r*r),q/=E,r/=E,q*=K,r*=K,s=-(n-p),t=m-o,E=Math.sqrt(s*s+t*t),s/=E,t/=E,s*=K,t*=K,w=-r+l-(-r+n),x=-q+m-(-q+k),y=(-q+k)*(-r+n)-(-q+m)*(-r+l),z=-t+p-(-t+n),A=-s+m-(-s+o),B=(-s+o)*(-t+n)-(-s+m)*(-t+p),C=w*A-z*x,Math.abs(C)<.1?(C+=10.1,F.push(m-q,n-r,N,O,P,M),F.push(m+q,n+r,N,O,P,M)):(i=(x*B-A*y)/C,j=(z*y-w*B)/C,D=(i-m)*(i-m)+(j-n)+(j-n),D>19600?(u=q-s,v=r-t,E=Math.sqrt(u*u+v*v),u/=E,v/=E,u*=K,v*=K,F.push(m-u,n-v),F.push(N,O,P,M),F.push(m+u,n+v),F.push(N,O,P,M),F.push(m-u,n-v),F.push(N,O,P,M),I++):(F.push(i,j),F.push(N,O,P,M),F.push(m-(i-m),n-(j-n)),F.push(N,O,P,M)));for(k=d[2*(H-2)],l=d[2*(H-2)+1],m=d[2*(H-1)],n=d[2*(H-1)+1],q=-(l-n),r=k-m,E=Math.sqrt(q*q+r*r),q/=E,r/=E,q*=K,r*=K,F.push(m-q,n-r),F.push(N,O,P,M),F.push(m+q,n+r),F.push(N,O,P,M),G.push(J),c=0;I>c;c++)G.push(J++);G.push(J-1)}},PIXI.WebGLGraphics.buildComplexPoly=function(a,b){var c=a.points.slice();if(!(c.length<6)){var d=b.indices;b.points=c,b.alpha=a.fillAlpha,b.color=PIXI.hex2rgb(a.fillColor);for(var e,f,g=1/0,h=-(1/0),i=1/0,j=-(1/0),k=0;k<c.length;k+=2)e=c[k],f=c[k+1],g=g>e?e:g,h=e>h?e:h,i=i>f?f:i,j=f>j?f:j;c.push(g,i,h,i,h,j,g,j);var l=c.length/2;for(k=0;l>k;k++)d.push(k)}},PIXI.WebGLGraphics.buildPoly=function(a,b){var c=a.points;if(!(c.length<6)){var d=b.points,e=b.indices,f=c.length/2,g=PIXI.hex2rgb(a.fillColor),h=a.fillAlpha,i=g[0]*h,j=g[1]*h,k=g[2]*h,l=PIXI.PolyK.Triangulate(c);if(!l)return!1;var m=d.length/6,n=0;for(n=0;n<l.length;n+=3)e.push(l[n]+m),e.push(l[n]+m),e.push(l[n+1]+m),e.push(l[n+2]+m),e.push(l[n+2]+m);for(n=0;f>n;n++)d.push(c[2*n],c[2*n+1],i,j,k,h);return!0}},PIXI.WebGLGraphics.graphicsDataPool=[],PIXI.WebGLGraphicsData=function(a){this.gl=a,this.color=[0,0,0],this.points=[],this.indices=[],this.buffer=a.createBuffer(),this.indexBuffer=a.createBuffer(),this.mode=1,this.alpha=1,this.dirty=!0},PIXI.WebGLGraphicsData.prototype.reset=function(){this.points=[],this.indices=[]},PIXI.WebGLGraphicsData.prototype.upload=function(){var a=this.gl;this.glPoints=new PIXI.Float32Array(this.points),a.bindBuffer(a.ARRAY_BUFFER,this.buffer),a.bufferData(a.ARRAY_BUFFER,this.glPoints,a.STATIC_DRAW),this.glIndicies=new PIXI.Uint16Array(this.indices),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,this.glIndicies,a.STATIC_DRAW),this.dirty=!1},PIXI.CanvasGraphics=function(){},PIXI.CanvasGraphics.renderGraphics=function(a,b){var c=a.worldAlpha;a.dirty&&(this.updateGraphicsTint(a),a.dirty=!1);for(var d=0;d<a.graphicsData.length;d++){var e=a.graphicsData[d],f=e.shape,g=e._fillTint,h=e._lineTint;if(b.lineWidth=e.lineWidth,e.type===PIXI.Graphics.POLY){b.beginPath();var i=f.points;b.moveTo(i[0],i[1]);for(var j=1;j<i.length/2;j++)b.lineTo(i[2*j],i[2*j+1]);f.closed&&b.lineTo(i[0],i[1]),i[0]===i[i.length-2]&&i[1]===i[i.length-1]&&b.closePath(),e.fill&&(b.globalAlpha=e.fillAlpha*c,b.fillStyle="#"+("00000"+(0|g).toString(16)).substr(-6),b.fill()),e.lineWidth&&(b.globalAlpha=e.lineAlpha*c,b.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),b.stroke())}else if(e.type===PIXI.Graphics.RECT)(e.fillColor||0===e.fillColor)&&(b.globalAlpha=e.fillAlpha*c,b.fillStyle="#"+("00000"+(0|g).toString(16)).substr(-6),b.fillRect(f.x,f.y,f.width,f.height)),e.lineWidth&&(b.globalAlpha=e.lineAlpha*c,b.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),b.strokeRect(f.x,f.y,f.width,f.height));else if(e.type===PIXI.Graphics.CIRC)b.beginPath(),b.arc(f.x,f.y,f.radius,0,2*Math.PI),b.closePath(),e.fill&&(b.globalAlpha=e.fillAlpha*c,b.fillStyle="#"+("00000"+(0|g).toString(16)).substr(-6),b.fill()),e.lineWidth&&(b.globalAlpha=e.lineAlpha*c,b.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),b.stroke());else if(e.type===PIXI.Graphics.ELIP){var k=2*f.width,l=2*f.height,m=f.x-k/2,n=f.y-l/2;b.beginPath();var o=.5522848,p=k/2*o,q=l/2*o,r=m+k,s=n+l,t=m+k/2,u=n+l/2;b.moveTo(m,u),b.bezierCurveTo(m,u-q,t-p,n,t,n),b.bezierCurveTo(t+p,n,r,u-q,r,u),b.bezierCurveTo(r,u+q,t+p,s,t,s),b.bezierCurveTo(t-p,s,m,u+q,m,u),b.closePath(),e.fill&&(b.globalAlpha=e.fillAlpha*c,b.fillStyle="#"+("00000"+(0|g).toString(16)).substr(-6),b.fill()),e.lineWidth&&(b.globalAlpha=e.lineAlpha*c,b.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),b.stroke())}else if(e.type===PIXI.Graphics.RREC){var v=f.x,w=f.y,x=f.width,y=f.height,z=f.radius,A=Math.min(x,y)/2|0;z=z>A?A:z,b.beginPath(),b.moveTo(v,w+z),b.lineTo(v,w+y-z),b.quadraticCurveTo(v,w+y,v+z,w+y),b.lineTo(v+x-z,w+y),b.quadraticCurveTo(v+x,w+y,v+x,w+y-z),b.lineTo(v+x,w+z),b.quadraticCurveTo(v+x,w,v+x-z,w),b.lineTo(v+z,w),b.quadraticCurveTo(v,w,v,w+z),b.closePath(),(e.fillColor||0===e.fillColor)&&(b.globalAlpha=e.fillAlpha*c,b.fillStyle="#"+("00000"+(0|g).toString(16)).substr(-6),b.fill()),e.lineWidth&&(b.globalAlpha=e.lineAlpha*c,b.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),b.stroke())}}},PIXI.CanvasGraphics.renderGraphicsMask=function(a,b){var c=a.graphicsData.length;if(0!==c){b.beginPath();for(var d=0;c>d;d++){var e=a.graphicsData[d],f=e.shape;if(e.type===PIXI.Graphics.POLY){var g=f.points;b.moveTo(g[0],g[1]);for(var h=1;h<g.length/2;h++)b.lineTo(g[2*h],g[2*h+1]);g[0]===g[g.length-2]&&g[1]===g[g.length-1]&&b.closePath(); +}else if(e.type===PIXI.Graphics.RECT)b.rect(f.x,f.y,f.width,f.height),b.closePath();else if(e.type===PIXI.Graphics.CIRC)b.arc(f.x,f.y,f.radius,0,2*Math.PI),b.closePath();else if(e.type===PIXI.Graphics.ELIP){var i=2*f.width,j=2*f.height,k=f.x-i/2,l=f.y-j/2,m=.5522848,n=i/2*m,o=j/2*m,p=k+i,q=l+j,r=k+i/2,s=l+j/2;b.moveTo(k,s),b.bezierCurveTo(k,s-o,r-n,l,r,l),b.bezierCurveTo(r+n,l,p,s-o,p,s),b.bezierCurveTo(p,s+o,r+n,q,r,q),b.bezierCurveTo(r-n,q,k,s+o,k,s),b.closePath()}else if(e.type===PIXI.Graphics.RREC){var t=f.x,u=f.y,v=f.width,w=f.height,x=f.radius,y=Math.min(v,w)/2|0;x=x>y?y:x,b.moveTo(t,u+x),b.lineTo(t,u+w-x),b.quadraticCurveTo(t,u+w,t+x,u+w),b.lineTo(t+v-x,u+w),b.quadraticCurveTo(t+v,u+w,t+v,u+w-x),b.lineTo(t+v,u+x),b.quadraticCurveTo(t+v,u,t+v-x,u),b.lineTo(t+x,u),b.quadraticCurveTo(t,u,t,u+x),b.closePath()}}}},PIXI.CanvasGraphics.updateGraphicsTint=function(a){if(16777215!==a.tint)for(var b=(a.tint>>16&255)/255,c=(a.tint>>8&255)/255,d=(255&a.tint)/255,e=0;e<a.graphicsData.length;e++){var f=a.graphicsData[e],g=0|f.fillColor,h=0|f.lineColor;f._fillTint=((g>>16&255)/255*b*255<<16)+((g>>8&255)/255*c*255<<8)+(255&g)/255*d*255,f._lineTint=((h>>16&255)/255*b*255<<16)+((h>>8&255)/255*c*255<<8)+(255&h)/255*d*255}},c.Graphics=function(a,b,d){void 0===b&&(b=0),void 0===d&&(d=0),this.type=c.GRAPHICS,this.physicsType=c.SPRITE,PIXI.Graphics.call(this),c.Component.Core.init.call(this,a,b,d,"",null)},c.Graphics.prototype=Object.create(PIXI.Graphics.prototype),c.Graphics.prototype.constructor=c.Graphics,c.Component.Core.install.call(c.Graphics.prototype,["Angle","AutoCull","Bounds","Destroy","FixedToCamera","InputEnabled","InWorld","LifeSpan","PhysicsBody","Reset"]),c.Graphics.prototype.preUpdatePhysics=c.Component.PhysicsBody.preUpdate,c.Graphics.prototype.preUpdateLifeSpan=c.Component.LifeSpan.preUpdate,c.Graphics.prototype.preUpdateInWorld=c.Component.InWorld.preUpdate,c.Graphics.prototype.preUpdateCore=c.Component.Core.preUpdate,c.Graphics.prototype.preUpdate=function(){return this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld()?this.preUpdateCore():!1},c.Graphics.prototype.destroy=function(a){this.clear(),c.Component.Destroy.prototype.destroy.call(this,a)},c.Graphics.prototype.drawTriangle=function(a,b){void 0===b&&(b=!1);var d=new c.Polygon(a);if(b){var e=new c.Point(this.game.camera.x-a[0].x,this.game.camera.y-a[0].y),f=new c.Point(a[1].x-a[0].x,a[1].y-a[0].y),g=new c.Point(a[1].x-a[2].x,a[1].y-a[2].y),h=g.cross(f);e.dot(h)>0&&this.drawPolygon(d)}else this.drawPolygon(d)},c.Graphics.prototype.drawTriangles=function(a,b,d){void 0===d&&(d=!1);var e,f=new c.Point,g=new c.Point,h=new c.Point,i=[];if(b)if(a[0]instanceof c.Point)for(e=0;e<b.length/3;e++)i.push(a[b[3*e]]),i.push(a[b[3*e+1]]),i.push(a[b[3*e+2]]),3===i.length&&(this.drawTriangle(i,d),i=[]);else for(e=0;e<b.length;e++)f.x=a[2*b[e]],f.y=a[2*b[e]+1],i.push(f.copyTo({})),3===i.length&&(this.drawTriangle(i,d),i=[]);else if(a[0]instanceof c.Point)for(e=0;e<a.length/3;e++)this.drawTriangle([a[3*e],a[3*e+1],a[3*e+2]],d);else for(e=0;e<a.length/6;e++)f.x=a[6*e+0],f.y=a[6*e+1],g.x=a[6*e+2],g.y=a[6*e+3],h.x=a[6*e+4],h.y=a[6*e+5],this.drawTriangle([f,g,h],d)},c.RenderTexture=function(a,b,d,e,f,g){void 0===e&&(e=""),void 0===f&&(f=c.scaleModes.DEFAULT),void 0===g&&(g=1),this.game=a,this.key=e,this.type=c.RENDERTEXTURE,this._tempMatrix=new PIXI.Matrix,PIXI.RenderTexture.call(this,b,d,this.game.renderer,f,g),this.render=c.RenderTexture.prototype.render},c.RenderTexture.prototype=Object.create(PIXI.RenderTexture.prototype),c.RenderTexture.prototype.constructor=c.RenderTexture,c.RenderTexture.prototype.renderXY=function(a,b,c,d){a.updateTransform(),this._tempMatrix.copyFrom(a.worldTransform),this._tempMatrix.tx=b,this._tempMatrix.ty=c,this.renderer.type===PIXI.WEBGL_RENDERER?this.renderWebGL(a,this._tempMatrix,d):this.renderCanvas(a,this._tempMatrix,d)},c.RenderTexture.prototype.renderRawXY=function(a,b,c,d){this._tempMatrix.identity().translate(b,c),this.renderer.type===PIXI.WEBGL_RENDERER?this.renderWebGL(a,this._tempMatrix,d):this.renderCanvas(a,this._tempMatrix,d)},c.RenderTexture.prototype.render=function(a,b,c){void 0===b||null===b?this._tempMatrix.copyFrom(a.worldTransform):this._tempMatrix.copyFrom(b),this.renderer.type===PIXI.WEBGL_RENDERER?this.renderWebGL(a,this._tempMatrix,c):this.renderCanvas(a,this._tempMatrix,c)},c.Text=function(a,b,d,e,f){b=b||0,d=d||0,e=void 0===e||null===e?"":e.toString(),f=f||{},this.type=c.TEXT,this.physicsType=c.SPRITE,this.padding=new c.Point,this.textBounds=null,this.canvas=PIXI.CanvasPool.create(this),this.context=this.canvas.getContext("2d"),this.colors=[],this.strokeColors=[],this.fontStyles=[],this.fontWeights=[],this.autoRound=!1,this._res=a.renderer.resolution,this._text=e,this._fontComponents=null,this._lineSpacing=0,this._charCount=0,this._width=0,this._height=0,c.Sprite.call(this,a,b,d,PIXI.Texture.fromCanvas(this.canvas)),this.setStyle(f),""!==e&&this.updateText()},c.Text.prototype=Object.create(c.Sprite.prototype),c.Text.prototype.constructor=c.Text,c.Text.prototype.preUpdate=function(){return this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld()?this.preUpdateCore():!1},c.Text.prototype.update=function(){},c.Text.prototype.destroy=function(a){this.texture.destroy(!0),PIXI.CanvasPool.remove(this),c.Component.Destroy.prototype.destroy.call(this,a)},c.Text.prototype.setShadow=function(a,b,c,d,e,f){return void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c="rgba(0, 0, 0, 1)"),void 0===d&&(d=0),void 0===e&&(e=!0),void 0===f&&(f=!0),this.style.shadowOffsetX=a,this.style.shadowOffsetY=b,this.style.shadowColor=c,this.style.shadowBlur=d,this.style.shadowStroke=e,this.style.shadowFill=f,this.dirty=!0,this},c.Text.prototype.setStyle=function(a){a=a||{},a.font=a.font||"bold 20pt Arial",a.backgroundColor=a.backgroundColor||null,a.fill=a.fill||"black",a.align=a.align||"left",a.boundsAlignH=a.boundsAlignH||"left",a.boundsAlignV=a.boundsAlignV||"top",a.stroke=a.stroke||"black",a.strokeThickness=a.strokeThickness||0,a.wordWrap=a.wordWrap||!1,a.wordWrapWidth=a.wordWrapWidth||100,a.shadowOffsetX=a.shadowOffsetX||0,a.shadowOffsetY=a.shadowOffsetY||0,a.shadowColor=a.shadowColor||"rgba(0,0,0,0)",a.shadowBlur=a.shadowBlur||0,a.tabs=a.tabs||0;var b=this.fontToComponents(a.font);return a.fontStyle&&(b.fontStyle=a.fontStyle),a.fontVariant&&(b.fontVariant=a.fontVariant),a.fontWeight&&(b.fontWeight=a.fontWeight),a.fontSize&&("number"==typeof a.fontSize&&(a.fontSize=a.fontSize+"px"),b.fontSize=a.fontSize),this._fontComponents=b,a.font=this.componentsToFont(this._fontComponents),this.style=a,this.dirty=!0,this},c.Text.prototype.updateText=function(){this.texture.baseTexture.resolution=this._res,this.context.font=this.style.font;var a=this.text;this.style.wordWrap&&(a=this.runWordWrap(this.text));for(var b=a.split(/(?:\r\n|\r|\n)/),c=this.style.tabs,d=[],e=0,f=this.determineFontProperties(this.style.font),g=0;g<b.length;g++){if(0===c){var h=this.context.measureText(b[g]).width+this.style.strokeThickness+this.padding.x;this.style.wordWrap&&(h-=this.context.measureText(" ").width)}else{var i=b[g].split(/(?:\t)/),h=this.padding.x+this.style.strokeThickness;if(Array.isArray(c))for(var j=0,k=0;k<i.length;k++){var l=Math.ceil(this.context.measureText(i[k]).width);k>0&&(j+=c[k-1]),h=j+l}else for(var k=0;k<i.length;k++){h+=Math.ceil(this.context.measureText(i[k]).width);var m=this.game.math.snapToCeil(h,c)-h;h+=m}}d[g]=Math.ceil(h),e=Math.max(e,d[g])}this.canvas.width=e*this._res;var n=f.fontSize+this.style.strokeThickness+this.padding.y,o=n*b.length,p=this._lineSpacing;if(0>p&&Math.abs(p)>n&&(p=-n),0!==p){var m=p*(b.length-1);o+=m}this.canvas.height=o*this._res,this.context.scale(this._res,this._res),navigator.isCocoonJS&&this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.style.backgroundColor&&(this.context.fillStyle=this.style.backgroundColor,this.context.fillRect(0,0,this.canvas.width,this.canvas.height)),this.context.fillStyle=this.style.fill,this.context.font=this.style.font,this.context.strokeStyle=this.style.stroke,this.context.textBaseline="alphabetic",this.context.lineWidth=this.style.strokeThickness,this.context.lineCap="round",this.context.lineJoin="round";var q,r;for(this._charCount=0,g=0;g<b.length;g++)q=this.style.strokeThickness/2,r=this.style.strokeThickness/2+g*n+f.ascent,g>0&&(r+=p*g),"right"===this.style.align?q+=e-d[g]:"center"===this.style.align&&(q+=(e-d[g])/2),this.autoRound&&(q=Math.round(q),r=Math.round(r)),this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?this.updateLine(b[g],q,r):(this.style.stroke&&this.style.strokeThickness&&(this.updateShadow(this.style.shadowStroke),0===c?this.context.strokeText(b[g],q,r):this.renderTabLine(b[g],q,r,!1)),this.style.fill&&(this.updateShadow(this.style.shadowFill),0===c?this.context.fillText(b[g],q,r):this.renderTabLine(b[g],q,r,!0)));this.updateTexture()},c.Text.prototype.renderTabLine=function(a,b,c,d){var e=a.split(/(?:\t)/),f=this.style.tabs,g=0;if(Array.isArray(f))for(var h=0,i=0;i<e.length;i++)i>0&&(h+=f[i-1]),g=b+h,d?this.context.fillText(e[i],g,c):this.context.strokeText(e[i],g,c);else for(var i=0;i<e.length;i++){var j=Math.ceil(this.context.measureText(e[i]).width);g=this.game.math.snapToCeil(b,f),d?this.context.fillText(e[i],g,c):this.context.strokeText(e[i],g,c),b=g+j}},c.Text.prototype.updateShadow=function(a){a?(this.context.shadowOffsetX=this.style.shadowOffsetX,this.context.shadowOffsetY=this.style.shadowOffsetY,this.context.shadowColor=this.style.shadowColor,this.context.shadowBlur=this.style.shadowBlur):(this.context.shadowOffsetX=0,this.context.shadowOffsetY=0,this.context.shadowColor=0,this.context.shadowBlur=0)},c.Text.prototype.updateLine=function(a,b,c){for(var d=0;d<a.length;d++){var e=a[d];if(this.fontWeights.length>0||this.fontStyles.length>0){var f=this.fontToComponents(this.context.font);this.fontStyles[this._charCount]&&(f.fontStyle=this.fontStyles[this._charCount]),this.fontWeights[this._charCount]&&(f.fontWeight=this.fontWeights[this._charCount]),this.context.font=this.componentsToFont(f)}this.style.stroke&&this.style.strokeThickness&&(this.strokeColors[this._charCount]&&(this.context.strokeStyle=this.strokeColors[this._charCount]),this.updateShadow(this.style.shadowStroke),this.context.strokeText(e,b,c)),this.style.fill&&(this.colors[this._charCount]&&(this.context.fillStyle=this.colors[this._charCount]),this.updateShadow(this.style.shadowFill),this.context.fillText(e,b,c)),b+=this.context.measureText(e).width,this._charCount++}},c.Text.prototype.clearColors=function(){return this.colors=[],this.strokeColors=[],this.dirty=!0,this},c.Text.prototype.clearFontValues=function(){return this.fontStyles=[],this.fontWeights=[],this.dirty=!0,this},c.Text.prototype.addColor=function(a,b){return this.colors[b]=a,this.dirty=!0,this},c.Text.prototype.addStrokeColor=function(a,b){return this.strokeColors[b]=a,this.dirty=!0,this},c.Text.prototype.addFontStyle=function(a,b){return this.fontStyles[b]=a,this.dirty=!0,this},c.Text.prototype.addFontWeight=function(a,b){return this.fontWeights[b]=a,this.dirty=!0,this},c.Text.prototype.runWordWrap=function(a){for(var b="",c=a.split("\n"),d=0;d<c.length;d++){for(var e=this.style.wordWrapWidth,f=c[d].split(" "),g=0;g<f.length;g++){var h=this.context.measureText(f[g]).width,i=h+this.context.measureText(" ").width;i>e?(g>0&&(b+="\n"),b+=f[g]+" ",e=this.style.wordWrapWidth-h):(e-=i,b+=f[g]+" ")}d<c.length-1&&(b+="\n")}return b},c.Text.prototype.updateFont=function(a){var b=this.componentsToFont(a);this.style.font!==b&&(this.style.font=b,this.dirty=!0,this.parent&&this.updateTransform())},c.Text.prototype.fontToComponents=function(a){var b=a.match(/^\s*(?:\b(normal|italic|oblique|inherit)?\b)\s*(?:\b(normal|small-caps|inherit)?\b)\s*(?:\b(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit)?\b)\s*(?:\b(xx-small|x-small|small|medium|large|x-large|xx-large|larger|smaller|0|\d*(?:[.]\d*)?(?:%|[a-z]{2,5}))?\b)\s*(.*)\s*$/);return b?{font:a,fontStyle:b[1]||"normal",fontVariant:b[2]||"normal",fontWeight:b[3]||"normal",fontSize:b[4]||"medium",fontFamily:b[5]}:(console.warn("Phaser.Text - unparsable CSS font: "+a),{font:a})},c.Text.prototype.componentsToFont=function(a){var b,c=[];return b=a.fontStyle,b&&"normal"!==b&&c.push(b),b=a.fontVariant,b&&"normal"!==b&&c.push(b),b=a.fontWeight,b&&"normal"!==b&&c.push(b),b=a.fontSize,b&&"medium"!==b&&c.push(b),b=a.fontFamily,b&&c.push(b),c.length||c.push(a.font),c.join(" ")},c.Text.prototype.setText=function(a){return this.text=a.toString()||"",this.dirty=!0,this},c.Text.prototype.parseList=function(a){if(!Array.isArray(a))return this;for(var b="",c=0;c<a.length;c++)Array.isArray(a[c])?(b+=a[c].join(" "),c<a.length-1&&(b+="\n")):(b+=a[c],c<a.length-1&&(b+=" "));return this.text=b,this.dirty=!0,this},c.Text.prototype.setTextBounds=function(a,b,d,e){return void 0===a?this.textBounds=null:(this.textBounds?this.textBounds.setTo(a,b,d,e):this.textBounds=new c.Rectangle(a,b,d,e),this.style.wordWrapWidth>d&&(this.style.wordWrapWidth=d)),this.updateTexture(),this},c.Text.prototype.updateTexture=function(){var a=this.texture.baseTexture,b=this.texture.crop,c=this.texture.frame,d=this.canvas.width,e=this.canvas.height;if(a.width=d,a.height=e,b.width=d,b.height=e,c.width=d,c.height=e,this.texture.width=d,this.texture.height=e,this._width=d,this._height=e,this.textBounds){var f=this.textBounds.x,g=this.textBounds.y;"right"===this.style.boundsAlignH?f+=this.textBounds.width-this.canvas.width:"center"===this.style.boundsAlignH&&(f+=this.textBounds.halfWidth-this.canvas.width/2),"bottom"===this.style.boundsAlignV?g+=this.textBounds.height-this.canvas.height:"middle"===this.style.boundsAlignV&&(g+=this.textBounds.halfHeight-this.canvas.height/2),this.pivot.x=-f,this.pivot.y=-g}this.renderable=0!==d&&0!==e,this.texture.requiresReTint=!0,this.texture.baseTexture.dirty()},c.Text.prototype._renderWebGL=function(a){this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype._renderWebGL.call(this,a)},c.Text.prototype._renderCanvas=function(a){this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype._renderCanvas.call(this,a)},c.Text.prototype.determineFontProperties=function(a){var b=c.Text.fontPropertiesCache[a];if(!b){b={};var d=c.Text.fontPropertiesCanvas,e=c.Text.fontPropertiesContext;e.font=a;var f=Math.ceil(e.measureText("|MÉq").width),g=Math.ceil(e.measureText("|MÉq").width),h=2*g;if(g=1.4*g|0,d.width=f,d.height=h,e.fillStyle="#f00",e.fillRect(0,0,f,h),e.font=a,e.textBaseline="alphabetic",e.fillStyle="#000",e.fillText("|MÉq",0,g),!e.getImageData(0,0,f,h))return b.ascent=g,b.descent=g+6,b.fontSize=b.ascent+b.descent,c.Text.fontPropertiesCache[a]=b,b;var i,j,k=e.getImageData(0,0,f,h).data,l=k.length,m=4*f,n=0,o=!1;for(i=0;g>i;i++){for(j=0;m>j;j+=4)if(255!==k[n+j]){o=!0;break}if(o)break;n+=m}for(b.ascent=g-i,n=l-m,o=!1,i=h;i>g;i--){for(j=0;m>j;j+=4)if(255!==k[n+j]){o=!0;break}if(o)break;n-=m}b.descent=i-g,b.descent+=6,b.fontSize=b.ascent+b.descent,c.Text.fontPropertiesCache[a]=b}return b},c.Text.prototype.getBounds=function(a){return this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype.getBounds.call(this,a)},Object.defineProperty(c.Text.prototype,"text",{get:function(){return this._text},set:function(a){a!==this._text&&(this._text=a.toString()||"",this.dirty=!0,this.parent&&this.updateTransform())}}),Object.defineProperty(c.Text.prototype,"cssFont",{get:function(){return this.componentsToFont(this._fontComponents)},set:function(a){a=a||"bold 20pt Arial",this._fontComponents=this.fontToComponents(a),this.updateFont(this._fontComponents)}}),Object.defineProperty(c.Text.prototype,"font",{get:function(){return this._fontComponents.fontFamily},set:function(a){a=a||"Arial",a=a.trim(),/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(a)||/['",]/.exec(a)||(a="'"+a+"'"),this._fontComponents.fontFamily=a,this.updateFont(this._fontComponents)}}),Object.defineProperty(c.Text.prototype,"fontSize",{get:function(){var a=this._fontComponents.fontSize;return a&&/(?:^0$|px$)/.exec(a)?parseInt(a,10):a},set:function(a){a=a||"0","number"==typeof a&&(a+="px"),this._fontComponents.fontSize=a,this.updateFont(this._fontComponents)}}),Object.defineProperty(c.Text.prototype,"fontWeight",{get:function(){return this._fontComponents.fontWeight||"normal"},set:function(a){a=a||"normal",this._fontComponents.fontWeight=a,this.updateFont(this._fontComponents)}}),Object.defineProperty(c.Text.prototype,"fontStyle",{get:function(){return this._fontComponents.fontStyle||"normal"},set:function(a){a=a||"normal",this._fontComponents.fontStyle=a,this.updateFont(this._fontComponents)}}),Object.defineProperty(c.Text.prototype,"fontVariant",{get:function(){return this._fontComponents.fontVariant||"normal"},set:function(a){a=a||"normal",this._fontComponents.fontVariant=a,this.updateFont(this._fontComponents)}}),Object.defineProperty(c.Text.prototype,"fill",{get:function(){return this.style.fill},set:function(a){a!==this.style.fill&&(this.style.fill=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"align",{get:function(){return this.style.align},set:function(a){a!==this.style.align&&(this.style.align=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"resolution",{get:function(){return this._res},set:function(a){a!==this._res&&(this._res=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"tabs",{get:function(){return this.style.tabs},set:function(a){a!==this.style.tabs&&(this.style.tabs=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"boundsAlignH",{get:function(){return this.style.boundsAlignH},set:function(a){a!==this.style.boundsAlignH&&(this.style.boundsAlignH=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"boundsAlignV",{get:function(){return this.style.boundsAlignV},set:function(a){a!==this.style.boundsAlignV&&(this.style.boundsAlignV=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"stroke",{get:function(){return this.style.stroke},set:function(a){a!==this.style.stroke&&(this.style.stroke=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"strokeThickness",{get:function(){return this.style.strokeThickness},set:function(a){a!==this.style.strokeThickness&&(this.style.strokeThickness=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"wordWrap",{get:function(){return this.style.wordWrap},set:function(a){a!==this.style.wordWrap&&(this.style.wordWrap=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"wordWrapWidth",{get:function(){return this.style.wordWrapWidth},set:function(a){a!==this.style.wordWrapWidth&&(this.style.wordWrapWidth=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"lineSpacing",{get:function(){return this._lineSpacing},set:function(a){a!==this._lineSpacing&&(this._lineSpacing=parseFloat(a),this.dirty=!0,this.parent&&this.updateTransform())}}),Object.defineProperty(c.Text.prototype,"shadowOffsetX",{get:function(){return this.style.shadowOffsetX},set:function(a){a!==this.style.shadowOffsetX&&(this.style.shadowOffsetX=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"shadowOffsetY",{get:function(){return this.style.shadowOffsetY},set:function(a){a!==this.style.shadowOffsetY&&(this.style.shadowOffsetY=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"shadowColor",{get:function(){return this.style.shadowColor},set:function(a){a!==this.style.shadowColor&&(this.style.shadowColor=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"shadowBlur",{get:function(){return this.style.shadowBlur},set:function(a){a!==this.style.shadowBlur&&(this.style.shadowBlur=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"shadowStroke",{get:function(){return this.style.shadowStroke},set:function(a){a!==this.style.shadowStroke&&(this.style.shadowStroke=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"shadowFill",{get:function(){return this.style.shadowFill},set:function(a){a!==this.style.shadowFill&&(this.style.shadowFill=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"width",{get:function(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.x*this.texture.frame.width},set:function(a){this.scale.x=a/this.texture.frame.width,this._width=a}}),Object.defineProperty(c.Text.prototype,"height",{get:function(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.y*this.texture.frame.height},set:function(a){this.scale.y=a/this.texture.frame.height,this._height=a}}),c.Text.fontPropertiesCache={},c.Text.fontPropertiesCanvas=PIXI.CanvasPool.create(c.Text.fontPropertiesCanvas),c.Text.fontPropertiesContext=c.Text.fontPropertiesCanvas.getContext("2d"),c.BitmapText=function(a,b,d,e,f,g,h){b=b||0,d=d||0,e=e||"",f=f||"",g=g||32,h=h||"left",PIXI.DisplayObjectContainer.call(this),this.type=c.BITMAPTEXT,this.physicsType=c.SPRITE,this.textWidth=0,this.textHeight=0,this.anchor=new c.Point,this._prevAnchor=new c.Point,this._glyphs=[],this._maxWidth=0,this._text=f,this._data=a.cache.getBitmapFont(e),this._font=e,this._fontSize=g,this._align=h,this._tint=16777215,this.updateText(),this.dirty=!1,c.Component.Core.init.call(this,a,b,d,"",null)},c.BitmapText.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),c.BitmapText.prototype.constructor=c.BitmapText,c.Component.Core.install.call(c.BitmapText.prototype,["Angle","AutoCull","Bounds","Destroy","FixedToCamera","InputEnabled","InWorld","LifeSpan","PhysicsBody","Reset"]),c.BitmapText.prototype.preUpdatePhysics=c.Component.PhysicsBody.preUpdate,c.BitmapText.prototype.preUpdateLifeSpan=c.Component.LifeSpan.preUpdate,c.BitmapText.prototype.preUpdateInWorld=c.Component.InWorld.preUpdate,c.BitmapText.prototype.preUpdateCore=c.Component.Core.preUpdate,c.BitmapText.prototype.preUpdate=function(){return this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld()?this.preUpdateCore():!1},c.BitmapText.prototype.postUpdate=function(){c.Component.PhysicsBody.postUpdate.call(this),c.Component.FixedToCamera.postUpdate.call(this),this.body&&this.body.type===c.Physics.ARCADE&&(this.textWidth!==this.body.sourceWidth||this.textHeight!==this.body.sourceHeight)&&this.body.setSize(this.textWidth,this.textHeight)},c.BitmapText.prototype.setText=function(a){this.text=a},c.BitmapText.prototype.scanLine=function(a,b,c){for(var d=0,e=0,f=-1,g=null,h=this._maxWidth>0?this._maxWidth:null,i=[],j=0;j<c.length;j++){var k=j===c.length-1?!0:!1;if(/(?:\r\n|\r|\n)/.test(c.charAt(j)))return{width:e,text:c.substr(0,j),end:k,chars:i};var l=c.charCodeAt(j),m=a.chars[l],n=0;if(m){var o=g&&m.kerning[g]?m.kerning[g]:0;if(f=/(\s)/.test(c.charAt(j))?j:f,n=(o+m.texture.width+m.xOffset)*b,h&&e+n>=h&&f>-1)return{width:e,text:c.substr(0,j-(j-f)),end:k,chars:i};e+=m.xAdvance*b,i.push(d+m.xOffset*b),d+=m.xAdvance*b,g=l}}return{width:e,text:c,end:k,chars:i}},c.BitmapText.prototype.updateText=function(){var a=this._data.font;if(a){var b=this.text,c=this._fontSize/a.size,d=[],e=0;this.textWidth=0;do{var f=this.scanLine(a,c,b);f.y=e,d.push(f),f.width>this.textWidth&&(this.textWidth=f.width),e+=a.lineHeight*c,b=b.substr(f.text.length+1)}while(f.end===!1);this.textHeight=e;for(var g=0,h=0,i=this.textWidth*this.anchor.x,j=this.textHeight*this.anchor.y,k=0;k<d.length;k++){var f=d[k];"right"===this._align?h=this.textWidth-f.width:"center"===this._align&&(h=(this.textWidth-f.width)/2);for(var l=0;l<f.text.length;l++){var m=f.text.charCodeAt(l),n=a.chars[m],o=this._glyphs[g];o?o.texture=n.texture:(o=new PIXI.Sprite(n.texture),o.name=f.text[l],this._glyphs.push(o)),o.position.x=f.chars[l]+h-i,o.position.y=f.y+n.yOffset*c-j,o.scale.set(c),o.tint=this.tint,o.texture.requiresReTint=!0,o.parent||this.addChild(o),g++}}for(k=g;k<this._glyphs.length;k++)this.removeChild(this._glyphs[k])}},c.BitmapText.prototype.purgeGlyphs=function(){for(var a=this._glyphs.length,b=[],c=0;c<this._glyphs.length;c++)this._glyphs[c].parent!==this?this._glyphs[c].destroy():b.push(this._glyphs[c]);return this._glyphs=[],this._glyphs=b,this.updateText(),a-b.length},c.BitmapText.prototype.updateTransform=function(){(this.dirty||!this.anchor.equals(this._prevAnchor))&&(this.updateText(),this.dirty=!1,this._prevAnchor.copyFrom(this.anchor)),PIXI.DisplayObjectContainer.prototype.updateTransform.call(this)},Object.defineProperty(c.BitmapText.prototype,"align",{get:function(){return this._align},set:function(a){a===this._align||"left"!==a&&"center"!==a&&"right"!==a||(this._align=a,this.updateText())}}),Object.defineProperty(c.BitmapText.prototype,"tint",{get:function(){return this._tint},set:function(a){a!==this._tint&&(this._tint=a,this.updateText())}}),Object.defineProperty(c.BitmapText.prototype,"font",{get:function(){return this._font},set:function(a){a!==this._font&&(this._font=a.trim(),this._data=this.game.cache.getBitmapFont(this._font),this.updateText())}}),Object.defineProperty(c.BitmapText.prototype,"fontSize",{get:function(){return this._fontSize},set:function(a){a=parseInt(a,10),a!==this._fontSize&&a>0&&(this._fontSize=a,this.updateText())}}),Object.defineProperty(c.BitmapText.prototype,"text",{get:function(){return this._text},set:function(a){a!==this._text&&(this._text=a.toString()||"",this.updateText())}}),Object.defineProperty(c.BitmapText.prototype,"maxWidth",{get:function(){return this._maxWidth},set:function(a){a!==this._maxWidth&&(this._maxWidth=a,this.updateText())}}),Object.defineProperty(c.BitmapText.prototype,"smoothed",{get:function(){return!this._data.base.scaleMode},set:function(a){a?this._data.base.scaleMode=0:this._data.base.scaleMode=1}}),c.RetroFont=function(a,b,d,e,f,g,h,i,j,k){if(!a.cache.checkImageKey(b))return!1;(void 0===g||null===g)&&(g=a.cache.getImage(b).width/d),this.characterWidth=d,this.characterHeight=e,this.characterSpacingX=h||0,this.characterSpacingY=i||0,this.characterPerRow=g,this.offsetX=j||0,this.offsetY=k||0,this.align="left",this.multiLine=!1,this.autoUpperCase=!0,this.customSpacingX=0,this.customSpacingY=0,this.fixedWidth=0,this.fontSet=a.cache.getImage(b),this._text="",this.grabData=[],this.frameData=new c.FrameData;for(var l=this.offsetX,m=this.offsetY,n=0,o=0;o<f.length;o++){var p=this.frameData.addFrame(new c.Frame(o,l,m,this.characterWidth,this.characterHeight));this.grabData[f.charCodeAt(o)]=p.index,n++,n===this.characterPerRow?(n=0,l=this.offsetX,m+=this.characterHeight+this.characterSpacingY):l+=this.characterWidth+this.characterSpacingX}a.cache.updateFrameData(b,this.frameData),this.stamp=new c.Image(a,0,0,b,0),c.RenderTexture.call(this,a,100,100,"",c.scaleModes.NEAREST),this.type=c.RETROFONT},c.RetroFont.prototype=Object.create(c.RenderTexture.prototype),c.RetroFont.prototype.constructor=c.RetroFont,c.RetroFont.ALIGN_LEFT="left",c.RetroFont.ALIGN_RIGHT="right",c.RetroFont.ALIGN_CENTER="center",c.RetroFont.TEXT_SET1=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",c.RetroFont.TEXT_SET2=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ",c.RetroFont.TEXT_SET3="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ",c.RetroFont.TEXT_SET4="ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789",c.RetroFont.TEXT_SET5="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789",c.RetroFont.TEXT_SET6="ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ",c.RetroFont.TEXT_SET7="AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39",c.RetroFont.TEXT_SET8="0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ",c.RetroFont.TEXT_SET9="ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!",c.RetroFont.TEXT_SET10="ABCDEFGHIJKLMNOPQRSTUVWXYZ",c.RetroFont.TEXT_SET11="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789",c.RetroFont.prototype.setFixedWidth=function(a,b){void 0===b&&(b="left"),this.fixedWidth=a,this.align=b},c.RetroFont.prototype.setText=function(a,b,c,d,e,f){this.multiLine=b||!1,this.customSpacingX=c||0,this.customSpacingY=d||0,this.align=e||"left",f?this.autoUpperCase=!1:this.autoUpperCase=!0,a.length>0&&(this.text=a)},c.RetroFont.prototype.buildRetroFontText=function(){var a=0,b=0;if(this.clear(),this.multiLine){var d=this._text.split("\n");this.fixedWidth>0?this.resize(this.fixedWidth,d.length*(this.characterHeight+this.customSpacingY)-this.customSpacingY,!0):this.resize(this.getLongestLine()*(this.characterWidth+this.customSpacingX),d.length*(this.characterHeight+this.customSpacingY)-this.customSpacingY,!0);for(var e=0;e<d.length;e++)a=0,this.align===c.RetroFont.ALIGN_RIGHT?a=this.width-d[e].length*(this.characterWidth+this.customSpacingX):this.align===c.RetroFont.ALIGN_CENTER&&(a=this.width/2-d[e].length*(this.characterWidth+this.customSpacingX)/2,a+=this.customSpacingX/2),0>a&&(a=0),this.pasteLine(d[e],a,b,this.customSpacingX),b+=this.characterHeight+this.customSpacingY}else this.fixedWidth>0?this.resize(this.fixedWidth,this.characterHeight,!0):this.resize(this._text.length*(this.characterWidth+this.customSpacingX),this.characterHeight,!0),a=0,this.align===c.RetroFont.ALIGN_RIGHT?a=this.width-this._text.length*(this.characterWidth+this.customSpacingX):this.align===c.RetroFont.ALIGN_CENTER&&(a=this.width/2-this._text.length*(this.characterWidth+this.customSpacingX)/2,a+=this.customSpacingX/2),0>a&&(a=0),this.pasteLine(this._text,a,0,this.customSpacingX);this.requiresReTint=!0},c.RetroFont.prototype.pasteLine=function(a,b,c,d){for(var e=0;e<a.length;e++)if(" "===a.charAt(e))b+=this.characterWidth+d;else if(this.grabData[a.charCodeAt(e)]>=0&&(this.stamp.frame=this.grabData[a.charCodeAt(e)],this.renderXY(this.stamp,b,c,!1),b+=this.characterWidth+d,b>this.width))break},c.RetroFont.prototype.getLongestLine=function(){var a=0;if(this._text.length>0)for(var b=this._text.split("\n"),c=0;c<b.length;c++)b[c].length>a&&(a=b[c].length);return a},c.RetroFont.prototype.removeUnsupportedCharacters=function(a){for(var b="",c=0;c<this._text.length;c++){var d=this._text[c],e=d.charCodeAt(0);(this.grabData[e]>=0||!a&&"\n"===d)&&(b=b.concat(d))}return b},c.RetroFont.prototype.updateOffset=function(a,b){if(this.offsetX!==a||this.offsetY!==b){for(var c=a-this.offsetX,d=b-this.offsetY,e=this.game.cache.getFrameData(this.stamp.key).getFrames(),f=e.length;f--;)e[f].x+=c,e[f].y+=d;this.buildRetroFontText()}},Object.defineProperty(c.RetroFont.prototype,"text",{get:function(){return this._text},set:function(a){var b;b=this.autoUpperCase?a.toUpperCase():a,b!==this._text&&(this._text=b,this.removeUnsupportedCharacters(this.multiLine),this.buildRetroFontText())}}),Object.defineProperty(c.RetroFont.prototype,"smoothed",{get:function(){return this.stamp.smoothed},set:function(a){this.stamp.smoothed=a,this.buildRetroFontText()}}),c.Rope=function(a,b,d,e,f,g){this.points=[],this.points=g,this._hasUpdateAnimation=!1,this._updateAnimationCallback=null,b=b||0,d=d||0,e=e||null,f=f||null,this.type=c.ROPE,PIXI.Rope.call(this,PIXI.TextureCache.__default,this.points),c.Component.Core.init.call(this,a,b,d,e,f)},c.Rope.prototype=Object.create(PIXI.Rope.prototype),c.Rope.prototype.constructor=c.Rope,c.Component.Core.install.call(c.Rope.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Delta","Destroy","FixedToCamera","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","ScaleMinMax","Smoothed"]),c.Rope.prototype.preUpdatePhysics=c.Component.PhysicsBody.preUpdate,c.Rope.prototype.preUpdateLifeSpan=c.Component.LifeSpan.preUpdate,c.Rope.prototype.preUpdateInWorld=c.Component.InWorld.preUpdate,c.Rope.prototype.preUpdateCore=c.Component.Core.preUpdate,c.Rope.prototype.preUpdate=function(){return this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld()?this.preUpdateCore():!1},c.Rope.prototype.update=function(){this._hasUpdateAnimation&&this.updateAnimation.call(this)},c.Rope.prototype.reset=function(a,b){return c.Component.Reset.prototype.reset.call(this,a,b),this},Object.defineProperty(c.Rope.prototype,"updateAnimation",{get:function(){return this._updateAnimation},set:function(a){a&&"function"==typeof a?(this._hasUpdateAnimation=!0,this._updateAnimation=a):(this._hasUpdateAnimation=!1,this._updateAnimation=null); +}}),Object.defineProperty(c.Rope.prototype,"segments",{get:function(){for(var a,b,d,e,f,g,h,i,j=[],k=0;k<this.points.length;k++)a=4*k,b=this.vertices[a]*this.scale.x,d=this.vertices[a+1]*this.scale.y,e=this.vertices[a+4]*this.scale.x,f=this.vertices[a+3]*this.scale.y,g=c.Math.difference(b,e),h=c.Math.difference(d,f),b+=this.world.x,d+=this.world.y,i=new c.Rectangle(b,d,g,h),j.push(i);return j}}),c.TileSprite=function(a,b,d,e,f,g,h){b=b||0,d=d||0,e=e||256,f=f||256,g=g||null,h=h||null,this.type=c.TILESPRITE,this.physicsType=c.SPRITE,this._scroll=new c.Point;var i=a.cache.getImage("__default",!0);PIXI.TilingSprite.call(this,new PIXI.Texture(i.base),e,f),c.Component.Core.init.call(this,a,b,d,g,h)},c.TileSprite.prototype=Object.create(PIXI.TilingSprite.prototype),c.TileSprite.prototype.constructor=c.TileSprite,c.Component.Core.install.call(c.TileSprite.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Destroy","FixedToCamera","Health","InCamera","InputEnabled","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","Smoothed"]),c.TileSprite.prototype.preUpdatePhysics=c.Component.PhysicsBody.preUpdate,c.TileSprite.prototype.preUpdateLifeSpan=c.Component.LifeSpan.preUpdate,c.TileSprite.prototype.preUpdateInWorld=c.Component.InWorld.preUpdate,c.TileSprite.prototype.preUpdateCore=c.Component.Core.preUpdate,c.TileSprite.prototype.preUpdate=function(){return 0!==this._scroll.x&&(this.tilePosition.x+=this._scroll.x*this.game.time.physicsElapsed),0!==this._scroll.y&&(this.tilePosition.y+=this._scroll.y*this.game.time.physicsElapsed),this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld()?this.preUpdateCore():!1},c.TileSprite.prototype.autoScroll=function(a,b){this._scroll.set(a,b)},c.TileSprite.prototype.stopScroll=function(){this._scroll.set(0,0)},c.TileSprite.prototype.destroy=function(a){c.Component.Destroy.prototype.destroy.call(this,a),PIXI.TilingSprite.prototype.destroy.call(this)},c.TileSprite.prototype.reset=function(a,b){return c.Component.Reset.prototype.reset.call(this,a,b),this.tilePosition.x=0,this.tilePosition.y=0,this},c.Device=function(){this.deviceReadyAt=0,this.initialized=!1,this.desktop=!1,this.iOS=!1,this.iOSVersion=0,this.cocoonJS=!1,this.cocoonJSApp=!1,this.cordova=!1,this.node=!1,this.nodeWebkit=!1,this.electron=!1,this.ejecta=!1,this.crosswalk=!1,this.android=!1,this.chromeOS=!1,this.linux=!1,this.macOS=!1,this.windows=!1,this.windowsPhone=!1,this.canvas=!1,this.canvasBitBltShift=null,this.webGL=!1,this.file=!1,this.fileSystem=!1,this.localStorage=!1,this.worker=!1,this.css3D=!1,this.pointerLock=!1,this.typedArray=!1,this.vibration=!1,this.getUserMedia=!0,this.quirksMode=!1,this.touch=!1,this.mspointer=!1,this.wheelEvent=null,this.arora=!1,this.chrome=!1,this.chromeVersion=0,this.epiphany=!1,this.firefox=!1,this.firefoxVersion=0,this.ie=!1,this.ieVersion=0,this.trident=!1,this.tridentVersion=0,this.mobileSafari=!1,this.midori=!1,this.opera=!1,this.safari=!1,this.webApp=!1,this.silk=!1,this.audioData=!1,this.webAudio=!1,this.ogg=!1,this.opus=!1,this.mp3=!1,this.wav=!1,this.m4a=!1,this.webm=!1,this.oggVideo=!1,this.h264Video=!1,this.mp4Video=!1,this.webmVideo=!1,this.vp9Video=!1,this.hlsVideo=!1,this.iPhone=!1,this.iPhone4=!1,this.iPad=!1,this.pixelRatio=0,this.littleEndian=!1,this.LITTLE_ENDIAN=!1,this.support32bit=!1,this.fullscreen=!1,this.requestFullscreen="",this.cancelFullscreen="",this.fullscreenKeyboard=!1},c.Device=new c.Device,c.Device.onInitialized=new c.Signal,c.Device.whenReady=function(a,b,c){var d=this._readyCheck;if(this.deviceReadyAt||!d)a.call(b,this);else if(d._monitor||c)d._queue=d._queue||[],d._queue.push([a,b]);else{d._monitor=d.bind(this),d._queue=d._queue||[],d._queue.push([a,b]);var e="undefined"!=typeof window.cordova,f=navigator.isCocoonJS;"complete"===document.readyState||"interactive"===document.readyState?window.setTimeout(d._monitor,0):e&&!f?document.addEventListener("deviceready",d._monitor,!1):(document.addEventListener("DOMContentLoaded",d._monitor,!1),window.addEventListener("load",d._monitor,!1))}},c.Device._readyCheck=function(){var a=this._readyCheck;if(document.body){if(!this.deviceReadyAt){this.deviceReadyAt=Date.now(),document.removeEventListener("deviceready",a._monitor),document.removeEventListener("DOMContentLoaded",a._monitor),window.removeEventListener("load",a._monitor),this._initialize(),this.initialized=!0,this.onInitialized.dispatch(this);for(var b;b=a._queue.shift();){var c=b[0],d=b[1];c.call(d,this)}this._readyCheck=null,this._initialize=null,this.onInitialized=null}}else window.setTimeout(a._monitor,20)},c.Device._initialize=function(){function a(){var a=navigator.userAgent;/Playstation Vita/.test(a)?l.vita=!0:/Kindle/.test(a)||/\bKF[A-Z][A-Z]+/.test(a)||/Silk.*Mobile Safari/.test(a)?l.kindle=!0:/Android/.test(a)?l.android=!0:/CrOS/.test(a)?l.chromeOS=!0:/iP[ao]d|iPhone/i.test(a)?(l.iOS=!0,navigator.appVersion.match(/OS (\d+)/),l.iOSVersion=parseInt(RegExp.$1,10)):/Linux/.test(a)?l.linux=!0:/Mac OS/.test(a)?l.macOS=!0:/Windows/.test(a)&&(l.windows=!0),(/Windows Phone/i.test(a)||/IEMobile/i.test(a))&&(l.android=!1,l.iOS=!1,l.macOS=!1,l.windows=!0,l.windowsPhone=!0);var b=/Silk/.test(a);(l.windows||l.macOS||l.linux&&!b||l.chromeOS)&&(l.desktop=!0),(l.windowsPhone||/Windows NT/i.test(a)&&/Touch/i.test(a))&&(l.desktop=!1)}function b(){l.canvas=!!window.CanvasRenderingContext2D||l.cocoonJS;try{l.localStorage=!!localStorage.getItem}catch(a){l.localStorage=!1}l.file=!!(window.File&&window.FileReader&&window.FileList&&window.Blob),l.fileSystem=!!window.requestFileSystem,l.webGL=function(){try{var a=document.createElement("canvas");return a.screencanvas=!1,!!window.WebGLRenderingContext&&(a.getContext("webgl")||a.getContext("experimental-webgl"))}catch(b){return!1}}(),l.webGL=!!l.webGL,l.worker=!!window.Worker,l.pointerLock="pointerLockElement"in document||"mozPointerLockElement"in document||"webkitPointerLockElement"in document,l.quirksMode="CSS1Compat"===document.compatMode?!1:!0,navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia||navigator.oGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,l.getUserMedia=l.getUserMedia&&!!navigator.getUserMedia&&!!window.URL,l.firefox&&l.firefoxVersion<21&&(l.getUserMedia=!1),!l.iOS&&(l.ie||l.firefox||l.chrome)&&(l.canvasBitBltShift=!0),(l.safari||l.mobileSafari)&&(l.canvasBitBltShift=!1)}function c(){("ontouchstart"in document.documentElement||window.navigator.maxTouchPoints&&window.navigator.maxTouchPoints>=1)&&(l.touch=!0),(window.navigator.msPointerEnabled||window.navigator.pointerEnabled)&&(l.mspointer=!0),l.cocoonJS||("onwheel"in window||l.ie&&"WheelEvent"in window?l.wheelEvent="wheel":"onmousewheel"in window?l.wheelEvent="mousewheel":l.firefox&&"MouseScrollEvent"in window&&(l.wheelEvent="DOMMouseScroll"))}function d(){for(var a=["requestFullscreen","requestFullScreen","webkitRequestFullscreen","webkitRequestFullScreen","msRequestFullscreen","msRequestFullScreen","mozRequestFullScreen","mozRequestFullscreen"],b=document.createElement("div"),c=0;c<a.length;c++)if(b[a[c]]){l.fullscreen=!0,l.requestFullscreen=a[c];break}var d=["cancelFullScreen","exitFullscreen","webkitCancelFullScreen","webkitExitFullscreen","msCancelFullScreen","msExitFullscreen","mozCancelFullScreen","mozExitFullscreen"];if(l.fullscreen)for(var c=0;c<d.length;c++)if(document[d[c]]){l.cancelFullscreen=d[c];break}window.Element&&Element.ALLOW_KEYBOARD_INPUT&&(l.fullscreenKeyboard=!0)}function e(){var a=navigator.userAgent;if(/Arora/.test(a)?l.arora=!0:/Chrome\/(\d+)/.test(a)&&!l.windowsPhone?(l.chrome=!0,l.chromeVersion=parseInt(RegExp.$1,10)):/Epiphany/.test(a)?l.epiphany=!0:/Firefox\D+(\d+)/.test(a)?(l.firefox=!0,l.firefoxVersion=parseInt(RegExp.$1,10)):/AppleWebKit/.test(a)&&l.iOS?l.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(a)?(l.ie=!0,l.ieVersion=parseInt(RegExp.$1,10)):/Midori/.test(a)?l.midori=!0:/Opera/.test(a)?l.opera=!0:/Safari/.test(a)&&!l.windowsPhone?l.safari=!0:/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(a)&&(l.ie=!0,l.trident=!0,l.tridentVersion=parseInt(RegExp.$1,10),l.ieVersion=parseInt(RegExp.$3,10)),/Silk/.test(a)&&(l.silk=!0),navigator.standalone&&(l.webApp=!0),"undefined"!=typeof window.cordova&&(l.cordova=!0),"undefined"!=typeof process&&"undefined"!=typeof require&&(l.node=!0),l.node&&"object"==typeof process.versions&&(l.nodeWebkit=!!process.versions["node-webkit"],l.electron=!!process.versions.electron),navigator.isCocoonJS&&(l.cocoonJS=!0),l.cocoonJS)try{l.cocoonJSApp="undefined"!=typeof CocoonJS}catch(b){l.cocoonJSApp=!1}"undefined"!=typeof window.ejecta&&(l.ejecta=!0),/Crosswalk/.test(a)&&(l.crosswalk=!0)}function f(){var a=document.createElement("video"),b=!1;try{(b=!!a.canPlayType)&&(a.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,"")&&(l.oggVideo=!0),a.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,"")&&(l.h264Video=!0,l.mp4Video=!0),a.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")&&(l.webmVideo=!0),a.canPlayType('video/webm; codecs="vp9"').replace(/^no$/,"")&&(l.vp9Video=!0),a.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(/^no$/,"")&&(l.hlsVideo=!0))}catch(c){}}function g(){l.audioData=!!window.Audio,l.webAudio=!(!window.AudioContext&&!window.webkitAudioContext);var a=document.createElement("audio"),b=!1;try{(b=!!a.canPlayType)&&(a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(l.ogg=!0),(a.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,"")||a.canPlayType("audio/opus;").replace(/^no$/,""))&&(l.opus=!0),a.canPlayType("audio/mpeg;").replace(/^no$/,"")&&(l.mp3=!0),a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,"")&&(l.wav=!0),(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;").replace(/^no$/,""))&&(l.m4a=!0),a.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")&&(l.webm=!0))}catch(c){}}function h(){l.pixelRatio=window.devicePixelRatio||1,l.iPhone=-1!=navigator.userAgent.toLowerCase().indexOf("iphone"),l.iPhone4=2==l.pixelRatio&&l.iPhone,l.iPad=-1!=navigator.userAgent.toLowerCase().indexOf("ipad"),"undefined"!=typeof Int8Array?l.typedArray=!0:l.typedArray=!1,"undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint32Array&&(l.littleEndian=i(),l.LITTLE_ENDIAN=l.littleEndian),l.support32bit="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof Int32Array&&null!==l.littleEndian&&j(),navigator.vibrate=navigator.vibrate||navigator.webkitVibrate||navigator.mozVibrate||navigator.msVibrate,navigator.vibrate&&(l.vibration=!0)}function i(){var a=new ArrayBuffer(4),b=new Uint8Array(a),c=new Uint32Array(a);return b[0]=161,b[1]=178,b[2]=195,b[3]=212,3569595041==c[0]?!0:2712847316==c[0]?!1:null}function j(){if(void 0===Uint8ClampedArray)return!1;var a=PIXI.CanvasPool.create(this,1,1),b=a.getContext("2d");if(!b)return!1;var c=b.createImageData(1,1);return PIXI.CanvasPool.remove(this),c.data instanceof Uint8ClampedArray}function k(){var a,b=document.createElement("p"),c={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"};document.body.insertBefore(b,null);for(var d in c)void 0!==b.style[d]&&(b.style[d]="translate3d(1px,1px,1px)",a=window.getComputedStyle(b).getPropertyValue(c[d]));document.body.removeChild(b),l.css3D=void 0!==a&&a.length>0&&"none"!==a}var l=this;a(),g(),f(),e(),k(),h(),b(),d(),c()},c.Device.canPlayAudio=function(a){return"mp3"===a&&this.mp3?!0:"ogg"===a&&(this.ogg||this.opus)?!0:"m4a"===a&&this.m4a?!0:"opus"===a&&this.opus?!0:"wav"===a&&this.wav?!0:"webm"===a&&this.webm?!0:!1},c.Device.canPlayVideo=function(a){return"webm"===a&&(this.webmVideo||this.vp9Video)?!0:"mp4"===a&&(this.mp4Video||this.h264Video)?!0:"ogg"!==a&&"ogv"!==a||!this.oggVideo?"mpeg"===a&&this.hlsVideo?!0:!1:!0},c.Device.isConsoleOpen=function(){return window.console&&window.console.firebug?!0:window.console&&(console.profile(),console.profileEnd(),console.clear&&console.clear(),console.profiles)?console.profiles.length>0:!1},c.Device.isAndroidStockBrowser=function(){var a=window.navigator.userAgent.match(/Android.*AppleWebKit\/([\d.]+)/);return a&&a[1]<537},c.Canvas={create:function(a,b,c,d,e){if(b=b||256,c=c||256,void 0===e)var f=PIXI.CanvasPool.create(a,b,c);else var f=document.createElement("canvas");return"string"==typeof d&&""!==d&&(f.id=d),f.width=b,f.height=c,f.style.display="block",f},setBackgroundColor:function(a,b){return b=b||"rgb(0,0,0)",a.style.backgroundColor=b,a},setTouchAction:function(a,b){return b=b||"none",a.style.msTouchAction=b,a.style["ms-touch-action"]=b,a.style["touch-action"]=b,a},setUserSelect:function(a,b){return b=b||"none",a.style["-webkit-touch-callout"]=b,a.style["-webkit-user-select"]=b,a.style["-khtml-user-select"]=b,a.style["-moz-user-select"]=b,a.style["-ms-user-select"]=b,a.style["user-select"]=b,a.style["-webkit-tap-highlight-color"]="rgba(0, 0, 0, 0)",a},addToDOM:function(a,b,c){var d;return void 0===c&&(c=!0),b&&("string"==typeof b?d=document.getElementById(b):"object"==typeof b&&1===b.nodeType&&(d=b)),d||(d=document.body),c&&d.style&&(d.style.overflow="hidden"),d.appendChild(a),a},removeFromDOM:function(a){a.parentNode&&a.parentNode.removeChild(a)},setTransform:function(a,b,c,d,e,f,g){return a.setTransform(d,f,g,e,b,c),a},setSmoothingEnabled:function(a,b){var d=c.Canvas.getSmoothingPrefix(a);return d&&(a[d]=b),a},getSmoothingPrefix:function(a){var b=["i","webkitI","msI","mozI","oI"];for(var c in b){var d=b[c]+"mageSmoothingEnabled";if(d in a)return d}return null},getSmoothingEnabled:function(a){var b=c.Canvas.getSmoothingPrefix(a);return b?a[b]:void 0},setImageRenderingCrisp:function(a){for(var b=["optimizeSpeed","crisp-edges","-moz-crisp-edges","-webkit-optimize-contrast","optimize-contrast","pixelated"],c=0;c<b.length;c++)a.style["image-rendering"]=b[c];return a.style.msInterpolationMode="nearest-neighbor",a},setImageRenderingBicubic:function(a){return a.style["image-rendering"]="auto",a.style.msInterpolationMode="bicubic",a}},c.RequestAnimationFrame=function(a,b){void 0===b&&(b=!1),this.game=a,this.isRunning=!1,this.forceSetTimeOut=b;for(var c=["ms","moz","webkit","o"],d=0;d<c.length&&!window.requestAnimationFrame;d++)window.requestAnimationFrame=window[c[d]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[c[d]+"CancelAnimationFrame"];this._isSetTimeOut=!1,this._onLoop=null,this._timeOutID=null},c.RequestAnimationFrame.prototype={start:function(){this.isRunning=!0;var a=this;!window.requestAnimationFrame||this.forceSetTimeOut?(this._isSetTimeOut=!0,this._onLoop=function(){return a.updateSetTimeout()},this._timeOutID=window.setTimeout(this._onLoop,0)):(this._isSetTimeOut=!1,this._onLoop=function(b){return a.updateRAF(b)},this._timeOutID=window.requestAnimationFrame(this._onLoop))},updateRAF:function(a){this.game.update(Math.floor(a)),this._timeOutID=window.requestAnimationFrame(this._onLoop)},updateSetTimeout:function(){this.game.update(Date.now()),this._timeOutID=window.setTimeout(this._onLoop,this.game.time.timeToCall)},stop:function(){this._isSetTimeOut?clearTimeout(this._timeOutID):window.cancelAnimationFrame(this._timeOutID),this.isRunning=!1},isSetTimeOut:function(){return this._isSetTimeOut},isRAF:function(){return this._isSetTimeOut===!1}},c.RequestAnimationFrame.prototype.constructor=c.RequestAnimationFrame,c.Math={PI2:2*Math.PI,fuzzyEqual:function(a,b,c){return void 0===c&&(c=1e-4),Math.abs(a-b)<c},fuzzyLessThan:function(a,b,c){return void 0===c&&(c=1e-4),b+c>a},fuzzyGreaterThan:function(a,b,c){return void 0===c&&(c=1e-4),a>b-c},fuzzyCeil:function(a,b){return void 0===b&&(b=1e-4),Math.ceil(a-b)},fuzzyFloor:function(a,b){return void 0===b&&(b=1e-4),Math.floor(a+b)},average:function(){for(var a=0,b=arguments.length,c=0;b>c;c++)a+=+arguments[c];return a/b},shear:function(a){return a%1},snapTo:function(a,b,c){return void 0===c&&(c=0),0===b?a:(a-=c,a=b*Math.round(a/b),c+a)},snapToFloor:function(a,b,c){return void 0===c&&(c=0),0===b?a:(a-=c,a=b*Math.floor(a/b),c+a)},snapToCeil:function(a,b,c){return void 0===c&&(c=0),0===b?a:(a-=c,a=b*Math.ceil(a/b),c+a)},roundTo:function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=10);var d=Math.pow(c,-b);return Math.round(a*d)/d},floorTo:function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=10);var d=Math.pow(c,-b);return Math.floor(a*d)/d},ceilTo:function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=10);var d=Math.pow(c,-b);return Math.ceil(a*d)/d},angleBetween:function(a,b,c,d){return Math.atan2(d-b,c-a)},angleBetweenY:function(a,b,c,d){return Math.atan2(c-a,d-b)},angleBetweenPoints:function(a,b){return Math.atan2(b.y-a.y,b.x-a.x)},angleBetweenPointsY:function(a,b){return Math.atan2(b.x-a.x,b.y-a.y)},reverseAngle:function(a){return this.normalizeAngle(a+Math.PI,!0)},normalizeAngle:function(a){return a%=2*Math.PI,a>=0?a:a+2*Math.PI},maxAdd:function(a,b,c){return Math.min(a+b,c)},minSub:function(a,b,c){return Math.max(a-b,c)},wrap:function(a,b,c){var d=c-b;if(0>=d)return 0;var e=(a-b)%d;return 0>e&&(e+=d),e+b},wrapValue:function(a,b,c){var d;return a=Math.abs(a),b=Math.abs(b),c=Math.abs(c),d=(a+b)%c},isOdd:function(a){return!!(1&a)},isEven:function(a){return!(1&a)},min:function(){if(1===arguments.length&&"object"==typeof arguments[0])var a=arguments[0];else var a=arguments;for(var b=1,c=0,d=a.length;d>b;b++)a[b]<a[c]&&(c=b);return a[c]},max:function(){if(1===arguments.length&&"object"==typeof arguments[0])var a=arguments[0];else var a=arguments;for(var b=1,c=0,d=a.length;d>b;b++)a[b]>a[c]&&(c=b);return a[c]},minProperty:function(a){if(2===arguments.length&&"object"==typeof arguments[1])var b=arguments[1];else var b=arguments.slice(1);for(var c=1,d=0,e=b.length;e>c;c++)b[c][a]<b[d][a]&&(d=c);return b[d][a]},maxProperty:function(a){if(2===arguments.length&&"object"==typeof arguments[1])var b=arguments[1];else var b=arguments.slice(1);for(var c=1,d=0,e=b.length;e>c;c++)b[c][a]>b[d][a]&&(d=c);return b[d][a]},wrapAngle:function(a,b){return b?this.wrap(a,-Math.PI,Math.PI):this.wrap(a,-180,180)},linearInterpolation:function(a,b){var c=a.length-1,d=c*b,e=Math.floor(d);return 0>b?this.linear(a[0],a[1],d):b>1?this.linear(a[c],a[c-1],c-d):this.linear(a[e],a[e+1>c?c:e+1],d-e)},bezierInterpolation:function(a,b){for(var c=0,d=a.length-1,e=0;d>=e;e++)c+=Math.pow(1-b,d-e)*Math.pow(b,e)*a[e]*this.bernstein(d,e);return c},catmullRomInterpolation:function(a,b){var c=a.length-1,d=c*b,e=Math.floor(d);return a[0]===a[c]?(0>b&&(e=Math.floor(d=c*(1+b))),this.catmullRom(a[(e-1+c)%c],a[e],a[(e+1)%c],a[(e+2)%c],d-e)):0>b?a[0]-(this.catmullRom(a[0],a[0],a[1],a[1],-d)-a[0]):b>1?a[c]-(this.catmullRom(a[c],a[c],a[c-1],a[c-1],d-c)-a[c]):this.catmullRom(a[e?e-1:0],a[e],a[e+1>c?c:e+1],a[e+2>c?c:e+2],d-e)},linear:function(a,b,c){return(b-a)*c+a},bernstein:function(a,b){return this.factorial(a)/this.factorial(b)/this.factorial(a-b)},factorial:function(a){if(0===a)return 1;for(var b=a;--a;)b*=a;return b},catmullRom:function(a,b,c,d,e){var f=.5*(c-a),g=.5*(d-b),h=e*e,i=e*h;return(2*b-2*c+f+g)*i+(-3*b+3*c-2*f-g)*h+f*e+b},difference:function(a,b){return Math.abs(a-b)},roundAwayFromZero:function(a){return a>0?Math.ceil(a):Math.floor(a)},sinCosGenerator:function(a,b,c,d){void 0===b&&(b=1),void 0===c&&(c=1),void 0===d&&(d=1);for(var e=b,f=c,g=d*Math.PI/a,h=[],i=[],j=0;a>j;j++)f-=e*g,e+=f*g,h[j]=f,i[j]=e;return{sin:i,cos:h,length:a}},distance:function(a,b,c,d){var e=a-c,f=b-d;return Math.sqrt(e*e+f*f)},distanceSq:function(a,b,c,d){var e=a-c,f=b-d;return e*e+f*f},distancePow:function(a,b,c,d,e){return void 0===e&&(e=2),Math.sqrt(Math.pow(c-a,e)+Math.pow(d-b,e))},clamp:function(a,b,c){return b>a?b:a>c?c:a},clampBottom:function(a,b){return b>a?b:a},within:function(a,b,c){return Math.abs(a-b)<=c},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},smoothstep:function(a,b,c){return a=Math.max(0,Math.min(1,(a-b)/(c-b))),a*a*(3-2*a)},smootherstep:function(a,b,c){return a=Math.max(0,Math.min(1,(a-b)/(c-b))),a*a*a*(a*(6*a-15)+10)},sign:function(a){return 0>a?-1:a>0?1:0},percent:function(a,b,c){return void 0===c&&(c=0),a>b||c>b?1:c>a||c>a?0:(a-c)/b}};var k=Math.PI/180,l=180/Math.PI;return c.Math.degToRad=function(a){return a*k},c.Math.radToDeg=function(a){return a*l},c.RandomDataGenerator=function(a){void 0===a&&(a=[]),this.c=1,this.s0=0,this.s1=0,this.s2=0,"string"==typeof a?this.state(a):this.sow(a)},c.RandomDataGenerator.prototype={rnd:function(){var a=2091639*this.s0+2.3283064365386963e-10*this.c;return this.c=0|a,this.s0=this.s1,this.s1=this.s2,this.s2=a-this.c,this.s2},sow:function(a){if(this.s0=this.hash(" "),this.s1=this.hash(this.s0),this.s2=this.hash(this.s1),this.c=1,a)for(var b=0;b<a.length&&null!=a[b];b++){var c=a[b];this.s0-=this.hash(c),this.s0+=~~(this.s0<0),this.s1-=this.hash(c),this.s1+=~~(this.s1<0),this.s2-=this.hash(c),this.s2+=~~(this.s2<0)}},hash:function(a){var b,c,d;for(d=4022871197,a=a.toString(),c=0;c<a.length;c++)d+=a.charCodeAt(c),b=.02519603282416938*d,d=b>>>0,b-=d,b*=d,d=b>>>0,b-=d,d+=4294967296*b;return 2.3283064365386963e-10*(d>>>0)},integer:function(){return 4294967296*this.rnd.apply(this)},frac:function(){return this.rnd.apply(this)+1.1102230246251565e-16*(2097152*this.rnd.apply(this)|0)},real:function(){return this.integer()+this.frac()},integerInRange:function(a,b){return Math.floor(this.realInRange(0,b-a+1)+a)},between:function(a,b){return this.integerInRange(a,b)},realInRange:function(a,b){return this.frac()*(b-a)+a},normal:function(){return 1-2*this.frac()},uuid:function(){var a="",b="";for(b=a="";a++<36;b+=~a%5|3*a&4?(15^a?8^this.frac()*(20^a?16:4):4).toString(16):"-");return b},pick:function(a){return a[this.integerInRange(0,a.length-1)]},weightedPick:function(a){return a[~~(Math.pow(this.frac(),2)*(a.length-1)+.5)]},timestamp:function(a,b){return this.realInRange(a||9466848e5,b||1577862e6)},angle:function(){return this.integerInRange(-180,180)},state:function(a){return"string"==typeof a&&a.match(/^!rnd/)&&(a=a.split(","),this.c=parseFloat(a[1]),this.s0=parseFloat(a[2]),this.s1=parseFloat(a[3]),this.s2=parseFloat(a[4])),["!rnd",this.c,this.s0,this.s1,this.s2].join(",")}},c.RandomDataGenerator.prototype.constructor=c.RandomDataGenerator,c.QuadTree=function(a,b,c,d,e,f,g){this.maxObjects=10,this.maxLevels=4,this.level=0,this.bounds={},this.objects=[],this.nodes=[],this._empty=[],this.reset(a,b,c,d,e,f,g)},c.QuadTree.prototype={reset:function(a,b,c,d,e,f,g){this.maxObjects=e||10,this.maxLevels=f||4,this.level=g||0,this.bounds={x:Math.round(a),y:Math.round(b),width:c,height:d,subWidth:Math.floor(c/2),subHeight:Math.floor(d/2),right:Math.round(a)+Math.floor(c/2),bottom:Math.round(b)+Math.floor(d/2)},this.objects.length=0,this.nodes.length=0},populate:function(a){a.forEach(this.populateHandler,this,!0)},populateHandler:function(a){a.body&&a.exists&&this.insert(a.body)},split:function(){this.nodes[0]=new c.QuadTree(this.bounds.right,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[1]=new c.QuadTree(this.bounds.x,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[2]=new c.QuadTree(this.bounds.x,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[3]=new c.QuadTree(this.bounds.right,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1)},insert:function(a){var b,c=0;if(null!=this.nodes[0]&&(b=this.getIndex(a),-1!==b))return void this.nodes[b].insert(a);if(this.objects.push(a),this.objects.length>this.maxObjects&&this.level<this.maxLevels)for(null==this.nodes[0]&&this.split();c<this.objects.length;)b=this.getIndex(this.objects[c]),-1!==b?this.nodes[b].insert(this.objects.splice(c,1)[0]):c++},getIndex:function(a){var b=-1;return a.x<this.bounds.right&&a.right<this.bounds.right?a.y<this.bounds.bottom&&a.bottom<this.bounds.bottom?b=1:a.y>this.bounds.bottom&&(b=2):a.x>this.bounds.right&&(a.y<this.bounds.bottom&&a.bottom<this.bounds.bottom?b=0:a.y>this.bounds.bottom&&(b=3)),b},retrieve:function(a){if(a instanceof c.Rectangle)var b=this.objects,d=this.getIndex(a);else{if(!a.body)return this._empty;var b=this.objects,d=this.getIndex(a.body)}return this.nodes[0]&&(-1!==d?b=b.concat(this.nodes[d].retrieve(a)):(b=b.concat(this.nodes[0].retrieve(a)),b=b.concat(this.nodes[1].retrieve(a)),b=b.concat(this.nodes[2].retrieve(a)),b=b.concat(this.nodes[3].retrieve(a)))),b},clear:function(){this.objects.length=0;for(var a=this.nodes.length;a--;)this.nodes[a].clear(),this.nodes.splice(a,1);this.nodes.length=0}},c.QuadTree.prototype.constructor=c.QuadTree,c.Net=function(a){this.game=a},c.Net.prototype={getHostName:function(){return window.location&&window.location.hostname?window.location.hostname:null},checkDomainName:function(a){return-1!==window.location.hostname.indexOf(a)},updateQueryString:function(a,b,c,d){void 0===c&&(c=!1),(void 0===d||""===d)&&(d=window.location.href);var e="",f=new RegExp("([?|&])"+a+"=.*?(&|#|$)(.*)","gi");if(f.test(d))e="undefined"!=typeof b&&null!==b?d.replace(f,"$1"+a+"="+b+"$2$3"):d.replace(f,"$1$3").replace(/(&|\?)$/,"");else if("undefined"!=typeof b&&null!==b){var g=-1!==d.indexOf("?")?"&":"?",h=d.split("#");d=h[0]+g+a+"="+b,h[1]&&(d+="#"+h[1]),e=d}else e=d;return c?void(window.location.href=e):e},getQueryString:function(a){void 0===a&&(a="");var b={},c=location.search.substring(1).split("&");for(var d in c){var e=c[d].split("=");if(e.length>1){if(a&&a==this.decodeURI(e[0]))return this.decodeURI(e[1]);b[this.decodeURI(e[0])]=this.decodeURI(e[1])}}return b},decodeURI:function(a){return decodeURIComponent(a.replace(/\+/g," "))}},c.Net.prototype.constructor=c.Net,c.TweenManager=function(a){this.game=a,this.frameBased=!1,this._tweens=[],this._add=[],this.easeMap={Power0:c.Easing.Power0,Power1:c.Easing.Power1,Power2:c.Easing.Power2,Power3:c.Easing.Power3,Power4:c.Easing.Power4,Linear:c.Easing.Linear.None,Quad:c.Easing.Quadratic.Out,Cubic:c.Easing.Cubic.Out,Quart:c.Easing.Quartic.Out,Quint:c.Easing.Quintic.Out,Sine:c.Easing.Sinusoidal.Out,Expo:c.Easing.Exponential.Out,Circ:c.Easing.Circular.Out,Elastic:c.Easing.Elastic.Out,Back:c.Easing.Back.Out,Bounce:c.Easing.Bounce.Out,"Quad.easeIn":c.Easing.Quadratic.In,"Cubic.easeIn":c.Easing.Cubic.In,"Quart.easeIn":c.Easing.Quartic.In,"Quint.easeIn":c.Easing.Quintic.In,"Sine.easeIn":c.Easing.Sinusoidal.In,"Expo.easeIn":c.Easing.Exponential.In,"Circ.easeIn":c.Easing.Circular.In,"Elastic.easeIn":c.Easing.Elastic.In,"Back.easeIn":c.Easing.Back.In,"Bounce.easeIn":c.Easing.Bounce.In,"Quad.easeOut":c.Easing.Quadratic.Out,"Cubic.easeOut":c.Easing.Cubic.Out,"Quart.easeOut":c.Easing.Quartic.Out,"Quint.easeOut":c.Easing.Quintic.Out,"Sine.easeOut":c.Easing.Sinusoidal.Out,"Expo.easeOut":c.Easing.Exponential.Out,"Circ.easeOut":c.Easing.Circular.Out,"Elastic.easeOut":c.Easing.Elastic.Out,"Back.easeOut":c.Easing.Back.Out,"Bounce.easeOut":c.Easing.Bounce.Out,"Quad.easeInOut":c.Easing.Quadratic.InOut,"Cubic.easeInOut":c.Easing.Cubic.InOut,"Quart.easeInOut":c.Easing.Quartic.InOut,"Quint.easeInOut":c.Easing.Quintic.InOut,"Sine.easeInOut":c.Easing.Sinusoidal.InOut,"Expo.easeInOut":c.Easing.Exponential.InOut,"Circ.easeInOut":c.Easing.Circular.InOut,"Elastic.easeInOut":c.Easing.Elastic.InOut,"Back.easeInOut":c.Easing.Back.InOut,"Bounce.easeInOut":c.Easing.Bounce.InOut},this.game.onPause.add(this._pauseAll,this),this.game.onResume.add(this._resumeAll,this)},c.TweenManager.prototype={getAll:function(){return this._tweens},removeAll:function(){for(var a=0;a<this._tweens.length;a++)this._tweens[a].pendingDelete=!0;this._add=[]},removeFrom:function(a,b){void 0===b&&(b=!0);var d,e;if(Array.isArray(a))for(d=0,e=a.length;e>d;d++)this.removeFrom(a[d]);else if(a.type===c.GROUP&&b)for(var d=0,e=a.children.length;e>d;d++)this.removeFrom(a.children[d]);else{for(d=0,e=this._tweens.length;e>d;d++)a===this._tweens[d].target&&this.remove(this._tweens[d]);for(d=0,e=this._add.length;e>d;d++)a===this._add[d].target&&this.remove(this._add[d])}},add:function(a){a._manager=this,this._add.push(a)},create:function(a){return new c.Tween(a,this.game,this)},remove:function(a){var b=this._tweens.indexOf(a);-1!==b?this._tweens[b].pendingDelete=!0:(b=this._add.indexOf(a),-1!==b&&(this._add[b].pendingDelete=!0))},update:function(){var a=this._add.length,b=this._tweens.length;if(0===b&&0===a)return!1;for(var c=0;b>c;)this._tweens[c].update(this.game.time.time)?c++:(this._tweens.splice(c,1),b--);return a>0&&(this._tweens=this._tweens.concat(this._add),this._add.length=0),!0},isTweening:function(a){return this._tweens.some(function(b){return b.target===a})},_pauseAll:function(){for(var a=this._tweens.length-1;a>=0;a--)this._tweens[a]._pause()},_resumeAll:function(){for(var a=this._tweens.length-1;a>=0;a--)this._tweens[a]._resume()},pauseAll:function(){for(var a=this._tweens.length-1;a>=0;a--)this._tweens[a].pause()},resumeAll:function(){for(var a=this._tweens.length-1;a>=0;a--)this._tweens[a].resume(!0)}},c.TweenManager.prototype.constructor=c.TweenManager,c.Tween=function(a,b,d){this.game=b,this.target=a,this.manager=d,this.timeline=[],this.reverse=!1,this.timeScale=1,this.repeatCounter=0,this.pendingDelete=!1,this.onStart=new c.Signal,this.onLoop=new c.Signal,this.onRepeat=new c.Signal,this.onChildComplete=new c.Signal,this.onComplete=new c.Signal,this.isRunning=!1,this.current=0,this.properties={},this.chainedTween=null,this.isPaused=!1,this.frameBased=d.frameBased,this._onUpdateCallback=null,this._onUpdateCallbackContext=null,this._pausedTime=0,this._codePaused=!1,this._hasStarted=!1},c.Tween.prototype={to:function(a,b,d,e,f,g,h){return(void 0===b||0>=b)&&(b=1e3),(void 0===d||null===d)&&(d=c.Easing.Default),void 0===e&&(e=!1),void 0===f&&(f=0),void 0===g&&(g=0),void 0===h&&(h=!1),"string"==typeof d&&this.manager.easeMap[d]&&(d=this.manager.easeMap[d]),this.isRunning?(console.warn("Phaser.Tween.to cannot be called after Tween.start"),this):(this.timeline.push(new c.TweenData(this).to(a,b,d,f,g,h)),e&&this.start(),this)},from:function(a,b,d,e,f,g,h){return void 0===b&&(b=1e3),(void 0===d||null===d)&&(d=c.Easing.Default),void 0===e&&(e=!1),void 0===f&&(f=0),void 0===g&&(g=0),void 0===h&&(h=!1),"string"==typeof d&&this.manager.easeMap[d]&&(d=this.manager.easeMap[d]),this.isRunning?(console.warn("Phaser.Tween.from cannot be called after Tween.start"),this):(this.timeline.push(new c.TweenData(this).from(a,b,d,f,g,h)),e&&this.start(),this)},start:function(a){if(void 0===a&&(a=0),null===this.game||null===this.target||0===this.timeline.length||this.isRunning)return this;for(var b=0;b<this.timeline.length;b++)for(var c in this.timeline[b].vEnd)this.properties[c]=this.target[c]||0,Array.isArray(this.properties[c])||(this.properties[c]*=1);for(var b=0;b<this.timeline.length;b++)this.timeline[b].loadValues();return this.manager.add(this),this.isRunning=!0,(0>a||a>this.timeline.length-1)&&(a=0),this.current=a,this.timeline[this.current].start(),this},stop:function(a){return void 0===a&&(a=!1),this.isRunning=!1,this._onUpdateCallback=null,this._onUpdateCallbackContext=null,a&&(this.onComplete.dispatch(this.target,this),this.chainedTween&&this.chainedTween.start()),this.manager.remove(this),this},updateTweenData:function(a,b,c){if(0===this.timeline.length)return this;if(void 0===c&&(c=0),-1===c)for(var d=0;d<this.timeline.length;d++)this.timeline[d][a]=b;else this.timeline[c][a]=b;return this},delay:function(a,b){return this.updateTweenData("delay",a,b)},repeat:function(a,b,c){return void 0===b&&(b=0),this.updateTweenData("repeatCounter",a,c),this.updateTweenData("repeatDelay",b,c)},repeatDelay:function(a,b){return this.updateTweenData("repeatDelay",a,b)},yoyo:function(a,b,c){return void 0===b&&(b=0),this.updateTweenData("yoyo",a,c),this.updateTweenData("yoyoDelay",b,c)},yoyoDelay:function(a,b){return this.updateTweenData("yoyoDelay",a,b)},easing:function(a,b){return"string"==typeof a&&this.manager.easeMap[a]&&(a=this.manager.easeMap[a]), +this.updateTweenData("easingFunction",a,b)},interpolation:function(a,b,d){return void 0===b&&(b=c.Math),this.updateTweenData("interpolationFunction",a,d),this.updateTweenData("interpolationContext",b,d)},repeatAll:function(a){return void 0===a&&(a=0),this.repeatCounter=a,this},chain:function(){for(var a=arguments.length;a--;)a>0?arguments[a-1].chainedTween=arguments[a]:this.chainedTween=arguments[a];return this},loop:function(a){return void 0===a&&(a=!0),a?this.repeatAll(-1):this.repeatCounter=0,this},onUpdateCallback:function(a,b){return this._onUpdateCallback=a,this._onUpdateCallbackContext=b,this},pause:function(){this.isPaused=!0,this._codePaused=!0,this._pausedTime=this.game.time.time},_pause:function(){this._codePaused||(this.isPaused=!0,this._pausedTime=this.game.time.time)},resume:function(){if(this.isPaused){this.isPaused=!1,this._codePaused=!1;for(var a=0;a<this.timeline.length;a++)this.timeline[a].isRunning||(this.timeline[a].startTime+=this.game.time.time-this._pausedTime)}},_resume:function(){this._codePaused||this.resume()},update:function(a){if(this.pendingDelete)return!1;if(this.isPaused)return!0;var b=this.timeline[this.current].update(a);if(b===c.TweenData.PENDING)return!0;if(b===c.TweenData.RUNNING)return this._hasStarted||(this.onStart.dispatch(this.target,this),this._hasStarted=!0),null!==this._onUpdateCallback&&this._onUpdateCallback.call(this._onUpdateCallbackContext,this,this.timeline[this.current].value,this.timeline[this.current]),this.isRunning;if(b===c.TweenData.LOOPED)return this.onLoop.dispatch(this.target,this),!0;if(b===c.TweenData.COMPLETE){var d=!1;return this.reverse?(this.current--,this.current<0&&(this.current=this.timeline.length-1,d=!0)):(this.current++,this.current===this.timeline.length&&(this.current=0,d=!0)),d?-1===this.repeatCounter?(this.timeline[this.current].start(),this.onRepeat.dispatch(this.target,this),!0):this.repeatCounter>0?(this.repeatCounter--,this.timeline[this.current].start(),this.onRepeat.dispatch(this.target,this),!0):(this.isRunning=!1,this.onComplete.dispatch(this.target,this),this.chainedTween&&this.chainedTween.start(),!1):(this.onChildComplete.dispatch(this.target,this),this.timeline[this.current].start(),!0)}},generateData:function(a,b){if(null===this.game||null===this.target)return null;void 0===a&&(a=60),void 0===b&&(b=[]);for(var c=0;c<this.timeline.length;c++)for(var d in this.timeline[c].vEnd)this.properties[d]=this.target[d]||0,Array.isArray(this.properties[d])||(this.properties[d]*=1);for(var c=0;c<this.timeline.length;c++)this.timeline[c].loadValues();for(var c=0;c<this.timeline.length;c++)b=b.concat(this.timeline[c].generateData(a));return b}},Object.defineProperty(c.Tween.prototype,"totalDuration",{get:function(){for(var a=0,b=0;b<this.timeline.length;b++)a+=this.timeline[b].duration;return a}}),c.Tween.prototype.constructor=c.Tween,c.TweenData=function(a){this.parent=a,this.game=a.game,this.vStart={},this.vStartCache={},this.vEnd={},this.vEndCache={},this.duration=1e3,this.percent=0,this.value=0,this.repeatCounter=0,this.repeatDelay=0,this.interpolate=!1,this.yoyo=!1,this.yoyoDelay=0,this.inReverse=!1,this.delay=0,this.dt=0,this.startTime=null,this.easingFunction=c.Easing.Default,this.interpolationFunction=c.Math.linearInterpolation,this.interpolationContext=c.Math,this.isRunning=!1,this.isFrom=!1},c.TweenData.PENDING=0,c.TweenData.RUNNING=1,c.TweenData.LOOPED=2,c.TweenData.COMPLETE=3,c.TweenData.prototype={to:function(a,b,c,d,e,f){return this.vEnd=a,this.duration=b,this.easingFunction=c,this.delay=d,this.repeatCounter=e,this.yoyo=f,this.isFrom=!1,this},from:function(a,b,c,d,e,f){return this.vEnd=a,this.duration=b,this.easingFunction=c,this.delay=d,this.repeatCounter=e,this.yoyo=f,this.isFrom=!0,this},start:function(){if(this.startTime=this.game.time.time+this.delay,this.parent.reverse?this.dt=this.duration:this.dt=0,this.delay>0?this.isRunning=!1:this.isRunning=!0,this.isFrom)for(var a in this.vStartCache)this.vStart[a]=this.vEndCache[a],this.vEnd[a]=this.vStartCache[a],this.parent.target[a]=this.vStart[a];return this.value=0,this.yoyoCounter=0,this},loadValues:function(){for(var a in this.parent.properties){if(this.vStart[a]=this.parent.properties[a],Array.isArray(this.vEnd[a])){if(0===this.vEnd[a].length)continue;0===this.percent&&(this.vEnd[a]=[this.vStart[a]].concat(this.vEnd[a]))}"undefined"!=typeof this.vEnd[a]?("string"==typeof this.vEnd[a]&&(this.vEnd[a]=this.vStart[a]+parseFloat(this.vEnd[a],10)),this.parent.properties[a]=this.vEnd[a]):this.vEnd[a]=this.vStart[a],this.vStartCache[a]=this.vStart[a],this.vEndCache[a]=this.vEnd[a]}return this},update:function(a){if(this.isRunning){if(a<this.startTime)return c.TweenData.RUNNING}else{if(!(a>=this.startTime))return c.TweenData.PENDING;this.isRunning=!0}var b=this.parent.frameBased?this.game.time.physicsElapsedMS:this.game.time.elapsedMS;this.parent.reverse?(this.dt-=b*this.parent.timeScale,this.dt=Math.max(this.dt,0)):(this.dt+=b*this.parent.timeScale,this.dt=Math.min(this.dt,this.duration)),this.percent=this.dt/this.duration,this.value=this.easingFunction(this.percent);for(var d in this.vEnd){var e=this.vStart[d],f=this.vEnd[d];Array.isArray(f)?this.parent.target[d]=this.interpolationFunction.call(this.interpolationContext,f,this.value):this.parent.target[d]=e+(f-e)*this.value}return!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent?this.repeat():c.TweenData.RUNNING},generateData:function(a){this.parent.reverse?this.dt=this.duration:this.dt=0;var b=[],c=!1,d=1/a*1e3;do{this.parent.reverse?(this.dt-=d,this.dt=Math.max(this.dt,0)):(this.dt+=d,this.dt=Math.min(this.dt,this.duration)),this.percent=this.dt/this.duration,this.value=this.easingFunction(this.percent);var e={};for(var f in this.vEnd){var g=this.vStart[f],h=this.vEnd[f];Array.isArray(h)?e[f]=this.interpolationFunction(h,this.value):e[f]=g+(h-g)*this.value}b.push(e),(!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent)&&(c=!0)}while(!c);if(this.yoyo){var i=b.slice();i.reverse(),b=b.concat(i)}return b},repeat:function(){if(this.yoyo){if(this.inReverse&&0===this.repeatCounter)return c.TweenData.COMPLETE;this.inReverse=!this.inReverse}else if(0===this.repeatCounter)return c.TweenData.COMPLETE;if(this.inReverse)for(var a in this.vStartCache)this.vStart[a]=this.vEndCache[a],this.vEnd[a]=this.vStartCache[a];else{for(var a in this.vStartCache)this.vStart[a]=this.vStartCache[a],this.vEnd[a]=this.vEndCache[a];this.repeatCounter>0&&this.repeatCounter--}return this.startTime=this.game.time.time,this.yoyo&&this.inReverse?this.startTime+=this.yoyoDelay:this.inReverse||(this.startTime+=this.repeatDelay),this.parent.reverse?this.dt=this.duration:this.dt=0,c.TweenData.LOOPED}},c.TweenData.prototype.constructor=c.TweenData,c.Easing={Linear:{None:function(a){return a}},Quadratic:{In:function(a){return a*a},Out:function(a){return a*(2-a)},InOut:function(a){return(a*=2)<1?.5*a*a:-.5*(--a*(a-2)-1)}},Cubic:{In:function(a){return a*a*a},Out:function(a){return--a*a*a+1},InOut:function(a){return(a*=2)<1?.5*a*a*a:.5*((a-=2)*a*a+2)}},Quartic:{In:function(a){return a*a*a*a},Out:function(a){return 1- --a*a*a*a},InOut:function(a){return(a*=2)<1?.5*a*a*a*a:-.5*((a-=2)*a*a*a-2)}},Quintic:{In:function(a){return a*a*a*a*a},Out:function(a){return--a*a*a*a*a+1},InOut:function(a){return(a*=2)<1?.5*a*a*a*a*a:.5*((a-=2)*a*a*a*a+2)}},Sinusoidal:{In:function(a){return 0===a?0:1===a?1:1-Math.cos(a*Math.PI/2)},Out:function(a){return 0===a?0:1===a?1:Math.sin(a*Math.PI/2)},InOut:function(a){return 0===a?0:1===a?1:.5*(1-Math.cos(Math.PI*a))}},Exponential:{In:function(a){return 0===a?0:Math.pow(1024,a-1)},Out:function(a){return 1===a?1:1-Math.pow(2,-10*a)},InOut:function(a){return 0===a?0:1===a?1:(a*=2)<1?.5*Math.pow(1024,a-1):.5*(-Math.pow(2,-10*(a-1))+2)}},Circular:{In:function(a){return 1-Math.sqrt(1-a*a)},Out:function(a){return Math.sqrt(1- --a*a)},InOut:function(a){return(a*=2)<1?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)}},Elastic:{In:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),-(c*Math.pow(2,10*(a-=1))*Math.sin((a-b)*(2*Math.PI)/d)))},Out:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),c*Math.pow(2,-10*a)*Math.sin((a-b)*(2*Math.PI)/d)+1)},InOut:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),(a*=2)<1?-.5*(c*Math.pow(2,10*(a-=1))*Math.sin((a-b)*(2*Math.PI)/d)):c*Math.pow(2,-10*(a-=1))*Math.sin((a-b)*(2*Math.PI)/d)*.5+1)}},Back:{In:function(a){var b=1.70158;return a*a*((b+1)*a-b)},Out:function(a){var b=1.70158;return--a*a*((b+1)*a+b)+1},InOut:function(a){var b=2.5949095;return(a*=2)<1?.5*(a*a*((b+1)*a-b)):.5*((a-=2)*a*((b+1)*a+b)+2)}},Bounce:{In:function(a){return 1-c.Easing.Bounce.Out(1-a)},Out:function(a){return 1/2.75>a?7.5625*a*a:2/2.75>a?7.5625*(a-=1.5/2.75)*a+.75:2.5/2.75>a?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375},InOut:function(a){return.5>a?.5*c.Easing.Bounce.In(2*a):.5*c.Easing.Bounce.Out(2*a-1)+.5}}},c.Easing.Default=c.Easing.Linear.None,c.Easing.Power0=c.Easing.Linear.None,c.Easing.Power1=c.Easing.Quadratic.Out,c.Easing.Power2=c.Easing.Cubic.Out,c.Easing.Power3=c.Easing.Quartic.Out,c.Easing.Power4=c.Easing.Quintic.Out,c.Time=function(a){this.game=a,this.time=0,this.prevTime=0,this.now=0,this.elapsed=0,this.elapsedMS=0,this.physicsElapsed=1/60,this.physicsElapsedMS=1/60*1e3,this.desiredFpsMult=1/60,this._desiredFps=60,this.suggestedFps=this.desiredFps,this.slowMotion=1,this.advancedTiming=!1,this.frames=0,this.fps=0,this.fpsMin=1e3,this.fpsMax=0,this.msMin=1e3,this.msMax=0,this.pauseDuration=0,this.timeToCall=0,this.timeExpected=0,this.events=new c.Timer(this.game,!1),this._frameCount=0,this._elapsedAccumulator=0,this._started=0,this._timeLastSecond=0,this._pauseStarted=0,this._justResumed=!1,this._timers=[]},c.Time.prototype={boot:function(){this._started=Date.now(),this.time=Date.now(),this.events.start(),this.timeExpected=this.time},add:function(a){return this._timers.push(a),a},create:function(a){void 0===a&&(a=!0);var b=new c.Timer(this.game,a);return this._timers.push(b),b},removeAll:function(){for(var a=0;a<this._timers.length;a++)this._timers[a].destroy();this._timers=[],this.events.removeAll()},refresh:function(){var a=this.time;this.time=Date.now(),this.elapsedMS=this.time-a},update:function(a){var b=this.time;this.time=Date.now(),this.elapsedMS=this.time-b,this.prevTime=this.now,this.now=a,this.elapsed=this.now-this.prevTime,this.game.raf._isSetTimeOut&&(this.timeToCall=Math.floor(Math.max(0,1e3/this._desiredFps-(this.timeExpected-a))),this.timeExpected=a+this.timeToCall),this.advancedTiming&&this.updateAdvancedTiming(),this.game.paused||(this.events.update(this.time),this._timers.length&&this.updateTimers())},updateTimers:function(){for(var a=0,b=this._timers.length;b>a;)this._timers[a].update(this.time)?a++:(this._timers.splice(a,1),b--)},updateAdvancedTiming:function(){this._frameCount++,this._elapsedAccumulator+=this.elapsed,this._frameCount>=2*this._desiredFps&&(this.suggestedFps=5*Math.floor(200/(this._elapsedAccumulator/this._frameCount)),this._frameCount=0,this._elapsedAccumulator=0),this.msMin=Math.min(this.msMin,this.elapsed),this.msMax=Math.max(this.msMax,this.elapsed),this.frames++,this.now>this._timeLastSecond+1e3&&(this.fps=Math.round(1e3*this.frames/(this.now-this._timeLastSecond)),this.fpsMin=Math.min(this.fpsMin,this.fps),this.fpsMax=Math.max(this.fpsMax,this.fps),this._timeLastSecond=this.now,this.frames=0)},gamePaused:function(){this._pauseStarted=Date.now(),this.events.pause();for(var a=this._timers.length;a--;)this._timers[a]._pause()},gameResumed:function(){this.time=Date.now(),this.pauseDuration=this.time-this._pauseStarted,this.events.resume();for(var a=this._timers.length;a--;)this._timers[a]._resume()},totalElapsedSeconds:function(){return.001*(this.time-this._started)},elapsedSince:function(a){return this.time-a},elapsedSecondsSince:function(a){return.001*(this.time-a)},reset:function(){this._started=this.time,this.removeAll()}},Object.defineProperty(c.Time.prototype,"desiredFps",{get:function(){return this._desiredFps},set:function(a){this._desiredFps=a,this.physicsElapsed=1/a,this.physicsElapsedMS=1e3*this.physicsElapsed,this.desiredFpsMult=1/a}}),c.Time.prototype.constructor=c.Time,c.Timer=function(a,b){void 0===b&&(b=!0),this.game=a,this.running=!1,this.autoDestroy=b,this.expired=!1,this.elapsed=0,this.events=[],this.onComplete=new c.Signal,this.nextTick=0,this.timeCap=1e3,this.paused=!1,this._codePaused=!1,this._started=0,this._pauseStarted=0,this._pauseTotal=0,this._now=Date.now(),this._len=0,this._marked=0,this._i=0,this._diff=0,this._newTick=0},c.Timer.MINUTE=6e4,c.Timer.SECOND=1e3,c.Timer.HALF=500,c.Timer.QUARTER=250,c.Timer.prototype={create:function(a,b,d,e,f,g){a=Math.round(a);var h=a;h+=0===this._now?this.game.time.time:this._now;var i=new c.TimerEvent(this,a,h,d,b,e,f,g);return this.events.push(i),this.order(),this.expired=!1,i},add:function(a,b,c){return this.create(a,!1,0,b,c,Array.prototype.slice.call(arguments,3))},repeat:function(a,b,c,d){return this.create(a,!1,b,c,d,Array.prototype.slice.call(arguments,4))},loop:function(a,b,c){return this.create(a,!0,0,b,c,Array.prototype.slice.call(arguments,3))},start:function(a){if(!this.running){this._started=this.game.time.time+(a||0),this.running=!0;for(var b=0;b<this.events.length;b++)this.events[b].tick=this.events[b].delay+this._started}},stop:function(a){this.running=!1,void 0===a&&(a=!0),a&&(this.events.length=0)},remove:function(a){for(var b=0;b<this.events.length;b++)if(this.events[b]===a)return this.events[b].pendingDelete=!0,!0;return!1},order:function(){this.events.length>0&&(this.events.sort(this.sortHandler),this.nextTick=this.events[0].tick)},sortHandler:function(a,b){return a.tick<b.tick?-1:a.tick>b.tick?1:0},clearPendingEvents:function(){for(this._i=this.events.length;this._i--;)this.events[this._i].pendingDelete&&this.events.splice(this._i,1);this._len=this.events.length,this._i=0},update:function(a){if(this.paused)return!0;if(this.elapsed=a-this._now,this._now=a,this.elapsed>this.timeCap&&this.adjustEvents(a-this.elapsed),this._marked=0,this.clearPendingEvents(),this.running&&this._now>=this.nextTick&&this._len>0){for(;this._i<this._len&&this.running&&this._now>=this.events[this._i].tick&&!this.events[this._i].pendingDelete;)this._newTick=this._now+this.events[this._i].delay-(this._now-this.events[this._i].tick),this._newTick<0&&(this._newTick=this._now+this.events[this._i].delay),this.events[this._i].loop===!0?(this.events[this._i].tick=this._newTick,this.events[this._i].callback.apply(this.events[this._i].callbackContext,this.events[this._i].args)):this.events[this._i].repeatCount>0?(this.events[this._i].repeatCount--,this.events[this._i].tick=this._newTick,this.events[this._i].callback.apply(this.events[this._i].callbackContext,this.events[this._i].args)):(this._marked++,this.events[this._i].pendingDelete=!0,this.events[this._i].callback.apply(this.events[this._i].callbackContext,this.events[this._i].args)),this._i++;this.events.length>this._marked?this.order():(this.expired=!0,this.onComplete.dispatch(this))}return this.expired&&this.autoDestroy?!1:!0},pause:function(){this.running&&(this._codePaused=!0,this.paused||(this._pauseStarted=this.game.time.time,this.paused=!0))},_pause:function(){!this.paused&&this.running&&(this._pauseStarted=this.game.time.time,this.paused=!0)},adjustEvents:function(a){for(var b=0;b<this.events.length;b++)if(!this.events[b].pendingDelete){var c=this.events[b].tick-a;0>c&&(c=0),this.events[b].tick=this._now+c}var d=this.nextTick-a;0>d?this.nextTick=this._now:this.nextTick=this._now+d},resume:function(){if(this.paused){var a=this.game.time.time;this._pauseTotal+=a-this._now,this._now=a,this.adjustEvents(this._pauseStarted),this.paused=!1,this._codePaused=!1}},_resume:function(){this._codePaused||this.resume()},removeAll:function(){this.onComplete.removeAll(),this.events.length=0,this._len=0,this._i=0},destroy:function(){this.onComplete.removeAll(),this.running=!1,this.events=[],this._len=0,this._i=0}},Object.defineProperty(c.Timer.prototype,"next",{get:function(){return this.nextTick}}),Object.defineProperty(c.Timer.prototype,"duration",{get:function(){return this.running&&this.nextTick>this._now?this.nextTick-this._now:0}}),Object.defineProperty(c.Timer.prototype,"length",{get:function(){return this.events.length}}),Object.defineProperty(c.Timer.prototype,"ms",{get:function(){return this.running?this._now-this._started-this._pauseTotal:0}}),Object.defineProperty(c.Timer.prototype,"seconds",{get:function(){return this.running?.001*this.ms:0}}),c.Timer.prototype.constructor=c.Timer,c.TimerEvent=function(a,b,c,d,e,f,g,h){this.timer=a,this.delay=b,this.tick=c,this.repeatCount=d-1,this.loop=e,this.callback=f,this.callbackContext=g,this.args=h,this.pendingDelete=!1},c.TimerEvent.prototype.constructor=c.TimerEvent,c.AnimationManager=function(a){this.sprite=a,this.game=a.game,this.currentFrame=null,this.currentAnim=null,this.updateIfVisible=!0,this.isLoaded=!1,this._frameData=null,this._anims={},this._outputFrames=[]},c.AnimationManager.prototype={loadFrameData:function(a,b){if(void 0===a)return!1;if(this.isLoaded)for(var c in this._anims)this._anims[c].updateFrameData(a);return this._frameData=a,void 0===b||null===b?this.frame=0:"string"==typeof b?this.frameName=b:this.frame=b,this.isLoaded=!0,!0},copyFrameData:function(a,b){if(this._frameData=a.clone(),this.isLoaded)for(var c in this._anims)this._anims[c].updateFrameData(this._frameData);return void 0===b||null===b?this.frame=0:"string"==typeof b?this.frameName=b:this.frame=b,this.isLoaded=!0,!0},add:function(a,b,d,e,f){return b=b||[],d=d||60,void 0===e&&(e=!1),void 0===f&&(f=b&&"number"==typeof b[0]?!0:!1),this._outputFrames=[],this._frameData.getFrameIndexes(b,f,this._outputFrames),this._anims[a]=new c.Animation(this.game,this.sprite,a,this._frameData,this._outputFrames,d,e),this.currentAnim=this._anims[a],this.sprite.tilingTexture&&(this.sprite.refreshTexture=!0),this._anims[a]},validateFrames:function(a,b){void 0===b&&(b=!0);for(var c=0;c<a.length;c++)if(b===!0){if(a[c]>this._frameData.total)return!1}else if(this._frameData.checkFrameName(a[c])===!1)return!1;return!0},play:function(a,b,c,d){return this._anims[a]?this.currentAnim===this._anims[a]?this.currentAnim.isPlaying===!1?(this.currentAnim.paused=!1,this.currentAnim.play(b,c,d)):this.currentAnim:(this.currentAnim&&this.currentAnim.isPlaying&&this.currentAnim.stop(),this.currentAnim=this._anims[a],this.currentAnim.paused=!1,this.currentFrame=this.currentAnim.currentFrame,this.currentAnim.play(b,c,d)):void 0},stop:function(a,b){void 0===b&&(b=!1),"string"==typeof a?this._anims[a]&&(this.currentAnim=this._anims[a],this.currentAnim.stop(b)):this.currentAnim&&this.currentAnim.stop(b)},update:function(){return this.updateIfVisible&&!this.sprite.visible?!1:this.currentAnim&&this.currentAnim.update()?(this.currentFrame=this.currentAnim.currentFrame,!0):!1},next:function(a){this.currentAnim&&(this.currentAnim.next(a),this.currentFrame=this.currentAnim.currentFrame)},previous:function(a){this.currentAnim&&(this.currentAnim.previous(a),this.currentFrame=this.currentAnim.currentFrame)},getAnimation:function(a){return"string"==typeof a&&this._anims[a]?this._anims[a]:null},refreshFrame:function(){this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid])},destroy:function(){var a=null;for(var a in this._anims)this._anims.hasOwnProperty(a)&&this._anims[a].destroy();this._anims={},this._outputFrames=[],this._frameData=null,this.currentAnim=null,this.currentFrame=null,this.sprite=null,this.game=null}},c.AnimationManager.prototype.constructor=c.AnimationManager,Object.defineProperty(c.AnimationManager.prototype,"frameData",{get:function(){return this._frameData}}),Object.defineProperty(c.AnimationManager.prototype,"frameTotal",{get:function(){return this._frameData.total}}),Object.defineProperty(c.AnimationManager.prototype,"paused",{get:function(){return this.currentAnim.isPaused},set:function(a){this.currentAnim.paused=a}}),Object.defineProperty(c.AnimationManager.prototype,"name",{get:function(){return this.currentAnim?this.currentAnim.name:void 0}}),Object.defineProperty(c.AnimationManager.prototype,"frame",{get:function(){return this.currentFrame?this.currentFrame.index:void 0},set:function(a){"number"==typeof a&&this._frameData&&null!==this._frameData.getFrame(a)&&(this.currentFrame=this._frameData.getFrame(a),this.currentFrame&&this.sprite.setFrame(this.currentFrame))}}),Object.defineProperty(c.AnimationManager.prototype,"frameName",{get:function(){return this.currentFrame?this.currentFrame.name:void 0},set:function(a){"string"==typeof a&&this._frameData&&null!==this._frameData.getFrameByName(a)?(this.currentFrame=this._frameData.getFrameByName(a),this.currentFrame&&(this._frameIndex=this.currentFrame.index,this.sprite.setFrame(this.currentFrame))):console.warn("Cannot set frameName: "+a)}}),c.Animation=function(a,b,d,e,f,g,h){void 0===h&&(h=!1),this.game=a,this._parent=b,this._frameData=e,this.name=d,this._frames=[],this._frames=this._frames.concat(f),this.delay=1e3/g,this.loop=h,this.loopCount=0,this.killOnComplete=!1,this.isFinished=!1,this.isPlaying=!1,this.isPaused=!1,this._pauseStartTime=0,this._frameIndex=0,this._frameDiff=0,this._frameSkip=1,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.onStart=new c.Signal,this.onUpdate=null,this.onComplete=new c.Signal,this.onLoop=new c.Signal,this.game.onPause.add(this.onPause,this),this.game.onResume.add(this.onResume,this)},c.Animation.prototype={play:function(a,b,c){return"number"==typeof a&&(this.delay=1e3/a),"boolean"==typeof b&&(this.loop=b),"undefined"!=typeof c&&(this.killOnComplete=c),this.isPlaying=!0,this.isFinished=!1,this.paused=!1,this.loopCount=0,this._timeLastFrame=this.game.time.time,this._timeNextFrame=this.game.time.time+this.delay,this._frameIndex=0,this.updateCurrentFrame(!1,!0),this._parent.events.onAnimationStart$dispatch(this._parent,this),this.onStart.dispatch(this._parent,this),this._parent.animations.currentAnim=this,this._parent.animations.currentFrame=this.currentFrame,this},restart:function(){this.isPlaying=!0,this.isFinished=!1,this.paused=!1,this.loopCount=0,this._timeLastFrame=this.game.time.time,this._timeNextFrame=this.game.time.time+this.delay,this._frameIndex=0,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this._parent.setFrame(this.currentFrame),this._parent.animations.currentAnim=this,this._parent.animations.currentFrame=this.currentFrame,this.onStart.dispatch(this._parent,this)},setFrame:function(a,b){var c;if(void 0===b&&(b=!1),"string"==typeof a)for(var d=0;d<this._frames.length;d++)this._frameData.getFrame(this._frames[d]).name===a&&(c=d);else if("number"==typeof a)if(b)c=a;else for(var d=0;d<this._frames.length;d++)this._frames[d]===c&&(c=d);c&&(this._frameIndex=c-1,this._timeNextFrame=this.game.time.time,this.update())},stop:function(a,b){void 0===a&&(a=!1),void 0===b&&(b=!1),this.isPlaying=!1,this.isFinished=!0,this.paused=!1,a&&(this.currentFrame=this._frameData.getFrame(this._frames[0]),this._parent.setFrame(this.currentFrame)),b&&(this._parent.events.onAnimationComplete$dispatch(this._parent,this),this.onComplete.dispatch(this._parent,this))},onPause:function(){this.isPlaying&&(this._frameDiff=this._timeNextFrame-this.game.time.time)},onResume:function(){this.isPlaying&&(this._timeNextFrame=this.game.time.time+this._frameDiff)},update:function(){return this.isPaused?!1:this.isPlaying&&this.game.time.time>=this._timeNextFrame?(this._frameSkip=1,this._frameDiff=this.game.time.time-this._timeNextFrame,this._timeLastFrame=this.game.time.time,this._frameDiff>this.delay&&(this._frameSkip=Math.floor(this._frameDiff/this.delay),this._frameDiff-=this._frameSkip*this.delay),this._timeNextFrame=this.game.time.time+(this.delay-this._frameDiff),this._frameIndex+=this._frameSkip,this._frameIndex>=this._frames.length?this.loop?(this._frameIndex%=this._frames.length,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&this._parent.setFrame(this.currentFrame),this.loopCount++,this._parent.events.onAnimationLoop$dispatch(this._parent,this),this.onLoop.dispatch(this._parent,this),this.onUpdate?(this.onUpdate.dispatch(this,this.currentFrame),!!this._frameData):!0):(this.complete(),!1):this.updateCurrentFrame(!0)):!1},updateCurrentFrame:function(a,b){if(void 0===b&&(b=!1),!this._frameData)return!1;var c=this.currentFrame.index;return this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&(b||!b&&c!==this.currentFrame.index)&&this._parent.setFrame(this.currentFrame),this.onUpdate&&a?(this.onUpdate.dispatch(this,this.currentFrame),!!this._frameData):!0},next:function(a){void 0===a&&(a=1);var b=this._frameIndex+a;b>=this._frames.length&&(this.loop?b%=this._frames.length:b=this._frames.length-1),b!==this._frameIndex&&(this._frameIndex=b,this.updateCurrentFrame(!0))},previous:function(a){void 0===a&&(a=1);var b=this._frameIndex-a;0>b&&(this.loop?b=this._frames.length+b:b++),b!==this._frameIndex&&(this._frameIndex=b,this.updateCurrentFrame(!0))},updateFrameData:function(a){this._frameData=a,this.currentFrame=this._frameData?this._frameData.getFrame(this._frames[this._frameIndex%this._frames.length]):null},destroy:function(){this._frameData&&(this.game.onPause.remove(this.onPause,this),this.game.onResume.remove(this.onResume,this),this.game=null,this._parent=null,this._frames=null,this._frameData=null,this.currentFrame=null,this.isPlaying=!1,this.onStart.dispose(),this.onLoop.dispose(),this.onComplete.dispose(),this.onUpdate&&this.onUpdate.dispose())},complete:function(){this._frameIndex=this._frames.length-1,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.isPlaying=!1,this.isFinished=!0,this.paused=!1,this._parent.events.onAnimationComplete$dispatch(this._parent,this),this.onComplete.dispatch(this._parent,this),this.killOnComplete&&this._parent.kill()}},c.Animation.prototype.constructor=c.Animation,Object.defineProperty(c.Animation.prototype,"paused",{get:function(){return this.isPaused},set:function(a){this.isPaused=a,a?this._pauseStartTime=this.game.time.time:this.isPlaying&&(this._timeNextFrame=this.game.time.time+this.delay)}}),Object.defineProperty(c.Animation.prototype,"frameTotal",{get:function(){return this._frames.length}}),Object.defineProperty(c.Animation.prototype,"frame",{get:function(){return null!==this.currentFrame?this.currentFrame.index:this._frameIndex},set:function(a){this.currentFrame=this._frameData.getFrame(this._frames[a]),null!==this.currentFrame&&(this._frameIndex=a,this._parent.setFrame(this.currentFrame),this.onUpdate&&this.onUpdate.dispatch(this,this.currentFrame))}}),Object.defineProperty(c.Animation.prototype,"speed",{get:function(){return Math.round(1e3/this.delay)},set:function(a){a>=1&&(this.delay=1e3/a)}}),Object.defineProperty(c.Animation.prototype,"enableUpdate",{get:function(){return null!==this.onUpdate},set:function(a){a&&null===this.onUpdate?this.onUpdate=new c.Signal:a||null===this.onUpdate||(this.onUpdate.dispose(),this.onUpdate=null)}}),c.Animation.generateFrameNames=function(a,b,d,e,f){void 0===e&&(e="");var g=[],h="";if(d>b)for(var i=b;d>=i;i++)h="number"==typeof f?c.Utils.pad(i.toString(),f,"0",1):i.toString(),h=a+h+e,g.push(h);else for(var i=b;i>=d;i--)h="number"==typeof f?c.Utils.pad(i.toString(),f,"0",1):i.toString(),h=a+h+e,g.push(h);return g},c.Frame=function(a,b,d,e,f,g){this.index=a,this.x=b,this.y=d,this.width=e,this.height=f,this.name=g,this.centerX=Math.floor(e/2),this.centerY=Math.floor(f/2),this.distance=c.Math.distance(0,0,e,f),this.rotated=!1,this.rotationDirection="cw",this.trimmed=!1,this.sourceSizeW=e,this.sourceSizeH=f,this.spriteSourceSizeX=0,this.spriteSourceSizeY=0,this.spriteSourceSizeW=0,this.spriteSourceSizeH=0,this.right=this.x+this.width,this.bottom=this.y+this.height},c.Frame.prototype={resize:function(a,b){this.width=a,this.height=b,this.centerX=Math.floor(a/2),this.centerY=Math.floor(b/2),this.distance=c.Math.distance(0,0,a,b),this.sourceSizeW=a,this.sourceSizeH=b,this.right=this.x+a,this.bottom=this.y+b},setTrim:function(a,b,c,d,e,f,g){this.trimmed=a,a&&(this.sourceSizeW=b,this.sourceSizeH=c,this.centerX=Math.floor(b/2),this.centerY=Math.floor(c/2),this.spriteSourceSizeX=d,this.spriteSourceSizeY=e,this.spriteSourceSizeW=f,this.spriteSourceSizeH=g)},clone:function(){var a=new c.Frame(this.index,this.x,this.y,this.width,this.height,this.name);for(var b in this)this.hasOwnProperty(b)&&(a[b]=this[b]);return a},getRect:function(a){return void 0===a?a=new c.Rectangle(this.x,this.y,this.width,this.height):a.setTo(this.x,this.y,this.width,this.height),a}},c.Frame.prototype.constructor=c.Frame,c.FrameData=function(){this._frames=[],this._frameNames=[]},c.FrameData.prototype={addFrame:function(a){return a.index=this._frames.length,this._frames.push(a),""!==a.name&&(this._frameNames[a.name]=a.index),a},getFrame:function(a){return a>=this._frames.length&&(a=0),this._frames[a]},getFrameByName:function(a){return"number"==typeof this._frameNames[a]?this._frames[this._frameNames[a]]:null},checkFrameName:function(a){return null==this._frameNames[a]?!1:!0},clone:function(){for(var a=new c.FrameData,b=0;b<this._frames.length;b++)a._frames.push(this._frames[b].clone());for(var d in this._frameNames)this._frameNames.hasOwnProperty(d)&&a._frameNames.push(this._frameNames[d]);return a},getFrameRange:function(a,b,c){void 0===c&&(c=[]);for(var d=a;b>=d;d++)c.push(this._frames[d]);return c},getFrames:function(a,b,c){if(void 0===b&&(b=!0),void 0===c&&(c=[]),void 0===a||0===a.length)for(var d=0;d<this._frames.length;d++)c.push(this._frames[d]);else for(var d=0;d<a.length;d++)b?c.push(this.getFrame(a[d])):c.push(this.getFrameByName(a[d]));return c},getFrameIndexes:function(a,b,c){if(void 0===b&&(b=!0),void 0===c&&(c=[]),void 0===a||0===a.length)for(var d=0;d<this._frames.length;d++)c.push(this._frames[d].index);else for(var d=0;d<a.length;d++)b?c.push(this._frames[a[d]].index):this.getFrameByName(a[d])&&c.push(this.getFrameByName(a[d]).index);return c}},c.FrameData.prototype.constructor=c.FrameData,Object.defineProperty(c.FrameData.prototype,"total",{get:function(){return this._frames.length}}),c.AnimationParser={spriteSheet:function(a,b,d,e,f,g,h){var i=b;if("string"==typeof b&&(i=a.cache.getImage(b)),null===i)return null;var j=i.width,k=i.height;0>=d&&(d=Math.floor(-j/Math.min(-1,d))),0>=e&&(e=Math.floor(-k/Math.min(-1,e)));var l=Math.floor((j-g)/(d+h)),m=Math.floor((k-g)/(e+h)),n=l*m;if(-1!==f&&(n=f),0===j||0===k||d>j||e>k||0===n)return console.warn("Phaser.AnimationParser.spriteSheet: '"+b+"'s width/height zero or width/height < given frameWidth/frameHeight"),null;for(var o=new c.FrameData,p=g,q=g,r=0;n>r;r++)o.addFrame(new c.Frame(r,p,q,d,e,"")),p+=d+h,p+d>j&&(p=g,q+=e+h);return o},JSONData:function(a,b){if(!b.frames)return console.warn("Phaser.AnimationParser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array"),void console.log(b);for(var d,e=new c.FrameData,f=b.frames,g=0;g<f.length;g++)d=e.addFrame(new c.Frame(g,f[g].frame.x,f[g].frame.y,f[g].frame.w,f[g].frame.h,f[g].filename)),f[g].trimmed&&d.setTrim(f[g].trimmed,f[g].sourceSize.w,f[g].sourceSize.h,f[g].spriteSourceSize.x,f[g].spriteSourceSize.y,f[g].spriteSourceSize.w,f[g].spriteSourceSize.h);return e},JSONDataPyxel:function(a,b){var d=["layers","tilewidth","tileheight","tileswide","tileshigh"];if(d.forEach(function(a){return b[a]?void 0:(console.warn("Phaser.AnimationParser.JSONDataPyxel: Invalid Pyxel Tilemap JSON given, missing '"+a+"' key."),void console.log(b))}),1!=b.layers.length)return console.warn("Phaser.AnimationParser.JSONDataPyxel: Too many layers, this parser only supports flat Tilemaps."),void console.log(b);for(var e,f=new c.FrameData,g=b.tileheight,h=b.tilewidth,i=b.layers[0].tiles,j=0;j<i.length;j++)e=f.addFrame(new c.Frame(j,i[j].x,i[j].y,h,g,"frame_"+j)), +e.setTrim(!1);return f},JSONDataHash:function(a,b){if(!b.frames)return console.warn("Phaser.AnimationParser.JSONDataHash: Invalid Texture Atlas JSON given, missing 'frames' object"),void console.log(b);var d,e=new c.FrameData,f=b.frames,g=0;for(var h in f)d=e.addFrame(new c.Frame(g,f[h].frame.x,f[h].frame.y,f[h].frame.w,f[h].frame.h,h)),f[h].trimmed&&d.setTrim(f[h].trimmed,f[h].sourceSize.w,f[h].sourceSize.h,f[h].spriteSourceSize.x,f[h].spriteSourceSize.y,f[h].spriteSourceSize.w,f[h].spriteSourceSize.h),g++;return e},XMLData:function(a,b){if(!b.getElementsByTagName("TextureAtlas"))return void console.warn("Phaser.AnimationParser.XMLData: Invalid Texture Atlas XML given, missing <TextureAtlas> tag");for(var d,e,f,g,h,i,j,k,l,m,n,o=new c.FrameData,p=b.getElementsByTagName("SubTexture"),q=0;q<p.length;q++)f=p[q].attributes,e=f.name.value,g=parseInt(f.x.value,10),h=parseInt(f.y.value,10),i=parseInt(f.width.value,10),j=parseInt(f.height.value,10),k=null,l=null,f.frameX&&(k=Math.abs(parseInt(f.frameX.value,10)),l=Math.abs(parseInt(f.frameY.value,10)),m=parseInt(f.frameWidth.value,10),n=parseInt(f.frameHeight.value,10)),d=o.addFrame(new c.Frame(q,g,h,i,j,e)),(null!==k||null!==l)&&d.setTrim(!0,i,j,k,l,m,n);return o}},c.Cache=function(a){this.game=a,this.autoResolveURL=!1,this._cache={canvas:{},image:{},texture:{},sound:{},video:{},text:{},json:{},xml:{},physics:{},tilemap:{},binary:{},bitmapData:{},bitmapFont:{},shader:{},renderTexture:{}},this._urlMap={},this._urlResolver=new Image,this._urlTemp=null,this.onSoundUnlock=new c.Signal,this._cacheMap=[],this._cacheMap[c.Cache.CANVAS]=this._cache.canvas,this._cacheMap[c.Cache.IMAGE]=this._cache.image,this._cacheMap[c.Cache.TEXTURE]=this._cache.texture,this._cacheMap[c.Cache.SOUND]=this._cache.sound,this._cacheMap[c.Cache.TEXT]=this._cache.text,this._cacheMap[c.Cache.PHYSICS]=this._cache.physics,this._cacheMap[c.Cache.TILEMAP]=this._cache.tilemap,this._cacheMap[c.Cache.BINARY]=this._cache.binary,this._cacheMap[c.Cache.BITMAPDATA]=this._cache.bitmapData,this._cacheMap[c.Cache.BITMAPFONT]=this._cache.bitmapFont,this._cacheMap[c.Cache.JSON]=this._cache.json,this._cacheMap[c.Cache.XML]=this._cache.xml,this._cacheMap[c.Cache.VIDEO]=this._cache.video,this._cacheMap[c.Cache.SHADER]=this._cache.shader,this._cacheMap[c.Cache.RENDER_TEXTURE]=this._cache.renderTexture,this.addDefaultImage(),this.addMissingImage()},c.Cache.CANVAS=1,c.Cache.IMAGE=2,c.Cache.TEXTURE=3,c.Cache.SOUND=4,c.Cache.TEXT=5,c.Cache.PHYSICS=6,c.Cache.TILEMAP=7,c.Cache.BINARY=8,c.Cache.BITMAPDATA=9,c.Cache.BITMAPFONT=10,c.Cache.JSON=11,c.Cache.XML=12,c.Cache.VIDEO=13,c.Cache.SHADER=14,c.Cache.RENDER_TEXTURE=15,c.Cache.prototype={addCanvas:function(a,b,c){void 0===c&&(c=b.getContext("2d")),this._cache.canvas[a]={canvas:b,context:c}},addImage:function(a,b,d){this.checkImageKey(a)&&this.removeImage(a);var e={key:a,url:b,data:d,base:new PIXI.BaseTexture(d),frame:new c.Frame(0,0,0,d.width,d.height,a),frameData:new c.FrameData};return e.frameData.addFrame(new c.Frame(0,0,0,d.width,d.height,b)),this._cache.image[a]=e,this._resolveURL(b,e),e},addDefaultImage:function(){var a=new Image;a.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==";var b=this.addImage("__default",null,a);b.base.skipRender=!0,PIXI.TextureCache.__default=new PIXI.Texture(b.base)},addMissingImage:function(){var a=new Image;a.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==";var b=this.addImage("__missing",null,a);PIXI.TextureCache.__missing=new PIXI.Texture(b.base)},addSound:function(a,b,c,d,e){void 0===d&&(d=!0,e=!1),void 0===e&&(d=!1,e=!0);var f=!1;e&&(f=!0),this._cache.sound[a]={url:b,data:c,isDecoding:!1,decoded:f,webAudio:d,audioTag:e,locked:this.game.sound.touchLocked},this._resolveURL(b,this._cache.sound[a])},addText:function(a,b,c){this._cache.text[a]={url:b,data:c},this._resolveURL(b,this._cache.text[a])},addPhysicsData:function(a,b,c,d){this._cache.physics[a]={url:b,data:c,format:d},this._resolveURL(b,this._cache.physics[a])},addTilemap:function(a,b,c,d){this._cache.tilemap[a]={url:b,data:c,format:d},this._resolveURL(b,this._cache.tilemap[a])},addBinary:function(a,b){this._cache.binary[a]=b},addBitmapData:function(a,b,d){return b.key=a,void 0===d&&(d=new c.FrameData,d.addFrame(b.textureFrame)),this._cache.bitmapData[a]={data:b,frameData:d},b},addBitmapFont:function(a,b,d,e,f,g,h){var i={url:b,data:d,font:null,base:new PIXI.BaseTexture(d)};void 0===g&&(g=0),void 0===h&&(h=0),"json"===f?i.font=c.LoaderParser.jsonBitmapFont(e,i.base,g,h):i.font=c.LoaderParser.xmlBitmapFont(e,i.base,g,h),this._cache.bitmapFont[a]=i,this._resolveURL(b,i)},addJSON:function(a,b,c){this._cache.json[a]={url:b,data:c},this._resolveURL(b,this._cache.json[a])},addXML:function(a,b,c){this._cache.xml[a]={url:b,data:c},this._resolveURL(b,this._cache.xml[a])},addVideo:function(a,b,c,d){this._cache.video[a]={url:b,data:c,isBlob:d,locked:!0},this._resolveURL(b,this._cache.video[a])},addShader:function(a,b,c){this._cache.shader[a]={url:b,data:c},this._resolveURL(b,this._cache.shader[a])},addRenderTexture:function(a,b){this._cache.renderTexture[a]={texture:b,frame:new c.Frame(0,0,0,b.width,b.height,"","")}},addSpriteSheet:function(a,b,d,e,f,g,h,i){void 0===g&&(g=-1),void 0===h&&(h=0),void 0===i&&(i=0);var j={key:a,url:b,data:d,frameWidth:e,frameHeight:f,margin:h,spacing:i,base:new PIXI.BaseTexture(d),frameData:c.AnimationParser.spriteSheet(this.game,d,e,f,g,h,i)};this._cache.image[a]=j,this._resolveURL(b,j)},addTextureAtlas:function(a,b,d,e,f){var g={key:a,url:b,data:d,base:new PIXI.BaseTexture(d)};f===c.Loader.TEXTURE_ATLAS_XML_STARLING?g.frameData=c.AnimationParser.XMLData(this.game,e,a):f===c.Loader.TEXTURE_ATLAS_JSON_PYXEL?g.frameData=c.AnimationParser.JSONDataPyxel(this.game,e,a):Array.isArray(e.frames)?g.frameData=c.AnimationParser.JSONData(this.game,e,a):g.frameData=c.AnimationParser.JSONDataHash(this.game,e,a),this._cache.image[a]=g,this._resolveURL(b,g)},reloadSound:function(a){var b=this,c=this.getSound(a);c&&(c.data.src=c.url,c.data.addEventListener("canplaythrough",function(){return b.reloadSoundComplete(a)},!1),c.data.load())},reloadSoundComplete:function(a){var b=this.getSound(a);b&&(b.locked=!1,this.onSoundUnlock.dispatch(a))},updateSound:function(a,b,c){var d=this.getSound(a);d&&(d[b]=c)},decodedSound:function(a,b){var c=this.getSound(a);c.data=b,c.decoded=!0,c.isDecoding=!1},isSoundDecoded:function(a){var b=this.getItem(a,c.Cache.SOUND,"isSoundDecoded");return b?b.decoded:void 0},isSoundReady:function(a){var b=this.getItem(a,c.Cache.SOUND,"isSoundDecoded");return b?b.decoded&&!this.game.sound.touchLocked:void 0},checkKey:function(a,b){return this._cacheMap[a][b]?!0:!1},checkURL:function(a){return this._urlMap[this._resolveURL(a)]?!0:!1},checkCanvasKey:function(a){return this.checkKey(c.Cache.CANVAS,a)},checkImageKey:function(a){return this.checkKey(c.Cache.IMAGE,a)},checkTextureKey:function(a){return this.checkKey(c.Cache.TEXTURE,a)},checkSoundKey:function(a){return this.checkKey(c.Cache.SOUND,a)},checkTextKey:function(a){return this.checkKey(c.Cache.TEXT,a)},checkPhysicsKey:function(a){return this.checkKey(c.Cache.PHYSICS,a)},checkTilemapKey:function(a){return this.checkKey(c.Cache.TILEMAP,a)},checkBinaryKey:function(a){return this.checkKey(c.Cache.BINARY,a)},checkBitmapDataKey:function(a){return this.checkKey(c.Cache.BITMAPDATA,a)},checkBitmapFontKey:function(a){return this.checkKey(c.Cache.BITMAPFONT,a)},checkJSONKey:function(a){return this.checkKey(c.Cache.JSON,a)},checkXMLKey:function(a){return this.checkKey(c.Cache.XML,a)},checkVideoKey:function(a){return this.checkKey(c.Cache.VIDEO,a)},checkShaderKey:function(a){return this.checkKey(c.Cache.SHADER,a)},checkRenderTextureKey:function(a){return this.checkKey(c.Cache.RENDER_TEXTURE,a)},getItem:function(a,b,c,d){return this.checkKey(b,a)?void 0===d?this._cacheMap[b][a]:this._cacheMap[b][a][d]:(c&&console.warn("Phaser.Cache."+c+': Key "'+a+'" not found in Cache.'),null)},getCanvas:function(a){return this.getItem(a,c.Cache.CANVAS,"getCanvas","canvas")},getImage:function(a,b){(void 0===a||null===a)&&(a="__default"),void 0===b&&(b=!1);var d=this.getItem(a,c.Cache.IMAGE,"getImage");return null===d&&(d=this.getItem("__missing",c.Cache.IMAGE,"getImage")),b?d:d.data},getTextureFrame:function(a){return this.getItem(a,c.Cache.TEXTURE,"getTextureFrame","frame")},getSound:function(a){return this.getItem(a,c.Cache.SOUND,"getSound")},getSoundData:function(a){return this.getItem(a,c.Cache.SOUND,"getSoundData","data")},getText:function(a){return this.getItem(a,c.Cache.TEXT,"getText","data")},getPhysicsData:function(a,b,d){var e=this.getItem(a,c.Cache.PHYSICS,"getPhysicsData","data");if(null===e||void 0===b||null===b)return e;if(e[b]){var f=e[b];if(!f||!d)return f;for(var g in f)if(g=f[g],g.fixtureKey===d)return g;console.warn('Phaser.Cache.getPhysicsData: Could not find given fixtureKey: "'+d+" in "+a+'"')}else console.warn('Phaser.Cache.getPhysicsData: Invalid key/object: "'+a+" / "+b+'"');return null},getTilemapData:function(a){return this.getItem(a,c.Cache.TILEMAP,"getTilemapData")},getBinary:function(a){return this.getItem(a,c.Cache.BINARY,"getBinary")},getBitmapData:function(a){return this.getItem(a,c.Cache.BITMAPDATA,"getBitmapData","data")},getBitmapFont:function(a){return this.getItem(a,c.Cache.BITMAPFONT,"getBitmapFont")},getJSON:function(a,b){var d=this.getItem(a,c.Cache.JSON,"getJSON","data");return d?b?c.Utils.extend(!0,d):d:null},getXML:function(a){return this.getItem(a,c.Cache.XML,"getXML","data")},getVideo:function(a){return this.getItem(a,c.Cache.VIDEO,"getVideo")},getShader:function(a){return this.getItem(a,c.Cache.SHADER,"getShader","data")},getRenderTexture:function(a){return this.getItem(a,c.Cache.RENDER_TEXTURE,"getRenderTexture")},getBaseTexture:function(a,b){return void 0===b&&(b=c.Cache.IMAGE),this.getItem(a,b,"getBaseTexture","base")},getFrame:function(a,b){return void 0===b&&(b=c.Cache.IMAGE),this.getItem(a,b,"getFrame","frame")},getFrameCount:function(a,b){var c=this.getFrameData(a,b);return c?c.total:0},getFrameData:function(a,b){return void 0===b&&(b=c.Cache.IMAGE),this.getItem(a,b,"getFrameData","frameData")},hasFrameData:function(a,b){return void 0===b&&(b=c.Cache.IMAGE),null!==this.getItem(a,b,"","frameData")},updateFrameData:function(a,b,d){void 0===d&&(d=c.Cache.IMAGE),this._cacheMap[d][a]&&(this._cacheMap[d][a].frameData=b)},getFrameByIndex:function(a,b,c){var d=this.getFrameData(a,c);return d?d.getFrame(b):null},getFrameByName:function(a,b,c){var d=this.getFrameData(a,c);return d?d.getFrameByName(b):null},getPixiTexture:function(a){if(PIXI.TextureCache[a])return PIXI.TextureCache[a];var b=this.getPixiBaseTexture(a);return b?new PIXI.Texture(b):null},getPixiBaseTexture:function(a){if(PIXI.BaseTextureCache[a])return PIXI.BaseTextureCache[a];var b=this.getItem(a,c.Cache.IMAGE,"getPixiBaseTexture");return null!==b?b.base:null},getURL:function(a){var a=this._resolveURL(a);return a?this._urlMap[a]:(console.warn('Phaser.Cache.getUrl: Invalid url: "'+a+'" or Cache.autoResolveURL was false'),null)},getKeys:function(a){void 0===a&&(a=c.Cache.IMAGE);var b=[];if(this._cacheMap[a])for(var d in this._cacheMap[a])"__default"!==d&&"__missing"!==d&&b.push(d);return b},removeCanvas:function(a){delete this._cache.canvas[a]},removeImage:function(a,b){void 0===b&&(b=!0);var c=this.getImage(a,!0);b&&c.base&&c.base.destroy(),delete this._cache.image[a]},removeSound:function(a){delete this._cache.sound[a]},removeText:function(a){delete this._cache.text[a]},removePhysics:function(a){delete this._cache.physics[a]},removeTilemap:function(a){delete this._cache.tilemap[a]},removeBinary:function(a){delete this._cache.binary[a]},removeBitmapData:function(a){delete this._cache.bitmapData[a]},removeBitmapFont:function(a){delete this._cache.bitmapFont[a]},removeJSON:function(a){delete this._cache.json[a]},removeXML:function(a){delete this._cache.xml[a]},removeVideo:function(a){delete this._cache.video[a]},removeShader:function(a){delete this._cache.shader[a]},removeRenderTexture:function(a){delete this._cache.renderTexture[a]},removeSpriteSheet:function(a){delete this._cache.spriteSheet[a]},removeTextureAtlas:function(a){delete this._cache.atlas[a]},clearGLTextures:function(){for(var a in this.cache.image)this.cache.image[a].base._glTextures=[]},_resolveURL:function(a,b){return this.autoResolveURL?(this._urlResolver.src=this.game.load.baseURL+a,this._urlTemp=this._urlResolver.src,this._urlResolver.src="",b&&(this._urlMap[this._urlTemp]=b),this._urlTemp):null},destroy:function(){for(var a=0;a<this._cacheMap.length;a++){var b=this._cacheMap[a];for(var c in b)"__default"!==c&&"__missing"!==c&&(b[c].destroy&&b[c].destroy(),delete b[c])}this._urlMap=null,this._urlResolver=null,this._urlTemp=null}},c.Cache.prototype.constructor=c.Cache,c.Loader=function(a){this.game=a,this.cache=a.cache,this.resetLocked=!1,this.isLoading=!1,this.hasLoaded=!1,this.preloadSprite=null,this.crossOrigin=!1,this.baseURL="",this.path="",this.onLoadStart=new c.Signal,this.onLoadComplete=new c.Signal,this.onPackComplete=new c.Signal,this.onFileStart=new c.Signal,this.onFileComplete=new c.Signal,this.onFileError=new c.Signal,this.useXDomainRequest=!1,this._warnedAboutXDomainRequest=!1,this.enableParallel=!0,this.maxParallelDownloads=4,this._withSyncPointDepth=0,this._fileList=[],this._flightQueue=[],this._processingHead=0,this._fileLoadStarted=!1,this._totalPackCount=0,this._totalFileCount=0,this._loadedPackCount=0,this._loadedFileCount=0},c.Loader.TEXTURE_ATLAS_JSON_ARRAY=0,c.Loader.TEXTURE_ATLAS_JSON_HASH=1,c.Loader.TEXTURE_ATLAS_XML_STARLING=2,c.Loader.PHYSICS_LIME_CORONA_JSON=3,c.Loader.PHYSICS_PHASER_JSON=4,c.Loader.TEXTURE_ATLAS_JSON_PYXEL=5,c.Loader.prototype={setPreloadSprite:function(a,b){b=b||0,this.preloadSprite={sprite:a,direction:b,width:a.width,height:a.height,rect:null},0===b?this.preloadSprite.rect=new c.Rectangle(0,0,1,a.height):this.preloadSprite.rect=new c.Rectangle(0,0,a.width,1),a.crop(this.preloadSprite.rect),a.visible=!0},resize:function(){this.preloadSprite&&this.preloadSprite.height!==this.preloadSprite.sprite.height&&(this.preloadSprite.rect.height=this.preloadSprite.sprite.height)},checkKeyExists:function(a,b){return this.getAssetIndex(a,b)>-1},getAssetIndex:function(a,b){for(var c=-1,d=0;d<this._fileList.length;d++){var e=this._fileList[d];if(e.type===a&&e.key===b&&(c=d,!e.loaded&&!e.loading))break}return c},getAsset:function(a,b){var c=this.getAssetIndex(a,b);return c>-1?{index:c,file:this._fileList[c]}:!1},reset:function(a,b){void 0===b&&(b=!1),this.resetLocked||(a&&(this.preloadSprite=null),this.isLoading=!1,this._processingHead=0,this._fileList.length=0,this._flightQueue.length=0,this._fileLoadStarted=!1,this._totalFileCount=0,this._totalPackCount=0,this._loadedPackCount=0,this._loadedFileCount=0,b&&(this.onLoadStart.removeAll(),this.onLoadComplete.removeAll(),this.onPackComplete.removeAll(),this.onFileStart.removeAll(),this.onFileComplete.removeAll(),this.onFileError.removeAll()))},addToFileList:function(a,b,c,d,e,f){if(void 0===e&&(e=!1),void 0===b||""===b)return console.warn("Phaser.Loader: Invalid or no key given of type "+a),this;if(void 0===c||null===c){if(!f)return console.warn("Phaser.Loader: No URL given for file type: "+a+" key: "+b),this;c=b+f}var g={type:a,key:b,path:this.path,url:c,syncPoint:this._withSyncPointDepth>0,data:null,loading:!1,loaded:!1,error:!1};if(d)for(var h in d)g[h]=d[h];var i=this.getAssetIndex(a,b);if(e&&i>-1){var j=this._fileList[i];j.loading||j.loaded?(this._fileList.push(g),this._totalFileCount++):this._fileList[i]=g}else-1===i&&(this._fileList.push(g),this._totalFileCount++);return this},replaceInFileList:function(a,b,c,d){return this.addToFileList(a,b,c,d,!0)},pack:function(a,b,c,d){if(void 0===b&&(b=null),void 0===c&&(c=null),void 0===d&&(d=null),!b&&!c)return console.warn("Phaser.Loader.pack - Both url and data are null. One must be set."),this;var e={type:"packfile",key:a,url:b,path:this.path,syncPoint:!0,data:null,loading:!1,loaded:!1,error:!1,callbackContext:d};c&&("string"==typeof c&&(c=JSON.parse(c)),e.data=c||{},e.loaded=!0);for(var f=0;f<this._fileList.length+1;f++){var g=this._fileList[f];if(!g||!g.loaded&&!g.loading&&"packfile"!==g.type){this._fileList.splice(f,1,e),this._totalPackCount++;break}}return this},image:function(a,b,c){return this.addToFileList("image",a,b,void 0,c,".png")},images:function(a,b){if(Array.isArray(b))for(var c=0;c<a.length;c++)this.image(a[c],b[c]);else for(var c=0;c<a.length;c++)this.image(a[c]);return this},text:function(a,b,c){return this.addToFileList("text",a,b,void 0,c,".txt")},json:function(a,b,c){return this.addToFileList("json",a,b,void 0,c,".json")},shader:function(a,b,c){return this.addToFileList("shader",a,b,void 0,c,".frag")},xml:function(a,b,c){return this.addToFileList("xml",a,b,void 0,c,".xml")},script:function(a,b,c,d){return void 0===c&&(c=!1),c!==!1&&void 0===d&&(d=this),this.addToFileList("script",a,b,{syncPoint:!0,callback:c,callbackContext:d},!1,".js")},binary:function(a,b,c,d){return void 0===c&&(c=!1),c!==!1&&void 0===d&&(d=c),this.addToFileList("binary",a,b,{callback:c,callbackContext:d},!1,".bin")},spritesheet:function(a,b,c,d,e,f,g){return void 0===e&&(e=-1),void 0===f&&(f=0),void 0===g&&(g=0),this.addToFileList("spritesheet",a,b,{frameWidth:c,frameHeight:d,frameMax:e,margin:f,spacing:g},!1,".png")},audio:function(a,b,c){return this.game.sound.noAudio?this:(void 0===c&&(c=!0),"string"==typeof b&&(b=[b]),this.addToFileList("audio",a,b,{buffer:null,autoDecode:c}))},audiosprite:function(a,b,c,d,e){return this.game.sound.noAudio?this:(void 0===c&&(c=null),void 0===d&&(d=null),void 0===e&&(e=!0),this.audio(a,b,e),c?this.json(a+"-audioatlas",c):d?("string"==typeof d&&(d=JSON.parse(d)),this.cache.addJSON(a+"-audioatlas","",d)):console.warn("Phaser.Loader.audiosprite - You must specify either a jsonURL or provide a jsonData object"),this)},video:function(a,b,c,d){return void 0===c&&(c=this.game.device.firefox?"loadeddata":"canplaythrough"),void 0===d&&(d=!1),"string"==typeof b&&(b=[b]),this.addToFileList("video",a,b,{buffer:null,asBlob:d,loadEvent:c})},tilemap:function(a,b,d,e){if(void 0===b&&(b=null),void 0===d&&(d=null),void 0===e&&(e=c.Tilemap.CSV),b||d||(b=e===c.Tilemap.CSV?a+".csv":a+".json"),d){switch(e){case c.Tilemap.CSV:break;case c.Tilemap.TILED_JSON:"string"==typeof d&&(d=JSON.parse(d))}this.cache.addTilemap(a,null,d,e)}else this.addToFileList("tilemap",a,b,{format:e});return this},physics:function(a,b,d,e){return void 0===b&&(b=null),void 0===d&&(d=null),void 0===e&&(e=c.Physics.LIME_CORONA_JSON),b||d||(b=a+".json"),d?("string"==typeof d&&(d=JSON.parse(d)),this.cache.addPhysicsData(a,null,d,e)):this.addToFileList("physics",a,b,{format:e}),this},bitmapFont:function(a,b,c,d,e,f){if((void 0===b||null===b)&&(b=a+".png"),void 0===c&&(c=null),void 0===d&&(d=null),null===c&&null===d&&(c=a+".xml"),void 0===e&&(e=0),void 0===f&&(f=0),c)this.addToFileList("bitmapfont",a,b,{atlasURL:c,xSpacing:e,ySpacing:f});else if("string"==typeof d){var g,h;try{g=JSON.parse(d)}catch(i){h=this.parseXml(d)}if(!h&&!g)throw new Error("Phaser.Loader. Invalid Bitmap Font atlas given");this.addToFileList("bitmapfont",a,b,{atlasURL:null,atlasData:g||h,atlasType:g?"json":"xml",xSpacing:e,ySpacing:f})}return this},atlasJSONArray:function(a,b,d,e){return this.atlas(a,b,d,e,c.Loader.TEXTURE_ATLAS_JSON_ARRAY)},atlasJSONHash:function(a,b,d,e){return this.atlas(a,b,d,e,c.Loader.TEXTURE_ATLAS_JSON_HASH)},atlasXML:function(a,b,d,e){return void 0===d&&(d=null),void 0===e&&(e=null),d||e||(d=a+".xml"),this.atlas(a,b,d,e,c.Loader.TEXTURE_ATLAS_XML_STARLING)},atlas:function(a,b,d,e,f){if((void 0===b||null===b)&&(b=a+".png"),void 0===d&&(d=null),void 0===e&&(e=null),void 0===f&&(f=c.Loader.TEXTURE_ATLAS_JSON_ARRAY),d||e||(d=f===c.Loader.TEXTURE_ATLAS_XML_STARLING?a+".xml":a+".json"),d)this.addToFileList("textureatlas",a,b,{atlasURL:d,format:f});else{switch(f){case c.Loader.TEXTURE_ATLAS_JSON_ARRAY:"string"==typeof e&&(e=JSON.parse(e));break;case c.Loader.TEXTURE_ATLAS_XML_STARLING:if("string"==typeof e){var g=this.parseXml(e);if(!g)throw new Error("Phaser.Loader. Invalid Texture Atlas XML given");e=g}}this.addToFileList("textureatlas",a,b,{atlasURL:null,atlasData:e,format:f})}return this},withSyncPoint:function(a,b){this._withSyncPointDepth++;try{a.call(b||this,this)}finally{this._withSyncPointDepth--}return this},addSyncPoint:function(a,b){var c=this.getAsset(a,b);return c&&(c.file.syncPoint=!0),this},removeFile:function(a,b){var c=this.getAsset(a,b);c&&(c.loaded||c.loading||this._fileList.splice(c.index,1))},removeAll:function(){this._fileList.length=0,this._flightQueue.length=0},start:function(){this.isLoading||(this.hasLoaded=!1,this.isLoading=!0,this.updateProgress(),this.processLoadQueue())},processLoadQueue:function(){if(!this.isLoading)return console.warn("Phaser.Loader - active loading canceled / reset"),void this.finishedLoading(!0);for(var a=0;a<this._flightQueue.length;a++){var b=this._flightQueue[a];(b.loaded||b.error)&&(this._flightQueue.splice(a,1),a--,b.loading=!1,b.requestUrl=null,b.requestObject=null,b.error&&this.onFileError.dispatch(b.key,b),"packfile"!==b.type?(this._loadedFileCount++,this.onFileComplete.dispatch(this.progress,b.key,!b.error,this._loadedFileCount,this._totalFileCount)):"packfile"===b.type&&b.error&&(this._loadedPackCount++,this.onPackComplete.dispatch(b.key,!b.error,this._loadedPackCount,this._totalPackCount)))}for(var d=!1,e=this.enableParallel?c.Math.clamp(this.maxParallelDownloads,1,12):1,a=this._processingHead;a<this._fileList.length;a++){var b=this._fileList[a];if("packfile"===b.type&&!b.error&&b.loaded&&a===this._processingHead&&(this.processPack(b),this._loadedPackCount++,this.onPackComplete.dispatch(b.key,!b.error,this._loadedPackCount,this._totalPackCount)),b.loaded||b.error?a===this._processingHead&&(this._processingHead=a+1):!b.loading&&this._flightQueue.length<e&&("packfile"!==b.type||b.data?d||(this._fileLoadStarted||(this._fileLoadStarted=!0,this.onLoadStart.dispatch()),this._flightQueue.push(b),b.loading=!0,this.onFileStart.dispatch(this.progress,b.key,b.url),this.loadFile(b)):(this._flightQueue.push(b),b.loading=!0,this.loadFile(b))),!b.loaded&&b.syncPoint&&(d=!0),this._flightQueue.length>=e||d&&this._loadedPackCount===this._totalPackCount)break}if(this.updateProgress(),this._processingHead>=this._fileList.length)this.finishedLoading();else if(!this._flightQueue.length){console.warn("Phaser.Loader - aborting: processing queue empty, loading may have stalled");var f=this;setTimeout(function(){f.finishedLoading(!0)},2e3)}},finishedLoading:function(a){this.hasLoaded||(this.hasLoaded=!0,this.isLoading=!1,a||this._fileLoadStarted||(this._fileLoadStarted=!0,this.onLoadStart.dispatch()),this.onLoadComplete.dispatch(),this.reset(),this.game.state.loadComplete())},asyncComplete:function(a,b){void 0===b&&(b=""),a.loaded=!0,a.error=!!b,b&&(a.errorMessage=b,console.warn("Phaser.Loader - "+a.type+"["+a.key+"]: "+b)),this.processLoadQueue()},processPack:function(a){var b=a.data[a.key];if(!b)return void console.warn("Phaser.Loader - "+a.key+": pack has data, but not for pack key");for(var d=0;d<b.length;d++){var e=b[d];switch(e.type){case"image":this.image(e.key,e.url,e.overwrite);break;case"text":this.text(e.key,e.url,e.overwrite);break;case"json":this.json(e.key,e.url,e.overwrite);break;case"xml":this.xml(e.key,e.url,e.overwrite);break;case"script":this.script(e.key,e.url,e.callback,a.callbackContext||this);break;case"binary":this.binary(e.key,e.url,e.callback,a.callbackContext||this);break;case"spritesheet":this.spritesheet(e.key,e.url,e.frameWidth,e.frameHeight,e.frameMax,e.margin,e.spacing);break;case"video":this.video(e.key,e.urls);break;case"audio":this.audio(e.key,e.urls,e.autoDecode);break;case"audiosprite":this.audiosprite(e.key,e.urls,e.jsonURL,e.jsonData,e.autoDecode);break;case"tilemap":this.tilemap(e.key,e.url,e.data,c.Tilemap[e.format]);break;case"physics":this.physics(e.key,e.url,e.data,c.Loader[e.format]);break;case"bitmapFont":this.bitmapFont(e.key,e.textureURL,e.atlasURL,e.atlasData,e.xSpacing,e.ySpacing);break;case"atlasJSONArray":this.atlasJSONArray(e.key,e.textureURL,e.atlasURL,e.atlasData);break;case"atlasJSONHash":this.atlasJSONHash(e.key,e.textureURL,e.atlasURL,e.atlasData);break;case"atlasXML":this.atlasXML(e.key,e.textureURL,e.atlasURL,e.atlasData);break;case"atlas":this.atlas(e.key,e.textureURL,e.atlasURL,e.atlasData,c.Loader[e.format]);break;case"shader":this.shader(e.key,e.url,e.overwrite)}}},transformUrl:function(a,b){return a?a.match(/^(?:blob:|data:|http:\/\/|https:\/\/|\/\/)/)?a:this.baseURL+b.path+a:!1},loadFile:function(a){switch(a.type){case"packfile":this.xhrLoad(a,this.transformUrl(a.url,a),"text",this.fileComplete);break;case"image":case"spritesheet":case"textureatlas":case"bitmapfont":this.loadImageTag(a);break;case"audio":a.url=this.getAudioURL(a.url),a.url?this.game.sound.usingWebAudio?this.xhrLoad(a,this.transformUrl(a.url,a),"arraybuffer",this.fileComplete):this.game.sound.usingAudioTag&&this.loadAudioTag(a):this.fileError(a,null,"No supported audio URL specified or device does not have audio playback support");break;case"video":a.url=this.getVideoURL(a.url),a.url?a.asBlob?this.xhrLoad(a,this.transformUrl(a.url,a),"arraybuffer",this.fileComplete):this.loadVideoTag(a):this.fileError(a,null,"No supported video URL specified or device does not have video playback support");break;case"json":this.xhrLoad(a,this.transformUrl(a.url,a),"text",this.jsonLoadComplete);break;case"xml":this.xhrLoad(a,this.transformUrl(a.url,a),"text",this.xmlLoadComplete);break;case"tilemap":a.format===c.Tilemap.TILED_JSON?this.xhrLoad(a,this.transformUrl(a.url,a),"text",this.jsonLoadComplete):a.format===c.Tilemap.CSV?this.xhrLoad(a,this.transformUrl(a.url,a),"text",this.csvLoadComplete):this.asyncComplete(a,"invalid Tilemap format: "+a.format);break;case"text":case"script":case"shader":case"physics":this.xhrLoad(a,this.transformUrl(a.url,a),"text",this.fileComplete);break;case"binary":this.xhrLoad(a,this.transformUrl(a.url,a),"arraybuffer",this.fileComplete)}},loadImageTag:function(a){var b=this;a.data=new Image,a.data.name=a.key,this.crossOrigin&&(a.data.crossOrigin=this.crossOrigin),a.data.onload=function(){a.data.onload&&(a.data.onload=null,a.data.onerror=null,b.fileComplete(a))},a.data.onerror=function(){a.data.onload&&(a.data.onload=null,a.data.onerror=null,b.fileError(a))},a.data.src=this.transformUrl(a.url,a),a.data.complete&&a.data.width&&a.data.height&&(a.data.onload=null,a.data.onerror=null,this.fileComplete(a))},loadVideoTag:function(a){var b=this;a.data=document.createElement("video"),a.data.name=a.key,a.data.controls=!1,a.data.autoplay=!1;var d=function(){a.data.removeEventListener(a.loadEvent,d,!1),a.data.onerror=null,a.data.canplay=!0,c.GAMES[b.game.id].load.fileComplete(a)};a.data.onerror=function(){a.data.removeEventListener(a.loadEvent,d,!1),a.data.onerror=null,a.data.canplay=!1,b.fileError(a)},a.data.addEventListener(a.loadEvent,d,!1),a.data.src=this.transformUrl(a.url,a),a.data.load()},loadAudioTag:function(a){var b=this;if(this.game.sound.touchLocked)a.data=new Audio,a.data.name=a.key,a.data.preload="auto",a.data.src=this.transformUrl(a.url,a),this.fileComplete(a);else{a.data=new Audio,a.data.name=a.key;var d=function(){a.data.removeEventListener("canplaythrough",d,!1),a.data.onerror=null,c.GAMES[b.game.id].load.fileComplete(a)};a.data.onerror=function(){a.data.removeEventListener("canplaythrough",d,!1),a.data.onerror=null,b.fileError(a)},a.data.preload="auto",a.data.src=this.transformUrl(a.url,a),a.data.addEventListener("canplaythrough",d,!1),a.data.load()}},xhrLoad:function(a,b,c,d,e){if(this.useXDomainRequest&&window.XDomainRequest)return void this.xhrLoadWithXDR(a,b,c,d,e);var f=new XMLHttpRequest;f.open("GET",b,!0),f.responseType=c,e=e||this.fileError;var g=this;f.onload=function(){try{return d.call(g,a,f)}catch(b){g.hasLoaded?window.console&&console.error(b):g.asyncComplete(a,b.message||"Exception")}},f.onerror=function(){try{return e.call(g,a,f)}catch(b){g.hasLoaded?window.console&&console.error(b):g.asyncComplete(a,b.message||"Exception")}},a.requestObject=f,a.requestUrl=b,f.send()},xhrLoadWithXDR:function(a,b,c,d,e){this._warnedAboutXDomainRequest||this.game.device.ie&&!(this.game.device.ieVersion>=10)||(this._warnedAboutXDomainRequest=!0,console.warn("Phaser.Loader - using XDomainRequest outside of IE 9"));var f=new window.XDomainRequest;f.open("GET",b,!0),f.responseType=c,f.timeout=3e3,e=e||this.fileError;var g=this;f.onerror=function(){try{return e.call(g,a,f)}catch(b){g.asyncComplete(a,b.message||"Exception")}},f.ontimeout=function(){try{return e.call(g,a,f)}catch(b){g.asyncComplete(a,b.message||"Exception")}},f.onprogress=function(){},f.onload=function(){try{return d.call(g,a,f)}catch(b){g.asyncComplete(a,b.message||"Exception")}},a.requestObject=f,a.requestUrl=b,setTimeout(function(){f.send()},0)},getVideoURL:function(a){for(var b=0;b<a.length;b++){var c,d=a[b];if(d.uri)d=d.uri,c=d.type;else{if(0===d.indexOf("blob:")||0===d.indexOf("data:"))return d;d.indexOf("?")>=0&&(d=d.substr(0,d.indexOf("?")));var e=d.substr((Math.max(0,d.lastIndexOf("."))||1/0)+1);c=e.toLowerCase()}if(this.game.device.canPlayVideo(c))return a[b]}return null},getAudioURL:function(a){if(this.game.sound.noAudio)return null;for(var b=0;b<a.length;b++){var c,d=a[b];if(d.uri)d=d.uri,c=d.type;else{if(0===d.indexOf("blob:")||0===d.indexOf("data:"))return d;d.indexOf("?")>=0&&(d=d.substr(0,d.indexOf("?")));var e=d.substr((Math.max(0,d.lastIndexOf("."))||1/0)+1);c=e.toLowerCase()}if(this.game.device.canPlayAudio(c))return a[b]}return null},fileError:function(a,b,c){var d=a.requestUrl||this.transformUrl(a.url,a),e="error loading asset from URL "+d;!c&&b&&(c=b.status),c&&(e=e+" ("+c+")"),this.asyncComplete(a,e)},fileComplete:function(a,b){var d=!0;switch(a.type){case"packfile":var e=JSON.parse(b.responseText);a.data=e||{};break;case"image":this.cache.addImage(a.key,a.url,a.data);break;case"spritesheet":this.cache.addSpriteSheet(a.key,a.url,a.data,a.frameWidth,a.frameHeight,a.frameMax,a.margin,a.spacing);break;case"textureatlas":if(null==a.atlasURL)this.cache.addTextureAtlas(a.key,a.url,a.data,a.atlasData,a.format);else if(d=!1,a.format==c.Loader.TEXTURE_ATLAS_JSON_ARRAY||a.format==c.Loader.TEXTURE_ATLAS_JSON_HASH||a.format==c.Loader.TEXTURE_ATLAS_JSON_PYXEL)this.xhrLoad(a,this.transformUrl(a.atlasURL,a),"text",this.jsonLoadComplete);else{if(a.format!=c.Loader.TEXTURE_ATLAS_XML_STARLING)throw new Error("Phaser.Loader. Invalid Texture Atlas format: "+a.format);this.xhrLoad(a,this.transformUrl(a.atlasURL,a),"text",this.xmlLoadComplete)}break;case"bitmapfont":a.atlasURL?(d=!1,this.xhrLoad(a,this.transformUrl(a.atlasURL,a),"text",function(a,b){var c;try{c=JSON.parse(b.responseText)}catch(d){}c?(a.atlasType="json",this.jsonLoadComplete(a,b)):(a.atlasType="xml",this.xmlLoadComplete(a,b))})):this.cache.addBitmapFont(a.key,a.url,a.data,a.atlasData,a.atlasType,a.xSpacing,a.ySpacing);break;case"video":if(a.asBlob)try{a.data=new Blob([new Uint8Array(b.response)])}catch(f){throw new Error("Phaser.Loader. Unable to parse video file as Blob: "+a.key)}this.cache.addVideo(a.key,a.url,a.data,a.asBlob);break;case"audio":this.game.sound.usingWebAudio?(a.data=b.response,this.cache.addSound(a.key,a.url,a.data,!0,!1),a.autoDecode&&this.game.sound.decode(a.key)):this.cache.addSound(a.key,a.url,a.data,!1,!0);break;case"text":a.data=b.responseText,this.cache.addText(a.key,a.url,a.data);break;case"shader":a.data=b.responseText,this.cache.addShader(a.key,a.url,a.data);break;case"physics": +var e=JSON.parse(b.responseText);this.cache.addPhysicsData(a.key,a.url,e,a.format);break;case"script":a.data=document.createElement("script"),a.data.language="javascript",a.data.type="text/javascript",a.data.defer=!1,a.data.text=b.responseText,document.head.appendChild(a.data),a.callback&&(a.data=a.callback.call(a.callbackContext,a.key,b.responseText));break;case"binary":a.callback?a.data=a.callback.call(a.callbackContext,a.key,b.response):a.data=b.response,this.cache.addBinary(a.key,a.data)}d&&this.asyncComplete(a)},jsonLoadComplete:function(a,b){var c=JSON.parse(b.responseText);"tilemap"===a.type?this.cache.addTilemap(a.key,a.url,c,a.format):"bitmapfont"===a.type?this.cache.addBitmapFont(a.key,a.url,a.data,c,a.atlasType,a.xSpacing,a.ySpacing):"json"===a.type?this.cache.addJSON(a.key,a.url,c):this.cache.addTextureAtlas(a.key,a.url,a.data,c,a.format),this.asyncComplete(a)},csvLoadComplete:function(a,b){var c=b.responseText;this.cache.addTilemap(a.key,a.url,c,a.format),this.asyncComplete(a)},xmlLoadComplete:function(a,b){var c=b.responseText,d=this.parseXml(c);if(!d){var e=b.responseType||b.contentType;return console.warn("Phaser.Loader - "+a.key+": invalid XML ("+e+")"),void this.asyncComplete(a,"invalid XML")}"bitmapfont"===a.type?this.cache.addBitmapFont(a.key,a.url,a.data,d,a.atlasType,a.xSpacing,a.ySpacing):"textureatlas"===a.type?this.cache.addTextureAtlas(a.key,a.url,a.data,d,a.format):"xml"===a.type&&this.cache.addXML(a.key,a.url,d),this.asyncComplete(a)},parseXml:function(a){var b;try{if(window.DOMParser){var c=new DOMParser;b=c.parseFromString(a,"text/xml")}else b=new ActiveXObject("Microsoft.XMLDOM"),b.async="false",b.loadXML(a)}catch(d){b=null}return b&&b.documentElement&&!b.getElementsByTagName("parsererror").length?b:null},updateProgress:function(){this.preloadSprite&&(0===this.preloadSprite.direction?this.preloadSprite.rect.width=Math.floor(this.preloadSprite.width/100*this.progress):this.preloadSprite.rect.height=Math.floor(this.preloadSprite.height/100*this.progress),this.preloadSprite.sprite?this.preloadSprite.sprite.updateCrop():this.preloadSprite=null)},totalLoadedFiles:function(){return this._loadedFileCount},totalQueuedFiles:function(){return this._totalFileCount-this._loadedFileCount},totalLoadedPacks:function(){return this._totalPackCount},totalQueuedPacks:function(){return this._totalPackCount-this._loadedPackCount}},Object.defineProperty(c.Loader.prototype,"progressFloat",{get:function(){var a=this._loadedFileCount/this._totalFileCount*100;return c.Math.clamp(a||0,0,100)}}),Object.defineProperty(c.Loader.prototype,"progress",{get:function(){return Math.round(this.progressFloat)}}),c.Loader.prototype.constructor=c.Loader,c.LoaderParser={bitmapFont:function(a,b,c,d){return this.xmlBitmapFont(a,b,c,d)},xmlBitmapFont:function(a,b,c,d){var e={},f=a.getElementsByTagName("info")[0],g=a.getElementsByTagName("common")[0];e.font=f.getAttribute("face"),e.size=parseInt(f.getAttribute("size"),10),e.lineHeight=parseInt(g.getAttribute("lineHeight"),10)+d,e.chars={};for(var h=a.getElementsByTagName("char"),i=0;i<h.length;i++){var j=parseInt(h[i].getAttribute("id"),10);e.chars[j]={x:parseInt(h[i].getAttribute("x"),10),y:parseInt(h[i].getAttribute("y"),10),width:parseInt(h[i].getAttribute("width"),10),height:parseInt(h[i].getAttribute("height"),10),xOffset:parseInt(h[i].getAttribute("xoffset"),10),yOffset:parseInt(h[i].getAttribute("yoffset"),10),xAdvance:parseInt(h[i].getAttribute("xadvance"),10)+c,kerning:{}}}var k=a.getElementsByTagName("kerning");for(i=0;i<k.length;i++){var l=parseInt(k[i].getAttribute("first"),10),m=parseInt(k[i].getAttribute("second"),10),n=parseInt(k[i].getAttribute("amount"),10);e.chars[m].kerning[l]=n}return this.finalizeBitmapFont(b,e)},jsonBitmapFont:function(a,b,c,d){var e={font:a.font.info._face,size:parseInt(a.font.info._size,10),lineHeight:parseInt(a.font.common._lineHeight,10)+d,chars:{}};return a.font.chars["char"].forEach(function(a){var b=parseInt(a._id,10);e.chars[b]={x:parseInt(a._x,10),y:parseInt(a._y,10),width:parseInt(a._width,10),height:parseInt(a._height,10),xOffset:parseInt(a._xoffset,10),yOffset:parseInt(a._yoffset,10),xAdvance:parseInt(a._xadvance,10)+c,kerning:{}}}),a.font.kernings&&a.font.kernings.kerning&&a.font.kernings.kerning.forEach(function(a){e.chars[a._second].kerning[a._first]=parseInt(a._amount,10)}),this.finalizeBitmapFont(b,e)},finalizeBitmapFont:function(a,b){return Object.keys(b.chars).forEach(function(d){var e=b.chars[d];e.texture=new PIXI.Texture(a,new c.Rectangle(e.x,e.y,e.width,e.height))}),b}},c.AudioSprite=function(a,b){this.game=a,this.key=b,this.config=this.game.cache.getJSON(b+"-audioatlas"),this.autoplayKey=null,this.autoplay=!1,this.sounds={};for(var c in this.config.spritemap){var d=this.config.spritemap[c],e=this.game.add.sound(this.key);e.addMarker(c,d.start,d.end-d.start,null,d.loop),this.sounds[c]=e}this.config.autoplay&&(this.autoplayKey=this.config.autoplay,this.play(this.autoplayKey),this.autoplay=this.sounds[this.autoplayKey])},c.AudioSprite.prototype={play:function(a,b){return void 0===b&&(b=1),this.sounds[a].play(a,null,b)},stop:function(a){if(a)this.sounds[a].stop();else for(var b in this.sounds)this.sounds[b].stop()},get:function(a){return this.sounds[a]}},c.AudioSprite.prototype.constructor=c.AudioSprite,c.Sound=function(a,b,d,e,f){void 0===d&&(d=1),void 0===e&&(e=!1),void 0===f&&(f=a.sound.connectToMaster),this.game=a,this.name=b,this.key=b,this.loop=e,this.volume=d,this.markers={},this.context=null,this.autoplay=!1,this.totalDuration=0,this.startTime=0,this.currentTime=0,this.duration=0,this.durationMS=0,this.position=0,this.stopTime=0,this.paused=!1,this.pausedPosition=0,this.pausedTime=0,this.isPlaying=!1,this.currentMarker="",this.fadeTween=null,this.pendingPlayback=!1,this.override=!1,this.allowMultiple=!1,this.usingWebAudio=this.game.sound.usingWebAudio,this.usingAudioTag=this.game.sound.usingAudioTag,this.externalNode=null,this.masterGainNode=null,this.gainNode=null,this._sound=null,this.usingWebAudio?(this.context=this.game.sound.context,this.masterGainNode=this.game.sound.masterGain,void 0===this.context.createGain?this.gainNode=this.context.createGainNode():this.gainNode=this.context.createGain(),this.gainNode.gain.value=d*this.game.sound.volume,f&&this.gainNode.connect(this.masterGainNode)):this.usingAudioTag&&(this.game.cache.getSound(b)&&this.game.cache.isSoundReady(b)?(this._sound=this.game.cache.getSoundData(b),this.totalDuration=0,this._sound.duration&&(this.totalDuration=this._sound.duration)):this.game.cache.onSoundUnlock.add(this.soundHasUnlocked,this)),this.onDecoded=new c.Signal,this.onPlay=new c.Signal,this.onPause=new c.Signal,this.onResume=new c.Signal,this.onLoop=new c.Signal,this.onStop=new c.Signal,this.onMute=new c.Signal,this.onMarkerComplete=new c.Signal,this.onFadeComplete=new c.Signal,this._volume=d,this._buffer=null,this._muted=!1,this._tempMarker=0,this._tempPosition=0,this._tempVolume=0,this._muteVolume=0,this._tempLoop=0,this._paused=!1,this._onDecodedEventDispatched=!1},c.Sound.prototype={soundHasUnlocked:function(a){a===this.key&&(this._sound=this.game.cache.getSoundData(this.key),this.totalDuration=this._sound.duration)},addMarker:function(a,b,c,d,e){(void 0===d||null===d)&&(d=1),void 0===e&&(e=!1),this.markers[a]={name:a,start:b,stop:b+c,volume:d,duration:c,durationMS:1e3*c,loop:e}},removeMarker:function(a){delete this.markers[a]},onEndedHandler:function(){this._sound.onended=null,this.isPlaying=!1,this.stop()},update:function(){return this.game.cache.checkSoundKey(this.key)?(this.isDecoded&&!this._onDecodedEventDispatched&&(this.onDecoded.dispatch(this),this._onDecodedEventDispatched=!0),this.pendingPlayback&&this.game.cache.isSoundReady(this.key)&&(this.pendingPlayback=!1,this.play(this._tempMarker,this._tempPosition,this._tempVolume,this._tempLoop)),void(this.isPlaying&&(this.currentTime=this.game.time.time-this.startTime,this.currentTime>=this.durationMS&&(this.usingWebAudio?this.loop?(this.onLoop.dispatch(this),""===this.currentMarker?(this.currentTime=0,this.startTime=this.game.time.time):(this.onMarkerComplete.dispatch(this.currentMarker,this),this.play(this.currentMarker,0,this.volume,!0,!0))):""!==this.currentMarker&&this.stop():this.loop?(this.onLoop.dispatch(this),this.play(this.currentMarker,0,this.volume,!0,!0)):this.stop())))):void this.destroy()},loopFull:function(a){this.play(null,0,a,!0)},play:function(a,b,c,d,e){if((void 0===a||a===!1||null===a)&&(a=""),void 0===e&&(e=!0),this.isPlaying&&!this.allowMultiple&&!e&&!this.override)return this;if(this._sound&&this.isPlaying&&!this.allowMultiple&&(this.override||e))if(this.usingWebAudio)if(this.externalNode?this._sound.disconnect(this.externalNode):this._sound.disconnect(this.gainNode),void 0===this._sound.stop)this._sound.noteOff(0);else try{this._sound.stop(0)}catch(f){}else this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0);if(""===a&&Object.keys(this.markers).length>0)return this;if(""!==a){if(this.currentMarker=a,!this.markers[a])return this;this.position=this.markers[a].start,this.volume=this.markers[a].volume,this.loop=this.markers[a].loop,this.duration=this.markers[a].duration,this.durationMS=this.markers[a].durationMS,"undefined"!=typeof c&&(this.volume=c),"undefined"!=typeof d&&(this.loop=d),this._tempMarker=a,this._tempPosition=this.position,this._tempVolume=this.volume,this._tempLoop=this.loop}else b=b||0,void 0===c&&(c=this._volume),void 0===d&&(d=this.loop),this.position=b,this.volume=c,this.loop=d,this.duration=0,this.durationMS=0,this._tempMarker=a,this._tempPosition=b,this._tempVolume=c,this._tempLoop=d;return this.usingWebAudio?this.game.cache.isSoundDecoded(this.key)?(this._sound=this.context.createBufferSource(),this.externalNode?this._sound.connect(this.externalNode):this._sound.connect(this.gainNode),this._buffer=this.game.cache.getSoundData(this.key),this._sound.buffer=this._buffer,this.loop&&""===a&&(this._sound.loop=!0),this.loop||""!==a||(this._sound.onended=this.onEndedHandler.bind(this)),this.totalDuration=this._sound.buffer.duration,0===this.duration&&(this.duration=this.totalDuration,this.durationMS=Math.ceil(1e3*this.totalDuration)),void 0===this._sound.start?this._sound.noteGrainOn(0,this.position,this.duration):this.loop&&""===a?this._sound.start(0,0):this._sound.start(0,this.position,this.duration),this.isPlaying=!0,this.startTime=this.game.time.time,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):(this.pendingPlayback=!0,this.game.cache.getSound(this.key)&&this.game.cache.getSound(this.key).isDecoding===!1&&this.game.sound.decode(this.key,this)):this.game.cache.getSound(this.key)&&this.game.cache.getSound(this.key).locked?(this.game.cache.reloadSound(this.key),this.pendingPlayback=!0):this._sound&&(this.game.device.cocoonJS||4===this._sound.readyState)?(this._sound.play(),this.totalDuration=this._sound.duration,0===this.duration&&(this.duration=this.totalDuration,this.durationMS=1e3*this.totalDuration),this._sound.currentTime=this.position,this._sound.muted=this._muted,this._muted?this._sound.volume=0:this._sound.volume=this._volume,this.isPlaying=!0,this.startTime=this.game.time.time,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):this.pendingPlayback=!0,this},restart:function(a,b,c,d){a=a||"",b=b||0,c=c||1,void 0===d&&(d=!1),this.play(a,b,c,d,!0)},pause:function(){this.isPlaying&&this._sound&&(this.paused=!0,this.pausedPosition=this.currentTime,this.pausedTime=this.game.time.time,this.onPause.dispatch(this),this.stop())},resume:function(){if(this.paused&&this._sound){if(this.usingWebAudio){var a=this.position+this.pausedPosition/1e3;this._sound=this.context.createBufferSource(),this._sound.buffer=this._buffer,this.externalNode?this._sound.connect(this.externalNode):this._sound.connect(this.gainNode),this.loop&&(this._sound.loop=!0),this.loop||""!==this.currentMarker||(this._sound.onended=this.onEndedHandler.bind(this));var b=this.duration-this.pausedPosition/1e3;void 0===this._sound.start?this._sound.noteGrainOn(0,a,b):this.loop&&this.game.device.chrome?42===this.game.device.chromeVersion?this._sound.start(0):this._sound.start(0,a):this._sound.start(0,a,b)}else this._sound.play();this.isPlaying=!0,this.paused=!1,this.startTime+=this.game.time.time-this.pausedTime,this.onResume.dispatch(this)}},stop:function(){if(this.isPlaying&&this._sound)if(this.usingWebAudio)if(this.externalNode?this._sound.disconnect(this.externalNode):this._sound.disconnect(this.gainNode),void 0===this._sound.stop)this._sound.noteOff(0);else try{this._sound.stop(0)}catch(a){}else this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0);this.pendingPlayback=!1,this.isPlaying=!1;var b=this.currentMarker;""!==this.currentMarker&&this.onMarkerComplete.dispatch(this.currentMarker,this),this.currentMarker="",null!==this.fadeTween&&this.fadeTween.stop(),this.paused||this.onStop.dispatch(this,b)},fadeIn:function(a,b,c){void 0===b&&(b=!1),void 0===c&&(c=this.currentMarker),this.paused||(this.play(c,0,0,b),this.fadeTo(a,1))},fadeOut:function(a){this.fadeTo(a,0)},fadeTo:function(a,b){if(this.isPlaying&&!this.paused&&b!==this.volume){if(void 0===a&&(a=1e3),void 0===b)return void console.warn("Phaser.Sound.fadeTo: No Volume Specified.");this.fadeTween=this.game.add.tween(this).to({volume:b},a,c.Easing.Linear.None,!0),this.fadeTween.onComplete.add(this.fadeComplete,this)}},fadeComplete:function(){this.onFadeComplete.dispatch(this,this.volume),0===this.volume&&this.stop()},destroy:function(a){void 0===a&&(a=!0),this.stop(),a?this.game.sound.remove(this):(this.markers={},this.context=null,this._buffer=null,this.externalNode=null,this.onDecoded.dispose(),this.onPlay.dispose(),this.onPause.dispose(),this.onResume.dispose(),this.onLoop.dispose(),this.onStop.dispose(),this.onMute.dispose(),this.onMarkerComplete.dispose())}},c.Sound.prototype.constructor=c.Sound,Object.defineProperty(c.Sound.prototype,"isDecoding",{get:function(){return this.game.cache.getSound(this.key).isDecoding}}),Object.defineProperty(c.Sound.prototype,"isDecoded",{get:function(){return this.game.cache.isSoundDecoded(this.key)}}),Object.defineProperty(c.Sound.prototype,"mute",{get:function(){return this._muted||this.game.sound.mute},set:function(a){a=a||!1,a!==this._muted&&(a?(this._muted=!0,this._muteVolume=this._tempVolume,this.usingWebAudio?this.gainNode.gain.value=0:this.usingAudioTag&&this._sound&&(this._sound.volume=0)):(this._muted=!1,this.usingWebAudio?this.gainNode.gain.value=this._muteVolume:this.usingAudioTag&&this._sound&&(this._sound.volume=this._muteVolume)),this.onMute.dispatch(this))}}),Object.defineProperty(c.Sound.prototype,"volume",{get:function(){return this._volume},set:function(a){return this.game.device.firefox&&this.usingAudioTag&&(a=this.game.math.clamp(a,0,1)),this._muted?void(this._muteVolume=a):(this._tempVolume=a,this._volume=a,void(this.usingWebAudio?this.gainNode.gain.value=a:this.usingAudioTag&&this._sound&&(this._sound.volume=a)))}}),c.SoundManager=function(a){this.game=a,this.onSoundDecode=new c.Signal,this.onVolumeChange=new c.Signal,this.onMute=new c.Signal,this.onUnMute=new c.Signal,this.context=null,this.usingWebAudio=!1,this.usingAudioTag=!1,this.noAudio=!1,this.connectToMaster=!0,this.touchLocked=!1,this.channels=32,this._codeMuted=!1,this._muted=!1,this._unlockSource=null,this._volume=1,this._sounds=[],this._watchList=new c.ArraySet,this._watching=!1,this._watchCallback=null,this._watchContext=null},c.SoundManager.prototype={boot:function(){if(this.game.device.iOS&&this.game.device.webAudio===!1&&(this.channels=1),window.PhaserGlobal){if(window.PhaserGlobal.disableAudio===!0)return this.noAudio=!0,void(this.touchLocked=!1);if(window.PhaserGlobal.disableWebAudio===!0)return this.usingAudioTag=!0,void(this.touchLocked=!1)}if(window.PhaserGlobal&&window.PhaserGlobal.audioContext)this.context=window.PhaserGlobal.audioContext;else if(window.AudioContext)try{this.context=new window.AudioContext}catch(a){this.context=null,this.usingWebAudio=!1,this.touchLocked=!1}else if(window.webkitAudioContext)try{this.context=new window.webkitAudioContext}catch(a){this.context=null,this.usingWebAudio=!1,this.touchLocked=!1}if(null===this.context){if(void 0===window.Audio)return void(this.noAudio=!0);this.usingAudioTag=!0}else this.usingWebAudio=!0,void 0===this.context.createGain?this.masterGain=this.context.createGainNode():this.masterGain=this.context.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this.context.destination);this.noAudio||(!this.game.device.cocoonJS&&this.game.device.iOS||window.PhaserGlobal&&window.PhaserGlobal.fakeiOSTouchLock)&&this.setTouchLock()},setTouchLock:function(){this.game.device.iOSVersion>8?this.game.input.touch.addTouchLockCallback(this.unlock,this,!0):this.game.input.touch.addTouchLockCallback(this.unlock,this),this.touchLocked=!0},unlock:function(){if(this.noAudio||!this.touchLocked||null!==this._unlockSource)return!0;if(this.usingAudioTag)this.touchLocked=!1,this._unlockSource=null;else if(this.usingWebAudio){var a=this.context.createBuffer(1,1,22050);this._unlockSource=this.context.createBufferSource(),this._unlockSource.buffer=a,this._unlockSource.connect(this.context.destination),void 0===this._unlockSource.start?this._unlockSource.noteOn(0):this._unlockSource.start(0)}return!0},stopAll:function(){if(!this.noAudio)for(var a=0;a<this._sounds.length;a++)this._sounds[a]&&this._sounds[a].stop()},pauseAll:function(){if(!this.noAudio)for(var a=0;a<this._sounds.length;a++)this._sounds[a]&&this._sounds[a].pause()},resumeAll:function(){if(!this.noAudio)for(var a=0;a<this._sounds.length;a++)this._sounds[a]&&this._sounds[a].resume()},decode:function(a,b){b=b||null;var c=this.game.cache.getSoundData(a);if(c&&this.game.cache.isSoundDecoded(a)===!1){this.game.cache.updateSound(a,"isDecoding",!0);var d=this;try{this.context.decodeAudioData(c,function(c){c&&(d.game.cache.decodedSound(a,c),d.onSoundDecode.dispatch(a,b))})}catch(e){}}},setDecodedCallback:function(a,b,d){"string"==typeof a&&(a=[a]),this._watchList.reset();for(var e=0;e<a.length;e++)a[e]instanceof c.Sound?this.game.cache.isSoundDecoded(a[e].key)||this._watchList.add(a[e].key):this.game.cache.isSoundDecoded(a[e])||this._watchList.add(a[e]);0===this._watchList.total?(this._watching=!1,b.call(d)):(this._watching=!0,this._watchCallback=b,this._watchContext=d)},update:function(){if(!this.noAudio){!this.touchLocked||null===this._unlockSource||this._unlockSource.playbackState!==this._unlockSource.PLAYING_STATE&&this._unlockSource.playbackState!==this._unlockSource.FINISHED_STATE||(this.touchLocked=!1,this._unlockSource=null);for(var a=0;a<this._sounds.length;a++)this._sounds[a].update();if(this._watching){for(var b=this._watchList.first;b;)this.game.cache.isSoundDecoded(b)&&this._watchList.remove(b),b=this._watchList.next;0===this._watchList.total&&(this._watching=!1,this._watchCallback.call(this._watchContext))}}},add:function(a,b,d,e){void 0===b&&(b=1),void 0===d&&(d=!1),void 0===e&&(e=this.connectToMaster);var f=new c.Sound(this.game,a,b,d,e);return this._sounds.push(f),f},addSprite:function(a){var b=new c.AudioSprite(this.game,a);return b},remove:function(a){for(var b=this._sounds.length;b--;)if(this._sounds[b]===a)return this._sounds[b].destroy(!1),this._sounds.splice(b,1),!0;return!1},removeByKey:function(a){for(var b=this._sounds.length,c=0;b--;)this._sounds[b].key===a&&(this._sounds[b].destroy(!1),this._sounds.splice(b,1),c++);return c},play:function(a,b,c){if(!this.noAudio){var d=this.add(a,b,c);return d.play(),d}},setMute:function(){if(!this._muted){this._muted=!0,this.usingWebAudio&&(this._muteVolume=this.masterGain.gain.value,this.masterGain.gain.value=0);for(var a=0;a<this._sounds.length;a++)this._sounds[a].usingAudioTag&&(this._sounds[a].mute=!0);this.onMute.dispatch()}},unsetMute:function(){if(this._muted&&!this._codeMuted){this._muted=!1,this.usingWebAudio&&(this.masterGain.gain.value=this._muteVolume);for(var a=0;a<this._sounds.length;a++)this._sounds[a].usingAudioTag&&(this._sounds[a].mute=!1);this.onUnMute.dispatch()}},destroy:function(){this.stopAll();for(var a=0;a<this._sounds.length;a++)this._sounds[a]&&this._sounds[a].destroy();this._sounds=[],this.onSoundDecode.dispose(),this.context&&window.PhaserGlobal&&(window.PhaserGlobal.audioContext=this.context)}},c.SoundManager.prototype.constructor=c.SoundManager,Object.defineProperty(c.SoundManager.prototype,"mute",{get:function(){return this._muted},set:function(a){if(a=a||!1){if(this._muted)return;this._codeMuted=!0,this.setMute()}else{if(!this._muted)return;this._codeMuted=!1,this.unsetMute()}}}),Object.defineProperty(c.SoundManager.prototype,"volume",{get:function(){return this._volume},set:function(a){if(0>a?a=0:a>1&&(a=1),this._volume!==a){if(this._volume=a,this.usingWebAudio)this.masterGain.gain.value=a;else for(var b=0;b<this._sounds.length;b++)this._sounds[b].usingAudioTag&&(this._sounds[b].volume=this._sounds[b].volume*a);this.onVolumeChange.dispatch(a)}}}),c.ScaleManager=function(a,b,d){this.game=a,this.dom=c.DOM,this.grid=null,this.width=0,this.height=0,this.minWidth=null,this.maxWidth=null,this.minHeight=null,this.maxHeight=null,this.offset=new c.Point,this.forceLandscape=!1,this.forcePortrait=!1,this.incorrectOrientation=!1,this._pageAlignHorizontally=!1,this._pageAlignVertically=!1,this.onOrientationChange=new c.Signal,this.enterIncorrectOrientation=new c.Signal,this.leaveIncorrectOrientation=new c.Signal,this.fullScreenTarget=null,this._createdFullScreenTarget=null,this.onFullScreenInit=new c.Signal,this.onFullScreenChange=new c.Signal,this.onFullScreenError=new c.Signal,this.screenOrientation=this.dom.getScreenOrientation(),this.scaleFactor=new c.Point(1,1),this.scaleFactorInversed=new c.Point(1,1),this.margin={left:0,top:0,right:0,bottom:0,x:0,y:0},this.bounds=new c.Rectangle,this.aspectRatio=0,this.sourceAspectRatio=0,this.event=null,this.windowConstraints={right:"layout",bottom:""},this.compatibility={supportsFullScreen:!1,orientationFallback:null,noMargins:!1,scrollTo:null,forceMinimumDocumentHeight:!1,canExpandParent:!0,clickTrampoline:""},this._scaleMode=c.ScaleManager.NO_SCALE,this._fullScreenScaleMode=c.ScaleManager.NO_SCALE,this.parentIsWindow=!1,this.parentNode=null,this.parentScaleFactor=new c.Point(1,1),this.trackParentInterval=2e3,this.onSizeChange=new c.Signal,this.onResize=null,this.onResizeContext=null,this._pendingScaleMode=null,this._fullScreenRestore=null,this._gameSize=new c.Rectangle,this._userScaleFactor=new c.Point(1,1),this._userScaleTrim=new c.Point(0,0),this._lastUpdate=0,this._updateThrottle=0,this._updateThrottleReset=100,this._parentBounds=new c.Rectangle,this._tempBounds=new c.Rectangle,this._lastReportedCanvasSize=new c.Rectangle,this._lastReportedGameSize=new c.Rectangle,this._booted=!1,a.config&&this.parseConfig(a.config),this.setupScale(b,d)},c.ScaleManager.EXACT_FIT=0,c.ScaleManager.NO_SCALE=1,c.ScaleManager.SHOW_ALL=2,c.ScaleManager.RESIZE=3,c.ScaleManager.USER_SCALE=4,c.ScaleManager.prototype={boot:function(){var a=this.compatibility;a.supportsFullScreen=this.game.device.fullscreen&&!this.game.device.cocoonJS,this.game.device.iPad||this.game.device.webApp||this.game.device.desktop||(this.game.device.android&&!this.game.device.chrome?a.scrollTo=new c.Point(0,1):a.scrollTo=new c.Point(0,0)),this.game.device.desktop?(a.orientationFallback="screen",a.clickTrampoline="when-not-mouse"):(a.orientationFallback="",a.clickTrampoline="");var b=this;this._orientationChange=function(a){return b.orientationChange(a)},this._windowResize=function(a){return b.windowResize(a)},window.addEventListener("orientationchange",this._orientationChange,!1),window.addEventListener("resize",this._windowResize,!1),this.compatibility.supportsFullScreen&&(this._fullScreenChange=function(a){return b.fullScreenChange(a)},this._fullScreenError=function(a){return b.fullScreenError(a)},document.addEventListener("webkitfullscreenchange",this._fullScreenChange,!1),document.addEventListener("mozfullscreenchange",this._fullScreenChange,!1),document.addEventListener("MSFullscreenChange",this._fullScreenChange,!1),document.addEventListener("fullscreenchange",this._fullScreenChange,!1),document.addEventListener("webkitfullscreenerror",this._fullScreenError,!1),document.addEventListener("mozfullscreenerror",this._fullScreenError,!1),document.addEventListener("MSFullscreenError",this._fullScreenError,!1),document.addEventListener("fullscreenerror",this._fullScreenError,!1)),this.game.onResume.add(this._gameResumed,this),this.dom.getOffset(this.game.canvas,this.offset),this.bounds.setTo(this.offset.x,this.offset.y,this.width,this.height),this.setGameSize(this.game.width,this.game.height),this.screenOrientation=this.dom.getScreenOrientation(this.compatibility.orientationFallback),c.FlexGrid&&(this.grid=new c.FlexGrid(this,this.width,this.height)),this._booted=!0,this._pendingScaleMode&&(this.scaleMode=this._pendingScaleMode,this._pendingScaleMode=null)},parseConfig:function(a){a.scaleMode&&(this._booted?this.scaleMode=a.scaleMode:this._pendingScaleMode=a.scaleMode),a.fullScreenScaleMode&&(this.fullScreenScaleMode=a.fullScreenScaleMode),a.fullScreenTarget&&(this.fullScreenTarget=a.fullScreenTarget)},setupScale:function(a,b){var d,e=new c.Rectangle;""!==this.game.parent&&("string"==typeof this.game.parent?d=document.getElementById(this.game.parent):this.game.parent&&1===this.game.parent.nodeType&&(d=this.game.parent)),d?(this.parentNode=d,this.parentIsWindow=!1,this.getParentBounds(this._parentBounds),e.width=this._parentBounds.width,e.height=this._parentBounds.height,this.offset.set(this._parentBounds.x,this._parentBounds.y)):(this.parentNode=null,this.parentIsWindow=!0,e.width=this.dom.visualBounds.width,e.height=this.dom.visualBounds.height,this.offset.set(0,0));var f=0,g=0;"number"==typeof a?f=a:(this.parentScaleFactor.x=parseInt(a,10)/100,f=e.width*this.parentScaleFactor.x),"number"==typeof b?g=b:(this.parentScaleFactor.y=parseInt(b,10)/100,g=e.height*this.parentScaleFactor.y),this._gameSize.setTo(0,0,f,g),this.updateDimensions(f,g,!1)},_gameResumed:function(){this.queueUpdate(!0)},setGameSize:function(a,b){this._gameSize.setTo(0,0,a,b),this.currentScaleMode!==c.ScaleManager.RESIZE&&this.updateDimensions(a,b,!0),this.queueUpdate(!0)},setUserScale:function(a,b,c,d){this._userScaleFactor.setTo(a,b),this._userScaleTrim.setTo(0|c,0|d),this.queueUpdate(!0)},setResizeCallback:function(a,b){this.onResize=a,this.onResizeContext=b},signalSizeChange:function(){if(!c.Rectangle.sameDimensions(this,this._lastReportedCanvasSize)||!c.Rectangle.sameDimensions(this.game,this._lastReportedGameSize)){var a=this.width,b=this.height;this._lastReportedCanvasSize.setTo(0,0,a,b),this._lastReportedGameSize.setTo(0,0,this.game.width,this.game.height),this.grid&&this.grid.onResize(a,b),this.onSizeChange.dispatch(this,a,b),this.currentScaleMode===c.ScaleManager.RESIZE&&(this.game.state.resize(a,b),this.game.load.resize(a,b))}},setMinMax:function(a,b,c,d){this.minWidth=a,this.minHeight=b,"undefined"!=typeof c&&(this.maxWidth=c),"undefined"!=typeof d&&(this.maxHeight=d)},preUpdate:function(){if(!(this.game.time.time<this._lastUpdate+this._updateThrottle)){var a=this._updateThrottle;this._updateThrottleReset=a>=400?0:100,this.dom.getOffset(this.game.canvas,this.offset);var b=this._parentBounds.width,d=this._parentBounds.height,e=this.getParentBounds(this._parentBounds),f=e.width!==b||e.height!==d,g=this.updateOrientationState();(f||g)&&(this.onResize&&this.onResize.call(this.onResizeContext,this,e),this.updateLayout(),this.signalSizeChange());var h=2*this._updateThrottle;this._updateThrottle<a&&(h=Math.min(a,this._updateThrottleReset)),this._updateThrottle=c.Math.clamp(h,25,this.trackParentInterval),this._lastUpdate=this.game.time.time}},pauseUpdate:function(){this.preUpdate(),this._updateThrottle=this.trackParentInterval},updateDimensions:function(a,b,c){this.width=a*this.parentScaleFactor.x,this.height=b*this.parentScaleFactor.y,this.game.width=this.width,this.game.height=this.height,this.sourceAspectRatio=this.width/this.height,this.updateScalingAndBounds(),c&&(this.game.renderer.resize(this.width,this.height),this.game.camera.setSize(this.width,this.height),this.game.world.resize(this.width,this.height))},updateScalingAndBounds:function(){this.scaleFactor.x=this.game.width/this.width,this.scaleFactor.y=this.game.height/this.height,this.scaleFactorInversed.x=this.width/this.game.width,this.scaleFactorInversed.y=this.height/this.game.height,this.aspectRatio=this.width/this.height,this.game.canvas&&this.dom.getOffset(this.game.canvas,this.offset),this.bounds.setTo(this.offset.x,this.offset.y,this.width,this.height),this.game.input&&this.game.input.scale&&this.game.input.scale.setTo(this.scaleFactor.x,this.scaleFactor.y)},forceOrientation:function(a,b){void 0===b&&(b=!1),this.forceLandscape=a,this.forcePortrait=b,this.queueUpdate(!0)},classifyOrientation:function(a){return"portrait-primary"===a||"portrait-secondary"===a?"portrait":"landscape-primary"===a||"landscape-secondary"===a?"landscape":null},updateOrientationState:function(){var a=this.screenOrientation,b=this.incorrectOrientation;this.screenOrientation=this.dom.getScreenOrientation(this.compatibility.orientationFallback),this.incorrectOrientation=this.forceLandscape&&!this.isLandscape||this.forcePortrait&&!this.isPortrait;var c=a!==this.screenOrientation,d=b!==this.incorrectOrientation;return d&&(this.incorrectOrientation?this.enterIncorrectOrientation.dispatch():this.leaveIncorrectOrientation.dispatch()),(c||d)&&this.onOrientationChange.dispatch(this,a,b),c||d},orientationChange:function(a){this.event=a,this.queueUpdate(!0)},windowResize:function(a){this.event=a,this.queueUpdate(!0)},scrollTop:function(){var a=this.compatibility.scrollTo;a&&window.scrollTo(a.x,a.y)},refresh:function(){this.scrollTop(),this.queueUpdate(!0)},updateLayout:function(){var a=this.currentScaleMode;if(a===c.ScaleManager.RESIZE)return void this.reflowGame();if(this.scrollTop(),this.compatibility.forceMinimumDocumentHeight&&(document.documentElement.style.minHeight=window.innerHeight+"px"),this.incorrectOrientation?this.setMaximum():a===c.ScaleManager.EXACT_FIT?this.setExactFit():a===c.ScaleManager.SHOW_ALL?!this.isFullScreen&&this.boundingParent&&this.compatibility.canExpandParent?(this.setShowAll(!0),this.resetCanvas(),this.setShowAll()):this.setShowAll():a===c.ScaleManager.NO_SCALE?(this.width=this.game.width,this.height=this.game.height):a===c.ScaleManager.USER_SCALE&&(this.width=this.game.width*this._userScaleFactor.x-this._userScaleTrim.x,this.height=this.game.height*this._userScaleFactor.y-this._userScaleTrim.y),!this.compatibility.canExpandParent&&(a===c.ScaleManager.SHOW_ALL||a===c.ScaleManager.USER_SCALE)){var b=this.getParentBounds(this._tempBounds);this.width=Math.min(this.width,b.width),this.height=Math.min(this.height,b.height)}this.width=0|this.width,this.height=0|this.height,this.reflowCanvas()},getParentBounds:function(a){var b=a||new c.Rectangle,d=this.boundingParent,e=this.dom.visualBounds,f=this.dom.layoutBounds;if(d){var g=d.getBoundingClientRect(),h=d.offsetParent?d.offsetParent.getBoundingClientRect():d.getBoundingClientRect();b.setTo(g.left-h.left,g.top-h.top,g.width,g.height);var i=this.windowConstraints;if(i.right){var j="layout"===i.right?f:e;b.right=Math.min(b.right,j.width)}if(i.bottom){var j="layout"===i.bottom?f:e;b.bottom=Math.min(b.bottom,j.height)}}else b.setTo(0,0,e.width,e.height);return b.setTo(Math.round(b.x),Math.round(b.y),Math.round(b.width),Math.round(b.height)),b},alignCanvas:function(a,b){var c=this.getParentBounds(this._tempBounds),d=this.game.canvas,e=this.margin;if(a){e.left=e.right=0;var f=d.getBoundingClientRect();if(this.width<c.width&&!this.incorrectOrientation){var g=f.left-c.x,h=c.width/2-this.width/2;h=Math.max(h,0);var i=h-g;e.left=Math.round(i)}d.style.marginLeft=e.left+"px",0!==e.left&&(e.right=-(c.width-f.width-e.left),d.style.marginRight=e.right+"px")}if(b){e.top=e.bottom=0; +var f=d.getBoundingClientRect();if(this.height<c.height&&!this.incorrectOrientation){var g=f.top-c.y,h=c.height/2-this.height/2;h=Math.max(h,0);var i=h-g;e.top=Math.round(i)}d.style.marginTop=e.top+"px",0!==e.top&&(e.bottom=-(c.height-f.height-e.top),d.style.marginBottom=e.bottom+"px")}e.x=e.left,e.y=e.top},reflowGame:function(){this.resetCanvas("","");var a=this.getParentBounds(this._tempBounds);this.updateDimensions(a.width,a.height,!0)},reflowCanvas:function(){this.incorrectOrientation||(this.width=c.Math.clamp(this.width,this.minWidth||0,this.maxWidth||this.width),this.height=c.Math.clamp(this.height,this.minHeight||0,this.maxHeight||this.height)),this.resetCanvas(),this.compatibility.noMargins||(this.isFullScreen&&this._createdFullScreenTarget?this.alignCanvas(!0,!0):this.alignCanvas(this.pageAlignHorizontally,this.pageAlignVertically)),this.updateScalingAndBounds()},resetCanvas:function(a,b){void 0===a&&(a=this.width+"px"),void 0===b&&(b=this.height+"px");var c=this.game.canvas;this.compatibility.noMargins||(c.style.marginLeft="",c.style.marginTop="",c.style.marginRight="",c.style.marginBottom=""),c.style.width=a,c.style.height=b},queueUpdate:function(a){a&&(this._parentBounds.width=0,this._parentBounds.height=0),this._updateThrottle=this._updateThrottleReset},reset:function(a){a&&this.grid&&this.grid.reset()},setMaximum:function(){this.width=this.dom.visualBounds.width,this.height=this.dom.visualBounds.height},setShowAll:function(a){var b,c=this.getParentBounds(this._tempBounds),d=c.width,e=c.height;b=a?Math.max(e/this.game.height,d/this.game.width):Math.min(e/this.game.height,d/this.game.width),this.width=Math.round(this.game.width*b),this.height=Math.round(this.game.height*b)},setExactFit:function(){var a=this.getParentBounds(this._tempBounds);this.width=a.width,this.height=a.height,this.isFullScreen||(this.maxWidth&&(this.width=Math.min(this.width,this.maxWidth)),this.maxHeight&&(this.height=Math.min(this.height,this.maxHeight)))},createFullScreenTarget:function(){var a=document.createElement("div");return a.style.margin="0",a.style.padding="0",a.style.background="#000",a},startFullScreen:function(a,b){if(this.isFullScreen)return!1;if(!this.compatibility.supportsFullScreen){var d=this;return void setTimeout(function(){d.fullScreenError()},10)}if("when-not-mouse"===this.compatibility.clickTrampoline){var e=this.game.input;if(e.activePointer&&e.activePointer!==e.mousePointer&&(b||b!==!1))return void e.activePointer.addClickTrampoline("startFullScreen",this.startFullScreen,this,[a,!1])}"undefined"!=typeof a&&this.game.renderType===c.CANVAS&&(this.game.stage.smoothed=a);var f=this.fullScreenTarget;f||(this.cleanupCreatedTarget(),this._createdFullScreenTarget=this.createFullScreenTarget(),f=this._createdFullScreenTarget);var g={targetElement:f};if(this.onFullScreenInit.dispatch(this,g),this._createdFullScreenTarget){var h=this.game.canvas,i=h.parentNode;i.insertBefore(f,h),f.appendChild(h)}return this.game.device.fullscreenKeyboard?f[this.game.device.requestFullscreen](Element.ALLOW_KEYBOARD_INPUT):f[this.game.device.requestFullscreen](),!0},stopFullScreen:function(){return this.isFullScreen&&this.compatibility.supportsFullScreen?(document[this.game.device.cancelFullscreen](),!0):!1},cleanupCreatedTarget:function(){var a=this._createdFullScreenTarget;if(a&&a.parentNode){var b=a.parentNode;b.insertBefore(this.game.canvas,a),b.removeChild(a)}this._createdFullScreenTarget=null},prepScreenMode:function(a){var b=!!this._createdFullScreenTarget,d=this._createdFullScreenTarget||this.fullScreenTarget;a?(b||this.fullScreenScaleMode===c.ScaleManager.EXACT_FIT)&&d!==this.game.canvas&&(this._fullScreenRestore={targetWidth:d.style.width,targetHeight:d.style.height},d.style.width="100%",d.style.height="100%"):(this._fullScreenRestore&&(d.style.width=this._fullScreenRestore.targetWidth,d.style.height=this._fullScreenRestore.targetHeight,this._fullScreenRestore=null),this.updateDimensions(this._gameSize.width,this._gameSize.height,!0),this.resetCanvas())},fullScreenChange:function(a){this.event=a,this.isFullScreen?(this.prepScreenMode(!0),this.updateLayout(),this.queueUpdate(!0)):(this.prepScreenMode(!1),this.cleanupCreatedTarget(),this.updateLayout(),this.queueUpdate(!0)),this.onFullScreenChange.dispatch(this,this.width,this.height)},fullScreenError:function(a){this.event=a,this.cleanupCreatedTarget(),console.warn("Phaser.ScaleManager: requestFullscreen failed or device does not support the Fullscreen API"),this.onFullScreenError.dispatch(this)},scaleSprite:function(a,b,c,d){if(void 0===b&&(b=this.width),void 0===c&&(c=this.height),void 0===d&&(d=!1),!a||!a.scale)return a;if(a.scale.x=1,a.scale.y=1,a.width<=0||a.height<=0||0>=b||0>=c)return a;var e=b,f=a.height*b/a.width,g=a.width*c/a.height,h=c,i=g>b;return i=i?d:!d,i?(a.width=Math.floor(e),a.height=Math.floor(f)):(a.width=Math.floor(g),a.height=Math.floor(h)),a},destroy:function(){this.game.onResume.remove(this._gameResumed,this),window.removeEventListener("orientationchange",this._orientationChange,!1),window.removeEventListener("resize",this._windowResize,!1),this.compatibility.supportsFullScreen&&(document.removeEventListener("webkitfullscreenchange",this._fullScreenChange,!1),document.removeEventListener("mozfullscreenchange",this._fullScreenChange,!1),document.removeEventListener("MSFullscreenChange",this._fullScreenChange,!1),document.removeEventListener("fullscreenchange",this._fullScreenChange,!1),document.removeEventListener("webkitfullscreenerror",this._fullScreenError,!1),document.removeEventListener("mozfullscreenerror",this._fullScreenError,!1),document.removeEventListener("MSFullscreenError",this._fullScreenError,!1),document.removeEventListener("fullscreenerror",this._fullScreenError,!1))}},c.ScaleManager.prototype.constructor=c.ScaleManager,Object.defineProperty(c.ScaleManager.prototype,"boundingParent",{get:function(){if(this.parentIsWindow||this.isFullScreen&&!this._createdFullScreenTarget)return null;var a=this.game.canvas&&this.game.canvas.parentNode;return a||null}}),Object.defineProperty(c.ScaleManager.prototype,"scaleMode",{get:function(){return this._scaleMode},set:function(a){return a!==this._scaleMode&&(this.isFullScreen||(this.updateDimensions(this._gameSize.width,this._gameSize.height,!0),this.queueUpdate(!0)),this._scaleMode=a),this._scaleMode}}),Object.defineProperty(c.ScaleManager.prototype,"fullScreenScaleMode",{get:function(){return this._fullScreenScaleMode},set:function(a){return a!==this._fullScreenScaleMode&&(this.isFullScreen?(this.prepScreenMode(!1),this._fullScreenScaleMode=a,this.prepScreenMode(!0),this.queueUpdate(!0)):this._fullScreenScaleMode=a),this._fullScreenScaleMode}}),Object.defineProperty(c.ScaleManager.prototype,"currentScaleMode",{get:function(){return this.isFullScreen?this._fullScreenScaleMode:this._scaleMode}}),Object.defineProperty(c.ScaleManager.prototype,"pageAlignHorizontally",{get:function(){return this._pageAlignHorizontally},set:function(a){a!==this._pageAlignHorizontally&&(this._pageAlignHorizontally=a,this.queueUpdate(!0))}}),Object.defineProperty(c.ScaleManager.prototype,"pageAlignVertically",{get:function(){return this._pageAlignVertically},set:function(a){a!==this._pageAlignVertically&&(this._pageAlignVertically=a,this.queueUpdate(!0))}}),Object.defineProperty(c.ScaleManager.prototype,"isFullScreen",{get:function(){return!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)}}),Object.defineProperty(c.ScaleManager.prototype,"isPortrait",{get:function(){return"portrait"===this.classifyOrientation(this.screenOrientation)}}),Object.defineProperty(c.ScaleManager.prototype,"isLandscape",{get:function(){return"landscape"===this.classifyOrientation(this.screenOrientation)}}),Object.defineProperty(c.ScaleManager.prototype,"isGamePortrait",{get:function(){return this.height>this.width}}),Object.defineProperty(c.ScaleManager.prototype,"isGameLandscape",{get:function(){return this.width>this.height}}),c.Utils.Debug=function(a){this.game=a,this.sprite=null,this.bmd=null,this.canvas=null,this.context=null,this.font="14px Courier",this.columnWidth=100,this.lineHeight=16,this.renderShadow=!0,this.currentX=0,this.currentY=0,this.currentAlpha=1,this.dirty=!1},c.Utils.Debug.prototype={boot:function(){this.game.renderType===c.CANVAS?this.context=this.game.context:(this.bmd=this.game.make.bitmapData(this.game.width,this.game.height),this.sprite=this.game.make.image(0,0,this.bmd),this.game.stage.addChild(this.sprite),this.canvas=PIXI.CanvasPool.create(this,this.game.width,this.game.height),this.context=this.canvas.getContext("2d"))},preUpdate:function(){this.dirty&&this.sprite&&(this.bmd.clear(),this.bmd.draw(this.canvas,0,0),this.context.clearRect(0,0,this.game.width,this.game.height),this.dirty=!1)},reset:function(){this.context&&this.context.clearRect(0,0,this.game.width,this.game.height),this.sprite&&this.bmd.clear()},start:function(a,b,c,d){"number"!=typeof a&&(a=0),"number"!=typeof b&&(b=0),c=c||"rgb(255,255,255)",void 0===d&&(d=0),this.currentX=a,this.currentY=b,this.currentColor=c,this.columnWidth=d,this.dirty=!0,this.context.save(),this.context.setTransform(1,0,0,1,0,0),this.context.strokeStyle=c,this.context.fillStyle=c,this.context.font=this.font,this.context.globalAlpha=this.currentAlpha},stop:function(){this.context.restore()},line:function(){for(var a=this.currentX,b=0;b<arguments.length;b++)this.renderShadow&&(this.context.fillStyle="rgb(0,0,0)",this.context.fillText(arguments[b],a+1,this.currentY+1),this.context.fillStyle=this.currentColor),this.context.fillText(arguments[b],a,this.currentY),a+=this.columnWidth;this.currentY+=this.lineHeight},soundInfo:function(a,b,c,d){this.start(b,c,d),this.line("Sound: "+a.key+" Locked: "+a.game.sound.touchLocked),this.line("Is Ready?: "+this.game.cache.isSoundReady(a.key)+" Pending Playback: "+a.pendingPlayback),this.line("Decoded: "+a.isDecoded+" Decoding: "+a.isDecoding),this.line("Total Duration: "+a.totalDuration+" Playing: "+a.isPlaying),this.line("Time: "+a.currentTime),this.line("Volume: "+a.volume+" Muted: "+a.mute),this.line("WebAudio: "+a.usingWebAudio+" Audio: "+a.usingAudioTag),""!==a.currentMarker&&(this.line("Marker: "+a.currentMarker+" Duration: "+a.duration+" (ms: "+a.durationMS+")"),this.line("Start: "+a.markers[a.currentMarker].start+" Stop: "+a.markers[a.currentMarker].stop),this.line("Position: "+a.position)),this.stop()},cameraInfo:function(a,b,c,d){this.start(b,c,d),this.line("Camera ("+a.width+" x "+a.height+")"),this.line("X: "+a.x+" Y: "+a.y),a.bounds&&this.line("Bounds x: "+a.bounds.x+" Y: "+a.bounds.y+" w: "+a.bounds.width+" h: "+a.bounds.height),this.line("View x: "+a.view.x+" Y: "+a.view.y+" w: "+a.view.width+" h: "+a.view.height),this.line("Total in view: "+a.totalInView),this.stop()},timer:function(a,b,c,d){this.start(b,c,d),this.line("Timer (running: "+a.running+" expired: "+a.expired+")"),this.line("Next Tick: "+a.next+" Duration: "+a.duration),this.line("Paused: "+a.paused+" Length: "+a.length),this.stop()},pointer:function(a,b,c,d,e){null!=a&&(void 0===b&&(b=!1),c=c||"rgba(0,255,0,0.5)",d=d||"rgba(255,0,0,0.5)",(b!==!0||a.isUp!==!0)&&(this.start(a.x,a.y-100,e),this.context.beginPath(),this.context.arc(a.x,a.y,a.circle.radius,0,2*Math.PI),a.active?this.context.fillStyle=c:this.context.fillStyle=d,this.context.fill(),this.context.closePath(),this.context.beginPath(),this.context.moveTo(a.positionDown.x,a.positionDown.y),this.context.lineTo(a.position.x,a.position.y),this.context.lineWidth=2,this.context.stroke(),this.context.closePath(),this.line("ID: "+a.id+" Active: "+a.active),this.line("World X: "+a.worldX+" World Y: "+a.worldY),this.line("Screen X: "+a.x+" Screen Y: "+a.y+" In: "+a.withinGame),this.line("Duration: "+a.duration+" ms"),this.line("is Down: "+a.isDown+" is Up: "+a.isUp),this.stop()))},spriteInputInfo:function(a,b,c,d){this.start(b,c,d),this.line("Sprite Input: ("+a.width+" x "+a.height+")"),this.line("x: "+a.input.pointerX().toFixed(1)+" y: "+a.input.pointerY().toFixed(1)),this.line("over: "+a.input.pointerOver()+" duration: "+a.input.overDuration().toFixed(0)),this.line("down: "+a.input.pointerDown()+" duration: "+a.input.downDuration().toFixed(0)),this.line("just over: "+a.input.justOver()+" just out: "+a.input.justOut()),this.stop()},key:function(a,b,c,d){this.start(b,c,d,150),this.line("Key:",a.keyCode,"isDown:",a.isDown),this.line("justDown:",a.justDown,"justUp:",a.justUp),this.line("Time Down:",a.timeDown.toFixed(0),"duration:",a.duration.toFixed(0)),this.stop()},inputInfo:function(a,b,c){this.start(a,b,c),this.line("Input"),this.line("X: "+this.game.input.x+" Y: "+this.game.input.y),this.line("World X: "+this.game.input.worldX+" World Y: "+this.game.input.worldY),this.line("Scale X: "+this.game.input.scale.x.toFixed(1)+" Scale Y: "+this.game.input.scale.x.toFixed(1)),this.line("Screen X: "+this.game.input.activePointer.screenX+" Screen Y: "+this.game.input.activePointer.screenY),this.stop()},spriteBounds:function(a,b,c){var d=a.getBounds();d.x+=this.game.camera.x,d.y+=this.game.camera.y,this.rectangle(d,b,c)},ropeSegments:function(a,b,c){var d=a.segments,e=this;d.forEach(function(a){e.rectangle(a,b,c)},this)},spriteInfo:function(a,b,c,d){this.start(b,c,d),this.line("Sprite: ("+a.width+" x "+a.height+") anchor: "+a.anchor.x+" x "+a.anchor.y),this.line("x: "+a.x.toFixed(1)+" y: "+a.y.toFixed(1)),this.line("angle: "+a.angle.toFixed(1)+" rotation: "+a.rotation.toFixed(1)),this.line("visible: "+a.visible+" in camera: "+a.inCamera),this.line("bounds x: "+a._bounds.x.toFixed(1)+" y: "+a._bounds.y.toFixed(1)+" w: "+a._bounds.width.toFixed(1)+" h: "+a._bounds.height.toFixed(1)),this.stop()},spriteCoords:function(a,b,c,d){this.start(b,c,d,100),a.name&&this.line(a.name),this.line("x:",a.x.toFixed(2),"y:",a.y.toFixed(2)),this.line("pos x:",a.position.x.toFixed(2),"pos y:",a.position.y.toFixed(2)),this.line("world x:",a.world.x.toFixed(2),"world y:",a.world.y.toFixed(2)),this.stop()},lineInfo:function(a,b,c,d){this.start(b,c,d,80),this.line("start.x:",a.start.x.toFixed(2),"start.y:",a.start.y.toFixed(2)),this.line("end.x:",a.end.x.toFixed(2),"end.y:",a.end.y.toFixed(2)),this.line("length:",a.length.toFixed(2),"angle:",a.angle),this.stop()},pixel:function(a,b,c,d){d=d||2,this.start(),this.context.fillStyle=c,this.context.fillRect(a,b,d,d),this.stop()},geom:function(a,b,d,e){void 0===d&&(d=!0),void 0===e&&(e=0),b=b||"rgba(0,255,0,0.4)",this.start(),this.context.fillStyle=b,this.context.strokeStyle=b,a instanceof c.Rectangle||1===e?d?this.context.fillRect(a.x-this.game.camera.x,a.y-this.game.camera.y,a.width,a.height):this.context.strokeRect(a.x-this.game.camera.x,a.y-this.game.camera.y,a.width,a.height):a instanceof c.Circle||2===e?(this.context.beginPath(),this.context.arc(a.x-this.game.camera.x,a.y-this.game.camera.y,a.radius,0,2*Math.PI,!1),this.context.closePath(),d?this.context.fill():this.context.stroke()):a instanceof c.Point||3===e?this.context.fillRect(a.x-this.game.camera.x,a.y-this.game.camera.y,4,4):(a instanceof c.Line||4===e)&&(this.context.lineWidth=1,this.context.beginPath(),this.context.moveTo(a.start.x+.5-this.game.camera.x,a.start.y+.5-this.game.camera.y),this.context.lineTo(a.end.x+.5-this.game.camera.x,a.end.y+.5-this.game.camera.y),this.context.closePath(),this.context.stroke()),this.stop()},rectangle:function(a,b,c){void 0===c&&(c=!0),b=b||"rgba(0, 255, 0, 0.4)",this.start(),c?(this.context.fillStyle=b,this.context.fillRect(a.x-this.game.camera.x,a.y-this.game.camera.y,a.width,a.height)):(this.context.strokeStyle=b,this.context.strokeRect(a.x-this.game.camera.x,a.y-this.game.camera.y,a.width,a.height)),this.stop()},text:function(a,b,c,d,e){d=d||"rgb(255,255,255)",e=e||"16px Courier",this.start(),this.context.font=e,this.renderShadow&&(this.context.fillStyle="rgb(0,0,0)",this.context.fillText(a,b+1,c+1)),this.context.fillStyle=d,this.context.fillText(a,b,c),this.stop()},quadTree:function(a,b){b=b||"rgba(255,0,0,0.3)",this.start();var c=a.bounds;if(0===a.nodes.length){this.context.strokeStyle=b,this.context.strokeRect(c.x,c.y,c.width,c.height),this.text("size: "+a.objects.length,c.x+4,c.y+16,"rgb(0,200,0)","12px Courier"),this.context.strokeStyle="rgb(0,255,0)";for(var d=0;d<a.objects.length;d++)this.context.strokeRect(a.objects[d].x,a.objects[d].y,a.objects[d].width,a.objects[d].height)}else for(var d=0;d<a.nodes.length;d++)this.quadTree(a.nodes[d]);this.stop()},body:function(a,b,d){a.body&&(this.start(),a.body.type===c.Physics.ARCADE?c.Physics.Arcade.Body.render(this.context,a.body,b,d):a.body.type===c.Physics.NINJA?c.Physics.Ninja.Body.render(this.context,a.body,b,d):a.body.type===c.Physics.BOX2D&&c.Physics.Box2D.renderBody(this.context,a.body,b),this.stop())},bodyInfo:function(a,b,d,e){a.body&&(this.start(b,d,e,210),a.body.type===c.Physics.ARCADE?c.Physics.Arcade.Body.renderBodyInfo(this,a.body):a.body.type===c.Physics.BOX2D&&this.game.physics.box2d.renderBodyInfo(this,a.body),this.stop())},box2dWorld:function(){this.start(),this.context.translate(-this.game.camera.view.x,-this.game.camera.view.y,0),this.game.physics.box2d.renderDebugDraw(this.context),this.stop()},box2dBody:function(a,b){this.start(),c.Physics.Box2D.renderBody(this.context,a,b),this.stop()},destroy:function(){PIXI.CanvasPool.remove(this)}},c.Utils.Debug.prototype.constructor=c.Utils.Debug,c.DOM={getOffset:function(a,b){b=b||new c.Point;var d=a.getBoundingClientRect(),e=c.DOM.scrollY,f=c.DOM.scrollX,g=document.documentElement.clientTop,h=document.documentElement.clientLeft;return b.x=d.left+f-h,b.y=d.top+e-g,b},getBounds:function(a,b){return void 0===b&&(b=0),a=a&&!a.nodeType?a[0]:a,a&&1===a.nodeType?this.calibrate(a.getBoundingClientRect(),b):!1},calibrate:function(a,b){b=+b||0;var c={width:0,height:0,left:0,right:0,top:0,bottom:0};return c.width=(c.right=a.right+b)-(c.left=a.left-b),c.height=(c.bottom=a.bottom+b)-(c.top=a.top-b),c},getAspectRatio:function(a){a=null==a?this.visualBounds:1===a.nodeType?this.getBounds(a):a;var b=a.width,c=a.height;return"function"==typeof b&&(b=b.call(a)),"function"==typeof c&&(c=c.call(a)),b/c},inLayoutViewport:function(a,b){var c=this.getBounds(a,b);return!!c&&c.bottom>=0&&c.right>=0&&c.top<=this.layoutBounds.width&&c.left<=this.layoutBounds.height},getScreenOrientation:function(a){var b=window.screen,c=b.orientation||b.mozOrientation||b.msOrientation;if(c&&"string"==typeof c.type)return c.type;if("string"==typeof c)return c;var d="portrait-primary",e="landscape-primary";if("screen"===a)return b.height>b.width?d:e;if("viewport"===a)return this.visualBounds.height>this.visualBounds.width?d:e;if("window.orientation"===a&&"number"==typeof window.orientation)return 0===window.orientation||180===window.orientation?d:e;if(window.matchMedia){if(window.matchMedia("(orientation: portrait)").matches)return d;if(window.matchMedia("(orientation: landscape)").matches)return e}return this.visualBounds.height>this.visualBounds.width?d:e},visualBounds:new c.Rectangle,layoutBounds:new c.Rectangle,documentBounds:new c.Rectangle},c.Device.whenReady(function(a){var b=window&&"pageXOffset"in window?function(){return window.pageXOffset}:function(){return document.documentElement.scrollLeft},d=window&&"pageYOffset"in window?function(){return window.pageYOffset}:function(){return document.documentElement.scrollTop};Object.defineProperty(c.DOM,"scrollX",{get:b}),Object.defineProperty(c.DOM,"scrollY",{get:d}),Object.defineProperty(c.DOM.visualBounds,"x",{get:b}),Object.defineProperty(c.DOM.visualBounds,"y",{get:d}),Object.defineProperty(c.DOM.layoutBounds,"x",{value:0}),Object.defineProperty(c.DOM.layoutBounds,"y",{value:0});var e=a.desktop&&document.documentElement.clientWidth<=window.innerWidth&&document.documentElement.clientHeight<=window.innerHeight;if(e){var f=function(){return Math.max(window.innerWidth,document.documentElement.clientWidth)},g=function(){return Math.max(window.innerHeight,document.documentElement.clientHeight)};Object.defineProperty(c.DOM.visualBounds,"width",{get:f}),Object.defineProperty(c.DOM.visualBounds,"height",{get:g}),Object.defineProperty(c.DOM.layoutBounds,"width",{get:f}),Object.defineProperty(c.DOM.layoutBounds,"height",{get:g})}else Object.defineProperty(c.DOM.visualBounds,"width",{get:function(){return window.innerWidth}}),Object.defineProperty(c.DOM.visualBounds,"height",{get:function(){return window.innerHeight}}),Object.defineProperty(c.DOM.layoutBounds,"width",{get:function(){var a=document.documentElement.clientWidth,b=window.innerWidth;return b>a?b:a}}),Object.defineProperty(c.DOM.layoutBounds,"height",{get:function(){var a=document.documentElement.clientHeight,b=window.innerHeight;return b>a?b:a}});Object.defineProperty(c.DOM.documentBounds,"x",{value:0}),Object.defineProperty(c.DOM.documentBounds,"y",{value:0}),Object.defineProperty(c.DOM.documentBounds,"width",{get:function(){var a=document.documentElement;return Math.max(a.clientWidth,a.offsetWidth,a.scrollWidth)}}),Object.defineProperty(c.DOM.documentBounds,"height",{get:function(){var a=document.documentElement;return Math.max(a.clientHeight,a.offsetHeight,a.scrollHeight)}})},null,!0),c.ArraySet=function(a){this.position=0,this.list=a||[]},c.ArraySet.prototype={add:function(a){return this.exists(a)||this.list.push(a),a},getIndex:function(a){return this.list.indexOf(a)},getByKey:function(a,b){for(var c=this.list.length;c--;)if(this.list[c][a]===b)return this.list[c];return null},exists:function(a){return this.list.indexOf(a)>-1},reset:function(){this.list.length=0},remove:function(a){var b=this.list.indexOf(a);return b>-1?(this.list.splice(b,1),a):void 0},setAll:function(a,b){for(var c=this.list.length;c--;)this.list[c]&&(this.list[c][a]=b)},callAll:function(a){for(var b=Array.prototype.slice.call(arguments,1),c=this.list.length;c--;)this.list[c]&&this.list[c][a]&&this.list[c][a].apply(this.list[c],b)},removeAll:function(a){void 0===a&&(a=!1);for(var b=this.list.length;b--;)if(this.list[b]){var c=this.remove(this.list[b]);a&&c.destroy()}this.position=0,this.list=[]}},Object.defineProperty(c.ArraySet.prototype,"total",{get:function(){return this.list.length}}),Object.defineProperty(c.ArraySet.prototype,"first",{get:function(){return this.position=0,this.list.length>0?this.list[0]:null}}),Object.defineProperty(c.ArraySet.prototype,"next",{get:function(){return this.position<this.list.length?(this.position++,this.list[this.position]):null}}),c.ArraySet.prototype.constructor=c.ArraySet,c.ArrayUtils={getRandomItem:function(a,b,c){if(null===a)return null;void 0===b&&(b=0),void 0===c&&(c=a.length);var d=b+Math.floor(Math.random()*c);return void 0===a[d]?null:a[d]},removeRandomItem:function(a,b,c){if(null==a)return null;void 0===b&&(b=0),void 0===c&&(c=a.length);var d=b+Math.floor(Math.random()*c);if(d<a.length){var e=a.splice(d,1);return void 0===e[0]?null:e[0]}return null},shuffle:function(a){for(var b=a.length-1;b>0;b--){var c=Math.floor(Math.random()*(b+1)),d=a[b];a[b]=a[c],a[c]=d}return a},transposeMatrix:function(a){for(var b=a.length,c=a[0].length,d=new Array(c),e=0;c>e;e++){d[e]=new Array(b);for(var f=b-1;f>-1;f--)d[e][f]=a[f][e]}return d},rotateMatrix:function(a,b){if("string"!=typeof b&&(b=(b%360+360)%360),90===b||-270===b||"rotateLeft"===b)a=c.ArrayUtils.transposeMatrix(a),a=a.reverse();else if(-90===b||270===b||"rotateRight"===b)a=a.reverse(),a=c.ArrayUtils.transposeMatrix(a);else if(180===Math.abs(b)||"rotate180"===b){for(var d=0;d<a.length;d++)a[d].reverse();a=a.reverse()}return a},findClosest:function(a,b){if(!b.length)return NaN;if(1===b.length||a<b[0])return b[0];for(var c=1;b[c]<a;)c++;var d=b[c-1],e=c<b.length?b[c]:Number.POSITIVE_INFINITY;return a-d>=e-a?e:d},rotate:function(a){var b=a.shift();return a.push(b),b},numberArray:function(a,b){for(var c=[],d=a;b>=d;d++)c.push(d);return c},numberArrayStep:function(a,b,d){(void 0===a||null===a)&&(a=0),(void 0===b||null===b)&&(b=a,a=0),void 0===d&&(d=1);for(var e=[],f=Math.max(c.Math.roundAwayFromZero((b-a)/(d||1)),0),g=0;f>g;g++)e.push(a),a+=d;return e}},c.LinkedList=function(){this.next=null,this.prev=null,this.first=null,this.last=null,this.total=0},c.LinkedList.prototype={add:function(a){return 0===this.total&&null===this.first&&null===this.last?(this.first=a,this.last=a,this.next=a,a.prev=this,this.total++,a):(this.last.next=a,a.prev=this.last,this.last=a,this.total++,a)},reset:function(){this.first=null,this.last=null,this.next=null,this.prev=null,this.total=0},remove:function(a){return 1===this.total?(this.reset(),void(a.next=a.prev=null)):(a===this.first?this.first=this.first.next:a===this.last&&(this.last=this.last.prev),a.prev&&(a.prev.next=a.next),a.next&&(a.next.prev=a.prev),a.next=a.prev=null,null===this.first&&(this.last=null),void this.total--)},callAll:function(a){if(this.first&&this.last){var b=this.first;do b&&b[a]&&b[a].call(b),b=b.next;while(b!=this.last.next)}}},c.LinkedList.prototype.constructor=c.LinkedList,c.Create=function(a){this.game=a,this.bmd=null,this.canvas=null,this.ctx=null,this.palettes=[{0:"#000",1:"#9D9D9D",2:"#FFF",3:"#BE2633",4:"#E06F8B",5:"#493C2B",6:"#A46422",7:"#EB8931",8:"#F7E26B",9:"#2F484E",A:"#44891A",B:"#A3CE27",C:"#1B2632",D:"#005784",E:"#31A2F2",F:"#B2DCEF"},{0:"#000",1:"#191028",2:"#46af45",3:"#a1d685",4:"#453e78",5:"#7664fe",6:"#833129",7:"#9ec2e8",8:"#dc534b",9:"#e18d79",A:"#d6b97b",B:"#e9d8a1",C:"#216c4b",D:"#d365c8",E:"#afaab9",F:"#f5f4eb"},{0:"#000",1:"#2234d1",2:"#0c7e45",3:"#44aacc",4:"#8a3622",5:"#5c2e78",6:"#aa5c3d",7:"#b5b5b5",8:"#5e606e",9:"#4c81fb",A:"#6cd947",B:"#7be2f9",C:"#eb8a60",D:"#e23d69",E:"#ffd93f",F:"#fff"},{0:"#000",1:"#fff",2:"#8b4131",3:"#7bbdc5",4:"#8b41ac",5:"#6aac41",6:"#3931a4",7:"#d5de73",8:"#945a20",9:"#5a4100",A:"#bd736a",B:"#525252",C:"#838383",D:"#acee8b",E:"#7b73de",F:"#acacac"},{0:"#000",1:"#191028",2:"#46af45",3:"#a1d685",4:"#453e78",5:"#7664fe",6:"#833129",7:"#9ec2e8",8:"#dc534b",9:"#e18d79",A:"#d6b97b",B:"#e9d8a1",C:"#216c4b",D:"#d365c8",E:"#afaab9",F:"#fff"}]},c.Create.PALETTE_ARNE=0,c.Create.PALETTE_JMP=1,c.Create.PALETTE_CGA=2,c.Create.PALETTE_C64=3,c.Create.PALETTE_JAPANESE_MACHINE=4,c.Create.prototype={texture:function(a,b,c,d,e){void 0===c&&(c=8),void 0===d&&(d=c),void 0===e&&(e=0);var f=b[0].length*c,g=b.length*d;null===this.bmd&&(this.bmd=this.game.make.bitmapData(),this.canvas=this.bmd.canvas,this.ctx=this.bmd.context),this.bmd.resize(f,g),this.bmd.clear();for(var h=0;h<b.length;h++)for(var i=b[h],j=0;j<i.length;j++){var k=i[j];"."!==k&&" "!==k&&(this.ctx.fillStyle=this.palettes[e][k],this.ctx.fillRect(j*c,h*d,c,d))}return this.bmd.generateTexture(a)},grid:function(a,b,c,d,e,f){null===this.bmd&&(this.bmd=this.game.make.bitmapData(),this.canvas=this.bmd.canvas,this.ctx=this.bmd.context),this.bmd.resize(b,c),this.ctx.fillStyle=f;for(var g=0;c>g;g+=e)this.ctx.fillRect(0,g,b,1);for(var h=0;b>h;h+=d)this.ctx.fillRect(h,0,1,c);return this.bmd.generateTexture(a)}},c.Create.prototype.constructor=c.Create,c.FlexGrid=function(a,b,d){this.game=a.game,this.manager=a,this.width=b,this.height=d,this.boundsCustom=new c.Rectangle(0,0,b,d),this.boundsFluid=new c.Rectangle(0,0,b,d),this.boundsFull=new c.Rectangle(0,0,b,d),this.boundsNone=new c.Rectangle(0,0,b,d),this.positionCustom=new c.Point(0,0),this.positionFluid=new c.Point(0,0),this.positionFull=new c.Point(0,0),this.positionNone=new c.Point(0,0),this.scaleCustom=new c.Point(1,1),this.scaleFluid=new c.Point(1,1),this.scaleFluidInversed=new c.Point(1,1),this.scaleFull=new c.Point(1,1),this.scaleNone=new c.Point(1,1),this.customWidth=0,this.customHeight=0,this.customOffsetX=0,this.customOffsetY=0,this.ratioH=b/d,this.ratioV=d/b,this.multiplier=0,this.layers=[]},c.FlexGrid.prototype={setSize:function(a,b){this.width=a,this.height=b,this.ratioH=a/b,this.ratioV=b/a,this.scaleNone=new c.Point(1,1),this.boundsNone.width=this.width,this.boundsNone.height=this.height,this.refresh()},createCustomLayer:function(a,b,d,e){void 0===e&&(e=!0),this.customWidth=a,this.customHeight=b,this.boundsCustom.width=a,this.boundsCustom.height=b;var f=new c.FlexLayer(this,this.positionCustom,this.boundsCustom,this.scaleCustom);return e&&this.game.world.add(f),this.layers.push(f),"undefined"!=typeof d&&null!==typeof d&&f.addMultiple(d),f},createFluidLayer:function(a,b){void 0===b&&(b=!0);var d=new c.FlexLayer(this,this.positionFluid,this.boundsFluid,this.scaleFluid);return b&&this.game.world.add(d),this.layers.push(d),"undefined"!=typeof a&&null!==typeof a&&d.addMultiple(a),d},createFullLayer:function(a){var b=new c.FlexLayer(this,this.positionFull,this.boundsFull,this.scaleFluid);return this.game.world.add(b),this.layers.push(b),"undefined"!=typeof a&&b.addMultiple(a),b},createFixedLayer:function(a){var b=new c.FlexLayer(this,this.positionNone,this.boundsNone,this.scaleNone);return this.game.world.add(b),this.layers.push(b),"undefined"!=typeof a&&b.addMultiple(a),b},reset:function(){for(var a=this.layers.length;a--;)this.layers[a].persist||(this.layers[a].position=null,this.layers[a].scale=null,this.layers.slice(a,1))},onResize:function(a,b){this.ratioH=a/b,this.ratioV=b/a,this.refresh(a,b)},refresh:function(){this.multiplier=Math.min(this.manager.height/this.height,this.manager.width/this.width),this.boundsFluid.width=Math.round(this.width*this.multiplier),this.boundsFluid.height=Math.round(this.height*this.multiplier),this.scaleFluid.set(this.boundsFluid.width/this.width,this.boundsFluid.height/this.height),this.scaleFluidInversed.set(this.width/this.boundsFluid.width,this.height/this.boundsFluid.height),this.scaleFull.set(this.boundsFull.width/this.width,this.boundsFull.height/this.height),this.boundsFull.width=Math.round(this.manager.width*this.scaleFluidInversed.x),this.boundsFull.height=Math.round(this.manager.height*this.scaleFluidInversed.y),this.boundsFluid.centerOn(this.manager.bounds.centerX,this.manager.bounds.centerY),this.boundsNone.centerOn(this.manager.bounds.centerX,this.manager.bounds.centerY),this.positionFluid.set(this.boundsFluid.x,this.boundsFluid.y),this.positionNone.set(this.boundsNone.x,this.boundsNone.y)},fitSprite:function(a){this.manager.scaleSprite(a),a.x=this.manager.bounds.centerX,a.y=this.manager.bounds.centerY},debug:function(){this.game.debug.text(this.boundsFluid.width+" x "+this.boundsFluid.height,this.boundsFluid.x+4,this.boundsFluid.y+16),this.game.debug.geom(this.boundsFluid,"rgba(255,0,0,0.9",!1)}},c.FlexGrid.prototype.constructor=c.FlexGrid,c.FlexLayer=function(a,b,d,e){c.Group.call(this,a.game,null,"__flexLayer"+a.game.rnd.uuid(),!1),this.manager=a.manager,this.grid=a,this.persist=!1,this.position=b,this.bounds=d,this.scale=e,this.topLeft=d.topLeft,this.topMiddle=new c.Point(d.halfWidth,0),this.topRight=d.topRight,this.bottomLeft=d.bottomLeft,this.bottomMiddle=new c.Point(d.halfWidth,d.bottom),this.bottomRight=d.bottomRight},c.FlexLayer.prototype=Object.create(c.Group.prototype),c.FlexLayer.prototype.constructor=c.FlexLayer,c.FlexLayer.prototype.resize=function(){},c.FlexLayer.prototype.debug=function(){this.game.debug.text(this.bounds.width+" x "+this.bounds.height,this.bounds.x+4,this.bounds.y+16),this.game.debug.geom(this.bounds,"rgba(0,0,255,0.9",!1),this.game.debug.geom(this.topLeft,"rgba(255,255,255,0.9"),this.game.debug.geom(this.topMiddle,"rgba(255,255,255,0.9"),this.game.debug.geom(this.topRight,"rgba(255,255,255,0.9")},c.Color={packPixel:function(a,b,d,e){return c.Device.LITTLE_ENDIAN?(e<<24|d<<16|b<<8|a)>>>0:(a<<24|b<<16|d<<8|e)>>>0},unpackPixel:function(a,b,d,e){return(void 0===b||null===b)&&(b=c.Color.createColor()),(void 0===d||null===d)&&(d=!1),(void 0===e||null===e)&&(e=!1),c.Device.LITTLE_ENDIAN?(b.a=(4278190080&a)>>>24,b.b=(16711680&a)>>>16,b.g=(65280&a)>>>8,b.r=255&a):(b.r=(4278190080&a)>>>24,b.g=(16711680&a)>>>16,b.b=(65280&a)>>>8,b.a=255&a),b.color=a,b.rgba="rgba("+b.r+","+b.g+","+b.b+","+b.a/255+")",d&&c.Color.RGBtoHSL(b.r,b.g,b.b,b),e&&c.Color.RGBtoHSV(b.r,b.g,b.b,b),b},fromRGBA:function(a,b){return b||(b=c.Color.createColor()),b.r=(4278190080&a)>>>24,b.g=(16711680&a)>>>16,b.b=(65280&a)>>>8,b.a=255&a,b.rgba="rgba("+b.r+","+b.g+","+b.b+","+b.a+")", +b},toRGBA:function(a,b,c,d){return a<<24|b<<16|c<<8|d},RGBtoHSL:function(a,b,d,e){e||(e=c.Color.createColor(a,b,d,1)),a/=255,b/=255,d/=255;var f=Math.min(a,b,d),g=Math.max(a,b,d);if(e.h=0,e.s=0,e.l=(g+f)/2,g!==f){var h=g-f;e.s=e.l>.5?h/(2-g-f):h/(g+f),g===a?e.h=(b-d)/h+(d>b?6:0):g===b?e.h=(d-a)/h+2:g===d&&(e.h=(a-b)/h+4),e.h/=6}return e},HSLtoRGB:function(a,b,d,e){if(e?(e.r=d,e.g=d,e.b=d):e=c.Color.createColor(d,d,d),0!==b){var f=.5>d?d*(1+b):d+b-d*b,g=2*d-f;e.r=c.Color.hueToColor(g,f,a+1/3),e.g=c.Color.hueToColor(g,f,a),e.b=c.Color.hueToColor(g,f,a-1/3)}return e.r=Math.floor(255*e.r|0),e.g=Math.floor(255*e.g|0),e.b=Math.floor(255*e.b|0),c.Color.updateColor(e),e},RGBtoHSV:function(a,b,d,e){e||(e=c.Color.createColor(a,b,d,255)),a/=255,b/=255,d/=255;var f=Math.min(a,b,d),g=Math.max(a,b,d),h=g-f;return e.h=0,e.s=0===g?0:h/g,e.v=g,g!==f&&(g===a?e.h=(b-d)/h+(d>b?6:0):g===b?e.h=(d-a)/h+2:g===d&&(e.h=(a-b)/h+4),e.h/=6),e},HSVtoRGB:function(a,b,d,e){void 0===e&&(e=c.Color.createColor(0,0,0,1,a,b,0,d));var f,g,h,i=Math.floor(6*a),j=6*a-i,k=d*(1-b),l=d*(1-j*b),m=d*(1-(1-j)*b);switch(i%6){case 0:f=d,g=m,h=k;break;case 1:f=l,g=d,h=k;break;case 2:f=k,g=d,h=m;break;case 3:f=k,g=l,h=d;break;case 4:f=m,g=k,h=d;break;case 5:f=d,g=k,h=l}return e.r=Math.floor(255*f),e.g=Math.floor(255*g),e.b=Math.floor(255*h),c.Color.updateColor(e),e},hueToColor:function(a,b,c){return 0>c&&(c+=1),c>1&&(c-=1),1/6>c?a+6*(b-a)*c:.5>c?b:2/3>c?a+(b-a)*(2/3-c)*6:a},createColor:function(a,b,d,e,f,g,h,i){var j={r:a||0,g:b||0,b:d||0,a:e||1,h:f||0,s:g||0,l:h||0,v:i||0,color:0,color32:0,rgba:""};return c.Color.updateColor(j)},updateColor:function(a){return a.rgba="rgba("+a.r.toString()+","+a.g.toString()+","+a.b.toString()+","+a.a.toString()+")",a.color=c.Color.getColor(a.r,a.g,a.b),a.color32=c.Color.getColor32(a.a,a.r,a.g,a.b),a},getColor32:function(a,b,c,d){return a<<24|b<<16|c<<8|d},getColor:function(a,b,c){return a<<16|b<<8|c},RGBtoString:function(a,b,d,e,f){return void 0===e&&(e=255),void 0===f&&(f="#"),"#"===f?"#"+((1<<24)+(a<<16)+(b<<8)+d).toString(16).slice(1):"0x"+c.Color.componentToHex(e)+c.Color.componentToHex(a)+c.Color.componentToHex(b)+c.Color.componentToHex(d)},hexToRGB:function(a){var b=c.Color.hexToColor(a);return b?c.Color.getColor32(b.a,b.r,b.g,b.b):void 0},hexToColor:function(a,b){a=a.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i,function(a,b,c,d){return b+b+c+c+d+d});var d=/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);if(d){var e=parseInt(d[1],16),f=parseInt(d[2],16),g=parseInt(d[3],16);b?(b.r=e,b.g=f,b.b=g):b=c.Color.createColor(e,f,g)}return b},webToColor:function(a,b){b||(b=c.Color.createColor());var d=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(a);return d&&(b.r=parseInt(d[1],10),b.g=parseInt(d[2],10),b.b=parseInt(d[3],10),b.a=void 0!==d[4]?parseFloat(d[4]):1,c.Color.updateColor(b)),b},valueToColor:function(a,b){if(b||(b=c.Color.createColor()),"string"==typeof a)return 0===a.indexOf("rgb")?c.Color.webToColor(a,b):(b.a=1,c.Color.hexToColor(a,b));if("number"==typeof a){var d=c.Color.getRGB(a);return b.r=d.r,b.g=d.g,b.b=d.b,b.a=d.a/255,b}return b},componentToHex:function(a){var b=a.toString(16);return 1==b.length?"0"+b:b},HSVColorWheel:function(a,b){void 0===a&&(a=1),void 0===b&&(b=1);for(var d=[],e=0;359>=e;e++)d.push(c.Color.HSVtoRGB(e/359,a,b));return d},HSLColorWheel:function(a,b){void 0===a&&(a=.5),void 0===b&&(b=.5);for(var d=[],e=0;359>=e;e++)d.push(c.Color.HSLtoRGB(e/359,a,b));return d},interpolateColor:function(a,b,d,e,f){void 0===f&&(f=255);var g=c.Color.getRGB(a),h=c.Color.getRGB(b),i=(h.red-g.red)*e/d+g.red,j=(h.green-g.green)*e/d+g.green,k=(h.blue-g.blue)*e/d+g.blue;return c.Color.getColor32(f,i,j,k)},interpolateColorWithRGB:function(a,b,d,e,f,g){var h=c.Color.getRGB(a),i=(b-h.red)*g/f+h.red,j=(d-h.green)*g/f+h.green,k=(e-h.blue)*g/f+h.blue;return c.Color.getColor(i,j,k)},interpolateRGB:function(a,b,d,e,f,g,h,i){var j=(e-a)*i/h+a,k=(f-b)*i/h+b,l=(g-d)*i/h+d;return c.Color.getColor(j,k,l)},getRandomColor:function(a,b,d){if(void 0===a&&(a=0),void 0===b&&(b=255),void 0===d&&(d=255),b>255||a>b)return c.Color.getColor(255,255,255);var e=a+Math.round(Math.random()*(b-a)),f=a+Math.round(Math.random()*(b-a)),g=a+Math.round(Math.random()*(b-a));return c.Color.getColor32(d,e,f,g)},getRGB:function(a){return a>16777215?{alpha:a>>>24,red:a>>16&255,green:a>>8&255,blue:255&a,a:a>>>24,r:a>>16&255,g:a>>8&255,b:255&a}:{alpha:255,red:a>>16&255,green:a>>8&255,blue:255&a,a:255,r:a>>16&255,g:a>>8&255,b:255&a}},getWebRGB:function(a){if("object"==typeof a)return"rgba("+a.r.toString()+","+a.g.toString()+","+a.b.toString()+","+(a.a/255).toString()+")";var b=c.Color.getRGB(a);return"rgba("+b.r.toString()+","+b.g.toString()+","+b.b.toString()+","+(b.a/255).toString()+")"},getAlpha:function(a){return a>>>24},getAlphaFloat:function(a){return(a>>>24)/255},getRed:function(a){return a>>16&255},getGreen:function(a){return a>>8&255},getBlue:function(a){return 255&a},blendNormal:function(a){return a},blendLighten:function(a,b){return b>a?b:a},blendDarken:function(a,b){return b>a?a:b},blendMultiply:function(a,b){return a*b/255},blendAverage:function(a,b){return(a+b)/2},blendAdd:function(a,b){return Math.min(255,a+b)},blendSubtract:function(a,b){return Math.max(0,a+b-255)},blendDifference:function(a,b){return Math.abs(a-b)},blendNegation:function(a,b){return 255-Math.abs(255-a-b)},blendScreen:function(a,b){return 255-((255-a)*(255-b)>>8)},blendExclusion:function(a,b){return a+b-2*a*b/255},blendOverlay:function(a,b){return 128>b?2*a*b/255:255-2*(255-a)*(255-b)/255},blendSoftLight:function(a,b){return 128>b?2*((a>>1)+64)*(b/255):255-2*(255-((a>>1)+64))*(255-b)/255},blendHardLight:function(a,b){return c.Color.blendOverlay(b,a)},blendColorDodge:function(a,b){return 255===b?b:Math.min(255,(a<<8)/(255-b))},blendColorBurn:function(a,b){return 0===b?b:Math.max(0,255-(255-a<<8)/b)},blendLinearDodge:function(a,b){return c.Color.blendAdd(a,b)},blendLinearBurn:function(a,b){return c.Color.blendSubtract(a,b)},blendLinearLight:function(a,b){return 128>b?c.Color.blendLinearBurn(a,2*b):c.Color.blendLinearDodge(a,2*(b-128))},blendVividLight:function(a,b){return 128>b?c.Color.blendColorBurn(a,2*b):c.Color.blendColorDodge(a,2*(b-128))},blendPinLight:function(a,b){return 128>b?c.Color.blendDarken(a,2*b):c.Color.blendLighten(a,2*(b-128))},blendHardMix:function(a,b){return c.Color.blendVividLight(a,b)<128?0:255},blendReflect:function(a,b){return 255===b?b:Math.min(255,a*a/(255-b))},blendGlow:function(a,b){return c.Color.blendReflect(b,a)},blendPhoenix:function(a,b){return Math.min(a,b)-Math.max(a,b)+255}},c.Physics=function(a,b){b=b||{},this.game=a,this.config=b,this.arcade=null,this.p2=null,this.ninja=null,this.box2d=null,this.chipmunk=null,this.matter=null,this.parseConfig()},c.Physics.ARCADE=0,c.Physics.P2JS=1,c.Physics.NINJA=2,c.Physics.BOX2D=3,c.Physics.CHIPMUNK=4,c.Physics.MATTERJS=5,c.Physics.prototype={parseConfig:function(){this.config.hasOwnProperty("arcade")&&this.config.arcade!==!0||!c.Physics.hasOwnProperty("Arcade")||(this.arcade=new c.Physics.Arcade(this.game)),this.config.hasOwnProperty("ninja")&&this.config.ninja===!0&&c.Physics.hasOwnProperty("Ninja")&&(this.ninja=new c.Physics.Ninja(this.game)),this.config.hasOwnProperty("p2")&&this.config.p2===!0&&c.Physics.hasOwnProperty("P2")&&(this.p2=new c.Physics.P2(this.game,this.config)),this.config.hasOwnProperty("box2d")&&this.config.box2d===!0&&c.Physics.hasOwnProperty("BOX2D")&&(this.box2d=new c.Physics.BOX2D(this.game,this.config)),this.config.hasOwnProperty("matter")&&this.config.matter===!0&&c.Physics.hasOwnProperty("Matter")&&(this.matter=new c.Physics.Matter(this.game,this.config))},startSystem:function(a){a===c.Physics.ARCADE?this.arcade=new c.Physics.Arcade(this.game):a===c.Physics.P2JS?null===this.p2?this.p2=new c.Physics.P2(this.game,this.config):this.p2.reset():a===c.Physics.NINJA?this.ninja=new c.Physics.Ninja(this.game):a===c.Physics.BOX2D?null===this.box2d?this.box2d=new c.Physics.Box2D(this.game,this.config):this.box2d.reset():a===c.Physics.MATTERJS&&(null===this.matter?this.matter=new c.Physics.Matter(this.game,this.config):this.matter.reset())},enable:function(a,b,d){void 0===b&&(b=c.Physics.ARCADE),void 0===d&&(d=!1),b===c.Physics.ARCADE?this.arcade.enable(a):b===c.Physics.P2JS&&this.p2?this.p2.enable(a,d):b===c.Physics.NINJA&&this.ninja?this.ninja.enableAABB(a):b===c.Physics.BOX2D&&this.box2d?this.box2d.enable(a):b===c.Physics.MATTERJS&&this.matter&&this.matter.enable(a)},preUpdate:function(){this.p2&&this.p2.preUpdate(),this.box2d&&this.box2d.preUpdate(),this.matter&&this.matter.preUpdate()},update:function(){this.p2&&this.p2.update(),this.box2d&&this.box2d.update(),this.matter&&this.matter.update()},setBoundsToWorld:function(){this.arcade&&this.arcade.setBoundsToWorld(),this.ninja&&this.ninja.setBoundsToWorld(),this.p2&&this.p2.setBoundsToWorld(),this.box2d&&this.box2d.setBoundsToWorld(),this.matter&&this.matter.setBoundsToWorld()},clear:function(){this.p2&&this.p2.clear(),this.box2d&&this.box2d.clear(),this.matter&&this.matter.clear()},reset:function(){this.p2&&this.p2.reset(),this.box2d&&this.box2d.reset(),this.matter&&this.matter.reset()},destroy:function(){this.p2&&this.p2.destroy(),this.box2d&&this.box2d.destroy(),this.matter&&this.matter.destroy(),this.arcade=null,this.ninja=null,this.p2=null,this.box2d=null,this.matter=null}},c.Physics.prototype.constructor=c.Physics,c.Physics.Arcade=function(a){this.game=a,this.gravity=new c.Point,this.bounds=new c.Rectangle(0,0,a.world.width,a.world.height),this.checkCollision={up:!0,down:!0,left:!0,right:!0},this.maxObjects=10,this.maxLevels=4,this.OVERLAP_BIAS=4,this.forceX=!1,this.sortDirection=c.Physics.Arcade.LEFT_RIGHT,this.skipQuadTree=!0,this.isPaused=!1,this.quadTree=new c.QuadTree(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels),this._total=0,this.setBoundsToWorld()},c.Physics.Arcade.prototype.constructor=c.Physics.Arcade,c.Physics.Arcade.SORT_NONE=0,c.Physics.Arcade.LEFT_RIGHT=1,c.Physics.Arcade.RIGHT_LEFT=2,c.Physics.Arcade.TOP_BOTTOM=3,c.Physics.Arcade.BOTTOM_TOP=4,c.Physics.Arcade.prototype={setBounds:function(a,b,c,d){this.bounds.setTo(a,b,c,d)},setBoundsToWorld:function(){this.bounds.copyFrom(this.game.world.bounds)},enable:function(a,b){void 0===b&&(b=!0);var d=1;if(Array.isArray(a))for(d=a.length;d--;)a[d]instanceof c.Group?this.enable(a[d].children,b):(this.enableBody(a[d]),b&&a[d].hasOwnProperty("children")&&a[d].children.length>0&&this.enable(a[d],!0));else a instanceof c.Group?this.enable(a.children,b):(this.enableBody(a),b&&a.hasOwnProperty("children")&&a.children.length>0&&this.enable(a.children,!0))},enableBody:function(a){a.hasOwnProperty("body")&&null===a.body&&(a.body=new c.Physics.Arcade.Body(a),a.parent&&a.parent instanceof c.Group&&a.parent.addToHash(a))},updateMotion:function(a){var b=this.computeVelocity(0,a,a.angularVelocity,a.angularAcceleration,a.angularDrag,a.maxAngular)-a.angularVelocity;a.angularVelocity+=b,a.rotation+=a.angularVelocity*this.game.time.physicsElapsed,a.velocity.x=this.computeVelocity(1,a,a.velocity.x,a.acceleration.x,a.drag.x,a.maxVelocity.x),a.velocity.y=this.computeVelocity(2,a,a.velocity.y,a.acceleration.y,a.drag.y,a.maxVelocity.y)},computeVelocity:function(a,b,c,d,e,f){return void 0===f&&(f=1e4),1===a&&b.allowGravity?c+=(this.gravity.x+b.gravity.x)*this.game.time.physicsElapsed:2===a&&b.allowGravity&&(c+=(this.gravity.y+b.gravity.y)*this.game.time.physicsElapsed),d?c+=d*this.game.time.physicsElapsed:e&&(e*=this.game.time.physicsElapsed,c-e>0?c-=e:0>c+e?c+=e:c=0),c>f?c=f:-f>c&&(c=-f),c},overlap:function(a,b,c,d,e){if(c=c||null,d=d||null,e=e||c,this._total=0,!Array.isArray(a)&&Array.isArray(b))for(var f=0;f<b.length;f++)this.collideHandler(a,b[f],c,d,e,!0);else if(Array.isArray(a)&&!Array.isArray(b))for(var f=0;f<a.length;f++)this.collideHandler(a[f],b,c,d,e,!0);else if(Array.isArray(a)&&Array.isArray(b))for(var f=0;f<a.length;f++)for(var g=0;g<b.length;g++)this.collideHandler(a[f],b[g],c,d,e,!0);else this.collideHandler(a,b,c,d,e,!0);return this._total>0},collide:function(a,b,c,d,e){if(c=c||null,d=d||null,e=e||c,this._total=0,!Array.isArray(a)&&Array.isArray(b))for(var f=0;f<b.length;f++)this.collideHandler(a,b[f],c,d,e,!1);else if(Array.isArray(a)&&!Array.isArray(b))for(var f=0;f<a.length;f++)this.collideHandler(a[f],b,c,d,e,!1);else if(Array.isArray(a)&&Array.isArray(b))for(var f=0;f<a.length;f++)for(var g=0;g<b.length;g++)this.collideHandler(a[f],b[g],c,d,e,!1);else this.collideHandler(a,b,c,d,e,!1);return this._total>0},sortLeftRight:function(a,b){return a.body&&b.body?a.body.x-b.body.x:0},sortRightLeft:function(a,b){return a.body&&b.body?b.body.x-a.body.x:0},sortTopBottom:function(a,b){return a.body&&b.body?a.body.y-b.body.y:0},sortBottomTop:function(a,b){return a.body&&b.body?b.body.y-a.body.y:0},sort:function(a,b){null!==a.physicsSortDirection?b=a.physicsSortDirection:void 0===b&&(b=this.sortDirection),b===c.Physics.Arcade.LEFT_RIGHT?a.hash.sort(this.sortLeftRight):b===c.Physics.Arcade.RIGHT_LEFT?a.hash.sort(this.sortRightLeft):b===c.Physics.Arcade.TOP_BOTTOM?a.hash.sort(this.sortTopBottom):b===c.Physics.Arcade.BOTTOM_TOP&&a.hash.sort(this.sortBottomTop)},collideHandler:function(a,b,d,e,f,g){return void 0===b&&a.physicsType===c.GROUP?(this.sort(a),void this.collideGroupVsSelf(a,d,e,f,g)):void(a&&b&&a.exists&&b.exists&&(this.sortDirection!==c.Physics.Arcade.SORT_NONE&&(a.physicsType===c.GROUP&&this.sort(a),b.physicsType===c.GROUP&&this.sort(b)),a.physicsType===c.SPRITE?b.physicsType===c.SPRITE?this.collideSpriteVsSprite(a,b,d,e,f,g):b.physicsType===c.GROUP?this.collideSpriteVsGroup(a,b,d,e,f,g):b.physicsType===c.TILEMAPLAYER&&this.collideSpriteVsTilemapLayer(a,b,d,e,f,g):a.physicsType===c.GROUP?b.physicsType===c.SPRITE?this.collideSpriteVsGroup(b,a,d,e,f,g):b.physicsType===c.GROUP?this.collideGroupVsGroup(a,b,d,e,f,g):b.physicsType===c.TILEMAPLAYER&&this.collideGroupVsTilemapLayer(a,b,d,e,f,g):a.physicsType===c.TILEMAPLAYER&&(b.physicsType===c.SPRITE?this.collideSpriteVsTilemapLayer(b,a,d,e,f,g):b.physicsType===c.GROUP&&this.collideGroupVsTilemapLayer(b,a,d,e,f,g))))},collideSpriteVsSprite:function(a,b,c,d,e,f){return a.body&&b.body?(this.separate(a.body,b.body,d,e,f)&&(c&&c.call(e,a,b),this._total++),!0):!1},collideSpriteVsGroup:function(a,b,d,e,f,g){if(0!==b.length&&a.body){var h;if(this.skipQuadTree||a.body.skipQuadTree){for(var i=0;i<b.hash.length;i++)if(b.hash[i]&&b.hash[i].exists&&b.hash[i].body){if(h=b.hash[i].body,this.sortDirection===c.Physics.Arcade.LEFT_RIGHT){if(a.body.right<h.x)break;if(h.right<a.body.x)continue}else if(this.sortDirection===c.Physics.Arcade.RIGHT_LEFT){if(a.body.x>h.right)break;if(h.x>a.body.right)continue}else if(this.sortDirection===c.Physics.Arcade.TOP_BOTTOM){if(a.body.bottom<h.y)break;if(h.bottom<a.body.y)continue}else if(this.sortDirection===c.Physics.Arcade.BOTTOM_TOP){if(a.body.y>h.bottom)break;if(h.y>a.body.bottom)continue}this.collideSpriteVsSprite(a,b.hash[i],d,e,f,g)}}else{this.quadTree.clear(),this.quadTree.reset(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels),this.quadTree.populate(b);for(var j=this.quadTree.retrieve(a),i=0;i<j.length;i++)this.separate(a.body,j[i],e,f,g)&&(d&&d.call(f,a,j[i].sprite),this._total++)}}},collideGroupVsSelf:function(a,b,d,e,f){if(0!==a.length)for(var g=0;g<a.hash.length;g++)if(a.hash[g]&&a.hash[g].exists&&a.hash[g].body)for(var h=a.hash[g],i=g+1;i<a.hash.length;i++)if(a.hash[i]&&a.hash[i].exists&&a.hash[i].body){var j=a.hash[i];if(this.sortDirection===c.Physics.Arcade.LEFT_RIGHT){if(h.body.right<j.body.x)break;if(j.body.right<h.body.x)continue}else if(this.sortDirection===c.Physics.Arcade.RIGHT_LEFT){if(h.body.x>j.body.right)continue;if(j.body.x>h.body.right)break}else if(this.sortDirection===c.Physics.Arcade.TOP_BOTTOM){if(h.body.bottom<j.body.y)continue;if(j.body.bottom<h.body.y)break}else if(this.sortDirection===c.Physics.Arcade.BOTTOM_TOP){if(h.body.y>j.body.bottom)continue;if(j.body.y>h.body.bottom)break}this.collideSpriteVsSprite(h,j,b,d,e,f)}},collideGroupVsGroup:function(a,b,d,e,f,g){if(0!==a.length&&0!==b.length)for(var h=0;h<a.children.length;h++)a.children[h].exists&&(a.children[h].physicsType===c.GROUP?this.collideGroupVsGroup(a.children[h],b,d,e,f,g):this.collideSpriteVsGroup(a.children[h],b,d,e,f,g))},separate:function(a,b,c,d,e){if(!a.enable||!b.enable||!this.intersects(a,b))return!1;if(c&&c.call(d,a.sprite,b.sprite)===!1)return!1;var f=!1;return f=this.forceX||Math.abs(this.gravity.y+a.gravity.y)<Math.abs(this.gravity.x+a.gravity.x)?this.separateX(a,b,e)||this.separateY(a,b,e):this.separateY(a,b,e)||this.separateX(a,b,e),e?!0:f},intersects:function(a,b){return a.right<=b.position.x?!1:a.bottom<=b.position.y?!1:a.position.x>=b.right?!1:a.position.y>=b.bottom?!1:!0},separateX:function(a,b,c){if(a.immovable&&b.immovable)return!1;var d=0;if(this.intersects(a,b)){var e=a.deltaAbsX()+b.deltaAbsX()+this.OVERLAP_BIAS;if(0===a.deltaX()&&0===b.deltaX()?(a.embedded=!0,b.embedded=!0):a.deltaX()>b.deltaX()?(d=a.right-b.x,d>e||a.checkCollision.right===!1||b.checkCollision.left===!1?d=0:(a.touching.none=!1,a.touching.right=!0,b.touching.none=!1,b.touching.left=!0)):a.deltaX()<b.deltaX()&&(d=a.x-b.width-b.x,-d>e||a.checkCollision.left===!1||b.checkCollision.right===!1?d=0:(a.touching.none=!1,a.touching.left=!0,b.touching.none=!1,b.touching.right=!0)),a.overlapX=d,b.overlapX=d,0!==d){if(c||a.customSeparateX||b.customSeparateX)return!0;var f=a.velocity.x,g=b.velocity.x;if(a.immovable||b.immovable)a.immovable?b.immovable||(b.x+=d,b.velocity.x=f-g*b.bounce.x,a.moves&&(b.y+=(a.y-a.prev.y)*a.friction.y)):(a.x=a.x-d,a.velocity.x=g-f*a.bounce.x,b.moves&&(a.y+=(b.y-b.prev.y)*b.friction.y));else{d*=.5,a.x=a.x-d,b.x+=d;var h=Math.sqrt(g*g*b.mass/a.mass)*(g>0?1:-1),i=Math.sqrt(f*f*a.mass/b.mass)*(f>0?1:-1),j=.5*(h+i);h-=j,i-=j,a.velocity.x=j+h*a.bounce.x,b.velocity.x=j+i*b.bounce.x}return!0}}return!1},separateY:function(a,b,c){if(a.immovable&&b.immovable)return!1;var d=0;if(this.intersects(a,b)){var e=a.deltaAbsY()+b.deltaAbsY()+this.OVERLAP_BIAS;if(0===a.deltaY()&&0===b.deltaY()?(a.embedded=!0,b.embedded=!0):a.deltaY()>b.deltaY()?(d=a.bottom-b.y,d>e||a.checkCollision.down===!1||b.checkCollision.up===!1?d=0:(a.touching.none=!1,a.touching.down=!0,b.touching.none=!1,b.touching.up=!0)):a.deltaY()<b.deltaY()&&(d=a.y-b.bottom,-d>e||a.checkCollision.up===!1||b.checkCollision.down===!1?d=0:(a.touching.none=!1,a.touching.up=!0,b.touching.none=!1,b.touching.down=!0)),a.overlapY=d,b.overlapY=d,0!==d){if(c||a.customSeparateY||b.customSeparateY)return!0;var f=a.velocity.y,g=b.velocity.y;if(a.immovable||b.immovable)a.immovable?b.immovable||(b.y+=d,b.velocity.y=f-g*b.bounce.y,a.moves&&(b.x+=(a.x-a.prev.x)*a.friction.x)):(a.y=a.y-d,a.velocity.y=g-f*a.bounce.y,b.moves&&(a.x+=(b.x-b.prev.x)*b.friction.x));else{d*=.5,a.y=a.y-d,b.y+=d;var h=Math.sqrt(g*g*b.mass/a.mass)*(g>0?1:-1),i=Math.sqrt(f*f*a.mass/b.mass)*(f>0?1:-1),j=.5*(h+i);h-=j,i-=j,a.velocity.y=j+h*a.bounce.y,b.velocity.y=j+i*b.bounce.y}return!0}}return!1},getObjectsUnderPointer:function(a,b,c,d){return 0!==b.length&&a.exists?this.getObjectsAtLocation(a.x,a.y,b,c,d,a):void 0},getObjectsAtLocation:function(a,b,d,e,f,g){this.quadTree.clear(),this.quadTree.reset(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels),this.quadTree.populate(d);for(var h=new c.Rectangle(a,b,1,1),i=[],j=this.quadTree.retrieve(h),k=0;k<j.length;k++)j[k].hitTest(a,b)&&(e&&e.call(f,g,j[k].sprite),i.push(j[k].sprite));return i},moveToObject:function(a,b,c,d){void 0===c&&(c=60),void 0===d&&(d=0);var e=Math.atan2(b.y-a.y,b.x-a.x);return d>0&&(c=this.distanceBetween(a,b)/(d/1e3)),a.body.velocity.x=Math.cos(e)*c,a.body.velocity.y=Math.sin(e)*c,e},moveToPointer:function(a,b,c,d){void 0===b&&(b=60),c=c||this.game.input.activePointer,void 0===d&&(d=0);var e=this.angleToPointer(a,c);return d>0&&(b=this.distanceToPointer(a,c)/(d/1e3)),a.body.velocity.x=Math.cos(e)*b,a.body.velocity.y=Math.sin(e)*b,e},moveToXY:function(a,b,c,d,e){void 0===d&&(d=60),void 0===e&&(e=0);var f=Math.atan2(c-a.y,b-a.x);return e>0&&(d=this.distanceToXY(a,b,c)/(e/1e3)),a.body.velocity.x=Math.cos(f)*d,a.body.velocity.y=Math.sin(f)*d,f},velocityFromAngle:function(a,b,d){return void 0===b&&(b=60),d=d||new c.Point,d.setTo(Math.cos(this.game.math.degToRad(a))*b,Math.sin(this.game.math.degToRad(a))*b)},velocityFromRotation:function(a,b,d){return void 0===b&&(b=60),d=d||new c.Point,d.setTo(Math.cos(a)*b,Math.sin(a)*b)},accelerationFromRotation:function(a,b,d){return void 0===b&&(b=60),d=d||new c.Point,d.setTo(Math.cos(a)*b,Math.sin(a)*b)},accelerateToObject:function(a,b,c,d,e){void 0===c&&(c=60),void 0===d&&(d=1e3),void 0===e&&(e=1e3);var f=this.angleBetween(a,b);return a.body.acceleration.setTo(Math.cos(f)*c,Math.sin(f)*c),a.body.maxVelocity.setTo(d,e),f},accelerateToPointer:function(a,b,c,d,e){void 0===c&&(c=60),void 0===b&&(b=this.game.input.activePointer),void 0===d&&(d=1e3),void 0===e&&(e=1e3);var f=this.angleToPointer(a,b);return a.body.acceleration.setTo(Math.cos(f)*c,Math.sin(f)*c),a.body.maxVelocity.setTo(d,e),f},accelerateToXY:function(a,b,c,d,e,f){void 0===d&&(d=60),void 0===e&&(e=1e3),void 0===f&&(f=1e3);var g=this.angleToXY(a,b,c);return a.body.acceleration.setTo(Math.cos(g)*d,Math.sin(g)*d),a.body.maxVelocity.setTo(e,f),g},distanceBetween:function(a,b){var c=a.x-b.x,d=a.y-b.y;return Math.sqrt(c*c+d*d)},distanceToXY:function(a,b,c){var d=a.x-b,e=a.y-c;return Math.sqrt(d*d+e*e)},distanceToPointer:function(a,b){b=b||this.game.input.activePointer;var c=a.x-b.worldX,d=a.y-b.worldY;return Math.sqrt(c*c+d*d)},angleBetween:function(a,b){var c=b.x-a.x,d=b.y-a.y;return Math.atan2(d,c)},angleToXY:function(a,b,c){var d=b-a.x,e=c-a.y;return Math.atan2(e,d)},angleToPointer:function(a,b){b=b||this.game.input.activePointer;var c=b.worldX-a.x,d=b.worldY-a.y;return Math.atan2(d,c)}},c.Physics.Arcade.Body=function(a){this.sprite=a,this.game=a.game,this.type=c.Physics.ARCADE,this.enable=!0,this.offset=new c.Point,this.position=new c.Point(a.x,a.y),this.prev=new c.Point(this.position.x,this.position.y),this.allowRotation=!0,this.rotation=a.rotation,this.preRotation=a.rotation,this.width=a.width,this.height=a.height,this.sourceWidth=a.width,this.sourceHeight=a.height,a.texture&&(this.sourceWidth=a.texture.frame.width,this.sourceHeight=a.texture.frame.height),this.halfWidth=Math.abs(a.width/2),this.halfHeight=Math.abs(a.height/2),this.center=new c.Point(a.x+this.halfWidth,a.y+this.halfHeight),this.velocity=new c.Point,this.newVelocity=new c.Point(0,0),this.deltaMax=new c.Point(0,0),this.acceleration=new c.Point,this.drag=new c.Point,this.allowGravity=!0,this.gravity=new c.Point(0,0),this.bounce=new c.Point,this.maxVelocity=new c.Point(1e4,1e4),this.friction=new c.Point(1,0),this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e3,this.mass=1,this.angle=0,this.speed=0,this.facing=c.NONE,this.immovable=!1,this.moves=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision={none:!1,any:!0,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.blocked={up:!1,down:!1,left:!1,right:!1},this.tilePadding=new c.Point,this.dirty=!1,this.skipQuadTree=!1,this.syncBounds=!1,this._reset=!0,this._sx=a.scale.x,this._sy=a.scale.y,this._dx=0,this._dy=0},c.Physics.Arcade.Body.prototype={updateBounds:function(){if(this.syncBounds){var a=this.sprite.getBounds();a.ceilAll(),(a.width!==this.width||a.height!==this.height)&&(this.width=a.width,this.height=a.height,this._reset=!0)}else{var b=Math.abs(this.sprite.scale.x),c=Math.abs(this.sprite.scale.y);(b!==this._sx||c!==this._sy)&&(this.width=this.sourceWidth*b,this.height=this.sourceHeight*c,this._sx=b,this._sy=c,this._reset=!0)}this._reset&&(this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.center.setTo(this.position.x+this.halfWidth,this.position.y+this.halfHeight))},preUpdate:function(){this.enable&&!this.game.physics.arcade.isPaused&&(this.dirty=!0,this.wasTouching.none=this.touching.none,this.wasTouching.up=this.touching.up,this.wasTouching.down=this.touching.down,this.wasTouching.left=this.touching.left,this.wasTouching.right=this.touching.right,this.touching.none=!0,this.touching.up=!1,this.touching.down=!1,this.touching.left=!1,this.touching.right=!1,this.blocked.up=!1,this.blocked.down=!1,this.blocked.left=!1,this.blocked.right=!1,this.embedded=!1,this.updateBounds(),this.position.x=this.sprite.world.x-this.sprite.anchor.x*this.width+this.offset.x,this.position.y=this.sprite.world.y-this.sprite.anchor.y*this.height+this.offset.y,this.rotation=this.sprite.angle,this.preRotation=this.rotation,(this._reset||this.sprite.fresh)&&(this.prev.x=this.position.x,this.prev.y=this.position.y),this.moves&&(this.game.physics.arcade.updateMotion(this),this.newVelocity.set(this.velocity.x*this.game.time.physicsElapsed,this.velocity.y*this.game.time.physicsElapsed),this.position.x+=this.newVelocity.x,this.position.y+=this.newVelocity.y,(this.position.x!==this.prev.x||this.position.y!==this.prev.y)&&(this.speed=Math.sqrt(this.velocity.x*this.velocity.x+this.velocity.y*this.velocity.y),this.angle=Math.atan2(this.velocity.y,this.velocity.x)),this.collideWorldBounds&&this.checkWorldBounds()),this._dx=this.deltaX(),this._dy=this.deltaY(),this._reset=!1)},postUpdate:function(){this.enable&&this.dirty&&(this.dirty=!1,this.deltaX()<0?this.facing=c.LEFT:this.deltaX()>0&&(this.facing=c.RIGHT),this.deltaY()<0?this.facing=c.UP:this.deltaY()>0&&(this.facing=c.DOWN),this.moves&&(this._dx=this.deltaX(),this._dy=this.deltaY(),0!==this.deltaMax.x&&0!==this._dx&&(this._dx<0&&this._dx<-this.deltaMax.x?this._dx=-this.deltaMax.x:this._dx>0&&this._dx>this.deltaMax.x&&(this._dx=this.deltaMax.x)),0!==this.deltaMax.y&&0!==this._dy&&(this._dy<0&&this._dy<-this.deltaMax.y?this._dy=-this.deltaMax.y:this._dy>0&&this._dy>this.deltaMax.y&&(this._dy=this.deltaMax.y)),this.sprite.position.x+=this._dx,this.sprite.position.y+=this._dy,this._reset=!0),this.center.setTo(this.position.x+this.halfWidth,this.position.y+this.halfHeight),this.allowRotation&&(this.sprite.angle+=this.deltaZ()),this.prev.x=this.position.x,this.prev.y=this.position.y)},destroy:function(){this.sprite.parent&&this.sprite.parent instanceof c.Group&&this.sprite.parent.removeFromHash(this.sprite),this.sprite.body=null,this.sprite=null},checkWorldBounds:function(){var a=this.position,b=this.game.physics.arcade.bounds,c=this.game.physics.arcade.checkCollision;a.x<b.x&&c.left?(a.x=b.x,this.velocity.x*=-this.bounce.x,this.blocked.left=!0):this.right>b.right&&c.right&&(a.x=b.right-this.width,this.velocity.x*=-this.bounce.x,this.blocked.right=!0),a.y<b.y&&c.up?(a.y=b.y,this.velocity.y*=-this.bounce.y,this.blocked.up=!0):this.bottom>b.bottom&&c.down&&(a.y=b.bottom-this.height,this.velocity.y*=-this.bounce.y,this.blocked.down=!0)},setSize:function(a,b,c,d){void 0===c&&(c=this.offset.x),void 0===d&&(d=this.offset.y),this.sourceWidth=a,this.sourceHeight=b,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.setTo(c,d),this.center.setTo(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},reset:function(a,b){this.velocity.set(0),this.acceleration.set(0),this.speed=0,this.angularVelocity=0,this.angularAcceleration=0,this.position.x=a-this.sprite.anchor.x*this.width+this.offset.x,this.position.y=b-this.sprite.anchor.y*this.height+this.offset.y,this.prev.x=this.position.x,this.prev.y=this.position.y,this.rotation=this.sprite.angle,this.preRotation=this.rotation,this._sx=this.sprite.scale.x,this._sy=this.sprite.scale.y,this.center.setTo(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},hitTest:function(a,b){return c.Rectangle.contains(this,a,b)},onFloor:function(){return this.blocked.down},onWall:function(){return this.blocked.left||this.blocked.right},deltaAbsX:function(){return this.deltaX()>0?this.deltaX():-this.deltaX()},deltaAbsY:function(){return this.deltaY()>0?this.deltaY():-this.deltaY()},deltaX:function(){return this.position.x-this.prev.x},deltaY:function(){return this.position.y-this.prev.y},deltaZ:function(){return this.rotation-this.preRotation}},Object.defineProperty(c.Physics.Arcade.Body.prototype,"bottom",{get:function(){return this.position.y+this.height}}),Object.defineProperty(c.Physics.Arcade.Body.prototype,"right",{get:function(){return this.position.x+this.width}}),Object.defineProperty(c.Physics.Arcade.Body.prototype,"x",{get:function(){return this.position.x},set:function(a){this.position.x=a}}),Object.defineProperty(c.Physics.Arcade.Body.prototype,"y",{get:function(){return this.position.y},set:function(a){this.position.y=a}}),c.Physics.Arcade.Body.render=function(a,b,c,d){void 0===d&&(d=!0),c=c||"rgba(0,255,0,0.4)",d?(a.fillStyle=c,a.fillRect(b.position.x-b.game.camera.x,b.position.y-b.game.camera.y,b.width,b.height)):(a.strokeStyle=c,a.strokeRect(b.position.x-b.game.camera.x,b.position.y-b.game.camera.y,b.width,b.height))},c.Physics.Arcade.Body.renderBodyInfo=function(a,b){a.line("x: "+b.x.toFixed(2),"y: "+b.y.toFixed(2),"width: "+b.width,"height: "+b.height),a.line("velocity x: "+b.velocity.x.toFixed(2),"y: "+b.velocity.y.toFixed(2),"deltaX: "+b._dx.toFixed(2),"deltaY: "+b._dy.toFixed(2)),a.line("acceleration x: "+b.acceleration.x.toFixed(2),"y: "+b.acceleration.y.toFixed(2),"speed: "+b.speed.toFixed(2),"angle: "+b.angle.toFixed(2)),a.line("gravity x: "+b.gravity.x,"y: "+b.gravity.y,"bounce x: "+b.bounce.x.toFixed(2),"y: "+b.bounce.y.toFixed(2)),a.line("touching left: "+b.touching.left,"right: "+b.touching.right,"up: "+b.touching.up,"down: "+b.touching.down),a.line("blocked left: "+b.blocked.left,"right: "+b.blocked.right,"up: "+b.blocked.up,"down: "+b.blocked.down)},c.Physics.Arcade.Body.prototype.constructor=c.Physics.Arcade.Body,c.Physics.Arcade.TilemapCollision=function(){},c.Physics.Arcade.TilemapCollision.prototype={TILE_BIAS:16,collideSpriteVsTilemapLayer:function(a,b,c,d,e,f){if(a.body){var g=b.getTiles(a.body.position.x-a.body.tilePadding.x,a.body.position.y-a.body.tilePadding.y,a.body.width+a.body.tilePadding.x,a.body.height+a.body.tilePadding.y,!1,!1);if(0!==g.length)for(var h=0;h<g.length;h++)d?d.call(e,a,g[h])&&this.separateTile(h,a.body,g[h],f)&&(this._total++,c&&c.call(e,a,g[h])):this.separateTile(h,a.body,g[h],f)&&(this._total++,c&&c.call(e,a,g[h]))}},collideGroupVsTilemapLayer:function(a,b,c,d,e,f){if(0!==a.length)for(var g=0;g<a.children.length;g++)a.children[g].exists&&this.collideSpriteVsTilemapLayer(a.children[g],b,c,d,e,f)},separateTile:function(a,b,c,d){if(!b.enable)return!1;if(!c.intersects(b.position.x,b.position.y,b.right,b.bottom))return!1;if(d)return!0;if(c.collisionCallback&&!c.collisionCallback.call(c.collisionCallbackContext,b.sprite,c))return!1;if(c.layer.callbacks[c.index]&&!c.layer.callbacks[c.index].callback.call(c.layer.callbacks[c.index].callbackContext,b.sprite,c))return!1;if(!(c.faceLeft||c.faceRight||c.faceTop||c.faceBottom))return!1;var e=0,f=0,g=0,h=1;if(b.deltaAbsX()>b.deltaAbsY()?g=-1:b.deltaAbsX()<b.deltaAbsY()&&(h=-1),0!==b.deltaX()&&0!==b.deltaY()&&(c.faceLeft||c.faceRight)&&(c.faceTop||c.faceBottom)&&(g=Math.min(Math.abs(b.position.x-c.right),Math.abs(b.right-c.left)),h=Math.min(Math.abs(b.position.y-c.bottom),Math.abs(b.bottom-c.top))),h>g){if((c.faceLeft||c.faceRight)&&(e=this.tileCheckX(b,c),0!==e&&!c.intersects(b.position.x,b.position.y,b.right,b.bottom)))return!0;(c.faceTop||c.faceBottom)&&(f=this.tileCheckY(b,c))}else{if((c.faceTop||c.faceBottom)&&(f=this.tileCheckY(b,c),0!==f&&!c.intersects(b.position.x,b.position.y,b.right,b.bottom)))return!0; +(c.faceLeft||c.faceRight)&&(e=this.tileCheckX(b,c))}return 0!==e||0!==f},tileCheckX:function(a,b){var c=0;return a.deltaX()<0&&!a.blocked.left&&b.collideRight&&a.checkCollision.left?b.faceRight&&a.x<b.right&&(c=a.x-b.right,c<-this.TILE_BIAS&&(c=0)):a.deltaX()>0&&!a.blocked.right&&b.collideLeft&&a.checkCollision.right&&b.faceLeft&&a.right>b.left&&(c=a.right-b.left,c>this.TILE_BIAS&&(c=0)),0!==c&&(a.customSeparateX?a.overlapX=c:this.processTileSeparationX(a,c)),c},tileCheckY:function(a,b){var c=0;return a.deltaY()<0&&!a.blocked.up&&b.collideDown&&a.checkCollision.up?b.faceBottom&&a.y<b.bottom&&(c=a.y-b.bottom,c<-this.TILE_BIAS&&(c=0)):a.deltaY()>0&&!a.blocked.down&&b.collideUp&&a.checkCollision.down&&b.faceTop&&a.bottom>b.top&&(c=a.bottom-b.top,c>this.TILE_BIAS&&(c=0)),0!==c&&(a.customSeparateY?a.overlapY=c:this.processTileSeparationY(a,c)),c},processTileSeparationX:function(a,b){0>b?a.blocked.left=!0:b>0&&(a.blocked.right=!0),a.position.x-=b,0===a.bounce.x?a.velocity.x=0:a.velocity.x=-a.velocity.x*a.bounce.x},processTileSeparationY:function(a,b){0>b?a.blocked.up=!0:b>0&&(a.blocked.down=!0),a.position.y-=b,0===a.bounce.y?a.velocity.y=0:a.velocity.y=-a.velocity.y*a.bounce.y}},c.Utils.mixinPrototype(c.Physics.Arcade.prototype,c.Physics.Arcade.TilemapCollision.prototype),p2.Body.prototype.parent=null,p2.Spring.prototype.parent=null,c.Physics.P2=function(a,b){this.game=a,void 0===b?b={gravity:[0,0],broadphase:new p2.SAPBroadphase}:(b.hasOwnProperty("gravity")||(b.gravity=[0,0]),b.hasOwnProperty("broadphase")||(b.broadphase=new p2.SAPBroadphase)),this.config=b,this.world=new p2.World(this.config),this.frameRate=1/60,this.useElapsedTime=!1,this.paused=!1,this.materials=[],this.gravity=new c.Physics.P2.InversePointProxy(this,this.world.gravity),this.walls={left:null,right:null,top:null,bottom:null},this.onBodyAdded=new c.Signal,this.onBodyRemoved=new c.Signal,this.onSpringAdded=new c.Signal,this.onSpringRemoved=new c.Signal,this.onConstraintAdded=new c.Signal,this.onConstraintRemoved=new c.Signal,this.onContactMaterialAdded=new c.Signal,this.onContactMaterialRemoved=new c.Signal,this.postBroadphaseCallback=null,this.callbackContext=null,this.onBeginContact=new c.Signal,this.onEndContact=new c.Signal,b.hasOwnProperty("mpx")&&b.hasOwnProperty("pxm")&&b.hasOwnProperty("mpxi")&&b.hasOwnProperty("pxmi")&&(this.mpx=b.mpx,this.mpxi=b.mpxi,this.pxm=b.pxm,this.pxmi=b.pxmi),this.world.on("beginContact",this.beginContactHandler,this),this.world.on("endContact",this.endContactHandler,this),this.collisionGroups=[],this.nothingCollisionGroup=new c.Physics.P2.CollisionGroup(1),this.boundsCollisionGroup=new c.Physics.P2.CollisionGroup(2),this.everythingCollisionGroup=new c.Physics.P2.CollisionGroup(2147483648),this.boundsCollidesWith=[],this._toRemove=[],this._collisionGroupID=2,this._boundsLeft=!0,this._boundsRight=!0,this._boundsTop=!0,this._boundsBottom=!0,this._boundsOwnGroup=!1,this.setBoundsToWorld(!0,!0,!0,!0,!1)},c.Physics.P2.prototype={removeBodyNextStep:function(a){this._toRemove.push(a)},preUpdate:function(){for(var a=this._toRemove.length;a--;)this.removeBody(this._toRemove[a]);this._toRemove.length=0},enable:function(a,b,d){void 0===b&&(b=!1),void 0===d&&(d=!0);var e=1;if(Array.isArray(a))for(e=a.length;e--;)a[e]instanceof c.Group?this.enable(a[e].children,b,d):(this.enableBody(a[e],b),d&&a[e].hasOwnProperty("children")&&a[e].children.length>0&&this.enable(a[e],b,!0));else a instanceof c.Group?this.enable(a.children,b,d):(this.enableBody(a,b),d&&a.hasOwnProperty("children")&&a.children.length>0&&this.enable(a.children,b,!0))},enableBody:function(a,b){a.hasOwnProperty("body")&&null===a.body&&(a.body=new c.Physics.P2.Body(this.game,a,a.x,a.y,1),a.body.debug=b,"undefined"!=typeof a.anchor&&a.anchor.set(.5))},setImpactEvents:function(a){a?this.world.on("impact",this.impactHandler,this):this.world.off("impact",this.impactHandler,this)},setPostBroadphaseCallback:function(a,b){this.postBroadphaseCallback=a,this.callbackContext=b,null!==a?this.world.on("postBroadphase",this.postBroadphaseHandler,this):this.world.off("postBroadphase",this.postBroadphaseHandler,this)},postBroadphaseHandler:function(a){if(this.postBroadphaseCallback&&0!==a.pairs.length)for(var b=a.pairs.length-2;b>=0;b-=2)a.pairs[b].parent&&a.pairs[b+1].parent&&!this.postBroadphaseCallback.call(this.callbackContext,a.pairs[b].parent,a.pairs[b+1].parent)&&a.pairs.splice(b,2)},impactHandler:function(a){if(a.bodyA.parent&&a.bodyB.parent){var b=a.bodyA.parent,c=a.bodyB.parent;b._bodyCallbacks[a.bodyB.id]&&b._bodyCallbacks[a.bodyB.id].call(b._bodyCallbackContext[a.bodyB.id],b,c,a.shapeA,a.shapeB),c._bodyCallbacks[a.bodyA.id]&&c._bodyCallbacks[a.bodyA.id].call(c._bodyCallbackContext[a.bodyA.id],c,b,a.shapeB,a.shapeA),b._groupCallbacks[a.shapeB.collisionGroup]&&b._groupCallbacks[a.shapeB.collisionGroup].call(b._groupCallbackContext[a.shapeB.collisionGroup],b,c,a.shapeA,a.shapeB),c._groupCallbacks[a.shapeA.collisionGroup]&&c._groupCallbacks[a.shapeA.collisionGroup].call(c._groupCallbackContext[a.shapeA.collisionGroup],c,b,a.shapeB,a.shapeA)}},beginContactHandler:function(a){a.bodyA&&a.bodyB&&(this.onBeginContact.dispatch(a.bodyA,a.bodyB,a.shapeA,a.shapeB,a.contactEquations),a.bodyA.parent&&a.bodyA.parent.onBeginContact.dispatch(a.bodyB.parent,a.bodyB,a.shapeA,a.shapeB,a.contactEquations),a.bodyB.parent&&a.bodyB.parent.onBeginContact.dispatch(a.bodyA.parent,a.bodyA,a.shapeB,a.shapeA,a.contactEquations))},endContactHandler:function(a){a.bodyA&&a.bodyB&&(this.onEndContact.dispatch(a.bodyA,a.bodyB,a.shapeA,a.shapeB),a.bodyA.parent&&a.bodyA.parent.onEndContact.dispatch(a.bodyB.parent,a.bodyB,a.shapeA,a.shapeB),a.bodyB.parent&&a.bodyB.parent.onEndContact.dispatch(a.bodyA.parent,a.bodyA,a.shapeB,a.shapeA))},setBoundsToWorld:function(a,b,c,d,e){this.setBounds(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,a,b,c,d,e)},setWorldMaterial:function(a,b,c,d,e){void 0===b&&(b=!0),void 0===c&&(c=!0),void 0===d&&(d=!0),void 0===e&&(e=!0),b&&this.walls.left&&(this.walls.left.shapes[0].material=a),c&&this.walls.right&&(this.walls.right.shapes[0].material=a),d&&this.walls.top&&(this.walls.top.shapes[0].material=a),e&&this.walls.bottom&&(this.walls.bottom.shapes[0].material=a)},updateBoundsCollisionGroup:function(a){var b=this.everythingCollisionGroup.mask;void 0===a&&(b=this.boundsCollisionGroup.mask),this.walls.left&&(this.walls.left.shapes[0].collisionGroup=b),this.walls.right&&(this.walls.right.shapes[0].collisionGroup=b),this.walls.top&&(this.walls.top.shapes[0].collisionGroup=b),this.walls.bottom&&(this.walls.bottom.shapes[0].collisionGroup=b)},setBounds:function(a,b,c,d,e,f,g,h,i){void 0===e&&(e=this._boundsLeft),void 0===f&&(f=this._boundsRight),void 0===g&&(g=this._boundsTop),void 0===h&&(h=this._boundsBottom),void 0===i&&(i=this._boundsOwnGroup),this.walls.left&&this.world.removeBody(this.walls.left),this.walls.right&&this.world.removeBody(this.walls.right),this.walls.top&&this.world.removeBody(this.walls.top),this.walls.bottom&&this.world.removeBody(this.walls.bottom),e&&(this.walls.left=new p2.Body({mass:0,position:[this.pxmi(a),this.pxmi(b)],angle:1.5707963267948966}),this.walls.left.addShape(new p2.Plane),i&&(this.walls.left.shapes[0].collisionGroup=this.boundsCollisionGroup.mask),this.world.addBody(this.walls.left)),f&&(this.walls.right=new p2.Body({mass:0,position:[this.pxmi(a+c),this.pxmi(b)],angle:-1.5707963267948966}),this.walls.right.addShape(new p2.Plane),i&&(this.walls.right.shapes[0].collisionGroup=this.boundsCollisionGroup.mask),this.world.addBody(this.walls.right)),g&&(this.walls.top=new p2.Body({mass:0,position:[this.pxmi(a),this.pxmi(b)],angle:-3.141592653589793}),this.walls.top.addShape(new p2.Plane),i&&(this.walls.top.shapes[0].collisionGroup=this.boundsCollisionGroup.mask),this.world.addBody(this.walls.top)),h&&(this.walls.bottom=new p2.Body({mass:0,position:[this.pxmi(a),this.pxmi(b+d)]}),this.walls.bottom.addShape(new p2.Plane),i&&(this.walls.bottom.shapes[0].collisionGroup=this.boundsCollisionGroup.mask),this.world.addBody(this.walls.bottom)),this._boundsLeft=e,this._boundsRight=f,this._boundsTop=g,this._boundsBottom=h,this._boundsOwnGroup=i},pause:function(){this.paused=!0},resume:function(){this.paused=!1},update:function(){this.paused||(this.useElapsedTime?this.world.step(this.game.time.physicsElapsed):this.world.step(this.frameRate))},reset:function(){this.world.on("beginContact",this.beginContactHandler,this),this.world.on("endContact",this.endContactHandler,this),this.nothingCollisionGroup=new c.Physics.P2.CollisionGroup(1),this.boundsCollisionGroup=new c.Physics.P2.CollisionGroup(2),this.everythingCollisionGroup=new c.Physics.P2.CollisionGroup(2147483648),this._collisionGroupID=2,this.setBoundsToWorld(!0,!0,!0,!0,!1)},clear:function(){this.world.time=0,this.world.fixedStepTime=0,this.world.solver&&this.world.solver.equations.length&&this.world.solver.removeAllEquations();for(var a=this.world.constraints,b=a.length-1;b>=0;b--)this.world.removeConstraint(a[b]);for(var c=this.world.bodies,b=c.length-1;b>=0;b--)this.world.removeBody(c[b]);for(var d=this.world.springs,b=d.length-1;b>=0;b--)this.world.removeSpring(d[b]);for(var e=this.world.contactMaterials,b=e.length-1;b>=0;b--)this.world.removeContactMaterial(e[b]);this.world.off("beginContact",this.beginContactHandler,this),this.world.off("endContact",this.endContactHandler,this),this.postBroadphaseCallback=null,this.callbackContext=null,this.impactCallback=null,this.collisionGroups=[],this._toRemove=[],this.boundsCollidesWith=[]},destroy:function(){this.clear(),this.game=null},addBody:function(a){return a.data.world?!1:(this.world.addBody(a.data),this.onBodyAdded.dispatch(a),!0)},removeBody:function(a){return a.data.world==this.world&&(this.world.removeBody(a.data),this.onBodyRemoved.dispatch(a)),a},addSpring:function(a){return a instanceof c.Physics.P2.Spring||a instanceof c.Physics.P2.RotationalSpring?this.world.addSpring(a.data):this.world.addSpring(a),this.onSpringAdded.dispatch(a),a},removeSpring:function(a){return a instanceof c.Physics.P2.Spring||a instanceof c.Physics.P2.RotationalSpring?this.world.removeSpring(a.data):this.world.removeSpring(a),this.onSpringRemoved.dispatch(a),a},createDistanceConstraint:function(a,b,d,e,f,g){return a=this.getBody(a),b=this.getBody(b),a&&b?this.addConstraint(new c.Physics.P2.DistanceConstraint(this,a,b,d,e,f,g)):void console.warn("Cannot create Constraint, invalid body objects given")},createGearConstraint:function(a,b,d,e){return a=this.getBody(a),b=this.getBody(b),a&&b?this.addConstraint(new c.Physics.P2.GearConstraint(this,a,b,d,e)):void console.warn("Cannot create Constraint, invalid body objects given")},createRevoluteConstraint:function(a,b,d,e,f,g){return a=this.getBody(a),d=this.getBody(d),a&&d?this.addConstraint(new c.Physics.P2.RevoluteConstraint(this,a,b,d,e,f,g)):void console.warn("Cannot create Constraint, invalid body objects given")},createLockConstraint:function(a,b,d,e,f){return a=this.getBody(a),b=this.getBody(b),a&&b?this.addConstraint(new c.Physics.P2.LockConstraint(this,a,b,d,e,f)):void console.warn("Cannot create Constraint, invalid body objects given")},createPrismaticConstraint:function(a,b,d,e,f,g,h){return a=this.getBody(a),b=this.getBody(b),a&&b?this.addConstraint(new c.Physics.P2.PrismaticConstraint(this,a,b,d,e,f,g,h)):void console.warn("Cannot create Constraint, invalid body objects given")},addConstraint:function(a){return this.world.addConstraint(a),this.onConstraintAdded.dispatch(a),a},removeConstraint:function(a){return this.world.removeConstraint(a),this.onConstraintRemoved.dispatch(a),a},addContactMaterial:function(a){return this.world.addContactMaterial(a),this.onContactMaterialAdded.dispatch(a),a},removeContactMaterial:function(a){return this.world.removeContactMaterial(a),this.onContactMaterialRemoved.dispatch(a),a},getContactMaterial:function(a,b){return this.world.getContactMaterial(a,b)},setMaterial:function(a,b){for(var c=b.length;c--;)b[c].setMaterial(a)},createMaterial:function(a,b){a=a||"";var d=new c.Physics.P2.Material(a);return this.materials.push(d),"undefined"!=typeof b&&b.setMaterial(d),d},createContactMaterial:function(a,b,d){void 0===a&&(a=this.createMaterial()),void 0===b&&(b=this.createMaterial());var e=new c.Physics.P2.ContactMaterial(a,b,d);return this.addContactMaterial(e)},getBodies:function(){for(var a=[],b=this.world.bodies.length;b--;)a.push(this.world.bodies[b].parent);return a},getBody:function(a){return a instanceof p2.Body?a:a instanceof c.Physics.P2.Body?a.data:a.body&&a.body.type===c.Physics.P2JS?a.body.data:null},getSprings:function(){for(var a=[],b=this.world.springs.length;b--;)a.push(this.world.springs[b].parent);return a},getConstraints:function(){for(var a=[],b=this.world.constraints.length;b--;)a.push(this.world.constraints[b]);return a},hitTest:function(a,b,d,e){void 0===b&&(b=this.world.bodies),void 0===d&&(d=5),void 0===e&&(e=!1);for(var f=[this.pxmi(a.x),this.pxmi(a.y)],g=[],h=b.length;h--;)b[h]instanceof c.Physics.P2.Body&&(!e||b[h].data.type!==p2.Body.STATIC)?g.push(b[h].data):b[h]instanceof p2.Body&&b[h].parent&&(!e||b[h].type!==p2.Body.STATIC)?g.push(b[h]):b[h]instanceof c.Sprite&&b[h].hasOwnProperty("body")&&(!e||b[h].body.data.type!==p2.Body.STATIC)&&g.push(b[h].body.data);return this.world.hitTest(f,g,d)},toJSON:function(){return this.world.toJSON()},createCollisionGroup:function(a){var b=Math.pow(2,this._collisionGroupID);this.walls.left&&(this.walls.left.shapes[0].collisionMask=this.walls.left.shapes[0].collisionMask|b),this.walls.right&&(this.walls.right.shapes[0].collisionMask=this.walls.right.shapes[0].collisionMask|b),this.walls.top&&(this.walls.top.shapes[0].collisionMask=this.walls.top.shapes[0].collisionMask|b),this.walls.bottom&&(this.walls.bottom.shapes[0].collisionMask=this.walls.bottom.shapes[0].collisionMask|b),this._collisionGroupID++;var d=new c.Physics.P2.CollisionGroup(b);return this.collisionGroups.push(d),a&&this.setCollisionGroup(a,d),d},setCollisionGroup:function(a,b){if(a instanceof c.Group)for(var d=0;d<a.total;d++)a.children[d].body&&a.children[d].body.type===c.Physics.P2JS&&a.children[d].body.setCollisionGroup(b);else a.body.setCollisionGroup(b)},createSpring:function(a,b,d,e,f,g,h,i,j){return a=this.getBody(a),b=this.getBody(b),a&&b?this.addSpring(new c.Physics.P2.Spring(this,a,b,d,e,f,g,h,i,j)):void console.warn("Cannot create Spring, invalid body objects given")},createRotationalSpring:function(a,b,d,e,f){return a=this.getBody(a),b=this.getBody(b),a&&b?this.addSpring(new c.Physics.P2.RotationalSpring(this,a,b,d,e,f)):void console.warn("Cannot create Rotational Spring, invalid body objects given")},createBody:function(a,b,d,e,f,g){void 0===e&&(e=!1);var h=new c.Physics.P2.Body(this.game,null,a,b,d);if(g){var i=h.addPolygon(f,g);if(!i)return!1}return e&&this.world.addBody(h.data),h},createParticle:function(a,b,d,e,f,g){void 0===e&&(e=!1);var h=new c.Physics.P2.Body(this.game,null,a,b,d);if(g){var i=h.addPolygon(f,g);if(!i)return!1}return e&&this.world.addBody(h.data),h},convertCollisionObjects:function(a,b,c){void 0===c&&(c=!0);for(var d=[],e=0,f=a.collision[b].length;f>e;e++){var g=a.collision[b][e],h=this.createBody(g.x,g.y,0,c,{},g.polyline);h&&d.push(h)}return d},clearTilemapLayerBodies:function(a,b){b=a.getLayer(b);for(var c=a.layers[b].bodies.length;c--;)a.layers[b].bodies[c].destroy();a.layers[b].bodies.length=0},convertTilemap:function(a,b,c,d){b=a.getLayer(b),void 0===c&&(c=!0),void 0===d&&(d=!0),this.clearTilemapLayerBodies(a,b);for(var e=0,f=0,g=0,h=0,i=a.layers[b].height;i>h;h++){e=0;for(var j=0,k=a.layers[b].width;k>j;j++){var l=a.layers[b].data[h][j];if(l&&l.index>-1&&l.collides)if(d){var m=a.getTileRight(b,j,h);if(0===e&&(f=l.x*l.width,g=l.y*l.height,e=l.width),m&&m.collides)e+=l.width;else{var n=this.createBody(f,g,0,!1);n.addRectangle(e,l.height,e/2,l.height/2,0),c&&this.addBody(n),a.layers[b].bodies.push(n),e=0}}else{var n=this.createBody(l.x*l.width,l.y*l.height,0,!1);n.addRectangle(l.width,l.height,l.width/2,l.height/2,0),c&&this.addBody(n),a.layers[b].bodies.push(n)}}}return a.layers[b].bodies},mpx:function(a){return a*=20},pxm:function(a){return.05*a},mpxi:function(a){return a*=-20},pxmi:function(a){return a*-.05}},Object.defineProperty(c.Physics.P2.prototype,"friction",{get:function(){return this.world.defaultContactMaterial.friction},set:function(a){this.world.defaultContactMaterial.friction=a}}),Object.defineProperty(c.Physics.P2.prototype,"restitution",{get:function(){return this.world.defaultContactMaterial.restitution},set:function(a){this.world.defaultContactMaterial.restitution=a}}),Object.defineProperty(c.Physics.P2.prototype,"contactMaterial",{get:function(){return this.world.defaultContactMaterial},set:function(a){this.world.defaultContactMaterial=a}}),Object.defineProperty(c.Physics.P2.prototype,"applySpringForces",{get:function(){return this.world.applySpringForces},set:function(a){this.world.applySpringForces=a}}),Object.defineProperty(c.Physics.P2.prototype,"applyDamping",{get:function(){return this.world.applyDamping},set:function(a){this.world.applyDamping=a}}),Object.defineProperty(c.Physics.P2.prototype,"applyGravity",{get:function(){return this.world.applyGravity},set:function(a){this.world.applyGravity=a}}),Object.defineProperty(c.Physics.P2.prototype,"solveConstraints",{get:function(){return this.world.solveConstraints},set:function(a){this.world.solveConstraints=a}}),Object.defineProperty(c.Physics.P2.prototype,"time",{get:function(){return this.world.time}}),Object.defineProperty(c.Physics.P2.prototype,"emitImpactEvent",{get:function(){return this.world.emitImpactEvent},set:function(a){this.world.emitImpactEvent=a}}),Object.defineProperty(c.Physics.P2.prototype,"sleepMode",{get:function(){return this.world.sleepMode},set:function(a){this.world.sleepMode=a}}),Object.defineProperty(c.Physics.P2.prototype,"total",{get:function(){return this.world.bodies.length}}),c.Physics.P2.FixtureList=function(a){Array.isArray(a)||(a=[a]),this.rawList=a,this.init(),this.parse(this.rawList)},c.Physics.P2.FixtureList.prototype={init:function(){this.namedFixtures={},this.groupedFixtures=[],this.allFixtures=[]},setCategory:function(a,b){var c=function(b){b.collisionGroup=a};this.getFixtures(b).forEach(c)},setMask:function(a,b){var c=function(b){b.collisionMask=a};this.getFixtures(b).forEach(c)},setSensor:function(a,b){var c=function(b){b.sensor=a};this.getFixtures(b).forEach(c)},setMaterial:function(a,b){var c=function(b){b.material=a};this.getFixtures(b).forEach(c)},getFixtures:function(a){var b=[];if(a){a instanceof Array||(a=[a]);var c=this;return a.forEach(function(a){c.namedFixtures[a]&&b.push(c.namedFixtures[a])}),this.flatten(b)}return this.allFixtures},getFixtureByKey:function(a){return this.namedFixtures[a]},getGroup:function(a){return this.groupedFixtures[a]},parse:function(){var a,b,c,d;c=this.rawList,d=[];for(a in c)b=c[a],isNaN(a-0)?this.namedFixtures[a]=this.flatten(b):(this.groupedFixtures[a]=this.groupedFixtures[a]||[],this.groupedFixtures[a]=this.groupedFixtures[a].concat(b)),d.push(this.allFixtures=this.flatten(this.groupedFixtures))},flatten:function(a){var b,c;return b=[],c=arguments.callee,a.forEach(function(a){return Array.prototype.push.apply(b,Array.isArray(a)?c(a):[a])}),b}},c.Physics.P2.PointProxy=function(a,b){this.world=a,this.destination=b},c.Physics.P2.PointProxy.prototype.constructor=c.Physics.P2.PointProxy,Object.defineProperty(c.Physics.P2.PointProxy.prototype,"x",{get:function(){return this.world.mpx(this.destination[0])},set:function(a){this.destination[0]=this.world.pxm(a)}}),Object.defineProperty(c.Physics.P2.PointProxy.prototype,"y",{get:function(){return this.world.mpx(this.destination[1])},set:function(a){this.destination[1]=this.world.pxm(a)}}),Object.defineProperty(c.Physics.P2.PointProxy.prototype,"mx",{get:function(){return this.destination[0]},set:function(a){this.destination[0]=a}}),Object.defineProperty(c.Physics.P2.PointProxy.prototype,"my",{get:function(){return this.destination[1]},set:function(a){this.destination[1]=a}}),c.Physics.P2.InversePointProxy=function(a,b){this.world=a,this.destination=b},c.Physics.P2.InversePointProxy.prototype.constructor=c.Physics.P2.InversePointProxy,Object.defineProperty(c.Physics.P2.InversePointProxy.prototype,"x",{get:function(){return this.world.mpxi(this.destination[0])},set:function(a){this.destination[0]=this.world.pxmi(a)}}),Object.defineProperty(c.Physics.P2.InversePointProxy.prototype,"y",{get:function(){return this.world.mpxi(this.destination[1])},set:function(a){this.destination[1]=this.world.pxmi(a)}}),Object.defineProperty(c.Physics.P2.InversePointProxy.prototype,"mx",{get:function(){return this.destination[0]},set:function(a){this.destination[0]=-a}}),Object.defineProperty(c.Physics.P2.InversePointProxy.prototype,"my",{get:function(){return this.destination[1]},set:function(a){this.destination[1]=-a}}),c.Physics.P2.Body=function(a,b,d,e,f){b=b||null,d=d||0,e=e||0,void 0===f&&(f=1),this.game=a,this.world=a.physics.p2,this.sprite=b,this.type=c.Physics.P2JS,this.offset=new c.Point,this.data=new p2.Body({position:[this.world.pxmi(d),this.world.pxmi(e)],mass:f}),this.data.parent=this,this.velocity=new c.Physics.P2.InversePointProxy(this.world,this.data.velocity),this.force=new c.Physics.P2.InversePointProxy(this.world,this.data.force),this.gravity=new c.Point,this.onBeginContact=new c.Signal,this.onEndContact=new c.Signal,this.collidesWith=[],this.removeNextStep=!1,this.debugBody=null,this.dirty=!1,this._collideWorldBounds=!0,this._bodyCallbacks={},this._bodyCallbackContext={},this._groupCallbacks={},this._groupCallbackContext={},this._reset=!1,b&&(this.setRectangleFromSprite(b),b.exists&&this.game.physics.p2.addBody(this))},c.Physics.P2.Body.prototype={createBodyCallback:function(a,b,c){var d=-1;a.id?d=a.id:a.body&&(d=a.body.id),d>-1&&(null===b?(delete this._bodyCallbacks[d],delete this._bodyCallbackContext[d]):(this._bodyCallbacks[d]=b,this._bodyCallbackContext[d]=c))},createGroupCallback:function(a,b,c){null===b?(delete this._groupCallbacks[a.mask],delete this._groupCallbackContext[a.mask]):(this._groupCallbacks[a.mask]=b,this._groupCallbackContext[a.mask]=c)},getCollisionMask:function(){var a=0;this._collideWorldBounds&&(a=this.game.physics.p2.boundsCollisionGroup.mask);for(var b=0;b<this.collidesWith.length;b++)a|=this.collidesWith[b].mask;return a},updateCollisionMask:function(a){var b=this.getCollisionMask();if(void 0===a)for(var c=this.data.shapes.length-1;c>=0;c--)this.data.shapes[c].collisionMask=b;else a.collisionMask=b},setCollisionGroup:function(a,b){var c=this.getCollisionMask();if(void 0===b)for(var d=this.data.shapes.length-1;d>=0;d--)this.data.shapes[d].collisionGroup=a.mask,this.data.shapes[d].collisionMask=c;else b.collisionGroup=a.mask,b.collisionMask=c},clearCollision:function(a,b,c){if(void 0===a&&(a=!0),void 0===b&&(b=!0),void 0===c)for(var d=this.data.shapes.length-1;d>=0;d--)a&&(this.data.shapes[d].collisionGroup=null),b&&(this.data.shapes[d].collisionMask=null);else a&&(c.collisionGroup=null),b&&(c.collisionMask=null);a&&(this.collidesWith.length=0)},removeCollisionGroup:function(a,b,c){void 0===b&&(b=!0);var d;if(Array.isArray(a))for(var e=0;e<a.length;e++)d=this.collidesWith.indexOf(a[e]),d>-1&&(this.collidesWith.splice(d,1),b&&(delete this._groupCallbacks[a.mask],delete this._groupCallbackContext[a.mask]));else d=this.collidesWith.indexOf(a),d>-1&&(this.collidesWith.splice(d,1),b&&(delete this._groupCallbacks[a.mask],delete this._groupCallbackContext[a.mask]));var f=this.getCollisionMask();if(void 0===c)for(var e=this.data.shapes.length-1;e>=0;e--)this.data.shapes[e].collisionMask=f;else c.collisionMask=f},collides:function(a,b,c,d){if(Array.isArray(a))for(var e=0;e<a.length;e++)-1===this.collidesWith.indexOf(a[e])&&(this.collidesWith.push(a[e]),b&&this.createGroupCallback(a[e],b,c));else-1===this.collidesWith.indexOf(a)&&(this.collidesWith.push(a),b&&this.createGroupCallback(a,b,c));var f=this.getCollisionMask();if(void 0===d)for(var e=this.data.shapes.length-1;e>=0;e--)this.data.shapes[e].collisionMask=f;else d.collisionMask=f},adjustCenterOfMass:function(){this.data.adjustCenterOfMass(),this.shapeChanged()},getVelocityAtPoint:function(a,b){return this.data.getVelocityAtPoint(a,b)},applyDamping:function(a){this.data.applyDamping(a)},applyImpulse:function(a,b,c){this.data.applyImpulse(a,[this.world.pxmi(b),this.world.pxmi(c)])},applyImpulseLocal:function(a,b,c){this.data.applyImpulseLocal(a,[this.world.pxmi(b),this.world.pxmi(c)])},applyForce:function(a,b,c){this.data.applyForce(a,[this.world.pxmi(b),this.world.pxmi(c)])},setZeroForce:function(){this.data.setZeroForce()},setZeroRotation:function(){this.data.angularVelocity=0},setZeroVelocity:function(){this.data.velocity[0]=0,this.data.velocity[1]=0},setZeroDamping:function(){this.data.damping=0,this.data.angularDamping=0},toLocalFrame:function(a,b){return this.data.toLocalFrame(a,b)},toWorldFrame:function(a,b){return this.data.toWorldFrame(a,b)},rotateLeft:function(a){this.data.angularVelocity=this.world.pxm(-a)},rotateRight:function(a){this.data.angularVelocity=this.world.pxm(a)},moveForward:function(a){var b=this.world.pxmi(-a),c=this.data.angle+Math.PI/2;this.data.velocity[0]=b*Math.cos(c),this.data.velocity[1]=b*Math.sin(c)},moveBackward:function(a){var b=this.world.pxmi(-a),c=this.data.angle+Math.PI/2;this.data.velocity[0]=-(b*Math.cos(c)),this.data.velocity[1]=-(b*Math.sin(c))},thrust:function(a){var b=this.world.pxmi(-a),c=this.data.angle+Math.PI/2;this.data.force[0]+=b*Math.cos(c),this.data.force[1]+=b*Math.sin(c)},reverse:function(a){var b=this.world.pxmi(-a),c=this.data.angle+Math.PI/2;this.data.force[0]-=b*Math.cos(c),this.data.force[1]-=b*Math.sin(c)},moveLeft:function(a){this.data.velocity[0]=this.world.pxmi(-a)},moveRight:function(a){this.data.velocity[0]=this.world.pxmi(a)},moveUp:function(a){this.data.velocity[1]=this.world.pxmi(-a)},moveDown:function(a){this.data.velocity[1]=this.world.pxmi(a)},preUpdate:function(){this.dirty=!0,this.removeNextStep&&(this.removeFromWorld(),this.removeNextStep=!1)},postUpdate:function(){this.sprite.x=this.world.mpxi(this.data.position[0]),this.sprite.y=this.world.mpxi(this.data.position[1]),this.fixedRotation||(this.sprite.rotation=this.data.angle),this.debugBody&&this.debugBody.updateSpriteTransform(),this.dirty=!1},reset:function(a,b,c,d){void 0===c&&(c=!1),void 0===d&&(d=!1),this.setZeroForce(),this.setZeroVelocity(),this.setZeroRotation(),c&&this.setZeroDamping(),d&&(this.mass=1),this.x=a,this.y=b},addToWorld:function(){if(this.game.physics.p2._toRemove)for(var a=0;a<this.game.physics.p2._toRemove.length;a++)this.game.physics.p2._toRemove[a]===this&&this.game.physics.p2._toRemove.splice(a,1);this.data.world!==this.game.physics.p2.world&&this.game.physics.p2.addBody(this)},removeFromWorld:function(){this.data.world===this.game.physics.p2.world&&this.game.physics.p2.removeBodyNextStep(this)},destroy:function(){this.removeFromWorld(),this.clearShapes(),this._bodyCallbacks={},this._bodyCallbackContext={},this._groupCallbacks={},this._groupCallbackContext={},this.debugBody&&this.debugBody.destroy(!0,!0),this.debugBody=null,this.sprite&&(this.sprite.body=null,this.sprite=null)},clearShapes:function(){for(var a=this.data.shapes.length;a--;)this.data.removeShape(this.data.shapes[a]);this.shapeChanged()},addShape:function(a,b,c,d){return void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=0),this.data.addShape(a,[this.world.pxmi(b),this.world.pxmi(c)],d),this.shapeChanged(),a},addCircle:function(a,b,c,d){var e=new p2.Circle({radius:this.world.pxm(a)});return this.addShape(e,b,c,d)},addRectangle:function(a,b,c,d,e){var f=new p2.Box({width:this.world.pxm(a),height:this.world.pxm(b)});return this.addShape(f,c,d,e)},addPlane:function(a,b,c){var d=new p2.Plane;return this.addShape(d,a,b,c)},addParticle:function(a,b,c){var d=new p2.Particle;return this.addShape(d,a,b,c)},addLine:function(a,b,c,d){var e=new p2.Line({length:this.world.pxm(a)});return this.addShape(e,b,c,d)},addCapsule:function(a,b,c,d,e){var f=new p2.Capsule({length:this.world.pxm(a),radius:this.world.pxm(b)});return this.addShape(f,c,d,e)},addPolygon:function(a,b){a=a||{},Array.isArray(b)||(b=Array.prototype.slice.call(arguments,1));var c=[];if(1===b.length&&Array.isArray(b[0]))c=b[0].slice(0);else if(Array.isArray(b[0]))c=b.slice();else if("number"==typeof b[0])for(var d=0,e=b.length;e>d;d+=2)c.push([b[d],b[d+1]]);var f=c.length-1;c[f][0]===c[0][0]&&c[f][1]===c[0][1]&&c.pop();for(var g=0;g<c.length;g++)c[g][0]=this.world.pxmi(c[g][0]),c[g][1]=this.world.pxmi(c[g][1]);var h=this.data.fromPolygon(c,a);return this.shapeChanged(),h},removeShape:function(a){var b=this.data.removeShape(a);return this.shapeChanged(),b},setCircle:function(a,b,c,d){return this.clearShapes(),this.addCircle(a,b,c,d)},setRectangle:function(a,b,c,d,e){return void 0===a&&(a=16),void 0===b&&(b=16),this.clearShapes(),this.addRectangle(a,b,c,d,e)},setRectangleFromSprite:function(a){return void 0===a&&(a=this.sprite),this.clearShapes(),this.addRectangle(a.width,a.height,0,0,a.rotation)},setMaterial:function(a,b){if(void 0===b)for(var c=this.data.shapes.length-1;c>=0;c--)this.data.shapes[c].material=a;else b.material=a},shapeChanged:function(){this.debugBody&&this.debugBody.draw()},addPhaserPolygon:function(a,b){for(var c=this.game.cache.getPhysicsData(a,b),d=[],e=0;e<c.length;e++){var f=c[e],g=this.addFixture(f);d[f.filter.group]=d[f.filter.group]||[],d[f.filter.group]=d[f.filter.group].concat(g),f.fixtureKey&&(d[f.fixtureKey]=g)}return this.data.aabbNeedsUpdate=!0,this.shapeChanged(),d},addFixture:function(a){var b=[];if(a.circle){var c=new p2.Circle({radius:this.world.pxm(a.circle.radius)});c.collisionGroup=a.filter.categoryBits,c.collisionMask=a.filter.maskBits,c.sensor=a.isSensor;var d=p2.vec2.create();d[0]=this.world.pxmi(a.circle.position[0]-this.sprite.width/2),d[1]=this.world.pxmi(a.circle.position[1]-this.sprite.height/2),this.data.addShape(c,d),b.push(c)}else for(var e=a.polygons,f=p2.vec2.create(),g=0;g<e.length;g++){for(var h=e[g],i=[],j=0;j<h.length;j+=2)i.push([this.world.pxmi(h[j]),this.world.pxmi(h[j+1])]);for(var c=new p2.Convex({vertices:i}),k=0;k!==c.vertices.length;k++){var l=c.vertices[k];p2.vec2.sub(l,l,c.centerOfMass)}p2.vec2.scale(f,c.centerOfMass,1),f[0]-=this.world.pxmi(this.sprite.width/2),f[1]-=this.world.pxmi(this.sprite.height/2),c.updateTriangles(),c.updateCenterOfMass(),c.updateBoundingRadius(),c.collisionGroup=a.filter.categoryBits,c.collisionMask=a.filter.maskBits,c.sensor=a.isSensor,this.data.addShape(c,f),b.push(c)}return b},loadPolygon:function(a,b){if(null===a)var c=b;else var c=this.game.cache.getPhysicsData(a,b);for(var d=p2.vec2.create(),e=0;e<c.length;e++){for(var f=[],g=0;g<c[e].shape.length;g+=2)f.push([this.world.pxmi(c[e].shape[g]),this.world.pxmi(c[e].shape[g+1])]);for(var h=new p2.Convex({vertices:f}),i=0;i!==h.vertices.length;i++){var j=h.vertices[i];p2.vec2.sub(j,j,h.centerOfMass)}p2.vec2.scale(d,h.centerOfMass,1),d[0]-=this.world.pxmi(this.sprite.width/2),d[1]-=this.world.pxmi(this.sprite.height/2),h.updateTriangles(),h.updateCenterOfMass(),h.updateBoundingRadius(),this.data.addShape(h,d)}return this.data.aabbNeedsUpdate=!0,this.shapeChanged(),!0}},c.Physics.P2.Body.prototype.constructor=c.Physics.P2.Body,c.Physics.P2.Body.DYNAMIC=1,c.Physics.P2.Body.STATIC=2,c.Physics.P2.Body.KINEMATIC=4,Object.defineProperty(c.Physics.P2.Body.prototype,"static",{get:function(){return this.data.type===c.Physics.P2.Body.STATIC},set:function(a){a&&this.data.type!==c.Physics.P2.Body.STATIC?(this.data.type=c.Physics.P2.Body.STATIC,this.mass=0):a||this.data.type!==c.Physics.P2.Body.STATIC||(this.data.type=c.Physics.P2.Body.DYNAMIC,this.mass=1)}}),Object.defineProperty(c.Physics.P2.Body.prototype,"dynamic",{get:function(){return this.data.type===c.Physics.P2.Body.DYNAMIC},set:function(a){a&&this.data.type!==c.Physics.P2.Body.DYNAMIC?(this.data.type=c.Physics.P2.Body.DYNAMIC, +this.mass=1):a||this.data.type!==c.Physics.P2.Body.DYNAMIC||(this.data.type=c.Physics.P2.Body.STATIC,this.mass=0)}}),Object.defineProperty(c.Physics.P2.Body.prototype,"kinematic",{get:function(){return this.data.type===c.Physics.P2.Body.KINEMATIC},set:function(a){a&&this.data.type!==c.Physics.P2.Body.KINEMATIC?(this.data.type=c.Physics.P2.Body.KINEMATIC,this.mass=4):a||this.data.type!==c.Physics.P2.Body.KINEMATIC||(this.data.type=c.Physics.P2.Body.STATIC,this.mass=0)}}),Object.defineProperty(c.Physics.P2.Body.prototype,"allowSleep",{get:function(){return this.data.allowSleep},set:function(a){a!==this.data.allowSleep&&(this.data.allowSleep=a)}}),Object.defineProperty(c.Physics.P2.Body.prototype,"angle",{get:function(){return c.Math.wrapAngle(c.Math.radToDeg(this.data.angle))},set:function(a){this.data.angle=c.Math.degToRad(c.Math.wrapAngle(a))}}),Object.defineProperty(c.Physics.P2.Body.prototype,"angularDamping",{get:function(){return this.data.angularDamping},set:function(a){this.data.angularDamping=a}}),Object.defineProperty(c.Physics.P2.Body.prototype,"angularForce",{get:function(){return this.data.angularForce},set:function(a){this.data.angularForce=a}}),Object.defineProperty(c.Physics.P2.Body.prototype,"angularVelocity",{get:function(){return this.data.angularVelocity},set:function(a){this.data.angularVelocity=a}}),Object.defineProperty(c.Physics.P2.Body.prototype,"damping",{get:function(){return this.data.damping},set:function(a){this.data.damping=a}}),Object.defineProperty(c.Physics.P2.Body.prototype,"fixedRotation",{get:function(){return this.data.fixedRotation},set:function(a){a!==this.data.fixedRotation&&(this.data.fixedRotation=a)}}),Object.defineProperty(c.Physics.P2.Body.prototype,"inertia",{get:function(){return this.data.inertia},set:function(a){this.data.inertia=a}}),Object.defineProperty(c.Physics.P2.Body.prototype,"mass",{get:function(){return this.data.mass},set:function(a){a!==this.data.mass&&(this.data.mass=a,this.data.updateMassProperties())}}),Object.defineProperty(c.Physics.P2.Body.prototype,"motionState",{get:function(){return this.data.type},set:function(a){a!==this.data.type&&(this.data.type=a)}}),Object.defineProperty(c.Physics.P2.Body.prototype,"rotation",{get:function(){return this.data.angle},set:function(a){this.data.angle=a}}),Object.defineProperty(c.Physics.P2.Body.prototype,"sleepSpeedLimit",{get:function(){return this.data.sleepSpeedLimit},set:function(a){this.data.sleepSpeedLimit=a}}),Object.defineProperty(c.Physics.P2.Body.prototype,"x",{get:function(){return this.world.mpxi(this.data.position[0])},set:function(a){this.data.position[0]=this.world.pxmi(a)}}),Object.defineProperty(c.Physics.P2.Body.prototype,"y",{get:function(){return this.world.mpxi(this.data.position[1])},set:function(a){this.data.position[1]=this.world.pxmi(a)}}),Object.defineProperty(c.Physics.P2.Body.prototype,"id",{get:function(){return this.data.id}}),Object.defineProperty(c.Physics.P2.Body.prototype,"debug",{get:function(){return null!==this.debugBody},set:function(a){a&&!this.debugBody?this.debugBody=new c.Physics.P2.BodyDebug(this.game,this.data):!a&&this.debugBody&&(this.debugBody.destroy(),this.debugBody=null)}}),Object.defineProperty(c.Physics.P2.Body.prototype,"collideWorldBounds",{get:function(){return this._collideWorldBounds},set:function(a){a&&!this._collideWorldBounds?(this._collideWorldBounds=!0,this.updateCollisionMask()):!a&&this._collideWorldBounds&&(this._collideWorldBounds=!1,this.updateCollisionMask())}}),c.Physics.P2.BodyDebug=function(a,b,d){c.Group.call(this,a);var e={pixelsPerLengthUnit:a.physics.p2.mpx(1),debugPolygons:!1,lineWidth:1,alpha:.5};this.settings=c.Utils.extend(e,d),this.ppu=this.settings.pixelsPerLengthUnit,this.ppu=-1*this.ppu,this.body=b,this.canvas=new c.Graphics(a),this.canvas.alpha=this.settings.alpha,this.add(this.canvas),this.draw(),this.updateSpriteTransform()},c.Physics.P2.BodyDebug.prototype=Object.create(c.Group.prototype),c.Physics.P2.BodyDebug.prototype.constructor=c.Physics.P2.BodyDebug,c.Utils.extend(c.Physics.P2.BodyDebug.prototype,{updateSpriteTransform:function(){this.position.x=this.body.position[0]*this.ppu,this.position.y=this.body.position[1]*this.ppu,this.rotation=this.body.angle},draw:function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o;if(h=this.body,j=this.canvas,j.clear(),c=parseInt(this.randomPastelHex(),16),f=16711680,g=this.lineWidth,h instanceof p2.Body&&h.shapes.length){var p=h.shapes.length;for(d=0;d!==p;){if(b=h.shapes[d],i=b.position||0,a=b.angle||0,b instanceof p2.Circle)this.drawCircle(j,i[0]*this.ppu,i[1]*this.ppu,a,b.radius*this.ppu,c,g);else if(b instanceof p2.Capsule)this.drawCapsule(j,i[0]*this.ppu,i[1]*this.ppu,a,b.length*this.ppu,b.radius*this.ppu,f,c,g);else if(b instanceof p2.Plane)this.drawPlane(j,i[0]*this.ppu,-i[1]*this.ppu,c,f,5*g,10*g,10*g,100*this.ppu,a);else if(b instanceof p2.Line)this.drawLine(j,b.length*this.ppu,f,g);else if(b instanceof p2.Box)this.drawRectangle(j,i[0]*this.ppu,i[1]*this.ppu,a,b.width*this.ppu,b.height*this.ppu,f,c,g);else if(b instanceof p2.Convex){for(l=[],m=p2.vec2.create(),e=n=0,o=b.vertices.length;o>=0?o>n:n>o;e=o>=0?++n:--n)k=b.vertices[e],p2.vec2.rotate(m,k,a),l.push([(m[0]+i[0])*this.ppu,-(m[1]+i[1])*this.ppu]);this.drawConvex(j,l,b.triangles,f,c,g,this.settings.debugPolygons,[i[0]*this.ppu,-i[1]*this.ppu])}d++}}},drawRectangle:function(a,b,c,d,e,f,g,h,i){void 0===i&&(i=1),void 0===g&&(g=0),a.lineStyle(i,g,1),a.beginFill(h),a.drawRect(b-e/2,c-f/2,e,f)},drawCircle:function(a,b,c,d,e,f,g){void 0===g&&(g=1),void 0===f&&(f=16777215),a.lineStyle(g,0,1),a.beginFill(f,1),a.drawCircle(b,c,2*-e),a.endFill(),a.moveTo(b,c),a.lineTo(b+e*Math.cos(-d),c+e*Math.sin(-d))},drawLine:function(a,b,c,d){void 0===d&&(d=1),void 0===c&&(c=0),a.lineStyle(5*d,c,1),a.moveTo(-b/2,0),a.lineTo(b/2,0)},drawConvex:function(a,b,c,d,e,f,g,h){var i,j,k,l,m,n,o,p,q,r,s;if(void 0===f&&(f=1),void 0===d&&(d=0),g){for(i=[16711680,65280,255],j=0;j!==b.length+1;)l=b[j%b.length],m=b[(j+1)%b.length],o=l[0],r=l[1],p=m[0],s=m[1],a.lineStyle(f,i[j%i.length],1),a.moveTo(o,-r),a.lineTo(p,-s),a.drawCircle(o,-r,2*f),j++;return a.lineStyle(f,0,1),a.drawCircle(h[0],h[1],2*f)}for(a.lineStyle(f,d,1),a.beginFill(e),j=0;j!==b.length;)k=b[j],n=k[0],q=k[1],0===j?a.moveTo(n,-q):a.lineTo(n,-q),j++;return a.endFill(),b.length>2?(a.moveTo(b[b.length-1][0],-b[b.length-1][1]),a.lineTo(b[0][0],-b[0][1])):void 0},drawPath:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r;for(void 0===e&&(e=1),void 0===c&&(c=0),a.lineStyle(e,c,1),"number"==typeof d&&a.beginFill(d),h=null,i=null,g=0;g<b.length;)p=b[g],q=p[0],r=p[1],(q!==h||r!==i)&&(0===g?a.moveTo(q,r):(j=h,k=i,l=q,m=r,n=b[(g+1)%b.length][0],o=b[(g+1)%b.length][1],f=(l-j)*(o-k)-(n-j)*(m-k),0!==f&&a.lineTo(q,r)),h=q,i=r),g++;"number"==typeof d&&a.endFill(),b.length>2&&"number"==typeof d&&(a.moveTo(b[b.length-1][0],b[b.length-1][1]),a.lineTo(b[0][0],b[0][1]))},drawPlane:function(a,b,c,d,e,f,g,h,i,j){var k,l,m;void 0===f&&(f=1),void 0===d&&(d=16777215),a.lineStyle(f,e,11),a.beginFill(d),k=i,a.moveTo(b,-c),l=b+Math.cos(j)*this.game.width,m=c+Math.sin(j)*this.game.height,a.lineTo(l,-m),a.moveTo(b,-c),l=b+Math.cos(j)*-this.game.width,m=c+Math.sin(j)*-this.game.height,a.lineTo(l,-m)},drawCapsule:function(a,b,c,d,e,f,g,h,i){void 0===i&&(i=1),void 0===g&&(g=0),a.lineStyle(i,g,1);var j=Math.cos(d),k=Math.sin(d);a.beginFill(h,1),a.drawCircle(-e/2*j+b,-e/2*k+c,2*-f),a.drawCircle(e/2*j+b,e/2*k+c,2*-f),a.endFill(),a.lineStyle(i,g,0),a.beginFill(h,1),a.moveTo(-e/2*j+f*k+b,-e/2*k+f*j+c),a.lineTo(e/2*j+f*k+b,e/2*k+f*j+c),a.lineTo(e/2*j-f*k+b,e/2*k-f*j+c),a.lineTo(-e/2*j-f*k+b,-e/2*k-f*j+c),a.endFill(),a.lineStyle(i,g,1),a.moveTo(-e/2*j+f*k+b,-e/2*k+f*j+c),a.lineTo(e/2*j+f*k+b,e/2*k+f*j+c),a.moveTo(-e/2*j-f*k+b,-e/2*k-f*j+c),a.lineTo(e/2*j-f*k+b,e/2*k-f*j+c)},randomPastelHex:function(){var a,b,c,d;return c=[255,255,255],d=Math.floor(256*Math.random()),b=Math.floor(256*Math.random()),a=Math.floor(256*Math.random()),d=Math.floor((d+3*c[0])/4),b=Math.floor((b+3*c[1])/4),a=Math.floor((a+3*c[2])/4),this.rgbToHex(d,b,a)},rgbToHex:function(a,b,c){return this.componentToHex(a)+this.componentToHex(b)+this.componentToHex(c)},componentToHex:function(a){var b;return b=a.toString(16),2===b.len?b:b+"0"}}),c.Physics.P2.Spring=function(a,b,c,d,e,f,g,h,i,j){this.game=a.game,this.world=a,void 0===d&&(d=1),void 0===e&&(e=100),void 0===f&&(f=1),d=a.pxm(d);var k={restLength:d,stiffness:e,damping:f};"undefined"!=typeof g&&null!==g&&(k.worldAnchorA=[a.pxm(g[0]),a.pxm(g[1])]),"undefined"!=typeof h&&null!==h&&(k.worldAnchorB=[a.pxm(h[0]),a.pxm(h[1])]),"undefined"!=typeof i&&null!==i&&(k.localAnchorA=[a.pxm(i[0]),a.pxm(i[1])]),"undefined"!=typeof j&&null!==j&&(k.localAnchorB=[a.pxm(j[0]),a.pxm(j[1])]),this.data=new p2.LinearSpring(b,c,k),this.data.parent=this},c.Physics.P2.Spring.prototype.constructor=c.Physics.P2.Spring,c.Physics.P2.RotationalSpring=function(a,b,c,d,e,f){this.game=a.game,this.world=a,void 0===d&&(d=null),void 0===e&&(e=100),void 0===f&&(f=1),d&&(d=a.pxm(d));var g={restAngle:d,stiffness:e,damping:f};this.data=new p2.RotationalSpring(b,c,g),this.data.parent=this},c.Physics.P2.Spring.prototype.constructor=c.Physics.P2.Spring,c.Physics.P2.Material=function(a){this.name=a,p2.Material.call(this)},c.Physics.P2.Material.prototype=Object.create(p2.Material.prototype),c.Physics.P2.Material.prototype.constructor=c.Physics.P2.Material,c.Physics.P2.ContactMaterial=function(a,b,c){p2.ContactMaterial.call(this,a,b,c)},c.Physics.P2.ContactMaterial.prototype=Object.create(p2.ContactMaterial.prototype),c.Physics.P2.ContactMaterial.prototype.constructor=c.Physics.P2.ContactMaterial,c.Physics.P2.CollisionGroup=function(a){this.mask=a},c.Physics.P2.DistanceConstraint=function(a,b,c,d,e,f,g){void 0===d&&(d=100),void 0===e&&(e=[0,0]),void 0===f&&(f=[0,0]),void 0===g&&(g=Number.MAX_VALUE),this.game=a.game,this.world=a,d=a.pxm(d),e=[a.pxmi(e[0]),a.pxmi(e[1])],f=[a.pxmi(f[0]),a.pxmi(f[1])];var h={distance:d,localAnchorA:e,localAnchorB:f,maxForce:g};p2.DistanceConstraint.call(this,b,c,h)},c.Physics.P2.DistanceConstraint.prototype=Object.create(p2.DistanceConstraint.prototype),c.Physics.P2.DistanceConstraint.prototype.constructor=c.Physics.P2.DistanceConstraint,c.Physics.P2.GearConstraint=function(a,b,c,d,e){void 0===d&&(d=0),void 0===e&&(e=1),this.game=a.game,this.world=a;var f={angle:d,ratio:e};p2.GearConstraint.call(this,b,c,f)},c.Physics.P2.GearConstraint.prototype=Object.create(p2.GearConstraint.prototype),c.Physics.P2.GearConstraint.prototype.constructor=c.Physics.P2.GearConstraint,c.Physics.P2.LockConstraint=function(a,b,c,d,e,f){void 0===d&&(d=[0,0]),void 0===e&&(e=0),void 0===f&&(f=Number.MAX_VALUE),this.game=a.game,this.world=a,d=[a.pxm(d[0]),a.pxm(d[1])];var g={localOffsetB:d,localAngleB:e,maxForce:f};p2.LockConstraint.call(this,b,c,g)},c.Physics.P2.LockConstraint.prototype=Object.create(p2.LockConstraint.prototype),c.Physics.P2.LockConstraint.prototype.constructor=c.Physics.P2.LockConstraint,c.Physics.P2.PrismaticConstraint=function(a,b,c,d,e,f,g,h){void 0===d&&(d=!0),void 0===e&&(e=[0,0]),void 0===f&&(f=[0,0]),void 0===g&&(g=[0,0]),void 0===h&&(h=Number.MAX_VALUE),this.game=a.game,this.world=a,e=[a.pxmi(e[0]),a.pxmi(e[1])],f=[a.pxmi(f[0]),a.pxmi(f[1])];var i={localAnchorA:e,localAnchorB:f,localAxisA:g,maxForce:h,disableRotationalLock:!d};p2.PrismaticConstraint.call(this,b,c,i)},c.Physics.P2.PrismaticConstraint.prototype=Object.create(p2.PrismaticConstraint.prototype),c.Physics.P2.PrismaticConstraint.prototype.constructor=c.Physics.P2.PrismaticConstraint,c.Physics.P2.RevoluteConstraint=function(a,b,c,d,e,f,g){void 0===f&&(f=Number.MAX_VALUE),void 0===g&&(g=null),this.game=a.game,this.world=a,c=[a.pxmi(c[0]),a.pxmi(c[1])],e=[a.pxmi(e[0]),a.pxmi(e[1])],g&&(g=[a.pxmi(g[0]),a.pxmi(g[1])]);var h={worldPivot:g,localPivotA:c,localPivotB:e,maxForce:f};p2.RevoluteConstraint.call(this,b,d,h)},c.Physics.P2.RevoluteConstraint.prototype=Object.create(p2.RevoluteConstraint.prototype),c.Physics.P2.RevoluteConstraint.prototype.constructor=c.Physics.P2.RevoluteConstraint,c.ImageCollection=function(a,b,c,d,e,f,g){(void 0===c||0>=c)&&(c=32),(void 0===d||0>=d)&&(d=32),void 0===e&&(e=0),void 0===f&&(f=0),this.name=a,this.firstgid=0|b,this.imageWidth=0|c,this.imageHeight=0|d,this.imageMargin=0|e,this.imageSpacing=0|f,this.properties=g||{},this.images=[],this.total=0},c.ImageCollection.prototype={containsImageIndex:function(a){return a>=this.firstgid&&a<this.firstgid+this.total},addImage:function(a,b){this.images.push({gid:a,image:b}),this.total++}},c.ImageCollection.prototype.constructor=c.ImageCollection,c.Tile=function(a,b,c,d,e,f){this.layer=a,this.index=b,this.x=c,this.y=d,this.rotation=0,this.flipped=!1,this.worldX=c*e,this.worldY=d*f,this.width=e,this.height=f,this.centerX=Math.abs(e/2),this.centerY=Math.abs(f/2),this.alpha=1,this.properties={},this.scanned=!1,this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.collisionCallback=null,this.collisionCallbackContext=this},c.Tile.prototype={containsPoint:function(a,b){return!(a<this.worldX||b<this.worldY||a>this.right||b>this.bottom)},intersects:function(a,b,c,d){return c<=this.worldX?!1:d<=this.worldY?!1:a>=this.worldX+this.width?!1:b>=this.worldY+this.height?!1:!0},setCollisionCallback:function(a,b){this.collisionCallback=a,this.collisionCallbackContext=b},destroy:function(){this.collisionCallback=null,this.collisionCallbackContext=null,this.properties=null},setCollision:function(a,b,c,d){this.collideLeft=a,this.collideRight=b,this.collideUp=c,this.collideDown=d,this.faceLeft=a,this.faceRight=b,this.faceTop=c,this.faceBottom=d},resetCollision:function(){this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1},isInteresting:function(a,b){return a&&b?this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.faceTop||this.faceBottom||this.faceLeft||this.faceRight||this.collisionCallback:a?this.collideLeft||this.collideRight||this.collideUp||this.collideDown:b?this.faceTop||this.faceBottom||this.faceLeft||this.faceRight:!1},copy:function(a){this.index=a.index,this.alpha=a.alpha,this.properties=a.properties,this.collideUp=a.collideUp,this.collideDown=a.collideDown,this.collideLeft=a.collideLeft,this.collideRight=a.collideRight,this.collisionCallback=a.collisionCallback,this.collisionCallbackContext=a.collisionCallbackContext}},c.Tile.prototype.constructor=c.Tile,Object.defineProperty(c.Tile.prototype,"collides",{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown}}),Object.defineProperty(c.Tile.prototype,"canCollide",{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.collisionCallback}}),Object.defineProperty(c.Tile.prototype,"left",{get:function(){return this.worldX}}),Object.defineProperty(c.Tile.prototype,"right",{get:function(){return this.worldX+this.width}}),Object.defineProperty(c.Tile.prototype,"top",{get:function(){return this.worldY}}),Object.defineProperty(c.Tile.prototype,"bottom",{get:function(){return this.worldY+this.height}}),c.Tilemap=function(a,b,d,e,f,g){this.game=a,this.key=b;var h=c.TilemapParser.parse(this.game,b,d,e,f,g);null!==h&&(this.width=h.width,this.height=h.height,this.tileWidth=h.tileWidth,this.tileHeight=h.tileHeight,this.orientation=h.orientation,this.format=h.format,this.version=h.version,this.properties=h.properties,this.widthInPixels=h.widthInPixels,this.heightInPixels=h.heightInPixels,this.layers=h.layers,this.tilesets=h.tilesets,this.imagecollections=h.imagecollections,this.tiles=h.tiles,this.objects=h.objects,this.collideIndexes=[],this.collision=h.collision,this.images=h.images,this.currentLayer=0,this.debugMap=[],this._results=[],this._tempA=0,this._tempB=0)},c.Tilemap.CSV=0,c.Tilemap.TILED_JSON=1,c.Tilemap.NORTH=0,c.Tilemap.EAST=1,c.Tilemap.SOUTH=2,c.Tilemap.WEST=3,c.Tilemap.prototype={create:function(a,b,c,d,e,f){return void 0===f&&(f=this.game.world),this.width=b,this.height=c,this.setTileSize(d,e),this.layers.length=0,this.createBlankLayer(a,b,c,d,e,f)},setTileSize:function(a,b){this.tileWidth=a,this.tileHeight=b,this.widthInPixels=this.width*a,this.heightInPixels=this.height*b},addTilesetImage:function(a,b,d,e,f,g,h){if(void 0===a)return null;void 0===d&&(d=this.tileWidth),void 0===e&&(e=this.tileHeight),void 0===f&&(f=0),void 0===g&&(g=0),void 0===h&&(h=0),0===d&&(d=32),0===e&&(e=32);var i=null;if((void 0===b||null===b)&&(b=a),b instanceof c.BitmapData)i=b.canvas;else{if(!this.game.cache.checkImageKey(b))return console.warn('Phaser.Tilemap.addTilesetImage: Invalid image key given: "'+b+'"'),null;i=this.game.cache.getImage(b)}var j=this.getTilesetIndex(a);if(null===j&&this.format===c.Tilemap.TILED_JSON)return console.warn('Phaser.Tilemap.addTilesetImage: No data found in the JSON matching the tileset name: "'+b+'"'),null;if(this.tilesets[j])return this.tilesets[j].setImage(i),this.tilesets[j];var k=new c.Tileset(a,h,d,e,f,g,{});k.setImage(i),this.tilesets.push(k);for(var l=this.tilesets.length-1,m=f,n=f,o=0,p=0,q=0,r=h;r<h+k.total&&(this.tiles[r]=[m,n,l],m+=d+g,o++,o!==k.total)&&(p++,p!==k.columns||(m=f,n+=e+g,p=0,q++,q!==k.rows));r++);return k},createFromObjects:function(a,b,d,e,f,g,h,i,j){if(void 0===f&&(f=!0),void 0===g&&(g=!1),void 0===h&&(h=this.game.world),void 0===i&&(i=c.Sprite),void 0===j&&(j=!0),!this.objects[a])return void console.warn("Tilemap.createFromObjects: Invalid objectgroup name given: "+a);for(var k=0;k<this.objects[a].length;k++){var l=!1,m=this.objects[a][k];if(void 0!==m.gid&&"number"==typeof b&&m.gid===b?l=!0:void 0!==m.id&&"number"==typeof b&&m.id===b?l=!0:void 0!==m.name&&"string"==typeof b&&m.name===b&&(l=!0),l){var n=new i(this.game,parseFloat(m.x,10),parseFloat(m.y,10),d,e);n.name=m.name,n.visible=m.visible,n.autoCull=g,n.exists=f,m.width&&(n.width=m.width),m.height&&(n.height=m.height),m.rotation&&(n.angle=m.rotation),j&&(n.y-=n.height),h.add(n);for(var o in m.properties)h.set(n,o,m.properties[o],!1,!1,0,!0)}}},createFromTiles:function(a,b,d,e,f,g){"number"==typeof a&&(a=[a]),void 0===b||null===b?b=[]:"number"==typeof b&&(b=[b]),e=this.getLayer(e),void 0===f&&(f=this.game.world),void 0===g&&(g={}),void 0===g.customClass&&(g.customClass=c.Sprite),void 0===g.adjustY&&(g.adjustY=!0);var h=this.layers[e].width,i=this.layers[e].height;if(this.copy(0,0,h,i,e),this._results.length<2)return 0;for(var j,k=0,l=1,m=this._results.length;m>l;l++)if(-1!==a.indexOf(this._results[l].index)){j=new g.customClass(this.game,this._results[l].worldX,this._results[l].worldY,d);for(var n in g)j[n]=g[n];f.add(j),k++}if(1===b.length)for(l=0;l<a.length;l++)this.replace(a[l],b[0],0,0,h,i,e);else if(b.length>1)for(l=0;l<a.length;l++)this.replace(a[l],b[l],0,0,h,i,e);return k},createLayer:function(a,b,d,e){void 0===b&&(b=this.game.width),void 0===d&&(d=this.game.height),void 0===e&&(e=this.game.world);var f=a;return"string"==typeof a&&(f=this.getLayerIndex(a)),null===f||f>this.layers.length?void console.warn("Tilemap.createLayer: Invalid layer ID given: "+f):e.add(new c.TilemapLayer(this.game,this,f,b,d))},createBlankLayer:function(a,b,d,e,f,g){if(void 0===g&&(g=this.game.world),null!==this.getLayerIndex(a))return void console.warn("Tilemap.createBlankLayer: Layer with matching name already exists");for(var h,i={name:a,x:0,y:0,width:b,height:d,widthInPixels:b*e,heightInPixels:d*f,alpha:1,visible:!0,properties:{},indexes:[],callbacks:[],bodies:[],data:null},j=[],k=0;d>k;k++){h=[];for(var l=0;b>l;l++)h.push(new c.Tile(i,-1,l,k,e,f));j.push(h)}i.data=j,this.layers.push(i),this.currentLayer=this.layers.length-1;var m=i.widthInPixels,n=i.heightInPixels;m>this.game.width&&(m=this.game.width),n>this.game.height&&(n=this.game.height);var j=new c.TilemapLayer(this.game,this,this.layers.length-1,m,n);return j.name=a,g.add(j)},getIndex:function(a,b){for(var c=0;c<a.length;c++)if(a[c].name===b)return c;return null},getLayerIndex:function(a){return this.getIndex(this.layers,a)},getTilesetIndex:function(a){return this.getIndex(this.tilesets,a)},getImageIndex:function(a){return this.getIndex(this.images,a)},getObjectIndex:function(a){return this.getIndex(this.objects,a)},setTileIndexCallback:function(a,b,c,d){if(d=this.getLayer(d),"number"==typeof a)this.layers[d].callbacks[a]={callback:b,callbackContext:c};else for(var e=0,f=a.length;f>e;e++)this.layers[d].callbacks[a[e]]={callback:b,callbackContext:c}},setTileLocationCallback:function(a,b,c,d,e,f,g){if(g=this.getLayer(g),this.copy(a,b,c,d,g),!(this._results.length<2))for(var h=1;h<this._results.length;h++)this._results[h].setCollisionCallback(e,f)},setCollision:function(a,b,c,d){if(void 0===b&&(b=!0),void 0===d&&(d=!0),c=this.getLayer(c),"number"==typeof a)return this.setCollisionByIndex(a,b,c,!0);if(Array.isArray(a)){for(var e=0;e<a.length;e++)this.setCollisionByIndex(a[e],b,c,!1);d&&this.calculateFaces(c)}},setCollisionBetween:function(a,b,c,d,e){if(void 0===c&&(c=!0),void 0===e&&(e=!0),d=this.getLayer(d),!(a>b)){for(var f=a;b>=f;f++)this.setCollisionByIndex(f,c,d,!1);e&&this.calculateFaces(d)}},setCollisionByExclusion:function(a,b,c,d){void 0===b&&(b=!0),void 0===d&&(d=!0),c=this.getLayer(c);for(var e=0,f=this.tiles.length;f>e;e++)-1===a.indexOf(e)&&this.setCollisionByIndex(e,b,c,!1);d&&this.calculateFaces(c)},setCollisionByIndex:function(a,b,c,d){if(void 0===b&&(b=!0),void 0===c&&(c=this.currentLayer),void 0===d&&(d=!0),b)this.collideIndexes.push(a);else{var e=this.collideIndexes.indexOf(a);e>-1&&this.collideIndexes.splice(e,1)}for(var f=0;f<this.layers[c].height;f++)for(var g=0;g<this.layers[c].width;g++){var h=this.layers[c].data[f][g];h&&h.index===a&&(b?h.setCollision(!0,!0,!0,!0):h.resetCollision(),h.faceTop=b,h.faceBottom=b,h.faceLeft=b,h.faceRight=b)}return d&&this.calculateFaces(c),c},getLayer:function(a){return void 0===a?a=this.currentLayer:"string"==typeof a?a=this.getLayerIndex(a):a instanceof c.TilemapLayer&&(a=a.index),a},setPreventRecalculate:function(a){if(a===!0&&this.preventingRecalculate!==!0&&(this.preventingRecalculate=!0,this.needToRecalculate={}),a===!1&&this.preventingRecalculate===!0){this.preventingRecalculate=!1;for(var b in this.needToRecalculate)this.calculateFaces(b);this.needToRecalculate=!1}},calculateFaces:function(a){if(this.preventingRecalculate)return void(this.needToRecalculate[a]=!0);for(var b=null,c=null,d=null,e=null,f=0,g=this.layers[a].height;g>f;f++)for(var h=0,i=this.layers[a].width;i>h;h++){var j=this.layers[a].data[f][h];j&&(b=this.getTileAbove(a,h,f),c=this.getTileBelow(a,h,f),d=this.getTileLeft(a,h,f),e=this.getTileRight(a,h,f),j.collides&&(j.faceTop=!0,j.faceBottom=!0,j.faceLeft=!0,j.faceRight=!0),b&&b.collides&&(j.faceTop=!1),c&&c.collides&&(j.faceBottom=!1),d&&d.collides&&(j.faceLeft=!1),e&&e.collides&&(j.faceRight=!1))}},getTileAbove:function(a,b,c){return c>0?this.layers[a].data[c-1][b]:null},getTileBelow:function(a,b,c){return c<this.layers[a].height-1?this.layers[a].data[c+1][b]:null},getTileLeft:function(a,b,c){return b>0?this.layers[a].data[c][b-1]:null},getTileRight:function(a,b,c){return b<this.layers[a].width-1?this.layers[a].data[c][b+1]:null},setLayer:function(a){a=this.getLayer(a),this.layers[a]&&(this.currentLayer=a)},hasTile:function(a,b,c){return c=this.getLayer(c),this.layers[c].data[b][a].index>-1},removeTile:function(a,b,d){if(d=this.getLayer(d),a>=0&&a<this.layers[d].width&&b>=0&&b<this.layers[d].height&&this.hasTile(a,b,d)){var e=this.layers[d].data[b][a];return this.layers[d].data[b][a]=new c.Tile(this.layers[d],-1,a,b,this.tileWidth,this.tileHeight),this.layers[d].dirty=!0,this.calculateFaces(d),e}},removeTileWorldXY:function(a,b,c,d,e){return e=this.getLayer(e),a=this.game.math.snapToFloor(a,c)/c,b=this.game.math.snapToFloor(b,d)/d,this.removeTile(a,b,e)},putTile:function(a,b,d,e){if(null===a)return this.removeTile(b,d,e);if(e=this.getLayer(e),b>=0&&b<this.layers[e].width&&d>=0&&d<this.layers[e].height){var f;return a instanceof c.Tile?(f=a.index,this.hasTile(b,d,e)?this.layers[e].data[d][b].copy(a):this.layers[e].data[d][b]=new c.Tile(e,f,b,d,a.width,a.height)):(f=a,this.hasTile(b,d,e)?this.layers[e].data[d][b].index=f:this.layers[e].data[d][b]=new c.Tile(this.layers[e],f,b,d,this.tileWidth,this.tileHeight)),this.collideIndexes.indexOf(f)>-1?this.layers[e].data[d][b].setCollision(!0,!0,!0,!0):this.layers[e].data[d][b].resetCollision(),this.layers[e].dirty=!0,this.calculateFaces(e),this.layers[e].data[d][b]}return null},putTileWorldXY:function(a,b,c,d,e,f){return f=this.getLayer(f),b=this.game.math.snapToFloor(b,d)/d,c=this.game.math.snapToFloor(c,e)/e,this.putTile(a,b,c,f)},searchTileIndex:function(a,b,c,d){void 0===b&&(b=0),void 0===c&&(c=!1),d=this.getLayer(d);var e=0;if(c){for(var f=this.layers[d].height-1;f>=0;f--)for(var g=this.layers[d].width-1;g>=0;g--)if(this.layers[d].data[f][g].index===a){if(e===b)return this.layers[d].data[f][g];e++}}else for(var f=0;f<this.layers[d].height;f++)for(var g=0;g<this.layers[d].width;g++)if(this.layers[d].data[f][g].index===a){if(e===b)return this.layers[d].data[f][g];e++}return null},getTile:function(a,b,c,d){return void 0===d&&(d=!1),c=this.getLayer(c),a>=0&&a<this.layers[c].width&&b>=0&&b<this.layers[c].height?-1===this.layers[c].data[b][a].index?d?this.layers[c].data[b][a]:null:this.layers[c].data[b][a]:null},getTileWorldXY:function(a,b,c,d,e,f){return void 0===c&&(c=this.tileWidth),void 0===d&&(d=this.tileHeight),e=this.getLayer(e),a=this.game.math.snapToFloor(a,c)/c,b=this.game.math.snapToFloor(b,d)/d,this.getTile(a,b,e,f)},copy:function(a,b,c,d,e){if(e=this.getLayer(e),!this.layers[e])return void(this._results.length=0);void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=this.layers[e].width),void 0===d&&(d=this.layers[e].height),0>a&&(a=0),0>b&&(b=0),c>this.layers[e].width&&(c=this.layers[e].width),d>this.layers[e].height&&(d=this.layers[e].height),this._results.length=0,this._results.push({x:a,y:b,width:c,height:d,layer:e});for(var f=b;b+d>f;f++)for(var g=a;a+c>g;g++)this._results.push(this.layers[e].data[f][g]);return this._results},paste:function(a,b,c,d){if(void 0===a&&(a=0),void 0===b&&(b=0),d=this.getLayer(d),c&&!(c.length<2)){for(var e=a-c[1].x,f=b-c[1].y,g=1;g<c.length;g++)this.layers[d].data[f+c[g].y][e+c[g].x].copy(c[g]);this.layers[d].dirty=!0,this.calculateFaces(d)}},swap:function(a,b,c,d,e,f,g){g=this.getLayer(g),this.copy(c,d,e,f,g),this._results.length<2||(this._tempA=a,this._tempB=b,this._results.forEach(this.swapHandler,this),this.paste(c,d,this._results,g))},swapHandler:function(a){a.index===this._tempA?a.index=this._tempB:a.index===this._tempB&&(a.index=this._tempA)},forEach:function(a,b,c,d,e,f,g){g=this.getLayer(g),this.copy(c,d,e,f,g),this._results.length<2||(this._results.forEach(a,b),this.paste(c,d,this._results,g))},replace:function(a,b,c,d,e,f,g){if(g=this.getLayer(g),this.copy(c,d,e,f,g),!(this._results.length<2)){for(var h=1;h<this._results.length;h++)this._results[h].index===a&&(this._results[h].index=b);this.paste(c,d,this._results,g)}},random:function(a,b,c,d,e){if(e=this.getLayer(e),this.copy(a,b,c,d,e),!(this._results.length<2)){for(var f=[],g=1;g<this._results.length;g++)if(this._results[g].index){var h=this._results[g].index;-1===f.indexOf(h)&&f.push(h)}for(var i=1;i<this._results.length;i++)this._results[i].index=this.game.rnd.pick(f);this.paste(a,b,this._results,e)}},shuffle:function(a,b,d,e,f){if(f=this.getLayer(f),this.copy(a,b,d,e,f),!(this._results.length<2)){for(var g=[],h=1;h<this._results.length;h++)this._results[h].index&&g.push(this._results[h].index);c.ArrayUtils.shuffle(g);for(var i=1;i<this._results.length;i++)this._results[i].index=g[i-1];this.paste(a,b,this._results,f)}},fill:function(a,b,c,d,e,f){if(f=this.getLayer(f),this.copy(b,c,d,e,f),!(this._results.length<2)){for(var g=1;g<this._results.length;g++)this._results[g].index=a;this.paste(b,c,this._results,f)}},removeAllLayers:function(){this.layers.length=0,this.currentLayer=0},dump:function(){for(var a="",b=[""],c=0;c<this.layers[this.currentLayer].height;c++){for(var d=0;d<this.layers[this.currentLayer].width;d++)a+="%c ",this.layers[this.currentLayer].data[c][d]>1?this.debugMap[this.layers[this.currentLayer].data[c][d]]?b.push("background: "+this.debugMap[this.layers[this.currentLayer].data[c][d]]):b.push("background: #ffffff"):b.push("background: rgb(0, 0, 0)");a+="\n"}b[0]=a,console.log.apply(console,b)},destroy:function(){this.removeAllLayers(),this.data=[],this.game=null}},c.Tilemap.prototype.constructor=c.Tilemap,Object.defineProperty(c.Tilemap.prototype,"layer",{get:function(){return this.layers[this.currentLayer]},set:function(a){a!==this.currentLayer&&this.setLayer(a)}}),c.TilemapLayer=function(a,b,d,e,f){e|=0,f|=0,c.Sprite.call(this,a,0,0),this.map=b,this.index=d,this.layer=b.layers[d],this.canvas=PIXI.CanvasPool.create(this,e,f),this.context=this.canvas.getContext("2d"),this.setTexture(new PIXI.Texture(new PIXI.BaseTexture(this.canvas))),this.type=c.TILEMAPLAYER,this.physicsType=c.TILEMAPLAYER,this.renderSettings={enableScrollDelta:!1,overdrawRatio:.2,copyCanvas:null},this.debug=!1,this.exists=!0,this.debugSettings={missingImageFill:"rgb(255,255,255)",debuggedTileOverfill:"rgba(0,255,0,0.4)",forceFullRedraw:!0,debugAlpha:.5,facingEdgeStroke:"rgba(0,255,0,1)",collidingTileOverfill:"rgba(0,255,0,0.2)"},this.scrollFactorX=1,this.scrollFactorY=1,this.dirty=!0,this.rayStepRate=4,this._wrap=!1,this._mc={scrollX:0,scrollY:0,renderWidth:0,renderHeight:0,tileWidth:b.tileWidth,tileHeight:b.tileHeight,cw:b.tileWidth,ch:b.tileHeight,tilesets:[]},this._scrollX=0,this._scrollY=0,this._results=[],a.device.canvasBitBltShift||(this.renderSettings.copyCanvas=c.TilemapLayer.ensureSharedCopyCanvas()),this.fixedToCamera=!0},c.TilemapLayer.prototype=Object.create(c.Sprite.prototype),c.TilemapLayer.prototype.constructor=c.TilemapLayer,c.TilemapLayer.prototype.preUpdateCore=c.Component.Core.preUpdate,c.TilemapLayer.sharedCopyCanvas=null,c.TilemapLayer.ensureSharedCopyCanvas=function(){return this.sharedCopyCanvas||(this.sharedCopyCanvas=c.Canvas.create(2,2)),this.sharedCopyCanvas},c.TilemapLayer.prototype.preUpdate=function(){return this.preUpdateCore()},c.TilemapLayer.prototype.postUpdate=function(){c.Component.FixedToCamera.postUpdate.call(this);var a=this.game.camera;this.scrollX=a.x*this.scrollFactorX/this.scale.x,this.scrollY=a.y*this.scrollFactorY/this.scale.y,this.render()},c.TilemapLayer.prototype.destroy=function(){PIXI.CanvasPool.remove(this),c.Component.Destroy.prototype.destroy.call(this)},c.TilemapLayer.prototype.resize=function(a,b){this.canvas.width=a,this.canvas.height=b,this.texture.frame.resize(a,b),this.texture.width=a,this.texture.height=b,this.texture.crop.width=a,this.texture.crop.height=b,this.texture.baseTexture.width=a,this.texture.baseTexture.height=b,this.texture.baseTexture.dirty(),this.texture.requiresUpdate=!0,this.texture._updateUvs(),this.dirty=!0},c.TilemapLayer.prototype.resizeWorld=function(){this.game.world.setBounds(0,0,this.layer.widthInPixels*this.scale.x,this.layer.heightInPixels*this.scale.y)},c.TilemapLayer.prototype._fixX=function(a){return 0>a&&(a=0),1===this.scrollFactorX?a:this._scrollX+(a-this._scrollX/this.scrollFactorX)},c.TilemapLayer.prototype._unfixX=function(a){return 1===this.scrollFactorX?a:this._scrollX/this.scrollFactorX+(a-this._scrollX)},c.TilemapLayer.prototype._fixY=function(a){return 0>a&&(a=0),1===this.scrollFactorY?a:this._scrollY+(a-this._scrollY/this.scrollFactorY)},c.TilemapLayer.prototype._unfixY=function(a){return 1===this.scrollFactorY?a:this._scrollY/this.scrollFactorY+(a-this._scrollY)},c.TilemapLayer.prototype.getTileX=function(a){return Math.floor(this._fixX(a)/this._mc.tileWidth)},c.TilemapLayer.prototype.getTileY=function(a){return Math.floor(this._fixY(a)/this._mc.tileHeight)},c.TilemapLayer.prototype.getTileXY=function(a,b,c){return c.x=this.getTileX(a),c.y=this.getTileY(b),c},c.TilemapLayer.prototype.getRayCastTiles=function(a,b,c,d){ +b||(b=this.rayStepRate),void 0===c&&(c=!1),void 0===d&&(d=!1);var e=this.getTiles(a.x,a.y,a.width,a.height,c,d);if(0===e.length)return[];for(var f=a.coordinatesOnLine(b),g=[],h=0;h<e.length;h++)for(var i=0;i<f.length;i++){var j=e[h],k=f[i];if(j.containsPoint(k[0],k[1])){g.push(j);break}}return g},c.TilemapLayer.prototype.getTiles=function(a,b,c,d,e,f){void 0===e&&(e=!1),void 0===f&&(f=!1);var g=!(e||f);a=this._fixX(a),b=this._fixY(b);for(var h=Math.floor(a/(this._mc.cw*this.scale.x)),i=Math.floor(b/(this._mc.ch*this.scale.y)),j=Math.ceil((a+c)/(this._mc.cw*this.scale.x))-h,k=Math.ceil((b+d)/(this._mc.ch*this.scale.y))-i;this._results.length;)this._results.pop();for(var l=i;i+k>l;l++)for(var m=h;h+j>m;m++){var n=this.layer.data[l];n&&n[m]&&(g||n[m].isInteresting(e,f))&&this._results.push(n[m])}return this._results.slice()},c.TilemapLayer.prototype.resolveTileset=function(a){var b=this._mc.tilesets;if(2e3>a)for(;b.length<a;)b.push(void 0);var c=this.map.tiles[a]&&this.map.tiles[a][2];if(null!=c){var d=this.map.tilesets[c];if(d&&d.containsTileIndex(a))return b[a]=d}return b[a]=null},c.TilemapLayer.prototype.resetTilesetCache=function(){for(var a=this._mc.tilesets;a.length;)a.pop()},c.TilemapLayer.prototype.setScale=function(a,b){a=a||1,b=b||a;for(var c=0;c<this.layer.data.length;c++)for(var d=this.layer.data[c],e=0;e<d.length;e++){var f=d[e];f.width=this.map.tileWidth*a,f.height=this.map.tileHeight*b,f.worldX=f.x*f.width,f.worldY=f.y*f.height}this.scale.setTo(a,b)},c.TilemapLayer.prototype.shiftCanvas=function(a,b,c){var d=a.canvas,e=d.width-Math.abs(b),f=d.height-Math.abs(c),g=0,h=0,i=b,j=c;0>b&&(g=-b,i=0),0>c&&(h=-c,j=0);var k=this.renderSettings.copyCanvas;if(k){(k.width<e||k.height<f)&&(k.width=e,k.height=f);var l=k.getContext("2d");l.clearRect(0,0,e,f),l.drawImage(d,g,h,e,f,0,0,e,f),a.clearRect(i,j,e,f),a.drawImage(k,0,0,e,f,i,j,e,f)}else a.save(),a.globalCompositeOperation="copy",a.drawImage(d,g,h,e,f,i,j,e,f),a.restore()},c.TilemapLayer.prototype.renderRegion=function(a,b,c,d,e,f){var g=this.context,h=this.layer.width,i=this.layer.height,j=this._mc.tileWidth,k=this._mc.tileHeight,l=this._mc.tilesets,m=NaN;this._wrap||(e>=c&&(c=Math.max(0,c),e=Math.min(h-1,e)),f>=d&&(d=Math.max(0,d),f=Math.min(i-1,f)));var n,o,p,q,r,s,t=c*j-a,u=d*k-b,v=(c+(1<<20)*h)%h,w=(d+(1<<20)*i)%i;for(g.fillStyle=this.tileColor,q=w,s=f-d,o=u;s>=0;q++,s--,o+=k){q>=i&&(q-=i);var x=this.layer.data[q];for(p=v,r=e-c,n=t;r>=0;p++,r--,n+=j){p>=h&&(p-=h);var y=x[p];if(y&&!(y.index<0)){var z=y.index,A=l[z];void 0===A&&(A=this.resolveTileset(z)),y.alpha===m||this.debug||(g.globalAlpha=y.alpha,m=y.alpha),A?y.rotation||y.flipped?(g.save(),g.translate(n+y.centerX,o+y.centerY),g.rotate(y.rotation),y.flipped&&g.scale(-1,1),A.draw(g,-y.centerX,-y.centerY,z),g.restore()):A.draw(g,n,o,z):this.debugSettings.missingImageFill&&(g.fillStyle=this.debugSettings.missingImageFill,g.fillRect(n,o,j,k)),y.debug&&this.debugSettings.debuggedTileOverfill&&(g.fillStyle=this.debugSettings.debuggedTileOverfill,g.fillRect(n,o,j,k))}}}},c.TilemapLayer.prototype.renderDeltaScroll=function(a,b){var c=this._mc.scrollX,d=this._mc.scrollY,e=this.canvas.width,f=this.canvas.height,g=this._mc.tileWidth,h=this._mc.tileHeight,i=0,j=-g,k=0,l=-h;if(0>a?(i=e+a,j=e-1):a>0&&(j=a),0>b?(k=f+b,l=f-1):b>0&&(l=b),this.shiftCanvas(this.context,a,b),i=Math.floor((i+c)/g),j=Math.floor((j+c)/g),k=Math.floor((k+d)/h),l=Math.floor((l+d)/h),j>=i){this.context.clearRect(i*g-c,0,(j-i+1)*g,f);var m=Math.floor((0+d)/h),n=Math.floor((f-1+d)/h);this.renderRegion(c,d,i,m,j,n)}if(l>=k){this.context.clearRect(0,k*h-d,e,(l-k+1)*h);var o=Math.floor((0+c)/g),p=Math.floor((e-1+c)/g);this.renderRegion(c,d,o,k,p,l)}},c.TilemapLayer.prototype.renderFull=function(){var a=this._mc.scrollX,b=this._mc.scrollY,c=this.canvas.width,d=this.canvas.height,e=this._mc.tileWidth,f=this._mc.tileHeight,g=Math.floor(a/e),h=Math.floor((c-1+a)/e),i=Math.floor(b/f),j=Math.floor((d-1+b)/f);this.context.clearRect(0,0,c,d),this.renderRegion(a,b,g,i,h,j)},c.TilemapLayer.prototype.render=function(){var a=!1;if(this.visible){(this.dirty||this.layer.dirty)&&(this.layer.dirty=!1,a=!0);var b=this.canvas.width,c=this.canvas.height,d=0|this._scrollX,e=0|this._scrollY,f=this._mc,g=f.scrollX-d,h=f.scrollY-e;if(a||0!==g||0!==h||f.renderWidth!==b||f.renderHeight!==c)return this.context.save(),f.scrollX=d,f.scrollY=e,(f.renderWidth!==b||f.renderHeight!==c)&&(f.renderWidth=b,f.renderHeight=c),this.debug&&(this.context.globalAlpha=this.debugSettings.debugAlpha,this.debugSettings.forceFullRedraw&&(a=!0)),!a&&this.renderSettings.enableScrollDelta&&Math.abs(g)+Math.abs(h)<Math.min(b,c)?this.renderDeltaScroll(g,h):this.renderFull(),this.debug&&(this.context.globalAlpha=1,this.renderDebug()),this.texture.baseTexture.dirty(),this.dirty=!1,this.context.restore(),!0}},c.TilemapLayer.prototype.renderDebug=function(){var a,b,c,d,e,f,g=this._mc.scrollX,h=this._mc.scrollY,i=this.context,j=this.canvas.width,k=this.canvas.height,l=this.layer.width,m=this.layer.height,n=this._mc.tileWidth,o=this._mc.tileHeight,p=Math.floor(g/n),q=Math.floor((j-1+g)/n),r=Math.floor(h/o),s=Math.floor((k-1+h)/o),t=p*n-g,u=r*o-h,v=(p+(1<<20)*l)%l,w=(r+(1<<20)*m)%m;for(i.strokeStyle=this.debugSettings.facingEdgeStroke,d=w,f=s-r,b=u;f>=0;d++,f--,b+=o){d>=m&&(d-=m);var x=this.layer.data[d];for(c=v,e=q-p,a=t;e>=0;c++,e--,a+=n){c>=l&&(c-=l);var y=x[c];!y||y.index<0||!y.collides||(this.debugSettings.collidingTileOverfill&&(i.fillStyle=this.debugSettings.collidingTileOverfill,i.fillRect(a,b,this._mc.cw,this._mc.ch)),this.debugSettings.facingEdgeStroke&&(i.beginPath(),y.faceTop&&(i.moveTo(a,b),i.lineTo(a+this._mc.cw,b)),y.faceBottom&&(i.moveTo(a,b+this._mc.ch),i.lineTo(a+this._mc.cw,b+this._mc.ch)),y.faceLeft&&(i.moveTo(a,b),i.lineTo(a,b+this._mc.ch)),y.faceRight&&(i.moveTo(a+this._mc.cw,b),i.lineTo(a+this._mc.cw,b+this._mc.ch)),i.stroke()))}}},Object.defineProperty(c.TilemapLayer.prototype,"wrap",{get:function(){return this._wrap},set:function(a){this._wrap=a,this.dirty=!0}}),Object.defineProperty(c.TilemapLayer.prototype,"scrollX",{get:function(){return this._scrollX},set:function(a){this._scrollX=a}}),Object.defineProperty(c.TilemapLayer.prototype,"scrollY",{get:function(){return this._scrollY},set:function(a){this._scrollY=a}}),Object.defineProperty(c.TilemapLayer.prototype,"collisionWidth",{get:function(){return this._mc.cw},set:function(a){this._mc.cw=0|a,this.dirty=!0}}),Object.defineProperty(c.TilemapLayer.prototype,"collisionHeight",{get:function(){return this._mc.ch},set:function(a){this._mc.ch=0|a,this.dirty=!0}}),c.TilemapParser={INSERT_NULL:!1,parse:function(a,b,d,e,f,g){if(void 0===d&&(d=32),void 0===e&&(e=32),void 0===f&&(f=10),void 0===g&&(g=10),void 0===b)return this.getEmptyData();if(null===b)return this.getEmptyData(d,e,f,g);var h=a.cache.getTilemapData(b);if(h){if(h.format===c.Tilemap.CSV)return this.parseCSV(b,h.data,d,e);if(!h.format||h.format===c.Tilemap.TILED_JSON)return this.parseTiledJSON(h.data)}else console.warn("Phaser.TilemapParser.parse - No map data found for key "+b)},parseCSV:function(a,b,d,e){var f=this.getEmptyData();b=b.trim();for(var g=[],h=b.split("\n"),i=h.length,j=0,k=0;k<h.length;k++){g[k]=[];for(var l=h[k].split(","),m=0;m<l.length;m++)g[k][m]=new c.Tile(f.layers[0],parseInt(l[m],10),m,k,d,e);0===j&&(j=l.length)}return f.format=c.Tilemap.CSV,f.name=a,f.width=j,f.height=i,f.tileWidth=d,f.tileHeight=e,f.widthInPixels=j*d,f.heightInPixels=i*e,f.layers[0].width=j,f.layers[0].height=i,f.layers[0].widthInPixels=f.widthInPixels,f.layers[0].heightInPixels=f.heightInPixels,f.layers[0].data=g,f},getEmptyData:function(a,b,c,d){var e={};e.width=0,e.height=0,e.tileWidth=0,e.tileHeight=0,"undefined"!=typeof a&&null!==a&&(e.tileWidth=a),"undefined"!=typeof b&&null!==b&&(e.tileHeight=b),"undefined"!=typeof c&&null!==c&&(e.width=c),"undefined"!=typeof d&&null!==d&&(e.height=d),e.orientation="orthogonal",e.version="1",e.properties={},e.widthInPixels=0,e.heightInPixels=0;var f=[],g={name:"layer",x:0,y:0,width:0,height:0,widthInPixels:0,heightInPixels:0,alpha:1,visible:!0,properties:{},indexes:[],callbacks:[],bodies:[],data:[]};return f.push(g),e.layers=f,e.images=[],e.objects={},e.collision={},e.tilesets=[],e.tiles=[],e},parseTiledJSON:function(a){function b(a,b){var c={};for(var d in b){var e=b[d];"undefined"!=typeof a[e]&&(c[e]=a[e])}return c}if("orthogonal"!==a.orientation)return console.warn("TilemapParser.parseTiledJSON - Only orthogonal map types are supported in this version of Phaser"),null;var d={};d.width=a.width,d.height=a.height,d.tileWidth=a.tilewidth,d.tileHeight=a.tileheight,d.orientation=a.orientation,d.format=c.Tilemap.TILED_JSON,d.version=a.version,d.properties=a.properties,d.widthInPixels=d.width*d.tileWidth,d.heightInPixels=d.height*d.tileHeight;for(var e=[],f=0;f<a.layers.length;f++)if("tilelayer"===a.layers[f].type){var g=a.layers[f];if(!g.compression&&g.encoding&&"base64"===g.encoding){for(var h=window.atob(g.data),i=h.length,j=new Array(i),f=0;i>f;f+=4)j[f/4]=(h.charCodeAt(f)|h.charCodeAt(f+1)<<8|h.charCodeAt(f+2)<<16|h.charCodeAt(f+3)<<24)>>>0;g.data=j}var k={name:g.name,x:g.x,y:g.y,width:g.width,height:g.height,widthInPixels:g.width*a.tilewidth,heightInPixels:g.height*a.tileheight,alpha:g.opacity,visible:g.visible,properties:{},indexes:[],callbacks:[],bodies:[]};g.properties&&(k.properties=g.properties);for(var l,m,n,o,p=0,q=[],r=[],s=0,i=g.data.length;i>s;s++){if(l=0,m=!1,o=g.data[s],o>536870912)switch(n=0,o>2147483648&&(o-=2147483648,n+=4),o>1073741824&&(o-=1073741824,n+=2),o>536870912&&(o-=536870912,n+=1),n){case 5:l=Math.PI/2;break;case 6:l=Math.PI;break;case 3:l=3*Math.PI/2;break;case 4:l=0,m=!0;break;case 7:l=Math.PI/2,m=!0;break;case 2:l=Math.PI,m=!0;break;case 1:l=3*Math.PI/2,m=!0}o>0?(q.push(new c.Tile(k,o,p,r.length,a.tilewidth,a.tileheight)),q[q.length-1].rotation=l,q[q.length-1].flipped=m):c.TilemapParser.INSERT_NULL?q.push(null):q.push(new c.Tile(k,-1,p,r.length,a.tilewidth,a.tileheight)),p++,p===g.width&&(r.push(q),p=0,q=[])}k.data=r,e.push(k)}d.layers=e;for(var t=[],f=0;f<a.layers.length;f++)if("imagelayer"===a.layers[f].type){var u=a.layers[f],v={name:u.name,image:u.image,x:u.x,y:u.y,alpha:u.opacity,visible:u.visible,properties:{}};u.properties&&(v.properties=u.properties),t.push(v)}d.images=t;for(var w=[],x=[],f=0;f<a.tilesets.length;f++){var y=a.tilesets[f];if(y.image){var z=new c.Tileset(y.name,y.firstgid,y.tilewidth,y.tileheight,y.margin,y.spacing,y.properties);y.tileproperties&&(z.tileProperties=y.tileproperties),z.updateTileData(y.imagewidth,y.imageheight),w.push(z)}else{var A=new c.ImageCollection(y.name,y.firstgid,y.tilewidth,y.tileheight,y.margin,y.spacing,y.properties);for(var f in y.tiles){var v=y.tiles[f].image,o=y.firstgid+parseInt(f,10);A.addImage(o,v)}x.push(A)}}d.tilesets=w,d.imagecollections=x;for(var B={},C={},f=0;f<a.layers.length;f++)if("objectgroup"===a.layers[f].type){var D=a.layers[f];B[D.name]=[],C[D.name]=[];for(var E=0,i=D.objects.length;i>E;E++)if(D.objects[E].gid){var F={gid:D.objects[E].gid,name:D.objects[E].name,type:D.objects[E].hasOwnProperty("type")?D.objects[E].type:"",x:D.objects[E].x,y:D.objects[E].y,visible:D.objects[E].visible,properties:D.objects[E].properties};D.objects[E].rotation&&(F.rotation=D.objects[E].rotation),B[D.name].push(F)}else if(D.objects[E].polyline){var F={name:D.objects[E].name,type:D.objects[E].type,x:D.objects[E].x,y:D.objects[E].y,width:D.objects[E].width,height:D.objects[E].height,visible:D.objects[E].visible,properties:D.objects[E].properties};D.objects[E].rotation&&(F.rotation=D.objects[E].rotation),F.polyline=[];for(var G=0;G<D.objects[E].polyline.length;G++)F.polyline.push([D.objects[E].polyline[G].x,D.objects[E].polyline[G].y]);C[D.name].push(F),B[D.name].push(F)}else if(D.objects[E].polygon){var F=b(D.objects[E],["name","type","x","y","visible","rotation","properties"]);F.polygon=[];for(var G=0;G<D.objects[E].polygon.length;G++)F.polygon.push([D.objects[E].polygon[G].x,D.objects[E].polygon[G].y]);B[D.name].push(F)}else if(D.objects[E].ellipse){var F=b(D.objects[E],["name","type","ellipse","x","y","width","height","visible","rotation","properties"]);B[D.name].push(F)}else{var F=b(D.objects[E],["name","type","x","y","width","height","visible","rotation","properties"]);F.rectangle=!0,B[D.name].push(F)}}d.objects=B,d.collision=C,d.tiles=[];for(var f=0;f<d.tilesets.length;f++)for(var y=d.tilesets[f],p=y.tileMargin,H=y.tileMargin,I=0,J=0,K=0,s=y.firstgid;s<y.firstgid+y.total&&(d.tiles[s]=[p,H,f],p+=y.tileWidth+y.tileSpacing,I++,I!==y.total)&&(J++,J!==y.columns||(p=y.tileMargin,H+=y.tileHeight+y.tileSpacing,J=0,K++,K!==y.rows));s++);for(var k,L,M,y,f=0;f<d.layers.length;f++){k=d.layers[f];for(var N=0;N<k.data.length;N++){q=k.data[N];for(var O=0;O<q.length;O++)L=q[O],null===L||L.index<0||(M=d.tiles[L.index][2],y=d.tilesets[M],y.tileProperties&&y.tileProperties[L.index-y.firstgid]&&(L.properties=c.Utils.mixin(y.tileProperties[L.index-y.firstgid],L.properties)))}}return d}},c.Tileset=function(a,b,c,d,e,f,g){(void 0===c||0>=c)&&(c=32),(void 0===d||0>=d)&&(d=32),void 0===e&&(e=0),void 0===f&&(f=0),this.name=a,this.firstgid=0|b,this.tileWidth=0|c,this.tileHeight=0|d,this.tileMargin=0|e,this.tileSpacing=0|f,this.properties=g||{},this.image=null,this.rows=0,this.columns=0,this.total=0,this.drawCoords=[]},c.Tileset.prototype={draw:function(a,b,c,d){var e=d-this.firstgid<<1;e>=0&&e+1<this.drawCoords.length&&a.drawImage(this.image,this.drawCoords[e],this.drawCoords[e+1],this.tileWidth,this.tileHeight,b,c,this.tileWidth,this.tileHeight)},containsTileIndex:function(a){return a>=this.firstgid&&a<this.firstgid+this.total},setImage:function(a){this.image=a,this.updateTileData(a.width,a.height)},setSpacing:function(a,b){this.tileMargin=0|a,this.tileSpacing=0|b,this.image&&this.updateTileData(this.image.width,this.image.height)},updateTileData:function(a,b){var c=(b-2*this.tileMargin+this.tileSpacing)/(this.tileHeight+this.tileSpacing),d=(a-2*this.tileMargin+this.tileSpacing)/(this.tileWidth+this.tileSpacing);(c%1!==0||d%1!==0)&&console.warn("Phaser.Tileset - image tile area is not an even multiple of tile size"),c=Math.floor(c),d=Math.floor(d),(this.rows&&this.rows!==c||this.columns&&this.columns!==d)&&console.warn("Phaser.Tileset - actual and expected number of tile rows and columns differ"),this.rows=c,this.columns=d,this.total=c*d,this.drawCoords.length=0;for(var e=this.tileMargin,f=this.tileMargin,g=0;g<this.rows;g++){for(var h=0;h<this.columns;h++)this.drawCoords.push(e),this.drawCoords.push(f),e+=this.tileWidth+this.tileSpacing;e=this.tileMargin,f+=this.tileHeight+this.tileSpacing}}},c.Tileset.prototype.constructor=c.Tileset,c.Particle=function(a,b,d,e,f){c.Sprite.call(this,a,b,d,e,f),this.autoScale=!1,this.scaleData=null,this._s=0,this.autoAlpha=!1,this.alphaData=null,this._a=0},c.Particle.prototype=Object.create(c.Sprite.prototype),c.Particle.prototype.constructor=c.Particle,c.Particle.prototype.update=function(){this.autoScale&&(this._s--,this._s?this.scale.set(this.scaleData[this._s].x,this.scaleData[this._s].y):this.autoScale=!1),this.autoAlpha&&(this._a--,this._a?this.alpha=this.alphaData[this._a].v:this.autoAlpha=!1)},c.Particle.prototype.onEmit=function(){},c.Particle.prototype.setAlphaData=function(a){this.alphaData=a,this._a=a.length-1,this.alpha=this.alphaData[this._a].v,this.autoAlpha=!0},c.Particle.prototype.setScaleData=function(a){this.scaleData=a,this._s=a.length-1,this.scale.set(this.scaleData[this._s].x,this.scaleData[this._s].y),this.autoScale=!0},c.Particle.prototype.reset=function(a,b,d){return c.Component.Reset.prototype.reset.call(this,a,b,d),this.alpha=1,this.scale.set(1),this.autoScale=!1,this.autoAlpha=!1,this},c.Particles=function(a){this.game=a,this.emitters={},this.ID=0},c.Particles.prototype={add:function(a){return this.emitters[a.name]=a,a},remove:function(a){delete this.emitters[a.name]},update:function(){for(var a in this.emitters)this.emitters[a].exists&&this.emitters[a].update()}},c.Particles.prototype.constructor=c.Particles,c.Particles.Arcade={},c.Particles.Arcade.Emitter=function(a,b,d,e){this.maxParticles=e||50,c.Group.call(this,a),this.name="emitter"+this.game.particles.ID++,this.type=c.EMITTER,this.physicsType=c.GROUP,this.area=new c.Rectangle(b,d,1,1),this.minParticleSpeed=new c.Point(-100,-100),this.maxParticleSpeed=new c.Point(100,100),this.minParticleScale=1,this.maxParticleScale=1,this.scaleData=null,this.minRotation=-360,this.maxRotation=360,this.minParticleAlpha=1,this.maxParticleAlpha=1,this.alphaData=null,this.gravity=100,this.particleClass=c.Particle,this.particleDrag=new c.Point,this.angularDrag=0,this.frequency=100,this.lifespan=2e3,this.bounce=new c.Point,this.on=!1,this.particleAnchor=new c.Point(.5,.5),this.blendMode=c.blendModes.NORMAL,this.emitX=b,this.emitY=d,this.autoScale=!1,this.autoAlpha=!1,this.particleBringToTop=!1,this.particleSendToBack=!1,this._minParticleScale=new c.Point(1,1),this._maxParticleScale=new c.Point(1,1),this._quantity=0,this._timer=0,this._counter=0,this._flowQuantity=0,this._flowTotal=0,this._explode=!0,this._frames=null},c.Particles.Arcade.Emitter.prototype=Object.create(c.Group.prototype),c.Particles.Arcade.Emitter.prototype.constructor=c.Particles.Arcade.Emitter,c.Particles.Arcade.Emitter.prototype.update=function(){if(this.on&&this.game.time.time>=this._timer)if(this._timer=this.game.time.time+this.frequency*this.game.time.slowMotion,0!==this._flowTotal)if(this._flowQuantity>0){for(var a=0;a<this._flowQuantity;a++)if(this.emitParticle()&&(this._counter++,-1!==this._flowTotal&&this._counter>=this._flowTotal)){this.on=!1;break}}else this.emitParticle()&&(this._counter++,-1!==this._flowTotal&&this._counter>=this._flowTotal&&(this.on=!1));else this.emitParticle()&&(this._counter++,this._quantity>0&&this._counter>=this._quantity&&(this.on=!1));for(var a=this.children.length;a--;)this.children[a].exists&&this.children[a].update()},c.Particles.Arcade.Emitter.prototype.makeParticles=function(a,b,c,d,e){void 0===b&&(b=0),void 0===c&&(c=this.maxParticles),void 0===d&&(d=!1),void 0===e&&(e=!1);var f,g=0,h=a,i=b;for(this._frames=b,c>this.maxParticles&&(this.maxParticles=c);c>g;)Array.isArray(a)&&(h=this.game.rnd.pick(a)),Array.isArray(b)&&(i=this.game.rnd.pick(b)),f=new this.particleClass(this.game,0,0,h,i),this.game.physics.arcade.enable(f,!1),d?(f.body.checkCollision.any=!0,f.body.checkCollision.none=!1):f.body.checkCollision.none=!0,f.body.collideWorldBounds=e,f.body.skipQuadTree=!0,f.exists=!1,f.visible=!1,f.anchor.copyFrom(this.particleAnchor),this.add(f),g++;return this},c.Particles.Arcade.Emitter.prototype.kill=function(){this.on=!1,this.alive=!1,this.exists=!1},c.Particles.Arcade.Emitter.prototype.revive=function(){this.alive=!0,this.exists=!0},c.Particles.Arcade.Emitter.prototype.explode=function(a,b){this._flowTotal=0,this.start(!0,a,0,b,!1)},c.Particles.Arcade.Emitter.prototype.flow=function(a,b,c,d,e){(void 0===c||0===c)&&(c=1),void 0===d&&(d=-1),void 0===e&&(e=!0),c>this.maxParticles&&(c=this.maxParticles),this._counter=0,this._flowQuantity=c,this._flowTotal=d,e?(this.start(!0,a,b,c),this._counter+=c,this.on=!0,this._timer=this.game.time.time+b*this.game.time.slowMotion):this.start(!1,a,b,c)},c.Particles.Arcade.Emitter.prototype.start=function(a,b,c,d,e){if(void 0===a&&(a=!0),void 0===b&&(b=0),(void 0===c||null===c)&&(c=250),void 0===d&&(d=0),void 0===e&&(e=!1),d>this.maxParticles&&(d=this.maxParticles),this.revive(),this.visible=!0,this.lifespan=b,this.frequency=c,a||e)for(var f=0;d>f;f++)this.emitParticle();else this.on=!0,this._quantity+=d,this._counter=0,this._timer=this.game.time.time+c*this.game.time.slowMotion},c.Particles.Arcade.Emitter.prototype.emitParticle=function(a,b,c,d){void 0===a&&(a=null),void 0===b&&(b=null);var e=this.getFirstExists(!1);if(null===e)return!1;var f=this.game.rnd;void 0!==c&&void 0!==d?e.loadTexture(c,d):void 0!==c&&e.loadTexture(c);var g=this.emitX,h=this.emitY;null!==a?g=a:this.width>1&&(g=f.between(this.left,this.right)),null!==b?h=b:this.height>1&&(h=f.between(this.top,this.bottom)),e.reset(g,h),e.angle=0,e.lifespan=this.lifespan,this.particleBringToTop?this.bringToTop(e):this.particleSendToBack&&this.sendToBack(e),this.autoScale?e.setScaleData(this.scaleData):1!==this.minParticleScale||1!==this.maxParticleScale?e.scale.set(f.realInRange(this.minParticleScale,this.maxParticleScale)):(this._minParticleScale.x!==this._maxParticleScale.x||this._minParticleScale.y!==this._maxParticleScale.y)&&e.scale.set(f.realInRange(this._minParticleScale.x,this._maxParticleScale.x),f.realInRange(this._minParticleScale.y,this._maxParticleScale.y)),void 0===d&&(Array.isArray(this._frames)?e.frame=this.game.rnd.pick(this._frames):e.frame=this._frames),this.autoAlpha?e.setAlphaData(this.alphaData):e.alpha=f.realInRange(this.minParticleAlpha,this.maxParticleAlpha),e.blendMode=this.blendMode;var i=e.body;return i.updateBounds(),i.bounce.copyFrom(this.bounce),i.drag.copyFrom(this.particleDrag),i.velocity.x=f.between(this.minParticleSpeed.x,this.maxParticleSpeed.x),i.velocity.y=f.between(this.minParticleSpeed.y,this.maxParticleSpeed.y),i.angularVelocity=f.between(this.minRotation,this.maxRotation),i.gravity.y=this.gravity,i.angularDrag=this.angularDrag,e.onEmit(),!0},c.Particles.Arcade.Emitter.prototype.destroy=function(){this.game.particles.remove(this),c.Group.prototype.destroy.call(this,!0,!1)},c.Particles.Arcade.Emitter.prototype.setSize=function(a,b){this.area.width=a,this.area.height=b},c.Particles.Arcade.Emitter.prototype.setXSpeed=function(a,b){a=a||0,b=b||0,this.minParticleSpeed.x=a,this.maxParticleSpeed.x=b},c.Particles.Arcade.Emitter.prototype.setYSpeed=function(a,b){a=a||0,b=b||0,this.minParticleSpeed.y=a,this.maxParticleSpeed.y=b},c.Particles.Arcade.Emitter.prototype.setRotation=function(a,b){a=a||0,b=b||0,this.minRotation=a,this.maxRotation=b},c.Particles.Arcade.Emitter.prototype.setAlpha=function(a,b,d,e,f){if(void 0===a&&(a=1),void 0===b&&(b=1),void 0===d&&(d=0),void 0===e&&(e=c.Easing.Linear.None),void 0===f&&(f=!1),this.minParticleAlpha=a,this.maxParticleAlpha=b,this.autoAlpha=!1,d>0&&a!==b){var g={v:a},h=this.game.make.tween(g).to({v:b},d,e);h.yoyo(f),this.alphaData=h.generateData(60),this.alphaData.reverse(),this.autoAlpha=!0}},c.Particles.Arcade.Emitter.prototype.setScale=function(a,b,d,e,f,g,h){if(void 0===a&&(a=1),void 0===b&&(b=1),void 0===d&&(d=1),void 0===e&&(e=1),void 0===f&&(f=0),void 0===g&&(g=c.Easing.Linear.None),void 0===h&&(h=!1),this.minParticleScale=1,this.maxParticleScale=1,this._minParticleScale.set(a,d),this._maxParticleScale.set(b,e),this.autoScale=!1,f>0&&(a!==b||d!==e)){var i={x:a,y:d},j=this.game.make.tween(i).to({x:b,y:e},f,g);j.yoyo(h),this.scaleData=j.generateData(60),this.scaleData.reverse(),this.autoScale=!0}},c.Particles.Arcade.Emitter.prototype.at=function(a){a.center?(this.emitX=a.center.x,this.emitY=a.center.y):(this.emitX=a.world.x+a.anchor.x*a.width,this.emitY=a.world.y+a.anchor.y*a.height)},Object.defineProperty(c.Particles.Arcade.Emitter.prototype,"width",{get:function(){return this.area.width},set:function(a){this.area.width=a}}),Object.defineProperty(c.Particles.Arcade.Emitter.prototype,"height",{get:function(){return this.area.height},set:function(a){this.area.height=a}}),Object.defineProperty(c.Particles.Arcade.Emitter.prototype,"x",{get:function(){return this.emitX},set:function(a){this.emitX=a}}),Object.defineProperty(c.Particles.Arcade.Emitter.prototype,"y",{get:function(){return this.emitY},set:function(a){this.emitY=a}}),Object.defineProperty(c.Particles.Arcade.Emitter.prototype,"left",{get:function(){return Math.floor(this.x-this.area.width/2)}}),Object.defineProperty(c.Particles.Arcade.Emitter.prototype,"right",{get:function(){return Math.floor(this.x+this.area.width/2)}}),Object.defineProperty(c.Particles.Arcade.Emitter.prototype,"top",{get:function(){return Math.floor(this.y-this.area.height/2)}}),Object.defineProperty(c.Particles.Arcade.Emitter.prototype,"bottom",{get:function(){return Math.floor(this.y+this.area.height/2)}}),c.Video=function(a,b,d){if(void 0===b&&(b=null),void 0===d&&(d=null),this.game=a,this.key=b,this.width=0,this.height=0,this.type=c.VIDEO,this.disableTextureUpload=!1,this.touchLocked=!1,this.onPlay=new c.Signal,this.onChangeSource=new c.Signal,this.onComplete=new c.Signal,this.onAccess=new c.Signal,this.onError=new c.Signal,this.onTimeout=new c.Signal,this.timeout=15e3,this._timeOutID=null,this.video=null,this.videoStream=null,this.isStreaming=!1,this.retryLimit=20,this.retry=0,this.retryInterval=500,this._retryID=null,this._codeMuted=!1,this._muted=!1,this._codePaused=!1,this._paused=!1,this._pending=!1,this._autoplay=!1,b&&this.game.cache.checkVideoKey(b)){var e=this.game.cache.getVideo(b);e.isBlob?this.createVideoFromBlob(e.data):this.video=e.data,this.width=this.video.videoWidth,this.height=this.video.videoHeight}else d&&this.createVideoFromURL(d,!1);this.video&&!d?(this.baseTexture=new PIXI.BaseTexture(this.video),this.baseTexture.forceLoaded(this.width,this.height)):(this.baseTexture=new PIXI.BaseTexture(PIXI.TextureCache.__default.baseTexture.source),this.baseTexture.forceLoaded(this.width,this.height)),this.texture=new PIXI.Texture(this.baseTexture),this.textureFrame=new c.Frame(0,0,0,this.width,this.height,"video"),this.texture.setFrame(this.textureFrame),this.texture.valid=!1,null!==b&&this.video&&(this.texture.valid=this.video.canplay),this.snapshot=null,c.BitmapData&&(this.snapshot=new c.BitmapData(this.game,"",this.width,this.height)),!this.game.device.cocoonJS&&(this.game.device.iOS||this.game.device.android)||window.PhaserGlobal&&window.PhaserGlobal.fakeiOSTouchLock?this.setTouchLock():e&&(e.locked=!1)},c.Video.prototype={connectToMediaStream:function(a,b){return a&&b&&(this.video=a,this.videoStream=b,this.isStreaming=!0,this.baseTexture.source=this.video,this.updateTexture(null,this.video.videoWidth,this.video.videoHeight),this.onAccess.dispatch(this)),this},startMediaStream:function(a,b,c){if(void 0===a&&(a=!1),void 0===b&&(b=null),void 0===c&&(c=null),!this.game.device.getUserMedia)return this.onError.dispatch(this,"No getUserMedia"),!1;null!==this.videoStream&&(this.videoStream.active?this.videoStream.active=!1:this.videoStream.stop()),this.removeVideoElement(),this.video=document.createElement("video"),this.video.setAttribute("autoplay","autoplay"),null!==b&&(this.video.width=b),null!==c&&(this.video.height=c),this._timeOutID=window.setTimeout(this.getUserMediaTimeout.bind(this),this.timeout);try{navigator.getUserMedia({audio:a,video:!0},this.getUserMediaSuccess.bind(this),this.getUserMediaError.bind(this))}catch(d){this.getUserMediaError(d)}return this},getUserMediaTimeout:function(){clearTimeout(this._timeOutID),this.onTimeout.dispatch(this)},getUserMediaError:function(a){clearTimeout(this._timeOutID),this.onError.dispatch(this,a)},getUserMediaSuccess:function(a){clearTimeout(this._timeOutID),this.videoStream=a,void 0!==this.video.mozSrcObject?this.video.mozSrcObject=a:this.video.src=window.URL&&window.URL.createObjectURL(a)||a;var b=this;this.video.onloadeddata=function(){function a(){if(c>0)if(b.video.videoWidth>0){var d=b.video.videoWidth,e=b.video.videoHeight;isNaN(b.video.videoHeight)&&(e=d/(4/3)),b.video.play(),b.isStreaming=!0,b.baseTexture.source=b.video,b.updateTexture(null,d,e),b.onAccess.dispatch(b)}else window.setTimeout(a,500);else console.warn("Unable to connect to video stream. Webcam error?");c--}var c=10;a()}},createVideoFromBlob:function(a){var b=this;return this.video=document.createElement("video"),this.video.controls=!1,this.video.setAttribute("autoplay","autoplay"),this.video.addEventListener("loadeddata",function(a){b.updateTexture(a)},!0),this.video.src=window.URL.createObjectURL(a),this.video.canplay=!0,this},createVideoFromURL:function(a,b){return void 0===b&&(b=!1),this.texture&&(this.texture.valid=!1),this.video=document.createElement("video"),this.video.controls=!1,b&&this.video.setAttribute("autoplay","autoplay"),this.video.src=a,this.video.canplay=!0,this.video.load(),this.retry=this.retryLimit,this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval),this.key=a,this},updateTexture:function(a,b,c){var d=!1;(void 0===b||null===b)&&(b=this.video.videoWidth,d=!0),(void 0===c||null===c)&&(c=this.video.videoHeight),this.width=b,this.height=c,this.baseTexture.source!==this.video&&(this.baseTexture.source=this.video),this.baseTexture.forceLoaded(b,c),this.texture.frame.resize(b,c),this.texture.width=b,this.texture.height=c,this.texture.valid=!0,this.snapshot&&this.snapshot.resize(b,c),d&&null!==this.key&&(this.onChangeSource.dispatch(this,b,c),this._autoplay&&(this.video.play(),this.onPlay.dispatch(this,this.loop,this.playbackRate)))},complete:function(){this.onComplete.dispatch(this)},play:function(a,b){return void 0===a&&(a=!1),void 0===b&&(b=1),this.game.sound.onMute&&(this.game.sound.onMute.add(this.setMute,this),this.game.sound.onUnMute.add(this.unsetMute,this),this.game.sound.mute&&this.setMute()),this.game.onPause.add(this.setPause,this),this.game.onResume.add(this.setResume,this),this.video.addEventListener("ended",this.complete.bind(this),!0),a?this.video.loop="loop":this.video.loop="",this.video.playbackRate=b,this.touchLocked?this._pending=!0:(this._pending=!1,null!==this.key&&(4!==this.video.readyState?(this.retry=this.retryLimit,this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval)):this.video.addEventListener("playing",this.playHandler.bind(this),!0)),this.video.play(),this.onPlay.dispatch(this,a,b)),this},playHandler:function(){this.video.removeEventListener("playing",this.playHandler.bind(this)),this.updateTexture()},stop:function(){return this.game.sound.onMute&&(this.game.sound.onMute.remove(this.setMute,this),this.game.sound.onUnMute.remove(this.unsetMute,this)),this.game.onPause.remove(this.setPause,this),this.game.onResume.remove(this.setResume,this),this.isStreaming?(this.video.mozSrcObject?(this.video.mozSrcObject.stop(),this.video.src=null):(this.video.src="",this.videoStream.active?this.videoStream.active=!1:this.videoStream.stop()),this.videoStream=null,this.isStreaming=!1):(this.video.removeEventListener("ended",this.complete.bind(this),!0),this.video.removeEventListener("playing",this.playHandler.bind(this),!0),this.touchLocked?this._pending=!1:this.video.pause()),this},add:function(a){if(Array.isArray(a))for(var b=0;b<a.length;b++)a[b].loadTexture&&a[b].loadTexture(this);else a.loadTexture(this);return this},addToWorld:function(a,b,c,d,e,f){e=e||1,f=f||1;var g=this.game.add.image(a,b,this);return g.anchor.set(c,d),g.scale.set(e,f),g},render:function(){!this.disableTextureUpload&&this.playing&&this.baseTexture.dirty()},setMute:function(){this._muted||(this._muted=!0,this.video.muted=!0)},unsetMute:function(){this._muted&&!this._codeMuted&&(this._muted=!1,this.video.muted=!1)},setPause:function(){this._paused||this.touchLocked||(this._paused=!0,this.video.pause())},setResume:function(){!this._paused||this._codePaused||this.touchLocked||(this._paused=!1,this.video.ended||this.video.play())},changeSource:function(a,b){return void 0===b&&(b=!0),this.texture.valid=!1,this.video.pause(),this.retry=this.retryLimit,this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval),this.video.src=a,this.video.load(),this._autoplay=b,b||(this.paused=!0),this},checkVideoProgress:function(){4===this.video.readyState?this.updateTexture():(this.retry--,this.retry>0?this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval):console.warn("Phaser.Video: Unable to start downloading video in time",this.isStreaming))},setTouchLock:function(){this.game.input.touch.addTouchLockCallback(this.unlock,this),this.touchLocked=!0},unlock:function(){if(this.touchLocked=!1,this.video.play(),this.onPlay.dispatch(this,this.loop,this.playbackRate),this.key){var a=this.game.cache.getVideo(this.key);a&&!a.isBlob&&(a.locked=!1)}return!0},grab:function(a,b,c){return void 0===a&&(a=!1),void 0===b&&(b=1),void 0===c&&(c=null), +null===this.snapshot?void console.warn("Video.grab cannot run because Phaser.BitmapData is unavailable"):(a&&this.snapshot.cls(),this.snapshot.copy(this.video,0,0,this.width,this.height,0,0,this.width,this.height,0,0,0,1,1,b,c),this.snapshot)},removeVideoElement:function(){if(this.video){for(this.video.parentNode&&this.video.parentNode.removeChild(this.video);this.video.hasChildNodes();)this.video.removeChild(this.video.firstChild);this.video.removeAttribute("autoplay"),this.video.removeAttribute("src"),this.video=null}},destroy:function(){this.stop(),this.removeVideoElement(),this.touchLocked&&this.game.input.touch.removeTouchLockCallback(this.unlock,this),this._retryID&&window.clearTimeout(this._retryID)}},Object.defineProperty(c.Video.prototype,"currentTime",{get:function(){return this.video?this.video.currentTime:0},set:function(a){this.video.currentTime=a}}),Object.defineProperty(c.Video.prototype,"duration",{get:function(){return this.video?this.video.duration:0}}),Object.defineProperty(c.Video.prototype,"progress",{get:function(){return this.video?this.video.currentTime/this.video.duration:0}}),Object.defineProperty(c.Video.prototype,"mute",{get:function(){return this._muted},set:function(a){if(a=a||null){if(this._muted)return;this._codeMuted=!0,this.setMute()}else{if(!this._muted)return;this._codeMuted=!1,this.unsetMute()}}}),Object.defineProperty(c.Video.prototype,"paused",{get:function(){return this._paused},set:function(a){if(a=a||null,!this.touchLocked)if(a){if(this._paused)return;this._codePaused=!0,this.setPause()}else{if(!this._paused)return;this._codePaused=!1,this.setResume()}}}),Object.defineProperty(c.Video.prototype,"volume",{get:function(){return this.video?this.video.volume:1},set:function(a){0>a?a=0:a>1&&(a=1),this.video&&(this.video.volume=a)}}),Object.defineProperty(c.Video.prototype,"playbackRate",{get:function(){return this.video?this.video.playbackRate:1},set:function(a){this.video&&(this.video.playbackRate=a)}}),Object.defineProperty(c.Video.prototype,"loop",{get:function(){return this.video?this.video.loop:!1},set:function(a){a&&this.video?this.video.loop="loop":this.video&&(this.video.loop="")}}),Object.defineProperty(c.Video.prototype,"playing",{get:function(){return!(this.video.paused&&this.video.ended)}}),c.Video.prototype.constructor=c.Video,void 0===PIXI.blendModes&&(PIXI.blendModes=c.blendModes),void 0===PIXI.scaleModes&&(PIXI.scaleModes=c.scaleModes),void 0===PIXI.Texture.emptyTexture&&(PIXI.Texture.emptyTexture=new PIXI.Texture(new PIXI.BaseTexture)),void 0===PIXI.DisplayObject._tempMatrix&&(PIXI.DisplayObject._tempMatrix=new PIXI.Matrix),void 0===PIXI.RenderTexture.tempMatrix&&(PIXI.RenderTexture.tempMatrix=new PIXI.Matrix),PIXI.Graphics&&void 0===PIXI.Graphics.POLY&&(PIXI.Graphics.POLY=c.POLYGON,PIXI.Graphics.RECT=c.RECTANGLE,PIXI.Graphics.CIRC=c.CIRCLE,PIXI.Graphics.ELIP=c.ELLIPSE,PIXI.Graphics.RREC=c.ROUNDEDRECTANGLE),PIXI.TextureSilentFail=!0,"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=c),exports.Phaser=c):"undefined"!=typeof define&&define.amd?define("Phaser",function(){return b.Phaser=c}()):b.Phaser=c,c}.call(this); //# sourceMappingURL=phaser.map \ No newline at end of file diff --git a/harkka3/samson/phaser/phaser_2-14-0.min.js b/harkka3/samson/phaser/phaser_2-14-0.min.js new file mode 100644 index 0000000000000000000000000000000000000000..847a62b3b49f94586192d60ff91b0750284910ce --- /dev/null +++ b/harkka3/samson/phaser/phaser_2-14-0.min.js @@ -0,0 +1,4 @@ +/* Phaser v2.14.0 - http://phaser.io - @photonstorm - (c) 2016 Photon Storm Ltd. */ + +!function(t){if("object"==typeof exports)module.exports=t();else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.p2=t()}}(function(){return function t(e,i,s){function n(o,a){if(!i[o]){if(!e[o]){var h="function"==typeof require&&require;if(!a&&h)return h(o,!0);if(r)return r(o,!0);throw new Error("Cannot find module '"+o+"'")}var l=i[o]={exports:{}};e[o][0].call(l.exports,function(t){var i=e[o][1][t];return n(i||t)},l,l.exports,t,e,i,s)}return i[o].exports}for(var r="function"==typeof require&&require,o=0;o<s.length;o++)n(s[o]);return n}({1:[function(t,e,i){function s(){}var n=t("./Scalar");e.exports=s,s.lineInt=function(t,e,i){i=i||0;var s,r,o,a,h,l,c,u=[0,0];return s=t[1][1]-t[0][1],r=t[0][0]-t[1][0],o=s*t[0][0]+r*t[0][1],a=e[1][1]-e[0][1],h=e[0][0]-e[1][0],l=a*e[0][0]+h*e[0][1],c=s*h-a*r,n.eq(c,0,i)||(u[0]=(h*o-r*l)/c,u[1]=(s*l-a*o)/c),u},s.segmentsIntersect=function(t,e,i,s){var n=e[0]-t[0],r=e[1]-t[1],o=s[0]-i[0],a=s[1]-i[1];if(o*r-a*n==0)return!1;var h=(n*(i[1]-t[1])+r*(t[0]-i[0]))/(o*r-a*n),l=(o*(t[1]-i[1])+a*(i[0]-t[0]))/(a*n-o*r);return h>=0&&h<=1&&l>=0&&l<=1}},{"./Scalar":4}],2:[function(t,e,i){function s(){}e.exports=s,s.area=function(t,e,i){return(e[0]-t[0])*(i[1]-t[1])-(i[0]-t[0])*(e[1]-t[1])},s.left=function(t,e,i){return s.area(t,e,i)>0},s.leftOn=function(t,e,i){return s.area(t,e,i)>=0},s.right=function(t,e,i){return s.area(t,e,i)<0},s.rightOn=function(t,e,i){return s.area(t,e,i)<=0};var n=[],r=[];s.collinear=function(t,e,i,o){if(o){var a=n,h=r;a[0]=e[0]-t[0],a[1]=e[1]-t[1],h[0]=i[0]-e[0],h[1]=i[1]-e[1];var l=a[0]*h[0]+a[1]*h[1],c=Math.sqrt(a[0]*a[0]+a[1]*a[1]),u=Math.sqrt(h[0]*h[0]+h[1]*h[1]);return Math.acos(l/(c*u))<o}return 0==s.area(t,e,i)},s.sqdist=function(t,e){var i=e[0]-t[0],s=e[1]-t[1];return i*i+s*s}},{}],3:[function(t,e,i){function s(){this.vertices=[]}function n(t,e,i,s,n){n=n||0;var r=e[1]-t[1],o=t[0]-e[0],h=r*t[0]+o*t[1],l=s[1]-i[1],c=i[0]-s[0],u=l*i[0]+c*i[1],d=r*c-l*o;return a.eq(d,0,n)?[0,0]:[(c*h-o*u)/d,(r*u-l*h)/d]}var r=t("./Line"),o=t("./Point"),a=t("./Scalar");e.exports=s,s.prototype.at=function(t){var e=this.vertices,i=e.length;return e[t<0?t%i+i:t%i]},s.prototype.first=function(){return this.vertices[0]},s.prototype.last=function(){return this.vertices[this.vertices.length-1]},s.prototype.clear=function(){this.vertices.length=0},s.prototype.append=function(t,e,i){if(void 0===e)throw new Error("From is not given!");if(void 0===i)throw new Error("To is not given!");if(i-1<e)throw new Error("lol1");if(i>t.vertices.length)throw new Error("lol2");if(e<0)throw new Error("lol3");for(var s=e;s<i;s++)this.vertices.push(t.vertices[s])},s.prototype.makeCCW=function(){for(var t=0,e=this.vertices,i=1;i<this.vertices.length;++i)(e[i][1]<e[t][1]||e[i][1]==e[t][1]&&e[i][0]>e[t][0])&&(t=i);o.left(this.at(t-1),this.at(t),this.at(t+1))||this.reverse()},s.prototype.reverse=function(){for(var t=[],e=0,i=this.vertices.length;e!==i;e++)t.push(this.vertices.pop());this.vertices=t},s.prototype.isReflex=function(t){return o.right(this.at(t-1),this.at(t),this.at(t+1))};var h=[],l=[];s.prototype.canSee=function(t,e){var i,s,n=h,a=l;if(o.leftOn(this.at(t+1),this.at(t),this.at(e))&&o.rightOn(this.at(t-1),this.at(t),this.at(e)))return!1;s=o.sqdist(this.at(t),this.at(e));for(var c=0;c!==this.vertices.length;++c)if((c+1)%this.vertices.length!==t&&c!==t&&o.leftOn(this.at(t),this.at(e),this.at(c+1))&&o.rightOn(this.at(t),this.at(e),this.at(c))&&(n[0]=this.at(t),n[1]=this.at(e),a[0]=this.at(c),a[1]=this.at(c+1),i=r.lineInt(n,a),o.sqdist(this.at(t),i)<s))return!1;return!0},s.prototype.copy=function(t,e,i){var n=i||new s;if(n.clear(),t<e)for(r=t;r<=e;r++)n.vertices.push(this.vertices[r]);else{for(r=0;r<=e;r++)n.vertices.push(this.vertices[r]);for(var r=t;r<this.vertices.length;r++)n.vertices.push(this.vertices[r])}return n},s.prototype.getCutEdges=function(){for(var t=[],e=[],i=[],n=new s,r=Number.MAX_VALUE,o=0;o<this.vertices.length;++o)if(this.isReflex(o))for(var a=0;a<this.vertices.length;++a)if(this.canSee(o,a)){e=this.copy(o,a,n).getCutEdges(),i=this.copy(a,o,n).getCutEdges();for(var h=0;h<i.length;h++)e.push(i[h]);e.length<r&&(t=e,r=e.length,t.push([this.at(o),this.at(a)]))}return t},s.prototype.decomp=function(){var t=this.getCutEdges();return t.length>0?this.slice(t):[this]},s.prototype.slice=function(t){if(0==t.length)return[this];if(t instanceof Array&&t.length&&t[0]instanceof Array&&2==t[0].length&&t[0][0]instanceof Array){for(var e=[this],i=0;i<t.length;i++)for(var s=t[i],n=0;n<e.length;n++){var r=e[n].slice(s);if(r){e.splice(n,1),e.push(r[0],r[1]);break}}return e}var s=t,i=this.vertices.indexOf(s[0]),n=this.vertices.indexOf(s[1]);return-1!=i&&-1!=n&&[this.copy(i,n),this.copy(n,i)]},s.prototype.isSimple=function(){for(var t=this.vertices,e=0;e<t.length-1;e++)for(var i=0;i<e-1;i++)if(r.segmentsIntersect(t[e],t[e+1],t[i],t[i+1]))return!1;for(e=1;e<t.length-2;e++)if(r.segmentsIntersect(t[0],t[t.length-1],t[e],t[e+1]))return!1;return!0},s.prototype.quickDecomp=function(t,e,i,r,a,h){a=a||100,h=h||0,r=r||25,t=void 0!==t?t:[],e=e||[],i=i||[];var l=[0,0],c=[0,0],u=[0,0],d=0,p=0,f=0,g=0,m=0,y=0,v=0,x=new s,b=new s,_=this,w=this.vertices;if(w.length<3)return t;if(++h>a)return console.warn("quickDecomp: max level ("+a+") reached."),t;for(var T=0;T<this.vertices.length;++T)if(_.isReflex(T)){e.push(_.vertices[T]),d=p=Number.MAX_VALUE;for(P=0;P<this.vertices.length;++P)o.left(_.at(T-1),_.at(T),_.at(P))&&o.rightOn(_.at(T-1),_.at(T),_.at(P-1))&&(u=n(_.at(T-1),_.at(T),_.at(P),_.at(P-1)),o.right(_.at(T+1),_.at(T),u)&&(f=o.sqdist(_.vertices[T],u))<p&&(p=f,c=u,y=P)),o.left(_.at(T+1),_.at(T),_.at(P+1))&&o.rightOn(_.at(T+1),_.at(T),_.at(P))&&(u=n(_.at(T+1),_.at(T),_.at(P),_.at(P+1)),o.left(_.at(T-1),_.at(T),u)&&(f=o.sqdist(_.vertices[T],u))<d&&(d=f,l=u,m=P));if(y==(m+1)%this.vertices.length)u[0]=(c[0]+l[0])/2,u[1]=(c[1]+l[1])/2,i.push(u),T<m?(x.append(_,T,m+1),x.vertices.push(u),b.vertices.push(u),0!=y&&b.append(_,y,_.vertices.length),b.append(_,0,T+1)):(0!=T&&x.append(_,T,_.vertices.length),x.append(_,0,m+1),x.vertices.push(u),b.vertices.push(u),b.append(_,y,T+1));else{if(y>m&&(m+=this.vertices.length),g=Number.MAX_VALUE,m<y)return t;for(var P=y;P<=m;++P)o.leftOn(_.at(T-1),_.at(T),_.at(P))&&o.rightOn(_.at(T+1),_.at(T),_.at(P))&&(f=o.sqdist(_.at(T),_.at(P)))<g&&(g=f,v=P%this.vertices.length);T<v?(x.append(_,T,v+1),0!=v&&b.append(_,v,w.length),b.append(_,0,T+1)):(0!=T&&x.append(_,T,w.length),x.append(_,0,v+1),b.append(_,v,T+1))}return x.vertices.length<b.vertices.length?(x.quickDecomp(t,e,i,r,a,h),b.quickDecomp(t,e,i,r,a,h)):(b.quickDecomp(t,e,i,r,a,h),x.quickDecomp(t,e,i,r,a,h)),t}return t.push(this),t},s.prototype.removeCollinearPoints=function(t){for(var e=0,i=this.vertices.length-1;this.vertices.length>3&&i>=0;--i)o.collinear(this.at(i-1),this.at(i),this.at(i+1),t)&&(this.vertices.splice(i%this.vertices.length,1),i--,e++);return e}},{"./Line":1,"./Point":2,"./Scalar":4}],4:[function(t,e,i){function s(){}e.exports=s,s.eq=function(t,e,i){return i=i||0,Math.abs(t-e)<i}},{}],5:[function(t,e,i){e.exports={Polygon:t("./Polygon"),Point:t("./Point")}},{"./Point":2,"./Polygon":3}],6:[function(t,e,i){e.exports={name:"p2",version:"0.7.1",description:"A JavaScript 2D physics engine.",author:"Stefan Hedman <schteppe@gmail.com> (http://steffe.se)",keywords:["p2.js","p2","physics","engine","2d"],main:"./src/p2.js",engines:{node:"*"},repository:{type:"git",url:"https://github.com/schteppe/p2.js.git"},bugs:{url:"https://github.com/schteppe/p2.js/issues"},licenses:[{type:"MIT"}],devDependencies:{grunt:"^0.4.5","grunt-contrib-jshint":"^0.11.2","grunt-contrib-nodeunit":"^0.4.1","grunt-contrib-uglify":"~0.4.0","grunt-contrib-watch":"~0.5.0","grunt-browserify":"~2.0.1","grunt-contrib-concat":"^0.4.0"},dependencies:{"poly-decomp":"0.1.1"}}},{}],7:[function(t,e,i){function s(t){this.lowerBound=n.create(),t&&t.lowerBound&&n.copy(this.lowerBound,t.lowerBound),this.upperBound=n.create(),t&&t.upperBound&&n.copy(this.upperBound,t.upperBound)}var n=t("../math/vec2");t("../utils/Utils");e.exports=s;var r=n.create();s.prototype.setFromPoints=function(t,e,i,s){var o=this.lowerBound,a=this.upperBound;"number"!=typeof i&&(i=0),0!==i?n.rotate(o,t[0],i):n.copy(o,t[0]),n.copy(a,o);for(var h=Math.cos(i),l=Math.sin(i),c=1;c<t.length;c++){var u=t[c];if(0!==i){var d=u[0],p=u[1];r[0]=h*d-l*p,r[1]=l*d+h*p,u=r}for(var f=0;f<2;f++)u[f]>a[f]&&(a[f]=u[f]),u[f]<o[f]&&(o[f]=u[f])}e&&(n.add(this.lowerBound,this.lowerBound,e),n.add(this.upperBound,this.upperBound,e)),s&&(this.lowerBound[0]-=s,this.lowerBound[1]-=s,this.upperBound[0]+=s,this.upperBound[1]+=s)},s.prototype.copy=function(t){n.copy(this.lowerBound,t.lowerBound),n.copy(this.upperBound,t.upperBound)},s.prototype.extend=function(t){for(var e=2;e--;){var i=t.lowerBound[e];this.lowerBound[e]>i&&(this.lowerBound[e]=i);var s=t.upperBound[e];this.upperBound[e]<s&&(this.upperBound[e]=s)}},s.prototype.overlaps=function(t){var e=this.lowerBound,i=this.upperBound,s=t.lowerBound,n=t.upperBound;return(s[0]<=i[0]&&i[0]<=n[0]||e[0]<=n[0]&&n[0]<=i[0])&&(s[1]<=i[1]&&i[1]<=n[1]||e[1]<=n[1]&&n[1]<=i[1])},s.prototype.containsPoint=function(t){var e=this.lowerBound,i=this.upperBound;return e[0]<=t[0]&&t[0]<=i[0]&&e[1]<=t[1]&&t[1]<=i[1]},s.prototype.overlapsRay=function(t){var e=1/t.direction[0],i=1/t.direction[1],s=(this.lowerBound[0]-t.from[0])*e,n=(this.upperBound[0]-t.from[0])*e,r=(this.lowerBound[1]-t.from[1])*i,o=(this.upperBound[1]-t.from[1])*i,a=Math.max(Math.max(Math.min(s,n),Math.min(r,o))),h=Math.min(Math.min(Math.max(s,n),Math.max(r,o)));return h<0?-1:a>h?-1:a}},{"../math/vec2":30,"../utils/Utils":57}],8:[function(t,e,i){function s(t){this.type=t,this.result=[],this.world=null,this.boundingVolumeType=s.AABB}var n=t("../math/vec2"),r=t("../objects/Body");e.exports=s,s.AABB=1,s.BOUNDING_CIRCLE=2,s.prototype.setWorld=function(t){this.world=t},s.prototype.getCollisionPairs=function(t){};var o=n.create();s.boundingRadiusCheck=function(t,e){n.sub(o,t.position,e.position);var i=n.squaredLength(o),s=t.boundingRadius+e.boundingRadius;return i<=s*s},s.aabbCheck=function(t,e){return t.getAABB().overlaps(e.getAABB())},s.prototype.boundingVolumeCheck=function(t,e){var i;switch(this.boundingVolumeType){case s.BOUNDING_CIRCLE:i=s.boundingRadiusCheck(t,e);break;case s.AABB:i=s.aabbCheck(t,e);break;default:throw new Error("Bounding volume type not recognized: "+this.boundingVolumeType)}return i},s.canCollide=function(t,e){var i=r.KINEMATIC,s=r.STATIC;return(t.type!==s||e.type!==s)&&(!(t.type===i&&e.type===s||t.type===s&&e.type===i)&&((t.type!==i||e.type!==i)&&((t.sleepState!==r.SLEEPING||e.sleepState!==r.SLEEPING)&&!(t.sleepState===r.SLEEPING&&e.type===s||e.sleepState===r.SLEEPING&&t.type===s))))},s.NAIVE=1,s.SAP=2},{"../math/vec2":30,"../objects/Body":31}],9:[function(t,e,i){function s(){n.call(this,n.NAIVE)}t("../shapes/Circle"),t("../shapes/Plane"),t("../shapes/Shape"),t("../shapes/Particle");var n=t("../collision/Broadphase");t("../math/vec2");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.getCollisionPairs=function(t){var e=t.bodies,i=this.result;i.length=0;for(var s=0,r=e.length;s!==r;s++)for(var o=e[s],a=0;a<s;a++){var h=e[a];n.canCollide(o,h)&&this.boundingVolumeCheck(o,h)&&i.push(o,h)}return i},s.prototype.aabbQuery=function(t,e,i){i=i||[];for(var s=t.bodies,n=0;n<s.length;n++){var r=s[n];r.aabbNeedsUpdate&&r.updateAABB(),r.aabb.overlaps(e)&&i.push(r)}return i}},{"../collision/Broadphase":8,"../math/vec2":30,"../shapes/Circle":39,"../shapes/Particle":43,"../shapes/Plane":44,"../shapes/Shape":45}],10:[function(t,e,i){function s(){this.contactEquations=[],this.frictionEquations=[],this.enableFriction=!0,this.enabledEquations=!0,this.slipForce=10,this.frictionCoefficient=.3,this.surfaceVelocity=0,this.contactEquationPool=new c({size:32}),this.frictionEquationPool=new u({size:64}),this.restitution=0,this.stiffness=p.DEFAULT_STIFFNESS,this.relaxation=p.DEFAULT_RELAXATION,this.frictionStiffness=p.DEFAULT_STIFFNESS,this.frictionRelaxation=p.DEFAULT_RELAXATION,this.enableFrictionReduction=!0,this.collidingBodiesLastStep=new d,this.contactSkinSize=.01}function n(t,e){o.set(t.vertices[0],.5*-e.length,-e.radius),o.set(t.vertices[1],.5*e.length,-e.radius),o.set(t.vertices[2],.5*e.length,e.radius),o.set(t.vertices[3],.5*-e.length,e.radius)}function r(t,e,i,s){for(var n=H,r=q,l=Y,c=z,u=t,d=e.vertices,p=null,f=0;f!==d.length+1;f++){var g=d[f%d.length],m=d[(f+1)%d.length];o.rotate(n,g,s),o.rotate(r,m,s),h(n,n,i),h(r,r,i),a(l,n,u),a(c,r,u);var y=o.crossLength(l,c);if(null===p&&(p=y),y*p<=0)return!1;p=y}return!0}var o=t("../math/vec2"),a=o.sub,h=o.add,l=o.dot,c=(t("../utils/Utils"),t("../utils/ContactEquationPool")),u=t("../utils/FrictionEquationPool"),d=t("../utils/TupleDictionary"),p=t("../equations/Equation"),f=(t("../equations/ContactEquation"),t("../equations/FrictionEquation"),t("../shapes/Circle")),g=t("../shapes/Convex"),m=t("../shapes/Shape"),y=(t("../objects/Body"),t("../shapes/Box"));e.exports=s;var v=o.fromValues(0,1),x=o.fromValues(0,0),b=o.fromValues(0,0),_=o.fromValues(0,0),w=o.fromValues(0,0),T=o.fromValues(0,0),P=o.fromValues(0,0),C=o.fromValues(0,0),S=o.fromValues(0,0),A=o.fromValues(0,0),E=o.fromValues(0,0),M=o.fromValues(0,0),R=o.fromValues(0,0),L=o.fromValues(0,0),B=o.fromValues(0,0),I=o.fromValues(0,0),O=o.fromValues(0,0),k=o.fromValues(0,0),F=o.fromValues(0,0),D=[],U=o.create(),G=o.create();s.prototype.bodiesOverlap=function(t,e){for(var i=U,s=G,n=0,r=t.shapes.length;n!==r;n++){var o=t.shapes[n];t.toWorldFrame(i,o.position);for(var a=0,h=e.shapes.length;a!==h;a++){var l=e.shapes[a];if(e.toWorldFrame(s,l.position),this[o.type|l.type](t,o,i,o.angle+t.angle,e,l,s,l.angle+e.angle,!0))return!0}}return!1},s.prototype.collidedLastStep=function(t,e){var i=0|t.id,s=0|e.id;return!!this.collidingBodiesLastStep.get(i,s)},s.prototype.reset=function(){this.collidingBodiesLastStep.reset();for(var t=this.contactEquations,e=t.length;e--;){var i=t[e],s=i.bodyA.id,n=i.bodyB.id;this.collidingBodiesLastStep.set(s,n,!0)}for(var r=this.contactEquations,o=this.frictionEquations,a=0;a<r.length;a++)this.contactEquationPool.release(r[a]);for(a=0;a<o.length;a++)this.frictionEquationPool.release(o[a]);this.contactEquations.length=this.frictionEquations.length=0},s.prototype.createContactEquation=function(t,e,i,s){var n=this.contactEquationPool.get();return n.bodyA=t,n.bodyB=e,n.shapeA=i,n.shapeB=s,n.restitution=this.restitution,n.firstImpact=!this.collidedLastStep(t,e),n.stiffness=this.stiffness,n.relaxation=this.relaxation,n.needsUpdate=!0,n.enabled=this.enabledEquations,n.offset=this.contactSkinSize,n},s.prototype.createFrictionEquation=function(t,e,i,s){var n=this.frictionEquationPool.get();return n.bodyA=t,n.bodyB=e,n.shapeA=i,n.shapeB=s,n.setSlipForce(this.slipForce),n.frictionCoefficient=this.frictionCoefficient,n.relativeVelocity=this.surfaceVelocity,n.enabled=this.enabledEquations,n.needsUpdate=!0,n.stiffness=this.frictionStiffness,n.relaxation=this.frictionRelaxation,n.contactEquations.length=0,n},s.prototype.createFrictionFromContact=function(t){var e=this.createFrictionEquation(t.bodyA,t.bodyB,t.shapeA,t.shapeB);return o.copy(e.contactPointA,t.contactPointA),o.copy(e.contactPointB,t.contactPointB),o.rotate90cw(e.t,t.normalA),e.contactEquations.push(t),e},s.prototype.createFrictionFromAverage=function(t){var e=this.contactEquations[this.contactEquations.length-1],i=this.createFrictionEquation(e.bodyA,e.bodyB,e.shapeA,e.shapeB),s=e.bodyA;e.bodyB;o.set(i.contactPointA,0,0),o.set(i.contactPointB,0,0),o.set(i.t,0,0);for(var n=0;n!==t;n++)(e=this.contactEquations[this.contactEquations.length-1-n]).bodyA===s?(o.add(i.t,i.t,e.normalA),o.add(i.contactPointA,i.contactPointA,e.contactPointA),o.add(i.contactPointB,i.contactPointB,e.contactPointB)):(o.sub(i.t,i.t,e.normalA),o.add(i.contactPointA,i.contactPointA,e.contactPointB),o.add(i.contactPointB,i.contactPointB,e.contactPointA)),i.contactEquations.push(e);var r=1/t;return o.scale(i.contactPointA,i.contactPointA,r),o.scale(i.contactPointB,i.contactPointB,r),o.normalize(i.t,i.t),o.rotate90cw(i.t,i.t),i},s.prototype[m.LINE|m.CONVEX]=s.prototype.convexLine=function(t,e,i,s,n,r,o,a,h){return!h&&0},s.prototype[m.LINE|m.BOX]=s.prototype.lineBox=function(t,e,i,s,n,r,o,a,h){return!h&&0};var N=new y({width:1,height:1}),X=o.create();s.prototype[m.CAPSULE|m.CONVEX]=s.prototype[m.CAPSULE|m.BOX]=s.prototype.convexCapsule=function(t,e,i,s,r,a,h,l,c){var u=X;o.set(u,a.length/2,0),o.rotate(u,u,l),o.add(u,u,h);var d=this.circleConvex(r,a,u,l,t,e,i,s,c,a.radius);o.set(u,-a.length/2,0),o.rotate(u,u,l),o.add(u,u,h);var p=this.circleConvex(r,a,u,l,t,e,i,s,c,a.radius);if(c&&(d||p))return!0;var f=N;return n(f,a),this.convexConvex(t,e,i,s,r,f,h,l,c)+d+p},s.prototype[m.CAPSULE|m.LINE]=s.prototype.lineCapsule=function(t,e,i,s,n,r,o,a,h){return!h&&0};var W=o.create(),j=o.create(),V=new y({width:1,height:1});s.prototype[m.CAPSULE|m.CAPSULE]=s.prototype.capsuleCapsule=function(t,e,i,s,r,a,h,l,c){for(var u=W,d=j,p=0,f=0;f<2;f++){o.set(u,(0===f?-1:1)*e.length/2,0),o.rotate(u,u,s),o.add(u,u,i);for(var g=0;g<2;g++){o.set(d,(0===g?-1:1)*a.length/2,0),o.rotate(d,d,l),o.add(d,d,h),this.enableFrictionReduction&&(x=this.enableFriction,this.enableFriction=!1);var m=this.circleCircle(t,e,u,s,r,a,d,l,c,e.radius,a.radius);if(this.enableFrictionReduction&&(this.enableFriction=x),c&&m)return!0;p+=m}}this.enableFrictionReduction&&(x=this.enableFriction,this.enableFriction=!1);var y=V;n(y,e);var v=this.convexCapsule(t,y,i,s,r,a,h,l,c);if(this.enableFrictionReduction&&(this.enableFriction=x),c&&v)return!0;if(p+=v,this.enableFrictionReduction){var x=this.enableFriction;this.enableFriction=!1}n(y,a);var b=this.convexCapsule(r,y,h,l,t,e,i,s,c);return this.enableFrictionReduction&&(this.enableFriction=x),!(!c||!b)||(p+=b,this.enableFrictionReduction&&p&&this.enableFriction&&this.frictionEquations.push(this.createFrictionFromAverage(p)),p)},s.prototype[m.LINE|m.LINE]=s.prototype.lineLine=function(t,e,i,s,n,r,o,a,h){return!h&&0},s.prototype[m.PLANE|m.LINE]=s.prototype.planeLine=function(t,e,i,s,n,r,c,u,d){var p=x,f=b,g=_,m=w,y=T,E=P,M=C,R=S,L=A,B=D,I=0;o.set(p,-r.length/2,0),o.set(f,r.length/2,0),o.rotate(g,p,u),o.rotate(m,f,u),h(g,g,c),h(m,m,c),o.copy(p,g),o.copy(f,m),a(y,f,p),o.normalize(E,y),o.rotate90cw(L,E),o.rotate(R,v,s),B[0]=p,B[1]=f;for(var O=0;O<B.length;O++){var k=B[O];a(M,k,i);var F=l(M,R);if(F<0){if(d)return!0;var U=this.createContactEquation(t,n,e,r);I++,o.copy(U.normalA,R),o.normalize(U.normalA,U.normalA),o.scale(M,R,F),a(U.contactPointA,k,M),a(U.contactPointA,U.contactPointA,t.position),a(U.contactPointB,k,c),h(U.contactPointB,U.contactPointB,c),a(U.contactPointB,U.contactPointB,n.position),this.contactEquations.push(U),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(U))}}return!d&&(this.enableFrictionReduction||I&&this.enableFriction&&this.frictionEquations.push(this.createFrictionFromAverage(I)),I)},s.prototype[m.PARTICLE|m.CAPSULE]=s.prototype.particleCapsule=function(t,e,i,s,n,r,o,a,h){return this.circleLine(t,e,i,s,n,r,o,a,h,r.radius,0)},s.prototype[m.CIRCLE|m.LINE]=s.prototype.circleLine=function(t,e,i,s,n,r,c,u,d,p,f){var p=p||0,f=void 0!==f?f:e.radius,g=x,m=b,y=_,v=w,I=T,O=P,k=C,F=S,U=A,G=E,N=M,X=R,W=L,j=B,V=D;o.set(F,-r.length/2,0),o.set(U,r.length/2,0),o.rotate(G,F,u),o.rotate(N,U,u),h(G,G,c),h(N,N,c),o.copy(F,G),o.copy(U,N),a(O,U,F),o.normalize(k,O),o.rotate90cw(I,k),a(X,i,F);var H=l(X,I);a(v,F,c),a(W,i,c);var q=f+p;if(Math.abs(H)<q){o.scale(g,I,H),a(y,i,g),o.scale(m,I,l(I,W)),o.normalize(m,m),o.scale(m,m,p),h(y,y,m);var Y=l(k,y),z=l(k,F),K=l(k,U);if(Y>z&&Y<K){if(d)return!0;Z=this.createContactEquation(t,n,e,r);return o.scale(Z.normalA,g,-1),o.normalize(Z.normalA,Z.normalA),o.scale(Z.contactPointA,Z.normalA,f),h(Z.contactPointA,Z.contactPointA,i),a(Z.contactPointA,Z.contactPointA,t.position),a(Z.contactPointB,y,c),h(Z.contactPointB,Z.contactPointB,c),a(Z.contactPointB,Z.contactPointB,n.position),this.contactEquations.push(Z),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(Z)),1}}V[0]=F,V[1]=U;for(var J=0;J<V.length;J++){var Q=V[J];if(a(X,Q,i),o.squaredLength(X)<Math.pow(q,2)){if(d)return!0;var Z=this.createContactEquation(t,n,e,r);return o.copy(Z.normalA,X),o.normalize(Z.normalA,Z.normalA),o.scale(Z.contactPointA,Z.normalA,f),h(Z.contactPointA,Z.contactPointA,i),a(Z.contactPointA,Z.contactPointA,t.position),a(Z.contactPointB,Q,c),o.scale(j,Z.normalA,-p),h(Z.contactPointB,Z.contactPointB,j),h(Z.contactPointB,Z.contactPointB,c),a(Z.contactPointB,Z.contactPointB,n.position),this.contactEquations.push(Z),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(Z)),1}}return 0},s.prototype[m.CIRCLE|m.CAPSULE]=s.prototype.circleCapsule=function(t,e,i,s,n,r,o,a,h){return this.circleLine(t,e,i,s,n,r,o,a,h,r.radius)},s.prototype[m.CIRCLE|m.CONVEX]=s.prototype[m.CIRCLE|m.BOX]=s.prototype.circleConvex=function(t,e,i,s,n,l,c,u,d,p){for(var p="number"==typeof p?p:e.radius,f=x,g=b,m=_,y=w,v=T,P=E,C=M,S=L,A=B,R=I,k=O,F=!1,D=Number.MAX_VALUE,U=l.vertices,G=0;G!==U.length+1;G++){var N=U[G%U.length],X=U[(G+1)%U.length];if(o.rotate(f,N,u),o.rotate(g,X,u),h(f,f,c),h(g,g,c),a(m,g,f),o.normalize(y,m),o.rotate90cw(v,y),o.scale(A,v,-e.radius),h(A,A,i),r(A,l,c,u)){o.sub(R,f,A);var W=Math.abs(o.dot(R,v));W<D&&(o.copy(k,A),D=W,o.scale(S,v,W),o.add(S,S,A),F=!0)}}if(F){if(d)return!0;V=this.createContactEquation(t,n,e,l);return o.sub(V.normalA,k,i),o.normalize(V.normalA,V.normalA),o.scale(V.contactPointA,V.normalA,p),h(V.contactPointA,V.contactPointA,i),a(V.contactPointA,V.contactPointA,t.position),a(V.contactPointB,S,c),h(V.contactPointB,V.contactPointB,c),a(V.contactPointB,V.contactPointB,n.position),this.contactEquations.push(V),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(V)),1}if(p>0)for(G=0;G<U.length;G++){var j=U[G];if(o.rotate(C,j,u),h(C,C,c),a(P,C,i),o.squaredLength(P)<Math.pow(p,2)){if(d)return!0;var V=this.createContactEquation(t,n,e,l);return o.copy(V.normalA,P),o.normalize(V.normalA,V.normalA),o.scale(V.contactPointA,V.normalA,p),h(V.contactPointA,V.contactPointA,i),a(V.contactPointA,V.contactPointA,t.position),a(V.contactPointB,C,c),h(V.contactPointB,V.contactPointB,c),a(V.contactPointB,V.contactPointB,n.position),this.contactEquations.push(V),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(V)),1}}return 0};var H=o.create(),q=o.create(),Y=o.create(),z=o.create();s.prototype[m.PARTICLE|m.CONVEX]=s.prototype[m.PARTICLE|m.BOX]=s.prototype.particleConvex=function(t,e,i,s,n,c,u,d,p){var f=x,g=b,m=_,y=w,v=T,S=P,A=C,M=E,R=L,B=k,I=F,O=Number.MAX_VALUE,D=!1,U=c.vertices;if(!r(i,c,u,d))return 0;if(p)return!0;for(var G=0;G!==U.length+1;G++){var N=U[G%U.length],X=U[(G+1)%U.length];o.rotate(f,N,d),o.rotate(g,X,d),h(f,f,u),h(g,g,u),a(m,g,f),o.normalize(y,m),o.rotate90cw(v,y),a(M,i,f);l(M,v);a(S,f,u),a(A,i,u),o.sub(B,f,i);var W=Math.abs(o.dot(B,v));W<O&&(O=W,o.scale(R,v,W),o.add(R,R,i),o.copy(I,v),D=!0)}if(D){var j=this.createContactEquation(t,n,e,c);return o.scale(j.normalA,I,-1),o.normalize(j.normalA,j.normalA),o.set(j.contactPointA,0,0),h(j.contactPointA,j.contactPointA,i),a(j.contactPointA,j.contactPointA,t.position),a(j.contactPointB,R,u),h(j.contactPointB,j.contactPointB,u),a(j.contactPointB,j.contactPointB,n.position),this.contactEquations.push(j),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(j)),1}return 0},s.prototype[m.CIRCLE]=s.prototype.circleCircle=function(t,e,i,s,n,r,l,c,u,d,p){var f=x,d=d||e.radius,p=p||r.radius;a(f,i,l);var g=d+p;if(o.squaredLength(f)>Math.pow(g,2))return 0;if(u)return!0;var m=this.createContactEquation(t,n,e,r);return a(m.normalA,l,i),o.normalize(m.normalA,m.normalA),o.scale(m.contactPointA,m.normalA,d),o.scale(m.contactPointB,m.normalA,-p),h(m.contactPointA,m.contactPointA,i),a(m.contactPointA,m.contactPointA,t.position),h(m.contactPointB,m.contactPointB,l),a(m.contactPointB,m.contactPointB,n.position),this.contactEquations.push(m),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(m)),1},s.prototype[m.PLANE|m.CONVEX]=s.prototype[m.PLANE|m.BOX]=s.prototype.planeConvex=function(t,e,i,s,n,r,c,u,d){var p=x,f=b,g=_,m=0;o.rotate(f,v,s);for(var y=0;y!==r.vertices.length;y++){var w=r.vertices[y];if(o.rotate(p,w,u),h(p,p,c),a(g,p,i),l(g,f)<=0){if(d)return!0;m++;var T=this.createContactEquation(t,n,e,r);a(g,p,i),o.copy(T.normalA,f);var P=l(g,T.normalA);o.scale(g,T.normalA,P),a(T.contactPointB,p,n.position),a(T.contactPointA,p,g),a(T.contactPointA,T.contactPointA,t.position),this.contactEquations.push(T),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(T))}}return this.enableFrictionReduction&&this.enableFriction&&m&&this.frictionEquations.push(this.createFrictionFromAverage(m)),m},s.prototype[m.PARTICLE|m.PLANE]=s.prototype.particlePlane=function(t,e,i,s,n,r,h,c,u){var d=x,p=b;c=c||0,a(d,i,h),o.rotate(p,v,c);var f=l(d,p);if(f>0)return 0;if(u)return!0;var g=this.createContactEquation(n,t,r,e);return o.copy(g.normalA,p),o.scale(d,g.normalA,f),a(g.contactPointA,i,d),a(g.contactPointA,g.contactPointA,n.position),a(g.contactPointB,i,t.position),this.contactEquations.push(g),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(g)),1},s.prototype[m.CIRCLE|m.PARTICLE]=s.prototype.circleParticle=function(t,e,i,s,n,r,l,c,u){var d=x;if(a(d,l,i),o.squaredLength(d)>Math.pow(e.radius,2))return 0;if(u)return!0;var p=this.createContactEquation(t,n,e,r);return o.copy(p.normalA,d),o.normalize(p.normalA,p.normalA),o.scale(p.contactPointA,p.normalA,e.radius),h(p.contactPointA,p.contactPointA,i),a(p.contactPointA,p.contactPointA,t.position),a(p.contactPointB,l,n.position),this.contactEquations.push(p),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(p)),1};var K=new f({radius:1}),J=o.create(),Q=o.create();o.create();s.prototype[m.PLANE|m.CAPSULE]=s.prototype.planeCapsule=function(t,e,i,s,n,r,a,l,c){var u=J,d=Q,p=K;o.set(u,-r.length/2,0),o.rotate(u,u,l),h(u,u,a),o.set(d,r.length/2,0),o.rotate(d,d,l),h(d,d,a),p.radius=r.radius;var f;this.enableFrictionReduction&&(f=this.enableFriction,this.enableFriction=!1);var g=this.circlePlane(n,p,u,0,t,e,i,s,c),m=this.circlePlane(n,p,d,0,t,e,i,s,c);if(this.enableFrictionReduction&&(this.enableFriction=f),c)return g||m;var y=g+m;return this.enableFrictionReduction&&y&&this.frictionEquations.push(this.createFrictionFromAverage(y)),y},s.prototype[m.CIRCLE|m.PLANE]=s.prototype.circlePlane=function(t,e,i,s,n,r,c,u,d){var p=t,f=e,g=i,m=n,y=c,w=u;w=w||0;var T=x,P=b,C=_;a(T,g,y),o.rotate(P,v,w);var S=l(P,T);if(S>f.radius)return 0;if(d)return!0;var A=this.createContactEquation(m,p,r,e);return o.copy(A.normalA,P),o.scale(A.contactPointB,A.normalA,-f.radius),h(A.contactPointB,A.contactPointB,g),a(A.contactPointB,A.contactPointB,p.position),o.scale(C,A.normalA,S),a(A.contactPointA,T,C),h(A.contactPointA,A.contactPointA,y),a(A.contactPointA,A.contactPointA,m.position),this.contactEquations.push(A),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(A)),1},s.prototype[m.CONVEX]=s.prototype[m.CONVEX|m.BOX]=s.prototype[m.BOX]=s.prototype.convexConvex=function(t,e,i,n,r,c,u,d,p,f){var g=x,m=b,y=_,v=w,P=T,E=C,M=S,R=A,L=0,f="number"==typeof f?f:0;if(!s.findSeparatingAxis(e,i,n,c,u,d,g))return 0;a(M,u,i),l(g,M)>0&&o.scale(g,g,-1);var B=s.getClosestEdge(e,n,g,!0),I=s.getClosestEdge(c,d,g);if(-1===B||-1===I)return 0;for(var O=0;O<2;O++){var k=B,F=I,D=e,U=c,G=i,N=u,X=n,W=d,j=t,V=r;if(0===O){var H;H=k,k=F,F=H,H=D,D=U,U=H,H=G,G=N,N=H,H=X,X=W,W=H,H=j,j=V,V=H}for(var q=F;q<F+2;q++){var Y=U.vertices[(q+U.vertices.length)%U.vertices.length];o.rotate(m,Y,W),h(m,m,N);for(var z=0,K=k-1;K<k+2;K++){var J=D.vertices[(K+D.vertices.length)%D.vertices.length],Q=D.vertices[(K+1+D.vertices.length)%D.vertices.length];o.rotate(y,J,X),o.rotate(v,Q,X),h(y,y,G),h(v,v,G),a(P,v,y),o.rotate90cw(R,P),o.normalize(R,R),a(M,m,y);$=l(R,M);(K===k&&$<=f||K!==k&&$<=0)&&z++}if(z>=3){if(p)return!0;var Z=this.createContactEquation(j,V,D,U);L++;var J=D.vertices[k%D.vertices.length],Q=D.vertices[(k+1)%D.vertices.length];o.rotate(y,J,X),o.rotate(v,Q,X),h(y,y,G),h(v,v,G),a(P,v,y),o.rotate90cw(Z.normalA,P),o.normalize(Z.normalA,Z.normalA),a(M,m,y);var $=l(Z.normalA,M);o.scale(E,Z.normalA,$),a(Z.contactPointA,m,G),a(Z.contactPointA,Z.contactPointA,E),h(Z.contactPointA,Z.contactPointA,G),a(Z.contactPointA,Z.contactPointA,j.position),a(Z.contactPointB,m,N),h(Z.contactPointB,Z.contactPointB,N),a(Z.contactPointB,Z.contactPointB,V.position),this.contactEquations.push(Z),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(Z))}}}return this.enableFrictionReduction&&this.enableFriction&&L&&this.frictionEquations.push(this.createFrictionFromAverage(L)),L};var Z=o.fromValues(0,0);s.projectConvexOntoAxis=function(t,e,i,s,n){var r,a,h=null,c=null,u=Z;o.rotate(u,s,-i);for(var d=0;d<t.vertices.length;d++)r=t.vertices[d],a=l(r,u),(null===h||a>h)&&(h=a),(null===c||a<c)&&(c=a);if(c>h){var p=c;c=h,h=p}var f=l(e,s);o.set(n,c+f,h+f)};var $=o.fromValues(0,0),tt=o.fromValues(0,0),et=o.fromValues(0,0),it=o.fromValues(0,0),st=o.fromValues(0,0),nt=o.fromValues(0,0);s.findSeparatingAxis=function(t,e,i,n,r,h,l){var c=null,u=!1,d=!1,p=$,f=tt,g=et,m=it,v=st,x=nt;if(t instanceof y&&n instanceof y)for(P=0;2!==P;P++){var b=t,_=i;1===P&&(b=n,_=h);for(C=0;2!==C;C++){0===C?o.set(m,0,1):1===C&&o.set(m,1,0),0!==_&&o.rotate(m,m,_),s.projectConvexOntoAxis(t,e,i,m,v),s.projectConvexOntoAxis(n,r,h,m,x);var w=v,T=x;v[0]>x[0]&&(T=v,w=x,!0),u=(S=T[0]-w[1])<=0,(null===c||S>c)&&(o.copy(l,m),c=S,d=u)}}else for(var P=0;2!==P;P++){var b=t,_=i;1===P&&(b=n,_=h);for(var C=0;C!==b.vertices.length;C++){o.rotate(f,b.vertices[C],_),o.rotate(g,b.vertices[(C+1)%b.vertices.length],_),a(p,g,f),o.rotate90cw(m,p),o.normalize(m,m),s.projectConvexOntoAxis(t,e,i,m,v),s.projectConvexOntoAxis(n,r,h,m,x);var w=v,T=x;v[0]>x[0]&&(T=v,w=x,!0);var S=T[0]-w[1];u=S<=0,(null===c||S>c)&&(o.copy(l,m),c=S,d=u)}}return d};var rt=o.fromValues(0,0),ot=o.fromValues(0,0),at=o.fromValues(0,0);s.getClosestEdge=function(t,e,i,s){var n=rt,r=ot,h=at;o.rotate(n,i,-e),s&&o.scale(n,n,-1);for(var c=-1,u=t.vertices.length,d=-1,p=0;p!==u;p++){a(r,t.vertices[(p+1)%u],t.vertices[p%u]),o.rotate90cw(h,r),o.normalize(h,h);var f=l(h,n);(-1===c||f>d)&&(c=p%u,d=f)}return c};var ht=o.create(),lt=o.create(),ct=o.create(),ut=o.create(),dt=o.create(),pt=o.create(),ft=o.create();s.prototype[m.CIRCLE|m.HEIGHTFIELD]=s.prototype.circleHeightfield=function(t,e,i,s,n,r,l,c,u,d){var p=r.heights,d=d||e.radius,f=r.elementWidth,g=lt,m=ht,y=dt,v=ft,x=pt,b=ct,_=ut,w=Math.floor((i[0]-d-l[0])/f),T=Math.ceil((i[0]+d-l[0])/f);w<0&&(w=0),T>=p.length&&(T=p.length-1);for(var P=p[w],C=p[T],S=w;S<T;S++)p[S]<C&&(C=p[S]),p[S]>P&&(P=p[S]);if(i[1]-d>P)return!u&&0;for(var A=!1,S=w;S<T;S++){o.set(b,S*f,p[S]),o.set(_,(S+1)*f,p[S+1]),o.add(b,b,l),o.add(_,_,l),o.sub(x,_,b),o.rotate(x,x,Math.PI/2),o.normalize(x,x),o.scale(m,x,-d),o.add(m,m,i),o.sub(g,m,b);var E=o.dot(g,x);if(m[0]>=b[0]&&m[0]<_[0]&&E<=0){if(u)return!0;A=!0,o.scale(g,x,-E),o.add(y,m,g),o.copy(v,x);M=this.createContactEquation(n,t,r,e);o.copy(M.normalA,v),o.scale(M.contactPointB,M.normalA,-d),h(M.contactPointB,M.contactPointB,i),a(M.contactPointB,M.contactPointB,t.position),o.copy(M.contactPointA,y),o.sub(M.contactPointA,M.contactPointA,n.position),this.contactEquations.push(M),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(M))}}if(A=!1,d>0)for(S=w;S<=T;S++)if(o.set(b,S*f,p[S]),o.add(b,b,l),o.sub(g,i,b),o.squaredLength(g)<Math.pow(d,2)){if(u)return!0;A=!0;var M=this.createContactEquation(n,t,r,e);o.copy(M.normalA,g),o.normalize(M.normalA,M.normalA),o.scale(M.contactPointB,M.normalA,-d),h(M.contactPointB,M.contactPointB,i),a(M.contactPointB,M.contactPointB,t.position),a(M.contactPointA,b,l),h(M.contactPointA,M.contactPointA,l),a(M.contactPointA,M.contactPointA,n.position),this.contactEquations.push(M),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(M))}return A?1:0};var gt=o.create(),mt=o.create(),yt=o.create(),vt=new g({vertices:[o.create(),o.create(),o.create(),o.create()]});s.prototype[m.BOX|m.HEIGHTFIELD]=s.prototype[m.CONVEX|m.HEIGHTFIELD]=s.prototype.convexHeightfield=function(t,e,i,s,n,r,a,h,l){var c=r.heights,u=r.elementWidth,d=gt,p=mt,f=yt,g=vt,m=Math.floor((t.aabb.lowerBound[0]-a[0])/u),y=Math.ceil((t.aabb.upperBound[0]-a[0])/u);m<0&&(m=0),y>=c.length&&(y=c.length-1);for(var v=c[m],x=c[y],b=m;b<y;b++)c[b]<x&&(x=c[b]),c[b]>v&&(v=c[b]);if(t.aabb.lowerBound[1]>v)return!l&&0;for(var _=0,b=m;b<y;b++){o.set(d,b*u,c[b]),o.set(p,(b+1)*u,c[b+1]),o.add(d,d,a),o.add(p,p,a);o.set(f,.5*(p[0]+d[0]),.5*(p[1]+d[1]-100)),o.sub(g.vertices[0],p,f),o.sub(g.vertices[1],d,f),o.copy(g.vertices[2],g.vertices[1]),o.copy(g.vertices[3],g.vertices[0]),g.vertices[2][1]-=100,g.vertices[3][1]-=100,_+=this.convexConvex(t,e,i,s,n,g,f,0,l)}return _}},{"../equations/ContactEquation":21,"../equations/Equation":22,"../equations/FrictionEquation":23,"../math/vec2":30,"../objects/Body":31,"../shapes/Box":37,"../shapes/Circle":39,"../shapes/Convex":40,"../shapes/Shape":45,"../utils/ContactEquationPool":48,"../utils/FrictionEquationPool":49,"../utils/TupleDictionary":56,"../utils/Utils":57}],11:[function(t,e,i){function s(t){t=t||{},this.from=t.from?r.fromValues(t.from[0],t.from[1]):r.create(),this.to=t.to?r.fromValues(t.to[0],t.to[1]):r.create(),this.checkCollisionResponse=void 0===t.checkCollisionResponse||t.checkCollisionResponse,this.skipBackfaces=!!t.skipBackfaces,this.collisionMask=void 0!==t.collisionMask?t.collisionMask:-1,this.collisionGroup=void 0!==t.collisionGroup?t.collisionGroup:-1,this.mode=void 0!==t.mode?t.mode:s.ANY,this.callback=t.callback||function(t){},this.direction=r.create(),this.length=1,this.update()}function n(t,e,i){r.sub(a,i,t);var s=r.dot(a,e);return r.scale(h,e,s),r.add(h,h,t),r.squaredDistance(i,h)}e.exports=s;var r=t("../math/vec2");t("../collision/RaycastResult"),t("../shapes/Shape"),t("../collision/AABB");s.prototype.constructor=s,s.CLOSEST=1,s.ANY=2,s.ALL=4,s.prototype.update=function(){var t=this.direction;r.sub(t,this.to,this.from),this.length=r.length(t),r.normalize(t,t)},s.prototype.intersectBodies=function(t,e){for(var i=0,s=e.length;!t.shouldStop(this)&&i<s;i++){var n=e[i],r=n.getAABB();(r.overlapsRay(this)>=0||r.containsPoint(this.from))&&this.intersectBody(t,n)}};var o=r.create();s.prototype.intersectBody=function(t,e){var i=this.checkCollisionResponse;if(!i||e.collisionResponse)for(var s=o,n=0,a=e.shapes.length;n<a;n++){var h=e.shapes[n];if((!i||h.collisionResponse)&&(0!=(this.collisionGroup&h.collisionMask)&&0!=(h.collisionGroup&this.collisionMask))){r.rotate(s,h.position,e.angle),r.add(s,s,e.position);var l=h.angle+e.angle;if(this.intersectShape(t,h,l,s,e),t.shouldStop(this))break}}},s.prototype.intersectShape=function(t,e,i,s,r){n(this.from,this.direction,s)>e.boundingRadius*e.boundingRadius||(this._currentBody=r,this._currentShape=e,e.raycast(t,this,s,i),this._currentBody=this._currentShape=null)},s.prototype.getAABB=function(t){var e=this.to,i=this.from;r.set(t.lowerBound,Math.min(e[0],i[0]),Math.min(e[1],i[1])),r.set(t.upperBound,Math.max(e[0],i[0]),Math.max(e[1],i[1]))};r.create();s.prototype.reportIntersection=function(t,e,i,n){this.from,this.to;var o=this._currentShape,a=this._currentBody;if(!(this.skipBackfaces&&r.dot(i,this.direction)>0))switch(this.mode){case s.ALL:t.set(i,o,a,e,n),this.callback(t);break;case s.CLOSEST:(e<t.fraction||!t.hasHit())&&t.set(i,o,a,e,n);break;case s.ANY:t.set(i,o,a,e,n)}};var a=r.create(),h=r.create()},{"../collision/AABB":7,"../collision/RaycastResult":12,"../math/vec2":30,"../shapes/Shape":45}],12:[function(t,e,i){function s(){this.normal=n.create(),this.shape=null,this.body=null,this.faceIndex=-1,this.fraction=-1,this.isStopped=!1}var n=t("../math/vec2"),r=t("../collision/Ray");e.exports=s,s.prototype.reset=function(){n.set(this.normal,0,0),this.shape=null,this.body=null,this.faceIndex=-1,this.fraction=-1,this.isStopped=!1},s.prototype.getHitDistance=function(t){return n.distance(t.from,t.to)*this.fraction},s.prototype.hasHit=function(){return-1!==this.fraction},s.prototype.getHitPoint=function(t,e){n.lerp(t,e.from,e.to,this.fraction)},s.prototype.stop=function(){this.isStopped=!0},s.prototype.shouldStop=function(t){return this.isStopped||-1!==this.fraction&&t.mode===r.ANY},s.prototype.set=function(t,e,i,s,r){n.copy(this.normal,t),this.shape=e,this.body=i,this.fraction=s,this.faceIndex=r}},{"../collision/Ray":11,"../math/vec2":30}],13:[function(t,e,i){function s(){r.call(this,r.SAP),this.axisList=[],this.axisIndex=0;var t=this;this._addBodyHandler=function(e){t.axisList.push(e.body)},this._removeBodyHandler=function(e){var i=t.axisList.indexOf(e.body);-1!==i&&t.axisList.splice(i,1)}}var n=t("../utils/Utils"),r=t("../collision/Broadphase");e.exports=s,(s.prototype=new r).constructor=s,s.prototype.setWorld=function(t){this.axisList.length=0,n.appendArray(this.axisList,t.bodies),t.off("addBody",this._addBodyHandler).off("removeBody",this._removeBodyHandler),t.on("addBody",this._addBodyHandler).on("removeBody",this._removeBodyHandler),this.world=t},s.sortAxisList=function(t,e){e|=0;for(var i=1,s=t.length;i<s;i++){for(var n=t[i],r=i-1;r>=0&&!(t[r].aabb.lowerBound[e]<=n.aabb.lowerBound[e]);r--)t[r+1]=t[r];t[r+1]=n}return t},s.prototype.sortList=function(){var t=this.axisList,e=this.axisIndex;s.sortAxisList(t,e)},s.prototype.getCollisionPairs=function(t){var e=this.axisList,i=this.result,s=this.axisIndex;i.length=0;for(var n=e.length;n--;){var o=e[n];o.aabbNeedsUpdate&&o.updateAABB()}this.sortList();for(var a=0,h=0|e.length;a!==h;a++)for(var l=e[a],c=a+1;c<h;c++){var u=e[c];if(!(u.aabb.lowerBound[s]<=l.aabb.upperBound[s]))break;r.canCollide(l,u)&&this.boundingVolumeCheck(l,u)&&i.push(l,u)}return i},s.prototype.aabbQuery=function(t,e,i){i=i||[],this.sortList();var s=this.axisIndex,n="x";1===s&&(n="y"),2===s&&(n="z");for(var r=this.axisList,o=(e.lowerBound[n],e.upperBound[n],0);o<r.length;o++){var a=r[o];a.aabbNeedsUpdate&&a.updateAABB(),a.aabb.overlaps(e)&&i.push(a)}return i}},{"../collision/Broadphase":8,"../utils/Utils":57}],14:[function(t,e,i){function s(t,e,i,s){this.type=i,s=n.defaults(s,{collideConnected:!0,wakeUpBodies:!0}),this.equations=[],this.bodyA=t,this.bodyB=e,this.collideConnected=s.collideConnected,s.wakeUpBodies&&(t&&t.wakeUp(),e&&e.wakeUp())}e.exports=s;var n=t("../utils/Utils");s.prototype.update=function(){throw new Error("method update() not implmemented in this Constraint subclass!")},s.DISTANCE=1,s.GEAR=2,s.LOCK=3,s.PRISMATIC=4,s.REVOLUTE=5,s.prototype.setStiffness=function(t){for(var e=this.equations,i=0;i!==e.length;i++){var s=e[i];s.stiffness=t,s.needsUpdate=!0}},s.prototype.setRelaxation=function(t){for(var e=this.equations,i=0;i!==e.length;i++){var s=e[i];s.relaxation=t,s.needsUpdate=!0}}},{"../utils/Utils":57}],15:[function(t,e,i){function s(t,e,i){i=a.defaults(i,{localAnchorA:[0,0],localAnchorB:[0,0]}),n.call(this,t,e,n.DISTANCE,i),this.localAnchorA=o.fromValues(i.localAnchorA[0],i.localAnchorA[1]),this.localAnchorB=o.fromValues(i.localAnchorB[0],i.localAnchorB[1]);var s=this.localAnchorA,h=this.localAnchorB;if(this.distance=0,"number"==typeof i.distance)this.distance=i.distance;else{var l=o.create(),c=o.create(),u=o.create();o.rotate(l,s,t.angle),o.rotate(c,h,e.angle),o.add(u,e.position,c),o.sub(u,u,l),o.sub(u,u,t.position),this.distance=o.length(u)}var d;d=void 0===i.maxForce?Number.MAX_VALUE:i.maxForce;var p=new r(t,e,-d,d);this.equations=[p],this.maxForce=d;var u=o.create(),f=o.create(),g=o.create(),m=this;p.computeGq=function(){var t=this.bodyA,e=this.bodyB,i=t.position,n=e.position;return o.rotate(f,s,t.angle),o.rotate(g,h,e.angle),o.add(u,n,g),o.sub(u,u,f),o.sub(u,u,i),o.length(u)-m.distance},this.setMaxForce(d),this.upperLimitEnabled=!1,this.upperLimit=1,this.lowerLimitEnabled=!1,this.lowerLimit=0,this.position=0}var n=t("./Constraint"),r=t("../equations/Equation"),o=t("../math/vec2"),a=t("../utils/Utils");e.exports=s,(s.prototype=new n).constructor=s;var h=o.create(),l=o.create(),c=o.create();s.prototype.update=function(){var t=this.equations[0],e=this.bodyA,i=this.bodyB,s=(this.distance,e.position),n=i.position,r=this.equations[0],a=t.G;o.rotate(l,this.localAnchorA,e.angle),o.rotate(c,this.localAnchorB,i.angle),o.add(h,n,c),o.sub(h,h,l),o.sub(h,h,s),this.position=o.length(h);var u=!1;if(this.upperLimitEnabled&&this.position>this.upperLimit&&(r.maxForce=0,r.minForce=-this.maxForce,this.distance=this.upperLimit,u=!0),this.lowerLimitEnabled&&this.position<this.lowerLimit&&(r.maxForce=this.maxForce,r.minForce=0,this.distance=this.lowerLimit,u=!0),!this.lowerLimitEnabled&&!this.upperLimitEnabled||u){r.enabled=!0,o.normalize(h,h);var d=o.crossLength(l,h),p=o.crossLength(c,h);a[0]=-h[0],a[1]=-h[1],a[2]=-d,a[3]=h[0],a[4]=h[1],a[5]=p}else r.enabled=!1},s.prototype.setMaxForce=function(t){var e=this.equations[0];e.minForce=-t,e.maxForce=t},s.prototype.getMaxForce=function(){return this.equations[0].maxForce}},{"../equations/Equation":22,"../math/vec2":30,"../utils/Utils":57,"./Constraint":14}],16:[function(t,e,i){function s(t,e,i){i=i||{},n.call(this,t,e,n.GEAR,i),this.ratio=void 0!==i.ratio?i.ratio:1,this.angle=void 0!==i.angle?i.angle:e.angle-this.ratio*t.angle,i.angle=this.angle,i.ratio=this.ratio,this.equations=[new r(t,e,i)],void 0!==i.maxTorque&&this.setMaxTorque(i.maxTorque)}var n=t("./Constraint"),r=(t("../equations/Equation"),t("../equations/AngleLockEquation"));t("../math/vec2");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.update=function(){var t=this.equations[0];t.ratio!==this.ratio&&t.setRatio(this.ratio),t.angle=this.angle},s.prototype.setMaxTorque=function(t){this.equations[0].setMaxTorque(t)},s.prototype.getMaxTorque=function(t){return this.equations[0].maxForce}},{"../equations/AngleLockEquation":20,"../equations/Equation":22,"../math/vec2":30,"./Constraint":14}],17:[function(t,e,i){function s(t,e,i){i=i||{},n.call(this,t,e,n.LOCK,i);var s=void 0===i.maxForce?Number.MAX_VALUE:i.maxForce,a=(i.localAngleB,new o(t,e,-s,s)),h=new o(t,e,-s,s),l=new o(t,e,-s,s),c=r.create(),u=r.create(),d=this;a.computeGq=function(){return r.rotate(c,d.localOffsetB,t.angle),r.sub(u,e.position,t.position),r.sub(u,u,c),u[0]},h.computeGq=function(){return r.rotate(c,d.localOffsetB,t.angle),r.sub(u,e.position,t.position),r.sub(u,u,c),u[1]};var p=r.create(),f=r.create();l.computeGq=function(){return r.rotate(p,d.localOffsetB,e.angle-d.localAngleB),r.scale(p,p,-1),r.sub(u,t.position,e.position),r.add(u,u,p),r.rotate(f,p,-Math.PI/2),r.normalize(f,f),r.dot(u,f)},this.localOffsetB=r.create(),i.localOffsetB?r.copy(this.localOffsetB,i.localOffsetB):(r.sub(this.localOffsetB,e.position,t.position),r.rotate(this.localOffsetB,this.localOffsetB,-t.angle)),this.localAngleB=0,"number"==typeof i.localAngleB?this.localAngleB=i.localAngleB:this.localAngleB=e.angle-t.angle,this.equations.push(a,h,l),this.setMaxForce(s)}var n=t("./Constraint"),r=t("../math/vec2"),o=t("../equations/Equation");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.setMaxForce=function(t){for(var e=this.equations,i=0;i<this.equations.length;i++)e[i].maxForce=t,e[i].minForce=-t},s.prototype.getMaxForce=function(){return this.equations[0].maxForce};var a=r.create(),h=r.create(),l=r.create(),c=r.fromValues(1,0),u=r.fromValues(0,1);s.prototype.update=function(){var t=this.equations[0],e=this.equations[1],i=this.equations[2],s=this.bodyA,n=this.bodyB;r.rotate(a,this.localOffsetB,s.angle),r.rotate(h,this.localOffsetB,n.angle-this.localAngleB),r.scale(h,h,-1),r.rotate(l,h,Math.PI/2),r.normalize(l,l),t.G[0]=-1,t.G[1]=0,t.G[2]=-r.crossLength(a,c),t.G[3]=1,e.G[0]=0,e.G[1]=-1,e.G[2]=-r.crossLength(a,u),e.G[4]=1,i.G[0]=-l[0],i.G[1]=-l[1],i.G[3]=l[0],i.G[4]=l[1],i.G[5]=r.crossLength(h,l)}},{"../equations/Equation":22,"../math/vec2":30,"./Constraint":14}],18:[function(t,e,i){function s(t,e,i){i=i||{},n.call(this,t,e,n.PRISMATIC,i);var s=a.fromValues(0,0),l=a.fromValues(1,0),c=a.fromValues(0,0);i.localAnchorA&&a.copy(s,i.localAnchorA),i.localAxisA&&a.copy(l,i.localAxisA),i.localAnchorB&&a.copy(c,i.localAnchorB),this.localAnchorA=s,this.localAnchorB=c,this.localAxisA=l;var u=this.maxForce=void 0!==i.maxForce?i.maxForce:Number.MAX_VALUE,d=new o(t,e,-u,u),p=new a.create,f=new a.create,g=new a.create,m=new a.create;if(d.computeGq=function(){return a.dot(g,m)},d.updateJacobian=function(){var i=this.G,n=t.position,r=e.position;a.rotate(p,s,t.angle),a.rotate(f,c,e.angle),a.add(g,r,f),a.sub(g,g,n),a.sub(g,g,p),a.rotate(m,l,t.angle+Math.PI/2),i[0]=-m[0],i[1]=-m[1],i[2]=-a.crossLength(p,m)+a.crossLength(m,g),i[3]=m[0],i[4]=m[1],i[5]=a.crossLength(f,m)},this.equations.push(d),!i.disableRotationalLock){var y=new h(t,e,-u,u);this.equations.push(y)}this.position=0,this.velocity=0,this.lowerLimitEnabled=void 0!==i.lowerLimit,this.upperLimitEnabled=void 0!==i.upperLimit,this.lowerLimit=void 0!==i.lowerLimit?i.lowerLimit:0,this.upperLimit=void 0!==i.upperLimit?i.upperLimit:1,this.upperLimitEquation=new r(t,e),this.lowerLimitEquation=new r(t,e),this.upperLimitEquation.minForce=this.lowerLimitEquation.minForce=0,this.upperLimitEquation.maxForce=this.lowerLimitEquation.maxForce=u,this.motorEquation=new o(t,e),this.motorEnabled=!1,this.motorSpeed=0;var v=this,x=this.motorEquation;x.computeGW;x.computeGq=function(){return 0},x.computeGW=function(){var t=this.G,e=this.bodyA,i=this.bodyB,s=e.velocity,n=i.velocity,r=e.angularVelocity,o=i.angularVelocity;return this.gmult(t,s,r,n,o)+v.motorSpeed}}var n=t("./Constraint"),r=t("../equations/ContactEquation"),o=t("../equations/Equation"),a=t("../math/vec2"),h=t("../equations/RotationalLockEquation");e.exports=s,(s.prototype=new n).constructor=s;var l=a.create(),c=a.create(),u=a.create(),d=a.create(),p=a.create(),f=a.create();s.prototype.update=function(){var t=this.equations,e=t[0],i=this.upperLimit,s=this.lowerLimit,n=this.upperLimitEquation,r=this.lowerLimitEquation,o=this.bodyA,h=this.bodyB,g=this.localAxisA,m=this.localAnchorA,y=this.localAnchorB;e.updateJacobian(),a.rotate(l,g,o.angle),a.rotate(d,m,o.angle),a.add(c,d,o.position),a.rotate(p,y,h.angle),a.add(u,p,h.position);var v=this.position=a.dot(u,l)-a.dot(c,l);if(this.motorEnabled){var x=this.motorEquation.G;x[0]=l[0],x[1]=l[1],x[2]=a.crossLength(l,p),x[3]=-l[0],x[4]=-l[1],x[5]=-a.crossLength(l,d)}if(this.upperLimitEnabled&&v>i?(a.scale(n.normalA,l,-1),a.sub(n.contactPointA,c,o.position),a.sub(n.contactPointB,u,h.position),a.scale(f,l,i),a.add(n.contactPointA,n.contactPointA,f),-1===t.indexOf(n)&&t.push(n)):-1!==(b=t.indexOf(n))&&t.splice(b,1),this.lowerLimitEnabled&&v<s)a.scale(r.normalA,l,1),a.sub(r.contactPointA,c,o.position),a.sub(r.contactPointB,u,h.position),a.scale(f,l,s),a.sub(r.contactPointB,r.contactPointB,f),-1===t.indexOf(r)&&t.push(r);else{var b=t.indexOf(r);-1!==b&&t.splice(b,1)}},s.prototype.enableMotor=function(){this.motorEnabled||(this.equations.push(this.motorEquation),this.motorEnabled=!0)},s.prototype.disableMotor=function(){if(this.motorEnabled){var t=this.equations.indexOf(this.motorEquation);this.equations.splice(t,1),this.motorEnabled=!1}},s.prototype.setLimits=function(t,e){"number"==typeof t?(this.lowerLimit=t,this.lowerLimitEnabled=!0):(this.lowerLimit=t,this.lowerLimitEnabled=!1),"number"==typeof e?(this.upperLimit=e,this.upperLimitEnabled=!0):(this.upperLimit=e,this.upperLimitEnabled=!1)}},{"../equations/ContactEquation":21,"../equations/Equation":22,"../equations/RotationalLockEquation":24,"../math/vec2":30,"./Constraint":14}],19:[function(t,e,i){function s(t,e,i){i=i||{},n.call(this,t,e,n.REVOLUTE,i);var s=this.maxForce=void 0!==i.maxForce?i.maxForce:Number.MAX_VALUE;this.pivotA=h.create(),this.pivotB=h.create(),i.worldPivot?(h.sub(this.pivotA,i.worldPivot,t.position),h.sub(this.pivotB,i.worldPivot,e.position),h.rotate(this.pivotA,this.pivotA,-t.angle),h.rotate(this.pivotB,this.pivotB,-e.angle)):(h.copy(this.pivotA,i.localPivotA),h.copy(this.pivotB,i.localPivotB));var f=this.equations=[new r(t,e,-s,s),new r(t,e,-s,s)],g=f[0],m=f[1],y=this;g.computeGq=function(){return h.rotate(l,y.pivotA,t.angle),h.rotate(c,y.pivotB,e.angle),h.add(p,e.position,c),h.sub(p,p,t.position),h.sub(p,p,l),h.dot(p,u)},m.computeGq=function(){return h.rotate(l,y.pivotA,t.angle),h.rotate(c,y.pivotB,e.angle),h.add(p,e.position,c),h.sub(p,p,t.position),h.sub(p,p,l),h.dot(p,d)},m.minForce=g.minForce=-s,m.maxForce=g.maxForce=s,this.motorEquation=new o(t,e),this.motorEnabled=!1,this.angle=0,this.lowerLimitEnabled=!1,this.upperLimitEnabled=!1,this.lowerLimit=0,this.upperLimit=0,this.upperLimitEquation=new a(t,e),this.lowerLimitEquation=new a(t,e),this.upperLimitEquation.minForce=0,this.lowerLimitEquation.maxForce=0}var n=t("./Constraint"),r=t("../equations/Equation"),o=t("../equations/RotationalVelocityEquation"),a=t("../equations/RotationalLockEquation"),h=t("../math/vec2");e.exports=s;var l=h.create(),c=h.create(),u=h.fromValues(1,0),d=h.fromValues(0,1),p=h.create();(s.prototype=new n).constructor=s,s.prototype.setLimits=function(t,e){"number"==typeof t?(this.lowerLimit=t,this.lowerLimitEnabled=!0):(this.lowerLimit=t,this.lowerLimitEnabled=!1),"number"==typeof e?(this.upperLimit=e,this.upperLimitEnabled=!0):(this.upperLimit=e,this.upperLimitEnabled=!1)},s.prototype.update=function(){var t=this.bodyA,e=this.bodyB,i=this.pivotA,s=this.pivotB,n=this.equations,r=(n[0],n[1],n[0]),o=n[1],a=this.upperLimit,p=this.lowerLimit,f=this.upperLimitEquation,g=this.lowerLimitEquation,m=this.angle=e.angle-t.angle;if(this.upperLimitEnabled&&m>a?(f.angle=a,-1===n.indexOf(f)&&n.push(f)):-1!==(y=n.indexOf(f))&&n.splice(y,1),this.lowerLimitEnabled&&m<p)g.angle=p,-1===n.indexOf(g)&&n.push(g);else{var y=n.indexOf(g);-1!==y&&n.splice(y,1)}h.rotate(l,i,t.angle),h.rotate(c,s,e.angle),r.G[0]=-1,r.G[1]=0,r.G[2]=-h.crossLength(l,u),r.G[3]=1,r.G[4]=0,r.G[5]=h.crossLength(c,u),o.G[0]=0,o.G[1]=-1,o.G[2]=-h.crossLength(l,d),o.G[3]=0,o.G[4]=1,o.G[5]=h.crossLength(c,d)},s.prototype.enableMotor=function(){this.motorEnabled||(this.equations.push(this.motorEquation),this.motorEnabled=!0)},s.prototype.disableMotor=function(){if(this.motorEnabled){var t=this.equations.indexOf(this.motorEquation);this.equations.splice(t,1),this.motorEnabled=!1}},s.prototype.setMotorSpeed=function(t){if(this.motorEnabled){var e=this.equations.indexOf(this.motorEquation);this.equations[e].relativeVelocity=t}},s.prototype.getMotorSpeed=function(){return!!this.motorEnabled&&this.motorEquation.relativeVelocity}},{"../equations/Equation":22,"../equations/RotationalLockEquation":24,"../equations/RotationalVelocityEquation":25,"../math/vec2":30,"./Constraint":14}],20:[function(t,e,i){function s(t,e,i){i=i||{},n.call(this,t,e,-Number.MAX_VALUE,Number.MAX_VALUE),this.angle=i.angle||0,this.ratio="number"==typeof i.ratio?i.ratio:1,this.setRatio(this.ratio)}var n=t("./Equation");t("../math/vec2");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.computeGq=function(){return this.ratio*this.bodyA.angle-this.bodyB.angle+this.angle},s.prototype.setRatio=function(t){var e=this.G;e[2]=t,e[5]=-1,this.ratio=t},s.prototype.setMaxTorque=function(t){this.maxForce=t,this.minForce=-t}},{"../math/vec2":30,"./Equation":22}],21:[function(t,e,i){function s(t,e){n.call(this,t,e,0,Number.MAX_VALUE),this.contactPointA=r.create(),this.penetrationVec=r.create(),this.contactPointB=r.create(),this.normalA=r.create(),this.restitution=0,this.firstImpact=!1,this.shapeA=null,this.shapeB=null}var n=t("./Equation"),r=t("../math/vec2");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.computeB=function(t,e,i){var s=this.bodyA,n=this.bodyB,o=this.contactPointA,a=this.contactPointB,h=s.position,l=n.position,c=this.penetrationVec,u=this.normalA,d=this.G,p=r.crossLength(o,u),f=r.crossLength(a,u);d[0]=-u[0],d[1]=-u[1],d[2]=-p,d[3]=u[0],d[4]=u[1],d[5]=f,r.add(c,l,a),r.sub(c,c,h),r.sub(c,c,o);var g,m;return this.firstImpact&&0!==this.restitution?(m=0,g=1/e*(1+this.restitution)*this.computeGW()):(m=r.dot(u,c)+this.offset,g=this.computeGW()),-m*t-g*e-i*this.computeGiMf()};var o=r.create(),a=r.create(),h=r.create();s.prototype.getVelocityAlongNormal=function(){return this.bodyA.getVelocityAtPoint(o,this.contactPointA),this.bodyB.getVelocityAtPoint(a,this.contactPointB),r.subtract(h,o,a),r.dot(this.normalA,h)}},{"../math/vec2":30,"./Equation":22}],22:[function(t,e,i){function s(t,e,i,n){this.minForce=void 0===i?-Number.MAX_VALUE:i,this.maxForce=void 0===n?Number.MAX_VALUE:n,this.bodyA=t,this.bodyB=e,this.stiffness=s.DEFAULT_STIFFNESS,this.relaxation=s.DEFAULT_RELAXATION,this.G=new r.ARRAY_TYPE(6);for(var o=0;o<6;o++)this.G[o]=0;this.offset=0,this.a=0,this.b=0,this.epsilon=0,this.timeStep=1/60,this.needsUpdate=!0,this.multiplier=0,this.relativeVelocity=0,this.enabled=!0}e.exports=s;var n=t("../math/vec2"),r=t("../utils/Utils");t("../objects/Body");s.prototype.constructor=s,s.DEFAULT_STIFFNESS=1e6,s.DEFAULT_RELAXATION=4,s.prototype.update=function(){var t=this.stiffness,e=this.relaxation,i=this.timeStep;this.a=4/(i*(1+4*e)),this.b=4*e/(1+4*e),this.epsilon=4/(i*i*t*(1+4*e)),this.needsUpdate=!1},s.prototype.gmult=function(t,e,i,s,n){return t[0]*e[0]+t[1]*e[1]+t[2]*i+t[3]*s[0]+t[4]*s[1]+t[5]*n},s.prototype.computeB=function(t,e,i){var s=this.computeGW();return-this.computeGq()*t-s*e-this.computeGiMf()*i};var o=n.create(),a=n.create();s.prototype.computeGq=function(){var t=this.G,e=this.bodyA,i=this.bodyB,s=(e.position,i.position,e.angle),n=i.angle;return this.gmult(t,o,s,a,n)+this.offset},s.prototype.computeGW=function(){var t=this.G,e=this.bodyA,i=this.bodyB,s=e.velocity,n=i.velocity,r=e.angularVelocity,o=i.angularVelocity;return this.gmult(t,s,r,n,o)+this.relativeVelocity},s.prototype.computeGWlambda=function(){var t=this.G,e=this.bodyA,i=this.bodyB,s=e.vlambda,n=i.vlambda,r=e.wlambda,o=i.wlambda;return this.gmult(t,s,r,n,o)};var h=n.create(),l=n.create();s.prototype.computeGiMf=function(){var t=this.bodyA,e=this.bodyB,i=t.force,s=t.angularForce,r=e.force,o=e.angularForce,a=t.invMassSolve,c=e.invMassSolve,u=t.invInertiaSolve,d=e.invInertiaSolve,p=this.G;return n.scale(h,i,a),n.multiply(h,t.massMultiplier,h),n.scale(l,r,c),n.multiply(l,e.massMultiplier,l),this.gmult(p,h,s*u,l,o*d)},s.prototype.computeGiMGt=function(){var t=this.bodyA,e=this.bodyB,i=t.invMassSolve,s=e.invMassSolve,n=t.invInertiaSolve,r=e.invInertiaSolve,o=this.G;return o[0]*o[0]*i*t.massMultiplier[0]+o[1]*o[1]*i*t.massMultiplier[1]+o[2]*o[2]*n+o[3]*o[3]*s*e.massMultiplier[0]+o[4]*o[4]*s*e.massMultiplier[1]+o[5]*o[5]*r};var c=n.create(),u=n.create(),d=n.create();n.create(),n.create(),n.create();s.prototype.addToWlambda=function(t){var e=this.bodyA,i=this.bodyB,s=c,r=u,o=d,a=e.invMassSolve,h=i.invMassSolve,l=e.invInertiaSolve,p=i.invInertiaSolve,f=this.G;r[0]=f[0],r[1]=f[1],o[0]=f[3],o[1]=f[4],n.scale(s,r,a*t),n.multiply(s,s,e.massMultiplier),n.add(e.vlambda,e.vlambda,s),e.wlambda+=l*f[2]*t,n.scale(s,o,h*t),n.multiply(s,s,i.massMultiplier),n.add(i.vlambda,i.vlambda,s),i.wlambda+=p*f[5]*t},s.prototype.computeInvC=function(t){return 1/(this.computeGiMGt()+t)}},{"../math/vec2":30,"../objects/Body":31,"../utils/Utils":57}],23:[function(t,e,i){function s(t,e,i){r.call(this,t,e,-i,i),this.contactPointA=n.create(),this.contactPointB=n.create(),this.t=n.create(),this.contactEquations=[],this.shapeA=null,this.shapeB=null,this.frictionCoefficient=.3}var n=t("../math/vec2"),r=t("./Equation");t("../utils/Utils");e.exports=s,(s.prototype=new r).constructor=s,s.prototype.setSlipForce=function(t){this.maxForce=t,this.minForce=-t},s.prototype.getSlipForce=function(){return this.maxForce},s.prototype.computeB=function(t,e,i){this.bodyA,this.bodyB;var s=this.contactPointA,r=this.contactPointB,o=this.t,a=this.G;return a[0]=-o[0],a[1]=-o[1],a[2]=-n.crossLength(s,o),a[3]=o[0],a[4]=o[1],a[5]=n.crossLength(r,o),-this.computeGW()*e-i*this.computeGiMf()}},{"../math/vec2":30,"../utils/Utils":57,"./Equation":22}],24:[function(t,e,i){function s(t,e,i){i=i||{},n.call(this,t,e,-Number.MAX_VALUE,Number.MAX_VALUE),this.angle=i.angle||0;var s=this.G;s[2]=1,s[5]=-1}var n=t("./Equation"),r=t("../math/vec2");e.exports=s,(s.prototype=new n).constructor=s;var o=r.create(),a=r.create(),h=r.fromValues(1,0),l=r.fromValues(0,1);s.prototype.computeGq=function(){return r.rotate(o,h,this.bodyA.angle+this.angle),r.rotate(a,l,this.bodyB.angle),r.dot(o,a)}},{"../math/vec2":30,"./Equation":22}],25:[function(t,e,i){function s(t,e){n.call(this,t,e,-Number.MAX_VALUE,Number.MAX_VALUE),this.relativeVelocity=1,this.ratio=1}var n=t("./Equation");t("../math/vec2");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.computeB=function(t,e,i){var s=this.G;s[2]=-1,s[5]=this.ratio;var n=this.computeGiMf();return-this.computeGW()*e-i*n}},{"../math/vec2":30,"./Equation":22}],26:[function(t,e,i){var s=function(){};e.exports=s,s.prototype={constructor:s,on:function(t,e,i){e.context=i||this,void 0===this._listeners&&(this._listeners={});var s=this._listeners;return void 0===s[t]&&(s[t]=[]),-1===s[t].indexOf(e)&&s[t].push(e),this},has:function(t,e){if(void 0===this._listeners)return!1;var i=this._listeners;if(e){if(void 0!==i[t]&&-1!==i[t].indexOf(e))return!0}else if(void 0!==i[t])return!0;return!1},off:function(t,e){if(void 0===this._listeners)return this;var i=this._listeners,s=i[t].indexOf(e);return-1!==s&&i[t].splice(s,1),this},emit:function(t){if(void 0===this._listeners)return this;var e=this._listeners[t.type];if(void 0!==e){t.target=this;for(var i=0,s=e.length;i<s;i++){var n=e[i];n.call(n.context,t)}}return this}}},{}],27:[function(t,e,i){function s(t,e,i){if(i=i||{},!(t instanceof n&&e instanceof n))throw new Error("First two arguments must be Material instances.");this.id=s.idCounter++,this.materialA=t,this.materialB=e,this.friction=void 0!==i.friction?Number(i.friction):.3,this.restitution=void 0!==i.restitution?Number(i.restitution):0,this.stiffness=void 0!==i.stiffness?Number(i.stiffness):r.DEFAULT_STIFFNESS,this.relaxation=void 0!==i.relaxation?Number(i.relaxation):r.DEFAULT_RELAXATION,this.frictionStiffness=void 0!==i.frictionStiffness?Number(i.frictionStiffness):r.DEFAULT_STIFFNESS,this.frictionRelaxation=void 0!==i.frictionRelaxation?Number(i.frictionRelaxation):r.DEFAULT_RELAXATION,this.surfaceVelocity=void 0!==i.surfaceVelocity?Number(i.surfaceVelocity):0,this.contactSkinSize=.005}var n=t("./Material"),r=t("../equations/Equation");e.exports=s,s.idCounter=0},{"../equations/Equation":22,"./Material":28}],28:[function(t,e,i){function s(t){this.id=t||s.idCounter++}e.exports=s,s.idCounter=0},{}],29:[function(t,e,i){var s={};s.GetArea=function(t){if(t.length<6)return 0;for(var e=t.length-2,i=0,s=0;s<e;s+=2)i+=(t[s+2]-t[s])*(t[s+1]+t[s+3]);return.5*-(i+=(t[0]-t[e])*(t[e+1]+t[1]))},s.Triangulate=function(t){var e=t.length>>1;if(e<3)return[];for(var i=[],n=[],r=0;r<e;r++)n.push(r);for(var r=0,o=e;o>3;){var a=n[(r+0)%o],h=n[(r+1)%o],l=n[(r+2)%o],c=t[2*a],u=t[2*a+1],d=t[2*h],p=t[2*h+1],f=t[2*l],g=t[2*l+1],m=!1;if(s._convex(c,u,d,p,f,g)){m=!0;for(var y=0;y<o;y++){var v=n[y];if(v!=a&&v!=h&&v!=l&&s._PointInTriangle(t[2*v],t[2*v+1],c,u,d,p,f,g)){m=!1;break}}}if(m)i.push(a,h,l),n.splice((r+1)%o,1),o--,r=0;else if(r++>3*o)break}return i.push(n[0],n[1],n[2]),i},s._PointInTriangle=function(t,e,i,s,n,r,o,a){var h=o-i,l=a-s,c=n-i,u=r-s,d=t-i,p=e-s,f=h*h+l*l,g=h*c+l*u,m=h*d+l*p,y=c*c+u*u,v=c*d+u*p,x=1/(f*y-g*g),b=(y*m-g*v)*x,_=(f*v-g*m)*x;return b>=0&&_>=0&&b+_<1},s._convex=function(t,e,i,s,n,r){return(e-s)*(n-i)+(i-t)*(r-s)>=0},e.exports=s},{}],30:[function(t,e,i){var s=e.exports={},n=t("../utils/Utils");s.crossLength=function(t,e){return t[0]*e[1]-t[1]*e[0]},s.crossVZ=function(t,e,i){return s.rotate(t,e,-Math.PI/2),s.scale(t,t,i),t},s.crossZV=function(t,e,i){return s.rotate(t,i,Math.PI/2),s.scale(t,t,e),t},s.rotate=function(t,e,i){if(0!==i){var s=Math.cos(i),n=Math.sin(i),r=e[0],o=e[1];t[0]=s*r-n*o,t[1]=n*r+s*o}else t[0]=e[0],t[1]=e[1]},s.rotate90cw=function(t,e){var i=e[0],s=e[1];t[0]=s,t[1]=-i},s.toLocalFrame=function(t,e,i,n){s.copy(t,e),s.sub(t,t,i),s.rotate(t,t,-n)},s.toGlobalFrame=function(t,e,i,n){s.copy(t,e),s.rotate(t,t,n),s.add(t,t,i)},s.vectorToLocalFrame=function(t,e,i){s.rotate(t,e,-i)},s.vectorToGlobalFrame=function(t,e,i){s.rotate(t,e,i)},s.centroid=function(t,e,i,n){return s.add(t,e,i),s.add(t,t,n),s.scale(t,t,1/3),t},s.create=function(){var t=new n.ARRAY_TYPE(2);return t[0]=0,t[1]=0,t},s.clone=function(t){var e=new n.ARRAY_TYPE(2);return e[0]=t[0],e[1]=t[1],e},s.fromValues=function(t,e){var i=new n.ARRAY_TYPE(2);return i[0]=t,i[1]=e,i},s.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t},s.set=function(t,e,i){return t[0]=e,t[1]=i,t},s.add=function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t},s.subtract=function(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t},s.sub=s.subtract,s.multiply=function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t},s.mul=s.multiply,s.divide=function(t,e,i){return t[0]=e[0]/i[0],t[1]=e[1]/i[1],t},s.div=s.divide,s.scale=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t},s.distance=function(t,e){var i=e[0]-t[0],s=e[1]-t[1];return Math.sqrt(i*i+s*s)},s.dist=s.distance,s.squaredDistance=function(t,e){var i=e[0]-t[0],s=e[1]-t[1];return i*i+s*s},s.sqrDist=s.squaredDistance,s.length=function(t){var e=t[0],i=t[1];return Math.sqrt(e*e+i*i)},s.len=s.length,s.squaredLength=function(t){var e=t[0],i=t[1];return e*e+i*i},s.sqrLen=s.squaredLength,s.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t},s.normalize=function(t,e){var i=e[0],s=e[1],n=i*i+s*s;return n>0&&(n=1/Math.sqrt(n),t[0]=e[0]*n,t[1]=e[1]*n),t},s.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},s.str=function(t){return"vec2("+t[0]+", "+t[1]+")"},s.lerp=function(t,e,i,s){var n=e[0],r=e[1];return t[0]=n+s*(i[0]-n),t[1]=r+s*(i[1]-r),t},s.reflect=function(t,e,i){var s=e[0]*i[0]+e[1]*i[1];t[0]=e[0]-2*i[0]*s,t[1]=e[1]-2*i[1]*s},s.getLineSegmentsIntersection=function(t,e,i,n,r){var o=s.getLineSegmentsIntersectionFraction(e,i,n,r);return!(o<0)&&(t[0]=e[0]+o*(i[0]-e[0]),t[1]=e[1]+o*(i[1]-e[1]),!0)},s.getLineSegmentsIntersectionFraction=function(t,e,i,s){var n,r,o=e[0]-t[0],a=e[1]-t[1],h=s[0]-i[0],l=s[1]-i[1];return n=(-a*(t[0]-i[0])+o*(t[1]-i[1]))/(-h*a+o*l),r=(h*(t[1]-i[1])-l*(t[0]-i[0]))/(-h*a+o*l),n>=0&&n<=1&&r>=0&&r<=1?r:-1}},{"../utils/Utils":57}],31:[function(t,e,i){function s(t){t=t||{},c.call(this),this.id=t.id||++s._idCounter,this.world=null,this.shapes=[],this.mass=t.mass||0,this.invMass=0,this.inertia=0,this.invInertia=0,this.invMassSolve=0,this.invInertiaSolve=0,this.fixedRotation=!!t.fixedRotation,this.fixedX=!!t.fixedX,this.fixedY=!!t.fixedY,this.massMultiplier=n.create(),this.position=n.fromValues(0,0),t.position&&n.copy(this.position,t.position),this.interpolatedPosition=n.fromValues(0,0),this.interpolatedAngle=0,this.previousPosition=n.fromValues(0,0),this.previousAngle=0,this.velocity=n.fromValues(0,0),t.velocity&&n.copy(this.velocity,t.velocity),this.vlambda=n.fromValues(0,0),this.wlambda=0,this.angle=t.angle||0,this.angularVelocity=t.angularVelocity||0,this.force=n.create(),t.force&&n.copy(this.force,t.force),this.angularForce=t.angularForce||0,this.damping="number"==typeof t.damping?t.damping:.1,this.angularDamping="number"==typeof t.angularDamping?t.angularDamping:.1,this.type=s.STATIC,void 0!==t.type?this.type=t.type:t.mass?this.type=s.DYNAMIC:this.type=s.STATIC,this.boundingRadius=0,this.aabb=new l,this.aabbNeedsUpdate=!0,this.allowSleep=void 0===t.allowSleep||t.allowSleep,this.wantsToSleep=!1,this.sleepState=s.AWAKE,this.sleepSpeedLimit=void 0!==t.sleepSpeedLimit?t.sleepSpeedLimit:.2,this.sleepTimeLimit=void 0!==t.sleepTimeLimit?t.sleepTimeLimit:1,this.gravityScale=void 0!==t.gravityScale?t.gravityScale:1,this.collisionResponse=void 0===t.collisionResponse||t.collisionResponse,this.idleTime=0,this.timeLastSleepy=0,this.ccdSpeedThreshold=void 0!==t.ccdSpeedThreshold?t.ccdSpeedThreshold:-1,this.ccdIterations=void 0!==t.ccdIterations?t.ccdIterations:10,this.concavePath=null,this._wakeUpAfterNarrowphase=!1,this.updateMassProperties()}var n=t("../math/vec2"),r=t("poly-decomp"),o=t("../shapes/Convex"),a=t("../collision/RaycastResult"),h=t("../collision/Ray"),l=t("../collision/AABB"),c=t("../events/EventEmitter");e.exports=s,s.prototype=new c,s.prototype.constructor=s,s._idCounter=0,s.prototype.updateSolveMassProperties=function(){this.sleepState===s.SLEEPING||this.type===s.KINEMATIC?(this.invMassSolve=0,this.invInertiaSolve=0):(this.invMassSolve=this.invMass,this.invInertiaSolve=this.invInertia)},s.prototype.setDensity=function(t){var e=this.getArea();this.mass=e*t,this.updateMassProperties()},s.prototype.getArea=function(){for(var t=0,e=0;e<this.shapes.length;e++)t+=this.shapes[e].area;return t},s.prototype.getAABB=function(){return this.aabbNeedsUpdate&&this.updateAABB(),this.aabb};var u=new l,d=n.create();s.prototype.updateAABB=function(){for(var t=this.shapes,e=t.length,i=d,s=this.angle,r=0;r!==e;r++){var o=t[r],a=o.angle+s;n.rotate(i,o.position,s),n.add(i,i,this.position),o.computeAABB(u,i,a),0===r?this.aabb.copy(u):this.aabb.extend(u)}this.aabbNeedsUpdate=!1},s.prototype.updateBoundingRadius=function(){for(var t=this.shapes,e=t.length,i=0,s=0;s!==e;s++){var r=t[s],o=n.length(r.position),a=r.boundingRadius;o+a>i&&(i=o+a)}this.boundingRadius=i},s.prototype.addShape=function(t,e,i){if(t.body)throw new Error("A shape can only be added to one body.");t.body=this,e?n.copy(t.position,e):n.set(t.position,0,0),t.angle=i||0,this.shapes.push(t),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0},s.prototype.removeShape=function(t){var e=this.shapes.indexOf(t);return-1!==e&&(this.shapes.splice(e,1),this.aabbNeedsUpdate=!0,t.body=null,!0)},s.prototype.updateMassProperties=function(){if(this.type===s.STATIC||this.type===s.KINEMATIC)this.mass=Number.MAX_VALUE,this.invMass=0,this.inertia=Number.MAX_VALUE,this.invInertia=0;else{var t=this.shapes,e=t.length,i=this.mass/e,r=0;if(this.fixedRotation)this.inertia=Number.MAX_VALUE,this.invInertia=0;else{for(var o=0;o<e;o++){var a=t[o],h=n.squaredLength(a.position);r+=a.computeMomentOfInertia(i)+i*h}this.inertia=r,this.invInertia=r>0?1/r:0}this.invMass=1/this.mass,n.set(this.massMultiplier,this.fixedX?0:1,this.fixedY?0:1)}};n.create();s.prototype.applyForce=function(t,e){if(n.add(this.force,this.force,t),e){var i=n.crossLength(e,t);this.angularForce+=i}};var p=n.create(),f=n.create(),g=n.create();s.prototype.applyForceLocal=function(t,e){e=e||g;var i=p,s=f;this.vectorToWorldFrame(i,t),this.vectorToWorldFrame(s,e),this.applyForce(i,s)};var m=n.create();s.prototype.applyImpulse=function(t,e){if(this.type===s.DYNAMIC){var i=m;if(n.scale(i,t,this.invMass),n.multiply(i,this.massMultiplier,i),n.add(this.velocity,i,this.velocity),e){var r=n.crossLength(e,t);r*=this.invInertia,this.angularVelocity+=r}}};var y=n.create(),v=n.create(),x=n.create();s.prototype.applyImpulseLocal=function(t,e){e=e||x;var i=y,s=v;this.vectorToWorldFrame(i,t),this.vectorToWorldFrame(s,e),this.applyImpulse(i,s)},s.prototype.toLocalFrame=function(t,e){n.toLocalFrame(t,e,this.position,this.angle)},s.prototype.toWorldFrame=function(t,e){n.toGlobalFrame(t,e,this.position,this.angle)},s.prototype.vectorToLocalFrame=function(t,e){n.vectorToLocalFrame(t,e,this.angle)},s.prototype.vectorToWorldFrame=function(t,e){n.vectorToGlobalFrame(t,e,this.angle)},s.prototype.fromPolygon=function(t,e){e=e||{};for(h=this.shapes.length;h>=0;--h)this.removeShape(this.shapes[h]);var i=new r.Polygon;if(i.vertices=t,i.makeCCW(),"number"==typeof e.removeCollinearPoints&&i.removeCollinearPoints(e.removeCollinearPoints),void 0===e.skipSimpleCheck&&!i.isSimple())return!1;this.concavePath=i.vertices.slice(0);for(h=0;h<this.concavePath.length;h++){u=[0,0];n.copy(u,this.concavePath[h]),this.concavePath[h]=u}var s;s=e.optimalDecomp?i.decomp():i.quickDecomp();for(var a=n.create(),h=0;h!==s.length;h++){for(var l=new o({vertices:s[h].vertices}),c=0;c!==l.vertices.length;c++){var u=l.vertices[c];n.sub(u,u,l.centerOfMass)}n.scale(a,l.centerOfMass,1),l.updateTriangles(),l.updateCenterOfMass(),l.updateBoundingRadius(),this.addShape(l,a)}return this.adjustCenterOfMass(),this.aabbNeedsUpdate=!0,!0};n.fromValues(0,0);var b=n.fromValues(0,0),_=n.fromValues(0,0),w=n.fromValues(0,0);s.prototype.adjustCenterOfMass=function(){var t=b,e=_,i=w,s=0;n.set(e,0,0);for(o=0;o!==this.shapes.length;o++){r=this.shapes[o];n.scale(t,r.position,r.area),n.add(e,e,t),s+=r.area}n.scale(i,e,1/s);for(o=0;o!==this.shapes.length;o++){var r=this.shapes[o];n.sub(r.position,r.position,i)}n.add(this.position,this.position,i);for(var o=0;this.concavePath&&o<this.concavePath.length;o++)n.sub(this.concavePath[o],this.concavePath[o],i);this.updateMassProperties(),this.updateBoundingRadius()},s.prototype.setZeroForce=function(){n.set(this.force,0,0),this.angularForce=0},s.prototype.resetConstraintVelocity=function(){var t=this,e=t.vlambda;n.set(e,0,0),t.wlambda=0},s.prototype.addConstraintVelocity=function(){var t=this,e=t.velocity;n.add(e,e,t.vlambda),t.angularVelocity+=t.wlambda},s.prototype.applyDamping=function(t){if(this.type===s.DYNAMIC){var e=this.velocity;n.scale(e,e,Math.pow(1-this.damping,t)),this.angularVelocity*=Math.pow(1-this.angularDamping,t)}},s.prototype.wakeUp=function(){var t=this.sleepState;this.sleepState=s.AWAKE,this.idleTime=0,t!==s.AWAKE&&this.emit(s.wakeUpEvent)},s.prototype.sleep=function(){this.sleepState=s.SLEEPING,this.angularVelocity=0,this.angularForce=0,n.set(this.velocity,0,0),n.set(this.force,0,0),this.emit(s.sleepEvent)},s.prototype.sleepTick=function(t,e,i){if(this.allowSleep&&this.type!==s.SLEEPING){this.wantsToSleep=!1;this.sleepState;n.squaredLength(this.velocity)+Math.pow(this.angularVelocity,2)>=Math.pow(this.sleepSpeedLimit,2)?(this.idleTime=0,this.sleepState=s.AWAKE):(this.idleTime+=i,this.sleepState=s.SLEEPY),this.idleTime>this.sleepTimeLimit&&(e?this.wantsToSleep=!0:this.sleep())}},s.prototype.overlaps=function(t){return this.world.overlapKeeper.bodiesAreOverlapping(this,t)};var T=n.create(),P=n.create();s.prototype.integrate=function(t){var e=this.invMass,i=this.force,s=this.position,r=this.velocity;n.copy(this.previousPosition,this.position),this.previousAngle=this.angle,this.fixedRotation||(this.angularVelocity+=this.angularForce*this.invInertia*t),n.scale(T,i,t*e),n.multiply(T,this.massMultiplier,T),n.add(r,T,r),this.integrateToTimeOfImpact(t)||(n.scale(P,r,t),n.add(s,s,P),this.fixedRotation||(this.angle+=this.angularVelocity*t)),this.aabbNeedsUpdate=!0};var C=new a,S=new h({mode:h.ALL}),A=n.create(),E=n.create(),M=n.create(),R=n.create();s.prototype.integrateToTimeOfImpact=function(t){if(this.ccdSpeedThreshold<0||n.squaredLength(this.velocity)<Math.pow(this.ccdSpeedThreshold,2))return!1;n.normalize(A,this.velocity),n.scale(E,this.velocity,t),n.add(E,E,this.position),n.sub(M,E,this.position);var e,i=this.angularVelocity*t,s=n.length(M),r=1,o=this;if(C.reset(),S.callback=function(t){t.body!==o&&(e=t.body,t.getHitPoint(E,S),n.sub(M,E,o.position),r=n.length(M)/s,t.stop())},n.copy(S.from,this.position),n.copy(S.to,E),S.update(),this.world.raycast(C,S),!e)return!1;var a=this.angle;n.copy(R,this.position);for(var h=0,l=0,c=0,u=r;u>=l&&h<this.ccdIterations;)h++,c=(u-l)/2,n.scale(P,M,r),n.add(this.position,R,P),this.angle=a+i*r,this.updateAABB(),this.aabb.overlaps(e.aabb)&&this.world.narrowphase.bodiesOverlap(this,e)?l=c:u=c;return r=c,n.copy(this.position,R),this.angle=a,n.scale(P,M,r),n.add(this.position,this.position,P),this.fixedRotation||(this.angle+=i*r),!0},s.prototype.getVelocityAtPoint=function(t,e){return n.crossVZ(t,e,this.angularVelocity),n.subtract(t,this.velocity,t),t},s.sleepyEvent={type:"sleepy"},s.sleepEvent={type:"sleep"},s.wakeUpEvent={type:"wakeup"},s.DYNAMIC=1,s.STATIC=2,s.KINEMATIC=4,s.AWAKE=0,s.SLEEPY=1,s.SLEEPING=2},{"../collision/AABB":7,"../collision/Ray":11,"../collision/RaycastResult":12,"../events/EventEmitter":26,"../math/vec2":30,"../shapes/Convex":40,"poly-decomp":5}],32:[function(t,e,i){function s(t,e,i){i=i||{},r.call(this,t,e,i),this.localAnchorA=n.fromValues(0,0),this.localAnchorB=n.fromValues(0,0),i.localAnchorA&&n.copy(this.localAnchorA,i.localAnchorA),i.localAnchorB&&n.copy(this.localAnchorB,i.localAnchorB),i.worldAnchorA&&this.setWorldAnchorA(i.worldAnchorA),i.worldAnchorB&&this.setWorldAnchorB(i.worldAnchorB);var s=n.create(),o=n.create();this.getWorldAnchorA(s),this.getWorldAnchorB(o);var a=n.distance(s,o);this.restLength="number"==typeof i.restLength?i.restLength:a}var n=t("../math/vec2"),r=t("./Spring");t("../utils/Utils");e.exports=s,(s.prototype=new r).constructor=s,s.prototype.setWorldAnchorA=function(t){this.bodyA.toLocalFrame(this.localAnchorA,t)},s.prototype.setWorldAnchorB=function(t){this.bodyB.toLocalFrame(this.localAnchorB,t)},s.prototype.getWorldAnchorA=function(t){this.bodyA.toWorldFrame(t,this.localAnchorA)},s.prototype.getWorldAnchorB=function(t){this.bodyB.toWorldFrame(t,this.localAnchorB)};var o=n.create(),a=n.create(),h=n.create(),l=n.create(),c=n.create(),u=n.create(),d=n.create(),p=n.create(),f=n.create();s.prototype.applyForce=function(){var t=this.stiffness,e=this.damping,i=this.restLength,s=this.bodyA,r=this.bodyB,g=o,m=a,y=h,v=l,x=f,b=c,_=u,w=d,T=p;this.getWorldAnchorA(b),this.getWorldAnchorB(_),n.sub(w,b,s.position),n.sub(T,_,r.position),n.sub(g,_,b);var P=n.len(g);n.normalize(m,g),n.sub(y,r.velocity,s.velocity),n.crossZV(x,r.angularVelocity,T),n.add(y,y,x),n.crossZV(x,s.angularVelocity,w),n.sub(y,y,x),n.scale(v,m,-t*(P-i)-e*n.dot(y,m)),n.sub(s.force,s.force,v),n.add(r.force,r.force,v);var C=n.crossLength(w,v),S=n.crossLength(T,v);s.angularForce-=C,r.angularForce+=S}},{"../math/vec2":30,"../utils/Utils":57,"./Spring":34}],33:[function(t,e,i){function s(t,e,i){i=i||{},n.call(this,t,e,i),this.restAngle="number"==typeof i.restAngle?i.restAngle:e.angle-t.angle}t("../math/vec2");var n=t("./Spring");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.applyForce=function(){var t=this.stiffness,e=this.damping,i=this.restAngle,s=this.bodyA,n=this.bodyB,r=-t*(n.angle-s.angle-i)-e*(n.angularVelocity-s.angularVelocity)*0;s.angularForce-=r,n.angularForce+=r}},{"../math/vec2":30,"./Spring":34}],34:[function(t,e,i){function s(t,e,i){i=n.defaults(i,{stiffness:100,damping:1}),this.stiffness=i.stiffness,this.damping=i.damping,this.bodyA=t,this.bodyB=e}t("../math/vec2");var n=t("../utils/Utils");e.exports=s,s.prototype.applyForce=function(){}},{"../math/vec2":30,"../utils/Utils":57}],35:[function(t,e,i){function s(t,e){e=e||{},this.chassisBody=t,this.wheels=[],this.groundBody=new h({mass:0}),this.world=null;var i=this;this.preStepCallback=function(){i.update()}}function n(t,e){e=e||{},this.vehicle=t,this.forwardEquation=new a(t.chassisBody,t.groundBody),this.sideEquation=new a(t.chassisBody,t.groundBody),this.steerValue=0,this.engineForce=0,this.setSideFriction(void 0!==e.sideFriction?e.sideFriction:5),this.localForwardVector=r.fromValues(0,1),e.localForwardVector&&r.copy(this.localForwardVector,e.localForwardVector),this.localPosition=r.fromValues(0,0),e.localPosition&&r.copy(this.localPosition,e.localPosition),o.apply(this,t.chassisBody,t.groundBody),this.equations.push(this.forwardEquation,this.sideEquation),this.setBrakeForce(0)}var r=t("../math/vec2"),o=(t("../utils/Utils"),t("../constraints/Constraint")),a=t("../equations/FrictionEquation"),h=t("../objects/Body");e.exports=s,s.prototype.addToWorld=function(t){this.world=t,t.addBody(this.groundBody),t.on("preStep",this.preStepCallback);for(var e=0;e<this.wheels.length;e++){var i=this.wheels[e];t.addConstraint(i)}},s.prototype.removeFromWorld=function(){var t=this.world;t.removeBody(this.groundBody),t.off("preStep",this.preStepCallback);for(var e=0;e<this.wheels.length;e++){var i=this.wheels[e];t.removeConstraint(i)}this.world=null},s.prototype.addWheel=function(t){var e=new n(this,t);return this.wheels.push(e),e},s.prototype.update=function(){for(var t=0;t<this.wheels.length;t++)this.wheels[t].update()},(n.prototype=new o).setBrakeForce=function(t){this.forwardEquation.setSlipForce(t)},n.prototype.setSideFriction=function(t){this.sideEquation.setSlipForce(t)};var l=r.create(),c=r.create();n.prototype.getSpeed=function(){return this.vehicle.chassisBody.vectorToWorldFrame(c,this.localForwardVector),this.vehicle.chassisBody.getVelocityAtPoint(l,c),r.dot(l,c)};var u=r.create();n.prototype.update=function(){this.vehicle.chassisBody.vectorToWorldFrame(this.forwardEquation.t,this.localForwardVector),r.rotate(this.sideEquation.t,this.localForwardVector,Math.PI/2),this.vehicle.chassisBody.vectorToWorldFrame(this.sideEquation.t,this.sideEquation.t),r.rotate(this.forwardEquation.t,this.forwardEquation.t,this.steerValue),r.rotate(this.sideEquation.t,this.sideEquation.t,this.steerValue),this.vehicle.chassisBody.toWorldFrame(this.forwardEquation.contactPointB,this.localPosition),r.copy(this.sideEquation.contactPointB,this.forwardEquation.contactPointB),this.vehicle.chassisBody.vectorToWorldFrame(this.forwardEquation.contactPointA,this.localPosition),r.copy(this.sideEquation.contactPointA,this.forwardEquation.contactPointA),r.normalize(u,this.forwardEquation.t),r.scale(u,u,this.engineForce),this.vehicle.chassisBody.applyForce(u,this.forwardEquation.contactPointA)}},{"../constraints/Constraint":14,"../equations/FrictionEquation":23,"../math/vec2":30,"../objects/Body":31,"../utils/Utils":57}],36:[function(t,e,i){var s=e.exports={AABB:t("./collision/AABB"),AngleLockEquation:t("./equations/AngleLockEquation"),Body:t("./objects/Body"),Broadphase:t("./collision/Broadphase"),Capsule:t("./shapes/Capsule"),Circle:t("./shapes/Circle"),Constraint:t("./constraints/Constraint"),ContactEquation:t("./equations/ContactEquation"),ContactEquationPool:t("./utils/ContactEquationPool"),ContactMaterial:t("./material/ContactMaterial"),Convex:t("./shapes/Convex"),DistanceConstraint:t("./constraints/DistanceConstraint"),Equation:t("./equations/Equation"),EventEmitter:t("./events/EventEmitter"),FrictionEquation:t("./equations/FrictionEquation"),FrictionEquationPool:t("./utils/FrictionEquationPool"),GearConstraint:t("./constraints/GearConstraint"),GSSolver:t("./solver/GSSolver"),Heightfield:t("./shapes/Heightfield"),Line:t("./shapes/Line"),LockConstraint:t("./constraints/LockConstraint"),Material:t("./material/Material"),Narrowphase:t("./collision/Narrowphase"),NaiveBroadphase:t("./collision/NaiveBroadphase"),Particle:t("./shapes/Particle"),Plane:t("./shapes/Plane"),Pool:t("./utils/Pool"),RevoluteConstraint:t("./constraints/RevoluteConstraint"),PrismaticConstraint:t("./constraints/PrismaticConstraint"),Ray:t("./collision/Ray"),RaycastResult:t("./collision/RaycastResult"),Box:t("./shapes/Box"),RotationalVelocityEquation:t("./equations/RotationalVelocityEquation"),SAPBroadphase:t("./collision/SAPBroadphase"),Shape:t("./shapes/Shape"),Solver:t("./solver/Solver"),Spring:t("./objects/Spring"),TopDownVehicle:t("./objects/TopDownVehicle"),LinearSpring:t("./objects/LinearSpring"),RotationalSpring:t("./objects/RotationalSpring"),Utils:t("./utils/Utils"),World:t("./world/World"),vec2:t("./math/vec2"),version:t("../package.json").version};Object.defineProperty(s,"Rectangle",{get:function(){return console.warn("The Rectangle class has been renamed to Box."),this.Box}})},{"../package.json":6,"./collision/AABB":7,"./collision/Broadphase":8,"./collision/NaiveBroadphase":9,"./collision/Narrowphase":10,"./collision/Ray":11,"./collision/RaycastResult":12,"./collision/SAPBroadphase":13,"./constraints/Constraint":14,"./constraints/DistanceConstraint":15,"./constraints/GearConstraint":16,"./constraints/LockConstraint":17,"./constraints/PrismaticConstraint":18,"./constraints/RevoluteConstraint":19,"./equations/AngleLockEquation":20,"./equations/ContactEquation":21,"./equations/Equation":22,"./equations/FrictionEquation":23,"./equations/RotationalVelocityEquation":25,"./events/EventEmitter":26,"./material/ContactMaterial":27,"./material/Material":28,"./math/vec2":30,"./objects/Body":31,"./objects/LinearSpring":32,"./objects/RotationalSpring":33,"./objects/Spring":34,"./objects/TopDownVehicle":35,"./shapes/Box":37,"./shapes/Capsule":38,"./shapes/Circle":39,"./shapes/Convex":40,"./shapes/Heightfield":41,"./shapes/Line":42,"./shapes/Particle":43,"./shapes/Plane":44,"./shapes/Shape":45,"./solver/GSSolver":46,"./solver/Solver":47,"./utils/ContactEquationPool":48,"./utils/FrictionEquationPool":49,"./utils/Pool":55,"./utils/Utils":57,"./world/World":61}],37:[function(t,e,i){function s(t){"number"==typeof arguments[0]&&"number"==typeof arguments[1]&&(t={width:arguments[0],height:arguments[1]},console.warn("The Rectangle has been renamed to Box and its constructor signature has changed. Please use the following format: new Box({ width: 1, height: 1, ... })")),t=t||{};var e=this.width=t.width||1,i=this.height=t.height||1,s=[n.fromValues(-e/2,-i/2),n.fromValues(e/2,-i/2),n.fromValues(e/2,i/2),n.fromValues(-e/2,i/2)],a=[n.fromValues(1,0),n.fromValues(0,1)];t.vertices=s,t.axes=a,t.type=r.BOX,o.call(this,t)}var n=t("../math/vec2"),r=t("./Shape"),o=t("./Convex");e.exports=s,(s.prototype=new o).constructor=s,s.prototype.computeMomentOfInertia=function(t){var e=this.width,i=this.height;return t*(i*i+e*e)/12},s.prototype.updateBoundingRadius=function(){var t=this.width,e=this.height;this.boundingRadius=Math.sqrt(t*t+e*e)/2};n.create(),n.create(),n.create(),n.create();s.prototype.computeAABB=function(t,e,i){t.setFromPoints(this.vertices,e,i,0)},s.prototype.updateArea=function(){this.area=this.width*this.height}},{"../math/vec2":30,"./Convex":40,"./Shape":45}],38:[function(t,e,i){function s(t){"number"==typeof arguments[0]&&"number"==typeof arguments[1]&&(t={length:arguments[0],radius:arguments[1]},console.warn("The Capsule constructor signature has changed. Please use the following format: new Capsule({ radius: 1, length: 1 })")),t=t||{},this.length=t.length||1,this.radius=t.radius||1,t.type=n.CAPSULE,n.call(this,t)}var n=t("./Shape"),r=t("../math/vec2");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.computeMomentOfInertia=function(t){var e=this.radius,i=this.length+e,s=2*e;return t*(s*s+i*i)/12},s.prototype.updateBoundingRadius=function(){this.boundingRadius=this.radius+this.length/2},s.prototype.updateArea=function(){this.area=Math.PI*this.radius*this.radius+2*this.radius*this.length};var o=r.create();s.prototype.computeAABB=function(t,e,i){var s=this.radius;r.set(o,this.length/2,0),0!==i&&r.rotate(o,o,i),r.set(t.upperBound,Math.max(o[0]+s,-o[0]+s),Math.max(o[1]+s,-o[1]+s)),r.set(t.lowerBound,Math.min(o[0]-s,-o[0]-s),Math.min(o[1]-s,-o[1]-s)),r.add(t.lowerBound,t.lowerBound,e),r.add(t.upperBound,t.upperBound,e)};var a=r.create(),h=r.create(),l=r.create(),c=r.create(),u=r.fromValues(0,1);s.prototype.raycast=function(t,e,i,s){for(var n=e.from,o=e.to,d=(e.direction,a),p=h,f=l,g=c,m=this.length/2,y=0;y<2;y++){var v=this.radius*(2*y-1);if(r.set(f,-m,v),r.set(g,m,v),r.toGlobalFrame(f,f,i,s),r.toGlobalFrame(g,g,i,s),(T=r.getLineSegmentsIntersectionFraction(n,o,f,g))>=0&&(r.rotate(p,u,s),r.scale(p,p,2*y-1),e.reportIntersection(t,T,p,-1),t.shouldStop(e)))return}for(var x=Math.pow(this.radius,2)+Math.pow(m,2),y=0;y<2;y++){r.set(f,m*(2*y-1),0),r.toGlobalFrame(f,f,i,s);var b=Math.pow(o[0]-n[0],2)+Math.pow(o[1]-n[1],2),_=2*((o[0]-n[0])*(n[0]-f[0])+(o[1]-n[1])*(n[1]-f[1])),w=Math.pow(n[0]-f[0],2)+Math.pow(n[1]-f[1],2)-Math.pow(this.radius,2),T=Math.pow(_,2)-4*b*w;if(!(T<0))if(0===T){if(r.lerp(d,n,o,T),r.squaredDistance(d,i)>x&&(r.sub(p,d,f),r.normalize(p,p),e.reportIntersection(t,T,p,-1),t.shouldStop(e)))return}else{var P=Math.sqrt(T),C=1/(2*b),S=(-_-P)*C,A=(-_+P)*C;if(S>=0&&S<=1&&(r.lerp(d,n,o,S),r.squaredDistance(d,i)>x&&(r.sub(p,d,f),r.normalize(p,p),e.reportIntersection(t,S,p,-1),t.shouldStop(e))))return;if(A>=0&&A<=1&&(r.lerp(d,n,o,A),r.squaredDistance(d,i)>x&&(r.sub(p,d,f),r.normalize(p,p),e.reportIntersection(t,A,p,-1),t.shouldStop(e))))return}}}},{"../math/vec2":30,"./Shape":45}],39:[function(t,e,i){function s(t){"number"==typeof arguments[0]&&(t={radius:arguments[0]},console.warn("The Circle constructor signature has changed. Please use the following format: new Circle({ radius: 1 })")),t=t||{},this.radius=t.radius||1,t.type=n.CIRCLE,n.call(this,t)}var n=t("./Shape"),r=t("../math/vec2");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.computeMomentOfInertia=function(t){var e=this.radius;return t*e*e/2},s.prototype.updateBoundingRadius=function(){this.boundingRadius=this.radius},s.prototype.updateArea=function(){this.area=Math.PI*this.radius*this.radius},s.prototype.computeAABB=function(t,e,i){var s=this.radius;r.set(t.upperBound,s,s),r.set(t.lowerBound,-s,-s),e&&(r.add(t.lowerBound,t.lowerBound,e),r.add(t.upperBound,t.upperBound,e))};var o=r.create(),a=r.create();s.prototype.raycast=function(t,e,i,s){var n=e.from,h=e.to,l=this.radius,c=Math.pow(h[0]-n[0],2)+Math.pow(h[1]-n[1],2),u=2*((h[0]-n[0])*(n[0]-i[0])+(h[1]-n[1])*(n[1]-i[1])),d=Math.pow(n[0]-i[0],2)+Math.pow(n[1]-i[1],2)-Math.pow(l,2),p=Math.pow(u,2)-4*c*d,f=o,g=a;if(!(p<0))if(0===p)r.lerp(f,n,h,p),r.sub(g,f,i),r.normalize(g,g),e.reportIntersection(t,p,g,-1);else{var m=Math.sqrt(p),y=1/(2*c),v=(-u-m)*y,x=(-u+m)*y;if(v>=0&&v<=1&&(r.lerp(f,n,h,v),r.sub(g,f,i),r.normalize(g,g),e.reportIntersection(t,v,g,-1),t.shouldStop(e)))return;x>=0&&x<=1&&(r.lerp(f,n,h,x),r.sub(g,f,i),r.normalize(g,g),e.reportIntersection(t,x,g,-1))}}},{"../math/vec2":30,"./Shape":45}],40:[function(t,e,i){function s(t){Array.isArray(arguments[0])&&(t={vertices:arguments[0],axes:arguments[1]},console.warn("The Convex constructor signature has changed. Please use the following format: new Convex({ vertices: [...], ... })")),t=t||{},this.vertices=[];for(var e=void 0!==t.vertices?t.vertices:[],i=0;i<e.length;i++){var s=r.create();r.copy(s,e[i]),this.vertices.push(s)}if(this.axes=[],t.axes)for(i=0;i<t.axes.length;i++){var o=r.create();r.copy(o,t.axes[i]),this.axes.push(o)}else for(i=0;i<this.vertices.length;i++){var a=this.vertices[i],h=this.vertices[(i+1)%this.vertices.length],l=r.create();r.sub(l,h,a),r.rotate90cw(l,l),r.normalize(l,l),this.axes.push(l)}if(this.centerOfMass=r.fromValues(0,0),this.triangles=[],this.vertices.length&&(this.updateTriangles(),this.updateCenterOfMass()),this.boundingRadius=0,t.type=n.CONVEX,n.call(this,t),this.updateBoundingRadius(),this.updateArea(),this.area<0)throw new Error("Convex vertices must be given in conter-clockwise winding.")}var n=t("./Shape"),r=t("../math/vec2"),o=t("../math/polyk");t("poly-decomp");e.exports=s,(s.prototype=new n).constructor=s;var a=r.create(),h=r.create();s.prototype.projectOntoLocalAxis=function(t,e){for(var i,s,n=null,o=null,t=a,h=0;h<this.vertices.length;h++)i=this.vertices[h],s=r.dot(i,t),(null===n||s>n)&&(n=s),(null===o||s<o)&&(o=s);if(o>n){var l=o;o=n,n=l}r.set(e,o,n)},s.prototype.projectOntoWorldAxis=function(t,e,i,s){var n=h;this.projectOntoLocalAxis(t,s),0!==i?r.rotate(n,t,i):n=t;var o=r.dot(e,n);r.set(s,s[0]+o,s[1]+o)},s.prototype.updateTriangles=function(){this.triangles.length=0;for(var t=[],e=0;e<this.vertices.length;e++){var i=this.vertices[e];t.push(i[0],i[1])}for(var s=o.Triangulate(t),e=0;e<s.length;e+=3){var n=s[e],r=s[e+1],a=s[e+2];this.triangles.push([n,r,a])}};var l=r.create(),c=r.create(),u=r.create(),d=r.create(),p=r.create();r.create(),r.create(),r.create(),r.create();s.prototype.updateCenterOfMass=function(){var t=this.triangles,e=this.vertices,i=this.centerOfMass,n=l,o=u,a=d,h=p,f=c;r.set(i,0,0);for(var g=0,m=0;m!==t.length;m++){var y=t[m],o=e[y[0]],a=e[y[1]],h=e[y[2]];r.centroid(n,o,a,h);var v=s.triangleArea(o,a,h);g+=v,r.scale(f,n,v),r.add(i,i,f)}r.scale(i,i,1/g)},s.prototype.computeMomentOfInertia=function(t){for(var e=0,i=0,s=this.vertices.length,n=s-1,o=0;o<s;n=o,o++){var a=this.vertices[n],h=this.vertices[o],l=Math.abs(r.crossLength(a,h));e+=l*(r.dot(h,h)+r.dot(h,a)+r.dot(a,a)),i+=l}return t/6*(e/i)},s.prototype.updateBoundingRadius=function(){for(var t=this.vertices,e=0,i=0;i!==t.length;i++){var s=r.squaredLength(t[i]);s>e&&(e=s)}this.boundingRadius=Math.sqrt(e)},s.triangleArea=function(t,e,i){return.5*((e[0]-t[0])*(i[1]-t[1])-(i[0]-t[0])*(e[1]-t[1]))},s.prototype.updateArea=function(){this.updateTriangles(),this.area=0;for(var t=this.triangles,e=this.vertices,i=0;i!==t.length;i++){var n=t[i],r=e[n[0]],o=e[n[1]],a=e[n[2]],h=s.triangleArea(r,o,a);this.area+=h}},s.prototype.computeAABB=function(t,e,i){t.setFromPoints(this.vertices,e,i,0)};var f=r.create(),g=r.create(),m=r.create();s.prototype.raycast=function(t,e,i,s){var n=f,o=g,a=m,h=this.vertices;r.toLocalFrame(n,e.from,i,s),r.toLocalFrame(o,e.to,i,s);for(var l=h.length,c=0;c<l&&!t.shouldStop(e);c++){var u=h[c],d=h[(c+1)%l],p=r.getLineSegmentsIntersectionFraction(n,o,u,d);p>=0&&(r.sub(a,d,u),r.rotate(a,a,-Math.PI/2+s),r.normalize(a,a),e.reportIntersection(t,p,a,c))}}},{"../math/polyk":29,"../math/vec2":30,"./Shape":45,"poly-decomp":5}],41:[function(t,e,i){function s(t){if(Array.isArray(arguments[0])){if(t={heights:arguments[0]},"object"==typeof arguments[1])for(var e in arguments[1])t[e]=arguments[1][e];console.warn("The Heightfield constructor signature has changed. Please use the following format: new Heightfield({ heights: [...], ... })")}t=t||{},this.heights=t.heights?t.heights.slice(0):[],this.maxValue=t.maxValue||null,this.minValue=t.minValue||null,this.elementWidth=t.elementWidth||.1,void 0!==t.maxValue&&void 0!==t.minValue||this.updateMaxMinValues(),t.type=n.HEIGHTFIELD,n.call(this,t)}var n=t("./Shape"),r=t("../math/vec2");t("../utils/Utils");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.updateMaxMinValues=function(){for(var t=this.heights,e=t[0],i=t[0],s=0;s!==t.length;s++){var n=t[s];n>e&&(e=n),n<i&&(i=n)}this.maxValue=e,this.minValue=i},s.prototype.computeMomentOfInertia=function(t){return Number.MAX_VALUE},s.prototype.updateBoundingRadius=function(){this.boundingRadius=Number.MAX_VALUE},s.prototype.updateArea=function(){for(var t=this.heights,e=0,i=0;i<t.length-1;i++)e+=(t[i]+t[i+1])/2*this.elementWidth;this.area=e};var o=[r.create(),r.create(),r.create(),r.create()];s.prototype.computeAABB=function(t,e,i){r.set(o[0],0,this.maxValue),r.set(o[1],this.elementWidth*this.heights.length,this.maxValue),r.set(o[2],this.elementWidth*this.heights.length,this.minValue),r.set(o[3],0,this.minValue),t.setFromPoints(o,e,i)},s.prototype.getLineSegment=function(t,e,i){var s=this.heights,n=this.elementWidth;r.set(t,i*n,s[i]),r.set(e,(i+1)*n,s[i+1])},s.prototype.getSegmentIndex=function(t){return Math.floor(t[0]/this.elementWidth)},s.prototype.getClampedSegmentIndex=function(t){var e=this.getSegmentIndex(t);return e=Math.min(this.heights.length,Math.max(e,0))};r.create();var a=r.create(),h=r.create(),l=r.create(),c=r.create(),u=r.create();r.fromValues(0,1);s.prototype.raycast=function(t,e,i,s){var n=e.from,o=e.to,d=(e.direction,a),p=h,f=l,g=c,m=u;r.toLocalFrame(g,n,i,s),r.toLocalFrame(m,o,i,s);var y=this.getClampedSegmentIndex(g),v=this.getClampedSegmentIndex(m);if(y>v){var x=y;y=v,v=x}for(var b=0;b<this.heights.length-1;b++){this.getLineSegment(p,f,b);var _=r.getLineSegmentsIntersectionFraction(g,m,p,f);if(_>=0&&(r.sub(d,f,p),r.rotate(d,d,s+Math.PI/2),r.normalize(d,d),e.reportIntersection(t,_,d,-1),t.shouldStop(e)))return}}},{"../math/vec2":30,"../utils/Utils":57,"./Shape":45}],42:[function(t,e,i){function s(t){"number"==typeof arguments[0]&&(t={length:arguments[0]},console.warn("The Line constructor signature has changed. Please use the following format: new Line({ length: 1, ... })")),t=t||{},this.length=t.length||1,t.type=n.LINE,n.call(this,t)}var n=t("./Shape"),r=t("../math/vec2");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.computeMomentOfInertia=function(t){return t*Math.pow(this.length,2)/12},s.prototype.updateBoundingRadius=function(){this.boundingRadius=this.length/2};var o=[r.create(),r.create()];s.prototype.computeAABB=function(t,e,i){var s=this.length/2;r.set(o[0],-s,0),r.set(o[1],s,0),t.setFromPoints(o,e,i,0)};r.create();var a=r.create(),h=r.create(),l=r.create(),c=r.fromValues(0,1);s.prototype.raycast=function(t,e,i,s){var n=e.from,o=e.to,u=h,d=l,p=this.length/2;r.set(u,-p,0),r.set(d,p,0),r.toGlobalFrame(u,u,i,s),r.toGlobalFrame(d,d,i,s);var f=r.getLineSegmentsIntersectionFraction(u,d,n,o);if(f>=0){var g=a;r.rotate(g,c,s),e.reportIntersection(t,f,g,-1)}}},{"../math/vec2":30,"./Shape":45}],43:[function(t,e,i){function s(t){(t=t||{}).type=n.PARTICLE,n.call(this,t)}var n=t("./Shape"),r=t("../math/vec2");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.computeMomentOfInertia=function(t){return 0},s.prototype.updateBoundingRadius=function(){this.boundingRadius=0},s.prototype.computeAABB=function(t,e,i){r.copy(t.lowerBound,e),r.copy(t.upperBound,e)}},{"../math/vec2":30,"./Shape":45}],44:[function(t,e,i){function s(t){(t=t||{}).type=n.PLANE,n.call(this,t)}var n=t("./Shape"),r=t("../math/vec2");t("../utils/Utils");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.computeMomentOfInertia=function(t){return 0},s.prototype.updateBoundingRadius=function(){this.boundingRadius=Number.MAX_VALUE},s.prototype.computeAABB=function(t,e,i){var s=i%(2*Math.PI),n=r.set,o=t.lowerBound,a=t.upperBound;n(o,-1e7,-1e7),n(a,1e7,1e7),0===s?a[1]=0:s===Math.PI/2?o[0]=0:s===Math.PI?o[1]=0:s===3*Math.PI/2&&(a[0]=0)},s.prototype.updateArea=function(){this.area=Number.MAX_VALUE};var o=r.create(),a=(r.create(),r.create(),r.create()),h=r.create();s.prototype.raycast=function(t,e,i,s){var n=e.from,l=e.to,c=e.direction,u=o,d=a,p=h;r.set(d,0,1),r.rotate(d,d,s),r.sub(p,n,i);var f=r.dot(p,d);if(r.sub(p,l,i),!(f*r.dot(p,d)>0||r.squaredDistance(n,l)<f*f)){var g=r.dot(d,c);r.sub(u,n,i);var m=-r.dot(d,u)/g/e.length;e.reportIntersection(t,m,d,-1)}}},{"../math/vec2":30,"../utils/Utils":57,"./Shape":45}],45:[function(t,e,i){function s(t){t=t||{},this.body=null,this.position=n.fromValues(0,0),t.position&&n.copy(this.position,t.position),this.angle=t.angle||0,this.type=t.type||0,this.id=s.idCounter++,this.boundingRadius=0,this.collisionGroup=void 0!==t.collisionGroup?t.collisionGroup:1,this.collisionResponse=void 0===t.collisionResponse||t.collisionResponse,this.collisionMask=void 0!==t.collisionMask?t.collisionMask:1,this.material=t.material||null,this.area=0,this.sensor=void 0!==t.sensor&&t.sensor,this.type&&this.updateBoundingRadius(),this.updateArea()}e.exports=s;var n=t("../math/vec2");s.idCounter=0,s.CIRCLE=1,s.PARTICLE=2,s.PLANE=4,s.CONVEX=8,s.LINE=16,s.BOX=32,s.CAPSULE=64,s.HEIGHTFIELD=128,s.prototype.computeMomentOfInertia=function(t){},s.prototype.updateBoundingRadius=function(){},s.prototype.updateArea=function(){},s.prototype.computeAABB=function(t,e,i){},s.prototype.raycast=function(t,e,i,s){}},{"../math/vec2":30}],46:[function(t,e,i){function s(t){o.call(this,t,o.GS),t=t||{},this.iterations=t.iterations||10,this.tolerance=t.tolerance||1e-7,this.arrayStep=30,this.lambda=new a.ARRAY_TYPE(this.arrayStep),this.Bs=new a.ARRAY_TYPE(this.arrayStep),this.invCs=new a.ARRAY_TYPE(this.arrayStep),this.useZeroRHS=!1,this.frictionIterations=void 0!==t.frictionIterations?0:t.frictionIterations,this.usedIterations=0}function n(t){for(var e=t.length;e--;)t[e]=0}var r=t("../math/vec2"),o=t("./Solver"),a=t("../utils/Utils"),h=t("../equations/FrictionEquation");e.exports=s,(s.prototype=new o).constructor=s,s.prototype.solve=function(t,e){this.sortEquations();var i=0,o=this.iterations,l=this.frictionIterations,c=this.equations,u=c.length,d=Math.pow(this.tolerance*u,2),p=e.bodies,f=e.bodies.length,g=(r.add,r.set,this.useZeroRHS),m=this.lambda;if(this.usedIterations=0,u)for(x=0;x!==f;x++)(T=p[x]).updateSolveMassProperties();m.length<u&&(m=this.lambda=new a.ARRAY_TYPE(u+this.arrayStep),this.Bs=new a.ARRAY_TYPE(u+this.arrayStep),this.invCs=new a.ARRAY_TYPE(u+this.arrayStep)),n(m);for(var y=this.invCs,v=this.Bs,m=this.lambda,x=0;x!==c.length;x++)((b=c[x]).timeStep!==t||b.needsUpdate)&&(b.timeStep=t,b.update()),v[x]=b.computeB(b.a,b.b,t),y[x]=b.computeInvC(b.epsilon);var b,_,w;if(0!==u){for(x=0;x!==f;x++){var T=p[x];T.resetConstraintVelocity()}if(l){for(i=0;i!==l;i++){for(_=0,w=0;w!==u;w++){b=c[w];A=s.iterateEquation(w,b,b.epsilon,v,y,m,g,t,i);_+=Math.abs(A)}if(this.usedIterations++,_*_<=d)break}for(s.updateMultipliers(c,m,1/t),w=0;w!==u;w++){var P=c[w];if(P instanceof h){for(var C=0,S=0;S!==P.contactEquations.length;S++)C+=P.contactEquations[S].multiplier;C*=P.frictionCoefficient/P.contactEquations.length,P.maxForce=C,P.minForce=-C}}}for(i=0;i!==o;i++){for(_=0,w=0;w!==u;w++){b=c[w];var A=s.iterateEquation(w,b,b.epsilon,v,y,m,g,t,i);_+=Math.abs(A)}if(this.usedIterations++,_*_<=d)break}for(x=0;x!==f;x++)p[x].addConstraintVelocity();s.updateMultipliers(c,m,1/t)}},s.updateMultipliers=function(t,e,i){for(var s=t.length;s--;)t[s].multiplier=e[s]*i},s.iterateEquation=function(t,e,i,s,n,r,o,a,h){var l=s[t],c=n[t],u=r[t],d=e.computeGWlambda(),p=e.maxForce,f=e.minForce;o&&(l=0);var g=c*(l-d-i*u),m=u+g;return m<f*a?g=f*a-u:m>p*a&&(g=p*a-u),r[t]+=g,e.addToWlambda(g),g}},{"../equations/FrictionEquation":23,"../math/vec2":30,"../utils/Utils":57,"./Solver":47}],47:[function(t,e,i){function s(t,e){t=t||{},n.call(this),this.type=e,this.equations=[],this.equationSortFunction=t.equationSortFunction||!1}t("../utils/Utils");var n=t("../events/EventEmitter");e.exports=s,(s.prototype=new n).constructor=s,s.prototype.solve=function(t,e){throw new Error("Solver.solve should be implemented by subclasses!")};var r={bodies:[]};s.prototype.solveIsland=function(t,e){this.removeAllEquations(),e.equations.length&&(this.addEquations(e.equations),r.bodies.length=0,e.getBodies(r.bodies),r.bodies.length&&this.solve(t,r))},s.prototype.sortEquations=function(){this.equationSortFunction&&this.equations.sort(this.equationSortFunction)},s.prototype.addEquation=function(t){t.enabled&&this.equations.push(t)},s.prototype.addEquations=function(t){for(var e=0,i=t.length;e!==i;e++){var s=t[e];s.enabled&&this.equations.push(s)}},s.prototype.removeEquation=function(t){var e=this.equations.indexOf(t);-1!==e&&this.equations.splice(e,1)},s.prototype.removeAllEquations=function(){this.equations.length=0},s.GS=1,s.ISLAND=2},{"../events/EventEmitter":26,"../utils/Utils":57}],48:[function(t,e,i){function s(){r.apply(this,arguments)}var n=t("../equations/ContactEquation"),r=t("./Pool");e.exports=s,(s.prototype=new r).constructor=s,s.prototype.create=function(){return new n},s.prototype.destroy=function(t){return t.bodyA=t.bodyB=null,this}},{"../equations/ContactEquation":21,"./Pool":55}],49:[function(t,e,i){function s(){r.apply(this,arguments)}var n=t("../equations/FrictionEquation"),r=t("./Pool");e.exports=s,(s.prototype=new r).constructor=s,s.prototype.create=function(){return new n},s.prototype.destroy=function(t){return t.bodyA=t.bodyB=null,this}},{"../equations/FrictionEquation":23,"./Pool":55}],50:[function(t,e,i){function s(){r.apply(this,arguments)}var n=t("../world/IslandNode"),r=t("./Pool");e.exports=s,(s.prototype=new r).constructor=s,s.prototype.create=function(){return new n},s.prototype.destroy=function(t){return t.reset(),this}},{"../world/IslandNode":60,"./Pool":55}],51:[function(t,e,i){function s(){r.apply(this,arguments)}var n=t("../world/Island"),r=t("./Pool");e.exports=s,(s.prototype=new r).constructor=s,s.prototype.create=function(){return new n},s.prototype.destroy=function(t){return t.reset(),this}},{"../world/Island":58,"./Pool":55}],52:[function(t,e,i){function s(){this.overlappingShapesLastState=new n,this.overlappingShapesCurrentState=new n,this.recordPool=new r({size:16}),this.tmpDict=new n,this.tmpArray1=[]}var n=t("./TupleDictionary"),r=(t("./OverlapKeeperRecord"),t("./OverlapKeeperRecordPool"));t("./Utils");e.exports=s,s.prototype.tick=function(){for(var t=this.overlappingShapesLastState,e=this.overlappingShapesCurrentState,i=t.keys.length;i--;){var s=t.keys[i],n=t.getByKey(s);e.getByKey(s);n&&this.recordPool.release(n)}t.reset(),t.copy(e),e.reset()},s.prototype.setOverlapping=function(t,e,i,s){this.overlappingShapesLastState;var n=this.overlappingShapesCurrentState;if(!n.get(e.id,s.id)){var r=this.recordPool.get();r.set(t,e,i,s),n.set(e.id,s.id,r)}},s.prototype.getNewOverlaps=function(t){return this.getDiff(this.overlappingShapesLastState,this.overlappingShapesCurrentState,t)},s.prototype.getEndOverlaps=function(t){return this.getDiff(this.overlappingShapesCurrentState,this.overlappingShapesLastState,t)},s.prototype.bodiesAreOverlapping=function(t,e){for(var i=this.overlappingShapesCurrentState,s=i.keys.length;s--;){var n=i.keys[s],r=i.data[n];if(r.bodyA===t&&r.bodyB===e||r.bodyA===e&&r.bodyB===t)return!0}return!1},s.prototype.getDiff=function(t,e,i){var s=t,n=e;(i=i||[]).length=0;for(var r=n.keys.length;r--;){var o=n.keys[r],a=n.data[o];if(!a)throw new Error("Key "+o+" had no data!");s.data[o]||i.push(a)}return i},s.prototype.isNewOverlap=function(t,e){var i=0|t.id,s=0|e.id,n=this.overlappingShapesLastState,r=this.overlappingShapesCurrentState;return!n.get(i,s)&&!!r.get(i,s)},s.prototype.getNewBodyOverlaps=function(t){this.tmpArray1.length=0;var e=this.getNewOverlaps(this.tmpArray1);return this.getBodyDiff(e,t)},s.prototype.getEndBodyOverlaps=function(t){this.tmpArray1.length=0;var e=this.getEndOverlaps(this.tmpArray1);return this.getBodyDiff(e,t)},s.prototype.getBodyDiff=function(t,e){e=e||[];for(var i=this.tmpDict,s=t.length;s--;){var n=t[s];i.set(0|n.bodyA.id,0|n.bodyB.id,n)}for(s=i.keys.length;s--;)(n=i.getByKey(i.keys[s]))&&e.push(n.bodyA,n.bodyB);return i.reset(),e}},{"./OverlapKeeperRecord":53,"./OverlapKeeperRecordPool":54,"./TupleDictionary":56,"./Utils":57}],53:[function(t,e,i){function s(t,e,i,s){this.shapeA=e,this.shapeB=s,this.bodyA=t,this.bodyB=i}e.exports=s,s.prototype.set=function(t,e,i,n){s.call(this,t,e,i,n)}},{}],54:[function(t,e,i){function s(){r.apply(this,arguments)}var n=t("./OverlapKeeperRecord"),r=t("./Pool");e.exports=s,(s.prototype=new r).constructor=s,s.prototype.create=function(){return new n},s.prototype.destroy=function(t){return t.bodyA=t.bodyB=t.shapeA=t.shapeB=null,this}},{"./OverlapKeeperRecord":53,"./Pool":55}],55:[function(t,e,i){function s(t){t=t||{},this.objects=[],void 0!==t.size&&this.resize(t.size)}e.exports=s,s.prototype.resize=function(t){for(var e=this.objects;e.length>t;)e.pop();for(;e.length<t;)e.push(this.create());return this},s.prototype.get=function(){var t=this.objects;return t.length?t.pop():this.create()},s.prototype.release=function(t){return this.destroy(t),this.objects.push(t),this}},{}],56:[function(t,e,i){function s(){this.data={},this.keys=[]}var n=t("./Utils");e.exports=s,s.prototype.getKey=function(t,e){return t|=0,e|=0,(0|t)==(0|e)?-1:0|((0|t)>(0|e)?t<<16|65535&e:e<<16|65535&t)},s.prototype.getByKey=function(t){return t|=0,this.data[t]},s.prototype.get=function(t,e){return this.data[this.getKey(t,e)]},s.prototype.set=function(t,e,i){if(!i)throw new Error("No data!");var s=this.getKey(t,e);return this.data[s]||this.keys.push(s),this.data[s]=i,s},s.prototype.reset=function(){for(var t=this.data,e=this.keys,i=e.length;i--;)delete t[e[i]];e.length=0},s.prototype.copy=function(t){this.reset(),n.appendArray(this.keys,t.keys);for(var e=t.keys.length;e--;){var i=t.keys[e];this.data[i]=t.data[i]}}},{"./Utils":57}],57:[function(t,e,i){function s(){}e.exports=s,s.appendArray=function(t,e){if(e.length<15e4)t.push.apply(t,e);else for(var i=0,s=e.length;i!==s;++i)t.push(e[i])},s.splice=function(t,e,i){i=i||1;for(var s=e,n=t.length-i;s<n;s++)t[s]=t[s+i];t.length=n},s.ARRAY_TYPE="undefined"!=typeof P2_ARRAY_TYPE?P2_ARRAY_TYPE:"undefined"!=typeof Float32Array?Float32Array:Array,s.extend=function(t,e){for(var i in e)t[i]=e[i]},s.defaults=function(t,e){t=t||{};for(var i in e)i in t||(t[i]=e[i]);return t}},{}],58:[function(t,e,i){function s(){this.equations=[],this.bodies=[]}var n=t("../objects/Body");e.exports=s,s.prototype.reset=function(){this.equations.length=this.bodies.length=0};var r=[];s.prototype.getBodies=function(t){var e=t||[],i=this.equations;r.length=0;for(var s=0;s!==i.length;s++){var n=i[s];-1===r.indexOf(n.bodyA.id)&&(e.push(n.bodyA),r.push(n.bodyA.id)),-1===r.indexOf(n.bodyB.id)&&(e.push(n.bodyB),r.push(n.bodyB.id))}return e},s.prototype.wantsToSleep=function(){for(var t=0;t<this.bodies.length;t++){var e=this.bodies[t];if(e.type===n.DYNAMIC&&!e.wantsToSleep)return!1}return!0},s.prototype.sleep=function(){for(var t=0;t<this.bodies.length;t++)this.bodies[t].sleep();return!0}},{"../objects/Body":31}],59:[function(t,e,i){function s(t){this.nodePool=new n({size:16}),this.islandPool=new r({size:8}),this.equations=[],this.islands=[],this.nodes=[],this.queue=[]}t("../math/vec2"),t("./Island"),t("./IslandNode");var n=t("./../utils/IslandNodePool"),r=t("./../utils/IslandPool"),o=t("../objects/Body");e.exports=s,s.getUnvisitedNode=function(t){for(var e=t.length,i=0;i!==e;i++){var s=t[i];if(!s.visited&&s.body.type===o.DYNAMIC)return s}return!1},s.prototype.visit=function(t,e,i){e.push(t.body);for(var s=t.equations.length,n=0;n!==s;n++){var r=t.equations[n];-1===i.indexOf(r)&&i.push(r)}},s.prototype.bfs=function(t,e,i){var n=this.queue;for(n.length=0,n.push(t),t.visited=!0,this.visit(t,e,i);n.length;)for(var r,a=n.pop();r=s.getUnvisitedNode(a.neighbors);)r.visited=!0,this.visit(r,e,i),r.body.type===o.DYNAMIC&&n.push(r)},s.prototype.split=function(t){for(var e=t.bodies,i=this.nodes,n=this.equations;i.length;)this.nodePool.release(i.pop());for(h=0;h!==e.length;h++){var r=this.nodePool.get();r.body=e[h],i.push(r)}for(var o=0;o!==n.length;o++){var a=n[o],h=e.indexOf(a.bodyA),l=e.indexOf(a.bodyB),c=i[h],u=i[l];c.neighbors.push(u),u.neighbors.push(c),c.equations.push(a),u.equations.push(a)}for(var d=this.islands,h=0;h<d.length;h++)this.islandPool.release(d[h]);d.length=0;for(var p;p=s.getUnvisitedNode(i);){var f=this.islandPool.get();this.bfs(p,f.bodies,f.equations),d.push(f)}return d}},{"../math/vec2":30,"../objects/Body":31,"./../utils/IslandNodePool":50,"./../utils/IslandPool":51,"./Island":58,"./IslandNode":60}],60:[function(t,e,i){function s(t){this.body=t,this.neighbors=[],this.equations=[],this.visited=!1}e.exports=s,s.prototype.reset=function(){this.equations.length=0,this.neighbors.length=0,this.visited=!1,this.body=null}},{}],61:[function(t,e,i){function s(t){u.apply(this),t=t||{},this.springs=[],this.bodies=[],this.disabledBodyCollisionPairs=[],this.solver=t.solver||new n,this.narrowphase=new y(this),this.islandManager=new b,this.gravity=r.fromValues(0,-9.78),t.gravity&&r.copy(this.gravity,t.gravity),this.frictionGravity=r.length(this.gravity)||10,this.useWorldGravityAsFrictionGravity=!0,this.useFrictionGravityOnZeroGravity=!0,this.broadphase=t.broadphase||new m,this.broadphase.setWorld(this),this.constraints=[],this.defaultMaterial=new p,this.defaultContactMaterial=new f(this.defaultMaterial,this.defaultMaterial),this.lastTimeStep=1/60,this.applySpringForces=!0,this.applyDamping=!0,this.applyGravity=!0,this.solveConstraints=!0,this.contactMaterials=[],this.time=0,this.accumulator=0,this.stepping=!1,this.bodiesToBeRemoved=[],this.islandSplit=void 0===t.islandSplit||!!t.islandSplit,this.emitImpactEvent=!0,this._constraintIdCounter=0,this._bodyIdCounter=0,this.postStepEvent={type:"postStep"},this.addBodyEvent={type:"addBody",body:null},this.removeBodyEvent={type:"removeBody",body:null},this.addSpringEvent={type:"addSpring",spring:null},this.impactEvent={type:"impact",bodyA:null,bodyB:null,shapeA:null,shapeB:null,contactEquation:null},this.postBroadphaseEvent={type:"postBroadphase",pairs:null},this.sleepMode=s.NO_SLEEPING,this.beginContactEvent={type:"beginContact",shapeA:null,shapeB:null,bodyA:null,bodyB:null,contactEquations:[]},this.endContactEvent={type:"endContact",shapeA:null,shapeB:null,bodyA:null,bodyB:null},this.preSolveEvent={type:"preSolve",contactEquations:null,frictionEquations:null},this.overlappingShapesLastState={keys:[]},this.overlappingShapesCurrentState={keys:[]},this.overlapKeeper=new x}var n=t("../solver/GSSolver"),r=(t("../solver/Solver"),t("../collision/Ray"),t("../math/vec2")),o=t("../shapes/Circle"),a=t("../shapes/Convex"),h=(t("../shapes/Line"),t("../shapes/Plane")),l=t("../shapes/Capsule"),c=t("../shapes/Particle"),u=t("../events/EventEmitter"),d=t("../objects/Body"),p=(t("../shapes/Shape"),t("../objects/LinearSpring"),t("../material/Material")),f=t("../material/ContactMaterial"),g=(t("../constraints/DistanceConstraint"),t("../constraints/Constraint"),t("../constraints/LockConstraint"),t("../constraints/RevoluteConstraint"),t("../constraints/PrismaticConstraint"),t("../constraints/GearConstraint"),t("../../package.json"),t("../collision/Broadphase"),t("../collision/AABB")),m=t("../collision/SAPBroadphase"),y=t("../collision/Narrowphase"),v=t("../utils/Utils"),x=t("../utils/OverlapKeeper"),b=t("./IslandManager");t("../objects/RotationalSpring");e.exports=s,s.prototype=new Object(u.prototype),s.prototype.constructor=s,s.NO_SLEEPING=1,s.BODY_SLEEPING=2,s.ISLAND_SLEEPING=4,s.prototype.addConstraint=function(t){this.constraints.push(t)},s.prototype.addContactMaterial=function(t){this.contactMaterials.push(t)},s.prototype.removeContactMaterial=function(t){var e=this.contactMaterials.indexOf(t);-1!==e&&v.splice(this.contactMaterials,e,1)},s.prototype.getContactMaterial=function(t,e){for(var i=this.contactMaterials,s=0,n=i.length;s!==n;s++){var r=i[s];if(r.materialA.id===t.id&&r.materialB.id===e.id||r.materialA.id===e.id&&r.materialB.id===t.id)return r}return!1},s.prototype.removeConstraint=function(t){var e=this.constraints.indexOf(t);-1!==e&&v.splice(this.constraints,e,1)};r.create(),r.create(),r.create(),r.create(),r.create(),r.create();var _=r.create(),w=r.fromValues(0,0),T=r.fromValues(0,0);r.fromValues(0,0),r.fromValues(0,0);s.prototype.step=function(t,e,i){if(i=i||10,0===(e=e||0))this.internalStep(t),this.time+=t;else{this.accumulator+=e;for(var s=0;this.accumulator>=t&&s<i;)this.internalStep(t),this.time+=t,this.accumulator-=t,s++;for(var n=this.accumulator%t/t,o=0;o!==this.bodies.length;o++){var a=this.bodies[o];r.lerp(a.interpolatedPosition,a.previousPosition,a.position,n),a.interpolatedAngle=a.previousAngle+n*(a.angle-a.previousAngle)}}};var P=[];s.prototype.internalStep=function(t){this.stepping=!0;var e=this.springs.length,i=this.springs,n=this.bodies,o=this.gravity,a=this.solver,h=this.bodies.length,l=this.broadphase,c=this.narrowphase,u=this.constraints,p=_,f=(r.scale,r.add),g=(r.rotate,this.islandManager);if(this.overlapKeeper.tick(),this.lastTimeStep=t,this.useWorldGravityAsFrictionGravity){var m=r.length(this.gravity);0===m&&this.useFrictionGravityOnZeroGravity||(this.frictionGravity=m)}if(this.applyGravity)for(T=0;T!==h;T++){var y=(x=n[T]).force;x.type===d.DYNAMIC&&x.sleepState!==d.SLEEPING&&(r.scale(p,o,x.mass*x.gravityScale),f(y,y,p))}if(this.applySpringForces)for(T=0;T!==e;T++)i[T].applyForce();if(this.applyDamping)for(T=0;T!==h;T++){var x=n[T];x.type===d.DYNAMIC&&x.applyDamping(t)}for(var b=l.getCollisionPairs(this),w=this.disabledBodyCollisionPairs,T=w.length-2;T>=0;T-=2)for(S=b.length-2;S>=0;S-=2)(w[T]===b[S]&&w[T+1]===b[S+1]||w[T+1]===b[S]&&w[T]===b[S+1])&&b.splice(S,2);H=u.length;for(T=0;T!==H;T++){var C=u[T];if(!C.collideConnected)for(var S=b.length-2;S>=0;S-=2)(C.bodyA===b[S]&&C.bodyB===b[S+1]||C.bodyB===b[S]&&C.bodyA===b[S+1])&&b.splice(S,2)}this.postBroadphaseEvent.pairs=b,this.emit(this.postBroadphaseEvent),this.postBroadphaseEvent.pairs=null,c.reset(this);for(var T=0,A=b.length;T!==A;T+=2)for(var E=b[T],M=b[T+1],R=0,L=E.shapes.length;R!==L;R++)for(var B=E.shapes[R],I=B.position,O=B.angle,k=0,F=M.shapes.length;k!==F;k++){var D=M.shapes[k],U=D.position,G=D.angle,N=this.defaultContactMaterial;if(B.material&&D.material){var X=this.getContactMaterial(B.material,D.material);X&&(N=X)}this.runNarrowphase(c,E,B,I,O,M,D,U,G,N,this.frictionGravity)}for(T=0;T!==h;T++)(q=n[T])._wakeUpAfterNarrowphase&&(q.wakeUp(),q._wakeUpAfterNarrowphase=!1);if(this.has("endContact")){this.overlapKeeper.getEndOverlaps(P);for(var W=this.endContactEvent,k=P.length;k--;){var j=P[k];W.shapeA=j.shapeA,W.shapeB=j.shapeB,W.bodyA=j.bodyA,W.bodyB=j.bodyB,this.emit(W)}P.length=0}var V=this.preSolveEvent;V.contactEquations=c.contactEquations,V.frictionEquations=c.frictionEquations,this.emit(V),V.contactEquations=V.frictionEquations=null;var H=u.length;for(T=0;T!==H;T++)u[T].update();if(c.contactEquations.length||c.frictionEquations.length||H)if(this.islandSplit){for(g.equations.length=0,v.appendArray(g.equations,c.contactEquations),v.appendArray(g.equations,c.frictionEquations),T=0;T!==H;T++)v.appendArray(g.equations,u[T].equations);g.split(this);for(T=0;T!==g.islands.length;T++)(K=g.islands[T]).equations.length&&a.solveIsland(t,K)}else{for(a.addEquations(c.contactEquations),a.addEquations(c.frictionEquations),T=0;T!==H;T++)a.addEquations(u[T].equations);this.solveConstraints&&a.solve(t,this),a.removeAllEquations()}for(T=0;T!==h;T++){var q=n[T];q.integrate(t)}for(T=0;T!==h;T++)n[T].setZeroForce();if(this.emitImpactEvent&&this.has("impact"))for(var Y=this.impactEvent,T=0;T!==c.contactEquations.length;T++){var z=c.contactEquations[T];z.firstImpact&&(Y.bodyA=z.bodyA,Y.bodyB=z.bodyB,Y.shapeA=z.shapeA,Y.shapeB=z.shapeB,Y.contactEquation=z,this.emit(Y))}if(this.sleepMode===s.BODY_SLEEPING)for(T=0;T!==h;T++)n[T].sleepTick(this.time,!1,t);else if(this.sleepMode===s.ISLAND_SLEEPING&&this.islandSplit){for(T=0;T!==h;T++)n[T].sleepTick(this.time,!0,t);for(T=0;T<this.islandManager.islands.length;T++){var K=this.islandManager.islands[T];K.wantsToSleep()&&K.sleep()}}this.stepping=!1;for(var J=this.bodiesToBeRemoved,T=0;T!==J.length;T++)this.removeBody(J[T]);J.length=0,this.emit(this.postStepEvent)},s.prototype.runNarrowphase=function(t,e,i,s,n,o,a,h,l,c,u){if(0!=(i.collisionGroup&a.collisionMask)&&0!=(a.collisionGroup&i.collisionMask)){r.rotate(w,s,e.angle),r.rotate(T,h,o.angle),r.add(w,w,e.position),r.add(T,T,o.position);var p=n+e.angle,f=l+o.angle;t.enableFriction=c.friction>0,t.frictionCoefficient=c.friction;var g;g=e.type===d.STATIC||e.type===d.KINEMATIC?o.mass:o.type===d.STATIC||o.type===d.KINEMATIC?e.mass:e.mass*o.mass/(e.mass+o.mass),t.slipForce=c.friction*u*g,t.restitution=c.restitution,t.surfaceVelocity=c.surfaceVelocity,t.frictionStiffness=c.frictionStiffness,t.frictionRelaxation=c.frictionRelaxation,t.stiffness=c.stiffness,t.relaxation=c.relaxation,t.contactSkinSize=c.contactSkinSize,t.enabledEquations=e.collisionResponse&&o.collisionResponse&&i.collisionResponse&&a.collisionResponse;var m=t[i.type|a.type],y=0;if(m){var v=i.sensor||a.sensor,x=t.frictionEquations.length;y=i.type<a.type?m.call(t,e,i,w,p,o,a,T,f,v):m.call(t,o,a,T,f,e,i,w,p,v);var b=t.frictionEquations.length-x;if(y){if(e.allowSleep&&e.type===d.DYNAMIC&&e.sleepState===d.SLEEPING&&o.sleepState===d.AWAKE&&o.type!==d.STATIC&&r.squaredLength(o.velocity)+Math.pow(o.angularVelocity,2)>=2*Math.pow(o.sleepSpeedLimit,2)&&(e._wakeUpAfterNarrowphase=!0),o.allowSleep&&o.type===d.DYNAMIC&&o.sleepState===d.SLEEPING&&e.sleepState===d.AWAKE&&e.type!==d.STATIC&&r.squaredLength(e.velocity)+Math.pow(e.angularVelocity,2)>=2*Math.pow(e.sleepSpeedLimit,2)&&(o._wakeUpAfterNarrowphase=!0),this.overlapKeeper.setOverlapping(e,i,o,a),this.has("beginContact")&&this.overlapKeeper.isNewOverlap(i,a)){var _=this.beginContactEvent;if(_.shapeA=i,_.shapeB=a,_.bodyA=e,_.bodyB=o,_.contactEquations.length=0,"number"==typeof y)for(P=t.contactEquations.length-y;P<t.contactEquations.length;P++)_.contactEquations.push(t.contactEquations[P]);this.emit(_)}if("number"==typeof y&&b>1)for(var P=t.frictionEquations.length-b;P<t.frictionEquations.length;P++){var C=t.frictionEquations[P];C.setSlipForce(C.getSlipForce()/b)}}}}},s.prototype.addSpring=function(t){this.springs.push(t);var e=this.addSpringEvent;e.spring=t,this.emit(e),e.spring=null},s.prototype.removeSpring=function(t){var e=this.springs.indexOf(t);-1!==e&&v.splice(this.springs,e,1)},s.prototype.addBody=function(t){if(-1===this.bodies.indexOf(t)){this.bodies.push(t),t.world=this;var e=this.addBodyEvent;e.body=t,this.emit(e),e.body=null}},s.prototype.removeBody=function(t){if(this.stepping)this.bodiesToBeRemoved.push(t);else{t.world=null;var e=this.bodies.indexOf(t);-1!==e&&(v.splice(this.bodies,e,1),this.removeBodyEvent.body=t,t.resetConstraintVelocity(),this.emit(this.removeBodyEvent),this.removeBodyEvent.body=null)}},s.prototype.getBodyById=function(t){for(var e=this.bodies,i=0;i<e.length;i++){var s=e[i];if(s.id===t)return s}return!1},s.prototype.disableBodyCollision=function(t,e){this.disabledBodyCollisionPairs.push(t,e)},s.prototype.enableBodyCollision=function(t,e){for(var i=this.disabledBodyCollisionPairs,s=0;s<i.length;s+=2)if(i[s]===t&&i[s+1]===e||i[s+1]===t&&i[s]===e)return void i.splice(s,2)},s.prototype.clear=function(){this.time=0,this.solver&&this.solver.equations.length&&this.solver.removeAllEquations();for(var t=this.constraints,e=t.length-1;e>=0;e--)this.removeConstraint(t[e]);for(var i=this.bodies,e=i.length-1;e>=0;e--)this.removeBody(i[e]);for(var n=this.springs,e=n.length-1;e>=0;e--)this.removeSpring(n[e]);for(var r=this.contactMaterials,e=r.length-1;e>=0;e--)this.removeContactMaterial(r[e]);s.apply(this)};var C=r.create(),S=(r.fromValues(0,0),r.fromValues(0,0));s.prototype.hitTest=function(t,e,i){i=i||0;var s=new d({position:t}),n=new c,u=t,p=C,f=S;s.addShape(n);for(var g=this.narrowphase,m=[],y=0,v=e.length;y!==v;y++)for(var x=e[y],b=0,_=x.shapes.length;b!==_;b++){var w=x.shapes[b];r.rotate(p,w.position,x.angle),r.add(p,p,x.position);var T=w.angle+x.angle;(w instanceof o&&g.circleParticle(x,w,p,T,s,n,u,0,!0)||w instanceof a&&g.particleConvex(s,n,u,0,x,w,p,T,!0)||w instanceof h&&g.particlePlane(s,n,u,0,x,w,p,T,!0)||w instanceof l&&g.particleCapsule(s,n,u,0,x,w,p,T,!0)||w instanceof c&&r.squaredLength(r.sub(f,p,t))<i*i)&&m.push(x)}return m},s.prototype.setGlobalStiffness=function(t){for(var e=this.constraints,i=0;i!==e.length;i++)for(var s=e[i],n=0;n!==s.equations.length;n++){var r=s.equations[n];r.stiffness=t,r.needsUpdate=!0}for(var o=this.contactMaterials,i=0;i!==o.length;i++)(s=o[i]).stiffness=s.frictionStiffness=t;(s=this.defaultContactMaterial).stiffness=s.frictionStiffness=t},s.prototype.setGlobalRelaxation=function(t){for(n=0;n!==this.constraints.length;n++)for(var e=this.constraints[n],i=0;i!==e.equations.length;i++){var s=e.equations[i];s.relaxation=t,s.needsUpdate=!0}for(var n=0;n!==this.contactMaterials.length;n++)(e=this.contactMaterials[n]).relaxation=e.frictionRelaxation=t;(e=this.defaultContactMaterial).relaxation=e.frictionRelaxation=t};var A=new g,E=[];s.prototype.raycast=function(t,e){return e.getAABB(A),this.broadphase.aabbQuery(this,A,E),e.intersectBodies(t,E),E.length=0,t.hasHit()}},{"../../package.json":6,"../collision/AABB":7,"../collision/Broadphase":8,"../collision/Narrowphase":10,"../collision/Ray":11,"../collision/SAPBroadphase":13,"../constraints/Constraint":14,"../constraints/DistanceConstraint":15,"../constraints/GearConstraint":16,"../constraints/LockConstraint":17,"../constraints/PrismaticConstraint":18,"../constraints/RevoluteConstraint":19,"../events/EventEmitter":26,"../material/ContactMaterial":27,"../material/Material":28,"../math/vec2":30,"../objects/Body":31,"../objects/LinearSpring":32,"../objects/RotationalSpring":33,"../shapes/Capsule":38,"../shapes/Circle":39,"../shapes/Convex":40,"../shapes/Line":42,"../shapes/Particle":43,"../shapes/Plane":44,"../shapes/Shape":45,"../solver/GSSolver":46,"../solver/Solver":47,"../utils/OverlapKeeper":52,"../utils/Utils":57,"./IslandManager":59}]},{},[36])(36)}),function(){function t(t,e,i,n){var r=t.createTexture();return t.bindTexture(t.TEXTURE_2D,r),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,n===s.scaleModes.LINEAR?t.LINEAR:t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,n===s.scaleModes.LINEAR?t.LINEAR:t.NEAREST),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,e,i,0,t.RGBA,t.UNSIGNED_BYTE,null),r}function e(e,i,s,r,o){var a=e.createFramebuffer(),h=e.createRenderbuffer(),l=null,c=0;return e.activeTexture(e.TEXTURE0+o),e.bindFramebuffer(e.FRAMEBUFFER,a),e.bindRenderbuffer(e.RENDERBUFFER,h),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,this.renderBuffer),l=t(e,i,s,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,l,0),(c=e.checkFramebufferStatus(e.FRAMEBUFFER))!==e.FRAMEBUFFER_COMPLETE&&console.error("Incomplete GL framebuffer. ",n[c]),a.width=i,a.height=s,a.targetTexture=l,a.renderBuffer=h,a}var i=this,s=s||{};s.DisplayObject=function(){this.position=new s.Point(0,0),this.scale=new s.Point(1,1),this.pivot=new s.Point(0,0),this.rotation=0,this.alpha=1,this.visible=!0,this.hitArea=null,this.renderable=!1,this.parent=null,this.worldAlpha=1,this.worldTransform=new Phaser.Matrix,this.worldPosition=new s.Point(0,0),this.worldScale=new s.Point(1,1),this.worldRotation=0,this.filterArea=null,this._sr=0,this._cr=1,this._bounds=new s.Rectangle(0,0,0,0),this._currentBounds=null,this._mask=null,this._cacheAsBitmap=!1,this._cacheIsDirty=!1},s.DisplayObject.prototype={constructor:s.DisplayObject,destroy:function(){if(this.children){for(var t=this.children.length;t--;)this.children[t].destroy();this.children=[]}this.hitArea=null,this.parent=null,this.worldTransform=null,this.filterArea=null,this.renderable=!1,this._bounds=null,this._currentBounds=null,this._mask=null,this._destroyCachedSprite(),this._destroyTintedTexture()},updateTransform:function(t){if(!t&&!this.parent&&!this.game)return this;var e=this.parent;t?e=t:this.parent||(e=this.game.world);var i,s,n,r,o,a,h=e.worldTransform,l=this.worldTransform;this.rotation%Phaser.Math.PI2?(this.rotation!==this.rotationCache&&(this.rotationCache=this.rotation,this._sr=Math.sin(this.rotation),this._cr=Math.cos(this.rotation)),i=this._cr*this.scale.x,s=this._sr*this.scale.x,n=-this._sr*this.scale.y,r=this._cr*this.scale.y,o=this.position.x,a=this.position.y,(this.pivot.x||this.pivot.y)&&(o-=this.pivot.x*i+this.pivot.y*n,a-=this.pivot.x*s+this.pivot.y*r),l.a=i*h.a+s*h.c,l.b=i*h.b+s*h.d,l.c=n*h.a+r*h.c,l.d=n*h.b+r*h.d,l.tx=o*h.a+a*h.c+h.tx,l.ty=o*h.b+a*h.d+h.ty):(i=this.scale.x,s=0,n=0,r=this.scale.y,o=this.position.x-this.pivot.x*i,a=this.position.y-this.pivot.y*r,l.a=i*h.a,l.b=i*h.b,l.c=r*h.c,l.d=r*h.d,l.tx=o*h.a+a*h.c+h.tx,l.ty=o*h.b+a*h.d+h.ty),i=l.a,s=l.b,n=l.c;var c=i*(r=l.d)-s*n;if(i||s){var u=Math.sqrt(i*i+s*s);this.worldRotation=s>0?Math.acos(i/u):-Math.acos(i/u),this.worldScale.x=u,this.worldScale.y=c/u}else if(n||r){var d=Math.sqrt(n*n+r*r);this.worldRotation=Phaser.Math.HALF_PI-(r>0?Math.acos(-n/d):-Math.acos(n/d)),this.worldScale.x=c/d,this.worldScale.y=d}else this.worldScale.x=0,this.worldScale.y=0;return this.worldAlpha=this.alpha*e.worldAlpha,this.worldPosition.x=l.tx,this.worldPosition.y=l.ty,this._currentBounds=null,this.transformCallback&&this.transformCallback.call(this.transformCallbackContext,l,h),this},preUpdate:function(){},generateTexture:function(t,e,i){var n=this.getLocalBounds(),r=new Phaser.RenderTexture(this.game,0|n.width,0|n.height,i,e,t);return s.DisplayObject._tempMatrix.tx=-n.x,s.DisplayObject._tempMatrix.ty=-n.y,r.render(this,s.DisplayObject._tempMatrix),r},updateCache:function(){return this._generateCachedSprite(),this},toGlobal:function(t){return this.updateTransform(),this.worldTransform.apply(t)},toLocal:function(t,e){return e&&(t=e.toGlobal(t)),this.updateTransform(),this.worldTransform.applyInverse(t)},_renderCachedSprite:function(t){this._cachedSprite.worldAlpha=this.worldAlpha,t.gl?s.Sprite.prototype._renderWebGL.call(this._cachedSprite,t):s.Sprite.prototype._renderCanvas.call(this._cachedSprite,t)},_generateCachedSprite:function(){this._cacheAsBitmap=!1;var t=this.getLocalBounds();if(t.width=Math.max(1,Math.ceil(t.width)),t.height=Math.max(1,Math.ceil(t.height)),this.updateTransform(),this._cachedSprite)this._cachedSprite.texture.resize(t.width,t.height);else{var e=0;this.texture&&this.texture.baseTexture&&s._enableMultiTextureToggle&&(e=this.texture.baseTexture.textureIndex);var i=new Phaser.RenderTexture(this.game,t.width,t.height,void 0,void 0,void 0,void 0,e);this._cachedSprite=new s.Sprite(i),this._cachedSprite.worldTransform=this.worldTransform}var n=this._filters;this._filters=null,this._cachedSprite.filters=n,s.DisplayObject._tempMatrix.tx=-t.x,s.DisplayObject._tempMatrix.ty=-t.y,this._cachedSprite.texture.render(this,s.DisplayObject._tempMatrix,!0),this._cachedSprite.anchor.x=-t.x/t.width,this._cachedSprite.anchor.y=-t.y/t.height,this._filters=n,this._cacheAsBitmap=!0},_destroyCachedSprite:function(){this._cachedSprite&&(this._cachedSprite.texture.destroy(!0),this._cachedSprite=null)},_destroyTintedTexture:function(){this.tintedTexture&&(Phaser.CanvasPool.removeByCanvas(this.tintedTexture),this.tintedTexture=null)}},s.DisplayObject.prototype.displayObjectUpdateTransform=s.DisplayObject.prototype.updateTransform,Object.defineProperties(s.DisplayObject.prototype,{x:{get:function(){return this.position.x},set:function(t){this.position.x=t}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t}},worldVisible:{get:function(){if(this.visible){var t=this.parent;if(!t)return this.visible;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}return!1}},mask:{get:function(){return this._mask},set:function(t){this._mask&&(this._mask.isMask=!1),this._mask=t,t&&(this._mask.isMask=!0)}},filters:{get:function(){return this._filters},set:function(t){if(Array.isArray(t)){for(var e=[],i=0;i<t.length;i++)for(var n=t[i].passes,r=0;r<n.length;r++)e.push(n[r]);this._filterBlock={target:this,filterPasses:e}}this._filters=t,this.blendMode&&this.blendMode===s.blendModes.MULTIPLY&&(this.blendMode=s.blendModes.NORMAL)}},cacheAsBitmap:{get:function(){return this._cacheAsBitmap},set:function(t){this._cacheAsBitmap!==t&&(t?this._generateCachedSprite():this._destroyCachedSprite(),this._cacheAsBitmap=t)}}}),s.DisplayObjectContainer=function(){s.DisplayObject.call(this),this.children=[],this.ignoreChildInput=!1},s.DisplayObjectContainer.prototype=Object.create(s.DisplayObject.prototype),s.DisplayObjectContainer.prototype.constructor=s.DisplayObjectContainer,s.DisplayObjectContainer.prototype.addChild=function(t){return this.addChildAt(t,this.children.length)},s.DisplayObjectContainer.prototype.addChildAt=function(t,e){if(e>=0&&e<=this.children.length)return t.parent&&t.parent.removeChild(t),t.parent=this,this.children.splice(e,0,t),t;throw new Error(t+"addChildAt: The index "+e+" supplied is out of bounds "+this.children.length)},s.DisplayObjectContainer.prototype.swapChildren=function(t,e){if(t!==e){var i=this.getChildIndex(t),s=this.getChildIndex(e);if(i<0||s<0)throw new Error("swapChildren: Both the supplied DisplayObjects must be a child of the caller.");this.children[i]=e,this.children[s]=t}},s.DisplayObjectContainer.prototype.getChildIndex=function(t){var e=this.children.indexOf(t);if(-1===e)throw new Error("The supplied DisplayObject must be a child of the caller");return e},s.DisplayObjectContainer.prototype.setChildIndex=function(t,e){if(e<0||e>=this.children.length)throw new Error("The supplied index is out of bounds");var i=this.getChildIndex(t);this.children.splice(i,1),this.children.splice(e,0,t)},s.DisplayObjectContainer.prototype.getChildAt=function(t){if(t<0||t>=this.children.length)throw new Error("getChildAt: Supplied index "+t+" does not exist in the child list, or the supplied DisplayObject must be a child of the caller");return this.children[t]},s.DisplayObjectContainer.prototype.removeChild=function(t){var e=this.children.indexOf(t);if(-1!==e)return this.removeChildAt(e)},s.DisplayObjectContainer.prototype.removeChildAt=function(t){var e=this.getChildAt(t);return e&&(e.parent=void 0,this.children.splice(t,1)),e},s.DisplayObjectContainer.prototype.bringChildToTop=function(t){if(t.parent===this)return this.setChildIndex(t,this.children.length-1)},s.DisplayObjectContainer.prototype.sendChildToBack=function(t){if(t.parent===this)return this.setChildIndex(t,0)},s.DisplayObjectContainer.prototype.removeChildren=function(t,e){void 0===t&&(t=0),void 0===e&&(e=this.children.length);var i=e-t;if(i>0&&i<=e){for(var s=this.children.splice(t,i),n=0;n<s.length;n++)s[n].parent=void 0;return s}if(0===i&&0===this.children.length)return[];throw new Error("removeChildren: Range Error, numeric values are outside the acceptable range")},s.DisplayObjectContainer.prototype.updateTransform=function(){if(this.visible&&(this.displayObjectUpdateTransform(),!this._cacheAsBitmap))for(var t=0;t<this.children.length;t++)this.children[t].updateTransform()},s.DisplayObjectContainer.prototype.displayObjectContainerUpdateTransform=s.DisplayObjectContainer.prototype.updateTransform,s.DisplayObjectContainer.prototype.getBounds=function(t){var e=t&&t instanceof s.DisplayObject,i=!0;e?i=t instanceof s.DisplayObjectContainer&&t.contains(this):t=this;var n;if(e){var r=t.worldTransform;for(t.worldTransform=Phaser.identityMatrix,n=0;n<t.children.length;n++)t.children[n].updateTransform()}var o,a,h,l=1/0,c=1/0,u=-1/0,d=-1/0,p=!1;for(n=0;n<this.children.length;n++)this.children[n].visible&&(p=!0,l=l<(o=this.children[n].getBounds()).x?l:o.x,c=c<o.y?c:o.y,a=o.width+o.x,h=o.height+o.y,u=u>a?u:a,d=d>h?d:h);var f=this._bounds;if(!p){var g=(f=new s.Rectangle).x,m=f.width+f.x,y=f.y,v=f.height+f.y,x=this.worldTransform,b=x.a,_=x.b,w=x.c,T=x.d,P=x.tx,C=x.ty,S=b*m+w*v+P,A=T*v+_*m+C,E=b*g+w*v+P,M=T*v+_*g+C,R=b*g+w*y+P,L=T*y+_*g+C,B=b*m+w*y+P,I=T*y+_*m+C;u=S,d=A,c=A,l=B<(l=R<(l=E<(l=S)?E:l)?R:l)?B:l,c=I<(c=L<(c=M<c?M:c)?L:c)?I:c,u=B>(u=R>(u=E>u?E:u)?R:u)?B:u,d=I>(d=L>(d=M>d?M:d)?L:d)?I:d}if(f.x=l,f.y=c,f.width=u-l,f.height=d-c,e)for(t.worldTransform=r,n=0;n<t.children.length;n++)t.children[n].updateTransform();if(!i){var O=t.getBounds();f.x-=O.x,f.y-=O.y}return f},s.DisplayObjectContainer.prototype.getLocalBounds=function(){return this.getBounds(this)},s.DisplayObjectContainer.prototype.contains=function(t){return!!t&&(t===this||this.contains(t.parent))},s.DisplayObjectContainer.prototype._renderWebGL=function(t){if(this.visible&&!(this.alpha<=0))if(this._cacheAsBitmap)this._renderCachedSprite(t);else{var e;if(this._mask||this._filters){for(this._filters&&(t.spriteBatch.flush(),t.filterManager.pushFilter(this._filterBlock)),this._mask&&(t.spriteBatch.stop(),t.maskManager.pushMask(this.mask,t),t.spriteBatch.start()),e=0;e<this.children.length;e++)this.children[e]._renderWebGL(t);t.spriteBatch.stop(),this._mask&&t.maskManager.popMask(this._mask,t),this._filters&&t.filterManager.popFilter(),t.spriteBatch.start()}else for(e=0;e<this.children.length;e++)this.children[e]._renderWebGL(t)}},s.DisplayObjectContainer.prototype._renderCanvas=function(t){if(!1!==this.visible&&0!==this.alpha)if(this._cacheAsBitmap)this._renderCachedSprite(t);else{this._mask&&t.maskManager.pushMask(this._mask,t);for(var e=0;e<this.children.length;e++)this.children[e]._renderCanvas(t);this._mask&&t.maskManager.popMask(t)}},Object.defineProperty(s.DisplayObjectContainer.prototype,"width",{get:function(){return this.getLocalBounds().width*this.scale.x},set:function(t){var e=this.getLocalBounds().width;this.scale.x=0!==e?t/e:1,this._width=t}}),Object.defineProperty(s.DisplayObjectContainer.prototype,"height",{get:function(){return this.getLocalBounds().height*this.scale.y},set:function(t){var e=this.getLocalBounds().height;this.scale.y=0!==e?t/e:1,this._height=t}}),s.Sprite=function(t){s.DisplayObjectContainer.call(this),this.anchor=new s.Point(s.Sprite.defaultAnchor.x,s.Sprite.defaultAnchor.y),this.texture=t||s.Texture.emptyTexture,this._width=0,this._height=0,this.tint=16777215,this.cachedTint=-1,this.tintedTexture=null,this.blendMode=s.blendModes.NORMAL,this.shader=null,this.exists=!0,this.texture.baseTexture.hasLoaded&&this.onTextureUpdate(),this.renderable=!0},s.Sprite.defaultAnchor={x:0,y:0},s.Sprite.prototype=Object.create(s.DisplayObjectContainer.prototype),s.Sprite.prototype.constructor=s.Sprite,Object.defineProperty(s.Sprite.prototype,"width",{get:function(){return this.scale.x*this.texture.frame.width},set:function(t){this.scale.x=t/this.texture.frame.width,this._width=t}}),Object.defineProperty(s.Sprite.prototype,"height",{get:function(){return this.scale.y*this.texture.frame.height},set:function(t){this.scale.y=t/this.texture.frame.height,this._height=t}}),s.Sprite.prototype.setTexture=function(t,e){e&&this.texture.baseTexture.destroy(),this.texture.baseTexture.skipRender=!1,this.texture=t,this.texture.valid=!0,this.cachedTint=-1},s.Sprite.prototype.onTextureUpdate=function(){this._width&&(this.scale.x=this._width/this.texture.frame.width),this._height&&(this.scale.y=this._height/this.texture.frame.height)},s.Sprite.prototype.getBounds=function(t){var e=this.texture.frame.width,i=this.texture.frame.height,s=e*(1-this.anchor.x),n=e*-this.anchor.x,r=i*(1-this.anchor.y),o=i*-this.anchor.y,a=t||this.worldTransform,h=a.a,l=a.b,c=a.c,u=a.d,d=a.tx,p=a.ty,f=-1/0,g=-1/0,m=1/0,y=1/0;if(0===l&&0===c){if(h<0){h*=-1;v=s;s=-n,n=-v}if(u<0){u*=-1;var v=r;r=-o,o=-v}m=h*n+d,f=h*s+d,y=u*o+p,g=u*r+p}else{var x=h*n+c*o+d,b=u*o+l*n+p,_=h*s+c*o+d,w=u*o+l*s+p,T=h*s+c*r+d,P=u*r+l*s+p,C=h*n+c*r+d,S=u*r+l*n+p;m=C<(m=T<(m=_<(m=x<m?x:m)?_:m)?T:m)?C:m,y=S<(y=P<(y=w<(y=b<y?b:y)?w:y)?P:y)?S:y,f=C>(f=T>(f=_>(f=x>f?x:f)?_:f)?T:f)?C:f,g=S>(g=P>(g=w>(g=b>g?b:g)?w:g)?P:g)?S:g}var A=this._bounds;return A.x=m,A.width=f-m,A.y=y,A.height=g-y,this._currentBounds=A,A},s.Sprite.prototype.getLocalBounds=function(){var t=this.worldTransform;this.worldTransform=Phaser.identityMatrix;for(var e=0;e<this.children.length;e++)this.children[e].updateTransform();var i=this.getBounds();for(this.worldTransform=t,e=0;e<this.children.length;e++)this.children[e].updateTransform();return i},s.Sprite.prototype._renderWebGL=function(t,e){if(this.visible&&!(this.alpha<=0)&&this.renderable){var i=this.worldTransform;if(e&&(i=e),this._mask||this._filters){var s=t.spriteBatch;this._filters&&(s.flush(),t.filterManager.pushFilter(this._filterBlock)),this._mask&&(s.stop(),t.maskManager.pushMask(this.mask,t),s.start()),s.render(this);for(n=0;n<this.children.length;n++)this.children[n]._renderWebGL(t);s.stop(),this._mask&&t.maskManager.popMask(this._mask,t),this._filters&&t.filterManager.popFilter(),s.start()}else{t.spriteBatch.render(this);for(var n=0;n<this.children.length;n++)this.children[n]._renderWebGL(t,i)}}},s.Sprite.prototype._renderCanvas=function(t,e){if(!(!this.visible||0===this.alpha||!this.renderable||this.texture.crop.width<1||this.texture.crop.height<1)){var i=this.worldTransform;if(e&&(i=e),this.blendMode!==t.currentBlendMode&&(t.currentBlendMode=this.blendMode,t.context.globalCompositeOperation=s.blendModesCanvas[t.currentBlendMode]),this._mask&&t.maskManager.pushMask(this._mask,t),this.texture.valid){var n=this.texture.baseTexture.resolution/t.resolution;t.context.globalAlpha=this.worldAlpha,t.smoothProperty&&t.scaleMode!==this.texture.baseTexture.scaleMode&&(t.scaleMode=this.texture.baseTexture.scaleMode,t.context[t.smoothProperty]=t.scaleMode===s.scaleModes.LINEAR);var r=this.texture.trim?this.texture.trim.x-this.anchor.x*this.texture.trim.width:this.anchor.x*-this.texture.frame.width,o=this.texture.trim?this.texture.trim.y-this.anchor.y*this.texture.trim.height:this.anchor.y*-this.texture.frame.height,a=i.tx*t.resolution+t.shakeX,h=i.ty*t.resolution+t.shakeY,l=this.texture.crop.width,c=this.texture.crop.height;if(this.texture.rotated){var u=i.a,d=i.b,p=i.c,f=i.d,g=l;a=i.c*c+a,h=i.d*c+h,i.a=6.123233995736766e-17*u-p,i.b=6.123233995736766e-17*d-f,i.c=u+6.123233995736766e-17*p,i.d=d+6.123233995736766e-17*f,l=c,c=g}if(t.roundPixels?(t.context.setTransform(i.a,i.b,i.c,i.d,0|a,0|h),r|=0,o|=0):t.context.setTransform(i.a,i.b,i.c,i.d,a,h),r/=n,o/=n,l|=0,c|=0,l&&c){if(16777215!==this.tint)(this.texture.requiresReTint||this.cachedTint!==this.tint)&&(this.tintedTexture=s.CanvasTinter.getTintedTexture(this,this.tint),this.cachedTint=this.tint,this.texture.requiresReTint=!1),t.context.drawImage(this.tintedTexture,0,0,l,c,r,o,l/n,c/n);else{var m=this.texture.crop.x,y=this.texture.crop.y;t.context.drawImage(this.texture.baseTexture.source,m,y,l,c,r,o,l/n,c/n)}for(v=0;v<this.children.length;v++)this.children[v]._renderCanvas(t);this._mask&&t.maskManager.popMask(t)}}else{for(var v=0;v<this.children.length;v++)this.children[v]._renderCanvas(t);this._mask&&t.maskManager.popMask(t)}}},s.initDefaultShaders=function(){},s.CompileVertexShader=function(t,e){return s._CompileShader(t,e,t.VERTEX_SHADER)},s.CompileFragmentShader=function(t,e){return s._CompileShader(t,e,t.FRAGMENT_SHADER)},s._CompileShader=function(t,e,i){var s=e;Array.isArray(e)&&(s=e.join("\n"));var n=t.createShader(i);return t.shaderSource(n,s),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS)?n:(window.console.log(t.getShaderInfoLog(n)),null)},s.compileProgram=function(t,e,i){var n=s.CompileFragmentShader(t,i),r=s.CompileVertexShader(t,e),o=t.createProgram();return t.attachShader(o,r),t.attachShader(o,n),t.linkProgram(o),t.getProgramParameter(o,t.LINK_STATUS)||(window.console.log(t.getProgramInfoLog(o)),window.console.log("Could not initialise shaders")),o},s.PixiShader=function(t){this._UID=Phaser._UID++,this.gl=t,this.program=null,this.fragmentSrc=null,this.textureCount=0,this.firstRun=!0,this.dirty=!0,this.attributes=[],this.init()},s.PixiShader.prototype.constructor=s.PixiShader,s.PixiShader.prototype.initMultitexShader=function(){var t=this.gl;this.MAX_TEXTURES=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);for(var e="\tif (vTextureIndex == 0.0) { gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;return;}\n",i=1;i<this.MAX_TEXTURES;++i)e+="\tif (vTextureIndex == "+i+".0) {gl_FragColor = texture2D(uSamplerArray["+i+"], vTextureCoord) * vColor;return;}\n";this.fragmentSrc=["// PixiShader Fragment Shader.","precision lowp float;","bool isnan( float val ) { return ( val < 0.0 || 0.0 < val || val == 0.0 ) ? false : true; }","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","uniform sampler2D uSamplerArray["+this.MAX_TEXTURES+"];","const vec4 BLUE = vec4(1.0, 0.0, 1.0, 1.0);","const vec4 RED = vec4(1.0, 0.0, 0.0, 1.0);","void main(void) {",e," if(vTextureIndex >= "+this.MAX_TEXTURES+".0) { gl_FragColor = BLUE;return;}"," if(isnan(vTextureIndex)) { gl_FragColor = RED;return;}","}"];var n=s.compileProgram(t,this.vertexSrc||s.PixiShader.defaultVertexSrc,this.fragmentSrc);t.useProgram(n),this.uSamplerArray=t.getUniformLocation(n,"uSamplerArray[0]"),this.projectionVector=t.getUniformLocation(n,"projectionVector"),this.offsetVector=t.getUniformLocation(n,"offsetVector"),this.dimensions=t.getUniformLocation(n,"dimensions"),this.aVertexPosition=t.getAttribLocation(n,"aVertexPosition"),this.aTextureCoord=t.getAttribLocation(n,"aTextureCoord"),this.colorAttribute=t.getAttribLocation(n,"aColor"),this.aTextureIndex=t.getAttribLocation(n,"aTextureIndex");var r=[],o=t.createTexture();t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,o),t.texImage2D(t.TEXTURE_2D,0,t.RGB,1,1,0,t.RGB,t.UNSIGNED_BYTE,null);for(var a=0;a<this.MAX_TEXTURES;++a)t.activeTexture(t.TEXTURE0+a),t.bindTexture(t.TEXTURE_2D,o),r.push(a);t.activeTexture(t.TEXTURE0),t.uniform1iv(this.uSamplerArray,r),-1===this.colorAttribute&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aTextureCoord,this.colorAttribute,this.aTextureIndex];for(var h in this.uniforms)this.uniforms[h].uniformLocation=t.getUniformLocation(n,h);this.initUniforms(),this.program=n},s.PixiShader.prototype.initDefaultShader=function(){null===this.fragmentSrc&&(this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"]);var t=this.gl,e=s.compileProgram(t,this.vertexSrc||s.PixiShader.defaultVertexSrc,this.fragmentSrc);t.useProgram(e),this.uSampler=t.getUniformLocation(e,"uSampler"),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.dimensions=t.getUniformLocation(e,"dimensions"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.aTextureCoord=t.getAttribLocation(e,"aTextureCoord"),this.colorAttribute=t.getAttribLocation(e,"aColor"),this.aTextureIndex=t.getAttribLocation(e,"aTextureIndex"),-1===this.colorAttribute&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aTextureCoord,this.colorAttribute,this.aTextureIndex];for(var i in this.uniforms)this.uniforms[i].uniformLocation=t.getUniformLocation(e,i);this.initUniforms(),this.program=e},s.PixiShader.prototype.init=function(t){s._enableMultiTextureToggle&&!t?this.initMultitexShader():this.initDefaultShader()},s.PixiShader.prototype.initUniforms=function(){this.textureCount=1;var t,e=this.gl;for(var i in this.uniforms){var s=(t=this.uniforms[i]).type;"sampler2D"===s?(t._init=!1,null!==t.value&&this.initSampler2D(t)):"mat2"===s||"mat3"===s||"mat4"===s?(t.glMatrix=!0,t.glValueLength=1,"mat2"===s?t.glFunc=e.uniformMatrix2fv:"mat3"===s?t.glFunc=e.uniformMatrix3fv:"mat4"===s&&(t.glFunc=e.uniformMatrix4fv)):(t.glFunc=e["uniform"+s],t.glValueLength="2f"===s||"2i"===s?2:"3f"===s||"3i"===s?3:"4f"===s||"4i"===s?4:1)}},s.PixiShader.prototype.initSampler2D=function(t){if(t.value&&t.value.baseTexture&&t.value.baseTexture.hasLoaded){var e=this.gl;if(e.activeTexture(e.TEXTURE0+this.textureCount),e.bindTexture(e.TEXTURE_2D,t.value.baseTexture._glTextures[e.id]),t.textureData){var i=t.textureData,s=i.magFilter?i.magFilter:e.LINEAR,n=i.minFilter?i.minFilter:e.LINEAR,r=i.wrapS?i.wrapS:e.CLAMP_TO_EDGE,o=i.wrapT?i.wrapT:e.CLAMP_TO_EDGE,a=i.luminance?e.LUMINANCE:e.RGBA;if(i.repeat&&(r=e.REPEAT,o=e.REPEAT),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!!i.flipY),i.width){var h=i.width?i.width:512,l=i.height?i.height:2,c=i.border?i.border:0;e.texImage2D(e.TEXTURE_2D,0,a,h,l,c,a,e.UNSIGNED_BYTE,null)}else e.texImage2D(e.TEXTURE_2D,0,a,e.RGBA,e.UNSIGNED_BYTE,t.value.baseTexture.source);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,s),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,n),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,r),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,o)}e.uniform1i(t.uniformLocation,this.textureCount),t._init=!0,this.textureCount++}},s.PixiShader.prototype.syncUniforms=function(){this.textureCount=1;var t,e=this.gl;for(var i in this.uniforms)1===(t=this.uniforms[i]).glValueLength?!0===t.glMatrix?t.glFunc.call(e,t.uniformLocation,t.transpose,t.value):t.glFunc.call(e,t.uniformLocation,t.value):2===t.glValueLength?t.glFunc.call(e,t.uniformLocation,t.value.x,t.value.y):3===t.glValueLength?t.glFunc.call(e,t.uniformLocation,t.value.x,t.value.y,t.value.z):4===t.glValueLength?t.glFunc.call(e,t.uniformLocation,t.value.x,t.value.y,t.value.z,t.value.w):"sampler2D"===t.type&&(t._init?(e.activeTexture(e["TEXTURE"+this.textureCount]),t.value.baseTexture._dirty[e.id]?s.instances[e.id].updateTexture(t.value.baseTexture):e.bindTexture(e.TEXTURE_2D,t.value.baseTexture._glTextures[e.id]),e.uniform1i(t.uniformLocation,this.textureCount),this.textureCount++):this.initSampler2D(t))},s.PixiShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},s.PixiShader.defaultVertexSrc=["// PixiShader Vertex Shader","// With multi-texture rendering","attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute vec4 aColor;","attribute float aTextureIndex;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {"," if (aTextureIndex > 0.0) gl_Position = vec4(0.0);"," gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = vec4(aColor.rgb * aColor.a, aColor.a);"," vTextureIndex = aTextureIndex;","}"],s.PixiFastShader=function(t){if(this._UID=Phaser._UID++,this.gl=t,this.program=null,s._enableMultiTextureToggle){var t=this.gl;this.MAX_TEXTURES=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);for(var e="\tif (vTextureIndex == 0.0) { gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;return;}\n",i=1;i<this.MAX_TEXTURES;++i)e+="\tif (vTextureIndex == "+i+".0) { gl_FragColor = texture2D(uSamplerArray["+i+"], vTextureCoord) * vColor;return;}\n";this.fragmentSrc=["// PixiFastShader Fragment Shader.","precision lowp float;","bool isnan( float val ) { return ( val < 0.0 || 0.0 < val || val == 0.0 ) ? false : true; }","varying vec2 vTextureCoord;","varying float vColor;","varying float vTextureIndex;","uniform sampler2D uSamplerArray["+this.MAX_TEXTURES+"];","const vec4 BLUE = vec4(1.0, 0.0, 1.0, 1.0);","const vec4 RED = vec4(1.0, 0.0, 0.0, 1.0);","void main(void) {",e," if(vTextureIndex >= "+this.MAX_TEXTURES+".0) { gl_FragColor = BLUE;return;}"," if(isnan(vTextureIndex)) {gl_FragColor = RED;return;}","}"]}else this.fragmentSrc=["// PixiFastShader Fragment Shader.","precision lowp float;","varying vec2 vTextureCoord;","varying float vColor;","varying float vTextureIndex;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;","}"];this.vertexSrc=["// PixiFastShader Vertex Shader.","attribute vec2 aVertexPosition;","attribute vec2 aPositionCoord;","attribute vec2 aScale;","attribute float aRotation;","attribute vec2 aTextureCoord;","attribute float aColor;","attribute float aTextureIndex;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform mat3 uMatrix;","varying vec2 vTextureCoord;","varying float vColor;","varying float vTextureIndex;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {"," vec2 v;"," vec2 sv = aVertexPosition * aScale;"," v.x = (sv.x) * cos(aRotation) - (sv.y) * sin(aRotation);"," v.y = (sv.x) * sin(aRotation) + (sv.y) * cos(aRotation);"," v = ( uMatrix * vec3(v + aPositionCoord , 1.0) ).xy ;"," gl_Position = vec4( ( v / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vTextureIndex = aTextureIndex;"," vColor = aColor;","}"],this.textureCount=0,this.init()},s.PixiFastShader.prototype.constructor=s.PixiFastShader,s.PixiFastShader.prototype.init=function(){var t=this.gl,e=s.compileProgram(t,this.vertexSrc,this.fragmentSrc);if(t.useProgram(e),this.uSampler=s._enableMultiTextureToggle?t.getUniformLocation(e,"uSamplerArray[0]"):t.getUniformLocation(e,"uSampler"),s._enableMultiTextureToggle){var i=[],n=t.createTexture();t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,n),t.texImage2D(t.TEXTURE_2D,0,t.RGB,1,1,0,t.RGB,t.UNSIGNED_BYTE,null);for(var r=0;r<this.MAX_TEXTURES;++r)t.activeTexture(t.TEXTURE0+r),t.bindTexture(t.TEXTURE_2D,n),i.push(r);t.activeTexture(t.TEXTURE0),t.uniform1iv(this.uSampler,i)}this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.dimensions=t.getUniformLocation(e,"dimensions"),this.uMatrix=t.getUniformLocation(e,"uMatrix"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.aPositionCoord=t.getAttribLocation(e,"aPositionCoord"),this.aScale=t.getAttribLocation(e,"aScale"),this.aRotation=t.getAttribLocation(e,"aRotation"),this.aTextureCoord=t.getAttribLocation(e,"aTextureCoord"),this.colorAttribute=t.getAttribLocation(e,"aColor"),this.aTextureIndex=t.getAttribLocation(e,"aTextureIndex"),-1===this.colorAttribute&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aPositionCoord,this.aScale,this.aRotation,this.aTextureCoord,this.colorAttribute,this.aTextureIndex],this.program=e},s.PixiFastShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},s.StripShader=function(t){if(this._UID=Phaser._UID++,this.gl=t,this.program=null,s._enableMultiTextureToggle){var t=this.gl;this.MAX_TEXTURES=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);for(var e="\tif (vTextureIndex == 0.0) { gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord);return;}\n",i=1;i<this.MAX_TEXTURES;++i)e+="\tif (vTextureIndex == "+i+".0) { gl_FragColor = texture2D(uSamplerArray["+i+"], vTextureCoord) ;return;}\n";this.fragmentSrc=["//StripShader Fragment Shader.","precision mediump float;","bool isnan( float val ) { return ( val < 0.0 || 0.0 < val || val == 0.0 ) ? false : true; }","varying vec2 vTextureCoord;","varying float vTextureIndex;","uniform float alpha;","uniform sampler2D uSamplerArray["+this.MAX_TEXTURES+"];","const vec4 BLUE = vec4(1.0, 0.0, 1.0, 1.0);","const vec4 RED = vec4(1.0, 0.0, 0.0, 1.0);","void main(void) {",e," if(vTextureIndex >= "+this.MAX_TEXTURES+".0) { gl_FragColor = BLUE;return;}"," if(isnan(vTextureIndex)) {gl_FragColor = RED;return;}","}"]}else this.fragmentSrc=["//StripShader Fragment Shader.","precision mediump float;","varying vec2 vTextureCoord;","varying float vTextureIndex;","uniform float alpha;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord);","}"];this.vertexSrc=["//StripShader Vertex Shader.","attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute float aTextureIndex;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","varying float vTextureIndex;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vTextureIndex = aTextureIndex;","}"],this.init()},s.StripShader.prototype.constructor=s.StripShader,s.StripShader.prototype.init=function(){var t=this.gl,e=s.compileProgram(t,this.vertexSrc,this.fragmentSrc);if(t.useProgram(e),this.uSampler=s._enableMultiTextureToggle?t.getUniformLocation(e,"uSamplerArray[0]"):t.getUniformLocation(e,"uSampler"),s._enableMultiTextureToggle){var i=[],n=t.createTexture();t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,n),t.texImage2D(t.TEXTURE_2D,0,t.RGB,1,1,0,t.RGB,t.UNSIGNED_BYTE,null);for(var r=0;r<this.MAX_TEXTURES;++r)t.activeTexture(t.TEXTURE0+r),t.bindTexture(t.TEXTURE_2D,n),i.push(r);t.activeTexture(t.TEXTURE0),t.uniform1iv(this.uSampler,i)}this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.colorAttribute=t.getAttribLocation(e,"aColor"),this.aTextureIndex=t.getAttribLocation(e,"aTextureIndex"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.aTextureCoord=t.getAttribLocation(e,"aTextureCoord"),this.attributes=[this.aVertexPosition,this.aTextureCoord,this.aTextureIndex],this.translationMatrix=t.getUniformLocation(e,"translationMatrix"),this.alpha=t.getUniformLocation(e,"alpha"),this.program=e},s.StripShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attribute=null},s.PrimitiveShader=function(t){this._UID=Phaser._UID++,this.gl=t,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {"," gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec4 aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform float alpha;","uniform float flipY;","uniform vec3 tint;","varying vec4 vColor;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);"," vColor = aColor * vec4(tint * alpha, alpha);","}"],this.init()},s.PrimitiveShader.prototype.constructor=s.PrimitiveShader,s.PrimitiveShader.prototype.init=function(){var t=this.gl,e=s.compileProgram(t,this.vertexSrc,this.fragmentSrc);t.useProgram(e),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.tintColor=t.getUniformLocation(e,"tint"),this.flipY=t.getUniformLocation(e,"flipY"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.colorAttribute=t.getAttribLocation(e,"aColor"),this.attributes=[this.aVertexPosition,this.colorAttribute],this.translationMatrix=t.getUniformLocation(e,"translationMatrix"),this.alpha=t.getUniformLocation(e,"alpha"),this.program=e},s.PrimitiveShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},s.ComplexPrimitiveShader=function(t){this._UID=Phaser._UID++,this.gl=t,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {"," gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform vec3 tint;","uniform float alpha;","uniform vec3 color;","uniform float flipY;","varying vec4 vColor;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);"," vColor = vec4(color * alpha * tint, alpha);","}"],this.init()},s.ComplexPrimitiveShader.prototype.constructor=s.ComplexPrimitiveShader,s.ComplexPrimitiveShader.prototype.init=function(){var t=this.gl,e=s.compileProgram(t,this.vertexSrc,this.fragmentSrc);t.useProgram(e),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.tintColor=t.getUniformLocation(e,"tint"),this.color=t.getUniformLocation(e,"color"),this.flipY=t.getUniformLocation(e,"flipY"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.attributes=[this.aVertexPosition,this.colorAttribute],this.translationMatrix=t.getUniformLocation(e,"translationMatrix"),this.alpha=t.getUniformLocation(e,"alpha"),this.program=e},s.ComplexPrimitiveShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attribute=null},s.glContexts=[],s.instances=[],s._enableMultiTextureToggle=!1,s.WebGLRenderer=function(t,e){this.game=t,s.defaultRenderer||(s.defaultRenderer=this),this.extensions={},this.type=Phaser.WEBGL,this.resolution=t.resolution,this.transparent=t.transparent,this.autoResize=!1,this.preserveDrawingBuffer=t.preserveDrawingBuffer,this.clearBeforeRender=t.clearBeforeRender,this.powerPreference=t.powerPreference,this.width=t.width,this.height=t.height,this.view=t.canvas,this._contextOptions={alpha:this.transparent,antialias:t.antialias,failIfMajorPerformanceCaveat:e.failIfMajorPerformanceCaveat,premultipliedAlpha:this.transparent&&"notMultiplied"!==this.transparent,stencil:!0,preserveDrawingBuffer:this.preserveDrawingBuffer,powerPreference:t.powerPreference},this.projection=new s.Point,this.offset=new s.Point,this.shaderManager=new s.WebGLShaderManager,this.spriteBatch=new s.WebGLSpriteBatch(t),this.maskManager=new s.WebGLMaskManager,this.filterManager=new s.WebGLFilterManager,this.stencilManager=new s.WebGLStencilManager,this.blendModeManager=new s.WebGLBlendModeManager,this.renderSession={},this.currentBatchedTextures=[],this.renderSession.game=this.game,this.renderSession.gl=this.gl,this.renderSession.drawCount=0,this.renderSession.shaderManager=this.shaderManager,this.renderSession.maskManager=this.maskManager,this.renderSession.filterManager=this.filterManager,this.renderSession.blendModeManager=this.blendModeManager,this.renderSession.spriteBatch=this.spriteBatch,this.renderSession.stencilManager=this.stencilManager,this.renderSession.renderer=this,this.renderSession.resolution=this.resolution,this.renderSession.roundPixels=e.roundPixels||!1,this.renderSession.maxTextureAvailableSpace=null,this.initContext(),this.mapBlendModes()},s.WebGLRenderer.prototype.constructor=s.WebGLRenderer,s.WebGLRenderer.prototype.initContext=function(){var t=this.view.getContext("webgl",this._contextOptions)||this.view.getContext("experimental-webgl",this._contextOptions);if(this.gl=t,!t)throw new Error("This browser does not support webGL. Try using the canvas renderer");this.maxTextures=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.maxTextureSize=this.gl.getParameter(t.MAX_TEXTURE_SIZE),this.glContextId=t.id=s.WebGLRenderer.glContextId++,s.glContexts[this.glContextId]=t,s.instances[this.glContextId]=this,t.disable(t.DEPTH_TEST),t.disable(t.CULL_FACE),t.enable(t.BLEND),this.shaderManager.setContext(t),this.spriteBatch.setContext(t),this.maskManager.setContext(t),this.filterManager.setContext(t),this.blendModeManager.setContext(t),this.stencilManager.setContext(t),this.renderSession.gl=this.gl,this.resize(this.width,this.height),this.extensions.compression={};var e=t.getExtension("WEBGL_compressed_texture_etc1")||t.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),i=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),n=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");e&&(this.extensions.compression.ETC1=e),i&&(this.extensions.compression.PVRTC=i),n&&(this.extensions.compression.S3TC=n)},s.WebGLRenderer.prototype.setTexturePriority=function(t){if(s._enableMultiTextureToggle){for(var e=function(t){return--t,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t},i=this.gl,n=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),r=i.getParameter(i.MAX_TEXTURE_SIZE),o=this.game.cache._cache.image,a=null,h=0;h<this.currentBatchedTextures.length;h++)(a=this.currentBatchedTextures[h])in o?o[a].base.textureIndex=0:console.warn('setTexturePriority: There is no image "%s" in the image cache.',a);var l=r-e(Math.max(this.width,this.height));this.currentBatchedTextures.length=0;for(var c=0;c<t.length;++c)if((a=t[c])in o){var u=o[a].base;(l-=e(Math.max(u.width,u.height)))<=0?(u.textureIndex=0,console.warn('setTexturePriority: Image "%s" was given textureIndex=0 because there is no available texture space (%s).',a,l)):u.textureIndex=1+c%(n-1),this.currentBatchedTextures.push(a)}else console.warn('setTexturePriority: There is no image "%s" in the image cache.',a);return this.renderSession.maxTextureAvailableSpace=l,this.currentBatchedTextures}console.warn("setTexturePriority error: Multi Texture support hasn't been enabled in the Phaser Game Config.")},s.WebGLRenderer.prototype.render=function(t){if(!this.contextLost){var e=this.gl;e.viewport(0,0,this.width,this.height),e.bindFramebuffer(e.FRAMEBUFFER,null),this.game.clearBeforeRender&&(e.clearColor(t._bgColor.r,t._bgColor.g,t._bgColor.b,t._bgColor.a),e.clear(e.COLOR_BUFFER_BIT)),this.offset.x=this.game.camera._shake.x,this.offset.y=this.game.camera._shake.y,this.renderDisplayObject(t,this.projection)}},s.WebGLRenderer.prototype.renderDisplayObject=function(t,e,i,n){this.renderSession.blendModeManager.setBlendMode(s.blendModes.NORMAL),this.renderSession.drawCount=0,this.renderSession.flipY=i?-1:1,this.renderSession.projection=e,this.renderSession.offset=this.offset,this.spriteBatch.begin(this.renderSession),this.filterManager.begin(this.renderSession,i),t._renderWebGL(this.renderSession,n),this.spriteBatch.end()},s.WebGLRenderer.prototype.resize=function(t,e){this.width=t*this.resolution,this.height=e*this.resolution,this.view.width=this.width,this.view.height=this.height,this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px"),this.gl.viewport(0,0,this.width,this.height),this.projection.x=this.width/2/this.resolution,this.projection.y=-this.height/2/this.resolution},s.WebGLRenderer.prototype.updateCompressedTexture=function(t){if(!t.hasLoaded)return!1;var e=this.gl,i=t.source;return t._glTextures[e.id]||(t._glTextures[e.id]=e.createTexture()),e.activeTexture(e.TEXTURE0+t.textureIndex),e.bindTexture(e.TEXTURE_2D,t._glTextures[e.id]),e.compressedTexImage2D(e.TEXTURE_2D,0,i.glExtensionFormat,i.width,i.height,0,i.textureData),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t.scaleMode===s.scaleModes.LINEAR?e.LINEAR:e.NEAREST),t.mipmap&&Phaser.Math.isPowerOfTwo(t.width,t.height)?(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t.scaleMode===s.scaleModes.LINEAR?e.LINEAR_MIPMAP_LINEAR:e.NEAREST_MIPMAP_NEAREST),e.generateMipmap(e.TEXTURE_2D)):e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t.scaleMode===s.scaleModes.LINEAR?e.LINEAR:e.NEAREST),t._powerOf2?(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT)):(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)),t._dirty[e.id]=!1,!0},s.WebGLRenderer.prototype.updateTexture=function(t){if(!t.hasLoaded||!t.source)return!1;if(t.source.compressionAlgorithm)return this.updateCompressedTexture(t);var e=this.gl;return t._glTextures[e.id]||(t._glTextures[e.id]=e.createTexture()),e.activeTexture(e.TEXTURE0+t.textureIndex),e.bindTexture(e.TEXTURE_2D,t._glTextures[e.id]),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultipliedAlpha),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t.source),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t.scaleMode===s.scaleModes.LINEAR?e.LINEAR:e.NEAREST),t.mipmap&&Phaser.Math.isPowerOfTwo(t.width,t.height)?(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t.scaleMode===s.scaleModes.LINEAR?e.LINEAR_MIPMAP_LINEAR:e.NEAREST_MIPMAP_NEAREST),e.generateMipmap(e.TEXTURE_2D)):e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t.scaleMode===s.scaleModes.LINEAR?e.LINEAR:e.NEAREST),t._powerOf2?(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT)):(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)),t._dirty[e.id]=!1,!0},s.WebGLRenderer.prototype.destroy=function(){s.glContexts[this.glContextId]=null,this.projection=null,this.offset=null,this.shaderManager.destroy(),this.spriteBatch.destroy(),this.maskManager.destroy(),this.filterManager.destroy(),this.shaderManager=null,this.spriteBatch=null,this.maskManager=null,this.filterManager=null,this.gl=null,this.renderSession=null,Phaser.CanvasPool.remove(this),s.instances[this.glContextId]=null,s.WebGLRenderer.glContextId--},s.WebGLRenderer.prototype.mapBlendModes=function(){var t=this.gl;if(!s.blendModesWebGL){var e=[],i=s.blendModes;e[i.NORMAL]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.ADD]=[t.SRC_ALPHA,t.DST_ALPHA],e[i.MULTIPLY]=[t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA],e[i.SCREEN]=[t.SRC_ALPHA,t.ONE],e[i.OVERLAY]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.DARKEN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.LIGHTEN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.COLOR_DODGE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.COLOR_BURN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.HARD_LIGHT]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.SOFT_LIGHT]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.DIFFERENCE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.EXCLUSION]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.HUE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.SATURATION]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.COLOR]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e[i.LUMINOSITY]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],s.blendModesWebGL=e}},s.WebGLRenderer.prototype.getMaxTextureUnit=function(){var t=this.gl;return t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS)},s.enableMultiTexture=function(){s._enableMultiTextureToggle=!0},s.WebGLRenderer.glContextId=0,s.WebGLRenderer.textureArray=[],s.WebGLBlendModeManager=function(){this.currentBlendMode=99999},s.WebGLBlendModeManager.prototype.constructor=s.WebGLBlendModeManager,s.WebGLBlendModeManager.prototype.setContext=function(t){this.gl=t},s.WebGLBlendModeManager.prototype.setBlendMode=function(t){if(this.currentBlendMode===t)return!1;this.currentBlendMode=t;var e=s.blendModesWebGL[this.currentBlendMode];return e&&this.gl.blendFunc(e[0],e[1]),!0},s.WebGLBlendModeManager.prototype.destroy=function(){this.gl=null},s.WebGLMaskManager=function(){},s.WebGLMaskManager.prototype.constructor=s.WebGLMaskManager,s.WebGLMaskManager.prototype.setContext=function(t){this.gl=t},s.WebGLMaskManager.prototype.pushMask=function(t,e){var i=e.gl;t.dirty&&s.WebGLGraphics.updateGraphics(t,i),void 0!==t._webGL[i.id]&&void 0!==t._webGL[i.id].data&&0!==t._webGL[i.id].data.length&&e.stencilManager.pushStencil(t,t._webGL[i.id].data[0],e)},s.WebGLMaskManager.prototype.popMask=function(t,e){var i=this.gl;void 0!==t._webGL[i.id]&&void 0!==t._webGL[i.id].data&&0!==t._webGL[i.id].data.length&&e.stencilManager.popStencil(t,t._webGL[i.id].data[0],e)},s.WebGLMaskManager.prototype.destroy=function(){this.gl=null},s.WebGLStencilManager=function(){this.stencilStack=[],this.reverse=!0,this.count=0},s.WebGLStencilManager.prototype.setContext=function(t){this.gl=t},s.WebGLStencilManager.prototype.pushStencil=function(t,e,i){var s=this.gl;this.bindGraphics(t,e,i),0===this.stencilStack.length&&(s.enable(s.STENCIL_TEST),s.clear(s.STENCIL_BUFFER_BIT),this.reverse=!0,this.count=0),this.stencilStack.push(e);var n=this.count;s.colorMask(!1,!1,!1,!1),s.stencilFunc(s.ALWAYS,0,255),s.stencilOp(s.KEEP,s.KEEP,s.INVERT),1===e.mode?(s.drawElements(s.TRIANGLE_FAN,e.indices.length-4,s.UNSIGNED_SHORT,0),this.reverse?(s.stencilFunc(s.EQUAL,255-n,255),s.stencilOp(s.KEEP,s.KEEP,s.DECR)):(s.stencilFunc(s.EQUAL,n,255),s.stencilOp(s.KEEP,s.KEEP,s.INCR)),s.drawElements(s.TRIANGLE_FAN,4,s.UNSIGNED_SHORT,2*(e.indices.length-4)),this.reverse?s.stencilFunc(s.EQUAL,255-(n+1),255):s.stencilFunc(s.EQUAL,n+1,255),this.reverse=!this.reverse):(this.reverse?(s.stencilFunc(s.EQUAL,n,255),s.stencilOp(s.KEEP,s.KEEP,s.INCR)):(s.stencilFunc(s.EQUAL,255-n,255),s.stencilOp(s.KEEP,s.KEEP,s.DECR)),s.drawElements(s.TRIANGLE_STRIP,e.indices.length,s.UNSIGNED_SHORT,0),this.reverse?s.stencilFunc(s.EQUAL,n+1,255):s.stencilFunc(s.EQUAL,255-(n+1),255)),s.colorMask(!0,!0,!0,!0),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),this.count++},s.WebGLStencilManager.prototype.bindGraphics=function(t,e,i){this._currentGraphics=t;var s,n=this.gl,r=i.projection,o=i.offset;1===e.mode?(s=i.shaderManager.complexPrimitiveShader,i.shaderManager.setShader(s),n.uniform1f(s.flipY,i.flipY),n.uniformMatrix3fv(s.translationMatrix,!1,t.worldTransform.toArray(!0)),n.uniform2f(s.projectionVector,r.x,-r.y),n.uniform2f(s.offsetVector,-o.x,-o.y),n.uniform3fv(s.tintColor,Phaser.Color.hexToRGBArray(t.tint)),n.uniform3fv(s.color,e.color),n.uniform1f(s.alpha,t.worldAlpha*e.alpha),n.bindBuffer(n.ARRAY_BUFFER,e.buffer),n.vertexAttribPointer(s.aVertexPosition,2,n.FLOAT,!1,8,0),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.indexBuffer)):(s=i.shaderManager.primitiveShader,i.shaderManager.setShader(s),n.uniformMatrix3fv(s.translationMatrix,!1,t.worldTransform.toArray(!0)),n.uniform1f(s.flipY,i.flipY),n.uniform2f(s.projectionVector,r.x,-r.y),n.uniform2f(s.offsetVector,-o.x,-o.y),n.uniform3fv(s.tintColor,Phaser.Color.hexToRGBArray(t.tint)),n.uniform1f(s.alpha,t.worldAlpha),n.bindBuffer(n.ARRAY_BUFFER,e.buffer),n.vertexAttribPointer(s.aVertexPosition,2,n.FLOAT,!1,24,0),n.vertexAttribPointer(s.colorAttribute,4,n.FLOAT,!1,24,8),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.indexBuffer))},s.WebGLStencilManager.prototype.popStencil=function(t,e,i){var s=this.gl;if(this.stencilStack.pop(),this.count--,0===this.stencilStack.length)s.disable(s.STENCIL_TEST);else{var n=this.count;this.bindGraphics(t,e,i),s.colorMask(!1,!1,!1,!1),1===e.mode?(this.reverse=!this.reverse,this.reverse?(s.stencilFunc(s.EQUAL,255-(n+1),255),s.stencilOp(s.KEEP,s.KEEP,s.INCR)):(s.stencilFunc(s.EQUAL,n+1,255),s.stencilOp(s.KEEP,s.KEEP,s.DECR)),s.drawElements(s.TRIANGLE_FAN,4,s.UNSIGNED_SHORT,2*(e.indices.length-4)),s.stencilFunc(s.ALWAYS,0,255),s.stencilOp(s.KEEP,s.KEEP,s.INVERT),s.drawElements(s.TRIANGLE_FAN,e.indices.length-4,s.UNSIGNED_SHORT,0),this.reverse?s.stencilFunc(s.EQUAL,n,255):s.stencilFunc(s.EQUAL,255-n,255)):(this.reverse?(s.stencilFunc(s.EQUAL,n+1,255),s.stencilOp(s.KEEP,s.KEEP,s.DECR)):(s.stencilFunc(s.EQUAL,255-(n+1),255),s.stencilOp(s.KEEP,s.KEEP,s.INCR)),s.drawElements(s.TRIANGLE_STRIP,e.indices.length,s.UNSIGNED_SHORT,0),this.reverse?s.stencilFunc(s.EQUAL,n,255):s.stencilFunc(s.EQUAL,255-n,255)),s.colorMask(!0,!0,!0,!0),s.stencilOp(s.KEEP,s.KEEP,s.KEEP)}},s.WebGLStencilManager.prototype.destroy=function(){this.stencilStack=null,this.gl=null},s.WebGLShaderManager=function(){this.maxAttibs=10,this.attribState=[],this.tempAttribState=[];for(var t=0;t<this.maxAttibs;t++)this.attribState[t]=!1;this.stack=[]},s.WebGLShaderManager.prototype.constructor=s.WebGLShaderManager,s.WebGLShaderManager.prototype.setContext=function(t){this.gl=t,this.primitiveShader=new s.PrimitiveShader(t),this.complexPrimitiveShader=new s.ComplexPrimitiveShader(t),this.defaultShader=new s.PixiShader(t),this.fastShader=new s.PixiFastShader(t),this.stripShader=new s.StripShader(t),this.creatureShader=s.CreatureShader?new s.CreatureShader(t):null,this.setShader(this.defaultShader)},s.WebGLShaderManager.prototype.setAttribs=function(t){var e;for(e=0;e<this.tempAttribState.length;e++)this.tempAttribState[e]=!1;for(e=0;e<t.length;e++){var i=t[e];this.tempAttribState[i]=!0}var s=this.gl;for(e=0;e<this.attribState.length;e++)this.attribState[e]!==this.tempAttribState[e]&&(this.attribState[e]=this.tempAttribState[e],this.tempAttribState[e]?s.enableVertexAttribArray(e):s.disableVertexAttribArray(e))},s.WebGLShaderManager.prototype.setShader=function(t){return this._currentId!==t._UID&&(this._currentId=t._UID,this.currentShader=t,this.gl.useProgram(t.program),this.setAttribs(t.attributes),!0)},s.WebGLShaderManager.prototype.destroy=function(){this.attribState=null,this.tempAttribState=null,this.primitiveShader.destroy(),this.complexPrimitiveShader.destroy(),this.defaultShader.destroy(),this.fastShader.destroy(),this.stripShader.destroy(),this.creatureShader&&this.creatureShader.destroy(),this.gl=null},s.WebGLSpriteBatch=function(t){this.game=t,this.vertSize=5,this.size=2e3,this.vertexSize=24;var e=this.vertexSize*this.size*4,i=6*this.size;this.vertices=new ArrayBuffer(e),this.positions=new Float32Array(this.vertices),this.colors=new Uint32Array(this.vertices),this.indices=new Uint16Array(i),this.lastIndexCount=0;for(var s=0,n=0;s<i;s+=6,n+=4)this.indices[s+0]=n+0,this.indices[s+1]=n+1,this.indices[s+2]=n+2,this.indices[s+3]=n+0,this.indices[s+4]=n+2,this.indices[s+5]=n+3;this.drawing=!1,this.currentBatchSize=0,this.currentBaseTexture=null,this.dirty=!0,this.textures=[],this.blendModes=[],this.shaders=[],this.sprites=[],this.defaultShader=null},s.WebGLSpriteBatch.prototype.setContext=function(t){if(this.MAX_TEXTURES=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.gl=t,s._enableMultiTextureToggle){for(var e="\tif (vTextureIndex == 0.0) {gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;return;}\n",i=1;i<this.MAX_TEXTURES;++i)e+="\tif (vTextureIndex == "+i+".0) {gl_FragColor = texture2D(uSamplerArray["+i+"], vTextureCoord) * vColor;return;}\n";this.defaultShader=new Phaser.Filter(this.game,void 0,["//WebGLSpriteBatch Fragment Shader.","precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","uniform sampler2D uSamplerArray["+this.MAX_TEXTURES+"];","void main(void) {",e,"\tgl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;","}"])}else this.defaultShader=new Phaser.Filter(this.game,void 0,["//WebGLSpriteBatch Fragment Shader.","precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;","}"]);this.vertexBuffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.indices,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertices,t.DYNAMIC_DRAW),this.currentBlendMode=99999;var n=new s.PixiShader(t);n.fragmentSrc=this.defaultShader.fragmentSrc,n.uniforms={},n.init(),this.defaultShader.shaders[t.id]=n},s.WebGLSpriteBatch.prototype.begin=function(t){this.renderSession=t,this.shader=this.renderSession.shaderManager.defaultShader,this.start()},s.WebGLSpriteBatch.prototype.end=function(){this.flush()},s.WebGLSpriteBatch.prototype.render=function(t,e){var i=t.texture,s=t.worldTransform;e&&(s=e),this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=i.baseTexture);var n=i._uvs;if(n){var r,o,a,h,l=t.anchor.x,c=t.anchor.y;if(i.trim){var u=i.trim;r=(o=u.x-l*u.width)+i.crop.width,a=(h=u.y-c*u.height)+i.crop.height}else r=i.frame.width*(1-l),o=i.frame.width*-l,a=i.frame.height*(1-c),h=i.frame.height*-c;var d=this.currentBatchSize*this.vertexSize,p=i.baseTexture.resolution,f=i.baseTexture.textureIndex,g=s.a/p,m=s.b/p,y=s.c/p,v=s.d/p,x=s.tx,b=s.ty,_=i.crop.height;if(i.rotated){var w=s.a,T=s.b,P=s.c,C=s.d,S=o,A=r;x=s.c*_+x,b=s.d*_+b,g=6.123233995736766e-17*w-P,m=6.123233995736766e-17*T-C,y=w+6.123233995736766e-17*P,v=T+6.123233995736766e-17*C,i._updateUvsInverted(),r=a,o=h,a=A,h=S}var E=this.colors,M=this.positions,R=t.tint,L=(R>>16)+(65280&R)+((255&R)<<16)+(255*t.worldAlpha<<24);this.renderSession.roundPixels?(M[d++]=g*o+y*h+x|0,M[d++]=v*h+m*o+b|0,M[d++]=n.x0,M[d++]=n.y0,E[d++]=L,M[d++]=f,M[d++]=g*r+y*h+x|0,M[d++]=v*h+m*r+b|0,M[d++]=n.x1,M[d++]=n.y1,E[d++]=L,M[d++]=f,M[d++]=g*r+y*a+x|0,M[d++]=v*a+m*r+b|0,M[d++]=n.x2,M[d++]=n.y2,E[d++]=L,M[d++]=f,M[d++]=g*o+y*a+x|0,M[d++]=v*a+m*o+b|0,M[d++]=n.x3,M[d++]=n.y3,E[d++]=L,M[d++]=f):(M[d++]=g*o+y*h+x,M[d++]=v*h+m*o+b,M[d++]=n.x0,M[d++]=n.y0,E[d++]=L,M[d++]=f,M[d++]=g*r+y*h+x,M[d++]=v*h+m*r+b,M[d++]=n.x1,M[d++]=n.y1,E[d++]=L,M[d++]=f,M[d++]=g*r+y*a+x,M[d++]=v*a+m*r+b,M[d++]=n.x2,M[d++]=n.y2,E[d++]=L,M[d++]=f,M[d++]=g*o+y*a+x,M[d++]=v*a+m*o+b,M[d++]=n.x3,M[d++]=n.y3,E[d++]=L,M[d++]=f),this.sprites[this.currentBatchSize++]=t}},s.WebGLSpriteBatch.prototype.renderTilingSprite=function(t){var e=t.tilingTexture,i=t.texture.baseTexture.textureIndex;this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=e.baseTexture),t._uvs||(t._uvs=new s.TextureUvs);var n=t._uvs,r=e.baseTexture.width,o=e.baseTexture.height;t.tilePosition.x%=r*t.tileScaleOffset.x,t.tilePosition.y%=o*t.tileScaleOffset.y;var a=t.tilePosition.x/(r*t.tileScaleOffset.x),h=t.tilePosition.y/(o*t.tileScaleOffset.y),l=t.width/r/(t.tileScale.x*t.tileScaleOffset.x),c=t.height/o/(t.tileScale.y*t.tileScaleOffset.y);n.x0=0-a,n.y0=0-h,n.x1=1*l-a,n.y1=0-h,n.x2=1*l-a,n.y2=1*c-h,n.x3=0-a,n.y3=1*c-h;var u=t.tint,d=(u>>16)+(65280&u)+((255&u)<<16)+(255*t.worldAlpha<<24),p=this.positions,f=this.colors,g=t.width,m=t.height,y=t.anchor.x,v=t.anchor.y,x=g*(1-y),b=g*-y,_=m*(1-v),w=m*-v,T=this.currentBatchSize*this.vertexSize,P=e.baseTexture.resolution,C=t.worldTransform,S=C.a/P,A=C.b/P,E=C.c/P,M=C.d/P,R=C.tx,L=C.ty;p[T++]=S*b+E*w+R,p[T++]=M*w+A*b+L,p[T++]=n.x0,p[T++]=n.y0,f[T++]=d,p[T++]=i,p[T++]=S*x+E*w+R,p[T++]=M*w+A*x+L,p[T++]=n.x1,p[T++]=n.y1,f[T++]=d,p[T++]=i,p[T++]=S*x+E*_+R,p[T++]=M*_+A*x+L,p[T++]=n.x2,p[T++]=n.y2,f[T++]=d,p[T++]=i,p[T++]=S*b+E*_+R,p[T++]=M*_+A*b+L,p[T++]=n.x3,p[T++]=n.y3,f[T++]=d,p[T++]=i,this.sprites[this.currentBatchSize++]=t},s.WebGLSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var t,e=this.gl;if(this.dirty){this.dirty=!1,t=this.defaultShader.shaders[e.id],e.activeTexture(e.TEXTURE0),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var i=this.vertexSize;e.vertexAttribPointer(t.aVertexPosition,2,e.FLOAT,!1,i,0),e.vertexAttribPointer(t.aTextureCoord,2,e.FLOAT,!1,i,8),e.vertexAttribPointer(t.colorAttribute,4,e.UNSIGNED_BYTE,!0,i,16),e.vertexAttribPointer(t.aTextureIndex,1,e.FLOAT,!1,i,20)}if(this.currentBatchSize>.5*this.size)e.bufferSubData(e.ARRAY_BUFFER,0,this.vertices);else{e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer);var n=this.positions.subarray(0,this.currentBatchSize*this.vertexSize);e.bufferSubData(e.ARRAY_BUFFER,0,n)}for(var r,o,a,h,l=0,c=0,u=null,d=this.renderSession.blendModeManager.currentBlendMode,p=null,f=!1,g=!1,m=0,y=this.currentBatchSize;m<y;m++){r=(h=this.sprites[m]).tilingTexture?h.tilingTexture.baseTexture:h.texture.baseTexture,f=d!==(o=h.blendMode),g=p!==(a=h.shader||this.defaultShader);var v=r.skipRender;if(v&&h.children.length>0&&(v=!1),(u!==r&&!v||f||g)&&(this.renderBatch(u,l,c),c=m,l=0,u=r,f&&(d=o,this.renderSession.blendModeManager.setBlendMode(d)),g)){(t=(p=a).shaders[e.id])||((t=new s.PixiShader(e)).fragmentSrc=p.fragmentSrc,t.uniforms=p.uniforms,t.init(),p.shaders[e.id]=t),this.renderSession.shaderManager.setShader(t),t.dirty&&t.syncUniforms();var x=this.renderSession.projection;e.uniform2f(t.projectionVector,x.x,x.y);var b=this.renderSession.offset;e.uniform2f(t.offsetVector,b.x,b.y)}l++}this.renderBatch(u,l,c),this.currentBatchSize=0}},s.WebGLSpriteBatch.prototype.renderBatch=function(t,e,i){if(0!==e){var s=this.gl;if(t._dirty[s.id]){if(!this.renderSession.renderer.updateTexture(t))return}else s.bindTexture(s.TEXTURE_2D,t._glTextures[s.id]);s.drawElements(s.TRIANGLES,6*e,s.UNSIGNED_SHORT,6*i*2),this.renderSession.drawCount++}},s.WebGLSpriteBatch.prototype.stop=function(){this.flush(),this.dirty=!0},s.WebGLSpriteBatch.prototype.start=function(){this.dirty=!0},s.WebGLSpriteBatch.prototype.destroy=function(){this.vertices=null,this.indices=null,this.gl.deleteBuffer(this.vertexBuffer),this.gl.deleteBuffer(this.indexBuffer),this.currentBaseTexture=null,this.gl=null},s.WebGLFastSpriteBatch=function(t){this.vertSize=11,this.maxSize=6e3,this.size=this.maxSize;var e=4*this.size*this.vertSize,i=6*this.maxSize;this.vertices=new Float32Array(e),this.indices=new Uint16Array(i),this.vertexBuffer=null,this.indexBuffer=null,this.lastIndexCount=0;for(var s=0,n=0;s<i;s+=6,n+=4)this.indices[s+0]=n+0,this.indices[s+1]=n+1,this.indices[s+2]=n+2,this.indices[s+3]=n+0,this.indices[s+4]=n+2,this.indices[s+5]=n+3;this.drawing=!1,this.currentBatchSize=0,this.currentBaseTexture=null,this.currentBlendMode=0,this.renderSession=null,this.shader=null,this.matrix=null,this.setContext(t)},s.WebGLFastSpriteBatch.prototype.constructor=s.WebGLFastSpriteBatch,s.WebGLFastSpriteBatch.prototype.setContext=function(t){this.gl=t,this.vertexBuffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.indices,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertices,t.DYNAMIC_DRAW)},s.WebGLFastSpriteBatch.prototype.begin=function(t,e){this.renderSession=e,this.shader=this.renderSession.shaderManager.fastShader,this.matrix=t.worldTransform.toArray(!0),this.start()},s.WebGLFastSpriteBatch.prototype.end=function(){this.flush()},s.WebGLFastSpriteBatch.prototype.render=function(t){var e=t.children,i=e[0];if(i.texture._uvs){this.currentBaseTexture=i.texture.baseTexture,i.blendMode!==this.renderSession.blendModeManager.currentBlendMode&&(this.flush(),this.renderSession.blendModeManager.setBlendMode(i.blendMode));var n=this.currentBaseTexture.textureIndex,r=this.gl;r.activeTexture(r.TEXTURE0+n),r.bindTexture(r.TEXTURE_2D,this.currentBaseTexture._glTextures[r.id]),s.WebGLRenderer.textureArray[n]=this.currentBaseTexture;for(var o=0,a=e.length;o<a;o++)this.renderSprite(e[o]);this.flush()}},s.WebGLFastSpriteBatch.prototype.renderSprite=function(t){var e=t.texture.baseTexture,i=this.gl,n=t.texture.baseTexture.textureIndex;if((s.WebGLRenderer.textureArray[n]==e||!e._glTextures[i.id]||t.texture.baseTexture.skipRender||(this.flush(),i.activeTexture(i.TEXTURE0+n),i.bindTexture(i.TEXTURE_2D,e._glTextures[i.id]),s.WebGLRenderer.textureArray[n]=e,t.texture._uvs))&&t.visible){var r,o,a,h,l,c,u,d,p=this.vertices;if(r=t.texture._uvs,o=t.texture.frame.width,a=t.texture.frame.height,t.texture.trim){var f=t.texture.trim;h=(l=f.x-t.anchor.x*f.width)+t.texture.crop.width,c=(u=f.y-t.anchor.y*f.height)+t.texture.crop.height}else h=o*(1-t.anchor.x),l=o*-t.anchor.x,c=a*(1-t.anchor.y),u=a*-t.anchor.y;d=4*this.currentBatchSize*this.vertSize,p[d++]=l,p[d++]=u,p[d++]=t.position.x,p[d++]=t.position.y,p[d++]=t.scale.x,p[d++]=t.scale.y,p[d++]=t.rotation,p[d++]=r.x0,p[d++]=r.y1,p[d++]=t.alpha,p[d++]=n,p[d++]=h,p[d++]=u,p[d++]=t.position.x,p[d++]=t.position.y,p[d++]=t.scale.x,p[d++]=t.scale.y,p[d++]=t.rotation,p[d++]=r.x1,p[d++]=r.y1,p[d++]=t.alpha,p[d++]=n,p[d++]=h,p[d++]=c,p[d++]=t.position.x,p[d++]=t.position.y,p[d++]=t.scale.x,p[d++]=t.scale.y,p[d++]=t.rotation,p[d++]=r.x2,p[d++]=r.y2,p[d++]=t.alpha,p[d++]=n,p[d++]=l,p[d++]=c,p[d++]=t.position.x,p[d++]=t.position.y,p[d++]=t.scale.x,p[d++]=t.scale.y,p[d++]=t.rotation,p[d++]=r.x3,p[d++]=r.y3,p[d++]=t.alpha,p[d++]=n,++this.currentBatchSize>=this.size&&this.flush()}},s.WebGLFastSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var t=this.gl;if(this.currentBaseTexture._glTextures[t.id]){if(this.currentBatchSize>.5*this.size)t.bufferSubData(t.ARRAY_BUFFER,0,this.vertices);else{var e=this.vertices.subarray(0,4*this.currentBatchSize*this.vertSize);t.bufferSubData(t.ARRAY_BUFFER,0,e)}t.drawElements(t.TRIANGLES,6*this.currentBatchSize,t.UNSIGNED_SHORT,0),this.currentBatchSize=0,this.renderSession.drawCount++}else this.renderSession.renderer.updateTexture(this.currentBaseTexture,t)}},s.WebGLFastSpriteBatch.prototype.stop=function(){this.flush()},s.WebGLFastSpriteBatch.prototype.start=function(){var t=this.gl;t.activeTexture(t.TEXTURE0),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var e=this.renderSession.projection;t.uniform2f(this.shader.projectionVector,e.x,e.y),t.uniformMatrix3fv(this.shader.uMatrix,!1,this.matrix);var i=4*this.vertSize;t.vertexAttribPointer(this.shader.aVertexPosition,2,t.FLOAT,!1,i,0),t.vertexAttribPointer(this.shader.aPositionCoord,2,t.FLOAT,!1,i,8),t.vertexAttribPointer(this.shader.aScale,2,t.FLOAT,!1,i,16),t.vertexAttribPointer(this.shader.aRotation,1,t.FLOAT,!1,i,24),t.vertexAttribPointer(this.shader.aTextureCoord,2,t.FLOAT,!1,i,28),t.vertexAttribPointer(this.shader.colorAttribute,1,t.FLOAT,!1,i,36),t.vertexAttribPointer(this.shader.aTextureIndex,1,t.FLOAT,!1,i,40)},s.WebGLFilterManager=function(){this.filterStack=[],this.offsetX=0,this.offsetY=0},s.WebGLFilterManager.prototype.constructor=s.WebGLFilterManager,s.WebGLFilterManager.prototype.setContext=function(t){this.gl=t,this.texturePool=[],this.initShaderBuffers()},s.WebGLFilterManager.prototype.begin=function(t,e){this.renderSession=t,this.defaultShader=t.shaderManager.defaultShader;var i=this.renderSession.projection;this.width=2*i.x,this.height=2*-i.y,this.buffer=e},s.WebGLFilterManager.prototype.pushFilter=function(t){var e=this.gl,i=this.renderSession.projection,n=this.renderSession.offset;t._filterArea=t.target.filterArea||t.target.getBounds(),t._previous_stencil_mgr=this.renderSession.stencilManager,this.renderSession.stencilManager=new s.WebGLStencilManager,this.renderSession.stencilManager.setContext(e),e.disable(e.STENCIL_TEST),this.filterStack.push(t);var r=t.filterPasses[0];this.offsetX+=t._filterArea.x,this.offsetY+=t._filterArea.y;var o=this.texturePool.pop();o?o.resize(this.width*this.renderSession.resolution,this.height*this.renderSession.resolution):o=new s.FilterTexture(this.gl,this.width*this.renderSession.resolution,this.height*this.renderSession.resolution),e.bindTexture(e.TEXTURE_2D,o.texture);var a=t._filterArea,h=r.padding;a.x-=h,a.y-=h,a.width+=2*h,a.height+=2*h,a.x<0&&(a.x=0),a.width>this.width&&(a.width=this.width),a.y<0&&(a.y=0),a.height>this.height&&(a.height=this.height),e.bindFramebuffer(e.FRAMEBUFFER,o.frameBuffer),e.viewport(0,0,a.width*this.renderSession.resolution,a.height*this.renderSession.resolution),i.x=a.width/2,i.y=-a.height/2,n.x=-a.x,n.y=-a.y,e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),t._glFilterTexture=o},s.WebGLFilterManager.prototype.popFilter=function(){var t=this.gl,e=this.filterStack.pop(),i=e._filterArea,n=e._glFilterTexture,r=this.renderSession.projection,o=this.renderSession.offset;if(e.filterPasses.length>1){t.viewport(0,0,i.width*this.renderSession.resolution,i.height*this.renderSession.resolution),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=0,this.vertexArray[1]=i.height,this.vertexArray[2]=i.width,this.vertexArray[3]=i.height,this.vertexArray[4]=0,this.vertexArray[5]=0,this.vertexArray[6]=i.width,this.vertexArray[7]=0,t.bufferSubData(t.ARRAY_BUFFER,0,this.vertexArray),t.bindBuffer(t.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=i.width/this.width,this.uvArray[5]=i.height/this.height,this.uvArray[6]=i.width/this.width,this.uvArray[7]=i.height/this.height,t.bufferSubData(t.ARRAY_BUFFER,0,this.uvArray);var a=n,h=this.texturePool.pop();h||(h=new s.FilterTexture(this.gl,this.width*this.renderSession.resolution,this.height*this.renderSession.resolution)),h.resize(this.width*this.renderSession.resolution,this.height*this.renderSession.resolution),t.bindFramebuffer(t.FRAMEBUFFER,h.frameBuffer),t.clear(t.COLOR_BUFFER_BIT),t.disable(t.BLEND);for(var l=0;l<e.filterPasses.length-1;l++){var c=e.filterPasses[l];t.bindFramebuffer(t.FRAMEBUFFER,h.frameBuffer),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,a.texture),this.applyFilterPass(c,i,i.width,i.height);var u=a;a=h,h=u}t.enable(t.BLEND),n=a,this.texturePool.push(h)}var d=e.filterPasses[e.filterPasses.length-1];this.offsetX-=i.x,this.offsetY-=i.y;var p=this.width,f=this.height,g=0,m=0,y=this.buffer;if(0===this.filterStack.length)t.colorMask(!0,!0,!0,!0);else{var v=this.filterStack[this.filterStack.length-1];p=(i=v._filterArea).width,f=i.height,g=i.x,m=i.y,y=v._glFilterTexture.frameBuffer}r.x=p/2,r.y=-f/2,o.x=g,o.y=m;var x=(i=e._filterArea).x-g,b=i.y-m;t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=x,this.vertexArray[1]=b+i.height,this.vertexArray[2]=x+i.width,this.vertexArray[3]=b+i.height,this.vertexArray[4]=x,this.vertexArray[5]=b,this.vertexArray[6]=x+i.width,this.vertexArray[7]=b,t.bufferSubData(t.ARRAY_BUFFER,0,this.vertexArray),t.bindBuffer(t.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=i.width/this.width,this.uvArray[5]=i.height/this.height,this.uvArray[6]=i.width/this.width,this.uvArray[7]=i.height/this.height,t.bufferSubData(t.ARRAY_BUFFER,0,this.uvArray),t.viewport(0,0,p*this.renderSession.resolution,f*this.renderSession.resolution),t.bindFramebuffer(t.FRAMEBUFFER,y),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,n.texture),this.renderSession.stencilManager&&this.renderSession.stencilManager.destroy(),this.renderSession.stencilManager=e._previous_stencil_mgr,e._previous_stencil_mgr=null,this.renderSession.stencilManager.count>0?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.applyFilterPass(d,i,p,f),this.texturePool.push(n),e._glFilterTexture=null},s.WebGLFilterManager.prototype.applyFilterPass=function(t,e,i,n){var r=this.gl,o=t.shaders[r.id];o||((o=new s.PixiShader(r)).fragmentSrc=t.fragmentSrc,o.uniforms=t.uniforms,o.init(!0),t.shaders[r.id]=o),this.renderSession.shaderManager.setShader(o),r.uniform2f(o.projectionVector,i/2,-n/2),r.uniform2f(o.offsetVector,0,0),t.uniforms.dimensions&&(t.uniforms.dimensions.value[0]=this.width,t.uniforms.dimensions.value[1]=this.height,t.uniforms.dimensions.value[2]=this.vertexArray[0],t.uniforms.dimensions.value[3]=this.vertexArray[5]),o.syncUniforms(),r.bindBuffer(r.ARRAY_BUFFER,this.vertexBuffer),r.vertexAttribPointer(o.aVertexPosition,2,r.FLOAT,!1,0,0),r.bindBuffer(r.ARRAY_BUFFER,this.uvBuffer),r.vertexAttribPointer(o.aTextureCoord,2,r.FLOAT,!1,0,0),r.bindBuffer(r.ARRAY_BUFFER,this.colorBuffer),r.vertexAttribPointer(o.colorAttribute,2,r.FLOAT,!1,0,0),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,this.indexBuffer),r.drawElements(r.TRIANGLES,6,r.UNSIGNED_SHORT,0),this.renderSession.drawCount++},s.WebGLFilterManager.prototype.initShaderBuffers=function(){var t=this.gl;this.vertexBuffer=t.createBuffer(),this.uvBuffer=t.createBuffer(),this.colorBuffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),this.vertexArray=new Float32Array([0,0,1,0,0,1,1,1]),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertexArray,t.STATIC_DRAW),this.uvArray=new Float32Array([0,0,1,0,0,1,1,1]),t.bindBuffer(t.ARRAY_BUFFER,this.uvBuffer),t.bufferData(t.ARRAY_BUFFER,this.uvArray,t.STATIC_DRAW),this.colorArray=new Float32Array([1,16777215,1,16777215,1,16777215,1,16777215]),t.bindBuffer(t.ARRAY_BUFFER,this.colorBuffer),t.bufferData(t.ARRAY_BUFFER,this.colorArray,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,new Uint16Array([0,1,2,1,3,2]),t.STATIC_DRAW)},s.WebGLFilterManager.prototype.destroy=function(){var t=this.gl;this.filterStack=null,this.offsetX=0,this.offsetY=0;for(var e=0;e<this.texturePool.length;e++)this.texturePool[e].destroy();this.texturePool=null,t.deleteBuffer(this.vertexBuffer),t.deleteBuffer(this.uvBuffer),t.deleteBuffer(this.colorBuffer),t.deleteBuffer(this.indexBuffer)};var n={36054:"Incomplete attachment",36055:"Missing attachment",36057:"Incomplete dimensions",36061:"Framebuffer unsupported"};return s.FilterTexture=function(t,i,n,r,o){o="number"==typeof o?o:0,this.gl=t,this.frameBuffer=e(t,i,n,r||s.scaleModes.DEFAULT,o),this.texture=this.frameBuffer.targetTexture,this.width=i,this.height=n,this.renderBuffer=this.frameBuffer.renderBuffer},s.FilterTexture.prototype.constructor=s.FilterTexture,s.FilterTexture.prototype.clear=function(){var t=this.gl;t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT)},s.FilterTexture.prototype.resize=function(t,e){if(this.width!==t||this.height!==e){this.width=t,this.height=e;var i=this.gl;i.bindTexture(i.TEXTURE_2D,this.texture),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,t,e,0,i.RGBA,i.UNSIGNED_BYTE,null),i.bindRenderbuffer(i.RENDERBUFFER,this.renderBuffer),i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,t,e)}},s.FilterTexture.prototype.destroy=function(){var t=this.gl;t.deleteFramebuffer(this.frameBuffer),t.deleteTexture(this.texture),this.frameBuffer=null,this.texture=null},s.CanvasBuffer=function(t,e){this.width=t,this.height=e,this.canvas=Phaser.CanvasPool.create(this,this.width,this.height),this.context=this.canvas.getContext("2d"),this.canvas.width=t,this.canvas.height=e},s.CanvasBuffer.prototype.constructor=s.CanvasBuffer,s.CanvasBuffer.prototype.clear=function(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.width,this.height)},s.CanvasBuffer.prototype.resize=function(t,e){this.width=this.canvas.width=t,this.height=this.canvas.height=e},s.CanvasBuffer.prototype.destroy=function(){Phaser.CanvasPool.remove(this)},s.CanvasMaskManager=function(){},s.CanvasMaskManager.prototype.constructor=s.CanvasMaskManager,s.CanvasMaskManager.prototype.pushMask=function(t,e){var i=e.context;i.save();var n=t.alpha,r=t.worldTransform,o=e.resolution;i.setTransform(r.a*o,r.b*o,r.c*o,r.d*o,r.tx*o,r.ty*o),s.CanvasGraphics.renderGraphicsMask(t,i),i.clip(),t.worldAlpha=n},s.CanvasMaskManager.prototype.popMask=function(t){t.context.restore()},s.CanvasTinter=function(){},s.CanvasTinter.getTintedTexture=function(t,e){var i=t.tintedTexture||Phaser.CanvasPool.create(this);return s.CanvasTinter.tintMethod(t.texture,e,i),i},s.CanvasTinter.tintWithMultiply=function(t,e,i){var s=i.getContext("2d"),n=t.crop,r=n.width,o=n.height;t.rotated&&(r=o,o=n.width),i.width===r&&i.height===o||(i.width=r,i.height=o),s.clearRect(0,0,r,o),s.fillStyle="#"+("00000"+(0|e).toString(16)).substr(-6),s.fillRect(0,0,r,o),s.globalCompositeOperation="multiply",s.drawImage(t.baseTexture.source,n.x,n.y,r,o,0,0,r,o),s.globalCompositeOperation="destination-atop",s.drawImage(t.baseTexture.source,n.x,n.y,r,o,0,0,r,o)},s.CanvasTinter.tintWithPerPixel=function(t,e,i){var n=i.getContext("2d"),r=t.crop,o=r.width,a=r.height;t.rotated&&(o=a,a=r.width),i.width===o&&i.height===a||(i.width=o,i.height=a),n.globalCompositeOperation="copy",n.drawImage(t.baseTexture.source,r.x,r.y,o,a,0,0,o,a);for(var h=Phaser.Color.hexToRGBArray(e),l=h[0],c=h[1],u=h[2],d=n.getImageData(0,0,o,a),p=d.data,f=0;f<p.length;f+=4)if(p[f+0]*=l,p[f+1]*=c,p[f+2]*=u,!s.CanvasTinter.canHandleAlpha){var g=p[f+3];p[f+0]/=255/g,p[f+1]/=255/g,p[f+2]/=255/g}n.putImageData(d,0,0)},s.CanvasRenderer=function(t,e){if(this.game=t,s.defaultRenderer||(s.defaultRenderer=this),this.type=Phaser.CANVAS,this.resolution=t.resolution,this.clearBeforeRender=t.clearBeforeRender,this.transparent=t.transparent,this.autoResize=!1,this.width=t.width*this.resolution,this.height=t.height*this.resolution,this.view=t.canvas,this.context=this.view.getContext("2d",{alpha:this.transparent}),!this.context)throw new Error("Failed to create a Canvas 2d context.");this.refresh=!0,this.count=0,this.maskManager=new s.CanvasMaskManager,this.renderSession={context:this.context,maskManager:this.maskManager,scaleMode:null,smoothProperty:Phaser.Canvas.getSmoothingPrefix(this.context),roundPixels:e.roundPixels||!1},this.mapBlendModes(),this.resize(this.width,this.height)},s.CanvasRenderer.prototype.constructor=s.CanvasRenderer,s.CanvasRenderer.prototype.render=function(t){this.context.setTransform(1,0,0,1,0,0),this.context.globalAlpha=1,this.renderSession.currentBlendMode=0,this.renderSession.shakeX=this.game.camera._shake.x,this.renderSession.shakeY=this.game.camera._shake.y,this.context.globalCompositeOperation="source-over",navigator.isCocoonJS&&this.view.screencanvas&&(this.context.fillStyle="black",this.context.clear()),this.clearBeforeRender&&(this.transparent?this.context.clearRect(0,0,this.width,this.height):t._bgColor&&(this.context.fillStyle=t._bgColor.rgba,this.context.fillRect(0,0,this.width,this.height))),this.renderDisplayObject(t)},s.CanvasRenderer.prototype.setTexturePriority=function(){},s.CanvasRenderer.prototype.destroy=function(t){void 0===t&&(t=!0),t&&this.view.parent&&this.view.parent.removeChild(this.view),this.view=null,this.context=null,this.maskManager=null,this.renderSession=null},s.CanvasRenderer.prototype.resize=function(t,e){this.width=t*this.resolution,this.height=e*this.resolution,this.view.width=this.width,this.view.height=this.height,this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px"),this.renderSession.smoothProperty&&(this.context[this.renderSession.smoothProperty]=this.renderSession.scaleMode===s.scaleModes.LINEAR)},s.CanvasRenderer.prototype.renderDisplayObject=function(t,e,i){this.renderSession.context=e||this.context,this.renderSession.resolution=this.resolution,t._renderCanvas(this.renderSession,i)},s.CanvasRenderer.prototype.mapBlendModes=function(){if(!s.blendModesCanvas){var t=[],e=s.blendModes,i=this.game.device.canUseMultiply;t[e.NORMAL]="source-over",t[e.ADD]="lighter",t[e.MULTIPLY]=i?"multiply":"source-over",t[e.SCREEN]=i?"screen":"source-over",t[e.OVERLAY]=i?"overlay":"source-over",t[e.DARKEN]=i?"darken":"source-over",t[e.LIGHTEN]=i?"lighten":"source-over",t[e.COLOR_DODGE]=i?"color-dodge":"source-over",t[e.COLOR_BURN]=i?"color-burn":"source-over",t[e.HARD_LIGHT]=i?"hard-light":"source-over",t[e.SOFT_LIGHT]=i?"soft-light":"source-over",t[e.DIFFERENCE]=i?"difference":"source-over",t[e.EXCLUSION]=i?"exclusion":"source-over",t[e.HUE]=i?"hue":"source-over",t[e.SATURATION]=i?"saturation":"source-over",t[e.COLOR]=i?"color":"source-over",t[e.LUMINOSITY]=i?"luminosity":"source-over",s.blendModesCanvas=t}},s.BaseTexture=function(t,e,i){this.resolution=i||1,this.width=100,this.height=100,this.scaleMode=e||s.scaleModes.DEFAULT,this.hasLoaded=!1,this.source=t,this.premultipliedAlpha=!0,this._glTextures=[],this.mipmap=!1,this.textureIndex=0,this._dirty=[!0,!0,!0,!0],t&&((this.source.complete||this.source.getContext)&&this.source.width&&this.source.height&&(this.hasLoaded=!0,this.width=this.source.naturalWidth||this.source.width,this.height=this.source.naturalHeight||this.source.height,this.dirty()),this.skipRender=!1,this._powerOf2=!1)},s.BaseTexture.prototype.constructor=s.BaseTexture,s.BaseTexture.prototype.forceLoaded=function(t,e){this.hasLoaded=!0,this.width=t,this.height=e,this.dirty()},s.BaseTexture.prototype.destroy=function(){this.source&&Phaser.CanvasPool.removeByCanvas(this.source),this.source=null,this.unloadFromGPU()},s.BaseTexture.prototype.dirty=function(){for(var t=0;t<this._glTextures.length;t++)this._dirty[t]=!0},s.BaseTexture.prototype.unloadFromGPU=function(){this.dirty();for(var t=this._glTextures.length-1;t>=0;t--){var e=this._glTextures[t],i=s.glContexts[t];i&&e&&i.deleteTexture(e)}this._glTextures.length=0,this.dirty()},s.BaseTexture.fromCanvas=function(t,e,i){return 0===t.width&&(t.width=1),0===t.height&&(t.height=1),i=i||1,new s.BaseTexture(t,e,i)},s.TextureSilentFail=!1,s.Texture=function(t,e,i,n){this.noFrame=!1,e||(this.noFrame=!0,e=new s.Rectangle(0,0,1,1)),t instanceof s.Texture&&(t=t.baseTexture),this.baseTexture=t,this.frame=e,this.trim=n,this.valid=!1,this.isTiling=!1,this.requiresUpdate=!1,this.requiresReTint=!1,this._uvs=null,this.width=0,this.height=0,this.crop=i||new s.Rectangle(0,0,1,1),this.rotated=!1,t.hasLoaded&&(this.noFrame&&(e=new s.Rectangle(0,0,t.width,t.height)),this.setFrame(e))},s.Texture.prototype.constructor=s.Texture,s.Texture.prototype.onBaseTextureLoaded=function(){var t=this.baseTexture;this.noFrame&&(this.frame=new s.Rectangle(0,0,t.width,t.height)),this.setFrame(this.frame)},s.Texture.prototype.destroy=function(t){t&&this.baseTexture.destroy(),this.valid=!1},s.Texture.prototype.setFrame=function(t){if(this.noFrame=!1,this.frame=t,this.width=t.width,this.height=t.height,this.crop.x=t.x,this.crop.y=t.y,this.crop.width=t.width,this.crop.height=t.height,this.trim||!(t.x+t.width>this.baseTexture.width||t.y+t.height>this.baseTexture.height))this.valid=t&&t.width&&t.height&&this.baseTexture.source&&this.baseTexture.hasLoaded,this.trim&&(this.width=this.trim.width,this.height=this.trim.height,this.frame.width=this.trim.width,this.frame.height=this.trim.height),this.valid&&this._updateUvs();else{if(!s.TextureSilentFail)throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);this.valid=!1}},s.Texture.prototype._updateUvs=function(){this._uvs||(this._uvs=new s.TextureUvs);var t=this.crop,e=this.baseTexture.width,i=this.baseTexture.height;this._uvs.x0=t.x/e,this._uvs.y0=t.y/i,this._uvs.x1=(t.x+t.width)/e,this._uvs.y1=t.y/i,this._uvs.x2=(t.x+t.width)/e,this._uvs.y2=(t.y+t.height)/i,this._uvs.x3=t.x/e,this._uvs.y3=(t.y+t.height)/i},s.Texture.prototype._updateUvsInverted=function(){this._uvs||(this._uvs=new s.TextureUvs);var t=this.crop,e=this.baseTexture.width,i=this.baseTexture.height;this._uvs.x0=t.x/e,this._uvs.y0=t.y/i,this._uvs.x1=(t.x+t.height)/e,this._uvs.y1=t.y/i,this._uvs.x2=(t.x+t.height)/e,this._uvs.y2=(t.y+t.width)/i,this._uvs.x3=t.x/e,this._uvs.y3=(t.y+t.width)/i},s.Texture.fromCanvas=function(t,e){var i=s.BaseTexture.fromCanvas(t,e);return new s.Texture(i)},s.TextureUvs=function(){this.x0=0,this.y0=0,this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.x3=0,this.y3=0},"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=s),exports.PIXI=s):"undefined"!=typeof define&&define.amd?define("PIXI",i.PIXI=s):i.PIXI=s,s}.call(this),function(){var t=this,e=e||{VERSION:"2.14.0",GAMES:[],AUTO:0,CANVAS:1,WEBGL:2,HEADLESS:3,WEBGL_MULTI:4,NONE:0,LEFT:1,RIGHT:2,UP:3,DOWN:4,SPRITE:0,BUTTON:1,IMAGE:2,GRAPHICS:3,TEXT:4,TILESPRITE:5,BITMAPTEXT:6,GROUP:7,RENDERTEXTURE:8,TILEMAP:9,TILEMAPLAYER:10,EMITTER:11,POLYGON:12,BITMAPDATA:13,CANVAS_FILTER:14,WEBGL_FILTER:15,ELLIPSE:16,SPRITEBATCH:17,RETROFONT:18,POINTER:19,ROPE:20,CIRCLE:21,RECTANGLE:22,LINE:23,MATRIX:24,POINT:25,ROUNDEDRECTANGLE:26,CREATURE:27,VIDEO:28,PENDING_ATLAS:-1,HORIZONTAL:0,VERTICAL:1,LANDSCAPE:0,PORTRAIT:1,ANGLE_UP:270,ANGLE_DOWN:90,ANGLE_LEFT:180,ANGLE_RIGHT:0,ANGLE_NORTH_EAST:315,ANGLE_NORTH_WEST:225,ANGLE_SOUTH_EAST:45,ANGLE_SOUTH_WEST:135,TOP_LEFT:0,TOP_CENTER:1,TOP_RIGHT:2,LEFT_TOP:3,LEFT_CENTER:4,LEFT_BOTTOM:5,CENTER:6,RIGHT_TOP:7,RIGHT_CENTER:8,RIGHT_BOTTOM:9,BOTTOM_LEFT:10,BOTTOM_CENTER:11,BOTTOM_RIGHT:12,blendModes:{NORMAL:0,ADD:1,MULTIPLY:2,SCREEN:3,OVERLAY:4,DARKEN:5,LIGHTEN:6,COLOR_DODGE:7,COLOR_BURN:8,HARD_LIGHT:9,SOFT_LIGHT:10,DIFFERENCE:11,EXCLUSION:12,HUE:13,SATURATION:14,COLOR:15,LUMINOSITY:16},scaleModes:{DEFAULT:0,LINEAR:0,NEAREST:1},PIXI:PIXI||{},_UID:0};if("undefined"!=typeof AudioBufferSourceNode&&(AudioBufferSourceNode.prototype.start||(AudioBufferSourceNode.prototype.start=AudioBufferSourceNode.prototype.noteGrainOn),AudioBufferSourceNode.prototype.stop||(AudioBufferSourceNode.prototype.stop=AudioBufferSourceNode.prototype.noteOff)),Math.trunc||(Math.trunc=function(t){return t<0?Math.ceil(t):Math.floor(t)}),Function.prototype.bind||(Function.prototype.bind=function(){var t=Array.prototype.slice;return function(e){function i(){var r=n.concat(t.call(arguments));s.apply(this instanceof i?this:e,r)}var s=this,n=t.call(arguments,1);if("function"!=typeof s)throw new TypeError;return i.prototype=function t(e){if(e&&(t.prototype=e),!(this instanceof t))return new t}(s.prototype),i}}()),Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),Array.prototype.forEach||(Array.prototype.forEach=function(t){"use strict";if(void 0===this||null===this)throw new TypeError;var e=Object(this),i=e.length>>>0;if("function"!=typeof t)throw new TypeError;for(var s=arguments.length>=2?arguments[1]:void 0,n=0;n<i;n++)n in e&&t.call(s,e[n],n,e)}),"function"!=typeof window.Uint32Array&&"object"!=typeof window.Uint32Array){var i=function(t){var e=new Array;window[t]=function(t){if("number"==typeof t){Array.call(this,t),this.length=t;for(e=0;e<this.length;e++)this[e]=0}else{Array.call(this,t.length),this.length=t.length;for(var e=0;e<this.length;e++)this[e]=t[e]}},window[t].prototype=e,window[t].constructor=window[t]};i("Float32Array"),i("Uint32Array"),i("Uint16Array"),i("Int16Array"),i("ArrayBuffer")}window.console||(window.console={},window.console.log=window.console.assert=function(){},window.console.warn=window.console.assert=function(){}),Object.assign||(Object.assign=function(t,e){"use strict";if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(t),s=Object.prototype.hasOwnProperty,n=1;n<arguments.length;n++){var r=arguments[n];if(null!=r)for(var o in r)s.call(r,o)&&(i[o]=r[o])}return i}),e.Utils={defaults:function(t,e){for(var i=Object.keys(e),s=0,n=i.length;s<n;s++){var r=i[s];void 0===t[r]&&(t[r]=e[r])}return t},reverseString:function(t){return t.split("").reverse().join("")},getProperty:function(t,e){var i=e.split(".");switch(i.length){case 1:return t[e];case 2:return t[i[0]][i[1]];case 3:return t[i[0]][i[1]][i[2]];case 4:return t[i[0]][i[1]][i[2]][i[3]];default:return this._getProperty(t,e)}},setProperties:function(t,e){for(var i in e)this.setProperty(t,i,e[i]);return t},setProperty:function(t,e,i){var s=e.split(".");switch(s.length){case 1:t[e]=i;break;case 2:t[s[0]][s[1]]=i;break;case 3:t[s[0]][s[1]][s[2]]=i;break;case 4:t[s[0]][s[1]][s[2]][s[3]]=i;break;default:this._setProperty(t,e,i)}},_getProperty:function(t,e){for(var i=e.split("."),s=i.length,n=0,r=t;n<s;){var o=i[n];if(null==r)return;r=r[o],n++}return r},_setProperty:function(t,e,i){var s=e.split("."),n=s.length,r=0,o=t,a=s[0];if(1===n)t[e]=i;else{for(;r<n-1;)o=o[a],a=s[++r];o[a]=i}return t},chanceRoll:function(t){return void 0===t&&(t=50),t>0&&100*Math.random()<=t},randomChoice:function(t,e){return Math.random()<.5?t:e},parseDimension:function(t,e){var i=0,s=0;return"string"==typeof t?"%"===t.substr(-1)?(i=parseInt(t,10)/100,s=0===e?window.innerWidth*i:window.innerHeight*i):s=parseInt(t,10):s=t,s},pad:function(t,e,i,s){if(void 0===e)var e=0;if(void 0===i)var i=" ";if(void 0===s)var s=3;var n=0;if(e+1>=(t=t.toString()).length)switch(s){case 1:t=new Array(e+1-t.length).join(i)+t;break;case 3:var r=Math.ceil((n=e-t.length)/2),o=n-r;t=new Array(o+1).join(i)+t+new Array(r+1).join(i);break;default:t+=new Array(e+1-t.length).join(i)}return t},isPlainObject:function(t){if("object"!=typeof t||t.nodeType||t===t.window)return!1;try{if(t.constructor&&!{}.hasOwnProperty.call(t.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}return!0},extend:function(){var t,i,s,n,r,o,a=arguments[0]||{},h=1,l=arguments.length,c=!1;for("boolean"==typeof a&&(c=a,a=arguments[1]||{},h=2),l===h&&(a=this,--h);h<l;h++)if(null!=(t=arguments[h]))for(i in t)s=a[i],a!==(n=t[i])&&(c&&n&&(e.Utils.isPlainObject(n)||(r=Array.isArray(n)))?(r?(r=!1,o=s&&Array.isArray(s)?s:[]):o=s&&e.Utils.isPlainObject(s)?s:{},a[i]=e.Utils.extend(c,o,n)):void 0!==n&&(a[i]=n));return a},mixinPrototype:function(t,e,i){void 0===i&&(i=!1);for(var s=Object.keys(e),n=0;n<s.length;n++){var r=s[n],o=e[r];!i&&r in t||(!o||"function"!=typeof o.get&&"function"!=typeof o.set?t[r]=o:"function"==typeof o.clone?t[r]=o.clone():Object.defineProperty(t,r,o))}},mixin:function(t,i){if(!t||"object"!=typeof t)return i;for(var s in t){var n=t[s];if(!n.childNodes&&!n.cloneNode){var r=typeof t[s];t[s]&&"object"===r?typeof i[s]===r?i[s]=e.Utils.mixin(t[s],i[s]):i[s]=e.Utils.mixin(t[s],new n.constructor):i[s]=t[s]}}return i}},e.Circle=function(t,i,s){t=t||0,i=i||0,s=s||0,this.x=t,this.y=i,this._diameter=s,this._radius=0,s>0&&(this._radius=.5*s),this.type=e.CIRCLE},e.Circle.prototype={circumference:function(){return Math.PI*this._radius*2},random:function(t){void 0===t&&(t=new e.Point);var i=2*Math.PI*Math.random(),s=Math.random()+Math.random(),n=s>1?2-s:s,r=n*Math.cos(i),o=n*Math.sin(i);return t.x=this.x+r*this.radius,t.y=this.y+o*this.radius,t},getBounds:function(){return new e.Rectangle(this.x-this.radius,this.y-this.radius,this.diameter,this.diameter)},setTo:function(t,e,i){return this.x=t,this.y=e,this._diameter=i,this._radius=.5*i,this},copyFrom:function(t){return this.setTo(t.x,t.y,t.diameter)},copyTo:function(t){return t.x=this.x,t.y=this.y,t.diameter=this._diameter,t},distance:function(t,i){var s=e.Math.distance(this.x,this.y,t.x,t.y);return i?Math.round(s):s},clone:function(t){return void 0===t||null===t?t=new e.Circle(this.x,this.y,this.diameter):t.setTo(this.x,this.y,this.diameter),t},contains:function(t,i){return e.Circle.contains(this,t,i)},circumferencePoint:function(t,i,s){return e.Circle.circumferencePoint(this,t,i,s)},sample:function(t,i,s,n,r){t||(t=60),null==i&&(i=0),null==s&&(s=e.Math.PI2),r||(r=[]);for(var o=0;o<t;)this.circumferencePoint(e.Math.linear(i,s,o/t),n,r[o]||(r[o]=new e.Point)),o+=1;return r},offset:function(t,e){return this.x+=t,this.y+=e,this},offsetPoint:function(t){return this.offset(t.x,t.y)},toString:function(){return"[{Phaser.Circle (x="+this.x+" y="+this.y+" diameter="+this.diameter+" radius="+this.radius+")}]"}},e.Circle.prototype.constructor=e.Circle,Object.defineProperty(e.Circle.prototype,"diameter",{get:function(){return this._diameter},set:function(t){t>0&&(this._diameter=t,this._radius=.5*t)}}),Object.defineProperty(e.Circle.prototype,"radius",{get:function(){return this._radius},set:function(t){t>0&&(this._radius=t,this._diameter=2*t)}}),Object.defineProperty(e.Circle.prototype,"left",{get:function(){return this.x-this._radius},set:function(t){t>this.x?(this._radius=0,this._diameter=0):this.radius=this.x-t}}),Object.defineProperty(e.Circle.prototype,"right",{get:function(){return this.x+this._radius},set:function(t){t<this.x?(this._radius=0,this._diameter=0):this.radius=t-this.x}}),Object.defineProperty(e.Circle.prototype,"top",{get:function(){return this.y-this._radius},set:function(t){t>this.y?(this._radius=0,this._diameter=0):this.radius=this.y-t}}),Object.defineProperty(e.Circle.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(t){t<this.y?(this._radius=0,this._diameter=0):this.radius=t-this.y}}),Object.defineProperty(e.Circle.prototype,"area",{get:function(){return this._radius>0?Math.PI*this._radius*this._radius:0}}),Object.defineProperty(e.Circle.prototype,"empty",{get:function(){return 0===this._diameter},set:function(t){!0===t&&this.setTo(0,0,0)}}),e.Circle.contains=function(t,e,i){return t.radius>0&&e>=t.left&&e<=t.right&&i>=t.top&&i<=t.bottom&&(t.x-e)*(t.x-e)+(t.y-i)*(t.y-i)<=t.radius*t.radius},e.Circle.equals=function(t,e){return t.x===e.x&&t.y===e.y&&t.diameter===e.diameter},e.Circle.intersects=function(t,i){return e.Math.distance(t.x,t.y,i.x,i.y)<=t.radius+i.radius},e.Circle.circumferencePoint=function(t,i,s,n){return void 0===s&&(s=!1),void 0===n&&(n=new e.Point),!0===s&&(i=e.Math.degToRad(i)),n.x=t.x+t.radius*Math.cos(i),n.y=t.y+t.radius*Math.sin(i),n},e.Circle.intersectsRectangle=function(t,e){var i=Math.abs(t.x-e.x-e.halfWidth);if(i>e.halfWidth+t.radius)return!1;var s=Math.abs(t.y-e.y-e.halfHeight);if(s>e.halfHeight+t.radius)return!1;if(i<=e.halfWidth||s<=e.halfHeight)return!0;var n=i-e.halfWidth,r=s-e.halfHeight;return n*n+r*r<=t.radius*t.radius},e.Circle.intersectsLine=function(t,i,s){var n=t.x,r=t.y,o=(i.end.y-i.start.y)/(i.end.x-i.start.x),a=i.end.y-o*i.end.x,h=t.radius,l=t.radius,c=a+o*n,u=(n*(l*l)-o*(h*h)*(a-r)+h*l*Math.sqrt(h*h*(o*o)+l*l-c*c-r*r+2*c*r))/(h*h*(o*o)+l*l),d=(n*(l*l)-o*(h*h)*(a-r)-h*l*Math.sqrt(h*h*(o*o)+l*l-c*c-r*r+2*c*r))/(h*h*(o*o)+l*l),p=o*u+a,f=o*d+a,g=new e.Point(u,p),m=new e.Point(d,f),y=i.pointOnSegment(g.x,g.y,.01),v=i.pointOnSegment(m.x,m.y,.01);return y&&v?!s||[g,m]:y?!s||[g]:v?!s||[m]:!!s&&[]},PIXI.Circle=e.Circle,e.Ellipse=function(t,i,s,n){t=t||0,i=i||0,s=s||0,n=n||0,this.x=t,this.y=i,this.width=s,this.height=n,this.type=e.ELLIPSE},e.Ellipse.prototype={setTo:function(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this},getBounds:function(){return new e.Rectangle(this.x-this.width,this.y-this.height,this.width,this.height)},copyFrom:function(t){return this.setTo(t.x,t.y,t.width,t.height)},copyTo:function(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t},clone:function(t){return void 0===t||null===t?t=new e.Ellipse(this.x,this.y,this.width,this.height):t.setTo(this.x,this.y,this.width,this.height),t},contains:function(t,i){return e.Ellipse.contains(this,t,i)},random:function(t){void 0===t&&(t=new e.Point);var i=Math.random()*Math.PI*2,s=Math.sqrt(Math.random());return t.x=this.centerX+.5*s*Math.cos(i)*this.width,t.y=this.centerY+.5*s*Math.sin(i)*this.height,t},toString:function(){return"[{Phaser.Ellipse (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+")}]"}},e.Ellipse.prototype.constructor=e.Ellipse,Object.defineProperty(e.Ellipse.prototype,"left",{get:function(){return this.x},set:function(t){this.x=t}}),Object.defineProperty(e.Ellipse.prototype,"right",{get:function(){return this.x+this.width},set:function(t){t<this.x?this.width=0:this.width=t-this.x}}),Object.defineProperty(e.Ellipse.prototype,"top",{get:function(){return this.y},set:function(t){this.y=t}}),Object.defineProperty(e.Ellipse.prototype,"bottom",{get:function(){return this.y+this.height},set:function(t){t<this.y?this.height=0:this.height=t-this.y}}),Object.defineProperty(e.Ellipse.prototype,"centerX",{get:function(){return this.x+.5*this.width}}),Object.defineProperty(e.Ellipse.prototype,"centerY",{get:function(){return this.y+.5*this.height}}),Object.defineProperty(e.Ellipse.prototype,"empty",{get:function(){return 0===this.width||0===this.height},set:function(t){!0===t&&this.setTo(0,0,0,0)}}),e.Ellipse.contains=function(t,e,i){if(t.width<=0||t.height<=0)return!1;var s=(e-t.x)/t.width-.5,n=(i-t.y)/t.height-.5;return s*=s,n*=n,s+n<.25},e.Ellipse.intersectsLine=function(t,i,s){var n=t.x,r=t.y,o=(i.end.y-i.start.y)/(i.end.x-i.start.x),a=i.end.y-o*i.end.x,h=t.width/2,l=t.height/2,c=a+o*n,u=(n*(l*l)-o*(h*h)*(a-r)+h*l*Math.sqrt(h*h*(o*o)+l*l-c*c-r*r+2*c*r))/(h*h*(o*o)+l*l),d=(n*(l*l)-o*(h*h)*(a-r)-h*l*Math.sqrt(h*h*(o*o)+l*l-c*c-r*r+2*c*r))/(h*h*(o*o)+l*l),p=o*u+a,f=o*d+a,g=new e.Point(u,p),m=new e.Point(d,f),y=i.pointOnSegment(g.x,g.y,.01),v=i.pointOnSegment(m.x,m.y,.01);return y&&v?!s||[g,m]:y?!s||[g]:v?!s||[m]:!!s&&[]},PIXI.Ellipse=e.Ellipse,e.Line=function(t,i,s,n){t=t||0,i=i||0,s=s||0,n=n||0,this.start=new e.Point(t,i),this.end=new e.Point(s,n),this.type=e.LINE},e.Line.prototype={setTo:function(t,e,i,s){return this.start.setTo(t,e),this.end.setTo(i,s),this},fromPoints:function(t,e){return this.setTo(t.x,t.y,e.x,e.y),this},fromSprite:function(t,e,i){return void 0===i&&(i=!1),i?this.setTo(t.centerX,t.centerY,e.centerX,e.centerY):this.fromPoints(t,e)},fromAngle:function(t,e,i,s){return this.start.setTo(t,e),this.end.setTo(t+Math.cos(i)*s,e+Math.sin(i)*s),this},rotate:function(t,e){var i=(this.start.x+this.end.x)/2,s=(this.start.y+this.end.y)/2;return this.start.rotate(i,s,t,e),this.end.rotate(i,s,t,e),this},rotateAround:function(t,e,i,s){return this.start.rotate(t,e,i,s),this.end.rotate(t,e,i,s),this},intersects:function(t,i,s){return e.Line.intersectsPoints(this.start,this.end,t.start,t.end,i,s)},reflect:function(t){return e.Line.reflect(this,t)},midPoint:function(t){return void 0===t&&(t=new e.Point),t.x=(this.start.x+this.end.x)/2,t.y=(this.start.y+this.end.y)/2,t},centerOn:function(t,e){var i=t-(this.start.x+this.end.x)/2,s=e-(this.start.y+this.end.y)/2;this.start.add(i,s),this.end.add(i,s)},pointOnLine:function(t,i,s){return e.Math.fuzzyEqual((t-this.start.x)*(this.end.y-this.start.y),(this.end.x-this.start.x)*(i-this.start.y),s||0)},pointOnSegment:function(t,e,i){var s=Math.min(this.start.x,this.end.x),n=Math.max(this.start.x,this.end.x),r=Math.min(this.start.y,this.end.y),o=Math.max(this.start.y,this.end.y);return this.pointOnLine(t,e,i)&&t>=s&&t<=n&&e>=r&&e<=o},random:function(t){void 0===t&&(t=new e.Point);var i=Math.random();return t.x=this.start.x+i*(this.end.x-this.start.x),t.y=this.start.y+i*(this.end.y-this.start.y),t},coordinatesOnLine:function(t,e){void 0===t&&(t=1),void 0===e&&(e=[]);var i=Math.round(this.start.x),s=Math.round(this.start.y),n=Math.round(this.end.x),r=Math.round(this.end.y),o=Math.abs(n-i),a=Math.abs(r-s),h=i<n?1:-1,l=s<r?1:-1,c=o-a;e.push([i,s]);for(var u=1;i!==n||s!==r;){var d=c<<1;d>-a&&(c-=a,i+=h),d<o&&(c+=o,s+=l),u%t==0&&e.push([i,s]),u++}return e},clone:function(t){return void 0===t||null===t?t=new e.Line(this.start.x,this.start.y,this.end.x,this.end.y):t.setTo(this.start.x,this.start.y,this.end.x,this.end.y),t}},Object.defineProperty(e.Line.prototype,"length",{get:function(){return Math.sqrt((this.end.x-this.start.x)*(this.end.x-this.start.x)+(this.end.y-this.start.y)*(this.end.y-this.start.y))}}),Object.defineProperty(e.Line.prototype,"angle",{get:function(){return e.Point.angle(this.end,this.start)}}),Object.defineProperty(e.Line.prototype,"slope",{get:function(){return(this.end.y-this.start.y)/(this.end.x-this.start.x)}}),Object.defineProperty(e.Line.prototype,"perpSlope",{get:function(){return-(this.end.x-this.start.x)/(this.end.y-this.start.y)}}),Object.defineProperty(e.Line.prototype,"x",{get:function(){return Math.min(this.start.x,this.end.x)}}),Object.defineProperty(e.Line.prototype,"y",{get:function(){return Math.min(this.start.y,this.end.y)}}),Object.defineProperty(e.Line.prototype,"left",{get:function(){return Math.min(this.start.x,this.end.x)}}),Object.defineProperty(e.Line.prototype,"right",{get:function(){return Math.max(this.start.x,this.end.x)}}),Object.defineProperty(e.Line.prototype,"top",{get:function(){return Math.min(this.start.y,this.end.y)}}),Object.defineProperty(e.Line.prototype,"bottom",{get:function(){return Math.max(this.start.y,this.end.y)}}),Object.defineProperty(e.Line.prototype,"width",{get:function(){return Math.abs(this.start.x-this.end.x)}}),Object.defineProperty(e.Line.prototype,"height",{get:function(){return Math.abs(this.start.y-this.end.y)}}),Object.defineProperty(e.Line.prototype,"normalX",{get:function(){return Math.cos(this.angle-1.5707963267948966)}}),Object.defineProperty(e.Line.prototype,"normalY",{get:function(){return Math.sin(this.angle-1.5707963267948966)}}),Object.defineProperty(e.Line.prototype,"normalAngle",{get:function(){return e.Math.wrap(this.angle-1.5707963267948966,-Math.PI,Math.PI)}}),e.Line.intersectsPoints=function(t,i,s,n,r,o){void 0===r&&(r=!0),void 0===o&&(o=new e.Point);var a=i.y-t.y,h=n.y-s.y,l=t.x-i.x,c=s.x-n.x,u=i.x*t.y-t.x*i.y,d=n.x*s.y-s.x*n.y,p=a*c-h*l;if(0===p)return null;if(o.x=(l*d-c*u)/p,o.y=(h*u-a*d)/p,r){var f=(n.y-s.y)*(i.x-t.x)-(n.x-s.x)*(i.y-t.y),g=((n.x-s.x)*(t.y-s.y)-(n.y-s.y)*(t.x-s.x))/f,m=((i.x-t.x)*(t.y-s.y)-(i.y-t.y)*(t.x-s.x))/f;return g>=0&&g<=1&&m>=0&&m<=1?o:null}return o},e.Line.intersects=function(t,i,s,n){return e.Line.intersectsPoints(t.start,t.end,i.start,i.end,s,n)},e.Line.intersectsRectangle=function(t,e){if(0===t.length||e.empty)return!1;var i=t.start.x,s=t.start.y,n=t.end.x,r=t.end.y,o=e.x,a=e.y,h=e.right,l=e.bottom,c=0;if(i>=o&&i<=h&&s>=a&&s<=l||n>=o&&n<=h&&r>=a&&r<=l)return!0;if(i<o&&n>=o){if((c=s+(r-s)*(o-i)/(n-i))>a&&c<=l)return!0}else if(i>h&&n<=h&&(c=s+(r-s)*(h-i)/(n-i))>=a&&c<=l)return!0;if(s<a&&r>=a){if((c=i+(n-i)*(a-s)/(r-s))>=o&&c<=h)return!0}else if(s>l&&r<=l&&(c=i+(n-i)*(l-s)/(r-s))>=o&&c<=h)return!0;return!1},e.Line.intersectionWithRectangle=function(t,i,s){var n=e.Line.intersectionWithRectangle;s||(s=new e.Point),n.edges||(n.edges=[new e.Line,new e.Line,new e.Line,new e.Line]),n.edgeIntersection||(n.edgeIntersection=new e.Point);var r=n.edges,o=n.edgeIntersection.set(0),a=i.x,h=i.y,l=i.right,c=i.bottom,u=1/0;r[0].setTo(a,h,l,h),r[1].setTo(a,c,l,c),r[2].setTo(a,h,a,c),r[3].setTo(l,h,l,c);for(var d,p=0;d=r[p];p++)if(t.intersects(d,!0,o)){var f=t.start.distance(o);f<u&&(u=f,s.copyFrom(o))}return null!=f?s:null},e.Line.reflect=function(t,e){return 2*e.normalAngle-3.141592653589793-t.angle},e.Matrix=function(t,i,s,n,r,o){void 0!==t&&null!==t||(t=1),void 0!==i&&null!==i||(i=0),void 0!==s&&null!==s||(s=0),void 0!==n&&null!==n||(n=1),void 0!==r&&null!==r||(r=0),void 0!==o&&null!==o||(o=0),this.a=t,this.b=i,this.c=s,this.d=n,this.tx=r,this.ty=o,this.type=e.MATRIX},e.Matrix.prototype={fromArray:function(t){return this.setTo(t[0],t[1],t[3],t[4],t[2],t[5])},setTo:function(t,e,i,s,n,r){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=r,this},clone:function(t){return void 0===t||null===t?t=new e.Matrix(this.a,this.b,this.c,this.d,this.tx,this.ty):(t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty),t},copyTo:function(t){return t.copyFrom(this),t},copyFrom:function(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this},toArray:function(t,e){return void 0===e&&(e=new Float32Array(9)),t?(e[0]=this.a,e[1]=this.b,e[2]=0,e[3]=this.c,e[4]=this.d,e[5]=0,e[6]=this.tx,e[7]=this.ty,e[8]=1):(e[0]=this.a,e[1]=this.c,e[2]=this.tx,e[3]=this.b,e[4]=this.d,e[5]=this.ty,e[6]=0,e[7]=0,e[8]=1),e},apply:function(t,i){return void 0===i&&(i=new e.Point),i.x=this.a*t.x+this.c*t.y+this.tx,i.y=this.b*t.x+this.d*t.y+this.ty,i},applyInverse:function(t,i){void 0===i&&(i=new e.Point);var s=1/(this.a*this.d+this.c*-this.b),n=t.x,r=t.y;return i.x=this.d*s*n+-this.c*s*r+(this.ty*this.c-this.tx*this.d)*s,i.y=this.a*s*r+-this.b*s*n+(-this.ty*this.a+this.tx*this.b)*s,i},translate:function(t,e){return this.tx+=t,this.ty+=e,this},scale:function(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this},rotate:function(t){var e=Math.cos(t),i=Math.sin(t),s=this.a,n=this.c,r=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=r*e-this.ty*i,this.ty=r*i+this.ty*e,this},append:function(t){var e=this.a,i=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this},identity:function(){return this.setTo(1,0,0,1,0,0)}},e.identityMatrix=new e.Matrix,e.Point=function(t,i){t=t||0,i=i||0,this.x=t,this.y=i,this.type=e.POINT},e.Point.prototype={copyFrom:function(t){return this.setTo(t.x,t.y)},invert:function(){return this.setTo(this.y,this.x)},setTo:function(t,i){return e.Point.set(this,t,i)},set:function(t,i){return e.Point.set(this,t,i)},setToPolar:function(t,i,s){return null==i&&(i=1),s&&(t=e.Math.degToRad(t)),this.setTo(Math.cos(t)*i,Math.sin(t)*i)},add:function(t,e){return this.x+=t,this.y+=e,this},subtract:function(t,e){return this.x-=t,this.y-=e,this},multiply:function(t,e){return this.x*=t,this.y*=e,this},divide:function(t,e){return this.x/=t,this.y/=e,this},clampX:function(t,i){return this.x=e.Math.clamp(this.x,t,i),this},clampY:function(t,i){return this.y=e.Math.clamp(this.y,t,i),this},clamp:function(t,i){return this.x=e.Math.clamp(this.x,t,i),this.y=e.Math.clamp(this.y,t,i),this},clip:function(t){var e=t.left,i=t.top,s=t.right,n=t.bottom;return this.x<e?this.x=e:this.x>s&&(this.x=s),this.y<i?this.y=i:this.y>n&&(this.y=n),this},clone:function(t){return void 0===t||null===t?t=new e.Point(this.x,this.y):t.setTo(this.x,this.y),t},copyTo:function(t){return t.x=this.x,t.y=this.y,t},distance:function(t,i){return e.Point.distance(this,t,i)},equals:function(t){return t.x===this.x&&t.y===this.y},equalsXY:function(t,e){return this.x===t&&this.y===e},fuzzyEquals:function(t,i){return e.Point.fuzzyEquals(this,t,i)},fuzzyEqualsXY:function(t,i,s){return e.Point.fuzzyEqualsXY(this,t,i,s)},angle:function(t,e){return this.angleXY(t.x,t.y,e)},angleXY:function(t,i,s){var n=Math.atan2(i-this.y,t-this.x);return s?e.Math.radToDeg(n):n},atan:function(t){var i=Math.atan2(this.y,this.x);return t?e.Math.radToDeg(i):i},rotate:function(t,i,s,n,r){return e.Point.rotate(this,t,i,s,n,r)},getMagnitude:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},getMagnitudeSq:function(){return this.x*this.x+this.y*this.y},setMagnitude:function(t){return this.normalize().multiply(t,t)},normalize:function(){if(!this.isZero()){var t=this.getMagnitude();this.x/=t,this.y/=t}return this},limit:function(t){return this.getMagnitudeSq()>t*t&&this.setMagnitude(t),this},expand:function(t){return this.getMagnitudeSq()<t*t&&this.setMagnitude(t),this},isZero:function(){return 0===this.x&&0===this.y},dot:function(t){return this.x*t.x+this.y*t.y},cross:function(t){return this.x*t.y-this.y*t.x},perp:function(){return this.setTo(-this.y,this.x)},rperp:function(){return this.setTo(this.y,-this.x)},normalRightHand:function(){return this.setTo(-1*this.y,this.x)},floor:function(){return this.setTo(Math.floor(this.x),Math.floor(this.y))},ceil:function(){return this.setTo(Math.ceil(this.x),Math.ceil(this.y))},round:function(){return this.setTo(Math.round(this.x),Math.round(this.y))},toString:function(){return"[{Point (x="+this.x+" y="+this.y+")}]"}},e.Point.prototype.constructor=e.Point,e.Point.add=function(t,i,s){return void 0===s&&(s=new e.Point),s.x=t.x+i.x,s.y=t.y+i.y,s},e.Point.subtract=function(t,i,s){return void 0===s&&(s=new e.Point),s.x=t.x-i.x,s.y=t.y-i.y,s},e.Point.multiply=function(t,i,s){return void 0===s&&(s=new e.Point),s.x=t.x*i.x,s.y=t.y*i.y,s},e.Point.divide=function(t,i,s){return void 0===s&&(s=new e.Point),s.x=t.x/i.x,s.y=t.y/i.y,s},e.Point.equals=function(t,e){return t.x===e.x&&t.y===e.y},e.Point.equalsXY=function(t,e,i){return t.x===e&&t.y===i},e.Point.fuzzyEquals=function(t,i,s){return e.Math.fuzzyEqual(t.x,i.x,s)&&e.Math.fuzzyEqual(t.y,i.y,s)},e.Point.fuzzyEqualsXY=function(t,i,s,n){return e.Math.fuzzyEqual(t.x,i,n)&&e.Math.fuzzyEqual(t.y,s,n)},e.Point.angle=function(t,e){return Math.atan2(t.y-e.y,t.x-e.x)},e.Point.negative=function(t,i){return void 0===i&&(i=new e.Point),i.setTo(-t.x,-t.y)},e.Point.multiplyAdd=function(t,i,s,n){return void 0===n&&(n=new e.Point),n.setTo(t.x+i.x*s,t.y+i.y*s)},e.Point.interpolate=function(t,i,s,n){return void 0===n&&(n=new e.Point),n.setTo(t.x+(i.x-t.x)*s,t.y+(i.y-t.y)*s)},e.Point.perp=function(t,i){return void 0===i&&(i=new e.Point),i.setTo(-t.y,t.x)},e.Point.rperp=function(t,i){return void 0===i&&(i=new e.Point),i.setTo(t.y,-t.x)},e.Point.distance=function(t,i,s){var n=e.Math.distance(t.x,t.y,i.x,i.y);return s?Math.round(n):n},e.Point.project=function(t,i,s){void 0===s&&(s=new e.Point);var n=t.dot(i)/i.getMagnitudeSq();return 0!==n&&s.setTo(n*i.x,n*i.y),s},e.Point.projectUnit=function(t,i,s){void 0===s&&(s=new e.Point);var n=t.dot(i);return 0!==n&&s.setTo(n*i.x,n*i.y),s},e.Point.normalRightHand=function(t,i){return void 0===i&&(i=new e.Point),i.setTo(-1*t.y,t.x)},e.Point.normalize=function(t,i){void 0===i&&(i=new e.Point);var s=t.getMagnitude();return 0!==s&&i.setTo(t.x/s,t.y/s),i},e.Point.rotate=function(t,i,s,n,r,o){if(r&&(n=e.Math.degToRad(n)),void 0===o){t.subtract(i,s);var a=Math.sin(n),h=Math.cos(n),l=h*t.x-a*t.y,c=a*t.x+h*t.y;t.x=l+i,t.y=c+s}else{var u=n+Math.atan2(t.y-s,t.x-i);t.x=i+o*Math.cos(u),t.y=s+o*Math.sin(u)}return t},e.Point.centroid=function(t,i){if(void 0===i&&(i=new e.Point),"[object Array]"!==Object.prototype.toString.call(t))throw new Error("Phaser.Point. Parameter 'points' must be an array");var s=t.length;if(s<1)throw new Error("Phaser.Point. Parameter 'points' array must not be empty");if(1===s)return i.copyFrom(t[0]),i;for(var n=0;n<s;n++)e.Point.add(i,t[n],i);return i.divide(s,s),i},e.Point.parse=function(t,i,s){i=i||"x",s=s||"y";var n=new e.Point;return t[i]&&(n.x=parseFloat(t[i])),t[s]&&(n.y=parseFloat(t[s])),n},e.Point.trunc=function(t){return t.x=e.Math.trunc(t.x),t.y=e.Math.trunc(t.y),t},e.Point.isPoint=function(t){return null!=t&&"number"==typeof t.x&&"number"==typeof t.y},e.Point.set=function(t,e,i){return t.x=e||0,t.y=i||(0!==i?t.x:0),t},e.Point.sortClockwise=function(t,e){e||(e=this.centroid(t));var i=e.x,s=e.y;return t.sort(function(t,e){if(t.x-i>=0&&e.x-i<0)return-1;if(t.x-i<0&&e.x-i>=0)return 1;if(t.x-i==0&&e.x-i==0)return t.y-s>=0||e.y-s>=0?t.y>e.y?1:-1:e.y>t.y?1:-1;var n=(t.x-i)*-(e.y-s)-(e.x-i)*-(t.y-s);return n<0?-1:n>0?1:(t.x-i)*(t.x-i)+(t.y-s)*(t.y-s)>(e.x-i)*(e.x-i)+(e.y-s)*(e.y-s)?-1:1})},PIXI.Point=e.Point,e.Polygon=function(){this.area=0,this._points=[],arguments.length>0&&this.setTo.apply(this,arguments),this.closed=!0,this.flattened=!1,this.type=e.POLYGON},e.Polygon.prototype={toNumberArray:function(t){void 0===t&&(t=[]);for(var e=0;e<this._points.length;e++)"number"==typeof this._points[e]?(t.push(this._points[e]),t.push(this._points[e+1]),e++):(t.push(this._points[e].x),t.push(this._points[e].y));return t},flatten:function(){return this._points=this.toNumberArray(),this.flattened=!0,this},clone:function(t){var i=this._points.slice();return void 0===t||null===t?t=new e.Polygon(i):t.setTo(i),t},contains:function(t,e){var i=!1;if(this.flattened)for(var s=-2,n=this._points.length-2;(s+=2)<this._points.length;n=s){var r=this._points[s],o=this._points[s+1],a=this._points[n],h=this._points[n+1];(o<=e&&e<h||h<=e&&e<o)&&t<(a-r)*(e-o)/(h-o)+r&&(i=!i)}else for(var s=-1,n=this._points.length-1;++s<this._points.length;n=s){var r=this._points[s].x,o=this._points[s].y,a=this._points[n].x,h=this._points[n].y;(o<=e&&e<h||h<=e&&e<o)&&t<(a-r)*(e-o)/(h-o)+r&&(i=!i)}return i},setTo:function(t){if(this.area=0,this._points=[],arguments.length>0){Array.isArray(t)||(t=Array.prototype.slice.call(arguments));for(var e=Number.MAX_VALUE,i=0,s=t.length;i<s;i++){if("number"==typeof t[i]){n=new PIXI.Point(t[i],t[i+1]);i++}else if(Array.isArray(t[i]))n=new PIXI.Point(t[i][0],t[i][1]);else var n=new PIXI.Point(t[i].x,t[i].y);this._points.push(n),n.y<e&&(e=n.y)}this.calculateArea(e)}return this},calculateArea:function(t){for(var e,i,s,n,r=0,o=this._points.length;r<o;r++)e=this._points[r],i=r===o-1?this._points[0]:this._points[r+1],s=(e.y-t+(i.y-t))/2,n=e.x-i.x,this.area+=s*n;return this.area}},e.Polygon.prototype.constructor=e.Polygon,Object.defineProperty(e.Polygon.prototype,"points",{get:function(){return this._points}}),PIXI.Polygon=e.Polygon,e.Rectangle=function(t,i,s,n){t=t||0,i=i||0,s=s||0,n=n||0,this.x=t,this.y=i,this.width=s,this.height=n,this.type=e.RECTANGLE},e.Rectangle.prototype={offset:function(t,e){return this.x+=t,this.y+=e,this},offsetPoint:function(t){return this.offset(t.x,t.y)},setTo:function(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this},scale:function(t,e){return void 0===e&&(e=t),this.width*=t,this.height*=e,this},centerOn:function(t,e){return this.centerX=t,this.centerY=e,this},floor:function(){this.x=Math.floor(this.x),this.y=Math.floor(this.y)},floorAll:function(){this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.width=Math.floor(this.width),this.height=Math.floor(this.height)},ceil:function(){this.x=Math.ceil(this.x),this.y=Math.ceil(this.y)},ceilAll:function(){this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.width=Math.ceil(this.width),this.height=Math.ceil(this.height)},copyFrom:function(t){return this.setTo(t.x,t.y,t.width,t.height)},copyFromBounds:function(t){return this.setTo(t.left,t.top,t.width,t.height)},copyTo:function(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t},inflate:function(t,i){return e.Rectangle.inflate(this,t,i)},size:function(t){return e.Rectangle.size(this,t)},resize:function(t,e){return this.width=t,this.height=e,this},clone:function(t){return e.Rectangle.clone(this,t)},contains:function(t,i){return e.Rectangle.contains(this,t,i)},containsRect:function(t){return e.Rectangle.containsRect(t,this)},equals:function(t){return e.Rectangle.equals(this,t)},intersection:function(t,i){return e.Rectangle.intersection(this,t,i)},intersects:function(t){return e.Rectangle.intersects(this,t)},intersectsRaw:function(t,i,s,n,r){return e.Rectangle.intersectsRaw(this,t,i,s,n,r)},union:function(t,i){return e.Rectangle.union(this,t,i)},random:function(t){return void 0===t&&(t=new e.Point),t.x=this.randomX,t.y=this.randomY,t},getPoint:function(t,i){switch(void 0===i&&(i=new e.Point),t){default:case e.TOP_LEFT:return i.set(this.x,this.y);case e.TOP_CENTER:return i.set(this.centerX,this.y);case e.TOP_RIGHT:return i.set(this.right,this.y);case e.LEFT_CENTER:return i.set(this.x,this.centerY);case e.CENTER:return i.set(this.centerX,this.centerY);case e.RIGHT_CENTER:return i.set(this.right,this.centerY);case e.BOTTOM_LEFT:return i.set(this.x,this.bottom);case e.BOTTOM_CENTER:return i.set(this.centerX,this.bottom);case e.BOTTOM_RIGHT:return i.set(this.right,this.bottom)}},sides:function(t,i,s,n){arguments.length||(t=new e.Line,i=new e.Line,s=new e.Line,n=new e.Line);var r=this.x,o=this.y,a=this.right,h=this.bottom;return t.setTo(r,o,a,o),i.setTo(a,o,a,h),s.setTo(r,h,a,h),n.setTo(r,o,r,h),arguments.length?null:[t,i,s,n]},toString:function(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" empty="+this.empty+")}]"}},Object.defineProperty(e.Rectangle.prototype,"halfWidth",{get:function(){return Math.round(this.width/2)}}),Object.defineProperty(e.Rectangle.prototype,"halfHeight",{get:function(){return Math.round(this.height/2)}}),Object.defineProperty(e.Rectangle.prototype,"bottom",{get:function(){return this.y+this.height},set:function(t){t<=this.y?this.height=0:this.height=t-this.y}}),Object.defineProperty(e.Rectangle.prototype,"bottomLeft",{get:function(){return new e.Point(this.x,this.bottom)},set:function(t){this.x=t.x,this.bottom=t.y}}),Object.defineProperty(e.Rectangle.prototype,"bottomRight",{get:function(){return new e.Point(this.right,this.bottom)},set:function(t){this.right=t.x,this.bottom=t.y}}),Object.defineProperty(e.Rectangle.prototype,"left",{get:function(){return this.x},set:function(t){t>=this.right?this.width=0:this.width=this.right-t,this.x=t}}),Object.defineProperty(e.Rectangle.prototype,"right",{get:function(){return this.x+this.width},set:function(t){t<=this.x?this.width=0:this.width=t-this.x}}),Object.defineProperty(e.Rectangle.prototype,"volume",{get:function(){return this.width*this.height}}),Object.defineProperty(e.Rectangle.prototype,"perimeter",{get:function(){return 2*this.width+2*this.height}}),Object.defineProperty(e.Rectangle.prototype,"centerX",{get:function(){return this.x+this.halfWidth},set:function(t){this.x=t-this.halfWidth}}),Object.defineProperty(e.Rectangle.prototype,"centerY",{get:function(){return this.y+this.halfHeight},set:function(t){this.y=t-this.halfHeight}}),Object.defineProperty(e.Rectangle.prototype,"randomX",{get:function(){return this.x+Math.random()*this.width}}),Object.defineProperty(e.Rectangle.prototype,"randomY",{get:function(){return this.y+Math.random()*this.height}}),Object.defineProperty(e.Rectangle.prototype,"top",{get:function(){return this.y},set:function(t){t>=this.bottom?(this.height=0,this.y=t):this.height=this.bottom-t}}),Object.defineProperty(e.Rectangle.prototype,"topLeft",{get:function(){return new e.Point(this.x,this.y)},set:function(t){this.x=t.x,this.y=t.y}}),Object.defineProperty(e.Rectangle.prototype,"topRight",{get:function(){return new e.Point(this.x+this.width,this.y)},set:function(t){this.right=t.x,this.y=t.y}}),Object.defineProperty(e.Rectangle.prototype,"empty",{get:function(){return!this.width||!this.height},set:function(t){!0===t&&this.setTo(0,0,0,0)}}),e.Rectangle.prototype.constructor=e.Rectangle,e.Rectangle.inflate=function(t,e,i){return t.x-=e,t.width+=2*e,t.y-=i,t.height+=2*i,t},e.Rectangle.inflatePoint=function(t,i){return e.Rectangle.inflate(t,i.x,i.y)},e.Rectangle.size=function(t,i){return void 0===i||null===i?i=new e.Point(t.width,t.height):i.setTo(t.width,t.height),i},e.Rectangle.clone=function(t,i){return void 0===i||null===i?i=new e.Rectangle(t.x,t.y,t.width,t.height):i.setTo(t.x,t.y,t.width,t.height),i},e.Rectangle.createFromBounds=function(t,i){return void 0!==i&&null!==i||(i=new e.Rectangle(t.x,t.y,t.width,t.height)),i.copyFromBounds(t)},e.Rectangle.contains=function(t,e,i){return!(t.width<=0||t.height<=0)&&(e>=t.x&&e<t.right&&i>=t.y&&i<t.bottom)},e.Rectangle.containsRaw=function(t,e,i,s,n,r){return n>=t&&n<t+i&&r>=e&&r<e+s},e.Rectangle.containsPoint=function(t,i){return e.Rectangle.contains(t,i.x,i.y)},e.Rectangle.containsRect=function(t,e){return!(t.volume>e.volume)&&(t.x>=e.x&&t.y>=e.y&&t.right<e.right&&t.bottom<e.bottom)},e.Rectangle.equals=function(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height},e.Rectangle.sameDimensions=function(t,e){return t.width===e.width&&t.height===e.height},e.Rectangle.intersection=function(t,i,s){return void 0===s&&(s=new e.Rectangle),e.Rectangle.intersects(t,i)&&(s.x=Math.max(t.x,i.x),s.y=Math.max(t.y,i.y),s.width=Math.min(t.right,i.right)-s.x,s.height=Math.min(t.bottom,i.bottom)-s.y),s},e.Rectangle.intersects=function(t,e){return!(t.width<=0||t.height<=0||e.width<=0||e.height<=0)&&!(t.right<e.x||t.bottom<e.y||t.x>e.right||t.y>e.bottom)},e.Rectangle.intersectsRaw=function(t,e,i,s,n,r){return void 0===r&&(r=0),!(e>t.right+r||i<t.left-r||s>t.bottom+r||n<t.top-r)},e.Rectangle.union=function(t,i,s){return void 0===s&&(s=new e.Rectangle),s.setTo(Math.min(t.x,i.x),Math.min(t.y,i.y),Math.max(t.right,i.right)-Math.min(t.left,i.left),Math.max(t.bottom,i.bottom)-Math.min(t.top,i.top))},e.Rectangle.aabb=function(t,i){void 0===i&&(i=new e.Rectangle);var s=Number.NEGATIVE_INFINITY,n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;return t.forEach(function(t){t.x>s&&(s=t.x),t.x<n&&(n=t.x),t.y>r&&(r=t.y),t.y<o&&(o=t.y)}),i.setTo(n,o,s-n,r-o),i},PIXI.Rectangle=e.Rectangle,e.EmptyRectangle=new e.Rectangle(0,0,0,0),e.RoundedRectangle=function(t,i,s,n,r){void 0===t&&(t=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=0),void 0===r&&(r=20),this.x=t,this.y=i,this.width=s,this.height=n,this.radius=r||20,this.type=e.ROUNDEDRECTANGLE},e.RoundedRectangle.prototype={clone:function(){return new e.RoundedRectangle(this.x,this.y,this.width,this.height,this.radius)},contains:function(t,e){if(this.width<=0||this.height<=0)return!1;var i=this.x;if(t>=i&&t<=i+this.width){var s=this.y;if(e>=s&&e<=s+this.height)return!0}return!1}},e.RoundedRectangle.prototype.constructor=e.RoundedRectangle,PIXI.RoundedRectangle=e.RoundedRectangle,e.Camera=function(t,i,s,n,r,o){this.game=t,this.world=t.world,this.id=0,this.view=new e.Rectangle(s,n,r,o),this.bounds=new e.Rectangle(s,n,r,o),this.deadzone=null,this.visible=!0,this.roundPx=!0,this.atLimit={x:!1,y:!1},this.target=null,this.displayObject=null,this.scale=null,this.totalInView=0,this.lerp=new e.Point(1,1),this.onShakeComplete=new e.Signal,this.onFlashComplete=new e.Signal,this.onFadeComplete=new e.Signal,this.fx=null,this._targetPosition=new e.Point,this._edge=0,this._position=new e.Point,this._shake={intensity:0,duration:0,horizontal:!1,vertical:!1,shakeBounds:!0,x:0,y:0},this._fxDuration=0,this._fxType=0,this._fixedView=new e.Rectangle},e.Camera.FOLLOW_LOCKON=0,e.Camera.FOLLOW_PLATFORMER=1,e.Camera.FOLLOW_TOPDOWN=2,e.Camera.FOLLOW_TOPDOWN_TIGHT=3,e.Camera.SHAKE_BOTH=4,e.Camera.SHAKE_HORIZONTAL=5,e.Camera.SHAKE_VERTICAL=6,e.Camera.ENABLE_FX=!0,e.Camera.prototype={boot:function(){this.displayObject=this.game.world,this.scale=this.game.world.scale,this.game.camera=this,e.Graphics&&e.Camera.ENABLE_FX&&(this.fx=new e.Graphics(this.game),this.game.stage.addChild(this.fx))},preUpdate:function(){this.totalInView=0},follow:function(t,i,s,n){void 0===i&&(i=e.Camera.FOLLOW_LOCKON),void 0===s&&(s=1),void 0===n&&(n=1),this.target=t,this.lerp.set(s,n);var r;switch(i){case e.Camera.FOLLOW_PLATFORMER:var o=this.width/8,a=this.height/3;this.deadzone=new e.Rectangle((this.width-o)/2,(this.height-a)/2-.25*a,o,a);break;case e.Camera.FOLLOW_TOPDOWN:r=Math.max(this.width,this.height)/4,this.deadzone=new e.Rectangle((this.width-r)/2,(this.height-r)/2,r,r);break;case e.Camera.FOLLOW_TOPDOWN_TIGHT:r=Math.max(this.width,this.height)/8,this.deadzone=new e.Rectangle((this.width-r)/2,(this.height-r)/2,r,r);break;case e.Camera.FOLLOW_LOCKON:default:this.deadzone=null}},unfollow:function(){this.target=null},focusOn:function(t){this.setPosition(Math.round(t.x-this.view.halfWidth),Math.round(t.y-this.view.halfHeight))},focusOnXY:function(t,e){this.setPosition(Math.round(t-this.view.halfWidth),Math.round(e-this.view.halfHeight))},shake:function(t,i,s,n,r){return void 0===t&&(t=.05),void 0===i&&(i=500),void 0===s&&(s=!0),void 0===n&&(n=e.Camera.SHAKE_BOTH),void 0===r&&(r=!0),!(!s&&this._shake.duration>0)&&(this._shake.intensity=t,this._shake.duration=i,this._shake.shakeBounds=r,this._shake.x=0,this._shake.y=0,this._shake.horizontal=n===e.Camera.SHAKE_BOTH||n===e.Camera.SHAKE_HORIZONTAL,this._shake.vertical=n===e.Camera.SHAKE_BOTH||n===e.Camera.SHAKE_VERTICAL,!0)},flash:function(t,e,i,s){return void 0===t&&(t=16777215),void 0===e&&(e=500),void 0===i&&(i=!1),void 0===s&&(s=1),!(!this.fx||!i&&this._fxDuration>0)&&(this.fx.clear(),this.fx.beginFill(t,s),this.fx.drawRect(0,0,this.width,this.height),this.fx.endFill(),this.fx.alpha=1,this._fxDuration=e,this._fxType=0,!0)},fade:function(t,e,i,s){return void 0===t&&(t=0),void 0===e&&(e=500),void 0===i&&(i=!1),void 0===s&&(s=1),!(!this.fx||!i&&this._fxDuration>0)&&(this.fx.clear(),this.fx.beginFill(t,s),this.fx.drawRect(0,0,this.width,this.height),this.fx.endFill(),this.fx.alpha=0,this._fxDuration=e,this._fxType=1,!0)},update:function(){this._fxDuration>0&&this.updateFX(),this._shake.duration>0&&this.updateShake(),this.bounds&&this.checkBounds(),this.roundPx&&(this.view.floor(),this._shake.x=Math.floor(this._shake.x),this._shake.y=Math.floor(this._shake.y)),this.displayObject.position.x=-this.view.x,this.displayObject.position.y=-this.view.y},updateFX:function(){0===this._fxType?(this.fx.alpha-=this.game.time.elapsedMS/this._fxDuration,this.fx.alpha<=0&&(this._fxDuration=0,this.fx.alpha=0,this.onFlashComplete.dispatch())):(this.fx.alpha+=this.game.time.elapsedMS/this._fxDuration,this.fx.alpha>=1&&(this._fxDuration=0,this.fx.alpha=1,this.onFadeComplete.dispatch()))},updateShake:function(){this._shake.duration-=this.game.time.elapsedMS,this._shake.duration<=0?(this.onShakeComplete.dispatch(),this._shake.x=0,this._shake.y=0):(this._shake.horizontal&&(this._shake.x=this.game.rnd.frac()*this._shake.intensity*this.view.width*2-this._shake.intensity*this.view.width),this._shake.vertical&&(this._shake.y=this.game.rnd.frac()*this._shake.intensity*this.view.height*2-this._shake.intensity*this.view.height))},updateTarget:function(){this._targetPosition.x=this.view.x+this.target.worldPosition.x,this._targetPosition.y=this.view.y+this.target.worldPosition.y,this.deadzone?(this._edge=this._targetPosition.x-this.view.x,this._edge<this.deadzone.left?this.view.x=this.game.math.linear(this.view.x,this._targetPosition.x-this.deadzone.left,this.lerp.x):this._edge>this.deadzone.right&&(this.view.x=this.game.math.linear(this.view.x,this._targetPosition.x-this.deadzone.right,this.lerp.x)),this._edge=this._targetPosition.y-this.view.y,this._edge<this.deadzone.top?this.view.y=this.game.math.linear(this.view.y,this._targetPosition.y-this.deadzone.top,this.lerp.y):this._edge>this.deadzone.bottom&&(this.view.y=this.game.math.linear(this.view.y,this._targetPosition.y-this.deadzone.bottom,this.lerp.y))):(this.view.x=this.game.math.linear(this.view.x,this._targetPosition.x-this.view.halfWidth,this.lerp.x),this.view.y=this.game.math.linear(this.view.y,this._targetPosition.y-this.view.halfHeight,this.lerp.y)),this.bounds&&this.checkBounds(),this.roundPx&&this.view.floor(),this.displayObject.position.x=-this.view.x,this.displayObject.position.y=-this.view.y},setBoundsToWorld:function(){this.bounds&&this.bounds.copyFrom(this.game.world.bounds)},checkBounds:function(){this.atLimit.x=!1,this.atLimit.y=!1;var t=this.view.x+this._shake.x,e=this.view.right+this._shake.x,i=this.view.y+this._shake.y,s=this.view.bottom+this._shake.y;t<=this.bounds.x*this.scale.x?(this.atLimit.x=!0,this.view.x=this.bounds.x*this.scale.x,this._shake.shakeBounds||(this._shake.x=0)):e>=this.bounds.right*this.scale.x&&(this.atLimit.x=!0,this.view.x=this.bounds.right*this.scale.x-this.width,this._shake.shakeBounds||(this._shake.x=0)),i<=this.bounds.top*this.scale.y?(this.atLimit.y=!0,this.view.y=this.bounds.top*this.scale.y,this._shake.shakeBounds||(this._shake.y=0)):s>=this.bounds.bottom*this.scale.y&&(this.atLimit.y=!0,this.view.y=this.bounds.bottom*this.scale.y-this.height,this._shake.shakeBounds||(this._shake.y=0))},setPosition:function(t,e){this.view.x=t,this.view.y=e,this.bounds&&this.checkBounds()},setSize:function(t,e){this.view.width=t,this.view.height=e},reset:function(){this.target=null,this.view.x=0,this.view.y=0,this._shake.duration=0,this._shake.x=0,this._shake.y=0,this.resetFX()},resetFX:function(){this.fx&&(this.fx.clear(),this.fx.alpha=0),this._fxDuration=0}},e.Camera.prototype.constructor=e.Camera,Object.defineProperty(e.Camera.prototype,"x",{get:function(){return this.view.x},set:function(t){this.view.x=t,this.bounds&&this.checkBounds()}}),Object.defineProperty(e.Camera.prototype,"y",{get:function(){return this.view.y},set:function(t){this.view.y=t,this.bounds&&this.checkBounds()}}),Object.defineProperty(e.Camera.prototype,"position",{get:function(){return this._position.set(this.view.x,this.view.y),this._position},set:function(t){void 0!==t.x&&(this.view.x=t.x),void 0!==t.y&&(this.view.y=t.y),this.bounds&&this.checkBounds()}}),Object.defineProperty(e.Camera.prototype,"width",{get:function(){return this.view.width},set:function(t){this.view.width=t}}),Object.defineProperty(e.Camera.prototype,"height",{get:function(){return this.view.height},set:function(t){this.view.height=t}}),Object.defineProperty(e.Camera.prototype,"shakeIntensity",{get:function(){return this._shake.intensity},set:function(t){this._shake.intensity=t}}),Object.defineProperty(e.Camera.prototype,"fixedView",{get:function(){return this._fixedView.setTo(0,0,this.view.width,this.view.height),this._fixedView}}),Object.defineProperty(e.Camera.prototype,"centerX",{get:function(){return this.x+.5*this.width}}),Object.defineProperty(e.Camera.prototype,"centerY",{get:function(){return this.y+.5*this.height}}),e.State=function(){this.game=null,this.key="",this.add=null,this.make=null,this.camera=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.sound=null,this.scale=null,this.stage=null,this.state=null,this.time=null,this.tweens=null,this.world=null,this.particles=null,this.physics=null,this.rnd=null},e.State.prototype={init:function(){},preload:function(){},loadUpdate:function(){},loadRender:function(){},create:function(){},update:function(){},postUpdate:function(){},preRender:function(){},render:function(){},resize:function(){},paused:function(){},resumed:function(){},pauseUpdate:function(){},shutdown:function(){}},e.State.prototype.constructor=e.State,e.StateManager=function(t,i){this.game=t,this.states={},this._pendingState=null,void 0!==i&&null!==i&&(this._pendingState=i),this._clearWorld=!1,this._clearCache=!1,this._created=!1,this._args=[],this.current="",this.onStateChange=new e.Signal,this.onInitCallback=null,this.onPreloadCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onRenderCallback=null,this.onResizeCallback=null,this.onPreRenderCallback=null,this.onLoadUpdateCallback=null,this.onLoadRenderCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null,this.onShutDownCallback=null},e.StateManager.prototype={boot:function(){this.game.onPause.add(this.pause,this),this.game.onResume.add(this.resume,this),null!==this._pendingState&&"string"!=typeof this._pendingState&&this.add("default",this._pendingState,!0)},add:function(t,i,s){void 0===s&&(s=!1);var n;return i instanceof e.State?n=i:"object"==typeof i?(n=i).game=this.game:"function"==typeof i&&(n=new i(this.game)),this.states[t]=n,s&&(this.game.isBooted?this.start(t):this._pendingState=t),n},remove:function(t){this.current===t&&(this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onLoadRenderCallback=null,this.onLoadUpdateCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onPreRenderCallback=null,this.onRenderCallback=null,this.onResizeCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null),delete this.states[t]},start:function(t,e,i){void 0===e&&(e=!0),void 0===i&&(i=!1),this.checkState(t)&&(this._pendingState=t,this._clearWorld=e,this._clearCache=i,arguments.length>3&&(this._args=Array.prototype.splice.call(arguments,3)))},restart:function(t,e){void 0===t&&(t=!0),void 0===e&&(e=!1),this._pendingState=this.current,this._clearWorld=t,this._clearCache=e,arguments.length>2&&(this._args=Array.prototype.slice.call(arguments,2))},dummy:function(){},preUpdate:function(){if(this._pendingState&&this.game.isBooted){var t=this.current;if(this.clearCurrentState(),this.setCurrentState(this._pendingState),this.onStateChange.dispatch(this.current,t),this.current!==this._pendingState)return;this._pendingState=null,this.onPreloadCallback?(this.game.load.reset(!0),this.onPreloadCallback.call(this.callbackContext,this.game),0===this.game.load.totalQueuedFiles()&&0===this.game.load.totalQueuedPacks()?this.loadComplete():this.game.load.start()):this.loadComplete()}},clearCurrentState:function(){this.current&&(this.onShutDownCallback&&this.onShutDownCallback.call(this.callbackContext,this.game),this.game.tweens.removeAll(),this.game.camera.reset(),this.game.input.reset(!0),this.game.physics.clear(),this.game.time.removeAll(),this.game.scale.reset(this._clearWorld),this.game.debug&&this.game.debug.reset(),this._clearWorld&&(this.game.world.shutdown(),this._clearCache&&this.game.cache.destroy()))},checkState:function(t){var e=this.states[t];return e?!!(e.preload||e.create||e.update||e.render)||(console.warn("Invalid Phaser State object given. Must contain at least one of the required functions: preload, create, update or render"),!1):(console.warn("Phaser.StateManager - No state found with the key: "+t),!1)},link:function(t){var e=this.states[t];e.game=this.game,e.add=this.game.add,e.make=this.game.make,e.camera=this.game.camera,e.cache=this.game.cache,e.input=this.game.input,e.load=this.game.load,e.math=this.game.math,e.sound=this.game.sound,e.scale=this.game.scale,e.state=this,e.stage=this.game.stage,e.time=this.game.time,e.tweens=this.game.tweens,e.world=this.game.world,e.particles=this.game.particles,e.rnd=this.game.rnd,e.physics=this.game.physics,e.key=t},unlink:function(t){var e=this.states[t];e&&(e.game=null,e.add=null,e.make=null,e.camera=null,e.cache=null,e.input=null,e.load=null,e.math=null,e.sound=null,e.scale=null,e.state=null,e.stage=null,e.time=null,e.tweens=null,e.world=null,e.particles=null,e.rnd=null,e.physics=null)},setCurrentState:function(t){var e=this.states[t];this.callbackContext=e,this.link(t),this.onInitCallback=e.init||this.dummy,this.onPreloadCallback=e.preload||null,this.onLoadRenderCallback=e.loadRender||null,this.onLoadUpdateCallback=e.loadUpdate||null,this.onCreateCallback=e.create||null,this.onUpdateCallback=e.update||null,this.onPostUpdateCallback=e.postUpdate||null,this.onPreRenderCallback=e.preRender||null,this.onRenderCallback=e.render||null,this.onResizeCallback=e.resize||null,this.onPausedCallback=e.paused||null,this.onResumedCallback=e.resumed||null,this.onPauseUpdateCallback=e.pauseUpdate||null,this.onShutDownCallback=e.shutdown||this.dummy,""!==this.current&&this.game.physics.reset(),this.current=t,this._created=!1,this.onInitCallback.apply(this.callbackContext,this._args),t===this._pendingState&&(this._args=[]),this.game._kickstart=!0},getCurrentState:function(){return this.states[this.current]},loadComplete:function(){!1===this._created&&this.onCreateCallback?(this._created=!0,this.onCreateCallback.call(this.callbackContext,this.game)):this._created=!0},loadUpdate:function(){!1===this._created&&this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game)},pause:function(){this._created&&this.onPausedCallback&&this.onPausedCallback.call(this.callbackContext,this.game)},resume:function(){this._created&&this.onResumedCallback&&this.onResumedCallback.call(this.callbackContext,this.game)},update:function(){this._created?this.onUpdateCallback&&this.onUpdateCallback.call(this.callbackContext,this.game):this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game)},postUpdate:function(){this._created&&this.onPostUpdateCallback&&this.onPostUpdateCallback.call(this.callbackContext,this.game)},pauseUpdate:function(){this._created?this.onPauseUpdateCallback&&this.onPauseUpdateCallback.call(this.callbackContext,this.game):this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game)},preRender:function(t){this._created&&this.onPreRenderCallback&&this.onPreRenderCallback.call(this.callbackContext,this.game,t)},resize:function(t,e){this.onResizeCallback&&this.onResizeCallback.call(this.callbackContext,t,e)},render:function(){this._created?this.onRenderCallback&&(this.game.renderType===e.CANVAS?(this.game.context.save(),this.game.context.setTransform(1,0,0,1,0,0),this.onRenderCallback.call(this.callbackContext,this.game),this.game.context.restore()):this.onRenderCallback.call(this.callbackContext,this.game)):this.onLoadRenderCallback&&this.onLoadRenderCallback.call(this.callbackContext,this.game)},destroy:function(){this._clearWorld=!0,this._clearCache=!0,this.clearCurrentState(),this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onLoadRenderCallback=null,this.onLoadUpdateCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onPostUpdateCallback=null,this.onRenderCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null,this.game=null,this.states={},this._pendingState=null,this.current=""}},e.StateManager.prototype.constructor=e.StateManager,Object.defineProperty(e.StateManager.prototype,"created",{get:function(){return this._created}}),e.Signal=function(){},e.Signal.prototype={_bindings:null,_prevParams:null,memorize:!1,_shouldPropagate:!0,active:!0,_boundDispatch:!1,validateListener:function(t,e){if("function"!=typeof t)throw new Error("Phaser.Signal: listener is a required param of {fn}() and should be a Function.".replace("{fn}",e))},_registerListener:function(t,i,s,n,r){var o,a=this._indexOfListener(t,s);if(-1!==a){if((o=this._bindings[a]).isOnce()!==i)throw new Error("You cannot add"+(i?"":"Once")+"() then add"+(i?"Once":"")+"() the same listener without removing the relationship first.")}else o=new e.SignalBinding(this,t,i,s,n,r),this._addBinding(o);return this.memorize&&this._prevParams&&o.execute(this._prevParams),o},_addBinding:function(t){this._bindings||(this._bindings=[]);var e=this._bindings.length;do{e--}while(this._bindings[e]&&t._priority<=this._bindings[e]._priority);this._bindings.splice(e+1,0,t)},_indexOfListener:function(t,e){if(!this._bindings)return-1;void 0===e&&(e=null);for(var i,s=this._bindings.length;s--;)if((i=this._bindings[s])._listener===t&&i.context===e)return s;return-1},has:function(t,e){return-1!==this._indexOfListener(t,e)},add:function(t,e,i){this.validateListener(t,"add");var s=[];if(arguments.length>3)for(var n=3;n<arguments.length;n++)s.push(arguments[n]);return this._registerListener(t,!1,e,i,s)},addOnce:function(t,e,i){this.validateListener(t,"addOnce");var s=[];if(arguments.length>3)for(var n=3;n<arguments.length;n++)s.push(arguments[n]);return this._registerListener(t,!0,e,i,s)},remove:function(t,e){this.validateListener(t,"remove");var i=this._indexOfListener(t,e);return-1!==i&&(this._bindings[i]._destroy(),this._bindings.splice(i,1)),t},removeAll:function(t){if(void 0===t&&(t=null),this._bindings){for(var e=this._bindings.length;e--;)t?this._bindings[e].context===t&&(this._bindings[e]._destroy(),this._bindings.splice(e,1)):this._bindings[e]._destroy();t||(this._bindings.length=0)}},getNumListeners:function(){return this._bindings?this._bindings.length:0},halt:function(){this._shouldPropagate=!1},dispatch:function(){if(this.active&&(this._bindings||this.memorize)){var t=Array.prototype.slice.call(arguments);this.memorize&&(this._prevParams=t);var e=this._bindings?this._bindings.length:0;if(e){var i=this._bindings.slice();this._shouldPropagate=!0;do{e--}while(i[e]&&this._shouldPropagate&&!1!==i[e].execute(t))}}},forget:function(){this._prevParams&&(this._prevParams=null)},dispose:function(){this.removeAll(),this._bindings=null,this._prevParams&&(this._prevParams=null)},toString:function(){return"[Phaser.Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}},Object.defineProperty(e.Signal.prototype,"boundDispatch",{get:function(){var t=this;return this._boundDispatch||(this._boundDispatch=function(){return t.dispatch.apply(t,arguments)})}}),e.Signal.prototype.constructor=e.Signal,e.SignalBinding=function(t,e,i,s,n,r){this._listener=e,i&&(this._isOnce=!0),null!=s&&(this.context=s),this._signal=t,n&&(this._priority=n),r&&r.length&&(this._args=r)},e.SignalBinding.prototype={context:null,_isOnce:!1,_priority:0,_args:null,callCount:0,active:!0,params:null,execute:function(t){var e,i;return this.active&&this._listener&&(i=this.params?this.params.concat(t):t,this._args&&(i=i.concat(this._args)),e=this._listener.apply(this.context,i),this.callCount++,this._isOnce&&this.detach()),e},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal,delete this._listener,delete this.context},toString:function(){return"[Phaser.SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}},e.SignalBinding.prototype.constructor=e.SignalBinding,e.Filter=function(t,i,s){this.game=t,this.type=e.WEBGL_FILTER,this.passes=[this],this.shaders=[],this.dirty=!0,this.padding=0,this.prevPoint=new e.Point;var n=new Date;if(this.uniforms={resolution:{type:"2f",value:{x:256,y:256}},time:{type:"1f",value:0},mouse:{type:"2f",value:{x:0,y:0}},date:{type:"4fv",value:[n.getFullYear(),n.getMonth(),n.getDate(),60*n.getHours()*60+60*n.getMinutes()+n.getSeconds()]},sampleRate:{type:"1f",value:44100},iChannel0:{type:"sampler2D",value:null,textureData:{repeat:!0}},iChannel1:{type:"sampler2D",value:null,textureData:{repeat:!0}},iChannel2:{type:"sampler2D",value:null,textureData:{repeat:!0}},iChannel3:{type:"sampler2D",value:null,textureData:{repeat:!0}}},i)for(var r in i)this.uniforms[r]=i[r];"string"==typeof s&&(s=s.split("\n")),this.fragmentSrc=s||[]},e.Filter.prototype={init:function(){},setResolution:function(t,e){this.uniforms.resolution.value.x=t,this.uniforms.resolution.value.y=e},update:function(t){if(t){var e=t.x/this.game.width,i=1-t.y/this.game.height;e===this.prevPoint.x&&i===this.prevPoint.y||(this.uniforms.mouse.value.x=e.toFixed(2),this.uniforms.mouse.value.y=i.toFixed(2),this.prevPoint.set(e,i))}this.uniforms.time.value=this.game.time.totalElapsedSeconds()},addToWorld:function(t,i,s,n,r,o){void 0===r&&(r=0),void 0===o&&(o=0),void 0!==s&&null!==s?this.width=s:s=this.width,void 0!==n&&null!==n?this.height=n:n=this.height;var a=this.game.add.image(t,i,e.Cache.DEFAULT);return a.width=s,a.height=n,a.anchor.set(r,o),a.filters=[this],a},syncUniforms:function(){for(var t=0;t<this.shaders.length;t++)this.shaders[t].dirty=!0},destroy:function(){this.passes.length=0,this.shaders.length=0,this.fragmentSrc.length=0,this.game=null,this.uniforms=null,this.prevPoint=null}},e.Filter.prototype.constructor=e.Filter,Object.defineProperty(e.Filter.prototype,"width",{get:function(){return this.uniforms.resolution.value.x},set:function(t){this.uniforms.resolution.value.x=t}}),Object.defineProperty(e.Filter.prototype,"height",{get:function(){return this.uniforms.resolution.value.y},set:function(t){this.uniforms.resolution.value.y=t}}),e.Plugin=function(t,e){void 0===e&&(e=null),this.game=t,this.parent=e,this.active=!1,this.visible=!1,this.hasPreUpdate=!1,this.hasUpdate=!1,this.hasPostUpdate=!1,this.hasRender=!1,this.hasPostRender=!1},e.Plugin.prototype={preUpdate:function(){},update:function(){},render:function(){},postRender:function(){},destroy:function(){this.game=null,this.parent=null,this.active=!1,this.visible=!1}},e.Plugin.prototype.constructor=e.Plugin,e.PluginManager=function(t){this.game=t,this.plugins=[],this._len=0,this._i=0},e.PluginManager.prototype={add:function(t){var e=Array.prototype.slice.call(arguments,1),i=!1;return"function"==typeof t?t=new t(this.game,this):(t.game=this.game,t.parent=this),"function"==typeof t.preUpdate&&(t.hasPreUpdate=!0,i=!0),"function"==typeof t.update&&(t.hasUpdate=!0,i=!0),"function"==typeof t.postUpdate&&(t.hasPostUpdate=!0,i=!0),"function"==typeof t.render&&(t.hasRender=!0,i=!0),"function"==typeof t.postRender&&(t.hasPostRender=!0,i=!0),i?((t.hasPreUpdate||t.hasUpdate||t.hasPostUpdate)&&(t.active=!0),(t.hasRender||t.hasPostRender)&&(t.visible=!0),this._len=this.plugins.push(t),"function"==typeof t.init&&t.init.apply(t,e),t):null},remove:function(t,e){for(void 0===e&&(e=!0),this._i=this._len;this._i--;)if(this.plugins[this._i]===t)return e&&t.destroy(),this.plugins.splice(this._i,1),void this._len--},removeAll:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].destroy();this.plugins.length=0,this._len=0},preUpdate:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].active&&this.plugins[this._i].hasPreUpdate&&this.plugins[this._i].preUpdate()},update:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].active&&this.plugins[this._i].hasUpdate&&this.plugins[this._i].update()},postUpdate:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].active&&this.plugins[this._i].hasPostUpdate&&this.plugins[this._i].postUpdate()},render:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].visible&&this.plugins[this._i].hasRender&&this.plugins[this._i].render()},postRender:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].visible&&this.plugins[this._i].hasPostRender&&this.plugins[this._i].postRender()},destroy:function(){this.removeAll(),this.game=null}},e.PluginManager.prototype.constructor=e.PluginManager,e.Stage=function(t){this.game=t,PIXI.DisplayObjectContainer.call(this),this.name="_stage_root",this.disableVisibilityChange=!1,this.exists=!0,this.worldTransform=new e.Matrix,this.stage=this,this.currentRenderOrderID=0,this._hiddenVar="hidden",this._onChange=null,this._bgColor={r:0,g:0,b:0,a:0,color:0,rgba:"#000000"},this.game.transparent||(this._bgColor.a=1),t.config&&this.parseConfig(t.config)},e.Stage.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),e.Stage.prototype.constructor=e.Stage,e.Stage.prototype.parseConfig=function(t){t.disableVisibilityChange&&(this.disableVisibilityChange=t.disableVisibilityChange),t.backgroundColor&&this.setBackgroundColor(t.backgroundColor)},e.Stage.prototype.boot=function(){e.DOM.getOffset(this.game.canvas,this.offset),e.Canvas.setUserSelect(this.game.canvas,"none"),e.Canvas.setTouchAction(this.game.canvas,"none"),this.checkVisibility()},e.Stage.prototype.preUpdate=function(){this.currentRenderOrderID=0;for(var t=0;t<this.children.length;){var e=this.children[t];e.preUpdate(),this===e.parent&&t++}},e.Stage.prototype.update=function(){for(var t=this.children.length;t--;)this.children[t].update()},e.Stage.prototype.postUpdate=function(){this.game.camera.update(),this.game.camera.target&&(this.game.camera.target.postUpdate(),this.updateTransform(),this.game.camera.updateTarget());for(var t=0;t<this.children.length;t++)this.children[t].postUpdate();this.updateTransform()},e.Stage.prototype.updateTransform=function(){this.worldAlpha=1;for(var t=0;t<this.children.length;t++)this.children[t].updateTransform()},e.Stage.prototype.checkVisibility=function(){void 0!==document.hidden?this._hiddenVar="visibilitychange":void 0!==document.webkitHidden?this._hiddenVar="webkitvisibilitychange":void 0!==document.mozHidden?this._hiddenVar="mozvisibilitychange":void 0!==document.msHidden?this._hiddenVar="msvisibilitychange":this._hiddenVar=null;var t=this;this._onChange=function(e){return t.visibilityChange(e)},this._onChangePause=function(){return t._onChange({type:"pause"})},this._onChangeResume=function(){return t._onChange({type:"resume"})},this._onClick=function(e){void 0===document.hasFocus||document.hasFocus()||t.visibilityChange(e)},this._hiddenVar&&document.addEventListener(this._hiddenVar,this._onChange,!1),window.onblur=this._onChange,window.onfocus=this._onChange,window.onpagehide=this._onChange,window.onpageshow=this._onChange,window.addEventListener("click",this._onClick),this.game.device.cocoonJSApp&&CocoonJS.App&&(CocoonJS.App.onSuspended&&CocoonJS.App.onSuspended.addEventListener(this._onChangePause),CocoonJS.App.onActivated&&CocoonJS.App.onActivated.addEventListener(this._onChangeResume),CocoonJS.App.on&&(CocoonJS.App.on("activated",this._onChangeResume),CocoonJS.App.on("suspended",this._onChangePause)))},e.Stage.prototype.visibilityChange=function(t){switch(t.type){case"blur":case"pagehide":return void this.game.focusLoss(t);case"click":case"focus":case"pageshow":return void this.game.focusGain(t)}this.disableVisibilityChange||(document.hidden||document.mozHidden||document.msHidden||document.webkitHidden||"pause"===t.type?this.game.gamePaused(t):this.game.gameResumed(t))},e.Stage.prototype.setBackgroundColor=function(t){this.game.transparent||(e.Color.valueToColor(t,this._bgColor),e.Color.updateColor(this._bgColor),this._bgColor.r/=255,this._bgColor.g/=255,this._bgColor.b/=255,this._bgColor.a=1)},e.Stage.prototype.destroy=function(){this._hiddenVar&&document.removeEventListener(this._hiddenVar,this._onChange,!1),window.onpagehide=null,window.onpageshow=null,window.onblur=null,window.onfocus=null,window.removeEventListener("click",this._onClick)},e.Stage.prototype.add=function(t,e,i){return t.parent===this?t:(t.body&&t.parent&&t.parent.hash&&t.parent.removeFromHash(t),void 0===i?this.addChild(t):this.addChildAt(t,i),t)},Object.defineProperty(e.Stage.prototype,"backgroundColor",{get:function(){return this._bgColor.color},set:function(t){this.setBackgroundColor(t)}}),Object.defineProperty(e.Stage.prototype,"smoothed",{get:function(){return PIXI.scaleModes.DEFAULT===PIXI.scaleModes.LINEAR},set:function(t){PIXI.scaleModes.DEFAULT=t?PIXI.scaleModes.LINEAR:PIXI.scaleModes.NEAREST}}),e.Group=function(t,i,s,n,r,o){void 0===n&&(n=!1),void 0===r&&(r=!1),void 0===o&&(o=e.Physics.ARCADE),this.game=t,void 0===i&&(i=t.world),this.name=s||"group",this.z=0,PIXI.DisplayObjectContainer.call(this),n?(this.game.stage.addChild(this),this.z=this.game.stage.children.length):i&&(i.addChild(this),this.z=i.children.length),this.type=e.GROUP,this.physicsType=e.GROUP,this.alive=!0,this.exists=!0,this.ignoreDestroy=!1,this.pendingDestroy=!1,this.classType=e.Sprite,this.cursor=null,this.inputEnableChildren=!1,this.updateOnlyExistingChildren=!1,this.onChildInputDown=new e.Signal,this.onChildInputUp=new e.Signal,this.onChildInputOver=new e.Signal,this.onChildInputOut=new e.Signal,this.enableBody=r,this.enableBodyDebug=!1,this.physicsBodyType=o,this.physicsSortDirection=null,this.onDestroy=new e.Signal,this.cursorIndex=0,this.fixedToCamera=!1,this.cameraOffset=new e.Point,this.hash=[],this._sortProperty="z"},e.Group.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),e.Group.prototype.constructor=e.Group,e.Group.RETURN_NONE=0,e.Group.RETURN_TOTAL=1,e.Group.RETURN_CHILD=2,e.Group.RETURN_ALL=3,e.Group.SORT_ASCENDING=-1,e.Group.SORT_DESCENDING=1,e.Group.prototype.add=function(t,e,i){return void 0===e&&(e=!1),t.parent===this?t:(t.body&&t.parent&&t.parent.hash&&t.parent.removeFromHash(t),void 0===i?(t.z=this.children.length,this.addChild(t)):(this.addChildAt(t,i),this.updateZ()),this.enableBody&&t.hasOwnProperty("body")&&null===t.body?this.game.physics.enable(t,this.physicsBodyType):t.body&&this.addToHash(t),!this.inputEnableChildren||t.input&&!t.inputEnabled||(t.inputEnabled=!0),!e&&t.events&&t.events.onAddedToGroup$dispatch(t,this),null===this.cursor&&(this.cursor=t),t)},e.Group.prototype.addAt=function(t,e,i){return this.add(t,i,e)},e.Group.prototype.addToHash=function(t){return t.parent===this&&-1===this.hash.indexOf(t)&&(this.hash.push(t),!0)},e.Group.prototype.removeFromHash=function(t){if(t){var e=this.hash.indexOf(t);if(-1!==e)return this.hash.splice(e,1),!0}return!1},e.Group.prototype.addMultiple=function(t,i){if(t instanceof e.Group)t.moveAll(this,i);else if(Array.isArray(t))for(var s=0;s<t.length;s++)this.add(t[s],i);return t},e.Group.prototype.getAt=function(t){return t<0||t>=this.children.length?-1:this.getChildAt(t)},e.Group.prototype.create=function(t,e,i,s,n,r){void 0===n&&(n=!0);var o=new this.classType(this.game,t,e,i,s);return o.exists=n,o.visible=n,o.alive=n,this.add(o,!1,r)},e.Group.prototype.createMultiple=function(t,e,i,s,n,r){void 0===i&&(i=0),void 0===s&&(s=!1),Array.isArray(e)||(e=[e]),Array.isArray(i)||(i=[i]);var o=this,a=[];return e.forEach(function(e){i.forEach(function(i){for(var h=0;h<t;h++){var l=o.create(0,0,e,i,s);n&&n.call(r||l,l,h),a.push(l)}})}),a},e.Group.prototype.updateZ=function(){for(var t=this.children.length;t--;)this.children[t].z=t},e.Group.prototype.align=function(t,i,s,n,r,o){if(void 0===r&&(r=e.TOP_LEFT),void 0===o&&(o=0),0===this.children.length||o>this.children.length||-1===t&&-1===i)return!1;for(var a=new e.Rectangle(0,0,s,n),h=t*s,l=i*n,c=o;c<this.children.length;c++){var u=this.children[c];if(u.alignIn)if(u.alignIn(a,r),-1===t)a.y+=n,a.y===l&&(a.x+=s,a.y=0);else if(-1===i)a.x+=s,a.x===h&&(a.x=0,a.y+=n);else if(a.x+=s,a.x===h&&(a.x=0,a.y+=n,a.y===l))return!0}return!0},e.Group.prototype.resetCursor=function(t){if(void 0===t&&(t=0),t>this.children.length-1&&(t=0),this.cursor)return this.cursorIndex=t,this.cursor=this.children[this.cursorIndex],this.cursor},e.Group.prototype.next=function(){if(this.cursor)return this.cursorIndex>=this.children.length-1?this.cursorIndex=0:this.cursorIndex++,this.cursor=this.children[this.cursorIndex],this.cursor},e.Group.prototype.previous=function(){if(this.cursor)return 0===this.cursorIndex?this.cursorIndex=this.children.length-1:this.cursorIndex--,this.cursor=this.children[this.cursorIndex],this.cursor},e.Group.prototype.swap=function(t,e){this.swapChildren(t,e),this.updateZ()},e.Group.prototype.bringToTop=function(t){return t.parent===this&&this.getIndex(t)<this.children.length&&(this.remove(t,!1,!0),this.add(t,!0)),t},e.Group.prototype.bringChildToTop=e.Group.prototype.bringToTop,e.Group.prototype.sendToBack=function(t){return t.parent===this&&this.getIndex(t)>0&&(this.remove(t,!1,!0),this.addAt(t,0,!0)),t},e.Group.prototype.sendChildToBack=e.Group.prototype.sendToBack,e.Group.prototype.moveUp=function(t){if(t.parent===this&&this.getIndex(t)<this.children.length-1){var e=this.getIndex(t),i=this.getAt(e+1);i&&this.swap(t,i)}return t},e.Group.prototype.moveDown=function(t){if(t.parent===this&&this.getIndex(t)>0){var e=this.getIndex(t),i=this.getAt(e-1);i&&this.swap(t,i)}return t},e.Group.prototype.xy=function(t,e,i){if(t<0||t>this.children.length)return-1;this.getChildAt(t).x=e,this.getChildAt(t).y=i},e.Group.prototype.reverse=function(){this.children.reverse(),this.updateZ()},e.Group.prototype.getIndex=function(t){return this.children.indexOf(t)},e.Group.prototype.getByName=function(t){return this.getFirst("name",t)},e.Group.prototype.replace=function(t,i){var s=this.getIndex(t);if(-1!==s)return i.parent&&(i.parent instanceof e.Group?i.parent.remove(i):i.parent.removeChild(i)),this.remove(t),this.addAt(i,s),t},e.Group.prototype.hasProperty=function(t,e){var i=e.length;return 1===i&&e[0]in t||(2===i&&e[0]in t&&e[1]in t[e[0]]||(3===i&&e[0]in t&&e[1]in t[e[0]]&&e[2]in t[e[0]][e[1]]||4===i&&e[0]in t&&e[1]in t[e[0]]&&e[2]in t[e[0]][e[1]]&&e[3]in t[e[0]][e[1]][e[2]]))},e.Group.prototype.setProperty=function(t,e,i,s,n){if(void 0===n&&(n=!1),s=s||0,!this.hasProperty(t,e)&&(!n||s>0))return!1;var r=e.length;return 1===r?0===s?t[e[0]]=i:1===s?t[e[0]]+=i:2===s?t[e[0]]-=i:3===s?t[e[0]]*=i:4===s&&(t[e[0]]/=i):2===r?0===s?t[e[0]][e[1]]=i:1===s?t[e[0]][e[1]]+=i:2===s?t[e[0]][e[1]]-=i:3===s?t[e[0]][e[1]]*=i:4===s&&(t[e[0]][e[1]]/=i):3===r?0===s?t[e[0]][e[1]][e[2]]=i:1===s?t[e[0]][e[1]][e[2]]+=i:2===s?t[e[0]][e[1]][e[2]]-=i:3===s?t[e[0]][e[1]][e[2]]*=i:4===s&&(t[e[0]][e[1]][e[2]]/=i):4===r&&(0===s?t[e[0]][e[1]][e[2]][e[3]]=i:1===s?t[e[0]][e[1]][e[2]][e[3]]+=i:2===s?t[e[0]][e[1]][e[2]][e[3]]-=i:3===s?t[e[0]][e[1]][e[2]][e[3]]*=i:4===s&&(t[e[0]][e[1]][e[2]][e[3]]/=i)),!0},e.Group.prototype.checkProperty=function(t,i,s,n){if(void 0===n&&(n=!1),this!==t.parent)return!1;var r=e.Utils.getProperty(t,i);return!(void 0===r&&n||r!==s)},e.Group.prototype.set=function(t,e,i,s,n,r,o){if(void 0===o&&(o=!1),e=e.split("."),void 0===s&&(s=!1),void 0===n&&(n=!1),(!1===s||s&&t.alive)&&(!1===n||n&&t.visible))return this.setProperty(t,e,i,r,o)},e.Group.prototype.setAll=function(t,e,i,s,n,r){void 0===i&&(i=!1),void 0===s&&(s=!1),void 0===r&&(r=!1),t=t.split("."),n=n||0;for(var o=this.children.length,a=0;a<o;a++){var h=this.children[a];i&&!h.alive||s&&!h.visible||this.setProperty(h,t,e,n,r)}},e.Group.prototype.setAllChildren=function(t,i,s,n,r,o){void 0===s&&(s=!1),void 0===n&&(n=!1),void 0===o&&(o=!1),r=r||0;for(var a=this.children.length,h=0;h<a;h++){var l=this.children[h];s&&!l.alive||n&&!l.visible||(l instanceof e.Group?l.setAllChildren(t,i,s,n,r,o):this.setProperty(l,t.split("."),i,r,o))}},e.Group.prototype.checkAll=function(t,e,i,s,n){void 0===i&&(i=!1),void 0===s&&(s=!1),void 0===n&&(n=!1);for(var r=0;r<this.children.length;r++){var o=this.children[r];if((!i||o.alive)&&(!s||o.visible)&&!this.checkProperty(o,t,e,n))return!1}return!0},e.Group.prototype.checkAny=function(t,e,i,s){void 0===i&&(i=!1),void 0===s&&(s=!1);for(var n=0;n<this.children.length;n++){var r=this.children[n];if((!i||r.alive)&&(!s||r.visible)&&this.checkProperty(r,t,e))return!0}return!1},e.Group.prototype.addAll=function(t,e,i,s){this.setAll(t,e,i,s,1)},e.Group.prototype.subAll=function(t,e,i,s){this.setAll(t,e,i,s,2)},e.Group.prototype.multiplyAll=function(t,e,i,s){this.setAll(t,e,i,s,3)},e.Group.prototype.divideAll=function(t,e,i,s){this.setAll(t,e,i,s,4)},e.Group.prototype.kill=function(){this.alive=!1,this.exists=!1,this.visible=!1},e.Group.prototype.killAll=function(){this.callAllExists("kill",!0)},e.Group.prototype.revive=function(){this.alive=!0,this.exists=!0,this.visible=!0},e.Group.prototype.reviveAll=function(){this.callAllExists("revive",!1)},e.Group.prototype.resetAll=function(t,e,i,s,n){this.forEach(this.resetChild,this,n,t,e,i,s)},e.Group.prototype.callAllExists=function(t,e){var i;if(arguments.length>2){i=[];for(s=2;s<arguments.length;s++)i.push(arguments[s])}for(var s=0;s<this.children.length;s++){var n=this.children[s];n.exists===e&&n[t]&&n[t].apply(n,i)}},e.Group.prototype.callbackFromArray=function(t,e,i){if(1===i){if(t[e[0]])return t[e[0]]}else if(2===i){if(t[e[0]][e[1]])return t[e[0]][e[1]]}else if(3===i){if(t[e[0]][e[1]][e[2]])return t[e[0]][e[1]][e[2]]}else if(4===i){if(t[e[0]][e[1]][e[2]][e[3]])return t[e[0]][e[1]][e[2]][e[3]]}else if(t[e])return t[e];return!1},e.Group.prototype.callAll=function(t,e){if(void 0!==t){var i=(t=t.split(".")).length;if(void 0===e||null===e||""===e)e=null;else if("string"==typeof e)var s=(e=e.split(".")).length;var n;if(arguments.length>2){n=[];for(a=2;a<arguments.length;a++)n.push(arguments[a])}for(var r=null,o=null,a=0;a<this.children.length;a++){var h=this.children[a];r=this.callbackFromArray(h,t,i),e&&r?(o=this.callbackFromArray(h,e,s),r.apply(o,n)):r&&r.apply(h,n)}}},e.Group.prototype.preUpdate=function(){if(this.pendingDestroy)return this.destroy(),!1;if(!this.exists||!this.parent.exists)return this.renderOrderID=-1,!1;for(var t=0;t<this.children.length;){var e=this.children[t];e.preUpdate(),this===e.parent&&t++}return!0},e.Group.prototype.update=function(){for(var t=this.children.length;t--;){var e=this.children.length;t>=e&&(t=e-1);var i=this.children[t];this.updateOnlyExistingChildren&&!i.exists||i.update()}},e.Group.prototype.postUpdate=function(){this.fixedToCamera&&(this.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y);for(var t=0;t<this.children.length;t++)this.children[t].postUpdate()},e.Group.prototype.filter=function(t,i){for(var s=-1,n=this.children.length,r=[];++s<n;){var o=this.children[s];(!i||i&&o.exists)&&t(o,s,this.children)&&r.push(o)}return new e.ArraySet(r)},e.Group.prototype.forEach=function(t,e,i){if(void 0===i&&(i=!1),arguments.length<=3)for(n=0;n<this.children.length;n++){r=this.children[n];i&&!r.exists||t.call(e,r)}else{for(var s=[null],n=3;n<arguments.length;n++)s.push(arguments[n]);for(n=0;n<this.children.length;n++){var r=this.children[n];i&&!r.exists||(s[0]=r,t.apply(e,s))}}},e.Group.prototype.forEachExists=function(t,i){var s;if(arguments.length>2){s=[null];for(var n=2;n<arguments.length;n++)s.push(arguments[n])}this.iterate("exists",!0,e.Group.RETURN_TOTAL,t,i,s)},e.Group.prototype.forEachAlive=function(t,i){var s;if(arguments.length>2){s=[null];for(var n=2;n<arguments.length;n++)s.push(arguments[n])}this.iterate("alive",!0,e.Group.RETURN_TOTAL,t,i,s)},e.Group.prototype.forEachDead=function(t,i){var s;if(arguments.length>2){s=[null];for(var n=2;n<arguments.length;n++)s.push(arguments[n])}this.iterate("alive",!1,e.Group.RETURN_TOTAL,t,i,s)},e.Group.prototype.sort=function(t,i){this.children.length<2||(void 0===t&&(t="z"),void 0===i&&(i=e.Group.SORT_ASCENDING),this._sortProperty=t,i===e.Group.SORT_ASCENDING?this.children.sort(this.ascendingSortHandler.bind(this)):this.children.sort(this.descendingSortHandler.bind(this)),this.updateZ())},e.Group.prototype.customSort=function(t,e){this.children.length<2||(this.children.sort(t.bind(e)),this.updateZ())},e.Group.prototype.ascendingSortHandler=function(t,e){return t[this._sortProperty]<e[this._sortProperty]?-1:t[this._sortProperty]>e[this._sortProperty]?1:t.z<e.z?-1:1},e.Group.prototype.descendingSortHandler=function(t,e){return t[this._sortProperty]<e[this._sortProperty]?1:t[this._sortProperty]>e[this._sortProperty]?-1:0},e.Group.prototype.iterate=function(t,i,s,n,r,o){if(0===this.children.length){if(s===e.Group.RETURN_TOTAL)return 0;if(s===e.Group.RETURN_ALL)return[]}var a=0;if(s===e.Group.RETURN_ALL)var h=[];for(var l=0;l<this.children.length;l++)if(this.children[l][t]===i){if(a++,n&&(o?(o[0]=this.children[l],n.apply(r,o)):n.call(r,this.children[l])),s===e.Group.RETURN_CHILD)return this.children[l];s===e.Group.RETURN_ALL&&h.push(this.children[l])}return s===e.Group.RETURN_TOTAL?a:s===e.Group.RETURN_ALL?h:null},e.Group.prototype.getFirst=function(t,i){return this.iterate(t,i,e.Group.RETURN_CHILD)},e.Group.prototype.getFirstExists=function(t,e,i,s,n,r){void 0===e&&(e=!1),"boolean"!=typeof t&&(t=!0);var o=this.getFirst("exists",t);return null===o&&e?this.create(i,s,n,r):this.resetChild(o,i,s,n,r)},e.Group.prototype.getFirstAlive=function(t,e,i,s,n){void 0===t&&(t=!1);var r=this.getFirst("alive",!0);return null===r&&t?this.create(e,i,s,n):this.resetChild(r,e,i,s,n)},e.Group.prototype.getFirstDead=function(t,e,i,s,n){void 0===t&&(t=!1);var r=this.getFirst("alive",!1);return null===r&&t?this.create(e,i,s,n):this.resetChild(r,e,i,s,n)},e.Group.prototype.resetChild=function(t,e,i,s,n){return null===t?null:(void 0===e&&(e=null),void 0===i&&(i=null),null!==e&&null!==i&&t.reset(e,i),void 0!==s&&t.loadTexture(s,n),t)},e.Group.prototype.getTop=function(){if(this.children.length>0)return this.children[this.children.length-1]},e.Group.prototype.getBottom=function(){if(this.children.length>0)return this.children[0]},e.Group.prototype.getClosestTo=function(t,i,s){for(var n=Number.MAX_VALUE,r=0,o=null,a=0;a<this.children.length;a++){var h=this.children[a];h.exists&&(r=Math.abs(e.Point.distance(t,h)))<n&&(!i||i.call(s,h,r))&&(n=r,o=h)}return o},e.Group.prototype.getFurthestFrom=function(t,i,s){for(var n=0,r=0,o=null,a=0;a<this.children.length;a++){var h=this.children[a];h.exists&&(r=Math.abs(e.Point.distance(t,h)))>n&&(!i||i.call(s,h,r))&&(n=r,o=h)}return o},e.Group.prototype.count=function(t,i){return this.iterate(t,i,e.Group.RETURN_TOTAL)},e.Group.prototype.countLiving=function(){return this.count("alive",!0)},e.Group.prototype.countDead=function(){return this.count("alive",!1)},e.Group.prototype.getRandom=function(t,i){return void 0===t&&(t=0),void 0===i&&(i=this.children.length),0===i?null:e.ArrayUtils.getRandomItem(this.children,t,i)},e.Group.prototype.getRandomExists=function(t,e){var i=this.getAll("exists",!0,t,e);return this.game.rnd.pick(i)},e.Group.prototype.getAll=function(t,e,i,s){void 0===i&&(i=0),void 0===s&&(s=this.children.length);for(var n=[],r=i;r<s;r++){var o=this.children[r];t?o[t]===e&&n.push(o):n.push(o)}return n},e.Group.prototype.remove=function(t,e,i){if(void 0===e&&(e=!1),void 0===i&&(i=!1),0===this.children.length||-1===this.children.indexOf(t))return!1;i||!t.events||t.destroyPhase||t.events.onRemovedFromGroup$dispatch(t,this);var s=this.removeChild(t);return this.removeFromHash(t),this.updateZ(),this.cursor===t&&this.next(),e&&s&&s.destroy(!0),!0},e.Group.prototype.moveAll=function(t,i){if(void 0===i&&(i=!1),this.children.length>0&&t instanceof e.Group){do{t.add(this.children[0],i)}while(this.children.length>0);this.hash=[],this.cursor=null}return t},e.Group.prototype.removeAll=function(t,e,i){if(void 0===t&&(t=!1),void 0===e&&(e=!1),void 0===i&&(i=!1),0!==this.children.length){do{!e&&this.children[0].events&&this.children[0].events.onRemovedFromGroup$dispatch(this.children[0],this);var s=this.removeChild(this.children[0]);this.removeFromHash(s),t&&s&&s.destroy(!0,i)}while(this.children.length>0);this.hash=[],this.cursor=null}},e.Group.prototype.removeBetween=function(t,e,i,s){if(void 0===e&&(e=this.children.length-1),void 0===i&&(i=!1),void 0===s&&(s=!1),0!==this.children.length){if(t>e||t<0||e>this.children.length)return!1;for(var n=e;n>=t;){!s&&this.children[n].events&&this.children[n].events.onRemovedFromGroup$dispatch(this.children[n],this);var r=this.removeChild(this.children[n]);this.removeFromHash(r),i&&r&&r.destroy(!0),this.cursor===this.children[n]&&(this.cursor=null),n--}this.updateZ()}},e.Group.prototype.scatter=function(t,e){null==t&&(t=this.game.world.bounds),this.forEach(function(e){e.position.set(t.randomX,t.randomY)},null,e)},e.Group.prototype.shuffle=function(){e.ArrayUtils.shuffle(this.children),this.updateZ()},e.Group.prototype.destroy=function(t,e){null===this.game||this.ignoreDestroy||(void 0===t&&(t=!0),void 0===e&&(e=!1),this.onDestroy.dispatch(this,t,e),this.removeAll(t),this.cursor=null,this.filters=null,this.pendingDestroy=!1,e||(this.parent&&this.parent.removeChild(this),this.game=null,this.exists=!1))},Object.defineProperty(e.Group.prototype,"total",{get:function(){return this.iterate("exists",!0,e.Group.RETURN_TOTAL)}}),Object.defineProperty(e.Group.prototype,"length",{get:function(){return this.children.length}}),Object.defineProperty(e.Group.prototype,"angle",{get:function(){return e.Math.radToDeg(this.rotation)},set:function(t){this.rotation=e.Math.degToRad(t)}}),Object.defineProperty(e.Group.prototype,"centerX",{get:function(){return this.getBounds(this.parent).centerX},set:function(t){var e=this.getBounds(this.parent),i=this.x-e.x;this.x=t+i-e.halfWidth}}),Object.defineProperty(e.Group.prototype,"centerY",{get:function(){return this.getBounds(this.parent).centerY},set:function(t){var e=this.getBounds(this.parent),i=this.y-e.y;this.y=t+i-e.halfHeight}}),Object.defineProperty(e.Group.prototype,"left",{get:function(){return this.getBounds(this.parent).left},set:function(t){var e=this.getBounds(this.parent),i=this.x-e.x;this.x=t+i}}),Object.defineProperty(e.Group.prototype,"right",{get:function(){return this.getBounds(this.parent).right},set:function(t){var e=this.getBounds(this.parent),i=this.x-e.x;this.x=t+i-e.width}}),Object.defineProperty(e.Group.prototype,"top",{get:function(){return this.getBounds(this.parent).top},set:function(t){var e=this.getBounds(this.parent),i=this.y-e.y;this.y=t+i}}),Object.defineProperty(e.Group.prototype,"bottom",{get:function(){return this.getBounds(this.parent).bottom},set:function(t){var e=this.getBounds(this.parent),i=this.y-e.y;this.y=t+i-e.height}}),e.World=function(t){e.Group.call(this,t,null,"__world",!1),this.bounds=new e.Rectangle(0,0,t.width,t.height),this.camera=null,this._definedSize=!1,this._width=t.width,this._height=t.height,this.game.state.onStateChange.add(this.stateChange,this)},e.World.prototype=Object.create(e.Group.prototype),e.World.prototype.constructor=e.World,e.World.prototype.boot=function(){this.camera=new e.Camera(this.game,0,0,0,this.game.width,this.game.height),this.game.stage.addChild(this),this.camera.boot()},e.World.prototype.stateChange=function(){this.x=0,this.y=0,this.camera.reset()},e.World.prototype.setBounds=function(t,e,i,s){this._definedSize=!0,this._width=i,this._height=s,this.bounds.setTo(t,e,i,s),this.x=t,this.y=e,this.camera.bounds&&this.camera.bounds.setTo(t,e,Math.max(i,this.game.width),Math.max(s,this.game.height)),this.game.physics.setBoundsToWorld()},e.World.prototype.resize=function(t,e){this._definedSize&&(t<this._width&&(t=this._width),e<this._height&&(e=this._height)),this.bounds.width=t,this.bounds.height=e,this.game.camera.setBoundsToWorld(),this.game.physics.setBoundsToWorld()},e.World.prototype.shutdown=function(){this.destroy(!0,!0)},e.World.prototype.wrap=function(t,e,i,s,n){void 0===e&&(e=0),void 0===i&&(i=!1),void 0===s&&(s=!0),void 0===n&&(n=!0),i?(t.getBounds(),s&&(t.x+t._currentBounds.width<this.bounds.x?t.x=this.bounds.right:t.x>this.bounds.right&&(t.x=this.bounds.left)),n&&(t.y+t._currentBounds.height<this.bounds.top?t.y=this.bounds.bottom:t.y>this.bounds.bottom&&(t.y=this.bounds.top))):(s&&t.x+e<this.bounds.x?t.x=this.bounds.right+e:s&&t.x-e>this.bounds.right&&(t.x=this.bounds.left-e),n&&t.y+e<this.bounds.top?t.y=this.bounds.bottom+e:n&&t.y-e>this.bounds.bottom&&(t.y=this.bounds.top-e))},e.World.prototype.wrapAll=function(t,e,i,s,n,r){t.forEach(this.wrap,this,e,i,s,n,r)},Object.defineProperty(e.World.prototype,"width",{get:function(){return this.bounds.width},set:function(t){t<this.game.width&&(t=this.game.width),this.bounds.width=t,this._width=t,this._definedSize=!0}}),Object.defineProperty(e.World.prototype,"height",{get:function(){return this.bounds.height},set:function(t){t<this.game.height&&(t=this.game.height),this.bounds.height=t,this._height=t,this._definedSize=!0}}),Object.defineProperty(e.World.prototype,"centerX",{get:function(){return this.bounds.halfWidth+this.bounds.x}}),Object.defineProperty(e.World.prototype,"centerY",{get:function(){return this.bounds.halfHeight+this.bounds.y}}),Object.defineProperty(e.World.prototype,"randomX",{get:function(){return this.bounds.x<0?this.game.rnd.between(this.bounds.x,this.bounds.width-Math.abs(this.bounds.x)):this.game.rnd.between(this.bounds.x,this.bounds.width)}}),Object.defineProperty(e.World.prototype,"randomY",{get:function(){return this.bounds.y<0?this.game.rnd.between(this.bounds.y,this.bounds.height-Math.abs(this.bounds.y)):this.game.rnd.between(this.bounds.y,this.bounds.height)}}),e.Game=function(t,i,s,n,r,o,a,h){return this.id=e.GAMES.push(this)-1,this.config=null,this.physicsConfig=h,this.parent="",this.width=800,this.height=600,this.resolution=1,this._width=800,this._height=600,this.transparent=!1,this.antialias=!0,this.multiTexture=!1,this.preserveDrawingBuffer=!1,this.clearBeforeRender=!0,this.renderer=null,this.renderType=e.AUTO,this.state=null,this.isBooted=!1,this.isRunning=!1,this.raf=null,this.add=null,this.make=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.net=null,this.scale=null,this.sound=null,this.stage=null,this.time=null,this.tweens=null,this.world=null,this.physics=null,this.plugins=null,this.rnd=null,this.device=e.Device,this.camera=null,this.canvas=null,this.context=null,this.debug=null,this.particles=null,this.create=null,this.lockRender=!1,this.pendingDestroy=!1,this.stepping=!1,this.pendingStep=!1,this.stepCount=0,this.onPause=null,this.onResume=null,this.onBlur=null,this.onFocus=null,this._paused=!1,this._codePaused=!1,this.currentUpdateID=0,this.updatesThisFrame=1,this.rendersThisFrame=1,this._deltaTime=0,this._lastCount=0,this._spiraling=0,this._kickstart=!0,this.fpsProblemNotifier=new e.Signal,this.forceSingleUpdate=!0,this.forceSingleRender=!0,this.dropFrames=!1,this.powerPreference="default",this._nextFpsNotification=0,1===arguments.length&&"object"==typeof arguments[0]?this.parseConfig(arguments[0]):(this.config={enableDebug:!0},void 0!==t&&(this._width=t),void 0!==i&&(this._height=i),void 0!==s&&(this.renderType=s),void 0!==n&&(this.parent=n),void 0!==o&&(this.transparent=o),void 0!==a&&(this.antialias=a),this.rnd=new e.RandomDataGenerator([(Date.now()*Math.random()).toString()]),this.state=new e.StateManager(this,r)),this.device.whenReady(this.boot,this),this},e.Game.prototype={parseConfig:function(t){this.config=t,void 0===t.enableDebug&&(this.config.enableDebug=!0),t.width&&(this._width=t.width),t.height&&(this._height=t.height),t.renderer&&(this.renderType=t.renderer),t.parent&&(this.parent=t.parent),void 0!==t.transparent&&(this.transparent=t.transparent),void 0!==t.antialias&&(this.antialias=t.antialias),void 0!==t.clearBeforeRender&&(this.clearBeforeRender=t.clearBeforeRender),void 0!==t.multiTexture&&(this.multiTexture=t.multiTexture),t.resolution&&(this.resolution=t.resolution),void 0!==t.preserveDrawingBuffer&&(this.preserveDrawingBuffer=t.preserveDrawingBuffer),void 0!==t.powerPreference&&(this.powerPreference=t.powerPreference),t.physicsConfig&&(this.physicsConfig=t.physicsConfig);var i=[(Date.now()*Math.random()).toString()];t.seed&&(i=t.seed),this.rnd=new e.RandomDataGenerator(i);var s=null;t.state&&(s=t.state),this.state=new e.StateManager(this,s)},boot:function(){if(!this.isBooted){if(this.onPause=new e.Signal,this.onResume=new e.Signal,this.onBlur=new e.Signal,this.onFocus=new e.Signal,this.isBooted=!0,PIXI.game=this,this.math=e.Math,this.scale=new e.ScaleManager(this,this._width,this._height),this.stage=new e.Stage(this),this.setUpRenderer(),this.world=new e.World(this),this.add=new e.GameObjectFactory(this),this.make=new e.GameObjectCreator(this),this.cache=new e.Cache(this),this.load=new e.Loader(this),this.time=new e.Time(this),this.tweens=new e.TweenManager(this),this.input=new e.Input(this),this.sound=new e.SoundManager(this),this.physics=new e.Physics(this,this.physicsConfig),this.particles=new e.Particles(this),this.create=new e.Create(this),this.plugins=new e.PluginManager(this),this.net=new e.Net(this),this.time.boot(),this.stage.boot(),this.world.boot(),this.scale.boot(),this.input.boot(this.config),this.sound.boot(),this.state.boot(),this.config.enableDebug)this.debug=new e.Utils.Debug(this),this.debug.boot();else{var t=function(){};this.debug={preUpdate:t,update:t,reset:t,destroy:t,isDisabled:!0}}this.showDebugHeader(),this.isRunning=!0,this.config&&this.config.forceSetTimeOut?this.raf=new e.RequestAnimationFrame(this,this.config.forceSetTimeOut):this.raf=new e.RequestAnimationFrame(this,!1),this._kickstart=!0,this.focusWindow(),this.config.disableStart||(this.cache.isReady?this.raf.start():this.cache.onReady.addOnce(function(){this.raf.start()},this))}},showDebugHeader:function(){if(!window.PhaserGlobal||!window.PhaserGlobal.hideBanner){var t=e.VERSION,i="Canvas",s="HTML Audio",n=1;if(this.renderType===e.WEBGL?(i="WebGL",n++):this.renderType===e.HEADLESS&&(i="Headless"),this.device.webAudio&&(s="WebAudio",n++),this.device.ie)window.console&&console.log("Phaser v"+t+" | Pixi.js | "+i+" | "+s+" | http://phaser.io");else{for(var r=["%c %c %c Phaser CE v"+t+" | Pixi.js | "+i+" | "+s+" %c %c %c http://phaser.io %c♥%c♥%c♥","background: #fb8cb3","background: #d44a52","color: #ffffff; background: #871905;","background: #d44a52","background: #fb8cb3","background: #ffffff"],o=0;o<3;o++)o<n?r.push("color: #ff2424; background: #fff"):r.push("color: #959595; background: #fff");console.log.apply(console,r)}}},setUpRenderer:function(){if(!this.device.canvas)throw new Error("Phaser.Game - Cannot create Canvas 2d context, aborting.");if(this.config.canvas?this.canvas=this.config.canvas:this.canvas=e.Canvas.create(this,this.width,this.height,this.config.canvasID,!0),this.config.canvasStyle?this.canvas.style=this.config.canvasStyle:this.canvas.style["-webkit-full-screen"]="width: 100%; height: 100%",this.config.crisp&&e.Canvas.setImageRenderingCrisp(this.canvas),this.renderType===e.WEBGL||this.renderType===e.WEBGL_MULTI||this.renderType===e.AUTO&&this.device.webGL){(this.multiTexture||this.renderType===e.WEBGL_MULTI)&&(PIXI.enableMultiTexture(),this.multiTexture=!0);try{this.renderer=new PIXI.WebGLRenderer(this,this.config),this.renderType=e.WEBGL,this.context=null,this.canvas.addEventListener("webglcontextlost",this.contextLost.bind(this),!1),this.canvas.addEventListener("webglcontextrestored",this.contextRestored.bind(this),!1)}catch(t){if(PIXI.defaultRenderer=null,this.renderer=null,this.multiTexture=!1,PIXI._enableMultiTextureToggle=!1,this.renderType===e.WEBGL)throw t}}this.renderer||(this.renderer=new PIXI.CanvasRenderer(this,this.config),this.context=this.renderer.context,this.renderType===e.AUTO&&(this.renderType=e.CANVAS)),this.device.cocoonJS&&(this.canvas.screencanvas=this.renderType===e.CANVAS),this.renderType!==e.HEADLESS&&(this.stage.smoothed=this.antialias,e.Canvas.addToDOM(this.canvas,this.parent,!1),e.Canvas.setTouchAction(this.canvas))},contextLost:function(t){t.preventDefault(),this.renderer.contextLost=!0},contextRestored:function(){this.renderer.initContext(),this.cache.clearGLTextures(),this.renderer.contextLost=!1},update:function(t){if(this.pendingDestroy)this.destroy();else{if(this.time.update(t),this._kickstart)return this.updateLogic(this.time.desiredFpsMult),this.updateRender(this.time.slowMotion*this.time.desiredFps),void(this._kickstart=!1);if(this._spiraling>1&&!this.forceSingleUpdate)this.time.time>this._nextFpsNotification&&(this._nextFpsNotification=this.time.time+1e4,this.fpsProblemNotifier.dispatch()),this._deltaTime=0,this._spiraling=0,this.dropFrames?this.rendersThisFrame=0:(this.updateRender(this.time.slowMotion*this.time.desiredFps),this.rendersThisFrame=1);else{var i=1e3*this.time.slowMotion/this.time.desiredFps;this._deltaTime+=Math.max(Math.min(3*i,this.time.elapsed),0);var s=0;for(this.updatesThisFrame=Math.floor(this._deltaTime/i),this.forceSingleUpdate&&(this.updatesThisFrame=Math.min(1,this.updatesThisFrame)),this.forceSingleRender?this.rendersThisFrame=1:this.rendersThisFrame=Math.min(1,this.updatesThisFrame);this._deltaTime>=i&&(this._deltaTime-=i,this.currentUpdateID=s,this.updateLogic(this.time.desiredFpsMult),s++,!this.forceSingleUpdate||1!==s);)this.time.refresh();s>this._lastCount?this._spiraling++:s<this._lastCount&&(this._spiraling=0),this._lastCount=s,this.rendersThisFrame>0&&this.updateRender(this._deltaTime/i)}this.renderer.type===e.WEBGL&&this.renderer.gl.flush()}},updateLogic:function(t){this._paused||this.pendingStep?(this.scale.pauseUpdate(),this.state.pauseUpdate(t),this.debug.preUpdate(),this.input.pauseUpdate()):(this.stepping&&(this.pendingStep=!0),this.time.countUpdate(),this.scale.preUpdate(),this.debug.preUpdate(),this.camera.preUpdate(),this.physics.preUpdate(),this.state.preUpdate(t),this.plugins.preUpdate(t),this.stage.preUpdate(),this.state.update(),this.stage.update(),this.tweens.update(),this.sound.update(),this.input.update(),this.physics.update(),this.plugins.update(),this.stage.postUpdate(),this.state.postUpdate(),this.plugins.postUpdate()),this.stage.updateTransform()},updateRender:function(t){this.lockRender||this.renderType===e.HEADLESS||(this.time.countRender(),this.state.preRender(t),this.renderer.render(this.stage),this.plugins.render(t),this.state.render(t),this.plugins.postRender(t))},enableStep:function(){this.stepping=!0,this.pendingStep=!1,this.stepCount=0},disableStep:function(){this.stepping=!1,this.pendingStep=!1},step:function(){this.pendingStep=!1,this.stepCount++},destroy:function(){this.raf.stop(),this.debug.destroy(),this.state.destroy(),this.sound.destroy(),this.scale.destroy(),this.stage.destroy(),this.input.destroy(),this.physics.destroy(),this.plugins.destroy(),this.tweens.destroy(),this.debug=null,this.state=null,this.sound=null,this.scale=null,this.stage=null,this.input=null,this.physics=null,this.plugins=null,this.tweens=null,this.cache=null,this.load=null,this.time=null,this.world=null,this.isBooted=!1,this.renderer.destroy(!1),e.Canvas.removeFromDOM(this.canvas),PIXI.game===this&&(PIXI.game=null),PIXI.defaultRenderer=null,e.GAMES[this.id]=null},gamePaused:function(t){this._paused||(this._paused=!0,this.time.gamePaused(),this.sound.muteOnPause&&this.sound.setMute(),this.onPause.dispatch(t),this.device.cordova&&this.device.iOS&&(this.lockRender=!0))},gameResumed:function(t){this._paused&&!this._codePaused&&(this._paused=!1,this.time.gameResumed(),this.input.reset(),this.sound.muteOnPause&&this.sound.unsetMute(),this.onResume.dispatch(t),this.device.cordova&&this.device.iOS&&(this.lockRender=!1))},focusLoss:function(t){this.onBlur.dispatch(t),this.stage.disableVisibilityChange||this.gamePaused(t)},focusGain:function(t){this.focusWindow(),this.onFocus.dispatch(t),this.stage.disableVisibilityChange||this.gameResumed(t)},focusWindow:function(){window.focus&&(!window.PhaserGlobal||window.PhaserGlobal&&!window.PhaserGlobal.stopFocus)&&window.focus()}},e.Game.prototype.constructor=e.Game,Object.defineProperty(e.Game.prototype,"paused",{get:function(){return this._paused},set:function(t){!0===t?(!1===this._paused&&(this._paused=!0,this.sound.muteOnPause&&this.sound.setMute(),this.time.gamePaused(),this.onPause.dispatch(this)),this._codePaused=!0):(this._paused&&(this._paused=!1,this.input.reset(),this.sound.unsetMute(),this.time.gameResumed(),this.onResume.dispatch(this)),this._codePaused=!1)}}),e.Input=function(t){this.game=t,this.hitCanvas=null,this.hitContext=null,this.moveCallbacks=[],this.customCandidateHandler=null,this.customCandidateHandlerContext=null,this.pollRate=0,this.enabled=!0,this.multiInputOverride=e.Input.MOUSE_TOUCH_COMBINE,this.position=null,this.speed=null,this.circle=null,this.scale=null,this.maxPointers=-1,this.tapRate=200,this.doubleTapRate=300,this.holdRate=2e3,this.justPressedRate=200,this.justReleasedRate=200,this.recordPointerHistory=!1,this.recordRate=100,this.recordLimit=100,this.touchLockCallbacks=[],this.pointer1=null,this.pointer2=null,this.pointer3=null,this.pointer4=null,this.pointer5=null,this.pointer6=null,this.pointer7=null,this.pointer8=null,this.pointer9=null,this.pointer10=null,this.pointers=[],this.activePointer=null,this.mousePointer=null,this.mouse=null,this.keyboard=null,this.touch=null,this.mspointer=null,this.gamepad=null,this.resetLocked=!1,this.onDown=null,this.onUp=null,this.onTap=null,this.onHold=null,this.minPriorityID=0,this.interactiveItems=new e.ArraySet,this._localPoint=new e.Point,this._pollCounter=0,this._oldPosition=null,this._x=0,this._y=0},e.Input.MOUSE_OVERRIDES_TOUCH=0,e.Input.TOUCH_OVERRIDES_MOUSE=1,e.Input.MOUSE_TOUCH_COMBINE=2,e.Input.MAX_POINTERS=10,e.Input.prototype={boot:function(t){"maxPointers"in t&&(this.maxPointers=t.maxPointers),this.mousePointer=new e.Pointer(this.game,0,e.PointerMode.CURSOR),this.addPointer(),this.addPointer(),this.mouse=new e.Mouse(this.game),this.touch=new e.Touch(this.game),this.mspointer=new e.MSPointer(this.game),this.mouseWheel=new e.MouseWheel(this.game),this.pointerLock=new e.PointerLock(this.game),e.Keyboard&&(this.keyboard=new e.Keyboard(this.game)),e.Gamepad&&(this.gamepad=new e.Gamepad(this.game)),this.onDown=new e.Signal,this.onUp=new e.Signal,this.onTap=new e.Signal,this.onHold=new e.Signal,this.scale=new e.Point(1,1),this.speed=new e.Point,this.position=new e.Point,this._oldPosition=new e.Point,this.circle=new e.Circle(0,0,45),this.activePointer=this.mousePointer,this.hitCanvas=e.CanvasPool.create(this,1,1),this.hitContext=this.hitCanvas.getContext("2d"),this.game.device.mspointer&&!1!==t.mspointer?this.mspointer.start():this.game.device.touch&&!1!==t.touch&&this.touch.start(),this.mspointer.active||!1===t.mouse||this.mouse.start(),this.mousePointer.active=!0,!1!==t.mouseWheel&&this.mouseWheel.start(),!1!==t.pointerLock&&this.pointerLock.start(),this.keyboard&&!1!==t.keyboard&&this.keyboard.start();var i=this;this._onClickTrampoline=function(t){i.onClickTrampoline(t)},this.game.canvas.addEventListener("click",this._onClickTrampoline,!1)},destroy:function(){this.mouse.stop(),this.mouseWheel.stop(),this.touch.stop(),this.mspointer.stop(),this.pointerLock.stop(),this.keyboard&&this.keyboard.stop(),this.gamepad&&this.gamepad.stop(),this.moveCallbacks=[],e.CanvasPool.remove(this),this.game.canvas.removeEventListener("click",this._onClickTrampoline)},setInteractiveCandidateHandler:function(t,e){this.customCandidateHandler=t,this.customCandidateHandlerContext=e},addMoveCallback:function(t,e){this.moveCallbacks.push({callback:t,context:e})},addTouchLockCallback:function(t,e,i){void 0===i&&(i=!1),this.touchLockCallbacks.push({callback:t,context:e,onEnd:i})},removeTouchLockCallback:function(t,e){for(var i=this.touchLockCallbacks.length;i--;)if(this.touchLockCallbacks[i].callback===t&&this.touchLockCallbacks[i].context===e)return this.touchLockCallbacks.splice(i,1),!0;return!1},executeTouchLockCallbacks:function(t,e){for(var i=this.touchLockCallbacks.length;i--;){var s=this.touchLockCallbacks[i];s.onEnd===t&&s.callback.call(s.context,this,e)&&this.touchLockCallbacks.splice(i,1)}},deleteMoveCallback:function(t,e){for(var i=this.moveCallbacks.length;i--;)if(this.moveCallbacks[i].callback===t&&this.moveCallbacks[i].context===e)return void this.moveCallbacks.splice(i,1)},addPointer:function(){if(this.pointers.length>=e.Input.MAX_POINTERS)return console.warn("Phaser.Input.addPointer: Maximum limit of "+e.Input.MAX_POINTERS+" pointers reached."),null;var t=this.pointers.length+1,i=new e.Pointer(this.game,t,e.PointerMode.CONTACT);return this.pointers.push(i),this["pointer"+t]=i,i},update:function(){if(this.keyboard&&this.keyboard.update(),this.pollRate>0&&this._pollCounter<this.pollRate)this._pollCounter++;else{this.speed.x=this.position.x-this._oldPosition.x,this.speed.y=this.position.y-this._oldPosition.y,this._oldPosition.copyFrom(this.position),this.mousePointer.update(),this.gamepad&&this.gamepad.active&&this.gamepad.update();for(var t=0;t<this.pointers.length;t++)this.pointers[t].update();this._pollCounter=0}},pauseUpdate:function(){this.gamepad&&this.gamepad.active&&this.gamepad.update()},reset:function(t){if(this.game.isBooted&&!this.resetLocked){void 0===t&&(t=!1),this.mousePointer.reset(),this.keyboard&&this.keyboard.reset(t);for(var i=0;i<this.pointers.length;i++)this.pointers[i].reset();"none"!==this.game.canvas.style.cursor&&(this.game.canvas.style.cursor=""),t&&(this.onDown.dispose(),this.onUp.dispose(),this.onTap.dispose(),this.onHold.dispose(),this.onDown=new e.Signal,this.onUp=new e.Signal,this.onTap=new e.Signal,this.onHold=new e.Signal,this.moveCallbacks=[]),this._pollCounter=0}},resetSpeed:function(t,e){this._oldPosition.setTo(t,e),this.speed.setTo(0,0)},startPointer:function(t){if(this.maxPointers>=0&&this.countActivePointers(this.maxPointers)>=this.maxPointers)return null;if(!this.pointer1.active)return this.pointer1.start(t);if(!this.pointer2.active)return this.pointer2.start(t);for(var e=2;e<this.pointers.length;e++){var i=this.pointers[e];if(!i.active)return i.start(t)}return null},updatePointer:function(t){if(this.pointer1.active&&this.pointer1.identifier===t.identifier)return this.pointer1.move(t);if(this.pointer2.active&&this.pointer2.identifier===t.identifier)return this.pointer2.move(t);for(var e=2;e<this.pointers.length;e++){var i=this.pointers[e];if(i.active&&i.identifier===t.identifier)return i.move(t)}return null},stopPointer:function(t){if(this.pointer1.active&&this.pointer1.identifier===t.identifier)return this.pointer1.stop(t);if(this.pointer2.active&&this.pointer2.identifier===t.identifier)return this.pointer2.stop(t);for(var e=2;e<this.pointers.length;e++){var i=this.pointers[e];if(i.active&&i.identifier===t.identifier)return i.stop(t)}return null},countActivePointers:function(t){void 0===t&&(t=this.pointers.length);for(var e=t,i=0;i<this.pointers.length&&e>0;i++)this.pointers[i].active&&e--;return t-e},getPointer:function(t){void 0===t&&(t=!1);for(var e=0;e<this.pointers.length;e++){var i=this.pointers[e];if(i.active===t)return i}return null},getPointerFromIdentifier:function(t){for(var e=0;e<this.pointers.length;e++){var i=this.pointers[e];if(i.identifier===t)return i}return null},getPointerFromId:function(t){for(var e=0;e<this.pointers.length;e++){var i=this.pointers[e];if(i.pointerId===t)return i}return null},getLocalPosition:function(t,i,s){void 0===s&&(s=new e.Point);var n=t.worldTransform,r=1/(n.a*n.d+n.c*-n.b);return s.setTo(n.d*r*i.x+-n.c*r*i.y+(n.ty*n.c-n.tx*n.d)*r,n.a*r*i.y+-n.b*r*i.x+(-n.ty*n.a+n.tx*n.b)*r)},hitTest:function(t,i,s){if(!t.worldVisible)return!1;if(this.getLocalPosition(t,i,this._localPoint),s.copyFrom(this._localPoint),t.hitArea&&t.hitArea.contains)return t.hitArea.contains(this._localPoint.x,this._localPoint.y);if(e.Creature&&t instanceof e.Creature){var n=Math.abs(t.width),r=Math.abs(t.height),o=t.x-n*t.anchorX;if(this.game.camera.x+i.x>=o&&this.game.camera.x+i.x<o+n){a=t.y-r*t.anchorY;if(this.game.camera.y+i.y>=a&&this.game.camera.y+i.y<a+r)return!0}}else if(t instanceof e.TileSprite){var n=t.width,r=t.height,o=-n*t.anchor.x;if(this._localPoint.x>=o&&this._localPoint.x<o+n){a=-r*t.anchor.y;if(this._localPoint.y>=a&&this._localPoint.y<a+r)return!0}}else if(t instanceof PIXI.Sprite){var n=t.texture.frame.width/t.texture.baseTexture.resolution,r=t.texture.frame.height/t.texture.baseTexture.resolution,o=-n*t.anchor.x;if(this._localPoint.x>=o&&this._localPoint.x<o+n){var a=-r*t.anchor.y;if(this._localPoint.y>=a&&this._localPoint.y<a+r)return!0}}else if(t instanceof e.Graphics)for(l=0;l<t.graphicsData.length;l++){var h=t.graphicsData[l];if(h.fill&&(h.shape&&h.shape.contains(this._localPoint.x,this._localPoint.y)))return!0}for(var l=0;l<t.children.length;l++)if(this.hitTest(t.children[l],i,s))return!0;return!1},onClickTrampoline:function(){this.activePointer.processClickTrampolines()},callAll:function(t,e){for(var i=this.interactiveItems.list,s=i.length;s--;){var n=i[s];n&&n.enabled&&n[t](e)}}},e.Input.prototype.constructor=e.Input,Object.defineProperty(e.Input.prototype,"x",{get:function(){return this._x},set:function(t){this._x=Math.floor(t)}}),Object.defineProperty(e.Input.prototype,"y",{get:function(){return this._y},set:function(t){this._y=Math.floor(t)}}),Object.defineProperty(e.Input.prototype,"pollLocked",{get:function(){return this.pollRate>0&&this._pollCounter<this.pollRate}}),Object.defineProperty(e.Input.prototype,"totalInactivePointers",{get:function(){return this.pointers.length-this.countActivePointers()}}),Object.defineProperty(e.Input.prototype,"totalActivePointers",{get:function(){return this.countActivePointers()}}),Object.defineProperty(e.Input.prototype,"worldX",{get:function(){return this.game.camera.view.x+this.x}}),Object.defineProperty(e.Input.prototype,"worldY",{get:function(){return this.game.camera.view.y+this.y}}),e.Mouse=function(t){this.game=t,this.input=t.input,this.callbackContext=this.game,this.mouseDownCallback=null,this.mouseUpCallback=null,this.mouseOutCallback=null,this.mouseOverCallback=null,this.capture=!1,this.active=!1,this.enabled=!0,this.stopOnGameOut=!1,this.event=null,this._onMouseDown=null,this._onMouseMove=null,this._onMouseUp=null,this._onMouseOut=null,this._onMouseOver=null},e.Mouse.NO_BUTTON=-1,e.Mouse.LEFT_BUTTON=0,e.Mouse.MIDDLE_BUTTON=1,e.Mouse.RIGHT_BUTTON=2,e.Mouse.BACK_BUTTON=3,e.Mouse.FORWARD_BUTTON=4,e.Mouse.prototype={start:function(){var t=this.game.device;if(t.isAndroidStockBrowser()&&this.input.touch.active)return!1;if(null!==this._onMouseDown)return!1;var e=this;this._onMouseDown=function(t){return e.onMouseDown(t)},this._onMouseMove=function(t){return e.onMouseMove(t)},this._onMouseUp=function(t){return e.onMouseUp(t)},this._onMouseUpGlobal=function(t){return e.onMouseUpGlobal(t)},this._onMouseOutGlobal=function(t){return e.onMouseOutGlobal(t)},this._onMouseOut=function(t){return e.onMouseOut(t)},this._onMouseOver=function(t){return e.onMouseOver(t)};var i=this.game.canvas;return i.addEventListener("mousedown",this._onMouseDown,!0),i.addEventListener("mousemove",this._onMouseMove,!0),i.addEventListener("mouseup",this._onMouseUp,!0),t.cocoonJS||(window.addEventListener("mouseup",this._onMouseUpGlobal,!0),window.addEventListener("mouseout",this._onMouseOutGlobal,!0),i.addEventListener("mouseover",this._onMouseOver,!0),i.addEventListener("mouseout",this._onMouseOut,!0)),this.active=!0,!0},onMouseDown:function(t){this.event=t,this.capture&&t.preventDefault(),this.mouseDownCallback&&this.mouseDownCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=0,this.input.mousePointer.start(t))},onMouseMove:function(t){this.event=t,this.capture&&t.preventDefault(),this.mouseMoveCallback&&this.mouseMoveCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=0,this.input.mousePointer.move(t))},onMouseUp:function(t){this.event=t,this.capture&&t.preventDefault(),this.mouseUpCallback&&this.mouseUpCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=0,this.input.mousePointer.stop(t))},onMouseUpGlobal:function(t){this.input.mousePointer.withinGame||(this.mouseUpCallback&&this.mouseUpCallback.call(this.callbackContext,t),t.identifier=0,this.input.mousePointer.stop(t))},onMouseOutGlobal:function(t){this.event=t,this.capture&&t.preventDefault(),this.input.mousePointer.withinGame=!1,this.input.enabled&&this.enabled&&(this.input.mousePointer.stop(t),this.input.mousePointer.resetButtons())},onMouseOut:function(t){this.event=t,this.capture&&t.preventDefault(),this.input.mousePointer.withinGame=!1,this.mouseOutCallback&&this.mouseOutCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(this.input.mousePointer.updateButtons(t),this.stopOnGameOut&&(t.identifier=0,this.input.mousePointer.stop(t),this.input.callAll("_pointerOutHandler",this.input.mousePointer)))},onMouseOver:function(t){this.event=t,this.capture&&t.preventDefault(),this.input.mousePointer.withinGame=!0,this.mouseOverCallback&&this.mouseOverCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&this.input.mousePointer.updateButtons(t)},stop:function(){var t=this.game.canvas;t.removeEventListener("mousedown",this._onMouseDown,!0),t.removeEventListener("mousemove",this._onMouseMove,!0),t.removeEventListener("mouseup",this._onMouseUp,!0),t.removeEventListener("mouseover",this._onMouseOver,!0),t.removeEventListener("mouseout",this._onMouseOut,!0),window.removeEventListener("mouseup",this._onMouseUpGlobal,!0),window.removeEventListener("mouseout",this._onMouseOutGlobal,!0),this.active=!1}},e.Mouse.prototype.constructor=e.Mouse,e.MouseWheel=function(t){this.game=t,this.input=t.input,this.element=t.canvas,this.preventDefault=!0,this.active=!1,this.callback=null,this.callbackContext=t,this.delta=0,this.wheelEventName=t.device.wheelEvent,this.boundOnWheelHandler=this.onWheelHandler.bind(this),this.eventProxy=null},e.MouseWheel.UP=1,e.MouseWheel.DOWN=-1,e.MouseWheel.prototype.start=function(){return!(!this.wheelEventName||this.active)&&(this.element.addEventListener(this.wheelEventName,this.boundOnWheelHandler,!0),"mousewheel"===this.wheelEventName?this.eventProxy=new e.WheelEventProxy(-.025,1):"DOMMouseScroll"===this.wheelEventName&&(this.eventProxy=new e.WheelEventProxy(1,1)),this.active=!0,!0)},e.MouseWheel.prototype.stop=function(){this.active&&(this.element.removeEventListener(this.wheelEventName,this.boundOnWheelHandler,!0),this.active=!1)},e.MouseWheel.prototype.onWheelHandler=function(t){this.eventProxy&&(t=this.eventProxy.bindEvent(t)),this.preventDefault&&t.preventDefault(),this.delta=e.Math.clamp(-t.deltaY,-1,1),this.callback&&this.callback.call(this.callbackContext,t)},e.MSPointer=function(t){this.game=t,this.input=t.input,this.callbackContext=this.game,this.pointerDownCallback=null,this.pointerMoveCallback=null,this.pointerUpCallback=null,this.pointerOutCallback=null,this.pointerOverCallback=null,this.capture=!1,this.event=null,this.active=!1,this.enabled=!0,this.stopOnGameOut=!1,this._onMSPointerDown=null,this._onMSPointerMove=null,this._onMSPointerUp=null,this._onMSPointerUpGlobal=null,this._onMSPointerOut=null,this._onMSPointerOver=null},e.MSPointer.prototype={start:function(){if(!this.game.device.mspointer)return!1;if(null!==this._onMSPointerDown)return!1;var t=this;this._onMSPointerDown=function(e){return t.onPointerDown(e)},this._onMSPointerMove=function(e){return t.onPointerMove(e)},this._onMSPointerUp=function(e){return t.onPointerUp(e)},this._onMSPointerUpGlobal=function(e){return t.onPointerUpGlobal(e)},this._onMSPointerOut=function(e){return t.onPointerOut(e)},this._onMSPointerOver=function(e){return t.onPointerOver(e)};var e=this.game.canvas;return e.addEventListener("MSPointerDown",this._onMSPointerDown,!1),e.addEventListener("MSPointerMove",this._onMSPointerMove,!1),e.addEventListener("MSPointerUp",this._onMSPointerUp,!1),e.addEventListener("pointerdown",this._onMSPointerDown,!1),e.addEventListener("pointermove",this._onMSPointerMove,!1),e.addEventListener("pointerup",this._onMSPointerUp,!1),e.style["-ms-content-zooming"]="none",e.style["-ms-touch-action"]="none",this.game.device.cocoonJS||(window.addEventListener("MSPointerUp",this._onMSPointerUpGlobal,!0),e.addEventListener("MSPointerOver",this._onMSPointerOver,!0),e.addEventListener("MSPointerOut",this._onMSPointerOut,!0),window.addEventListener("pointerup",this._onMSPointerUpGlobal,!0),e.addEventListener("pointerover",this._onMSPointerOver,!0),e.addEventListener("pointerout",this._onMSPointerOut,!0)),this.active=!0,!0},onPointerDown:function(t){this.game.input.executeTouchLockCallbacks(!1,t),this.event=t,this.capture&&t.preventDefault(),this.pointerDownCallback&&this.pointerDownCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=t.pointerId,"mouse"===t.pointerType||4===t.pointerType?this.input.mousePointer.start(t):this.input.startPointer(t))},onPointerMove:function(t){this.event=t,this.capture&&t.preventDefault(),this.pointerMoveCallback&&this.pointerMoveCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=t.pointerId,"mouse"===t.pointerType||4===t.pointerType?this.input.mousePointer.move(t):this.input.updatePointer(t))},onPointerUp:function(t){this.game.input.executeTouchLockCallbacks(!0,t),this.event=t,this.capture&&t.preventDefault(),this.pointerUpCallback&&this.pointerUpCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&(t.identifier=t.pointerId,"mouse"===t.pointerType||4===t.pointerType?this.input.mousePointer.stop(t):this.input.stopPointer(t))},onPointerUpGlobal:function(t){if(t.identifier=t.pointerId,"mouse"!==t.pointerType&&4!==t.pointerType||this.input.mousePointer.withinGame){var e=this.input.getPointerFromIdentifier(t.identifier);e&&e.withinGame&&this.onPointerUp(t)}else this.onPointerUp(t)},onPointerOut:function(t){if(this.event=t,this.capture&&t.preventDefault(),t.identifier=t.pointerId,"mouse"===t.pointerType||4===t.pointerType)this.input.mousePointer.withinGame=!1;else{var e=this.input.getPointerFromIdentifier(t.identifier);e&&(e.withinGame=!1)}this.pointerOutCallback&&this.pointerOutCallback.call(this.callbackContext,t),this.input.enabled&&this.enabled&&this.stopOnGameOut&&(t.identifier=0,e||(e=this.input.mousePointer),e.stop(t),this.input.callAll("_pointerOutHandler",e))},onPointerOver:function(t){if(this.event=t,this.capture&&t.preventDefault(),t.identifier=t.pointerId,"mouse"===t.pointerType||4===t.pointerType)this.input.mousePointer.withinGame=!0;else{var e=this.input.getPointerFromIdentifier(t.identifier);e&&(e.withinGame=!0)}this.pointerOverCallback&&this.pointerOverCallback.call(this.callbackContext,t)},stop:function(){var t=this.game.canvas;t.removeEventListener("MSPointerDown",this._onMSPointerDown,!1),t.removeEventListener("MSPointerMove",this._onMSPointerMove,!1),t.removeEventListener("MSPointerUp",this._onMSPointerUp,!1),t.removeEventListener("pointerdown",this._onMSPointerDown,!1),t.removeEventListener("pointermove",this._onMSPointerMove,!1),t.removeEventListener("pointerup",this._onMSPointerUp,!1),window.removeEventListener("MSPointerUp",this._onMSPointerUpGlobal,!0),t.removeEventListener("MSPointerOver",this._onMSPointerOver,!0),t.removeEventListener("MSPointerOut",this._onMSPointerOut,!0),window.removeEventListener("pointerup",this._onMSPointerUpGlobal,!0),t.removeEventListener("pointerover",this._onMSPointerOver,!0),t.removeEventListener("pointerout",this._onMSPointerOut,!0),this.active=!1}},e.MSPointer.prototype.constructor=e.MSPointer,e.DeviceButton=function(t,i){this.parent=t,this.game=t.game,this.event=null,this.isDown=!1,this.isUp=!0,this.timeDown=0,this.timeUp=0,this.repeats=0,this.altKey=!1,this.shiftKey=!1,this.ctrlKey=!1,this.value=0,this.buttonCode=i,this.onDown=new e.Signal,this.onUp=new e.Signal,this.onFloat=new e.Signal},e.DeviceButton.prototype={start:function(t,e){this.isDown||(this.isDown=!0,this.isUp=!1,this.timeDown=this.game.time.time,this.repeats=0,this.event=t,this.value=e,t&&(this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.ctrlKey=t.ctrlKey),this.onDown.dispatch(this,e))},stop:function(t,e){this.isUp||(this.isDown=!1,this.isUp=!0,this.timeUp=this.game.time.time,this.event=t,this.value=e,t&&(this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.ctrlKey=t.ctrlKey),this.onUp.dispatch(this,e))},startStop:function(t,e,i){t?this.start(e,i):this.stop(e,i)},padFloat:function(t){this.isDown=!1,this.isUp=!1,this.value=t,this.onFloat.dispatch(this,t)},justPressed:function(t){return t=t||250,this.isDown&&this.timeDown+t>this.game.time.time},justReleased:function(t){return t=t||250,this.isUp&&this.timeUp+t>this.game.time.time},reset:function(){this.isDown=!1,this.isUp=!0,this.timeDown=this.game.time.time,this.repeats=0,this.altKey=!1,this.shiftKey=!1,this.ctrlKey=!1},destroy:function(){this.onDown.dispose(),this.onUp.dispose(),this.onFloat.dispose(),this.parent=null,this.game=null}},e.DeviceButton.prototype.constructor=e.DeviceButton,Object.defineProperty(e.DeviceButton.prototype,"duration",{get:function(){return this.isUp?-1:this.game.time.time-this.timeDown}}),e.Pointer=function(t,i,s){this.game=t,this.id=i,this.type=e.POINTER,this.exists=!0,this.identifier=0,this.pointerId=null,this.pointerMode=s||e.PointerMode.CURSOR|e.PointerMode.CONTACT,this.target=null,this.button=null,this.leftButton=new e.DeviceButton(this,e.Pointer.LEFT_BUTTON),this.middleButton=new e.DeviceButton(this,e.Pointer.MIDDLE_BUTTON),this.rightButton=new e.DeviceButton(this,e.Pointer.RIGHT_BUTTON),this.backButton=new e.DeviceButton(this,e.Pointer.BACK_BUTTON),this.forwardButton=new e.DeviceButton(this,e.Pointer.FORWARD_BUTTON),this.eraserButton=new e.DeviceButton(this,e.Pointer.ERASER_BUTTON),this._holdSent=!1,this._history=[],this._nextDrop=0,this._stateReset=!1,this.withinGame=!1,this.clientX=-1,this.clientY=-1,this.pageX=-1,this.pageY=-1,this.screenX=-1,this.screenY=-1,this.rawMovementX=0,this.rawMovementY=0,this.movementX=0,this.movementY=0,this.x=-1,this.y=-1,this.isMouse=0===i,this.isDown=!1,this.isUp=!0,this.timeDown=0,this.timeUp=0,this.previousTapTime=0,this.totalTouches=0,this.msSinceLastClick=Number.MAX_VALUE,this.targetObject=null,this.interactiveCandidates=[],this.active=!1,this.dirty=!1,this.position=new e.Point,this.positionDown=new e.Point,this.positionUp=new e.Point,this.circle=new e.Circle(0,0,44),this._clickTrampolines=null,this._trampolineTargetObject=null},e.Pointer.NO_BUTTON=0,e.Pointer.LEFT_BUTTON=1,e.Pointer.RIGHT_BUTTON=2,e.Pointer.MIDDLE_BUTTON=4,e.Pointer.BACK_BUTTON=8,e.Pointer.FORWARD_BUTTON=16,e.Pointer.ERASER_BUTTON=32,e.Pointer.prototype={resetButtons:function(){this.isDown=!1,this.isUp=!0,this.isMouse&&(this.leftButton.reset(),this.middleButton.reset(),this.rightButton.reset(),this.backButton.reset(),this.forwardButton.reset(),this.eraserButton.reset())},processButtonsDown:function(t,i){switch(t){case e.Mouse.LEFT_BUTTON:this.leftButton.start(i);break;case e.Mouse.RIGHT_BUTTON:this.rightButton.start(i);break;case e.Mouse.MIDDLE_BUTTON:this.middleButton.start(i);break;case e.Mouse.BACK_BUTTON:this.backButton.start(i);break;case e.Mouse.FORWARD_BUTTON:this.forwardButton.start(i)}},processButtonsUp:function(t,i){switch(t){case e.Mouse.LEFT_BUTTON:this.leftButton.stop(i);break;case e.Mouse.RIGHT_BUTTON:this.rightButton.stop(i);break;case e.Mouse.MIDDLE_BUTTON:this.middleButton.stop(i);break;case e.Mouse.BACK_BUTTON:this.backButton.stop(i);break;case e.Mouse.FORWARD_BUTTON:this.forwardButton.stop(i)}},processButtonsUpDown:function(t,i){var s=i.type.toLowerCase().substr(-4),n="down"===s,r="move"===s;void 0!==t?(n&&1===t&&i.ctrlKey&&(t=2),this.leftButton.startStop(e.Pointer.LEFT_BUTTON&t,i),this.rightButton.startStop(e.Pointer.RIGHT_BUTTON&t,i),this.middleButton.startStop(e.Pointer.MIDDLE_BUTTON&t,i),this.backButton.startStop(e.Pointer.BACK_BUTTON&t,i),this.forwardButton.startStop(e.Pointer.FORWARD_BUTTON&t,i),this.eraserButton.startStop(e.Pointer.ERASER_BUTTON&t,i)):void 0!==i.button?n&&i.ctrlKey&&0===i.button?this.rightButton.start(i):n?this.processButtonsDown(i.button,i):r||this.processButtonsUp(i.button,i):n?i.ctrlKey?this.rightButton.start(i):this.leftButton.start(i):(this.leftButton.stop(i),this.rightButton.stop(i))},updateButtons:function(t){this.button=t.button,this.processButtonsUpDown(t.buttons,t),this.isUp=!0,this.isDown=!1,(this.leftButton.isDown||this.rightButton.isDown||this.middleButton.isDown||this.backButton.isDown||this.forwardButton.isDown||this.eraserButton.isDown)&&(this.isUp=!1,this.isDown=!0)},start:function(t){var i=this.game.input;return t.pointerId&&(this.pointerId=t.pointerId),this.identifier=t.identifier,this.target=t.target,this.isMouse?this.updateButtons(t):(this.isDown=!0,this.isUp=!1),this.active=!0,this.withinGame=!0,this.dirty=!1,this._history=[],this._clickTrampolines=null,this._trampolineTargetObject=null,this.msSinceLastClick=this.game.time.time-this.timeDown,this.timeDown=this.game.time.time,this._holdSent=!1,this.move(t,!0),this.positionDown.setTo(this.x,this.y),(i.multiInputOverride===e.Input.MOUSE_OVERRIDES_TOUCH||i.multiInputOverride===e.Input.MOUSE_TOUCH_COMBINE||i.multiInputOverride===e.Input.TOUCH_OVERRIDES_MOUSE&&0===i.totalActivePointers)&&(i.x=this.x,i.y=this.y,i.position.setTo(this.x,this.y),i.onDown.dispatch(this,t),i.resetSpeed(this.x,this.y)),this._stateReset=!1,this.totalTouches++,null!==this.targetObject&&this.targetObject._touchedHandler(this),this},update:function(){var t=this.game.input;this.active&&(this.dirty&&(t.interactiveItems.total>0&&this.processInteractiveObjects(!1),this.dirty=!1),!1===this._holdSent&&this.duration>=t.holdRate&&((t.multiInputOverride===e.Input.MOUSE_OVERRIDES_TOUCH||t.multiInputOverride===e.Input.MOUSE_TOUCH_COMBINE||t.multiInputOverride===e.Input.TOUCH_OVERRIDES_MOUSE&&0===t.totalActivePointers)&&t.onHold.dispatch(this),this._holdSent=!0),t.recordPointerHistory&&this.game.time.time>=this._nextDrop&&(this._nextDrop=this.game.time.time+t.recordRate,this._history.push({x:this.position.x,y:this.position.y}),this._history.length>t.recordLimit&&this._history.shift()))},move:function(t,i){var s=this.game.input;if(!s.pollLocked){void 0===i&&(i=!1),void 0!==t.button&&(this.button=t.button),this.isMouse&&this.updateButtons(t),this.clientX=t.clientX,this.clientY=t.clientY,this.pageX=t.pageX,this.pageY=t.pageY,this.screenX=t.screenX,this.screenY=t.screenY,this.isMouse&&s.pointerLock.locked&&!i&&(this.rawMovementX=t.movementX||t.mozMovementX||t.webkitMovementX||0,this.rawMovementY=t.movementY||t.mozMovementY||t.webkitMovementY||0,this.movementX+=this.rawMovementX,this.movementY+=this.rawMovementY),this.x=(this.pageX-this.game.scale.offset.x)*s.scale.x,this.y=(this.pageY-this.game.scale.offset.y)*s.scale.y,this.position.setTo(this.x,this.y),this.circle.x=this.x,this.circle.y=this.y,(s.multiInputOverride===e.Input.MOUSE_OVERRIDES_TOUCH||s.multiInputOverride===e.Input.MOUSE_TOUCH_COMBINE||s.multiInputOverride===e.Input.TOUCH_OVERRIDES_MOUSE&&0===s.totalActivePointers)&&(s.activePointer=this,s.x=this.x,s.y=this.y,s.position.setTo(s.x,s.y),s.circle.x=s.x,s.circle.y=s.y),this.withinGame=this.game.scale.bounds.contains(this.pageX,this.pageY);for(var n=s.moveCallbacks.length;n--;)s.moveCallbacks[n].callback.call(s.moveCallbacks[n].context,this,this.x,this.y,i,t);return null===this.targetObject||this.game.paused&&!this.targetObject.noPause||!0!==this.targetObject.isDragged?s.interactiveItems.total>0&&this.processInteractiveObjects(i):!1===this.targetObject.update(this)&&(this.targetObject=null),this}},processInteractiveObjects:function(t){var e=0,i=-1,s=null,n=this.game.input.interactiveItems.first;for(this.interactiveCandidates=[];n;)n.checked=!1,!n.validForInput(i,e,!1)||this.game.paused&&!n.sprite.noPause||(n.checked=!0,(t&&n.checkPointerDown(this,!0)||!t&&n.checkPointerOver(this,!0))&&(e=n.sprite.renderOrderID,i=n.priorityID,s=n,this.interactiveCandidates.push(n))),n=this.game.input.interactiveItems.next;for(n=this.game.input.interactiveItems.first;n;)!n.checked&&n.validForInput(i,e,!0)&&(t&&n.checkPointerDown(this,!1)||!t&&n.checkPointerOver(this,!1))&&(e=n.sprite.renderOrderID,i=n.priorityID,s=n,this.interactiveCandidates.push(n)),n=this.game.input.interactiveItems.next;return this.game.input.customCandidateHandler&&(s=this.game.input.customCandidateHandler.call(this.game.input.customCandidateHandlerContext,this,this.interactiveCandidates,s)),this.swapTarget(s,!1),null!==this.targetObject},swapTarget:function(t,e){void 0===e&&(e=!1),null===t?this.targetObject&&(this.targetObject._pointerOutHandler(this,e),this.targetObject=null):null===this.targetObject?(this.targetObject=t,t._pointerOverHandler(this,e)):this.targetObject===t?!1===t.update(this)&&(this.targetObject=null):(this.targetObject._pointerOutHandler(this,e),this.targetObject=t,this.targetObject._pointerOverHandler(this,e))},leave:function(t){this.withinGame=!1,this.move(t,!1)},stop:function(t){var i=this.game.input;{if(!this._stateReset||!this.withinGame){if(this.timeUp=this.game.time.time,(i.multiInputOverride===e.Input.MOUSE_OVERRIDES_TOUCH||i.multiInputOverride===e.Input.MOUSE_TOUCH_COMBINE||i.multiInputOverride===e.Input.TOUCH_OVERRIDES_MOUSE&&0===i.totalActivePointers)&&(i.onUp.dispatch(this,t),this.duration>=0&&this.duration<=i.tapRate)){var s=this.timeUp-this.previousTapTime<i.doubleTapRate;i.onTap.dispatch(this,s,t),this.previousTapTime=this.timeUp}return this.isMouse?this.updateButtons(t):(this.isDown=!1,this.isUp=!0),this.id>0&&(this.active=!1),this.withinGame=this.game.scale.bounds.contains(t.pageX,t.pageY),this.pointerId=null,this.identifier=null,this.positionUp.setTo(this.x,this.y),!1===this.isMouse&&i.currentPointers--,i.callAll("_releasedHandler",this),this._clickTrampolines&&(this._trampolineTargetObject=this.targetObject),this.targetObject=null,this}t.preventDefault()}},justPressed:function(t){return t=t||this.game.input.justPressedRate,!0===this.isDown&&this.timeDown+t>this.game.time.time},justReleased:function(t){return t=t||this.game.input.justReleasedRate,this.isUp&&this.timeUp+t>this.game.time.time},addClickTrampoline:function(t,e,i,s){if(this.isDown){for(var n=this._clickTrampolines=this._clickTrampolines||[],r=0;r<n.length;r++)if(n[r].name===t){n.splice(r,1);break}n.push({name:t,targetObject:this.targetObject,callback:e,callbackContext:i,callbackArgs:s})}},processClickTrampolines:function(){var t=this._clickTrampolines;if(t){for(var e=0;e<t.length;e++){var i=t[e];i.targetObject===this._trampolineTargetObject&&i.callback.apply(i.callbackContext,i.callbackArgs)}this._clickTrampolines=null,this._trampolineTargetObject=null}},reset:function(){!1===this.isMouse&&(this.active=!1),this.pointerId=null,this.identifier=null,this.dirty=!1,this.totalTouches=0,this._holdSent=!1,this._history.length=0,this._stateReset=!0,this.resetButtons(),this.targetObject&&this.targetObject._releasedHandler(this),this.targetObject=null},resetMovement:function(){this.movementX=0,this.movementY=0}},e.Pointer.prototype.constructor=e.Pointer,Object.defineProperty(e.Pointer.prototype,"duration",{get:function(){return this.isUp?-1:this.game.time.time-this.timeDown}}),Object.defineProperty(e.Pointer.prototype,"worldX",{get:function(){return this.game.world.camera.x+this.x}}),Object.defineProperty(e.Pointer.prototype,"worldY",{get:function(){return this.game.world.camera.y+this.y}}),e.PointerMode={CURSOR:1,CONTACT:2},e.PointerModes={},e.PointerModes[e.PointerMode.CURSOR]="CURSOR",e.PointerModes[e.PointerMode.CONTACT]="CONTACT",e.Touch=function(t){this.game=t,this.active=!1,this.enabled=!0,this.callbackContext=this.game,this.touchStartCallback=null,this.touchMoveCallback=null,this.touchEndCallback=null,this.touchEnterCallback=null,this.touchLeaveCallback=null,this.touchCancelCallback=null,this.preventDefault=!0,this.event=null,this._onTouchStart=null,this._onTouchMove=null,this._onTouchEnd=null,this._onTouchEnter=null,this._onTouchLeave=null,this._onTouchCancel=null,this._onTouchMove=null},e.Touch.prototype={start:function(){if(!this.game.device.touch)return!1;if(null!==this._onTouchStart)return!1;var t=this;return this._onTouchStart=function(e){return t.onTouchStart(e)},this._onTouchMove=function(e){return t.onTouchMove(e)},this._onTouchEnd=function(e){return t.onTouchEnd(e)},this._onTouchEnter=function(e){return t.onTouchEnter(e)},this._onTouchLeave=function(e){return t.onTouchLeave(e)},this._onTouchCancel=function(e){return t.onTouchCancel(e)},this.game.canvas.addEventListener("touchstart",this._onTouchStart,!1),this.game.canvas.addEventListener("touchmove",this._onTouchMove,!1),this.game.canvas.addEventListener("touchend",this._onTouchEnd,!1),this.game.canvas.addEventListener("touchcancel",this._onTouchCancel,!1),this.game.device.cocoonJS||(this.game.canvas.addEventListener("touchenter",this._onTouchEnter,!1),this.game.canvas.addEventListener("touchleave",this._onTouchLeave,!1)),this.active=!0,!0},consumeDocumentTouches:function(){this._documentTouchMove=function(t){t.preventDefault()},document.addEventListener("touchmove",this._documentTouchMove,!1)},onTouchStart:function(t){if(this.game.input.executeTouchLockCallbacks(!1,t),this.event=t,this.game.input.enabled&&this.enabled){this.touchStartCallback&&this.touchStartCallback.call(this.callbackContext,t),this.preventDefault&&t.preventDefault();for(var e=0;e<t.changedTouches.length;e++)this.game.input.startPointer(t.changedTouches[e])}},onTouchCancel:function(t){if(this.event=t,this.touchCancelCallback&&this.touchCancelCallback.call(this.callbackContext,t),this.game.input.enabled&&this.enabled){this.preventDefault&&t.preventDefault();for(var e=0;e<t.changedTouches.length;e++)this.game.input.stopPointer(t.changedTouches[e])}},onTouchEnter:function(t){this.event=t,this.touchEnterCallback&&this.touchEnterCallback.call(this.callbackContext,t),this.game.input.enabled&&this.enabled&&this.preventDefault&&t.preventDefault()},onTouchLeave:function(t){this.event=t,this.touchLeaveCallback&&this.touchLeaveCallback.call(this.callbackContext,t),this.preventDefault&&t.preventDefault()},onTouchMove:function(t){this.event=t,this.touchMoveCallback&&this.touchMoveCallback.call(this.callbackContext,t),this.preventDefault&&t.preventDefault();for(var e=0;e<t.changedTouches.length;e++)this.game.input.updatePointer(t.changedTouches[e])},onTouchEnd:function(t){this.game.input.executeTouchLockCallbacks(!0,t),this.event=t,this.touchEndCallback&&this.touchEndCallback.call(this.callbackContext,t),this.preventDefault&&t.preventDefault();for(var e=0;e<t.changedTouches.length;e++)this.game.input.stopPointer(t.changedTouches[e])},stop:function(){this.game.device.touch&&(this.game.canvas.removeEventListener("touchstart",this._onTouchStart),this.game.canvas.removeEventListener("touchmove",this._onTouchMove),this.game.canvas.removeEventListener("touchend",this._onTouchEnd),this.game.canvas.removeEventListener("touchenter",this._onTouchEnter),this.game.canvas.removeEventListener("touchleave",this._onTouchLeave),this.game.canvas.removeEventListener("touchcancel",this._onTouchCancel),this.active=!1)}},e.Touch.prototype.constructor=e.Touch,e.InputHandler=function(t){this.sprite=t,this.game=t.game,this.enabled=!1,this.checked=!1,this.priorityID=0,this.useHandCursor=!1,this._setHandCursor=!1,this.isDragged=!1,this.allowHorizontalDrag=!0,this.allowVerticalDrag=!0,this.bringToTop=!1,this.snapOffset=null,this.snapOnDrag=!1,this.snapOnRelease=!1,this.snapX=0,this.snapY=0,this.snapOffsetX=0,this.snapOffsetY=0,this.pixelPerfectOver=!1,this.pixelPerfectClick=!1,this.pixelPerfectAlpha=255,this.draggable=!1,this.boundsRect=null,this.boundsSprite=null,this.scaleLayer=!1,this.dragOffset=new e.Point,this.dragFromCenter=!1,this.dragStopBlocksInputUp=!1,this.dragStartPoint=new e.Point,this.dragDistanceThreshold=0,this.dragTimeThreshold=0,this.downPoint=new e.Point,this.snapPoint=new e.Point,this._dragPoint=new e.Point,this._dragPhase=!1,this._pendingDrag=!1,this._dragTimePass=!1,this._dragDistancePass=!1,this._wasEnabled=!1,this._tempPoint=new e.Point,this._pointerData=[],this._pointerData.push({id:0,x:0,y:0,camX:0,camY:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1})},e.InputHandler.prototype={start:function(t,i){if(t=t||0,void 0===i&&(i=!1),!1===this.enabled){this.game.input.interactiveItems.add(this),this.useHandCursor=i,this.priorityID=t;for(var s=0;s<10;s++)this._pointerData[s]={id:s,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1};this.snapOffset=new e.Point,this.enabled=!0,this._wasEnabled=!0}return this.sprite.events.onAddedToGroup.add(this.addedToGroup,this),this.sprite.events.onRemovedFromGroup.add(this.removedFromGroup,this),this.sprite},addedToGroup:function(){this._dragPhase||this._wasEnabled&&!this.enabled&&this.start()},removedFromGroup:function(){this._dragPhase||(this.enabled?(this._wasEnabled=!0,this.stop()):this._wasEnabled=!1)},reset:function(){this.enabled=!1;for(var t=0;t<10;t++)this._pointerData[t]={id:t,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1}},stop:function(){!1!==this.enabled&&(this.enabled=!1,this.game.input.interactiveItems.remove(this))},destroy:function(){this.sprite&&(this._setHandCursor&&(this.game.canvas.style.cursor="",this._setHandCursor=!1),this.enabled=!1,this.game.input.interactiveItems.remove(this),this._pointerData.length=0,this.boundsRect=null,this.boundsSprite=null,this.sprite=null)},validForInput:function(t,e,i){return void 0===i&&(i=!0),!(!this.enabled||0===this.sprite.scale.x||0===this.sprite.scale.y||this.priorityID<this.game.input.minPriorityID||this.sprite.parent&&this.sprite.parent.ignoreChildInput)&&(!(!i&&(this.pixelPerfectClick||this.pixelPerfectOver))&&(this.priorityID>t||this.priorityID===t&&this.sprite.renderOrderID>e))},isPixelPerfect:function(){return this.pixelPerfectClick||this.pixelPerfectOver},pointerX:function(t){return t=t||0,this._pointerData[t].x},pointerY:function(t){return t=t||0,this._pointerData[t].y},pointerDown:function(t){return t=t||0,this._pointerData[t].isDown},pointerUp:function(t){return t=t||0,this._pointerData[t].isUp},pointerTimeDown:function(t){return t=t||0,this._pointerData[t].timeDown},pointerTimeUp:function(t){return t=t||0,this._pointerData[t].timeUp},pointerOver:function(t){if(!this.enabled)return!1;if(void 0===t){for(var e=0;e<10;e++)if(this._pointerData[e].isOver)return!0;return!1}return this._pointerData[t].isOver},pointerOut:function(t){if(!this.enabled)return!1;if(void 0!==t)return this._pointerData[t].isOut;for(var e=0;e<10;e++)if(this._pointerData[e].isOut)return!0},pointerTimeOver:function(t){return t=t||0,this._pointerData[t].timeOver},pointerTimeOut:function(t){return t=t||0,this._pointerData[t].timeOut},pointerDragged:function(t){return t=t||0,this._pointerData[t].isDragged},checkPointerDown:function(t,e){return!!(t.isDown&&this.enabled&&this.sprite&&this.sprite.parent&&this.sprite.visible&&this.sprite.parent.visible&&0!==this.sprite.worldScale.x&&0!==this.sprite.worldScale.y)&&(!!this.game.input.hitTest(this.sprite,t,this._tempPoint)&&(void 0===e&&(e=!1),!(!e&&this.pixelPerfectClick)||this.checkPixel(this._tempPoint.x,this._tempPoint.y)))},checkPointerOver:function(t,e){return!!(this.enabled&&this.sprite&&this.sprite.parent&&this.sprite.visible&&this.sprite.parent.visible&&0!==this.sprite.worldScale.x&&0!==this.sprite.worldScale.y)&&(!!this.game.input.hitTest(this.sprite,t,this._tempPoint)&&(void 0===e&&(e=!1),!(!e&&this.pixelPerfectOver)||this.checkPixel(this._tempPoint.x,this._tempPoint.y)))},checkPixel:function(t,e,i){if(this.sprite.texture.baseTexture.source){if(null===t&&null===e){this.game.input.getLocalPosition(this.sprite,i,this._tempPoint);var t=this._tempPoint.x,e=this._tempPoint.y}if(0!==this.sprite.anchor.x&&(t-=-this.sprite.texture.frame.width*this.sprite.anchor.x),0!==this.sprite.anchor.y&&(e-=-this.sprite.texture.frame.height*this.sprite.anchor.y),t+=this.sprite.texture.frame.x,e+=this.sprite.texture.frame.y,this.sprite.texture.trim&&(t-=this.sprite.texture.trim.x,e-=this.sprite.texture.trim.y,t<this.sprite.texture.crop.x||t>this.sprite.texture.crop.right||e<this.sprite.texture.crop.y||e>this.sprite.texture.crop.bottom))return this._dx=t,this._dy=e,!1;if(this._dx=t,this._dy=e,this.game.input.hitContext.clearRect(0,0,1,1),this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source,t,e,1,1,0,0,1,1),this.game.input.hitContext.getImageData(0,0,1,1).data[3]>=this.pixelPerfectAlpha)return!0}return!1},update:function(t){if(null!==this.sprite&&void 0!==this.sprite.parent)return this.enabled&&this.sprite.visible&&this.sprite.parent.visible?this._pendingDrag?(this._dragDistancePass||(this._dragDistancePass=e.Math.distance(t.x,t.y,this.downPoint.x,this.downPoint.y)>=this.dragDistanceThreshold),this._dragDistancePass&&this._dragTimePass&&this.startDrag(t),!0):this.draggable&&this._draggedPointerID===t.id?this.updateDrag(t,!1):this._pointerData[t.id].isOver?this.checkPointerOver(t)?(this._pointerData[t.id].x=t.x-this.sprite.x,this._pointerData[t.id].y=t.y-this.sprite.y,!0):(this._pointerOutHandler(t),!1):void 0:(this._pointerOutHandler(t),!1)},_pointerOverHandler:function(t,e){if(null!==this.sprite){var i=this._pointerData[t.id];if(!1===i.isOver||t.dirty){var s=!1===i.isOver;i.isOver=!0,i.isOut=!1,i.timeOver=this.game.time.time,i.x=t.x-this.sprite.x,i.y=t.y-this.sprite.y,this.useHandCursor&&!1===i.isDragged&&(this.game.canvas.style.cursor="pointer",this._setHandCursor=!0),!e&&s&&this.sprite&&this.sprite.events&&this.sprite.events.onInputOver$dispatch(this.sprite,t),this.sprite.parent&&this.sprite.parent.onChildInputOver&&this.sprite.parent.onChildInputOver.dispatch(this.sprite,t)}}},_pointerOutHandler:function(t,e){if(null!==this.sprite){var i=this._pointerData[t.id];i.isOver=!1,i.isOut=!0,i.timeOut=this.game.time.time,this.useHandCursor&&!1===i.isDragged&&(this.game.canvas.style.cursor="",this._setHandCursor=!1),!e&&this.sprite&&this.sprite.events&&(this.sprite.events.onInputOut$dispatch(this.sprite,t),this.sprite&&this.sprite.parent&&this.sprite.parent.onChildInputOut&&this.sprite.parent.onChildInputOut.dispatch(this.sprite,t))}},_touchedHandler:function(t){if(null!==this.sprite){var e=this._pointerData[t.id];if(!e.isDown&&e.isOver){if(this.pixelPerfectClick&&!this.checkPixel(null,null,t))return;if(e.isDown=!0,e.isUp=!1,e.timeDown=this.game.time.time,this.downPoint.set(t.x,t.y),t.dirty=!0,this.sprite&&this.sprite.events&&(this.sprite.events.onInputDown$dispatch(this.sprite,t),this.sprite&&this.sprite.parent&&this.sprite.parent.onChildInputDown&&this.sprite.parent.onChildInputDown.dispatch(this.sprite,t),null===this.sprite))return;this.draggable&&!1===this.isDragged&&(0===this.dragTimeThreshold&&0===this.dragDistanceThreshold?this.startDrag(t):(this._pendingDrag=!0,this._dragDistancePass=0===this.dragDistanceThreshold,this.dragTimeThreshold>0?(this._dragTimePass=!1,this.game.time.events.add(this.dragTimeThreshold,this.dragTimeElapsed,this,t)):this._dragTimePass=!0)),this.bringToTop&&this.sprite.bringToTop()}}},dragTimeElapsed:function(t){this._dragTimePass=!0,this._pendingDrag&&this.sprite&&this._dragDistancePass&&this.startDrag(t)},_releasedHandler:function(t){if(null!==this.sprite){var e=this._pointerData[t.id];if(e.isDown&&t.isUp){e.isDown=!1,e.isUp=!0,e.timeUp=this.game.time.time,e.downDuration=e.timeUp-e.timeDown;var i=this.checkPointerOver(t);this.sprite&&this.sprite.events&&(this.dragStopBlocksInputUp&&(!this.dragStopBlocksInputUp||this.draggable&&this.isDragged&&this._draggedPointerID===t.id)||this.sprite.events.onInputUp$dispatch(this.sprite,t,i),this.sprite&&this.sprite.parent&&this.sprite.parent.onChildInputUp&&this.sprite.parent.onChildInputUp.dispatch(this.sprite,t,i),i&&(i=this.checkPointerOver(t))),e.isOver=i,!i&&this.useHandCursor&&(this.game.canvas.style.cursor="default",this._setHandCursor=!1),t.dirty=!0,this._pendingDrag=!1,this.draggable&&this.isDragged&&this._draggedPointerID===t.id&&this.stopDrag(t)}}},updateDrag:function(t,e){var i=this.game.camera,s=this.dragOffset,n=this._dragPoint,r=this._pointerData[t.id],o=this.snapPoint,a=this.sprite;if(void 0===e&&(e=!1),t.isUp)return this.stopDrag(t),!1;var h=this.globalToLocal(t);if(a.fixedToCamera)var l=i.scale.x*h.x+n.x+s.x,c=i.scale.y*h.y+n.y+s.y;else var l=h.x+n.x+s.x,c=h.y+n.y+s.y;if(a.fixedToCamera){var u=a.cameraOffset,d=u.x,p=u.y;this.allowHorizontalDrag&&(u.x=l-i.x),this.allowVerticalDrag&&(u.y=c-i.y),this.boundsRect&&this.checkBoundsRect(),this.boundsSprite&&this.checkBoundsSprite(),this.snapOnDrag&&(u.x=Math.round((u.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,u.y=Math.round((u.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY,o.set(u.x,u.y));var f=u.x-d,g=u.y-p}else{var m=i.x-r.camX,y=i.y-r.camY,d=a.x,p=a.y;this.allowHorizontalDrag&&(a.x=l+m),this.allowVerticalDrag&&(a.y=c+y),this.boundsRect&&this.checkBoundsRect(),this.boundsSprite&&this.checkBoundsSprite(),this.snapOnDrag&&(a.x=Math.round((a.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,a.y=Math.round((a.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY,o.set(a.x,a.y));var f=a.x-d,g=a.y-p}return this.sprite.events.onDragUpdate.dispatch(a,t,l,c,o,e,f,g),!0},justOver:function(t,e){return t=t||0,e=e||500,this._pointerData[t].isOver&&this.overDuration(t)<e},justOut:function(t,e){return t=t||0,e=e||500,this._pointerData[t].isOut&&this.game.time.time-this._pointerData[t].timeOut<e},justPressed:function(t,e){return t=t||0,e=e||500,this._pointerData[t].isDown&&this.downDuration(t)<e},justReleased:function(t,e){return t=t||0,e=e||500,this._pointerData[t].isUp&&this.game.time.time-this._pointerData[t].timeUp<e},overDuration:function(t){return t=t||0,this._pointerData[t].isOver?this.game.time.time-this._pointerData[t].timeOver:-1},downDuration:function(t){return t=t||0,this._pointerData[t].isDown?this.game.time.time-this._pointerData[t].timeDown:-1},enableDrag:function(t,i,s,n,r,o){void 0===t&&(t=!1),void 0===i&&(i=!1),void 0===s&&(s=!1),void 0===n&&(n=255),void 0===r&&(r=null),void 0===o&&(o=null),this._dragPoint=new e.Point,this.draggable=!0,this.bringToTop=i,this.dragOffset=new e.Point,this.dragFromCenter=t,this.pixelPerfectClick=s,this.pixelPerfectAlpha=n,r&&(this.boundsRect=r),o&&(this.boundsSprite=o)},disableDrag:function(){if(this._pointerData)for(var t=0;t<10;t++)this._pointerData[t].isDragged=!1;this.draggable=!1,this.isDragged=!1,this._draggedPointerID=-1,this._pendingDrag=!1},startDrag:function(t){var i=this.sprite.x,s=this.sprite.y,n=this.globalToLocal(t);if(this.isDragged=!0,this._draggedPointerID=t.id,this._pointerData[t.id].camX=this.game.camera.x,this._pointerData[t.id].camY=this.game.camera.y,this._pointerData[t.id].isDragged=!0,this.sprite.fixedToCamera){if(this.dragFromCenter){var r=this.sprite.getBounds(),o=this.globalToLocal(new e.Point(r.centerX,r.centerY));this.sprite.cameraOffset.x=n.x+(this.sprite.cameraOffset.x-o.x),this.sprite.cameraOffset.y=n.y+(this.sprite.cameraOffset.y-o.y)}this._dragPoint.setTo(this.sprite.cameraOffset.x-t.x,this.sprite.cameraOffset.y-t.y)}else{if(this.dragFromCenter){var r=this.sprite.getBounds(),o=this.globalToLocal(new e.Point(r.centerX,r.centerY));this.sprite.x=n.x+(this.sprite.x-o.x),this.sprite.y=n.y+(this.sprite.y-o.y)}this._dragPoint.setTo(this.sprite.x-n.x,this.sprite.y-n.y)}this.updateDrag(t,!0),this.bringToTop&&(this._dragPhase=!0,this.sprite.bringToTop()),this.dragStartPoint.set(i,s),this.sprite.events.onDragStart$dispatch(this.sprite,t,i,s),this._pendingDrag=!1},globalToLocalX:function(t){return this.scaleLayer&&(t-=this.game.scale.grid.boundsFluid.x,t*=this.game.scale.grid.scaleFluidInversed.x),t},globalToLocalY:function(t){return this.scaleLayer&&(t-=this.game.scale.grid.boundsFluid.y,t*=this.game.scale.grid.scaleFluidInversed.y),t},globalToLocal:function(t){return this.sprite.parent?this.game.input.getLocalPosition(this.sprite.parent,{x:t.x,y:t.y}):t},stopDrag:function(t){this.isDragged=!1,this._draggedPointerID=-1,this._pointerData[t.id].isDragged=!1,this._dragPhase=!1,this._pendingDrag=!1,this.snapOnRelease&&(this.sprite.fixedToCamera?(this.sprite.cameraOffset.x=Math.round((this.sprite.cameraOffset.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.cameraOffset.y=Math.round((this.sprite.cameraOffset.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY):(this.sprite.x=Math.round((this.sprite.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.y=Math.round((this.sprite.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY)),this.sprite.events.onDragStop$dispatch(this.sprite,t),!1===this.checkPointerOver(t)&&this._pointerOutHandler(t)},setDragLock:function(t,e){void 0===t&&(t=!0),void 0===e&&(e=!0),this.allowHorizontalDrag=t,this.allowVerticalDrag=e},enableSnap:function(t,e,i,s,n,r){void 0===i&&(i=!0),void 0===s&&(s=!1),void 0===n&&(n=0),void 0===r&&(r=0),this.snapX=t,this.snapY=e,this.snapOffsetX=n,this.snapOffsetY=r,this.snapOnDrag=i,this.snapOnRelease=s},disableSnap:function(){this.snapOnDrag=!1,this.snapOnRelease=!1},checkBoundsRect:function(){this.sprite.fixedToCamera?(this.sprite.cameraOffset.x<this.boundsRect.left?this.sprite.cameraOffset.x=this.boundsRect.left:this.sprite.cameraOffset.x+this.sprite.width>this.boundsRect.right&&(this.sprite.cameraOffset.x=this.boundsRect.right-this.sprite.width),this.sprite.cameraOffset.y<this.boundsRect.top?this.sprite.cameraOffset.y=this.boundsRect.top:this.sprite.cameraOffset.y+this.sprite.height>this.boundsRect.bottom&&(this.sprite.cameraOffset.y=this.boundsRect.bottom-this.sprite.height)):(this.sprite.left<this.boundsRect.left?this.sprite.x=this.boundsRect.x+this.sprite.offsetX:this.sprite.right>this.boundsRect.right&&(this.sprite.x=this.boundsRect.right-(this.sprite.width-this.sprite.offsetX)),this.sprite.top<this.boundsRect.top?this.sprite.y=this.boundsRect.top+this.sprite.offsetY:this.sprite.bottom>this.boundsRect.bottom&&(this.sprite.y=this.boundsRect.bottom-(this.sprite.height-this.sprite.offsetY)))},checkBoundsSprite:function(){this.sprite.fixedToCamera&&this.boundsSprite.fixedToCamera?(this.sprite.cameraOffset.x<this.boundsSprite.cameraOffset.x?this.sprite.cameraOffset.x=this.boundsSprite.cameraOffset.x:this.sprite.cameraOffset.x+this.sprite.width>this.boundsSprite.cameraOffset.x+this.boundsSprite.width&&(this.sprite.cameraOffset.x=this.boundsSprite.cameraOffset.x+this.boundsSprite.width-this.sprite.width),this.sprite.cameraOffset.y<this.boundsSprite.cameraOffset.y?this.sprite.cameraOffset.y=this.boundsSprite.cameraOffset.y:this.sprite.cameraOffset.y+this.sprite.height>this.boundsSprite.cameraOffset.y+this.boundsSprite.height&&(this.sprite.cameraOffset.y=this.boundsSprite.cameraOffset.y+this.boundsSprite.height-this.sprite.height)):(this.sprite.left<this.boundsSprite.left?this.sprite.x=this.boundsSprite.left+this.sprite.offsetX:this.sprite.right>this.boundsSprite.right&&(this.sprite.x=this.boundsSprite.right-(this.sprite.width-this.sprite.offsetX)),this.sprite.top<this.boundsSprite.top?this.sprite.y=this.boundsSprite.top+this.sprite.offsetY:this.sprite.bottom>this.boundsSprite.bottom&&(this.sprite.y=this.boundsSprite.bottom-(this.sprite.height-this.sprite.offsetY)))}},e.InputHandler.prototype.constructor=e.InputHandler,e.PointerLock=function(t){this.game=t,this.input=t.input,this.element=t.canvas,this.active=!1,this.locked=!1,this.onChange=new e.Signal,this.onError=new e.Signal,this.boundOnChangeHandler=this.onChangeHandler.bind(this),this.boundOnErrorHandler=this.onErrorHandler.bind(this);var i=t.device;this.pointerLockElement=i.pointerLockElement,this.pointerlockchange=i.pointerlockchange,this.pointerlockerror=i.pointerlockerror},e.PointerLock.prototype.start=function(){return!(!this.game.device.pointerLock||this.active)&&(this.element.requestPointerLock||(this.element.requestPointerLock=this.element.mozRequestPointerLock||this.element.webkitRequestPointerLock),document.exitPointerLock||(document.exitPointerLock=document.mozExitPointerLock||document.webkitExitPointerLock),document.addEventListener(this.pointerlockchange,this.boundOnChangeHandler,!0),document.addEventListener(this.pointerlockerror,this.boundOnErrorHandler,!0),this.active=!0,!0)},e.PointerLock.prototype.stop=function(){this.active&&(document.removeEventListener(this.pointerlockchange,this.boundOnChangeHandler,!0),document.removeEventListener(this.pointerlockerror,this.boundOnErrorHandler,!0),this.active=!1)},e.PointerLock.prototype.request=function(){this.active&&!this.locked&&this.element.requestPointerLock()},e.PointerLock.prototype.exit=function(){document.exitPointerLock()},e.PointerLock.prototype.onChangeHandler=function(t){this.locked=document[this.pointerLockElement]===this.element,this.onChange.dispatch(this.locked,t)},e.PointerLock.prototype.onErrorHandler=function(t){this.onError.dispatch(t)},e.Gamepad=function(t){this.game=t,this._gamepadIndexMap={},this._rawPads=[],this._active=!1,this.enabled=!0,this._gamepadSupportAvailable=!!navigator.webkitGetGamepads||!!navigator.webkitGamepads||-1!==navigator.userAgent.indexOf("Firefox/")||!!navigator.getGamepads,this._prevRawGamepadTypes=[],this._prevTimestamps=[],this.callbackContext=this,this.onConnectCallback=null,this.onDisconnectCallback=null,this.onDownCallback=null,this.onUpCallback=null,this.onAxisCallback=null,this.onFloatCallback=null,this._ongamepadconnected=null,this._gamepaddisconnected=null,this._gamepads=[new e.SinglePad(t,this),new e.SinglePad(t,this),new e.SinglePad(t,this),new e.SinglePad(t,this)]},e.Gamepad.prototype={addCallbacks:function(t,e){void 0!==e&&(this.onConnectCallback="function"==typeof e.onConnect?e.onConnect:this.onConnectCallback,this.onDisconnectCallback="function"==typeof e.onDisconnect?e.onDisconnect:this.onDisconnectCallback,this.onDownCallback="function"==typeof e.onDown?e.onDown:this.onDownCallback,this.onUpCallback="function"==typeof e.onUp?e.onUp:this.onUpCallback,this.onAxisCallback="function"==typeof e.onAxis?e.onAxis:this.onAxisCallback,this.onFloatCallback="function"==typeof e.onFloat?e.onFloat:this.onFloatCallback,this.callbackContext=t)},start:function(){if(!this._active){this._active=!0;var t=this;this._onGamepadConnected=function(e){return t.onGamepadConnected(e)},this._onGamepadDisconnected=function(e){return t.onGamepadDisconnected(e)},window.addEventListener("gamepadconnected",this._onGamepadConnected,!1),window.addEventListener("gamepaddisconnected",this._onGamepadDisconnected,!1)}},onGamepadConnected:function(t){var e=t.gamepad;this._rawPads.push(e),this._gamepads[e.index].connect(e)},onGamepadDisconnected:function(t){var e=t.gamepad;for(var i in this._rawPads)this._rawPads[i].index===e.index&&this._rawPads.splice(i,1);this._gamepads[e.index].disconnect()},update:function(){this._pollGamepads(),this.pad1.pollStatus(),this.pad2.pollStatus(),this.pad3.pollStatus(),this.pad4.pollStatus()},_pollGamepads:function(){if(this._active){if(navigator.getGamepads)t=navigator.getGamepads();else if(navigator.webkitGetGamepads)t=navigator.webkitGetGamepads();else if(navigator.webkitGamepads)var t=navigator.webkitGamepads();if(t){this._rawPads=[];for(var e=!1,i=0;i<t.length&&(typeof t[i]!==this._prevRawGamepadTypes[i]&&(e=!0,this._prevRawGamepadTypes[i]=typeof t[i]),t[i]&&this._rawPads.push(t[i]),3!==i);i++);for(var s=0;s<this._gamepads.length;s++)this._gamepads[s]._rawPad=this._rawPads[s];if(e){for(var n,r={rawIndices:{},padIndices:{}},o=0;o<this._gamepads.length;o++)if((n=this._gamepads[o]).connected)for(var a=0;a<this._rawPads.length;a++)this._rawPads[a].index===n.index&&(r.rawIndices[n.index]=!0,r.padIndices[o]=!0);for(var h=0;h<this._gamepads.length;h++)if(n=this._gamepads[h],!r.padIndices[h]){this._rawPads.length<1&&n.disconnect();for(var l=0;l<this._rawPads.length&&!r.padIndices[h];l++){var c=this._rawPads[l];if(c){if(r.rawIndices[c.index]){n.disconnect();continue}n.connect(c),r.rawIndices[c.index]=!0,r.padIndices[h]=!0}else n.disconnect()}}}}}},setDeadZones:function(t){for(var e=0;e<this._gamepads.length;e++)this._gamepads[e].deadZone=t},stop:function(){this._active=!1,window.removeEventListener("gamepadconnected",this._onGamepadConnected),window.removeEventListener("gamepaddisconnected",this._onGamepadDisconnected)},reset:function(){this.update();for(var t=0;t<this._gamepads.length;t++)this._gamepads[t].reset()},justPressed:function(t,e){for(var i=0;i<this._gamepads.length;i++)if(!0===this._gamepads[i].justPressed(t,e))return!0;return!1},justReleased:function(t,e){for(var i=0;i<this._gamepads.length;i++)if(!0===this._gamepads[i].justReleased(t,e))return!0;return!1},isDown:function(t){for(var e=0;e<this._gamepads.length;e++)if(!0===this._gamepads[e].isDown(t))return!0;return!1},destroy:function(){this.stop();for(var t=0;t<this._gamepads.length;t++)this._gamepads[t].destroy()}},e.Gamepad.prototype.constructor=e.Gamepad,Object.defineProperty(e.Gamepad.prototype,"active",{get:function(){return this._active}}),Object.defineProperty(e.Gamepad.prototype,"supported",{get:function(){return this._gamepadSupportAvailable}}),Object.defineProperty(e.Gamepad.prototype,"padsConnected",{get:function(){return this._rawPads.length}}),Object.defineProperty(e.Gamepad.prototype,"pad1",{get:function(){return this._gamepads[0]}}),Object.defineProperty(e.Gamepad.prototype,"pad2",{get:function(){return this._gamepads[1]}}),Object.defineProperty(e.Gamepad.prototype,"pad3",{get:function(){return this._gamepads[2]}}),Object.defineProperty(e.Gamepad.prototype,"pad4",{get:function(){return this._gamepads[3]}}),e.Gamepad.BUTTON_0=0,e.Gamepad.BUTTON_1=1,e.Gamepad.BUTTON_2=2,e.Gamepad.BUTTON_3=3,e.Gamepad.BUTTON_4=4,e.Gamepad.BUTTON_5=5,e.Gamepad.BUTTON_6=6,e.Gamepad.BUTTON_7=7,e.Gamepad.BUTTON_8=8,e.Gamepad.BUTTON_9=9,e.Gamepad.BUTTON_10=10,e.Gamepad.BUTTON_11=11,e.Gamepad.BUTTON_12=12,e.Gamepad.BUTTON_13=13,e.Gamepad.BUTTON_14=14,e.Gamepad.BUTTON_15=15,e.Gamepad.AXIS_0=0,e.Gamepad.AXIS_1=1,e.Gamepad.AXIS_2=2,e.Gamepad.AXIS_3=3,e.Gamepad.AXIS_4=4,e.Gamepad.AXIS_5=5,e.Gamepad.AXIS_6=6,e.Gamepad.AXIS_7=7,e.Gamepad.AXIS_8=8,e.Gamepad.AXIS_9=9,e.Gamepad.XBOX360_A=0,e.Gamepad.XBOX360_B=1,e.Gamepad.XBOX360_X=2,e.Gamepad.XBOX360_Y=3,e.Gamepad.XBOX360_LEFT_BUMPER=4,e.Gamepad.XBOX360_RIGHT_BUMPER=5,e.Gamepad.XBOX360_LEFT_TRIGGER=6,e.Gamepad.XBOX360_RIGHT_TRIGGER=7,e.Gamepad.XBOX360_BACK=8,e.Gamepad.XBOX360_START=9,e.Gamepad.XBOX360_STICK_LEFT_BUTTON=10,e.Gamepad.XBOX360_STICK_RIGHT_BUTTON=11,e.Gamepad.XBOX360_DPAD_LEFT=14,e.Gamepad.XBOX360_DPAD_RIGHT=15,e.Gamepad.XBOX360_DPAD_UP=12,e.Gamepad.XBOX360_DPAD_DOWN=13,e.Gamepad.XBOX360_STICK_LEFT_X=0,e.Gamepad.XBOX360_STICK_LEFT_Y=1,e.Gamepad.XBOX360_STICK_RIGHT_X=2,e.Gamepad.XBOX360_STICK_RIGHT_Y=3,e.Gamepad.PS3XC_X=0,e.Gamepad.PS3XC_CIRCLE=1,e.Gamepad.PS3XC_SQUARE=2,e.Gamepad.PS3XC_TRIANGLE=3,e.Gamepad.PS3XC_L1=4,e.Gamepad.PS3XC_R1=5,e.Gamepad.PS3XC_L2=6,e.Gamepad.PS3XC_R2=7,e.Gamepad.PS3XC_SELECT=8,e.Gamepad.PS3XC_START=9,e.Gamepad.PS3XC_STICK_LEFT_BUTTON=10,e.Gamepad.PS3XC_STICK_RIGHT_BUTTON=11,e.Gamepad.PS3XC_DPAD_UP=12,e.Gamepad.PS3XC_DPAD_DOWN=13,e.Gamepad.PS3XC_DPAD_LEFT=14,e.Gamepad.PS3XC_DPAD_RIGHT=15,e.Gamepad.PS3XC_STICK_LEFT_X=0,e.Gamepad.PS3XC_STICK_LEFT_Y=1,e.Gamepad.PS3XC_STICK_RIGHT_X=2,e.Gamepad.PS3XC_STICK_RIGHT_Y=3,e.SinglePad=function(t,e){this.game=t,this.index=null,this.connected=!1,this.callbackContext=this,this.onConnectCallback=null,this.onDisconnectCallback=null,this.onDownCallback=null,this.onUpCallback=null,this.onAxisCallback=null,this.onFloatCallback=null,this.deadZone=.26,this._padParent=e,this._rawPad=null,this._prevTimestamp=null,this._buttons=[],this._buttonsLen=0,this._axes=[],this._axesLen=0},e.SinglePad.prototype={addCallbacks:function(t,e){void 0!==e&&(this.onConnectCallback="function"==typeof e.onConnect?e.onConnect:this.onConnectCallback,this.onDisconnectCallback="function"==typeof e.onDisconnect?e.onDisconnect:this.onDisconnectCallback,this.onDownCallback="function"==typeof e.onDown?e.onDown:this.onDownCallback,this.onUpCallback="function"==typeof e.onUp?e.onUp:this.onUpCallback,this.onAxisCallback="function"==typeof e.onAxis?e.onAxis:this.onAxisCallback,this.onFloatCallback="function"==typeof e.onFloat?e.onFloat:this.onFloatCallback,this.callbackContext=t)},getButton:function(t){return this._buttons[t]?this._buttons[t]:null},pollStatus:function(){if(this.connected&&this.game.input.enabled&&this.game.input.gamepad.enabled&&this._rawPad&&(!this._rawPad.timestamp||this._rawPad.timestamp!==this._prevTimestamp)){for(var t=0;t<this._buttonsLen;t++){var e=isNaN(this._rawPad.buttons[t])?this._rawPad.buttons[t].value:this._rawPad.buttons[t];e!==this._buttons[t].value&&(1===e?this.processButtonDown(t,e):0===e?this.processButtonUp(t,e):this.processButtonFloat(t,e))}for(var i=0;i<this._axesLen;i++){var s=this._rawPad.axes[i];s>0&&s>this.deadZone||s<0&&s<-this.deadZone?this.processAxisChange(i,s):this.processAxisChange(i,0)}this._prevTimestamp=this._rawPad.timestamp}},connect:function(t){var i=!this.connected;this.connected=!0,this.index=t.index,this._rawPad=t,this._buttons=[],this._buttonsLen=t.buttons.length,this._axes=[],this._axesLen=t.axes.length;for(var s=0;s<this._axesLen;s++)this._axes[s]=t.axes[s];for(var n in t.buttons)n=parseInt(n,10),this._buttons[n]=new e.DeviceButton(this,n);i&&this._padParent.onConnectCallback&&this._padParent.onConnectCallback.call(this._padParent.callbackContext,this.index),i&&this.onConnectCallback&&this.onConnectCallback.call(this.callbackContext)},disconnect:function(){var t=this.connected,e=this.index;this.connected=!1,this.index=null,this._rawPad=void 0;for(var i=0;i<this._buttonsLen;i++)this._buttons[i].destroy();this._buttons=[],this._buttonsLen=0,this._axes=[],this._axesLen=0,t&&this._padParent.onDisconnectCallback&&this._padParent.onDisconnectCallback.call(this._padParent.callbackContext,e),t&&this.onDisconnectCallback&&this.onDisconnectCallback.call(this.callbackContext)},destroy:function(){this._rawPad=void 0;for(var t=0;t<this._buttonsLen;t++)this._buttons[t].destroy();this._buttons=[],this._buttonsLen=0,this._axes=[],this._axesLen=0,this.onConnectCallback=null,this.onDisconnectCallback=null,this.onDownCallback=null,this.onUpCallback=null,this.onAxisCallback=null,this.onFloatCallback=null},processAxisChange:function(t,e){this._axes[t]!==e&&(this._axes[t]=e,this._padParent.onAxisCallback&&this._padParent.onAxisCallback.call(this._padParent.callbackContext,this,t,e),this.onAxisCallback&&this.onAxisCallback.call(this.callbackContext,this,t,e))},processButtonDown:function(t,e){this._buttons[t]&&this._buttons[t].start(null,e),this._padParent.onDownCallback&&this._padParent.onDownCallback.call(this._padParent.callbackContext,t,e,this.index),this.onDownCallback&&this.onDownCallback.call(this.callbackContext,t,e)},processButtonUp:function(t,e){this._padParent.onUpCallback&&this._padParent.onUpCallback.call(this._padParent.callbackContext,t,e,this.index),this.onUpCallback&&this.onUpCallback.call(this.callbackContext,t,e),this._buttons[t]&&this._buttons[t].stop(null,e)},processButtonFloat:function(t,e){this._padParent.onFloatCallback&&this._padParent.onFloatCallback.call(this._padParent.callbackContext,t,e,this.index),this.onFloatCallback&&this.onFloatCallback.call(this.callbackContext,t,e),this._buttons[t]&&this._buttons[t].padFloat(e)},axis:function(t){return!!this._axes[t]&&this._axes[t]},isDown:function(t){return!!this._buttons[t]&&this._buttons[t].isDown},isUp:function(t){return!!this._buttons[t]&&this._buttons[t].isUp},justReleased:function(t,e){if(this._buttons[t])return this._buttons[t].justReleased(e)},justPressed:function(t,e){if(this._buttons[t])return this._buttons[t].justPressed(e)},buttonValue:function(t){return this._buttons[t]?this._buttons[t].value:null},reset:function(){for(var t=0;t<this._axes.length;t++)this._axes[t]=0}},e.SinglePad.prototype.constructor=e.SinglePad,e.Key=function(t,i){this.game=t,this._enabled=!0,this.event=null,this.isDown=!1,this.isUp=!0,this.altKey=!1,this.ctrlKey=!1,this.shiftKey=!1,this.timeDown=0,this.duration=0,this.timeUp=-2500,this.durationUp=-2500,this.repeats=0,this.keyCode=i,this.onDown=new e.Signal,this.onHoldCallback=null,this.onHoldContext=null,this.onUp=new e.Signal,this._justDown=!1,this._justUp=!1},e.Key.prototype={update:function(){this._enabled&&(this.isDown?(this.duration=this.game.time.time-this.timeDown,this.repeats++,this.onHoldCallback&&this.onHoldCallback.call(this.onHoldContext,this)):this.durationUp=this.game.time.time-this.timeUp)},processKeyDown:function(t){this._enabled&&(this.event=t,this.isDown||(this.altKey=t.altKey,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.isDown=!0,this.isUp=!1,this.timeDown=this.game.time.time,this.duration=0,this.durationUp=this.game.time.time-this.timeUp,this.repeats=0,this._justDown=!0,this.onDown.dispatch(this)))},processKeyUp:function(t){this._enabled&&(this.event=t,this.isUp||(this.isDown=!1,this.isUp=!0,this.timeUp=this.game.time.time,this.duration=this.game.time.time-this.timeDown,this.durationUp=0,this._justUp=!0,this.onUp.dispatch(this)))},reset:function(t){void 0===t&&(t=!0),this.isDown=!1,this.isUp=!0,this.timeUp=this.game.time.time,this.duration=0,this.durationUp=-2500,this._enabled=!0,this._justDown=!1,this._justUp=!1,t&&(this.onDown.removeAll(),this.onUp.removeAll(),this.onHoldCallback=null,this.onHoldContext=null)},downDuration:function(t){return void 0===t&&(t=50),this.isDown&&this.duration<t},upDuration:function(t){return void 0===t&&(t=50),!this.isDown&&this.game.time.time-this.timeUp<t},justPressed:function(){return this.isDown&&0===this.duration},justReleased:function(){return!this.isDown&&0===this.durationUp}},Object.defineProperty(e.Key.prototype,"justDown",{get:function(){var t=this._justDown;return this._justDown=!1,t}}),Object.defineProperty(e.Key.prototype,"justUp",{get:function(){var t=this._justUp;return this._justUp=!1,t}}),Object.defineProperty(e.Key.prototype,"enabled",{get:function(){return this._enabled},set:function(t){(t=!!t)!==this._enabled&&(t||this.reset(!1),this._enabled=t)}}),e.Key.prototype.constructor=e.Key,e.Keyboard=function(t){this.game=t,this.active=!1,this.enabled=!0,this.event=null,this.pressEvent=null,this.callbackContext=this,this.onDownCallback=null,this.onPressCallback=null,this.onUpCallback=null,this._keys=[],this._capture=[],this._onKeyDown=null,this._onKeyPress=null,this._onKeyUp=null,this._i=0,this._k=0},e.Keyboard.prototype={addCallbacks:function(t,e,i,s){this.callbackContext=t,void 0!==e&&null!==e&&(this.onDownCallback=e),void 0!==i&&null!==i&&(this.onUpCallback=i),void 0!==s&&null!==s&&(this.onPressCallback=s)},removeCallbacks:function(){this.callbackContext=this,this.onDownCallback=null,this.onUpCallback=null,this.onPressCallback=null},addKey:function(t){return this._keys[t]||(this._keys[t]=new e.Key(this.game,t),this.addKeyCapture(t)),this._keys[t]},addKeys:function(t){var e={};for(var i in t)e[i]=this.addKey(t[i]);return e},removeKey:function(t){this._keys[t]&&(this._keys[t]=null,this.removeKeyCapture(t))},createCursorKeys:function(){return this.addKeys({up:e.KeyCode.UP,down:e.KeyCode.DOWN,left:e.KeyCode.LEFT,right:e.KeyCode.RIGHT})},start:function(){if(this.game.device.cocoonJS)return!1;if(this.active)return!1;var t=this;return this._onKeyDown=function(e){return t.processKeyDown(e)},this._onKeyUp=function(e){return t.processKeyUp(e)},this._onKeyPress=function(e){return t.processKeyPress(e)},window.addEventListener("keydown",this._onKeyDown,!1),window.addEventListener("keyup",this._onKeyUp,!1),window.addEventListener("keypress",this._onKeyPress,!1),this.active=!0,!0},stop:function(){window.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("keyup",this._onKeyUp),window.removeEventListener("keypress",this._onKeyPress),this._onKeyDown=null,this._onKeyUp=null,this._onKeyPress=null,this.active=!1},destroy:function(){this.stop(),this.clearCaptures(),this._keys.length=0,this._i=0},addKeyCapture:function(t){if("object"==typeof t)for(var e in t)this._capture[t[e]]=!0;else this._capture[t]=!0},removeKeyCapture:function(t){delete this._capture[t]},clearCaptures:function(){this._capture={}},update:function(){for(this._i=this._keys.length;this._i--;)this._keys[this._i]&&this._keys[this._i].update()},processKeyDown:function(t){if(this.event=t,this.game.input.enabled&&this.enabled){var i=t.keyCode;this._capture[i]&&t.preventDefault(),this._keys[i]||(this._keys[i]=new e.Key(this.game,i)),this._keys[i].processKeyDown(t),this._k=i,this.onDownCallback&&this.onDownCallback.call(this.callbackContext,t)}},processKeyPress:function(t){this.pressEvent=t,this.game.input.enabled&&this.enabled&&this.onPressCallback&&this.onPressCallback.call(this.callbackContext,String.fromCharCode(t.charCode),t)},processKeyUp:function(t){if(this.event=t,this.game.input.enabled&&this.enabled){var i=t.keyCode;this._capture[i]&&t.preventDefault(),this._keys[i]||(this._keys[i]=new e.Key(this.game,i)),this._keys[i].processKeyUp(t),this.onUpCallback&&this.onUpCallback.call(this.callbackContext,t)}},reset:function(t){void 0===t&&(t=!0),this.event=null;for(var e=this._keys.length;e--;)this._keys[e]&&this._keys[e].reset(t)},downDuration:function(t,e){return this._keys[t]?this._keys[t].downDuration(e):null},upDuration:function(t,e){return this._keys[t]?this._keys[t].upDuration(e):null},justPressed:function(t){return this._keys[t]?this._keys[t].justPressed():null},justReleased:function(t){return this._keys[t]?this._keys[t].justReleased():null},isDown:function(t){return this._keys[t]?this._keys[t].isDown:null}},Object.defineProperty(e.Keyboard.prototype,"lastChar",{get:function(){return this.event&&32===this.event.charCode?"":this.pressEvent?String.fromCharCode(this.pressEvent.charCode):null}}),Object.defineProperty(e.Keyboard.prototype,"lastKey",{get:function(){return this._keys[this._k]}}),e.Keyboard.prototype.constructor=e.Keyboard,e.KeyCode={A:"A".charCodeAt(0),B:"B".charCodeAt(0),C:"C".charCodeAt(0),D:"D".charCodeAt(0),E:"E".charCodeAt(0),F:"F".charCodeAt(0),G:"G".charCodeAt(0),H:"H".charCodeAt(0),I:"I".charCodeAt(0),J:"J".charCodeAt(0),K:"K".charCodeAt(0),L:"L".charCodeAt(0),M:"M".charCodeAt(0),N:"N".charCodeAt(0),O:"O".charCodeAt(0),P:"P".charCodeAt(0),Q:"Q".charCodeAt(0),R:"R".charCodeAt(0),S:"S".charCodeAt(0),T:"T".charCodeAt(0),U:"U".charCodeAt(0),V:"V".charCodeAt(0),W:"W".charCodeAt(0),X:"X".charCodeAt(0),Y:"Y".charCodeAt(0),Z:"Z".charCodeAt(0),ZERO:"0".charCodeAt(0),ONE:"1".charCodeAt(0),TWO:"2".charCodeAt(0),THREE:"3".charCodeAt(0),FOUR:"4".charCodeAt(0),FIVE:"5".charCodeAt(0),SIX:"6".charCodeAt(0),SEVEN:"7".charCodeAt(0),EIGHT:"8".charCodeAt(0),NINE:"9".charCodeAt(0),NUMPAD_0:96,NUMPAD_1:97,NUMPAD_2:98,NUMPAD_3:99,NUMPAD_4:100,NUMPAD_5:101,NUMPAD_6:102,NUMPAD_7:103,NUMPAD_8:104,NUMPAD_9:105,NUMPAD_MULTIPLY:106,NUMPAD_ADD:107,NUMPAD_ENTER:108,NUMPAD_SUBTRACT:109,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,F13:124,F14:125,F15:126,COLON:186,EQUALS:187,COMMA:188,UNDERSCORE:189,PERIOD:190,QUESTION_MARK:191,TILDE:192,OPEN_BRACKET:219,BACKWARD_SLASH:220,CLOSED_BRACKET:221,QUOTES:222,BACKSPACE:8,TAB:9,CLEAR:12,ENTER:13,SHIFT:16,CONTROL:17,ALT:18,CAPS_LOCK:20,ESC:27,SPACEBAR:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PLUS:43,MINUS:44,INSERT:45,DELETE:46,HELP:47,NUM_LOCK:144};for(var s in e.KeyCode)e.KeyCode.hasOwnProperty(s)&&!s.match(/[a-z]/)&&(e.Keyboard[s]=e.KeyCode[s]);e.Component=function(){},e.Component.Angle=function(){},e.Component.Angle.prototype={angle:{get:function(){return e.Math.wrapAngle(e.Math.radToDeg(this.rotation))},set:function(t){this.rotation=e.Math.degToRad(e.Math.wrapAngle(t))}}},e.Component.Animation=function(){},e.Component.Animation.prototype={play:function(t,e,i,s){if(this.animations)return this.animations.play(t,e,i,s)}},e.Component.AutoCull=function(){},e.Component.AutoCull.prototype={autoCull:!1,inCamera:{get:function(){return this.autoCull||this.checkWorldBounds||(this._bounds.copyFrom(this.getBounds()),this._bounds.x+=this.game.camera.view.x,this._bounds.y+=this.game.camera.view.y),this.game.world.camera.view.intersects(this._bounds)}}},e.Component.Bounds=function(){},e.Component.Bounds.prototype={offsetX:{get:function(){return this.anchor.x*this.width}},offsetY:{get:function(){return this.anchor.y*this.height}},centerX:{get:function(){return this.x-this.offsetX+.5*this.width},set:function(t){this.x=t+this.offsetX-.5*this.width}},centerY:{get:function(){return this.y-this.offsetY+.5*this.height},set:function(t){this.y=t+this.offsetY-.5*this.height}},left:{get:function(){return this.x-this.offsetX},set:function(t){this.x=t+this.offsetX}},right:{get:function(){return this.x+this.width-this.offsetX},set:function(t){this.x=t-this.width+this.offsetX}},top:{get:function(){return this.y-this.offsetY},set:function(t){this.y=t+this.offsetY}},bottom:{get:function(){return this.y+this.height-this.offsetY},set:function(t){this.y=t-this.height+this.offsetY}},alignIn:function(t,i,s,n){switch(void 0===s&&(s=0),void 0===n&&(n=0),i){default:case e.TOP_LEFT:this.left=t.left-s,this.top=t.top-n;break;case e.TOP_CENTER:this.centerX=t.centerX+s,this.top=t.top-n;break;case e.TOP_RIGHT:this.right=t.right+s,this.top=t.top-n;break;case e.LEFT_CENTER:this.left=t.left-s,this.centerY=t.centerY+n;break;case e.CENTER:this.centerX=t.centerX+s,this.centerY=t.centerY+n;break;case e.RIGHT_CENTER:this.right=t.right+s,this.centerY=t.centerY+n;break;case e.BOTTOM_LEFT:this.left=t.left-s,this.bottom=t.bottom+n;break;case e.BOTTOM_CENTER:this.centerX=t.centerX+s,this.bottom=t.bottom+n;break;case e.BOTTOM_RIGHT:this.right=t.right+s,this.bottom=t.bottom+n}return this},alignTo:function(t,i,s,n){switch(void 0===s&&(s=0),void 0===n&&(n=0),i){default:case e.TOP_LEFT:this.left=t.left-s,this.bottom=t.top-n;break;case e.TOP_CENTER:this.centerX=t.centerX+s,this.bottom=t.top-n;break;case e.TOP_RIGHT:this.right=t.right+s,this.bottom=t.top-n;break;case e.LEFT_TOP:this.right=t.left-s,this.top=t.top-n;break;case e.LEFT_CENTER:this.right=t.left-s,this.centerY=t.centerY+n;break;case e.LEFT_BOTTOM:this.right=t.left-s,this.bottom=t.bottom+n;break;case e.RIGHT_TOP:this.left=t.right+s,this.top=t.top-n;break;case e.RIGHT_CENTER:this.left=t.right+s,this.centerY=t.centerY+n;break;case e.RIGHT_BOTTOM:this.left=t.right+s,this.bottom=t.bottom+n;break;case e.BOTTOM_LEFT:this.left=t.left-s,this.top=t.bottom+n;break;case e.BOTTOM_CENTER:this.centerX=t.centerX+s,this.top=t.bottom+n;break;case e.BOTTOM_RIGHT:this.right=t.right+s,this.top=t.bottom+n}return this}},e.Group.prototype.alignIn=e.Component.Bounds.prototype.alignIn,e.Group.prototype.alignTo=e.Component.Bounds.prototype.alignTo,e.Component.BringToTop=function(){},e.Component.BringToTop.prototype.bringToTop=function(){return this.parent&&this.parent.bringChildToTop&&this.parent.bringChildToTop(this),this},e.Component.BringToTop.prototype.sendToBack=function(){return this.parent&&this.parent.sendChildToBack&&this.parent.sendChildToBack(this),this},e.Component.BringToTop.prototype.moveUp=function(){return this.parent&&this.parent.moveUp(this),this},e.Component.BringToTop.prototype.moveDown=function(){return this.parent&&this.parent.moveDown(this),this},e.Component.Core=function(){},e.Component.Core.skipTypeChecks=!1,e.Component.Core.install=function(t){e.Utils.mixinPrototype(this,e.Component.Core.prototype),this.components={};for(var i=0;i<t.length;i++){var s=t[i],n=!1;"Destroy"===s&&(n=!0),e.Utils.mixinPrototype(this,e.Component[s].prototype,n),this.components[s]=!0}},e.Component.Core.init=function(t,i,s,n,r){if(!e.Component.Core.skipTypeChecks){if(!(t instanceof e.Game))throw new Error("The value passed as the `game` argument ("+t+") is not an instance of Phaser.Game.");"number"!=typeof i&&(console.warn("The `x` argument value (%s) should be a number.",i),i=0),"number"!=typeof s&&(console.warn("The `y` argument value (%s) should be a number.",s),s=0)}this.game=t,this.key=n,this.data={},this.position.set(i,s),this.world=new e.Point(i,s),this.previousPosition=new e.Point(i,s),this.events=new e.Events(this),this._bounds=new e.Rectangle,this.components.PhysicsBody&&(this.body=this.body),this.components.Animation&&(this.animations=new e.AnimationManager(this)),this.components.LoadTexture&&null!==n&&this.loadTexture(n,r),this.components.FixedToCamera&&(this.cameraOffset=new e.Point(i,s))},e.Component.Core.preUpdate=function(){return this.pendingDestroy?(this.destroy(),!1):(this.previousPosition.set(this.world.x,this.world.y),this.previousRotation=this.rotation,this.exists&&this.parent.exists?(this.world.setTo(this.game.camera.x+this.worldTransform.tx,this.game.camera.y+this.worldTransform.ty),this.visible&&(this.renderOrderID=this.game.stage.currentRenderOrderID++),this.animations&&this.animations.update(),this.body&&this.body.preUpdate(),this.preUpdateChildren(),!0):(this.renderOrderID=-1,!1))},e.Component.Core.prototype={game:null,name:"",data:{},components:{},z:0,events:void 0,animations:void 0,key:"",world:null,debug:!1,previousPosition:null,previousRotation:0,renderOrderID:0,fresh:!0,pendingDestroy:!1,_bounds:null,_exists:!0,exists:{get:function(){return this._exists},set:function(t){t?(this._exists=!0,this.body&&this.body.type===e.Physics.P2JS&&this.body.addToWorld(),this.visible=!0):(this._exists=!1,this.body&&this.body.type===e.Physics.P2JS&&this.body.removeFromWorld(),this.visible=!1)}},preUpdateChildren:function(){for(var t=0;t<this.children.length;){var e=this.children[t];e.preUpdate(),this===e.parent&&t++}},update:function(){},postUpdate:function(){this.customRender&&this.key.render(),this.components.PhysicsBody&&e.Component.PhysicsBody.postUpdate.call(this),this.components.FixedToCamera&&e.Component.FixedToCamera.postUpdate.call(this);for(var t=0;t<this.children.length;t++)this.children[t].postUpdate()}},e.Component.Crop=function(){},e.Component.Crop.prototype={cropRect:null,_crop:null,crop:function(t,i){void 0===i&&(i=!1),t?(i&&null!==this.cropRect?this.cropRect.setTo(t.x,t.y,t.width,t.height):i&&null===this.cropRect?this.cropRect=new e.Rectangle(t.x,t.y,t.width,t.height):this.cropRect=t,this.updateCrop()):(this._crop=null,this.cropRect=null,this.resetFrame())},updateCrop:function(){if(this.cropRect){var t=this.texture.crop.x,i=this.texture.crop.y,s=this.texture.crop.width,n=this.texture.crop.height;this._crop=e.Rectangle.clone(this.cropRect,this._crop),this._crop.x+=this._frame.x,this._crop.y+=this._frame.y;var r=Math.max(this._frame.x,this._crop.x),o=Math.max(this._frame.y,this._crop.y),a=Math.min(this._frame.right,this._crop.right)-r,h=Math.min(this._frame.bottom,this._crop.bottom)-o;this.texture.crop.x=r,this.texture.crop.y=o,this.texture.crop.width=a,this.texture.crop.height=h,this.texture.frame.width=Math.min(a,this.cropRect.width),this.texture.frame.height=Math.min(h,this.cropRect.height),this.texture.width=this.texture.frame.width,this.texture.height=this.texture.frame.height,this.texture._updateUvs(),16777215===this.tint||t===r&&i===o&&s===a&&n===h||(this.texture.requiresReTint=!0)}}},e.Component.Delta=function(){},e.Component.Delta.prototype={deltaX:{get:function(){return this.world.x-this.previousPosition.x}},deltaY:{get:function(){return this.world.y-this.previousPosition.y}},deltaZ:{get:function(){return this.rotation-this.previousRotation}}},e.Component.Destroy=function(){},e.Component.Destroy.prototype={destroyPhase:!1,destroy:function(t,i){if(null!==this.game&&!this.destroyPhase){void 0===t&&(t=!0),void 0===i&&(i=!1),this.destroyPhase=!0,this.events&&this.events.onDestroy$dispatch(this),this.parent&&(this.parent instanceof e.Group?this.parent.remove(this):this.parent.removeChild(this)),this.input&&this.input.destroy(),this.animations&&this.animations.destroy(),this.body&&this.body.destroy(),this.events&&this.events.destroy(),this.game.tweens.removeFrom(this);var s=this.children.length;if(t)for(;s--;)this.children[s].destroy(t);else for(;s--;)this.removeChild(this.children[s]);this._crop&&(this._crop=null,this.cropRect=null),this._frame&&(this._frame=null),e.Video&&this.key instanceof e.Video&&this.key.onChangeSource.remove(this.resizeFrame,this),e.BitmapText&&this._glyphs&&(this._glyphs=[]),this.alive=!1,this.exists=!1,this.visible=!1,this.filters=null,this.mask=null,this.game=null,this.data={},this.renderable=!1,this.transformCallback&&(this.transformCallback=null,this.transformCallbackContext=null),this.hitArea=null,this.parent=null,this.stage=null,this.worldTransform=null,this.filterArea=null,this._bounds=null,this._currentBounds=null,this._mask=null,this._destroyCachedSprite(),this._destroyTintedTexture(),i&&this.texture.destroy(!0),this.destroyPhase=!1,this.pendingDestroy=!1}}},e.Events=function(t){this.parent=t},e.Events.prototype={destroy:function(){this._parent=null,this._onDestroy&&this._onDestroy.dispose(),this._onAddedToGroup&&this._onAddedToGroup.dispose(),this._onRemovedFromGroup&&this._onRemovedFromGroup.dispose(),this._onKilled&&this._onKilled.dispose(),this._onRevived&&this._onRevived.dispose(),this._onEnterBounds&&this._onEnterBounds.dispose(),this._onOutOfBounds&&this._onOutOfBounds.dispose(),this._onInputOver&&this._onInputOver.dispose(),this._onInputOut&&this._onInputOut.dispose(),this._onInputDown&&this._onInputDown.dispose(),this._onInputUp&&this._onInputUp.dispose(),this._onDragStart&&this._onDragStart.dispose(),this._onDragUpdate&&this._onDragUpdate.dispose(),this._onDragStop&&this._onDragStop.dispose(),this._onAnimationStart&&this._onAnimationStart.dispose(),this._onAnimationComplete&&this._onAnimationComplete.dispose(),this._onAnimationLoop&&this._onAnimationLoop.dispose()},onAddedToGroup:null,onRemovedFromGroup:null,onDestroy:null,onKilled:null,onRevived:null,onOutOfBounds:null,onEnterBounds:null,onInputOver:null,onInputOut:null,onInputDown:null,onInputUp:null,onDragStart:null,onDragUpdate:null,onDragStop:null,onAnimationStart:null,onAnimationComplete:null,onAnimationLoop:null},e.Events.prototype.constructor=e.Events;for(var n in e.Events.prototype)e.Events.prototype.hasOwnProperty(n)&&0===n.indexOf("on")&&null===e.Events.prototype[n]&&function(t,i){"use strict";Object.defineProperty(e.Events.prototype,t,{get:function(){return this[i]||(this[i]=new e.Signal)}}),e.Events.prototype[t+"$dispatch"]=function(){return this[i]?this[i].dispatch.apply(this[i],arguments):null}}(n,"_"+n);e.Component.FixedToCamera=function(){},e.Component.FixedToCamera.postUpdate=function(){this.fixedToCamera&&(this.position.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.position.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y)},e.Component.FixedToCamera.prototype={_fixedToCamera:!1,fixedToCamera:{get:function(){return this._fixedToCamera},set:function(t){t?(this._fixedToCamera=!0,this.cameraOffset.set(this.x,this.y)):this._fixedToCamera=!1}},cameraOffset:new e.Point},e.Component.Health=function(){},e.Component.Health.prototype={health:1,maxHealth:100,damage:function(t){return this.alive&&(this.health-=t,this.health<=0&&this.kill()),this},setHealth:function(t){return this.health=t,this.health>this.maxHealth&&(this.health=this.maxHealth),this},heal:function(t){return this.alive&&(this.health+=t,this.health>this.maxHealth&&(this.health=this.maxHealth)),this}},e.Component.InCamera=function(){},e.Component.InCamera.prototype={inCamera:{get:function(){return this.game.world.camera.view.intersects(this._bounds)}}},e.Component.InputEnabled=function(){},e.Component.InputEnabled.prototype={input:null,inputEnabled:{get:function(){return this.input&&this.input.enabled},set:function(t){t?null===this.input?(this.input=new e.InputHandler(this),this.input.start()):this.input&&!this.input.enabled&&this.input.start():this.input&&this.input.enabled&&this.input.stop()}}},e.Component.InWorld=function(){},e.Component.InWorld.preUpdate=function(){if(this.pendingDestroy)return this.destroy(),!1;if(this.autoCull||this.checkWorldBounds){if(this._bounds.copyFrom(this.getBounds()),this._bounds.x+=this.game.camera.view.x,this._bounds.y+=this.game.camera.view.y,this.autoCull)if(this.game.world.camera.view.intersects(this._bounds))this.renderable=!0,this.game.world.camera.totalInView++;else if(this.renderable=!1,this.outOfCameraBoundsKill)return this.kill(),!1;if(this.checkWorldBounds)if(this._outOfBoundsFired&&this.game.world.bounds.intersects(this._bounds))this._outOfBoundsFired=!1,this.events.onEnterBounds$dispatch(this);else if(!this._outOfBoundsFired&&!this.game.world.bounds.intersects(this._bounds)&&(this._outOfBoundsFired=!0,this.events.onOutOfBounds$dispatch(this),this.outOfBoundsKill))return this.kill(),!1}return!0},e.Component.InWorld.prototype={checkWorldBounds:!1,outOfBoundsKill:!1,outOfCameraBoundsKill:!1,_outOfBoundsFired:!1,inWorld:{get:function(){return this.game.world.bounds.intersects(this.getBounds())}}},e.Component.LifeSpan=function(){},e.Component.LifeSpan.preUpdate=function(){return this.pendingDestroy?(this.destroy(),!1):!(this.lifespan>0&&(this.lifespan-=this.game.time.physicsElapsedMS,this.lifespan<=0))||(this.kill(),!1)},e.Component.LifeSpan.prototype={alive:!0,lifespan:0,revive:function(t){return void 0===t&&(t=100),this.alive=!0,this.exists=!0,this.visible=!0,"function"==typeof this.setHealth&&this.setHealth(t),this.events&&this.events.onRevived$dispatch(this),this},kill:function(){return this.alive=!1,this.exists=!1,this.visible=!1,this.events&&this.events.onKilled$dispatch(this),this}},e.Component.LoadTexture=function(){},e.Component.LoadTexture.prototype={customRender:!1,_frame:null,loadTexture:function(t,i,s){t===e.PENDING_ATLAS?(t=i,i=0):i=i||0,(s||void 0===s)&&this.animations&&this.animations.stop(),this.key=t,this.customRender=!1;var n=this.game.cache,r=!0,o=this.texture.baseTexture.scaleMode===PIXI.scaleModes.LINEAR;if(e.RenderTexture&&t instanceof e.RenderTexture)this.key=t.key,this.setTexture(t);else if(e.BitmapData&&t instanceof e.BitmapData)this.customRender=!0,this.setTexture(t.texture),r=n.hasFrameData(t.key,e.Cache.BITMAPDATA)?!this.animations.loadFrameData(n.getFrameData(t.key,e.Cache.BITMAPDATA),i):!this.animations.loadFrameData(t.frameData,0);else if(e.Video&&t instanceof e.Video){this.customRender=!0;var a=t.texture.valid;this.setTexture(t.texture),this.setFrame(t.texture.frame.clone()),t.onChangeSource.add(this.resizeFrame,this),this.texture.valid=a}else if(e.Tilemap&&t instanceof e.TilemapLayer)this.setTexture(PIXI.Texture.fromCanvas(t.canvas));else if(t instanceof PIXI.Texture)o=t.baseTexture.scaleMode===PIXI.scaleModes.LINEAR,this.setTexture(t);else{var h=n.getImage(t,!0);this.key=h.key,this.setTexture(new PIXI.Texture(h.base)),this.texture.baseTexture.skipRender="__default"===t,r=!this.animations.loadFrameData(h.frameData,i)}r&&(this._frame=e.Rectangle.clone(this.texture.frame)),o||(this.texture.baseTexture.scaleMode=1)},setFrame:function(t){this._frame=t,this.texture.frame.x=t.x,this.texture.frame.y=t.y,this.texture.frame.width=t.width,this.texture.frame.height=t.height,this.texture.crop.x=t.x,this.texture.crop.y=t.y,this.texture.crop.width=t.width,this.texture.crop.height=t.height,t.trimmed?(this.texture.trim?(this.texture.trim.x=t.spriteSourceSizeX,this.texture.trim.y=t.spriteSourceSizeY,this.texture.trim.width=t.sourceSizeW,this.texture.trim.height=t.sourceSizeH):this.texture.trim={x:t.spriteSourceSizeX,y:t.spriteSourceSizeY,width:t.sourceSizeW,height:t.sourceSizeH},this.texture.width=t.sourceSizeW,this.texture.height=t.sourceSizeH,this.texture.frame.width=t.sourceSizeW,this.texture.frame.height=t.sourceSizeH):!t.trimmed&&this.texture.trim&&(this.texture.trim=null),t.rotated&&(this.texture.rotated=!0),this.cropRect&&this.updateCrop(),this.texture.requiresReTint=!0,this.texture._updateUvs(),this.tilingTexture&&(this.refreshTexture=!0)},resizeFrame:function(t,e,i){this.texture.frame.resize(e,i),this.texture.setFrame(this.texture.frame)},resetFrame:function(){this._frame&&this.setFrame(this._frame)},frame:{get:function(){return this.animations.frame},set:function(t){this.animations.frame=t}},frameName:{get:function(){return this.animations.frameName},set:function(t){this.animations.frameName=t}}},e.Component.Overlap=function(){},e.Component.Overlap.prototype={overlap:function(t){return e.Rectangle.intersects(this.getBounds(),t.getBounds())}},e.Component.PhysicsBody=function(){},e.Component.PhysicsBody.preUpdate=function(){return this.pendingDestroy?(this.destroy(),!1):this.fresh&&this.exists?(this.world.setTo(this.parent.position.x+this.position.x,this.parent.position.y+this.position.y),this.worldTransform.tx=this.world.x,this.worldTransform.ty=this.world.y,this.previousPosition.set(this.world.x,this.world.y),this.previousRotation=this.rotation,this.body&&this.body.preUpdate(),this.fresh=!1,this.preUpdateChildren(),!1):(this.previousPosition.set(this.world.x,this.world.y),this.previousRotation=this.rotation,!(!this._exists||!this.parent.exists)||(this.renderOrderID=-1,!1))},e.Component.PhysicsBody.postUpdate=function(){this.exists&&this.body&&this.body.postUpdate()},e.Component.PhysicsBody.prototype={body:null,x:{get:function(){return this.position.x},set:function(t){this.position.x=t,this.body&&!this.body.dirty&&(this.body._reset=!0)}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t,this.body&&!this.body.dirty&&(this.body._reset=!0)}}},e.Component.Reset=function(){},e.Component.Reset.prototype.reset=function(t,e,i){return void 0===i&&(i=1),this.world.set(t,e),this.position.set(t,e),this.fresh=!0,this.exists=!0,this.visible=!0,this.renderable=!0,this.components.InWorld&&(this._outOfBoundsFired=!1),this.components.LifeSpan&&(this.alive=!0,this.health=i),this.components.PhysicsBody&&this.body&&this.body.reset(t,e,!1,!1),this},e.Component.ScaleMinMax=function(){},e.Component.ScaleMinMax.prototype={transformCallback:null,transformCallbackContext:this,scaleMin:null,scaleMax:null,checkTransform:function(t){this.scaleMin&&(t.a<this.scaleMin.x&&(t.a=this.scaleMin.x),t.d<this.scaleMin.y&&(t.d=this.scaleMin.y)),this.scaleMax&&(t.a>this.scaleMax.x&&(t.a=this.scaleMax.x),t.d>this.scaleMax.y&&(t.d=this.scaleMax.y))},setScaleMinMax:function(t,i,s,n){void 0===i?i=s=n=t:void 0===s&&(s=n=i,i=t),null===t?this.scaleMin=null:this.scaleMin?this.scaleMin.set(t,i):this.scaleMin=new e.Point(t,i),null===s?this.scaleMax=null:this.scaleMax?this.scaleMax.set(s,n):this.scaleMax=new e.Point(s,n),null===this.scaleMin?this.transformCallback=null:(this.transformCallback=this.checkTransform,this.transformCallbackContext=this)}},e.Component.Smoothed=function(){},e.Component.Smoothed.prototype={smoothed:{get:function(){return!this.texture.baseTexture.scaleMode},set:function(t){t?this.texture&&0!==this.texture.baseTexture.scaleMode&&(this.texture.baseTexture.scaleMode=0,this.texture.baseTexture.dirty()):this.texture&&1!==this.texture.baseTexture.scaleMode&&(this.texture.baseTexture.scaleMode=1,this.texture.baseTexture.dirty())}}},e.GameObjectFactory=function(t){this.game=t,this.world=this.game.world},e.GameObjectFactory.prototype={existing:function(t){return this.world.add(t)},weapon:function(t,i,s,n,r){var o=this.game.plugins.add(e.Weapon);return r&&(o.bulletClass=r),o.createBullets(t,i,s,n),o},image:function(t,i,s,n,r){return void 0===r&&(r=this.world),r.add(new e.Image(this.game,t,i,s,n))},sprite:function(t,i,s,n,r){return void 0===r&&(r=this.world),r.add(new e.Sprite(this.game,t,i,s,n))},creature:function(t,i,s,n,r,o,a){void 0===r&&(r=this.world);var h=new e.Creature(this.game,t,i,s,n,o,a);return r.add(h),h},tween:function(t){return this.game.tweens.create(t)},group:function(t,i,s,n,r){return new e.Group(this.game,t,i,s,n,r)},physicsGroup:function(t,i,s,n){return new e.Group(this.game,i,s,n,!0,t)},spriteBatch:function(t,i,s){return void 0===t&&(t=null),void 0===i&&(i="group"),void 0===s&&(s=!1),new e.SpriteBatch(this.game,t,i,s)},audio:function(t,e,i,s){return this.game.sound.add(t,e,i,s)},sound:function(t,e,i,s){return this.game.sound.add(t,e,i,s)},audioSprite:function(t){return this.game.sound.addSprite(t)},tileSprite:function(t,i,s,n,r,o,a){return void 0===a&&(a=this.world),a.add(new e.TileSprite(this.game,t,i,s,n,r,o))},rope:function(t,i,s,n,r,o){return void 0===o&&(o=this.world),o.add(new e.Rope(this.game,t,i,s,n,r))},text:function(t,i,s,n,r){return void 0===r&&(r=this.world),r.add(new e.Text(this.game,t,i,s,n))},button:function(t,i,s,n,r,o,a,h,l,c){return void 0===c&&(c=this.world),c.add(new e.Button(this.game,t,i,s,n,r,o,a,h,l))},graphics:function(t,i,s){return void 0===s&&(s=this.world),s.add(new e.Graphics(this.game,t,i))},emitter:function(t,i,s){return this.game.particles.add(new e.Particles.Arcade.Emitter(this.game,t,i,s))},retroFont:function(t,i,s,n,r,o,a,h,l){return new e.RetroFont(this.game,t,i,s,n,r,o,a,h,l)},bitmapText:function(t,i,s,n,r,o){return void 0===o&&(o=this.world),o.add(new e.BitmapText(this.game,t,i,s,n,r))},tilemap:function(t,i,s,n,r){return new e.Tilemap(this.game,t,i,s,n,r)},renderTexture:function(t,i,s,n){void 0!==s&&""!==s||(s=this.game.rnd.uuid()),void 0===n&&(n=!1);var r=new e.RenderTexture(this.game,t,i,s);return n&&this.game.cache.addRenderTexture(s,r),r},video:function(t,i){return new e.Video(this.game,t,i)},bitmapData:function(t,i,s,n){void 0===n&&(n=!1),void 0!==s&&""!==s||(s=this.game.rnd.uuid());var r=new e.BitmapData(this.game,s,t,i);return n&&this.game.cache.addBitmapData(s,r),r},filter:function(t){var i=Array.prototype.slice.call(arguments,1);return(t=new e.Filter[t](this.game)).init.apply(t,i),t},plugin:function(){return this.game.plugins.add.apply(this.game.plugins,arguments)}},e.GameObjectFactory.prototype.constructor=e.GameObjectFactory,e.GameObjectCreator=function(t){this.game=t,this.world=this.game.world},e.GameObjectCreator.prototype={image:function(t,i,s,n){return new e.Image(this.game,t,i,s,n)},sprite:function(t,i,s,n){return new e.Sprite(this.game,t,i,s,n)},tween:function(t){return new e.Tween(t,this.game,this.game.tweens)},group:function(t,i,s,n,r){return new e.Group(this.game,t||null,i,s,n,r)},spriteBatch:function(t,i,s){return void 0===i&&(i="group"),void 0===s&&(s=!1),new e.SpriteBatch(this.game,t,i,s)},audio:function(t,e,i,s){return this.game.sound.add(t,e,i,s)},audioSprite:function(t){return this.game.sound.addSprite(t)},sound:function(t,e,i,s){return this.game.sound.add(t,e,i,s)},tileSprite:function(t,i,s,n,r,o){return new e.TileSprite(this.game,t,i,s,n,r,o)},rope:function(t,i,s,n,r){return new e.Rope(this.game,t,i,s,n,r)},text:function(t,i,s,n){return new e.Text(this.game,t,i,s,n)},button:function(t,i,s,n,r,o,a,h,l){return new e.Button(this.game,t,i,s,n,r,o,a,h,l)},graphics:function(t,i){return new e.Graphics(this.game,t,i)},emitter:function(t,i,s){return new e.Particles.Arcade.Emitter(this.game,t,i,s)},retroFont:function(t,i,s,n,r,o,a,h,l){return new e.RetroFont(this.game,t,i,s,n,r,o,a,h,l)},bitmapText:function(t,i,s,n,r,o){return new e.BitmapText(this.game,t,i,s,n,r,o)},tilemap:function(t,i,s,n,r){return new e.Tilemap(this.game,t,i,s,n,r)},renderTexture:function(t,i,s,n){void 0!==s&&""!==s||(s=this.game.rnd.uuid()),void 0===n&&(n=!1);var r=new e.RenderTexture(this.game,t,i,s);return n&&this.game.cache.addRenderTexture(s,r),r},bitmapData:function(t,i,s,n){void 0===n&&(n=!1),void 0!==s&&""!==s||(s=this.game.rnd.uuid());var r=new e.BitmapData(this.game,s,t,i);return n&&this.game.cache.addBitmapData(s,r),r},filter:function(t){var i=Array.prototype.slice.call(arguments,1);return(t=new e.Filter[t](this.game)).init.apply(t,i),t}},e.GameObjectCreator.prototype.constructor=e.GameObjectCreator,e.Sprite=function(t,i,s,n,r){i=i||0,s=s||0,n=n||null,r=r||null,this.type=e.SPRITE,this.physicsType=e.SPRITE,PIXI.Sprite.call(this,e.Cache.DEFAULT),e.Component.Core.init.call(this,t,i,s,n,r)},e.Sprite.prototype=Object.create(PIXI.Sprite.prototype),e.Sprite.prototype.constructor=e.Sprite,e.Component.Core.install.call(e.Sprite.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Delta","Destroy","FixedToCamera","Health","InCamera","InputEnabled","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","ScaleMinMax","Smoothed"]),e.Sprite.prototype.preUpdatePhysics=e.Component.PhysicsBody.preUpdate,e.Sprite.prototype.preUpdateLifeSpan=e.Component.LifeSpan.preUpdate,e.Sprite.prototype.preUpdateInWorld=e.Component.InWorld.preUpdate,e.Sprite.prototype.preUpdateCore=e.Component.Core.preUpdate,e.Sprite.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},e.Image=function(t,i,s,n,r){i=i||0,s=s||0,n=n||null,r=r||null,this.type=e.IMAGE,PIXI.Sprite.call(this,e.Cache.DEFAULT),e.Component.Core.init.call(this,t,i,s,n,r)},e.Image.prototype=Object.create(PIXI.Sprite.prototype),e.Image.prototype.constructor=e.Image,e.Component.Core.install.call(e.Image.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Destroy","FixedToCamera","InputEnabled","LifeSpan","LoadTexture","Overlap","Reset","ScaleMinMax","Smoothed"]),e.Image.prototype.preUpdateLifeSpan=e.Component.LifeSpan.preUpdate,e.Image.prototype.preUpdateInWorld=e.Component.InWorld.preUpdate,e.Image.prototype.preUpdateCore=e.Component.Core.preUpdate,e.Image.prototype.preUpdate=function(){return!(!this.preUpdateInWorld()||!this.preUpdateLifeSpan())&&this.preUpdateCore()},e.Button=function(t,i,s,n,r,o,a,h,l,c){i=i||0,s=s||0,n=n||null,r=r||null,o=o||this,e.Image.call(this,t,i,s,n,h),this.type=e.BUTTON,this.physicsType=e.SPRITE,this._onOverFrame=null,this._onOutFrame=null,this._onDownFrame=null,this._onUpFrame=null,this.onOverSound=null,this.onOutSound=null,this.onDownSound=null,this.onUpSound=null,this.onOverSoundMarker="",this.onOutSoundMarker="",this.onDownSoundMarker="",this.onUpSoundMarker="",this.onInputOver=new e.Signal,this.onInputOut=new e.Signal,this.onInputDown=new e.Signal,this.onInputUp=new e.Signal,this.onOverMouseOnly=!0,this.justReleasedPreventsOver=e.PointerMode.CONTACT,this.freezeFrames=!1,this.forceOut=!1,this.inputEnabled=!0,this.input.start(0,!0),this.input.useHandCursor=!0,this.setFrames(a,h,l,c),null!==r&&this.onInputUp.add(r,o),this.events.onInputOver.add(this.onInputOverHandler,this),this.events.onInputOut.add(this.onInputOutHandler,this),this.events.onInputDown.add(this.onInputDownHandler,this),this.events.onInputUp.add(this.onInputUpHandler,this)},e.Button.prototype=Object.create(e.Image.prototype),e.Button.prototype.constructor=e.Button;return e.Button.prototype.clearFrames=function(){this.setFrames(null,null,null,null)},e.Button.prototype.setStateFrame=function(t,e,i){var s="_on"+t+"Frame";null!==e?(this[s]=e,i&&this.changeStateFrame(t)):this[s]=null},e.Button.prototype.changeStateFrame=function(t){if(this.freezeFrames)return!1;var e=this["_on"+t+"Frame"];return"string"==typeof e?(this.frameName=e,!0):"number"==typeof e&&(this.frame=e,!0)},e.Button.prototype.setFrames=function(t,e,i,s){this.setStateFrame("Over",t,this.input.pointerOver()),this.setStateFrame("Out",e,!this.input.pointerOver()),this.setStateFrame("Down",i,this.input.pointerDown()),this.setStateFrame("Up",s,this.input.pointerUp())},e.Button.prototype.setStateSound=function(t,i,s){var n="on"+t+"Sound",r="on"+t+"SoundMarker";i instanceof e.Sound||i instanceof e.AudioSprite?(this[n]=i,this[r]="string"==typeof s?s:""):(this[n]=null,this[r]="")},e.Button.prototype.playStateSound=function(t){var e=this["on"+t+"Sound"];if(e){var i=this["on"+t+"SoundMarker"];return e.play(i),!0}return!1},e.Button.prototype.setSounds=function(t,e,i,s,n,r,o,a){this.setStateSound("Over",t,e),this.setStateSound("Out",n,r),this.setStateSound("Down",i,s),this.setStateSound("Up",o,a)},e.Button.prototype.setOverSound=function(t,e){this.setStateSound("Over",t,e)},e.Button.prototype.setOutSound=function(t,e){this.setStateSound("Out",t,e)},e.Button.prototype.setDownSound=function(t,e){this.setStateSound("Down",t,e)},e.Button.prototype.setUpSound=function(t,e){this.setStateSound("Up",t,e)},e.Button.prototype.onInputOverHandler=function(t,e){e.justReleased()&&(this.justReleasedPreventsOver&e.pointerMode)===e.pointerMode||(this.changeStateFrame("Over"),this.onOverMouseOnly&&!e.isMouse||(this.playStateSound("Over"),this.onInputOver&&this.onInputOver.dispatch(this,e)))},e.Button.prototype.onInputOutHandler=function(t,e){this.changeStateFrame("Out"),this.playStateSound("Out"),this.onInputOut&&this.onInputOut.dispatch(this,e)},e.Button.prototype.onInputDownHandler=function(t,e){this.changeStateFrame("Down"),this.playStateSound("Down"),this.onInputDown&&this.onInputDown.dispatch(this,e)},e.Button.prototype.onInputUpHandler=function(t,e,i){this.playStateSound("Up"),this.onInputUp&&this.onInputUp.dispatch(this,e,i),this.freezeFrames||(!0===this.forceOut||(this.forceOut&e.pointerMode)===e.pointerMode?this.changeStateFrame("Out"):this.changeStateFrame("Up")||(i?this.changeStateFrame("Over"):this.changeStateFrame("Out")))},e.SpriteBatch=function(t,i,s,n){void 0!==i&&null!==i||(i=t.world),e.Group.call(this,t,i,s,n),this.type=e.SPRITEBATCH,this.fastSpriteBatch=null,this.ready=!1},e.SpriteBatch.prototype=Object.create(e.Group.prototype),e.SpriteBatch.prototype.constructor=e.SpriteBatch,e.SpriteBatch.prototype._renderWebGL=function(t){!this.visible||this.alpha<=0||!this.children.length||(this.ready||(this.fastSpriteBatch=new PIXI.WebGLFastSpriteBatch(t.gl),this.ready=!0),this.fastSpriteBatch.gl!==t.gl&&this.fastSpriteBatch.setContext(t.gl),t.spriteBatch.stop(),t.shaderManager.setShader(t.shaderManager.fastShader),this.fastSpriteBatch.begin(this,t),this.fastSpriteBatch.render(this),t.spriteBatch.start())},e.SpriteBatch.prototype._renderCanvas=function(t){if(this.visible&&!(this.alpha<=0)&&this.children.length){var e=t.context;e.globalAlpha=this.worldAlpha,this.displayObjectUpdateTransform();for(var i=this.worldTransform,s=!0,n=0;n<this.children.length;n++){var r=this.children[n];if(r.visible){var o=r.texture,a=o.frame;if(e.globalAlpha=this.worldAlpha*r.alpha,r.rotation%(2*Math.PI)==0)s&&(e.setTransform(i.a,i.b,i.c,i.d,i.tx,i.ty),s=!1),e.drawImage(o.baseTexture.source,a.x,a.y,a.width,a.height,r.anchor.x*(-a.width*r.scale.x)+r.position.x+.5+t.shakeX|0,r.anchor.y*(-a.height*r.scale.y)+r.position.y+.5+t.shakeY|0,a.width*r.scale.x,a.height*r.scale.y);else{s||(s=!0),r.displayObjectUpdateTransform();var h=r.worldTransform,l=h.tx*t.resolution+t.shakeX,c=h.ty*t.resolution+t.shakeY;t.roundPixels?e.setTransform(h.a,h.b,h.c,h.d,0|l,0|c):e.setTransform(h.a,h.b,h.c,h.d,l,c),e.drawImage(o.baseTexture.source,a.x,a.y,a.width,a.height,r.anchor.x*-a.width+.5|0,r.anchor.y*-a.height+.5|0,a.width,a.height)}}}}},e.BitmapData=function(t,i,s,n,r){void 0!==s&&0!==s||(s=256),void 0!==n&&0!==n||(n=256),void 0===r&&(r=!1),this.game=t,this.key=i,this.width=s,this.height=n,this.canvas=e.Canvas.create(this,s,n,null,r),this.context=this.canvas.getContext("2d",{alpha:!0}),this.ctx=this.context,this.smoothProperty=t.renderType===e.CANVAS?t.renderer.renderSession.smoothProperty:e.Canvas.getSmoothingPrefix(this.context),this.imageData=this.context.getImageData(0,0,s,n),this.data=null,this.imageData&&(this.data=this.imageData.data),this.pixels=null,this.data&&(this.imageData.data.buffer?(this.buffer=this.imageData.data.buffer,this.pixels=new Uint32Array(this.buffer)):window.ArrayBuffer?(this.buffer=new ArrayBuffer(this.imageData.data.length),this.pixels=new Uint32Array(this.buffer)):this.pixels=this.imageData.data),this.baseTexture=new PIXI.BaseTexture(this.canvas,null,this.game.resolution),this.texture=new PIXI.Texture(this.baseTexture),this.frameData=new e.FrameData,this.textureFrame=this.frameData.addFrame(new e.Frame(0,0,0,s,n,"bitmapData")),this.texture.frame=this.textureFrame,this.type=e.BITMAPDATA,this.disableTextureUpload=!1,this.dirty=!1,this.cls=this.clear,this._image=null,this._pos=new e.Point,this._size=new e.Point,this._scale=new e.Point,this._rotate=0,this._alpha={prev:1,current:1},this._anchor=new e.Point,this._tempR=0,this._tempG=0,this._tempB=0,this._circle=new e.Circle,this._swapCanvas=void 0},e.BitmapData.prototype={move:function(t,e,i){return 0!==t&&this.moveH(t,i),0!==e&&this.moveV(e,i),this},moveH:function(t,i){void 0===i&&(i=!0),void 0===this._swapCanvas&&(this._swapCanvas=e.CanvasPool.create(this,this.width,this.height));var s=this._swapCanvas.getContext("2d"),n=this.height,r=this.canvas;if(s.clearRect(0,0,this.width,this.height),t<0){t=Math.abs(t);o=this.width-t;i&&s.drawImage(r,0,0,t,n,o,0,t,n),s.drawImage(r,t,0,o,n,0,0,o,n)}else{var o=this.width-t;i&&s.drawImage(r,o,0,t,n,0,0,t,n),s.drawImage(r,0,0,o,n,t,0,o,n)}return this.clear(),this.copy(this._swapCanvas)},moveV:function(t,i){void 0===i&&(i=!0),void 0===this._swapCanvas&&(this._swapCanvas=e.CanvasPool.create(this,this.width,this.height));var s=this._swapCanvas.getContext("2d"),n=this.width,r=this.canvas;if(s.clearRect(0,0,this.width,this.height),t<0){t=Math.abs(t);o=this.height-t;i&&s.drawImage(r,0,0,n,t,0,o,n,t),s.drawImage(r,0,t,n,o,0,0,n,o)}else{var o=this.height-t;i&&s.drawImage(r,0,o,n,t,0,0,n,t),s.drawImage(r,0,0,n,o,0,t,n,o)}return this.clear(),this.copy(this._swapCanvas)},add:function(t){if(Array.isArray(t))for(var e=0;e<t.length;e++)t[e].loadTexture&&t[e].loadTexture(this);else t.loadTexture(this);return this},load:function(t){if("string"==typeof t&&(t=this.game.cache.getImage(t)),t)return this.resize(t.width,t.height),this.cls(),this.draw(t),this.update(),this},clear:function(t,e,i,s){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.width),void 0===s&&(s=this.height),this.context.clearRect(t,e,i,s),this.dirty=!0,this},fill:function(t,e,i,s){return void 0===s&&(s=1),this.context.fillStyle="rgba("+t+","+e+","+i+","+s+")",this.context.fillRect(0,0,this.width,this.height),this.dirty=!0,this},generateTexture:function(t,e,i){var s=this.game.cache,n=new Image;if(e&&(n.onload=function(){var r=s.addImage(t,"",n),o=new PIXI.Texture(r.base);e.call(i||null,o),n.onload=null}),n.src=this.canvas.toDataURL("image/png"),!e){var r=s.addImage(t,"",n);return new PIXI.Texture(r.base)}return null},resize:function(t,e){return t===this.width&&e===this.height||(this.width=t,this.height=e,this.canvas.width=t,this.canvas.height=e,void 0!==this._swapCanvas&&(this._swapCanvas.width=t,this._swapCanvas.height=e),this.baseTexture.width=t,this.baseTexture.height=e,this.textureFrame.width=t,this.textureFrame.height=e,this.texture.width=t,this.texture.height=e,this.texture.crop.width=t,this.texture.crop.height=e,this.update(),this.dirty=!0),this},update:function(t,e,i,s){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=Math.max(1,this.width)),void 0===s&&(s=Math.max(1,this.height)),this.imageData=this.context.getImageData(t,e,i,s),this.data=this.imageData.data,this.imageData.data.buffer?(this.buffer=this.imageData.data.buffer,this.pixels=new Uint32Array(this.buffer)):window.ArrayBuffer?(this.buffer=new ArrayBuffer(this.imageData.data.length),this.pixels=new Uint32Array(this.buffer)):this.pixels=this.imageData.data,this},processPixelRGB:function(t,i,s,n,r,o){void 0===s&&(s=0),void 0===n&&(n=0),void 0===r&&(r=this.width),void 0===o&&(o=this.height);for(var a=s+r,h=n+o,l=e.Color.createColor(),c={r:0,g:0,b:0,a:0},u=!1,d=n;d<h;d++)for(var p=s;p<a;p++)e.Color.unpackPixel(this.getPixel32(p,d),l),!1!==(c=t.call(i,l,p,d))&&null!==c&&void 0!==c&&(this.setPixel32(p,d,c.r,c.g,c.b,c.a,!1),u=!0);return u&&(this.context.putImageData(this.imageData,0,0),this.dirty=!0),this},processPixel:function(t,e,i,s,n,r){void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=this.width),void 0===r&&(r=this.height);for(var o=i+n,a=s+r,h=0,l=0,c=!1,u=s;u<a;u++)for(var d=i;d<o;d++)h=this.getPixel32(d,u),(l=t.call(e,h,d,u))!==h&&(this.pixels[u*this.width+d]=l,c=!0);return c&&(this.context.putImageData(this.imageData,0,0),this.dirty=!0),this},replaceRGB:function(t,i,s,n,r,o,a,h,l){var c=0,u=0,d=this.width,p=this.height,f=e.Color.packPixel(t,i,s,n);void 0!==l&&l instanceof e.Rectangle&&(c=l.x,u=l.y,d=l.width,p=l.height);for(var g=0;g<p;g++)for(var m=0;m<d;m++)this.getPixel32(c+m,u+g)===f&&this.setPixel32(c+m,u+g,r,o,a,h,!1);return this.context.putImageData(this.imageData,0,0),this.dirty=!0,this},setHSL:function(t,i,s,n){var r=t||0===t,o=i||0===i,a=s||0===s;if(r||o||a){void 0===n&&(n=new e.Rectangle(0,0,this.width,this.height));for(var h=e.Color.createColor(),l=n.y;l<n.bottom;l++)for(var c=n.x;c<n.right;c++)e.Color.unpackPixel(this.getPixel32(c,l),h,!0),r&&(h.h=t),o&&(h.s=i),a&&(h.l=s),e.Color.HSLtoRGB(h.h,h.s,h.l,h),this.setPixel32(c,l,h.r,h.g,h.b,h.a,!1);return this.context.putImageData(this.imageData,0,0),this.dirty=!0,this}},shiftHSL:function(t,i,s,n){if(void 0!==t&&null!==t||(t=!1),void 0!==i&&null!==i||(i=!1),void 0!==s&&null!==s||(s=!1),t||i||s){void 0===n&&(n=new e.Rectangle(0,0,this.width,this.height));for(var r=e.Color.createColor(),o=n.y;o<n.bottom;o++)for(var a=n.x;a<n.right;a++)e.Color.unpackPixel(this.getPixel32(a,o),r,!0),t&&(r.h=this.game.math.wrap(r.h+t,0,1)),i&&(r.s=this.game.math.clamp(r.s+i,0,1)),s&&(r.l=this.game.math.clamp(r.l+s,0,1)),e.Color.HSLtoRGB(r.h,r.s,r.l,r),this.setPixel32(a,o,r.r,r.g,r.b,r.a,!1);return this.context.putImageData(this.imageData,0,0),this.dirty=!0,this}},setPixel32:function(t,i,s,n,r,o,a){return void 0===a&&(a=!0),t>=0&&t<=this.width&&i>=0&&i<=this.height&&(e.Device.LITTLE_ENDIAN?this.pixels[i*this.width+t]=o<<24|r<<16|n<<8|s:this.pixels[i*this.width+t]=s<<24|n<<16|r<<8|o,a&&(this.context.putImageData(this.imageData,0,0),this.dirty=!0)),this},setPixel:function(t,e,i,s,n,r){return this.setPixel32(t,e,i,s,n,255,r)},getPixel:function(t,i,s){s||(s=e.Color.createColor());var n=~~(t+i*this.width);return n*=4,s.r=this.data[n],s.g=this.data[++n],s.b=this.data[++n],s.a=this.data[++n],s},getPixel32:function(t,e){if(t>=0&&t<=this.width&&e>=0&&e<=this.height)return this.pixels[e*this.width+t]},getPixelRGB:function(t,i,s,n,r){return e.Color.unpackPixel(this.getPixel32(t,i),s,n,r)},getPixels:function(t){return this.context.getImageData(t.x,t.y,t.width,t.height)},getFirstPixel:function(t){void 0===t&&(t=0);var i=e.Color.createColor(),s=0,n=0,r=1,o=!1;1===t?(r=-1,n=this.height):3===t&&(r=-1,s=this.width);do{e.Color.unpackPixel(this.getPixel32(s,n),i),0===t||1===t?++s===this.width&&(s=0,((n+=r)>=this.height||n<=0)&&(o=!0)):2!==t&&3!==t||++n===this.height&&(n=0,((s+=r)>=this.width||s<=0)&&(o=!0))}while(0===i.a&&!o);return i.x=s,i.y=n,i},getBounds:function(t){return void 0===t&&(t=new e.Rectangle),t.x=this.getFirstPixel(2).x,t.x===this.width?t.setTo(0,0,0,0):(t.y=this.getFirstPixel(0).y,t.width=this.getFirstPixel(3).x-t.x+1,t.height=this.getFirstPixel(1).y-t.y+1,t)},addToWorld:function(t,e,i,s,n,r){n=n||1,r=r||1;var o=this.game.add.image(t,e,this);return o.anchor.set(i,s),o.scale.set(n,r),o},copy:function(t,i,s,n,r,o,a,h,l,c,u,d,p,f,g,m,y){if(void 0!==t&&null!==t||(t=this),t instanceof e.RenderTexture&&(t=t.getCanvas()),this._image=t,t instanceof e.Sprite||t instanceof e.Image||t instanceof e.Text||t instanceof PIXI.Sprite)this._pos.set(t.texture.crop.x,t.texture.crop.y),this._size.set(t.texture.crop.width,t.texture.crop.height),this._scale.set(t.scale.x,t.scale.y),this._anchor.set(t.anchor.x,t.anchor.y),this._rotate=t.rotation,this._alpha.current=t.alpha,t.texture instanceof e.RenderTexture?this._image=t.texture.getCanvas():this._image=t.texture.baseTexture.source,void 0!==o&&null!==o||(o=t.x),void 0!==a&&null!==a||(a=t.y),t.texture.trim&&(o+=t.texture.trim.x-t.anchor.x*t.texture.trim.width,a+=t.texture.trim.y-t.anchor.y*t.texture.trim.height),16777215!==t.tint&&(t.cachedTint!==t.tint&&(t.cachedTint=t.tint,t.tintedTexture=PIXI.CanvasTinter.getTintedTexture(t,t.tint)),this._image=t.tintedTexture,this._pos.set(0));else{if(this._pos.set(0),this._scale.set(1),this._anchor.set(0),this._rotate=0,this._alpha.current=1,t instanceof e.BitmapData)this._image=t.canvas;else if("string"==typeof t){if(null===(t=this.game.cache.getImage(t)))return this;this._image=t}this._size.set(this._image.width,this._image.height)}if(void 0!==i&&null!==i||(i=0),void 0!==s&&null!==s||(s=0),n&&(this._size.x=n),r&&(this._size.y=r),void 0!==o&&null!==o||(o=i),void 0!==a&&null!==a||(a=s),void 0!==h&&null!==h||(h=this._size.x),void 0!==l&&null!==l||(l=this._size.y),"number"==typeof c&&(this._rotate=c),"number"==typeof u&&(this._anchor.x=u),"number"==typeof d&&(this._anchor.y=d),"number"==typeof p&&(this._scale.x=p),"number"==typeof f&&(this._scale.y=f),"number"==typeof g&&(this._alpha.current=g),void 0===m&&(m=null),void 0===y&&(y=!1),this._alpha.current<=0||0===this._scale.x||0===this._scale.y||0===this._size.x||0===this._size.y)return this;var v=this.context;return this._alpha.prev=v.globalAlpha,v.save(),v.globalAlpha=this._alpha.current,m&&(this.op=m),y&&(o|=0,a|=0),v.translate(o,a),v.scale(this._scale.x,this._scale.y),v.rotate(this._rotate),v.drawImage(this._image,this._pos.x+i,this._pos.y+s,this._size.x,this._size.y,-h*this._anchor.x,-l*this._anchor.y,h,l),v.restore(),v.globalAlpha=this._alpha.prev,this.dirty=!0,this},copyTransform:function(t,i,s){if(void 0===i&&(i=null),void 0===s&&(s=!1),!t.hasOwnProperty("worldTransform")||!t.worldVisible||0===t.worldAlpha)return this;var n=t.worldTransform;if(this._pos.set(t.texture.crop.x,t.texture.crop.y),this._size.set(t.texture.crop.width,t.texture.crop.height),0===n.a||0===n.d||0===this._size.x||0===this._size.y)return this;t.texture instanceof e.RenderTexture?this._image=t.texture.getCanvas():this._image=t.texture.baseTexture.source;var r=n.tx,o=n.ty;t.texture.trim&&(r+=t.texture.trim.x-t.anchor.x*t.texture.trim.width,o+=t.texture.trim.y-t.anchor.y*t.texture.trim.height),16777215!==t.tint&&(t.cachedTint!==t.tint&&(t.cachedTint=t.tint,t.tintedTexture=PIXI.CanvasTinter.getTintedTexture(t,t.tint)),this._image=t.tintedTexture,this._pos.set(0)),s&&(r|=0,o|=0);var a=this.context;return this._alpha.prev=a.globalAlpha,a.save(),a.globalAlpha=this._alpha.current,i&&(this.op=i),a[this.smoothProperty]=t.texture.baseTexture.scaleMode===PIXI.scaleModes.LINEAR,a.setTransform(n.a,n.b,n.c,n.d,r,o),a.drawImage(this._image,this._pos.x,this._pos.y,this._size.x,this._size.y,-this._size.x*t.anchor.x,-this._size.y*t.anchor.y,this._size.x,this._size.y),a.restore(),a.globalAlpha=this._alpha.prev,this.dirty=!0,this},copyRect:function(t,e,i,s,n,r,o){return this.copy(t,e.x,e.y,e.width,e.height,i,s,e.width,e.height,0,0,0,1,1,n,r,o)},draw:function(t,e,i,s,n,r,o){return this.copy(t,null,null,null,null,e,i,s,n,null,null,null,null,null,null,r,o)},drawGroup:function(t,e,i){return t.total>0&&t.forEachExists(this.drawGroupProxy,this,e,i),this},drawGroupProxy:function(t,i,s){if(t.hasOwnProperty("texture")&&this.copyTransform(t,i,s),t.type===e.GROUP&&t.exists)this.drawGroup(t,i,s);else if(t.hasOwnProperty("children")&&t.children.length>0)for(var n=0;n<t.children.length;n++)t.children[n].exists&&this.copyTransform(t.children[n],i,s)},drawFull:function(t,i,s){if(!1===t.worldVisible||0===t.worldAlpha||t.hasOwnProperty("exists")&&!1===t.exists)return this;if(t.type!==e.GROUP&&t.type!==e.EMITTER&&t.type!==e.BITMAPTEXT)if(t.type===e.GRAPHICS){var n=t.getBounds();this.ctx.save(),this.ctx.translate(n.x,n.y),PIXI.CanvasGraphics.renderGraphics(t,this.ctx),this.ctx.restore()}else this.copy(t,null,null,null,null,t.worldPosition.x,t.worldPosition.y,null,null,t.worldRotation,null,null,t.worldScale.x,t.worldScale.y,t.worldAlpha,i,s);if(t.children)for(var r=0;r<t.children.length;r++)this.drawFull(t.children[r],i,s);return this},shadow:function(t,e,i,s){var n=this.context;return void 0===t||null===t?n.shadowColor="rgba(0,0,0,0)":(n.shadowColor=t,n.shadowBlur=0===e?0:e||5,n.shadowOffsetX=0===i?0:i||10,n.shadowOffsetY=0===s?0:s||10),this},alphaMask:function(t,e,i,s){return void 0===s||null===s?this.draw(e).blendSourceAtop():this.draw(e,s.x,s.y,s.width,s.height).blendSourceAtop(),void 0===i||null===i?this.draw(t).blendReset():this.draw(t,i.x,i.y,i.width,i.height).blendReset(),this},extract:function(t,e,i,s,n,r,o,a,h){return void 0===n&&(n=255),void 0===r&&(r=!1),void 0===o&&(o=e),void 0===a&&(a=i),void 0===h&&(h=s),r&&t.resize(this.width,this.height),this.processPixelRGB(function(r,l,c){return r.r===e&&r.g===i&&r.b===s&&t.setPixel32(l,c,o,a,h,n,!1),!1},this),t.context.putImageData(t.imageData,0,0),t.dirty=!0,t},rect:function(t,e,i,s,n){return void 0!==n&&(this.context.fillStyle=n),this.context.fillRect(t,e,i,s),this},text:function(t,e,i,s,n,r){void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s="14px Courier"),void 0===n&&(n="rgb(255,255,255)"),void 0===r&&(r=!0);var o=this.context,a=o.font;return o.font=s,r&&(o.fillStyle="rgb(0,0,0)",o.fillText(t,e+1,i+1)),o.fillStyle=n,o.fillText(t,e,i),o.font=a,this},circle:function(t,e,i,s){var n=this.context;return void 0!==s&&(n.fillStyle=s),n.beginPath(),n.arc(t,e,i,0,2*Math.PI,!1),n.closePath(),n.fill(),this},line:function(t,e,i,s,n,r){void 0===n&&(n="#fff"),void 0===r&&(r=1);var o=this.context;return o.beginPath(),o.moveTo(t,e),o.lineTo(i,s),o.lineWidth=r,o.strokeStyle=n,o.stroke(),o.closePath(),this},polygon:function(t,e,i,s){void 0===s&&(s="#fff"),void 0===i&&(i=0);var n=this.context;e&&(n.fillStyle=e),i&&(n.lineWidth=i,n.strokeStyle=s),n.beginPath(),n.moveTo(t[0].x,t[0].y);for(var r=1,o=t.length;r<o;r++){var a=t[r];n.lineTo(a.x,a.y)}return n.closePath(),e&&n.fill(),i&&n.stroke(),this},textureLine:function(t,i,s){if(void 0===s&&(s="repeat-x"),"string"!=typeof i||(i=this.game.cache.getImage(i))){var n=t.length;"no-repeat"===s&&n>i.width&&(n=i.width);var r=this.context;return r.fillStyle=r.createPattern(i,s),this._circle=new e.Circle(t.start.x,t.start.y,i.height),this._circle.circumferencePoint(t.angle-1.5707963267948966,!1,this._pos),r.save(),r.translate(this._pos.x,this._pos.y),r.rotate(t.angle),r.fillRect(0,0,n,i.height),r.restore(),this.dirty=!0,this}},render:function(){return!this.disableTextureUpload&&this.dirty&&(this.baseTexture.dirty(),this.dirty=!1),this},destroy:function(){this.frameData.destroy(),this.texture.destroy(!0),e.CanvasPool.remove(this)},blendReset:function(){return this.op="source-over",this},blendSourceOver:function(){return this.op="source-over",this},blendSourceIn:function(){return this.op="source-in",this},blendSourceOut:function(){return this.op="source-out",this},blendSourceAtop:function(){return this.op="source-atop",this},blendDestinationOver:function(){return this.op="destination-over",this},blendDestinationIn:function(){return this.op="destination-in",this},blendDestinationOut:function(){return this.op="destination-out",this},blendDestinationAtop:function(){return this.op="destination-atop",this},blendXor:function(){return this.op="xor",this},blendAdd:function(){return this.op="lighter",this},blendMultiply:function(){return this.op="multiply",this},blendScreen:function(){return this.op="screen",this},blendOverlay:function(){return this.op="overlay",this},blendDarken:function(){return this.op="darken",this},blendLighten:function(){return this.op="lighten",this},blendColorDodge:function(){return this.op="color-dodge",this},blendColorBurn:function(){return this.op="color-burn",this},blendHardLight:function(){return this.op="hard-light",this},blendSoftLight:function(){return this.op="soft-light",this},blendDifference:function(){return this.op="difference",this},blendExclusion:function(){return this.op="exclusion",this},blendHue:function(){return this.op="hue",this},blendSaturation:function(){return this.op="saturation",this},blendColor:function(){return this.op="color",this},blendLuminosity:function(){return this.op="luminosity",this},copyBitmapData:function(t,e,i){t.update();for(var s,n=0;n<t.height;n++){s=(i+n)*this.width+e;for(var r=0;r<t.width;r++)this.pixels[s+r]=t.pixels[n*t.width+r]}return this}},Object.defineProperty(e.BitmapData.prototype,"smoothed",{get:function(){return e.Canvas.getSmoothingEnabled(this.context)},set:function(t){e.Canvas.setSmoothingEnabled(this.context,t)}}),Object.defineProperty(e.BitmapData.prototype,"op",{get:function(){return this.context.globalCompositeOperation},set:function(t){this.context.globalCompositeOperation=t}}),e.BitmapData.getTransform=function(t,e,i,s,n,r){return"number"!=typeof t&&(t=0),"number"!=typeof e&&(e=0),"number"!=typeof i&&(i=1),"number"!=typeof s&&(s=1),"number"!=typeof n&&(n=0),"number"!=typeof r&&(r=0),{sx:i,sy:s,scaleX:i,scaleY:s,skewX:n,skewY:r,translateX:t,translateY:e,tx:t,ty:e}},e.BitmapData.prototype.constructor=e.BitmapData,e.EarCut={},e.EarCut.Triangulate=function(t,i,s){s=s||2;var n=i&&i.length,r=n?i[0]*s:t.length,o=e.EarCut.linkedList(t,0,r,s,!0),a=[];if(!o)return a;var h,l,c,u,d,p,f;if(n&&(o=e.EarCut.eliminateHoles(t,i,o,s)),t.length>80*s){h=c=t[0],l=u=t[1];for(var g=s;g<r;g+=s)d=t[g],p=t[g+1],d<h&&(h=d),p<l&&(l=p),d>c&&(c=d),p>u&&(u=p);f=Math.max(c-h,u-l)}return e.EarCut.earcutLinked(o,a,s,h,l,f),a},e.EarCut.linkedList=function(t,i,s,n,r){var o,a,h,l=0;for(o=i,a=s-n;o<s;o+=n)l+=(t[a]-t[o])*(t[o+1]+t[a+1]),a=o;if(r===l>0)for(o=i;o<s;o+=n)h=e.EarCut.insertNode(o,t[o],t[o+1],h);else for(o=s-n;o>=i;o-=n)h=e.EarCut.insertNode(o,t[o],t[o+1],h);return h},e.EarCut.filterPoints=function(t,i){if(!t)return t;i||(i=t);var s,n=t;do{if(s=!1,n.steiner||!e.EarCut.equals(n,n.next)&&0!==e.EarCut.area(n.prev,n,n.next))n=n.next;else{if(e.EarCut.removeNode(n),(n=i=n.prev)===n.next)return null;s=!0}}while(s||n!==i);return i},e.EarCut.earcutLinked=function(t,i,s,n,r,o,a){if(t){!a&&o&&e.EarCut.indexCurve(t,n,r,o);for(var h,l,c=t;t.prev!==t.next;)if(h=t.prev,l=t.next,o?e.EarCut.isEarHashed(t,n,r,o):e.EarCut.isEar(t))i.push(h.i/s),i.push(t.i/s),i.push(l.i/s),e.EarCut.removeNode(t),t=l.next,c=l.next;else if((t=l)===c){a?1===a?(t=e.EarCut.cureLocalIntersections(t,i,s),e.EarCut.earcutLinked(t,i,s,n,r,o,2)):2===a&&e.EarCut.splitEarcut(t,i,s,n,r,o):e.EarCut.earcutLinked(e.EarCut.filterPoints(t),i,s,n,r,o,1);break}}},e.EarCut.isEar=function(t){var i=t.prev,s=t,n=t.next;if(e.EarCut.area(i,s,n)>=0)return!1;for(var r=t.next.next;r!==t.prev;){if(e.EarCut.pointInTriangle(i.x,i.y,s.x,s.y,n.x,n.y,r.x,r.y)&&e.EarCut.area(r.prev,r,r.next)>=0)return!1;r=r.next}return!0},e.EarCut.isEarHashed=function(t,i,s,n){var r=t.prev,o=t,a=t.next;if(e.EarCut.area(r,o,a)>=0)return!1;for(var h=r.x<o.x?r.x<a.x?r.x:a.x:o.x<a.x?o.x:a.x,l=r.y<o.y?r.y<a.y?r.y:a.y:o.y<a.y?o.y:a.y,c=r.x>o.x?r.x>a.x?r.x:a.x:o.x>a.x?o.x:a.x,u=r.y>o.y?r.y>a.y?r.y:a.y:o.y>a.y?o.y:a.y,d=e.EarCut.zOrder(h,l,i,s,n),p=e.EarCut.zOrder(c,u,i,s,n),f=t.nextZ;f&&f.z<=p;){if(f!==t.prev&&f!==t.next&&e.EarCut.pointInTriangle(r.x,r.y,o.x,o.y,a.x,a.y,f.x,f.y)&&e.EarCut.area(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(f=t.prevZ;f&&f.z>=d;){if(f!==t.prev&&f!==t.next&&e.EarCut.pointInTriangle(r.x,r.y,o.x,o.y,a.x,a.y,f.x,f.y)&&e.EarCut.area(f.prev,f,f.next)>=0)return!1;f=f.prevZ}return!0},e.EarCut.cureLocalIntersections=function(t,i,s){var n=t;do{var r=n.prev,o=n.next.next;e.EarCut.intersects(r,n,n.next,o)&&e.EarCut.locallyInside(r,o)&&e.EarCut.locallyInside(o,r)&&(i.push(r.i/s),i.push(n.i/s),i.push(o.i/s),e.EarCut.removeNode(n),e.EarCut.removeNode(n.next),n=t=o),n=n.next}while(n!==t);return n},e.EarCut.splitEarcut=function(t,i,s,n,r,o){var a=t;do{for(var h=a.next.next;h!==a.prev;){if(a.i!==h.i&&e.EarCut.isValidDiagonal(a,h)){var l=e.EarCut.splitPolygon(a,h);return a=e.EarCut.filterPoints(a,a.next),l=e.EarCut.filterPoints(l,l.next),e.EarCut.earcutLinked(a,i,s,n,r,o),void e.EarCut.earcutLinked(l,i,s,n,r,o)}h=h.next}a=a.next}while(a!==t)},e.EarCut.eliminateHoles=function(t,i,s,n){var r,o,a,h,l,c=[];for(r=0,o=i.length;r<o;r++)a=i[r]*n,h=r<o-1?i[r+1]*n:t.length,(l=e.EarCut.linkedList(t,a,h,n,!1))===l.next&&(l.steiner=!0),c.push(e.EarCut.getLeftmost(l));for(c.sort(e.EarCut.compareX),r=0;r<c.length;r++)e.EarCut.eliminateHole(c[r],s),s=e.EarCut.filterPoints(s,s.next);return s},e.EarCut.compareX=function(t,e){return t.x-e.x},e.EarCut.eliminateHole=function(t,i){if(i=e.EarCut.findHoleBridge(t,i)){var s=e.EarCut.splitPolygon(i,t);e.EarCut.filterPoints(s,s.next)}},e.EarCut.findHoleBridge=function(t,i){var s,n=i,r=t.x,o=t.y,a=-1/0;do{if(o<=n.y&&o>=n.next.y){var h=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);h<=r&&h>a&&(a=h,s=n.x<n.next.x?n:n.next)}n=n.next}while(n!==i);if(!s)return null;if(t.x===s.x)return s.prev;var l,c=s,u=1/0;for(n=s.next;n!==c;)r>=n.x&&n.x>=s.x&&e.EarCut.pointInTriangle(o<s.y?r:a,o,s.x,s.y,o<s.y?a:r,o,n.x,n.y)&&((l=Math.abs(o-n.y)/(r-n.x))<u||l===u&&n.x>s.x)&&e.EarCut.locallyInside(n,t)&&(s=n,u=l),n=n.next;return s},e.EarCut.indexCurve=function(t,i,s,n){var r=t;do{null===r.z&&(r.z=e.EarCut.zOrder(r.x,r.y,i,s,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,e.EarCut.sortLinked(r)},e.EarCut.sortLinked=function(t){var e,i,s,n,r,o,a,h,l=1;do{for(i=t,t=null,r=null,o=0;i;){for(o++,s=i,a=0,e=0;e<l&&(a++,s=s.nextZ);e++);for(h=l;a>0||h>0&&s;)0===a?(n=s,s=s.nextZ,h--):0!==h&&s?i.z<=s.z?(n=i,i=i.nextZ,a--):(n=s,s=s.nextZ,h--):(n=i,i=i.nextZ,a--),r?r.nextZ=n:t=n,n.prevZ=r,r=n;i=s}r.nextZ=null,l*=2}while(o>1);return t},e.EarCut.zOrder=function(t,e,i,s,n){return t=32767*(t-i)/n,e=32767*(e-s)/n,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1},e.EarCut.getLeftmost=function(t){var e=t,i=t;do{e.x<i.x&&(i=e),e=e.next}while(e!==t);return i},e.EarCut.pointInTriangle=function(t,e,i,s,n,r,o,a){return(n-o)*(e-a)-(t-o)*(r-a)>=0&&(t-o)*(s-a)-(i-o)*(e-a)>=0&&(i-o)*(r-a)-(n-o)*(s-a)>=0},e.EarCut.isValidDiagonal=function(t,i){return e.EarCut.equals(t,i)||t.next.i!==i.i&&t.prev.i!==i.i&&!e.EarCut.intersectsPolygon(t,i)&&e.EarCut.locallyInside(t,i)&&e.EarCut.locallyInside(i,t)&&e.EarCut.middleInside(t,i)},e.EarCut.area=function(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)},e.EarCut.equals=function(t,e){return t.x===e.x&&t.y===e.y},e.EarCut.intersects=function(t,i,s,n){return e.EarCut.area(t,i,s)>0!=e.EarCut.area(t,i,n)>0&&e.EarCut.area(s,n,t)>0!=e.EarCut.area(s,n,i)>0},e.EarCut.intersectsPolygon=function(t,i){var s=t;do{if(s.i!==t.i&&s.next.i!==t.i&&s.i!==i.i&&s.next.i!==i.i&&e.EarCut.intersects(s,s.next,t,i))return!0;s=s.next}while(s!==t);return!1},e.EarCut.locallyInside=function(t,i){return e.EarCut.area(t.prev,t,t.next)<0?e.EarCut.area(t,i,t.next)>=0&&e.EarCut.area(t,t.prev,i)>=0:e.EarCut.area(t,i,t.prev)<0||e.EarCut.area(t,t.next,i)<0},e.EarCut.middleInside=function(t,e){var i=t,s=!1,n=(t.x+e.x)/2,r=(t.y+e.y)/2;do{i.y>r!=i.next.y>r&&n<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(s=!s),i=i.next}while(i!==t);return s},e.EarCut.splitPolygon=function(t,i){var s=new e.EarCut.Node(t.i,t.x,t.y),n=new e.EarCut.Node(i.i,i.x,i.y),r=t.next,o=i.prev;return t.next=i,i.prev=t,s.next=r,r.prev=s,n.next=s,s.prev=n,o.next=n,n.prev=o,n},e.EarCut.insertNode=function(t,i,s,n){var r=new e.EarCut.Node(t,i,s);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r},e.EarCut.removeNode=function(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)},e.EarCut.Node=function(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1},PIXI.WebGLGraphics=function(){},PIXI.WebGLGraphics.stencilBufferLimit=6,PIXI.WebGLGraphics.renderGraphics=function(t,i){var s,n=i.gl,r=i.projection,o=i.offset,a=i.shaderManager.primitiveShader;t.dirty&&PIXI.WebGLGraphics.updateGraphics(t,n);var h=t._webGL[n.id];if(h)for(var l=0;l<h.data.length;l++)1===h.data[l].mode?(s=h.data[l],i.stencilManager.pushStencil(t,s,i),n.drawElements(n.TRIANGLE_FAN,4,n.UNSIGNED_SHORT,2*(s.indices.length-4)),i.stencilManager.popStencil(t,s,i)):(s=h.data[l],i.shaderManager.setShader(a),a=i.shaderManager.primitiveShader,n.uniformMatrix3fv(a.translationMatrix,!1,t.worldTransform.toArray(!0)),n.uniform1f(a.flipY,1),n.uniform2f(a.projectionVector,r.x,-r.y),n.uniform2f(a.offsetVector,-o.x,-o.y),n.uniform3fv(a.tintColor,e.Color.hexToRGBArray(t.tint)),n.uniform1f(a.alpha,t.worldAlpha),n.bindBuffer(n.ARRAY_BUFFER,s.buffer),n.vertexAttribPointer(a.aVertexPosition,2,n.FLOAT,!1,24,0),n.vertexAttribPointer(a.colorAttribute,4,n.FLOAT,!1,24,8),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,s.indexBuffer),n.drawElements(n.TRIANGLE_STRIP,s.indices.length,n.UNSIGNED_SHORT,0))},PIXI.WebGLGraphics.updateGraphics=function(t,i){var s=t._webGL[i.id];s||(s=t._webGL[i.id]={lastIndex:0,data:[],gl:i}),t.dirty=!1;var n;if(t.clearDirty){for(t.clearDirty=!1,n=0;n<s.data.length;n++){var r=s.data[n];r.reset(),PIXI.WebGLGraphics.graphicsDataPool.push(r)}s.data=[],s.lastIndex=0}var o;for(n=s.lastIndex;n<t.graphicsData.length;n++){var a=t.graphicsData[n];a.type===e.POLYGON?(a.points=a.shape.points.slice(),a.shape.closed&&(a.points[0]===a.points[a.points.length-2]&&a.points[1]===a.points[a.points.length-1]||a.points.push(a.points[0],a.points[1])),a.fill&&a.points.length>=PIXI.WebGLGraphics.stencilBufferLimit&&(a.points.length<2*PIXI.WebGLGraphics.stencilBufferLimit?(o=PIXI.WebGLGraphics.switchMode(s,0),PIXI.WebGLGraphics.buildPoly(a,o)||(o=PIXI.WebGLGraphics.switchMode(s,1),PIXI.WebGLGraphics.buildComplexPoly(a,o))):(o=PIXI.WebGLGraphics.switchMode(s,1),PIXI.WebGLGraphics.buildComplexPoly(a,o))),a.lineWidth>0&&(o=PIXI.WebGLGraphics.switchMode(s,0),PIXI.WebGLGraphics.buildLine(a,o))):(o=PIXI.WebGLGraphics.switchMode(s,0),a.type===e.RECTANGLE?PIXI.WebGLGraphics.buildRectangle(a,o):a.type===e.CIRCLE||a.type===e.ELLIPSE?PIXI.WebGLGraphics.buildCircle(a,o):a.type===e.ROUNDEDRECTANGLE&&PIXI.WebGLGraphics.buildRoundedRectangle(a,o)),s.lastIndex++}for(n=0;n<s.data.length;n++)(o=s.data[n]).dirty&&o.upload()},PIXI.WebGLGraphics.switchMode=function(t,e){var i;return t.data.length?(i=t.data[t.data.length-1]).mode===e&&1!==e||((i=PIXI.WebGLGraphics.graphicsDataPool.pop()||new PIXI.WebGLGraphicsData(t.gl)).mode=e,t.data.push(i)):((i=PIXI.WebGLGraphics.graphicsDataPool.pop()||new PIXI.WebGLGraphicsData(t.gl)).mode=e,t.data.push(i)),i.dirty=!0,i},PIXI.WebGLGraphics.buildRectangle=function(t,i){var s=t.shape,n=s.x,r=s.y,o=s.width,a=s.height;if(t.fill){var h=e.Color.hexToRGBArray(t.fillColor),l=t.fillAlpha,c=h[0]*l,u=h[1]*l,d=h[2]*l,p=i.points,f=i.indices,g=p.length/6;p.push(n,r),p.push(c,u,d,l),p.push(n+o,r),p.push(c,u,d,l),p.push(n,r+a),p.push(c,u,d,l),p.push(n+o,r+a),p.push(c,u,d,l),f.push(g,g,g+1,g+2,g+3,g+3)}if(t.lineWidth){var m=t.points;t.points=[n,r,n+o,r,n+o,r+a,n,r+a,n,r],PIXI.WebGLGraphics.buildLine(t,i),t.points=m}},PIXI.WebGLGraphics.buildRoundedRectangle=function(t,i){var s=t.shape,n=s.x,r=s.y,o=s.width,a=s.height,h=s.radius,l=[];if(l.push(n,r+h),l=l.concat(PIXI.WebGLGraphics.quadraticBezierCurve(n,r+a-h,n,r+a,n+h,r+a)),l=l.concat(PIXI.WebGLGraphics.quadraticBezierCurve(n+o-h,r+a,n+o,r+a,n+o,r+a-h)),l=l.concat(PIXI.WebGLGraphics.quadraticBezierCurve(n+o,r+h,n+o,r,n+o-h,r)),l=l.concat(PIXI.WebGLGraphics.quadraticBezierCurve(n+h,r,n,r,n,r+h)),t.fill){var c=e.Color.hexToRGBArray(t.fillColor),u=t.fillAlpha,d=c[0]*u,p=c[1]*u,f=c[2]*u,g=i.points,m=i.indices,y=g.length/6,v=e.EarCut.Triangulate(l,null,2),x=0;for(x=0;x<v.length;x+=3)m.push(v[x]+y),m.push(v[x]+y),m.push(v[x+1]+y),m.push(v[x+2]+y),m.push(v[x+2]+y);for(x=0;x<l.length;x++)g.push(l[x],l[++x],d,p,f,u)}if(t.lineWidth){var b=t.points;t.points=l,PIXI.WebGLGraphics.buildLine(t,i),t.points=b}},PIXI.WebGLGraphics.quadraticBezierCurve=function(t,e,i,s,n,r){function o(t,e,i){return t+(e-t)*i}for(var a,h,l,c,u,d,p=[],f=0,g=0;g<=20;g++)a=o(t,i,f=g/20),h=o(e,s,f),l=o(i,n,f),c=o(s,r,f),u=o(a,l,f),d=o(h,c,f),p.push(u,d);return p},PIXI.WebGLGraphics.buildCircle=function(t,i){var s,n,r=t.shape,o=r.x,a=r.y;t.type===e.CIRCLE?(s=r.radius,n=r.radius):(s=r.width,n=r.height);var h=2*Math.PI/40,l=0;if(t.fill){var c=e.Color.hexToRGBArray(t.fillColor),u=t.fillAlpha,d=c[0]*u,p=c[1]*u,f=c[2]*u,g=i.points,m=i.indices,y=g.length/6;for(m.push(y),l=0;l<41;l++)g.push(o,a,d,p,f,u),g.push(o+Math.sin(h*l)*s,a+Math.cos(h*l)*n,d,p,f,u),m.push(y++,y++);m.push(y-1)}if(t.lineWidth){var v=t.points;for(t.points=[],l=0;l<41;l++)t.points.push(o+Math.sin(h*l)*s,a+Math.cos(h*l)*n);PIXI.WebGLGraphics.buildLine(t,i),t.points=v}},PIXI.WebGLGraphics.buildLine=function(t,i){var s=0,n=t.points;if(0!==n.length){if(t.lineWidth%2)for(s=0;s<n.length;s++)n[s]+=.5;var r=new PIXI.Point(n[0],n[1]),o=new PIXI.Point(n[n.length-2],n[n.length-1]);if(r.x===o.x&&r.y===o.y){(n=n.slice()).pop(),n.pop();var a=(o=new PIXI.Point(n[n.length-2],n[n.length-1])).x+.5*(r.x-o.x),h=o.y+.5*(r.y-o.y);n.unshift(a,h),n.push(a,h)}var l,c,u,d,p,f,g,m,y,v,x,b,_,w,T,P,C,S,A,E,M,R,L=i.points,B=i.indices,I=n.length/2,O=n.length,k=L.length/6,F=t.lineWidth/2,D=e.Color.hexToRGBArray(t.lineColor),U=t.lineAlpha,G=D[0]*U,N=D[1]*U,X=D[2]*U;for(u=n[0],d=n[1],p=n[2],y=-(d-(f=n[3])),v=u-p,y/=R=Math.sqrt(y*y+v*v),v/=R,y*=F,v*=F,L.push(u-y,d-v,G,N,X,U),L.push(u+y,d+v,G,N,X,U),s=1;s<I-1;s++)u=n[2*(s-1)],d=n[2*(s-1)+1],p=n[2*s],f=n[2*s+1],g=n[2*(s+1)],m=n[2*(s+1)+1],y=-(d-f),v=u-p,y/=R=Math.sqrt(y*y+v*v),v/=R,y*=F,v*=F,x=-(f-m),b=p-g,x/=R=Math.sqrt(x*x+b*b),b/=R,C=(-y+u)*(-v+f)-(-y+p)*(-v+d),E=(-(x*=F)+g)*(-(b*=F)+f)-(-x+p)*(-b+m),M=(T=-v+d-(-v+f))*(A=-x+p-(-x+g))-(S=-b+m-(-b+f))*(P=-y+p-(-y+u)),Math.abs(M)<.1?(M+=10.1,L.push(p-y,f-v,G,N,X,U),L.push(p+y,f+v,G,N,X,U)):((l=(P*E-A*C)/M)-p)*(l-p)+((c=(S*C-T*E)/M)-f)+(c-f)>19600?(_=y-x,w=v-b,_/=R=Math.sqrt(_*_+w*w),w/=R,_*=F,w*=F,L.push(p-_,f-w),L.push(G,N,X,U),L.push(p+_,f+w),L.push(G,N,X,U),L.push(p-_,f-w),L.push(G,N,X,U),O++):(L.push(l,c),L.push(G,N,X,U),L.push(p-(l-p),f-(c-f)),L.push(G,N,X,U));for(u=n[2*(I-2)],d=n[2*(I-2)+1],p=n[2*(I-1)],y=-(d-(f=n[2*(I-1)+1])),v=u-p,y/=R=Math.sqrt(y*y+v*v),v/=R,y*=F,v*=F,L.push(p-y,f-v),L.push(G,N,X,U),L.push(p+y,f+v),L.push(G,N,X,U),B.push(k),s=0;s<O;s++)B.push(k++);B.push(k-1)}},PIXI.WebGLGraphics.buildComplexPoly=function(t,i){var s=t.points.slice();if(!(s.length<6)){var n=i.indices;i.points=s,i.alpha=t.fillAlpha,i.color=e.Color.hexToRGBArray(t.fillColor);for(var r,o,a=1/0,h=-1/0,l=1/0,c=-1/0,u=0;u<s.length;u+=2)r=s[u],o=s[u+1],a=r<a?r:a,h=r>h?r:h,l=o<l?o:l,c=o>c?o:c;s.push(a,l,h,l,h,c,a,c);var d=s.length/2;for(u=0;u<d;u++)n.push(u)}},PIXI.WebGLGraphics.buildPoly=function(t,i){var s=t.points;if(!(s.length<6)){var n=i.points,r=i.indices,o=s.length/2,a=e.Color.hexToRGBArray(t.fillColor),h=t.fillAlpha,l=a[0]*h,c=a[1]*h,u=a[2]*h,d=e.EarCut.Triangulate(s,null,2);if(!d)return!1;var p=n.length/6,f=0;for(f=0;f<d.length;f+=3)r.push(d[f]+p),r.push(d[f]+p),r.push(d[f+1]+p),r.push(d[f+2]+p),r.push(d[f+2]+p);for(f=0;f<o;f++)n.push(s[2*f],s[2*f+1],l,c,u,h);return!0}},PIXI.WebGLGraphics.graphicsDataPool=[],PIXI.WebGLGraphicsData=function(t){this.gl=t,this.color=[0,0,0],this.points=[],this.indices=[],this.buffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),this.mode=1,this.alpha=1,this.dirty=!0},PIXI.WebGLGraphicsData.prototype.reset=function(){this.points=[],this.indices=[]},PIXI.WebGLGraphicsData.prototype.upload=function(){var t=this.gl;this.glPoints=new Float32Array(this.points),t.bindBuffer(t.ARRAY_BUFFER,this.buffer),t.bufferData(t.ARRAY_BUFFER,this.glPoints,t.STATIC_DRAW),this.glIndicies=new Uint16Array(this.indices),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.glIndicies,t.STATIC_DRAW),this.dirty=!1},PIXI.CanvasGraphics=function(){},PIXI.CanvasGraphics.renderGraphics=function(t,i){var s=t.worldAlpha;t.dirty&&(this.updateGraphicsTint(t),t.dirty=!1);for(var n=0;n<t.graphicsData.length;n++){var r=t.graphicsData[n],o=r.shape,a=r._fillTint,h=r._lineTint;if(i.lineWidth=r.lineWidth,r.type===e.POLYGON){i.beginPath();var l=o.points;i.moveTo(l[0],l[1]);for(var c=1;c<l.length/2;c++)i.lineTo(l[2*c],l[2*c+1]);o.closed&&i.lineTo(l[0],l[1]),l[0]===l[l.length-2]&&l[1]===l[l.length-1]&&i.closePath(),r.fill&&(i.globalAlpha=r.fillAlpha*s,i.fillStyle="#"+("00000"+(0|a).toString(16)).substr(-6),i.fill()),r.lineWidth&&(i.globalAlpha=r.lineAlpha*s,i.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),i.stroke())}else if(r.type===e.RECTANGLE)(r.fillColor||0===r.fillColor)&&(i.globalAlpha=r.fillAlpha*s,i.fillStyle="#"+("00000"+(0|a).toString(16)).substr(-6),i.fillRect(o.x,o.y,o.width,o.height)),r.lineWidth&&(i.globalAlpha=r.lineAlpha*s,i.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),i.strokeRect(o.x,o.y,o.width,o.height));else if(r.type===e.CIRCLE)i.beginPath(),i.arc(o.x,o.y,o.radius,0,2*Math.PI),i.closePath(),r.fill&&(i.globalAlpha=r.fillAlpha*s,i.fillStyle="#"+("00000"+(0|a).toString(16)).substr(-6),i.fill()),r.lineWidth&&(i.globalAlpha=r.lineAlpha*s,i.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),i.stroke());else if(r.type===e.ELLIPSE){var u=2*o.width,d=2*o.height,p=o.x-u/2,f=o.y-d/2;i.beginPath();var g=u/2*.5522848,m=d/2*.5522848,y=p+u,v=f+d,x=p+u/2,b=f+d/2;i.moveTo(p,b),i.bezierCurveTo(p,b-m,x-g,f,x,f),i.bezierCurveTo(x+g,f,y,b-m,y,b),i.bezierCurveTo(y,b+m,x+g,v,x,v),i.bezierCurveTo(x-g,v,p,b+m,p,b),i.closePath(),r.fill&&(i.globalAlpha=r.fillAlpha*s,i.fillStyle="#"+("00000"+(0|a).toString(16)).substr(-6),i.fill()),r.lineWidth&&(i.globalAlpha=r.lineAlpha*s,i.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),i.stroke())}else if(r.type===e.ROUNDEDRECTANGLE){var _=o.x,w=o.y,T=o.width,P=o.height,C=o.radius,S=Math.min(T,P)/2|0;C=C>S?S:C,i.beginPath(),i.moveTo(_,w+C),i.lineTo(_,w+P-C),i.quadraticCurveTo(_,w+P,_+C,w+P),i.lineTo(_+T-C,w+P),i.quadraticCurveTo(_+T,w+P,_+T,w+P-C),i.lineTo(_+T,w+C),i.quadraticCurveTo(_+T,w,_+T-C,w),i.lineTo(_+C,w),i.quadraticCurveTo(_,w,_,w+C),i.closePath(),(r.fillColor||0===r.fillColor)&&(i.globalAlpha=r.fillAlpha*s,i.fillStyle="#"+("00000"+(0|a).toString(16)).substr(-6),i.fill()),r.lineWidth&&(i.globalAlpha=r.lineAlpha*s,i.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),i.stroke())}}},PIXI.CanvasGraphics.renderGraphicsMask=function(t,i){var s=t.graphicsData.length;if(0!==s){i.beginPath();for(var n=0;n<s;n++){var r=t.graphicsData[n],o=r.shape;if(r.type===e.POLYGON){var a=o.points;i.moveTo(a[0],a[1]);for(var h=1;h<a.length/2;h++)i.lineTo(a[2*h],a[2*h+1]);a[0]===a[a.length-2]&&a[1]===a[a.length-1]&&i.closePath()}else if(r.type===e.RECTANGLE)i.rect(o.x,o.y,o.width,o.height),i.closePath();else if(r.type===e.CIRCLE)i.arc(o.x,o.y,o.radius,0,2*Math.PI),i.closePath();else if(r.type===e.ELLIPSE){var l=2*o.width,c=2*o.height,u=o.x-l/2,d=o.y-c/2,p=l/2*.5522848,f=c/2*.5522848,g=u+l,m=d+c,y=u+l/2,v=d+c/2;i.moveTo(u,v),i.bezierCurveTo(u,v-f,y-p,d,y,d),i.bezierCurveTo(y+p,d,g,v-f,g,v),i.bezierCurveTo(g,v+f,y+p,m,y,m),i.bezierCurveTo(y-p,m,u,v+f,u,v),i.closePath()}else if(r.type===e.ROUNDEDRECTANGLE){var x=o.x,b=o.y,_=o.width,w=o.height,T=o.radius,P=Math.min(_,w)/2|0;T=T>P?P:T,i.moveTo(x,b+T),i.lineTo(x,b+w-T),i.quadraticCurveTo(x,b+w,x+T,b+w),i.lineTo(x+_-T,b+w),i.quadraticCurveTo(x+_,b+w,x+_,b+w-T),i.lineTo(x+_,b+T),i.quadraticCurveTo(x+_,b,x+_-T,b),i.lineTo(x+T,b),i.quadraticCurveTo(x,b,x,b+T),i.closePath()}}}},PIXI.CanvasGraphics.updateGraphicsTint=function(t){if(16777215!==t.tint)for(var e=(t.tint>>16&255)/255,i=(t.tint>>8&255)/255,s=(255&t.tint)/255,n=0;n<t.graphicsData.length;n++){var r=t.graphicsData[n],o=0|r.fillColor,a=0|r.lineColor;r._fillTint=((o>>16&255)/255*e*255<<16)+((o>>8&255)/255*i*255<<8)+(255&o)/255*s*255,r._lineTint=((a>>16&255)/255*e*255<<16)+((a>>8&255)/255*i*255<<8)+(255&a)/255*s*255}},e.GraphicsData=function(t,e,i,s,n,r,o){this.lineWidth=t,this.lineColor=e,this.lineAlpha=i,this._lineTint=e,this.fillColor=s,this.fillAlpha=n,this._fillTint=s,this.fill=r,this.shape=o,this.type=o.type},e.GraphicsData.prototype.constructor=e.GraphicsData,e.GraphicsData.prototype.clone=function(){return new e.GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.fill,this.shape)},e.Graphics=function(t,i,s){void 0===i&&(i=0),void 0===s&&(s=0),this.type=e.GRAPHICS,this.physicsType=e.SPRITE,this.anchor=new e.Point,PIXI.DisplayObjectContainer.call(this),this.renderable=!0,this.fillAlpha=1,this.lineWidth=0,this.lineColor=0,this.graphicsData=[],this.tint=16777215,this.blendMode=PIXI.blendModes.NORMAL,this.currentPath=null,this._webGL=[],this.isMask=!1,this.boundsPadding=0,this._localBounds=new e.Rectangle(0,0,1,1),this.dirty=!0,this._boundsDirty=!1,this.webGLDirty=!1,this.cachedSpriteDirty=!1,e.Component.Core.init.call(this,t,i,s,"",null)},e.Graphics.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),e.Graphics.prototype.constructor=e.Graphics,e.Component.Core.install.call(e.Graphics.prototype,["Angle","AutoCull","Bounds","Destroy","FixedToCamera","InputEnabled","InWorld","LifeSpan","PhysicsBody","Reset"]),e.Graphics.prototype.preUpdatePhysics=e.Component.PhysicsBody.preUpdate,e.Graphics.prototype.preUpdateLifeSpan=e.Component.LifeSpan.preUpdate,e.Graphics.prototype.preUpdateInWorld=e.Component.InWorld.preUpdate,e.Graphics.prototype.preUpdateCore=e.Component.Core.preUpdate,e.Graphics.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},e.Graphics.prototype.postUpdate=function(){e.Component.PhysicsBody.postUpdate.call(this),e.Component.FixedToCamera.postUpdate.call(this),this._boundsDirty&&(this.updateLocalBounds(),this._boundsDirty=!1);for(var t=0;t<this.children.length;t++)this.children[t].postUpdate()},e.Graphics.prototype.destroy=function(t){this.clear(),e.Component.Destroy.prototype.destroy.call(this,t)},e.Graphics.prototype.drawTriangle=function(t,i){void 0===i&&(i=!1);var s=new e.Polygon(t);if(i){var n=new e.Point(this.game.camera.x-t[0].x,this.game.camera.y-t[0].y),r=new e.Point(t[1].x-t[0].x,t[1].y-t[0].y),o=new e.Point(t[1].x-t[2].x,t[1].y-t[2].y).cross(r);n.dot(o)>0&&this.drawPolygon(s)}else this.drawPolygon(s)},e.Graphics.prototype.drawTriangles=function(t,i,s){void 0===s&&(s=!1);var n,r=new e.Point,o=new e.Point,a=new e.Point,h=[];if(i)if(t[0]instanceof e.Point)for(n=0;n<i.length/3;n++)h.push(t[i[3*n]]),h.push(t[i[3*n+1]]),h.push(t[i[3*n+2]]),3===h.length&&(this.drawTriangle(h,s),h=[]);else for(n=0;n<i.length;n++)r.x=t[2*i[n]],r.y=t[2*i[n]+1],h.push(r.copyTo({})),3===h.length&&(this.drawTriangle(h,s),h=[]);else if(t[0]instanceof e.Point)for(n=0;n<t.length/3;n++)this.drawTriangle([t[3*n],t[3*n+1],t[3*n+2]],s);else for(n=0;n<t.length/6;n++)r.x=t[6*n+0],r.y=t[6*n+1],o.x=t[6*n+2],o.y=t[6*n+3],a.x=t[6*n+4],a.y=t[6*n+5],this.drawTriangle([r,o,a],s)},e.Graphics.prototype.lineStyle=function(t,i,s){return this.lineWidth=t||0,this.lineColor=i||0,this.lineAlpha=void 0===s?1:s,this.currentPath&&(this.currentPath.shape.points.length?this.drawShape(new e.Polygon(this.currentPath.shape.points.slice(-2))):(this.currentPath.lineWidth=this.lineWidth,this.currentPath.lineColor=this.lineColor,this.currentPath.lineAlpha=this.lineAlpha)),this},e.Graphics.prototype.moveTo=function(t,i){return this.drawShape(new e.Polygon([t,i])),this},e.Graphics.prototype.lineTo=function(t,e){return this.currentPath||this.moveTo(0,0),this.currentPath.shape.points.push(t,e),this.dirty=!0,this._boundsDirty=!0,this},e.Graphics.prototype.quadraticCurveTo=function(t,e,i,s){this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);var n,r,o=this.currentPath.shape.points;0===o.length&&this.moveTo(0,0);for(var a=o[o.length-2],h=o[o.length-1],l=0,c=1;c<=20;++c)n=a+(t-a)*(l=c/20),r=h+(e-h)*l,o.push(n+(t+(i-t)*l-n)*l,r+(e+(s-e)*l-r)*l);return this.dirty=!0,this._boundsDirty=!0,this},e.Graphics.prototype.bezierCurveTo=function(t,e,i,s,n,r){this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);for(var o,a,h,l,c,u=this.currentPath.shape.points,d=u[u.length-2],p=u[u.length-1],f=0,g=1;g<=20;++g)h=(a=(o=1-(f=g/20))*o)*o,c=(l=f*f)*f,u.push(h*d+3*a*f*t+3*o*l*i+c*n,h*p+3*a*f*e+3*o*l*s+c*r);return this.dirty=!0,this._boundsDirty=!0,this},e.Graphics.prototype.arcTo=function(t,e,i,s,n){this.currentPath?0===this.currentPath.shape.points.length&&this.currentPath.shape.points.push(t,e):this.moveTo(t,e);var r=this.currentPath.shape.points,o=r[r.length-2],a=r[r.length-1]-e,h=o-t,l=s-e,c=i-t,u=Math.abs(a*c-h*l);if(u<1e-8||0===n)r[r.length-2]===t&&r[r.length-1]===e||r.push(t,e);else{var d=a*a+h*h,p=l*l+c*c,f=a*l+h*c,g=n*Math.sqrt(d)/u,m=n*Math.sqrt(p)/u,y=g*f/d,v=m*f/p,x=g*c+m*h,b=g*l+m*a,_=h*(m+y),w=a*(m+y),T=c*(g+v),P=l*(g+v),C=Math.atan2(w-b,_-x),S=Math.atan2(P-b,T-x);this.arc(x+t,b+e,n,C,S,h*l>c*a)}return this.dirty=!0,this._boundsDirty=!0,this},e.Graphics.prototype.arc=function(t,e,i,s,n,r,o){if(s===n)return this;void 0===r&&(r=!1),void 0===o&&(o=40),!r&&n<=s?n+=2*Math.PI:r&&s<=n&&(s+=2*Math.PI);var a=r?-1*(s-n):n-s,h=Math.ceil(Math.abs(a)/(2*Math.PI))*o;if(0===a)return this;var l=t+Math.cos(s)*i,c=e+Math.sin(s)*i;r&&this.filling?this.moveTo(t,e):this.moveTo(l,c);for(var u=this.currentPath.shape.points,d=a/(2*h),p=2*d,f=Math.cos(d),g=Math.sin(d),m=h-1,y=m%1/m,v=0;v<=m;v++){var x=d+s+p*(v+y*v),b=Math.cos(x),_=-Math.sin(x);u.push((f*b+g*_)*i+t,(f*-_+g*b)*i+e)}return this.dirty=!0,this._boundsDirty=!0,this},e.Graphics.prototype.beginFill=function(t,e){return this.filling=!0,this.fillColor=t||0,this.fillAlpha=void 0===e?1:e,this.currentPath&&this.currentPath.shape.points.length<=2&&(this.currentPath.fill=this.filling,this.currentPath.fillColor=this.fillColor,this.currentPath.fillAlpha=this.fillAlpha),this},e.Graphics.prototype.endFill=function(){return this.filling=!1,this.fillColor=null,this.fillAlpha=1,this},e.Graphics.prototype.drawRect=function(t,i,s,n){return this.drawShape(new e.Rectangle(t,i,s,n)),this},e.Graphics.prototype.drawRoundedRect=function(t,i,s,n,r){return this.drawShape(new e.RoundedRectangle(t,i,s,n,r)),this},e.Graphics.prototype.drawCircle=function(t,i,s){return this.drawShape(new e.Circle(t,i,s)),this},e.Graphics.prototype.drawEllipse=function(t,i,s,n){return this.drawShape({x:t,y:i,width:s,height:n,type:e.ELLIPSE}),this},e.Graphics.prototype.drawPolygon=function(t){t instanceof e.Polygon&&(t=t.points);var i=t;if(!Array.isArray(i)){i=new Array(arguments.length);for(var s=0;s<i.length;++s)i[s]=arguments[s]}return this.drawShape(new e.Polygon(i)),this},e.Graphics.prototype.clear=function(){return this.lineWidth=0,this.filling=!1,this.dirty=!0,this._boundsDirty=!0,this.clearDirty=!0,this.graphicsData=[],this.updateLocalBounds(),this},e.Graphics.prototype.generateTexture=function(t,e,i){void 0===t&&(t=1),void 0===e&&(e=PIXI.scaleModes.DEFAULT),void 0===i&&(i=0);var s=this.getBounds();s.width+=i,s.height+=i;var n=new PIXI.CanvasBuffer(s.width*t,s.height*t),r=PIXI.Texture.fromCanvas(n.canvas,e);return r.baseTexture.resolution=t,n.context.scale(t,t),n.context.translate(-s.x,-s.y),PIXI.CanvasGraphics.renderGraphics(this,n.context),r},e.Graphics.prototype._renderWebGL=function(t){if(!1!==this.visible&&0!==this.alpha&&!0!==this.isMask){if(this._cacheAsBitmap)return(this.dirty||this.cachedSpriteDirty)&&(this._generateCachedSprite(),this.updateCachedSpriteTexture(),this.cachedSpriteDirty=!1,this.dirty=!1),this._cachedSprite.worldAlpha=this.worldAlpha,void PIXI.Sprite.prototype._renderWebGL.call(this._cachedSprite,t);if(t.spriteBatch.stop(),t.blendModeManager.setBlendMode(this.blendMode),this._mask&&t.maskManager.pushMask(this._mask,t),this._filters&&t.filterManager.pushFilter(this._filterBlock),this.blendMode!==t.spriteBatch.currentBlendMode){t.spriteBatch.currentBlendMode=this.blendMode;var e=PIXI.blendModesWebGL[t.spriteBatch.currentBlendMode];t.spriteBatch.gl.blendFunc(e[0],e[1])}if(this.webGLDirty&&(this.dirty=!0,this.webGLDirty=!1),PIXI.WebGLGraphics.renderGraphics(this,t),this.children.length){t.spriteBatch.start();for(var i=0;i<this.children.length;i++)this.children[i]._renderWebGL(t);t.spriteBatch.stop()}this._filters&&t.filterManager.popFilter(),this._mask&&t.maskManager.popMask(this.mask,t),t.drawCount++,t.spriteBatch.start()}},e.Graphics.prototype._renderCanvas=function(t){if(!1!==this.visible&&0!==this.alpha&&!0!==this.isMask){if(this._prevTint!==this.tint&&(this.dirty=!0,this._prevTint=this.tint),this._cacheAsBitmap)return(this.dirty||this.cachedSpriteDirty)&&(this._generateCachedSprite(),this.updateCachedSpriteTexture(),this.cachedSpriteDirty=!1,this.dirty=!1),this._cachedSprite.alpha=this.alpha,void PIXI.Sprite.prototype._renderCanvas.call(this._cachedSprite,t);var e=t.context,i=this.worldTransform;this.blendMode!==t.currentBlendMode&&(t.currentBlendMode=this.blendMode,e.globalCompositeOperation=PIXI.blendModesCanvas[t.currentBlendMode]),this._mask&&t.maskManager.pushMask(this._mask,t);var s=t.resolution,n=i.tx*t.resolution+t.shakeX,r=i.ty*t.resolution+t.shakeY;e.setTransform(i.a*s,i.b*s,i.c*s,i.d*s,n,r),PIXI.CanvasGraphics.renderGraphics(this,e);for(var o=0;o<this.children.length;o++)this.children[o]._renderCanvas(t);this._mask&&t.maskManager.popMask(t)}},e.Graphics.prototype.getBounds=function(t){if(this._currentBounds)return this._currentBounds;if(this.isMask)return e.EmptyRectangle;this.dirty&&(this.updateLocalBounds(),this.webGLDirty=!0,this.cachedSpriteDirty=!0,this.dirty=!1);var i=this._localBounds,s=i.x,n=i.width+i.x,r=i.y,o=i.height+i.y,a=t||this.worldTransform,h=a.a,l=a.b,c=a.c,u=a.d,d=a.tx,p=a.ty,f=h*n+c*o+d,g=u*o+l*n+p,m=h*s+c*o+d,y=u*o+l*s+p,v=h*s+c*r+d,x=u*r+l*s+p,b=h*n+c*r+d,_=u*r+l*n+p,w=f,T=g,P=f,C=g;return P=m<P?m:P,P=v<P?v:P,P=b<P?b:P,C=y<C?y:C,C=x<C?x:C,C=_<C?_:C,w=m>w?m:w,w=v>w?v:w,w=b>w?b:w,T=y>T?y:T,T=x>T?x:T,T=_>T?_:T,this._bounds.x=P,this._bounds.width=w-P,this._bounds.y=C,this._bounds.height=T-C,this._currentBounds=this._bounds,this._currentBounds},e.Graphics.prototype.getLocalBounds=function(){var t=this.worldTransform;this.worldTransform=e.identityMatrix;for(var i=0;i<this.children.length;i++)this.children[i].updateTransform();var s=this.getBounds();for(this.worldTransform=t,i=0;i<this.children.length;i++)this.children[i].updateTransform();return s},e.Graphics.prototype.containsPoint=function(t,i){void 0===i&&(i=new e.Point),this.worldTransform.applyInverse(t,i);for(var s=this.graphicsData,n=0;n<s.length;n++){var r=s[n];if(r.fill&&(r.shape&&r.shape.contains(i.x,i.y)))return!0}return!1},e.Graphics.prototype.getVisualBounds=function(t){return this._boundsDirty&&(this.updateLocalBounds(),this._boundsDirty=!1),this._localBounds.clone(t)},e.Graphics.prototype.updateLocalBounds=function(){var t=1/0,i=-1/0,s=1/0,n=-1/0;if(this.graphicsData.length)for(var r,o,a,h,l,c,u=0;u<this.graphicsData.length;u++){var d=this.graphicsData[u],p=d.type,f=d.lineWidth;if(r=d.shape,p===e.RECTANGLE||p===e.ROUNDEDRECTANGLE)a=r.x-f/2,h=r.y-f/2,l=r.width+f,c=r.height+f,t=a<t?a:t,i=a+l>i?a+l:i,s=h<s?h:s,n=h+c>n?h+c:n;else if(p===e.CIRCLE)a=r.x,h=r.y,l=r.radius+f/2,c=r.radius+f/2,t=a-l<t?a-l:t,i=a+l>i?a+l:i,s=h-c<s?h-c:s,n=h+c>n?h+c:n;else if(p===e.ELLIPSE)a=r.x,h=r.y,l=r.width+f/2,c=r.height+f/2,t=a-l<t?a-l:t,i=a+l>i?a+l:i,s=h-c<s?h-c:s,n=h+c>n?h+c:n;else{o=r.points;for(var g=0;g<o.length;g++)o[g]instanceof e.Point?(a=o[g].x,h=o[g].y):(a=o[g],h=o[g+1],g<o.length-1&&g++),t=a-f<t?a-f:t,i=a+f>i?a+f:i,s=h-f<s?h-f:s,n=h+f>n?h+f:n}}else t=0,i=0,s=0,n=0;var m=this.boundsPadding;this._localBounds.x=t-m,this._localBounds.width=i-t+2*m,this._localBounds.y=s-m,this._localBounds.height=n-s+2*m},e.Graphics.prototype._generateCachedSprite=function(){var t=this.getLocalBounds();if(this._cachedSprite)this._cachedSprite.buffer.resize(t.width,t.height);else{var e=new PIXI.CanvasBuffer(t.width,t.height),i=PIXI.Texture.fromCanvas(e.canvas);this._cachedSprite=new PIXI.Sprite(i),this._cachedSprite.buffer=e,this._cachedSprite.worldTransform=this.worldTransform}this._cachedSprite.anchor.x=-t.x/t.width,this._cachedSprite.anchor.y=-t.y/t.height,this._cachedSprite.buffer.context.translate(-t.x,-t.y),this.worldAlpha=1,PIXI.CanvasGraphics.renderGraphics(this,this._cachedSprite.buffer.context),this._cachedSprite.alpha=this.alpha},e.Graphics.prototype.updateCachedSpriteTexture=function(){var t=this._cachedSprite,e=t.texture,i=t.buffer.canvas;e.baseTexture.width=i.width,e.baseTexture.height=i.height,e.crop.width=e.frame.width=i.width,e.crop.height=e.frame.height=i.height,t._width=i.width,t._height=i.height,e.baseTexture.dirty()},e.Graphics.prototype.destroyCachedSprite=function(){this._cachedSprite.texture.destroy(!0),this._cachedSprite=null},e.Graphics.prototype.drawShape=function(t){this.currentPath&&this.currentPath.shape.points.length<=2&&this.graphicsData.pop(),this.currentPath=null,t instanceof e.Polygon&&(t=t.clone()).flatten();var i=new e.GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.filling,t);return this.graphicsData.push(i),i.type===e.POLYGON&&(i.shape.closed=this.filling,this.currentPath=i),this.dirty=!0,this._boundsDirty=!0,i},Object.defineProperty(e.Graphics.prototype,"cacheAsBitmap",{get:function(){return this._cacheAsBitmap},set:function(t){this._cacheAsBitmap=t,this._cacheAsBitmap?this._generateCachedSprite():this.destroyCachedSprite(),this.dirty=!0,this.webGLDirty=!0}}),e.RenderTexture=function(t,i,s,n,r,o,a,h){if(void 0===i&&(i=100),void 0===s&&(s=100),void 0===n&&(n=""),void 0===r&&(r=e.scaleModes.DEFAULT),void 0===o&&(o=1),void 0===a&&(a=PIXI.defaultRenderer),void 0===h&&(h=0),this.game=t,this.key=n,this.type=e.RENDERTEXTURE,this._tempMatrix=new e.Matrix,this.width=i,this.height=s,this.resolution=o,this.frame=new e.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution),this.crop=this.frame.clone(),this.baseTexture=new PIXI.BaseTexture,this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution,this.baseTexture._glTextures=[],this.baseTexture.resolution=this.resolution,this.baseTexture.scaleMode=r,this.baseTexture.hasLoaded=!0,PIXI.Texture.call(this,this.baseTexture,this.frame.clone()),this.renderer=a,this.renderer.type===e.WEBGL){var l=this.renderer.gl;this.baseTexture.textureIndex=h,this.baseTexture._dirty[l.id]=!1,this.textureBuffer=new PIXI.FilterTexture(l,this.width,this.height,this.baseTexture.scaleMode,h),this.baseTexture._glTextures[l.id]=this.textureBuffer.texture,this.projection=new e.Point(.5*this.width,.5*-this.height)}else this.textureBuffer=new PIXI.CanvasBuffer(this.width*this.resolution,this.height*this.resolution),this.baseTexture.source=this.textureBuffer.canvas;this.valid=!0,this.tempMatrix=new e.Matrix,this._updateUvs()},e.RenderTexture.prototype=Object.create(PIXI.Texture.prototype),e.RenderTexture.prototype.constructor=e.RenderTexture,e.RenderTexture.prototype.renderXY=function(t,i,s,n){t.updateTransform(),this._tempMatrix.copyFrom(t.worldTransform),this._tempMatrix.tx=i,this._tempMatrix.ty=s,this.renderer.type===e.WEBGL?this._renderWebGL(t,this._tempMatrix,n):this._renderCanvas(t,this._tempMatrix,n)},e.RenderTexture.prototype.renderRawXY=function(t,i,s,n){this._tempMatrix.identity().translate(i,s),this.renderer.type===e.WEBGL?this._renderWebGL(t,this._tempMatrix,n):this._renderCanvas(t,this._tempMatrix,n)},e.RenderTexture.prototype.render=function(t,i,s){void 0===i||null===i?this._tempMatrix.copyFrom(t.worldTransform):this._tempMatrix.copyFrom(i),this.renderer.type===e.WEBGL?this._renderWebGL(t,this._tempMatrix,s):this._renderCanvas(t,this._tempMatrix,s)},e.RenderTexture.prototype.resize=function(t,i,s){t===this.width&&i===this.height||(this.valid=t>0&&i>0,this.width=t,this.height=i,this.frame.width=this.crop.width=t*this.resolution,this.frame.height=this.crop.height=i*this.resolution,s&&(this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution),this.renderer.type===e.WEBGL&&(this.projection.x=this.width/2,this.projection.y=-this.height/2),this.valid&&this.textureBuffer.resize(this.width,this.height))},e.RenderTexture.prototype.clear=function(){this.valid&&(this.renderer.type===e.WEBGL&&this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER,this.textureBuffer.frameBuffer),this.textureBuffer.clear())},e.RenderTexture.prototype._renderWebGL=function(t,e,i){if(this.valid&&0!==t.alpha){var s=t.worldTransform;s.identity(),s.translate(0,2*this.projection.y),e&&s.append(e),s.scale(1,-1);for(var n=0;n<t.children.length;n++)t.children[n].updateTransform();var r=this.renderer.gl;r.viewport(0,0,this.width*this.resolution,this.height*this.resolution),r.bindFramebuffer(r.FRAMEBUFFER,this.textureBuffer.frameBuffer),i&&this.textureBuffer.clear(),this.renderer.spriteBatch.dirty=!0,this.renderer.renderDisplayObject(t,this.projection,this.textureBuffer.frameBuffer,e),this.renderer.spriteBatch.dirty=!0,r.bindFramebuffer(r.FRAMEBUFFER,null)}},e.RenderTexture.prototype._renderCanvas=function(t,e,i){if(this.valid&&0!==t.alpha){var s=t.worldTransform;s.identity(),e&&s.append(e);for(var n=0;n<t.children.length;n++)t.children[n].updateTransform();i&&this.textureBuffer.clear();var r=this.renderer.resolution;this.renderer.resolution=this.resolution,this.renderer.renderDisplayObject(t,this.textureBuffer.context,e),this.renderer.resolution=r}},e.RenderTexture.prototype.getImage=function(){var t=new Image;return t.src=this.getBase64(),t},e.RenderTexture.prototype.getBase64=function(){return this.getCanvas().toDataURL()},e.RenderTexture.prototype.getCanvas=function(){if(this.renderer.type===e.WEBGL){var t=this.renderer.gl,i=this.textureBuffer.width,s=this.textureBuffer.height,n=new Uint8Array(4*i*s);t.bindFramebuffer(t.FRAMEBUFFER,this.textureBuffer.frameBuffer),t.readPixels(0,0,i,s,t.RGBA,t.UNSIGNED_BYTE,n),t.bindFramebuffer(t.FRAMEBUFFER,null);var r=new PIXI.CanvasBuffer(i,s),o=r.context.getImageData(0,0,i,s);return o.data.set(n),r.context.putImageData(o,0,0),r.canvas}return this.textureBuffer.canvas},e.Text=function(t,i,s,n,r){i=i||0,s=s||0,n=void 0===n||null===n?"":n.toString(),this.canvas=e.CanvasPool.create(this),e.Sprite.call(this,t,i,s,PIXI.Texture.fromCanvas(this.canvas)),this.type=e.TEXT,this.physicsType=e.SPRITE,this.padding=new e.Point,this.textBounds=null,this.context=this.canvas.getContext("2d"),this.colors=[],this.strokeColors=[],this.fontStyles=[],this.fontWeights=[],this.autoRound=!1,this.useAdvancedWrap=!1,this.splitRegExp=/(?:\r\n|\r|\n)/,this.characterLimitSize=-1,this.characterLimitSuffix="",this._testString="|MÉq",this._res=t.renderer.resolution,this._text=n,this._fontComponents=null,this._lineSpacing=0,this._charCount=0,this._width=0,this._height=0,this.style={},this.setStyle(r||{}),""!==n&&this.updateText()},e.Text.prototype=Object.create(e.Sprite.prototype),e.Text.prototype.constructor=e.Text,e.Text.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},e.Text.prototype.update=function(){},e.Text.prototype.destroy=function(t){this.texture.destroy(!0),e.Component.Destroy.prototype.destroy.call(this,t)},e.Text.prototype.setShadow=function(t,e,i,s,n,r){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i="rgba(0, 0, 0, 1)"),void 0===s&&(s=0),void 0===n&&(n=!0),void 0===r&&(r=!0),this.style.shadowOffsetX=t,this.style.shadowOffsetY=e,this.style.shadowColor=i,this.style.shadowBlur=s,this.style.shadowStroke=n,this.style.shadowFill=r,this.dirty=!0,this},e.Text.prototype.setStyle=function(t,e){void 0===e&&(e=!1);var i=Object.assign({},t);i.font=t.font||"bold 20pt Arial",i.backgroundColor=t.backgroundColor||null,i.fill=t.fill||"black",i.align=(t.align||"left").toLowerCase(),i.boundsAlignH=(t.boundsAlignH||"left").toLowerCase(),i.boundsAlignV=(t.boundsAlignV||"top").toLowerCase(),i.stroke=t.stroke||"black",i.strokeThickness=Number(t.strokeThickness)||0,i.wordWrap=t.wordWrap||!1,i.wordWrapWidth=t.wordWrapWidth||100,i.maxLines=t.maxLines||0,i.shadowOffsetX=t.shadowOffsetX||0,i.shadowOffsetY=t.shadowOffsetY||0,i.shadowColor=t.shadowColor||"rgba(0,0,0,0)",i.shadowBlur=t.shadowBlur||0,i.tabs=t.tabs||0;var s=this.fontToComponents(i.font);return i.fontStyle&&(s.fontStyle=i.fontStyle),i.fontVariant&&(s.fontVariant=i.fontVariant),i.fontWeight&&(s.fontWeight=i.fontWeight),i.fontSize&&("number"==typeof i.fontSize&&(i.fontSize=i.fontSize+"px"),s.fontSize=i.fontSize),this._fontComponents=s,i.font=this.componentsToFont(this._fontComponents),this.style=i,this.dirty=!0,e&&this.updateText(),this},e.Text.prototype.updateText=function(){this.texture.baseTexture.resolution=this._res,this.context.font=this.style.font;var t=this.text;this.characterLimitSize>-1&&this.characterLimitSize<t.length&&(t=this.text.substring(0,this.characterLimitSize)+this.characterLimitSuffix),this.style.wordWrap&&(t=this.runWordWrap(this.text));var e=t.split(this.splitRegExp),i=this.style.tabs,s=[],n=0,r=this.determineFontProperties(this.style.font),o=e.length;this.style.maxLines>0&&this.style.maxLines<e.length&&(o=this.style.maxLines),this._charCount=0;for(var a=0;a<o;a++){if(0===i){l=this.style.strokeThickness+this.padding.x;this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?l+=this.measureLine(e[a]):l+=this.context.measureText(e[a]).width,this.style.wordWrap&&(l-=this.context.measureText(" ").width)}else{var h=e[a].split(/(?:\t)/),l=this.padding.x+this.style.strokeThickness;if(Array.isArray(i))for(var c=0,u=0;u<h.length;u++){var d=0;d=this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?this.measureLine(h[u]):Math.ceil(this.context.measureText(h[u]).width),u>0&&(c+=i[u-1]),l=c+d}else for(u=0;u<h.length;u++)this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?l+=this.measureLine(h[u]):l+=Math.ceil(this.context.measureText(h[u]).width),l+=this.game.math.snapToCeil(l,i)-l}s[a]=Math.ceil(l),n=Math.max(n,s[a])}this.canvas.width=n*this._res;var p=r.fontSize+this.style.strokeThickness+this.padding.y,f=p*o,g=this._lineSpacing;g<0&&Math.abs(g)>p&&(g=-p),0!==g&&(f+=g>0?g*e.length:g*(e.length-1)),this.canvas.height=f*this._res,this.context.scale(this._res,this._res),navigator.isCocoonJS&&this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.style.backgroundColor&&(this.context.fillStyle=this.style.backgroundColor,this.context.fillRect(0,0,this.canvas.width,this.canvas.height)),this.context.fillStyle=this.style.fill,this.context.font=this.style.font,this.context.strokeStyle=this.style.stroke,this.context.textBaseline="alphabetic",this.context.lineWidth=this.style.strokeThickness,this.context.lineCap="round",this.context.lineJoin="round";var m,y;for(this._charCount=0,a=0;a<o;a++)m=this.style.strokeThickness/2,y=this.style.strokeThickness/2+a*p+r.ascent,a>0&&(y+=g*a),"right"===this.style.align?m+=n-s[a]:"center"===this.style.align&&(m+=(n-s[a])/2),this.autoRound&&(m=Math.round(m),y=Math.round(y)),this.colors.length>0||this.strokeColors.length>0||this.fontWeights.length>0||this.fontStyles.length>0?this.updateLine(e[a],m,y):(this.style.stroke&&this.style.strokeThickness&&(this.updateShadow(this.style.shadowStroke),0===i?this.context.strokeText(e[a],m,y):this.renderTabLine(e[a],m,y,!1)),this.style.fill&&(this.updateShadow(this.style.shadowFill),0===i?this.context.fillText(e[a],m,y):this.renderTabLine(e[a],m,y,!0)));this.updateTexture(),this.dirty=!1},e.Text.prototype.renderTabLine=function(t,e,i,s){var n=t.split(/(?:\t)/),r=this.style.tabs,o=0;if(Array.isArray(r))for(var a=0,h=0;h<n.length;h++)h>0&&(a+=r[h-1]),o=e+a,s?this.context.fillText(n[h],o,i):this.context.strokeText(n[h],o,i);else for(h=0;h<n.length;h++){var l=Math.ceil(this.context.measureText(n[h]).width);o=this.game.math.snapToCeil(e,r),s?this.context.fillText(n[h],o,i):this.context.strokeText(n[h],o,i),e=o+l}},e.Text.prototype.updateShadow=function(t){t?(this.context.shadowOffsetX=this.style.shadowOffsetX,this.context.shadowOffsetY=this.style.shadowOffsetY,this.context.shadowColor=this.style.shadowColor,this.context.shadowBlur=this.style.shadowBlur):(this.context.shadowOffsetX=0,this.context.shadowOffsetY=0,this.context.shadowColor=0,this.context.shadowBlur=0)},e.Text.prototype.measureLine=function(t){for(var e=0,i=0;i<t.length;i++){var s=t[i];if(this.fontWeights.length>0||this.fontStyles.length>0){var n=this.fontToComponents(this.context.font);this.fontStyles[this._charCount]&&(n.fontStyle=this.fontStyles[this._charCount]),this.fontWeights[this._charCount]&&(n.fontWeight=this.fontWeights[this._charCount]),this.context.font=this.componentsToFont(n)}this.style.stroke&&this.style.strokeThickness&&(this.strokeColors[this._charCount]&&(this.context.strokeStyle=this.strokeColors[this._charCount]),this.updateShadow(this.style.shadowStroke)),this.style.fill&&(this.colors[this._charCount]&&(this.context.fillStyle=this.colors[this._charCount]),this.updateShadow(this.style.shadowFill)),e+=this.context.measureText(s).width,this._charCount++}return Math.ceil(e)},e.Text.prototype.updateLine=function(t,e,i){for(var s=0;s<t.length;s++){var n=t[s];if(this.fontWeights.length>0||this.fontStyles.length>0){var r=this.fontToComponents(this.context.font);this.fontStyles[this._charCount]&&(r.fontStyle=this.fontStyles[this._charCount]),this.fontWeights[this._charCount]&&(r.fontWeight=this.fontWeights[this._charCount]),this.context.font=this.componentsToFont(r)}this.style.stroke&&this.style.strokeThickness&&(this.strokeColors[this._charCount]&&(this.context.strokeStyle=this.strokeColors[this._charCount]),this.updateShadow(this.style.shadowStroke),this.context.strokeText(n,e,i)),this.style.fill&&(this.colors[this._charCount]&&(this.context.fillStyle=this.colors[this._charCount]),this.updateShadow(this.style.shadowFill),this.context.fillText(n,e,i)),e+=this.context.measureText(n).width,this._charCount++}},e.Text.prototype.clearColors=function(){return this.colors=[],this.strokeColors=[],this.dirty=!0,this},e.Text.prototype.clearFontValues=function(){return this.fontStyles=[],this.fontWeights=[],this.dirty=!0,this},e.Text.prototype.addColor=function(t,e){return this.colors[e]=t,this.dirty=!0,this},e.Text.prototype.addStrokeColor=function(t,e){return this.strokeColors[e]=t,this.dirty=!0,this},e.Text.prototype.addFontStyle=function(t,e){return this.fontStyles[e]=t,this.dirty=!0,this},e.Text.prototype.addFontWeight=function(t,e){return this.fontWeights[e]=t,this.dirty=!0,this},e.Text.prototype.precalculateWordWrap=function(t){return this.texture.baseTexture.resolution=this._res,this.context.font=this.style.font,this.runWordWrap(t).split(/(?:\r\n|\r|\n)/)},e.Text.prototype.runWordWrap=function(t){return this.useAdvancedWrap?this.advancedWordWrap(t):this.basicWordWrap(t)},e.Text.prototype.advancedWordWrap=function(t){for(var e=this.context,i=this.style.wordWrapWidth,s="",n=t.replace(/ +/gi," ").split(/\r?\n/gi),r=n.length,o=0;o<r;o++){var a=n[o],h="";if(a=a.replace(/^ *|\s*$/gi,""),e.measureText(a).width<i)s+=a+"\n";else{for(var l=i,c=a.split(" "),u=0;u<c.length;u++){var d=c[u],p=d+" ",f=e.measureText(p).width;if(f>l){if(0===u){for(var g=p;g.length&&(g=g.slice(0,-1),!((f=e.measureText(g).width)<=l)););if(!g.length)throw new Error("This text's wordWrapWidth setting is less than a single character!");var m=d.substr(g.length);c[u]=m,h+=g}var y=c[u].length?u:u+1,v=c.slice(y).join(" ").replace(/[ \n]*$/gi,"");n[o+1]=v+" "+(n[o+1]||""),r=n.length;break}h+=p,l-=f}s+=h.replace(/[ \n]*$/gi,"")+"\n"}}return s=s.replace(/[\s|\n]*$/gi,"")},e.Text.prototype.basicWordWrap=function(t){for(var e="",i=t.split("\n"),s=0;s<i.length;s++){for(var n=this.style.wordWrapWidth,r=i[s].split(" "),o=0;o<r.length;o++){var a=this.context.measureText(r[o]).width,h=a+this.context.measureText(" ").width;h>n?(o>0&&(e+="\n"),e+=r[o]+" ",n=this.style.wordWrapWidth-a):(n-=h,e+=r[o]+" ")}s<i.length-1&&(e+="\n")}return e},e.Text.prototype.updateFont=function(t){var e=this.componentsToFont(t);this.style.font!==e&&(this.style.font=e,this.dirty=!0,this.parent&&this.updateTransform())},e.Text.prototype.fontToComponents=function(t){var e=t.match(/^\s*(?:\b(normal|italic|oblique|inherit)?\b)\s*(?:\b(normal|small-caps|inherit)?\b)\s*(?:\b(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit)?\b)\s*(?:\b(xx-small|x-small|small|medium|large|x-large|xx-large|larger|smaller|0|\d*(?:[.]\d*)?(?:%|[a-z]{2,5}))?\b)\s*(.*)\s*$/);if(e){var i=e[5].trim();return/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(i)||/['",]/.exec(i)||(i="'"+i+"'"),{font:t,fontStyle:e[1]||"normal",fontVariant:e[2]||"normal",fontWeight:e[3]||"normal",fontSize:e[4]||"medium",fontFamily:i}}return console.warn("Phaser.Text - unparsable CSS font: "+t),{font:t}},e.Text.prototype.componentsToFont=function(t){var e,i=[];return(e=t.fontStyle)&&"normal"!==e&&i.push(e),(e=t.fontVariant)&&"normal"!==e&&i.push(e),(e=t.fontWeight)&&"normal"!==e&&i.push(e),(e=t.fontSize)&&"medium"!==e&&i.push(e),(e=t.fontFamily)&&i.push(e),i.length||i.push(t.font),i.join(" ")},e.Text.prototype.setText=function(t,e){return void 0===e&&(e=!1),(t=t.toString()||"")===this._text?this:(this.text=t,e?this.updateText():this.dirty=!0,this)},e.Text.prototype.parseList=function(t){if(!Array.isArray(t))return this;for(var e="",i=0;i<t.length;i++)Array.isArray(t[i])?(e+=t[i].join("\t"),i<t.length-1&&(e+="\n")):(e+=t[i],i<t.length-1&&(e+="\t"));return this.text=e,this.dirty=!0,this},e.Text.prototype.setTextBounds=function(t,i,s,n){return void 0===t?this.textBounds=null:(this.textBounds?this.textBounds.setTo(t,i,s,n):this.textBounds=new e.Rectangle(t,i,s,n),this.style.wordWrapWidth>s&&(this.style.wordWrapWidth=s)),this.updateTexture(),this},e.Text.prototype.updateTexture=function(){var t=this.texture.baseTexture,e=this.texture.crop,i=this.texture.frame,s=this.canvas.width,n=this.canvas.height;if(t.width=s,t.height=n,e.width=s,e.height=n,i.width=s,i.height=n,this.texture.width=s,this.texture.height=n,this._width=s,this._height=n,this.textBounds){var r=this.textBounds.x,o=this.textBounds.y;"right"===this.style.boundsAlignH?r+=this.textBounds.width-this.canvas.width/this.resolution:"center"===this.style.boundsAlignH&&(r+=this.textBounds.halfWidth-this.canvas.width/this.resolution/2),"bottom"===this.style.boundsAlignV?o+=this.textBounds.height-this.canvas.height/this.resolution:"middle"===this.style.boundsAlignV&&(o+=this.textBounds.halfHeight-this.canvas.height/this.resolution/2),this.pivot.x=-r,this.pivot.y=-o}this.renderable=0!==s&&0!==n,this.texture.requiresReTint=!0,this.texture.baseTexture.dirty()},e.Text.prototype._renderWebGL=function(t){this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype._renderWebGL.call(this,t)},e.Text.prototype._renderCanvas=function(t){this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype._renderCanvas.call(this,t)},e.Text.prototype.determineFontProperties=function(t){var i=e.Text.fontPropertiesCache[t],s=this.testString||"|MÉq";if(!i){i={};var n=e.Text.fontPropertiesCanvas,r=e.Text.fontPropertiesContext;r.font=t;var o=Math.ceil(r.measureText(s).width),a=Math.ceil(r.measureText(s).width),h=2*a;if(a=1.4*a|0,n.width=o,n.height=h,r.fillStyle="#f00",r.fillRect(0,0,o,h),r.font=t,r.textBaseline="alphabetic",r.fillStyle="#000",r.fillText(s,0,a),!r.getImageData(0,0,o,h))return i.ascent=a,i.descent=a+6,i.fontSize=i.ascent+i.descent,e.Text.fontPropertiesCache[t]=i,i;var l,c,u=r.getImageData(0,0,o,h).data,d=u.length,p=4*o,f=0,g=!1;for(l=0;l<a;l++){for(c=0;c<p;c+=4)if(255!==u[f+c]){g=!0;break}if(g)break;f+=p}for(i.ascent=a-l,f=d-p,g=!1,l=h;l>a;l--){for(c=0;c<p;c+=4)if(255!==u[f+c]){g=!0;break}if(g)break;f-=p}i.descent=l-a,i.descent+=6,i.fontSize=i.ascent+i.descent,e.Text.fontPropertiesCache[t]=i}return i},e.Text.prototype.getBounds=function(t){return this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype.getBounds.call(this,t)},e.Text.prototype.setCharacterLimit=function(t,e){this.characterLimitSuffix=void 0===e?"":e,this.characterLimitSize=t,this.updateText()},Object.defineProperty(e.Text.prototype,"text",{get:function(){return this._text},set:function(t){t!==this._text&&(this._text=t.toString()||"",this.dirty=!0,this.parent&&this.updateTransform())}}),Object.defineProperty(e.Text.prototype,"cssFont",{get:function(){return this.componentsToFont(this._fontComponents)},set:function(t){t=t||"bold 20pt Arial",this._fontComponents=this.fontToComponents(t),this.updateFont(this._fontComponents)}}),Object.defineProperty(e.Text.prototype,"font",{get:function(){return this._fontComponents.fontFamily},set:function(t){t=(t=t||"Arial").trim(),/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(t)||/['",]/.exec(t)||(t="'"+t+"'"),this._fontComponents.fontFamily=t,this.updateFont(this._fontComponents)}}),Object.defineProperty(e.Text.prototype,"fontSize",{get:function(){var t=this._fontComponents.fontSize;return t&&/(?:^0$|px$)/.exec(t)?parseInt(t,10):t},set:function(t){"number"==typeof(t=t||"0")&&(t+="px"),this._fontComponents.fontSize=t,this.updateFont(this._fontComponents)}}),Object.defineProperty(e.Text.prototype,"fontWeight",{get:function(){return this._fontComponents.fontWeight||"normal"},set:function(t){t=t||"normal",this._fontComponents.fontWeight=t,this.updateFont(this._fontComponents)}}),Object.defineProperty(e.Text.prototype,"fontStyle",{get:function(){return this._fontComponents.fontStyle||"normal"},set:function(t){t=t||"normal",this._fontComponents.fontStyle=t,this.updateFont(this._fontComponents)}}),Object.defineProperty(e.Text.prototype,"fontVariant",{get:function(){return this._fontComponents.fontVariant||"normal"},set:function(t){t=t||"normal",this._fontComponents.fontVariant=t,this.updateFont(this._fontComponents)}}),Object.defineProperty(e.Text.prototype,"fill",{get:function(){return this.style.fill},set:function(t){t!==this.style.fill&&(this.style.fill=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"align",{get:function(){return this.style.align},set:function(t){(t=t.toLowerCase())!==this.style.align&&(this.style.align=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"resolution",{get:function(){return this._res},set:function(t){t!==this._res&&(this._res=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"tabs",{get:function(){return this.style.tabs},set:function(t){t!==this.style.tabs&&(this.style.tabs=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"boundsAlignH",{get:function(){return this.style.boundsAlignH},set:function(t){(t=t.toLowerCase())!==this.style.boundsAlignH&&(this.style.boundsAlignH=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"boundsAlignV",{get:function(){return this.style.boundsAlignV},set:function(t){(t=t.toLowerCase())!==this.style.boundsAlignV&&(this.style.boundsAlignV=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"stroke",{get:function(){return this.style.stroke},set:function(t){t!==this.style.stroke&&(this.style.stroke=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"strokeThickness",{get:function(){return this.style.strokeThickness},set:function(t){t!==this.style.strokeThickness&&(this.style.strokeThickness=Number(t),this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"wordWrap",{get:function(){return this.style.wordWrap},set:function(t){t!==this.style.wordWrap&&(this.style.wordWrap=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"wordWrapWidth",{get:function(){return this.style.wordWrapWidth},set:function(t){t!==this.style.wordWrapWidth&&(this.style.wordWrapWidth=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"lineSpacing",{get:function(){return this._lineSpacing},set:function(t){t!==this._lineSpacing&&(this._lineSpacing=parseFloat(t),this.dirty=!0,this.parent&&this.updateTransform())}}),Object.defineProperty(e.Text.prototype,"shadowOffsetX",{get:function(){return this.style.shadowOffsetX},set:function(t){t!==this.style.shadowOffsetX&&(this.style.shadowOffsetX=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"shadowOffsetY",{get:function(){return this.style.shadowOffsetY},set:function(t){t!==this.style.shadowOffsetY&&(this.style.shadowOffsetY=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"shadowColor",{get:function(){return this.style.shadowColor},set:function(t){t!==this.style.shadowColor&&(this.style.shadowColor=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"shadowBlur",{get:function(){return this.style.shadowBlur},set:function(t){t!==this.style.shadowBlur&&(this.style.shadowBlur=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"shadowStroke",{get:function(){return this.style.shadowStroke},set:function(t){t!==this.style.shadowStroke&&(this.style.shadowStroke=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"shadowFill",{get:function(){return this.style.shadowFill},set:function(t){t!==this.style.shadowFill&&(this.style.shadowFill=t,this.dirty=!0)}}),Object.defineProperty(e.Text.prototype,"width",{get:function(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.x*(this.texture.frame.width/this.resolution)},set:function(t){this.scale.x=t/this.texture.frame.width,this._width=t}}),Object.defineProperty(e.Text.prototype,"height",{get:function(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.y*(this.texture.frame.height/this.resolution)},set:function(t){this.scale.y=t/this.texture.frame.height,this._height=t}}),Object.defineProperty(e.Text.prototype,"testString",{get:function(){return this._testString},set:function(t){this._testString=t,this.updateText()}}),e.Text.fontPropertiesCache={},e.Text.fontPropertiesCanvas=document.createElement("canvas"),e.Text.fontPropertiesContext=e.Text.fontPropertiesCanvas.getContext("2d"),e.BitmapText=function(t,i,s,n,r,o,a){i=i||0,s=s||0,n=n||"",r=r||"",o=o||32,a=a||"left",PIXI.DisplayObjectContainer.call(this),this.type=e.BITMAPTEXT,this.physicsType=e.SPRITE,this.textWidth=0,this.textHeight=0,this.anchor=new e.Point,this._prevAnchor=new e.Point,this._glyphs=[],this._maxWidth=0,this._text=r.toString()||"",this._data=t.cache.getBitmapFont(n),this._font=n,this._fontSize=o,this._align=a,this._letterSpacing=0,this._tint=16777215,this.updateText(),this.dirty=!1,e.Component.Core.init.call(this,t,i,s,"",null)},e.BitmapText.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),e.BitmapText.prototype.constructor=e.BitmapText,e.Component.Core.install.call(e.BitmapText.prototype,["Angle","AutoCull","Bounds","Destroy","FixedToCamera","InputEnabled","InWorld","LifeSpan","PhysicsBody","Reset"]),e.BitmapText.prototype.preUpdatePhysics=e.Component.PhysicsBody.preUpdate,e.BitmapText.prototype.preUpdateLifeSpan=e.Component.LifeSpan.preUpdate,e.BitmapText.prototype.preUpdateInWorld=e.Component.InWorld.preUpdate,e.BitmapText.prototype.preUpdateCore=e.Component.Core.preUpdate,e.BitmapText.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},e.BitmapText.prototype.postUpdate=function(){e.Component.PhysicsBody.postUpdate.call(this),e.Component.FixedToCamera.postUpdate.call(this),this.body&&this.body.type===e.Physics.ARCADE&&(this.textWidth===this.body.sourceWidth&&this.textHeight===this.body.sourceHeight||this.body.setSize(this.textWidth,this.textHeight))},e.BitmapText.prototype.setText=function(t){this.text=t},e.BitmapText.prototype.scanLine=function(t,e,i){for(var s=0,n=0,r=-1,o=0,a=null,h=this._maxWidth>0?this._maxWidth:null,l=[],c=0;c<i.length;c++){var u=c===i.length-1;if(/(?:\r\n|\r|\n)/.test(i.charAt(c)))return{width:n,text:i.substr(0,c),end:u,chars:l};var d=i.charCodeAt(c),p=t.chars[d],f=0;void 0===p&&(d=32,p=t.chars[d]);var g=a&&p.kerning[a]?p.kerning[a]:0;if(/(\s)/.test(i.charAt(c))&&(r=c,o=n),f=(g+p.texture.width+p.xOffset)*e,h&&n+f>=h&&r>-1)return{width:o||n,text:i.substr(0,c-(c-r)),end:!1,chars:l};n+=(p.xAdvance+g+this.letterSpacing)*e,l.push(s+(p.xOffset+g+this.letterSpacing)*e),s+=(p.xAdvance+g+this.letterSpacing)*e,a=d}return{width:n,text:i,end:u,chars:l}},e.BitmapText.prototype.cleanText=function(t,e){void 0===e&&(e="");var i=this._data.font;if(!i)return"";for(var s=/\r\n|\n\r|\n|\r/g,n=t.replace(s,"\n").split("\n"),r=0;r<n.length;r++){for(var o="",a=n[r],h=0;h<a.length;h++)o=i.chars[a.charCodeAt(h)]?o.concat(a[h]):o.concat(e);n[r]=o}return n.join("\n")},e.BitmapText.prototype.updateText=function(){var t=this._data.font;if(t){var e=this.text,i=this._fontSize/t.size,s=[],n=0;this.textWidth=0;do{(c=this.scanLine(t,i,e)).y=n,s.push(c),c.width>this.textWidth&&(this.textWidth=c.width),n+=t.lineHeight*i,e=e.substr(c.text.length+1)}while(!1===c.end);this.textHeight=n;for(var r=0,o=0,a=this.textWidth*this.anchor.x,h=this.textHeight*this.anchor.y,l=0;l<s.length;l++){var c=s[l];"right"===this._align?o=this.textWidth-c.width:"center"===this._align&&(o=(this.textWidth-c.width)/2);for(var u=0;u<c.text.length;u++){var d=c.text.charCodeAt(u),p=t.chars[d];void 0===p&&(d=32,p=t.chars[d]);var f=this._glyphs[r];f?f.texture=p.texture:((f=new PIXI.Sprite(p.texture)).name=c.text[u],this._glyphs.push(f)),f.position.x=c.chars[u]+o-a,f.position.y=c.y+p.yOffset*i-h,f.scale.set(i),f.tint=this.tint,f.texture.requiresReTint=!0,f.cachedTint=16777215,f.parent||this.addChild(f),r++}}for(l=r;l<this._glyphs.length;l++)this.removeChild(this._glyphs[l])}},e.BitmapText.prototype.purgeGlyphs=function(){for(var t=this._glyphs.length,e=[],i=0;i<this._glyphs.length;i++)this._glyphs[i].parent!==this?this._glyphs[i].destroy():e.push(this._glyphs[i]);return this._glyphs=[],this._glyphs=e,this.updateText(),t-e.length},e.BitmapText.prototype.updateTransform=function(){!this.dirty&&this.anchor.equals(this._prevAnchor)||(this.updateText(),this.dirty=!1,this._prevAnchor.copyFrom(this.anchor)),PIXI.DisplayObjectContainer.prototype.updateTransform.call(this)},Object.defineProperty(e.BitmapText.prototype,"letterSpacing",{get:function(){return this._letterSpacing},set:function(t){"number"==typeof t&&(this._letterSpacing=t,this.updateText())}}),Object.defineProperty(e.BitmapText.prototype,"align",{get:function(){return this._align},set:function(t){t===this._align||"left"!==t&&"center"!==t&&"right"!==t||(this._align=t,this.updateText())}}),Object.defineProperty(e.BitmapText.prototype,"tint",{get:function(){return this._tint},set:function(t){t!==this._tint&&(this._tint=t,this.updateText())}}),Object.defineProperty(e.BitmapText.prototype,"font",{get:function(){return this._font},set:function(t){t!==this._font&&(this._font=t.trim(),this._data=this.game.cache.getBitmapFont(this._font),this.updateText())}}),Object.defineProperty(e.BitmapText.prototype,"fontSize",{get:function(){return this._fontSize},set:function(t){(t=parseInt(t,10))!==this._fontSize&&t>0&&(this._fontSize=t,this.updateText())}}),Object.defineProperty(e.BitmapText.prototype,"text",{get:function(){return this._text},set:function(t){t!==this._text&&(this._text=t.toString()||"",this.updateText())}}),Object.defineProperty(e.BitmapText.prototype,"maxWidth",{get:function(){return this._maxWidth},set:function(t){t!==this._maxWidth&&(this._maxWidth=t,this.updateText())}}),Object.defineProperty(e.BitmapText.prototype,"smoothed",{get:function(){return!this._data.base.scaleMode},set:function(t){this._data.base.scaleMode=t?0:1,this._data.base.dirty()}}),e.RetroFont=function(t,i,s,n,r,o,a,h,l,c){if(!t.cache.checkImageKey(i))return!1;void 0!==o&&null!==o||(o=t.cache.getImage(i).width/s),this.characterWidth=s,this.characterHeight=n,this.characterSpacingX=a||0,this.characterSpacingY=h||0,this.characterPerRow=o,this.offsetX=l||0,this.offsetY=c||0,this.align="left",this.multiLine=!1,this.autoUpperCase=!0,this.customSpacingX=0,this.customSpacingY=0,this.fixedWidth=0,this.fontSet=t.cache.getImage(i),this._text="",this.grabData=[],this.frameData=new e.FrameData;for(var u=this.offsetX,d=this.offsetY,p=0,f=0;f<r.length;f++){var g=this.frameData.addFrame(new e.Frame(f,u,d,this.characterWidth,this.characterHeight));this.grabData[r.charCodeAt(f)]=g.index,++p===this.characterPerRow?(p=0,u=this.offsetX,d+=this.characterHeight+this.characterSpacingY):u+=this.characterWidth+this.characterSpacingX}t.cache.updateFrameData(i,this.frameData),this.stamp=new e.Image(t,0,0,i,0),e.RenderTexture.call(this,t,100,100,"",e.scaleModes.NEAREST),this.type=e.RETROFONT},e.RetroFont.prototype=Object.create(e.RenderTexture.prototype),e.RetroFont.prototype.constructor=e.RetroFont,e.RetroFont.ALIGN_LEFT="left",e.RetroFont.ALIGN_RIGHT="right",e.RetroFont.ALIGN_CENTER="center",e.RetroFont.TEXT_SET1=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",e.RetroFont.TEXT_SET2=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ",e.RetroFont.TEXT_SET3="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ",e.RetroFont.TEXT_SET4="ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789",e.RetroFont.TEXT_SET5="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789",e.RetroFont.TEXT_SET6="ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ",e.RetroFont.TEXT_SET7="AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39",e.RetroFont.TEXT_SET8="0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ",e.RetroFont.TEXT_SET9="ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!",e.RetroFont.TEXT_SET10="ABCDEFGHIJKLMNOPQRSTUVWXYZ",e.RetroFont.TEXT_SET11="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789",e.RetroFont.prototype.setFixedWidth=function(t,e){void 0===e&&(e="left"),this.fixedWidth=t,this.align=e},e.RetroFont.prototype.setText=function(t,e,i,s,n,r){this.multiLine=e||!1,this.customSpacingX=i||0,this.customSpacingY=s||0,this.align=n||"left",this.autoUpperCase=!r,t.length>0&&(this.text=t)},e.RetroFont.prototype.buildRetroFontText=function(){var t=0,i=0;if(this.clear(),this.multiLine){var s=this._text.split("\n");this.fixedWidth>0?this.resize(this.fixedWidth,s.length*(this.characterHeight+this.customSpacingY)-this.customSpacingY,!0):this.resize(this.getLongestLine()*(this.characterWidth+this.customSpacingX),s.length*(this.characterHeight+this.customSpacingY)-this.customSpacingY,!0);for(var n=0;n<s.length;n++)t=0,this.align===e.RetroFont.ALIGN_RIGHT?t=this.width-s[n].length*(this.characterWidth+this.customSpacingX):this.align===e.RetroFont.ALIGN_CENTER&&(t=this.width/2-s[n].length*(this.characterWidth+this.customSpacingX)/2,t+=this.customSpacingX/2),t<0&&(t=0),this.pasteLine(s[n],t,i,this.customSpacingX),i+=this.characterHeight+this.customSpacingY}else this.fixedWidth>0?this.resize(this.fixedWidth,this.characterHeight,!0):this.resize(this._text.length*(this.characterWidth+this.customSpacingX),this.characterHeight,!0),t=0,this.align===e.RetroFont.ALIGN_RIGHT?t=this.width-this._text.length*(this.characterWidth+this.customSpacingX):this.align===e.RetroFont.ALIGN_CENTER&&(t=this.width/2-this._text.length*(this.characterWidth+this.customSpacingX)/2,t+=this.customSpacingX/2),t<0&&(t=0),this.pasteLine(this._text,t,0,this.customSpacingX);this.requiresReTint=!0},e.RetroFont.prototype.pasteLine=function(t,e,i,s){for(var n=0;n<t.length;n++)if(" "===t.charAt(n))e+=this.characterWidth+s;else if(this.grabData[t.charCodeAt(n)]>=0&&(this.stamp.frame=this.grabData[t.charCodeAt(n)],this.renderXY(this.stamp,e,i,!1),(e+=this.characterWidth+s)>this.width))break},e.RetroFont.prototype.getLongestLine=function(){var t=0;if(this._text.length>0)for(var e=this._text.split("\n"),i=0;i<e.length;i++)e[i].length>t&&(t=e[i].length);return t},e.RetroFont.prototype.removeUnsupportedCharacters=function(t){for(var e="",i=0;i<this._text.length;i++){var s=this._text[i],n=s.charCodeAt(0);(this.grabData[n]>=0||!t&&"\n"===s)&&(e=e.concat(s))}return e},e.RetroFont.prototype.updateOffset=function(t,e){if(this.offsetX!==t||this.offsetY!==e){for(var i=t-this.offsetX,s=e-this.offsetY,n=this.game.cache.getFrameData(this.stamp.key).getFrames(),r=n.length;r--;)n[r].x+=i,n[r].y+=s;this.buildRetroFontText()}},Object.defineProperty(e.RetroFont.prototype,"text",{get:function(){return this._text},set:function(t){var e;(e=this.autoUpperCase?t.toUpperCase():t)!==this._text&&(this._text=e,this.removeUnsupportedCharacters(this.multiLine),this.buildRetroFontText())}}),Object.defineProperty(e.RetroFont.prototype,"smoothed",{get:function(){return this.stamp.smoothed},set:function(t){this.stamp.smoothed=t,this.buildRetroFontText()}}),e.Rope=function(t,i,s,n,r,o){this.points=o||[],this._hasUpdateAnimation=!1,this._updateAnimationCallback=null,i=i||0,s=s||0,n=n||null,r=r||null,this.type=e.ROPE,PIXI.DisplayObjectContainer.call(this),this.texture=e.Cache.DEFAULT,this.uvs=new Float32Array([0,1,1,1,1,0,0,1]),this.vertices=new Float32Array([0,0,100,0,100,100,0,100]),this.colors=new Float32Array([1,1,1,1]),this.indices=new Uint16Array([0,1,2,3]),o&&(this.vertices=new Float32Array(4*o.length),this.uvs=new Float32Array(4*o.length),this.colors=new Float32Array(2*o.length),this.indices=new Uint16Array(2*o.length)),this.dirty=!0,this.canvasPadding=0,this.drawMode=e.Rope.TRIANGLE_STRIP,e.Component.Core.init.call(this,t,i,s,n,r),this.refresh()},e.Rope.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),e.Rope.prototype.constructor=e.Rope,e.Component.Core.install.call(e.Rope.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Delta","Destroy","FixedToCamera","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","ScaleMinMax","Smoothed"]),e.Rope.prototype.preUpdatePhysics=e.Component.PhysicsBody.preUpdate,e.Rope.prototype.preUpdateLifeSpan=e.Component.LifeSpan.preUpdate,e.Rope.prototype.preUpdateInWorld=e.Component.InWorld.preUpdate,e.Rope.prototype.preUpdateCore=e.Component.Core.preUpdate,e.Rope.TRIANGLE_STRIP=0,e.Rope.TRIANGLES=1,e.Rope.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},e.Rope.prototype.update=function(){this._hasUpdateAnimation&&this.updateAnimation.call(this)},e.Rope.prototype.reset=function(t,i){return e.Component.Reset.prototype.reset.call(this,t,i),this},e.Rope.prototype.refresh=function(){var t=this.points;if(!(t.length<1)){var e=this.uvs,i=this.indices,s=this.colors;this.count-=.2;for(var n=t.length,r=0,o=0,a=0;a<n;a++)o=a/(n-1),e[r=4*a]=o,e[r+1]=0,e[r+2]=o,e[r+3]=1,s[r=2*a]=1,s[r+1]=1,i[r=2*a]=r,i[r+1]=r+1}},e.Rope.prototype.updateTransform=function(){var t=this.points;if(!(t.length<1)){var e,i=t[0],s={x:0,y:0};this.count-=.2;for(var n,r,o,a,h=this.vertices,l=t.length,c=this.texture.height/2,u=0;u<l;u++)n=t[u],r=4*u,e=u<l-1?t[u+1]:n,s.y=-(e.x-i.x),s.x=e.y-i.y,o=Math.sqrt(s.x*s.x+s.y*s.y),a=c,s.x/=o,s.y/=o,s.x*=a,s.y*=a,h[r]=n.x+s.x,h[r+1]=n.y+s.y,h[r+2]=n.x-s.x,h[r+3]=n.y-s.y,i=n;PIXI.DisplayObjectContainer.prototype.updateTransform.call(this)}},e.Rope.prototype.setTexture=function(t){this.texture=t},e.Rope.prototype._renderWebGL=function(t){!this.visible||this.alpha<=0||(t.spriteBatch.stop(),this._vertexBuffer||this._initWebGL(t),t.shaderManager.setShader(t.shaderManager.stripShader),this._renderStrip(t),t.spriteBatch.start())},e.Rope.prototype._initWebGL=function(t){var e=t.gl;this._vertexBuffer=e.createBuffer(),this._indexBuffer=e.createBuffer(),this._uvBuffer=e.createBuffer(),this._colorBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this._vertexBuffer),e.bufferData(e.ARRAY_BUFFER,this.vertices,e.DYNAMIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,this._uvBuffer),e.bufferData(e.ARRAY_BUFFER,this.uvs,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,this._colorBuffer),e.bufferData(e.ARRAY_BUFFER,this.colors,e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this._indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.indices,e.STATIC_DRAW)},e.Rope.prototype._renderStrip=function(t){var i=t.gl,s=t.projection,n=t.offset,r=t.shaderManager.stripShader,o=this.drawMode===e.Rope.TRIANGLE_STRIP?i.TRIANGLE_STRIP:i.TRIANGLES;t.blendModeManager.setBlendMode(this.blendMode),i.uniformMatrix3fv(r.translationMatrix,!1,this.worldTransform.toArray(!0)),i.uniform2f(r.projectionVector,s.x,-s.y),i.uniform2f(r.offsetVector,-n.x,-n.y),i.uniform1f(r.alpha,this.worldAlpha),this.dirty?(this.dirty=!1,i.bindBuffer(i.ARRAY_BUFFER,this._vertexBuffer),i.bufferData(i.ARRAY_BUFFER,this.vertices,i.STATIC_DRAW),i.vertexAttribPointer(r.aVertexPosition,2,i.FLOAT,!1,0,0),i.bindBuffer(i.ARRAY_BUFFER,this._uvBuffer),i.bufferData(i.ARRAY_BUFFER,this.uvs,i.STATIC_DRAW),i.vertexAttribPointer(r.aTextureCoord,2,i.FLOAT,!1,0,0),i.activeTexture(i.TEXTURE0),this.texture.baseTexture._dirty[i.id]?t.renderer.updateTexture(this.texture.baseTexture):i.bindTexture(i.TEXTURE_2D,this.texture.baseTexture._glTextures[i.id]),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,this._indexBuffer),i.bufferData(i.ELEMENT_ARRAY_BUFFER,this.indices,i.STATIC_DRAW)):(i.bindBuffer(i.ARRAY_BUFFER,this._vertexBuffer),i.bufferSubData(i.ARRAY_BUFFER,0,this.vertices),i.vertexAttribPointer(r.aVertexPosition,2,i.FLOAT,!1,0,0),i.bindBuffer(i.ARRAY_BUFFER,this._uvBuffer),i.vertexAttribPointer(r.aTextureCoord,2,i.FLOAT,!1,0,0),i.activeTexture(i.TEXTURE0),this.texture.baseTexture._dirty[i.id]?t.renderer.updateTexture(this.texture.baseTexture):i.bindTexture(i.TEXTURE_2D,this.texture.baseTexture._glTextures[i.id]),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,this._indexBuffer)),i.drawElements(o,this.indices.length,i.UNSIGNED_SHORT,0)},e.Rope.prototype._renderCanvas=function(t){var i=t.context,s=this.worldTransform,n=s.tx*t.resolution+t.shakeX,r=s.ty*t.resolution+t.shakeY;t.roundPixels?i.setTransform(s.a,s.b,s.c,s.d,0|n,0|r):i.setTransform(s.a,s.b,s.c,s.d,n,r),this.drawMode===e.Rope.TRIANGLE_STRIP?this._renderCanvasTriangleStrip(i):this._renderCanvasTriangles(i)},e.Rope.prototype._renderCanvasTriangleStrip=function(t){var e=this.vertices,i=this.uvs,s=e.length/2;this.count++;for(var n=0;n<s-2;n++){var r=2*n;this._renderCanvasDrawTriangle(t,e,i,r,r+2,r+4)}},e.Rope.prototype._renderCanvasTriangles=function(t){var e=this.vertices,i=this.uvs,s=this.indices,n=s.length;this.count++;for(var r=0;r<n;r+=3){var o=2*s[r],a=2*s[r+1],h=2*s[r+2];this._renderCanvasDrawTriangle(t,e,i,o,a,h)}},e.Rope.prototype._renderCanvasDrawTriangle=function(t,e,i,s,n,r){var o=this.texture.baseTexture.source,a=this.texture.width,h=this.texture.height,l=e[s],c=e[n],u=e[r],d=e[s+1],p=e[n+1],f=e[r+1],g=i[s]*a,m=i[n]*a,y=i[r]*a,v=i[s+1]*h,x=i[n+1]*h,b=i[r+1]*h;if(this.canvasPadding>0){var _=this.canvasPadding/this.worldTransform.a,w=this.canvasPadding/this.worldTransform.d,T=(l+c+u)/3,P=(d+p+f)/3,C=l-T,S=d-P,A=Math.sqrt(C*C+S*S);l=T+C/A*(A+_),d=P+S/A*(A+w),S=p-P,c=T+(C=c-T)/(A=Math.sqrt(C*C+S*S))*(A+_),p=P+S/A*(A+w),S=f-P,u=T+(C=u-T)/(A=Math.sqrt(C*C+S*S))*(A+_),f=P+S/A*(A+w)}t.save(),t.beginPath(),t.moveTo(l,d),t.lineTo(c,p),t.lineTo(u,f),t.closePath(),t.clip();var E=g*x+v*y+m*b-x*y-v*m-g*b,M=l*x+v*u+c*b-x*u-v*c-l*b,R=g*c+l*y+m*u-c*y-l*m-g*u,L=g*x*u+v*c*y+l*m*b-l*x*y-v*m*u-g*c*b,B=d*x+v*f+p*b-x*f-v*p-d*b,I=g*p+d*y+m*f-p*y-d*m-g*f,O=g*x*f+v*p*y+d*m*b-d*x*y-v*m*f-g*p*b;t.transform(M/E,B/E,R/E,I/E,L/E,O/E),t.drawImage(o,0,0),t.restore()},e.Rope.prototype.renderStripFlat=function(t){var e=this.context,i=t.vertices,s=i.length/2;this.count++,e.beginPath();for(var n=1;n<s-2;n++){var r=2*n,o=i[r],a=i[r+2],h=i[r+4],l=i[r+1],c=i[r+3],u=i[r+5];e.moveTo(o,l),e.lineTo(a,c),e.lineTo(h,u)}e.fillStyle="#FF0000",e.fill(),e.closePath()},e.Rope.prototype.getBounds=function(t){for(var i=t||this.worldTransform,s=i.a,n=i.b,r=i.c,o=i.d,a=i.tx,h=i.ty,l=-1/0,c=-1/0,u=1/0,d=1/0,p=this.vertices,f=0;f<p.length;f+=2){var g=p[f],m=p[f+1],y=s*g+r*m+a,v=o*m+n*g+h;u=y<u?y:u,d=v<d?v:d,l=y>l?y:l,c=v>c?v:c}if(u===-1/0||c===1/0)return e.EmptyRectangle;var x=this._bounds;return x.x=u,x.width=l-u,x.y=d,x.height=c-d,this._currentBounds=x,x},Object.defineProperty(e.Rope.prototype,"updateAnimation",{get:function(){return this._updateAnimation},set:function(t){t&&"function"==typeof t?(this._hasUpdateAnimation=!0,this._updateAnimation=t):(this._hasUpdateAnimation=!1,this._updateAnimation=null)}}),Object.defineProperty(e.Rope.prototype,"segments",{get:function(){for(var t,i,s,n,r,o,a,h,l=[],c=0;c<this.points.length;c++)t=4*c,i=this.vertices[t]*this.scale.x,s=this.vertices[t+1]*this.scale.y,n=this.vertices[t+4]*this.scale.x,r=this.vertices[t+3]*this.scale.y,o=e.Math.difference(i,n),a=e.Math.difference(s,r),i+=this.world.x,s+=this.world.y,h=new e.Rectangle(i,s,o,a),l.push(h);return l}}),e.TileSprite=function(t,i,s,n,r,o,a){i=i||0,s=s||0,n=n||256,r=r||256,o=o||null,a=a||null,PIXI.Sprite.call(this,new PIXI.Texture(e.Cache.DEFAULT.baseTexture),n,r),this.type=e.TILESPRITE,this.physicsType=e.SPRITE,this._scroll=new e.Point,this.tileScale=new e.Point(1,1),this.tileScaleOffset=new e.Point(1,1),this.tilePosition=new e.Point,this.textureDebug=!1,this.canvasBuffer=null,this.tilingTexture=null,this.tilePattern=null,this.refreshTexture=!0,this.frameWidth=0,this.frameHeight=0,this._width=n,this._height=r,e.Component.Core.init.call(this,t,i,s,o,a)},e.TileSprite.prototype=Object.create(PIXI.Sprite.prototype),e.TileSprite.prototype.constructor=e.TileSprite,e.Component.Core.install.call(e.TileSprite.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Destroy","FixedToCamera","Health","InCamera","InputEnabled","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","Smoothed"]),e.TileSprite.prototype.preUpdatePhysics=e.Component.PhysicsBody.preUpdate,e.TileSprite.prototype.preUpdateLifeSpan=e.Component.LifeSpan.preUpdate,e.TileSprite.prototype.preUpdateInWorld=e.Component.InWorld.preUpdate,e.TileSprite.prototype.preUpdateCore=e.Component.Core.preUpdate,e.TileSprite.prototype.preUpdate=function(){return 0!==this._scroll.x&&(this.tilePosition.x+=this._scroll.x*this.game.time.physicsElapsed),0!==this._scroll.y&&(this.tilePosition.y+=this._scroll.y*this.game.time.physicsElapsed),!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},e.TileSprite.prototype.autoScroll=function(t,e){return this._scroll.set(t,e),this},e.TileSprite.prototype.stopScroll=function(){return this._scroll.set(0,0),this},e.TileSprite.prototype.destroy=function(t){e.Component.Destroy.prototype.destroy.call(this,t),PIXI.Sprite.prototype.destroy.call(this),this.canvasBuffer&&(this.canvasBuffer.destroy(),this.canvasBuffer=null),this.tileScale=null,this.tileScaleOffset=null,this.tilePosition=null,this.tilingTexture&&(this.tilingTexture.destroy(!0),this.tilingTexture=null)},e.TileSprite.prototype.reset=function(t,i){return e.Component.Reset.prototype.reset.call(this,t,i),this.tilePosition.x=0,this.tilePosition.y=0,this},e.TileSprite.prototype.setTexture=function(t){return this.texture!==t&&(this.texture=t,this.refreshTexture=!0,this.cachedTint=16777215),this},e.TileSprite.prototype._renderWebGL=function(t){if(this.visible&&this.renderable&&0!==this.alpha){if(this._mask&&(t.spriteBatch.stop(),t.maskManager.pushMask(this.mask,t),t.spriteBatch.start()),this._filters&&(t.spriteBatch.flush(),t.filterManager.pushFilter(this._filterBlock)),this.refreshTexture){if(this.generateTilingTexture(!0,t),!this.tilingTexture)return;this.tilingTexture.needsUpdate&&(this.tilingTexture.baseTexture.textureIndex=this.texture.baseTexture.textureIndex,t.renderer.updateTexture(this.tilingTexture.baseTexture),this.tilingTexture.needsUpdate=!1)}t.spriteBatch.renderTilingSprite(this);for(var e=0;e<this.children.length;e++)this.children[e]._renderWebGL(t);var i=!1;this._filters&&(i=!0,t.spriteBatch.stop(),t.filterManager.popFilter()),this._mask&&(i||t.spriteBatch.stop(),t.maskManager.popMask(this._mask,t)),i&&t.spriteBatch.start()}},e.TileSprite.prototype._renderCanvas=function(t){if(this.visible&&this.renderable&&0!==this.alpha){var e=t.context;this._mask&&t.maskManager.pushMask(this._mask,t),e.globalAlpha=this.worldAlpha;var i=this.worldTransform,s=t.resolution,n=i.tx*s+t.shakeX,r=i.ty*s+t.shakeY;if(e.setTransform(i.a*s,i.b*s,i.c*s,i.d*s,n,r),16777215===this.tint||!this.texture.requiresReTint&&this.cachedTint===this.tint||(this.tintedTexture=PIXI.CanvasTinter.getTintedTexture(this,this.tint),this.cachedTint=this.tint,this.texture.requiresReTint=!1,this.refreshTexture=!0),this.refreshTexture){if(this.generateTilingTexture(!1,t),!this.tilingTexture)return;this.tilePattern=e.createPattern(this.tilingTexture.baseTexture.source,"repeat")}var o=t.currentBlendMode;this.blendMode!==t.currentBlendMode&&(t.currentBlendMode=this.blendMode,e.globalCompositeOperation=PIXI.blendModesCanvas[t.currentBlendMode]);var a=this.tilePosition,h=this.tileScale;a.x%=this.tilingTexture.baseTexture.width,a.y%=this.tilingTexture.baseTexture.height,e.scale(h.x,h.y),e.translate(a.x+this.anchor.x*-this._width,a.y+this.anchor.y*-this._height),e.fillStyle=this.tilePattern,n=-a.x,r=-a.y;var l=this._width/h.x,c=this._height/h.y;t.roundPixels&&(n|=0,r|=0,l|=0,c|=0),e.fillRect(n,r,l,c),e.scale(1/h.x,1/h.y),e.translate(-a.x+this.anchor.x*this._width,-a.y+this.anchor.y*this._height),this._mask&&t.maskManager.popMask(t);for(var u=0;u<this.children.length;u++)this.children[u]._renderCanvas(t);o!==this.blendMode&&(t.currentBlendMode=o,e.globalCompositeOperation=PIXI.blendModesCanvas[o])}},e.TileSprite.prototype.onTextureUpdate=function(){},e.TileSprite.prototype.generateTilingTexture=function(t){if(this.texture.baseTexture.hasLoaded){var i=this.texture,s=i.frame,n=this._frame.sourceSizeW||this._frame.width,r=this._frame.sourceSizeH||this._frame.height,o=0,a=0;this._frame.trimmed&&(o=this._frame.spriteSourceSizeX,a=this._frame.spriteSourceSizeY),t&&(n=e.Math.getNextPowerOfTwo(n),r=e.Math.getNextPowerOfTwo(r)),this.canvasBuffer?(this.canvasBuffer.resize(n,r),this.tilingTexture.baseTexture.width=n,this.tilingTexture.baseTexture.height=r,this.tilingTexture.needsUpdate=!0):(this.canvasBuffer=new PIXI.CanvasBuffer(n,r),this.tilingTexture=PIXI.Texture.fromCanvas(this.canvasBuffer.canvas),this.tilingTexture.isTiling=!0,this.tilingTexture.needsUpdate=!0),this.textureDebug&&(this.canvasBuffer.context.strokeStyle="#00ff00",this.canvasBuffer.context.strokeRect(0,0,n,r));var h=i.crop.width,l=i.crop.height;h===n&&l===r||(h=n,l=r);var c=this.tintedTexture?this.tintedTexture:i.baseTexture.source;this.canvasBuffer.context.drawImage(c,i.crop.x,i.crop.y,i.crop.width,i.crop.height,o,a,h,l),this.tileScaleOffset.x=s.width/n,this.tileScaleOffset.y=s.height/r,this.refreshTexture=!1,this.tilingTexture.baseTexture._powerOf2=!0}},e.TileSprite.prototype.getBounds=function(){var t=this._width,e=this._height,i=t*(1-this.anchor.x),s=t*-this.anchor.x,n=e*(1-this.anchor.y),r=e*-this.anchor.y,o=this.worldTransform,a=o.a,h=o.b,l=o.c,c=o.d,u=o.tx,d=o.ty,p=a*s+l*r+u,f=c*r+h*s+d,g=a*i+l*r+u,m=c*r+h*i+d,y=a*i+l*n+u,v=c*n+h*i+d,x=a*s+l*n+u,b=c*n+h*s+d,_=-1/0,w=-1/0,T=1/0,P=1/0;T=x<(T=y<(T=g<(T=p<T?p:T)?g:T)?y:T)?x:T,P=b<(P=v<(P=m<(P=f<P?f:P)?m:P)?v:P)?b:P,_=x>(_=y>(_=g>(_=p>_?p:_)?g:_)?y:_)?x:_,w=b>(w=v>(w=m>(w=f>w?f:w)?m:w)?v:w)?b:w;var C=this._bounds;return C.x=T,C.width=_-T,C.y=P,C.height=w-P,this._currentBounds=C,C},Object.defineProperty(e.TileSprite.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t}}),Object.defineProperty(e.TileSprite.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t}}),e.CanvasPool={create:function(t,i,s){var n,r=e.CanvasPool.getFirst();if(-1===r){var o={parent:t,canvas:document.createElement("canvas")};e.CanvasPool.pool.push(o),n=o.canvas}else e.CanvasPool.pool[r].parent=t,n=e.CanvasPool.pool[r].canvas;return void 0!==i&&(n.width=i,n.height=s),n},getFirst:function(){for(var t=e.CanvasPool.pool,i=0;i<t.length;i++)if(!t[i].parent)return i;return-1},remove:function(t){for(var i=e.CanvasPool.pool,s=0;s<i.length;s++)i[s].parent===t&&(i[s].parent=null,i[s].canvas.width=1,i[s].canvas.height=1)},removeByCanvas:function(t){for(var i=e.CanvasPool.pool,s=0;s<i.length;s++)i[s].canvas===t&&(i[s].parent=null,i[s].canvas.width=1,i[s].canvas.height=1)},getTotal:function(){for(var t=e.CanvasPool.pool,i=0,s=0;s<t.length;s++)t[s].parent&&i++;return i},getFree:function(){for(var t=e.CanvasPool.pool,i=0,s=0;s<t.length;s++)t[s].parent||i++;return i},log:function(){console.log("CanvasPool: %s used, %s free, %s total",e.CanvasPool.getTotal(),e.CanvasPool.getFree(),e.CanvasPool.pool.length)}},e.CanvasPool.pool=[],Object.defineProperty(e.CanvasPool,"length",{get:function(){return this.pool.length}}),e.Device=function(){this.deviceReadyAt=0,this.initialized=!1,this.desktop=!1,this.iOS=!1,this.iOSVersion=0,this.cocoonJS=!1,this.cocoonJSApp=!1,this.cordova=!1,this.node=!1,this.nodeWebkit=!1,this.electron=!1,this.ejecta=!1,this.crosswalk=!1,this.android=!1,this.chromeOS=!1,this.linux=!1,this.macOS=!1,this.windows=!1,this.windowsPhone=!1,this.canvas=!1,this.canvasBitBltShift=null,this.canHandleAlpha=!1,this.canUseMultiply=!1,this.webGL=!1,this.file=!1,this.fileSystem=!1,this.localStorage=!1,this.worker=!1,this.css3D=!1,this.pointerLock=!1,this.typedArray=!1,this.vibration=!1,this.getUserMedia=!0,this.quirksMode=!1,this.touch=!1,this.mspointer=!1,this.wheelEvent=null,this.arora=!1,this.chrome=!1,this.chromeVersion=0,this.epiphany=!1,this.firefox=!1,this.firefoxVersion=0,this.ie=!1,this.ieVersion=0,this.trident=!1,this.tridentVersion=0,this.edge=!1,this.mobileSafari=!1,this.midori=!1,this.opera=!1,this.safari=!1,this.safariVersion=0,this.webApp=!1,this.silk=!1,this.audioData=!1,this.webAudio=!1,this.ogg=!1,this.opus=!1,this.mp3=!1,this.wav=!1,this.m4a=!1,this.webm=!1,this.dolby=!1,this.oggVideo=!1,this.h264Video=!1,this.mp4Video=!1,this.webmVideo=!1,this.vp9Video=!1,this.hlsVideo=!1,this.iPhone=!1,this.iPhone4=!1,this.iPad=!1,this.pixelRatio=0,this.littleEndian=!1,this.LITTLE_ENDIAN=!1,this.support32bit=!1,this.fullscreen=!1,this.requestFullscreen="",this.cancelFullscreen="",this.fullscreenKeyboard=!1},e.Device=new e.Device,e.Device.onInitialized=new e.Signal,e.Device.whenReady=function(t,e,i){var s=this._readyCheck;if(this.deviceReadyAt||!s)t.call(e,this);else if(s._monitor||i)s._queue=s._queue||[],s._queue.push([t,e]);else{s._monitor=s.bind(this),s._queue=s._queue||[],s._queue.push([t,e]);var n=void 0!==window.cordova,r=navigator.isCocoonJS;"complete"===document.readyState||"interactive"===document.readyState?window.setTimeout(s._monitor,0):n&&!r?document.addEventListener("deviceready",s._monitor,!1):(document.addEventListener("DOMContentLoaded",s._monitor,!1),window.addEventListener("load",s._monitor,!1))}},e.Device._readyCheck=function(){var t=this._readyCheck;if(document.body){if(!this.deviceReadyAt){this.deviceReadyAt=Date.now(),document.removeEventListener("deviceready",t._monitor),document.removeEventListener("DOMContentLoaded",t._monitor),window.removeEventListener("load",t._monitor),this._initialize(),this.initialized=!0,this.onInitialized.dispatch(this);for(var e;e=t._queue.shift();){var i=e[0],s=e[1];i.call(s,this)}this._readyCheck=null,this._initialize=null,this.onInitialized=null}}else window.setTimeout(t._monitor,20)},e.Device._initialize=function(){function t(){var t=new ArrayBuffer(4),e=new Uint8Array(t),i=new Uint32Array(t);return e[0]=161,e[1]=178,e[2]=195,e[3]=212,3569595041===i[0]||2712847316!==i[0]&&null}function i(){if(void 0===Uint8ClampedArray)return!1;var t=e.CanvasPool.create(this,1,1).getContext("2d");if(!t)return!1;var i=t.createImageData(1,1);return e.CanvasPool.remove(this),i.data instanceof Uint8ClampedArray}var s=this;!function(){var t=navigator.userAgent;/Playstation Vita/.test(t)?s.vita=!0:/Kindle/.test(t)||/\bKF[A-Z][A-Z]+/.test(t)||/Silk.*Mobile Safari/.test(t)?s.kindle=!0:/Android/.test(t)?s.android=!0:/CrOS/.test(t)?s.chromeOS=!0:/iP[ao]d|iPhone/i.test(t)?(s.iOS=!0,navigator.appVersion.match(/OS (\d+)/),s.iOSVersion=parseInt(RegExp.$1,10)):/Linux/.test(t)?s.linux=!0:/Mac OS/.test(t)?s.macOS=!0:/Windows/.test(t)&&(s.windows=!0),(/Windows Phone/i.test(t)||/IEMobile/i.test(t))&&(s.android=!1,s.iOS=!1,s.macOS=!1,s.windows=!0,s.windowsPhone=!0);var e=/Silk/.test(t);(s.windows||s.macOS||s.linux&&!e||s.chromeOS)&&(s.desktop=!0),(s.windowsPhone||/Windows NT/i.test(t)&&/Touch/i.test(t))&&(s.desktop=!1)}(),function(){var t=navigator.userAgent;if(/Arora/.test(t)?s.arora=!0:/Edge\/\d+/.test(t)?s.edge=!0:/Chrome\/(\d+)/.test(t)&&!s.windowsPhone?(s.chrome=!0,s.chromeVersion=parseInt(RegExp.$1,10)):/Epiphany/.test(t)?s.epiphany=!0:/Firefox\D+(\d+)/.test(t)?(s.firefox=!0,s.firefoxVersion=parseInt(RegExp.$1,10)):/AppleWebKit/.test(t)&&s.iOS?s.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(t)?(s.ie=!0,s.ieVersion=parseInt(RegExp.$1,10)):/Midori/.test(t)?s.midori=!0:/Opera/.test(t)?s.opera=!0:/Safari\/(\d+)/.test(t)&&!s.windowsPhone?(s.safari=!0,/Version\/(\d+)\./.test(t)&&(s.safariVersion=parseInt(RegExp.$1,10))):/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(t)&&(s.ie=!0,s.trident=!0,s.tridentVersion=parseInt(RegExp.$1,10),s.ieVersion=parseInt(RegExp.$3,10)),/Silk/.test(t)&&(s.silk=!0),navigator.standalone&&(s.webApp=!0),void 0!==window.cordova&&(s.cordova=!0),"undefined"!=typeof process&&"undefined"!=typeof require&&(s.node=!0),s.node&&"object"==typeof process.versions&&(s.nodeWebkit=!!process.versions["node-webkit"],s.electron=!!process.versions.electron),navigator.isCocoonJS&&(s.cocoonJS=!0),s.cocoonJS)try{s.cocoonJSApp="undefined"!=typeof CocoonJS}catch(t){s.cocoonJSApp=!1}void 0!==window.ejecta&&(s.ejecta=!0),/Crosswalk/.test(t)&&(s.crosswalk=!0)}(),function(){s.audioData=!!window.Audio,s.webAudio=!(!window.AudioContext&&!window.webkitAudioContext);var t=document.createElement("audio");try{if(t.canPlayType&&(t.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(s.ogg=!0),(t.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,"")||t.canPlayType("audio/opus;").replace(/^no$/,""))&&(s.opus=!0),t.canPlayType("audio/mpeg;").replace(/^no$/,"")&&(s.mp3=!0),t.canPlayType('audio/wav; codecs="1"').replace(/^no$/,"")&&(s.wav=!0),(t.canPlayType("audio/x-m4a;")||t.canPlayType("audio/aac;").replace(/^no$/,""))&&(s.m4a=!0),t.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")&&(s.webm=!0),""!==t.canPlayType('audio/mp4;codecs="ec-3"')))if(s.edge)s.dolby=!0;else if(s.safari&&s.safariVersion>=9&&/Mac OS X (\d+)_(\d+)/.test(navigator.userAgent)){var e=parseInt(RegExp.$1,10),i=parseInt(RegExp.$2,10);(10===e&&i>=11||e>10)&&(s.dolby=!0)}}catch(t){}}(),function(){var t=document.createElement("video");try{t.canPlayType&&(t.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,"")&&(s.oggVideo=!0),t.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,"")&&(s.h264Video=!0,s.mp4Video=!0),t.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")&&(s.webmVideo=!0),t.canPlayType('video/webm; codecs="vp9"').replace(/^no$/,"")&&(s.vp9Video=!0),t.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(/^no$/,"")&&(s.hlsVideo=!0))}catch(t){}}(),function(){var t,e=document.createElement("p"),i={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"};document.body.insertBefore(e,null);for(var n in i)void 0!==e.style[n]&&(e.style[n]="translate3d(1px,1px,1px)",t=window.getComputedStyle(e).getPropertyValue(i[n]));document.body.removeChild(e),s.css3D=void 0!==t&&t.length>0&&"none"!==t}(),s.pixelRatio=window.devicePixelRatio||1,s.iPhone=-1!==navigator.userAgent.toLowerCase().indexOf("iphone"),s.iPhone4=2===s.pixelRatio&&s.iPhone,s.iPad=-1!==navigator.userAgent.toLowerCase().indexOf("ipad"),"undefined"!=typeof Int8Array?s.typedArray=!0:s.typedArray=!1,"undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint32Array&&(s.littleEndian=t(),s.LITTLE_ENDIAN=s.littleEndian),s.support32bit="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof Int32Array&&null!==s.littleEndian&&i(),navigator.vibrate=navigator.vibrate||navigator.webkitVibrate||navigator.mozVibrate||navigator.msVibrate,navigator.vibrate&&(s.vibration=!0),function(){s.canvas=!!window.CanvasRenderingContext2D||s.cocoonJS;try{s.localStorage=!!localStorage.getItem}catch(t){s.localStorage=!1}s.file=!!(window.File&&window.FileReader&&window.FileList&&window.Blob),s.fileSystem=!!window.requestFileSystem,s.webGL=!!window.WebGLRenderingContext,s.worker=!!window.Worker,s.pointerLockElement="pointerLockElement"in document&&"pointerLockElement"||"mozPointerLockElement"in document&&"mozPointerLockElement"||"webkitPointerLockElement"in document&&"webkitPointerLockElement",s.pointerlockchange="onpointerlockchange"in document&&"pointerlockchange"||"onmozpointerlockchange"in document&&"mozpointerlockchange"||"onwebkitpointerlockchange"in document&&"webkitpointerlockchange",s.pointerlockerror="onpointerlockerror"in document&&"pointerlockerror"||"onmozpointerlockerror"in document&&"mozpointerlockerror"||"onwebkitpointerlockerror"in document&&"webkitpointerlockerror",s.pointerLock=!!s.pointerLockElement,s.quirksMode="CSS1Compat"!==document.compatMode,navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia||navigator.oGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,s.getUserMedia=s.getUserMedia&&!!navigator.getUserMedia&&!!window.URL,s.firefox&&s.firefoxVersion<21&&(s.getUserMedia=!1),!s.iOS&&(s.ie||s.firefox||s.chrome)&&(s.canvasBitBltShift=!0),(s.safari||s.mobileSafari)&&(s.canvasBitBltShift=!1)}(),function(){var t=e.CanvasPool.create(this,6,1),i=t.getContext("2d");i.fillStyle="rgba(10, 20, 30, 0.5)",i.fillRect(0,0,1,1);var n=i.getImageData(0,0,1,1);if(n){i.putImageData(n,1,0);var r=i.getImageData(1,0,1,1);s.canHandleAlpha=r.data[0]===n.data[0]&&r.data[1]===n.data[1]&&r.data[2]===n.data[2]&&r.data[3]===n.data[3]}i.globalCompositeOperation="multiply",s.canUseMultiply="multiply"===i.globalCompositeOperation,e.CanvasPool.removeByCanvas(t),PIXI.CanvasTinter.tintMethod=s.canUseMultiply?PIXI.CanvasTinter.tintWithMultiply:PIXI.CanvasTinter.tintWithPerPixel}(),function(){for(var t=["requestFullscreen","requestFullScreen","webkitRequestFullscreen","webkitRequestFullScreen","msRequestFullscreen","msRequestFullScreen","mozRequestFullScreen","mozRequestFullscreen"],e=document.createElement("div"),i=0;i<t.length;i++)if(e[t[i]]){s.fullscreen=!0,s.requestFullscreen=t[i];break}var n=["cancelFullScreen","exitFullscreen","webkitCancelFullScreen","webkitExitFullscreen","msCancelFullScreen","msExitFullscreen","mozCancelFullScreen","mozExitFullscreen"];if(s.fullscreen)for(i=0;i<n.length;i++)if(document[n[i]]){s.cancelFullscreen=n[i];break}window.Element&&Element.ALLOW_KEYBOARD_INPUT&&(s.fullscreenKeyboard=!0)}(),("ontouchstart"in document.documentElement||window.navigator.maxTouchPoints&&window.navigator.maxTouchPoints>=1)&&(s.touch=!0),(window.PointerEvent||window.MSPointerEvent||window.navigator.msPointerEnabled||window.navigator.pointerEnabled)&&(s.mspointer=!0),s.cocoonJS||("onwheel"in window||s.ie&&"WheelEvent"in window?s.wheelEvent="wheel":"onmousewheel"in window?s.wheelEvent="mousewheel":s.firefox&&"MouseScrollEvent"in window&&(s.wheelEvent="DOMMouseScroll"))},e.Device.canPlayAudio=function(t){return!("mp3"!==t||!this.mp3)||(!("ogg"!==t||!this.ogg&&!this.opus)||(!("m4a"!==t||!this.m4a)||(!("opus"!==t||!this.opus)||(!("wav"!==t||!this.wav)||(!("webm"!==t||!this.webm)||!("mp4"!==t||!this.dolby))))))},e.Device.canPlayVideo=function(t){return!("webm"!==t||!this.webmVideo&&!this.vp9Video)||(!("mp4"!==t||!this.mp4Video&&!this.h264Video)||(!("ogg"!==t&&"ogv"!==t||!this.oggVideo)||!("mpeg"!==t||!this.hlsVideo)))},e.Device.needsTouchUnlock=function(){return!!(!this.cocoonJS&&(this.iOS||this.android)||window.PhaserGlobal&&window.PhaserGlobal.fakeiOSTouchLock)},e.Device.isAndroidStockBrowser=function(){var t=window.navigator.userAgent.match(/Android.*AppleWebKit\/([\d.]+)/);return t&&t[1]<537},e.Canvas={create:function(t,i,s,n,r){i=i||256,s=s||256;var o=r?document.createElement("canvas"):e.CanvasPool.create(t,i,s);return"string"==typeof n&&""!==n&&(o.id=n),o.width=i,o.height=s,o.style.display="block",o},setBackgroundColor:function(t,e){return e=e||"rgb(0,0,0)",t.style.backgroundColor=e,t},setTouchAction:function(t,e){return e=e||"none",t.style.msTouchAction=e,t.style["ms-touch-action"]=e,t.style["touch-action"]=e,t},setUserSelect:function(t,e){return e=e||"none",t.style["-webkit-touch-callout"]=e,t.style["-webkit-user-select"]=e,t.style["-khtml-user-select"]=e,t.style["-moz-user-select"]=e,t.style["-ms-user-select"]=e,t.style["user-select"]=e,t.style["-webkit-tap-highlight-color"]="rgba(0, 0, 0, 0)",t},addToDOM:function(t,e,i){var s;return void 0===i&&(i=!0),e&&("string"==typeof e?s=document.getElementById(e):"object"==typeof e&&1===e.nodeType&&(s=e)),s||(s=document.body),i&&s.style&&(s.style.overflow="hidden"),s.appendChild(t),t},removeFromDOM:function(t){t.parentNode&&t.parentNode.removeChild(t)},setTransform:function(t,e,i,s,n,r,o){return t.setTransform(s,r,o,n,e,i),t},setSmoothingEnabled:function(t,i){var s=e.Canvas.getSmoothingPrefix(t);return s&&(t[s]=i),t},getSmoothingPrefix:function(t){var e=["i","webkitI","msI","mozI","oI"];for(var i in e){var s=e[i]+"mageSmoothingEnabled";if(s in t)return s}return null},getSmoothingEnabled:function(t){var i=e.Canvas.getSmoothingPrefix(t);if(i)return t[i]},setImageRenderingCrisp:function(t){for(var e=["-webkit-optimize-contrast","-moz-crisp-edges","crisp-edges","pixelated"],i=0;i<e.length;i++)t.style["image-rendering"]=e[i];return t.style.msInterpolationMode="nearest-neighbor",t},setImageRenderingBicubic:function(t){return t.style["image-rendering"]="auto",t.style.msInterpolationMode="bicubic",t}},e.RequestAnimationFrame=function(t,e){void 0===e&&(e=!1),this.game=t,this.isRunning=!1,this.forceSetTimeOut=e;for(var i=["ms","moz","webkit","o"],s=0;s<i.length&&!window.requestAnimationFrame;s++)window.requestAnimationFrame=window[i[s]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[i[s]+"CancelAnimationFrame"]||window[i[s]+"CancelRequestAnimationFrame"];this._isSetTimeOut=!1,this._onLoop=null,this._timeOutID=null},e.RequestAnimationFrame.prototype={start:function(){this.isRunning=!0;var t=this;!window.requestAnimationFrame||this.forceSetTimeOut?(this._isSetTimeOut=!0,this._onLoop=function(){return t.updateSetTimeout()},this._timeOutID=window.setTimeout(this._onLoop,0)):(this._isSetTimeOut=!1,this._onLoop=function(e){return t.updateRAF(e)},this._timeOutID=window.requestAnimationFrame(this._onLoop))},updateRAF:function(t){this.isRunning&&(this.game.update(Math.floor(t)),this._timeOutID=window.requestAnimationFrame(this._onLoop))},updateSetTimeout:function(){this.isRunning&&(this.game.update(Date.now()),this._timeOutID=window.setTimeout(this._onLoop,this.game.time.timeToCall))},stop:function(){this._isSetTimeOut?clearTimeout(this._timeOutID):window.cancelAnimationFrame(this._timeOutID),this.isRunning=!1},isSetTimeOut:function(){return this._isSetTimeOut},isRAF:function(){return!1===this._isSetTimeOut}},e.RequestAnimationFrame.prototype.constructor=e.RequestAnimationFrame,e.Math={PI2:2*Math.PI,HALF_PI:.5*Math.PI,DEG_TO_RAD:Math.PI/180,RAD_TO_DEG:180/Math.PI,degToRad:function(t){return t*e.Math.DEG_TO_RAD},radToDeg:function(t){return t*e.Math.RAD_TO_DEG},getNextPowerOfTwo:function(t){if(t>0&&0==(t&t-1))return t;for(var e=1;e<t;)e<<=1;return e},isPowerOfTwo:function(t,e){return t>0&&0==(t&t-1)&&e>0&&0==(e&e-1)},random:function(t,e){if(void 0===t&&(t=0),void 0===e&&(e=1),t===e)return t;if(t>e){var i=t;t=e,e=i}return Math.random()*(e-t)+t},between:function(t,e){if(void 0===t&&(t=0),void 0===e&&(e=1),t===e)return t;if(t>e){var i=t;t=e,e=i}return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t},fuzzyEqual:function(t,e,i){return void 0===i&&(i=1e-4),Math.abs(t-e)<i},fuzzyLessThan:function(t,e,i){return void 0===i&&(i=1e-4),t<e+i},fuzzyGreaterThan:function(t,e,i){return void 0===i&&(i=1e-4),t>e-i},fuzzyCeil:function(t,e){return void 0===e&&(e=1e-4),Math.ceil(t-e)},fuzzyFloor:function(t,e){return void 0===e&&(e=1e-4),Math.floor(t+e)},average:function(){for(var t=0,e=arguments.length,i=0;i<e;i++)t+=+arguments[i];return t/e},shear:function(t){return t%1},snapTo:function(t,e,i){return void 0===i&&(i=0),0===e?t:(t-=i,t=e*Math.round(t/e),i+t)},snapToFloor:function(t,e,i){return void 0===i&&(i=0),0===e?t:(t-=i,t=e*Math.floor(t/e),i+t)},snapToCeil:function(t,e,i){return void 0===i&&(i=0),0===e?t:(t-=i,t=e*Math.ceil(t/e),i+t)},roundTo:function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var s=Math.pow(i,-e);return Math.round(t*s)/s},floorTo:function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var s=Math.pow(i,-e);return Math.floor(t*s)/s},ceilTo:function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var s=Math.pow(i,-e);return Math.ceil(t*s)/s},trunc:function(t){return isFinite(t)?t-t%1||(t<0?-0:0===t?t:0):t},rotateToAngle:function(t,i,s){return void 0===s&&(s=.05),t===i?t:(Math.abs(i-t)<=s||Math.abs(i-t)>=e.Math.PI2-s?t=i:(Math.abs(i-t)>Math.PI&&(i<t?i+=e.Math.PI2:i-=e.Math.PI2),i>t?t+=s:i<t&&(t-=s)),t)},getShortestAngle:function(t,e){var i=e-t;return 0===i?0:i-360*Math.floor((i- -180)/360)},angleBetween:function(t,e,i,s){return Math.atan2(s-e,i-t)},angleBetweenY:function(t,e,i,s){return Math.atan2(i-t,s-e)},angleBetweenPoints:function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)},angleBetweenPointsY:function(t,e){return Math.atan2(e.x-t.x,e.y-t.y)},reverseAngle:function(t){return this.normalizeAngle(t+Math.PI,!0)},normalizeAngle:function(t){return(t%=2*Math.PI)>=0?t:t+2*Math.PI},maxAdd:function(t,e,i){return Math.min(t+e,i)},minSub:function(t,e,i){return Math.max(t-e,i)},wrap:function(t,e,i){var s=i-e;if(s<=0)return 0;var n=(t-e)%s;return n<0&&(n+=s),n+e},wrapValue:function(t,e,i){return t=Math.abs(t),e=Math.abs(e),i=Math.abs(i),(t+e)%i},isOdd:function(t){return!!(1&t)},isEven:function(t){return!(1&t)},min:function(){if(1===arguments.length&&"object"==typeof arguments[0])t=arguments[0];else var t=arguments;for(var e=1,i=0,s=t.length;e<s;e++)t[e]<t[i]&&(i=e);return t[i]},max:function(){if(1===arguments.length&&"object"==typeof arguments[0])t=arguments[0];else var t=arguments;for(var e=1,i=0,s=t.length;e<s;e++)t[e]>t[i]&&(i=e);return t[i]},minProperty:function(t){if(2===arguments.length&&"object"==typeof arguments[1])e=arguments[1];else var e=arguments.slice(1);for(var i=1,s=0,n=e.length;i<n;i++)e[i][t]<e[s][t]&&(s=i);return e[s][t]},maxProperty:function(t){if(2===arguments.length&&"object"==typeof arguments[1])e=arguments[1];else var e=arguments.slice(1);for(var i=1,s=0,n=e.length;i<n;i++)e[i][t]>e[s][t]&&(s=i);return e[s][t]},wrapAngle:function(t,e){return e?this.wrap(t,-Math.PI,Math.PI):this.wrap(t,-180,180)},linearInterpolation:function(t,e){var i=t.length-1,s=i*e,n=Math.floor(s);return e<0?this.linear(t[0],t[1],s):e>1?this.linear(t[i],t[i-1],i-s):this.linear(t[n],t[n+1>i?i:n+1],s-n)},bezierInterpolation:function(t,e){for(var i=0,s=t.length-1,n=0;n<=s;n++)i+=Math.pow(1-e,s-n)*Math.pow(e,n)*t[n]*this.bernstein(s,n);return i},catmullRomInterpolation:function(t,e){var i=t.length-1,s=i*e,n=Math.floor(s);return t[0]===t[i]?(e<0&&(n=Math.floor(s=i*(1+e))),this.catmullRom(t[(n-1+i)%i],t[n],t[(n+1)%i],t[(n+2)%i],s-n)):e<0?t[0]-(this.catmullRom(t[0],t[0],t[1],t[1],-s)-t[0]):e>1?t[i]-(this.catmullRom(t[i],t[i],t[i-1],t[i-1],s-i)-t[i]):this.catmullRom(t[n?n-1:0],t[n],t[i<n+1?i:n+1],t[i<n+2?i:n+2],s-n)},linear:function(t,e,i){return(e-t)*i+t},bernstein:function(t,e){return this.factorial(t)/this.factorial(e)/this.factorial(t-e)},factorial:function(t){if(0===t)return 1;for(var e=t;--t;)e*=t;return e},catmullRom:function(t,e,i,s,n){var r=.5*(i-t),o=.5*(s-e),a=n*n;return(2*e-2*i+r+o)*(n*a)+(-3*e+3*i-2*r-o)*a+r*n+e},difference:function(t,e){return Math.abs(t-e)},roundAwayFromZero:function(t){return t>0?Math.ceil(t):Math.floor(t)},sinCosGenerator:function(t,e,i,s){void 0===e&&(e=1),void 0===i&&(i=1),void 0===s&&(s=1);for(var n=e,r=i,o=s*Math.PI/t,a=[],h=[],l=0;l<t;l++)n+=(r-=n*o)*o,a[l]=r,h[l]=n;return{sin:h,cos:a,length:t}},hypot:function(t,e){return Math.sqrt(t*t+e*e)},distance:function(t,e,i,s){var n=t-i,r=e-s;return Math.sqrt(n*n+r*r)},distanceSq:function(t,e,i,s){var n=t-i,r=e-s;return n*n+r*r},distancePow:function(t,e,i,s,n){return void 0===n&&(n=2),Math.sqrt(Math.pow(i-t,n)+Math.pow(s-e,n))},clamp:function(t,e,i){return t<e?e:i<t?i:t},clampBottom:function(t,e){return t<e?e:t},within:function(t,e,i){return Math.abs(t-e)<=i},mapLinear:function(t,e,i,s,n){return s+(t-e)*(n-s)/(i-e)},smoothstep:function(t,e,i){return(t=Math.max(0,Math.min(1,(t-e)/(i-e))))*t*(3-2*t)},smootherstep:function(t,e,i){return(t=Math.max(0,Math.min(1,(t-e)/(i-e))))*t*t*(t*(6*t-15)+10)},sign:function(t){return t<0?-1:t>0?1:0},percent:function(t,e,i){return void 0===i&&(i=0),t>e||i>e?1:t<i||i>t?0:(t-i)/e}},e.RandomDataGenerator=function(t){void 0===t&&(t=[]),this.c=1,this.s0=0,this.s1=0,this.s2=0,"string"==typeof t?this.state(t):this.sow(t)},e.RandomDataGenerator.prototype={rnd:function(){var t=2091639*this.s0+2.3283064365386963e-10*this.c;return this.c=0|t,this.s0=this.s1,this.s1=this.s2,this.s2=t-this.c,this.s2},sow:function(t){if(this.s0=this.hash(" "),this.s1=this.hash(this.s0),this.s2=this.hash(this.s1),this.c=1,t)for(var e=0;e<t.length&&null!=t[e];e++){var i=t[e];this.s0-=this.hash(i),this.s0+=~~(this.s0<0),this.s1-=this.hash(i),this.s1+=~~(this.s1<0),this.s2-=this.hash(i),this.s2+=~~(this.s2<0)}},hash:function(t){var e,i,s;for(s=4022871197,t=t.toString(),i=0;i<t.length;i++)e=.02519603282416938*(s+=t.charCodeAt(i)),e-=s=e>>>0,s=(e*=s)>>>0,s+=4294967296*(e-=s);return 2.3283064365386963e-10*(s>>>0)},integer:function(){return 4294967296*this.rnd.apply(this)},frac:function(){return this.rnd.apply(this)+1.1102230246251565e-16*(2097152*this.rnd.apply(this)|0)},real:function(){return this.integer()+this.frac()},integerInRange:function(t,e){return Math.floor(this.realInRange(0,e-t+1)+t)},between:function(t,e){return this.integerInRange(t,e)},realInRange:function(t,e){return this.frac()*(e-t)+t},normal:function(){return 1-2*this.frac()},uuid:function(){var t="",e="";for(e=t="";t++<36;e+=~t%5|3*t&4?(15^t?8^this.frac()*(20^t?16:4):4).toString(16):"-");return e},pick:function(t){return t[this.integerInRange(0,t.length-1)]},sign:function(){return this.pick([-1,1])},weightedPick:function(t){return t[~~(Math.pow(this.frac(),2)*(t.length-1)+.5)]},timestamp:function(t,e){return this.realInRange(t||9466848e5,e||1577862e6)},angle:function(){return this.integerInRange(-180,180)},state:function(t){return"string"==typeof t&&t.match(/^!rnd/)&&(t=t.split(","),this.c=parseFloat(t[1]),this.s0=parseFloat(t[2]),this.s1=parseFloat(t[3]),this.s2=parseFloat(t[4])),["!rnd",this.c,this.s0,this.s1,this.s2].join(",")}},e.RandomDataGenerator.prototype.constructor=e.RandomDataGenerator,e.QuadTree=function(t,e,i,s,n,r,o){this.maxObjects=10,this.maxLevels=4,this.level=0,this.bounds={},this.objects=[],this.nodes=[],this._empty=[],this.reset(t,e,i,s,n,r,o)},e.QuadTree.prototype={reset:function(t,e,i,s,n,r,o){this.maxObjects=n||10,this.maxLevels=r||4,this.level=o||0,this.bounds={x:Math.round(t),y:Math.round(e),width:i,height:s,subWidth:Math.floor(i/2),subHeight:Math.floor(s/2),right:Math.round(t)+Math.floor(i/2),bottom:Math.round(e)+Math.floor(s/2)},this.objects.length=0,this.nodes.length=0},populate:function(t){t.forEach(this.populateHandler,this,!0)},populateHandler:function(t){t.body&&t.exists&&this.insert(t.body)},split:function(){this.nodes[0]=new e.QuadTree(this.bounds.right,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[1]=new e.QuadTree(this.bounds.x,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[2]=new e.QuadTree(this.bounds.x,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[3]=new e.QuadTree(this.bounds.right,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1)},insert:function(t){var e,i=0;if(null==this.nodes[0]||-1===(e=this.getIndex(t))){if(this.objects.push(t),this.objects.length>this.maxObjects&&this.level<this.maxLevels)for(null==this.nodes[0]&&this.split();i<this.objects.length;)-1!==(e=this.getIndex(this.objects[i]))?this.nodes[e].insert(this.objects.splice(i,1)[0]):i++}else this.nodes[e].insert(t)},getIndex:function(t){var e=-1;return t.x<this.bounds.right&&t.right<this.bounds.right?t.y<this.bounds.bottom&&t.bottom<this.bounds.bottom?e=1:t.y>this.bounds.bottom&&(e=2):t.x>this.bounds.right&&(t.y<this.bounds.bottom&&t.bottom<this.bounds.bottom?e=0:t.y>this.bounds.bottom&&(e=3)),e},retrieve:function(t){if(t instanceof e.Rectangle)var i=this.objects,s=this.getIndex(t);else{if(!t.body)return this._empty;var i=this.objects,s=this.getIndex(t.body)}return this.nodes[0]&&(i=-1!==s?i.concat(this.nodes[s].retrieve(t)):(i=(i=(i=i.concat(this.nodes[0].retrieve(t))).concat(this.nodes[1].retrieve(t))).concat(this.nodes[2].retrieve(t))).concat(this.nodes[3].retrieve(t))),i},clear:function(){this.objects.length=0;for(var t=this.nodes.length;t--;)this.nodes[t].clear(),this.nodes.splice(t,1);this.nodes.length=0}},e.QuadTree.prototype.constructor=e.QuadTree,e.Net=function(t){this.game=t},e.Net.prototype={getHostName:function(){return window.location&&window.location.hostname?window.location.hostname:null},checkDomainName:function(t){return-1!==window.location.hostname.indexOf(t)},updateQueryString:function(t,e,i,s){void 0===i&&(i=!1),void 0!==s&&""!==s||(s=window.location.href);var n="",r=new RegExp("([?|&])"+t+"=.*?(&|#|$)(.*)","gi");if(r.test(s))n=void 0!==e&&null!==e?s.replace(r,"$1"+t+"="+e+"$2$3"):s.replace(r,"$1$3").replace(/(&|\?)$/,"");else if(void 0!==e&&null!==e){var o=-1!==s.indexOf("?")?"&":"?",a=s.split("#");s=a[0]+o+t+"="+e,a[1]&&(s+="#"+a[1]),n=s}else n=s;if(!i)return n;window.location.href=n},getQueryString:function(t){void 0===t&&(t="");var e={},i=location.search.substring(1).split("&");for(var s in i){var n=i[s].split("=");if(n.length>1){if(t&&t===this.decodeURI(n[0]))return this.decodeURI(n[1]);e[this.decodeURI(n[0])]=this.decodeURI(n[1])}}return e},decodeURI:function(t){return decodeURIComponent(t.replace(/\+/g," "))}},e.Net.prototype.constructor=e.Net,e.TweenManager=function(t){this.game=t,this.frameBased=!1,this._tweens=[],this._add=[],this.easeMap={Power0:e.Easing.Power0,Power1:e.Easing.Power1,Power2:e.Easing.Power2,Power3:e.Easing.Power3,Power4:e.Easing.Power4,Linear:e.Easing.Linear.None,Quad:e.Easing.Quadratic.Out,Cubic:e.Easing.Cubic.Out,Quart:e.Easing.Quartic.Out,Quint:e.Easing.Quintic.Out,Sine:e.Easing.Sinusoidal.Out,Expo:e.Easing.Exponential.Out,Circ:e.Easing.Circular.Out,Elastic:e.Easing.Elastic.Out,Back:e.Easing.Back.Out,Bounce:e.Easing.Bounce.Out,"Quad.easeIn":e.Easing.Quadratic.In,"Cubic.easeIn":e.Easing.Cubic.In,"Quart.easeIn":e.Easing.Quartic.In,"Quint.easeIn":e.Easing.Quintic.In,"Sine.easeIn":e.Easing.Sinusoidal.In,"Expo.easeIn":e.Easing.Exponential.In,"Circ.easeIn":e.Easing.Circular.In,"Elastic.easeIn":e.Easing.Elastic.In,"Back.easeIn":e.Easing.Back.In,"Bounce.easeIn":e.Easing.Bounce.In,"Quad.easeOut":e.Easing.Quadratic.Out,"Cubic.easeOut":e.Easing.Cubic.Out,"Quart.easeOut":e.Easing.Quartic.Out,"Quint.easeOut":e.Easing.Quintic.Out,"Sine.easeOut":e.Easing.Sinusoidal.Out,"Expo.easeOut":e.Easing.Exponential.Out,"Circ.easeOut":e.Easing.Circular.Out,"Elastic.easeOut":e.Easing.Elastic.Out,"Back.easeOut":e.Easing.Back.Out,"Bounce.easeOut":e.Easing.Bounce.Out,"Quad.easeInOut":e.Easing.Quadratic.InOut,"Cubic.easeInOut":e.Easing.Cubic.InOut,"Quart.easeInOut":e.Easing.Quartic.InOut,"Quint.easeInOut":e.Easing.Quintic.InOut,"Sine.easeInOut":e.Easing.Sinusoidal.InOut,"Expo.easeInOut":e.Easing.Exponential.InOut,"Circ.easeInOut":e.Easing.Circular.InOut,"Elastic.easeInOut":e.Easing.Elastic.InOut,"Back.easeInOut":e.Easing.Back.InOut,"Bounce.easeInOut":e.Easing.Bounce.InOut},this.game.onPause.add(this._pauseAll,this),this.game.onResume.add(this._resumeAll,this)},e.TweenManager.prototype={getAll:function(){return this._tweens},removeAll:function(){for(var t=0;t<this._tweens.length;t++)this._tweens[t].pendingDelete=!0;this._add=[]},removeFrom:function(t,i){void 0===i&&(i=!0);if(Array.isArray(t))for(s=0,n=t.length;s<n;s++)this.removeFrom(t[s]);else if(t.type===e.GROUP&&i)for(var s=0,n=t.children.length;s<n;s++)this.removeFrom(t.children[s]);else{for(s=0,n=this._tweens.length;s<n;s++)t===this._tweens[s].target&&this.remove(this._tweens[s]);for(s=0,n=this._add.length;s<n;s++)t===this._add[s].target&&this.remove(this._add[s])}},add:function(t){t._manager=this,this._add.push(t)},create:function(t){return new e.Tween(t,this.game,this)},remove:function(t){var e=this._tweens.indexOf(t);-1!==e?this._tweens[e].pendingDelete=!0:-1!==(e=this._add.indexOf(t))&&(this._add[e].pendingDelete=!0)},update:function(){var t=this._add.length,e=this._tweens.length;if(0===e&&0===t)return!1;for(var i=0;i<e;)this._tweens[i].update(this.game.time.time)?i++:(this._tweens.splice(i,1),e--);return t>0&&(this._tweens=this._tweens.concat(this._add),this._add.length=0),!0},isTweening:function(t,e){return e||(e=!1),this._tweens.some(function(i){return i.target===t&&(!e||i.isRunning&&!i.pendingDelete)})},_pauseAll:function(){for(var t=this._tweens.length-1;t>=0;t--)this._tweens[t]._pause()},_resumeAll:function(){for(var t=this._tweens.length-1;t>=0;t--)this._tweens[t]._resume()},pauseAll:function(){for(var t=this._tweens.length-1;t>=0;t--)this._tweens[t].pause()},resumeAll:function(){for(var t=this._tweens.length-1;t>=0;t--)this._tweens[t].resume(!0)},destroy:function(){this.game.onPause.remove(this._pauseAll,this),this.game.onResume.remove(this._resumeAll,this),this.game=null,this._add=null,this._tweens=null}},e.TweenManager.prototype.constructor=e.TweenManager,e.Tween=function(t,i,s){this.game=i,this.target=t,this.manager=s,this.timeline=[],this.reverse=!1,this.timeScale=1,this.repeatCounter=0,this.pendingDelete=!1,this.onStart=new e.Signal,this.onLoop=new e.Signal,this.onRepeat=new e.Signal,this.onChildComplete=new e.Signal,this.onComplete=new e.Signal,this.isRunning=!1,this.current=0,this.properties={},this.chainedTween=null,this.isPaused=!1,this.frameBased=s.frameBased,this._onUpdateCallback=null,this._onUpdateCallbackContext=null,this._pausedTime=0,this._codePaused=!1,this._hasStarted=!1},e.Tween.updateColor=function(t){e.Color.updateColor(t.target)},e.Tween.prototype={to:function(t,i,s,n,r,o,a){return(void 0===i||i<=0)&&(i=1e3),void 0!==s&&null!==s||(s=e.Easing.Default),void 0===n&&(n=!1),void 0===r&&(r=0),void 0===o&&(o=0),void 0===a&&(a=!1),"string"==typeof s&&this.manager.easeMap[s]&&(s=this.manager.easeMap[s]),this.isRunning?(console.warn("Phaser.Tween.to cannot be called after Tween.start"),this):(this.timeline.push(new e.TweenData(this).to(t,i,s,r,o,a)),n&&this.start(),this)},from:function(t,i,s,n,r,o,a){return void 0===i&&(i=1e3),void 0!==s&&null!==s||(s=e.Easing.Default),void 0===n&&(n=!1),void 0===r&&(r=0),void 0===o&&(o=0),void 0===a&&(a=!1),"string"==typeof s&&this.manager.easeMap[s]&&(s=this.manager.easeMap[s]),this.isRunning?(console.warn("Phaser.Tween.from cannot be called after Tween.start"),this):(this.timeline.push(new e.TweenData(this).from(t,i,s,r,o,a)),n&&this.start(),this)},start:function(t){if(void 0===t&&(t=0),this.pendingDelete)return console.warn("Phaser.Tween.start cannot be called after Tween.stop"),this;if(null===this.game||null===this.target||0===this.timeline.length||this.isRunning)return this;for(i=0;i<this.timeline.length;i++)for(var e in this.timeline[i].vEnd)this.properties[e]=this.target[e]||0,Array.isArray(this.properties[e])||(this.properties[e]*=1);for(var i=0;i<this.timeline.length;i++)this.timeline[i].loadValues();return this.manager.add(this),this.isRunning=!0,(t<0||t>this.timeline.length-1)&&(t=0),this.current=t,this.timeline[this.current].start(),this},stop:function(t){return void 0===t&&(t=!1),this.isRunning=!1,this._onUpdateCallback=null,this._onUpdateCallbackContext=null,t&&(this.onComplete.dispatch(this.target,this),this._hasStarted=!1,this.chainedTween&&this.chainedTween.start()),this.manager.remove(this),this},updateTweenData:function(t,e,i){if(0===this.timeline.length)return this;if(void 0===i&&(i=0),-1===i)for(var s=0;s<this.timeline.length;s++)this.timeline[s][t]=e;else this.timeline[i][t]=e;return this},delay:function(t,e){return this.updateTweenData("delay",t,e)},repeat:function(t,e,i){return void 0===e&&(e=0),this.updateTweenData("repeatCounter",t,i),this.updateTweenData("repeatTotal",t,i),this.updateTweenData("repeatDelay",e,i)},repeatDelay:function(t,e){return this.updateTweenData("repeatDelay",t,e)},yoyo:function(t,e,i){return void 0===e&&(e=0),this.updateTweenData("yoyo",t,i),this.updateTweenData("yoyoDelay",e,i)},yoyoDelay:function(t,e){return this.updateTweenData("yoyoDelay",t,e)},easing:function(t,e){return"string"==typeof t&&this.manager.easeMap[t]&&(t=this.manager.easeMap[t]),this.updateTweenData("easingFunction",t,e)},interpolation:function(t,i,s){return void 0===i&&(i=e.Math),this.updateTweenData("interpolationFunction",t,s),this.updateTweenData("interpolationContext",i,s)},repeatAll:function(t){return void 0===t&&(t=0),this.repeatCounter=t,this},chain:function(){for(var t=arguments.length;t--;)t>0?arguments[t-1].chainedTween=arguments[t]:this.chainedTween=arguments[t];return this},loop:function(t){return void 0===t&&(t=!0),this.repeatCounter=t?-1:0,this},onUpdateCallback:function(t,e){return this._onUpdateCallback=t,this._onUpdateCallbackContext=e,this},pause:function(){this.isPaused=!0,this._codePaused=!0,this._pausedTime=this.game.time.time},_pause:function(){this._codePaused||(this.isPaused=!0,this._pausedTime=this.game.time.time)},resume:function(){if(this.isPaused){this.isPaused=!1,this._codePaused=!1;for(var t=0;t<this.timeline.length;t++)this.timeline[t].isRunning||(this.timeline[t].startTime+=this.game.time.time-this._pausedTime)}},_resume:function(){this._codePaused||this.resume()},update:function(t){if(this.pendingDelete||!this.target)return!1;if(this.isPaused)return!0;var i=this.timeline[this.current].update(t);if(i===e.TweenData.PENDING)return!0;if(i===e.TweenData.RUNNING)return this._hasStarted||(this.onStart.dispatch(this.target,this),this._hasStarted=!0),null!==this._onUpdateCallback&&this._onUpdateCallback.call(this._onUpdateCallbackContext,this,this.timeline[this.current].value,this.timeline[this.current]),this.isRunning;if(i===e.TweenData.LOOPED)return-1===this.timeline[this.current].repeatCounter?this.onLoop.dispatch(this.target,this):this.onRepeat.dispatch(this.target,this),!0;if(i===e.TweenData.COMPLETE){var s=!1;return this.reverse?--this.current<0&&(this.current=this.timeline.length-1,s=!0):++this.current===this.timeline.length&&(this.current=0,s=!0),s?-1===this.repeatCounter?(this.timeline[this.current].start(),this.onLoop.dispatch(this.target,this),!0):this.repeatCounter>0?(this.repeatCounter--,this.timeline[this.current].start(),this.onRepeat.dispatch(this.target,this),!0):(this.isRunning=!1,this.onComplete.dispatch(this.target,this),this._hasStarted=!1,this.chainedTween&&this.chainedTween.start(),!1):(this.onChildComplete.dispatch(this.target,this),this.timeline[this.current].start(),!0)}},generateData:function(t,e){if(null===this.game||null===this.target)return null;void 0===t&&(t=60),void 0===e&&(e=[]);for(s=0;s<this.timeline.length;s++)for(var i in this.timeline[s].vEnd)this.properties[i]=this.target[i]||0,Array.isArray(this.properties[i])||(this.properties[i]*=1);for(s=0;s<this.timeline.length;s++)this.timeline[s].loadValues();for(var s=0;s<this.timeline.length;s++)e=e.concat(this.timeline[s].generateData(t));return e}},Object.defineProperty(e.Tween.prototype,"totalDuration",{get:function(){for(var t=0,e=0;e<this.timeline.length;e++)t+=this.timeline[e].duration;return t}}),e.Tween.prototype.constructor=e.Tween,e.TweenData=function(t){this.parent=t,this.game=t.game,this.vStart={},this.vStartCache={},this.vEnd={},this.vEndCache={},this.duration=1e3,this.percent=0,this.value=0,this.repeatCounter=0,this.repeatDelay=0,this.repeatTotal=0,this.interpolate=!1,this.yoyo=!1,this.yoyoDelay=0,this.inReverse=!1,this.delay=0,this.dt=0,this.startTime=null,this.easingFunction=e.Easing.Default,this.interpolationFunction=e.Math.linearInterpolation,this.interpolationContext=e.Math,this.isRunning=!1,this.isFrom=!1},e.TweenData.PENDING=0,e.TweenData.RUNNING=1,e.TweenData.LOOPED=2,e.TweenData.COMPLETE=3,e.TweenData.prototype={to:function(t,e,i,s,n,r){return this.vEnd=t,this.duration=e,this.easingFunction=i,this.delay=s,this.repeatTotal=n,this.yoyo=r,this.isFrom=!1,this},from:function(t,e,i,s,n,r){return this.vEnd=t,this.duration=e,this.easingFunction=i,this.delay=s,this.repeatTotal=n,this.yoyo=r,this.isFrom=!0,this},start:function(){if(this.startTime=this.game.time.time+this.delay,this.parent.reverse?this.dt=this.duration:this.dt=0,this.delay>0?this.isRunning=!1:this.isRunning=!0,this.isFrom)for(var t in this.vStartCache)this.vStart[t]=this.vEndCache[t],this.vEnd[t]=this.vStartCache[t],this.parent.target[t]=this.vStart[t];return this.value=0,this.repeatCounter=this.repeatTotal,this},loadValues:function(){for(var t in this.parent.properties){if(this.vStart[t]=this.parent.properties[t],Array.isArray(this.vEnd[t])){if(0===this.vEnd[t].length)continue;0===this.percent&&(this.vEnd[t]=[this.vStart[t]].concat(this.vEnd[t]))}void 0!==this.vEnd[t]?("string"==typeof this.vEnd[t]&&(this.vEnd[t]=this.vStart[t]+parseFloat(this.vEnd[t])),this.parent.properties[t]=this.vEnd[t]):this.vEnd[t]=this.vStart[t],this.vStartCache[t]=this.vStart[t],this.vEndCache[t]=this.vEnd[t]}return this},update:function(t){if(this.isRunning){if(t<this.startTime)return e.TweenData.RUNNING}else{if(!(t>=this.startTime))return e.TweenData.PENDING;this.isRunning=!0}var i=this.parent.frameBased?this.game.time.physicsElapsedMS:this.game.time.elapsedMS;this.parent.reverse?(this.dt-=i*this.parent.timeScale,this.dt=Math.max(this.dt,0)):(this.dt+=i*this.parent.timeScale,this.dt=Math.min(this.dt,this.duration)),this.percent=this.dt/this.duration,this.value=this.easingFunction(this.percent);for(var s in this.vEnd){var n=this.vStart[s],r=this.vEnd[s];Array.isArray(r)?this.parent.target[s]=this.interpolationFunction.call(this.interpolationContext,r,this.value):this.parent.target[s]=n+(r-n)*this.value}return!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent?this.repeat():e.TweenData.RUNNING},generateData:function(t){this.parent.reverse?this.dt=this.duration:this.dt=0;var e=[],i=!1,s=1/t*1e3;do{this.parent.reverse?(this.dt-=s,this.dt=Math.max(this.dt,0)):(this.dt+=s,this.dt=Math.min(this.dt,this.duration)),this.percent=this.dt/this.duration,this.value=this.easingFunction(this.percent);var n={};for(var r in this.vEnd){var o=this.vStart[r],a=this.vEnd[r];Array.isArray(a)?n[r]=this.interpolationFunction.call(this.interpolationContext,a,this.value):n[r]=o+(a-o)*this.value}e.push(n),(!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent)&&(i=!0)}while(!i);if(this.yoyo){var h=e.slice();h.reverse(),e=e.concat(h)}return e},repeat:function(){if(this.yoyo){if(this.inReverse&&0===this.repeatCounter){for(var t in this.vStartCache)this.vStart[t]=this.vStartCache[t],this.vEnd[t]=this.vEndCache[t];return this.inReverse=!1,e.TweenData.COMPLETE}this.inReverse=!this.inReverse}else if(0===this.repeatCounter)return e.TweenData.COMPLETE;if(this.inReverse)for(var t in this.vStartCache)this.vStart[t]=this.vEndCache[t],this.vEnd[t]=this.vStartCache[t];else{for(var t in this.vStartCache)this.vStart[t]=this.vStartCache[t],this.vEnd[t]=this.vEndCache[t];this.repeatCounter>0&&this.repeatCounter--}return this.startTime=this.game.time.time,this.yoyo&&this.inReverse?this.startTime+=this.yoyoDelay:this.inReverse||(this.startTime+=this.repeatDelay),this.parent.reverse?this.dt=this.duration:this.dt=0,e.TweenData.LOOPED}},e.TweenData.prototype.constructor=e.TweenData,e.Easing={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 0===t?0:1===t?1:1-Math.cos(t*Math.PI/2)},Out:function(t){return 0===t?0:1===t?1:Math.sin(t*Math.PI/2)},InOut:function(t){return 0===t?0:1===t?1:.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:(.1,-1*Math.pow(2,10*(t-=1))*Math.sin((t-.1)*(2*Math.PI)/.4))},Out:function(t){return 0===t?0:1===t?1:(.1,1*Math.pow(2,-10*t)*Math.sin((t-.1)*(2*Math.PI)/.4)+1)},InOut:function(t){return 0===t?0:1===t?1:(.1,(t*=2)<1?1*Math.pow(2,10*(t-=1))*Math.sin((t-.1)*(2*Math.PI)/.4)*-.5:1*Math.pow(2,-10*(t-=1))*Math.sin((t-.1)*(2*Math.PI)/.4)*.5+1)}},Back:{In:function(t){var e=1.70158;return t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:function(t){return 1-e.Easing.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*e.Easing.Bounce.In(2*t):.5*e.Easing.Bounce.Out(2*t-1)+.5}}},e.Easing.Default=e.Easing.Linear.None,e.Easing.Power0=e.Easing.Linear.None,e.Easing.Power1=e.Easing.Quadratic.Out,e.Easing.Power2=e.Easing.Cubic.Out,e.Easing.Power3=e.Easing.Quartic.Out,e.Easing.Power4=e.Easing.Quintic.Out,e.Time=function(t){this.game=t,this.time=0,this.prevTime=0,this.now=0,this.elapsed=0,this.elapsedMS=0,this.physicsElapsed=1/60,this.physicsElapsedMS=1/60*1e3,this.desiredFpsMult=1/60,this._desiredFps=60,this.suggestedFps=this.desiredFps,this.slowMotion=1,this.advancedTiming=!1,this.frames=0,this.updates=0,this.renders=0,this.fps=0,this.ups=0,this.rps=0,this.fpsMin=1e3,this.fpsMax=0,this.msMin=1e3,this.msMax=0,this.pauseDuration=0,this.timeToCall=0,this.timeExpected=0,this.events=new e.Timer(this.game,!1),this._frameCount=0,this._elapsedAccumulator=0,this._started=0,this._timeLastSecond=0,this._pauseStarted=0,this._justResumed=!1,this._timers=[]},e.Time.prototype={boot:function(){this._started=Date.now(),this.time=Date.now(),this.events.start(),this.timeExpected=this.time},add:function(t){return this._timers.push(t),t},create:function(t){void 0===t&&(t=!0);var i=new e.Timer(this.game,t);return this._timers.push(i),i},removeAll:function(){for(var t=0;t<this._timers.length;t++)this._timers[t].destroy();this._timers=[],this.events.removeAll()},refresh:function(){var t=this.time;this.time=Date.now(),this.elapsedMS=this.time-t},update:function(t){var e=this.time;this.time=Date.now(),this.elapsedMS=this.time-e,this.prevTime=this.now,this.now=t,this.elapsed=this.now-this.prevTime,this.game.raf._isSetTimeOut&&(this.timeToCall=Math.floor(Math.max(0,1e3/this._desiredFps-(this.timeExpected-t))),this.timeExpected=t+this.timeToCall),this.advancedTiming&&this.updateAdvancedTiming(),this.game.paused||(this.events.update(this.time),this._timers.length&&this.updateTimers())},updateTimers:function(){for(var t=0,e=this._timers.length;t<e;)this._timers[t].update(this.time)?t++:(this._timers.splice(t,1),e--)},updateAdvancedTiming:function(){if(this._frameCount++,this._elapsedAccumulator+=this.elapsed,this._frameCount>=2*this._desiredFps&&(this.suggestedFps=5*Math.floor(200/(this._elapsedAccumulator/this._frameCount)),this._frameCount=0,this._elapsedAccumulator=0),this.msMin=Math.min(this.msMin,this.elapsed),this.msMax=Math.max(this.msMax,this.elapsed),this.frames++,this.now>this._timeLastSecond+1e3){var t=this.now-this._timeLastSecond;this.fps=Math.round(1e3*this.frames/t),this.ups=Math.round(1e3*this.updates/t),this.rps=Math.round(1e3*this.renders/t),this.fpsMin=Math.min(this.fpsMin,this.fps),this.fpsMax=Math.max(this.fpsMax,this.fps),this._timeLastSecond=this.now,this.frames=0,this.updates=0,this.renders=0}},countUpdate:function(){this.advancedTiming&&this.updates++},countRender:function(){this.advancedTiming&&this.renders++},gamePaused:function(){this._pauseStarted=Date.now(),this.events.pause();for(var t=this._timers.length;t--;)this._timers[t]._pause()},gameResumed:function(){this.time=Date.now(),this.pauseDuration=this.time-this._pauseStarted,this.events.resume();for(var t=this._timers.length;t--;)this._timers[t]._resume()},totalElapsedSeconds:function(){return.001*(this.time-this._started)},elapsedSince:function(t){return this.time-t},elapsedSecondsSince:function(t){return.001*(this.time-t)},reset:function(){this._started=this.time,this.removeAll()}},Object.defineProperty(e.Time.prototype,"desiredFps",{get:function(){return this._desiredFps},set:function(t){this._desiredFps=t,this.physicsElapsed=1/t,this.physicsElapsedMS=1e3*this.physicsElapsed,this.desiredFpsMult=1/t}}),e.Time.prototype.constructor=e.Time,e.Timer=function(t,i){void 0===i&&(i=!0),this.game=t,this.running=!1,this.autoDestroy=i,this.expired=!1,this.elapsed=0,this.events=[],this.onComplete=new e.Signal,this.nextTick=0,this.timeCap=1e3,this.paused=!1,this._codePaused=!1,this._started=0,this._pauseStarted=0,this._pauseTotal=0,this._now=Date.now(),this._len=0,this._marked=0,this._i=0,this._diff=0,this._newTick=0},e.Timer.MINUTE=6e4,e.Timer.SECOND=1e3,e.Timer.HALF=500,e.Timer.QUARTER=250,e.Timer.prototype={create:function(t,i,s,n,r,o){var a=t=Math.round(t);0===this._now?a+=this.game.time.time:a+=this._now;var h=new e.TimerEvent(this,t,a,s,i,n,r,o);return this.events.push(h),this.order(),this.expired=!1,h},add:function(t,e,i){return this.create(t,!1,0,e,i,Array.prototype.slice.call(arguments,3))},repeat:function(t,e,i,s){return this.create(t,!1,e,i,s,Array.prototype.slice.call(arguments,4))},loop:function(t,e,i){return this.create(t,!0,0,e,i,Array.prototype.slice.call(arguments,3))},start:function(t){if(!this.running){this._started=this.game.time.time+(t||0),this.running=!0;for(var e=0;e<this.events.length;e++)this.events[e].tick=this.events[e].delay+this._started}},stop:function(t){this.running=!1,void 0===t&&(t=!0),t&&(this.events.length=0)},remove:function(t){for(var e=0;e<this.events.length;e++)if(this.events[e]===t)return this.events[e].pendingDelete=!0,!0;return!1},order:function(){this.events.length>0&&(this.events.sort(this.sortHandler),this.nextTick=this.events[0].tick)},sortHandler:function(t,e){return t.tick<e.tick?-1:t.tick>e.tick?1:0},clearPendingEvents:function(){for(this._i=this.events.length;this._i--;)this.events[this._i].pendingDelete&&this.events.splice(this._i,1);this._len=this.events.length,this._i=0},update:function(t){if(this.paused)return!0;if(this.elapsed=t-this._now,this._now=t,this.elapsed>this.timeCap&&this.adjustEvents(t-this.elapsed),this._marked=0,this.clearPendingEvents(),this.running&&this._now>=this.nextTick&&this._len>0){for(;this._i<this._len&&this.running;){var e=this.events[this._i];if(!(this._now>=e.tick)||e.pendingDelete)break;this._newTick=this._now+e.delay-(this._now-e.tick),this._newTick<0&&(this._newTick=this._now+e.delay),!0===e.loop?(e.tick=this._newTick,e.callback.apply(e.callbackContext,e.args)):e.repeatCount>0?(e.repeatCount--,e.tick=this._newTick,e.callback.apply(e.callbackContext,e.args)):(this._marked++,e.pendingDelete=!0,e.callback.apply(e.callbackContext,e.args)),this._i++}this.events.length>this._marked?this.order():(this.expired=!0,this.onComplete.dispatch(this))}return!this.expired||!this.autoDestroy},pause:function(){this.running&&(this._codePaused=!0,this.paused||(this._pauseStarted=this.game.time.time,this.paused=!0))},_pause:function(){!this.paused&&this.running&&(this._pauseStarted=this.game.time.time,this.paused=!0)},adjustEvents:function(t){for(var e=0;e<this.events.length;e++)if(!this.events[e].pendingDelete){var i=this.events[e].tick-t;i<0&&(i=0),this.events[e].tick=this._now+i}var s=this.nextTick-t;this.nextTick=s<0?this._now:this._now+s},resume:function(){if(this.paused){var t=this.game.time.time;this._pauseTotal+=t-this._now,this._now=t,this.adjustEvents(this._pauseStarted),this.paused=!1,this._codePaused=!1}},_resume:function(){this._codePaused||this.resume()},removeAll:function(){this.onComplete.removeAll(),this.events.length=0,this._len=0,this._i=0},destroy:function(){this.onComplete.removeAll(),this.running=!1,this.expired=!0,this.events=[],this._len=0,this._i=0}},Object.defineProperty(e.Timer.prototype,"next",{get:function(){return this.nextTick}}),Object.defineProperty(e.Timer.prototype,"duration",{get:function(){return this.running&&this.nextTick>this._now?this.nextTick-this._now:0}}),Object.defineProperty(e.Timer.prototype,"length",{get:function(){return this.events.length}}),Object.defineProperty(e.Timer.prototype,"ms",{get:function(){return this.running?this._now-this._started-this._pauseTotal:0}}),Object.defineProperty(e.Timer.prototype,"seconds",{get:function(){return this.running?.001*this.ms:0}}),e.Timer.prototype.constructor=e.Timer,e.TimerEvent=function(t,e,i,s,n,r,o,a){this.timer=t,this.delay=e,this.tick=i,this.repeatCount=s-1,this.loop=n,this.callback=r,this.callbackContext=o,this.args=a,this.pendingDelete=!1},e.TimerEvent.prototype.constructor=e.TimerEvent,e.AnimationManager=function(t){this.sprite=t,this.game=t.game,this.currentFrame=null,this.currentAnim=null,this.updateIfVisible=!0,this.isLoaded=!1,this._frameData=null,this._anims={},this._outputFrames=[]},e.AnimationManager.prototype={loadFrameData:function(t,e){if(void 0===t)return!1;if(this.isLoaded)for(var i in this._anims)this._anims[i].updateFrameData(t);return this._frameData=t,void 0===e||null===e?this.frame=0:"string"==typeof e?this.frameName=e:this.frame=e,this.isLoaded=!0,!0},copyFrameData:function(t,e){if(this._frameData=t.clone(),this.isLoaded)for(var i in this._anims)this._anims[i].updateFrameData(this._frameData);return void 0===e||null===e?this.frame=0:"string"==typeof e?this.frameName=e:this.frame=e,this.isLoaded=!0,!0},add:function(t,i,s,n,r){return i=i||[],s=s||60,void 0===n&&(n=!1),void 0===r&&(r=!(!i||"number"!=typeof i[0])),this._outputFrames=[],this._frameData.getFrameIndexes(i,r,this._outputFrames),this._anims[t]=new e.Animation(this.game,this.sprite,t,this._frameData,this._outputFrames,s,n),this.currentAnim=this._anims[t],this.sprite.tilingTexture&&(this.sprite.refreshTexture=!0),this._anims[t]},validateFrames:function(t,e){void 0===e&&(e=!0);for(var i=0;i<t.length;i++)if(!0===e){if(t[i]>this._frameData.total)return!1}else if(!1===this._frameData.checkFrameName(t[i]))return!1;return!0},play:function(t,e,i,s){if(this._anims[t])return this.currentAnim===this._anims[t]?!1===this.currentAnim.isPlaying?(this.currentAnim.paused=!1,this.currentAnim.play(e,i,s)):this.currentAnim:(this.currentAnim&&this.currentAnim.isPlaying&&this.currentAnim.stop(),this.currentAnim=this._anims[t],this.currentAnim.paused=!1,this.currentFrame=this.currentAnim.currentFrame,this.currentAnim.play(e,i,s))},stop:function(t,e){void 0===e&&(e=!1),!this.currentAnim||"string"==typeof t&&t!==this.currentAnim.name||this.currentAnim.stop(e)},update:function(){return!(this.updateIfVisible&&!this.sprite.visible)&&(!(!this.currentAnim||!this.currentAnim.update())&&(this.currentFrame=this.currentAnim.currentFrame,!0))},next:function(t){this.currentAnim&&(this.currentAnim.next(t),this.currentFrame=this.currentAnim.currentFrame)},previous:function(t){this.currentAnim&&(this.currentAnim.previous(t),this.currentFrame=this.currentAnim.currentFrame)},getAnimation:function(t){return"string"==typeof t&&this._anims[t]?this._anims[t]:null},refreshFrame:function(){},destroy:function(){t=null;for(var t in this._anims)this._anims.hasOwnProperty(t)&&this._anims[t].destroy();this._anims={},this._outputFrames=[],this._frameData=null,this.currentAnim=null,this.currentFrame=null,this.sprite=null,this.game=null}},e.AnimationManager.prototype.constructor=e.AnimationManager,Object.defineProperty(e.AnimationManager.prototype,"frameData",{get:function(){return this._frameData}}),Object.defineProperty(e.AnimationManager.prototype,"frameTotal",{get:function(){return this._frameData.total}}),Object.defineProperty(e.AnimationManager.prototype,"paused",{get:function(){return this.currentAnim.isPaused},set:function(t){this.currentAnim.paused=t}}),Object.defineProperty(e.AnimationManager.prototype,"name",{get:function(){return this.currentAnim?this.currentAnim.name:void 0}}),Object.defineProperty(e.AnimationManager.prototype,"frame",{get:function(){return this.currentFrame?this.currentFrame.index:void 0},set:function(t){var e;"number"==typeof t&&this._frameData&&(e=this._frameData.getFrame(t))&&(this.currentFrame=e,this.sprite.setFrame(this.currentFrame))}}),Object.defineProperty(e.AnimationManager.prototype,"frameName",{get:function(){return this.currentFrame?this.currentFrame.name:void 0},set:function(t){var e;"string"==typeof t&&this._frameData&&(e=this._frameData.getFrameByName(t))?(this.currentFrame=e,this._frameIndex=this.currentFrame.index,this.sprite.setFrame(this.currentFrame)):console.warn("Cannot set frameName: "+t)}}),e.Animation=function(t,i,s,n,r,o,a){void 0===a&&(a=!1),this.game=t,this._parent=i,this._frameData=n,this.name=s,this._frames=[],this._frames=this._frames.concat(r),this.delay=1e3/o,this.loop=a,this.loopCount=0,this.killOnComplete=!1,this.isFinished=!1,this.isPlaying=!1,this.isPaused=!1,this._pauseStartTime=0,this._frameIndex=0,this._frameDiff=0,this._frameSkip=1,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.onStart=new e.Signal,this.onUpdate=null,this.onComplete=new e.Signal,this.onLoop=new e.Signal,this.isReversed=!1,this.game.onPause.add(this.onPause,this),this.game.onResume.add(this.onResume,this)},e.Animation.prototype={play:function(t,e,i){return"number"==typeof t&&(this.delay=1e3/t),"boolean"==typeof e&&(this.loop=e),void 0!==i&&(this.killOnComplete=i),this.isPlaying=!0,this.isFinished=!1,this.paused=!1,this.loopCount=0,this._timeLastFrame=this.game.time.time,this._timeNextFrame=this.game.time.time+this.delay,this._frameIndex=this.isReversed?this._frames.length-1:0,this.updateCurrentFrame(!1,!0),this._parent.events.onAnimationStart$dispatch(this._parent,this),this.onStart.dispatch(this._parent,this),this._parent.animations.currentAnim=this,this._parent.animations.currentFrame=this.currentFrame,this},restart:function(){this.isPlaying=!0,this.isFinished=!1,this.paused=!1,this.loopCount=0,this._timeLastFrame=this.game.time.time,this._timeNextFrame=this.game.time.time+this.delay,this._frameIndex=0,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this._parent.setFrame(this.currentFrame),this._parent.animations.currentAnim=this,this._parent.animations.currentFrame=this.currentFrame,this.onStart.dispatch(this._parent,this)},reverse:function(){return this.reversed=!this.reversed,this},reverseOnce:function(){return this.onComplete.addOnce(this.reverse,this),this.reverse()},setFrame:function(t,e){var i;if(void 0===e&&(e=!1),"string"==typeof t)for(s=0;s<this._frames.length;s++)this._frameData.getFrame(this._frames[s]).name===t&&(i=s);else if("number"==typeof t)if(e)i=t;else for(var s=0;s<this._frames.length;s++)this._frames[s]===t&&(i=s);if(i){var n=this.isReversed?-1:1;this._frameIndex=i-n,this._timeNextFrame=this.game.time.time,this.update()}},stop:function(t,e){void 0===t&&(t=!1),void 0===e&&(e=!1),this.isPlaying=!1,this.isFinished=!0,this.paused=!1,t&&(this.currentFrame=this._frameData.getFrame(this._frames[0]),this._parent.setFrame(this.currentFrame)),e&&(this._parent.events.onAnimationComplete$dispatch(this._parent,this),this.onComplete.dispatch(this._parent,this))},onPause:function(){this.isPlaying&&(this._frameDiff=this._timeNextFrame-this.game.time.time)},onResume:function(){this.isPlaying&&(this._timeNextFrame=this.game.time.time+this._frameDiff)},update:function(){if(this.isPaused)return!1;var t=this.game.time.time,e=t-this._timeNextFrame;return!!(this.isPlaying&&e>=0)&&(this._frameSkip=1,this._frameDiff=e,this._timeLastFrame=t,this._frameDiff>this.delay&&(this._frameSkip=Math.floor(this._frameDiff/this.delay),this._frameDiff-=this._frameSkip*this.delay),this._timeNextFrame=t+(this.delay-this._frameDiff),this.isReversed?this._frameIndex-=this._frameSkip:this._frameIndex+=this._frameSkip,!this.isReversed&&this._frameIndex>=this._frames.length||this.isReversed&&this._frameIndex<=-1?this.loop?(this._frameIndex=Math.abs(this._frameIndex)%this._frames.length,this.isReversed&&(this._frameIndex=this._frames.length-1-this._frameIndex),this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&this._parent.setFrame(this.currentFrame),this.loopCount++,this._parent.events.onAnimationLoop$dispatch(this._parent,this),this.onLoop.dispatch(this._parent,this),!this.onUpdate||(this.onUpdate.dispatch(this,this.currentFrame),!!this._frameData)):(this.complete(),!1):this.updateCurrentFrame(!0))},updateCurrentFrame:function(t,e){if(void 0===e&&(e=!1),!this._frameData)return!1;var i=this.currentFrame.index;return this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&(e||i!==this.currentFrame.index)&&this._parent.setFrame(this.currentFrame),!this.onUpdate||!t||(this.onUpdate.dispatch(this,this.currentFrame),!!this._frameData)},next:function(t){void 0===t&&(t=1);var e=this._frameIndex+t;e>=this._frames.length&&(this.loop?e%=this._frames.length:e=this._frames.length-1),e!==this._frameIndex&&(this._frameIndex=e,this.updateCurrentFrame(!0))},previous:function(t){void 0===t&&(t=1);var e=this._frameIndex-t;e<0&&(this.loop?e=this._frames.length+e:e++),e!==this._frameIndex&&(this._frameIndex=e,this.updateCurrentFrame(!0))},updateFrameData:function(t){this._frameData=t,this.currentFrame=this._frameData?this._frameData.getFrame(this._frames[this._frameIndex%this._frames.length]):null},destroy:function(){this._frameData&&(this.game.onPause.remove(this.onPause,this),this.game.onResume.remove(this.onResume,this),this.game=null,this._parent=null,this._frames=null,this._frameData=null,this.currentFrame=null,this.isPlaying=!1,this.onStart.dispose(),this.onLoop.dispose(),this.onComplete.dispose(),this.onUpdate&&this.onUpdate.dispose())},complete:function(){this._frameIndex=this._frames.length-1,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.updateCurrentFrame(!1),this.isPlaying=!1,this.isFinished=!0,this.paused=!1,this._parent.events.onAnimationComplete$dispatch(this._parent,this),this.onComplete.dispatch(this._parent,this),this.killOnComplete&&this._parent.kill()}},e.Animation.prototype.constructor=e.Animation,Object.defineProperty(e.Animation.prototype,"paused",{get:function(){return this.isPaused},set:function(t){this.isPaused=t,t?this._pauseStartTime=this.game.time.time:this.isPlaying&&(this._timeNextFrame=this.game.time.time+this.delay)}}),Object.defineProperty(e.Animation.prototype,"reversed",{get:function(){return this.isReversed},set:function(t){this.isReversed=t}}),Object.defineProperty(e.Animation.prototype,"frameTotal",{get:function(){return this._frames.length}}),Object.defineProperty(e.Animation.prototype,"frame",{get:function(){return null!==this.currentFrame?this.currentFrame.index:this._frameIndex},set:function(t){this.currentFrame=this._frameData.getFrame(this._frames[t]),null!==this.currentFrame&&(this._frameIndex=t,this._parent.setFrame(this.currentFrame),this.onUpdate&&this.onUpdate.dispatch(this,this.currentFrame))}}),Object.defineProperty(e.Animation.prototype,"speed",{get:function(){return 1e3/this.delay},set:function(t){t>0&&(this.delay=1e3/t)}}),Object.defineProperty(e.Animation.prototype,"enableUpdate",{get:function(){return null!==this.onUpdate},set:function(t){t&&null===this.onUpdate?this.onUpdate=new e.Signal:t||null===this.onUpdate||(this.onUpdate.dispose(),this.onUpdate=null)}}),e.Animation.generateFrameNames=function(t,i,s,n,r){void 0===n&&(n="");var o=[],a="";if(i<s)for(h=i;h<=s;h++)a=t+(a="number"==typeof r?e.Utils.pad(h.toString(),r,"0",1):h.toString())+n,o.push(a);else for(var h=i;h>=s;h--)a=t+(a="number"==typeof r?e.Utils.pad(h.toString(),r,"0",1):h.toString())+n,o.push(a);return o},e.Frame=function(t,i,s,n,r,o){this.index=t,this.x=i,this.y=s,this.width=n,this.height=r,0!==this.width&&0!==this.height||console.warn('Phaser.Frame: Frame "'+this.name+'" has a width or height of zero'),this.name=o,this.centerX=Math.floor(n/2),this.centerY=Math.floor(r/2),this.distance=e.Math.distance(0,0,n,r),this.rotated=!1,this.trimmed=!1,this.sourceSizeW=n,this.sourceSizeH=r,this.spriteSourceSizeX=0,this.spriteSourceSizeY=0,this.spriteSourceSizeW=0,this.spriteSourceSizeH=0,this.right=this.x+this.width,this.bottom=this.y+this.height},e.Frame.prototype={resize:function(t,i){this.width=t,this.height=i,this.centerX=Math.floor(t/2),this.centerY=Math.floor(i/2),this.distance=e.Math.distance(0,0,t,i),this.sourceSizeW=t,this.sourceSizeH=i,this.right=this.x+t,this.bottom=this.y+i},setTrim:function(t,e,i,s,n,r,o){this.trimmed=t,t&&(this.sourceSizeW=e,this.sourceSizeH=i,this.centerX=Math.floor(e/2),this.centerY=Math.floor(i/2),this.spriteSourceSizeX=s,this.spriteSourceSizeY=n,this.spriteSourceSizeW=r,this.spriteSourceSizeH=o)},clone:function(){var t=new e.Frame(this.index,this.x,this.y,this.width,this.height,this.name);for(var i in this)this.hasOwnProperty(i)&&(t[i]=this[i]);return t},getRect:function(t){return void 0===t?t=new e.Rectangle(this.x,this.y,this.width,this.height):t.setTo(this.x,this.y,this.width,this.height),t}},e.Frame.prototype.constructor=e.Frame,e.FrameData=function(){this._frames=[],this._frameNames=[]},e.FrameData.prototype={addFrame:function(t){return t.index=this._frames.length,this._frames.push(t),""!==t.name&&(this._frameNames[t.name]=t.index),t},getFrame:function(t){return t>=this._frames.length&&(t=0),this._frames[t]},getFrameByName:function(t){return"number"==typeof this._frameNames[t]?this._frames[this._frameNames[t]]:null},checkFrameName:function(t){return null!=this._frameNames[t]},clone:function(){for(var t=new e.FrameData,i=0;i<this._frames.length;i++)t._frames.push(this._frames[i].clone());for(var s in this._frameNames)this._frameNames.hasOwnProperty(s)&&(t._frameNames[s]=this._frameNames[s]);return t},getFrameRange:function(t,e,i){void 0===i&&(i=[]);for(var s=t;s<=e;s++)i.push(this._frames[s]);return i},getFrames:function(t,e,i){if(void 0===e&&(e=!0),void 0===i&&(i=[]),void 0===t||0===t.length)for(s=0;s<this._frames.length;s++)i.push(this._frames[s]);else for(var s=0;s<t.length;s++)e?i.push(this.getFrame(t[s])):i.push(this.getFrameByName(t[s]));return i},getFrameIndexes:function(t,e,i){if(void 0===e&&(e=!0),void 0===i&&(i=[]),void 0===t||0===t.length)for(s=0;s<this._frames.length;s++)i.push(this._frames[s].index);else for(var s=0;s<t.length;s++)e&&this._frames[t[s]]?i.push(this._frames[t[s]].index):this.getFrameByName(t[s])&&i.push(this.getFrameByName(t[s]).index);return i},destroy:function(){this._frames=null,this._frameNames=null}},e.FrameData.prototype.constructor=e.FrameData,Object.defineProperty(e.FrameData.prototype,"total",{get:function(){return this._frames.length}}),e.AnimationParser={spriteSheet:function(t,i,s,n,r,o,a,h){void 0===r&&(r=-1),void 0===o&&(o=0),void 0===a&&(a=0),void 0===h&&(h=0);var l=i;if("string"==typeof i?l=t.cache.getImage(i):i=l.name,null===l)return null;if(s<=0||n<=0)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' frameWidth (%s) or frameHeight (%s) must be positive",i,s,n),null;var c=l.width,u=l.height;if(0===c||0===u)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' width (%s) or height (%s) is zero",i,c,u),null;if(c<s||u<n)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' width (%s) or height (%s) is less than the given frameWidth (%s) or frameHeight (%s)",i,c,u,s,n),null;var d=Math.floor((c-o)/(s+a)),p=Math.floor((u-o)/(n+a)),f=d*p,g=f,m=f-1,y=0,v=m;if(h>f||h<-f)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' skipFrames = %s is larger than the frame total %s",i,h,f),null;if(r>-1&&(v=(f=r)-1),d<1&&console.warn("Phaser.AnimationParser.spriteSheet: image '%s' has width %d, but it should be at least %d (frameWidth=%s, margin=%s, spacing=%s)",i,c,s+o+a,s,o,a),p<1&&console.warn("Phaser.AnimationParser.spriteSheet: image '%s' has height %d, but it should be at least %d (frameHeight=%s, margin=%s, spacing=%s)",i,u,n+o+a,n,o,a),0===g)return console.warn("Phaser.AnimationParser.spriteSheet: '%s' zero frames were produced",i),null;if(h>0?v=(y=h)+(f=Math.min(f,g-h))-1:h<0&&(y=(v=m+h)-(f=Math.min(f,g+h))+1),y<0)return console.warn("First frame index %s is outside of range [0, %d]",y,m),null;if(v>m)return console.warn("Last frame index %s is outside of range [0, %d]",v,m),null;for(var x=new e.FrameData,b=o,_=o,w=0,T=0;T<g&&!(T>v);T++)T>=y&&x.addFrame(new e.Frame(w++,b,_,s,n,"")),(b+=s+a)+s>c&&(b=o,_+=n+a);return x},JSONData:function(t,i){if(!i.frames)return console.warn("Phaser.AnimationParser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array"),void console.log(i);for(var s,n=new e.FrameData,r=i.frames,o=0;o<r.length;o++)s=n.addFrame(new e.Frame(o,r[o].frame.x,r[o].frame.y,r[o].frame.w,r[o].frame.h,r[o].filename)),r[o].trimmed&&s.setTrim(r[o].trimmed,r[o].sourceSize.w,r[o].sourceSize.h,r[o].spriteSourceSize.x,r[o].spriteSourceSize.y,r[o].spriteSourceSize.w,r[o].spriteSourceSize.h),r[o].rotated&&(s.rotated=!0);return n},JSONDataPyxel:function(t,i){if(["layers","tilewidth","tileheight","tileswide","tileshigh"].forEach(function(t){if(!i[t])return console.warn('Phaser.AnimationParser.JSONDataPyxel: Invalid Pyxel Tilemap JSON given, missing "'+t+'" key.'),void console.log(i)}),1!==i.layers.length)return console.warn("Phaser.AnimationParser.JSONDataPyxel: Too many layers, this parser only supports flat Tilemaps."),void console.log(i);for(var s=new e.FrameData,n=i.tileheight,r=i.tilewidth,o=i.layers[0].tiles,a=0;a<o.length;a++)s.addFrame(new e.Frame(a,o[a].x,o[a].y,r,n,"frame_"+a)).setTrim(!1);return s},JSONDataHash:function(t,i){if(!i.frames)return console.warn("Phaser.AnimationParser.JSONDataHash: Invalid Texture Atlas JSON given, missing 'frames' object"),void console.log(i);var s,n=new e.FrameData,r=i.frames,o=0;for(var a in r)s=n.addFrame(new e.Frame(o,r[a].frame.x,r[a].frame.y,r[a].frame.w,r[a].frame.h,a)),r[a].trimmed&&s.setTrim(r[a].trimmed,r[a].sourceSize.w,r[a].sourceSize.h,r[a].spriteSourceSize.x,r[a].spriteSourceSize.y,r[a].spriteSourceSize.w,r[a].spriteSourceSize.h),r[a].rotated&&(s.rotated=!0),o++;return n},XMLData:function(t,i){if(i.getElementsByTagName("TextureAtlas")){for(var s,n,r,o,a,h,l,c,u,d,p,f=new e.FrameData,g=i.getElementsByTagName("SubTexture"),m=0;m<g.length;m++)n=(r=g[m].attributes).name.value,o=parseInt(r.x.value,10),a=parseInt(r.y.value,10),h=parseInt(r.width.value,10),l=parseInt(r.height.value,10),c=null,u=null,r.frameX&&(c=Math.abs(parseInt(r.frameX.value,10)),u=Math.abs(parseInt(r.frameY.value,10)),d=parseInt(r.frameWidth.value,10),p=parseInt(r.frameHeight.value,10)),s=f.addFrame(new e.Frame(m,o,a,h,l,n)),null===c&&null===u||s.setTrim(!0,h,l,c,u,d,p);return f}console.warn("Phaser.AnimationParser.XMLData: Invalid Texture Atlas XML given, missing <TextureAtlas> tag")}},e.Cache=function(t){this.game=t,this.autoResolveURL=!1,this._cache={canvas:{},image:{},texture:{},sound:{},video:{},text:{},json:{},xml:{},physics:{},tilemap:{},binary:{},bitmapData:{},bitmapFont:{},shader:{},renderTexture:{},compressedTexture:{}},this._urlMap={},this._urlResolver=new Image,this._urlTemp=null,this.onSoundUnlock=new e.Signal,this._cacheMap=[],this._cacheMap[e.Cache.CANVAS]=this._cache.canvas,this._cacheMap[e.Cache.IMAGE]=this._cache.image,this._cacheMap[e.Cache.TEXTURE]=this._cache.texture,this._cacheMap[e.Cache.SOUND]=this._cache.sound,this._cacheMap[e.Cache.TEXT]=this._cache.text,this._cacheMap[e.Cache.PHYSICS]=this._cache.physics,this._cacheMap[e.Cache.TILEMAP]=this._cache.tilemap,this._cacheMap[e.Cache.BINARY]=this._cache.binary,this._cacheMap[e.Cache.BITMAPDATA]=this._cache.bitmapData,this._cacheMap[e.Cache.BITMAPFONT]=this._cache.bitmapFont,this._cacheMap[e.Cache.JSON]=this._cache.json,this._cacheMap[e.Cache.XML]=this._cache.xml,this._cacheMap[e.Cache.VIDEO]=this._cache.video,this._cacheMap[e.Cache.SHADER]=this._cache.shader,this._cacheMap[e.Cache.RENDER_TEXTURE]=this._cache.renderTexture,this._pendingCount=0,this.onReady=new e.Signal,this._addImages()},e.Cache.CANVAS=1,e.Cache.IMAGE=2,e.Cache.TEXTURE=3,e.Cache.SOUND=4,e.Cache.TEXT=5,e.Cache.PHYSICS=6,e.Cache.TILEMAP=7,e.Cache.BINARY=8,e.Cache.BITMAPDATA=9,e.Cache.BITMAPFONT=10,e.Cache.JSON=11,e.Cache.XML=12,e.Cache.VIDEO=13,e.Cache.SHADER=14,e.Cache.RENDER_TEXTURE=15,e.Cache.DEFAULT=null,e.Cache.DEFAULT_KEY="__default",e.Cache.DEFAULT_SRC="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==",e.Cache.MISSING=null,e.Cache.MISSING_KEY="__missing",e.Cache.MISSING_SRC="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==",e.Cache.READY_TIMEOUT=1e3,e.Cache.prototype={addCompressedTextureMetaData:function(t,i,s,n){this.checkImageKey(t)&&this.removeImage(t);var r=s in e.LoaderParser?e.LoaderParser[s](n):n,o={key:t,url:i,data:r,base:new PIXI.BaseTexture(r,null,this.game.resolution),frame:new e.Frame(0,0,0,r.width,r.height,t),frameData:new e.FrameData,fileFormat:s};return o.frameData.addFrame(new e.Frame(0,0,0,r.width,r.height,i)),this._cache.image[t]=o,this._resolveURL(i,o),o},addCanvas:function(t,e,i){void 0===i&&(i=e.getContext("2d")),this._cache.canvas[t]={canvas:e,context:i}},addImage:function(t,i,s){this.checkImageKey(t)&&this.removeImage(t),!1===s.complete&&console.warn('Phaser.Cache.addImage: Image "%s" is not complete',t);var n={key:t,url:i,data:s,base:new PIXI.BaseTexture(s,null,this.game.resolution),frame:new e.Frame(0,0,0,s.width,s.height,t),frameData:new e.FrameData};return n.frameData.addFrame(new e.Frame(0,0,0,s.width,s.height,i)),this._cache.image[t]=n,this._resolveURL(i,n),"__default"===t?e.Cache.DEFAULT=new PIXI.Texture(n.base):"__missing"===t&&(e.Cache.MISSING=new PIXI.Texture(n.base)),n},addImageAsync:function(t,e,i){var s=this,n=new Image;n.onload=function(){i.call(this,s.addImage(t,null,n)),s._removePending(),n.onload=null},this._addPending(),n.src=e},addDefaultImage:function(){this.addImageAsync(e.Cache.DEFAULT_KEY,e.Cache.DEFAULT_SRC,function(t){t.base.skipRender=!0,e.Cache.DEFAULT=new PIXI.Texture(t.base)})},addMissingImage:function(){this.addImageAsync(e.Cache.MISSING_KEY,e.Cache.MISSING_SRC,function(t){e.Cache.MISSING=new PIXI.Texture(t.base)})},addSound:function(t,e,i,s,n){void 0===s&&(s=!0,n=!1),void 0===n&&(s=!1,n=!0);var r=!1;n&&(r=!0),this._cache.sound[t]={url:e,data:i,isDecoding:!1,decoded:r,webAudio:s,audioTag:n,locked:this.game.sound.touchLocked},this._resolveURL(e,this._cache.sound[t])},addText:function(t,e,i){this._cache.text[t]={url:e,data:i},this._resolveURL(e,this._cache.text[t])},addPhysicsData:function(t,e,i,s){this._cache.physics[t]={url:e,data:i,format:s},this._resolveURL(e,this._cache.physics[t])},addTilemap:function(t,e,i,s){this._cache.tilemap[t]={url:e,data:i,format:s},this._resolveURL(e,this._cache.tilemap[t])},addBinary:function(t,e){this._cache.binary[t]=e},addBitmapData:function(t,i,s){return i.key=t,void 0===s&&(s=new e.FrameData).addFrame(i.textureFrame),this._cache.bitmapData[t]={data:i,frameData:s},i},addBitmapFont:function(t,i,s,n,r,o,a){var h={url:i,data:s,font:null,base:new PIXI.BaseTexture(s,null,this.game.resolution)};void 0===o&&(o=0),void 0===a&&(a=0),h.font="json"===r?e.LoaderParser.jsonBitmapFont(n,h.base,o,a,!1,this.game.resolution):e.LoaderParser.xmlBitmapFont(n,h.base,o,a,!1,this.game.resolution),this._cache.bitmapFont[t]=h,this._resolveURL(i,h)},addBitmapFontFromAtlas:function(t,i,s,n,r,o,a){var h=this.getFrameByName(i,s);if(h){var l={font:null,base:this.getBaseTexture(i),frame:h};void 0===o&&(o=0),void 0===a&&(a=0);var c;"json"===r?(c=this.getJSON(n),l.font=e.LoaderParser.jsonBitmapFont(c,l.base,o,a,h,this.game.resolution)):(c=this.getXML(n),l.font=e.LoaderParser.xmlBitmapFont(c,l.base,o,a,h,this.game.resolution)),this._cache.bitmapFont[t]=l}},addJSON:function(t,e,i){this._cache.json[t]={url:e,data:i},this._resolveURL(e,this._cache.json[t])},addXML:function(t,e,i){this._cache.xml[t]={url:e,data:i},this._resolveURL(e,this._cache.xml[t])},addVideo:function(t,e,i,s){this._cache.video[t]={url:e,data:i,isBlob:s,locked:!0},this._resolveURL(e,this._cache.video[t])},addShader:function(t,e,i){this._cache.shader[t]={url:e,data:i},this._resolveURL(e,this._cache.shader[t])},addRenderTexture:function(t,i){this._cache.renderTexture[t]={texture:i,frame:new e.Frame(0,0,0,i.width,i.height,"","")}},addSpriteSheet:function(t,i,s,n,r,o,a,h,l){void 0===o&&(o=-1),void 0===a&&(a=0),void 0===h&&(h=0);var c={key:t,url:i,data:s,frameWidth:n,frameHeight:r,margin:a,spacing:h,base:new PIXI.BaseTexture(s,null,this.game.resolution),frameData:e.AnimationParser.spriteSheet(this.game,s,n,r,o,a,h,l)};this._cache.image[t]=c,this._resolveURL(i,c)},addTextureAtlas:function(t,i,s,n,r){var o={key:t,url:i,data:s,base:new PIXI.BaseTexture(s,null,this.game.resolution)};r===e.Loader.TEXTURE_ATLAS_XML_STARLING?o.frameData=e.AnimationParser.XMLData(this.game,n,t):r===e.Loader.TEXTURE_ATLAS_JSON_PYXEL?o.frameData=e.AnimationParser.JSONDataPyxel(this.game,n,t):Array.isArray(n.frames)?o.frameData=e.AnimationParser.JSONData(this.game,n,t):o.frameData=e.AnimationParser.JSONDataHash(this.game,n,t),this._cache.image[t]=o,this._resolveURL(i,o)},reloadSound:function(t){var e=this,i=this.getSound(t);i&&(i.data.src=i.url,i.data.addEventListener("canplaythrough",function(){return e.reloadSoundComplete(t)},!1),i.data.load())},reloadSoundComplete:function(t){var e=this.getSound(t);e&&(e.locked=!1,this.onSoundUnlock.dispatch(t))},updateSound:function(t,e,i){var s=this.getSound(t);s&&(s[e]=i)},decodedSound:function(t,e){var i=this.getSound(t);i.data=e,i.decoded=!0,i.isDecoding=!1},isSoundDecoded:function(t){var i=this.getItem(t,e.Cache.SOUND,"isSoundDecoded");if(i)return i.decoded},isSoundReady:function(t){var i=this.getItem(t,e.Cache.SOUND,"isSoundDecoded");if(i)return i.decoded&&!this.game.sound.touchLocked},checkKey:function(t,e){return!!this._cacheMap[t][e]},checkURL:function(t){return!!this._urlMap[this._resolveURL(t)]},checkCanvasKey:function(t){return this.checkKey(e.Cache.CANVAS,t)},checkImageKey:function(t){return this.checkKey(e.Cache.IMAGE,t)},checkTextureKey:function(t){return this.checkKey(e.Cache.TEXTURE,t)},checkSoundKey:function(t){return this.checkKey(e.Cache.SOUND,t)},checkTextKey:function(t){return this.checkKey(e.Cache.TEXT,t)},checkPhysicsKey:function(t){return this.checkKey(e.Cache.PHYSICS,t)},checkTilemapKey:function(t){return this.checkKey(e.Cache.TILEMAP,t)},checkBinaryKey:function(t){return this.checkKey(e.Cache.BINARY,t)},checkBitmapDataKey:function(t){return this.checkKey(e.Cache.BITMAPDATA,t)},checkBitmapFontKey:function(t){return this.checkKey(e.Cache.BITMAPFONT,t)},checkJSONKey:function(t){return this.checkKey(e.Cache.JSON,t)},checkXMLKey:function(t){return this.checkKey(e.Cache.XML,t)},checkVideoKey:function(t){return this.checkKey(e.Cache.VIDEO,t)},checkShaderKey:function(t){return this.checkKey(e.Cache.SHADER,t)},checkRenderTextureKey:function(t){return this.checkKey(e.Cache.RENDER_TEXTURE,t)},getItem:function(t,e,i,s){return this.checkKey(e,t)?void 0===s?this._cacheMap[e][t]:this._cacheMap[e][t][s]:(i&&console.warn("Phaser.Cache."+i+': Key "'+t+'" not found in Cache.'),null)},getCanvas:function(t){return this.getItem(t,e.Cache.CANVAS,"getCanvas","canvas")},getImage:function(t,i){void 0!==t&&null!==t||(t="__default"),void 0===i&&(i=!1);var s=this.getItem(t,e.Cache.IMAGE,"getImage");return null===s&&(s=this.getItem("__missing",e.Cache.IMAGE,"getImage")),i?s:s.data},getTextureFrame:function(t){return this.getItem(t,e.Cache.TEXTURE,"getTextureFrame","frame")},getSound:function(t){return this.getItem(t,e.Cache.SOUND,"getSound")},getSoundData:function(t){return this.getItem(t,e.Cache.SOUND,"getSoundData","data")},getText:function(t){return this.getItem(t,e.Cache.TEXT,"getText","data")},getPhysicsData:function(t,i,s){var n=this.getItem(t,e.Cache.PHYSICS,"getPhysicsData","data");if(null===n||void 0===i||null===i)return n;if(n[i]){var r=n[i];if(!r||!s)return r;for(var o in r)if((o=r[o]).fixtureKey===s)return o;console.warn('Phaser.Cache.getPhysicsData: Could not find given fixtureKey: "'+s+" in "+t+'"')}else console.warn('Phaser.Cache.getPhysicsData: Invalid key/object: "'+t+" / "+i+'"');return null},getTilemapData:function(t){return this.getItem(t,e.Cache.TILEMAP,"getTilemapData")},getBinary:function(t){return this.getItem(t,e.Cache.BINARY,"getBinary")},getBitmapData:function(t){return this.getItem(t,e.Cache.BITMAPDATA,"getBitmapData","data")},getBitmapFont:function(t){return this.getItem(t,e.Cache.BITMAPFONT,"getBitmapFont")},getJSON:function(t,i){var s=this.getItem(t,e.Cache.JSON,"getJSON","data");return s?i?e.Utils.extend(!0,Array.isArray(s)?[]:{},s):s:null},getXML:function(t){return this.getItem(t,e.Cache.XML,"getXML","data")},getVideo:function(t){return this.getItem(t,e.Cache.VIDEO,"getVideo")},getShader:function(t){return this.getItem(t,e.Cache.SHADER,"getShader","data")},getRenderTexture:function(t){return this.getItem(t,e.Cache.RENDER_TEXTURE,"getRenderTexture")},getBaseTexture:function(t,i){return void 0===i&&(i=e.Cache.IMAGE),this.getItem(t,i,"getBaseTexture","base")},getFrame:function(t,i){return void 0===i&&(i=e.Cache.IMAGE),this.getItem(t,i,"getFrame","frame")},getFrameCount:function(t,e){var i=this.getFrameData(t,e);return i?i.total:0},getFrameData:function(t,i){return void 0===i&&(i=e.Cache.IMAGE),this.getItem(t,i,"getFrameData","frameData")},hasFrameData:function(t,i){return void 0===i&&(i=e.Cache.IMAGE),null!==this.getItem(t,i,"","frameData")},updateFrameData:function(t,i,s){void 0===s&&(s=e.Cache.IMAGE),this._cacheMap[s][t]&&(this._cacheMap[s][t].frameData=i)},getFrameByIndex:function(t,e,i){var s=this.getFrameData(t,i);return s?s.getFrame(e):null},getFrameByName:function(t,e,i){var s=this.getFrameData(t,i);return s?s.getFrameByName(e):null},getURL:function(t){return(t=this._resolveURL(t))?this._urlMap[t]:(console.warn('Phaser.Cache.getUrl: Invalid url: "'+t+'" or Cache.autoResolveURL was false'),null)},getKeys:function(t){void 0===t&&(t=e.Cache.IMAGE);var i=[];if(this._cacheMap[t])for(var s in this._cacheMap[t])"__default"!==s&&"__missing"!==s&&i.push(s);return i},removeCanvas:function(t){delete this._cache.canvas[t]},removeImage:function(t,e){void 0===e&&(e=!0);var i=this.getImage(t,!0);e&&i.base&&i.base.destroy(),delete this._cache.image[t]},removeSound:function(t){delete this._cache.sound[t]},removeText:function(t){delete this._cache.text[t]},removePhysics:function(t){delete this._cache.physics[t]},removeTilemap:function(t){delete this._cache.tilemap[t]},removeBinary:function(t){delete this._cache.binary[t]},removeBitmapData:function(t){delete this._cache.bitmapData[t]},removeBitmapFont:function(t){delete this._cache.bitmapFont[t]},removeJSON:function(t){delete this._cache.json[t]},removeXML:function(t){delete this._cache.xml[t]},removeVideo:function(t){delete this._cache.video[t]},removeShader:function(t){delete this._cache.shader[t]},removeRenderTexture:function(t){delete this._cache.renderTexture[t]},removeSpriteSheet:function(t){delete this._cache.spriteSheet[t]},removeTextureAtlas:function(t){delete this._cache.image[t]},clearGLTextures:function(){for(var t in this._cache.image)this._cache.image[t].base._glTextures=[]},_resolveURL:function(t,e){return this.autoResolveURL?(this._urlResolver.src=this.game.load.baseURL+t,this._urlTemp=this._urlResolver.src,this._urlResolver.src="",e&&(this._urlMap[this._urlTemp]=e),this._urlTemp):null},destroy:function(){for(var t=0;t<this._cacheMap.length;t++){var e=this._cacheMap[t];for(var i in e)"__default"!==i&&"__missing"!==i&&(this.destroyItem(e[i]),delete e[i])}this._urlMap=null,this._urlResolver=null,this._urlTemp=null},destroyItem:function(t){t.destroy?t.destroy():(t.base&&t.base.destroy&&t.base.destroy(),t.data&&t.data.destroy&&t.data.destroy(),t.frameData&&t.frameData.destroy&&t.frameData.destroy(),t.texture&&t.texture.destroy&&t.texture.destroy(!0))},_addImages:function(){this._pendingCount=0,this.addDefaultImage(),this.addMissingImage();var t=this,i=e.Cache.READY_TIMEOUT;e.Cache.READY_TIMEOUT>0?setTimeout(function(){t.isReady||(console.warn("Phaser.Cache: Still waiting for images after %s ms.",i),t._ready())},e.Cache.READY_TIMEOUT):this._ready()},_addPending:function(){this._pendingCount+=1},_removePending:function(){this._pendingCount-=1,this._checkReady()},_checkReady:function(){this.isReady&&this._ready()},_ready:function(){this._pendingCount=0,this.onReady.dispatch(this)}},e.Cache.prototype.constructor=e.Cache,Object.defineProperty(e.Cache.prototype,"isReady",{get:function(){return this._pendingCount<=0}}),e.Loader=function(t){this.game=t,this.cache=t.cache,this.resetLocked=!1,this.isLoading=!1,this.hasLoaded=!1,this.preloadSprite=null,this.crossOrigin=!1,this.baseURL="",this.path="",this.headers={requestedWith:!1,json:"application/json",xml:"application/xml"},this.onLoadStart=new e.Signal,this.onBeforeLoadComplete=new e.Signal,this.onLoadComplete=new e.Signal,this.onPackComplete=new e.Signal,this.onFileStart=new e.Signal,this.onFileComplete=new e.Signal,this.onFileError=new e.Signal,this.enableParallel=!0,this.maxParallelDownloads=4,this._withSyncPointDepth=0,this._fileList=[],this._flightQueue=[],this._processingHead=0,this._fileLoadStarted=!1,this._totalPackCount=0,this._totalFileCount=0,this._loadedPackCount=0,this._loadedFileCount=0},e.Loader.TEXTURE_ATLAS_JSON_ARRAY=0,e.Loader.TEXTURE_ATLAS_JSON_HASH=1,e.Loader.TEXTURE_ATLAS_XML_STARLING=2,e.Loader.PHYSICS_LIME_CORONA_JSON=3,e.Loader.PHYSICS_PHASER_JSON=4,e.Loader.TEXTURE_ATLAS_JSON_PYXEL=5,e.Loader.prototype={setPreloadSprite:function(t,i){i=i||0,this.preloadSprite={sprite:t,direction:i,width:t.width,height:t.height,rect:null},this.preloadSprite.rect=0===i?new e.Rectangle(0,0,1,t.height):new e.Rectangle(0,0,t.width,1),t.crop(this.preloadSprite.rect),t.visible=!0},resize:function(){this.preloadSprite&&this.preloadSprite.height!==this.preloadSprite.sprite.height&&(this.preloadSprite.rect.height=this.preloadSprite.sprite.height)},checkKeyExists:function(t,e){return this.getAssetIndex(t,e)>-1},getAssetIndex:function(t,e){for(var i=-1,s=0;s<this._fileList.length;s++){var n=this._fileList[s];if(n.type===t&&n.key===e&&(i=s,!n.loaded&&!n.loading))break}return i},getAsset:function(t,e){var i=this.getAssetIndex(t,e);return i>-1&&{index:i,file:this._fileList[i]}},reset:function(t,e){void 0===e&&(e=!1),this.resetLocked||(t&&(this.preloadSprite=null),this.isLoading=!1,this._processingHead=0,this._fileList.length=0,this._flightQueue.length=0,this._fileLoadStarted=!1,this._totalFileCount=0,this._totalPackCount=0,this._loadedPackCount=0,this._loadedFileCount=0,e&&(this.onLoadStart.removeAll(),this.onLoadComplete.removeAll(),this.onPackComplete.removeAll(),this.onFileStart.removeAll(),this.onFileComplete.removeAll(),this.onFileError.removeAll()))},addToFileList:function(t,e,i,s,n,r){if(void 0===n&&(n=!1),void 0===e||""===e)return console.warn("Phaser.Loader: Invalid or no key given of type "+t),this;if(void 0===i||null===i){if(!r)return console.warn("Phaser.Loader: No URL given for file type: "+t+" key: "+e),this;i=e+r}var o={type:t,key:e,path:this.path,url:i,syncPoint:this._withSyncPointDepth>0,data:null,loading:!1,loaded:!1,error:!1};if(s)for(var a in s)o[a]=s[a];var h=this.getAssetIndex(t,e);if(n&&h>-1){var l=this._fileList[h];l.loading||l.loaded?(this._fileList.push(o),this._totalFileCount++):this._fileList[h]=o}else-1===h&&(this._fileList.push(o),this._totalFileCount++);return this},replaceInFileList:function(t,e,i,s){return this.addToFileList(t,e,i,s,!0)},pack:function(t,e,i,s){if(void 0===e&&(e=null),void 0===i&&(i=null),void 0===s&&(s=null),!e&&!i)return console.warn("Phaser.Loader.pack - Both url and data are null. One must be set."),this;var n={type:"packfile",key:t,url:e,path:this.path,syncPoint:!0,data:null,loading:!1,loaded:!1,error:!1,callbackContext:s};i&&("string"==typeof i&&(i=JSON.parse(i)),n.data=i||{},n.loaded=!0);for(var r=0;r<this._fileList.length+1;r++){var o=this._fileList[r];if(!o||!o.loaded&&!o.loading&&"packfile"!==o.type){this._fileList.splice(r,0,n),this._totalPackCount++;break}}return this},image:function(t,e,i){return"object"==typeof e?this.texture(t,e,i):this.addToFileList("image",t,e,void 0,i,".png")},imageFromBitmapData:function(t,e,i){return this.image(t,e.canvas.toDataURL("image/png"),i)},imageFromGrid:function(t,e,i,s,n,r){return this.imageFromBitmapData(t,this.game.create.grid(t,e,i,s,n,r,!1))},imageFromTexture:function(t,e,i,s,n){return this.imageFromBitmapData(t,this.game.create.texture(t,e,i,s,n,!1))},texture:function(t,i,s){if(this.game.renderType===e.WEBGL){var n,r=this.game.renderer.extensions.compression;for(n in i)if(n.toUpperCase()in r)return this.addToFileList("texture",t,i[n],void 0,s,".pvr")}return i.truecolor&&this.addToFileList("image",t,i.truecolor,void 0,s,".png"),this},images:function(t,e){if(Array.isArray(e))for(i=0;i<t.length;i++)this.image(t[i],e[i]);else for(var i=0;i<t.length;i++)this.image(t[i]);return this},text:function(t,e,i){return this.addToFileList("text",t,e,void 0,i,".txt")},json:function(t,e,i){return this.addToFileList("json",t,e,void 0,i,".json")},shader:function(t,e,i){return this.addToFileList("shader",t,e,void 0,i,".frag")},xml:function(t,e,i){return this.addToFileList("xml",t,e,void 0,i,".xml")},script:function(t,e,i,s){return void 0===i&&(i=!1),!1!==i&&void 0===s&&(s=this),this.addToFileList("script",t,e,{syncPoint:!0,callback:i,callbackContext:s},!1,".js")},binary:function(t,e,i,s){return void 0===i&&(i=!1),!1!==i&&void 0===s&&(s=i),this.addToFileList("binary",t,e,{callback:i,callbackContext:s},!1,".bin")},spritesheet:function(t,e,i,s,n,r,o,a){return void 0===n&&(n=-1),void 0===r&&(r=0),void 0===o&&(o=0),void 0===a&&(a=0),this.addToFileList("spritesheet",t,e,{frameWidth:i,frameHeight:s,frameMax:n,margin:r,spacing:o,skipFrames:a},!1,".png")},audio:function(t,e,i){return this.game.sound.noAudio?this:(void 0===i&&(i=!0),"string"==typeof e&&(e=[e]),this.addToFileList("audio",t,e,{buffer:null,autoDecode:i}))},audioSprite:function(t,e,i,s,n){return this.game.sound.noAudio?this:(void 0===i&&(i=null),void 0===s&&(s=null),void 0===n&&(n=!0),this.audio(t,e,n),i?this.json(t+"-audioatlas",i):s?("string"==typeof s&&(s=JSON.parse(s)),this.cache.addJSON(t+"-audioatlas","",s)):console.warn("Phaser.Loader.audiosprite - You must specify either a jsonURL or provide a jsonData object"),this)},audiosprite:function(t,e,i,s,n){return this.audioSprite(t,e,i,s,n)},video:function(t,e,i,s){return void 0===i&&(i=this.game.device.firefox?"loadeddata":"canplaythrough"),void 0===s&&(s=!1),"string"==typeof e&&(e=[e]),this.addToFileList("video",t,e,{buffer:null,asBlob:s,loadEvent:i})},tilemap:function(t,i,s,n){if(void 0===i&&(i=null),void 0===s&&(s=null),void 0===n&&(n=e.Tilemap.CSV),i||s||(i=n===e.Tilemap.CSV?t+".csv":t+".json"),s){switch(n){case e.Tilemap.CSV:break;case e.Tilemap.TILED_JSON:"string"==typeof s&&(s=JSON.parse(s))}this.cache.addTilemap(t,null,s,n)}else this.addToFileList("tilemap",t,i,{format:n});return this},tilemapCSV:function(t,i,s){return this.tilemap(t,i,s,e.Tilemap.CSV)},tilemapTiledJSON:function(t,i,s){return this.tilemap(t,i,s,e.Tilemap.TILED_JSON)},physics:function(t,i,s,n){return void 0===i&&(i=null),void 0===s&&(s=null),void 0===n&&(n=e.Physics.LIME_CORONA_JSON),i||s||(i=t+".json"),s?("string"==typeof s&&(s=JSON.parse(s)),this.cache.addPhysicsData(t,null,s,n)):this.addToFileList("physics",t,i,{format:n}),this},bitmapFont:function(t,e,i,s,n,r){if(void 0!==e&&null!==e||(e=t+".png"),void 0===i&&(i=null),void 0===s&&(s=null),null===i&&null===s&&(i=t+".xml"),void 0===n&&(n=0),void 0===r&&(r=0),i)this.addToFileList("bitmapfont",t,e,{atlasURL:i,xSpacing:n,ySpacing:r});else if("string"==typeof s){var o,a;try{o=JSON.parse(s)}catch(t){a=this.parseXml(s)}if(!a&&!o)throw new Error("Phaser.Loader. Invalid Bitmap Font atlas given");this.addToFileList("bitmapfont",t,e,{atlasURL:null,atlasData:o||a,atlasType:o?"json":"xml",xSpacing:n,ySpacing:r})}return this},atlasJSONArray:function(t,i,s,n){return this.atlas(t,i,s,n,e.Loader.TEXTURE_ATLAS_JSON_ARRAY)},atlasJSONHash:function(t,i,s,n){return this.atlas(t,i,s,n,e.Loader.TEXTURE_ATLAS_JSON_HASH)},atlasXML:function(t,i,s,n){return void 0===s&&(s=null),void 0===n&&(n=null),s||n||(s=t+".xml"),this.atlas(t,i,s,n,e.Loader.TEXTURE_ATLAS_XML_STARLING)},atlas:function(t,i,s,n,r){if(void 0!==i&&null!==i||(i=t+".png"),void 0===s&&(s=null),void 0===n&&(n=null),void 0===r&&(r=e.Loader.TEXTURE_ATLAS_JSON_ARRAY),s||n||(s=r===e.Loader.TEXTURE_ATLAS_XML_STARLING?t+".xml":t+".json"),s)this.addToFileList("textureatlas",t,i,{atlasURL:s,format:r});else{switch(r){case e.Loader.TEXTURE_ATLAS_JSON_ARRAY:"string"==typeof n&&(n=JSON.parse(n));break;case e.Loader.TEXTURE_ATLAS_XML_STARLING:if("string"==typeof n){var o=this.parseXml(n);if(!o)throw new Error("Phaser.Loader. Invalid Texture Atlas XML given");n=o}}this.addToFileList("textureatlas",t,i,{atlasURL:null,atlasData:n,format:r})}return this},withSyncPoint:function(t,e){this._withSyncPointDepth++;try{t.call(e||this,this)}finally{this._withSyncPointDepth--}return this},addSyncPoint:function(t,e){var i=this.getAsset(t,e);return i&&(i.file.syncPoint=!0),this},removeFile:function(t,e){var i=this.getAsset(t,e);i&&(i.loaded||i.loading||this._fileList.splice(i.index,1))},removeAll:function(){this._fileList.length=0,this._flightQueue.length=0},start:function(){this.isLoading||(this.hasLoaded=!1,this.isLoading=!0,this.updateProgress(),this.processLoadQueue())},processLoadQueue:function(){if(!this.isLoading)return console.warn("Phaser.Loader - active loading canceled / reset"),void this.finishedLoading(!0);for(i=0;i<this._flightQueue.length;i++)((s=this._flightQueue[i]).loaded||s.error)&&(this._flightQueue.splice(i,1),i--,s.loading=!1,s.requestUrl=null,s.requestObject=null,s.error&&this.onFileError.dispatch(s.key,s),"packfile"!==s.type?(this._loadedFileCount++,this.onFileComplete.dispatch(this.progress,s.key,!s.error,this._loadedFileCount,this._totalFileCount)):"packfile"===s.type&&s.error&&(this._loadedPackCount++,this.onPackComplete.dispatch(s.key,!s.error,this._loadedPackCount,this._totalPackCount)));for(var t=!1,e=this.enableParallel?Math.max(1,this.maxParallelDownloads):1,i=this._processingHead;i<this._fileList.length;i++){var s=this._fileList[i];if("packfile"===s.type&&!s.error&&s.loaded&&i===this._processingHead&&(this.processPack(s),this._loadedPackCount++,this.onPackComplete.dispatch(s.key,!s.error,this._loadedPackCount,this._totalPackCount)),s.loaded||s.error?i===this._processingHead&&(this._processingHead=i+1):!s.loading&&this._flightQueue.length<e&&("packfile"!==s.type||s.data?t||(this._fileLoadStarted||(this._fileLoadStarted=!0,this.onLoadStart.dispatch()),this._flightQueue.push(s),s.loading=!0,this.onFileStart.dispatch(this.progress,s.key,s.url),this.loadFile(s)):(this._flightQueue.push(s),s.loading=!0,this.loadFile(s))),!s.loaded&&s.syncPoint&&(t=!0),this._flightQueue.length>=e||t&&this._loadedPackCount===this._totalPackCount)break}if(this.updateProgress(),this._processingHead>=this._fileList.length)this.finishedLoading();else if(!this._flightQueue.length){console.warn("Phaser.Loader - aborting: processing queue empty, loading may have stalled");var n=this;setTimeout(function(){n.finishedLoading(!0)},2e3)}},finishedLoading:function(t){this.hasLoaded||(this.hasLoaded=!0,this.isLoading=!1,t||this._fileLoadStarted||(this._fileLoadStarted=!0,this.onLoadStart.dispatch()),this.game.state.loadUpdate(),this.onBeforeLoadComplete.dispatch(),this.reset(),this.onLoadComplete.dispatch(),this.game.state&&this.game.state.loadComplete())},asyncComplete:function(t,e){void 0===e&&(e=""),t.loaded=!0,t.error=!!e,e&&(t.errorMessage=e,console.warn("Phaser.Loader - "+t.type+"["+t.key+"]: "+e)),this.processLoadQueue()},processPack:function(t){var i=t.data[t.key];if(i)for(var s=0;s<i.length;s++){var n=i[s];switch(n.type){case"image":this.image(n.key,n.url,n.overwrite);break;case"text":this.text(n.key,n.url,n.overwrite);break;case"json":this.json(n.key,n.url,n.overwrite);break;case"xml":this.xml(n.key,n.url,n.overwrite);break;case"script":this.script(n.key,n.url,n.callback,t.callbackContext||this);break;case"binary":this.binary(n.key,n.url,n.callback,t.callbackContext||this);break;case"spritesheet":this.spritesheet(n.key,n.url,n.frameWidth,n.frameHeight,n.frameMax,n.margin,n.spacing,n.skipFrames);break;case"video":this.video(n.key,n.urls);break;case"audio":this.audio(n.key,n.urls,n.autoDecode);break;case"audiosprite":this.audiosprite(n.key,n.urls,n.jsonURL,n.jsonData,n.autoDecode);break;case"tilemap":this.tilemap(n.key,n.url,n.data,e.Tilemap[n.format]);break;case"physics":this.physics(n.key,n.url,n.data,e.Loader[n.format]);break;case"bitmapFont":this.bitmapFont(n.key,n.textureURL,n.atlasURL,n.atlasData,n.xSpacing,n.ySpacing);break;case"atlasJSONArray":this.atlasJSONArray(n.key,n.textureURL,n.atlasURL,n.atlasData);break;case"atlasJSONHash":this.atlasJSONHash(n.key,n.textureURL,n.atlasURL,n.atlasData);break;case"atlasXML":this.atlasXML(n.key,n.textureURL,n.atlasURL,n.atlasData);break;case"atlas":this.atlas(n.key,n.textureURL,n.atlasURL,n.atlasData,e.Loader[n.format]);break;case"shader":this.shader(n.key,n.url,n.overwrite)}}else console.warn("Phaser.Loader - "+t.key+": pack has data, but not for pack key")},transformUrl:function(t,e){return!!t&&(t.match(/^(?:blob:|data:|http:\/\/|https:\/\/|\/\/)/)?t:this.baseURL+e.path+t)},loadFile:function(t){switch(t.type){case"packfile":this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.fileComplete);break;case"image":case"spritesheet":case"textureatlas":case"bitmapfont":this.loadImageTag(t);break;case"audio":t.url=this.getAudioURL(t.url),t.url?this.game.sound.usingWebAudio?this.xhrLoad(t,this.transformUrl(t.url,t),"arraybuffer",this.fileComplete):this.game.sound.usingAudioTag&&this.loadAudioTag(t):this.fileError(t,null,"No supported audio URL specified or device does not have audio playback support");break;case"video":t.url=this.getVideoURL(t.url),t.url?t.asBlob?this.xhrLoad(t,this.transformUrl(t.url,t),"blob",this.fileComplete):this.loadVideoTag(t):this.fileError(t,null,"No supported video URL specified or device does not have video playback support");break;case"json":this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.jsonLoadComplete);break;case"xml":this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.xmlLoadComplete);break;case"tilemap":t.format===e.Tilemap.TILED_JSON?this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.jsonLoadComplete):t.format===e.Tilemap.CSV?this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.csvLoadComplete):this.asyncComplete(t,"invalid Tilemap format: "+t.format);break;case"text":case"script":case"shader":case"physics":this.xhrLoad(t,this.transformUrl(t.url,t),"text",this.fileComplete);break;case"texture":"truecolor"===t.key.split("_").pop()?this.loadImageTag(t):this.xhrLoad(t,this.transformUrl(t.url,t),"arraybuffer",this.fileComplete);break;case"binary":this.xhrLoad(t,this.transformUrl(t.url,t),"arraybuffer",this.fileComplete)}},loadImageTag:function(t){var e=this;t.data=new Image,t.data.name=t.key,this.crossOrigin&&(t.data.crossOrigin=this.crossOrigin),t.data.onload=function(){t.data.onload&&(t.data.onload=null,t.data.onerror=null,e.fileComplete(t))},t.data.onerror=function(){t.data.onload&&(t.data.onload=null,t.data.onerror=null,e.fileError(t))},t.data.src=this.transformUrl(t.url,t),!this.game.device.firefox&&t.data.complete&&t.data.width&&t.data.height&&(t.data.onload=null,t.data.onerror=null,this.fileComplete(t))},loadVideoTag:function(t){var i=this;t.data=document.createElement("video"),t.data.name=t.key,t.data.controls=!1,t.data.autoplay=!1,t.data.playsInline=!0;var s=function(){t.data.removeEventListener(t.loadEvent,s,!1),t.data.onerror=null,t.data.canplay=!0,e.GAMES[i.game.id].load.fileComplete(t)};t.data.onerror=function(){t.data.removeEventListener(t.loadEvent,s,!1),t.data.onerror=null,t.data.canplay=!1,i.fileError(t)},t.data.addEventListener(t.loadEvent,s,!1),t.data.src=this.transformUrl(t.url,t),t.data.load()},loadAudioTag:function(t){var e=this;if(this.game.sound.touchLocked)t.data=new Audio,t.data.name=t.key,t.data.preload="auto",t.data.src=this.transformUrl(t.url,t),this.fileComplete(t);else{t.data=new Audio,t.data.name=t.key;var i=function(){t.data.removeEventListener("canplaythrough",i,!1),t.data.onerror=null,e.fileComplete(t)};t.data.onerror=function(){t.data.removeEventListener("canplaythrough",i,!1),t.data.onerror=null,e.fileError(t)},t.data.preload="auto",t.data.src=this.transformUrl(t.url,t),t.data.addEventListener("canplaythrough",i,!1),t.data.load()}},xhrLoad:function(t,e,i,s,n){var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType=i,!1!==this.headers.requestedWith&&r.setRequestHeader("X-Requested-With",this.headers.requestedWith),this.headers[t.type]&&r.setRequestHeader("Accept",this.headers[t.type]),n=n||this.fileError;var o=this;r.onload=function(){try{return 4===r.readyState&&r.status>=400&&r.status<=599?n.call(o,t,r):s.call(o,t,r)}catch(e){o.hasLoaded?window.console&&console.error(e):o.asyncComplete(t,e.message||"Exception")}},r.onerror=function(){try{return n.call(o,t,r)}catch(e){o.hasLoaded?window.console&&console.error(e):o.asyncComplete(t,e.message||"Exception")}},t.requestObject=r,t.requestUrl=e,r.send()},getVideoURL:function(t){for(var e=0;e<t.length;e++){var i,s=t[e];if(s.uri){if(i=s.type,s=s.uri,this.game.device.canPlayVideo(i))return s}else{if(0===s.indexOf("blob:")||0===s.indexOf("data:"))return s;if(s.indexOf("?")>=0&&(s=s.substr(0,s.indexOf("?"))),i=s.substr((Math.max(0,s.lastIndexOf("."))||1/0)+1).toLowerCase(),this.game.device.canPlayVideo(i))return t[e]}}return null},getAudioURL:function(t){if(this.game.sound.noAudio)return null;for(var e=0;e<t.length;e++){var i,s=t[e];if(s.uri){if(i=s.type,s=s.uri,this.game.device.canPlayAudio(i))return s}else{if(0===s.indexOf("blob:")||0===s.indexOf("data:"))return s;if(s.indexOf("?")>=0&&(s=s.substr(0,s.indexOf("?"))),i=s.substr((Math.max(0,s.lastIndexOf("."))||1/0)+1).toLowerCase(),this.game.device.canPlayAudio(i))return t[e]}}return null},fileError:function(t,e,i){var s="error loading asset from URL "+(t.requestUrl||this.transformUrl(t.url,t));!i&&e&&(i=e.status),i&&(s=s+" ("+i+")"),this.asyncComplete(t,s)},fileComplete:function(t,i){var s=!0;switch(t.type){case"packfile":r=JSON.parse(i.responseText);t.data=r||{};break;case"texture":var n=/\.([^.]+)$/.exec(t.url.split("?",1)[0])[1].toLowerCase();null!==t.data?this.cache.addCompressedTextureMetaData(t.key,t.url,n,t.data):this.cache.addCompressedTextureMetaData(t.key,t.url,n,i.response);break;case"image":this.cache.addImage(t.key,t.url,t.data);break;case"spritesheet":this.cache.addSpriteSheet(t.key,t.url,t.data,t.frameWidth,t.frameHeight,t.frameMax,t.margin,t.spacing,t.skipFrames);break;case"textureatlas":if(null==t.atlasURL)this.cache.addTextureAtlas(t.key,t.url,t.data,t.atlasData,t.format);else if(s=!1,t.format===e.Loader.TEXTURE_ATLAS_JSON_ARRAY||t.format===e.Loader.TEXTURE_ATLAS_JSON_HASH||t.format===e.Loader.TEXTURE_ATLAS_JSON_PYXEL)this.xhrLoad(t,this.transformUrl(t.atlasURL,t),"text",this.jsonLoadComplete);else{if(t.format!==e.Loader.TEXTURE_ATLAS_XML_STARLING)throw new Error("Phaser.Loader. Invalid Texture Atlas format: "+t.format);this.xhrLoad(t,this.transformUrl(t.atlasURL,t),"text",this.xmlLoadComplete)}break;case"bitmapfont":t.atlasURL?(s=!1,this.xhrLoad(t,this.transformUrl(t.atlasURL,t),"text",function(t,e){var i;try{i=JSON.parse(e.responseText)}catch(t){}i?(t.atlasType="json",this.jsonLoadComplete(t,e)):(t.atlasType="xml",this.xmlLoadComplete(t,e))})):this.cache.addBitmapFont(t.key,t.url,t.data,t.atlasData,t.atlasType,t.xSpacing,t.ySpacing);break;case"video":if(t.asBlob)try{t.data=i.response}catch(e){throw new Error("Phaser.Loader. Unable to parse video file as Blob: "+t.key)}this.cache.addVideo(t.key,t.url,t.data,t.asBlob);break;case"audio":this.game.sound.usingWebAudio?(t.data=i.response,this.cache.addSound(t.key,t.url,t.data,!0,!1),t.autoDecode&&this.game.sound.decode(t.key)):this.cache.addSound(t.key,t.url,t.data,!1,!0);break;case"text":t.data=i.responseText,this.cache.addText(t.key,t.url,t.data);break;case"shader":t.data=i.responseText,this.cache.addShader(t.key,t.url,t.data);break;case"physics":var r=JSON.parse(i.responseText);this.cache.addPhysicsData(t.key,t.url,r,t.format);break;case"script":t.data=document.createElement("script"),t.data.language="javascript",t.data.type="text/javascript",t.data.defer=!1,t.data.text=i.responseText,document.head.appendChild(t.data),t.callback&&(t.data=t.callback.call(t.callbackContext,t.key,i.responseText));break;case"binary":t.callback?t.data=t.callback.call(t.callbackContext,t.key,i.response):t.data=i.response,this.cache.addBinary(t.key,t.data)}s&&this.asyncComplete(t)},jsonLoadComplete:function(t,e){var i=JSON.parse(e.responseText);"tilemap"===t.type?this.cache.addTilemap(t.key,t.url,i,t.format):"bitmapfont"===t.type?this.cache.addBitmapFont(t.key,t.url,t.data,i,t.atlasType,t.xSpacing,t.ySpacing):"json"===t.type?this.cache.addJSON(t.key,t.url,i):this.cache.addTextureAtlas(t.key,t.url,t.data,i,t.format),this.asyncComplete(t)},csvLoadComplete:function(t,e){var i=e.responseText;this.cache.addTilemap(t.key,t.url,i,t.format),this.asyncComplete(t)},xmlLoadComplete:function(t,e){var i=e.responseText,s=this.parseXml(i);if(!s){var n=e.responseType||e.contentType;return console.warn("Phaser.Loader - "+t.key+": invalid XML ("+n+")"),void this.asyncComplete(t,"invalid XML")}"bitmapfont"===t.type?this.cache.addBitmapFont(t.key,t.url,t.data,s,t.atlasType,t.xSpacing,t.ySpacing):"textureatlas"===t.type?this.cache.addTextureAtlas(t.key,t.url,t.data,s,t.format):"xml"===t.type&&this.cache.addXML(t.key,t.url,s),this.asyncComplete(t)},parseXml:function(t){var e;try{if(window.DOMParser){var i=new DOMParser;e=i.parseFromString(t,"text/xml")}else(e=new ActiveXObject("Microsoft.XMLDOM")).async="false",e.loadXML(t)}catch(t){e=null}return e&&e.documentElement&&!e.getElementsByTagName("parsererror").length?e:null},updateProgress:function(){this.preloadSprite&&(0===this.preloadSprite.direction?this.preloadSprite.rect.width=Math.floor(this.preloadSprite.width/100*this.progress):this.preloadSprite.rect.height=Math.floor(this.preloadSprite.height/100*this.progress),this.preloadSprite.sprite?this.preloadSprite.sprite.updateCrop():this.preloadSprite=null)},totalLoadedFiles:function(){return this._loadedFileCount},totalQueuedFiles:function(){return this._totalFileCount-this._loadedFileCount},totalLoadedPacks:function(){return this._totalPackCount},totalQueuedPacks:function(){return this._totalPackCount-this._loadedPackCount}},Object.defineProperty(e.Loader.prototype,"progressFloat",{get:function(){var t=this._loadedFileCount/this._totalFileCount*100;return e.Math.clamp(t||0,0,100)}}),Object.defineProperty(e.Loader.prototype,"progress",{get:function(){return Math.round(this.progressFloat)}}),e.Loader.prototype.constructor=e.Loader,e.LoaderParser={bitmapFont:function(t,e,i,s,n,r){return this.xmlBitmapFont(t,e,i,s,n,r)},xmlBitmapFont:function(t,e,i,s,n,r){null==r&&(r=1);var o={},a=t.getElementsByTagName("info")[0],h=t.getElementsByTagName("common")[0];o.font=a.getAttribute("face"),o.size=parseInt(a.getAttribute("size"),10),o.lineHeight=parseInt(h.getAttribute("lineHeight"),10)+s,o.chars={};for(var l=t.getElementsByTagName("char"),c=n?n.x:0,u=n?n.y:0,d=0;d<l.length;d++){var p=parseInt(l[d].getAttribute("id"),10),f=o.chars[p]={x:parseInt(l[d].getAttribute("x"),10),y:parseInt(l[d].getAttribute("y"),10),width:parseInt(l[d].getAttribute("width"),10),height:parseInt(l[d].getAttribute("height"),10),xOffset:parseInt(l[d].getAttribute("xoffset"),10)/r,yOffset:parseInt(l[d].getAttribute("yoffset"),10)/r,xAdvance:(parseInt(l[d].getAttribute("xadvance"),10)+i)/r,kerning:{}};if(n&&n.trimmed){if(f.x+f.width>n.spriteSourceSizeX+n.spriteSourceSizeW&&(f.width-=f.x+f.width-n.spriteSourceSizeX-n.spriteSourceSizeW),f.y+f.height>n.spriteSourceSizeY+n.spriteSourceSizeH&&(f.height-=f.y+f.height-n.spriteSourceSizeY-n.spriteSourceSizeH),f.x<n.spriteSourceSizeX){g=n.spriteSourceSizeX-f.x;f.x=0,f.width-=g,f.xOffset+=g}if(f.y<n.spriteSourceSizeY){var g=n.spriteSourceSizeY-f.y;f.y=0,f.height-=g,f.yOffset+=g}}f.x+=c,f.y+=u}var m=t.getElementsByTagName("kerning");for(d=0;d<m.length;d++){var y=parseInt(m[d].getAttribute("first"),10),v=parseInt(m[d].getAttribute("second"),10),x=parseInt(m[d].getAttribute("amount"),10)/r;o.chars[v]&&(o.chars[v].kerning[y]=x)}return this.finalizeBitmapFont(e,o)},jsonBitmapFont:function(t,e,i,s,n,r){null==r&&(r=1);var o={font:t.font.info._face,size:parseInt(t.font.info._size,10),lineHeight:parseInt(t.font.common._lineHeight,10)+s,chars:{}},a=n?n.x:0,h=n?n.y:0;return t.font.chars.char.forEach(function(t){var e=parseInt(t._id,10),s=o.chars[e]={x:parseInt(t._x,10),y:parseInt(t._y,10),width:parseInt(t._width,10),height:parseInt(t._height,10),xOffset:parseInt(t._xoffset,10)/r,yOffset:parseInt(t._yoffset,10)/r,xAdvance:(parseInt(t._xadvance,10)+i)/r,kerning:{}};if(n&&n.trimmed){if(s.x+s.width>n.spriteSourceSizeX+n.spriteSourceSizeW&&(s.width-=s.x+s.width-n.spriteSourceSizeX-n.spriteSourceSizeW),s.y+s.height>n.spriteSourceSizeY+n.spriteSourceSizeH&&(s.height-=s.y+s.height-n.spriteSourceSizeY-n.spriteSourceSizeH),s.x<n.spriteSourceSizeX){l=n.spriteSourceSizeX-s.x;s.x=0,s.width-=l,s.xOffset+=l}if(s.y<n.spriteSourceSizeY){var l=n.spriteSourceSizeY-s.y;s.y=0,s.height-=l,s.yOffset+=l}}s.x+=a,s.y+=h}),t.font.kernings&&t.font.kernings.kerning&&t.font.kernings.kerning.forEach(function(t){o.chars[t._second]&&(o.chars[t._second].kerning[t._first]=parseInt(t._amount,10)/r)}),this.finalizeBitmapFont(e,o)},finalizeBitmapFont:function(t,i){return Object.keys(i.chars).forEach(function(s){var n=i.chars[s];n.texture=new PIXI.Texture(t,new e.Rectangle(n.x,n.y,n.width,n.height))}),i},pvr:function(t){var e,i=new Uint32Array(t.slice(0,52)),s=new Uint8Array(t),n=null,r=i[3]<<32|i[2],o=0;if(55727696===i[0]&&[0,1,2,3,6,7,9,11].indexOf(r)>=0){switch(r>=0&&r<=3?e="PVRTC":r>=7&&r<=11?e="S3TC":6===r&&(e="ETC1"),r){case 0:o=35841;break;case 1:o=35843;break;case 2:o=35840;break;case 3:o=35842;break;case 6:o=36196;break;case 7:o=33777;break;case 9:o=33778;break;case 11:o=33779;break;default:o=-1}n={complete:!0,fileFormat:"PVR",compressionAlgorithm:e,flags:i[1],pixelFormat:r,colorSpace:i[4],channelType:i[5],height:i[6],width:i[7],depth:i[8],numberOfSurfaces:i[9],numberOfFaces:i[10],numberOfMipmaps:i[11],metaDataSize:i[12],textureData:s.subarray(52+i[12],s.byteLength),glExtensionFormat:o}}return n},dds:function(t){var e=new Uint8Array(t),i=new Uint32Array(t),s=null;return 68===e[0]&&68===e[1]&&83===e[2]&&32===e[3]&&("DX10"===(s={complete:!0,fileFormat:"DDS",compressionAlgorithm:"S3TC",size:i[1],flags:i[2],height:i[3],width:i[4],pitch:i[5],depth:i[6],mipmapCount:i[7],formatSize:i[19],formatFlag:i[19],formatFourCC:[String.fromCharCode(e[84]),String.fromCharCode(e[85]),String.fromCharCode(e[86]),String.fromCharCode(e[87])].join(""),formatBitCount:i[21],formatRBitMask:i[22],formatGBitMask:i[23],formatBBitMask:i[24],formatABitMask:i[25],caps1:i[26],caps2:i[27],caps3:i[28],caps4:i[29],reserved2:i[30],DXGIFormat:null,resourceDimension:null,miscFlag:null,arraySize:null,textureData:e.subarray(i[1]+4,e.byteLength)}).formatFourCC?(s.DXGIFormat=i[31],s.resourceDimension=i[32],s.miscFlag=i[33],s.arraySize=i[34],s.miscFlag=i[35]):"DXT5"===s.formatFourCC?s.glExtensionFormat=33779:"DXT3"===s.formatFourCC&&(s.glExtensionFormat=33778)),s},ktx:function(t){var e=new Uint8Array(t),i=new Uint32Array(t),s=null,n=16+i[15]/4|0,r=i[n],o=i[7],a=0;if(171===e[0]&&75===e[1]&&84===e[2]&&88===e[3]&&32===e[4]&&49===e[5]&&49===e[6]&&187===e[7]&&13===e[8]&&10===e[9]&&26===e[10]&&10===e[11]&&[36196,35840,35841,35842,35843,33776,33777,33778,33779].indexOf(o)>=0){switch(o){case 36196:a="ETC1";break;case 35840:case 35841:case 35842:case 35843:a="PVRTC";break;case 33776:case 33777:case 33778:case 33779:a="S3TC"}s={complete:!0,fileFormat:"KTX",compressionAlgorithm:a,endianness:i[3],glType:i[4],glTypeSize:i[5],glFormat:i[6],glInternalFormat:i[7],glBaseInternalFormat:i[8],width:i[9],height:i[10],pixelDepth:i[11],numberOfArrayElements:i[12],numberOfFaces:i[13],numberOfMipmapLevels:i[14],bytesOfKeyValueData:i[15],keyAndValueByteSize:i[16],imageSize:r,textureData:e.subarray(4*(n+1),r+100)}}return s},pkm:function(t){var e=new Uint8Array(t),i=null;return 80===e[0]&&75===e[1]&&77===e[2]&&32===e[3]&&(i={complete:!0,fileFormat:"PKM",compressionAlgorithm:"ETC1",format:65535&(e[6]<<8|e[7]),width:65535&(e[8]<<8|e[9]),height:65535&(e[10]<<8|e[11]),originalWidth:65535&(e[12]<<8|e[13]),originalHeight:65535&(e[14]<<8|e[15]),textureData:e.subarray(16,e.length)}),i}},e.AudioSprite=function(t,e){this.game=t,this.key=e,this.config=this.game.cache.getJSON(e+"-audioatlas"),this.autoplayKey=null,this.autoplay=!1,this.sounds={};for(var i in this.config.spritemap){var s=this.config.spritemap[i],n=this.game.add.sound(this.key);n.addMarker(i,s.start,s.end-s.start,null,s.loop),this.sounds[i]=n}this.config.autoplay&&(this.autoplayKey=this.config.autoplay,this.play(this.autoplayKey),this.autoplay=this.sounds[this.autoplayKey])},e.AudioSprite.prototype={play:function(t,e){return void 0===e&&(e=1),this.sounds[t].play(t,null,e)},stop:function(t){if(t)this.sounds[t].stop();else for(var e in this.sounds)this.sounds[e].stop()},get:function(t){return this.sounds[t]}},e.AudioSprite.prototype.constructor=e.AudioSprite,e.Sound=function(t,i,s,n,r){void 0===s&&(s=1),void 0===n&&(n=!1),void 0===r&&(r=t.sound.connectToMaster),this.game=t,this.name=i,this.key=i,this.loop=n,this.markers={},this.context=null,this.autoplay=!1,this.totalDuration=0,this.startTime=0,this.currentTime=0,this.duration=0,this.durationMS=0,this.position=0,this.stopTime=0,this.paused=!1,this.pausedPosition=0,this.pausedTime=0,this.isPlaying=!1,this.currentMarker="",this.fadeTween=null,this.pendingPlayback=!1,this.override=!1,this.allowMultiple=!1,this.playOnce=!1,this.usingWebAudio=this.game.sound.usingWebAudio,this.usingAudioTag=this.game.sound.usingAudioTag,this.externalNode=null,this.masterGainNode=null,this.gainNode=null,this._sound=null,this._globalVolume=1,this._markedToDelete=!1,this._pendingStart=!1,this._removeFromSoundManager=!1,this._sourceId=0,this.usingWebAudio?(this.context=this.game.sound.context,this.masterGainNode=this.game.sound.masterGain,void 0===this.context.createGain?this.gainNode=this.context.createGainNode():this.gainNode=this.context.createGain(),this.gainNode.gain.value=s,r&&this.gainNode.connect(this.masterGainNode)):this.usingAudioTag&&(this.game.cache.getSound(i)&&this.game.cache.isSoundReady(i)?(this._sound=this.game.cache.getSoundData(i),this.totalDuration=0,this._sound.duration&&(this.totalDuration=this._sound.duration)):this.game.cache.onSoundUnlock.add(this.soundHasUnlocked,this)),this.onDecoded=new e.Signal,this.onPlay=new e.Signal,this.onPause=new e.Signal,this.onResume=new e.Signal,this.onLoop=new e.Signal,this.onStop=new e.Signal,this.onMute=new e.Signal,this.onMarkerComplete=new e.Signal,this.onFadeComplete=new e.Signal,this._volume=s,this._buffer=null,this._muted=!1,this._tempMarker=0,this._tempPosition=0,this._tempVolume=0,this._tempPause=0,this._muteVolume=0,this._tempLoop=0,this._paused=!1,this._onDecodedEventDispatched=!1},e.Sound.prototype={soundHasUnlocked:function(t){t===this.key&&(this._sound=this.game.cache.getSoundData(this.key),this.totalDuration=this._sound.duration)},addMarker:function(t,e,i,s,n){void 0!==i&&null!==i||(i=1),void 0!==s&&null!==s||(s=1),void 0===n&&(n=!1),this.markers[t]={name:t,start:e,stop:e+i,volume:s,duration:i,durationMS:1e3*i,loop:n}},removeMarker:function(t){delete this.markers[t]},onEndedHandler:function(){this._removeOnEndedHandler(),this.isPlaying=!1,this.currentTime=this.durationMS,this.stop(),this.playOnce&&(this._markedToDelete=!0,this._removeFromSoundManager=!0),this._markedToDelete&&(this._disconnectSource(),this._removeFromSoundManager?this.game.sound.remove(this):(this.markers={},this.context=null,this._buffer=null,this.externalNode=null,this.onDecoded.dispose(),this.onPlay.dispose(),this.onPause.dispose(),this.onResume.dispose(),this.onLoop.dispose(),this.onStop.dispose(),this.onMute.dispose(),this.onMarkerComplete.dispose()))},update:function(){if(this.game.cache.checkSoundKey(this.key)){this.isDecoded&&!this._onDecodedEventDispatched&&(this.onDecoded.dispatch(this),this._onDecodedEventDispatched=!0),this.pendingPlayback&&this.game.cache.isSoundReady(this.key)&&(this.pendingPlayback=!1,this.play(this._tempMarker,this._tempPosition,this._tempVolume,this._tempLoop));var t=this.game.time.time;if(this.isPlaying){if(this._pendingStart){var e=this._sound.currentTime;if(!(e>((this.paused?this._tempPause:0)||this.position||0)))return;this._pendingStart=!1,this.startTime=t-1e3*e,this.stopTime=this.startTime+this.durationMS}this.currentTime=t-this.startTime,this.currentTime>=this.durationMS&&(this.usingWebAudio?this.loop?(this.onLoop.dispatch(this),this.isPlaying=!1,""===this.currentMarker?(this.currentTime=0,this.startTime=t,this.isPlaying=!0):(this.onMarkerComplete.dispatch(this.currentMarker,this),this.play(this.currentMarker,0,this.volume,!0,!0,!1))):""!==this.currentMarker&&this.stop():this.loop?(this.onLoop.dispatch(this),""===this.currentMarker&&(this.currentTime=0,this.startTime=t),this.isPlaying=!1,this.play(this.currentMarker,0,this.volume,!0,!0,!1)):this.stop())}}else this.destroy()},loopFull:function(t){return this.play(null,0,t,!0)},play:function(t,e,i,s,n,r){if(void 0!==t&&!1!==t&&null!==t||(t=""),void 0===n&&(n=!0),void 0===r&&(r=!0),this.isPlaying&&!this.allowMultiple&&!n&&!this.override)return this;if(this._sound&&this.isPlaying&&!this.allowMultiple&&(this.override||n)&&(this.usingWebAudio?this._stopSourceAndDisconnect():this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0),this.isPlaying=!1),""===t&&Object.keys(this.markers).length>0)return this;if(""!==t){if(!this.markers[t])return console.warn("Phaser.Sound.play: audio marker "+t+" doesn't exist"),this;this.currentMarker=t,this.position=this.markers[t].start,this.volume=this.markers[t].volume,this.loop=this.markers[t].loop,this.duration=this.markers[t].duration,this.durationMS=this.markers[t].durationMS,void 0!==i&&(this.volume=i),void 0!==s&&(this.loop=s),this._tempMarker=t,this._tempPosition=this.position,this._tempVolume=this.volume,this._tempLoop=this.loop}else e=e||0,void 0===i&&(i=this._volume),void 0===s&&(s=this.loop),this.position=Math.max(0,e),this.volume=i,this.loop=s,this.duration=0,this.durationMS=0,this._tempMarker=t,this._tempPosition=e,this._tempVolume=i,this._tempLoop=s;return this.usingWebAudio?this.game.cache.isSoundDecoded(this.key)?(this._createSourceAndConnect(),this.loop&&""===t&&(this._sound.loop=!0),this.loop||""!==t||this._addOnEndedHandler(),this.totalDuration=this._sound.buffer.duration,0===this.duration&&(this.duration=this.totalDuration,this.durationMS=Math.ceil(1e3*this.totalDuration)),this.loop&&""===t?this._startSource(0,0):this._startSource(0,this.position,this.duration),this.isPlaying=!0,this.paused=!1,this.startTime=this.game.time.time,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,r&&this.onPlay.dispatch(this)):(this.pendingPlayback=!0,this.game.cache.getSound(this.key)&&!1===this.game.cache.getSound(this.key).isDecoding&&this.game.sound.decode(this.key,this)):this.game.cache.getSound(this.key)&&this.game.cache.getSound(this.key).locked?(this.game.cache.reloadSound(this.key),this.pendingPlayback=!0):this._sound&&(this.game.device.cocoonJS||4===this._sound.readyState)?(this._sound.play(),this._sound.loop=this.loop,this.totalDuration=this._sound.duration,0===this.duration&&(this.duration=this.totalDuration,this.durationMS=1e3*this.totalDuration),this._globalVolume=this.game.sound.volume,this._sound.currentTime=this.position,this._sound.muted=this._muted,this._muted||this.game.sound.mute?this._sound.volume=0:this._sound.volume=this._volume*this._globalVolume,this._pendingStart=!this.currentMarker,this.isPlaying=!0,this.paused=!1,this._tempPause=0,this.startTime=this.game.time.time,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,r&&this.onPlay.dispatch(this)):this.pendingPlayback=!0,this.playOnce&&(this.loop&&console.warn("Phaser.Sound.play: audio clip "+this.name+" cannot be deleted while looping."),this._markedToDelete=!0,this._removeFromSoundManager=!0),this},restart:function(t,e,i,s){t=t||"",e=e||0,i=i||1,void 0===s&&(s=!1),this.play(t,e,i,s,!0)},pause:function(){this.isPlaying&&(this.paused=!0,this.pausedPosition=this.currentTime,this.pausedTime=this.game.time.time,this._tempPause=this._sound.currentTime,this.onPause.dispatch(this),this.stop())},resume:function(){if(this.paused){if(this.usingWebAudio){var t=Math.max(0,this.position+this.pausedPosition/1e3);this._createSourceAndConnect(),""===this.currentMarker&&(this.loop?this._sound.loop=!0:this._addOnEndedHandler());var e=this.duration-this.pausedPosition/1e3;this.loop&&""===this.currentMarker?this._startSource(0,t):this._startSource(0,t,e)}else this._pendingStart=!this.currentMarker,this._sound.currentTime=this._tempPause,this._tempPause=0,this._sound.play();this.isPlaying=!0,this.paused=!1,this.startTime+=this.game.time.time-this.pausedTime,this.onResume.dispatch(this)}},stop:function(){if(this.isPlaying&&this._sound&&(this.usingWebAudio?this._stopSourceAndDisconnect():this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0)),this.pendingPlayback=!1,this.isPlaying=!1,!this.paused){var t=this.currentMarker;""!==this.currentMarker&&this.onMarkerComplete.dispatch(this.currentMarker,this),this.currentMarker="",null!==this.fadeTween&&this.fadeTween.stop(),this.onStop.dispatch(this,t)}},fadeIn:function(t,e,i){void 0===e&&(e=!1),void 0===i&&(i=this.currentMarker),this.paused||(this.play(i,0,0,e),this.fadeTo(t,1))},fadeOut:function(t){this.fadeTo(t,0)},fadeTo:function(t,i){this.isPlaying&&!this.paused&&i!==this.volume&&(void 0===t&&(t=1e3),void 0!==i?(this.fadeTween=this.game.add.tween(this).to({volume:i},t,e.Easing.Linear.None,!0),this.fadeTween.onComplete.add(this.fadeComplete,this)):console.warn("Phaser.Sound.fadeTo: No Volume Specified."))},fadeComplete:function(){this.onFadeComplete.dispatch(this,this.volume),0===this.volume&&this.stop()},updateGlobalVolume:function(t){this.usingAudioTag&&this._sound&&(this._globalVolume=t,this._sound.volume=this._globalVolume*this._volume)},destroy:function(t){void 0===t&&(t=!0),this._markedToDelete=!0,this._removeFromSoundManager=t,this.stop(),t?this.game.sound.remove(this):(this.markers={},this.context=null,this._buffer=null,this.externalNode=null,this.onDecoded.dispose(),this.onPlay.dispose(),this.onPause.dispose(),this.onResume.dispose(),this.onLoop.dispose(),this.onStop.dispose(),this.onMute.dispose(),this.onMarkerComplete.dispose())},_createSourceAndConnect:function(){this._sound=this.context.createBufferSource(),this._sound.connect(this.externalNode||this.gainNode),this._buffer=this.game.cache.getSoundData(this.key),this._sound.buffer=this._buffer,this._sourceId++},_disconnectSource:function(){this._sound.disconnect(this.externalNode||this.gainNode)},_startSource:function(t,e,i){void 0===i?this._sound.start(t||0,e||0):this._sound.start(t||0,e||0,i)},_stopSourceAndDisconnect:function(){this._removeOnEndedHandler();try{this._sound.stop(0)}catch(t){}this._disconnectSource(),this._sound=null},_addOnEndedHandler:function(){this._sound.onended=this.onEndedHandler.bind(this)},_removeOnEndedHandler:function(){this._sound.onended=null}},e.Sound.prototype.constructor=e.Sound,Object.defineProperty(e.Sound.prototype,"isDecoding",{get:function(){return this.game.cache.getSound(this.key).isDecoding}}),Object.defineProperty(e.Sound.prototype,"isDecoded",{get:function(){return this.game.cache.isSoundDecoded(this.key)}}),Object.defineProperty(e.Sound.prototype,"mute",{get:function(){return this._muted||this.game.sound.mute},set:function(t){(t=t||!1)!==this._muted&&(t?(this._muted=!0,this._muteVolume=this._tempVolume,this.usingWebAudio?this.gainNode.gain.value=0:this.usingAudioTag&&this._sound&&(this._sound.volume=0)):(this._muted=!1,this.usingWebAudio?this.gainNode.gain.value=this._muteVolume:this.usingAudioTag&&this._sound&&(this._sound.volume=this._muteVolume)),this.onMute.dispatch(this))}}),Object.defineProperty(e.Sound.prototype,"volume",{get:function(){return this._volume},set:function(t){this.usingAudioTag&&(t=this.game.math.clamp(t,0,1)),this._muted?this._muteVolume=t:(this._tempVolume=t,this._volume=t,this.usingWebAudio?this.gainNode.gain.value=t:this.usingAudioTag&&this._sound&&(this._sound.volume=this._globalVolume*t))}}),Object.defineProperty(e.Sound.prototype,"sourceId",{get:function(){return this._sound?this._sourceId:null}}),e.SoundManager=function(t){this.game=t,this.onSoundDecode=new e.Signal,this.onVolumeChange=new e.Signal,this.onMute=new e.Signal,this.onUnMute=new e.Signal,this.onTouchUnlock=new e.Signal,this.context=null,this.baseLatency=null,this.usingWebAudio=!1,this.usingAudioTag=!1,this.noAudio=!1,this.connectToMaster=!0,this.touchLocked=!1,this.channels=32,this.muteOnPause=!0,this._codeMuted=!1,this._muted=!1,this._unlockSource=null,this._volume=1,this._sounds=[],this._watchList=new e.ArraySet,this._watching=!1,this._watchCallback=null,this._watchContext=null,this._resumeWebAudioOnClick=this._resumeWebAudioOnClick.bind(this)},e.SoundManager.prototype={boot:function(){var t=this.game.device,e=window.PhaserGlobal;if(t.iOS&&!1===t.webAudio&&(this.channels=1),e){if(!0===e.disableAudio)return this.noAudio=!0,void(this.touchLocked=!1);if(!0===e.disableWebAudio)return this.usingAudioTag=!0,void(this.touchLocked=!1)}if(e&&e.audioContext)this.context=e.audioContext;else{var i=window.AudioContext||window.webkitAudioContext;if(i)try{this.context=new i}catch(t){this.context=null,this.usingWebAudio=!1,this.touchLocked=!1,console.warn(t)}}if(null===this.context){if(void 0===window.Audio)return void(this.noAudio=!0);this.usingAudioTag=!0}else this.usingWebAudio=!0,this.baseLatency=this.context.baseLatency||256/(this.context.sampleRate||44100),void 0===this.context.createGain?this.masterGain=this.context.createGainNode():this.masterGain=this.context.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this.context.destination),"suspended"===this.context.state&&this.game.canvas.addEventListener("click",this._resumeWebAudioOnClick);this.noAudio||t.needsTouchUnlock()&&this.setTouchLock(),this.usingWebAudio&&t.chrome&&t.chromeVersion<=65&&console.log('A "GainNode.gain.value setter smoothing is deprecated" notice in Chrome is normal. <https://github.com/photonstorm/phaser-ce/issues/385>')},setTouchLock:function(){this.noAudio||window.PhaserGlobal&&!0===window.PhaserGlobal.disableAudio||(this.game.input.addTouchLockCallback(this.unlock,this,!0),this.touchLocked=!0)},setTouchUnlock:function(){this.touchLocked=!1,this._unlockSource=null,this.onTouchUnlock.dispatch()},resumeWebAudio:function(){if(this.usingWebAudio&&"suspended"===this.context.state)return this.context.resume()},unlock:function(){if(this.noAudio||!this.touchLocked||null!==this._unlockSource)return!0;if(this.usingAudioTag)this.setTouchUnlock();else if(this.usingWebAudio){var t=this.context.createBuffer(1,1,22050);this._unlockSource=this.context.createBufferSource(),this._unlockSource.buffer=t,this._unlockSource.connect(this.context.destination);var e=this;this._unlockSource.onended=function(){e.setTouchUnlock(),e.resumeWebAudio()},void 0===this._unlockSource.start?this._unlockSource.noteOn(0):this._unlockSource.start(0),this.resumeWebAudio()}return!0},stopAll:function(){if(!this.noAudio)for(var t=0;t<this._sounds.length;t++)this._sounds[t]&&this._sounds[t].stop()},pauseAll:function(){if(!this.noAudio)for(var t=0;t<this._sounds.length;t++)this._sounds[t]&&this._sounds[t].pause()},resumeAll:function(){if(!this.noAudio)for(var t=0;t<this._sounds.length;t++)this._sounds[t]&&this._sounds[t].resume()},decode:function(t,e){e=e||null;var i=this.game.cache.getSoundData(t);if(i&&!1===this.game.cache.isSoundDecoded(t)){this.game.cache.updateSound(t,"isDecoding",!0);var s=this;try{this.context.decodeAudioData(i,function(i){i&&(s.game.cache.decodedSound(t,i),s.onSoundDecode.dispatch(t,e))})}catch(t){}}},setDecodedCallback:function(t,i,s){"string"==typeof t&&(t=[t]),this._watchList.reset();for(var n=0;n<t.length;n++)t[n]instanceof e.Sound?this.game.cache.isSoundDecoded(t[n].key)||this._watchList.add(t[n].key):this.game.cache.isSoundDecoded(t[n])||this._watchList.add(t[n]);0===this._watchList.total?(this._watching=!1,i.call(s)):(this._watching=!0,this._watchCallback=i,this._watchContext=s)},update:function(){if(!this.noAudio){for(var t=0;t<this._sounds.length;t++)this._sounds[t].update();if(this._watching){for(var e=this._watchList.first;e;)this.game.cache.isSoundDecoded(e)&&this._watchList.remove(e),e=this._watchList.next;0===this._watchList.total&&(this._watching=!1,this._watchCallback.call(this._watchContext))}}},add:function(t,i,s,n){void 0===i&&(i=1),void 0===s&&(s=!1),void 0===n&&(n=this.connectToMaster);var r=new e.Sound(this.game,t,i,s,n);return this._sounds.push(r),r},addSprite:function(t){return new e.AudioSprite(this.game,t)},remove:function(t){for(var e=this._sounds.length;e--;)if(this._sounds[e]===t)return this._sounds[e].destroy(!1),this._sounds.splice(e,1),!0;return!1},removeAll:function(){this.stopAll();for(var t=0;t<this._sounds.length;t++)this._sounds[t]&&this._sounds[t].destroy();this._sounds.length=0},removeByKey:function(t){for(var e=this._sounds.length,i=0;e--;)this._sounds[e].key===t&&(this._sounds[e].destroy(!1),this._sounds.splice(e,1),i++);return i},play:function(t,e,i){if(!this.noAudio){var s=this.add(t,e,i);return s.play(),s}},setMute:function(){if(!this._muted){this._muted=!0,this.usingWebAudio&&(this._muteVolume=this.masterGain.gain.value,this.masterGain.gain.value=0);for(var t=0;t<this._sounds.length;t++)this._sounds[t].usingAudioTag&&(this._sounds[t].mute=!0);this.onMute.dispatch()}},unsetMute:function(){if(this._muted&&!this._codeMuted){this._muted=!1,this.usingWebAudio&&(this.masterGain.gain.value=this._muteVolume);for(var t=0;t<this._sounds.length;t++)this._sounds[t].usingAudioTag&&(this._sounds[t].mute=!1);this.onUnMute.dispatch()}},destroy:function(){this.removeAll(),this.onSoundDecode.dispose(),this.game.canvas.removeEventListener("click",this._resumeWebAudioOnClick),this.context&&(window.PhaserGlobal?window.PhaserGlobal.audioContext=this.context:this.context.close&&this.context.close())},_resumeWebAudioOnClick:function(){this.resumeWebAudio(),this.game.canvas.removeEventListener("click",this._resumeWebAudioOnClick)}},e.SoundManager.prototype.constructor=e.SoundManager,Object.defineProperty(e.SoundManager.prototype,"mute",{get:function(){return this._muted},set:function(t){if(t=t||!1){if(this._muted)return;this._codeMuted=!0,this.setMute()}else{if(!this._muted)return;this._codeMuted=!1,this.unsetMute()}}}),Object.defineProperty(e.SoundManager.prototype,"volume",{get:function(){return this._volume},set:function(t){if(t<0?t=0:t>1&&(t=1),this._volume!==t){if(this._volume=t,this.usingWebAudio)this.masterGain.gain.value=t;else for(var e=0;e<this._sounds.length;e++)this._sounds[e].usingAudioTag&&this._sounds[e].updateGlobalVolume(t);this.onVolumeChange.dispatch(t)}}}),e.ScaleManager=function(t,i,s){this.game=t,this.dom=e.DOM,this.grid=null,this.width=0,this.height=0,this.minWidth=null,this.maxWidth=null,this.minHeight=null,this.maxHeight=null,this.offset=new e.Point,this.forceLandscape=!1,this.forcePortrait=!1,this.incorrectOrientation=!1,this._pageAlignHorizontally=!1,this._pageAlignVertically=!1,this.onOrientationChange=new e.Signal,this.enterIncorrectOrientation=new e.Signal,this.leaveIncorrectOrientation=new e.Signal,this.hasPhaserSetFullScreen=!1,this.fullScreenTarget=null,this._createdFullScreenTarget=null,this.onFullScreenInit=new e.Signal,this.onFullScreenChange=new e.Signal,this.onFullScreenError=new e.Signal,this.screenOrientation=this.dom.getScreenOrientation(),this.scaleFactor=new e.Point(1,1),this.scaleFactorInversed=new e.Point(1,1),this.margin={left:0,top:0,right:0,bottom:0,x:0,y:0},this.bounds=new e.Rectangle,this.aspectRatio=0,this.sourceAspectRatio=0,this.event=null,this.windowConstraints={right:"layout",bottom:""},this.compatibility={supportsFullScreen:!1,orientationFallback:null,noMargins:!1,scrollTo:null,forceMinimumDocumentHeight:!1,canExpandParent:!0,clickTrampoline:""},this._scaleMode=e.ScaleManager.NO_SCALE,this._fullScreenScaleMode=e.ScaleManager.NO_SCALE,this.parentIsWindow=!1,this.parentNode=null,this.parentScaleFactor=new e.Point(1,1),this.trackParentInterval=2e3,this.onSizeChange=new e.Signal,this.onResize=null,this.onResizeContext=null,this._pendingScaleMode=null,this._fullScreenRestore=null,this._gameSize=new e.Rectangle,this._userScaleFactor=new e.Point(1,1),this._userScaleTrim=new e.Point(0,0),this._lastUpdate=0,this._updateThrottle=0,this._updateThrottleReset=100,this._parentBounds=new e.Rectangle,this._tempBounds=new e.Rectangle,this._lastReportedCanvasSize=new e.Rectangle,this._lastReportedGameSize=new e.Rectangle,this._booted=!1,t.config&&this.parseConfig(t.config),this.setupScale(i,s)},e.ScaleManager.EXACT_FIT=0,e.ScaleManager.NO_SCALE=1,e.ScaleManager.SHOW_ALL=2,e.ScaleManager.RESIZE=3,e.ScaleManager.USER_SCALE=4,e.ScaleManager.MODES=["EXACT_FIT","NO_SCALE","SHOW_ALL","RESIZE","USER_SCALE"],e.ScaleManager.prototype={boot:function(){var t=this.compatibility;t.supportsFullScreen=this.game.device.fullscreen&&!this.game.device.cocoonJS,this.game.device.iPad||this.game.device.webApp||this.game.device.desktop||(this.game.device.android&&!this.game.device.chrome?t.scrollTo=new e.Point(0,1):t.scrollTo=new e.Point(0,0)),this.game.device.desktop?(t.orientationFallback="screen",t.clickTrampoline="when-not-mouse"):(t.orientationFallback="",t.clickTrampoline="");var i=this;this._orientationChange=function(t){return i.orientationChange(t)},this._windowResize=function(t){return i.windowResize(t)},window.addEventListener("orientationchange",this._orientationChange,!1),window.addEventListener("resize",this._windowResize,!1),this.compatibility.supportsFullScreen&&(this._fullScreenChange=function(t){return i.fullScreenChange(t)},this._fullScreenError=function(t){return i.fullScreenError(t)},document.addEventListener("webkitfullscreenchange",this._fullScreenChange,!1),document.addEventListener("mozfullscreenchange",this._fullScreenChange,!1),document.addEventListener("MSFullscreenChange",this._fullScreenChange,!1),document.addEventListener("fullscreenchange",this._fullScreenChange,!1),document.addEventListener("webkitfullscreenerror",this._fullScreenError,!1),document.addEventListener("mozfullscreenerror",this._fullScreenError,!1),document.addEventListener("MSFullscreenError",this._fullScreenError,!1),document.addEventListener("fullscreenerror",this._fullScreenError,!1)),this.game.onResume.add(this._gameResumed,this),this.dom.getOffset(this.game.canvas,this.offset),this.bounds.setTo(this.offset.x,this.offset.y,this.width,this.height),this.setGameSize(this.game.width,this.game.height),this.screenOrientation=this.dom.getScreenOrientation(this.compatibility.orientationFallback),e.FlexGrid&&(this.grid=new e.FlexGrid(this,this.width,this.height)),this._booted=!0,null!==this._pendingScaleMode&&(this.scaleMode=this._pendingScaleMode,this._pendingScaleMode=null)},parseConfig:function(t){void 0!==t.scaleMode&&(this._booted?this.scaleMode=t.scaleMode:this._pendingScaleMode=t.scaleMode),void 0!==t.fullScreenScaleMode&&(this.fullScreenScaleMode=t.fullScreenScaleMode),t.fullScreenTarget&&(this.fullScreenTarget=t.fullScreenTarget),this.pageAlignHorizontally=t.alignH||!1,this.pageAlignVertically=t.alignV||!1,t.scaleH&&t.scaleV&&this.setUserScale(t.scaleH,t.scaleV,t.trimH,t.trimV)},setupScale:function(t,i){var s,n=new e.Rectangle;""!==this.game.parent&&("string"==typeof this.game.parent?s=document.getElementById(this.game.parent):this.game.parent&&1===this.game.parent.nodeType&&(s=this.game.parent)),s?(this.parentNode=s,this.parentIsWindow=!1,this.getParentBounds(this._parentBounds,this.parentNode),n.width=this._parentBounds.width,n.height=this._parentBounds.height,this.offset.set(this._parentBounds.x,this._parentBounds.y)):(this.parentNode=null,this.parentIsWindow=!0,n.width=this.dom.visualBounds.width,n.height=this.dom.visualBounds.height,this.offset.set(0,0));var r=0,o=0;"number"==typeof t?r=t:(this.parentScaleFactor.x=parseInt(t,10)/100,r=n.width*this.parentScaleFactor.x),"number"==typeof i?o=i:(this.parentScaleFactor.y=parseInt(i,10)/100,o=n.height*this.parentScaleFactor.y),r=Math.floor(r),o=Math.floor(o),this._gameSize.setTo(0,0,r,o),this.updateDimensions(r,o,!1)},_gameResumed:function(){this.queueUpdate(!0)},setGameSize:function(t,i){this._gameSize.setTo(0,0,t,i),this.currentScaleMode!==e.ScaleManager.RESIZE&&this.updateDimensions(t,i,!0),this.queueUpdate(!0)},setUserScale:function(t,e,i,s,n,r){this._userScaleFactor.setTo(t,e),this._userScaleTrim.setTo(0|i,0|s),void 0===n&&(n=!0),void 0===r&&(r=!0),n&&this.queueUpdate(r)},setResizeCallback:function(t,e){this.onResize=t,this.onResizeContext=e},signalSizeChange:function(){if(!e.Rectangle.sameDimensions(this,this._lastReportedCanvasSize)||!e.Rectangle.sameDimensions(this.game,this._lastReportedGameSize)){var t=this.width,i=this.height;this._lastReportedCanvasSize.setTo(0,0,t,i),this._lastReportedGameSize.setTo(0,0,this.game.width,this.game.height),this.grid&&this.grid.onResize(t,i),this.onSizeChange.dispatch(this,t,i),this.currentScaleMode===e.ScaleManager.RESIZE&&(this.game.state.resize(t,i),this.game.load.resize(t,i))}},setMinMax:function(t,e,i,s){this.minWidth=t,this.minHeight=e,void 0!==i&&(this.maxWidth=i),void 0!==s&&(this.maxHeight=s)},preUpdate:function(){if(!(this.game.time.time<this._lastUpdate+this._updateThrottle)){var t=this._updateThrottle;this._updateThrottleReset=t>=400?0:100,this.dom.getOffset(this.game.canvas,this.offset);var i=this._parentBounds.width,s=this._parentBounds.height,n=this.getParentBounds(this._parentBounds),r=n.width!==i||n.height!==s,o=this.updateOrientationState();(r||o)&&(this.onResize&&this.onResize.call(this.onResizeContext,this,n),this.updateLayout(),this.signalSizeChange());var a=2*this._updateThrottle;this._updateThrottle<t&&(a=Math.min(t,this._updateThrottleReset)),this._updateThrottle=e.Math.clamp(a,25,this.trackParentInterval),this._lastUpdate=this.game.time.time}},pauseUpdate:function(){this.preUpdate(),this._updateThrottle=this.trackParentInterval},updateDimensions:function(t,e,i){this.width=t*this.parentScaleFactor.x,this.height=e*this.parentScaleFactor.y,this.game.width=this.width,this.game.height=this.height,this.sourceAspectRatio=this.width/this.height,this.updateScalingAndBounds(),i&&(this.game.renderer.resize(this.width,this.height),this.game.camera.setSize(this.width,this.height),this.game.world.resize(this.width,this.height))},updateScalingAndBounds:function(){this.scaleFactor.x=this.game.width/this.width,this.scaleFactor.y=this.game.height/this.height,this.scaleFactorInversed.x=this.width/this.game.width,this.scaleFactorInversed.y=this.height/this.game.height,this.aspectRatio=this.width/this.height,this.game.canvas&&this.dom.getOffset(this.game.canvas,this.offset),this.bounds.setTo(this.offset.x,this.offset.y,this.width,this.height),this.game.input&&this.game.input.scale&&this.game.input.scale.setTo(this.scaleFactor.x,this.scaleFactor.y)},forceOrientation:function(t,e){void 0===e&&(e=!1),!0!==t||!0!==e?(this.forceLandscape=t,this.forcePortrait=e,this.queueUpdate(!0)):console.warn("Phaser.ScaleManager: forceLandscape and forcePortrait cannot both be true.")},classifyOrientation:function(t){return"portrait-primary"===t||"portrait-secondary"===t?"portrait":"landscape-primary"===t||"landscape-secondary"===t?"landscape":null},updateOrientationState:function(){var t=this.screenOrientation,e=this.incorrectOrientation;this.screenOrientation=this.dom.getScreenOrientation(this.compatibility.orientationFallback),this.incorrectOrientation=this.forceLandscape&&!this.isLandscape||this.forcePortrait&&!this.isPortrait;var i=t!==this.screenOrientation,s=e!==this.incorrectOrientation;return s&&(this.incorrectOrientation?this.enterIncorrectOrientation.dispatch():this.leaveIncorrectOrientation.dispatch()),(i||s)&&this.onOrientationChange.dispatch(this,t,e),i||s},orientationChange:function(t){this.event=t,this.queueUpdate(!0)},windowResize:function(t){this.event=t,this.queueUpdate(!0)},scrollTop:function(){var t=this.compatibility.scrollTo;t&&window.scrollTo(t.x,t.y)},refresh:function(){this.scrollTop(),this.queueUpdate(!0)},updateLayout:function(){var t=this.currentScaleMode;if(t!==e.ScaleManager.RESIZE){if(this.scrollTop(),this.compatibility.forceMinimumDocumentHeight&&(document.documentElement.style.minHeight=window.innerHeight+"px"),this.incorrectOrientation?this.setMaximum():t===e.ScaleManager.EXACT_FIT?this.setExactFit():t===e.ScaleManager.SHOW_ALL?!this.isFullScreen&&this.boundingParent&&this.compatibility.canExpandParent?(this.setShowAll(!0),this.resetCanvas(),this.setShowAll()):this.setShowAll():t===e.ScaleManager.NO_SCALE?(this.width=this.game.width,this.height=this.game.height):t===e.ScaleManager.USER_SCALE&&(this.width=this.game.width*this._userScaleFactor.x-this._userScaleTrim.x,this.height=this.game.height*this._userScaleFactor.y-this._userScaleTrim.y),!this.compatibility.canExpandParent&&(t===e.ScaleManager.SHOW_ALL||t===e.ScaleManager.USER_SCALE)){var i=this.getParentBounds(this._tempBounds);this.width=Math.min(this.width,i.width),this.height=Math.min(this.height,i.height)}this.width=0|this.width,this.height=0|this.height,this.reflowCanvas()}else this.reflowGame()},getParentBounds:function(t,i){var s=t||new e.Rectangle,n=i||this.boundingParent,r=this.dom.visualBounds,o=this.dom.layoutBounds;if(n){var a=n.getBoundingClientRect(),h=n.offsetParent?n.offsetParent.getBoundingClientRect():n.getBoundingClientRect();s.setTo(a.left-h.left,a.top-h.top,a.width,a.height);var l=this.windowConstraints;if(l.right){c="layout"===l.right?o:r;s.right=Math.min(s.right,c.width)}if(l.bottom){var c="layout"===l.bottom?o:r;s.bottom=Math.min(s.bottom,c.height)}}else s.setTo(0,0,r.width,r.height);return s.setTo(Math.round(s.x),Math.round(s.y),Math.round(s.width),Math.round(s.height)),s},align:function(t,e){null!=t&&(this.pageAlignHorizontally=t),null!=e&&(this.pageAlignVertically=e)},alignCanvas:function(t,e){var i=this.getParentBounds(this._tempBounds),s=this.game.canvas,n=this.margin;if(t){n.left=n.right=0;h=s.getBoundingClientRect();if(this.width<i.width&&!this.incorrectOrientation){var r=h.left-i.x,o=i.width/2-this.width/2,a=(o=Math.max(o,0))-r;n.left=Math.round(a)}s.style.marginLeft=n.left+"px",0!==n.left&&(n.right=-(i.width-h.width-n.left),s.style.marginRight=n.right+"px")}if(e){n.top=n.bottom=0;var h=s.getBoundingClientRect();if(this.height<i.height&&!this.incorrectOrientation){var r=h.top-i.y,o=i.height/2-this.height/2,a=(o=Math.max(o,0))-r;n.top=Math.round(a)}s.style.marginTop=n.top+"px",0!==n.top&&(n.bottom=-(i.height-h.height-n.top),s.style.marginBottom=n.bottom+"px")}n.x=n.left,n.y=n.top},reflowGame:function(){this.resetCanvas("","");var t=this.getParentBounds(this._tempBounds);this.updateDimensions(t.width,t.height,!0)},reflowCanvas:function(){this.incorrectOrientation||(this.width=e.Math.clamp(this.width,this.minWidth||0,this.maxWidth||this.width),this.height=e.Math.clamp(this.height,this.minHeight||0,this.maxHeight||this.height)),this.resetCanvas(),this.compatibility.noMargins||(this.isFullScreen&&this._createdFullScreenTarget?this.alignCanvas(!0,!0):this.alignCanvas(this.pageAlignHorizontally,this.pageAlignVertically)),this.updateScalingAndBounds()},resetCanvas:function(t,e){void 0===t&&(t=this.width+"px"),void 0===e&&(e=this.height+"px");var i=this.game.canvas;this.compatibility.noMargins||(i.style.marginLeft="",i.style.marginTop="",i.style.marginRight="",i.style.marginBottom=""),i.style.width=t,i.style.height=e},queueUpdate:function(t){t&&(this._parentBounds.width=0,this._parentBounds.height=0),this._updateThrottle=this._updateThrottleReset},reset:function(t){t&&this.grid&&this.grid.reset()},setMaximum:function(){this.width=this.dom.visualBounds.width,this.height=this.dom.visualBounds.height},setShowAll:function(t){var e,i=this.getParentBounds(this._tempBounds),s=i.width,n=i.height;e=t?Math.max(n/this.game.height,s/this.game.width):Math.min(n/this.game.height,s/this.game.width),this.width=Math.round(this.game.width*e),this.height=Math.round(this.game.height*e)},setExactFit:function(){var t=this.getParentBounds(this._tempBounds);this.width=t.width,this.height=t.height,this.isFullScreen||(this.maxWidth&&(this.width=Math.min(this.width,this.maxWidth)),this.maxHeight&&(this.height=Math.min(this.height,this.maxHeight)))},createFullScreenTarget:function(){var t=document.createElement("div");return t.style.margin="0",t.style.padding="0",t.style.background="#000",t},startFullScreen:function(t,i,s){if(this.isFullScreen)return!1;{if(this.compatibility.supportsFullScreen){if("when-not-mouse"===this.compatibility.clickTrampoline){var n=this.game.input;if(n.activePointer&&n.activePointer!==n.mousePointer&&(i||!1!==i))return void n.activePointer.addClickTrampoline("startFullScreen",this.startFullScreen,this,[t,!1])}void 0!==t&&this.game.renderType===e.CANVAS&&(this.game.stage.smoothed=t);var r=this.fullScreenTarget;r||(this.cleanupCreatedTarget(),this._createdFullScreenTarget=this.createFullScreenTarget(),r=this._createdFullScreenTarget);var o={targetElement:r};if(this.hasPhaserSetFullScreen=!0,this.onFullScreenInit.dispatch(this,o),this._createdFullScreenTarget){var a=this.game.canvas;a.parentNode.insertBefore(r,a),r.appendChild(a)}return void 0===s&&(s={navigationUI:"hide"}),this.game.device.fullscreenKeyboard?r[this.game.device.requestFullscreen](Element.ALLOW_KEYBOARD_INPUT):r[this.game.device.requestFullscreen](s),!0}var h=this;setTimeout(function(){h.fullScreenError()},10)}},stopFullScreen:function(){return!(!this.isFullScreen||!this.compatibility.supportsFullScreen)&&(this.hasPhaserSetFullScreen=!1,document[this.game.device.cancelFullscreen](),!0)},cleanupCreatedTarget:function(){var t=this._createdFullScreenTarget;if(t&&t.parentNode){var e=t.parentNode;e.insertBefore(this.game.canvas,t),e.removeChild(t)}this._createdFullScreenTarget=null},prepScreenMode:function(t){var i=!!this._createdFullScreenTarget,s=this._createdFullScreenTarget||this.fullScreenTarget;t?(i||this.fullScreenScaleMode===e.ScaleManager.EXACT_FIT)&&s!==this.game.canvas&&(this._fullScreenRestore={targetWidth:s.style.width,targetHeight:s.style.height},s.style.width="100%",s.style.height="100%"):(this._fullScreenRestore&&(s.style.width=this._fullScreenRestore.targetWidth,s.style.height=this._fullScreenRestore.targetHeight,this._fullScreenRestore=null),this.updateDimensions(this._gameSize.width,this._gameSize.height,!0),this.resetCanvas())},fullScreenChange:function(t){this.event=t,this.isFullScreen?(this.prepScreenMode(!0),this.updateLayout(),this.queueUpdate(!0)):(this.prepScreenMode(!1),this.cleanupCreatedTarget(),this.updateLayout(),this.queueUpdate(!0)),this.onFullScreenChange.dispatch(this,this.width,this.height)},fullScreenError:function(t){this.event=t,this.cleanupCreatedTarget(),console.warn("Phaser.ScaleManager: requestFullscreen failed or device does not support the Fullscreen API"),this.onFullScreenError.dispatch(this)},scaleSprite:function(t,e,i,s){if(void 0===e&&(e=this.width),void 0===i&&(i=this.height),void 0===s&&(s=!1),!t||!t.scale)return t;if(t.scale.x=1,t.scale.y=1,t.width<=0||t.height<=0||e<=0||i<=0)return t;var n=e,r=t.height*e/t.width,o=t.width*i/t.height,a=i,h=o>e;return(h=h?s:!s)?(t.width=Math.floor(n),t.height=Math.floor(r)):(t.width=Math.floor(o),t.height=Math.floor(a)),t},destroy:function(){this.game.onResume.remove(this._gameResumed,this),window.removeEventListener("orientationchange",this._orientationChange,!1),window.removeEventListener("resize",this._windowResize,!1),this.compatibility.supportsFullScreen&&(document.removeEventListener("webkitfullscreenchange",this._fullScreenChange,!1),document.removeEventListener("mozfullscreenchange",this._fullScreenChange,!1),document.removeEventListener("MSFullscreenChange",this._fullScreenChange,!1),document.removeEventListener("fullscreenchange",this._fullScreenChange,!1),document.removeEventListener("webkitfullscreenerror",this._fullScreenError,!1),document.removeEventListener("mozfullscreenerror",this._fullScreenError,!1),document.removeEventListener("MSFullscreenError",this._fullScreenError,!1),document.removeEventListener("fullscreenerror",this._fullScreenError,!1))}},e.ScaleManager.prototype.constructor=e.ScaleManager,Object.defineProperty(e.ScaleManager.prototype,"boundingParent",{get:function(){return this.parentIsWindow||this.isFullScreen&&this.hasPhaserSetFullScreen&&!this._createdFullScreenTarget?null:this.game.canvas&&this.game.canvas.parentNode||null}}),Object.defineProperty(e.ScaleManager.prototype,"scaleMode",{get:function(){return this._scaleMode},set:function(t){return t!==this._scaleMode&&(this.isFullScreen||(this.updateDimensions(this._gameSize.width,this._gameSize.height,!0),this.queueUpdate(!0)),this._scaleMode=t),this._scaleMode}}),Object.defineProperty(e.ScaleManager.prototype,"fullScreenScaleMode",{get:function(){return this._fullScreenScaleMode},set:function(t){return t!==this._fullScreenScaleMode&&(this.isFullScreen?(this.prepScreenMode(!1),this._fullScreenScaleMode=t,this.prepScreenMode(!0),this.queueUpdate(!0)):this._fullScreenScaleMode=t),this._fullScreenScaleMode}}),Object.defineProperty(e.ScaleManager.prototype,"currentScaleMode",{get:function(){return this.isFullScreen?this._fullScreenScaleMode:this._scaleMode}}),Object.defineProperty(e.ScaleManager.prototype,"pageAlignHorizontally",{get:function(){return this._pageAlignHorizontally},set:function(t){t!==this._pageAlignHorizontally&&(this._pageAlignHorizontally=t,this.queueUpdate(!0))}}),Object.defineProperty(e.ScaleManager.prototype,"pageAlignVertically",{get:function(){return this._pageAlignVertically},set:function(t){t!==this._pageAlignVertically&&(this._pageAlignVertically=t,this.queueUpdate(!0))}}),Object.defineProperty(e.ScaleManager.prototype,"isFullScreen",{get:function(){return!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)}}),Object.defineProperty(e.ScaleManager.prototype,"isPortrait",{get:function(){return"portrait"===this.classifyOrientation(this.screenOrientation)}}),Object.defineProperty(e.ScaleManager.prototype,"isLandscape",{get:function(){return"landscape"===this.classifyOrientation(this.screenOrientation)}}),Object.defineProperty(e.ScaleManager.prototype,"isGamePortrait",{get:function(){return this.height>this.width}}),Object.defineProperty(e.ScaleManager.prototype,"isGameLandscape",{get:function(){return this.width>this.height}}),e.Utils.Debug=function(t){this.game=t,this.sprite=null,this.bmd=null,this.canvas=null,this.context=null,this.font="14px monospace",this.columnWidth=100,this.lineHeight=16,this.lineWidth=1,this.renderShadow=!0,this.currentColor=null,this.currentX=0,this.currentY=0,this.currentAlpha=1,this.dirty=!1,this.isDisabled=!1,this._line=null,this._rect=null},e.Utils.Debug.GEOM_AUTO=0,e.Utils.Debug.GEOM_RECTANGLE=1,e.Utils.Debug.GEOM_CIRCLE=2,e.Utils.Debug.GEOM_POINT=3,e.Utils.Debug.GEOM_LINE=4,e.Utils.Debug.GEOM_ELLIPSE=5,e.Utils.Debug.prototype={boot:function(){this.game.renderType===e.CANVAS?this.context=this.game.context:(this.bmd=new e.BitmapData(this.game,"__DEBUG",this.game.width,this.game.height,!0),this.sprite=this.game.make.image(0,0,this.bmd),this.game.stage.addChild(this.sprite),this.game.scale.onSizeChange.add(this.resize,this),this.canvas=e.CanvasPool.create(this,this.game.width,this.game.height),this.context=this.canvas.getContext("2d")),this._line=new e.Line,this._rect=new e.Rectangle},resize:function(){this.bmd.resize(this.game.width,this.game.height),this.canvas.width=this.game.width,this.canvas.height=this.game.height},preUpdate:function(){this.dirty&&this.sprite&&(this.bmd.clear(),this.bmd.draw(this.canvas,0,0),this.context.clearRect(0,0,this.game.width,this.game.height),this.dirty=!1)},reset:function(){this.context&&this.context.clearRect(0,0,this.game.width,this.game.height),this.sprite&&this.bmd.clear()},start:function(t,e,i,s){"number"!=typeof t&&(t=0),"number"!=typeof e&&(e=0),i=i||"rgb(255,255,255)",void 0===s&&(s=0),this.currentX=t,this.currentY=e,this.currentColor=i,this.columnWidth=s,this.dirty=!0,this.context.save(),this.context.setTransform(1,0,0,1,0,0),this.context.strokeStyle=i,this.context.fillStyle=i,this.context.font=this.font,this.context.globalAlpha=this.currentAlpha},stop:function(){this.context.restore()},line:function(){for(var t=this.currentX,e=0;e<arguments.length;e++)this.renderShadow&&(this.context.fillStyle="rgb(0,0,0)",this.context.fillText(arguments[e],t+1,this.currentY+1),this.context.fillStyle=this.currentColor),this.context.fillText(arguments[e],t,this.currentY),t+=this.columnWidth;this.currentY+=this.lineHeight},sound:function(t,e,i){var s=this.game.sound;this.start(t,e,i),s.noAudio?this.line("Audio is disabled"):(this.line("Volume: "+s.volume.toFixed(2)+(s.mute?" (Mute)":"")),this.line("Mute on pause: "+s.muteOnPause),this.line("Using: "+(s.usingWebAudio?"Web Audio - "+s.context.state:"Audio Tag")),this.line("Touch locked: "+s.touchLocked),this.line("Sounds: "+s._sounds.length)),this.stop()},soundInfo:function(t,e,i,s){if(this.start(e,i,s),this.line("Sound: "+t.key+" Touch locked: "+t.game.sound.touchLocked),this.line("Is Ready?: "+this.game.cache.isSoundReady(t.key)+" Pending Playback: "+t.pendingPlayback),this.line("Decoded: "+t.isDecoded+" Decoding: "+t.isDecoding),this.line("Playing: "+t.isPlaying+" Loop: "+t.loop),this.line("Time: "+(t.currentTime/1e3).toFixed(3)+"s Total: "+t.totalDuration.toFixed(3)+"s"),this.line("Volume: "+t.volume.toFixed(2)+(t.mute?" (Mute)":"")),this.line("Using: "+(t.usingWebAudio?"Web Audio":"Audio Tag")),t.usingWebAudio&&this.line(" Source: "+(t.sourceId||"none")),t.usingAudioTag&&t._sound){var n=t._sound;this.line(" currentSrc: "+n.currentSrc),this.line(" currentTime: "+n.currentTime),this.line(" duration: "+n.duration),this.line(" ended: "+n.ended),this.line(" loop: "+n.loop),this.line(" muted: "+n.muted),this.line(" paused: "+n.paused)}""!==t.currentMarker&&(this.line("Marker: "+t.currentMarker+" Duration: "+t.duration.toFixed(3)+"s ("+t.durationMS+"ms)"),this.line("Start: "+t.markers[t.currentMarker].start.toFixed(3)+" Stop: "+t.markers[t.currentMarker].stop.toFixed(3)),this.line("Position: "+t.position.toFixed(3))),this.stop()},camera:function(t,e,i){var s=t.deadzone,n=t.target,r=t.view;s&&(this._rect.setTo(r.x+s.x,r.y+s.y,s.width,s.height),this.rectangle(this._rect,e,i)),n&&(this._line.setTo(r.centerX,r.centerY,n.x,n.y),this.geom(this._line,e,i),this.geom(n,e,!1,3))},cameraInfo:function(t,e,i,s){var n=t.bounds,r=t.deadzone,o=t.target,a=t.view;this.start(e,i,s),this.line("Camera ("+t.width+" x "+t.height+")"),this.line("x: "+t.x+" y: "+t.y),this.line("Bounds: "+(n?"x: "+n.x+" y: "+n.y+" w: "+n.width+" h: "+n.height:"none")),this.line("View: x: "+a.x+" y: "+a.y+" w: "+a.width+" h: "+a.height),this.line("Center: x: "+t.centerX+" y: "+t.centerY),this.line("Deadzone: "+(r?"x: "+r.x+" y: "+r.y+" w: "+r.width+" h: "+r.height:r)),this.line("Total in view: "+t.totalInView),this.line("At limit: x: "+t.atLimit.x+" y: "+t.atLimit.y),this.line("Target: "+(o?o.name||o:"none")),this.stop()},timer:function(t,e,i,s){this.start(e,i,s),this.line("Timer (running: "+t.running+" expired: "+t.expired+")"),this.line("Next Tick: "+t.next+" Duration: "+t.duration),this.line("Paused: "+t.paused+" Length: "+t.length),this.stop()},pointer:function(t,e,i,s,n,r){if(null!=t&&(void 0===e&&(e=!1),i=i||"rgba(0,255,0,0.5)",s=s||"rgba(255,255,0,0.5)",r=r||"rgba(255,0,0,0.5)",!0!==e||!0!==t.isUp)){this.start(t.x,t.y-150,n),this.context.beginPath(),this.context.arc(t.x,t.y,t.circle.radius,0,2*Math.PI),t.active?this.context.fillStyle=t.isDown?i:s:this.context.fillStyle=r,this.context.fill(),this.context.closePath(),this.context.beginPath(),this.context.moveTo(t.positionDown.x,t.positionDown.y),this.context.lineTo(t.position.x,t.position.y),this.context.lineWidth=2,this.context.stroke(),this.context.closePath();var o=t.movementX,a=t.movementY;(o||a)&&(this.context.beginPath(),this.context.moveTo(o+t.position.x,a+t.position.y),this.context.lineTo(t.position.x,t.position.y),this.context.lineWidth=2,this.context.stroke(),this.context.closePath()),this.line("ID: "+t.id+" Active: "+t.active),this.line("World X: "+t.worldX.toFixed(1)+" World Y: "+t.worldY.toFixed(1)),this.line("Screen X: "+t.x.toFixed(1)+" Screen Y: "+t.y.toFixed(1)+" In: "+t.withinGame),this.line("Movement: X: "+o+" Y: "+a),this.line("Duration: "+t.duration+" ms"),this.line("is Down: "+t.isDown+" is Up: "+t.isUp),t.isMouse&&this.line("Buttons: "+this._pointerButtonIcon(t.leftButton)+" "+this._pointerButtonIcon(t.middleButton)+" "+this._pointerButtonIcon(t.rightButton)),this.stop()}},_pointerButtonIcon:function(t){return t.isDown?"x":t.isUp?"o":"-"},spriteInputInfo:function(t,e,i,s){this.start(e,i,s),this.line("Sprite Input: ("+t.width+" x "+t.height+")"),this.line("x: "+t.input.pointerX().toFixed(1)+" y: "+t.input.pointerY().toFixed(1)),this.line("over: "+t.input.pointerOver()+" duration: "+t.input.overDuration().toFixed(0)),this.line("down: "+t.input.pointerDown()+" duration: "+t.input.downDuration().toFixed(0)),this.line("just over: "+t.input.justOver()+" just out: "+t.input.justOut()),this.stop()},key:function(t,e,i,s){this.start(e,i,s,150),this.line("Key:",t.keyCode,"isDown:",t.isDown),this.line("justDown:",t.justDown,"justUp:",t.justUp),this.line("Time Down:",t.timeDown.toFixed(0),"duration:",t.duration.toFixed(0)),this.stop()},inputInfo:function(t,i,s,n){var r=this.game.input;if(void 0===n&&(n=!0),this.start(t,i,s),this.line("Input"),this.line("X: "+r.x+" Y: "+r.y),this.line("World X: "+r.worldX+" World Y: "+r.worldY),this.line("Scale X: "+r.scale.x.toFixed(2)+" Scale Y: "+r.scale.x.toFixed(2)),this.line("Screen X: "+r.activePointer.screenX.toFixed(1)+" Screen Y: "+r.activePointer.screenY.toFixed(1)),n){this.line("Sources:"),this.line(" "+this._inputHandler(r.mouse,"mouse")),this.line(" "+this._inputHandler(r.mspointer,"mspointer")),this.line(" "+this._inputHandler(r.touch,"touch"));var o=r.pointers,a=r.mousePointer,h=e.PointerModes;this.line("Pointers: (Max: "+r.maxPointers+")"),this.line(" "+(a.isDown?"x":"o")+" "+h[a.pointerMode]+" "+a.identifier);for(var l=0;l<o.length;l++){var c=o[l];this.line(" "+(c.active?"+":"-")+" "+h[c.pointerMode]+" "+c.identifier)}this.stop()}else this.stop()},_inputHandler:function(t,e){return this._inputHandlerStatusIcon(t)+" "+e+" "+this._inputHandlerCaptureIcon(t)},_inputHandlerStatusIcon:function(t){return t.active?t.enabled?"+":"-":" "},_inputHandlerCaptureIcon:function(t){return t.active&&(t.capture||t.preventDefault)?"*":" "},spriteBounds:function(t,e,i){var s=t.getBounds();s.x+=this.game.camera.x,s.y+=this.game.camera.y,this.rectangle(s,e,i)},ropeSegments:function(t,e,i){var s=this;t.segments.forEach(function(t){s.rectangle(t,e,i)},this)},spriteInfo:function(t,e,i,s){this.start(e,i,s),this.line("Sprite: "+(t.name||"")+" ("+t.width+" x "+t.height+") anchor: "+t.anchor.x+" x "+t.anchor.y),this.line("x: "+t.x.toFixed(1)+" y: "+t.y.toFixed(1)),this.line("angle: "+t.angle.toFixed(1)+" rotation: "+t.rotation.toFixed(1)),this.line("visible: "+t.visible+" in camera: "+t.inCamera),this.line("bounds x: "+t._bounds.x.toFixed(1)+" y: "+t._bounds.y.toFixed(1)+" w: "+t._bounds.width.toFixed(1)+" h: "+t._bounds.height.toFixed(1)),this.line("parent: "+(t.parent?t.parent.name||"(DisplayObject)":"(none)")),this.stop()},spriteCoords:function(t,e,i,s){this.start(e,i,s,100),t.name&&this.line(t.name),this.line("x:",t.x.toFixed(2),"y:",t.y.toFixed(2)),this.line("pos x:",t.position.x.toFixed(2),"pos y:",t.position.y.toFixed(2)),this.line("world x:",t.world.x.toFixed(2),"world y:",t.world.y.toFixed(2)),this.stop()},lineInfo:function(t,e,i,s){this.start(e,i,s,80),this.line("start.x:",t.start.x.toFixed(2),"start.y:",t.start.y.toFixed(2)),this.line("end.x:",t.end.x.toFixed(2),"end.y:",t.end.y.toFixed(2)),this.line("length:",t.length.toFixed(2),"angle:",t.angle),this.stop()},pixel:function(t,e,i,s){s=s||2,this.start(),this.context.fillStyle=i,this.context.fillRect(t,e,s,s),this.stop()},geom:function(t,i,s,n){void 0===s&&(s=!0),void 0===n&&(n=0),i=i||"rgba(0,255,0,0.4)",this.start(),this.context.fillStyle=i,this.context.strokeStyle=i,this.context.lineWidth=this.lineWidth;var r=e.Utils.Debug;n===r.GEOM_RECTANGLE||t instanceof e.Rectangle?s?this.context.fillRect(t.x-this.game.camera.x,t.y-this.game.camera.y,t.width,t.height):this.context.strokeRect(t.x-this.game.camera.x,t.y-this.game.camera.y,t.width,t.height):n===r.GEOM_CIRCLE||t instanceof e.Circle?(this.context.beginPath(),this.context.arc(t.x-this.game.camera.x,t.y-this.game.camera.y,t.radius,0,2*Math.PI,!1),this.context.closePath(),s?this.context.fill():this.context.stroke()):n===r.GEOM_POINT||t instanceof e.Point?this.context.fillRect(t.x-this.game.camera.x,t.y-this.game.camera.y,4,4):n===r.GEOM_LINE||t instanceof e.Line?(this.context.beginPath(),this.context.moveTo(t.start.x+.5-this.game.camera.x,t.start.y+.5-this.game.camera.y),this.context.lineTo(t.end.x+.5-this.game.camera.x,t.end.y+.5-this.game.camera.y),this.context.closePath(),this.context.stroke()):(n===r.GEOM_ELLIPSE||t instanceof e.Ellipse)&&(this.context.beginPath(),this.context.ellipse(t.centerX-this.game.camera.x,t.centerY-this.game.camera.y,t.width/2,t.height/2,0,2*Math.PI,!1),this.context.closePath(),s?this.context.fill():this.context.stroke()),this.stop()},rectangle:function(t,e,i){void 0===i&&(i=!0),e=e||"rgba(0, 255, 0, 0.4)",this.start(),i?(this.context.fillStyle=e,this.context.fillRect(t.x-this.game.camera.x,t.y-this.game.camera.y,t.width,t.height)):(this.context.lineWidth=this.lineWidth,this.context.strokeStyle=e,this.context.strokeRect(t.x-this.game.camera.x,t.y-this.game.camera.y,t.width,t.height)),this.stop()},text:function(t,e,i,s,n){s=s||"rgb(255,255,255)",n=n||this.font,this.start(),this.context.font=n,this.renderShadow&&(this.context.fillStyle="rgb(0,0,0)",this.context.fillText(t,e+1,i+1)),this.context.fillStyle=s,this.context.fillText(t,e,i),this.stop()},quadTree:function(t,e){e=e||"rgba(255,0,0,0.3)",this.start();var i=t.bounds;if(0===t.nodes.length){this.context.strokeStyle=e,this.context.strokeRect(i.x,i.y,i.width,i.height),this.text("size: "+t.objects.length,i.x+4,i.y+16,"rgb(0,200,0)","12px Courier"),this.context.strokeStyle="rgb(0,255,0)";for(s=0;s<t.objects.length;s++)this.context.strokeRect(t.objects[s].x,t.objects[s].y,t.objects[s].width,t.objects[s].height)}else for(var s=0;s<t.nodes.length;s++)this.quadTree(t.nodes[s]);this.stop()},body:function(t,i,s){t.body&&(this.start(),t.body.type===e.Physics.ARCADE?e.Physics.Arcade.Body.render(this.context,t.body,i,s,this.lineWidth):t.body.type===e.Physics.NINJA?e.Physics.Ninja.Body.render(this.context,t.body,i,s):t.body.type===e.Physics.BOX2D&&e.Physics.Box2D.renderBody(this.context,t.body,i),this.stop())},bodyInfo:function(t,i,s,n){t.body&&(this.start(i,s,n,210),t.body.type===e.Physics.ARCADE?e.Physics.Arcade.Body.renderBodyInfo(this,t.body):t.body.type===e.Physics.BOX2D&&this.game.physics.box2d.renderBodyInfo(this,t.body),this.stop())},box2dWorld:function(){this.start(),this.context.translate(-this.game.camera.view.x,-this.game.camera.view.y,0),this.game.physics.box2d.renderDebugDraw(this.context),this.stop()},box2dBody:function(t,i){this.start(),e.Physics.Box2D.renderBody(this.context,t,i),this.stop()},displayList:function(t){if(void 0===t&&(t=this.game.world),t.hasOwnProperty("renderOrderID")?console.log("["+t.renderOrderID+"]",t):console.log("[]",t),t.children&&t.children.length>0)for(var e=0;e<t.children.length;e++)this.game.debug.displayList(t.children[e])},renderer:function(t,e,i){var s=this.game.renderer,n=s.renderSession;if(this.start(t,e,i),this.line((s.gl?"WebGL":"Canvas")+" Renderer ("+s.width+" x "+s.height+")"),this.line("autoResize: "+s.autoResize),this.line("clearBeforeRender: "+s.clearBeforeRender),this.line("resolution: "+s.resolution),this.line("transparent: "+s.transparent),this.line("renderSession:"),s.gl){this.line(" currentBatchedTextures: ("+s.currentBatchedTextures.length+")");for(var r=0;r<s.currentBatchedTextures.length;r++)this.line(" "+s.currentBatchedTextures[r]);this.line(" drawCount: "+n.drawCount),this.line(" maxTextures: "+s.maxTextures),this.line(" maxTextureSize: "+s.maxTextureSize),this.line(" maxTextureAvailableSpace: "+n.maxTextureAvailableSpace),this.line(" roundPixels: "+n.roundPixels)}else this.line(" roundPixels: "+n.roundPixels),this.line(" scaleMode: "+(0===n.scaleMode?"LINEAR":1===n.scaleMode?"NEAREST":n.scaleMode));this.stop()},canvasPool:function(t,i,s,n){var r=e.CanvasPool;this.start(t,i,s,n||100),this.line("Canvas Pool"),this.line("Used:",r.getTotal()),this.line("Free:",r.getFree()),this.line("Total:",r.length),this.stop()},physicsGroup:function(t,e,i,s){t.forEach(this.body,this,s,e,i)},phaser:function(t,i,s){this.text("Phaser v"+e.VERSION+" "+(this.game.renderType===e.WEBGL?"WebGL":"Canvas")+" "+(this.game.device.webAudio?"WebAudio":"HTML Audio"),t,i,s,this.font)},scale:function(t,i,s){this.start(t,i,s);var n=this.game.scale,r=n.scaleFactorInversed,o=n._parentBounds,t=" x ";this.line("Game: "+this.game.width+t+this.game.height),this.line("Canvas: "+n.width+t+n.height+" ("+r.x.toFixed(2)+t+r.y.toFixed(2)+") ["+n.aspectRatio.toFixed(2)+"]"),this.line("Mode: "+e.ScaleManager.MODES[n.currentScaleMode]+(n.currentScaleMode===e.ScaleManager.USER_SCALE?" ("+n._userScaleFactor.x+t+n._userScaleFactor.y+")":"")),this.line("Parent: "+(n.parentIsWindow?"window":n.parentNode)+(o.empty?"":" ("+o.width+t+o.height+")")),this.line("Screen: "+n.classifyOrientation(n.screenOrientation)+(n.incorrectOrientation?" (incorrect)":"")),this.stop()},loader:function(t,i,s,n){var r=e.Utils.pad;this.start(i,s,n),t.hasLoaded?this.line("Complete"+(t.resetLocked?" [locked]":"")):t.isLoading?this.line("Loading"):this.line("Not started"),t.hasLoaded&&!t.resetLocked||(this.line("Progress: "+r(t.progress,3)+"%"),this.line("Files: "+t._loadedFileCount+" of "+t._totalFileCount),this.line("Packs: "+t._loadedPackCount+" of "+t._loadedPackCount)),this.stop()},device:function(t,e,i){var s=this.game.device;this.start(t,e,i),this.line("Device"),this.line("Pointer Events: "+s.mspointer),this.line("Touch: "+s.touch),this.line("Web Audio: "+s.webAudio),this.line("WebGL: "+s.webGL),this.stop()},destroy:function(){e.CanvasPool.remove(this)}},e.Utils.Debug.prototype.constructor=e.Utils.Debug,e.DOM={getOffset:function(t,i){i=i||new e.Point;var s=t.getBoundingClientRect(),n=e.DOM.scrollY,r=e.DOM.scrollX,o=document.documentElement.clientTop,a=document.documentElement.clientLeft;return i.x=s.left+r-a,i.y=s.top+n-o,i},getBounds:function(t,e){return void 0===e&&(e=0),!(!(t=t&&!t.nodeType?t[0]:t)||1!==t.nodeType)&&this.calibrate(t.getBoundingClientRect(),e)},calibrate:function(t,e){e=+e||0;var i={width:0,height:0,left:0,right:0,top:0,bottom:0};return i.width=(i.right=t.right+e)-(i.left=t.left-e),i.height=(i.bottom=t.bottom+e)-(i.top=t.top-e),i},getAspectRatio:function(t){var e=(t=null==t?this.visualBounds:1===t.nodeType?this.getBounds(t):t).width,i=t.height;return"function"==typeof e&&(e=e.call(t)),"function"==typeof i&&(i=i.call(t)),e/i},inLayoutViewport:function(t,e){var i=this.getBounds(t,e);return!!i&&i.bottom>=0&&i.right>=0&&i.top<=this.layoutBounds.width&&i.left<=this.layoutBounds.height},getScreenOrientation:function(t){var e=window.screen,i=e.orientation||e.mozOrientation||e.msOrientation;if(i&&"string"==typeof i.type)return i.type;if("string"==typeof i)return i;var s="portrait-primary",n="landscape-primary";if("screen"===t)return e.height>e.width?s:n;if("viewport"===t)return this.visualBounds.height>this.visualBounds.width?s:n;if("window.orientation"===t&&"number"==typeof window.orientation)return 0===window.orientation||180===window.orientation?s:n;if(window.matchMedia){if(window.matchMedia("(orientation: portrait)").matches)return s;if(window.matchMedia("(orientation: landscape)").matches)return n}return this.visualBounds.height>this.visualBounds.width?s:n},visualBounds:new e.Rectangle,layoutBounds:new e.Rectangle,documentBounds:new e.Rectangle},e.Device.whenReady(function(t){var i=window&&"pageXOffset"in window?function(){return window.pageXOffset}:function(){return document.documentElement.scrollLeft},s=window&&"pageYOffset"in window?function(){return window.pageYOffset}:function(){return document.documentElement.scrollTop};if(Object.defineProperty(e.DOM,"scrollX",{get:i}),Object.defineProperty(e.DOM,"scrollY",{get:s}),Object.defineProperty(e.DOM.visualBounds,"x",{get:i}),Object.defineProperty(e.DOM.visualBounds,"y",{get:s}),Object.defineProperty(e.DOM.layoutBounds,"x",{value:0}),Object.defineProperty(e.DOM.layoutBounds,"y",{value:0}),t.desktop&&document.documentElement.clientWidth<=window.innerWidth&&document.documentElement.clientHeight<=window.innerHeight){var n=function(){return Math.max(window.innerWidth,document.documentElement.clientWidth)},r=function(){return Math.max(window.innerHeight,document.documentElement.clientHeight)};Object.defineProperty(e.DOM.visualBounds,"width",{get:n}),Object.defineProperty(e.DOM.visualBounds,"height",{get:r}),Object.defineProperty(e.DOM.layoutBounds,"width",{get:n}),Object.defineProperty(e.DOM.layoutBounds,"height",{get:r})}else Object.defineProperty(e.DOM.visualBounds,"width",{get:function(){return window.innerWidth}}),Object.defineProperty(e.DOM.visualBounds,"height",{get:function(){return window.innerHeight}}),Object.defineProperty(e.DOM.layoutBounds,"width",{get:function(){var t=document.documentElement.clientWidth,e=window.innerWidth;return t<e?e:t}}),Object.defineProperty(e.DOM.layoutBounds,"height",{get:function(){var t=document.documentElement.clientHeight,e=window.innerHeight;return t<e?e:t}});Object.defineProperty(e.DOM.documentBounds,"x",{value:0}),Object.defineProperty(e.DOM.documentBounds,"y",{value:0}),Object.defineProperty(e.DOM.documentBounds,"width",{get:function(){var t=document.documentElement;return Math.max(t.clientWidth,t.offsetWidth,t.scrollWidth)}}),Object.defineProperty(e.DOM.documentBounds,"height",{get:function(){var t=document.documentElement;return Math.max(t.clientHeight,t.offsetHeight,t.scrollHeight)}})},null,!0),e.ArraySet=function(t){this.position=0,this.list=t||[]},e.ArraySet.prototype={add:function(t){return this.exists(t)||this.list.push(t),t},getIndex:function(t){return this.list.indexOf(t)},getByKey:function(t,e){for(var i=this.list.length;i--;)if(this.list[i][t]===e)return this.list[i];return null},exists:function(t){return this.list.indexOf(t)>-1},reset:function(){this.list.length=0},remove:function(t){var e=this.list.indexOf(t);if(e>-1)return this.list.splice(e,1),t},setAll:function(t,e){for(var i=this.list.length;i--;)this.list[i]&&(this.list[i][t]=e)},callAll:function(t){for(var e=Array.prototype.slice.call(arguments,1),i=this.list.length;i--;)this.list[i]&&this.list[i][t]&&this.list[i][t].apply(this.list[i],e)},removeAll:function(t){void 0===t&&(t=!1);for(var e=this.list.length;e--;)if(this.list[e]){var i=this.remove(this.list[e]);t&&i.destroy()}this.position=0,this.list=[]}},Object.defineProperty(e.ArraySet.prototype,"total",{get:function(){return this.list.length}}),Object.defineProperty(e.ArraySet.prototype,"first",{get:function(){return this.position=0,this.list.length>0?this.list[0]:null}}),Object.defineProperty(e.ArraySet.prototype,"next",{get:function(){return this.position<this.list.length?(this.position++,this.list[this.position]):null}}),e.ArraySet.prototype.constructor=e.ArraySet,e.ArrayUtils={getRandomItem:function(t,e,i){if(null===t)return null;void 0===e&&(e=0),void 0===i&&(i=t.length);var s=e+Math.floor(Math.random()*i);return void 0===t[s]?null:t[s]},removeRandomItem:function(t,e,i){if(null==t)return null;void 0===e&&(e=0),void 0===i&&(i=t.length);var s=e+Math.floor(Math.random()*i);if(s<t.length){var n=t.splice(s,1);return void 0===n[0]?null:n[0]}return null},remove:function(t,e,i){var s=t.length;if(!(e>=s||0===i)){null==i&&(i=1);for(var n=s-i,r=e;r<n;++r)t[r]=t[r+i];t.length=n}},shuffle:function(t){for(var e=t.length-1;e>0;e--){var i=Math.floor(Math.random()*(e+1)),s=t[e];t[e]=t[i],t[i]=s}return t},transposeMatrix:function(t){for(var e=t.length,i=t[0].length,s=new Array(i),n=0;n<i;n++){s[n]=new Array(e);for(var r=e-1;r>-1;r--)s[n][r]=t[r][n]}return s},rotateMatrix:function(t,i){if("string"!=typeof i&&(i=(i%360+360)%360),90===i||-270===i||"rotateLeft"===i)t=(t=e.ArrayUtils.transposeMatrix(t)).reverse();else if(-90===i||270===i||"rotateRight"===i)t=t.reverse(),t=e.ArrayUtils.transposeMatrix(t);else if(180===Math.abs(i)||"rotate180"===i){for(var s=0;s<t.length;s++)t[s].reverse();t=t.reverse()}return t},findClosest:function(t,e){if(!e.length)return NaN;if(1===e.length||t<e[0])return e[0];for(var i=1;e[i]<t;)i++;var s=e[i-1],n=i<e.length?e[i]:Number.POSITIVE_INFINITY;return n-t<=t-s?n:s},rotateRight:function(t){var e=t.pop();return t.unshift(e),e},rotateLeft:function(t){var e=t.shift();return t.push(e),e},numberArray:function(t,e){void 0!==e&&null!==e||(e=t,t=0);for(var i=[],s=t;s<=e;s++)i.push(s);return i},numberArrayStep:function(t,i,s){void 0!==t&&null!==t||(t=0),void 0!==i&&null!==i||(i=t,t=0),void 0===s&&(s=1);for(var n=[],r=Math.max(e.Math.roundAwayFromZero((i-t)/(s||1)),0),o=0;o<r;o++)n.push(t),t+=s;return n}},e.LinkedList=function(){this.next=null,this.prev=null,this.first=null,this.last=null,this.total=0},e.LinkedList.prototype={add:function(t){return 0===this.total&&null===this.first&&null===this.last?(this.first=t,this.last=t,this.next=t,t.prev=this,this.total++,t):(this.last.next=t,t.prev=this.last,this.last=t,this.total++,t)},reset:function(){this.first=null,this.last=null,this.next=null,this.prev=null,this.total=0},remove:function(t){if(1===this.total)return this.reset(),void(t.next=t.prev=null);t===this.first?this.first=this.first.next:t===this.last&&(this.last=this.last.prev),t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),t.next=t.prev=null,null===this.first&&(this.last=null),this.total--},callAll:function(t){if(this.first&&this.last){var e=this.first;do{e&&e[t]&&e[t].call(e),e=e.next}while(e!==this.last.next)}}},e.LinkedList.prototype.constructor=e.LinkedList,e.Create=function(t){this.game=t,this.bmd=null,this.canvas=null,this.ctx=null,this.palettes=[{0:"#000",1:"#9D9D9D",2:"#FFF",3:"#BE2633",4:"#E06F8B",5:"#493C2B",6:"#A46422",7:"#EB8931",8:"#F7E26B",9:"#2F484E",A:"#44891A",B:"#A3CE27",C:"#1B2632",D:"#005784",E:"#31A2F2",F:"#B2DCEF"},{0:"#000",1:"#191028",2:"#46af45",3:"#a1d685",4:"#453e78",5:"#7664fe",6:"#833129",7:"#9ec2e8",8:"#dc534b",9:"#e18d79",A:"#d6b97b",B:"#e9d8a1",C:"#216c4b",D:"#d365c8",E:"#afaab9",F:"#f5f4eb"},{0:"#000",1:"#2234d1",2:"#0c7e45",3:"#44aacc",4:"#8a3622",5:"#5c2e78",6:"#aa5c3d",7:"#b5b5b5",8:"#5e606e",9:"#4c81fb",A:"#6cd947",B:"#7be2f9",C:"#eb8a60",D:"#e23d69",E:"#ffd93f",F:"#fff"},{0:"#000",1:"#fff",2:"#8b4131",3:"#7bbdc5",4:"#8b41ac",5:"#6aac41",6:"#3931a4",7:"#d5de73",8:"#945a20",9:"#5a4100",A:"#bd736a",B:"#525252",C:"#838383",D:"#acee8b",E:"#7b73de",F:"#acacac"},{0:"#000",1:"#191028",2:"#46af45",3:"#a1d685",4:"#453e78",5:"#7664fe",6:"#833129",7:"#9ec2e8",8:"#dc534b",9:"#e18d79",A:"#d6b97b",B:"#e9d8a1",C:"#216c4b",D:"#d365c8",E:"#afaab9",F:"#fff"}]},e.Create.PALETTE_ARNE=0,e.Create.PALETTE_JMP=1,e.Create.PALETTE_CGA=2,e.Create.PALETTE_C64=3,e.Create.PALETTE_JAPANESE_MACHINE=4,e.Create.prototype={texture:function(t,e,i,s,n,r,o,a){void 0===i&&(i=8),void 0===s&&(s=i),void 0===n&&(n=0),void 0===r&&(r=!0);var h=e[0].length*i,l=e.length*s;null===this.bmd&&(this.bmd=this.game.make.bitmapData(),this.canvas=this.bmd.canvas,this.ctx=this.bmd.context),this.bmd.resize(h,l),this.bmd.clear();for(var c=0;c<e.length;c++)for(var u=e[c],d=0;d<u.length;d++){var p=u[d];"."!==p&&" "!==p&&(this.ctx.fillStyle=this.palettes[n][p],this.ctx.fillRect(d*i,c*s,i,s))}return r?this.bmd.generateTexture(t,o,a):this.copy()},grid:function(t,e,i,s,n,r,o,a,h){void 0===o&&(o=!0),null===this.bmd&&(this.bmd=this.game.make.bitmapData(),this.canvas=this.bmd.canvas,this.ctx=this.bmd.context),this.bmd.resize(e,i),this.ctx.fillStyle=r;for(var l=0;l<i;l+=n)this.ctx.fillRect(0,l,e,1);for(var c=0;c<e;c+=s)this.ctx.fillRect(c,0,1,i);return o?this.bmd.generateTexture(t,a,h):this.copy()},copy:function(t,e,i,s,n,r,o){return null==t&&(t=this.game.make.bitmapData()),t.resize(this.bmd.width,this.bmd.height),t.draw(this.bmd,e,i,s,n,r,o)}},e.Create.prototype.constructor=e.Create,e.FlexGrid=function(t,i,s){this.game=t.game,this.manager=t,this.width=i,this.height=s,this.boundsCustom=new e.Rectangle(0,0,i,s),this.boundsFluid=new e.Rectangle(0,0,i,s),this.boundsFull=new e.Rectangle(0,0,i,s),this.boundsNone=new e.Rectangle(0,0,i,s),this.positionCustom=new e.Point(0,0),this.positionFluid=new e.Point(0,0),this.positionFull=new e.Point(0,0),this.positionNone=new e.Point(0,0),this.scaleCustom=new e.Point(1,1),this.scaleFluid=new e.Point(1,1),this.scaleFluidInversed=new e.Point(1,1),this.scaleFull=new e.Point(1,1),this.scaleNone=new e.Point(1,1),this.customWidth=0,this.customHeight=0,this.customOffsetX=0,this.customOffsetY=0,this.ratioH=i/s,this.ratioV=s/i,this.multiplier=0,this.layers=[]},e.FlexGrid.prototype={setSize:function(t,i){this.width=t,this.height=i,this.ratioH=t/i,this.ratioV=i/t,this.scaleNone=new e.Point(1,1),this.boundsNone.width=this.width,this.boundsNone.height=this.height,this.refresh()},createCustomLayer:function(t,i,s,n){void 0===n&&(n=!0),this.customWidth=t,this.customHeight=i,this.boundsCustom.width=t,this.boundsCustom.height=i;var r=new e.FlexLayer(this,this.positionCustom,this.boundsCustom,this.scaleCustom);return n&&this.game.world.add(r),this.layers.push(r),s&&r.addMultiple(s),r},createFluidLayer:function(t,i){void 0===i&&(i=!0);var s=new e.FlexLayer(this,this.positionFluid,this.boundsFluid,this.scaleFluid);return i&&this.game.world.add(s),this.layers.push(s),t&&s.addMultiple(t),s},createFullLayer:function(t){var i=new e.FlexLayer(this,this.positionFull,this.boundsFull,this.scaleFluid);return this.game.world.add(i),this.layers.push(i),void 0!==t&&i.addMultiple(t),i},createFixedLayer:function(t){var i=new e.FlexLayer(this,this.positionNone,this.boundsNone,this.scaleNone);return this.game.world.add(i),this.layers.push(i),void 0!==t&&i.addMultiple(t),i},reset:function(){for(var t=this.layers.length;t--;)this.layers[t].persist||(this.layers[t].position=null,this.layers[t].scale=null,this.layers.slice(t,1))},onResize:function(t,e){this.ratioH=t/e,this.ratioV=e/t,this.refresh(t,e)},refresh:function(){this.multiplier=Math.min(this.manager.height/this.height,this.manager.width/this.width),this.boundsFluid.width=Math.round(this.width*this.multiplier),this.boundsFluid.height=Math.round(this.height*this.multiplier),this.scaleFluid.set(this.boundsFluid.width/this.width,this.boundsFluid.height/this.height),this.scaleFluidInversed.set(this.width/this.boundsFluid.width,this.height/this.boundsFluid.height),this.scaleFull.set(this.boundsFull.width/this.width,this.boundsFull.height/this.height),this.boundsFull.width=Math.round(this.manager.width*this.scaleFluidInversed.x),this.boundsFull.height=Math.round(this.manager.height*this.scaleFluidInversed.y),this.boundsFluid.centerOn(this.manager.bounds.centerX,this.manager.bounds.centerY),this.boundsNone.centerOn(this.manager.bounds.centerX,this.manager.bounds.centerY),this.positionFluid.set(this.boundsFluid.x,this.boundsFluid.y),this.positionNone.set(this.boundsNone.x,this.boundsNone.y)},fitSprite:function(t){this.manager.scaleSprite(t),t.x=this.manager.bounds.centerX,t.y=this.manager.bounds.centerY},debug:function(){this.game.debug.text(this.boundsFluid.width+" x "+this.boundsFluid.height,this.boundsFluid.x+4,this.boundsFluid.y+16),this.game.debug.geom(this.boundsFluid,"rgba(255,0,0,0.9",!1)}},e.FlexGrid.prototype.constructor=e.FlexGrid,e.FlexLayer=function(t,i,s,n){e.Group.call(this,t.game,null,"__flexLayer"+t.game.rnd.uuid(),!1),this.manager=t.manager,this.grid=t,this.persist=!1,this.position=i,this.bounds=s,this.scale=n,this.topLeft=s.topLeft,this.topMiddle=new e.Point(s.halfWidth,0),this.topRight=s.topRight,this.bottomLeft=s.bottomLeft,this.bottomMiddle=new e.Point(s.halfWidth,s.bottom),this.bottomRight=s.bottomRight},e.FlexLayer.prototype=Object.create(e.Group.prototype),e.FlexLayer.prototype.constructor=e.FlexLayer,e.FlexLayer.prototype.resize=function(){},e.FlexLayer.prototype.debug=function(){this.game.debug.text(this.bounds.width+" x "+this.bounds.height,this.bounds.x+4,this.bounds.y+16),this.game.debug.geom(this.bounds,"rgba(0,0,255,0.9",!1),this.game.debug.geom(this.topLeft,"rgba(255,255,255,0.9"),this.game.debug.geom(this.topMiddle,"rgba(255,255,255,0.9"),this.game.debug.geom(this.topRight,"rgba(255,255,255,0.9")},e.Color={RED:16711680,ORANGE:16750848,YELLOW:16776960,GREEN:65280,AQUA:65535,BLUE:255,VIOLET:16711935,WHITE:16777215,BLACK:0,GRAY:6710886,packPixel:function(t,i,s,n){return e.Device.LITTLE_ENDIAN?(n<<24|s<<16|i<<8|t)>>>0:(t<<24|i<<16|s<<8|n)>>>0},unpackPixel:function(t,i,s,n){return void 0!==i&&null!==i||(i=e.Color.createColor()),void 0!==s&&null!==s||(s=!1),void 0!==n&&null!==n||(n=!1),e.Device.LITTLE_ENDIAN?(i.a=(4278190080&t)>>>24,i.b=(16711680&t)>>>16,i.g=(65280&t)>>>8,i.r=255&t):(i.r=(4278190080&t)>>>24,i.g=(16711680&t)>>>16,i.b=(65280&t)>>>8,i.a=255&t),i.color=t,i.rgba="rgba("+i.r+","+i.g+","+i.b+","+i.a/255+")",s&&e.Color.RGBtoHSL(i.r,i.g,i.b,i),n&&e.Color.RGBtoHSV(i.r,i.g,i.b,i),i},fromRGBA:function(t,i){return i||(i=e.Color.createColor()),i.r=(4278190080&t)>>>24,i.g=(16711680&t)>>>16,i.b=(65280&t)>>>8,i.a=255&t,i.rgba="rgba("+i.r+","+i.g+","+i.b+","+i.a+")",i},toRGBA:function(t,e,i,s){return t<<24|e<<16|i<<8|s},toABGR:function(t,e,i,s){return(s<<24|i<<16|e<<8|t)>>>0},hexToRGBArray:function(t){return[(t>>16&255)/255,(t>>8&255)/255,(255&t)/255]},RGBArrayToHex:function(t){return(255*t[0]<<16)+(255*t[1]<<8)+255*t[2]},RGBtoHSL:function(t,i,s,n){n||(n=e.Color.createColor(t,i,s,1)),t/=255,i/=255,s/=255;var r=Math.min(t,i,s),o=Math.max(t,i,s);if(n.h=0,n.s=0,n.l=(o+r)/2,o!==r){var a=o-r;n.s=n.l>.5?a/(2-o-r):a/(o+r),o===t?n.h=(i-s)/a+(i<s?6:0):o===i?n.h=(s-t)/a+2:o===s&&(n.h=(t-i)/a+4),n.h/=6}return n},HSLtoRGB:function(t,i,s,n){if(n?(n.r=s,n.g=s,n.b=s):n=e.Color.createColor(s,s,s),0!==i){var r=s<.5?s*(1+i):s+i-s*i,o=2*s-r;n.r=e.Color.hueToColor(o,r,t+1/3),n.g=e.Color.hueToColor(o,r,t),n.b=e.Color.hueToColor(o,r,t-1/3)}return n.r=Math.floor(255*n.r|0),n.g=Math.floor(255*n.g|0),n.b=Math.floor(255*n.b|0),e.Color.updateColor(n),n},RGBtoHSV:function(t,i,s,n){n||(n=e.Color.createColor(t,i,s,255)),t/=255,i/=255,s/=255;var r=Math.min(t,i,s),o=Math.max(t,i,s),a=o-r;return n.h=0,n.s=0===o?0:a/o,n.v=o,o!==r&&(o===t?n.h=(i-s)/a+(i<s?6:0):o===i?n.h=(s-t)/a+2:o===s&&(n.h=(t-i)/a+4),n.h/=6),n},HSVtoRGB:function(t,i,s,n){void 0===n&&(n=e.Color.createColor(0,0,0,1,t,i,0,s));var r,o,a,h=Math.floor(6*t),l=6*t-h,c=s*(1-i),u=s*(1-l*i),d=s*(1-(1-l)*i);switch(h%6){case 0:r=s,o=d,a=c;break;case 1:r=u,o=s,a=c;break;case 2:r=c,o=s,a=d;break;case 3:r=c,o=u,a=s;break;case 4:r=d,o=c,a=s;break;case 5:r=s,o=c,a=u}return n.r=Math.floor(255*r),n.g=Math.floor(255*o),n.b=Math.floor(255*a),e.Color.updateColor(n),n},hueToColor:function(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t},createColor:function(t,i,s,n,r,o,a,h){var l={r:t||0,g:i||0,b:s||0,a:n||1,h:r||0,s:o||0,l:a||0,v:h||0,color:0,color32:0,rgba:""};return e.Color.updateColor(l)},updateColor:function(t){return t.rgba="rgba("+t.r.toFixed()+","+t.g.toFixed()+","+t.b.toFixed()+","+t.a.toString()+")",t.color=e.Color.getColor(t.r,t.g,t.b),t.color32=e.Color.getColor32(255*t.a,t.r,t.g,t.b),t},getColor32:function(t,e,i,s){return t<<24|e<<16|i<<8|s},getColor:function(t,e,i){return t<<16|e<<8|i},RGBtoString:function(t,i,s,n,r){return void 0===n&&(n=255),void 0===r&&(r="#"),"#"===r?"#"+((1<<24)+(t<<16)+(i<<8)+s).toString(16).slice(1):"0x"+e.Color.componentToHex(n)+e.Color.componentToHex(t)+e.Color.componentToHex(i)+e.Color.componentToHex(s)},hexToRGB:function(t){var i=e.Color.hexToColor(t);if(i)return e.Color.getColor32(i.a,i.r,i.g,i.b)},hexToColor:function(t,i){t=t.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i,function(t,e,i,s){return e+e+i+i+s+s});var s=/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);if(s){var n=parseInt(s[1],16),r=parseInt(s[2],16),o=parseInt(s[3],16);i?(i.r=n,i.g=r,i.b=o):i=e.Color.createColor(n,r,o)}return i},webToColor:function(t,i){i||(i=e.Color.createColor());var s=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(t);return s&&(i.r=~~Number(s[1]),i.g=~~Number(s[2]),i.b=~~Number(s[3]),i.a=void 0!==s[4]?Number(s[4]):1,e.Color.updateColor(i)),i},valueToColor:function(t,i){if(i||(i=e.Color.createColor()),"string"==typeof t)return 0===t.indexOf("rgb")?e.Color.webToColor(t,i):(i.a=1,e.Color.hexToColor(t,i));if("number"==typeof t){var s=e.Color.getRGB(t);return i.r=s.r,i.g=s.g,i.b=s.b,i.a=s.a/255,i}return i},componentToHex:function(t){var e=t.toString(16);return 1===e.length?"0"+e:e},HSVColorWheel:function(t,i){void 0===t&&(t=1),void 0===i&&(i=1);for(var s=[],n=0;n<=359;n++)s.push(e.Color.HSVtoRGB(n/359,t,i));return s},HSLColorWheel:function(t,i){void 0===t&&(t=.5),void 0===i&&(i=.5);for(var s=[],n=0;n<=359;n++)s.push(e.Color.HSLtoRGB(n/359,t,i));return s},interpolateColor:function(t,i,s,n,r,o){void 0===r&&(r=255),void 0===o&&(o=0);var a=e.Color.getRGB(t),h=e.Color.getRGB(i);if(0===o)var l=(h.red-a.red)*n/s+a.red,c=(h.green-a.green)*n/s+a.green,u=(h.blue-a.blue)*n/s+a.blue;if(1===o){var d,p=e.Color.RGBtoHSV(a.r,a.g,a.b),f=e.Color.RGBtoHSV(h.r,h.g,h.b),g=f.h-p.h;if(p.h>f.h){var m=f.h;f.h=p.h,p.h=m,g=-g,n=s-n}g>.5&&(p.h=p.h+1,d=((f.h-p.h)*n/s+p.h)%1),g<=.5&&(d=(f.h-p.h)*n/s+p.h);var y=(f.s-p.s)*n/s+p.s,v=(f.v-p.v)*n/s+p.v,x=e.Color.HSVtoRGB(d,y,v,x),l=x.r,c=x.g,u=x.b}return e.Color.getColor32(r,l,c,u)},interpolateColorWithRGB:function(t,i,s,n,r,o){var a=e.Color.getRGB(t),h=(i-a.red)*o/r+a.red,l=(s-a.green)*o/r+a.green,c=(n-a.blue)*o/r+a.blue;return e.Color.getColor(h,l,c)},interpolateRGB:function(t,i,s,n,r,o,a,h){var l=(n-t)*h/a+t,c=(r-i)*h/a+i,u=(o-s)*h/a+s;return e.Color.getColor(l,c,u)},linear:function(t,e,i){return this.interpolateColor(t,e,1,i)},linearInterpolation:function(t,i){var s=e.Math.linear(0,t.length-1,i),n=t[Math.floor(s)],r=t[Math.ceil(s)];return this.linear(n,r,s%1)},getRandomColor:function(t,i,s){if(void 0===t&&(t=0),void 0===i&&(i=255),void 0===s&&(s=255),i>255||t>i)return e.Color.getColor(255,255,255);var n=t+Math.round(Math.random()*(i-t)),r=t+Math.round(Math.random()*(i-t)),o=t+Math.round(Math.random()*(i-t));return e.Color.getColor32(s,n,r,o)},getRGB:function(t){return t>16777215?{alpha:t>>>24,red:t>>16&255,green:t>>8&255,blue:255&t,a:t>>>24,r:t>>16&255,g:t>>8&255,b:255&t}:{alpha:255,red:t>>16&255,green:t>>8&255,blue:255&t,a:255,r:t>>16&255,g:t>>8&255,b:255&t}},getWebRGB:function(t){if("object"==typeof t)return"rgba("+t.r.toString()+","+t.g.toString()+","+t.b.toString()+","+(t.a/255).toString()+")";var i=e.Color.getRGB(t);return"rgba("+i.r.toString()+","+i.g.toString()+","+i.b.toString()+","+(i.a/255).toString()+")"},getAlpha:function(t){return t>>>24},getAlphaFloat:function(t){return(t>>>24)/255},getRed:function(t){return t>>16&255},getGreen:function(t){return t>>8&255},getBlue:function(t){return 255&t},blendNormal:function(t){return t},blendLighten:function(t,e){return e>t?e:t},blendDarken:function(t,e){return e>t?t:e},blendMultiply:function(t,e){return t*e/255},blendAverage:function(t,e){return(t+e)/2},blendAdd:function(t,e){return Math.min(255,t+e)},blendSubtract:function(t,e){return Math.max(0,t+e-255)},blendDifference:function(t,e){return Math.abs(t-e)},blendNegation:function(t,e){return 255-Math.abs(255-t-e)},blendScreen:function(t,e){return 255-((255-t)*(255-e)>>8)},blendExclusion:function(t,e){return t+e-2*t*e/255},blendOverlay:function(t,e){return e<128?2*t*e/255:255-2*(255-t)*(255-e)/255},blendSoftLight:function(t,e){return e<128?2*(64+(t>>1))*(e/255):255-2*(255-(64+(t>>1)))*(255-e)/255},blendHardLight:function(t,i){return e.Color.blendOverlay(i,t)},blendColorDodge:function(t,e){return 255===e?e:Math.min(255,(t<<8)/(255-e))},blendColorBurn:function(t,e){return 0===e?e:Math.max(0,255-(255-t<<8)/e)},blendLinearDodge:function(t,i){return e.Color.blendAdd(t,i)},blendLinearBurn:function(t,i){return e.Color.blendSubtract(t,i)},blendLinearLight:function(t,i){return i<128?e.Color.blendLinearBurn(t,2*i):e.Color.blendLinearDodge(t,2*(i-128))},blendVividLight:function(t,i){return i<128?e.Color.blendColorBurn(t,2*i):e.Color.blendColorDodge(t,2*(i-128))},blendPinLight:function(t,i){return i<128?e.Color.blendDarken(t,2*i):e.Color.blendLighten(t,2*(i-128))},blendHardMix:function(t,i){return e.Color.blendVividLight(t,i)<128?0:255},blendReflect:function(t,e){return 255===e?e:Math.min(255,t*t/(255-e))},blendGlow:function(t,i){return e.Color.blendReflect(i,t)},blendPhoenix:function(t,e){return Math.min(t,e)-Math.max(t,e)+255}},e.Physics=function(t,e){e=e||{},this.game=t,this.config=e,this.arcade=null,this.p2=null,this.ninja=null,this.box2d=null,this.chipmunk=null,this.matter=null,this.parseConfig()},e.Physics.ARCADE=0,e.Physics.P2JS=1,e.Physics.NINJA=2,e.Physics.BOX2D=3,e.Physics.CHIPMUNK=4,e.Physics.MATTERJS=5,e.Physics.prototype={parseConfig:function(){this.config.hasOwnProperty("arcade")&&!0!==this.config.arcade||!e.Physics.hasOwnProperty("Arcade")||(this.arcade=new e.Physics.Arcade(this.game)),this.config.hasOwnProperty("ninja")&&!0===this.config.ninja&&e.Physics.hasOwnProperty("Ninja")&&(this.ninja=new e.Physics.Ninja(this.game)),this.config.hasOwnProperty("p2")&&!0===this.config.p2&&e.Physics.hasOwnProperty("P2")&&(this.p2=new e.Physics.P2(this.game,this.config)),this.config.hasOwnProperty("box2d")&&!0===this.config.box2d&&e.Physics.hasOwnProperty("BOX2D")&&(this.box2d=new e.Physics.Box2D(this.game,this.config)),this.config.hasOwnProperty("matter")&&!0===this.config.matter&&e.Physics.hasOwnProperty("Matter")&&(this.matter=new e.Physics.Matter(this.game,this.config))},startSystem:function(t){t===e.Physics.ARCADE?this.arcade=new e.Physics.Arcade(this.game):t===e.Physics.P2JS?null===this.p2?this.p2=new e.Physics.P2(this.game,this.config):this.p2.reset():t===e.Physics.NINJA?this.ninja=new e.Physics.Ninja(this.game):t===e.Physics.BOX2D?null===this.box2d?this.box2d=new e.Physics.Box2D(this.game,this.config):this.box2d.reset():t===e.Physics.MATTERJS&&(null===this.matter?this.matter=new e.Physics.Matter(this.game,this.config):this.matter.reset())},enable:function(t,i,s){void 0===i&&(i=e.Physics.ARCADE),void 0===s&&(s=!1),i===e.Physics.ARCADE?this.arcade.enable(t):i===e.Physics.P2JS&&this.p2?this.p2.enable(t,s):i===e.Physics.NINJA&&this.ninja?this.ninja.enableAABB(t):i===e.Physics.BOX2D&&this.box2d?this.box2d.enable(t):i===e.Physics.MATTERJS&&this.matter?this.matter.enable(t):console.warn(t.key+" is attempting to enable a physics body using an unknown physics system.")},preUpdate:function(){this.p2&&this.p2.preUpdate(),this.box2d&&this.box2d.preUpdate(),this.matter&&this.matter.preUpdate()},update:function(){this.p2&&this.p2.update(),this.box2d&&this.box2d.update(),this.matter&&this.matter.update()},setBoundsToWorld:function(){this.arcade&&this.arcade.setBoundsToWorld(),this.ninja&&this.ninja.setBoundsToWorld(),this.p2&&this.p2.setBoundsToWorld(),this.box2d&&this.box2d.setBoundsToWorld(),this.matter&&this.matter.setBoundsToWorld()},clear:function(){this.p2&&this.p2.clear(),this.box2d&&this.box2d.clear(),this.matter&&this.matter.clear()},reset:function(){this.p2&&this.p2.reset(),this.box2d&&this.box2d.reset(),this.matter&&this.matter.reset()},destroy:function(){this.p2&&this.p2.destroy(),this.box2d&&this.box2d.destroy(),this.matter&&this.matter.destroy(),this.arcade=null,this.ninja=null,this.p2=null,this.box2d=null,this.matter=null}},e.Physics.prototype.constructor=e.Physics,e.Physics.Arcade=function(t){this.game=t,this.gravity=new e.Point,this.bounds=new e.Rectangle(0,0,t.world.width,t.world.height),this.checkCollision={up:!0,down:!0,left:!0,right:!0},this.maxObjects=10,this.maxLevels=4,this.OVERLAP_BIAS=4,this.forceX=!1,this.sortDirection=e.Physics.Arcade.LEFT_RIGHT,this.skipQuadTree=!0,this.isPaused=!1,this.quadTree=new e.QuadTree(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels),this._total=0,this.setBoundsToWorld()},e.Physics.Arcade.prototype.constructor=e.Physics.Arcade,e.Physics.Arcade.SORT_NONE=0,e.Physics.Arcade.LEFT_RIGHT=1,e.Physics.Arcade.RIGHT_LEFT=2,e.Physics.Arcade.TOP_BOTTOM=3,e.Physics.Arcade.BOTTOM_TOP=4,e.Physics.Arcade.prototype={setBounds:function(t,e,i,s){this.bounds.setTo(t,e,i,s)},setBoundsToWorld:function(){this.bounds.copyFrom(this.game.world.bounds)},enable:function(t,i){void 0===i&&(i=!0);var s=1;if(Array.isArray(t))for(s=t.length;s--;)t[s]instanceof e.Group?this.enable(t[s].children,i):(this.enableBody(t[s]),i&&t[s].hasOwnProperty("children")&&t[s].children.length>0&&this.enable(t[s],!0));else t instanceof e.Group?this.enable(t.children,i):(this.enableBody(t),i&&t.hasOwnProperty("children")&&t.children.length>0&&this.enable(t.children,!0))},enableBody:function(t){t.hasOwnProperty("body")&&null===t.body&&(t.body=new e.Physics.Arcade.Body(t),t.parent&&t.parent instanceof e.Group&&t.parent.addToHash(t))},updateMotion:function(t){if(t.allowRotation){var e=this.computeVelocity(0,t,t.angularVelocity,t.angularAcceleration,t.angularDrag,t.maxAngular)-t.angularVelocity;t.angularVelocity+=e,t.rotation+=t.angularVelocity*this.game.time.physicsElapsed}t.velocity.x=this.computeVelocity(1,t,t.velocity.x,t.acceleration.x,t.drag.x,t.maxVelocity.x),t.velocity.y=this.computeVelocity(2,t,t.velocity.y,t.acceleration.y,t.drag.y,t.maxVelocity.y)},computeVelocity:function(t,e,i,s,n,r){return void 0===r&&(r=1e4),1===t&&e.allowGravity?i+=(this.gravity.x+e.gravity.x)*this.game.time.physicsElapsed:2===t&&e.allowGravity&&(i+=(this.gravity.y+e.gravity.y)*this.game.time.physicsElapsed),s?i+=s*this.game.time.physicsElapsed:n&&e.allowDrag&&(i-(n*=this.game.time.physicsElapsed)>0?i-=n:i+n<0?i+=n:i=0),i>r?i=r:i<-r&&(i=-r),i},overlap:function(t,e,i,s,n){return i=i||null,s=s||null,n=n||i,this._total=0,this.collideObjects(t,e,i,s,n,!0),this._total>0},collide:function(t,e,i,s,n){return i=i||null,s=s||null,n=n||i,this._total=0,this.collideObjects(t,e,i,s,n,!1),this._total>0},sortLeftRight:function(t,e){return t.body&&e.body?t.body.x-e.body.x:0},sortRightLeft:function(t,e){return t.body&&e.body?e.body.x-t.body.x:0},sortTopBottom:function(t,e){return t.body&&e.body?t.body.y-e.body.y:0},sortBottomTop:function(t,e){return t.body&&e.body?e.body.y-t.body.y:0},sort:function(t,i){null!==t.physicsSortDirection?i=t.physicsSortDirection:void 0===i&&(i=this.sortDirection),i===e.Physics.Arcade.LEFT_RIGHT?t.hash.sort(this.sortLeftRight):i===e.Physics.Arcade.RIGHT_LEFT?t.hash.sort(this.sortRightLeft):i===e.Physics.Arcade.TOP_BOTTOM?t.hash.sort(this.sortTopBottom):i===e.Physics.Arcade.BOTTOM_TOP&&t.hash.sort(this.sortBottomTop)},collideObjects:function(t,e,i,s,n,r){if(!Array.isArray(t)&&Array.isArray(e))for(o=0;o<e.length;o++)e[o]&&this.collideHandler(t,e[o],i,s,n,r);else if(Array.isArray(t)&&!Array.isArray(e))for(o=0;o<t.length;o++)t[o]&&this.collideHandler(t[o],e,i,s,n,r);else if(Array.isArray(t)&&Array.isArray(e)){for(var o=0;o<t.length;o++)if(t[o])for(var a=0;a<e.length;a++)e[a]&&this.collideHandler(t[o],e[a],i,s,n,r)}else this.collideHandler(t,e,i,s,n,r)},collideHandler:function(t,i,s,n,r,o){if(void 0===i&&t.physicsType===e.GROUP)return this.sort(t),void this.collideGroupVsSelf(t,s,n,r,o);t&&i&&t.exists&&i.exists&&(this.sortDirection!==e.Physics.Arcade.SORT_NONE&&(t.physicsType===e.GROUP&&this.sort(t),i.physicsType===e.GROUP&&this.sort(i)),t.physicsType===e.SPRITE?i.physicsType===e.SPRITE?this.collideSpriteVsSprite(t,i,s,n,r,o):i.physicsType===e.GROUP?this.collideSpriteVsGroup(t,i,s,n,r,o):i.physicsType===e.TILEMAPLAYER&&this.collideSpriteVsTilemapLayer(t,i,s,n,r,o):t.physicsType===e.GROUP?i.physicsType===e.SPRITE?this.collideSpriteVsGroup(i,t,s,n,r,o):i.physicsType===e.GROUP?this.collideGroupVsGroup(t,i,s,n,r,o):i.physicsType===e.TILEMAPLAYER&&this.collideGroupVsTilemapLayer(t,i,s,n,r,o):t.physicsType===e.TILEMAPLAYER&&(i.physicsType===e.SPRITE?this.collideSpriteVsTilemapLayer(i,t,s,n,r,o):i.physicsType===e.GROUP&&this.collideGroupVsTilemapLayer(i,t,s,n,r,o)))},collideSpriteVsSprite:function(t,e,i,s,n,r){return!(!t.body||!e.body)&&(this.separate(t.body,e.body,s,n,r)&&(i&&i.call(n,t,e),this._total++),!0)},collideSpriteVsGroup:function(t,i,s,n,r,o){if(0!==i.length&&t.body)if(this.skipQuadTree||t.body.skipQuadTree)for(var a={},h=0;h<i.hash.length;h++){var l=i.hash[h];if(l&&l.exists&&l.body){if(a=l.body.getBounds(a),this.sortDirection===e.Physics.Arcade.LEFT_RIGHT){if(t.body.right<a.x)break;if(a.right<t.body.x)continue}else if(this.sortDirection===e.Physics.Arcade.RIGHT_LEFT){if(t.body.x>a.right)break;if(a.x>t.body.right)continue}else if(this.sortDirection===e.Physics.Arcade.TOP_BOTTOM){if(t.body.bottom<a.y)break;if(a.bottom<t.body.y)continue}else if(this.sortDirection===e.Physics.Arcade.BOTTOM_TOP){if(t.body.y>a.bottom)break;if(a.y>t.body.bottom)continue}this.collideSpriteVsSprite(t,l,s,n,r,o)}}else{this.quadTree.clear(),this.quadTree.reset(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels),this.quadTree.populate(i);for(var c=this.quadTree.retrieve(t),h=0;h<c.length;h++)this.separate(t.body,c[h],n,r,o)&&(s&&s.call(r,t,c[h].sprite),this._total++)}},collideGroupVsSelf:function(t,i,s,n,r){if(0!==t.length)for(var o=0;o<t.hash.length;o++){var a={},h=t.hash[o];if(h&&h.exists&&h.body){a=h.body.getBounds(a);for(var l=o+1;l<t.hash.length;l++){var c={},u=t.hash[l];if(u&&u.exists&&u.body){if(c=u.body.getBounds(c),this.sortDirection===e.Physics.Arcade.LEFT_RIGHT){if(a.right<c.x)break;if(c.right<a.x)continue}else if(this.sortDirection===e.Physics.Arcade.RIGHT_LEFT){if(a.x>c.right)continue;if(c.x>a.right)break}else if(this.sortDirection===e.Physics.Arcade.TOP_BOTTOM){if(a.bottom<c.y)continue;if(c.bottom<a.y)break}else if(this.sortDirection===e.Physics.Arcade.BOTTOM_TOP){if(a.y>c.bottom)continue;if(c.y>h.body.bottom)break}this.collideSpriteVsSprite(h,u,i,s,n,r)}}}}},collideGroupVsGroup:function(t,i,s,n,r,o){if(0!==t.length&&0!==i.length)for(var a=0;a<t.children.length;a++)t.children[a].exists&&(t.children[a].physicsType===e.GROUP?this.collideGroupVsGroup(t.children[a],i,s,n,r,o):this.collideSpriteVsGroup(t.children[a],i,s,n,r,o))},separate:function(t,e,i,s,n){if(!t.enable||!e.enable||t.checkCollision.none||e.checkCollision.none||!this.intersects(t,e))return!1;if(i&&!1===i.call(s,t.sprite,e.sprite))return!1;if(t.isCircle&&e.isCircle)return this.separateCircle(t,e,n);if(t.isCircle!==e.isCircle){var r=t.isCircle?e:t,o=t.isCircle?t:e,a={x:r.x,y:r.y,right:r.right,bottom:r.bottom},h=o.center;if((h.y<a.y||h.y>a.bottom)&&(h.x<a.x||h.x>a.right))return this.separateCircle(t,e,n)}var l=!1,c=!1;this.forceX||Math.abs(this.gravity.y+t.gravity.y)<Math.abs(this.gravity.x+t.gravity.x)?(l=this.separateX(t,e,n),this.intersects(t,e)&&(c=this.separateY(t,e,n))):(c=this.separateY(t,e,n),this.intersects(t,e)&&(l=this.separateX(t,e,n)));var u=l||c;return u&&(n?(t.onOverlap&&t.onOverlap.dispatch(t.sprite,e.sprite),e.onOverlap&&e.onOverlap.dispatch(e.sprite,t.sprite)):(t.onCollide&&t.onCollide.dispatch(t.sprite,e.sprite),e.onCollide&&e.onCollide.dispatch(e.sprite,t.sprite))),u},intersects:function(t,i){return t!==i&&(t.isCircle?i.isCircle?e.Math.distance(t.center.x,t.center.y,i.center.x,i.center.y)<=t.halfWidth+i.halfWidth:this.circleBodyIntersects(t,i):i.isCircle?this.circleBodyIntersects(i,t):!(t.right<=i.position.x)&&(!(t.bottom<=i.position.y)&&(!(t.position.x>=i.right)&&!(t.position.y>=i.bottom))))},circleBodyIntersects:function(t,i){var s=e.Math.clamp(t.center.x,i.left,i.right),n=e.Math.clamp(t.center.y,i.top,i.bottom);return(t.center.x-s)*(t.center.x-s)+(t.center.y-n)*(t.center.y-n)<=t.halfWidth*t.halfWidth},separateCircle:function(t,i,s){this.getOverlapX(t,i),this.getOverlapY(t,i);var n=i.center.x-t.center.x,r=i.center.y-t.center.y,o=Math.atan2(r,n),a=0;if(t.isCircle!==i.isCircle){var h={x:i.isCircle?t.position.x:i.position.x,y:i.isCircle?t.position.y:i.position.y,right:i.isCircle?t.right:i.right,bottom:i.isCircle?t.bottom:i.bottom},l={x:t.isCircle?t.center.x:i.center.x,y:t.isCircle?t.center.y:i.center.y,radius:t.isCircle?t.halfWidth:i.halfWidth};l.y<h.y?l.x<h.x?a=e.Math.distance(l.x,l.y,h.x,h.y)-l.radius:l.x>h.right&&(a=e.Math.distance(l.x,l.y,h.right,h.y)-l.radius):l.y>h.bottom&&(l.x<h.x?a=e.Math.distance(l.x,l.y,h.x,h.bottom)-l.radius:l.x>h.right&&(a=e.Math.distance(l.x,l.y,h.right,h.bottom)-l.radius)),a*=-1}else a=t.halfWidth+i.halfWidth-e.Math.distance(t.center.x,t.center.y,i.center.x,i.center.y);if(s||0===a||t.immovable&&i.immovable||t.customSeparateX||i.customSeparateX)return 0!==a&&(t.onOverlap&&t.onOverlap.dispatch(t.sprite,i.sprite),i.onOverlap&&i.onOverlap.dispatch(i.sprite,t.sprite)),0!==a;var c={x:t.velocity.x*Math.cos(o)+t.velocity.y*Math.sin(o),y:-t.velocity.x*Math.sin(o)+t.velocity.y*Math.cos(o)},u={x:i.velocity.x*Math.cos(o)+i.velocity.y*Math.sin(o),y:-i.velocity.x*Math.sin(o)+i.velocity.y*Math.cos(o)},d=((t.mass-i.mass)*c.x+2*i.mass*u.x)/(t.mass+i.mass),p=(2*t.mass*c.x+(i.mass-t.mass)*u.x)/(t.mass+i.mass);return t.immovable||(t.velocity.x=(d*Math.cos(o)-c.y*Math.sin(o))*t.bounce.x,t.velocity.y=(c.y*Math.cos(o)+d*Math.sin(o))*t.bounce.y),i.immovable||(i.velocity.x=(p*Math.cos(o)-u.y*Math.sin(o))*i.bounce.x,i.velocity.y=(u.y*Math.cos(o)+p*Math.sin(o))*i.bounce.y),Math.abs(o)<Math.PI/2?t.velocity.x>0&&!t.immovable&&i.velocity.x>t.velocity.x?t.velocity.x*=-1:i.velocity.x<0&&!i.immovable&&t.velocity.x<i.velocity.x?i.velocity.x*=-1:t.velocity.y>0&&!t.immovable&&i.velocity.y>t.velocity.y?t.velocity.y*=-1:i.velocity.y<0&&!i.immovable&&t.velocity.y<i.velocity.y&&(i.velocity.y*=-1):Math.abs(o)>Math.PI/2&&(t.velocity.x<0&&!t.immovable&&i.velocity.x<t.velocity.x?t.velocity.x*=-1:i.velocity.x>0&&!i.immovable&&t.velocity.x>i.velocity.x?i.velocity.x*=-1:t.velocity.y<0&&!t.immovable&&i.velocity.y<t.velocity.y?t.velocity.y*=-1:i.velocity.y>0&&!i.immovable&&t.velocity.x>i.velocity.y&&(i.velocity.y*=-1)),t.immovable||(t.x+=t.velocity.x*this.game.time.physicsElapsed-a*Math.cos(o),t.y+=t.velocity.y*this.game.time.physicsElapsed-a*Math.sin(o)),i.immovable||(i.x+=i.velocity.x*this.game.time.physicsElapsed+a*Math.cos(o),i.y+=i.velocity.y*this.game.time.physicsElapsed+a*Math.sin(o)),t.onCollide&&t.onCollide.dispatch(t.sprite,i.sprite),i.onCollide&&i.onCollide.dispatch(i.sprite,t.sprite),!0},getOverlapX:function(t,e,i){var s=0,n=t.deltaAbsX()+e.deltaAbsX()+this.OVERLAP_BIAS;return 0===t.deltaX()&&0===e.deltaX()?(t.embedded=!0,e.embedded=!0):t.deltaX()>e.deltaX()?(s=t.right-e.x)>n&&!i||!1===t.checkCollision.right||!1===e.checkCollision.left?s=0:(t.touching.none=!1,t.touching.right=!0,e.touching.none=!1,e.touching.left=!0):t.deltaX()<e.deltaX()&&(-(s=t.x-e.width-e.x)>n&&!i||!1===t.checkCollision.left||!1===e.checkCollision.right?s=0:(t.touching.none=!1,t.touching.left=!0,e.touching.none=!1,e.touching.right=!0)),t.overlapX=s,e.overlapX=s,s},getOverlapY:function(t,e,i){var s=0,n=t.deltaAbsY()+e.deltaAbsY()+this.OVERLAP_BIAS;return 0===t.deltaY()&&0===e.deltaY()?(t.embedded=!0,e.embedded=!0):t.deltaY()>e.deltaY()?(s=t.bottom-e.y)>n&&!i||!1===t.checkCollision.down||!1===e.checkCollision.up?s=0:(t.touching.none=!1,t.touching.down=!0,e.touching.none=!1,e.touching.up=!0):t.deltaY()<e.deltaY()&&(-(s=t.y-e.bottom)>n&&!i||!1===t.checkCollision.up||!1===e.checkCollision.down?s=0:(t.touching.none=!1,t.touching.up=!0,e.touching.none=!1,e.touching.down=!0)),t.overlapY=s,e.overlapY=s,s},separateX:function(t,e,i){var s=this.getOverlapX(t,e,i);if(i||0===s||t.immovable&&e.immovable||t.customSeparateX||e.customSeparateX)return 0!==s||t.embedded&&e.embedded;var n=t.velocity.x,r=e.velocity.x;if(t.immovable||e.immovable)t.immovable?(e.x+=s,e.velocity.x=n-r*e.bounce.x,t.moves&&(e.y+=(t.y-t.prev.y)*t.friction.y)):(t.x-=s,t.velocity.x=r-n*t.bounce.x,e.moves&&(t.y+=(e.y-e.prev.y)*e.friction.y));else{s*=.5,t.x-=s,e.x+=s;var o=Math.sqrt(r*r*e.mass/t.mass)*(r>0?1:-1),a=Math.sqrt(n*n*t.mass/e.mass)*(n>0?1:-1),h=.5*(o+a);o-=h,a-=h,t.velocity.x=h+o*t.bounce.x,e.velocity.x=h+a*e.bounce.x}return!0},separateY:function(t,e,i){var s=this.getOverlapY(t,e,i);if(i||0===s||t.immovable&&e.immovable||t.customSeparateY||e.customSeparateY)return 0!==s||t.embedded&&e.embedded;var n=t.velocity.y,r=e.velocity.y;if(t.immovable||e.immovable)t.immovable?(e.y+=s,e.velocity.y=n-r*e.bounce.y,t.moves&&(e.x+=(t.x-t.prev.x)*t.friction.x)):(t.y-=s,t.velocity.y=r-n*t.bounce.y,e.moves&&(t.x+=(e.x-e.prev.x)*e.friction.x));else{s*=.5,t.y-=s,e.y+=s;var o=Math.sqrt(r*r*e.mass/t.mass)*(r>0?1:-1),a=Math.sqrt(n*n*t.mass/e.mass)*(n>0?1:-1),h=.5*(o+a);o-=h,a-=h,t.velocity.y=h+o*t.bounce.y,e.velocity.y=h+a*e.bounce.y}return!0},getObjectsUnderPointer:function(t,e,i,s){if(0!==e.length&&t.exists)return this.getObjectsAtLocation(t.x,t.y,e,i,s,t)},getObjectsAtLocation:function(t,i,s,n,r,o){this.quadTree.clear(),this.quadTree.reset(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels),this.quadTree.populate(s);for(var a=new e.Rectangle(t,i,1,1),h=[],l=this.quadTree.retrieve(a),c=0;c<l.length;c++)l[c].hitTest(t,i)&&(n&&n.call(r,o,l[c].sprite),h.push(l[c].sprite));return h},moveToObject:function(t,i,s,n){void 0===s&&(s=60),void 0===n&&(n=0);var r=e.Point.angle(i,t);return n>0&&(s=this.distanceBetween(t,i)/(n/1e3)),t.body.velocity.setToPolar(r,s),r},moveToPointer:function(t,e,i,s){void 0===e&&(e=60),i=i||this.game.input.activePointer,void 0===s&&(s=0);var n=this.angleToPointer(t,i);return s>0&&(e=this.distanceToPointer(t,i)/(s/1e3)),t.body.velocity.setToPolar(n,e),n},moveToXY:function(t,e,i,s,n){void 0===s&&(s=60),void 0===n&&(n=0);var r=Math.atan2(i-t.y,e-t.x);return n>0&&(s=this.distanceToXY(t,e,i)/(n/1e3)),t.body.velocity.setToPolar(r,s),r},velocityFromAngle:function(t,i,s){return void 0===i&&(i=60),(s=s||new e.Point).setToPolar(t,i,!0)},velocityFromRotation:function(t,i,s){return void 0===i&&(i=60),(s=s||new e.Point).setToPolar(t,i)},accelerationFromRotation:function(t,i,s){return void 0===i&&(i=60),(s=s||new e.Point).setToPolar(t,i)},accelerateToObject:function(t,e,i,s,n){void 0===i&&(i=60),void 0===s&&(s=1e3),void 0===n&&(n=1e3);var r=this.angleBetween(t,e);return t.body.acceleration.setToPolar(r,i),t.body.maxVelocity.setTo(s,n),r},accelerateToPointer:function(t,e,i,s,n){void 0===i&&(i=60),void 0===e&&(e=this.game.input.activePointer),void 0===s&&(s=1e3),void 0===n&&(n=1e3);var r=this.angleToPointer(t,e);return t.body.acceleration.setToPolar(r,i),t.body.maxVelocity.setTo(s,n),r},accelerateToXY:function(t,e,i,s,n,r){void 0===s&&(s=60),void 0===n&&(n=1e3),void 0===r&&(r=1e3);var o=this.angleToXY(t,e,i);return t.body.acceleration.setTo(o,s),t.body.maxVelocity.setTo(n,r),o},distanceBetween:function(t,e,i,s){void 0===i&&(i=!1);var n,r;return s?(n=t.centerX-e.centerX,r=t.centerY-e.centerY):i?(n=t.world.x-e.world.x,r=t.world.y-e.world.y):(n=t.x-e.x,r=t.y-e.y),Math.sqrt(n*n+r*r)},distanceToXY:function(t,e,i,s){void 0===s&&(s=!1);var n=s?t.world.x-e:t.x-e,r=s?t.world.y-i:t.y-i;return Math.sqrt(n*n+r*r)},distanceToPointer:function(t,e,i){void 0===e&&(e=this.game.input.activePointer),void 0===i&&(i=!1);var s=i?t.world.x-e.worldX:t.x-e.worldX,n=i?t.world.y-e.worldY:t.y-e.worldY;return Math.sqrt(s*s+n*n)},closest:function(t,e,i,s){for(var n=1/0,r=null,o=0,a=e.length;o<a;o++){var h=e[o],l=this.distanceBetween(t,h,i,s);l<n&&(r=h,n=l)}return r},farthest:function(t,e,i,s){for(var n=-1,r=null,o=0,a=e.length;o<a;o++){var h=e[o],l=this.distanceBetween(t,h,i,s);l>n&&(r=h,n=l)}return r},angleBetween:function(t,i,s){return void 0===s&&(s=!1),s?e.Point.angle(i.world,t.world):e.Point.angle(i,t)},angleBetweenCenters:function(t,e){var i=e.centerX-t.centerX,s=e.centerY-t.centerY;return Math.atan2(s,i)},angleToXY:function(t,e,i,s){return void 0===s&&(s=!1),s?Math.atan2(i-t.world.y,e-t.world.x):Math.atan2(i-t.y,e-t.x)},angleToPointer:function(t,e,i){return void 0===e&&(e=this.game.input.activePointer),void 0===i&&(i=!1),i?Math.atan2(e.worldY-t.world.y,e.worldX-t.world.x):Math.atan2(e.worldY-t.y,e.worldX-t.x)},worldAngleToPointer:function(t,e){return this.angleToPointer(t,e,!0)}},e.Physics.Arcade.Body=function(t){this.sprite=t,this.game=t.game,this.type=e.Physics.ARCADE,this.enable=!0,this.isCircle=!1,this.radius=0,this.offset=new e.Point,this.position=new e.Point(t.x,t.y),this.prev=new e.Point(this.position.x,this.position.y),this.allowRotation=!0,this.rotation=t.angle,this.preRotation=t.angle,this.width=t.width,this.height=t.height,this.sourceWidth=t.width,this.sourceHeight=t.height,t.texture&&(this.sourceWidth=t.texture.frame.width,this.sourceHeight=t.texture.frame.height),this.halfWidth=Math.abs(t.width/2),this.halfHeight=Math.abs(t.height/2),this.center=new e.Point(t.x+this.halfWidth,t.y+this.halfHeight),this.velocity=new e.Point,this.newVelocity=new e.Point,this.deltaMax=new e.Point,this.acceleration=new e.Point,this.allowDrag=!0,this.drag=new e.Point,this.allowGravity=!0,this.gravity=new e.Point,this.bounce=new e.Point,this.worldBounce=null,this.onWorldBounds=null,this.onCollide=null,this.onOverlap=null,this.maxVelocity=new e.Point(1e4,1e4),this.friction=new e.Point(1,0),this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e3,this.mass=1,this.angle=0,this.speed=0,this.facing=e.NONE,this.immovable=!1,this.moves=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.overlapR=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision={none:!1,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.blocked={none:!0,up:!1,down:!1,left:!1,right:!1},this.tilePadding=new e.Point,this.dirty=!1,this.skipQuadTree=!1,this.syncBounds=!1,this.isMoving=!1,this.stopVelocityOnCollide=!0,this.moveTimer=0,this.moveDistance=0,this.moveDuration=0,this.moveTarget=null,this.moveEnd=null,this.onMoveComplete=new e.Signal,this.movementCallback=null,this.movementCallbackContext=null,this._reset=!0,this._sx=t.scale.x,this._sy=t.scale.y,this._dx=0,this._dy=0},e.Physics.Arcade.Body.prototype={updateBounds:function(){if(this.syncBounds){var t=this.sprite.getBounds();t.ceilAll(),t.width===this.width&&t.height===this.height||(this.width=t.width,this.height=t.height,this._reset=!0)}else{var e=Math.abs(this.sprite.scale.x),i=Math.abs(this.sprite.scale.y);e===this._sx&&i===this._sy||(this.width=this.sourceWidth*e,this.height=this.sourceHeight*i,this._sx=e,this._sy=i,this._reset=!0)}this._reset&&(this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.updateCenter())},updateCenter:function(){this.center.setTo(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},preUpdate:function(){this.enable&&!this.game.physics.arcade.isPaused&&(this.dirty=!0,this.wasTouching.none=this.touching.none,this.wasTouching.up=this.touching.up,this.wasTouching.down=this.touching.down,this.wasTouching.left=this.touching.left,this.wasTouching.right=this.touching.right,this.touching.none=!0,this.touching.up=!1,this.touching.down=!1,this.touching.left=!1,this.touching.right=!1,this.blocked.none=!0,this.blocked.up=!1,this.blocked.down=!1,this.blocked.left=!1,this.blocked.right=!1,this.overlapR=0,this.overlapX=0,this.overlapY=0,this.embedded=!1,this.updateBounds(),this.position.x=this.sprite.world.x-this.sprite.anchor.x*this.sprite.width+this.sprite.scale.x*this.offset.x,this.position.x-=this.sprite.scale.x<0?this.width:0,this.position.y=this.sprite.world.y-this.sprite.anchor.y*this.sprite.height+this.sprite.scale.y*this.offset.y,this.position.y-=this.sprite.scale.y<0?this.height:0,this.updateCenter(),this.rotation=this.sprite.angle,this.preRotation=this.rotation,(this._reset||this.sprite.fresh)&&(this.prev.x=this.position.x,this.prev.y=this.position.y),this.moves&&(this.game.physics.arcade.updateMotion(this),this.newVelocity.set(this.velocity.x*this.game.time.physicsElapsed,this.velocity.y*this.game.time.physicsElapsed),this.position.x+=this.newVelocity.x,this.position.y+=this.newVelocity.y,this.updateCenter(),this.position.x===this.prev.x&&this.position.y===this.prev.y||(this.angle=this.velocity.atan()),this.speed=Math.sqrt(this.velocity.x*this.velocity.x+this.velocity.y*this.velocity.y),this.collideWorldBounds&&this.checkWorldBounds()&&this.onWorldBounds&&this.onWorldBounds.dispatch(this.sprite,this.blocked.up,this.blocked.down,this.blocked.left,this.blocked.right)),this._dx=this.deltaX(),this._dy=this.deltaY(),this._reset=!1)},updateMovement:function(){var t=0,e=0!==this.overlapX||0!==this.overlapY;if(this.moveDuration>0?(this.moveTimer+=this.game.time.elapsedMS,t=this.moveTimer/this.moveDuration):(this.moveTarget.end.set(this.position.x,this.position.y),t=this.moveTarget.length/this.moveDistance),this.movementCallback)var i=this.movementCallback.call(this.movementCallbackContext,this,this.velocity,t);return!(e||t>=1||void 0!==i&&!0!==i)||(this.stopMovement(t>=1||this.stopVelocityOnCollide&&e),!1)},stopMovement:function(t){this.isMoving&&(this.isMoving=!1,t&&this.velocity.set(0),this.onMoveComplete.dispatch(this.sprite,0!==this.overlapX||0!==this.overlapY))},postUpdate:function(){this.enable&&this.dirty&&(this.isMoving&&this.updateMovement(),this.dirty=!1,this.deltaX()<0?this.facing=e.LEFT:this.deltaX()>0&&(this.facing=e.RIGHT),this.deltaY()<0?this.facing=e.UP:this.deltaY()>0&&(this.facing=e.DOWN),this.moves&&(this._dx=this.deltaX(),this._dy=this.deltaY(),0!==this.deltaMax.x&&0!==this._dx&&(this._dx<0&&this._dx<-this.deltaMax.x?this._dx=-this.deltaMax.x:this._dx>0&&this._dx>this.deltaMax.x&&(this._dx=this.deltaMax.x)),0!==this.deltaMax.y&&0!==this._dy&&(this._dy<0&&this._dy<-this.deltaMax.y?this._dy=-this.deltaMax.y:this._dy>0&&this._dy>this.deltaMax.y&&(this._dy=this.deltaMax.y)),this.sprite.position.x+=this._dx,this.sprite.position.y+=this._dy,this._reset=!0),this.updateCenter(),this.allowRotation&&(this.sprite.angle+=this.deltaZ()),this.prev.x=this.position.x,this.prev.y=this.position.y)},checkWorldBounds:function(){var t=this.position,e=this.game.physics.arcade.bounds,i=this.game.physics.arcade.checkCollision,s=this.worldBounce?-this.worldBounce.x:-this.bounce.x,n=this.worldBounce?-this.worldBounce.y:-this.bounce.y;return t.x<e.x&&i.left?(t.x=e.x,this.velocity.x*=s,this.blocked.left=!0,this.blocked.none=!1):this.right>e.right&&i.right&&(t.x=e.right-this.width,this.velocity.x*=s,this.blocked.right=!0,this.blocked.none=!1),t.y<e.y&&i.up?(t.y=e.y,this.velocity.y*=n,this.blocked.up=!0,this.blocked.none=!1):this.bottom>e.bottom&&i.down&&(t.y=e.bottom-this.height,this.velocity.y*=n,this.blocked.down=!0,this.blocked.none=!1),!this.blocked.none},moveFrom:function(t,e,i){if(void 0===e&&(e=this.speed),0===e)return!1;var s;return void 0===i?(s=this.angle,i=this.game.math.radToDeg(s)):s=this.game.math.degToRad(i),this.moveTimer=0,this.moveDuration=t,0===i||180===i?this.velocity.set(Math.cos(s)*e,0):90===i||270===i?this.velocity.set(0,Math.sin(s)*e):this.velocity.setToPolar(s,e),this.isMoving=!0,!0},moveTo:function(t,i,s){var n=i/(t/1e3);if(0===n)return!1;var r;return void 0===s?(r=this.angle,s=this.game.math.radToDeg(r)):r=this.game.math.degToRad(s),i=Math.abs(i),this.moveDuration=0,this.moveDistance=i,null===this.moveTarget&&(this.moveTarget=new e.Line,this.moveEnd=new e.Point),this.moveTarget.fromAngle(this.x,this.y,r,i),this.moveEnd.set(this.moveTarget.end.x,this.moveTarget.end.y),this.moveTarget.setTo(this.x,this.y,this.x,this.y),0===s||180===s?this.velocity.set(Math.cos(r)*n,0):90===s||270===s?this.velocity.set(0,Math.sin(r)*n):this.velocity.setToPolar(r,n),this.isMoving=!0,!0},setSize:function(t,e,i,s){void 0===i&&(i=this.offset.x),void 0===s&&(s=this.offset.y),this.sourceWidth=t,this.sourceHeight=e,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.setTo(i,s),this.updateCenter(),this.isCircle=!1,this.radius=0},setCircle:function(t,e,i){void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),t>0?(this.isCircle=!0,this.radius=t,this.sourceWidth=2*t,this.sourceHeight=2*t,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.setTo(e,i),this.updateCenter()):this.isCircle=!1},reset:function(t,e){this.stop(),this.position.x=t-this.sprite.anchor.x*this.sprite.width+this.sprite.scale.x*this.offset.x,this.position.x-=this.sprite.scale.x<0?this.width:0,this.position.y=e-this.sprite.anchor.y*this.sprite.height+this.sprite.scale.y*this.offset.y,this.position.y-=this.sprite.scale.y<0?this.height:0,this.prev.x=this.position.x,this.prev.y=this.position.y,this.rotation=this.sprite.angle,this.preRotation=this.rotation,this.updateBounds(),this.updateCenter()},stop:function(){this.velocity.set(0),this.acceleration.set(0),this.speed=0,this.angularVelocity=0,this.angularAcceleration=0},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,i){return this.isCircle?e.Circle.contains(this,t,i):e.Rectangle.contains(this,t,i)},onFloor:function(){return this.blocked.down},onCeiling:function(){return this.blocked.up},onWall:function(){return this.blocked.left||this.blocked.right},deltaAbsX:function(){return this.deltaX()>0?this.deltaX():-this.deltaX()},deltaAbsY:function(){return this.deltaY()>0?this.deltaY():-this.deltaY()},deltaX:function(){return this.position.x-this.prev.x},deltaY:function(){return this.position.y-this.prev.y},deltaZ:function(){return this.rotation-this.preRotation},destroy:function(){this.sprite.parent&&this.sprite.parent instanceof e.Group&&this.sprite.parent.removeFromHash(this.sprite),this.sprite.body=null,this.sprite=null}},Object.defineProperty(e.Physics.Arcade.Body.prototype,"left",{get:function(){return this.position.x}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"right",{get:function(){return this.position.x+this.width}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"top",{get:function(){return this.position.y}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"bottom",{get:function(){return this.position.y+this.height}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"x",{get:function(){return this.position.x},set:function(t){this.position.x=t}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"y",{get:function(){return this.position.y},set:function(t){this.position.y=t}}),e.Physics.Arcade.Body.render=function(t,e,i,s,n){void 0===s&&(s=!0),i=i||"rgba(0,255,0,0.4)",t.fillStyle=i,t.strokeStyle=i,t.lineWidth=n||1,e.isCircle?(t.beginPath(),t.arc(e.center.x-e.game.camera.x,e.center.y-e.game.camera.y,e.halfWidth,0,2*Math.PI),s?t.fill():t.stroke()):s?t.fillRect(e.position.x-e.game.camera.x,e.position.y-e.game.camera.y,e.width,e.height):t.strokeRect(e.position.x-e.game.camera.x,e.position.y-e.game.camera.y,e.width,e.height)},e.Physics.Arcade.Body.renderBodyInfo=function(t,e){t.line("x: "+e.x.toFixed(2),"y: "+e.y.toFixed(2),"width: "+e.width,"height: "+e.height),t.line("velocity x: "+e.velocity.x.toFixed(2),"y: "+e.velocity.y.toFixed(2),"deltaX: "+e._dx.toFixed(2),"deltaY: "+e._dy.toFixed(2)),t.line("acceleration x: "+e.acceleration.x.toFixed(2),"y: "+e.acceleration.y.toFixed(2),"speed: "+e.speed.toFixed(2),"angle: "+e.angle.toFixed(2)),t.line("gravity x: "+e.gravity.x,"y: "+e.gravity.y,"bounce x: "+e.bounce.x.toFixed(2),"y: "+e.bounce.y.toFixed(2)),t.line("touching left: "+e.touching.left,"right: "+e.touching.right,"up: "+e.touching.up,"down: "+e.touching.down),t.line("blocked left: "+e.blocked.left,"right: "+e.blocked.right,"up: "+e.blocked.up,"down: "+e.blocked.down)},e.Physics.Arcade.Body.prototype.constructor=e.Physics.Arcade.Body,e.Physics.Arcade.TilemapCollision=function(){},e.Physics.Arcade.TilemapCollision.prototype={TILE_BIAS:16,collideSpriteVsTilemapLayer:function(t,e,i,s,n,r){if(t.body){var o=e.getTiles(t.body.position.x-t.body.tilePadding.x-e.getTileOffsetX(),t.body.position.y-t.body.tilePadding.y-e.getTileOffsetY(),t.body.width+t.body.tilePadding.x,t.body.height+t.body.tilePadding.y,!1,!1);if(0!==o.length)for(var a=0;a<o.length;a++)s?s.call(n,t,o[a])&&this.separateTile(a,t.body,o[a],e,r)&&(this._total++,i&&i.call(n,t,o[a])):this.separateTile(a,t.body,o[a],e,r)&&(this._total++,i&&i.call(n,t,o[a]))}},collideGroupVsTilemapLayer:function(t,e,i,s,n,r){if(0!==t.length)for(var o=0;o<t.children.length;o++)t.children[o].exists&&this.collideSpriteVsTilemapLayer(t.children[o],e,i,s,n,r)},separateTile:function(t,e,i,s,n){if(!e.enable)return!1;var r=s.getTileOffsetX(),o=s.getTileOffsetY();if(!i.intersects(e.position.x-r,e.position.y-o,e.right-r,e.bottom-o))return!1;if(n)return!0;if(i.collisionCallback&&!i.collisionCallback.call(i.collisionCallbackContext,e.sprite,i))return!1;if(void 0!==i.layer.callbacks&&i.layer.callbacks[i.index]&&!i.layer.callbacks[i.index].callback.call(i.layer.callbacks[i.index].callbackContext,e.sprite,i))return!1;if(!(i.faceLeft||i.faceRight||i.faceTop||i.faceBottom))return!1;var a=0,h=0,l=0,c=1;if(e.deltaAbsX()>e.deltaAbsY()?l=-1:e.deltaAbsX()<e.deltaAbsY()&&(c=-1),0!==e.deltaX()&&0!==e.deltaY()&&(i.faceLeft||i.faceRight)&&(i.faceTop||i.faceBottom)&&(l=Math.min(Math.abs(e.position.x-r-i.right),Math.abs(e.right-r-i.left)),c=Math.min(Math.abs(e.position.y-o-i.bottom),Math.abs(e.bottom-o-i.top))),l<c){if((i.faceLeft||i.faceRight)&&0!==(a=this.tileCheckX(e,i,s))&&!i.intersects(e.position.x-r,e.position.y-o,e.right-r,e.bottom-o))return!0;(i.faceTop||i.faceBottom)&&(h=this.tileCheckY(e,i,s))}else{if((i.faceTop||i.faceBottom)&&0!==(h=this.tileCheckY(e,i,s))&&!i.intersects(e.position.x-r,e.position.y-o,e.right-r,e.bottom-o))return!0;(i.faceLeft||i.faceRight)&&(a=this.tileCheckX(e,i,s))}return 0!==a||0!==h},tileCheckX:function(t,e,i){var s=0,n=i.getTileOffsetX();return t.deltaX()<0&&!t.blocked.left&&e.collideRight&&t.checkCollision.left?e.faceRight&&t.x-n<e.right&&(s=t.x-n-e.right)<-this.TILE_BIAS&&(s=0):t.deltaX()>0&&!t.blocked.right&&e.collideLeft&&t.checkCollision.right&&e.faceLeft&&t.right-n>e.left&&(s=t.right-n-e.left)>this.TILE_BIAS&&(s=0),0!==s&&(t.customSeparateX?t.overlapX=s:this.processTileSeparationX(t,s)),s},tileCheckY:function(t,e,i){var s=0,n=i.getTileOffsetY();return t.deltaY()<0&&!t.blocked.up&&e.collideDown&&t.checkCollision.up?e.faceBottom&&t.y-n<e.bottom&&(s=t.y-n-e.bottom)<-this.TILE_BIAS&&(s=0):t.deltaY()>0&&!t.blocked.down&&e.collideUp&&t.checkCollision.down&&e.faceTop&&t.bottom-n>e.top&&(s=t.bottom-n-e.top)>this.TILE_BIAS&&(s=0),0!==s&&(t.customSeparateY?t.overlapY=s:this.processTileSeparationY(t,s)),s},processTileSeparationX:function(t,e){e<0?(t.blocked.left=!0,t.blocked.none=!1):e>0&&(t.blocked.right=!0,t.blocked.none=!1),t.position.x-=e,0===t.bounce.x?t.velocity.x=0:t.velocity.x=-t.velocity.x*t.bounce.x},processTileSeparationY:function(t,e){e<0?(t.blocked.up=!0,t.blocked.none=!1):e>0&&(t.blocked.down=!0,t.blocked.none=!1),t.position.y-=e,0===t.bounce.y?t.velocity.y=0:t.velocity.y=-t.velocity.y*t.bounce.y}},e.Utils.mixinPrototype(e.Physics.Arcade.prototype,e.Physics.Arcade.TilemapCollision.prototype),p2.Body.prototype.parent=null,p2.Spring.prototype.parent=null,e.Physics.P2=function(t,i){this.game=t,void 0===i?i={gravity:[0,0],broadphase:new p2.SAPBroadphase}:(i.hasOwnProperty("gravity")||(i.gravity=[0,0]),i.hasOwnProperty("broadphase")||(i.broadphase=new p2.SAPBroadphase)),this.config=i,this.world=new p2.World(this.config),this.frameRate=1/60,this.useElapsedTime=!1,this.paused=!1,this.materials=[],this.gravity=new e.Physics.P2.InversePointProxy(this,this.world.gravity),this.walls={left:null,right:null,top:null,bottom:null},this.onBodyAdded=new e.Signal,this.onBodyRemoved=new e.Signal,this.onSpringAdded=new e.Signal,this.onSpringRemoved=new e.Signal,this.onConstraintAdded=new e.Signal,this.onConstraintRemoved=new e.Signal,this.onContactMaterialAdded=new e.Signal,this.onContactMaterialRemoved=new e.Signal,this.postBroadphaseCallback=null,this.callbackContext=null,this.onBeginContact=new e.Signal,this.onEndContact=new e.Signal,i.hasOwnProperty("mpx")&&i.hasOwnProperty("pxm")&&i.hasOwnProperty("mpxi")&&i.hasOwnProperty("pxmi")&&(this.mpx=i.mpx,this.mpxi=i.mpxi,this.pxm=i.pxm,this.pxmi=i.pxmi),this.world.on("beginContact",this.beginContactHandler,this),this.world.on("endContact",this.endContactHandler,this),this.collisionGroups=[],this.nothingCollisionGroup=new e.Physics.P2.CollisionGroup(1),this.boundsCollisionGroup=new e.Physics.P2.CollisionGroup(2),this.everythingCollisionGroup=new e.Physics.P2.CollisionGroup(2147483648),this.boundsCollidesWith=[],this._toRemove=[],this._collisionGroupID=2,this._boundsLeft=!0,this._boundsRight=!0,this._boundsTop=!0,this._boundsBottom=!0,this._boundsOwnGroup=!1,this.setBoundsToWorld(!0,!0,!0,!0,!1)},e.Physics.P2.prototype={removeBodyNextStep:function(t){this._toRemove.push(t)},preUpdate:function(){for(var t=this._toRemove.length;t--;)this.removeBody(this._toRemove[t]);this._toRemove.length=0},enable:function(t,i,s){void 0===i&&(i=!1),void 0===s&&(s=!0);var n=1;if(Array.isArray(t))for(n=t.length;n--;)t[n]instanceof e.Group?this.enable(t[n].children,i,s):(this.enableBody(t[n],i),s&&t[n].hasOwnProperty("children")&&t[n].children.length>0&&this.enable(t[n],i,!0));else t instanceof e.Group?this.enable(t.children,i,s):(this.enableBody(t,i),s&&t.hasOwnProperty("children")&&t.children.length>0&&this.enable(t.children,i,!0))},enableBody:function(t,i){t.hasOwnProperty("body")&&null===t.body&&(t.body=new e.Physics.P2.Body(this.game,t,t.x,t.y,1),t.body.debug=i,void 0!==t.anchor&&t.anchor.set(.5))},setImpactEvents:function(t){t?this.world.on("impact",this.impactHandler,this):this.world.off("impact",this.impactHandler,this)},setPostBroadphaseCallback:function(t,e){this.postBroadphaseCallback=t,this.callbackContext=e,null!==t?this.world.on("postBroadphase",this.postBroadphaseHandler,this):this.world.off("postBroadphase",this.postBroadphaseHandler,this)},postBroadphaseHandler:function(t){if(this.postBroadphaseCallback&&0!==t.pairs.length)for(var e=t.pairs.length-2;e>=0;e-=2)t.pairs[e].parent&&t.pairs[e+1].parent&&!this.postBroadphaseCallback.call(this.callbackContext,t.pairs[e].parent,t.pairs[e+1].parent)&&t.pairs.splice(e,2)},impactHandler:function(t){if(t.bodyA.parent&&t.bodyB.parent){var e=t.bodyA.parent,i=t.bodyB.parent;e._bodyCallbacks[t.bodyB.id]&&e._bodyCallbacks[t.bodyB.id].call(e._bodyCallbackContext[t.bodyB.id],e,i,t.shapeA,t.shapeB),i._bodyCallbacks[t.bodyA.id]&&i._bodyCallbacks[t.bodyA.id].call(i._bodyCallbackContext[t.bodyA.id],i,e,t.shapeB,t.shapeA),e._groupCallbacks[t.shapeB.collisionGroup]&&e._groupCallbacks[t.shapeB.collisionGroup].call(e._groupCallbackContext[t.shapeB.collisionGroup],e,i,t.shapeA,t.shapeB),i._groupCallbacks[t.shapeA.collisionGroup]&&i._groupCallbacks[t.shapeA.collisionGroup].call(i._groupCallbackContext[t.shapeA.collisionGroup],i,e,t.shapeB,t.shapeA)}},beginContactHandler:function(t){t.bodyA&&t.bodyB&&(this.onBeginContact.dispatch(t.bodyA,t.bodyB,t.shapeA,t.shapeB,t.contactEquations),t.bodyA.parent&&t.bodyA.parent.onBeginContact.dispatch(t.bodyB.parent,t.bodyB,t.shapeA,t.shapeB,t.contactEquations),t.bodyB.parent&&t.bodyB.parent.onBeginContact.dispatch(t.bodyA.parent,t.bodyA,t.shapeB,t.shapeA,t.contactEquations))},endContactHandler:function(t){t.bodyA&&t.bodyB&&(this.onEndContact.dispatch(t.bodyA,t.bodyB,t.shapeA,t.shapeB),t.bodyA.parent&&t.bodyA.parent.onEndContact.dispatch(t.bodyB.parent,t.bodyB,t.shapeA,t.shapeB),t.bodyB.parent&&t.bodyB.parent.onEndContact.dispatch(t.bodyA.parent,t.bodyA,t.shapeB,t.shapeA))},setBoundsToWorld:function(t,e,i,s,n){this.setBounds(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,t,e,i,s,n)},setWorldMaterial:function(t,e,i,s,n){void 0===e&&(e=!0),void 0===i&&(i=!0),void 0===s&&(s=!0),void 0===n&&(n=!0),e&&this.walls.left&&(this.walls.left.shapes[0].material=t),i&&this.walls.right&&(this.walls.right.shapes[0].material=t),s&&this.walls.top&&(this.walls.top.shapes[0].material=t),n&&this.walls.bottom&&(this.walls.bottom.shapes[0].material=t)},updateBoundsCollisionGroup:function(t){void 0===t&&(t=!0);var e=t?this.boundsCollisionGroup.mask:this.everythingCollisionGroup.mask;this.walls.left&&(this.walls.left.shapes[0].collisionGroup=e),this.walls.right&&(this.walls.right.shapes[0].collisionGroup=e),this.walls.top&&(this.walls.top.shapes[0].collisionGroup=e),this.walls.bottom&&(this.walls.bottom.shapes[0].collisionGroup=e),this._boundsOwnGroup=t},setBounds:function(t,e,i,s,n,r,o,a,h){void 0===n&&(n=this._boundsLeft),void 0===r&&(r=this._boundsRight),void 0===o&&(o=this._boundsTop),void 0===a&&(a=this._boundsBottom),void 0===h&&(h=this._boundsOwnGroup),this.setupWall(n,"left",t,e,1.5707963267948966,h),this.setupWall(r,"right",t+i,e,-1.5707963267948966,h),this.setupWall(o,"top",t,e,-3.141592653589793,h),this.setupWall(a,"bottom",t,e+s,0,h),this._boundsLeft=n,this._boundsRight=r,this._boundsTop=o,this._boundsBottom=a,this._boundsOwnGroup=h},setupWall:function(t,e,i,s,n,r){t?(this.walls[e]?this.walls[e].position=[this.pxmi(i),this.pxmi(s)]:(this.walls[e]=new p2.Body({mass:0,position:[this.pxmi(i),this.pxmi(s)],angle:n}),this.walls[e].addShape(new p2.Plane),this.world.addBody(this.walls[e])),r&&(this.walls[e].shapes[0].collisionGroup=this.boundsCollisionGroup.mask)):this.walls[e]&&(this.world.removeBody(this.walls[e]),this.walls[e]=null)},pause:function(){this.paused=!0},resume:function(){this.paused=!1},update:function(){this.paused||(this.useElapsedTime?this.world.step(this.game.time.physicsElapsed):this.world.step(this.frameRate))},reset:function(){this.world.on("beginContact",this.beginContactHandler,this),this.world.on("endContact",this.endContactHandler,this),this.nothingCollisionGroup=new e.Physics.P2.CollisionGroup(1),this.boundsCollisionGroup=new e.Physics.P2.CollisionGroup(2),this.everythingCollisionGroup=new e.Physics.P2.CollisionGroup(2147483648),this._collisionGroupID=2,this.setBoundsToWorld(!0,!0,!0,!0,!1)},clear:function(){this.world.time=0,this.world.fixedStepTime=0,this.world.solver&&this.world.solver.equations.length&&this.world.solver.removeAllEquations();for(var t=this.world.constraints,e=t.length-1;e>=0;e--)this.world.removeConstraint(t[e]);for(var i=this.world.bodies,e=i.length-1;e>=0;e--)this.world.removeBody(i[e]);for(var s=this.world.springs,e=s.length-1;e>=0;e--)this.world.removeSpring(s[e]);for(var n=this.world.contactMaterials,e=n.length-1;e>=0;e--)this.world.removeContactMaterial(n[e]);this.world.off("beginContact",this.beginContactHandler,this),this.world.off("endContact",this.endContactHandler,this),this.postBroadphaseCallback=null,this.callbackContext=null,this.impactCallback=null,this.collisionGroups=[],this._toRemove=[],this.boundsCollidesWith=[],this.walls={left:null,right:null,top:null,bottom:null}},destroy:function(){this.clear(),this.game=null},addBody:function(t){return!t.data.world&&(this.world.addBody(t.data),this.onBodyAdded.dispatch(t),!0)},removeBody:function(t){return t.data.world===this.world&&(this.world.removeBody(t.data),this.onBodyRemoved.dispatch(t)),t},addSpring:function(t){return t instanceof e.Physics.P2.Spring||t instanceof e.Physics.P2.RotationalSpring?this.world.addSpring(t.data):this.world.addSpring(t),this.onSpringAdded.dispatch(t),t},removeSpring:function(t){return t instanceof e.Physics.P2.Spring||t instanceof e.Physics.P2.RotationalSpring?this.world.removeSpring(t.data):this.world.removeSpring(t),this.onSpringRemoved.dispatch(t),t},createDistanceConstraint:function(t,i,s,n,r,o){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addConstraint(new e.Physics.P2.DistanceConstraint(this,t,i,s,n,r,o));console.warn("Cannot create Constraint, invalid body objects given")},createGearConstraint:function(t,i,s,n){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addConstraint(new e.Physics.P2.GearConstraint(this,t,i,s,n));console.warn("Cannot create Constraint, invalid body objects given")},createRevoluteConstraint:function(t,i,s,n,r,o){if(t=this.getBody(t),s=this.getBody(s),t&&s)return this.addConstraint(new e.Physics.P2.RevoluteConstraint(this,t,i,s,n,r,o));console.warn("Cannot create Constraint, invalid body objects given")},createLockConstraint:function(t,i,s,n,r){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addConstraint(new e.Physics.P2.LockConstraint(this,t,i,s,n,r));console.warn("Cannot create Constraint, invalid body objects given")},createPrismaticConstraint:function(t,i,s,n,r,o,a){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addConstraint(new e.Physics.P2.PrismaticConstraint(this,t,i,s,n,r,o,a));console.warn("Cannot create Constraint, invalid body objects given")},addConstraint:function(t){return this.world.addConstraint(t),this.onConstraintAdded.dispatch(t),t},removeConstraint:function(t){return this.world.removeConstraint(t),this.onConstraintRemoved.dispatch(t),t},addContactMaterial:function(t){return this.world.addContactMaterial(t),this.onContactMaterialAdded.dispatch(t),t},removeContactMaterial:function(t){return this.world.removeContactMaterial(t),this.onContactMaterialRemoved.dispatch(t),t},getContactMaterial:function(t,e){return this.world.getContactMaterial(t,e)},setMaterial:function(t,e){for(var i=e.length;i--;)e[i].setMaterial(t)},createMaterial:function(t,i){t=t||"";var s=new e.Physics.P2.Material(t);return this.materials.push(s),void 0!==i&&i.setMaterial(s),s},createContactMaterial:function(t,i,s){void 0===t&&(t=this.createMaterial()),void 0===i&&(i=this.createMaterial());var n=new e.Physics.P2.ContactMaterial(t,i,s);return this.addContactMaterial(n)},getBodies:function(){for(var t=[],e=this.world.bodies.length;e--;)t.push(this.world.bodies[e].parent);return t},getBody:function(t){return t instanceof p2.Body?t:t instanceof e.Physics.P2.Body?t.data:t.body&&t.body.type===e.Physics.P2JS?t.body.data:null},getSprings:function(){for(var t=[],e=this.world.springs.length;e--;)t.push(this.world.springs[e].parent);return t},getConstraints:function(){for(var t=[],e=this.world.constraints.length;e--;)t.push(this.world.constraints[e]);return t},hitTest:function(t,i,s,n){void 0===i&&(i=this.world.bodies),void 0===s&&(s=5),void 0===n&&(n=!1);for(var r=[this.pxmi(t.x),this.pxmi(t.y)],o=[],a=i.length;a--;)i[a]instanceof e.Physics.P2.Body&&(!n||i[a].data.type!==p2.Body.STATIC)?o.push(i[a].data):i[a]instanceof p2.Body&&i[a].parent&&(!n||i[a].type!==p2.Body.STATIC)?o.push(i[a]):i[a]instanceof e.Sprite&&i[a].hasOwnProperty("body")&&(!n||i[a].body.data.type!==p2.Body.STATIC)&&o.push(i[a].body.data);return this.world.hitTest(r,o,s)},toJSON:function(){return this.world.toJSON()},createCollisionGroup:function(t){var i=Math.pow(2,this._collisionGroupID);this.walls.left&&(this.walls.left.shapes[0].collisionMask=this.walls.left.shapes[0].collisionMask|i),this.walls.right&&(this.walls.right.shapes[0].collisionMask=this.walls.right.shapes[0].collisionMask|i),this.walls.top&&(this.walls.top.shapes[0].collisionMask=this.walls.top.shapes[0].collisionMask|i),this.walls.bottom&&(this.walls.bottom.shapes[0].collisionMask=this.walls.bottom.shapes[0].collisionMask|i),this._collisionGroupID++;var s=new e.Physics.P2.CollisionGroup(i);return this.collisionGroups.push(s),t&&this.setCollisionGroup(t,s),s},setCollisionGroup:function(t,i){if(t instanceof e.Group)for(var s=0;s<t.total;s++)t.children[s].body&&t.children[s].body.type===e.Physics.P2JS&&t.children[s].body.setCollisionGroup(i);else t.body.setCollisionGroup(i)},createSpring:function(t,i,s,n,r,o,a,h,l){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addSpring(new e.Physics.P2.Spring(this,t,i,s,n,r,o,a,h,l));console.warn("Cannot create Spring, invalid body objects given")},createRotationalSpring:function(t,i,s,n,r){if(t=this.getBody(t),i=this.getBody(i),t&&i)return this.addSpring(new e.Physics.P2.RotationalSpring(this,t,i,s,n,r));console.warn("Cannot create Rotational Spring, invalid body objects given")},createBody:function(t,i,s,n,r,o){void 0===n&&(n=!1);var a=new e.Physics.P2.Body(this.game,null,t,i,s);return!(o&&!a.addPolygon(r,o))&&(n&&this.world.addBody(a.data),a)},createParticle:function(t,i,s,n,r,o){void 0===n&&(n=!1);var a=new e.Physics.P2.Body(this.game,null,t,i,s);return!(o&&!a.addPolygon(r,o))&&(n&&this.world.addBody(a.data),a)},convertCollisionObjects:function(t,e,i){void 0===i&&(i=!0);for(var s=[],n=0,r=t.collision[e].length;n<r;n++){var o=t.collision[e][n],a=o.polyline||o.polygon;if(a)var h=this.createBody(o.x,o.y,0,i,{},a);else o.rectangle&&(h=this.createBody(o.x,o.y,0,i)).addRectangle(o.width,o.height,o.width/2,o.height/2);h&&s.push(h)}return s},clearTilemapLayerBodies:function(t,e){e=t.getLayer(e);for(var i=t.layers[e].bodies.length;i--;)t.layers[e].bodies[i].destroy();t.layers[e].bodies.length=0},convertTilemap:function(t,e,i,s){e=t.getLayer(e),void 0===i&&(i=!0),void 0===s&&(s=!0),this.clearTilemapLayerBodies(t,e);for(var n=0,r=0,o=0,a=0,h=t.layers[e].height;a<h;a++){n=0;for(var l=0,c=t.layers[e].width;l<c;l++){var u=t.layers[e].data[a][l];if(u&&u.index>-1&&u.collides)if(s){var d=t.getTileRight(e,l,a);0===n&&(r=u.x*u.width,o=u.y*u.height,n=u.width),d&&d.collides?n+=u.width:((p=this.createBody(r,o,0,!1)).addRectangle(n,u.height,n/2,u.height/2,0),i&&this.addBody(p),t.layers[e].bodies.push(p),n=0)}else{var p=this.createBody(u.x*u.width,u.y*u.height,0,!1);p.addRectangle(u.width,u.height,u.width/2,u.height/2,0),i&&this.addBody(p),t.layers[e].bodies.push(p)}}}return t.layers[e].bodies},mpx:function(t){return t*=20},pxm:function(t){return.05*t},mpxi:function(t){return t*=-20},pxmi:function(t){return-.05*t}},Object.defineProperty(e.Physics.P2.prototype,"friction",{get:function(){return this.world.defaultContactMaterial.friction},set:function(t){this.world.defaultContactMaterial.friction=t}}),Object.defineProperty(e.Physics.P2.prototype,"restitution",{get:function(){return this.world.defaultContactMaterial.restitution},set:function(t){this.world.defaultContactMaterial.restitution=t}}),Object.defineProperty(e.Physics.P2.prototype,"contactMaterial",{get:function(){return this.world.defaultContactMaterial},set:function(t){this.world.defaultContactMaterial=t}}),Object.defineProperty(e.Physics.P2.prototype,"applySpringForces",{get:function(){return this.world.applySpringForces},set:function(t){this.world.applySpringForces=t}}),Object.defineProperty(e.Physics.P2.prototype,"applyDamping",{get:function(){return this.world.applyDamping},set:function(t){this.world.applyDamping=t}}),Object.defineProperty(e.Physics.P2.prototype,"applyGravity",{get:function(){return this.world.applyGravity},set:function(t){this.world.applyGravity=t}}),Object.defineProperty(e.Physics.P2.prototype,"solveConstraints",{get:function(){return this.world.solveConstraints},set:function(t){this.world.solveConstraints=t}}),Object.defineProperty(e.Physics.P2.prototype,"time",{get:function(){return this.world.time}}),Object.defineProperty(e.Physics.P2.prototype,"emitImpactEvent",{get:function(){return this.world.emitImpactEvent},set:function(t){this.world.emitImpactEvent=t}}),Object.defineProperty(e.Physics.P2.prototype,"sleepMode",{get:function(){return this.world.sleepMode},set:function(t){this.world.sleepMode=t}}),Object.defineProperty(e.Physics.P2.prototype,"total",{get:function(){return this.world.bodies.length}}),e.Physics.P2.FixtureList=function(t){Array.isArray(t)||(t=[t]),this.rawList=t,this.init(),this.parse(this.rawList)},e.Physics.P2.FixtureList.prototype={init:function(){this.namedFixtures={},this.groupedFixtures=[],this.allFixtures=[]},setCategory:function(t,e){this.getFixtures(e).forEach(function(e){e.collisionGroup=t})},setMask:function(t,e){this.getFixtures(e).forEach(function(e){e.collisionMask=t})},setSensor:function(t,e){this.getFixtures(e).forEach(function(e){e.sensor=t})},setMaterial:function(t,e){this.getFixtures(e).forEach(function(e){e.material=t})},getFixtures:function(t){var e=[];if(t){t instanceof Array||(t=[t]);var i=this;return t.forEach(function(t){i.namedFixtures[t]&&e.push(i.namedFixtures[t])}),this.flatten(e)}return this.allFixtures},getFixtureByKey:function(t){return this.namedFixtures[t]},getGroup:function(t){return this.groupedFixtures[t]},parse:function(){var t,e,i,s;i=this.rawList,s=[];for(t in i)e=i[t],isNaN(t-0)?this.namedFixtures[t]=this.flatten(e):(this.groupedFixtures[t]=this.groupedFixtures[t]||[],this.groupedFixtures[t]=this.groupedFixtures[t].concat(e)),s.push(this.allFixtures=this.flatten(this.groupedFixtures))},flatten:function(t){var e,i;return e=[],i=arguments.callee,t.forEach(function(t){return Array.prototype.push.apply(e,Array.isArray(t)?i(t):[t])}),e}},e.Physics.P2.PointProxy=function(t,e){this.world=t,this.destination=e},e.Physics.P2.PointProxy.prototype.constructor=e.Physics.P2.PointProxy,Object.defineProperty(e.Physics.P2.PointProxy.prototype,"x",{get:function(){return this.world.mpx(this.destination[0])},set:function(t){this.destination[0]=this.world.pxm(t)}}),Object.defineProperty(e.Physics.P2.PointProxy.prototype,"y",{get:function(){return this.world.mpx(this.destination[1])},set:function(t){this.destination[1]=this.world.pxm(t)}}),Object.defineProperty(e.Physics.P2.PointProxy.prototype,"mx",{get:function(){return this.destination[0]},set:function(t){this.destination[0]=t}}),Object.defineProperty(e.Physics.P2.PointProxy.prototype,"my",{get:function(){return this.destination[1]},set:function(t){this.destination[1]=t}}),e.Physics.P2.InversePointProxy=function(t,e){this.world=t,this.destination=e},e.Physics.P2.InversePointProxy.prototype.constructor=e.Physics.P2.InversePointProxy,Object.defineProperty(e.Physics.P2.InversePointProxy.prototype,"x",{get:function(){return this.world.mpxi(this.destination[0])},set:function(t){this.destination[0]=this.world.pxmi(t)}}),Object.defineProperty(e.Physics.P2.InversePointProxy.prototype,"y",{get:function(){return this.world.mpxi(this.destination[1])},set:function(t){this.destination[1]=this.world.pxmi(t)}}),Object.defineProperty(e.Physics.P2.InversePointProxy.prototype,"mx",{get:function(){return this.destination[0]},set:function(t){this.destination[0]=-t}}),Object.defineProperty(e.Physics.P2.InversePointProxy.prototype,"my",{get:function(){return this.destination[1]},set:function(t){this.destination[1]=-t}}),e.Physics.P2.Body=function(t,i,s,n,r){i=i||null,s=s||0,n=n||0,void 0===r&&(r=1),this.game=t,this.world=t.physics.p2,this.sprite=i,this.type=e.Physics.P2JS,this.offset=new e.Point,this.data=new p2.Body({position:[this.world.pxmi(s),this.world.pxmi(n)],mass:r}),this.data.parent=this,this.velocity=new e.Physics.P2.InversePointProxy(this.world,this.data.velocity),this.force=new e.Physics.P2.InversePointProxy(this.world,this.data.force),this.gravity=new e.Point,this.onBeginContact=new e.Signal,this.onEndContact=new e.Signal,this.collidesWith=[],this.removeNextStep=!1,this.debugBody=null,this.dirty=!1,this._collideWorldBounds=!0,this._bodyCallbacks={},this._bodyCallbackContext={},this._groupCallbacks={},this._groupCallbackContext={},this._reset=!1,i&&(this.setRectangleFromSprite(i),i.exists&&this.game.physics.p2.addBody(this))},e.Physics.P2.Body.prototype={createBodyCallback:function(t,e,i){var s=-1;t.id?s=t.id:t.body&&(s=t.body.id),s>-1&&(null===e?(delete this._bodyCallbacks[s],delete this._bodyCallbackContext[s]):(this._bodyCallbacks[s]=e,this._bodyCallbackContext[s]=i))},createGroupCallback:function(t,e,i){null===e?(delete this._groupCallbacks[t.mask],delete this._groupCallbackContext[t.mask]):(this._groupCallbacks[t.mask]=e,this._groupCallbackContext[t.mask]=i)},getCollisionMask:function(){var t=0;this._collideWorldBounds&&(t=this.game.physics.p2.boundsCollisionGroup.mask);for(var e=0;e<this.collidesWith.length;e++)t|=this.collidesWith[e].mask;return t},updateCollisionMask:function(t){var e=this.getCollisionMask();if(void 0===t)for(var i=this.data.shapes.length-1;i>=0;i--)this.data.shapes[i].collisionMask=e;else t.collisionMask=e},setCollisionGroup:function(t,e){var i=this.getCollisionMask();if(void 0===e)for(var s=this.data.shapes.length-1;s>=0;s--)this.data.shapes[s].collisionGroup=t.mask,this.data.shapes[s].collisionMask=i;else e.collisionGroup=t.mask,e.collisionMask=i},clearCollision:function(t,e,i){if(void 0===t&&(t=!0),void 0===e&&(e=!0),void 0===i)for(var s=this.data.shapes.length-1;s>=0;s--)t&&(this.data.shapes[s].collisionGroup=null),e&&(this.data.shapes[s].collisionMask=null);else t&&(i.collisionGroup=null),e&&(i.collisionMask=null);t&&(this.collidesWith.length=0)},removeCollisionGroup:function(t,e,i){void 0===e&&(e=!0);var s;if(Array.isArray(t))for(r=0;r<t.length;r++)(s=this.collidesWith.indexOf(t[r]))>-1&&(this.collidesWith.splice(s,1),e&&(delete this._groupCallbacks[t.mask],delete this._groupCallbackContext[t.mask]));else(s=this.collidesWith.indexOf(t))>-1&&(this.collidesWith.splice(s,1),e&&(delete this._groupCallbacks[t.mask],delete this._groupCallbackContext[t.mask]));var n=this.getCollisionMask();if(void 0===i)for(var r=this.data.shapes.length-1;r>=0;r--)this.data.shapes[r].collisionMask=n;else i.collisionMask=n},collides:function(t,e,i,s){if(Array.isArray(t))for(r=0;r<t.length;r++)-1===this.collidesWith.indexOf(t[r])&&(this.collidesWith.push(t[r]),e&&this.createGroupCallback(t[r],e,i));else-1===this.collidesWith.indexOf(t)&&(this.collidesWith.push(t),e&&this.createGroupCallback(t,e,i));var n=this.getCollisionMask();if(void 0===s)for(var r=this.data.shapes.length-1;r>=0;r--)this.data.shapes[r].collisionMask=n;else s.collisionMask=n},adjustCenterOfMass:function(){this.data.adjustCenterOfMass(),this.shapeChanged()},getVelocityAtPoint:function(t,e){return this.data.getVelocityAtPoint(t,e)},applyDamping:function(t){this.data.applyDamping(t)},applyImpulse:function(t,e,i){this.data.applyImpulse(t,[this.world.pxmi(e),this.world.pxmi(i)])},applyImpulseLocal:function(t,e,i){this.data.applyImpulseLocal(t,[this.world.pxmi(e),this.world.pxmi(i)])},applyForce:function(t,e,i){this.data.applyForce(t,[this.world.pxmi(e),this.world.pxmi(i)])},setZeroForce:function(){this.data.setZeroForce()},setZeroRotation:function(){this.data.angularVelocity=0},setZeroVelocity:function(){this.data.velocity[0]=0,this.data.velocity[1]=0},setZeroDamping:function(){this.data.damping=0,this.data.angularDamping=0},toLocalFrame:function(t,e){return this.data.toLocalFrame(t,e)},toWorldFrame:function(t,e){return this.data.toWorldFrame(t,e)},rotateLeft:function(t){this.data.angularVelocity=this.world.pxm(-t)},rotateRight:function(t){this.data.angularVelocity=this.world.pxm(t)},moveForward:function(t){var e=this.world.pxmi(-t),i=this.data.angle+Math.PI/2;this.data.velocity[0]=e*Math.cos(i),this.data.velocity[1]=e*Math.sin(i)},moveBackward:function(t){var e=this.world.pxmi(-t),i=this.data.angle+Math.PI/2;this.data.velocity[0]=-e*Math.cos(i),this.data.velocity[1]=-e*Math.sin(i)},thrust:function(t){var e=this.world.pxmi(-t),i=this.data.angle+Math.PI/2;this.data.force[0]+=e*Math.cos(i),this.data.force[1]+=e*Math.sin(i)},thrustLeft:function(t){var e=this.world.pxmi(-t),i=this.data.angle;this.data.force[0]+=e*Math.cos(i),this.data.force[1]+=e*Math.sin(i)},thrustRight:function(t){var e=this.world.pxmi(-t),i=this.data.angle;this.data.force[0]-=e*Math.cos(i),this.data.force[1]-=e*Math.sin(i)},reverse:function(t){var e=this.world.pxmi(-t),i=this.data.angle+Math.PI/2;this.data.force[0]-=e*Math.cos(i),this.data.force[1]-=e*Math.sin(i)},moveLeft:function(t){this.data.velocity[0]=this.world.pxmi(-t)},moveRight:function(t){this.data.velocity[0]=this.world.pxmi(t)},moveUp:function(t){this.data.velocity[1]=this.world.pxmi(-t)},moveDown:function(t){this.data.velocity[1]=this.world.pxmi(t)},preUpdate:function(){this.dirty=!0,this.removeNextStep&&(this.removeFromWorld(),this.removeNextStep=!1)},postUpdate:function(){this.sprite.x=this.world.mpxi(this.data.position[0])+this.offset.x,this.sprite.y=this.world.mpxi(this.data.position[1])+this.offset.y,this.fixedRotation||(this.sprite.rotation=this.data.angle),this.debugBody&&this.debugBody.updateSpriteTransform(),this.dirty=!1},reset:function(t,e,i,s){void 0===i&&(i=!1),void 0===s&&(s=!1),this.setZeroForce(),this.setZeroVelocity(),this.setZeroRotation(),i&&this.setZeroDamping(),s&&(this.mass=1),this.x=t,this.y=e},addToWorld:function(){if(this.game.physics.p2._toRemove)for(var t=0;t<this.game.physics.p2._toRemove.length;t++)this.game.physics.p2._toRemove[t]===this&&this.game.physics.p2._toRemove.splice(t,1);this.data.world!==this.game.physics.p2.world&&this.game.physics.p2.addBody(this)},removeFromWorld:function(){this.data.world===this.game.physics.p2.world&&this.game.physics.p2.removeBodyNextStep(this)},destroy:function(){this.removeFromWorld(),this.clearShapes(),this._bodyCallbacks={},this._bodyCallbackContext={},this._groupCallbacks={},this._groupCallbackContext={},this.debugBody&&this.debugBody.destroy(!0,!0),this.debugBody=null,this.sprite&&(this.sprite.body=null,this.sprite=null)},clearShapes:function(){for(var t=this.data.shapes.length;t--;)this.data.removeShape(this.data.shapes[t]);this.shapeChanged()},addShape:function(t,e,i,s){return void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),this.data.addShape(t,[this.world.pxmi(e),this.world.pxmi(i)],s),this.shapeChanged(),t},addCircle:function(t,e,i,s){var n=new p2.Circle({radius:this.world.pxm(t)});return this.addShape(n,e,i,s)},addRectangle:function(t,e,i,s,n){var r=new p2.Box({width:this.world.pxm(t),height:this.world.pxm(e)});return this.addShape(r,i,s,n)},addPlane:function(t,e,i){var s=new p2.Plane;return this.addShape(s,t,e,i)},addParticle:function(t,e,i){var s=new p2.Particle;return this.addShape(s,t,e,i)},addLine:function(t,e,i,s){var n=new p2.Line({length:this.world.pxm(t)});return this.addShape(n,e,i,s)},addCapsule:function(t,e,i,s,n){var r=new p2.Capsule({length:this.world.pxm(t),radius:this.world.pxm(e)});return this.addShape(r,i,s,n)},addPolygon:function(t,e){t=t||{},Array.isArray(e)||(e=Array.prototype.slice.call(arguments,1));var i=[];if(1===e.length&&Array.isArray(e[0]))i=e[0].slice(0);else if(Array.isArray(e[0]))i=e.slice();else if("number"==typeof e[0])for(var s=0,n=e.length;s<n;s+=2)i.push([e[s],e[s+1]]);var r=i.length-1;i[r][0]===i[0][0]&&i[r][1]===i[0][1]&&i.pop();for(var o=0;o<i.length;o++)i[o][0]=this.world.pxmi(i[o][0]),i[o][1]=this.world.pxmi(i[o][1]);var a=this.data.fromPolygon(i,t);return this.shapeChanged(),a},removeShape:function(t){var e=this.data.removeShape(t);return this.shapeChanged(),e},setCircle:function(t,e,i,s){return this.clearShapes(),this.addCircle(t,e,i,s)},setRectangle:function(t,e,i,s,n){return void 0===t&&(t=16),void 0===e&&(e=16),this.clearShapes(),this.addRectangle(t,e,i,s,n)},setRectangleFromSprite:function(t){return void 0===t&&(t=this.sprite),this.clearShapes(),this.addRectangle(t.width,t.height,0,0,t.rotation)},setMaterial:function(t,e){if(void 0===e)for(var i=this.data.shapes.length-1;i>=0;i--)this.data.shapes[i].material=t;else e.material=t},shapeChanged:function(){this.debugBody&&this.debugBody.draw()},addPhaserPolygon:function(t,e){for(var i=this.game.cache.getPhysicsData(t,e),s=[],n=0;n<i.length;n++){var r=i[n],o=this.addFixture(r);s[r.filter.group]=s[r.filter.group]||[],s[r.filter.group]=s[r.filter.group].concat(o),r.fixtureKey&&(s[r.fixtureKey]=o)}return this.data.aabbNeedsUpdate=!0,this.shapeChanged(),s},addFixture:function(t){var e=[];if(t.circle){(l=new p2.Circle({radius:this.world.pxm(t.circle.radius)})).collisionGroup=t.filter.categoryBits,l.collisionMask=t.filter.maskBits,l.sensor=t.isSensor;var i=p2.vec2.create();i[0]=this.world.pxmi(t.circle.position[0]-this.sprite.width/2),i[1]=this.world.pxmi(t.circle.position[1]-this.sprite.height/2),this.data.addShape(l,i),e.push(l)}else for(var s=t.polygons,n=p2.vec2.create(),r=0;r<s.length;r++){for(var o=s[r],a=[],h=0;h<o.length;h+=2)a.push([this.world.pxmi(o[h]),this.world.pxmi(o[h+1])]);for(var l=new p2.Convex({vertices:a}),c=0;c!==l.vertices.length;c++){var u=l.vertices[c];p2.vec2.sub(u,u,l.centerOfMass)}p2.vec2.scale(n,l.centerOfMass,1),n[0]-=this.world.pxmi(this.sprite.width/2),n[1]-=this.world.pxmi(this.sprite.height/2),l.updateTriangles(),l.updateCenterOfMass(),l.updateBoundingRadius(),l.collisionGroup=t.filter.categoryBits,l.collisionMask=t.filter.maskBits,l.sensor=t.isSensor,this.data.addShape(l,n),e.push(l)}return e},loadPolygon:function(t,e,i){if(null===t)s=e;else var s=this.game.cache.getPhysicsData(t,e);"number"!=typeof i&&(i=1);for(var n=p2.vec2.create(),r=0;r<s.length;r++){for(var o=[],a=0;a<s[r].shape.length;a+=2)o.push([this.world.pxmi(s[r].shape[a]*i),this.world.pxmi(s[r].shape[a+1]*i)]);for(var h=new p2.Convex({vertices:o}),l=0;l!==h.vertices.length;l++){var c=h.vertices[l];p2.vec2.sub(c,c,h.centerOfMass)}p2.vec2.scale(n,h.centerOfMass,1),n[0]-=this.world.pxmi(this.sprite.width/2),n[1]-=this.world.pxmi(this.sprite.height/2),h.updateTriangles(),h.updateCenterOfMass(),h.updateBoundingRadius(),this.data.addShape(h,n)}return this.data.aabbNeedsUpdate=!0,this.shapeChanged(),!0}},e.Physics.P2.Body.prototype.constructor=e.Physics.P2.Body,e.Physics.P2.Body.DYNAMIC=1,e.Physics.P2.Body.STATIC=2,e.Physics.P2.Body.KINEMATIC=4,Object.defineProperty(e.Physics.P2.Body.prototype,"static",{get:function(){return this.data.type===e.Physics.P2.Body.STATIC},set:function(t){t&&this.data.type!==e.Physics.P2.Body.STATIC?(this.data.type=e.Physics.P2.Body.STATIC,this.mass=0):t||this.data.type!==e.Physics.P2.Body.STATIC||(this.data.type=e.Physics.P2.Body.DYNAMIC,this.mass=1)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"dynamic",{get:function(){return this.data.type===e.Physics.P2.Body.DYNAMIC},set:function(t){t&&this.data.type!==e.Physics.P2.Body.DYNAMIC?(this.data.type=e.Physics.P2.Body.DYNAMIC,this.mass=1):t||this.data.type!==e.Physics.P2.Body.DYNAMIC||(this.data.type=e.Physics.P2.Body.STATIC,this.mass=0)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"kinematic",{get:function(){return this.data.type===e.Physics.P2.Body.KINEMATIC},set:function(t){t&&this.data.type!==e.Physics.P2.Body.KINEMATIC?(this.data.type=e.Physics.P2.Body.KINEMATIC,this.mass=4):t||this.data.type!==e.Physics.P2.Body.KINEMATIC||(this.data.type=e.Physics.P2.Body.STATIC,this.mass=0)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"allowSleep",{get:function(){return this.data.allowSleep},set:function(t){t!==this.data.allowSleep&&(this.data.allowSleep=t)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"angle",{get:function(){return e.Math.wrapAngle(e.Math.radToDeg(this.data.angle))},set:function(t){this.data.angle=e.Math.degToRad(e.Math.wrapAngle(t))}}),Object.defineProperty(e.Physics.P2.Body.prototype,"angularDamping",{get:function(){return this.data.angularDamping},set:function(t){this.data.angularDamping=t}}),Object.defineProperty(e.Physics.P2.Body.prototype,"angularForce",{get:function(){return this.data.angularForce},set:function(t){this.data.angularForce=t}}),Object.defineProperty(e.Physics.P2.Body.prototype,"angularVelocity",{get:function(){return this.data.angularVelocity},set:function(t){this.data.angularVelocity=t}}),Object.defineProperty(e.Physics.P2.Body.prototype,"damping",{get:function(){return this.data.damping},set:function(t){this.data.damping=t}}),Object.defineProperty(e.Physics.P2.Body.prototype,"fixedRotation",{get:function(){return this.data.fixedRotation},set:function(t){t!==this.data.fixedRotation&&(this.data.fixedRotation=t)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"inertia",{get:function(){return this.data.inertia},set:function(t){this.data.inertia=t}}),Object.defineProperty(e.Physics.P2.Body.prototype,"mass",{get:function(){return this.data.mass},set:function(t){t!==this.data.mass&&(this.data.mass=t,this.data.updateMassProperties())}}),Object.defineProperty(e.Physics.P2.Body.prototype,"motionState",{get:function(){return this.data.type},set:function(t){t!==this.data.type&&(this.data.type=t)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"rotation",{get:function(){return this.data.angle},set:function(t){this.data.angle=t}}),Object.defineProperty(e.Physics.P2.Body.prototype,"sleepSpeedLimit",{get:function(){return this.data.sleepSpeedLimit},set:function(t){this.data.sleepSpeedLimit=t}}),Object.defineProperty(e.Physics.P2.Body.prototype,"x",{get:function(){return this.world.mpxi(this.data.position[0])},set:function(t){this.data.position[0]=this.world.pxmi(t)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"y",{get:function(){return this.world.mpxi(this.data.position[1])},set:function(t){this.data.position[1]=this.world.pxmi(t)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"id",{get:function(){return this.data.id}}),Object.defineProperty(e.Physics.P2.Body.prototype,"debug",{get:function(){return null!==this.debugBody},set:function(t){t&&!this.debugBody?this.debugBody=new e.Physics.P2.BodyDebug(this.game,this.data):!t&&this.debugBody&&(this.debugBody.destroy(),this.debugBody=null)}}),Object.defineProperty(e.Physics.P2.Body.prototype,"collideWorldBounds",{get:function(){return this._collideWorldBounds},set:function(t){t&&!this._collideWorldBounds?(this._collideWorldBounds=!0,this.updateCollisionMask()):!t&&this._collideWorldBounds&&(this._collideWorldBounds=!1,this.updateCollisionMask())}}),e.Physics.P2.BodyDebug=function(t,i,s){e.Group.call(this,t);var n={pixelsPerLengthUnit:t.physics.p2.mpx(1),debugPolygons:!1,lineWidth:1,alpha:.5};this.settings=Object.assign(n,s),this.ppu=this.settings.pixelsPerLengthUnit,this.ppu=-1*this.ppu,this.body=i,this.canvas=new e.Graphics(t),this.canvas.alpha=this.settings.alpha,this.add(this.canvas),this.draw(),this.updateSpriteTransform()},e.Physics.P2.BodyDebug.prototype=Object.create(e.Group.prototype),e.Physics.P2.BodyDebug.prototype.constructor=e.Physics.P2.BodyDebug,Object.assign(e.Physics.P2.BodyDebug.prototype,{updateSpriteTransform:function(){this.position.x=this.body.position[0]*this.ppu,this.position.y=this.body.position[1]*this.ppu,this.rotation=this.body.angle},draw:function(){var t,e,i,s,n,r,o,a,h,l,c,u,d,p;if(o=this.body,(h=this.canvas).clear(),i=parseInt(this.randomPastelHex(),16),16711680,r=this.lineWidth,o instanceof p2.Body&&o.shapes.length){var f=o.shapes.length;for(s=0;s!==f;){if(e=o.shapes[s],a=e.position||0,t=e.angle||0,e instanceof p2.Circle)this.drawCircle(h,a[0]*this.ppu,a[1]*this.ppu,t,e.radius*this.ppu,i,r);else if(e instanceof p2.Capsule)this.drawCapsule(h,a[0]*this.ppu,a[1]*this.ppu,t,e.length*this.ppu,e.radius*this.ppu,16711680,i,r);else if(e instanceof p2.Plane)this.drawPlane(h,a[0]*this.ppu,-a[1]*this.ppu,i,16711680,5*r,10*r,10*r,100*this.ppu,t);else if(e instanceof p2.Line)this.drawLine(h,e.length*this.ppu,16711680,r);else if(e instanceof p2.Box)this.drawRectangle(h,a[0]*this.ppu,a[1]*this.ppu,t,e.width*this.ppu,e.height*this.ppu,16711680,i,r);else if(e instanceof p2.Convex){for(c=[],u=p2.vec2.create(),n=d=0,p=e.vertices.length;p>=0?d<p:d>p;n=p>=0?++d:--d)l=e.vertices[n],p2.vec2.rotate(u,l,t),c.push([(u[0]+a[0])*this.ppu,-(u[1]+a[1])*this.ppu]);this.drawConvex(h,c,e.triangles,16711680,i,r,this.settings.debugPolygons,[a[0]*this.ppu,-a[1]*this.ppu])}s++}}},drawRectangle:function(t,e,i,s,n,r,o,a,h){void 0===h&&(h=1),void 0===o&&(o=0),t.lineStyle(h,o,1),t.beginFill(a),t.drawRect(e-n/2,i-r/2,n,r)},drawCircle:function(t,e,i,s,n,r,o){void 0===o&&(o=1),void 0===r&&(r=16777215),t.lineStyle(o,0,1),t.beginFill(r,1),t.drawCircle(e,i,2*-n),t.endFill(),t.moveTo(e,i),t.lineTo(e+n*Math.cos(-s),i+n*Math.sin(-s))},drawLine:function(t,e,i,s){void 0===s&&(s=1),void 0===i&&(i=0),t.lineStyle(5*s,i,1),t.moveTo(-e/2,0),t.lineTo(e/2,0)},drawConvex:function(t,e,i,s,n,r,o,a){var h,l,c,u,d,p,f,g,m,y,v;if(void 0===r&&(r=1),void 0===s&&(s=0),o){for(h=[16711680,65280,255],l=0;l!==e.length+1;)u=e[l%e.length],d=e[(l+1)%e.length],f=u[0],y=u[1],g=d[0],v=d[1],t.lineStyle(r,h[l%h.length],1),t.moveTo(f,-y),t.lineTo(g,-v),t.drawCircle(f,-y,2*r),l++;return t.lineStyle(r,0,1),t.drawCircle(a[0],a[1],2*r)}for(t.lineStyle(r,s,1),t.beginFill(n),l=0;l!==e.length;)p=(c=e[l])[0],m=c[1],0===l?t.moveTo(p,-m):t.lineTo(p,-m),l++;if(t.endFill(),e.length>2)return t.moveTo(e[e.length-1][0],-e[e.length-1][1]),t.lineTo(e[0][0],-e[0][1])},drawPath:function(t,e,i,s,n){var r,o,a,h,l,c,u,d,p,f,g;for(void 0===n&&(n=1),void 0===i&&(i=0),t.lineStyle(n,i,1),"number"==typeof s&&t.beginFill(s),o=null,a=null,r=0;r<e.length;)f=(p=e[r])[0],g=p[1],f===o&&g===a||(0===r?t.moveTo(f,g):(h=o,l=a,c=f,u=g,d=e[(r+1)%e.length][0],0!==(c-h)*(e[(r+1)%e.length][1]-l)-(d-h)*(u-l)&&t.lineTo(f,g)),o=f,a=g),r++;"number"==typeof s&&t.endFill(),e.length>2&&"number"==typeof s&&(t.moveTo(e[e.length-1][0],e[e.length-1][1]),t.lineTo(e[0][0],e[0][1]))},drawPlane:function(t,e,i,s,n,r,o,a,h,l){var c,u;void 0===r&&(r=1),void 0===s&&(s=16777215),t.lineStyle(r,n,11),t.beginFill(s),t.moveTo(e,-i),c=e+Math.cos(l)*this.game.width,u=i+Math.sin(l)*this.game.height,t.lineTo(c,-u),t.moveTo(e,-i),c=e+Math.cos(l)*-this.game.width,u=i+Math.sin(l)*-this.game.height,t.lineTo(c,-u)},drawCapsule:function(t,e,i,s,n,r,o,a,h){void 0===h&&(h=1),void 0===o&&(o=0),t.lineStyle(h,o,1);var l=Math.cos(s),c=Math.sin(s);t.beginFill(a,1),t.drawCircle(-n/2*l+e,-n/2*c+i,2*-r),t.drawCircle(n/2*l+e,n/2*c+i,2*-r),t.endFill(),t.lineStyle(h,o,0),t.beginFill(a,1),t.moveTo(-n/2*l+r*c+e,-n/2*c+r*l+i),t.lineTo(n/2*l+r*c+e,n/2*c+r*l+i),t.lineTo(n/2*l-r*c+e,n/2*c-r*l+i),t.lineTo(-n/2*l-r*c+e,-n/2*c-r*l+i),t.endFill(),t.lineStyle(h,o,1),t.moveTo(-n/2*l+r*c+e,-n/2*c+r*l+i),t.lineTo(n/2*l+r*c+e,n/2*c+r*l+i),t.moveTo(-n/2*l-r*c+e,-n/2*c-r*l+i),t.lineTo(n/2*l-r*c+e,n/2*c-r*l+i)},randomPastelHex:function(){var t,e,i,s;return i=[255,255,255],s=Math.floor(256*Math.random()),e=Math.floor(256*Math.random()),t=Math.floor(256*Math.random()),s=Math.floor((s+3*i[0])/4),e=Math.floor((e+3*i[1])/4),t=Math.floor((t+3*i[2])/4),this.rgbToHex(s,e,t)},rgbToHex:function(t,e,i){return this.componentToHex(t)+this.componentToHex(e)+this.componentToHex(i)},componentToHex:function(t){var e;return 2===(e=t.toString(16)).length?e:e+"0"}}),e.Physics.P2.Spring=function(t,e,i,s,n,r,o,a,h,l){this.game=t.game,this.world=t,void 0===s&&(s=1),void 0===n&&(n=100),void 0===r&&(r=1);var c={restLength:s=t.pxm(s),stiffness:n,damping:r};void 0!==o&&null!==o&&(c.worldAnchorA=[t.pxm(o[0]),t.pxm(o[1])]),void 0!==a&&null!==a&&(c.worldAnchorB=[t.pxm(a[0]),t.pxm(a[1])]),void 0!==h&&null!==h&&(c.localAnchorA=[t.pxm(h[0]),t.pxm(h[1])]),void 0!==l&&null!==l&&(c.localAnchorB=[t.pxm(l[0]),t.pxm(l[1])]),this.data=new p2.LinearSpring(e,i,c),this.data.parent=this},e.Physics.P2.Spring.prototype.constructor=e.Physics.P2.Spring,e.Physics.P2.RotationalSpring=function(t,e,i,s,n,r){this.game=t.game,this.world=t,void 0===s&&(s=null),void 0===n&&(n=100),void 0===r&&(r=1),s&&(s=t.pxm(s));var o={restAngle:s,stiffness:n,damping:r};this.data=new p2.RotationalSpring(e,i,o),this.data.parent=this},e.Physics.P2.Spring.prototype.constructor=e.Physics.P2.Spring,e.Physics.P2.Material=function(t){this.name=t,p2.Material.call(this)},e.Physics.P2.Material.prototype=Object.create(p2.Material.prototype),e.Physics.P2.Material.prototype.constructor=e.Physics.P2.Material,e.Physics.P2.ContactMaterial=function(t,e,i){p2.ContactMaterial.call(this,t,e,i)},e.Physics.P2.ContactMaterial.prototype=Object.create(p2.ContactMaterial.prototype),e.Physics.P2.ContactMaterial.prototype.constructor=e.Physics.P2.ContactMaterial,e.Physics.P2.CollisionGroup=function(t){this.mask=t},e.Physics.P2.DistanceConstraint=function(t,e,i,s,n,r,o){void 0===s&&(s=100),void 0===n&&(n=[0,0]),void 0===r&&(r=[0,0]),void 0===o&&(o=Number.MAX_VALUE),this.game=t.game,this.world=t;var a={distance:s=t.pxm(s),localAnchorA:n=[t.pxmi(n[0]),t.pxmi(n[1])],localAnchorB:r=[t.pxmi(r[0]),t.pxmi(r[1])],maxForce:o};p2.DistanceConstraint.call(this,e,i,a)},e.Physics.P2.DistanceConstraint.prototype=Object.create(p2.DistanceConstraint.prototype),e.Physics.P2.DistanceConstraint.prototype.constructor=e.Physics.P2.DistanceConstraint,e.Physics.P2.GearConstraint=function(t,e,i,s,n){void 0===s&&(s=0),void 0===n&&(n=1),this.game=t.game,this.world=t;var r={angle:s,ratio:n};p2.GearConstraint.call(this,e,i,r)},e.Physics.P2.GearConstraint.prototype=Object.create(p2.GearConstraint.prototype),e.Physics.P2.GearConstraint.prototype.constructor=e.Physics.P2.GearConstraint,e.Physics.P2.LockConstraint=function(t,e,i,s,n,r){void 0===s&&(s=[0,0]),void 0===n&&(n=0),void 0===r&&(r=Number.MAX_VALUE),this.game=t.game,this.world=t;var o={localOffsetB:s=[t.pxm(s[0]),t.pxm(s[1])],localAngleB:n,maxForce:r};p2.LockConstraint.call(this,e,i,o)},e.Physics.P2.LockConstraint.prototype=Object.create(p2.LockConstraint.prototype),e.Physics.P2.LockConstraint.prototype.constructor=e.Physics.P2.LockConstraint,e.Physics.P2.PrismaticConstraint=function(t,e,i,s,n,r,o,a){void 0===s&&(s=!0),void 0===n&&(n=[0,0]),void 0===r&&(r=[0,0]),void 0===o&&(o=[0,0]),void 0===a&&(a=Number.MAX_VALUE),this.game=t.game,this.world=t;var h={localAnchorA:n=[t.pxmi(n[0]),t.pxmi(n[1])],localAnchorB:r=[t.pxmi(r[0]),t.pxmi(r[1])],localAxisA:o,maxForce:a,disableRotationalLock:!s};p2.PrismaticConstraint.call(this,e,i,h)},e.Physics.P2.PrismaticConstraint.prototype=Object.create(p2.PrismaticConstraint.prototype),e.Physics.P2.PrismaticConstraint.prototype.constructor=e.Physics.P2.PrismaticConstraint,e.Physics.P2.RevoluteConstraint=function(t,e,i,s,n,r,o){void 0===r&&(r=Number.MAX_VALUE),void 0===o&&(o=null),this.game=t.game,this.world=t,i=[t.pxmi(i[0]),t.pxmi(i[1])],n=[t.pxmi(n[0]),t.pxmi(n[1])],o&&(o=[t.pxmi(o[0]),t.pxmi(o[1])]);var a={worldPivot:o,localPivotA:i,localPivotB:n,maxForce:r};p2.RevoluteConstraint.call(this,e,s,a)},e.Physics.P2.RevoluteConstraint.prototype=Object.create(p2.RevoluteConstraint.prototype),e.Physics.P2.RevoluteConstraint.prototype.constructor=e.Physics.P2.RevoluteConstraint,e.ImageCollection=function(t,e,i,s,n,r,o){(void 0===i||i<=0)&&(i=32),(void 0===s||s<=0)&&(s=32),void 0===n&&(n=0),void 0===r&&(r=0),this.name=t,this.firstgid=0|e,this.imageWidth=0|i,this.imageHeight=0|s,this.imageMargin=0|n,this.imageSpacing=0|r,this.properties=o||{},this.images=[],this.total=0},e.ImageCollection.prototype={containsImageIndex:function(t){return t>=this.firstgid&&t<this.firstgid+this.total},addImage:function(t,e){this.images.push({gid:t,image:e}),this.total++}},e.ImageCollection.prototype.constructor=e.ImageCollection,e.Tile=function(t,e,i,s,n,r){this.layer=t,this.index=e,this.x=i,this.y=s,this.rotation=0,this.flipped=!1,this.worldX=i*n,this.worldY=s*r,this.width=n,this.height=r,this.centerX=Math.abs(n/2),this.centerY=Math.abs(r/2),this.alpha=1,this.properties={},this.scanned=!1,this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.collisionCallback=null,this.collisionCallbackContext=this,this.debug=!1},e.Tile.prototype={containsPoint:function(t,e){return!(t<this.worldX||e<this.worldY||t>this.right||e>this.bottom)},intersects:function(t,e,i,s){return!(i<=this.worldX)&&(!(s<=this.worldY)&&(!(t>=this.worldX+this.width)&&!(e>=this.worldY+this.height)))},setCollisionCallback:function(t,e){this.collisionCallback=t,this.collisionCallbackContext=e},destroy:function(){this.collisionCallback=null,this.collisionCallbackContext=null,this.properties=null},setCollision:function(t,e,i,s){this.collideLeft=t,this.collideRight=e,this.collideUp=i,this.collideDown=s,this.faceLeft=t,this.faceRight=e,this.faceTop=i,this.faceBottom=s},resetCollision:function(){this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1},isInteresting:function(t,e){return t&&e?this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.faceTop||this.faceBottom||this.faceLeft||this.faceRight||this.collisionCallback:t?this.collideLeft||this.collideRight||this.collideUp||this.collideDown:!!e&&(this.faceTop||this.faceBottom||this.faceLeft||this.faceRight)},copy:function(t){this.index=t.index,this.alpha=t.alpha,this.properties=t.properties,this.collideUp=t.collideUp,this.collideDown=t.collideDown,this.collideLeft=t.collideLeft,this.collideRight=t.collideRight,this.collisionCallback=t.collisionCallback,this.collisionCallbackContext=t.collisionCallbackContext}},e.Tile.prototype.constructor=e.Tile,Object.defineProperty(e.Tile.prototype,"collides",{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown}}),Object.defineProperty(e.Tile.prototype,"canCollide",{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.collisionCallback}}),Object.defineProperty(e.Tile.prototype,"left",{get:function(){return this.worldX}}),Object.defineProperty(e.Tile.prototype,"right",{get:function(){return this.worldX+this.width}}),Object.defineProperty(e.Tile.prototype,"top",{get:function(){return this.worldY}}),Object.defineProperty(e.Tile.prototype,"bottom",{get:function(){return this.worldY+this.height}}),e.Tilemap=function(t,i,s,n,r,o){this.game=t,this.key=i;var a=e.TilemapParser.parse(this.game,i,s,n,r,o);null!==a&&(this.width=a.width,this.height=a.height,this.tileWidth=a.tileWidth,this.tileHeight=a.tileHeight,this.orientation=a.orientation,this.format=a.format,this.version=a.version,this.properties=a.properties,this.widthInPixels=a.widthInPixels,this.heightInPixels=a.heightInPixels,this.layers=a.layers,this.tilesets=a.tilesets,this.imagecollections=a.imagecollections,this.tiles=a.tiles,this.objects=a.objects,this.collideIndexes=[],this.collision=a.collision,this.images=a.images,this.enableDebug=!1,this.currentLayer=0,this.debugMap=[],this._results=[],this._tempA=0,this._tempB=0)},e.Tilemap.CSV=0,e.Tilemap.TILED_JSON=1,e.Tilemap.NORTH=0,e.Tilemap.EAST=1,e.Tilemap.SOUTH=2,e.Tilemap.WEST=3,e.Tilemap.prototype={create:function(t,e,i,s,n,r){return void 0===r&&(r=this.game.world),this.width=e,this.height=i,this.setTileSize(s,n),this.layers.length=0,this.createBlankLayer(t,e,i,s,n,r)},setTileSize:function(t,e){this.tileWidth=t,this.tileHeight=e,this.widthInPixels=this.width*t,this.heightInPixels=this.height*e},addTilesetImage:function(t,i,s,n,r,o,a){if(void 0===t)return null;void 0===s&&(s=this.tileWidth),void 0===n&&(n=this.tileHeight),void 0===r&&(r=0),void 0===o&&(o=0),void 0===a&&(a=0),0===s&&(s=32),0===n&&(n=32);var h=null;if(void 0!==i&&null!==i||(i=t),i instanceof e.BitmapData)h=i.canvas;else{if(!this.game.cache.checkImageKey(i))return console.warn('Phaser.Tilemap.addTilesetImage: Invalid image key given: "'+i+'"'),null;h=this.game.cache.getImage(i)}var l=this.getTilesetIndex(t);if(null===l&&this.format===e.Tilemap.TILED_JSON)return console.warn('Phaser.Tilemap.addTilesetImage: No data found in the JSON matching the tileset name: "'+t+'"'),console.log("Tilesets: ",this.tilesets),null;if(this.tilesets[l])return this.tilesets[l].setImage(h),this.tilesets[l];var c=new e.Tileset(t,a,s,n,r,o,{});c.setImage(h),this.tilesets.push(c);for(var u=this.tilesets.length-1,d=r,p=r,f=0,g=0,m=0,y=a;y<a+c.total&&(this.tiles[y]=[d,p,u],d+=s+o,++f!==c.total)&&(++g!==c.columns||(d=r,p+=n+o,g=0,++m!==c.rows));y++);return c},createFromObjects:function(t,i,s,n,r,o,a,h,l,c){if(void 0===r&&(r=!0),void 0===o&&(o=!1),void 0===a&&(a=this.game.world),void 0===h&&(h=e.Sprite),void 0===l&&(l=!0),void 0===c&&(c=!0),!this.objects[t])return console.warn("Tilemap.createFromObjects: Invalid objectgroup name given: "+t),void console.log("Objects: ",this.objects);for(var u=0;u<this.objects[t].length;u++){var d=!1,p=this.objects[t][u];if(void 0!==p.gid&&"number"==typeof i&&p.gid===i?d=!0:void 0!==p.id&&"number"==typeof i&&p.id===i?d=!0:void 0!==p.name&&"string"==typeof i&&p.name===i&&(d=!0),d){var f=new h(this.game,parseFloat(p.x),parseFloat(p.y),s,n);f.name=p.name,f.autoCull=o,f.exists=r,f.visible=p.visible,c&&(p.width&&(f.width=p.width),p.height&&(f.height=p.height)),p.rotation&&(f.angle=p.rotation),l&&(f.y-=f.height),a.add(f);for(var g in p.properties)a.set(f,g,p.properties[g],!1,!1,0,!0)}}},createFromTiles:function(t,i,s,n,r,o){"number"==typeof t&&(t=[t]),void 0===i||null===i?i=[]:"number"==typeof i&&(i=[i]),n=this.getLayer(n),void 0===r&&(r=this.game.world),void 0===o&&(o={}),void 0===o.customClass&&(o.customClass=e.Sprite),void 0===o.adjustY&&(o.adjustY=!0);var a=this.layers[n].width,h=this.layers[n].height;if(this.copy(0,0,a,h,n),this._results.length<2)return 0;for(var l,c=0,u=1,d=this._results.length;u<d;u++)if(-1!==t.indexOf(this._results[u].index)){l=new o.customClass(this.game,this._results[u].worldX,this._results[u].worldY,s);for(var p in o)l[p]=o[p];r.add(l),c++}if(1===i.length)for(u=0;u<t.length;u++)this.replace(t[u],i[0],0,0,a,h,n);else if(i.length>1)for(u=0;u<t.length;u++)this.replace(t[u],i[u],0,0,a,h,n);return c},createLayer:function(t,i,s,n){void 0===i&&(i=this.game.width),void 0===s&&(s=this.game.height),void 0===n&&(n=this.game.world);var r=t;if("string"==typeof t&&(r=this.getLayerIndex(t)),null===r||r>this.layers.length)return console.warn('Tilemap.createLayer: Invalid layer ID given: "'+t+'"'),void console.log("Layers: ",this.layers);void 0===i||i<=0?i=Math.min(this.game.width,this.layers[r].widthInPixels):i>this.game.width&&(i=this.game.width),void 0===s||s<=0?s=Math.min(this.game.height,this.layers[r].heightInPixels):s>this.game.height&&(s=this.game.height),this.enableDebug&&(console.group("Tilemap.createLayer"),console.log("Name:",this.layers[r].name),console.log("Size:",i,"x",s),console.log("Tileset:",this.tilesets[0].name,"index:",r));var o=n.add(new e.TilemapLayer(this.game,this,r,i,s));return this.enableDebug&&console.groupEnd(),o},createBlankLayer:function(t,i,s,n,r,o){void 0===o&&(o=this.game.world);{if(null===this.getLayerIndex(t)){for(var a,h={name:t,x:0,y:0,width:i,height:s,widthInPixels:i*n,heightInPixels:s*r,alpha:1,visible:!0,properties:{},indexes:[],callbacks:[],bodies:[],data:null},l=[],c=0;c<s;c++){a=[];for(var u=0;u<i;u++)a.push(new e.Tile(h,-1,u,c,n,r));l.push(a)}h.data=l,this.layers.push(h),this.currentLayer=this.layers.length-1;var d=h.widthInPixels,p=h.heightInPixels;return d>this.game.width&&(d=this.game.width),p>this.game.height&&(p=this.game.height),(l=new e.TilemapLayer(this.game,this,this.layers.length-1,d,p)).name=t,o.add(l)}console.warn("Tilemap.createBlankLayer: Layer with matching name already exists: "+t)}},getIndex:function(t,e){for(var i=0;i<t.length;i++)if(t[i].name===e)return i;return null},getLayerIndex:function(t){return this.getIndex(this.layers,t)},getTilesetIndex:function(t){return this.getIndex(this.tilesets,t)},getImageIndex:function(t){return this.getIndex(this.images,t)},setTileIndexCallback:function(t,e,i,s){if(s=this.getLayer(s),"number"==typeof t)null===e?delete this.layers[s].callbacks[t]:this.layers[s].callbacks[t]={callback:e,callbackContext:i};else for(var n=0,r=t.length;n<r;n++)null===e?delete this.layers[s].callbacks[t[n]]:this.layers[s].callbacks[t[n]]={callback:e,callbackContext:i}},setTileLocationCallback:function(t,e,i,s,n,r,o){if(o=this.getLayer(o),this.copy(t,e,i,s,o),!(this._results.length<2))for(var a=1;a<this._results.length;a++)this._results[a].setCollisionCallback(n,r)},setCollision:function(t,e,i,s){if(void 0===e&&(e=!0),void 0===s&&(s=!0),i=this.getLayer(i),"number"==typeof t)return this.setCollisionByIndex(t,e,i,!0);if(Array.isArray(t)){for(var n=0;n<t.length;n++)this.setCollisionByIndex(t[n],e,i,!1);s&&this.calculateFaces(i)}},setCollisionBetween:function(t,e,i,s,n){if(void 0===i&&(i=!0),void 0===n&&(n=!0),s=this.getLayer(s),!(t>e)){for(var r=t;r<=e;r++)this.setCollisionByIndex(r,i,s,!1);n&&this.calculateFaces(s)}},setCollisionByExclusion:function(t,e,i,s){void 0===e&&(e=!0),void 0===s&&(s=!0),i=this.getLayer(i);for(var n=0,r=this.tiles.length;n<r;n++)-1===t.indexOf(n)&&this.setCollisionByIndex(n,e,i,!1);s&&this.calculateFaces(i)},setCollisionByIndex:function(t,e,i,s){if(void 0===e&&(e=!0),void 0===i&&(i=this.currentLayer),void 0===s&&(s=!0),e)this.collideIndexes.push(t);else{var n=this.collideIndexes.indexOf(t);n>-1&&this.collideIndexes.splice(n,1)}for(var r=0;r<this.layers[i].height;r++)for(var o=0;o<this.layers[i].width;o++){var a=this.layers[i].data[r][o];a&&a.index===t&&(e?a.setCollision(!0,!0,!0,!0):a.resetCollision(),a.faceTop=e,a.faceBottom=e,a.faceLeft=e,a.faceRight=e)}return s&&this.calculateFaces(i),i},getLayer:function(t){if(void 0===t)t=this.currentLayer;else if("string"==typeof t){var i=t;null===(t=this.getLayerIndex(t))&&console.warn("No such layer name: "+i)}else t instanceof e.TilemapLayer&&(t=t.index);return t},setPreventRecalculate:function(t){if(!0===t&&!0!==this.preventingRecalculate&&(this.preventingRecalculate=!0,this.needToRecalculate={}),!1===t&&!0===this.preventingRecalculate){this.preventingRecalculate=!1;for(var e in this.needToRecalculate)this.calculateFaces(e);this.needToRecalculate=!1}},calculateFaces:function(t){if(this.preventingRecalculate)this.needToRecalculate[t]=!0;else for(var e=null,i=null,s=null,n=null,r=0,o=this.layers[t].height;r<o;r++)for(var a=0,h=this.layers[t].width;a<h;a++){var l=this.layers[t].data[r][a];l&&(e=this.getTileAbove(t,a,r),i=this.getTileBelow(t,a,r),s=this.getTileLeft(t,a,r),n=this.getTileRight(t,a,r),l.collides&&(l.faceTop=!0,l.faceBottom=!0,l.faceLeft=!0,l.faceRight=!0),e&&e.collides&&(l.faceTop=!1),i&&i.collides&&(l.faceBottom=!1),s&&s.collides&&(l.faceLeft=!1),n&&n.collides&&(l.faceRight=!1))}},getTileAbove:function(t,e,i){return i>0?this.layers[t].data[i-1][e]:null},getTileBelow:function(t,e,i){return i<this.layers[t].height-1?this.layers[t].data[i+1][e]:null},getTileLeft:function(t,e,i){return e>0?this.layers[t].data[i][e-1]:null},getTileRight:function(t,e,i){return e<this.layers[t].width-1?this.layers[t].data[i][e+1]:null},setLayer:function(t){t=this.getLayer(t),this.layers[t]&&(this.currentLayer=t)},hasTile:function(t,e,i){return i=this.getLayer(i),void 0!==this.layers[i].data[e]&&void 0!==this.layers[i].data[e][t]&&this.layers[i].data[e][t].index>-1},removeTile:function(t,i,s){if(s=this.getLayer(s),t>=0&&t<this.layers[s].width&&i>=0&&i<this.layers[s].height&&this.hasTile(t,i,s)){var n=this.layers[s].data[i][t];return this.layers[s].data[i][t]=new e.Tile(this.layers[s],-1,t,i,this.tileWidth,this.tileHeight),this.layers[s].dirty=!0,this.calculateFaces(s),n}},removeTileWorldXY:function(t,e,i,s,n){return n=this.getLayer(n),t=this.game.math.snapToFloor(t,i)/i,e=this.game.math.snapToFloor(e,s)/s,this.removeTile(t,e,n)},putTile:function(t,i,s,n){if(null===t)return this.removeTile(i,s,n);if(n=this.getLayer(n),i>=0&&i<this.layers[n].width&&s>=0&&s<this.layers[n].height){var r;return t instanceof e.Tile?(r=t.index,this.hasTile(i,s,n)?this.layers[n].data[s][i].copy(t):this.layers[n].data[s][i]=new e.Tile(n,r,i,s,t.width,t.height)):(r=t,this.hasTile(i,s,n)?this.layers[n].data[s][i].index=r:this.layers[n].data[s][i]=new e.Tile(this.layers[n],r,i,s,this.tileWidth,this.tileHeight)),this.collideIndexes.indexOf(r)>-1?this.layers[n].data[s][i].setCollision(!0,!0,!0,!0):this.layers[n].data[s][i].resetCollision(),this.layers[n].dirty=!0,this.calculateFaces(n),this.layers[n].data[s][i]}return null},putTileWorldXY:function(t,e,i,s,n,r){return r=this.getLayer(r),e=this.game.math.snapToFloor(e,s)/s,i=this.game.math.snapToFloor(i,n)/n,this.putTile(t,e,i,r)},searchTileIndex:function(t,e,i,s){void 0===e&&(e=0),void 0===i&&(i=!1),s=this.getLayer(s);var n=0;if(i){for(r=this.layers[s].height-1;r>=0;r--)for(o=this.layers[s].width-1;o>=0;o--)if(this.layers[s].data[r][o].index===t){if(n===e)return this.layers[s].data[r][o];n++}}else for(var r=0;r<this.layers[s].height;r++)for(var o=0;o<this.layers[s].width;o++)if(this.layers[s].data[r][o].index===t){if(n===e)return this.layers[s].data[r][o];n++}return null},getTile:function(t,e,i,s){return void 0===s&&(s=!1),i=this.getLayer(i),t>=0&&t<this.layers[i].width&&e>=0&&e<this.layers[i].height?-1===this.layers[i].data[e][t].index?s?this.layers[i].data[e][t]:null:this.layers[i].data[e][t]:null},getTileWorldXY:function(t,e,i,s,n,r){return void 0===i&&(i=this.tileWidth),void 0===s&&(s=this.tileHeight),n=this.getLayer(n),t=this.game.math.snapToFloor(t,i)/i,e=this.game.math.snapToFloor(e,s)/s,this.getTile(t,e,n,r)},copy:function(t,e,i,s,n){n=this.getLayer(n);{if(this.layers[n]){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.layers[n].width),void 0===s&&(s=this.layers[n].height),t<0&&(t=0),e<0&&(e=0),i>this.layers[n].width&&(i=this.layers[n].width),s>this.layers[n].height&&(s=this.layers[n].height),this._results.length=0,this._results.push({x:t,y:e,width:i,height:s,layer:n});for(var r=e;r<e+s;r++)for(var o=t;o<t+i;o++)this._results.push(this.layers[n].data[r][o]);return this._results}this._results.length=0}},paste:function(t,e,i,s){if(void 0===t&&(t=0),void 0===e&&(e=0),s=this.getLayer(s),i&&!(i.length<2)){for(var n=t-i[1].x,r=e-i[1].y,o=1;o<i.length;o++)this.layers[s].data[r+i[o].y][n+i[o].x].copy(i[o]);this.layers[s].dirty=!0,this.calculateFaces(s)}},swap:function(t,e,i,s,n,r,o){o=this.getLayer(o),this.copy(i,s,n,r,o),this._results.length<2||(this._tempA=t,this._tempB=e,this._results.forEach(this.swapHandler,this),this.paste(i,s,this._results,o))},swapHandler:function(t){t.index===this._tempA?t.index=this._tempB:t.index===this._tempB&&(t.index=this._tempA)},forEach:function(t,e,i,s,n,r,o){o=this.getLayer(o),this.copy(i,s,n,r,o),this._results.length<2||(this._results.forEach(t,e),this.paste(i,s,this._results,o))},replace:function(t,e,i,s,n,r,o){if(o=this.getLayer(o),this.copy(i,s,n,r,o),!(this._results.length<2)){for(var a=1;a<this._results.length;a++)this._results[a].index===t&&(this._results[a].index=e);this.paste(i,s,this._results,o)}},random:function(t,e,i,s,n){if(n=this.getLayer(n),this.copy(t,e,i,s,n),!(this._results.length<2)){for(var r=[],o=1;o<this._results.length;o++)if(this._results[o].index){var a=this._results[o].index;-1===r.indexOf(a)&&r.push(a)}for(var h=1;h<this._results.length;h++)this._results[h].index=this.game.rnd.pick(r);this.paste(t,e,this._results,n)}},shuffle:function(t,i,s,n,r){if(r=this.getLayer(r),this.copy(t,i,s,n,r),!(this._results.length<2)){for(var o=[],a=1;a<this._results.length;a++)this._results[a].index&&o.push(this._results[a].index);e.ArrayUtils.shuffle(o);for(var h=1;h<this._results.length;h++)this._results[h].index=o[h-1];this.paste(t,i,this._results,r)}},fill:function(t,e,i,s,n,r){if(r=this.getLayer(r),this.copy(e,i,s,n,r),!(this._results.length<2)){for(var o=1;o<this._results.length;o++)this._results[o].index=t;this.paste(e,i,this._results,r)}},removeAllLayers:function(){this.layers.length=0,this.currentLayer=0},dump:function(){for(var t="",e=[""],i=0;i<this.layers[this.currentLayer].height;i++){for(var s=0;s<this.layers[this.currentLayer].width;s++)t+="%c ",this.layers[this.currentLayer].data[i][s]>1?this.debugMap[this.layers[this.currentLayer].data[i][s]]?e.push("background: "+this.debugMap[this.layers[this.currentLayer].data[i][s]]):e.push("background: #ffffff"):e.push("background: rgb(0, 0, 0)");t+="\n"}e[0]=t,console.log.apply(console,e)},destroy:function(){this.removeAllLayers(),this.data=[],this.game=null}},e.Tilemap.prototype.constructor=e.Tilemap,Object.defineProperty(e.Tilemap.prototype,"layer",{get:function(){return this.layers[this.currentLayer]},set:function(t){t!==this.currentLayer&&this.setLayer(t)}}),e.TilemapLayer=function(t,i,s,n,r){n|=0,r|=0,e.Sprite.call(this,t,0,0),this.map=i,this.index=s,this.layer=i.layers[s],this.canvas=e.CanvasPool.create(this,n,r),this.context=this.canvas.getContext("2d"),this.setTexture(new PIXI.Texture(new PIXI.BaseTexture(this.canvas,null,this.game.resolution))),this.type=e.TILEMAPLAYER,this.physicsType=e.TILEMAPLAYER,this.renderSettings={enableScrollDelta:!0,overdrawRatio:.2,copyCanvas:null},this.debug=!1,this.exists=!0,this.debugSettings={missingImageFill:"rgb(255,255,255)",debuggedTileOverfill:"rgba(0,255,0,0.4)",forceFullRedraw:!0,debugAlpha:.5,facingEdgeStroke:"rgba(0,255,0,1)",collidingTileOverfill:"rgba(0,255,0,0.2)"},this.scrollFactorX=1,this.scrollFactorY=1,this.dirty=!0,this.rayStepRate=4,this._wrap=!1,this._mc={scrollX:0,scrollY:0,renderWidth:0,renderHeight:0,tileWidth:i.tileWidth,tileHeight:i.tileHeight,cw:i.tileWidth,ch:i.tileHeight,tilesets:[]},this._scrollX=0,this._scrollY=0,this.tileOffset=new e.Point(this.layer.offsetX||0,this.layer.offsetY||0),this._results=[],t.device.canvasBitBltShift||(this.renderSettings.copyCanvas=e.TilemapLayer.ensureSharedCopyCanvas()),this.fixedToCamera=!0},e.TilemapLayer.prototype=Object.create(e.Sprite.prototype),e.TilemapLayer.prototype.constructor=e.TilemapLayer,e.TilemapLayer.prototype.preUpdateCore=e.Component.Core.preUpdate,e.TilemapLayer.sharedCopyCanvas=null,e.TilemapLayer.ensureSharedCopyCanvas=function(){return this.sharedCopyCanvas||(this.sharedCopyCanvas=e.CanvasPool.create(this,2,2)),this.sharedCopyCanvas},e.TilemapLayer.prototype.preUpdate=function(){return this.preUpdateCore()},e.TilemapLayer.prototype.postUpdate=function(){this.fixedToCamera&&(this.position.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.position.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y),this._scrollX=(this.game.camera.view.x-this.tileOffset.x)*this.scrollFactorX/this.scale.x,this._scrollY=(this.game.camera.view.y-this.tileOffset.y)*this.scrollFactorY/this.scale.y},e.TilemapLayer.prototype._renderCanvas=function(t){this.fixedToCamera&&(this.position.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.position.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y),this._scrollX=(this.game.camera.view.x-this.tileOffset.x)*this.scrollFactorX/this.scale.x,this._scrollY=(this.game.camera.view.y-this.tileOffset.y)*this.scrollFactorY/this.scale.y,this.render(),PIXI.Sprite.prototype._renderCanvas.call(this,t)},e.TilemapLayer.prototype._renderWebGL=function(t){this.fixedToCamera&&(this.position.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.position.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y),this._scrollX=(this.game.camera.view.x-this.tileOffset.x)*this.scrollFactorX/this.scale.x,this._scrollY=(this.game.camera.view.y-this.tileOffset.y)*this.scrollFactorY/this.scale.y,this.render(),PIXI.Sprite.prototype._renderWebGL.call(this,t)},e.TilemapLayer.prototype.destroy=function(){e.CanvasPool.remove(this),e.Component.Destroy.prototype.destroy.call(this)},e.TilemapLayer.prototype.resize=function(t,e){this.canvas.width=t,this.canvas.height=e,this.texture.frame.resize(t,e),this.texture.width=t,this.texture.height=e,this.texture.crop.width=t,this.texture.crop.height=e,this.texture.baseTexture.width=t,this.texture.baseTexture.height=e,this.texture.baseTexture.dirty(),this.texture.requiresUpdate=!0,this.texture._updateUvs(),this.dirty=!0},e.TilemapLayer.prototype.resizeWorld=function(){this.game.world.setBounds(0,0,this.layer.widthInPixels*this.scale.x,this.layer.heightInPixels*this.scale.y)},e.TilemapLayer.prototype.getTileOffsetX=function(){return this.tileOffset.x||(this.fixedToCamera?0:this.position.x)},e.TilemapLayer.prototype.getTileOffsetY=function(){return this.tileOffset.y||(this.fixedToCamera?0:this.position.y)},e.TilemapLayer.prototype._fixX=function(t){return 1===this.scrollFactorX||0===this.scrollFactorX&&0===this.position.x?t:0===this.scrollFactorX&&0!==this.position.x?t-this.position.x:this._scrollX+(t-this._scrollX/this.scrollFactorX)},e.TilemapLayer.prototype._unfixX=function(t){return 1===this.scrollFactorX?t:this._scrollX/this.scrollFactorX+(t-this._scrollX)},e.TilemapLayer.prototype._fixY=function(t){return 1===this.scrollFactorY||0===this.scrollFactorY&&0===this.position.y?t:0===this.scrollFactorY&&0!==this.position.y?t-this.position.y:this._scrollY+(t-this._scrollY/this.scrollFactorY)},e.TilemapLayer.prototype._unfixY=function(t){return 1===this.scrollFactorY?t:this._scrollY/this.scrollFactorY+(t-this._scrollY)},e.TilemapLayer.prototype.getTileX=function(t){return Math.floor(this._fixX(t)/this._mc.tileWidth)},e.TilemapLayer.prototype.getTileY=function(t){return Math.floor(this._fixY(t)/this._mc.tileHeight)},e.TilemapLayer.prototype.getTileXY=function(t,e,i){return i.x=this.getTileX(t),i.y=this.getTileY(e),i},e.TilemapLayer.prototype.getRayCastTiles=function(t,e,i,s){e||(e=this.rayStepRate),void 0===i&&(i=!1),void 0===s&&(s=!1);var n=this.getTiles(t.x,t.y,t.width,t.height,i,s);if(0===n.length)return[];for(var r=t.coordinatesOnLine(e),o=[],a=0;a<n.length;a++)for(var h=0;h<r.length;h++){var l=n[a],c=r[h];if(l.containsPoint(c[0],c[1])){o.push(l);break}}return o},e.TilemapLayer.prototype.getTiles=function(t,e,i,s,n,r){void 0===n&&(n=!1),void 0===r&&(r=!1);var o=!(n||r);t=this._fixX(t),e=this._fixY(e);for(var a=Math.floor(t/(this._mc.cw*this.scale.x)),h=Math.floor(e/(this._mc.ch*this.scale.y)),l=Math.ceil((t+i)/(this._mc.cw*this.scale.x))-a,c=Math.ceil((e+s)/(this._mc.ch*this.scale.y))-h;this._results.length;)this._results.pop();for(var u=h;u<h+c;u++)for(var d=a;d<a+l;d++){var p=this.layer.data[u];p&&p[d]&&(o||p[d].isInteresting(n,r))&&this._results.push(p[d])}return this._results.slice()},e.TilemapLayer.prototype.resolveTileset=function(t){var e=this._mc.tilesets;if(t<2e3)for(;e.length<t;)e.push(void 0);var i=this.map.tiles[t]&&this.map.tiles[t][2];if(null!==i){var s=this.map.tilesets[i];if(s&&s.containsTileIndex(t))return e[t]=s}return e[t]=null},e.TilemapLayer.prototype.resetTilesetCache=function(){for(var t=this._mc.tilesets;t.length;)t.pop()},e.TilemapLayer.prototype.setScale=function(t,e){t=t||1,e=e||t;for(var i=0;i<this.layer.data.length;i++)for(var s=this.layer.data[i],n=0;n<s.length;n++){var r=s[n];r.width=this.map.tileWidth*t,r.height=this.map.tileHeight*e,r.worldX=r.x*r.width,r.worldY=r.y*r.height}this.scale.setTo(t,e)},e.TilemapLayer.prototype.shiftCanvas=function(t,e,i){var s=t.canvas,n=s.width-Math.abs(e),r=s.height-Math.abs(i),o=0,a=0,h=e,l=i;e<0&&(o=-e,h=0),i<0&&(a=-i,l=0);var c=this.renderSettings.copyCanvas;if(c){(c.width<n||c.height<r)&&(c.width=n,c.height=r);var u=c.getContext("2d");u.clearRect(0,0,n,r),u.drawImage(s,o,a,n,r,0,0,n,r),t.clearRect(h,l,n,r),t.drawImage(c,0,0,n,r,h,l,n,r)}else t.save(),t.globalCompositeOperation="copy",t.drawImage(s,o,a,n,r,h,l,n,r),t.restore()},e.TilemapLayer.prototype.renderRegion=function(t,e,i,s,n,r){var o=this.context,a=this.layer.width,h=this.layer.height,l=this._mc.tileWidth,c=this._mc.tileHeight,u=this._mc.tilesets,d=NaN;this._wrap||(i<=n&&(i=Math.max(0,i),n=Math.min(a-1,n)),s<=r&&(s=Math.max(0,s),r=Math.min(h-1,r)));var p,f,g,m,y,v,x=i*l-t,b=(i+(1<<20)*a)%a;for(m=(s+(1<<20)*h)%h,v=r-s,f=s*c-e;v>=0;m++,v--,f+=c){m>=h&&(m-=h);var _=this.layer.data[m];for(g=b,y=n-i,p=x;y>=0;g++,y--,p+=l){g>=a&&(g-=a);var w=_[g];if(w&&!(w.index<0)){var T=w.index,P=u[T];void 0===P&&(P=this.resolveTileset(T)),w.alpha===d||this.debug||(o.globalAlpha=w.alpha,d=w.alpha),P?w.rotation||w.flipped?(o.save(),o.translate(p+w.centerX,f+w.centerY),o.rotate(w.rotation),w.flipped&&o.scale(-1,1),P.draw(o,-w.centerX,-w.centerY,T),o.restore()):P.draw(o,p,f,T):this.debugSettings.missingImageFill&&(o.fillStyle=this.debugSettings.missingImageFill,o.fillRect(p,f,l,c)),w.debug&&this.debugSettings.debuggedTileOverfill&&(o.fillStyle=this.debugSettings.debuggedTileOverfill,o.fillRect(p,f,l,c))}}}},e.TilemapLayer.prototype.renderDeltaScroll=function(t,e){var i=this._mc.scrollX,s=this._mc.scrollY,n=this.canvas.width,r=this.canvas.height,o=this._mc.tileWidth,a=this._mc.tileHeight,h=0,l=-o,c=0,u=-a;if(t<0?(h=n+t,l=n-1):t>0&&(l=t),e<0?(c=r+e,u=r-1):e>0&&(u=e),this.shiftCanvas(this.context,t,e),h=Math.floor((h+i)/o),l=Math.floor((l+i)/o),c=Math.floor((c+s)/a),u=Math.floor((u+s)/a),h<=l){this.context.clearRect(h*o-i,0,(l-h+1)*o,r);var d=Math.floor((0+s)/a),p=Math.floor((r-1+s)/a);this.renderRegion(i,s,h,d,l,p)}if(c<=u){this.context.clearRect(0,c*a-s,n,(u-c+1)*a);var f=Math.floor((0+i)/o),g=Math.floor((n-1+i)/o);this.renderRegion(i,s,f,c,g,u)}},e.TilemapLayer.prototype.renderFull=function(){var t=this._mc.scrollX,e=this._mc.scrollY,i=this.canvas.width,s=this.canvas.height,n=this._mc.tileWidth,r=this._mc.tileHeight,o=Math.floor(t/n),a=Math.floor((i-1+t)/n),h=Math.floor(e/r),l=Math.floor((s-1+e)/r);this.context.clearRect(0,0,i,s),this.renderRegion(t,e,o,h,a,l)},e.TilemapLayer.prototype.render=function(){var t=!1;if(this.visible){(this.dirty||this.layer.dirty)&&(this.layer.dirty=!1,t=!0);var e=this.canvas.width,i=this.canvas.height,s=0|this._scrollX,n=0|this._scrollY,r=this._mc,o=r.scrollX-s,a=r.scrollY-n;if(t||0!==o||0!==a||r.renderWidth!==e||r.renderHeight!==i)return this.context.save(),r.scrollX=s,r.scrollY=n,r.renderWidth===e&&r.renderHeight===i||(r.renderWidth=e,r.renderHeight=i),this.debug&&(this.context.globalAlpha=this.debugSettings.debugAlpha,this.debugSettings.forceFullRedraw&&(t=!0)),!t&&this.renderSettings.enableScrollDelta&&Math.abs(o)+Math.abs(a)<Math.min(e,i)?this.renderDeltaScroll(o,a):this.renderFull(),this.debug&&(this.context.globalAlpha=1,this.renderDebug()),this.texture.baseTexture.dirty(),this.dirty=!1,this.context.restore(),!0}},e.TilemapLayer.prototype.renderDebug=function(){var t,e,i,s,n,r,o=this._mc.scrollX,a=this._mc.scrollY,h=this.context,l=this.canvas.width,c=this.canvas.height,u=this.layer.width,d=this.layer.height,p=this._mc.tileWidth,f=this._mc.tileHeight,g=Math.floor(o/p),m=Math.floor((l-1+o)/p),y=Math.floor(a/f),v=Math.floor((c-1+a)/f),x=g*p-o,b=y*f-a,_=(g+(1<<20)*u)%u,w=(y+(1<<20)*d)%d;for(h.strokeStyle=this.debugSettings.facingEdgeStroke,s=w,r=v-y,e=b;r>=0;s++,r--,e+=f){s>=d&&(s-=d);var T=this.layer.data[s];for(i=_,n=m-g,t=x;n>=0;i++,n--,t+=p){i>=u&&(i-=u);var P=T[i];!P||P.index<0||!P.collides||(this.debugSettings.collidingTileOverfill&&(h.fillStyle=this.debugSettings.collidingTileOverfill,h.fillRect(t,e,this._mc.cw,this._mc.ch)),this.debugSettings.facingEdgeStroke&&(h.beginPath(),P.faceTop&&(h.moveTo(t,e),h.lineTo(t+this._mc.cw,e)),P.faceBottom&&(h.moveTo(t,e+this._mc.ch),h.lineTo(t+this._mc.cw,e+this._mc.ch)),P.faceLeft&&(h.moveTo(t,e),h.lineTo(t,e+this._mc.ch)),P.faceRight&&(h.moveTo(t+this._mc.cw,e),h.lineTo(t+this._mc.cw,e+this._mc.ch)),h.closePath(),h.stroke()))}}},Object.defineProperty(e.TilemapLayer.prototype,"wrap",{get:function(){return this._wrap},set:function(t){this._wrap=t,this.dirty=!0}}),Object.defineProperty(e.TilemapLayer.prototype,"scrollX",{get:function(){return this._scrollX},set:function(t){this._scrollX=t}}),Object.defineProperty(e.TilemapLayer.prototype,"scrollY",{get:function(){return this._scrollY},set:function(t){this._scrollY=t}}),Object.defineProperty(e.TilemapLayer.prototype,"collisionWidth",{get:function(){return this._mc.cw},set:function(t){this._mc.cw=0|t,this.dirty=!0}}),Object.defineProperty(e.TilemapLayer.prototype,"collisionHeight",{get:function(){return this._mc.ch},set:function(t){this._mc.ch=0|t,this.dirty=!0}}),e.TilemapParser={INSERT_NULL:!1,parse:function(t,i,s,n,r,o){if(void 0===s&&(s=32),void 0===n&&(n=32),void 0===r&&(r=10),void 0===o&&(o=10),void 0===i)return this.getEmptyData();if(null===i)return this.getEmptyData(s,n,r,o);var a=t.cache.getTilemapData(i);if(a){if(a.format===e.Tilemap.CSV)return this.parseCSV(i,a.data,s,n);if(!a.format||a.format===e.Tilemap.TILED_JSON)return this.parseTiledJSON(a.data)}else console.warn('No map data found for key "%s"',i)},parseCSV:function(t,i,s,n){for(var r=this.getEmptyData(),o=[],a=(i=i.trim()).split("\n"),h=a.length,l=0,c=0;c<a.length;c++){o[c]=[];for(var u=a[c].split(","),d=0;d<u.length;d++)o[c][d]=new e.Tile(r.layers[0],parseInt(u[d],10),d,c,s,n);0===l&&(l=u.length)}return r.format=e.Tilemap.CSV,r.name=t,r.width=l,r.height=h,r.tileWidth=s,r.tileHeight=n,r.widthInPixels=l*s,r.heightInPixels=h*n,r.layers[0].width=l,r.layers[0].height=h,r.layers[0].widthInPixels=r.widthInPixels,r.layers[0].heightInPixels=r.heightInPixels,r.layers[0].data=o,r},getEmptyData:function(t,e,i,s){return{width:void 0!==i&&null!==i?i:0,height:void 0!==s&&null!==s?s:0,tileWidth:void 0!==t&&null!==t?t:0,tileHeight:void 0!==e&&null!==e?e:0,orientation:"orthogonal",version:"1",properties:{},widthInPixels:0,heightInPixels:0,layers:[{name:"layer",x:0,y:0,width:0,height:0,widthInPixels:0,heightInPixels:0,alpha:1,visible:!0,properties:{},indexes:[],callbacks:[],bodies:[],data:[]}],images:[],objects:{},collision:{},tilesets:[],tiles:[]}},_slice:function(t,e){var i={};for(var s in e){var n=e[s];void 0!==t[n]&&(i[n]=t[n])}return i},parseObjectGroup:function(t,e,i,s,n){var s=s||t.name,n=n||{x:0,y:0},r=this._slice;s||console.warn("No name found for objectGroup",t),void 0!==n.x&&void 0!==n.y||console.warn("Malformed xy properties in relativePosition",n),e[s]=e[s]||[],i[s]=i[s]||[];for(var o=0,a=t.objects.length;o<a;o++){var h=t.objects[o];if(h.gid){l={gid:h.gid,name:h.name,type:h.type||"",x:h.x+n.x,y:h.y+n.y,width:h.width,height:h.height,visible:h.visible,properties:h.properties};h.rotation&&(l.rotation=h.rotation),e[s].push(l)}else if(h.polyline){var l={name:h.name,type:h.type,x:h.x+n.x,y:h.y+n.y,width:h.width,height:h.height,visible:h.visible,properties:h.properties};h.rotation&&(l.rotation=h.rotation),l.polyline=[];for(c=0;c<h.polyline.length;c++)l.polyline.push([h.polyline[c].x,h.polyline[c].y]);i[s].push(l),e[s].push(l)}else if(h.polygon){(l=r(h,["name","type","x","y","visible","rotation","properties"])).x+=n.x,l.y+=n.y,l.polygon=[];for(var c=0;c<h.polygon.length;c++)l.polygon.push([h.polygon[c].x,h.polygon[c].y]);i[s].push(l),e[s].push(l)}else h.ellipse?((l=r(h,["name","type","ellipse","x","y","width","height","visible","rotation","properties"])).x+=n.x,l.y+=n.y,i[s].push(l),e[s].push(l)):((l=r(h,["name","type","x","y","width","height","visible","rotation","properties"])).x+=n.x,l.y+=n.y,l.rectangle=!0,i[s].push(l),e[s].push(l))}return{objectsCollection:e,collisionCollection:i}},parseTiledJSON:function(t){if("orthogonal"!==t.orientation)return console.warn('Phaser CE supports only orthogonal maps. This map\'s orientation is "%s".',t.orientation),null;t.version>1.1&&console.warn('Some features in this Tiled JSON map (version %s) may not work in Phaser CE. Enable the json1 plugin and reexport the map in "Tiled 1.1" format. https://github.com/photonstorm/phaser-ce/issues/623',t.version);for(var i={width:t.width,height:t.height,tileWidth:t.tilewidth,tileHeight:t.tileheight,orientation:t.orientation,format:e.Tilemap.TILED_JSON,version:t.version,properties:t.properties,widthInPixels:t.width*t.tilewidth,heightInPixels:t.height*t.tileheight},s=[],n=0;n<t.layers.length;n++)if("tilelayer"===t.layers[n].type){var r=t.layers[n];if(!r.compression&&r.encoding&&"base64"===r.encoding){for(var o=window.atob(r.data),a=o.length,h=new Array(a),l=0;l<a;l+=4)h[l/4]=(o.charCodeAt(l)|o.charCodeAt(l+1)<<8|o.charCodeAt(l+2)<<16|o.charCodeAt(l+3)<<24)>>>0;r.data=h,delete r.encoding}else if(r.compression){console.warn('Layer compression is unsupported, skipping layer "%s".',r.name);continue}k={name:r.name,x:r.x,y:r.y,width:r.width,height:r.height,widthInPixels:r.width*t.tilewidth,heightInPixels:r.height*t.tileheight,alpha:r.opacity,offsetX:r.offsetx,offsetY:r.offsety,visible:r.visible,properties:{},indexes:[],callbacks:[],bodies:[]};r.properties&&(k.properties=r.properties);for(var c,u,d,p=0,f=[],g=[],m=0,a=r.data.length;m<a;m++){if(c=0,u=!1,A=r.data[m],d=0,A>536870912)switch(A>2147483648&&(A-=2147483648,d+=4),A>1073741824&&(A-=1073741824,d+=2),A>536870912&&(A-=536870912,d+=1),d){case 5:c=Math.PI/2;break;case 6:c=Math.PI;break;case 3:c=3*Math.PI/2;break;case 4:c=0,u=!0;break;case 7:c=Math.PI/2,u=!0;break;case 2:c=Math.PI,u=!0;break;case 1:c=3*Math.PI/2,u=!0}A>0?((F=new e.Tile(k,A,p,g.length,t.tilewidth,t.tileheight)).rotation=c,F.flipped=u,0!==d&&(F.flippedVal=d),f.push(F)):e.TilemapParser.INSERT_NULL?f.push(null):f.push(new e.Tile(k,-1,p,g.length,t.tilewidth,t.tileheight)),++p===r.width&&(g.push(f),p=0,f=[])}k.data=g,s.push(k)}i.layers=s;for(var y=[],n=0;n<t.layers.length;n++)if("imagelayer"===t.layers[n].type){var v=t.layers[n],x={name:v.name,image:v.image,x:v.x,y:v.y,alpha:v.opacity,visible:v.visible,properties:{}};v.properties&&(x.properties=v.properties),y.push(x)}i.images=y;for(var b=[],_={},w=[],T=null,n=0;n<t.tilesets.length;n++){if((U=t.tilesets[n]).source)console.warn("Phaser CE can't load external tilesets (%s). Embed the tileset and then export the map again. https://github.com/photonstorm/phaser-ce/issues/273",U.source);else if(U.image){var P=new e.Tileset(U.name,U.firstgid,U.tilewidth,U.tileheight,U.margin,U.spacing,U.properties);U.tileproperties&&(P.tileProperties=U.tileproperties),P.updateTileData(U.imagewidth,U.imageheight),b.push(P)}else{if(!U.tiles)throw new Error("Tileset "+U.name+" has no `image` or `tiles` property.");var C=new e.ImageCollection(U.name,U.firstgid,U.tilewidth,U.tileheight,U.margin,U.spacing,U.properties);for(var S in U.tiles){var x=U.tiles[S].image,A=U.firstgid+parseInt(S,10);C.addImage(A,x)}w.push(C)}for(var S in U.tiles)(R=U.tiles[S].objectgroup)&&(_[parseInt(S,10)+U.firstgid]=R);T&&(T.lastgid=U.firstgid-1),T=U}if(0===b.length&&0===w.length)throw new Error("This tilemap has no tilesets.");i.tilesets=b,i.imagecollections=w;for(var E={},M={},n=0;n<t.layers.length;n++)if("objectgroup"===t.layers[n].type){var R=t.layers[n];this.parseObjectGroup(R,E,M)}i.objects=E,i.collision=M,i.tiles=[];for(n=0;n<i.tilesets.length;n++)for(var p=(U=i.tilesets[n]).tileMargin,L=U.tileMargin,B=0,I=0,O=0,m=U.firstgid;m<U.firstgid+U.total&&(i.tiles[m]=[p,L,n],p+=U.tileWidth+U.tileSpacing,++B!==U.total)&&(++I!==U.columns||(p=U.tileMargin,L+=U.tileHeight+U.tileSpacing,I=0,++O!==U.rows));m++);for(var k,F,D,U,n=0;n<i.layers.length;n++){M[(k=i.layers[n]).name]=[],U=null;for(l=0;l<k.data.length;l++){f=k.data[l];for(var G=0;G<f.length;G++)null===(F=f[G])||F.index<0||(D=i.tiles[F.index][2],(U=i.tilesets[D]).tileProperties&&U.tileProperties[F.index-U.firstgid]&&(F.properties=e.Utils.mixin(U.tileProperties[F.index-U.firstgid],F.properties)),(R=_[F.index])&&this.parseObjectGroup(R,i.objects,i.collision,F.layer.name,{x:F.worldX+R.x,y:F.worldY+R.y}))}}return i}},e.Tileset=function(t,e,i,s,n,r,o){(void 0===i||i<=0)&&(i=32),(void 0===s||s<=0)&&(s=32),void 0===n&&(n=0),void 0===r&&(r=0),this.name=t,this.firstgid=0|e,this.tileWidth=0|i,this.tileHeight=0|s,this.tileMargin=0|n,this.tileSpacing=0|r,this.properties=o||{},this.image=null,this.rows=0,this.columns=0,this.total=0,this.drawCoords=[]},e.Tileset.prototype={draw:function(t,e,i,s){var n=s-this.firstgid<<1;n>=0&&n+1<this.drawCoords.length&&t.drawImage(this.image,this.drawCoords[n],this.drawCoords[n+1],this.tileWidth,this.tileHeight,e,i,this.tileWidth,this.tileHeight)},containsTileIndex:function(t){return t>=this.firstgid&&t<this.firstgid+this.total},setImage:function(t){this.image=t,this.updateTileData(t.width,t.height)},setSpacing:function(t,e){this.tileMargin=0|t,this.tileSpacing=0|e,this.image&&this.updateTileData(this.image.width,this.image.height)},updateTileData:function(t,e){var i=(e-2*this.tileMargin+this.tileSpacing)/(this.tileHeight+this.tileSpacing),s=(t-2*this.tileMargin+this.tileSpacing)/(this.tileWidth+this.tileSpacing);i%1==0&&s%1==0||console.warn("Phaser.Tileset - '%s' image tile area (%s x %s) is not a whole multiple of tile size (%s x %s + %s + %s)",this.name,t,e,this.tileWidth,this.tileHeight,this.tileMargin,this.tileSpacing),i=Math.floor(i),s=Math.floor(s),(this.rows&&this.rows!==i||this.columns&&this.columns!==s)&&console.warn("Phaser.Tileset - Tile layout from image '%s' (%s rows by %s columns) differs from tileset '%s' (%s rows by %s columns)",this.image.name,s,i,this.name,this.columns,this.rows),this.rows=i,this.columns=s,this.total=i*s,this.drawCoords.length=0;for(var n=this.tileMargin,r=this.tileMargin,o=0;o<this.rows;o++){for(var a=0;a<this.columns;a++)this.drawCoords.push(n),this.drawCoords.push(r),n+=this.tileWidth+this.tileSpacing;n=this.tileMargin,r+=this.tileHeight+this.tileSpacing}}},e.Tileset.prototype.constructor=e.Tileset,e.Particle=function(t,i,s,n,r){e.Sprite.call(this,t,i,s,n,r),this.autoScale=!1,this.scaleData=null,this._s=0,this.autoAlpha=!1,this.alphaData=null,this._a=0},e.Particle.prototype=Object.create(e.Sprite.prototype),e.Particle.prototype.constructor=e.Particle,e.Particle.prototype.update=function(){this.autoScale&&(--this._s?this.scale.set(this.scaleData[this._s].x,this.scaleData[this._s].y):this.autoScale=!1),this.autoAlpha&&(--this._a?this.alpha=this.alphaData[this._a].v:this.autoAlpha=!1)},e.Particle.prototype.onEmit=function(){},e.Particle.prototype.setAlphaData=function(t){this.alphaData=t,this._a=t.length-1,this.alpha=this.alphaData[this._a].v,this.autoAlpha=!0},e.Particle.prototype.setScaleData=function(t){this.scaleData=t,this._s=t.length-1,this.scale.set(this.scaleData[this._s].x,this.scaleData[this._s].y),this.autoScale=!0},e.Particle.prototype.reset=function(t,i,s){return e.Component.Reset.prototype.reset.call(this,t,i,s),this.alpha=1,this.scale.set(1),this.autoScale=!1,this.autoAlpha=!1,this},e.Particles=function(t){this.game=t,this.emitters={},this.ID=0},e.Particles.prototype={add:function(t){return this.emitters[t.id]=t,t},remove:function(t){delete this.emitters[t.id]}},e.Particles.prototype.constructor=e.Particles,e.Particles.Arcade={},e.Particles.Arcade.Emitter=function(t,i,s,n){this.maxParticles=n||50,e.Group.call(this,t),this._id=this.game.particles.ID++,this.name="emitter"+this.id,this.type=e.EMITTER,this.physicsType=e.GROUP,this.area=new e.Rectangle(i,s,1,1),this.minAngle=null,this.maxAngle=null,this.minSpeed=0,this.maxSpeed=100,this.minParticleSpeed=new e.Point(-100,-100),this.maxParticleSpeed=new e.Point(100,100),this.minParticleScale=1,this.maxParticleScale=1,this.scaleData=null,this.minRotation=-360,this.maxRotation=360,this.minParticleAlpha=1,this.maxParticleAlpha=1,this.alphaData=null,this.particleClass=e.Particle,this.particleDrag=new e.Point,this.angularDrag=0,this.frequency=100,this.lifespan=2e3,this.bounce=new e.Point,this.on=!1,this.particleAnchor=new e.Point(.5,.5),this.blendMode=e.blendModes.NORMAL,this.emitX=i,this.emitY=s,this.autoScale=!1,this.autoAlpha=!1,this.particleBringToTop=!1,this.particleSendToBack=!1,this.counts={emitted:0,failed:0,totalEmitted:0,totalFailed:0},this._gravity=new e.Point(0,100),this._minParticleScale=new e.Point(1,1),this._maxParticleScale=new e.Point(1,1),this._total=0,this._timer=0,this._counter=0,this._flowQuantity=0,this._flowTotal=0,this._explode=!0,this._frames=null},e.Particles.Arcade.Emitter.prototype=Object.create(e.Group.prototype),e.Particles.Arcade.Emitter.prototype.constructor=e.Particles.Arcade.Emitter,e.Particles.Arcade.Emitter.prototype.update=function(){if(this.counts.emitted=0,this.counts.failed=0,this.on&&this.game.time.time>=this._timer)if(this._timer=this.game.time.time+this.frequency*this.game.time.slowMotion,0!==this._flowTotal)if(this._flowQuantity>0){for(t=0;t<this._flowQuantity;t++)if(this.emitParticle()&&(this._counter++,-1!==this._flowTotal&&this._counter>=this._flowTotal)){this.on=!1;break}}else this.emitParticle()&&(this._counter++,-1!==this._flowTotal&&this._counter>=this._flowTotal&&(this.on=!1));else this.emitParticle()&&(this._counter++,this._total>0&&this._counter>=this._total&&(this.on=!1));for(var t=this.children.length;t--;)this.children[t].exists&&this.children[t].update()},e.Particles.Arcade.Emitter.prototype.makeParticles=function(t,e,i,s,n,r){void 0===e&&(e=0),void 0===i&&(i=this.maxParticles),void 0===s&&(s=!1),void 0===n&&(n=!1),void 0===r&&(r=null);var o,a=0,h=t,l=e;for(this._frames=e,i>this.maxParticles&&(this.maxParticles=i);a<i;)Array.isArray(t)&&(h=this.game.rnd.pick(t)),Array.isArray(e)&&(l=this.game.rnd.pick(e)),o=new this.particleClass(this.game,0,0,h,l,r),this.game.physics.arcade.enable(o,!1),o.body.checkCollision.none=!s,o.body.collideWorldBounds=n,o.body.skipQuadTree=!0,o.exists=!1,o.visible=!1,o.anchor.copyFrom(this.particleAnchor),this.add(o),a++;return this},e.Particles.Arcade.Emitter.prototype.kill=function(){return this.on=!1,this.alive=!1,this.exists=!1,this},e.Particles.Arcade.Emitter.prototype.revive=function(){return this.alive=!0,this.exists=!0,this},e.Particles.Arcade.Emitter.prototype.explode=function(t,e){return void 0===e&&(e=this.maxParticles),this._flowTotal=0,this.start(!0,t,0,e,!1),this},e.Particles.Arcade.Emitter.prototype.flow=function(t,e,i,s,n){return void 0!==e&&null!==e||(e=250),void 0!==i&&0!==i||(i=1),void 0===s&&(s=-1),void 0===n&&(n=!0),i>this.maxParticles&&(i=this.maxParticles),this._counter=0,this._flowQuantity=i,this._flowTotal=s,n?(this.start(!0,t,e,i),this._counter+=i,this.on=!0,this._timer=this.game.time.time+e*this.game.time.slowMotion):this.start(!1,t,e,i),this},e.Particles.Arcade.Emitter.prototype.start=function(t,e,i,s,n){if(void 0===t&&(t=!0),void 0===e&&(e=0),void 0!==i&&null!==i||(i=250),void 0===s&&(s=0),void 0===n&&(n=!1),s>this.maxParticles&&(s=this.maxParticles),this.revive(),this.visible=!0,this.lifespan=e,this.frequency=i,t||n)for(var r=0;r<s;r++)this.emitParticle();else this.on=!0,this._total=s,this._counter=0,this._timer=this.game.time.time+i*this.game.time.slowMotion;return this},e.Particles.Arcade.Emitter.prototype.emitParticle=function(t,e,i,s){void 0===t&&(t=null),void 0===e&&(e=null);var n=this.getNextParticle();if(null===n)return this.counts.failed++,this.counts.totalFailed++,!1;this.counts.emitted++,this.counts.totalEmitted++;var r=this.game.rnd;void 0!==i&&void 0!==s?n.loadTexture(i,s):void 0!==i&&(n.loadTexture(i),n.frame=Array.isArray(this._frames)?r.pick(this._frames):this._frames);var o=this.emitX,a=this.emitY;return null!==t?o=t:this.width>1&&(o=r.between(this.left,this.right)),null!==e?a=e:this.height>1&&(a=r.between(this.top,this.bottom)),this.resetParticle(n,o,a),!0},e.Particles.Arcade.Emitter.prototype.getNextParticle=function(){for(var t=this.length;t--;){var e=this.next();if(!e.exists)return e}return null},e.Particles.Arcade.Emitter.prototype.resetParticle=function(t,e,i){var s=this.game.rnd;t.reset(e,i),t.angle=0,t.lifespan=this.lifespan,this.particleBringToTop?this.bringToTop(t):this.particleSendToBack&&this.sendToBack(t),this.autoScale?t.setScaleData(this.scaleData):1!==this.minParticleScale||1!==this.maxParticleScale?t.scale.set(s.realInRange(this.minParticleScale,this.maxParticleScale)):this._minParticleScale.x!==this._maxParticleScale.x||this._minParticleScale.y!==this._maxParticleScale.y?t.scale.set(s.realInRange(this._minParticleScale.x,this._maxParticleScale.x),s.realInRange(this._minParticleScale.y,this._maxParticleScale.y)):t.scale.set(this._minParticleScale.x,this._minParticleScale.y),this.autoAlpha?t.setAlphaData(this.alphaData):t.alpha=s.realInRange(this.minParticleAlpha,this.maxParticleAlpha),t.blendMode=this.blendMode;var n=t.body;n.updateBounds(),n.bounce.copyFrom(this.bounce),n.drag.copyFrom(this.particleDrag),null!=this.minAngle&&null!=this.maxAngle?this.game.physics.arcade.velocityFromAngle(this.minAngle===this.maxAngle?this.minAngle:s.between(this.minAngle,this.maxAngle),this.minSpeed===this.maxSpeed?this.minSpeed:s.between(this.minSpeed,this.maxSpeed),n.velocity):(n.velocity.x=s.between(this.minParticleSpeed.x,this.maxParticleSpeed.x),n.velocity.y=s.between(this.minParticleSpeed.y,this.maxParticleSpeed.y)),n.angularVelocity=s.between(this.minRotation,this.maxRotation),n.gravity.copyFrom(this.gravity),n.angularDrag=this.angularDrag,t.onEmit()},e.Particles.Arcade.Emitter.prototype.destroy=function(){this.game.particles.remove(this),e.Group.prototype.destroy.call(this,!0,!1)},e.Particles.Arcade.Emitter.prototype.setSize=function(t,e){return this.area.width=t,this.area.height=e,this},e.Particles.Arcade.Emitter.prototype.setXSpeed=function(t,e){return t=t||0,e=e||0,this.minParticleSpeed.x=t,this.maxParticleSpeed.x=e,this},e.Particles.Arcade.Emitter.prototype.setYSpeed=function(t,e){return t=t||0,e=e||0,this.minParticleSpeed.y=t,this.maxParticleSpeed.y=e,this},e.Particles.Arcade.Emitter.prototype.setRotation=function(t,e){return t=t||0,e=e||0,this.minRotation=t,this.maxRotation=e,this},e.Particles.Arcade.Emitter.prototype.setAlpha=function(t,i,s,n,r){if(void 0===t&&(t=1),void 0===i&&(i=1),void 0===s&&(s=0),void 0===n&&(n=e.Easing.Linear.None),void 0===r&&(r=!1),this.minParticleAlpha=t,this.maxParticleAlpha=i,this.autoAlpha=!1,s>0&&t!==i){var o={v:t},a=this.game.make.tween(o).to({v:i},s,n);a.yoyo(r),this.alphaData=a.generateData(60),this.alphaData.reverse(),this.autoAlpha=!0}return this},e.Particles.Arcade.Emitter.prototype.setScale=function(t,i,s,n,r,o,a){if(void 0===t&&(t=1),void 0===i&&(i=1),void 0===s&&(s=1),void 0===n&&(n=1),void 0===r&&(r=0),void 0===o&&(o=e.Easing.Linear.None),void 0===a&&(a=!1),this.minParticleScale=1,this.maxParticleScale=1,this._minParticleScale.set(t,s),this._maxParticleScale.set(i,n),this.autoScale=!1,r>0&&(t!==i||s!==n)){var h={x:t,y:s},l=this.game.make.tween(h).to({x:i,y:n},r,o);l.yoyo(a),this.scaleData=l.generateData(60),this.scaleData.reverse(),this.autoScale=!0}return this},e.Particles.Arcade.Emitter.prototype.setAngle=function(t,e,i,s){return this.minAngle=t,this.maxAngle=e,null!=i&&(this.minSpeed=i),null!=s&&(this.maxSpeed=s),this},e.Particles.Arcade.Emitter.prototype.at=function(t){return t.center?(this.emitX=t.center.x,this.emitY=t.center.y):(this.emitX=t.world.x+t.anchor.x*t.width,this.emitY=t.world.y+t.anchor.y*t.height),this},Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"gravity",{get:function(){return this._gravity},set:function(t){"number"==typeof t?this._gravity.y=t:this._gravity=t}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"id",{get:function(){return this._id}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"width",{get:function(){return this.area.width},set:function(t){this.area.width=t}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"height",{get:function(){return this.area.height},set:function(t){this.area.height=t}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"x",{get:function(){return this.emitX},set:function(t){this.emitX=t}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"y",{get:function(){return this.emitY},set:function(t){this.emitY=t}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"left",{get:function(){return Math.floor(this.x-this.area.width/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"right",{get:function(){return Math.floor(this.x+this.area.width/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"top",{get:function(){return Math.floor(this.y-this.area.height/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"bottom",{get:function(){return Math.floor(this.y+this.area.height/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"output",{get:function(){return 1e3*this._flowQuantity/this.frequency}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"lifespanOutput",{get:function(){return(0===this.lifespan?1/0:this.lifespan)*this._flowQuantity/this.frequency}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"remainder",{get:function(){return this.maxParticles-this.lifespanOutput}}),e.Weapon=function(t,i){e.Plugin.call(this,t,i),this.bullets=null,this.autoExpandBulletsGroup=!1,this.autofire=!1,this.shots=0,this.fireLimit=0,this.fireRate=100,this.fireRateVariance=0,this.fireFrom=new e.Rectangle(0,0,1,1),this.fireAngle=e.ANGLE_UP,this.bulletInheritSpriteSpeed=!1,this.bulletAnimation="",this.bulletFrameRandom=!1,this.bulletFrameCycle=!1,this.bulletWorldWrap=!1,this.bulletWorldWrapPadding=0,this.bulletAngleOffset=0,this.bulletAngleVariance=0,this.bulletSpeed=200,this.bulletSpeedVariance=0,this.bulletLifespan=0,this.bulletKillDistance=0,this.bulletGravity=new e.Point(0,0),this.bulletRotateToVelocity=!1,this.bulletKey="",this.bulletFrame="",this._bulletClass=e.Bullet,this._bulletCollideWorldBounds=!1,this._bulletKillType=e.Weapon.KILL_WORLD_BOUNDS,this._data={customBody:!1,width:0,height:0,offsetX:0,offsetY:0},this.bounds=new e.Rectangle,this.bulletBounds=t.world.bounds,this.bulletFrames=[],this.bulletFrameIndex=0,this.anims={},this.onFire=new e.Signal,this.onKill=new e.Signal,this.onFireLimit=new e.Signal,this.trackedSprite=null,this.trackedPointer=null,this.multiFire=!1,this._hasFired=!1,this.trackRotation=!1,this.trackOffset=new e.Point,this._nextFire=0,this._tempNextFire=0,this._rotatedPoint=new e.Point},e.Weapon.prototype=Object.create(e.Plugin.prototype),e.Weapon.prototype.constructor=e.Weapon,e.Weapon.KILL_NEVER=0,e.Weapon.KILL_LIFESPAN=1,e.Weapon.KILL_DISTANCE=2,e.Weapon.KILL_WEAPON_BOUNDS=3,e.Weapon.KILL_CAMERA_BOUNDS=4,e.Weapon.KILL_WORLD_BOUNDS=5,e.Weapon.KILL_STATIC_BOUNDS=6,e.Weapon.prototype.createBullets=function(t,i,s,n){return void 0===t&&(t=1),void 0===n&&(n=this.game.world),this.bullets&&!this.bullets.game&&(this.bullets=null),this.bullets||(this.bullets=this.game.add.physicsGroup(e.Physics.ARCADE,n),this.bullets.classType=this._bulletClass),0!==t&&(-1===t&&(this.autoExpandBulletsGroup=!0,t=1),this.bullets.createMultiple(t,i,s),this.bullets.setAll("data.bulletManager",this),this.bulletKey=i,this.bulletFrame=s),this},e.Weapon.prototype.forEach=function(t,e){return this.bullets.forEachExists(t,e,arguments),this},e.Weapon.prototype.pauseAll=function(){return this.bullets.setAll("body.enable",!1),this},e.Weapon.prototype.resumeAll=function(){return this.bullets.setAll("body.enable",!0),this},e.Weapon.prototype.killAll=function(){return this.bullets.callAllExists("kill",!0),this.bullets.setAll("body.enable",!0),this},e.Weapon.prototype.resetShots=function(t){return this.shots=0,void 0!==t&&(this.fireLimit=t),this},e.Weapon.prototype.destroy=function(){this.parent.remove(this,!1),this.bullets.destroy(),this.game=null,this.parent=null,this.active=!1,this.visible=!1},e.Weapon.prototype.update=function(){this._bulletKillType===e.Weapon.KILL_WEAPON_BOUNDS&&(this.trackedSprite?(this.trackedSprite.updateTransform(),this.bounds.centerOn(this.trackedSprite.worldPosition.x,this.trackedSprite.worldPosition.y)):this.trackedPointer&&this.bounds.centerOn(this.trackedPointer.worldX,this.trackedPointer.worldY)),this.autofire&&this.fire()},e.Weapon.prototype.postRender=function(){this.multiFire&&this._hasFired&&(this._hasFired=!1,this._nextFire=this._tempNextFire)},e.Weapon.prototype.trackSprite=function(t,e,i,s){return void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=!1),this.trackedPointer=null,this.trackedSprite=t,this.trackRotation=s,this.trackOffset.set(e,i),this},e.Weapon.prototype.trackPointer=function(t,e,i){return void 0===t&&(t=this.game.input.activePointer),void 0===e&&(e=0),void 0===i&&(i=0),this.trackedPointer=t,this.trackedSprite=null,this.trackRotation=!1,this.trackOffset.set(e,i),this},e.Weapon.prototype.fireMany=function(t,e){this.multiFire=!0;var i=[],s=this;return e||this.trackedSprite||this.trackedPointer?t.forEach(function(t){i.push(s.fire(e,null,null,t.x,t.y))}):t.forEach(function(t){i.push(s.fire(t))}),i},e.Weapon.prototype.fireOffset=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.fire(null,null,null,t,e)},e.Weapon.prototype.fire=function(t,i,s,n,r){if(void 0===i&&(i=null),void 0===s&&(s=null),this.game.time.now<this._nextFire||this.fireLimit>0&&this.shots===this.fireLimit)return null;var o=this.bulletSpeed;0!==this.bulletSpeedVariance&&(o+=e.Math.between(-this.bulletSpeedVariance,this.bulletSpeedVariance)),t?this.fireFrom.width>1?this.fireFrom.centerOn(t.x,t.y):(this.fireFrom.x=t.x,this.fireFrom.y=t.y):this.trackedSprite?(this.trackRotation?(this._rotatedPoint.set(this.trackedSprite.world.x+this.trackOffset.x,this.trackedSprite.world.y+this.trackOffset.y),this._rotatedPoint.rotate(this.trackedSprite.world.x,this.trackedSprite.world.y,this.trackedSprite.worldRotation),this.fireFrom.width>1?this.fireFrom.centerOn(this._rotatedPoint.x,this._rotatedPoint.y):(this.fireFrom.x=this._rotatedPoint.x,this.fireFrom.y=this._rotatedPoint.y)):this.fireFrom.width>1?this.fireFrom.centerOn(this.trackedSprite.world.x+this.trackOffset.x,this.trackedSprite.world.y+this.trackOffset.y):(this.fireFrom.x=this.trackedSprite.world.x+this.trackOffset.x,this.fireFrom.y=this.trackedSprite.world.y+this.trackOffset.y),this.bulletInheritSpriteSpeed&&(o+=this.trackedSprite.body.speed)):this.trackedPointer&&(this.fireFrom.width>1?this.fireFrom.centerOn(this.trackedPointer.world.x+this.trackOffset.x,this.trackedPointer.world.y+this.trackOffset.y):(this.fireFrom.x=this.trackedPointer.world.x+this.trackOffset.x,this.fireFrom.y=this.trackedPointer.world.y+this.trackOffset.y)),void 0!==n&&(this.fireFrom.x+=n),void 0!==r&&(this.fireFrom.y+=r);var a=this.fireFrom.width>1?this.fireFrom.randomX:this.fireFrom.x,h=this.fireFrom.height>1?this.fireFrom.randomY:this.fireFrom.y,l=this.trackRotation?this.trackedSprite.angle:this.fireAngle;null!==i&&null!==s&&(l=this.game.math.radToDeg(Math.atan2(s-h,i-a))),0!==this.bulletAngleVariance&&(l+=e.Math.between(-this.bulletAngleVariance,this.bulletAngleVariance));var c=0,u=0;0===l||180===l?c=Math.cos(this.game.math.degToRad(l))*o:90===l||270===l?u=Math.sin(this.game.math.degToRad(l))*o:(c=Math.cos(this.game.math.degToRad(l))*o,u=Math.sin(this.game.math.degToRad(l))*o);var d=null;if(this.autoExpandBulletsGroup?(d=this.bullets.getFirstExists(!1,!0,a,h,this.bulletKey,this.bulletFrame)).data.bulletManager=this:d=this.bullets.getFirstExists(!1),d){if(d.reset(a,h),d.data.fromX=a,d.data.fromY=h,d.data.killType=this.bulletKillType,d.data.killDistance=this.bulletKillDistance,d.data.rotateToVelocity=this.bulletRotateToVelocity,this.bulletKillType===e.Weapon.KILL_LIFESPAN&&(d.lifespan=this.bulletLifespan),d.angle=l+this.bulletAngleOffset,""!==this.bulletAnimation){if(null===d.animations.getAnimation(this.bulletAnimation)){var p=this.anims[this.bulletAnimation];d.animations.add(p.name,p.frames,p.frameRate,p.loop,p.useNumericIndex)}d.animations.play(this.bulletAnimation)}else this.bulletFrameCycle?(d.frame=this.bulletFrames[this.bulletFrameIndex],++this.bulletFrameIndex>=this.bulletFrames.length&&(this.bulletFrameIndex=0)):this.bulletFrameRandom&&(d.frame=this.bulletFrames[Math.floor(Math.random()*this.bulletFrames.length)]);d.data.bodyDirty&&(this._data.customBody&&d.body.setSize(this._data.width,this._data.height,this._data.offsetX,this._data.offsetY),d.body.collideWorldBounds=this.bulletCollideWorldBounds,d.data.bodyDirty=!1),d.body.velocity.set(c,u),d.body.gravity.set(this.bulletGravity.x,this.bulletGravity.y);var f=0;if(0!==this.bulletSpeedVariance){var g=this.fireRate;(g+=e.Math.between(-this.fireRateVariance,this.fireRateVariance))<0&&(g=0),f=this.game.time.now+g}else f=this.game.time.now+this.fireRate;this.multiFire?this._hasFired||(this._hasFired=!0,this._tempNextFire=f,this.shots++):(this._nextFire=f,this.shots++),this.onFire.dispatch(d,this,o),this.fireLimit>0&&this.shots===this.fireLimit&&this.onFireLimit.dispatch(this,this.fireLimit)}return d},e.Weapon.prototype.fireAtPointer=function(t){return void 0===t&&(t=this.game.input.activePointer),this.fire(null,t.worldX,t.worldY)},e.Weapon.prototype.fireAtSprite=function(t){return this.fire(null,t.world.x,t.world.y)},e.Weapon.prototype.fireAtXY=function(t,e){return this.fire(null,t,e)},e.Weapon.prototype.setBulletBodyOffset=function(t,e,i,s){return void 0===i&&(i=0),void 0===s&&(s=0),this._data.customBody=!0,this._data.width=t,this._data.height=e,this._data.offsetX=i,this._data.offsetY=s,this.bullets.callAll("body.setSize","body",t,e,i,s),this.bullets.setAll("data.bodyDirty",!1),this},e.Weapon.prototype.setBulletFrames=function(t,i,s,n){return void 0===s&&(s=!0),void 0===n&&(n=!1),this.bulletFrames=e.ArrayUtils.numberArray(t,i),this.bulletFrameIndex=0,this.bulletFrameCycle=s,this.bulletFrameRandom=n,this},e.Weapon.prototype.addBulletAnimation=function(t,e,i,s,n){return this.anims[t]={name:t,frames:e,frameRate:i,loop:s,useNumericIndex:n},this.bullets.callAll("animations.add","animations",t,e,i,s,n),this.bulletAnimation=t,this},e.Weapon.prototype.debug=function(t,e,i){void 0===t&&(t=16),void 0===e&&(e=32),void 0===i&&(i=!1),this.game.debug.text("Weapon Plugin",t,e),this.game.debug.text("Bullets Alive: "+this.bullets.total+" - Total: "+this.bullets.length,t,e+24),i&&this.bullets.forEachExists(this.game.debug.body,this.game.debug,"rgba(255, 0, 255, 0.8)")},Object.defineProperty(e.Weapon.prototype,"bulletClass",{get:function(){return this._bulletClass},set:function(t){this._bulletClass=t,this.bullets&&(this.bullets.classType=this._bulletClass)}}),Object.defineProperty(e.Weapon.prototype,"bulletKillType",{get:function(){return this._bulletKillType},set:function(t){switch(t){case e.Weapon.KILL_STATIC_BOUNDS:case e.Weapon.KILL_WEAPON_BOUNDS:this.bulletBounds=this.bounds;break;case e.Weapon.KILL_CAMERA_BOUNDS:this.bulletBounds=this.game.camera.view;break;case e.Weapon.KILL_WORLD_BOUNDS:this.bulletBounds=this.game.world.bounds}this._bulletKillType=t}}),Object.defineProperty(e.Weapon.prototype,"bulletCollideWorldBounds",{get:function(){return this._bulletCollideWorldBounds},set:function(t){this._bulletCollideWorldBounds=t,this.bullets.setAll("body.collideWorldBounds",t),this.bullets.setAll("data.bodyDirty",!1)}}),Object.defineProperty(e.Weapon.prototype,"x",{get:function(){return this.fireFrom.x},set:function(t){this.fireFrom.x=t}}),Object.defineProperty(e.Weapon.prototype,"y",{get:function(){return this.fireFrom.y},set:function(t){this.fireFrom.y=t}}),e.Bullet=function(t,i,s,n,r){e.Sprite.call(this,t,i,s,n,r),this.anchor.set(.5),this.data={bulletManager:null,fromX:0,fromY:0,bodyDirty:!0,rotateToVelocity:!1,killType:0,killDistance:0}},e.Bullet.prototype=Object.create(e.Sprite.prototype),e.Bullet.prototype.constructor=e.Bullet,e.Bullet.prototype.kill=function(){return this.alive=!1,this.exists=!1,this.visible=!1,this.data.bulletManager.onKill.dispatch(this),this},e.Bullet.prototype.update=function(){this.exists&&(this.data.killType>e.Weapon.KILL_LIFESPAN&&(this.data.killType===e.Weapon.KILL_DISTANCE?this.game.physics.arcade.distanceToXY(this,this.data.fromX,this.data.fromY,!0)>this.data.killDistance&&this.kill():this.data.bulletManager.bulletBounds.intersects(this)||this.kill()),this.data.rotateToVelocity&&(this.rotation=this.body.velocity.atan()),this.data.bulletManager.bulletWorldWrap&&this.game.world.wrap(this,this.data.bulletManager.bulletWorldWrapPadding))},e.Video=function(t,i,s){if(void 0===i&&(i=null),void 0===s&&(s=null),this.game=t,this.key=i,this.width=0,this.height=0,this.type=e.VIDEO,this.disableTextureUpload=!1,this.touchLocked=!1,this.onPlay=new e.Signal,this.onChangeSource=new e.Signal,this.onComplete=new e.Signal,this.onAccess=new e.Signal,this.onError=new e.Signal,this.onTimeout=new e.Signal,this.onTouchUnlock=new e.Signal,this.playWhenUnlocked=!0,this.timeout=15e3,this._timeOutID=null,this.video=null,this.videoStream=null,this.isStreaming=!1,this.retryLimit=20,this.retry=0,this.retryInterval=500,this._retryID=null,this._codeMuted=!1,this._muted=!1,this._codePaused=!1,this._paused=!1,this._pending=!1,this._pendingChangeSource=!1,this._autoplay=!1,this._endCallback=null,this._playCallback=null,i&&this.game.cache.checkVideoKey(i)){var n=this.game.cache.getVideo(i);n.isBlob?this.createVideoFromBlob(n.data):this.video=n.data,this.width=this.video.videoWidth,this.height=this.video.videoHeight}else s&&this.createVideoFromURL(s,!1);this.video&&!s?(this.baseTexture=new PIXI.BaseTexture(this.video,null,this.game.resolution),this.baseTexture.forceLoaded(this.width,this.height)):(this.baseTexture=new PIXI.BaseTexture(e.Cache.DEFAULT.baseTexture.source,null,this.game.resolution),this.baseTexture.forceLoaded(this.width,this.height)),this.texture=new PIXI.Texture(this.baseTexture),this.textureFrame=new e.Frame(0,0,0,this.width,this.height,"video"),this.texture.setFrame(this.textureFrame),this.texture.valid=!1,null!==i&&this.video&&(this.texture.valid=this.video.canplay),this.snapshot=null,e.BitmapData&&(this.snapshot=new e.BitmapData(this.game,"",this.width,this.height)),this.game.device.needsTouchUnlock()?this.setTouchLock():n&&(n.locked=!1)},e.Video.prototype={connectToMediaStream:function(t,e){return t&&e&&(this.video=t,this.videoStream=e,this.isStreaming=!0,this.baseTexture.source=this.video,this.updateTexture(null,this.video.videoWidth,this.video.videoHeight),this.onAccess.dispatch(this)),this},startMediaStream:function(t,e,i){if(void 0===t&&(t=!1),void 0===e&&(e=null),void 0===i&&(i=null),!this.game.device.getUserMedia)return this.onError.dispatch(this,"No getUserMedia"),!1;null!==this.videoStream&&(this.videoStream.active?this.videoStream.active=!1:this.videoStream.stop()),this.removeVideoElement(),this.video=document.createElement("video"),this.video.setAttribute("autoplay","autoplay"),this.video.setAttribute("playsinline","playsinline"),null!==e&&(this.video.width=e),null!==i&&(this.video.height=i),this._timeOutID=window.setTimeout(this.getUserMediaTimeout.bind(this),this.timeout);try{navigator.getUserMedia({audio:t,video:!0},this.getUserMediaSuccess.bind(this),this.getUserMediaError.bind(this))}catch(t){this.getUserMediaError(t)}return this},getUserMediaTimeout:function(){clearTimeout(this._timeOutID),this.onTimeout.dispatch(this)},getUserMediaError:function(t){clearTimeout(this._timeOutID),this.onError.dispatch(this,t)},getUserMediaSuccess:function(t){clearTimeout(this._timeOutID),this.videoStream=t,void 0!==this.video.mozSrcObject?this.video.mozSrcObject=t:void 0!==this.video.srcObject?this.video.srcObject=t:this.video.src=window.URL&&window.URL.createObjectURL(t)||t;var e=this;this.video.onloadeddata=function(){function t(){if(i>0)if(e.video.videoWidth>0){var s=e.video.videoWidth,n=e.video.videoHeight;isNaN(e.video.videoHeight)&&(n=s/(4/3)),e.video.play(),e.isStreaming=!0,e.baseTexture.source=e.video,e.updateTexture(null,s,n),e.onAccess.dispatch(e)}else window.setTimeout(t,500);else console.warn("Unable to connect to video stream. Webcam error?");i--}var i=10;t()}},createVideoFromBlob:function(t){var e=this;return this.video=document.createElement("video"),this.video.controls=!1,this.video.setAttribute("autoplay","autoplay"),this.video.setAttribute("playsinline","playsinline"),this.video.addEventListener("loadeddata",function(t){e.updateTexture(t)},!0),this.video.src=window.URL.createObjectURL(t),this.video.canplay=!0,this},createVideoFromURL:function(t,e){return void 0===e&&(e=!1),this.texture&&(this.texture.valid=!1),this.video=document.createElement("video"),this.video.controls=!1,e&&this.video.setAttribute("autoplay","autoplay"),this.video.setAttribute("playsinline","playsinline"),this.video.src=t,this.video.canplay=!0,this.video.load(),this.retry=this.retryLimit,this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval),this.key=t,this},updateTexture:function(t,e,i){var s=!1;void 0!==e&&null!==e||(e=this.video.videoWidth,s=!0),void 0!==i&&null!==i||(i=this.video.videoHeight),this.width=e,this.height=i,this.baseTexture.source!==this.video&&(this.baseTexture.source=this.video),this.baseTexture.forceLoaded(e,i),this.texture.frame.resize(e,i),this.texture.width=e,this.texture.height=i,this.texture.valid=!0,this.snapshot&&this.snapshot.resize(e,i),s&&null!==this.key&&(this.onChangeSource.dispatch(this,e,i),this._autoplay&&(this.video.play(),this.onPlay.dispatch(this,this.loop,this.playbackRate)))},complete:function(){this.onComplete.dispatch(this)},play:function(t,e){return this._pendingChangeSource?this:(void 0===t&&(t=!1),void 0===e&&(e=1),this.game.sound.onMute&&(this.game.sound.onMute.add(this.setMute,this),this.game.sound.onUnMute.add(this.unsetMute,this),this.game.sound.mute&&this.setMute()),this.game.onPause.add(this.setPause,this),this.game.onResume.add(this.setResume,this),this._endCallback=this.complete.bind(this),this.video.addEventListener("ended",this._endCallback,!0),this.video.addEventListener("webkitendfullscreen",this._endCallback,!0),this.video.loop=t?"loop":"",this.video.playbackRate=e,this.touchLocked?this._pending=!0:(this._pending=!1,null!==this.key&&(4!==this.video.readyState?(this.retry=this.retryLimit,this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval)):(this._playCallback=this.playHandler.bind(this),this.video.addEventListener("playing",this._playCallback,!0))),this.video.play(),this.onPlay.dispatch(this,t,e)),this)},playHandler:function(){this.video.removeEventListener("playing",this._playCallback,!0),this.updateTexture()},stop:function(){return this.game.sound.onMute&&(this.game.sound.onMute.remove(this.setMute,this),this.game.sound.onUnMute.remove(this.unsetMute,this)),this.game.onPause.remove(this.setPause,this),this.game.onResume.remove(this.setResume,this),this.isStreaming?(this.video.mozSrcObject?(this.video.mozSrcObject.stop(),this.video.src=null):this.video.srcObject?(this.video.srcObject.stop(),this.video.src=null):(this.video.src="",this.videoStream.active?this.videoStream.active=!1:this.videoStream.getTracks?this.videoStream.getTracks().forEach(function(t){t.stop()}):this.videoStream.stop()),this.videoStream=null,this.isStreaming=!1):(this.video.removeEventListener("ended",this._endCallback,!0),this.video.removeEventListener("webkitendfullscreen",this._endCallback,!0),this.video.removeEventListener("playing",this._playCallback,!0),this.touchLocked?this._pending=!1:this.video.pause()),this},add:function(t){if(Array.isArray(t))for(var e=0;e<t.length;e++)t[e].loadTexture&&t[e].loadTexture(this);else t.loadTexture(this);return this},addToWorld:function(t,e,i,s,n,r){n=n||1,r=r||1;var o=this.game.add.image(t,e,this);return o.anchor.set(i,s),o.scale.set(n,r),o},render:function(){!this.disableTextureUpload&&this.playing&&this.baseTexture.dirty()},setMute:function(){this._muted||(this._muted=!0,this.video.muted=!0)},unsetMute:function(){this._muted&&!this._codeMuted&&(this._muted=!1,this.video.muted=!1)},setPause:function(){this._paused||this.touchLocked||(this._paused=!0,this.video.pause())},setResume:function(){!this._paused||this._codePaused||this.touchLocked||(this._paused=!1,this.video.ended||this.video.play())},changeSource:function(t,e){return void 0===e&&(e=!0),this.texture.valid=!1,this.video.pause(),this._pendingChangeSource=!0,this.retry=this.retryLimit,this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval),this.video.src=t,this.video.load(),this._autoplay=e,e||(this.paused=!0),this},checkVideoProgress:function(){4===this.video.readyState?(this._pendingChangeSource=!1,this.updateTexture()):--this.retry>0?this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval):console.warn("Phaser.Video: Unable to start downloading video in time",this.isStreaming)},setTouchLock:function(){this.game.input.addTouchLockCallback(this.unlock,this,!0),this.touchLocked=!0},unlock:function(){if(this.touchLocked=!1,this.playWhenUnlocked&&(this.video.play(),this.onPlay.dispatch(this,this.loop,this.playbackRate)),this.key){var t=this.game.cache.getVideo(this.key);t&&!t.isBlob&&(t.locked=!1)}return this.onTouchUnlock.dispatch(this),!0},grab:function(t,e,i){if(void 0===t&&(t=!1),void 0===e&&(e=1),void 0===i&&(i=null),null!==this.snapshot)return t&&this.snapshot.cls(),this.snapshot.copy(this.video,0,0,this.width,this.height,0,0,this.width,this.height,0,0,0,1,1,e,i),this.snapshot;console.warn("Video.grab cannot run because Phaser.BitmapData is unavailable")},removeVideoElement:function(){if(this.video){for(this.video.parentNode&&this.video.parentNode.removeChild(this.video);this.video.hasChildNodes();)this.video.removeChild(this.video.firstChild);this.video.removeAttribute("autoplay"),this.video.removeAttribute("src"),this.video=null}},destroy:function(){this.stop(),this.removeVideoElement(),this.touchLocked&&this.game.input.removeTouchLockCallback(this.unlock,this),this._retryID&&window.clearTimeout(this._retryID)}},Object.defineProperty(e.Video.prototype,"currentTime",{get:function(){return this.video?this.video.currentTime:0},set:function(t){this.video.currentTime=t}}),Object.defineProperty(e.Video.prototype,"duration",{get:function(){return this.video?this.video.duration:0}}),Object.defineProperty(e.Video.prototype,"progress",{get:function(){return this.video?this.video.currentTime/this.video.duration:0}}),Object.defineProperty(e.Video.prototype,"mute",{get:function(){return this._muted},set:function(t){if(t=t||null){if(this._muted)return;this._codeMuted=!0,this.setMute()}else{if(!this._muted)return;this._codeMuted=!1,this.unsetMute()}}}),Object.defineProperty(e.Video.prototype,"paused",{get:function(){return this._paused},set:function(t){if(t=t||null,!this.touchLocked)if(t){if(this._paused)return;this._codePaused=!0,this.setPause()}else{if(!this._paused)return;this._codePaused=!1,this.setResume()}}}),Object.defineProperty(e.Video.prototype,"volume",{get:function(){return this.video?this.video.volume:1},set:function(t){t<0?t=0:t>1&&(t=1),this.video&&(this.video.volume=t)}}),Object.defineProperty(e.Video.prototype,"playbackRate",{get:function(){return this.video?this.video.playbackRate:1},set:function(t){this.video&&(this.video.playbackRate=t)}}),Object.defineProperty(e.Video.prototype,"loop",{get:function(){return!!this.video&&this.video.loop},set:function(t){t&&this.video?this.video.loop="loop":this.video&&(this.video.loop="")}}),Object.defineProperty(e.Video.prototype,"playing",{get:function(){return!!this.video&&!(this.video.paused&&this.video.ended)}}),e.Video.prototype.constructor=e.Video,void 0===PIXI.blendModes&&(PIXI.blendModes=e.blendModes),void 0===PIXI.scaleModes&&(PIXI.scaleModes=e.scaleModes),void 0===PIXI.Texture.emptyTexture&&(PIXI.Texture.emptyTexture=new PIXI.Texture(new PIXI.BaseTexture)),void 0===PIXI.DisplayObject._tempMatrix&&(PIXI.DisplayObject._tempMatrix=new e.Matrix),PIXI.TextureSilentFail=!0,PIXI.canUseNewCanvasBlendModes=function(){return e.Device.canUseMultiply},"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=e),exports.Phaser=e):"undefined"!=typeof define&&define.amd?define("Phaser",t.Phaser=e):t.Phaser=e,e}.call(this); +//# sourceMappingURL=phaser.map \ No newline at end of file diff --git a/harkka3/samson/rock-tile.tsx b/harkka3/samson/rock-tile.tsx new file mode 100644 index 0000000000000000000000000000000000000000..ef7190d2b023c0ed5b305a7988a260ee959a484f --- /dev/null +++ b/harkka3/samson/rock-tile.tsx @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<tileset version="1.2" tiledversion="1.3.2" name="rock-tile" tilewidth="32" tileheight="32" tilecount="9" columns="3"> + <image source="assets/tilemaps/rock-tile.png" width="96" height="96"/> +</tileset> diff --git a/harkka3/samson/state0.js b/harkka3/samson/state0.js index ebe99371bf6f2d80e79b30dedc3057c11bd6fc01..98def5629b93b62cb6e9dad3209f8881c5382fd4 100644 --- a/harkka3/samson/state0.js +++ b/harkka3/samson/state0.js @@ -8,7 +8,6 @@ demo.state0.prototype = { create: function(){ game.physics.startSystem(Phaser.Physics.ARCADE); game.stage.backgroundColor = '#ffcccc'; - console.log('state0'); addChangeStateEventListeners(); game.world.setBounds(0, 0, 2875, 1000); game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; @@ -53,6 +52,7 @@ demo.state0.prototype = { } function changeState(i, stateNum){ + console.log('state' + stateNum); game.state.start('state' + stateNum); } diff --git a/harkka3/samson/state1.js b/harkka3/samson/state1.js index bddb4666f2c5ccbc43b21d38678c976ef5886472..20289e299f3fb6d6be44f114e8ef9a1f996f0d94 100644 --- a/harkka3/samson/state1.js +++ b/harkka3/samson/state1.js @@ -1,10 +1,55 @@ demo.state1 = function(){}; +var cursors, vel = 500, rocks, beach; + demo.state1.prototype = { - preload: function(){}, + preload: function(){ + game.load.tilemap('beach2', 'assets/tilemaps/beach.json', null, Phaser.Tilemap.TILED_JSON); + game.load.image('beach-grass-tile', 'assets/tilemaps/beach-grass-tile.png'); + game.load.image('rock-tile', 'assets/tilemaps/rock-tile.png'); + game.load.image('jorma', 'assets/sprites/penis.png'); + }, create: function(){ + game.physics.startSystem(Phaser.Physics.ARCADE); game.stage.backgroundColor = '#DDDDDD'; - console.log('state1'); addChangeStateEventListeners(); + + var map = game.add.tilemap('beach2'); + map.addTilesetImage('beach-grass-tile'); + map.addTilesetImage('rock-tile'); + + beach = map.createLayer('beach'); + rocks = map.createLayer('rocks'); + + map.setCollisionBetween(1, 9, true, 'rocks'); + map.setCollision(11, true, 'beach'); + + jorma = game.add.sprite(30, 30, 'jorma'); + jorma.scale.setTo(0.2, 0.2); + game.physics.enable(jorma); + + cursors = game.input.keyboard.createCursorKeys(); }, - update: function(){} + update: function(){ + game.physics.arcade.collide(jorma, rocks, function(){console.log('dickrock collision!')}); + game.physics.arcade.collide(jorma, beach, function(){console.log('dickbush collision!')}); + + if(cursors.up.isDown){ + jorma.body.velocity.y = -vel; + } + else if(cursors.down.isDown){ + jorma.body.velocity.y = vel; + } + else { + jorma.body.velocity.y = 0; + } + if(cursors.left.isDown){ + jorma.body.velocity.x = -vel; + } + else if(cursors.right.isDown){ + jorma.body.velocity.x = vel; + } + else { + jorma.body.velocity.x = 0; + } + } } \ No newline at end of file diff --git a/harkka3/samson/state2.js b/harkka3/samson/state2.js index 49c24f4f75e3a6db6cd9fa8f762f91bf2a24990b..c20aa82190aed6251675118cfaeeaf3cb3e366fb 100644 --- a/harkka3/samson/state2.js +++ b/harkka3/samson/state2.js @@ -3,7 +3,6 @@ demo.state2.prototype = { preload: function(){}, create: function(){ game.stage.backgroundColor = '#0066ff'; - console.log('state2'); addChangeStateEventListeners(); }, update: function(){} diff --git a/harkka3/samson/state3.js b/harkka3/samson/state3.js index fd3e9611a2514a343ac197e54e3fde79c529a76a..c803491387866fe2a35a26d21d9bae9cd8841017 100644 --- a/harkka3/samson/state3.js +++ b/harkka3/samson/state3.js @@ -3,7 +3,6 @@ demo.state3.prototype = { preload: function(){}, create: function(){ game.stage.backgroundColor = '#cc3300'; - console.log('state3'); addChangeStateEventListeners(); }, update: function(){} diff --git a/harkka3/samson/state4.js b/harkka3/samson/state4.js index 7409a84338fbc3354b4bded2c3983a76b025e4c5..40389b622ef3cfab0af295a2e5d853377234e57c 100644 --- a/harkka3/samson/state4.js +++ b/harkka3/samson/state4.js @@ -3,7 +3,6 @@ demo.state4.prototype = { preload: function(){}, create: function(){ game.stage.backgroundColor = '#ffff00'; - console.log('state4'); addChangeStateEventListeners(); }, update: function(){} diff --git a/harkka3/samson/state5.js b/harkka3/samson/state5.js index 8b20925b86fc76881c7a2bf11d1318427bbae9f9..52f9000afcd8d44f7275e60ae3913e8b037bd040 100644 --- a/harkka3/samson/state5.js +++ b/harkka3/samson/state5.js @@ -3,7 +3,6 @@ demo.state5.prototype = { preload: function(){}, create: function(){ game.stage.backgroundColor = '#009900'; - console.log('state5'); addChangeStateEventListeners(); }, update: function(){} diff --git a/harkka3/samson/state6.js b/harkka3/samson/state6.js index b4b25e7d701db06131492716c3226a190c7098e4..5c4251e3fab0c8d9470f40776b64868e41ebd085 100644 --- a/harkka3/samson/state6.js +++ b/harkka3/samson/state6.js @@ -3,7 +3,6 @@ demo.state6.prototype = { preload: function(){}, create: function(){ game.stage.backgroundColor = '#000099'; - console.log('state6'); addChangeStateEventListeners(); }, update: function(){} diff --git a/harkka3/samson/state7.js b/harkka3/samson/state7.js index 3e0eecc904d6df23dc78a120ee7335c17d9a606f..e03b50b5059c92ec0297638691eadcd7b2905583 100644 --- a/harkka3/samson/state7.js +++ b/harkka3/samson/state7.js @@ -3,7 +3,6 @@ demo.state7.prototype = { preload: function(){}, create: function(){ game.stage.backgroundColor = '#ff00ff'; - console.log('state7'); addChangeStateEventListeners(); }, update: function(){} diff --git a/harkka3/samson/state8.js b/harkka3/samson/state8.js index 073d44a1c1c6774cd401377aee2dd87c1b7c7f6c..e106fd55ae14411d1325f15406f82f50cc484b24 100644 --- a/harkka3/samson/state8.js +++ b/harkka3/samson/state8.js @@ -3,7 +3,6 @@ demo.state8.prototype = { preload: function(){}, create: function(){ game.stage.backgroundColor = '#000066'; - console.log('state8'); addChangeStateEventListeners(); }, update: function(){} diff --git a/harkka3/samson/state9.js b/harkka3/samson/state9.js index f9a0737b3de5a5cf0cec7aba1e0f1e136cb29231..5b9f7487beeb00aa0fb19f57a077a66dc0a3068d 100644 --- a/harkka3/samson/state9.js +++ b/harkka3/samson/state9.js @@ -3,7 +3,6 @@ demo.state9.prototype = { preload: function(){}, create: function(){ game.stage.backgroundColor = '#000000'; - console.log('state9'); addChangeStateEventListeners(); }, update: function(){} diff --git a/harkka3/samson/tilemap.tmx b/harkka3/samson/tilemap.tmx new file mode 100644 index 0000000000000000000000000000000000000000..d8826f2192f14d94ae10b86b85005c46b3c0e0ad --- /dev/null +++ b/harkka3/samson/tilemap.tmx @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?> +<map version="1.2" tiledversion="1.3.2" orientation="orthogonal" renderorder="right-down" compressionlevel="-1" width="42" height="31" tilewidth="32" tileheight="32" infinite="0" nextlayerid="3" nextobjectid="1"> + <tileset firstgid="1" source="rock-tile.tsx"/> + <tileset firstgid="10" source="beach-grass-tile.tsx"/> + <layer id="1" name="beach" width="42" height="31"> + <data encoding="csv"> +10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, +10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, +10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, +10,10,10,10,11,10,10,10,11,11,10,10,11,10,10,10,11,10,10,10,10,10,10,10,10,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, +10,10,10,10,10,11,10,11,11,10,10,10,11,11,10,11,10,10,10,10,10,10,10,10,10,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, +10,10,10,10,10,10,10,11,10,10,11,10,10,11,10,10,10,10,10,10,10,10,10,10,10,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, +10,10,10,10,11,11,10,11,10,10,11,10,10,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, +10,10,10,10,10,10,10,11,10,10,11,10,10,11,10,11,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, +10,10,10,10,11,11,10,11,11,10,11,10,10,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, +10,10,10,10,10,10,10,10,11,10,10,10,10,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, +10,10,10,10,10,10,11,10,11,11,10,10,11,11,10,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,10,10,10,10, +10,10,10,10,10,11,10,10,10,11,10,11,11,10,10,10,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, +10,10,10,10,10,10,10,10,10,11,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, +10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, +10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, +10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, +10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,10,10,10,10,10,10, +10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,10,10,10,10,10,10,10,10,10,10,10,11,11,10,10,10,10,10, +10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,10,10,10,10, +10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,10,10,10,10, +10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,10,10,10,10, +10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,10,10,10,10,10,10,10,11,10,10,10,10,10,10,11,11,10,10,10,10, +10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,10,10,10,10,10,10,10,10,11,10,10,10,10,10,10,11,10,10,10,10,10, +10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,10,10,10,10,10,10,10,11,10,10,10,11,10,11,11,10,10,10,10,10, +10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,10,10,11,10,10,10,11,11,11,10,10,10,10,11,10,10,10,10,10,10, +10,10,10,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,10,10,11,11,11,10,11,11,11,11,11,11,10,10,10,10,10,10, +10,10,10,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,10,10,10,10,10,10,11,11,10,10,10,10,10,10,10, +10,10,10,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, +10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, +10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, +10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10 +</data> + </layer> + <layer id="2" name="rocks" width="42" height="31"> + <data encoding="csv"> +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,5,6,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,8,9,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,2,2,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,8,8,8,8,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,7,9,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,8,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,4,5,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,7,8,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +</data> + </layer> +</map>