diff --git a/.gitattributes b/.gitattributes index 9f0973c36fa4c3f70d0285a7410b096b7a0d5666..9a8af8ec9c753e180ed88d8427d8fe5aebf1bebd 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2009,3 +2009,16 @@ benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r413_MIT_Mystery_Hunt_2014_A_Puzz benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell06.ogv filter=lfs diff=lfs merge=lfs -text benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r413_MIT_Mystery_Hunt_2014_A_Puzzle_with_the_Answer_LOVE_ME_DO/09.ogv filter=lfs diff=lfs merge=lfs -text benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r084_MIT_Mystery_Hunt_2016_Puzzle_Extravaganza/_solution_assets/solution.pdf filter=lfs diff=lfs merge=lfs -text +benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r0131_MIT_Mystery_Hunt_2016_Don_t_Cross_an_Alpha_Bitch/_solution_assets/dont_cross_an_alpha_bitch_sol.pdf filter=lfs diff=lfs merge=lfs -text +benchmark/MIT_Mystery_Hunt/puzzles/2013/mit201302_MIT_Mystery_Hunt_2013_You_Will_Not_Go_to_Space_Today/puzzle.pdf filter=lfs diff=lfs merge=lfs -text +benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013245_MIT_Mystery_Hunt_2013_Slinking_Slumber/Snake.jar filter=lfs diff=lfs merge=lfs -text +benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell03.ogv filter=lfs diff=lfs merge=lfs -text +benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell01.ogv filter=lfs diff=lfs merge=lfs -text +benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell02.ogv filter=lfs diff=lfs merge=lfs -text +benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013309_MIT_Mystery_Hunt_2013_A_Walk_Around_Town/instructions.pdf filter=lfs diff=lfs merge=lfs -text +benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell04.ogv filter=lfs diff=lfs merge=lfs -text +benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell08.ogv filter=lfs diff=lfs merge=lfs -text +benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell09.ogv filter=lfs diff=lfs merge=lfs -text +benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r413_MIT_Mystery_Hunt_2014_A_Puzzle_with_the_Answer_LOVE_ME_DO/11.ogv filter=lfs diff=lfs merge=lfs -text +benchmark/MIT_Mystery_Hunt/puzzles/2013/mit20136mm_MIT_Mystery_Hunt_2013_Cryptocube_ErnÅ_Rubik_meta/cryptocube.pdf filter=lfs diff=lfs merge=lfs -text +benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r418_MIT_Mystery_Hunt_2014_A_Puzzle_with_the_Answer_CAN_T_BUY_ME_LOVE/Video_IVA.ogv filter=lfs diff=lfs merge=lfs -text diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/1999/mit1999r108_MIT_Mystery_Hunt_1999_Phnom_Penh/_solution_assets/marshplaque.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/1999/mit1999r108_MIT_Mystery_Hunt_1999_Phnom_Penh/_solution_assets/marshplaque.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6f3c157a01cde527c0bec4611799872c5fe07395 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/1999/mit1999r108_MIT_Mystery_Hunt_1999_Phnom_Penh/_solution_assets/marshplaque.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b11b8fbdb978b94caf6509bbd31727a8d5ef92f153583fb4f6e5b736a2fd49cd +size 626443 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit201302_MIT_Mystery_Hunt_2013_You_Will_Not_Go_to_Space_Today/puzzle.pdf b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit201302_MIT_Mystery_Hunt_2013_You_Will_Not_Go_to_Space_Today/puzzle.pdf new file mode 100644 index 0000000000000000000000000000000000000000..f36fe49465867c52068d93dc8adedb4d890ad39c --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit201302_MIT_Mystery_Hunt_2013_You_Will_Not_Go_to_Space_Today/puzzle.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:26b24c38e88aa2efbf69d1e06b88402c6777fa5742968839a6c1e41a169a226b +size 729319 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013226_MIT_Mystery_Hunt_2013_Road_Trip/a8.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013226_MIT_Mystery_Hunt_2013_Road_Trip/a8.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b6c168b00005098823dccf5ec8dea02359d71617 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013226_MIT_Mystery_Hunt_2013_Road_Trip/a8.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:46fbe382fa41fa0d8c744d42cd24dff0121317298662f6df873330599ae5eae3 +size 730856 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW28.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW28.jpg new file mode 100644 index 0000000000000000000000000000000000000000..3e2a34038d31931d431f86c5a23b4ec52ce687e5 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW28.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cc2da8041cca01dabb0b349d4d518ebfd2059285a36cbb7b0b713160ac0b625f +size 609097 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW30.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW30.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f070431e48ce873e18acac833ed221fcd5413fc0 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW30.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f8f90729d1ebd1101c23b85f4574b1080efbdf7527fe9522c7ef984c10d8089d +size 590737 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW31.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW31.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e618c6fc771df03f44f761f9a1b8be1118030211 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW31.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e1334a80c51b1faa3049c4b010b918b331053a26024ea221ef4f2deb1ad55c2e +size 587790 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW34.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW34.jpg new file mode 100644 index 0000000000000000000000000000000000000000..dd2d75a62ebc68980f798916068dfcccf0cc987f --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW34.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a674a439a486c9088b08cecbb3ea68caf54831e6c290e7dc50b258d8053da242 +size 588153 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW36.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW36.jpg new file mode 100644 index 0000000000000000000000000000000000000000..79014fc51acef753fed0b4e3e6300e2feeb22d94 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW36.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:39ff35957d9d8de4335d9167d8fc28de21ff06156dc897c45d6c8d8a8c7d95fd +size 693584 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW39.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW39.jpg new file mode 100644 index 0000000000000000000000000000000000000000..aff6bfe02b7027b48fe1cb4e1c1a8d4d95d0cead --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW39.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5cf51d8cc5c01055ff4dad1f8c68503b0e8503477d714bd4e1f8b5301ee323c6 +size 698615 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW40.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW40.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d7488d9aa1e53aa1e55b9d3dc950168fb0cf35fc --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW40.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0a71986df6e54de8f1e6c8b7544b33beb34eca381a3e0e37028af5436265544d +size 676982 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW42.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW42.jpg new file mode 100644 index 0000000000000000000000000000000000000000..905c9a97e99fc3f925d742e8c899bc19c3e481ae --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW42.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3e1fa310189df456fb98e43a0ae7dcc7cdde08c1060449a0a0aadfbafa92a027 +size 714010 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW43.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW43.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c69358b608e7fff4133cb57b3cca79a223f17675 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW43.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2b13601b6a223a642d397ce6d2d640f5ac9d01cfd3fa3a5789bc91e8f68c2656 +size 590652 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW45.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW45.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e5d97e3f1ff016e0600948f1907c1d468614903b --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW45.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:027b0749d558013e596bec24c67e48b714d551ebeddd799d9a33ac94091edcb7 +size 588098 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW47.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW47.jpg new file mode 100644 index 0000000000000000000000000000000000000000..82d748e6f67dc4fdc2e98919451cafee84671e63 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW47.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7e58d93309c5ba22dd1d7914ad479c668d2f0b7d4433863b6dee89baf6f58c7f +size 610634 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW48.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW48.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ae09a5fb0c0073f90e37961ad3c6ad629b14a0a0 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013231_MIT_Mystery_Hunt_2013_Cambridge_Waldo/CW48.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b773eef33349188d5cc3b743082a79758349ac38df5caaf01a4a9359344d9000 +size 674910 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013245_MIT_Mystery_Hunt_2013_Slinking_Slumber/Snake.jar b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013245_MIT_Mystery_Hunt_2013_Slinking_Slumber/Snake.jar new file mode 100644 index 0000000000000000000000000000000000000000..a6bd5cb8924fb18ecbe7f321413cf66e59fb7a7e --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013245_MIT_Mystery_Hunt_2013_Slinking_Slumber/Snake.jar @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:366694c436b1a6e9cdbb9daa155f164cf303b33a04d2bd112ffe0fd4fabcb1ef +size 712961 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013274_MIT_Mystery_Hunt_2013_Hap_p_y_Days_Are_Here_Again/15.mp3 b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013274_MIT_Mystery_Hunt_2013_Hap_p_y_Days_Are_Here_Again/15.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..35044c620bfa53d6deb409b734d316f921d3cf2e --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013274_MIT_Mystery_Hunt_2013_Hap_p_y_Days_Are_Here_Again/15.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ce062214d5557e48742a03ef45dd2ecb79a5b19171b6b5c96c185264d7bad75e +size 699648 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013274_MIT_Mystery_Hunt_2013_Hap_p_y_Days_Are_Here_Again/5.mp3 b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013274_MIT_Mystery_Hunt_2013_Hap_p_y_Days_Are_Here_Again/5.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..f6e0687517832e65cc76a97c6d83adabc3e082d2 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013274_MIT_Mystery_Hunt_2013_Hap_p_y_Days_Are_Here_Again/5.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:98b3c796b1b094931083a00519ddf9510f2605ac56c3aa7c90dc93e5ff90ca41 +size 602278 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013309_MIT_Mystery_Hunt_2013_A_Walk_Around_Town/instructions.pdf b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013309_MIT_Mystery_Hunt_2013_A_Walk_Around_Town/instructions.pdf new file mode 100644 index 0000000000000000000000000000000000000000..cf15bba632070c97eafedb534da43073bb0ce081 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013309_MIT_Mystery_Hunt_2013_A_Walk_Around_Town/instructions.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4a966b3bd7fb7bc470ed87e41a13b49f951b453dac6670f6eba8c626701a4cbe +size 680661 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013509_MIT_Mystery_Hunt_2013_Around_the_World_in_1_Day/14.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013509_MIT_Mystery_Hunt_2013_Around_the_World_in_1_Day/14.jpg new file mode 100644 index 0000000000000000000000000000000000000000..73cb25ea45e5c4aade222dc9beb2be9c7498720c --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013509_MIT_Mystery_Hunt_2013_Around_the_World_in_1_Day/14.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9b79250e5447f40c1197076dbe70c70bedd8bead0369a82f91e8c0e9ea70bac0 +size 661753 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013605_MIT_Mystery_Hunt_2013_Bottom_of_the_Top/10.mp3 b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013605_MIT_Mystery_Hunt_2013_Bottom_of_the_Top/10.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..87df7df7cfb33817d256885ff110f6561094420c --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013605_MIT_Mystery_Hunt_2013_Bottom_of_the_Top/10.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:593378fb5e8951be348eca00761116f941a929bf19d05ad8dc4fbd83c510510f +size 690469 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013605_MIT_Mystery_Hunt_2013_Bottom_of_the_Top/13.mp3 b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013605_MIT_Mystery_Hunt_2013_Bottom_of_the_Top/13.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..ae0257a4e119c5b45ceba0bb44d563a016e5d494 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013605_MIT_Mystery_Hunt_2013_Bottom_of_the_Top/13.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:83c57d23083a617a65e129892945c55d45cdfa0243aeb5e1b27177ea6f79ec63 +size 642822 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013605_MIT_Mystery_Hunt_2013_Bottom_of_the_Top/22.mp3 b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013605_MIT_Mystery_Hunt_2013_Bottom_of_the_Top/22.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..2df2ae8e28d3459044f8090970d83ab246dafd63 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013605_MIT_Mystery_Hunt_2013_Bottom_of_the_Top/22.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0cc4744e01d819e514f2ec67cd6497d93ac727f911f93b005f33e1af1b83d887 +size 619416 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013605_MIT_Mystery_Hunt_2013_Bottom_of_the_Top/6.mp3 b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013605_MIT_Mystery_Hunt_2013_Bottom_of_the_Top/6.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..99a6b6960c3382af80dc77153cb1b19f12877db9 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013605_MIT_Mystery_Hunt_2013_Bottom_of_the_Top/6.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:938de6454fb851b58d709177272ffc0b91be8307ef577f0fec56f914b644daaf +size 595592 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013605_MIT_Mystery_Hunt_2013_Bottom_of_the_Top/7.mp3 b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013605_MIT_Mystery_Hunt_2013_Bottom_of_the_Top/7.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..3cdcf6114a6a4f2867b88a6e34b1a05a7d48c8f2 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit2013605_MIT_Mystery_Hunt_2013_Bottom_of_the_Top/7.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7a716a5dd4e475964853f13ab76030620a211d15af5ef29d87625d805bc6c4a1 +size 738116 diff --git "a/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit20136mm_MIT_Mystery_Hunt_2013_Cryptocube_Ern\303\205_Rubik_meta/cryptocube.pdf" "b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit20136mm_MIT_Mystery_Hunt_2013_Cryptocube_Ern\303\205_Rubik_meta/cryptocube.pdf" new file mode 100644 index 0000000000000000000000000000000000000000..9370da1481bb18ba0c6546039a9c58553c11dc0e --- /dev/null +++ "b/benchmark/MIT_Mystery_Hunt/puzzles/2013/mit20136mm_MIT_Mystery_Hunt_2013_Cryptocube_Ern\303\205_Rubik_meta/cryptocube.pdf" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:92fe6300cf68b0145e7d86352f820d40b9bcd0a48848693eca5f65382d5d4144 +size 598861 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell01.ogv b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell01.ogv new file mode 100644 index 0000000000000000000000000000000000000000..670c448e463441710feb99500e64ae501dafd2e6 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell01.ogv @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1aafbba338d4198c9101154886bc6dfdbf578d35aea4898605d5722e376d6249 +size 700623 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell02.ogv b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell02.ogv new file mode 100644 index 0000000000000000000000000000000000000000..eb47fc165c7fe34676862e472361b856c1329487 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell02.ogv @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f90decf7c0fd40c2a4890502013daf2d74bf2a53df8b3dc67d517d3f09c49d65 +size 688611 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell03.ogv b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell03.ogv new file mode 100644 index 0000000000000000000000000000000000000000..d6730b7136d5c8492343e202591d3ba6c475e817 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell03.ogv @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:582d40ce63d4fad8cfd437a000ca1bb307c396300deec719f1069238b6681bcb +size 703346 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell04.ogv b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell04.ogv new file mode 100644 index 0000000000000000000000000000000000000000..660212051d02b89731640bcfb1b75cfa5d0b7534 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell04.ogv @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b839c754f4d50fdfcf8f7dc64f3def08b1db588f422445e51c9786674add8402 +size 658916 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell08.ogv b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell08.ogv new file mode 100644 index 0000000000000000000000000000000000000000..444694fa49f9edd418960d3829f996d678eb25d0 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell08.ogv @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:54345e902760a28c368c27b2b449b412249e68c0a82b835bbd1a40b3cba8450b +size 656462 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell09.ogv b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell09.ogv new file mode 100644 index 0000000000000000000000000000000000000000..803770477db2df5898746bc245ead12306fd51dd --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r201_MIT_Mystery_Hunt_2014_The_Puzzle_Your_Puzzle_Could_Smell_Like/smell09.ogv @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dd64f3d2f23541058c3cb5f33f5bc7a9d053eb23e0edfb4dbaf89288f728d5d5 +size 648645 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r413_MIT_Mystery_Hunt_2014_A_Puzzle_with_the_Answer_LOVE_ME_DO/11.ogv b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r413_MIT_Mystery_Hunt_2014_A_Puzzle_with_the_Answer_LOVE_ME_DO/11.ogv new file mode 100644 index 0000000000000000000000000000000000000000..e38cbadffdb2368a113a62b6b0a59cefcf674d6d --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r413_MIT_Mystery_Hunt_2014_A_Puzzle_with_the_Answer_LOVE_ME_DO/11.ogv @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6f95c3a850b974fca1a1eb5c8b20209aa7f189027e66d860fa8b28b13f1f3fc4 +size 645841 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r418_MIT_Mystery_Hunt_2014_A_Puzzle_with_the_Answer_CAN_T_BUY_ME_LOVE/Video_IA.webm b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r418_MIT_Mystery_Hunt_2014_A_Puzzle_with_the_Answer_CAN_T_BUY_ME_LOVE/Video_IA.webm new file mode 100644 index 0000000000000000000000000000000000000000..7cc39ce32b43451f749acfc3f1b79b93ccfb5a16 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r418_MIT_Mystery_Hunt_2014_A_Puzzle_with_the_Answer_CAN_T_BUY_ME_LOVE/Video_IA.webm @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:463d3b3b15583d1599addb7c6d14315724e842b485817d374aa27d5056f51f28 +size 715658 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r418_MIT_Mystery_Hunt_2014_A_Puzzle_with_the_Answer_CAN_T_BUY_ME_LOVE/Video_IB.mp4 b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r418_MIT_Mystery_Hunt_2014_A_Puzzle_with_the_Answer_CAN_T_BUY_ME_LOVE/Video_IB.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..cf4b832fc1905d4c4617389691f32dda1e53aa32 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r418_MIT_Mystery_Hunt_2014_A_Puzzle_with_the_Answer_CAN_T_BUY_ME_LOVE/Video_IB.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2707ed2c75302e2e2e2219ed78dfe036de739943fe50838e3704c47da49e86bb +size 617056 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r418_MIT_Mystery_Hunt_2014_A_Puzzle_with_the_Answer_CAN_T_BUY_ME_LOVE/Video_IVA.ogv b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r418_MIT_Mystery_Hunt_2014_A_Puzzle_with_the_Answer_CAN_T_BUY_ME_LOVE/Video_IVA.ogv new file mode 100644 index 0000000000000000000000000000000000000000..2ec221e4be36c7c62e85ae11280a6a7a2fa680a0 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r418_MIT_Mystery_Hunt_2014_A_Puzzle_with_the_Answer_CAN_T_BUY_ME_LOVE/Video_IVA.ogv @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e58058318346423a55fb02a20ae89826faf017f8c4de0bba70ee0a78882e3939 +size 594038 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r418_MIT_Mystery_Hunt_2014_A_Puzzle_with_the_Answer_CAN_T_BUY_ME_LOVE/Video_IVB.webm b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r418_MIT_Mystery_Hunt_2014_A_Puzzle_with_the_Answer_CAN_T_BUY_ME_LOVE/Video_IVB.webm new file mode 100644 index 0000000000000000000000000000000000000000..b87776d740fdc68c105d25cdacd87c7875fde866 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r418_MIT_Mystery_Hunt_2014_A_Puzzle_with_the_Answer_CAN_T_BUY_ME_LOVE/Video_IVB.webm @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b2ba8a441e9e7d32d8f8af2af97bfd80a79a011095e36f2febf72a4e63addef0 +size 617159 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r503_MIT_Mystery_Hunt_2014_Walk_Across_Some_Dungeons/_solution_assets/WASD_09.mp4 b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r503_MIT_Mystery_Hunt_2014_Walk_Across_Some_Dungeons/_solution_assets/WASD_09.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..79cdb29a85e85e5e0a2368a7952b6dceb775ee74 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r503_MIT_Mystery_Hunt_2014_Walk_Across_Some_Dungeons/_solution_assets/WASD_09.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:342c4d99c05ccf00ff0a8d8c890ae76c132b02fd52d094dbd8d03fe452e3d553 +size 688843 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r503_MIT_Mystery_Hunt_2014_Walk_Across_Some_Dungeons/_solution_assets/WASD_11.mp4 b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r503_MIT_Mystery_Hunt_2014_Walk_Across_Some_Dungeons/_solution_assets/WASD_11.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..5a1ffcc7c5fdbd3bdd854aafb22bf40338b626e0 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r503_MIT_Mystery_Hunt_2014_Walk_Across_Some_Dungeons/_solution_assets/WASD_11.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7ec53d704b8120007af02f6f88f9ba328bdf32a749733cd771d83b41de67f97d +size 646127 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r503_MIT_Mystery_Hunt_2014_Walk_Across_Some_Dungeons/_solution_assets/WASD_13.mp4 b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r503_MIT_Mystery_Hunt_2014_Walk_Across_Some_Dungeons/_solution_assets/WASD_13.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..91cd9133d3245e377fd35e72e4652c4ac0a553c1 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r503_MIT_Mystery_Hunt_2014_Walk_Across_Some_Dungeons/_solution_assets/WASD_13.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5238b76cbd7c770f1183c6bd178974c2e707f0414b616dbbaab19b76b2d7c857 +size 662439 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r714_MIT_Mystery_Hunt_2014_The_Circle_of_Life/_solution_assets/solution_letters.png b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r714_MIT_Mystery_Hunt_2014_The_Circle_of_Life/_solution_assets/solution_letters.png new file mode 100644 index 0000000000000000000000000000000000000000..19faa56c4ee324b602e5cfe6ac6beb505968bbc9 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2014/mit2014r714_MIT_Mystery_Hunt_2014_The_Circle_of_Life/_solution_assets/solution_letters.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e73a7bfbb0a7b218204921a0031dfed687dcb90eef53214051d19fb366616538 +size 656426 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2015/mit2015r0415_MIT_Mystery_Hunt_2015_Moves/2.png b/benchmark/MIT_Mystery_Hunt/puzzles/2015/mit2015r0415_MIT_Mystery_Hunt_2015_Moves/2.png new file mode 100644 index 0000000000000000000000000000000000000000..11f1db6cf3fc2e6fe28c34358ef537e53982565b --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2015/mit2015r0415_MIT_Mystery_Hunt_2015_Moves/2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6531eaeb27e4506e4e198e557103daead0593973fe226d4a611dca5a514c89fa +size 605241 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2015/mit2015r0442_MIT_Mystery_Hunt_2015_A_Toast/_solution_assets/a-toast-solution.png b/benchmark/MIT_Mystery_Hunt/puzzles/2015/mit2015r0442_MIT_Mystery_Hunt_2015_A_Toast/_solution_assets/a-toast-solution.png new file mode 100644 index 0000000000000000000000000000000000000000..38c374ae1c37b69efc98de30ca115df859770ca7 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2015/mit2015r0442_MIT_Mystery_Hunt_2015_A_Toast/_solution_assets/a-toast-solution.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eea051ab99808c7556bea5793a923a6af95e55bb864015577252be62e9dbef7e +size 657223 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2015/mit2015r073_MIT_Mystery_Hunt_2015_Knit_Square/_solution_assets/1.png b/benchmark/MIT_Mystery_Hunt/puzzles/2015/mit2015r073_MIT_Mystery_Hunt_2015_Knit_Square/_solution_assets/1.png new file mode 100644 index 0000000000000000000000000000000000000000..cef3698768f528e47c051b84dba71c90bff14a06 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2015/mit2015r073_MIT_Mystery_Hunt_2015_Knit_Square/_solution_assets/1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0c2a4b804d3f9f11fa2e857020ebfbe9ea2bf023aecfc820b193065ddf13f57e +size 715868 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2015/mit2015r076_MIT_Mystery_Hunt_2015_Locks/treasure-chest-lid.png b/benchmark/MIT_Mystery_Hunt/puzzles/2015/mit2015r076_MIT_Mystery_Hunt_2015_Locks/treasure-chest-lid.png new file mode 100644 index 0000000000000000000000000000000000000000..f833a5486e5852067a4d29e048b39dd86ec4d2af --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2015/mit2015r076_MIT_Mystery_Hunt_2015_Locks/treasure-chest-lid.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6832427661d438652d75319ff386d5535c98bb8b9e73e9597054279b82d0874d +size 608814 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2015/mit2015r129_MIT_Mystery_Hunt_2015_Follow_the_Bees/background.png b/benchmark/MIT_Mystery_Hunt/puzzles/2015/mit2015r129_MIT_Mystery_Hunt_2015_Follow_the_Bees/background.png new file mode 100644 index 0000000000000000000000000000000000000000..751e1f5f3e50467ea3234b4c37e7dab007e2fb7a --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2015/mit2015r129_MIT_Mystery_Hunt_2015_Follow_the_Bees/background.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:286120ede4e5cc3689501154153aa1c3d382a5ced0d83b25270085fae7c86cd3 +size 689229 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r012m_MIT_Mystery_Hunt_2016_Obstacle_Training_Meta/_solution_assets/obstacletraining.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r012m_MIT_Mystery_Hunt_2016_Obstacle_Training_Meta/_solution_assets/obstacletraining.jpg new file mode 100644 index 0000000000000000000000000000000000000000..307b59e5b5c790d2b0be711929e40585fe630e7b --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r012m_MIT_Mystery_Hunt_2016_Obstacle_Training_Meta/_solution_assets/obstacletraining.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:14b5deb492dd9f5a2638e9440b9c00115ba582543c6576243af005ba7d6d452e +size 709748 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r012m_MIT_Mystery_Hunt_2016_Obstacle_Training_Meta/obstacletraining.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r012m_MIT_Mystery_Hunt_2016_Obstacle_Training_Meta/obstacletraining.jpg new file mode 100644 index 0000000000000000000000000000000000000000..307b59e5b5c790d2b0be711929e40585fe630e7b --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r012m_MIT_Mystery_Hunt_2016_Obstacle_Training_Meta/obstacletraining.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:14b5deb492dd9f5a2638e9440b9c00115ba582543c6576243af005ba7d6d452e +size 709748 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r0131_MIT_Mystery_Hunt_2016_Don_t_Cross_an_Alpha_Bitch/_solution_assets/dont_cross_an_alpha_bitch_sol.pdf b/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r0131_MIT_Mystery_Hunt_2016_Don_t_Cross_an_Alpha_Bitch/_solution_assets/dont_cross_an_alpha_bitch_sol.pdf new file mode 100644 index 0000000000000000000000000000000000000000..7110f5389809293134a32dbe4d4ded49f7b35f71 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r0131_MIT_Mystery_Hunt_2016_Don_t_Cross_an_Alpha_Bitch/_solution_assets/dont_cross_an_alpha_bitch_sol.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:22bed4533a7c9a4967dca5836abb5e77cfcb7b1cf0f9b740c0d9e66e804c191e +size 736836 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r05m_MIT_Mystery_Hunt_2016_King_Arthur_Meta/_solution_assets/circular.png b/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r05m_MIT_Mystery_Hunt_2016_King_Arthur_Meta/_solution_assets/circular.png new file mode 100644 index 0000000000000000000000000000000000000000..167594d78db852940b6c6d370012f649451e5de3 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r05m_MIT_Mystery_Hunt_2016_King_Arthur_Meta/_solution_assets/circular.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aee2fa705ec912eb37d37991c36a388cdceeefd94b770539575f219390f4e408 +size 592067 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r094_MIT_Mystery_Hunt_2016_The_Tenebrous_Stygian_Test_of_Knowledge/pic14.jpeg b/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r094_MIT_Mystery_Hunt_2016_The_Tenebrous_Stygian_Test_of_Knowledge/pic14.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..4e07247fc355edd0f5e77a54fdcc7338f1ac1835 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r094_MIT_Mystery_Hunt_2016_The_Tenebrous_Stygian_Test_of_Knowledge/pic14.jpeg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6abb9285b410253e90b93db65b49ef657ae5e0579e034e75674ecc15abea80bd +size 593324 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r094_MIT_Mystery_Hunt_2016_The_Tenebrous_Stygian_Test_of_Knowledge/pic3.jpeg b/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r094_MIT_Mystery_Hunt_2016_The_Tenebrous_Stygian_Test_of_Knowledge/pic3.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..4edb428b67074b9dda90ec85a84dafa75556953e --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r094_MIT_Mystery_Hunt_2016_The_Tenebrous_Stygian_Test_of_Knowledge/pic3.jpeg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c303f615e3584227e56886ed863f412d1696f52b636b2a184e73b4c71f3eedbe +size 652432 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r094_MIT_Mystery_Hunt_2016_The_Tenebrous_Stygian_Test_of_Knowledge/pic6.jpeg b/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r094_MIT_Mystery_Hunt_2016_The_Tenebrous_Stygian_Test_of_Knowledge/pic6.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..e9bd11c60512ae9fc09682adab7d86a831b4258c --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r094_MIT_Mystery_Hunt_2016_The_Tenebrous_Stygian_Test_of_Knowledge/pic6.jpeg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dfc57a8e03c1e48d0eab4c7ad828331e1ed77ac22b1540b3f4f4580fd04d2290 +size 630216 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r094_MIT_Mystery_Hunt_2016_The_Tenebrous_Stygian_Test_of_Knowledge/pic8.jpeg b/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r094_MIT_Mystery_Hunt_2016_The_Tenebrous_Stygian_Test_of_Knowledge/pic8.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..6f5ac9259a9683ede2196f523176251eeeebdc13 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r094_MIT_Mystery_Hunt_2016_The_Tenebrous_Stygian_Test_of_Knowledge/pic8.jpeg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:db436bf708ff17b9c419b8dd3df201b4f1c35300e183193a4b4adaa9b303e3b5 +size 667008 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r1209_MIT_Mystery_Hunt_2016_Sleeping_Gypsy_Dream_Fragment/_solution_assets/sleeping-gypsy-dream-fragment-2.png b/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r1209_MIT_Mystery_Hunt_2016_Sleeping_Gypsy_Dream_Fragment/_solution_assets/sleeping-gypsy-dream-fragment-2.png new file mode 100644 index 0000000000000000000000000000000000000000..4a16c0ec66ea14c238ce10d72bb1b53d8c6405a0 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2016/mit2016r1209_MIT_Mystery_Hunt_2016_Sleeping_Gypsy_Dream_Fragment/_solution_assets/sleeping-gypsy-dream-fragment-2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dda76bb8044c18197885a5c25b3771258fcc47e63a9d33ed0e023b062dbff33d +size 646381 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0207_MIT_Mystery_Hunt_2017_Net_Work/vis.min.js b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0207_MIT_Mystery_Hunt_2017_Net_Work/vis.min.js new file mode 100644 index 0000000000000000000000000000000000000000..4faffbc23d6628df36034cc3f1c6a823106a46e4 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0207_MIT_Mystery_Hunt_2017_Net_Work/vis.min.js @@ -0,0 +1,45 @@ +/** + * vis.js + * https://github.com/almende/vis + * + * A dynamic, browser-based visualization library. + * + * @version 4.17.0 + * @date 2016-11-05 + * + * @license + * Copyright (C) 2011-2016 Almende B.V, http://almende.com + * + * Vis.js is dual licensed under both + * + * * The Apache 2.0 License + * http://www.apache.org/licenses/LICENSE-2.0 + * + * and + * + * * The MIT License + * http://opensource.org/licenses/MIT + * + * Vis.js may be distributed under either license. + */ +"use strict";!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.vis=e():t.vis=e()}(this,function(){return function(t){function e(o){if(i[o])return i[o].exports;var n=i[o]={exports:{},id:o,loaded:!1};return t[o].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([function(t,e,i){var o=i(1);o.extend(e,i(7)),o.extend(e,i(26)),o.extend(e,i(62))},function(t,e,i){var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n=i(2),s=i(6);e.isNumber=function(t){return t instanceof Number||"number"==typeof t},e.recursiveDOMDelete=function(t){if(t)for(;t.hasChildNodes()===!0;)e.recursiveDOMDelete(t.firstChild),t.removeChild(t.firstChild)},e.giveRange=function(t,e,i,o){if(e==t)return.5;var n=1/(e-t);return Math.max(0,(o-t)*n)},e.isString=function(t){return t instanceof String||"string"==typeof t},e.isDate=function(t){if(t instanceof Date)return!0;if(e.isString(t)){var i=r.exec(t);if(i)return!0;if(!isNaN(Date.parse(t)))return!0}return!1},e.randomUUID=function(){return s.v4()},e.assignAllKeys=function(t,e){for(var i in t)t.hasOwnProperty(i)&&"object"!==o(t[i])&&(t[i]=e)},e.fillIfDefined=function(t,i){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];for(var s in t)void 0!==i[s]&&("object"!==o(i[s])?void 0!==i[s]&&null!==i[s]||void 0===t[s]||n!==!0?t[s]=i[s]:delete t[s]:"object"===o(t[s])&&e.fillIfDefined(t[s],i[s],n))},e.protoExtend=function(t,e){for(var i=1;i3&&void 0!==arguments[3]&&arguments[3];if(Array.isArray(o))throw new TypeError("Arrays are not supported by deepExtend");for(var s=2;s3&&void 0!==arguments[3]&&arguments[3];if(Array.isArray(o))throw new TypeError("Arrays are not supported by deepExtend");for(var s in o)if(o.hasOwnProperty(s)&&t.indexOf(s)==-1)if(o[s]&&o[s].constructor===Object)void 0===i[s]&&(i[s]={}),i[s].constructor===Object?e.deepExtend(i[s],o[s]):null===o[s]&&void 0!==i[s]&&n===!0?delete i[s]:i[s]=o[s];else if(Array.isArray(o[s])){i[s]=[];for(var r=0;r=0&&(e="DOMMouseScroll"),t.addEventListener(e,i,o)):t.attachEvent("on"+e,i)},e.removeEventListener=function(t,e,i,o){t.removeEventListener?(void 0===o&&(o=!1),"mousewheel"===e&&navigator.userAgent.indexOf("Firefox")>=0&&(e="DOMMouseScroll"),t.removeEventListener(e,i,o)):t.detachEvent("on"+e,i)},e.preventDefault=function(t){t||(t=window.event),t.preventDefault?t.preventDefault():t.returnValue=!1},e.getTarget=function(t){t||(t=window.event);var e;return t.target?e=t.target:t.srcElement&&(e=t.srcElement),void 0!=e.nodeType&&3==e.nodeType&&(e=e.parentNode),e},e.hasParent=function(t,e){for(var i=t;i;){if(i===e)return!0;i=i.parentNode}return!1},e.option={},e.option.asBoolean=function(t,e){return"function"==typeof t&&(t=t()),null!=t?0!=t:e||null},e.option.asNumber=function(t,e){return"function"==typeof t&&(t=t()),null!=t?Number(t)||e||null:e||null},e.option.asString=function(t,e){return"function"==typeof t&&(t=t()),null!=t?String(t):e||null},e.option.asSize=function(t,i){return"function"==typeof t&&(t=t()),e.isString(t)?t:e.isNumber(t)?t+"px":i||null},e.option.asElement=function(t,e){return"function"==typeof t&&(t=t()),t||e||null},e.hexToRGB=function(t){var e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;t=t.replace(e,function(t,e,i,o){return e+e+i+i+o+o});var i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return i?{r:parseInt(i[1],16),g:parseInt(i[2],16),b:parseInt(i[3],16)}:null},e.overrideOpacity=function(t,i){if(t.indexOf("rgba")!=-1)return t;if(t.indexOf("rgb")!=-1){var o=t.substr(t.indexOf("(")+1).replace(")","").split(",");return"rgba("+o[0]+","+o[1]+","+o[2]+","+i+")"}var o=e.hexToRGB(t);return null==o?t:"rgba("+o.r+","+o.g+","+o.b+","+i+")"},e.RGBToHex=function(t,e,i){return"#"+((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1)},e.parseColor=function(t){var i;if(e.isString(t)===!0){if(e.isValidRGB(t)===!0){var o=t.substr(4).substr(0,t.length-5).split(",").map(function(t){return parseInt(t)});t=e.RGBToHex(o[0],o[1],o[2])}if(e.isValidHex(t)===!0){var n=e.hexToHSV(t),s={h:n.h,s:.8*n.s,v:Math.min(1,1.02*n.v)},r={h:n.h,s:Math.min(1,1.25*n.s),v:.8*n.v},a=e.HSVToHex(r.h,r.s,r.v),h=e.HSVToHex(s.h,s.s,s.v);i={background:t,border:a,highlight:{background:h,border:a},hover:{background:h,border:a}}}else i={background:t,border:t,highlight:{background:t,border:t},hover:{background:t,border:t}}}else i={},i.background=t.background||void 0,i.border=t.border||void 0,e.isString(t.highlight)?i.highlight={border:t.highlight,background:t.highlight}:(i.highlight={},i.highlight.background=t.highlight&&t.highlight.background||void 0,i.highlight.border=t.highlight&&t.highlight.border||void 0),e.isString(t.hover)?i.hover={border:t.hover,background:t.hover}:(i.hover={},i.hover.background=t.hover&&t.hover.background||void 0,i.hover.border=t.hover&&t.hover.border||void 0);return i},e.RGBToHSV=function(t,e,i){t/=255,e/=255,i/=255;var o=Math.min(t,Math.min(e,i)),n=Math.max(t,Math.max(e,i));if(o==n)return{h:0,s:0,v:o};var s=t==o?e-i:i==o?t-e:i-t,r=t==o?3:i==o?1:5,a=60*(r-s/(n-o))/360,h=(n-o)/n,d=n;return{h:a,s:h,v:d}};var a={split:function(t){var e={};return t.split(";").forEach(function(t){if(""!=t.trim()){var i=t.split(":"),o=i[0].trim(),n=i[1].trim();e[o]=n}}),e},join:function(t){return Object.keys(t).map(function(e){return e+": "+t[e]}).join("; ")}};e.addCssText=function(t,i){var o=a.split(t.style.cssText),n=a.split(i),s=e.extend(o,n);t.style.cssText=a.join(s)},e.removeCssText=function(t,e){var i=a.split(t.style.cssText),o=a.split(e);for(var n in o)o.hasOwnProperty(n)&&delete i[n];t.style.cssText=a.join(i)},e.HSVToRGB=function(t,e,i){var o,n,s,r=Math.floor(6*t),a=6*t-r,h=i*(1-e),d=i*(1-a*e),l=i*(1-(1-a)*e);switch(r%6){case 0:o=i,n=l,s=h;break;case 1:o=d,n=i,s=h;break;case 2:o=h,n=i,s=l;break;case 3:o=h,n=d,s=i;break;case 4:o=l,n=h,s=i;break;case 5:o=i,n=h,s=d}return{r:Math.floor(255*o),g:Math.floor(255*n),b:Math.floor(255*s)}},e.HSVToHex=function(t,i,o){var n=e.HSVToRGB(t,i,o);return e.RGBToHex(n.r,n.g,n.b)},e.hexToHSV=function(t){var i=e.hexToRGB(t);return e.RGBToHSV(i.r,i.g,i.b)},e.isValidHex=function(t){var e=/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t);return e},e.isValidRGB=function(t){t=t.replace(" ","");var e=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/i.test(t);return e},e.isValidRGBA=function(t){t=t.replace(" ","");var e=/rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(.{1,3})\)/i.test(t);return e},e.selectiveBridgeObject=function(t,i){if("object"==("undefined"==typeof i?"undefined":o(i))){for(var n=Object.create(i),s=0;s0&&e(o,t[n-1])<0;n--)t[n]=t[n-1];t[n]=o}return t},e.mergeOptions=function(t,e,i){var o=(arguments.length>3&&void 0!==arguments[3]&&arguments[3],arguments.length>4&&void 0!==arguments[4]?arguments[4]:{});if(null===e[i])t[i]=Object.create(o[i]);else if(void 0!==e[i])if("boolean"==typeof e[i])t[i].enabled=e[i];else{void 0===e[i].enabled&&(t[i].enabled=!0);for(var n in e[i])e[i].hasOwnProperty(n)&&(t[i][n]=e[i][n])}},e.binarySearchCustom=function(t,e,i,o){for(var n=1e4,s=0,r=0,a=t.length-1;r<=a&&s0)return"before"==o?Math.max(0,h-1):h;if(n(r,e)<0&&n(a,e)>0)return"before"==o?h:Math.min(t.length-1,h+1);n(r,e)<0?c=h+1:u=h-1,l++}return-1},e.easingFunctions={linear:function(t){return t},easeInQuad:function(t){return t*t},easeOutQuad:function(t){return t*(2-t)},easeInOutQuad:function(t){return t<.5?2*t*t:-1+(4-2*t)*t},easeInCubic:function(t){return t*t*t},easeOutCubic:function(t){return--t*t*t+1},easeInOutCubic:function(t){return t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(t){return 1- --t*t*t*t},easeInOutQuart:function(t){return t<.5?8*t*t*t*t:1-8*--t*t*t*t},easeInQuint:function(t){return t*t*t*t*t},easeOutQuint:function(t){return 1+--t*t*t*t*t},easeInOutQuint:function(t){return t<.5?16*t*t*t*t*t:1+16*--t*t*t*t*t}},e.getScrollBarWidth=function(){var t=document.createElement("p");t.style.width="100%",t.style.height="200px";var e=document.createElement("div");e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.visibility="hidden",e.style.width="200px",e.style.height="150px",e.style.overflow="hidden",e.appendChild(t),document.body.appendChild(e);var i=t.offsetWidth;e.style.overflow="scroll";var o=t.offsetWidth;return i==o&&(o=e.clientWidth),document.body.removeChild(e),i-o}},function(t,e,i){t.exports="undefined"!=typeof window&&window.moment||i(3)},function(t,e,i){(function(t){!function(e,i){t.exports=i()}(this,function(){function e(){return fo.apply(null,arguments)}function i(t){fo=t}function o(t){return t instanceof Array||"[object Array]"===Object.prototype.toString.call(t)}function n(t){return null!=t&&"[object Object]"===Object.prototype.toString.call(t)}function s(t){var e;for(e in t)return!1;return!0}function r(t){return t instanceof Date||"[object Date]"===Object.prototype.toString.call(t)}function a(t,e){var i,o=[];for(i=0;i0)for(i in vo)o=vo[i],n=e[o],m(n)||(t[o]=n);return t}function g(t){v(this,t),this._d=new Date(null!=t._d?t._d.getTime():NaN),go===!1&&(go=!0,e.updateOffset(this),go=!1)}function y(t){return t instanceof g||null!=t&&null!=t._isAMomentObject}function b(t){return t<0?Math.ceil(t)||0:Math.floor(t)}function _(t){var e=+t,i=0;return 0!==e&&isFinite(e)&&(i=b(e)),i}function w(t,e,i){var o,n=Math.min(t.length,e.length),s=Math.abs(t.length-e.length),r=0;for(o=0;o0?"future":"past"];return D(i)?i(e):i.replace(/%s/i,e)}function L(t,e){var i=t.toLowerCase();Co[i]=Co[i+"s"]=Co[e]=t}function z(t){return"string"==typeof t?Co[t]||Co[t.toLowerCase()]:void 0}function A(t){var e,i,o={};for(i in t)h(t,i)&&(e=z(i),e&&(o[e]=t[i]));return o}function B(t,e){To[t]=e}function j(t){var e=[];for(var i in t)e.push({unit:i,priority:To[i]});return e.sort(function(t,e){return t.priority-e.priority}),e}function F(t,i){return function(o){return null!=o?(W(this,t,o),e.updateOffset(this,i),this):H(this,t)}}function H(t,e){return t.isValid()?t._d["get"+(t._isUTC?"UTC":"")+e]():NaN}function W(t,e,i){t.isValid()&&t._d["set"+(t._isUTC?"UTC":"")+e](i)}function Y(t){return t=z(t),D(this[t])?this[t]():this}function G(t,e){if("object"==typeof t){t=A(t);for(var i=j(t),o=0;o=0;return(s?i?"+":"":"-")+Math.pow(10,Math.max(0,n)).toString().substr(1)+o}function U(t,e,i,o){var n=o;"string"==typeof o&&(n=function(){return this[o]()}),t&&(Io[t]=n),e&&(Io[e[0]]=function(){return V(n.apply(this,arguments),e[1],e[2])}),i&&(Io[i]=function(){return this.localeData().ordinal(n.apply(this,arguments),t)})}function q(t){return t.match(/\[[\s\S]/)?t.replace(/^\[|\]$/g,""):t.replace(/\\/g,"")}function X(t){var e,i,o=t.match(Eo);for(e=0,i=o.length;e=0&&Mo.test(t);)t=t.replace(Mo,i),Mo.lastIndex=0,o-=1;return t}function J(t,e,i){Ko[t]=D(e)?e:function(t,o){return t&&i?i:e}}function Q(t,e){return h(Ko,t)?Ko[t](e._strict,e._locale):new RegExp($(t))}function $(t){return tt(t.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(t,e,i,o,n){return e||i||o||n}))}function tt(t){return t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function et(t,e){var i,o=e;for("string"==typeof t&&(t=[t]),"number"==typeof e&&(o=function(t,i){i[e]=_(t)}),i=0;i=0&&isFinite(a.getFullYear())&&a.setFullYear(t),a}function bt(t){var e=new Date(Date.UTC.apply(null,arguments));return t<100&&t>=0&&isFinite(e.getUTCFullYear())&&e.setUTCFullYear(t),e}function _t(t,e,i){var o=7+e-i,n=(7+bt(t,0,o).getUTCDay()-e)%7;return-n+o-1}function wt(t,e,i,o,n){var s,r,a=(7+i-o)%7,h=_t(t,o,n),d=1+7*(e-1)+a+h;return d<=0?(s=t-1,r=mt(s)+d):d>mt(t)?(s=t+1,r=d-mt(t)):(s=t,r=d),{year:s,dayOfYear:r}}function xt(t,e,i){var o,n,s=_t(t.year(),e,i),r=Math.floor((t.dayOfYear()-s-1)/7)+1;return r<1?(n=t.year()-1,o=r+kt(n,e,i)):r>kt(t.year(),e,i)?(o=r-kt(t.year(),e,i),n=t.year()+1):(n=t.year(),o=r),{week:o,year:n}}function kt(t,e,i){var o=_t(t,e,i),n=_t(t+1,e,i);return(mt(t)-o+n)/7}function Ot(t){return xt(t,this._week.dow,this._week.doy).week}function Dt(){return this._week.dow}function St(){return this._week.doy}function Ct(t){var e=this.localeData().week(this);return null==t?e:this.add(7*(t-e),"d")}function Tt(t){var e=xt(this,1,4).week;return null==t?e:this.add(7*(t-e),"d")}function Et(t,e){return"string"!=typeof t?t:isNaN(t)?(t=e.weekdaysParse(t),"number"==typeof t?t:null):parseInt(t,10)}function Mt(t,e){return"string"==typeof t?e.weekdaysParse(t)%7||7:isNaN(t)?null:t}function Pt(t,e){return t?o(this._weekdays)?this._weekdays[t.day()]:this._weekdays[this._weekdays.isFormat.test(e)?"format":"standalone"][t.day()]:this._weekdays}function It(t){return t?this._weekdaysShort[t.day()]:this._weekdaysShort}function Nt(t){return t?this._weekdaysMin[t.day()]:this._weekdaysMin}function Rt(t,e,i){var o,n,s,r=t.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],o=0;o<7;++o)s=l([2e3,1]).day(o),this._minWeekdaysParse[o]=this.weekdaysMin(s,"").toLocaleLowerCase(),this._shortWeekdaysParse[o]=this.weekdaysShort(s,"").toLocaleLowerCase(),this._weekdaysParse[o]=this.weekdays(s,"").toLocaleLowerCase();return i?"dddd"===e?(n=_o.call(this._weekdaysParse,r),n!==-1?n:null):"ddd"===e?(n=_o.call(this._shortWeekdaysParse,r),n!==-1?n:null):(n=_o.call(this._minWeekdaysParse,r),n!==-1?n:null):"dddd"===e?(n=_o.call(this._weekdaysParse,r),n!==-1?n:(n=_o.call(this._shortWeekdaysParse,r),n!==-1?n:(n=_o.call(this._minWeekdaysParse,r),n!==-1?n:null))):"ddd"===e?(n=_o.call(this._shortWeekdaysParse,r),n!==-1?n:(n=_o.call(this._weekdaysParse,r),n!==-1?n:(n=_o.call(this._minWeekdaysParse,r),n!==-1?n:null))):(n=_o.call(this._minWeekdaysParse,r),n!==-1?n:(n=_o.call(this._weekdaysParse,r),n!==-1?n:(n=_o.call(this._shortWeekdaysParse,r),n!==-1?n:null)))}function Lt(t,e,i){var o,n,s;if(this._weekdaysParseExact)return Rt.call(this,t,e,i);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),o=0;o<7;o++){if(n=l([2e3,1]).day(o),i&&!this._fullWeekdaysParse[o]&&(this._fullWeekdaysParse[o]=new RegExp("^"+this.weekdays(n,"").replace(".",".?")+"$","i"),this._shortWeekdaysParse[o]=new RegExp("^"+this.weekdaysShort(n,"").replace(".",".?")+"$","i"),this._minWeekdaysParse[o]=new RegExp("^"+this.weekdaysMin(n,"").replace(".",".?")+"$","i")),this._weekdaysParse[o]||(s="^"+this.weekdays(n,"")+"|^"+this.weekdaysShort(n,"")+"|^"+this.weekdaysMin(n,""),this._weekdaysParse[o]=new RegExp(s.replace(".",""),"i")),i&&"dddd"===e&&this._fullWeekdaysParse[o].test(t))return o;if(i&&"ddd"===e&&this._shortWeekdaysParse[o].test(t))return o;if(i&&"dd"===e&&this._minWeekdaysParse[o].test(t))return o;if(!i&&this._weekdaysParse[o].test(t))return o}}function zt(t){if(!this.isValid())return null!=t?this:NaN;var e=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=t?(t=Et(t,this.localeData()),this.add(t-e,"d")):e}function At(t){if(!this.isValid())return null!=t?this:NaN;var e=(this.day()+7-this.localeData()._week.dow)%7;return null==t?e:this.add(t-e,"d")}function Bt(t){if(!this.isValid())return null!=t?this:NaN;if(null!=t){var e=Mt(t,this.localeData());return this.day(this.day()%7?e:e-7)}return this.day()||7}function jt(t){return this._weekdaysParseExact?(h(this,"_weekdaysRegex")||Wt.call(this),t?this._weekdaysStrictRegex:this._weekdaysRegex):(h(this,"_weekdaysRegex")||(this._weekdaysRegex=yn),this._weekdaysStrictRegex&&t?this._weekdaysStrictRegex:this._weekdaysRegex)}function Ft(t){return this._weekdaysParseExact?(h(this,"_weekdaysRegex")||Wt.call(this),t?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(h(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=bn),this._weekdaysShortStrictRegex&&t?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function Ht(t){return this._weekdaysParseExact?(h(this,"_weekdaysRegex")||Wt.call(this),t?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(h(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=_n),this._weekdaysMinStrictRegex&&t?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function Wt(){function t(t,e){return e.length-t.length}var e,i,o,n,s,r=[],a=[],h=[],d=[];for(e=0;e<7;e++)i=l([2e3,1]).day(e),o=this.weekdaysMin(i,""),n=this.weekdaysShort(i,""),s=this.weekdays(i,""),r.push(o),a.push(n),h.push(s),d.push(o),d.push(n),d.push(s);for(r.sort(t),a.sort(t),h.sort(t),d.sort(t),e=0;e<7;e++)a[e]=tt(a[e]),h[e]=tt(h[e]),d[e]=tt(d[e]);this._weekdaysRegex=new RegExp("^("+d.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+h.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+a.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+r.join("|")+")","i")}function Yt(){return this.hours()%12||12}function Gt(){return this.hours()||24}function Vt(t,e){U(t,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),e)})}function Ut(t,e){return e._meridiemParse}function qt(t){return"p"===(t+"").toLowerCase().charAt(0)}function Xt(t,e,i){return t>11?i?"pm":"PM":i?"am":"AM"}function Zt(t){return t?t.toLowerCase().replace("_","-"):t}function Kt(t){for(var e,i,o,n,s=0;s0;){if(o=Jt(n.slice(0,e).join("-")))return o;if(i&&i.length>=e&&w(n,i,!0)>=e-1)break;e--}s++}return null}function Jt(e){var i=null;if(!Dn[e]&&"undefined"!=typeof t&&t&&t.exports)try{i=wn._abbr,!function(){var t=new Error('Cannot find module "./locale"');throw t.code="MODULE_NOT_FOUND",t}(),Qt(i)}catch(t){}return Dn[e]}function Qt(t,e){var i;return t&&(i=m(e)?ee(t):$t(t,e),i&&(wn=i)),wn._abbr}function $t(t,e){if(null!==e){var i=On;return e.abbr=t,null!=Dn[t]?(O("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),i=Dn[t]._config):null!=e.parentLocale&&(null!=Dn[e.parentLocale]?i=Dn[e.parentLocale]._config:O("parentLocaleUndefined","specified parentLocale is not defined yet. See http://momentjs.com/guides/#/warnings/parent-locale/")),Dn[t]=new T(C(i,e)),Qt(t),Dn[t]}return delete Dn[t],null}function te(t,e){if(null!=e){var i,o=On;null!=Dn[t]&&(o=Dn[t]._config),e=C(o,e),i=new T(e),i.parentLocale=Dn[t],Dn[t]=i,Qt(t)}else null!=Dn[t]&&(null!=Dn[t].parentLocale?Dn[t]=Dn[t].parentLocale:null!=Dn[t]&&delete Dn[t]);return Dn[t]}function ee(t){var e;if(t&&t._locale&&t._locale._abbr&&(t=t._locale._abbr),!t)return wn;if(!o(t)){if(e=Jt(t))return e;t=[t]}return Kt(t)}function ie(){return bo(Dn)}function oe(t){var e,i=t._a;return i&&u(t).overflow===-2&&(e=i[$o]<0||i[$o]>11?$o:i[tn]<1||i[tn]>nt(i[Qo],i[$o])?tn:i[en]<0||i[en]>24||24===i[en]&&(0!==i[on]||0!==i[nn]||0!==i[sn])?en:i[on]<0||i[on]>59?on:i[nn]<0||i[nn]>59?nn:i[sn]<0||i[sn]>999?sn:-1,u(t)._overflowDayOfYear&&(etn)&&(e=tn),u(t)._overflowWeeks&&e===-1&&(e=rn),u(t)._overflowWeekday&&e===-1&&(e=an),u(t).overflow=e),t}function ne(t){var e,i,o,n,s,r,a=t._i,h=Sn.exec(a)||Cn.exec(a);if(h){for(u(t).iso=!0,e=0,i=En.length;emt(n)&&(u(t)._overflowDayOfYear=!0),i=bt(n,0,t._dayOfYear),t._a[$o]=i.getUTCMonth(),t._a[tn]=i.getUTCDate()),e=0;e<3&&null==t._a[e];++e)t._a[e]=s[e]=o[e];for(;e<7;e++)t._a[e]=s[e]=null==t._a[e]?2===e?1:0:t._a[e];24===t._a[en]&&0===t._a[on]&&0===t._a[nn]&&0===t._a[sn]&&(t._nextDay=!0,t._a[en]=0),t._d=(t._useUTC?bt:yt).apply(null,s),null!=t._tzm&&t._d.setUTCMinutes(t._d.getUTCMinutes()-t._tzm),t._nextDay&&(t._a[en]=24)}}function de(t){var e,i,o,n,s,r,a,h;e=t._w,null!=e.GG||null!=e.W||null!=e.E?(s=1,r=4,i=re(e.GG,t._a[Qo],xt(ye(),1,4).year),o=re(e.W,1),n=re(e.E,1),(n<1||n>7)&&(h=!0)):(s=t._locale._week.dow,r=t._locale._week.doy,i=re(e.gg,t._a[Qo],xt(ye(),s,r).year),o=re(e.w,1),null!=e.d?(n=e.d,(n<0||n>6)&&(h=!0)):null!=e.e?(n=e.e+s,(e.e<0||e.e>6)&&(h=!0)):n=s),o<1||o>kt(i,s,r)?u(t)._overflowWeeks=!0:null!=h?u(t)._overflowWeekday=!0:(a=wt(i,o,n,s,r),t._a[Qo]=a.year,t._dayOfYear=a.dayOfYear)}function le(t){if(t._f===e.ISO_8601)return void ne(t);t._a=[],u(t).empty=!0;var i,o,n,s,r,a=""+t._i,h=a.length,d=0;for(n=K(t._f,t._locale).match(Eo)||[],i=0;i0&&u(t).unusedInput.push(r),a=a.slice(a.indexOf(o)+o.length),d+=o.length),Io[s]?(o?u(t).empty=!1:u(t).unusedTokens.push(s),ot(s,o,t)):t._strict&&!o&&u(t).unusedTokens.push(s);u(t).charsLeftOver=h-d,a.length>0&&u(t).unusedInput.push(a),t._a[en]<=12&&u(t).bigHour===!0&&t._a[en]>0&&(u(t).bigHour=void 0),u(t).parsedDateParts=t._a.slice(0),u(t).meridiem=t._meridiem,t._a[en]=ce(t._locale,t._a[en],t._meridiem),he(t),oe(t)}function ce(t,e,i){var o;return null==i?e:null!=t.meridiemHour?t.meridiemHour(e,i):null!=t.isPM?(o=t.isPM(i),o&&e<12&&(e+=12),o||12!==e||(e=0),e):e}function ue(t){var e,i,o,n,s;if(0===t._f.length)return u(t).invalidFormat=!0,void(t._d=new Date(NaN));for(n=0;nthis.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function ze(){if(!m(this._isDSTShifted))return this._isDSTShifted;var t={};if(v(t,this),t=me(t),t._a){var e=t._isUTC?l(t._a):ye(t._a);this._isDSTShifted=this.isValid()&&w(t._a,e.toArray())>0}else this._isDSTShifted=!1;return this._isDSTShifted}function Ae(){return!!this.isValid()&&!this._isUTC}function Be(){return!!this.isValid()&&this._isUTC}function je(){return!!this.isValid()&&(this._isUTC&&0===this._offset)}function Fe(t,e){var i,o,n,s=t,r=null;return ke(t)?s={ms:t._milliseconds,d:t._days,M:t._months}:"number"==typeof t?(s={},e?s[e]=t:s.milliseconds=t):(r=zn.exec(t))?(i="-"===r[1]?-1:1,s={y:0,d:_(r[tn])*i,h:_(r[en])*i,m:_(r[on])*i,s:_(r[nn])*i,ms:_(Oe(1e3*r[sn]))*i}):(r=An.exec(t))?(i="-"===r[1]?-1:1,s={y:He(r[2],i),M:He(r[3],i),w:He(r[4],i),d:He(r[5],i),h:He(r[6],i),m:He(r[7],i),s:He(r[8],i)}):null==s?s={}:"object"==typeof s&&("from"in s||"to"in s)&&(n=Ye(ye(s.from),ye(s.to)),s={},s.ms=n.milliseconds,s.M=n.months),o=new xe(s),ke(t)&&h(t,"_locale")&&(o._locale=t._locale),o}function He(t,e){var i=t&&parseFloat(t.replace(",","."));return(isNaN(i)?0:i)*e}function We(t,e){var i={milliseconds:0,months:0};return i.months=e.month()-t.month()+12*(e.year()-t.year()),t.clone().add(i.months,"M").isAfter(e)&&--i.months,i.milliseconds=+e-+t.clone().add(i.months,"M"),i}function Ye(t,e){var i;return t.isValid()&&e.isValid()?(e=Ce(e,t),t.isBefore(e)?i=We(t,e):(i=We(e,t),i.milliseconds=-i.milliseconds,i.months=-i.months),i):{milliseconds:0,months:0}}function Ge(t,e){return function(i,o){var n,s;return null===o||isNaN(+o)||(O(e,"moment()."+e+"(period, number) is deprecated. Please use moment()."+e+"(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info."),s=i,i=o,o=s),i="string"==typeof i?+i:i,n=Fe(i,o),Ve(this,n,t),this}}function Ve(t,i,o,n){var s=i._milliseconds,r=Oe(i._days),a=Oe(i._months);t.isValid()&&(n=null==n||n,s&&t._d.setTime(t._d.valueOf()+s*o),r&&W(t,"Date",H(t,"Date")+r*o),a&&dt(t,H(t,"Month")+a*o),n&&e.updateOffset(t,r||a))}function Ue(t,e){var i=t.diff(e,"days",!0);return i<-6?"sameElse":i<-1?"lastWeek":i<0?"lastDay":i<1?"sameDay":i<2?"nextDay":i<7?"nextWeek":"sameElse"}function qe(t,i){var o=t||ye(),n=Ce(o,this).startOf("day"),s=e.calendarFormat(this,n)||"sameElse",r=i&&(D(i[s])?i[s].call(this,o):i[s]);return this.format(r||this.localeData().calendar(s,this,ye(o)))}function Xe(){return new g(this)}function Ze(t,e){var i=y(t)?t:ye(t);return!(!this.isValid()||!i.isValid())&&(e=z(m(e)?"millisecond":e),"millisecond"===e?this.valueOf()>i.valueOf():i.valueOf()s&&(e=s),Mi.call(this,t,e,i,o,n))}function Mi(t,e,i,o,n){var s=wt(t,e,i,o,n),r=bt(s.year,0,s.dayOfYear);return this.year(r.getUTCFullYear()),this.month(r.getUTCMonth()),this.date(r.getUTCDate()),this}function Pi(t){return null==t?Math.ceil((this.month()+1)/3):this.month(3*(t-1)+this.month()%3)}function Ii(t){var e=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return null==t?e:this.add(t-e,"d")}function Ni(t,e){e[sn]=_(1e3*("0."+t))}function Ri(){return this._isUTC?"UTC":""}function Li(){return this._isUTC?"Coordinated Universal Time":""}function zi(t){return ye(1e3*t)}function Ai(){return ye.apply(null,arguments).parseZone()}function Bi(t){return t}function ji(t,e,i,o){var n=ee(),s=l().set(o,e);return n[i](s,t)}function Fi(t,e,i){if("number"==typeof t&&(e=t,t=void 0),t=t||"",null!=e)return ji(t,e,i,"month");var o,n=[];for(o=0;o<12;o++)n[o]=ji(t,o,i,"month");return n}function Hi(t,e,i,o){"boolean"==typeof t?("number"==typeof e&&(i=e,e=void 0),e=e||""):(e=t,i=e,t=!1,"number"==typeof e&&(i=e,e=void 0),e=e||"");var n=ee(),s=t?n._week.dow:0;if(null!=i)return ji(e,(i+s)%7,o,"day");var r,a=[];for(r=0;r<7;r++)a[r]=ji(e,(r+s)%7,o,"day");return a}function Wi(t,e){return Fi(t,e,"months")}function Yi(t,e){return Fi(t,e,"monthsShort")}function Gi(t,e,i){return Hi(t,e,i,"weekdays")}function Vi(t,e,i){return Hi(t,e,i,"weekdaysShort")}function Ui(t,e,i){return Hi(t,e,i,"weekdaysMin")}function qi(){var t=this._data;return this._milliseconds=Zn(this._milliseconds),this._days=Zn(this._days),this._months=Zn(this._months),t.milliseconds=Zn(t.milliseconds),t.seconds=Zn(t.seconds),t.minutes=Zn(t.minutes),t.hours=Zn(t.hours),t.months=Zn(t.months),t.years=Zn(t.years),this}function Xi(t,e,i,o){var n=Fe(e,i);return t._milliseconds+=o*n._milliseconds,t._days+=o*n._days,t._months+=o*n._months,t._bubble()}function Zi(t,e){return Xi(this,t,e,1)}function Ki(t,e){return Xi(this,t,e,-1)}function Ji(t){return t<0?Math.floor(t):Math.ceil(t)}function Qi(){var t,e,i,o,n,s=this._milliseconds,r=this._days,a=this._months,h=this._data;return s>=0&&r>=0&&a>=0||s<=0&&r<=0&&a<=0||(s+=864e5*Ji(to(a)+r),r=0,a=0),h.milliseconds=s%1e3,t=b(s/1e3),h.seconds=t%60,e=b(t/60),h.minutes=e%60,i=b(e/60),h.hours=i%24,r+=b(i/24),n=b($i(r)),a+=n,r-=Ji(to(n)),o=b(a/12),a%=12,h.days=r,h.months=a,h.years=o,this}function $i(t){return 4800*t/146097}function to(t){return 146097*t/4800}function eo(t){var e,i,o=this._milliseconds;if(t=z(t),"month"===t||"year"===t)return e=this._days+o/864e5,i=this._months+$i(e),"month"===t?i:i/12;switch(e=this._days+Math.round(to(this._months)),t){case"week":return e/7+o/6048e5;case"day":return e+o/864e5;case"hour":return 24*e+o/36e5;case"minute":return 1440*e+o/6e4;case"second":return 86400*e+o/1e3;case"millisecond":return Math.floor(864e5*e)+o;default:throw new Error("Unknown unit "+t)}}function io(){return this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*_(this._months/12)}function oo(t){return function(){return this.as(t)}}function no(t){return t=z(t),this[t+"s"]()}function so(t){return function(){return this._data[t]}}function ro(){return b(this.days()/7)}function ao(t,e,i,o,n){return n.relativeTime(e||1,!!i,t,o)}function ho(t,e,i){var o=Fe(t).abs(),n=cs(o.as("s")),s=cs(o.as("m")),r=cs(o.as("h")),a=cs(o.as("d")),h=cs(o.as("M")),d=cs(o.as("y")),l=n0,l[4]=i,ao.apply(null,l)}function lo(t){return void 0===t?cs:"function"==typeof t&&(cs=t,!0)}function co(t,e){return void 0!==us[t]&&(void 0===e?us[t]:(us[t]=e,!0))}function uo(t){var e=this.localeData(),i=ho(this,!t,e);return t&&(i=e.pastFuture(+this,i)),e.postformat(i)}function po(){var t,e,i,o=ps(this._milliseconds)/1e3,n=ps(this._days),s=ps(this._months);t=b(o/60),e=b(t/60),o%=60,t%=60,i=b(s/12),s%=12;var r=i,a=s,h=n,d=e,l=t,c=o,u=this.asSeconds();return u?(u<0?"-":"")+"P"+(r?r+"Y":"")+(a?a+"M":"")+(h?h+"D":"")+(d||l||c?"T":"")+(d?d+"H":"")+(l?l+"M":"")+(c?c+"S":""):"P0D"}var fo,mo;mo=Array.prototype.some?Array.prototype.some:function(t){for(var e=Object(this),i=e.length>>>0,o=0;o68?1900:2e3)};var pn=F("FullYear",!0);U("w",["ww",2],"wo","week"),U("W",["WW",2],"Wo","isoWeek"),L("week","w"),L("isoWeek","W"),B("week",5),B("isoWeek",5),J("w",Bo),J("ww",Bo,Ro),J("W",Bo),J("WW",Bo,Ro),it(["w","ww","W","WW"],function(t,e,i,o){e[o.substr(0,1)]=_(t)});var fn={dow:0,doy:6};U("d",0,"do","day"),U("dd",0,0,function(t){return this.localeData().weekdaysMin(this,t)}),U("ddd",0,0,function(t){return this.localeData().weekdaysShort(this,t)}),U("dddd",0,0,function(t){return this.localeData().weekdays(this,t)}),U("e",0,0,"weekday"),U("E",0,0,"isoWeekday"),L("day","d"),L("weekday","e"),L("isoWeekday","E"),B("day",11),B("weekday",11),B("isoWeekday",11),J("d",Bo),J("e",Bo),J("E",Bo),J("dd",function(t,e){return e.weekdaysMinRegex(t)}),J("ddd",function(t,e){return e.weekdaysShortRegex(t)}),J("dddd",function(t,e){return e.weekdaysRegex(t)}),it(["dd","ddd","dddd"],function(t,e,i,o){var n=i._locale.weekdaysParse(t,o,i._strict);null!=n?e.d=n:u(i).invalidWeekday=t}),it(["d","e","E"],function(t,e,i,o){e[o]=_(t)});var mn="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),vn="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),gn="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),yn=Zo,bn=Zo,_n=Zo;U("H",["HH",2],0,"hour"),U("h",["hh",2],0,Yt),U("k",["kk",2],0,Gt),U("hmm",0,0,function(){return""+Yt.apply(this)+V(this.minutes(),2)}),U("hmmss",0,0,function(){return""+Yt.apply(this)+V(this.minutes(),2)+V(this.seconds(),2)}),U("Hmm",0,0,function(){return""+this.hours()+V(this.minutes(),2)}),U("Hmmss",0,0,function(){return""+this.hours()+V(this.minutes(),2)+V(this.seconds(),2)}),Vt("a",!0),Vt("A",!1),L("hour","h"),B("hour",13),J("a",Ut),J("A",Ut),J("H",Bo),J("h",Bo),J("HH",Bo,Ro),J("hh",Bo,Ro),J("hmm",jo),J("hmmss",Fo),J("Hmm",jo),J("Hmmss",Fo),et(["H","HH"],en),et(["a","A"],function(t,e,i){i._isPm=i._locale.isPM(t),i._meridiem=t}),et(["h","hh"],function(t,e,i){e[en]=_(t),u(i).bigHour=!0}),et("hmm",function(t,e,i){var o=t.length-2;e[en]=_(t.substr(0,o)),e[on]=_(t.substr(o)),u(i).bigHour=!0}),et("hmmss",function(t,e,i){var o=t.length-4,n=t.length-2;e[en]=_(t.substr(0,o)),e[on]=_(t.substr(o,2)),e[nn]=_(t.substr(n)),u(i).bigHour=!0}),et("Hmm",function(t,e,i){var o=t.length-2;e[en]=_(t.substr(0,o)),e[on]=_(t.substr(o))}),et("Hmmss",function(t,e,i){var o=t.length-4,n=t.length-2;e[en]=_(t.substr(0,o)),e[on]=_(t.substr(o,2)),e[nn]=_(t.substr(n))});var wn,xn=/[ap]\.?m?\.?/i,kn=F("Hours",!0),On={calendar:wo,longDateFormat:xo,invalidDate:ko,ordinal:Oo,ordinalParse:Do,relativeTime:So,months:dn,monthsShort:ln,week:fn,weekdays:mn,weekdaysMin:gn,weekdaysShort:vn,meridiemParse:xn},Dn={},Sn=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?/,Cn=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?/,Tn=/Z|[+-]\d\d(?::?\d\d)?/,En=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/]],Mn=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],Pn=/^\/?Date\((\-?\d+)/i;e.createFromInputFallback=k("value provided is not in a recognized ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.",function(t){t._d=new Date(t._i+(t._useUTC?" UTC":""))}),e.ISO_8601=function(){};var In=k("moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var t=ye.apply(null,arguments);return this.isValid()&&t.isValid()?tthis?this:t:f()}),Rn=function(){return Date.now?Date.now():+new Date};De("Z",":"),De("ZZ",""),J("Z",qo),J("ZZ",qo),et(["Z","ZZ"],function(t,e,i){i._useUTC=!0,i._tzm=Se(qo,t)});var Ln=/([\+\-]|\d\d)/gi;e.updateOffset=function(){};var zn=/^(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/,An=/^(-)?P(?:(-?[0-9,.]*)Y)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)W)?(?:(-?[0-9,.]*)D)?(?:T(?:(-?[0-9,.]*)H)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)S)?)?$/;Fe.fn=xe.prototype;var Bn=Ge(1,"add"),jn=Ge(-1,"subtract");e.defaultFormat="YYYY-MM-DDTHH:mm:ssZ",e.defaultFormatUtc="YYYY-MM-DDTHH:mm:ss[Z]";var Fn=k("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(t){return void 0===t?this.localeData():this.locale(t)});U(0,["gg",2],0,function(){return this.weekYear()%100}),U(0,["GG",2],0,function(){return this.isoWeekYear()%100}),Oi("gggg","weekYear"),Oi("ggggg","weekYear"),Oi("GGGG","isoWeekYear"),Oi("GGGGG","isoWeekYear"),L("weekYear","gg"),L("isoWeekYear","GG"),B("weekYear",1),B("isoWeekYear",1),J("G",Vo),J("g",Vo),J("GG",Bo,Ro),J("gg",Bo,Ro),J("GGGG",Wo,zo),J("gggg",Wo,zo),J("GGGGG",Yo,Ao),J("ggggg",Yo,Ao),it(["gggg","ggggg","GGGG","GGGGG"],function(t,e,i,o){e[o.substr(0,2)]=_(t)}),it(["gg","GG"],function(t,i,o,n){i[n]=e.parseTwoDigitYear(t)}),U("Q",0,"Qo","quarter"),L("quarter","Q"),B("quarter",7),J("Q",No),et("Q",function(t,e){e[$o]=3*(_(t)-1)}),U("D",["DD",2],"Do","date"),L("date","D"),B("date",9),J("D",Bo),J("DD",Bo,Ro),J("Do",function(t,e){return t?e._ordinalParse:e._ordinalParseLenient}),et(["D","DD"],tn),et("Do",function(t,e){e[tn]=_(t.match(Bo)[0],10)});var Hn=F("Date",!0);U("DDD",["DDDD",3],"DDDo","dayOfYear"),L("dayOfYear","DDD"),B("dayOfYear",4),J("DDD",Ho),J("DDDD",Lo),et(["DDD","DDDD"],function(t,e,i){i._dayOfYear=_(t)}),U("m",["mm",2],0,"minute"),L("minute","m"),B("minute",14),J("m",Bo),J("mm",Bo,Ro),et(["m","mm"],on);var Wn=F("Minutes",!1);U("s",["ss",2],0,"second"),L("second","s"),B("second",15),J("s",Bo),J("ss",Bo,Ro),et(["s","ss"],nn);var Yn=F("Seconds",!1);U("S",0,0,function(){return~~(this.millisecond()/100)}),U(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),U(0,["SSS",3],0,"millisecond"),U(0,["SSSS",4],0,function(){return 10*this.millisecond()}),U(0,["SSSSS",5],0,function(){return 100*this.millisecond()}),U(0,["SSSSSS",6],0,function(){return 1e3*this.millisecond()}),U(0,["SSSSSSS",7],0,function(){return 1e4*this.millisecond()}),U(0,["SSSSSSSS",8],0,function(){return 1e5*this.millisecond()}),U(0,["SSSSSSSSS",9],0,function(){return 1e6*this.millisecond()}),L("millisecond","ms"),B("millisecond",16),J("S",Ho,No),J("SS",Ho,Ro),J("SSS",Ho,Lo);var Gn;for(Gn="SSSS";Gn.length<=9;Gn+="S")J(Gn,Go);for(Gn="S";Gn.length<=9;Gn+="S")et(Gn,Ni);var Vn=F("Milliseconds",!1);U("z",0,0,"zoneAbbr"),U("zz",0,0,"zoneName");var Un=g.prototype;Un.add=Bn,Un.calendar=qe,Un.clone=Xe,Un.diff=ei,Un.endOf=pi,Un.format=si,Un.from=ri,Un.fromNow=ai,Un.to=hi,Un.toNow=di,Un.get=Y,Un.invalidAt=xi,Un.isAfter=Ze,Un.isBefore=Ke,Un.isBetween=Je,Un.isSame=Qe,Un.isSameOrAfter=$e,Un.isSameOrBefore=ti,Un.isValid=_i,Un.lang=Fn,Un.locale=li,Un.localeData=ci,Un.max=Nn,Un.min=In,Un.parsingFlags=wi,Un.set=G,Un.startOf=ui,Un.subtract=jn,Un.toArray=gi,Un.toObject=yi,Un.toDate=vi,Un.toISOString=ni,Un.toJSON=bi,Un.toString=oi,Un.unix=mi,Un.valueOf=fi,Un.creationData=ki,Un.year=pn,Un.isLeapYear=gt,Un.weekYear=Di,Un.isoWeekYear=Si,Un.quarter=Un.quarters=Pi,Un.month=lt,Un.daysInMonth=ct,Un.week=Un.weeks=Ct,Un.isoWeek=Un.isoWeeks=Tt,Un.weeksInYear=Ti,Un.isoWeeksInYear=Ci,Un.date=Hn,Un.day=Un.days=zt,Un.weekday=At,Un.isoWeekday=Bt,Un.dayOfYear=Ii,Un.hour=Un.hours=kn,Un.minute=Un.minutes=Wn,Un.second=Un.seconds=Yn,Un.millisecond=Un.milliseconds=Vn,Un.utcOffset=Ee,Un.utc=Pe,Un.local=Ie,Un.parseZone=Ne,Un.hasAlignedHourOffset=Re,Un.isDST=Le,Un.isLocal=Ae,Un.isUtcOffset=Be,Un.isUtc=je,Un.isUTC=je,Un.zoneAbbr=Ri,Un.zoneName=Li,Un.dates=k("dates accessor is deprecated. Use date instead.",Hn),Un.months=k("months accessor is deprecated. Use month instead",lt),Un.years=k("years accessor is deprecated. Use year instead",pn),Un.zone=k("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",Me),Un.isDSTShifted=k("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",ze);var qn=Un,Xn=T.prototype;Xn.calendar=E,Xn.longDateFormat=M,Xn.invalidDate=P,Xn.ordinal=I,Xn.preparse=Bi,Xn.postformat=Bi,Xn.relativeTime=N,Xn.pastFuture=R,Xn.set=S,Xn.months=st,Xn.monthsShort=rt,Xn.monthsParse=ht,Xn.monthsRegex=pt,Xn.monthsShortRegex=ut,Xn.week=Ot,Xn.firstDayOfYear=St,Xn.firstDayOfWeek=Dt,Xn.weekdays=Pt,Xn.weekdaysMin=Nt,Xn.weekdaysShort=It,Xn.weekdaysParse=Lt,Xn.weekdaysRegex=jt,Xn.weekdaysShortRegex=Ft,Xn.weekdaysMinRegex=Ht,Xn.isPM=qt,Xn.meridiem=Xt,Qt("en",{ordinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(t){var e=t%10,i=1===_(t%100/10)?"th":1===e?"st":2===e?"nd":3===e?"rd":"th";return t+i}}),e.lang=k("moment.lang is deprecated. Use moment.locale instead.",Qt),e.langData=k("moment.langData is deprecated. Use moment.localeData instead.",ee);var Zn=Math.abs,Kn=oo("ms"),Jn=oo("s"),Qn=oo("m"),$n=oo("h"),ts=oo("d"),es=oo("w"),is=oo("M"),os=oo("y"),ns=so("milliseconds"),ss=so("seconds"),rs=so("minutes"),as=so("hours"),hs=so("days"),ds=so("months"),ls=so("years"),cs=Math.round,us={s:45,m:45,h:22,d:26,M:11},ps=Math.abs,fs=xe.prototype;fs.abs=qi,fs.add=Zi,fs.subtract=Ki,fs.as=eo,fs.asMilliseconds=Kn,fs.asSeconds=Jn,fs.asMinutes=Qn,fs.asHours=$n,fs.asDays=ts,fs.asWeeks=es,fs.asMonths=is,fs.asYears=os,fs.valueOf=io,fs._bubble=Qi,fs.get=no,fs.milliseconds=ns,fs.seconds=ss,fs.minutes=rs,fs.hours=as,fs.days=hs,fs.weeks=ro,fs.months=ds,fs.years=ls,fs.humanize=uo,fs.toISOString=po,fs.toString=po,fs.toJSON=po,fs.locale=li,fs.localeData=ci,fs.toIsoString=k("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",po),fs.lang=Fn,U("X",0,0,"unix"),U("x",0,0,"valueOf"),J("x",Vo),J("X",Xo),et("X",function(t,e,i){i._d=new Date(1e3*parseFloat(t,10))}),et("x",function(t,e,i){i._d=new Date(_(t))}),e.version="2.15.2",i(ye),e.fn=qn,e.min=_e,e.max=we,e.now=Rn,e.utc=l,e.unix=zi,e.months=Wi,e.isDate=r,e.locale=Qt,e.invalid=f,e.duration=Fe,e.isMoment=y,e.weekdays=Gi,e.parseZone=Ai,e.localeData=ee,e.isDuration=ke,e.monthsShort=Yi,e.weekdaysMin=Ui,e.defineLocale=$t,e.updateLocale=te,e.locales=ie,e.weekdaysShort=Vi,e.normalizeUnits=z,e.relativeTimeRounding=lo,e.relativeTimeThreshold=co,e.calendarFormat=Ue,e.prototype=qn;var ms=e;return ms})}).call(e,i(4)(t))},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children=[],t.webpackPolyfill=1),t}},function(t,e){function i(t){throw new Error("Cannot find module '"+t+"'.")}i.keys=function(){return[]},i.resolve=i,t.exports=i,i.id=5},function(t,e){(function(e){function i(t,e,i){var o=e&&i||0,n=0;for(e=e||[],t.toLowerCase().replace(/[0-9a-f]{2}/g,function(t){n<16&&(e[o+n++]=c[t])});n<16;)e[o+n++]=0;return e}function o(t,e){var i=e||0,o=l;return o[t[i++]]+o[t[i++]]+o[t[i++]]+o[t[i++]]+"-"+o[t[i++]]+o[t[i++]]+"-"+o[t[i++]]+o[t[i++]]+"-"+o[t[i++]]+o[t[i++]]+"-"+o[t[i++]]+o[t[i++]]+o[t[i++]]+o[t[i++]]+o[t[i++]]+o[t[i++]]}function n(t,e,i){var n=e&&i||0,s=e||[];t=t||{};var r=void 0!==t.clockseq?t.clockseq:m,a=void 0!==t.msecs?t.msecs:(new Date).getTime(),h=void 0!==t.nsecs?t.nsecs:g+1,d=a-v+(h-g)/1e4;if(d<0&&void 0===t.clockseq&&(r=r+1&16383),(d<0||a>v)&&void 0===t.nsecs&&(h=0),h>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");v=a,g=h,m=r,a+=122192928e5;var l=(1e4*(268435455&a)+h)%4294967296;s[n++]=l>>>24&255,s[n++]=l>>>16&255,s[n++]=l>>>8&255,s[n++]=255&l;var c=a/4294967296*1e4&268435455;s[n++]=c>>>8&255,s[n++]=255&c,s[n++]=c>>>24&15|16,s[n++]=c>>>16&255,s[n++]=r>>>8|128,s[n++]=255&r;for(var u=t.node||f,p=0;p<6;p++)s[n+p]=u[p];return e?e:o(s)}function s(t,e,i){var n=e&&i||0;"string"==typeof t&&(e="binary"==t?new Array(16):null, +t=null),t=t||{};var s=t.random||(t.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,e)for(var a=0;a<16;a++)e[n+a]=s[a];return e||o(s)}var r,a="undefined"!=typeof window?window:"undefined"!=typeof e?e:null;if(a&&a.crypto&&crypto.getRandomValues){var h=new Uint8Array(16);r=function(){return crypto.getRandomValues(h),h}}if(!r){var d=new Array(16);r=function(){for(var t,e=0;e<16;e++)0===(3&e)&&(t=4294967296*Math.random()),d[e]=t>>>((3&e)<<3)&255;return d}}for(var l=[],c={},u=0;u<256;u++)l[u]=(u+256).toString(16).substr(1),c[l[u]]=u;var p=r(),f=[1|p[0],p[1],p[2],p[3],p[4],p[5]],m=16383&(p[6]<<8|p[7]),v=0,g=0,y=s;y.v1=n,y.v4=s,y.parse=i,y.unparse=o,t.exports=y}).call(e,function(){return this}())},function(t,e,i){e.util=i(1),e.DOMutil=i(8),e.DataSet=i(9),e.DataView=i(11),e.Queue=i(10),e.Graph3d=i(12),e.graph3d={Camera:i(16),Filter:i(17),Point2d:i(15),Point3d:i(14),Slider:i(18),StepNumber:i(19)},e.moment=i(2),e.Hammer=i(22),e.keycharm=i(25)},function(t,e){e.prepareElements=function(t){for(var e in t)t.hasOwnProperty(e)&&(t[e].redundant=t[e].used,t[e].used=[])},e.cleanupElements=function(t){for(var e in t)if(t.hasOwnProperty(e)&&t[e].redundant){for(var i=0;i0?(o=e[t].redundant[0],e[t].redundant.shift()):(o=document.createElementNS("http://www.w3.org/2000/svg",t),i.appendChild(o)):(o=document.createElementNS("http://www.w3.org/2000/svg",t),e[t]={used:[],redundant:[]},i.appendChild(o)),e[t].used.push(o),o},e.getDOMElement=function(t,e,i,o){var n;return e.hasOwnProperty(t)?e[t].redundant.length>0?(n=e[t].redundant[0],e[t].redundant.shift()):(n=document.createElement(t),void 0!==o?i.insertBefore(n,o):i.appendChild(n)):(n=document.createElement(t),e[t]={used:[],redundant:[]},void 0!==o?i.insertBefore(n,o):i.appendChild(n)),e[t].used.push(n),n},e.drawPoint=function(t,i,o,n,s,r){var a;if("circle"==o.style?(a=e.getSVGElement("circle",n,s),a.setAttributeNS(null,"cx",t),a.setAttributeNS(null,"cy",i),a.setAttributeNS(null,"r",.5*o.size)):(a=e.getSVGElement("rect",n,s),a.setAttributeNS(null,"x",t-.5*o.size),a.setAttributeNS(null,"y",i-.5*o.size),a.setAttributeNS(null,"width",o.size),a.setAttributeNS(null,"height",o.size)),void 0!==o.styles&&a.setAttributeNS(null,"style",o.styles),a.setAttributeNS(null,"class",o.className+" vis-point"),r){var h=e.getSVGElement("text",n,s);r.xOffset&&(t+=r.xOffset),r.yOffset&&(i+=r.yOffset),r.content&&(h.textContent=r.content),r.className&&h.setAttributeNS(null,"class",r.className+" vis-label"),h.setAttributeNS(null,"x",t),h.setAttributeNS(null,"y",i)}return a},e.drawBar=function(t,i,o,n,s,r,a,h){if(0!=n){n<0&&(n*=-1,i-=n);var d=e.getSVGElement("rect",r,a);d.setAttributeNS(null,"x",t-.5*o),d.setAttributeNS(null,"y",i),d.setAttributeNS(null,"width",o),d.setAttributeNS(null,"height",n),d.setAttributeNS(null,"class",s),h&&d.setAttributeNS(null,"style",h)}}},function(t,e,i){function o(t,e){if(t&&!Array.isArray(t)&&(e=t,t=null),this._options=e||{},this._data={},this.length=0,this._fieldId=this._options.fieldId||"id",this._type={},this._options.type)for(var i=Object.keys(this._options.type),o=0,n=i.length;on?1:or)&&(s=h,r=d)}return s},o.prototype.min=function(t){var e,i,o=this._data,n=Object.keys(o),s=null,r=null;for(e=0,i=n.length;ethis.max&&this.flush(),clearTimeout(this._timeout),this.queue.length>0&&"number"==typeof this.delay){var t=this;this._timeout=setTimeout(function(){t.flush()},this.delay)}},i.prototype.flush=function(){for(;this._queue.length>0;){var t=this._queue.shift();t.fn.apply(t.context||t.fn,t.args||[])}},t.exports=i},function(t,e,i){function o(t,e){this._data=null,this._ids={},this.length=0,this._options=e||{},this._fieldId="id",this._subscribers={};var i=this;this.listener=function(){i._onEvent.apply(i,arguments)},this.setData(t)}var n=i(1),s=i(9);o.prototype.setData=function(t){var e,i,o,n,s;if(this._data){for(this._data.off&&this._data.off("*",this.listener),e=this._data.getIds({filter:this._options&&this._options.filter}),s=[],o=0,n=e.length;o0&&(h[n-1].pointNext=r),h.push(r);return h},o.prototype.create=function(){for(;this.containerElement.hasChildNodes();)this.containerElement.removeChild(this.containerElement.firstChild);this.frame=document.createElement("div"),this.frame.style.position="relative",this.frame.style.overflow="hidden",this.frame.canvas=document.createElement("canvas"),this.frame.canvas.style.position="relative",this.frame.appendChild(this.frame.canvas);var t=document.createElement("DIV");t.style.color="red",t.style.fontWeight="bold",t.style.padding="10px",t.innerHTML="Error: your browser does not support HTML canvas",this.frame.canvas.appendChild(t),this.frame.filter=document.createElement("div"),this.frame.filter.style.position="absolute",this.frame.filter.style.bottom="0px",this.frame.filter.style.left="0px",this.frame.filter.style.width="100%",this.frame.appendChild(this.frame.filter);var e=this,i=function(t){e._onMouseDown(t)},o=function(t){e._onTouchStart(t)},n=function(t){e._onWheel(t)},s=function(t){e._onTooltip(t)};d.addEventListener(this.frame.canvas,"keydown",onkeydown),d.addEventListener(this.frame.canvas,"mousedown",i),d.addEventListener(this.frame.canvas,"touchstart",o),d.addEventListener(this.frame.canvas,"mousewheel",n),d.addEventListener(this.frame.canvas,"mousemove",s),this.containerElement.appendChild(this.frame)},o.prototype.setSize=function(t,e){this.frame.style.width=t,this.frame.style.height=e,this._resizeCanvas()},o.prototype._resizeCanvas=function(){this.frame.canvas.style.width="100%",this.frame.canvas.style.height="100%",this.frame.canvas.width=this.frame.canvas.clientWidth,this.frame.canvas.height=this.frame.canvas.clientHeight,this.frame.filter.style.width=this.frame.canvas.clientWidth-20+"px"},o.prototype.animationStart=function(){if(!this.frame.filter||!this.frame.filter.slider)throw new Error("No animation available");this.frame.filter.slider.play()},o.prototype.animationStop=function(){this.frame.filter&&this.frame.filter.slider&&this.frame.filter.slider.stop()},o.prototype._resizeCenter=function(){"%"===this.xCenter.charAt(this.xCenter.length-1)?this.currentXCenter=parseFloat(this.xCenter)/100*this.frame.canvas.clientWidth:this.currentXCenter=parseFloat(this.xCenter),"%"===this.yCenter.charAt(this.yCenter.length-1)?this.currentYCenter=parseFloat(this.yCenter)/100*(this.frame.canvas.clientHeight-this.frame.filter.clientHeight):this.currentYCenter=parseFloat(this.yCenter)},o.prototype.getCameraPosition=function(){var t=this.camera.getArmRotation();return t.distance=this.camera.getArmLength(),t},o.prototype._readData=function(t){this._dataInitialize(t,this.style),this.dataFilter?this.dataPoints=this.dataFilter._getDataPoints():this.dataPoints=this._getDataPoints(this.dataTable),this._redrawFilter()},o.prototype.setData=function(t){this._readData(t),this.redraw(),this.animationAutoStart&&this.dataFilter&&this.animationStart()},o.prototype.setOptions=function(t){this.animationStop(),v.setOptions(t,this),this.setPointDrawingMethod(),this.setSize(this.width,this.height),this.dataTable&&this.setData(this.dataTable),this.animationAutoStart&&this.dataFilter&&this.animationStart()},o.prototype.setPointDrawingMethod=function(){var t=void 0;switch(this.style){case o.STYLE.BAR:t=o.prototype._redrawBarGraphPoint;break;case o.STYLE.BARCOLOR:t=o.prototype._redrawBarColorGraphPoint;break;case o.STYLE.BARSIZE:t=o.prototype._redrawBarSizeGraphPoint;break;case o.STYLE.DOT:t=o.prototype._redrawDotGraphPoint;break;case o.STYLE.DOTLINE:t=o.prototype._redrawDotLineGraphPoint;break;case o.STYLE.DOTCOLOR:t=o.prototype._redrawDotColorGraphPoint;break;case o.STYLE.DOTSIZE:t=o.prototype._redrawDotSizeGraphPoint;break;case o.STYLE.SURFACE:t=o.prototype._redrawSurfaceGraphPoint;break;case o.STYLE.GRID:t=o.prototype._redrawGridGraphPoint;break;case o.STYLE.LINE:t=o.prototype._redrawLineGraphPoint;break;default:throw new Error("Can not determine point drawing method for graph style '"+this.style+"'")}this._pointDrawingMethod=t},o.prototype.redraw=function(){if(void 0===this.dataPoints)throw new Error("Graph data not initialized");this._resizeCanvas(),this._resizeCenter(),this._redrawSlider(),this._redrawClear(),this._redrawAxis(),this._redrawDataGraph(),this._redrawInfo(),this._redrawLegend()},o.prototype._getContext=function(){var t=this.frame.canvas,e=t.getContext("2d");return e.lineJoin="round",e.lineCap="round",e},o.prototype._redrawClear=function(){var t=this.frame.canvas,e=t.getContext("2d");e.clearRect(0,0,t.width,t.height)},o.prototype._dotSize=function(){return this.frame.clientWidth*this.dotSizeRatio},o.prototype._getLegendWidth=function(){var t;if(this.style===o.STYLE.DOTSIZE){var e=this._dotSize();t=e/2+2*e}else t=this.style===o.STYLE.BARSIZE?this.xBarWidth:20;return t},o.prototype._redrawLegend=function(){if(this.showLegend===!0&&this.style!==o.STYLE.LINE&&this.style!==o.STYLE.BARSIZE){var t=this.style===o.STYLE.BARSIZE||this.style===o.STYLE.DOTSIZE,e=this.style===o.STYLE.DOTSIZE||this.style===o.STYLE.DOTCOLOR||this.style===o.STYLE.BARCOLOR,i=Math.max(.25*this.frame.clientHeight,100),n=this.margin,s=this._getLegendWidth(),r=this.frame.clientWidth-this.margin,a=r-s,h=n+i,d=this._getContext();if(d.lineWidth=1,d.font="14px arial",t===!1){var l,u=0,p=i;for(l=u;l0?(t.textAlign="center",t.textBaseline="top",s.y+=n):Math.sin(2*o)<0?(t.textAlign="right",t.textBaseline="middle"):(t.textAlign="left",t.textBaseline="middle"),t.fillStyle=this.axisColor,t.fillText(i,s.x,s.y)},o.prototype.drawAxisLabelY=function(t,e,i,o,n){void 0===n&&(n=0);var s=this._convert3Dto2D(e);Math.cos(2*o)<0?(t.textAlign="center",t.textBaseline="top",s.y+=n):Math.sin(2*o)>0?(t.textAlign="right",t.textBaseline="middle"):(t.textAlign="left",t.textBaseline="middle"),t.fillStyle=this.axisColor,t.fillText(i,s.x,s.y)},o.prototype.drawAxisLabelZ=function(t,e,i,o){void 0===o&&(o=0);var n=this._convert3Dto2D(e);t.textAlign="right",t.textBaseline="middle",t.fillStyle=this.axisColor,t.fillText(i,n.x-o,n.y)},o.prototype._line3d=function(t,e,i,o){var n=this._convert3Dto2D(e),s=this._convert3Dto2D(i);this._line(t,n,s,o)},o.prototype._redrawAxis=function(){var t,e,i,o,n,s,r,a,h,d,u,p=this._getContext();p.font=24/this.camera.getArmLength()+"px arial";var m=.025/this.scale.x,v=.025/this.scale.y,g=5/this.camera.getArmLength(),y=this.camera.getArmRotation().horizontal,b=new c(Math.cos(y),Math.sin(y)),_=this.xRange,w=this.yRange,x=this.zRange;for(p.lineWidth=1,o=void 0===this.defaultXStep,i=new f(_.min,_.max,this.xStep,o),i.start(!0);!i.end();){var k=i.getCurrent();this.showGrid?(t=new l(k,w.min,x.min),e=new l(k,w.max,x.min),this._line3d(p,t,e,this.gridColor)):(t=new l(k,w.min,x.min),e=new l(k,w.min+m,x.min),this._line3d(p,t,e,this.axisColor),t=new l(k,w.max,x.min),e=new l(k,w.max-m,x.min),this._line3d(p,t,e,this.axisColor)),r=b.x>0?w.min:w.max;var O=new l(k,r,x.min),D=" "+this.xValueLabel(k)+" ";this.drawAxisLabelX(p,O,D,y,g),i.next()}for(p.lineWidth=1,o=void 0===this.defaultYStep,i=new f(w.min,w.max,this.yStep,o),i.start(!0);!i.end();){var S=i.getCurrent();this.showGrid?(t=new l(_.min,S,x.min),e=new l(_.max,S,x.min),this._line3d(p,t,e,this.gridColor)):(t=new l(_.min,S,x.min),e=new l(_.min+v,S,x.min),this._line3d(p,t,e,this.axisColor),t=new l(_.max,S,x.min),e=new l(_.max-v,S,x.min),this._line3d(p,t,e,this.axisColor)),s=b.y>0?_.min:_.max,O=new l(s,S,x.min);var D=" "+this.yValueLabel(S)+" ";this.drawAxisLabelY(p,O,D,y,g),i.next()}for(p.lineWidth=1,o=void 0===this.defaultZStep,i=new f(x.min,x.max,this.zStep,o), +i.start(!0),s=b.x>0?_.min:_.max,r=b.y<0?w.min:w.max;!i.end();){var C=i.getCurrent(),T=new l(s,r,C),E=this._convert3Dto2D(T);e=new c(E.x-g,E.y),this._line(p,E,e,this.axisColor);var D=this.zValueLabel(C)+" ";this.drawAxisLabelZ(p,T,D,5),i.next()}p.lineWidth=1,t=new l(s,r,x.min),e=new l(s,r,x.max),this._line3d(p,t,e,this.axisColor);var M,P;p.lineWidth=1,M=new l(_.min,w.min,x.min),P=new l(_.max,w.min,x.min),this._line3d(p,M,P,this.axisColor),M=new l(_.min,w.max,x.min),P=new l(_.max,w.max,x.min),this._line3d(p,M,P,this.axisColor),p.lineWidth=1,t=new l(_.min,w.min,x.min),e=new l(_.min,w.max,x.min),this._line3d(p,t,e,this.axisColor),t=new l(_.max,w.min,x.min),e=new l(_.max,w.max,x.min),this._line3d(p,t,e,this.axisColor);var I=this.xLabel;I.length>0&&(u=.1/this.scale.y,s=_.center()/2,r=b.x>0?w.min-u:w.max+u,n=new l(s,r,x.min),this.drawAxisLabelX(p,n,I,y));var N=this.yLabel;N.length>0&&(d=.1/this.scale.x,s=b.y>0?_.min-d:_.max+d,r=w.center()/2,n=new l(s,r,x.min),this.drawAxisLabelY(p,n,N,y));var R=this.zLabel;R.length>0&&(h=30,s=b.x>0?_.min:_.max,r=b.y<0?w.min:w.max,a=x.center()/2,n=new l(s,r,a),this.drawAxisLabelZ(p,n,R,h))},o.prototype._hsv2rgb=function(t,e,i){var o,n,s,r,a,h;switch(r=i*e,a=Math.floor(t/60),h=r*(1-Math.abs(t/60%2-1)),a){case 0:o=r,n=h,s=0;break;case 1:o=h,n=r,s=0;break;case 2:o=0,n=r,s=h;break;case 3:o=0,n=h,s=r;break;case 4:o=h,n=0,s=r;break;case 5:o=r,n=0,s=h;break;default:o=0,n=0,s=0}return"RGB("+parseInt(255*o)+","+parseInt(255*n)+","+parseInt(255*s)+")"},o.prototype._getStrokeWidth=function(t){return void 0!==t?this.showPerspective?1/-t.trans.z*this.dataColor.strokeWidth:-(this.eye.z/this.camera.getArmLength())*this.dataColor.strokeWidth:this.dataColor.strokeWidth},o.prototype._redrawBar=function(t,e,i,o,n,s){var r,a,h=this,d=e.point,c=this.zRange.min,u=[{point:new l(d.x-i,d.y-o,d.z)},{point:new l(d.x+i,d.y-o,d.z)},{point:new l(d.x+i,d.y+o,d.z)},{point:new l(d.x-i,d.y+o,d.z)}],p=[{point:new l(d.x-i,d.y-o,c)},{point:new l(d.x+i,d.y-o,c)},{point:new l(d.x+i,d.y+o,c)},{point:new l(d.x-i,d.y+o,c)}];u.forEach(function(t){t.screen=h._convert3Dto2D(t.point)}),p.forEach(function(t){t.screen=h._convert3Dto2D(t.point)});var f=[{corners:u,center:l.avg(p[0].point,p[2].point)},{corners:[u[0],u[1],p[1],p[0]],center:l.avg(p[1].point,p[0].point)},{corners:[u[1],u[2],p[2],p[1]],center:l.avg(p[2].point,p[1].point)},{corners:[u[2],u[3],p[3],p[2]],center:l.avg(p[3].point,p[2].point)},{corners:[u[3],u[0],p[0],p[3]],center:l.avg(p[0].point,p[3].point)}];for(e.surfaces=f,r=0;r0}if(a){var p,f=(e.point.z+i.point.z+o.point.z+n.point.z)/4,m=240*(1-(f-this.zRange.min)*this.scale.z/this.verticalRatio),v=1;this.showShadow?(p=Math.min(1+c.x/u/2,1),s=this._hsv2rgb(m,v,p),r=s):(p=1,s=this._hsv2rgb(m,v,p),r=this.axisColor)}else s="gray",r=this.axisColor;t.lineWidth=this._getStrokeWidth(e);var g=[e,i,n,o];this._polygon(t,g,s,r)}},o.prototype._drawGridLine=function(t,e,i){if(void 0!==e&&void 0!==i){var o=(e.point.z+i.point.z)/2,n=240*(1-(o-this.zRange.min)*this.scale.z/this.verticalRatio);t.lineWidth=2*this._getStrokeWidth(e),t.strokeStyle=this._hsv2rgb(n,1,1),this._line(t,e.screen,i.screen)}},o.prototype._redrawGridGraphPoint=function(t,e){this._drawGridLine(t,e,e.pointRight),this._drawGridLine(t,e,e.pointTop)},o.prototype._redrawLineGraphPoint=function(t,e){void 0!==e.pointNext&&(t.lineWidth=this._getStrokeWidth(e),t.strokeStyle=this.dataColor.stroke,this._line(t,e.screen,e.pointNext.screen))},o.prototype._redrawDataGraph=function(){var t,e=this._getContext();if(!(void 0===this.dataPoints||this.dataPoints.length<=0))for(this._calcTranslations(this.dataPoints),t=0;t0?1:t<0?-1:0}var o=e[0],n=e[1],s=e[2],r=i((n.x-o.x)*(t.y-o.y)-(n.y-o.y)*(t.x-o.x)),a=i((s.x-n.x)*(t.y-n.y)-(s.y-n.y)*(t.x-n.x)),h=i((o.x-s.x)*(t.y-s.y)-(o.y-s.y)*(t.x-s.x));return!(0!=r&&0!=a&&r!=a||0!=a&&0!=h&&a!=h||0!=r&&0!=h&&r!=h)},o.prototype._dataPointFromXY=function(t,e){var i,n=100,s=null,r=null,a=null,h=new c(t,e);if(this.style===o.STYLE.BAR||this.style===o.STYLE.BARCOLOR||this.style===o.STYLE.BARSIZE)for(i=this.dataPoints.length-1;i>=0;i--){s=this.dataPoints[i];var d=s.surfaces;if(d)for(var l=d.length-1;l>=0;l--){var u=d[l],p=u.corners,f=[p[0].screen,p[1].screen,p[2].screen],m=[p[2].screen,p[3].screen,p[0].screen];if(this._insideTriangle(h,f)||this._insideTriangle(h,m))return s}}else for(i=0;i"+this.xLabel+":"+t.point.x+""+this.yLabel+":"+t.point.y+""+this.zLabel+":"+t.point.z+"",e.style.left="0",e.style.top="0",this.frame.appendChild(e),this.frame.appendChild(i),this.frame.appendChild(o);var n=e.offsetWidth,s=e.offsetHeight,r=i.offsetHeight,a=o.offsetWidth,h=o.offsetHeight,d=t.screen.x-n/2;d=Math.min(Math.max(d,10),this.frame.clientWidth-10-n),i.style.left=t.screen.x+"px",i.style.top=t.screen.y-r+"px",e.style.left=d+"px",e.style.top=t.screen.y-r-s+"px",o.style.left=t.screen.x-a/2+"px",o.style.top=t.screen.y-h/2+"px"},o.prototype._hideTooltip=function(){if(this.tooltip){this.tooltip.dataPoint=null;for(var t in this.tooltip.dom)if(this.tooltip.dom.hasOwnProperty(t)){var e=this.tooltip.dom[t];e&&e.parentNode&&e.parentNode.removeChild(e)}}},o.prototype.setCameraPosition=function(t){v.setCameraPosition(t,this),this.redraw()},t.exports=o},function(t,e){function i(t){if(t)return o(t)}function o(t){for(var e in i.prototype)t[e]=i.prototype[e];return t}t.exports=i,i.prototype.on=i.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[t]=this._callbacks[t]||[]).push(e),this},i.prototype.once=function(t,e){function i(){o.off(t,i),e.apply(this,arguments)}var o=this;return this._callbacks=this._callbacks||{},i.fn=e,this.on(t,i),this},i.prototype.off=i.prototype.removeListener=i.prototype.removeAllListeners=i.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var i=this._callbacks[t];if(!i)return this;if(1==arguments.length)return delete this._callbacks[t],this;for(var o,n=0;n.5*Math.PI&&(this.armRotation.vertical=.5*Math.PI)),void 0===t&&void 0===e||this.calculateCameraOrientation()},o.prototype.getArmRotation=function(){var t={};return t.horizontal=this.armRotation.horizontal,t.vertical=this.armRotation.vertical,t},o.prototype.setArmLength=function(t){void 0!==t&&(this.armLength=t,this.armLength<.71&&(this.armLength=.71),this.armLength>5&&(this.armLength=5),this.calculateCameraOrientation())},o.prototype.getArmLength=function(){return this.armLength},o.prototype.getCameraLocation=function(){return this.cameraLocation},o.prototype.getCameraRotation=function(){return this.cameraRotation},o.prototype.calculateCameraOrientation=function(){this.cameraLocation.x=this.armLocation.x-this.armLength*Math.sin(this.armRotation.horizontal)*Math.cos(this.armRotation.vertical),this.cameraLocation.y=this.armLocation.y-this.armLength*Math.cos(this.armRotation.horizontal)*Math.cos(this.armRotation.vertical),this.cameraLocation.z=this.armLocation.z+this.armLength*Math.sin(this.armRotation.vertical),this.cameraRotation.x=Math.PI/2-this.armRotation.vertical,this.cameraRotation.y=0,this.cameraRotation.z=-this.armRotation.horizontal},t.exports=o},function(t,e,i){function o(t,e,i){this.data=t,this.column=e,this.graph=i,this.index=void 0,this.value=void 0,this.values=i.getDistinctValues(t.get(),this.column),this.values.sort(function(t,e){return t>e?1:t0&&this.selectValue(0),this.dataPoints=[],this.loaded=!1,this.onLoadCallback=void 0,i.animationPreload?(this.loaded=!1,this.loadInBackground()):this.loaded=!0}var n=i(11);o.prototype.isLoaded=function(){return this.loaded},o.prototype.getLoadedProgress=function(){for(var t=this.values.length,e=0;this.dataPoints[e];)e++;return Math.round(e/t*100)},o.prototype.getLabel=function(){return this.graph.filterLabel},o.prototype.getColumn=function(){return this.column},o.prototype.getSelectedValue=function(){if(void 0!==this.index)return this.values[this.index]},o.prototype.getValues=function(){return this.values},o.prototype.getValue=function(t){if(t>=this.values.length)throw new Error("Index out of range");return this.values[t]},o.prototype._getDataPoints=function(t){if(void 0===t&&(t=this.index),void 0===t)return[];var e;if(this.dataPoints[t])e=this.dataPoints[t];else{var i={};i.column=this.column,i.value=this.values[t];var o=new n(this.data,{filter:function(t){return t[i.column]==i.value}}).get();e=this.graph._getDataPoints(o),this.dataPoints[t]=e}return e},o.prototype.setOnLoadCallback=function(t){this.onLoadCallback=t},o.prototype.selectValue=function(t){if(t>=this.values.length)throw new Error("Index out of range");this.index=t,this.value=this.values[t]},o.prototype.loadInBackground=function(t){void 0===t&&(t=0);var e=this.graph.frame;if(t0&&(t--,this.setIndex(t))},o.prototype.next=function(){var t=this.getIndex();t0?this.setIndex(0):this.index=void 0},o.prototype.setIndex=function(t){if(!(tthis.values.length-1&&(o=this.values.length-1),o},o.prototype.indexToLeft=function(t){var e=parseFloat(this.frame.bar.style.width)-this.frame.slide.clientWidth-10,i=t/(this.values.length-1)*e,o=i+3;return o},o.prototype._onMouseMove=function(t){var e=t.clientX-this.startClientX,i=this.startSlideX+e,o=this.leftToIndex(i);this.setIndex(o),n.preventDefault()},o.prototype._onMouseUp=function(t){this.frame.style.cursor="auto",n.removeEventListener(document,"mousemove",this.onmousemove),n.removeEventListener(document,"mouseup",this.onmouseup),n.preventDefault()},t.exports=o},function(t,e){function i(t,e,i,o){this._start=0,this._end=0,this._step=1,this.prettyStep=!0,this.precision=5,this._current=0,this.setRange(t,e,i,o)}i.prototype.isNumeric=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},i.prototype.setRange=function(t,e,i,o){if(!this.isNumeric(t))throw new Error("Parameter 'start' is not numeric; value: "+t);if(!this.isNumeric(e))throw new Error("Parameter 'end' is not numeric; value: "+t);if(!this.isNumeric(i))throw new Error("Parameter 'step' is not numeric; value: "+t);this._start=t?t:0,this._end=e?e:0,this.setStep(i,o)},i.prototype.setStep=function(t,e){void 0===t||t<=0||(void 0!==e&&(this.prettyStep=e),this.prettyStep===!0?this._step=i.calculatePrettyStep(t):this._step=t)},i.calculatePrettyStep=function(t){var e=function(t){return Math.log(t)/Math.LN10},i=Math.pow(10,Math.round(e(t))),o=2*Math.pow(10,Math.round(e(t/2))),n=5*Math.pow(10,Math.round(e(t/5))),s=i;return Math.abs(o-t)<=Math.abs(s-t)&&(s=o),Math.abs(n-t)<=Math.abs(s-t)&&(s=n),s<=0&&(s=1),s},i.prototype.getCurrent=function(){return parseFloat(this._current.toPrecision(this.precision))},i.prototype.getStep=function(){return this._step},i.prototype.start=function(t){void 0===t&&(t=!1),this._current=this._start-this._start%this._step,t&&this.getCurrent()this._end},t.exports=i},function(t,e){function i(){this.min=void 0,this.max=void 0}i.prototype.adjust=function(t){void 0!==t&&((void 0===this.min||this.min>t)&&(this.min=t),(void 0===this.max||this.maxi)throw new Error("Passed expansion value makes range invalid");this.min=e,this.max=i}},i.prototype.range=function(){return this.max-this.min},i.prototype.center=function(){return(this.min+this.max)/2},t.exports=i},function(t,e,i){function o(t){for(var e in t)if(t.hasOwnProperty(e))return!1;return!0}function n(t){return void 0===t||""===t?t:t.charAt(0).toUpperCase()+t.slice(1)}function s(t,e){return void 0===t||""===t?e:t+n(e)}function r(t,e,i,o){var n,r;for(var a in i)n=i[a],r=s(o,n),e[r]=t[n]}function a(t,e,i,o){var n,r;for(var a in i)n=i[a],void 0!==t[n]&&(r=s(o,n),e[r]=t[n])}function h(t,e){if(void 0===t||o(t))throw new Error("No DEFAULTS passed");if(void 0===e)throw new Error("No dst passed");D=t,r(t,e,k),r(t,e,O,"default"),l(t,e),e.margin=10,e.showGrayBottom=!1,e.showTooltip=!1,e.eye=new _(0,0,-1)}function d(t,e){if(void 0!==t){if(void 0===e)throw new Error("No dst passed");if(void 0===D||o(D))throw new Error("DEFAULTS not set for module Settings");a(t,e,k),a(t,e,O,"default"),l(t,e)}}function l(t,e){void 0!==t.backgroundColor&&m(t.backgroundColor,e),v(t.dataColor,e),f(t.style,e),c(t.showLegend,e),g(t.cameraPosition,e),void 0!==t.tooltip&&(e.showTooltip=t.tooltip)}function c(t,e){if(void 0===t){var i=void 0===D.showLegend;if(i){var o=e.style===w.DOTCOLOR||e.style===w.DOTSIZE;e.showLegend=o}}else e.showLegend=t}function u(t){var e=x[t];return void 0===e?-1:e}function p(t){var e=!1;for(var i in w)if(w[i]===t){e=!0;break}return e}function f(t,e){if(void 0!==t){var i;if("string"==typeof t){if(i=u(t),i===-1)throw new Error("Style '"+t+"' is invalid")}else{if(!p(t))throw new Error("Style '"+t+"' is invalid");i=t}e.style=i}}function m(t,e){var i="white",o="gray",n=1;if("string"==typeof t)i=t,o="none",n=0;else{if("object"!==("undefined"==typeof t?"undefined":y(t)))throw new Error("Unsupported type of backgroundColor");void 0!==t.fill&&(i=t.fill),void 0!==t.stroke&&(o=t.stroke),void 0!==t.strokeWidth&&(n=t.strokeWidth)}e.frame.style.backgroundColor=i,e.frame.style.borderColor=o,e.frame.style.borderWidth=n+"px",e.frame.style.borderStyle="solid"}function v(t,e){void 0!==t&&(void 0===e.dataColor&&(e.dataColor={}),"string"==typeof t?(e.dataColor.fill=t,e.dataColor.stroke=t):(t.fill&&(e.dataColor.fill=t.fill),t.stroke&&(e.dataColor.stroke=t.stroke),void 0!==t.strokeWidth&&(e.dataColor.strokeWidth=t.strokeWidth)))}function g(t,e){var i=t;void 0!==i&&(void 0===e.camera&&(e.camera=new b),e.camera.setArmRotation(i.horizontal,i.vertical),e.camera.setArmLength(i.distance))}var y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},b=i(16),_=i(14),w={BAR:0,BARCOLOR:1,BARSIZE:2,DOT:3,DOTLINE:4,DOTCOLOR:5,DOTSIZE:6,GRID:7,LINE:8,SURFACE:9},x={dot:w.DOT,"dot-line":w.DOTLINE,"dot-color":w.DOTCOLOR,"dot-size":w.DOTSIZE,line:w.LINE,grid:w.GRID,surface:w.SURFACE,bar:w.BAR,"bar-color":w.BARCOLOR,"bar-size":w.BARSIZE},k=["width","height","filterLabel","legendLabel","xLabel","yLabel","zLabel","xValueLabel","yValueLabel","zValueLabel","showGrid","showPerspective","showShadow","keepAspectRatio","verticalRatio","dotSizeRatio","showAnimationControls","animationInterval","animationPreload","animationAutoStart","axisColor","gridColor","xCenter","yCenter"],O=["xBarWidth","yBarWidth","valueMin","valueMax","xMin","xMax","xStep","yMin","yMax","yStep","zMin","zMax","zStep"],D=void 0;t.exports.STYLE=w,t.exports.setDefaults=h,t.exports.setOptions=d,t.exports.setCameraPosition=g},function(t,e,i){if("undefined"!=typeof window){var o=i(23),n=window.Hammer||i(24);t.exports=o(n,{preventDefault:"mouse"})}else t.exports=function(){throw Error("hammer.js is only available in a browser, not in node.js.")}},function(t,e,i){var o,n,s;!function(i){n=[],o=i,s="function"==typeof o?o.apply(e,n):o,!(void 0!==s&&(t.exports=s))}(function(){var t=null;return function e(i,o){function n(t){return t.match(/[^ ]+/g)}function s(e){if("hammer.input"!==e.type){if(e.srcEvent._handled||(e.srcEvent._handled={}),e.srcEvent._handled[e.type])return;e.srcEvent._handled[e.type]=!0}var i=!1;e.stopPropagation=function(){i=!0};var o=e.srcEvent.stopPropagation.bind(e.srcEvent);"function"==typeof o&&(e.srcEvent.stopPropagation=function(){o(),e.stopPropagation()}),e.firstTarget=t;for(var n=t;n&&!i;){var s=n.hammer;if(s)for(var r,a=0;a0?d._handlers[t]=o:(i.off(t,s),delete d._handlers[t]))}),d},d.emit=function(e,o){t=o.target,i.emit(e,o)},d.destroy=function(){var t=i.element.hammer,e=t.indexOf(d);e!==-1&&t.splice(e,1),t.length||delete i.element.hammer,d._handlers={},i.destroy()},d}})},function(t,e,i){var o;!function(n,s,r,a){function h(t,e,i){return setTimeout(p(t,i),e)}function d(t,e,i){return!!Array.isArray(t)&&(l(t,i[e],i),!0)}function l(t,e,i){var o;if(t)if(t.forEach)t.forEach(e,i);else if(t.length!==a)for(o=0;o\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",s=n.console&&(n.console.warn||n.console.log);return s&&s.call(n.console,o,i),t.apply(this,arguments)}}function u(t,e,i){var o,n=e.prototype;o=t.prototype=Object.create(n),o.constructor=t,o._super=n,i&&mt(o,i)}function p(t,e){return function(){return t.apply(e,arguments)}}function f(t,e){return typeof t==yt?t.apply(e?e[0]||a:a,e):t}function m(t,e){return t===a?e:t}function v(t,e,i){l(_(e),function(e){t.addEventListener(e,i,!1)})}function g(t,e,i){l(_(e),function(e){t.removeEventListener(e,i,!1)})}function y(t,e){for(;t;){if(t==e)return!0;t=t.parentNode}return!1}function b(t,e){return t.indexOf(e)>-1}function _(t){return t.trim().split(/\s+/g)}function w(t,e,i){if(t.indexOf&&!i)return t.indexOf(e);for(var o=0;oi[e]}):o.sort()),o}function O(t,e){for(var i,o,n=e[0].toUpperCase()+e.slice(1),s=0;s1&&!i.firstMultiple?i.firstMultiple=N(e):1===n&&(i.firstMultiple=!1);var s=i.firstInput,r=i.firstMultiple,a=r?r.center:s.center,h=e.center=R(o);e.timeStamp=wt(),e.deltaTime=e.timeStamp-s.timeStamp,e.angle=B(a,h),e.distance=A(a,h),P(i,e),e.offsetDirection=z(e.deltaX,e.deltaY);var d=L(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=d.x,e.overallVelocityY=d.y,e.overallVelocity=_t(d.x)>_t(d.y)?d.x:d.y,e.scale=r?F(r.pointers,o):1,e.rotation=r?j(r.pointers,o):0,e.maxPointers=i.prevInput?e.pointers.length>i.prevInput.maxPointers?e.pointers.length:i.prevInput.maxPointers:e.pointers.length,I(i,e);var l=t.element;y(e.srcEvent.target,l)&&(l=e.srcEvent.target),e.target=l}function P(t,e){var i=e.center,o=t.offsetDelta||{},n=t.prevDelta||{},s=t.prevInput||{};e.eventType!==Rt&&s.eventType!==zt||(n=t.prevDelta={x:s.deltaX||0,y:s.deltaY||0},o=t.offsetDelta={x:i.x,y:i.y}),e.deltaX=n.x+(i.x-o.x),e.deltaY=n.y+(i.y-o.y)}function I(t,e){var i,o,n,s,r=t.lastInterval||e,h=e.timeStamp-r.timeStamp;if(e.eventType!=At&&(h>Nt||r.velocity===a)){var d=e.deltaX-r.deltaX,l=e.deltaY-r.deltaY,c=L(h,d,l);o=c.x,n=c.y,i=_t(c.x)>_t(c.y)?c.x:c.y,s=z(d,l),t.lastInterval=e}else i=r.velocity,o=r.velocityX,n=r.velocityY,s=r.direction;e.velocity=i,e.velocityX=o,e.velocityY=n,e.direction=s}function N(t){for(var e=[],i=0;i=_t(e)?t<0?jt:Ft:e<0?Ht:Wt}function A(t,e,i){i||(i=Ut);var o=e[i[0]]-t[i[0]],n=e[i[1]]-t[i[1]];return Math.sqrt(o*o+n*n)}function B(t,e,i){i||(i=Ut);var o=e[i[0]]-t[i[0]],n=e[i[1]]-t[i[1]];return 180*Math.atan2(n,o)/Math.PI}function j(t,e){return B(e[1],e[0],qt)+B(t[1],t[0],qt)}function F(t,e){return A(e[0],e[1],qt)/A(t[0],t[1],qt)}function H(){this.evEl=Zt,this.evWin=Kt,this.pressed=!1,C.apply(this,arguments)}function W(){this.evEl=$t,this.evWin=te,C.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}function Y(){this.evTarget=ie,this.evWin=oe,this.started=!1,C.apply(this,arguments)}function G(t,e){var i=x(t.touches),o=x(t.changedTouches);return e&(zt|At)&&(i=k(i.concat(o),"identifier",!0)),[i,o]}function V(){this.evTarget=se,this.targetIds={},C.apply(this,arguments)}function U(t,e){var i=x(t.touches),o=this.targetIds;if(e&(Rt|Lt)&&1===i.length)return o[i[0].identifier]=!0,[i,i];var n,s,r=x(t.changedTouches),a=[],h=this.target;if(s=i.filter(function(t){return y(t.target,h)}),e===Rt)for(n=0;n-1&&o.splice(t,1)};setTimeout(n,re)}}function K(t){for(var e=t.srcEvent.clientX,i=t.srcEvent.clientY,o=0;o-1&&this.requireFail.splice(e,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(t){return!!this.simultaneous[t.id]},emit:function(t){function e(e){i.manager.emit(e,t)}var i=this,o=this.state;o<_e&&e(i.options.event+et(o)),e(i.options.event),t.additionalEvent&&e(t.additionalEvent),o>=_e&&e(i.options.event+et(o))},tryEmit:function(t){return this.canEmit()?this.emit(t):void(this.state=ke)},canEmit:function(){for(var t=0;te.threshold&&n&e.direction},attrTest:function(t){return nt.prototype.attrTest.call(this,t)&&(this.state&ye||!(this.state&ye)&&this.directionTest(t))},emit:function(t){this.pX=t.deltaX,this.pY=t.deltaY;var e=it(t.direction);e&&(t.additionalEvent=this.options.event+e),this._super.emit.call(this,t)}}),u(rt,nt,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[pe]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.scale-1)>this.options.threshold||this.state&ye)},emit:function(t){if(1!==t.scale){var e=t.scale<1?"in":"out";t.additionalEvent=this.options.event+e}this._super.emit.call(this,t)}}),u(at,tt,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[ce]},process:function(t){var e=this.options,i=t.pointers.length===e.pointers,o=t.distancee.time;if(this._input=t,!o||!i||t.eventType&(zt|At)&&!n)this.reset();else if(t.eventType&Rt)this.reset(),this._timer=h(function(){this.state=we,this.tryEmit()},e.time,this);else if(t.eventType&zt)return we;return ke},reset:function(){clearTimeout(this._timer)},emit:function(t){this.state===we&&(t&&t.eventType&zt?this.manager.emit(this.options.event+"up",t):(this._input.timeStamp=wt(),this.manager.emit(this.options.event,this._input)))}}),u(ht,nt,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[pe]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.rotation)>this.options.threshold||this.state&ye)}}),u(dt,nt,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:Yt|Gt,pointers:1},getTouchAction:function(){return st.prototype.getTouchAction.call(this)},attrTest:function(t){var e,i=this.options.direction;return i&(Yt|Gt)?e=t.overallVelocity:i&Yt?e=t.overallVelocityX:i&Gt&&(e=t.overallVelocityY),this._super.attrTest.call(this,t)&&i&t.offsetDirection&&t.distance>this.options.threshold&&t.maxPointers==this.options.pointers&&_t(e)>this.options.velocity&&t.eventType&zt},emit:function(t){var e=it(t.offsetDirection);e&&this.manager.emit(this.options.event+e,t),this.manager.emit(this.options.event,t)}}),u(lt,tt,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[ue]},process:function(t){var e=this.options,i=t.pointers.length===e.pointers,o=t.distances)&&(s=i)}),null!==n&&null!==s){var r=(n+s)/2,a=Math.max(this.range.end-this.range.start,1.1*(s-n)),h=!e||void 0===e.animation||e.animation;this.range.setRange(r-a/2,r+a/2,h)}}},n.prototype.fit=function(t){var e,i=!t||void 0===t.animation||t.animation,o=this.itemsData&&this.itemsData.getDataSet();1===o.length&&void 0===o.get()[0].end?(e=this.getDataRange(),this.moveTo(e.min.valueOf(),{animation:i})):(e=this.getItemRange(),this.range.setRange(e.min,e.max,i))},n.prototype.getItemRange=function(){var t=this,e=this.getDataRange(),i=null!==e.min?e.min.valueOf():null,o=null!==e.max?e.max.valueOf():null,n=null,s=null;if(null!=i&&null!=o){var r,a,h,d,c;!function(){var e=function(t){return l.convert(t.data.start,"Date").valueOf()},u=function(t){var e=void 0!=t.data.end?t.data.end:t.data.start;return l.convert(e,"Date").valueOf()};r=o-i,r<=0&&(r=10),a=r/t.props.center.width,l.forEach(t.itemSet.items,function(t){t.show(),t.repositionX();var r=e(t),h=u(t);if(this.options.rtl)var d=r-(t.getWidthRight()+10)*a,l=h+(t.getWidthLeft()+10)*a;else var d=r-(t.getWidthLeft()+10)*a,l=h+(t.getWidthRight()+10)*a;do&&(o=l,s=t)}.bind(t)),n&&s&&(h=n.getWidthLeft()+10,d=s.getWidthRight()+10,c=t.props.center.width-h-d,c>0&&(t.options.rtl?(i=e(n)-d*r/c,o=u(s)+h*r/c):(i=e(n)-h*r/c,o=u(s)+d*r/c)))}()}return{min:null!=i?new Date(i):null,max:null!=o?new Date(o):null}},n.prototype.getDataRange=function(){var t=null,e=null,i=this.itemsData&&this.itemsData.getDataSet();return i&&i.forEach(function(i){var o=l.convert(i.start,"Date").valueOf(),n=l.convert(void 0!=i.end?i.end:i.start,"Date").valueOf();(null===t||oe)&&(e=n)}),{min:null!=t?new Date(t):null,max:null!=e?new Date(e):null}},n.prototype.getEventProperties=function(t){var e=t.center?t.center.x:t.clientX,i=t.center?t.center.y:t.clientY;if(this.options.rtl)var o=l.getAbsoluteRight(this.dom.centerContainer)-e;else var o=e-l.getAbsoluteLeft(this.dom.centerContainer);var n=i-l.getAbsoluteTop(this.dom.centerContainer),s=this.itemSet.itemFromTarget(t),r=this.itemSet.groupFromTarget(t),a=g.customTimeFromTarget(t),h=this.itemSet.options.snap||null,d=this.body.util.getScale(),c=this.body.util.getStep(),u=this._toTime(o),p=h?h(u,d,c):u,f=l.getTarget(t),m=null;return null!=s?m="item":null!=a?m="custom-time":l.hasParent(f,this.timeAxis.dom.foreground)?m="axis":this.timeAxis2&&l.hasParent(f,this.timeAxis2.dom.foreground)?m="axis":l.hasParent(f,this.itemSet.dom.labelSet)?m="group-label":l.hasParent(f,this.currentTime.bar)?m="current-time":l.hasParent(f,this.dom.center)&&(m="background"),{event:t,item:s?s.id:null,group:r?r.groupId:null,what:m,pageX:t.srcEvent?t.srcEvent.pageX:t.pageX,pageY:t.srcEvent?t.srcEvent.pageY:t.pageY,x:o,y:n,time:u,snappedTime:p}},t.exports=n},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r=function(){function t(t,e){for(var i=0;i3&&void 0!==arguments[3]?arguments[3]:1;n(this,t),this.parent=e,this.changedOptions=[],this.container=i,this.allowCreation=!1,this.options={},this.initialized=!1,this.popupCounter=0,this.defaultOptions={enabled:!1,filter:!0,container:void 0,showButton:!0},d.extend(this.options,this.defaultOptions),this.configureOptions=o,this.moduleOptions={},this.domElements=[],this.popupDiv={},this.popupLimit=5,this.popupHistory={},this.colorPicker=new h.default(s),this.wrapper=void 0}return r(t,[{key:"setOptions",value:function(t){if(void 0!==t){this.popupHistory={},this._removePopup();var e=!0;"string"==typeof t?this.options.filter=t:t instanceof Array?this.options.filter=t.join():"object"===("undefined"==typeof t?"undefined":s(t))?(void 0!==t.container&&(this.options.container=t.container),void 0!==t.filter&&(this.options.filter=t.filter),void 0!==t.showButton&&(this.options.showButton=t.showButton),void 0!==t.enabled&&(e=t.enabled)):"boolean"==typeof t?(this.options.filter=!0,e=t):"function"==typeof t&&(this.options.filter=t,e=!0),this.options.filter===!1&&(e=!1),this.options.enabled=e}this._clean()}},{key:"setModuleOptions",value:function(t){this.moduleOptions=t,this.options.enabled===!0&&(this._clean(),void 0!==this.options.container&&(this.container=this.options.container),this._create())}},{key:"_create",value:function(){var t=this;this._clean(),this.changedOptions=[];var e=this.options.filter,i=0,o=!1;for(var n in this.configureOptions)this.configureOptions.hasOwnProperty(n)&&(this.allowCreation=!1,o=!1,"function"==typeof e?(o=e(n,[]),o=o||this._handleObject(this.configureOptions[n],[n],!0)):e!==!0&&e.indexOf(n)===-1||(o=!0),o!==!1&&(this.allowCreation=!0,i>0&&this._makeItem([]),this._makeHeader(n),this._handleObject(this.configureOptions[n],[n])),i++);this.options.showButton===!0&&!function(){var e=document.createElement("div");e.className="vis-configuration vis-config-button",e.innerHTML="generate options",e.onclick=function(){t._printOptions()},e.onmouseover=function(){e.className="vis-configuration vis-config-button hover"},e.onmouseout=function(){e.className="vis-configuration vis-config-button"},t.optionsContainer=document.createElement("div"),t.optionsContainer.className="vis-configuration vis-config-option-container",t.domElements.push(t.optionsContainer),t.domElements.push(e)}(),this._push()}},{key:"_push",value:function(){this.wrapper=document.createElement("div"),this.wrapper.className="vis-configuration-wrapper",this.container.appendChild(this.wrapper);for(var t=0;t1?o-1:0),r=1;r2&&void 0!==arguments[2]&&arguments[2],o=document.createElement("div");return o.className="vis-configuration vis-config-label vis-config-s"+e.length,i===!0?o.innerHTML=""+t+":":o.innerHTML=t+":",o}},{key:"_makeDropdown",value:function(t,e,i){var o=document.createElement("select");o.className="vis-configuration vis-config-select";var n=0;void 0!==e&&t.indexOf(e)!==-1&&(n=t.indexOf(e));for(var s=0;ss&&1!==s&&(a.max=Math.ceil(e*l),d=a.max,h="range increased"),a.value=e}else a.value=o;var c=document.createElement("input");c.className="vis-configuration vis-config-rangeinput",c.value=a.value;var u=this;a.onchange=function(){c.value=this.value,u._update(Number(this.value),i)},a.oninput=function(){c.value=this.value};var p=this._makeLabel(i[i.length-1],i),f=this._makeItem(i,p,a,c);""!==h&&this.popupHistory[f]!==d&&(this.popupHistory[f]=d,this._setupPopup(h,f))}},{key:"_setupPopup",value:function(t,e){var i=this;if(this.initialized===!0&&this.allowCreation===!0&&this.popupCounter1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=!1,n=this.options.filter,s=!1;for(var r in t)if(t.hasOwnProperty(r)){o=!0;var a=t[r],h=d.copyAndExtendArray(e,r);if("function"==typeof n&&(o=n(r,e),o===!1&&!(a instanceof Array)&&"string"!=typeof a&&"boolean"!=typeof a&&a instanceof Object&&(this.allowCreation=!1,o=this._handleObject(a,h,!0),this.allowCreation=i===!1)),o!==!1){s=!0;var l=this._getValue(h);if(a instanceof Array)this._handleArray(a,l,h);else if("string"==typeof a)this._makeTextInput(a,l,h);else if("boolean"==typeof a)this._makeCheckbox(a,l,h);else if(a instanceof Object){var c=!0;if(e.indexOf("physics")!==-1&&this.moduleOptions.physics.solver!==r&&(c=!1),c===!0)if(void 0!==a.enabled){var u=d.copyAndExtendArray(h,"enabled"),p=this._getValue(u);if(p===!0){var f=this._makeLabel(r,h,!0);this._makeItem(h,f),s=this._handleObject(a,h)||s}else this._makeCheckbox(a,p,h)}else{var m=this._makeLabel(r,h,!0);this._makeItem(h,m),s=this._handleObject(a,h)||s}}else console.error("dont know how to handle",a,r,h)}}return s}},{key:"_handleArray",value:function(t,e,i){"string"==typeof t[0]&&"color"===t[0]?(this._makeColorField(t,e,i),t[1]!==e&&this.changedOptions.push({path:i,value:e})):"string"==typeof t[0]?(this._makeDropdown(t,e,i),t[0]!==e&&this.changedOptions.push({path:i,value:e})):"number"==typeof t[0]&&(this._makeRange(t,e,i),t[0]!==e&&this.changedOptions.push({path:i,value:Number(e)}))}},{key:"_update",value:function(t,e){var i=this._constructOptions(t,e);this.parent.body&&this.parent.body.emitter&&this.parent.body.emitter.emit&&this.parent.body.emitter.emit("configChange",i),this.initialized=!0,this.parent.setOptions(i)}},{key:"_constructOptions",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=i;t="true"===t||t,t="false"!==t&&t;for(var n=0;nvar options = "+JSON.stringify(t,null,2)+""}},{key:"getOptions",value:function(){for(var t={},e=0;e0&&void 0!==arguments[0]?arguments[0]:1;o(this,t),this.pixelRatio=e,this.generated=!1,this.centerCoordinates={x:144.5,y:144.5},this.r=289*.49,this.color={r:255,g:255,b:255,a:1},this.hueCircle=void 0,this.initialColor={r:255,g:255,b:255,a:1},this.previousColor=void 0,this.applied=!1,this.updateCallback=function(){},this.closeCallback=function(){},this._create()}return n(t,[{key:"insertTo",value:function(t){void 0!==this.hammer&&(this.hammer.destroy(),this.hammer=void 0),this.container=t,this.container.appendChild(this.frame),this._bindHammer(),this._setSize()}},{key:"setUpdateCallback",value:function(t){if("function"!=typeof t)throw new Error("Function attempted to set as colorPicker update callback is not a function.");this.updateCallback=t}},{key:"setCloseCallback",value:function(t){if("function"!=typeof t)throw new Error("Function attempted to set as colorPicker closing callback is not a function.");this.closeCallback=t}},{key:"_isColorString",value:function(t){var e={black:"#000000",navy:"#000080",darkblue:"#00008B",mediumblue:"#0000CD",blue:"#0000FF",darkgreen:"#006400",green:"#008000",teal:"#008080",darkcyan:"#008B8B",deepskyblue:"#00BFFF",darkturquoise:"#00CED1",mediumspringgreen:"#00FA9A",lime:"#00FF00",springgreen:"#00FF7F",aqua:"#00FFFF",cyan:"#00FFFF",midnightblue:"#191970",dodgerblue:"#1E90FF",lightseagreen:"#20B2AA",forestgreen:"#228B22",seagreen:"#2E8B57",darkslategray:"#2F4F4F",limegreen:"#32CD32",mediumseagreen:"#3CB371",turquoise:"#40E0D0",royalblue:"#4169E1",steelblue:"#4682B4",darkslateblue:"#483D8B",mediumturquoise:"#48D1CC",indigo:"#4B0082",darkolivegreen:"#556B2F",cadetblue:"#5F9EA0",cornflowerblue:"#6495ED",mediumaquamarine:"#66CDAA",dimgray:"#696969",slateblue:"#6A5ACD",olivedrab:"#6B8E23",slategray:"#708090",lightslategray:"#778899",mediumslateblue:"#7B68EE",lawngreen:"#7CFC00",chartreuse:"#7FFF00",aquamarine:"#7FFFD4",maroon:"#800000",purple:"#800080",olive:"#808000",gray:"#808080",skyblue:"#87CEEB",lightskyblue:"#87CEFA",blueviolet:"#8A2BE2",darkred:"#8B0000",darkmagenta:"#8B008B",saddlebrown:"#8B4513",darkseagreen:"#8FBC8F",lightgreen:"#90EE90",mediumpurple:"#9370D8",darkviolet:"#9400D3",palegreen:"#98FB98",darkorchid:"#9932CC",yellowgreen:"#9ACD32",sienna:"#A0522D",brown:"#A52A2A",darkgray:"#A9A9A9",lightblue:"#ADD8E6",greenyellow:"#ADFF2F",paleturquoise:"#AFEEEE",lightsteelblue:"#B0C4DE",powderblue:"#B0E0E6",firebrick:"#B22222",darkgoldenrod:"#B8860B",mediumorchid:"#BA55D3",rosybrown:"#BC8F8F",darkkhaki:"#BDB76B",silver:"#C0C0C0",mediumvioletred:"#C71585",indianred:"#CD5C5C",peru:"#CD853F",chocolate:"#D2691E",tan:"#D2B48C",lightgrey:"#D3D3D3",palevioletred:"#D87093",thistle:"#D8BFD8",orchid:"#DA70D6",goldenrod:"#DAA520",crimson:"#DC143C",gainsboro:"#DCDCDC",plum:"#DDA0DD",burlywood:"#DEB887",lightcyan:"#E0FFFF",lavender:"#E6E6FA",darksalmon:"#E9967A",violet:"#EE82EE",palegoldenrod:"#EEE8AA",lightcoral:"#F08080",khaki:"#F0E68C",aliceblue:"#F0F8FF",honeydew:"#F0FFF0",azure:"#F0FFFF",sandybrown:"#F4A460",wheat:"#F5DEB3",beige:"#F5F5DC",whitesmoke:"#F5F5F5",mintcream:"#F5FFFA",ghostwhite:"#F8F8FF",salmon:"#FA8072",antiquewhite:"#FAEBD7",linen:"#FAF0E6",lightgoldenrodyellow:"#FAFAD2",oldlace:"#FDF5E6",red:"#FF0000",fuchsia:"#FF00FF",magenta:"#FF00FF",deeppink:"#FF1493",orangered:"#FF4500",tomato:"#FF6347",hotpink:"#FF69B4",coral:"#FF7F50",darkorange:"#FF8C00",lightsalmon:"#FFA07A",orange:"#FFA500",lightpink:"#FFB6C1",pink:"#FFC0CB",gold:"#FFD700",peachpuff:"#FFDAB9",navajowhite:"#FFDEAD",moccasin:"#FFE4B5",bisque:"#FFE4C4",mistyrose:"#FFE4E1",blanchedalmond:"#FFEBCD",papayawhip:"#FFEFD5",lavenderblush:"#FFF0F5",seashell:"#FFF5EE",cornsilk:"#FFF8DC",lemonchiffon:"#FFFACD",floralwhite:"#FFFAF0",snow:"#FFFAFA",yellow:"#FFFF00",lightyellow:"#FFFFE0",ivory:"#FFFFF0",white:"#FFFFFF"};if("string"==typeof t)return e[t]}},{key:"setColor",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("none"!==t){var i=void 0,o=this._isColorString(t);if(void 0!==o&&(t=o),a.isString(t)===!0){if(a.isValidRGB(t)===!0){var n=t.substr(4).substr(0,t.length-5).split(",");i={r:n[0],g:n[1],b:n[2],a:1}}else if(a.isValidRGBA(t)===!0){var s=t.substr(5).substr(0,t.length-6).split(",");i={r:s[0],g:s[1],b:s[2],a:s[3]}}else if(a.isValidHex(t)===!0){var r=a.hexToRGB(t);i={r:r.r,g:r.g,b:r.b,a:1}}}else if(t instanceof Object&&void 0!==t.r&&void 0!==t.g&&void 0!==t.b){var h=void 0!==t.a?t.a:"1.0";i={r:t.r,g:t.g,b:t.b,a:h}}if(void 0===i)throw new Error("Unknown color passed to the colorPicker. Supported are strings: rgb, hex, rgba. Object: rgb ({r:r,g:g,b:b,[a:a]}). Supplied: "+JSON.stringify(t));this._setColor(i,e)}}},{key:"show",value:function(){void 0!==this.closeCallback&&(this.closeCallback(),this.closeCallback=void 0),this.applied=!1,this.frame.style.display="block",this._generateHueCircle()}},{key:"_hide",value:function(){var t=this,e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];e===!0&&(this.previousColor=a.extend({},this.color)),this.applied===!0&&this.updateCallback(this.initialColor),this.frame.style.display="none",setTimeout(function(){void 0!==t.closeCallback&&(t.closeCallback(),t.closeCallback=void 0)},0)}},{key:"_save",value:function(){this.updateCallback(this.color),this.applied=!1,this._hide()}},{key:"_apply",value:function(){this.applied=!0,this.updateCallback(this.color),this._updatePicker(this.color)}},{key:"_loadLast",value:function(){void 0!==this.previousColor?this.setColor(this.previousColor,!1):alert("There is no last color to load...")}},{key:"_setColor",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e===!0&&(this.initialColor=a.extend({},t)),this.color=t;var i=a.RGBToHSV(t.r,t.g,t.b),o=2*Math.PI,n=this.r*i.s,s=this.centerCoordinates.x+n*Math.sin(o*i.h),r=this.centerCoordinates.y+n*Math.cos(o*i.h);this.colorPickerSelector.style.left=s-.5*this.colorPickerSelector.clientWidth+"px",this.colorPickerSelector.style.top=r-.5*this.colorPickerSelector.clientHeight+"px",this._updatePicker(t)}},{key:"_setOpacity",value:function(t){this.color.a=t/100,this._updatePicker(this.color)}},{key:"_setBrightness",value:function(t){var e=a.RGBToHSV(this.color.r,this.color.g,this.color.b);e.v=t/100;var i=a.HSVToRGB(e.h,e.s,e.v);i.a=this.color.a,this.color=i,this._updatePicker()}},{key:"_updatePicker",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.color,e=a.RGBToHSV(t.r,t.g,t.b),i=this.colorPickerCanvas.getContext("2d");void 0===this.pixelRation&&(this.pixelRatio=(window.devicePixelRatio||1)/(i.webkitBackingStorePixelRatio||i.mozBackingStorePixelRatio||i.msBackingStorePixelRatio||i.oBackingStorePixelRatio||i.backingStorePixelRatio||1)),i.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0);var o=this.colorPickerCanvas.clientWidth,n=this.colorPickerCanvas.clientHeight;i.clearRect(0,0,o,n),i.putImageData(this.hueCircle,0,0),i.fillStyle="rgba(0,0,0,"+(1-e.v)+")",i.circle(this.centerCoordinates.x,this.centerCoordinates.y,this.r),i.fill(),this.brightnessRange.value=100*e.v,this.opacityRange.value=100*t.a,this.initialColorDiv.style.backgroundColor="rgba("+this.initialColor.r+","+this.initialColor.g+","+this.initialColor.b+","+this.initialColor.a+")",this.newColorDiv.style.backgroundColor="rgba("+this.color.r+","+this.color.g+","+this.color.b+","+this.color.a+")"}},{key:"_setSize",value:function(){this.colorPickerCanvas.style.width="100%",this.colorPickerCanvas.style.height="100%",this.colorPickerCanvas.width=289*this.pixelRatio,this.colorPickerCanvas.height=289*this.pixelRatio}},{key:"_create",value:function(){if(this.frame=document.createElement("div"),this.frame.className="vis-color-picker",this.colorPickerDiv=document.createElement("div"),this.colorPickerSelector=document.createElement("div"),this.colorPickerSelector.className="vis-selector",this.colorPickerDiv.appendChild(this.colorPickerSelector),this.colorPickerCanvas=document.createElement("canvas"),this.colorPickerDiv.appendChild(this.colorPickerCanvas),this.colorPickerCanvas.getContext){var t=this.colorPickerCanvas.getContext("2d");this.pixelRatio=(window.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1),this.colorPickerCanvas.getContext("2d").setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0)}else{var e=document.createElement("DIV");e.style.color="red",e.style.fontWeight="bold",e.style.padding="10px",e.innerHTML="Error: your browser does not support HTML canvas",this.colorPickerCanvas.appendChild(e)}this.colorPickerDiv.className="vis-color",this.opacityDiv=document.createElement("div"),this.opacityDiv.className="vis-opacity",this.brightnessDiv=document.createElement("div"),this.brightnessDiv.className="vis-brightness",this.arrowDiv=document.createElement("div"),this.arrowDiv.className="vis-arrow",this.opacityRange=document.createElement("input");try{this.opacityRange.type="range",this.opacityRange.min="0",this.opacityRange.max="100"}catch(t){}this.opacityRange.value="100",this.opacityRange.className="vis-range",this.brightnessRange=document.createElement("input");try{this.brightnessRange.type="range",this.brightnessRange.min="0",this.brightnessRange.max="100"}catch(t){}this.brightnessRange.value="100",this.brightnessRange.className="vis-range",this.opacityDiv.appendChild(this.opacityRange),this.brightnessDiv.appendChild(this.brightnessRange);var i=this;this.opacityRange.onchange=function(){i._setOpacity(this.value)},this.opacityRange.oninput=function(){i._setOpacity(this.value)},this.brightnessRange.onchange=function(){i._setBrightness(this.value)},this.brightnessRange.oninput=function(){i._setBrightness(this.value)},this.brightnessLabel=document.createElement("div"),this.brightnessLabel.className="vis-label vis-brightness",this.brightnessLabel.innerHTML="brightness:",this.opacityLabel=document.createElement("div"),this.opacityLabel.className="vis-label vis-opacity",this.opacityLabel.innerHTML="opacity:",this.newColorDiv=document.createElement("div"),this.newColorDiv.className="vis-new-color",this.newColorDiv.innerHTML="new",this.initialColorDiv=document.createElement("div"),this.initialColorDiv.className="vis-initial-color",this.initialColorDiv.innerHTML="initial",this.cancelButton=document.createElement("div"),this.cancelButton.className="vis-button vis-cancel",this.cancelButton.innerHTML="cancel",this.cancelButton.onclick=this._hide.bind(this,!1),this.applyButton=document.createElement("div"),this.applyButton.className="vis-button vis-apply",this.applyButton.innerHTML="apply",this.applyButton.onclick=this._apply.bind(this),this.saveButton=document.createElement("div"),this.saveButton.className="vis-button vis-save",this.saveButton.innerHTML="save",this.saveButton.onclick=this._save.bind(this),this.loadButton=document.createElement("div"),this.loadButton.className="vis-button vis-load",this.loadButton.innerHTML="load last",this.loadButton.onclick=this._loadLast.bind(this),this.frame.appendChild(this.colorPickerDiv),this.frame.appendChild(this.arrowDiv),this.frame.appendChild(this.brightnessLabel),this.frame.appendChild(this.brightnessDiv),this.frame.appendChild(this.opacityLabel),this.frame.appendChild(this.opacityDiv),this.frame.appendChild(this.newColorDiv),this.frame.appendChild(this.initialColorDiv),this.frame.appendChild(this.cancelButton),this.frame.appendChild(this.applyButton),this.frame.appendChild(this.saveButton),this.frame.appendChild(this.loadButton)}},{key:"_bindHammer",value:function(){var t=this;this.drag={},this.pinch={},this.hammer=new s(this.colorPickerCanvas),this.hammer.get("pinch").set({enable:!0}),r.onTouch(this.hammer,function(e){t._moveSelector(e)}),this.hammer.on("tap",function(e){t._moveSelector(e)}),this.hammer.on("panstart",function(e){t._moveSelector(e)}),this.hammer.on("panmove",function(e){t._moveSelector(e)}),this.hammer.on("panend",function(e){t._moveSelector(e)})}},{key:"_generateHueCircle",value:function(){if(this.generated===!1){var t=this.colorPickerCanvas.getContext("2d");void 0===this.pixelRation&&(this.pixelRatio=(window.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)),t.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0);var e=this.colorPickerCanvas.clientWidth,i=this.colorPickerCanvas.clientHeight;t.clearRect(0,0,e,i);var o=void 0,n=void 0,s=void 0,r=void 0;this.centerCoordinates={x:.5*e,y:.5*i},this.r=.49*e;var h=2*Math.PI/360,d=1/360,l=1/this.r,c=void 0;for(s=0;s<360;s++)for(r=0;rs.distance?console.log('%cUnknown option detected: "'+e+'" in '+t.printLocation(n.path,e,"")+"Perhaps it was misplaced? Matching option found at: "+t.printLocation(s.path,s.closestMatch,""),d):n.distance<=r?console.log('%cUnknown option detected: "'+e+'". Did you mean "'+n.closestMatch+'"?'+t.printLocation(n.path,e),d):console.log('%cUnknown option detected: "'+e+'". Did you mean one of these: '+t.print(Object.keys(i))+t.printLocation(o,e),d),a=!0}},{key:"findInOptions",value:function(e,i,o){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=1e9,a="",h=[],d=e.toLowerCase(),l=void 0;for(var c in i){var u=void 0;if(void 0!==i[c].__type__&&n===!0){var p=t.findInOptions(e,i[c],r.copyAndExtendArray(o,c));s>p.distance&&(a=p.closestMatch,h=p.path,s=p.distance,l=p.indexMatch)}else c.toLowerCase().indexOf(d)!==-1&&(l=c),u=t.levenshteinDistance(e,c),s>u&&(a=c,h=r.copyArray(o),s=u)}return{closestMatch:a,path:h,distance:s,indexMatch:l}}},{key:"printLocation",value:function(t,e){for(var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Problem value found at: \n",o="\n\n"+i+"options = {\n",n=0;nu,p=r||null===n?n:l+(n-l)*s,g=r||null===a?a:c+(a-c)*s;y=h._applyRange(p,g),d.updateHiddenDates(h.options.moment,h.body,h.options.hiddenDates),v=v||y,y&&h.body.emitter.emit("rangechange",{start:new Date(h.start),end:new Date(h.end),byUser:o}),r?v&&h.body.emitter.emit("rangechanged",{start:new Date(h.start),end:new Date(h.end),byUser:o}):h.animationTimer=setTimeout(t,20)}};return g()}var y=this._applyRange(n,a);if(d.updateHiddenDates(this.options.moment,this.body,this.options.hiddenDates),y){var b={start:new Date(this.start),end:new Date(this.end),byUser:o};this.body.emitter.emit("rangechange",b),this.body.emitter.emit("rangechanged",b)}},o.prototype._cancelAnimation=function(){this.animationTimer&&(clearTimeout(this.animationTimer),this.animationTimer=null)},o.prototype._applyRange=function(t,e){var i,o=null!=t?r.convert(t,"Date").valueOf():this.start,n=null!=e?r.convert(e,"Date").valueOf():this.end,s=null!=this.options.max?r.convert(this.options.max,"Date").valueOf():null,a=null!=this.options.min?r.convert(this.options.min,"Date").valueOf():null;if(isNaN(o)||null===o)throw new Error('Invalid start "'+t+'"');if(isNaN(n)||null===n)throw new Error('Invalid end "'+e+'"');if(ns&&(n=s)),null!==s&&n>s&&(i=n-s,o-=i,n-=i,null!=a&&othis.start&&nd&&(this.end-this.start===d&&othis.end?(o=this.start,n=this.end):(i=n-o-d,o+=i/2,n-=i/2))}var l=this.start!=o||this.end!=n;return o>=this.start&&o<=this.end||n>=this.start&&n<=this.end||this.start>=o&&this.start<=n||this.end>=o&&this.end<=n||this.body.emitter.emit("checkRangedItems"),this.start=o,this.end=n,l},o.prototype.getRange=function(){return{start:this.start,end:this.end}},o.prototype.conversion=function(t,e){return o.conversion(this.start,this.end,t,e)},o.conversion=function(t,e,i,o){return void 0===o&&(o=0),0!=i&&e-t!=0?{offset:t,scale:i/(e-t-o)}:{offset:0,scale:1}},o.prototype._onDragStart=function(t){this.deltaDifference=0,this.previousDelta=0,this.options.moveable&&this._isInsideRange(t)&&this.props.touch.allowDragging&&(this.props.touch.start=this.start,this.props.touch.end=this.end,this.props.touch.dragging=!0,this.body.dom.root&&(this.body.dom.root.style.cursor="move"))},o.prototype._onDrag=function(t){if(t&&this.props.touch.dragging&&this.options.moveable&&this.props.touch.allowDragging){var e=this.options.direction;n(e);var i="horizontal"==e?t.deltaX:t.deltaY;i-=this.deltaDifference;var o=this.props.touch.end-this.props.touch.start,s=d.getHiddenDurationBetween(this.body.hiddenDates,this.start,this.end);o-=s;var r="horizontal"==e?this.body.domProps.center.width:this.body.domProps.center.height;if(this.options.rtl)var a=i/r*o;else var a=-i/r*o;var h=this.props.touch.start+a,l=this.props.touch.end+a,c=d.snapAwayFromHidden(this.body.hiddenDates,h,this.previousDelta-i,!0),u=d.snapAwayFromHidden(this.body.hiddenDates,l,this.previousDelta-i,!0);if(c!=h||u!=l)return this.deltaDifference+=i, +this.props.touch.start=c,this.props.touch.end=u,void this._onDrag(t);this.previousDelta=i,this._applyRange(h,l);var p=new Date(this.start),f=new Date(this.end);this.body.emitter.emit("rangechange",{start:p,end:f,byUser:!0}),this.body.emitter.emit("panmove")}},o.prototype._onDragEnd=function(t){this.props.touch.dragging&&this.options.moveable&&this.props.touch.allowDragging&&(this.props.touch.dragging=!1,this.body.dom.root&&(this.body.dom.root.style.cursor="auto"),this.body.emitter.emit("rangechanged",{start:new Date(this.start),end:new Date(this.end),byUser:!0}))},o.prototype._onMouseWheel=function(t){t.preventDefault();var e=0;if(t.wheelDelta?e=t.wheelDelta/120:t.detail&&(e=-t.detail/3),this.options.zoomKey&&!t[this.options.zoomKey]&&this.options.zoomable||!this.options.zoomable&&this.options.moveable){if(this.options.horizontalScroll){var i=e*(this.end-this.start)/20,o=this.start-i,n=this.end-i;this.setRange(o,n)}}else if(this.options.zoomable&&this.options.moveable&&this._isInsideRange(t)&&e){var s;s=e<0?1-e/5:1/(1+e/5);var r=this.getPointer({x:t.clientX,y:t.clientY},this.body.dom.center),a=this._pointerToDate(r);this.zoom(s,a,e)}},o.prototype._onTouch=function(t){this.props.touch.start=this.start,this.props.touch.end=this.end,this.props.touch.allowDragging=!0,this.props.touch.center=null,this.scaleOffset=0,this.deltaDifference=0},o.prototype._onPinch=function(t){if(this.options.zoomable&&this.options.moveable){this.props.touch.allowDragging=!1,this.props.touch.center||(this.props.touch.center=this.getPointer(t.center,this.body.dom.center));var e=1/(t.scale+this.scaleOffset),i=this._pointerToDate(this.props.touch.center),o=d.getHiddenDurationBetween(this.body.hiddenDates,this.start,this.end),n=d.getHiddenDurationBefore(this.options.moment,this.body.hiddenDates,this,i),s=o-n,r=i-n+(this.props.touch.start-(i-n))*e,a=i+s+(this.props.touch.end-(i+s))*e;this.startToFront=1-e<=0,this.endToFront=e-1<=0;var h=d.snapAwayFromHidden(this.body.hiddenDates,r,1-e,!0),l=d.snapAwayFromHidden(this.body.hiddenDates,a,e-1,!0);h==r&&l==a||(this.props.touch.start=h,this.props.touch.end=l,this.scaleOffset=1-t.scale,r=h,a=l),this.setRange(r,a,!1,!0),this.startToFront=!1,this.endToFront=!0}},o.prototype._isInsideRange=function(t){var e=t.center?t.center.x:t.clientX;if(this.options.rtl)var i=e-r.getAbsoluteLeft(this.body.dom.centerContainer);else var i=r.getAbsoluteRight(this.body.dom.centerContainer)-e;var o=this.body.util.toTime(i);return o>=this.start&&o<=this.end},o.prototype._pointerToDate=function(t){var e,i=this.options.direction;if(n(i),"horizontal"==i)return this.body.util.toTime(t.x).valueOf();var o=this.body.domProps.center.height;return e=this.conversion(o),t.y/e.scale+e.offset},o.prototype.getPointer=function(t,e){return this.options.rtl?{x:r.getAbsoluteRight(e)-t.x,y:t.y-r.getAbsoluteTop(e)}:{x:t.x-r.getAbsoluteLeft(e),y:t.y-r.getAbsoluteTop(e)}},o.prototype.zoom=function(t,e,i){null==e&&(e=(this.start+this.end)/2);var o=d.getHiddenDurationBetween(this.body.hiddenDates,this.start,this.end),n=d.getHiddenDurationBefore(this.options.moment,this.body.hiddenDates,this,e),s=o-n,r=e-n+(this.start-(e-n))*t,a=e+s+(this.end-(e+s))*t;this.startToFront=!(i>0),this.endToFront=!(-i>0);var h=d.snapAwayFromHidden(this.body.hiddenDates,r,i,!0),l=d.snapAwayFromHidden(this.body.hiddenDates,a,-i,!0);h==r&&l==a||(r=h,a=l),this.setRange(r,a,!1,!0),this.startToFront=!1,this.endToFront=!0},o.prototype.move=function(t){var e=this.end-this.start,i=this.start+e*t,o=this.end+e*t;this.start=i,this.end=o},o.prototype.moveTo=function(t){var e=(this.start+this.end)/2,i=e-t,o=this.start-i,n=this.end-i;this.setRange(o,n)},t.exports=o},function(t,e,i){function o(t,e){this.options=null,this.props=null}var n=i(1);o.prototype.setOptions=function(t){t&&n.extend(this.options,t)},o.prototype.redraw=function(){return!1},o.prototype.destroy=function(){},o.prototype._isResized=function(){var t=this.props._previousWidth!==this.props.width||this.props._previousHeight!==this.props.height;return this.props._previousWidth=this.props.width,this.props._previousHeight=this.props.height,t},t.exports=o},function(t,e){e.convertHiddenOptions=function(t,i,o){if(o&&!Array.isArray(o))return e.convertHiddenOptions(t,i,[o]);if(i.hiddenDates=[],o&&1==Array.isArray(o)){for(var n=0;n=4*a){var u=0,p=s.clone();switch(o[h].repeat){case"daily":d.day()!=l.day()&&(u=1),d.dayOfYear(n.dayOfYear()),d.year(n.year()),d.subtract(7,"days"),l.dayOfYear(n.dayOfYear()),l.year(n.year()),l.subtract(7-u,"days"),p.add(1,"weeks");break;case"weekly":var f=l.diff(d,"days"),m=d.day();d.date(n.date()),d.month(n.month()),d.year(n.year()),l=d.clone(),d.day(m),l.day(m),l.add(f,"days"),d.subtract(1,"weeks"),l.subtract(1,"weeks"),p.add(1,"weeks");break;case"monthly":d.month()!=l.month()&&(u=1),d.month(n.month()),d.year(n.year()),d.subtract(1,"months"),l.month(n.month()),l.year(n.year()),l.subtract(1,"months"),l.add(u,"months"),p.add(1,"months");break;case"yearly":d.year()!=l.year()&&(u=1),d.year(n.year()),d.subtract(1,"years"),l.year(n.year()),l.subtract(1,"years"),l.add(u,"years"),p.add(1,"years");break;default:return void console.log("Wrong repeat format, allowed are: daily, weekly, monthly, yearly. Given:",o[h].repeat)}for(;d=e[o].start&&e[n].end<=e[o].end?e[n].remove=!0:e[n].start>=e[o].start&&e[n].start<=e[o].end?(e[o].end=e[n].end,e[n].remove=!0):e[n].end>=e[o].start&&e[n].end<=e[o].end&&(e[o].start=e[n].start,e[n].remove=!0));for(var o=0;o=r&&nt.range.end){var h={start:t.range.start,end:i};i=e.correctTimeForHidden(t.options.moment,t.body.hiddenDates,h,i);var n=t.range.conversion(o,r);return(i.valueOf()-n.offset)*n.scale}i=e.correctTimeForHidden(t.options.moment,t.body.hiddenDates,t.range,i);var n=t.range.conversion(o,r);return(i.valueOf()-n.offset)*n.scale},e.toTime=function(t,i,o){if(0==t.body.hiddenDates.length){var n=t.range.conversion(o);return new Date(i/n.scale+n.offset)}var s=e.getHiddenDurationBetween(t.body.hiddenDates,t.range.start,t.range.end),r=t.range.end-t.range.start-s,a=r*i/o,h=e.getAccumulatedHiddenDuration(t.body.hiddenDates,t.range,a),d=new Date(h+a+t.range.start);return d},e.getHiddenDurationBetween=function(t,e,i){for(var o=0,n=0;n=e&&r=e&&r<=i&&(o+=r-s)}return o},e.correctTimeForHidden=function(t,i,o,n){return n=t(n).toDate().valueOf(),n-=e.getHiddenDurationBefore(t,i,o,n)},e.getHiddenDurationBefore=function(t,e,i,o){var n=0;o=t(o).toDate().valueOf();for(var s=0;s=i.start&&a=a&&(n+=a-r)}return n},e.getAccumulatedHiddenDuration=function(t,e,i){for(var o=0,n=0,s=e.start,r=0;r=e.start&&h=i)break;o+=h-a}}return o},e.snapAwayFromHidden=function(t,i,o,n){var s=e.isHidden(i,t);return 1==s.hidden?o<0?1==n?s.startDate-(s.endDate-i)-1:s.startDate-1:1==n?s.endDate+(i-s.startDate)+1:s.endDate+1:i},e.isHidden=function(t,e){for(var i=0;i=o&&t0&&i[0].setCustomTime(t)},o.prototype.getCustomTime=function(t){var e=this.customTimes.filter(function(e){return e.options.id===t});if(0===e.length)throw new Error("No custom time bar found with id "+JSON.stringify(t));return e[0].getCustomTime()},o.prototype.setCustomTimeTitle=function(t,e){var i=this.customTimes.filter(function(t){return t.options.id===e});if(0===i.length)throw new Error("No custom time bar found with id "+JSON.stringify(e));if(i.length>0)return i[0].setCustomTitle(t)},o.prototype.getEventProperties=function(t){return{event:t}},o.prototype.addCustomTime=function(t,e){var i=void 0!==t?h.convert(t,"Date").valueOf():new Date,o=this.customTimes.some(function(t){return t.options.id===e});if(o)throw new Error("A custom time with id "+JSON.stringify(e)+" already exists");var n=new u(this.body,h.extend({},this.options,{time:i,id:e}));return this.customTimes.push(n),this.components.push(n),this._redraw(),e},o.prototype.removeCustomTime=function(t){var e=this.customTimes.filter(function(e){return e.options.id===t});if(0===e.length)throw new Error("No custom time bar found with id "+JSON.stringify(t));e.forEach(function(t){this.customTimes.splice(this.customTimes.indexOf(t),1),this.components.splice(this.components.indexOf(t),1),t.destroy()}.bind(this))},o.prototype.getVisibleItems=function(){return this.itemSet&&this.itemSet.getVisibleItems()||[]},o.prototype.fit=function(t){var e=this.getDataRange();if(null!==e.min||null!==e.max){var i=e.max-e.min,o=new Date(e.min.valueOf()-.01*i),n=new Date(e.max.valueOf()+.01*i),s=!t||void 0===t.animation||t.animation;this.range.setRange(o,n,s)}},o.prototype.getDataRange=function(){throw new Error("Cannot invoke abstract method getDataRange")},o.prototype.setWindow=function(t,e,i){var o;if(1==arguments.length){var n=arguments[0];o=void 0===n.animation||n.animation,this.range.setRange(n.start,n.end,o)}else o=!i||void 0===i.animation||i.animation,this.range.setRange(t,e,o)},o.prototype.moveTo=function(t,e){var i=this.range.end-this.range.start,o=h.convert(t,"Date").valueOf(),n=o-i/2,s=o+i/2,r=!e||void 0===e.animation||e.animation;this.range.setRange(n,s,r)},o.prototype.getWindow=function(){var t=this.range.getRange();return{start:new Date(t.start),end:new Date(t.end)}},o.prototype.zoomIn=function(t){if(!(!t||t<0||t>1)){var e=this.getWindow(),i=e.start.valueOf(),o=e.end.valueOf(),n=o-i,s=n/(1+t),r=(n-s)/2,a=i+r,h=o-r;this.setWindow({start:a,end:h})}},o.prototype.zoomOut=function(t){if(!(!t||t<0||t>1)){var e=this.getWindow(),i=e.start.valueOf(),o=e.end.valueOf(),n=o-i,s=i-n*t/2,r=o+n*t/2;this.setWindow({start:s,end:r})}},o.prototype.redraw=function(){this._redraw()},o.prototype._redraw=function(){this.redrawCount++;var t=!1,e=this.options,i=this.props,o=this.dom;if(o&&o.container&&0!=o.root.offsetWidth){c.updateHiddenDates(this.options.moment,this.body,this.options.hiddenDates),"top"==e.orientation?(h.addClassName(o.root,"vis-top"),h.removeClassName(o.root,"vis-bottom")):(h.removeClassName(o.root,"vis-top"),h.addClassName(o.root,"vis-bottom")),o.root.style.maxHeight=h.option.asSize(e.maxHeight,""),o.root.style.minHeight=h.option.asSize(e.minHeight,""),o.root.style.width=h.option.asSize(e.width,""),i.border.left=(o.centerContainer.offsetWidth-o.centerContainer.clientWidth)/2,i.border.right=i.border.left,i.border.top=(o.centerContainer.offsetHeight-o.centerContainer.clientHeight)/2,i.border.bottom=i.border.top;var n=o.root.offsetHeight-o.root.clientHeight,s=o.root.offsetWidth-o.root.clientWidth;0===o.centerContainer.clientHeight&&(i.border.left=i.border.top,i.border.right=i.border.left),0===o.root.clientHeight&&(s=n),i.center.height=o.center.offsetHeight,i.left.height=o.left.offsetHeight,i.right.height=o.right.offsetHeight,i.top.height=o.top.clientHeight||-i.border.top,i.bottom.height=o.bottom.clientHeight||-i.border.bottom;var a=Math.max(i.left.height,i.center.height,i.right.height),d=i.top.height+a+i.bottom.height+n+i.border.top+i.border.bottom;o.root.style.height=h.option.asSize(e.height,d+"px"),i.root.height=o.root.offsetHeight,i.background.height=i.root.height-n;var l=i.root.height-i.top.height-i.bottom.height-n;i.centerContainer.height=l,i.leftContainer.height=l,i.rightContainer.height=i.leftContainer.height,i.root.width=o.root.offsetWidth,i.background.width=i.root.width-s,this.initialDrawDone||(i.scrollbarWidth=h.getScrollBarWidth()),this.options.verticalScroll?this.options.rtl?(i.left.width=o.leftContainer.clientWidth||-i.border.left,i.right.width=o.rightContainer.clientWidth+i.scrollbarWidth||-i.border.right):(i.left.width=o.leftContainer.clientWidth+i.scrollbarWidth||-i.border.left,i.right.width=o.rightContainer.clientWidth||-i.border.right):(i.left.width=o.leftContainer.clientWidth||-i.border.left,i.right.width=o.rightContainer.clientWidth||-i.border.right),i.leftContainer.width=i.left.width,i.rightContainer.width=i.right.width;var u=i.root.width-i.left.width-i.right.width-s;i.center.width=u,i.centerContainer.width=u,i.top.width=u,i.bottom.width=u,o.background.style.height=i.background.height+"px",o.backgroundVertical.style.height=i.background.height+"px",o.backgroundHorizontal.style.height=i.centerContainer.height+"px",o.centerContainer.style.height=i.centerContainer.height+"px",o.leftContainer.style.height=i.leftContainer.height+"px",o.rightContainer.style.height=i.rightContainer.height+"px",o.background.style.width=i.background.width+"px",o.backgroundVertical.style.width=i.centerContainer.width+"px",o.backgroundHorizontal.style.width=i.background.width+"px",o.centerContainer.style.width=i.center.width+"px",o.top.style.width=i.top.width+"px",o.bottom.style.width=i.bottom.width+"px",o.background.style.left="0",o.background.style.top="0",o.backgroundVertical.style.left=i.left.width+i.border.left+"px",o.backgroundVertical.style.top="0",o.backgroundHorizontal.style.left="0",o.backgroundHorizontal.style.top=i.top.height+"px",o.centerContainer.style.left=i.left.width+"px",o.centerContainer.style.top=i.top.height+"px",o.leftContainer.style.left="0",o.leftContainer.style.top=i.top.height+"px",o.rightContainer.style.left=i.left.width+i.center.width+"px",o.rightContainer.style.top=i.top.height+"px",o.top.style.left=i.left.width+"px",o.top.style.top="0",o.bottom.style.left=i.left.width+"px",o.bottom.style.top=i.top.height+i.centerContainer.height+"px";var p=this._updateScrollTop();"top"!=e.orientation.item&&(p+=Math.max(this.props.centerContainer.height-this.props.center.height-this.props.border.top-this.props.border.bottom,0)),o.center.style.left="0",o.center.style.top=p+"px",o.left.style.left="0",o.right.style.left="0";var f=0==this.props.scrollTop?"hidden":"",m=this.props.scrollTop==this.props.scrollTopMin?"hidden":"";o.shadowTop.style.visibility=f,o.shadowBottom.style.visibility=m,o.shadowTopLeft.style.visibility=f,o.shadowBottomLeft.style.visibility=m,o.shadowTopRight.style.visibility=f,o.shadowBottomRight.style.visibility=m,this.options.verticalScroll?(o.shadowTopRight.style.visibility="hidden",o.shadowBottomRight.style.visibility="hidden",o.shadowTopLeft.style.visibility="hidden",o.shadowBottomLeft.style.visibility="hidden"):(o.left.style.top=p+"px",o.right.style.top=p+"px");var v=this.props.center.height>this.props.centerContainer.height;this.hammer.get("pan").set({direction:v?r.DIRECTION_ALL:r.DIRECTION_HORIZONTAL}),this.components.forEach(function(e){t=e.redraw()||t});var g=5;if(t){if(this.redrawCount0&&(this.props.scrollTop=0),this.props.scrollTope&&o.push(h.id):h.lefti&&o.push(h.id)}return o},o.prototype._deselect=function(t){for(var e=this.selection,i=0,o=e.length;io)return}}if(e&&e!=this.groupTouchParams.group){var h=this.groupsData,d=h.get(e.groupId),l=h.get(this.groupTouchParams.group.groupId);l&&d&&(this.options.groupOrderSwap(l,d,this.groupsData),this.groupsData.update(l),this.groupsData.update(d));var c=this.groupsData.getIds({order:this.options.groupOrder});if(!r.equalArray(c,this.groupTouchParams.originalOrder))for(var h=this.groupsData,u=this.groupTouchParams.originalOrder,p=this.groupTouchParams.group.groupId,f=Math.min(u.length,c.length),m=0,v=0,g=0;m=f)break;if(c[m+v]!=p)if(u[m+g]!=p){var y=c.indexOf(u[m+g]),b=h.get(c[m+v]),_=h.get(u[m+g]);this.options.groupOrderSwap(b,_,h),h.update(b),h.update(_);var w=c[m+v];c[m+v]=u[m+g],c[y]=w,m++}else g=1;else v=1}}}},o.prototype._onGroupDragEnd=function(t){if(this.options.groupEditable.order&&this.groupTouchParams.group){t.stopPropagation();var e=this,i=e.groupTouchParams.group.groupId,o=e.groupsData.getDataSet(),n=r.extend({},o.get(i));e.options.onMoveGroup(n,function(t){if(t)t[o._fieldId]=i,o.update(t);else{var n=o.getIds({order:e.options.groupOrder});if(!r.equalArray(n,e.groupTouchParams.originalOrder))for(var s=e.groupTouchParams.originalOrder,a=Math.min(s.length,n.length),h=0;h=a)break;var d=n.indexOf(s[h]),l=o.get(n[h]),c=o.get(s[h]);e.options.groupOrderSwap(l,c,o),groupsData.update(l),groupsData.update(c);var u=n[h];n[h]=s[h],n[d]=u,h++}}}),e.body.emitter.emit("groupDragged",{groupId:i})}},o.prototype._onSelectItem=function(t){if(this.options.selectable){var e=t.srcEvent&&(t.srcEvent.ctrlKey||t.srcEvent.metaKey),i=t.srcEvent&&t.srcEvent.shiftKey;if(e||i)return void this._onMultiSelectItem(t);var o=this.getSelection(),n=this.itemFromTarget(t),s=n?[n.id]:[];this.setSelection(s);var r=this.getSelection();(r.length>0||o.length>0)&&this.body.emitter.emit("select",{items:r,event:t})}},o.prototype._onMouseOver=function(t){var e=this.itemFromTarget(t);e&&this.body.emitter.emit("itemover",{item:e.id,event:t})},o.prototype._onMouseOut=function(t){var e=this.itemFromTarget(t);e&&this.body.emitter.emit("itemout",{item:e.id,event:t})},o.prototype._onAddItem=function(t){if(this.options.selectable&&this.options.editable.add){var e=this,i=this.options.snap||null,o=this.itemFromTarget(t);if(o){var n=e.itemsData.get(o.id);this.options.onUpdate(n,function(t){t&&e.itemsData.getDataSet().update(t)})}else{if(this.options.rtl)var s=r.getAbsoluteRight(this.dom.frame),a=s-t.center.x;else var s=r.getAbsoluteLeft(this.dom.frame),a=t.center.x-s;var h=this.body.util.toTime(a),d=this.body.util.getScale(),l=this.body.util.getStep(),c={start:i?i(h,d,l):h,content:"new item"};if("drop"==t.type){var n=JSON.parse(t.dataTransfer.getData("text/plain"));if(c.content=n.content,c.type=n.type||"box",c[this.itemsData._fieldId]=n.id||r.randomUUID(),"range"==n.type||n.end&&n.start)if(n.end)c.end=new Date(c.start._i).getTime()+new Date(n.end).getTime()-new Date(n.start).getTime();else{var u=this.body.util.toTime(a+this.props.width/5);c.end=i?i(u,d,l):u}}else if(c[this.itemsData._fieldId]=r.randomUUID(),"range"===this.options.type){var u=this.body.util.toTime(a+this.props.width/5);c.end=i?i(u,d,l):u}var p=this.groupFromTarget(t);p&&(c.group=p.groupId),c=this._cloneItemData(c),this.options.onAdd(c,function(i){i&&(e.itemsData.getDataSet().add(i),"drop"==t.type&&e.setSelection([i.id]))})}}},o.prototype._onMultiSelectItem=function(t){if(this.options.selectable){var e=this.itemFromTarget(t);if(e){var i=this.options.multiselect?this.getSelection():[],n=t.srcEvent&&t.srcEvent.shiftKey||!1;if(n&&this.options.multiselect){var s=this.itemsData.get(e.id).group,r=void 0;this.options.multiselectPerGroup&&i.length>0&&(r=this.itemsData.get(i[0]).group),this.options.multiselectPerGroup&&void 0!=r&&r!=s||i.push(e.id);var a=o._getItemRange(this.itemsData.get(i,this.itemOptions));if(!this.options.multiselectPerGroup||r==s){i=[];for(var h in this.items)if(this.items.hasOwnProperty(h)){var d=this.items[h],l=d.data.start,c=void 0!==d.data.end?d.data.end:l;!(l>=a.min&&c<=a.max)||this.options.multiselectPerGroup&&r!=this.itemsData.get(d.id).group||d instanceof v||i.push(d.id)}}}else{var u=i.indexOf(e.id);u==-1?i.push(e.id):i.splice(u,1)}this.setSelection(i),this.body.emitter.emit("select",{items:this.getSelection(),event:t})}}},o._getItemRange=function(t){var e=null,i=null;return t.forEach(function(t){(null==i||t.starte)&&(e=t.end):(null==e||t.start>e)&&(e=t.start)}),{min:i,max:e}},o.prototype.itemFromTarget=function(t){for(var e=t.target;e;){if(e.hasOwnProperty("timeline-item"))return e["timeline-item"];e=e.parentNode}return null},o.prototype.groupFromTarget=function(t){for(var e=t.center?t.center.y:t.clientY,i=0;ia&&ea)return n}else if(0===i&&e0?t.step:1,this.autoScale=!1)},o.prototype.setAutoScale=function(t){this.autoScale=t},o.prototype.setMinimumStep=function(t){if(void 0!=t){var e=31104e6,i=2592e6,o=864e5,n=36e5,s=6e4,r=1e3,a=1;1e3*e>t&&(this.scale="year",this.step=1e3),500*e>t&&(this.scale="year",this.step=500),100*e>t&&(this.scale="year",this.step=100),50*e>t&&(this.scale="year",this.step=50),10*e>t&&(this.scale="year",this.step=10),5*e>t&&(this.scale="year",this.step=5),e>t&&(this.scale="year",this.step=1),3*i>t&&(this.scale="month",this.step=3),i>t&&(this.scale="month",this.step=1),5*o>t&&(this.scale="day",this.step=5),2*o>t&&(this.scale="day",this.step=2),o>t&&(this.scale="day",this.step=1),o/2>t&&(this.scale="weekday",this.step=1),4*n>t&&(this.scale="hour",this.step=4),n>t&&(this.scale="hour",this.step=1),15*s>t&&(this.scale="minute",this.step=15),10*s>t&&(this.scale="minute",this.step=10),5*s>t&&(this.scale="minute",this.step=5),s>t&&(this.scale="minute",this.step=1),15*r>t&&(this.scale="second",this.step=15),10*r>t&&(this.scale="second",this.step=10),5*r>t&&(this.scale="second",this.step=5),r>t&&(this.scale="second",this.step=1),200*a>t&&(this.scale="millisecond",this.step=200),100*a>t&&(this.scale="millisecond",this.step=100),50*a>t&&(this.scale="millisecond",this.step=50),10*a>t&&(this.scale="millisecond",this.step=10),5*a>t&&(this.scale="millisecond",this.step=5),a>t&&(this.scale="millisecond",this.step=1)}},o.snap=function(t,e,i){var o=n(t);if("year"==e){var s=o.year()+Math.round(o.month()/12);o.year(Math.round(s/i)*i),o.month(0),o.date(0),o.hours(0),o.minutes(0),o.seconds(0),o.milliseconds(0)}else if("month"==e)o.date()>15?(o.date(1),o.add(1,"month")):o.date(1),o.hours(0),o.minutes(0),o.seconds(0),o.milliseconds(0);else if("day"==e){switch(i){case 5:case 2:o.hours(24*Math.round(o.hours()/24));break;default:o.hours(12*Math.round(o.hours()/12))}o.minutes(0),o.seconds(0),o.milliseconds(0)}else if("weekday"==e){switch(i){case 5:case 2:o.hours(12*Math.round(o.hours()/12));break;default:o.hours(6*Math.round(o.hours()/6))}o.minutes(0),o.seconds(0),o.milliseconds(0)}else if("hour"==e){switch(i){case 4:o.minutes(60*Math.round(o.minutes()/60));break;default:o.minutes(30*Math.round(o.minutes()/30))}o.seconds(0),o.milliseconds(0)}else if("minute"==e){switch(i){case 15:case 10:o.minutes(5*Math.round(o.minutes()/5)),o.seconds(0);break;case 5:o.seconds(60*Math.round(o.seconds()/60));break;default:o.seconds(30*Math.round(o.seconds()/30))}o.milliseconds(0)}else if("second"==e)switch(i){case 15:case 10:o.seconds(5*Math.round(o.seconds()/5)),o.milliseconds(0);break;case 5:o.milliseconds(1e3*Math.round(o.milliseconds()/1e3));break;default:o.milliseconds(500*Math.round(o.milliseconds()/500))}else if("millisecond"==e){var r=i>5?i/2:1;o.milliseconds(Math.round(o.milliseconds()/r)*r)}return o},o.prototype.isMajor=function(){if(1==this.switchedYear)switch(this.scale){case"year":case"month":case"weekday":case"day":case"hour":case"minute":case"second":case"millisecond":return!0;default:return!1}else if(1==this.switchedMonth)switch(this.scale){case"weekday":case"day":case"hour":case"minute":case"second":case"millisecond":return!0;default:return!1}else if(1==this.switchedDay)switch(this.scale){case"millisecond":case"second":case"minute":case"hour":return!0;default:return!1}var t=this.moment(this.current);switch(this.scale){case"millisecond":return 0==t.milliseconds();case"second":return 0==t.seconds();case"minute":return 0==t.hours()&&0==t.minutes();case"hour":return 0==t.hours();case"weekday":case"day":return 1==t.date();case"month":return 0==t.month();case"year":return!1;default:return!1}},o.prototype.getLabelMinor=function(t){if(void 0==t&&(t=this.current),"function"==typeof this.format.minorLabels)return this.format.minorLabels(t,this.scale,this.step);var e=this.format.minorLabels[this.scale];return e&&e.length>0?this.moment(t).format(e):""},o.prototype.getLabelMajor=function(t){if(void 0==t&&(t=this.current),"function"==typeof this.format.majorLabels)return this.format.majorLabels(t,this.scale,this.step);var e=this.format.majorLabels[this.scale];return e&&e.length>0?this.moment(t).format(e):""},o.prototype.getClassName=function(){function t(t){return t/h%2==0?" vis-even":" vis-odd"}function e(t){return t.isSame(new Date,"day")?" vis-today":t.isSame(s().add(1,"day"),"day")?" vis-tomorrow":t.isSame(s().add(-1,"day"),"day")?" vis-yesterday":""}function i(t){return t.isSame(new Date,"week")?" vis-current-week":""}function o(t){return t.isSame(new Date,"month")?" vis-current-month":""}function n(t){return t.isSame(new Date,"year")?" vis-current-year":""}var s=this.moment,r=this.moment(this.current),a=r.locale?r.locale("en"):r.lang("en"),h=this.step;switch(this.scale){case"millisecond":return e(a)+t(a.milliseconds()).trim();case"second":return e(a)+t(a.seconds()).trim();case"minute":return e(a)+t(a.minutes()).trim();case"hour":return"vis-h"+a.hours()+(4==this.step?"-h"+(a.hours()+4):"")+e(a)+t(a.hours());case"weekday":return"vis-"+a.format("dddd").toLowerCase()+e(a)+i(a)+t(a.date());case"day":return"vis-day"+a.date()+" vis-"+a.format("MMMM").toLowerCase()+e(a)+o(a)+this.step<=2?e(a):""+this.step<=2?" vis-"+a.format("dddd").toLowerCase():""+t(a.date()-1);case"month":return"vis-"+a.format("MMMM").toLowerCase()+o(a)+t(a.month());case"year":var d=a.year();return"vis-year"+d+n(a)+t(d);default:return""}},t.exports=o},function(t,e,i){function o(t,e,i){this.groupId=t,this.subgroups={},this.subgroupIndex=0,this.subgroupOrderer=e&&e.subgroupOrder,this.itemSet=i,this.isVisible=null,this.dom={},this.props={label:{width:0,height:0}},this.className=null,this.items={},this.visibleItems=[],this.orderedItems={byStart:[],byEnd:[]},this.checkRangedItems=!1;var o=this;this.itemSet.body.emitter.on("checkRangedItems",function(){o.checkRangedItems=!0}),this._create(),this.setData(e)}var n=i(1),s=i(39);i(40);o.prototype._create=function(){var t=document.createElement("div"); +this.itemSet.options.groupEditable.order?t.className="vis-label draggable":t.className="vis-label",this.dom.label=t;var e=document.createElement("div");e.className="vis-inner",t.appendChild(e),this.dom.inner=e;var i=document.createElement("div");i.className="vis-group",i["timeline-group"]=this,this.dom.foreground=i,this.dom.background=document.createElement("div"),this.dom.background.className="vis-group",this.dom.axis=document.createElement("div"),this.dom.axis.className="vis-group",this.dom.marker=document.createElement("div"),this.dom.marker.style.visibility="hidden",this.dom.marker.innerHTML="?",this.dom.background.appendChild(this.dom.marker)},o.prototype.setData=function(t){var e,i;if(this.itemSet.options&&this.itemSet.options.groupTemplate?(i=this.itemSet.options.groupTemplate.bind(this),e=i(t,this.dom.inner)):e=t&&t.content,e instanceof Element){for(this.dom.inner.appendChild(e);this.dom.inner.firstChild;)this.dom.inner.removeChild(this.dom.inner.firstChild);this.dom.inner.appendChild(e)}else e instanceof Object?i(t,this.dom.inner):void 0!==e&&null!==e?this.dom.inner.innerHTML=e:this.dom.inner.innerHTML=this.groupId||"";this.dom.label.title=t&&t.title||"",this.dom.inner.firstChild?n.removeClassName(this.dom.inner,"vis-hidden"):n.addClassName(this.dom.inner,"vis-hidden");var o=t&&t.className||null;o!=this.className&&(this.className&&(n.removeClassName(this.dom.label,this.className),n.removeClassName(this.dom.foreground,this.className),n.removeClassName(this.dom.background,this.className),n.removeClassName(this.dom.axis,this.className)),n.addClassName(this.dom.label,o),n.addClassName(this.dom.foreground,o),n.addClassName(this.dom.background,o),n.addClassName(this.dom.axis,o),this.className=o),this.style&&(n.removeCssText(this.dom.label,this.style),this.style=null),t&&t.style&&(n.addCssText(this.dom.label,t.style),this.style=t.style)},o.prototype.getLabelWidth=function(){return this.props.label.width},o.prototype.redraw=function(t,e,i){var o=!1,r=this.dom.marker.clientHeight;r!=this.lastMarkerHeight&&(this.lastMarkerHeight=r,n.forEach(this.items,function(t){t.dirty=!0,t.displayed&&t.redraw()}),i=!0),this._calculateSubGroupHeights(),this.isVisible=this._isGroupVisible(t,e);var a=this.dom.foreground;if(this.top=a.offsetTop,this.right=a.offsetLeft,this.width=a.offsetWidth,this.isVisible=this._isGroupVisible(t,e),"function"==typeof this.itemSet.options.order){if(i){var h=this,d=!1;n.forEach(this.items,function(t){t.displayed||(t.redraw(),h.visibleItems.push(t)),t.repositionX(d)});var l=this.orderedItems.byStart.slice().sort(function(t,e){return h.itemSet.options.order(t.data,e.data)});s.stack(l,e,!0)}this.visibleItems=this._updateVisibleItems(this.orderedItems,this.visibleItems,t)}else this.visibleItems=this._updateVisibleItems(this.orderedItems,this.visibleItems,t),this.itemSet.options.stack?s.stack(this.visibleItems,e,i):s.nostack(this.visibleItems,e,this.subgroups);if(!this.isVisible&&this.height)return o=!1;var c=this._calculateHeight(e),a=this.dom.foreground;this.top=a.offsetTop,this.right=a.offsetLeft,this.width=a.offsetWidth,o=n.updateProperty(this,"height",c)||o,o=n.updateProperty(this.props.label,"width",this.dom.inner.clientWidth)||o,o=n.updateProperty(this.props.label,"height",this.dom.inner.clientHeight)||o,this.dom.background.style.height=c+"px",this.dom.foreground.style.height=c+"px",this.dom.label.style.height=c+"px";for(var u=0,p=this.visibleItems.length;u0){var t=this;this.resetSubgroups(),n.forEach(this.visibleItems,function(e){void 0!==e.data.subgroup&&(t.subgroups[e.data.subgroup].height=Math.max(t.subgroups[e.data.subgroup].height,e.height),t.subgroups[e.data.subgroup].visible=!0)})}},o.prototype._isGroupVisible=function(t,e){var i=this.top<=t.body.domProps.centerContainer.height-t.body.domProps.scrollTop+e.axis&&this.top+this.height+e.axis>=-t.body.domProps.scrollTop;return i},o.prototype._calculateHeight=function(t){var e,i=this.visibleItems;if(i.length>0){var o=i[0].top,s=i[0].top+i[0].height;if(n.forEach(i,function(t){o=Math.min(o,t.top),s=Math.max(s,t.top+t.height)}),o>t.axis){var r=o-t.axis;s-=r,n.forEach(i,function(t){t.top-=r})}e=s+t.item.vertical/2}else e=0;return e=Math.max(e,this.props.label.height)},o.prototype.show=function(){this.dom.label.parentNode||this.itemSet.dom.labelSet.appendChild(this.dom.label),this.dom.foreground.parentNode||this.itemSet.dom.foreground.appendChild(this.dom.foreground),this.dom.background.parentNode||this.itemSet.dom.background.appendChild(this.dom.background),this.dom.axis.parentNode||this.itemSet.dom.axis.appendChild(this.dom.axis)},o.prototype.hide=function(){var t=this.dom.label;t.parentNode&&t.parentNode.removeChild(t);var e=this.dom.foreground;e.parentNode&&e.parentNode.removeChild(e);var i=this.dom.background;i.parentNode&&i.parentNode.removeChild(i);var o=this.dom.axis;o.parentNode&&o.parentNode.removeChild(o)},o.prototype.add=function(t){if(this.items[t.id]=t,t.setParent(this),void 0!==t.data.subgroup&&(void 0===this.subgroups[t.data.subgroup]&&(this.subgroups[t.data.subgroup]={height:0,visible:!1,index:this.subgroupIndex,items:[]},this.subgroupIndex++),this.subgroups[t.data.subgroup].items.push(t)),this.orderSubgroups(),this.visibleItems.indexOf(t)==-1){var e=this.itemSet.body.range;this._checkIfVisible(t,this.visibleItems,e)}},o.prototype.orderSubgroups=function(){if(void 0!==this.subgroupOrderer){var t=[];if("string"==typeof this.subgroupOrderer){for(var e in this.subgroups)t.push({subgroup:e,sortField:this.subgroups[e].items[0].data[this.subgroupOrderer]});t.sort(function(t,e){return t.sortField-e.sortField})}else if("function"==typeof this.subgroupOrderer){for(var e in this.subgroups)t.push(this.subgroups[e].items[0].data);t.sort(this.subgroupOrderer)}if(t.length>0)for(var i=0;i0)for(var r=0;rl}),1==this.checkRangedItems)for(this.checkRangedItems=!1,r=0;rl})}for(var r=0;r=0;s--){var r=e[s];if(n(r))break;void 0===o[r.id]&&(o[r.id]=!0,i.push(r))}for(var s=t+1;se.right&&t.top-o.vertical+ie.top:t.left-o.horizontal+ie.left&&t.top-o.vertical+ie.top}},function(t,e,i){function o(t,e,i){if(this.props={content:{width:0}},this.overflow=!1,this.options=i,t){if(void 0==t.start)throw new Error('Property "start" missing in item '+t.id);if(void 0==t.end)throw new Error('Property "end" missing in item '+t.id)}n.call(this,t,e,i)}var n=(i(22),i(41));o.prototype=new n(null,null,null),o.prototype.baseClassName="vis-item vis-range",o.prototype.isVisible=function(t){return this.data.startt.start},o.prototype.redraw=function(){var t=this.dom;if(t||(this.dom={},t=this.dom,t.box=document.createElement("div"),t.frame=document.createElement("div"),t.frame.className="vis-item-overflow",t.box.appendChild(t.frame),t.content=document.createElement("div"),t.content.className="vis-item-content",t.frame.appendChild(t.content),t.box["timeline-item"]=this,this.dirty=!0),!this.parent)throw new Error("Cannot redraw item: no parent attached");if(!t.box.parentNode){var e=this.parent.dom.foreground;if(!e)throw new Error("Cannot redraw item: parent has no foreground container element");e.appendChild(t.box)}if(this.displayed=!0,this.dirty){this._updateContents(this.dom.content),this._updateTitle(this.dom.box),this._updateDataAttributes(this.dom.box),this._updateStyle(this.dom.box);var i=(this.options.editable.updateTime||this.options.editable.updateGroup||this.editable===!0)&&this.editable!==!1,o=(this.data.className?" "+this.data.className:"")+(this.selected?" vis-selected":"")+(i?" vis-editable":" vis-readonly");t.box.className=this.baseClassName+o,this.overflow="hidden"!==window.getComputedStyle(t.frame).overflow,this.dom.content.style.maxWidth="none",this.props.content.width=this.dom.content.offsetWidth,this.height=this.dom.box.offsetHeight,this.dom.content.style.maxWidth="",this.dirty=!1}this._repaintOnItemUpdateTimeTooltip(t.box),this._repaintDeleteButton(t.box),this._repaintDragCenter(),this._repaintDragLeft(),this._repaintDragRight()},o.prototype.show=function(){this.displayed||this.redraw()},o.prototype.hide=function(){if(this.displayed){var t=this.dom.box;t.parentNode&&t.parentNode.removeChild(t),this.displayed=!1}},o.prototype.repositionX=function(t){var e,i,o=this.parent.width,n=this.conversion.toScreen(this.data.start),s=this.conversion.toScreen(this.data.end);void 0!==t&&t!==!0||(n<-o&&(n=-o),s>2*o&&(s=2*o));var r=Math.max(s-n+.5,1);switch(this.overflow?(this.options.rtl?this.right=n:this.left=n,this.width=r+this.props.content.width,i=this.props.content.width):(this.options.rtl?this.right=n:this.left=n,this.width=r,i=Math.min(s-n,this.props.content.width)),this.options.rtl?this.dom.box.style.right=this.right+"px":this.dom.box.style.left=this.left+"px",this.dom.box.style.width=r+"px",this.options.align){case"left":this.options.rtl?this.dom.content.style.right="0":this.dom.content.style.left="0";break;case"right":this.options.rtl?this.dom.content.style.right=Math.max(r-i,0)+"px":this.dom.content.style.left=Math.max(r-i,0)+"px";break;case"center":this.options.rtl?this.dom.content.style.right=Math.max((r-i)/2,0)+"px":this.dom.content.style.left=Math.max((r-i)/2,0)+"px";break;default:e=this.overflow?s>0?Math.max(-n,0):-i:n<0?-n:0,this.options.rtl?this.dom.content.style.right=e+"px":(this.dom.content.style.left=e+"px",this.dom.content.style.width="calc(100% - "+e+"px)")}},o.prototype.repositionY=function(){var t=this.options.orientation.item,e=this.dom.box;"top"==t?e.style.top=this.top+"px":e.style.top=this.parent.height-this.top-this.height+"px"},o.prototype._repaintDragLeft=function(){if(this.selected&&this.options.editable.updateTime&&!this.dom.dragLeft){var t=document.createElement("div");t.className="vis-drag-left",t.dragLeftItem=this,this.dom.box.appendChild(t),this.dom.dragLeft=t}else!this.selected&&this.dom.dragLeft&&(this.dom.dragLeft.parentNode&&this.dom.dragLeft.parentNode.removeChild(this.dom.dragLeft),this.dom.dragLeft=null)},o.prototype._repaintDragRight=function(){if(this.selected&&this.options.editable.updateTime&&!this.dom.dragRight){var t=document.createElement("div");t.className="vis-drag-right",t.dragRightItem=this,this.dom.box.appendChild(t),this.dom.dragRight=t}else!this.selected&&this.dom.dragRight&&(this.dom.dragRight.parentNode&&this.dom.dragRight.parentNode.removeChild(this.dom.dragRight),this.dom.dragRight=null)},t.exports=o},function(t,e,i){function o(t,e,i){this.id=null,this.parent=null,this.data=t,this.dom=null,this.conversion=e||{},this.options=i||{},this.selected=!1,this.displayed=!1,this.dirty=!0,this.top=null,this.right=null,this.left=null,this.width=null,this.height=null,this.editable=null,this.data&&this.data.hasOwnProperty("editable")&&"boolean"==typeof this.data.editable&&(this.editable=t.editable)}var n=i(22),s=i(1),r=i(2);o.prototype.stack=!0,o.prototype.select=function(){this.selected=!0,this.dirty=!0,this.displayed&&this.redraw()},o.prototype.unselect=function(){this.selected=!1,this.dirty=!0,this.displayed&&this.redraw()},o.prototype.setData=function(t){var e=void 0!=t.group&&this.data.group!=t.group;e&&this.parent.itemSet._moveToGroup(this,t.group),t.hasOwnProperty("editable")&&"boolean"==typeof t.editable&&(this.editable=t.editable),this.data=t,this.dirty=!0,this.displayed&&this.redraw()},o.prototype.setParent=function(t){this.displayed?(this.hide(),this.parent=t,this.parent&&this.show()):this.parent=t},o.prototype.isVisible=function(t){return!1},o.prototype.show=function(){return!1},o.prototype.hide=function(){return!1},o.prototype.redraw=function(){},o.prototype.repositionX=function(){},o.prototype.repositionY=function(){},o.prototype._repaintDeleteButton=function(t){var e=(this.options.editable.remove||this.data.editable===!0)&&this.data.editable!==!1;if(this.selected&&e&&!this.dom.deleteButton){var i=this,o=document.createElement("div");this.options.rtl?o.className="vis-delete-rtl":o.className="vis-delete",o.title="Delete this item",new n(o).on("tap",function(t){t.stopPropagation(),i.parent.removeFromDataSet(i)}),t.appendChild(o),this.dom.deleteButton=o}else!this.selected&&this.dom.deleteButton&&(this.dom.deleteButton.parentNode&&this.dom.deleteButton.parentNode.removeChild(this.dom.deleteButton),this.dom.deleteButton=null)},o.prototype._repaintOnItemUpdateTimeTooltip=function(t){if(this.options.tooltipOnItemUpdateTime){var e=(this.options.editable.updateTime||this.data.editable===!0)&&this.data.editable!==!1;if(this.selected&&e&&!this.dom.onItemUpdateTimeTooltip){var i=document.createElement("div");i.className="vis-onUpdateTime-tooltip",t.appendChild(i),this.dom.onItemUpdateTimeTooltip=i}else!this.selected&&this.dom.onItemUpdateTimeTooltip&&(this.dom.onItemUpdateTimeTooltip.parentNode&&this.dom.onItemUpdateTimeTooltip.parentNode.removeChild(this.dom.onItemUpdateTimeTooltip),this.dom.onItemUpdateTimeTooltip=null);if(this.dom.onItemUpdateTimeTooltip){this.dom.onItemUpdateTimeTooltip.style.visibility=this.parent.itemSet.touchParams.itemIsDragging?"visible":"hidden",this.options.rtl?this.dom.onItemUpdateTimeTooltip.style.right=this.dom.content.style.right:this.dom.onItemUpdateTimeTooltip.style.left=this.dom.content.style.left;var o,n=50,s=this.parent.itemSet.body.domProps.scrollTop;o="top"==this.options.orientation.item?this.top:this.parent.height-this.top-this.height;var a=o+this.parent.top-n<-s;a?(this.dom.onItemUpdateTimeTooltip.style.bottom="",this.dom.onItemUpdateTimeTooltip.style.top=this.height+2+"px"):(this.dom.onItemUpdateTimeTooltip.style.top="",this.dom.onItemUpdateTimeTooltip.style.bottom=this.height+2+"px");var h,d;this.options.tooltipOnItemUpdateTime&&this.options.tooltipOnItemUpdateTime.template?(d=this.options.tooltipOnItemUpdateTime.template.bind(this),h=d(this.data)):(h="start: "+r(this.data.start).format("MM/DD/YYYY hh:mm"),this.data.end&&(h+="
end: "+r(this.data.end).format("MM/DD/YYYY hh:mm"))),this.dom.onItemUpdateTimeTooltip.innerHTML=h}}},o.prototype._updateContents=function(t){var e,i;if(this.options.template){var o=this.parent.itemSet.itemsData.get(this.id);i=this.options.template.bind(this),e=i(o,t)}else e=this.data.content;if(e instanceof Object&&!(e instanceof Element))i(o,t);else{var n=this._contentToString(this.content)!==this._contentToString(e);if(n){if(e instanceof Element)t.innerHTML="",t.appendChild(e);else if(void 0!=e)t.innerHTML=e;else if("background"!=this.data.type||void 0!==this.data.content)throw new Error('Property "content" missing in item '+this.id);this.content=e}}},o.prototype._updateTitle=function(t){null!=this.data.title?t.title=this.data.title||"":t.removeAttribute("vis-title")},o.prototype._updateDataAttributes=function(t){if(this.options.dataAttributes&&this.options.dataAttributes.length>0){var e=[];if(Array.isArray(this.options.dataAttributes))e=this.options.dataAttributes;else{if("all"!=this.options.dataAttributes)return;e=Object.keys(this.data)}for(var i=0;it.start&&this.data.start.getTime()-nt.start&&this.data.start.getTime()t.start&&this.data.start.getTime()-n/2t.start&&this.data.startt.start},o.prototype.redraw=function(){var t=this.dom;if(t||(this.dom={},t=this.dom,t.box=document.createElement("div"),t.frame=document.createElement("div"),t.frame.className="vis-item-overflow",t.box.appendChild(t.frame),t.content=document.createElement("div"),t.content.className="vis-item-content",t.frame.appendChild(t.content),this.dirty=!0),!this.parent)throw new Error("Cannot redraw item: no parent attached");if(!t.box.parentNode){var e=this.parent.dom.background;if(!e)throw new Error("Cannot redraw item: parent has no background container element");e.appendChild(t.box)}if(this.displayed=!0,this.dirty){this._updateContents(this.dom.content),this._updateTitle(this.dom.content),this._updateDataAttributes(this.dom.content),this._updateStyle(this.dom.box);var i=(this.data.className?" "+this.data.className:"")+(this.selected?" vis-selected":"");t.box.className=this.baseClassName+i,this.overflow="hidden"!==window.getComputedStyle(t.content).overflow,this.props.content.width=this.dom.content.offsetWidth,this.height=0,this.dirty=!1}},o.prototype.show=r.prototype.show,o.prototype.hide=r.prototype.hide,o.prototype.repositionX=r.prototype.repositionX,o.prototype.repositionY=function(t){var e="top"===this.options.orientation.item;this.dom.content.style.top=e?"":"0",this.dom.content.style.bottom=e?"0":"";var i;if(void 0!==this.data.subgroup){var o=this.data.subgroup,n=this.parent.subgroups,r=n[o].index;if(1==e){i=this.parent.subgroups[o].height+t.item.vertical,i+=0==r?t.axis-.5*t.item.vertical:0;var a=this.parent.top;for(var h in n)n.hasOwnProperty(h)&&1==n[h].visible&&n[h].indexr&&(a+=l)}i=this.parent.subgroups[o].height+t.item.vertical,this.dom.box.style.top=this.parent.height-d+a+"px",this.dom.box.style.bottom=""}}else this.parent instanceof s?(i=Math.max(this.parent.height,this.parent.itemSet.body.domProps.center.height,this.parent.itemSet.body.domProps.centerContainer.height),this.dom.box.style.top=e?"0":"",this.dom.box.style.bottom=e?"":"0"):(i=this.parent.height,this.dom.box.style.top=this.parent.top+"px",this.dom.box.style.bottom="");this.dom.box.style.height=i+"px"},t.exports=o},function(t,e,i){function o(t,e){this.dom={foreground:null,lines:[],majorTexts:[],minorTexts:[],redundant:{lines:[],majorTexts:[],minorTexts:[]}},this.props={range:{start:0,end:0,minimumStep:0},lineTop:0},this.defaultOptions={orientation:{axis:"bottom"},showMinorLabels:!0,showMajorLabels:!0,maxMinorChars:7,format:a.FORMAT,moment:d,timeAxis:null},this.options=s.extend({},this.defaultOptions),this.body=t,this._create(),this.setOptions(e)}var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s=i(1),r=i(33),a=i(37),h=i(34),d=i(2);o.prototype=new r,o.prototype.setOptions=function(t){t&&(s.selectiveExtend(["showMinorLabels","showMajorLabels","maxMinorChars","hiddenDates","timeAxis","moment","rtl"],this.options,t),s.selectiveDeepExtend(["format"],this.options,t),"orientation"in t&&("string"==typeof t.orientation?this.options.orientation.axis=t.orientation:"object"===n(t.orientation)&&"axis"in t.orientation&&(this.options.orientation.axis=t.orientation.axis)),"locale"in t&&("function"==typeof d.locale?d.locale(t.locale):d.lang(t.locale)))},o.prototype._create=function(){this.dom.foreground=document.createElement("div"),this.dom.background=document.createElement("div"),this.dom.foreground.className="vis-time-axis vis-foreground",this.dom.background.className="vis-time-axis vis-background"},o.prototype.destroy=function(){this.dom.foreground.parentNode&&this.dom.foreground.parentNode.removeChild(this.dom.foreground),this.dom.background.parentNode&&this.dom.background.parentNode.removeChild(this.dom.background),this.body=null},o.prototype.redraw=function(){var t=this.props,e=this.dom.foreground,i=this.dom.background,o="top"==this.options.orientation.axis?this.body.dom.top:this.body.dom.bottom,n=e.parentNode!==o; +this._calculateCharSize();var s=this.options.showMinorLabels&&"none"!==this.options.orientation.axis,r=this.options.showMajorLabels&&"none"!==this.options.orientation.axis;t.minorLabelHeight=s?t.minorCharHeight:0,t.majorLabelHeight=r?t.majorCharHeight:0,t.height=t.minorLabelHeight+t.majorLabelHeight,t.width=e.offsetWidth,t.minorLineHeight=this.body.domProps.root.height-t.majorLabelHeight-("top"==this.options.orientation.axis?this.body.domProps.bottom.height:this.body.domProps.top.height),t.minorLineWidth=1,t.majorLineHeight=t.minorLineHeight+t.majorLabelHeight,t.majorLineWidth=1;var a=e.nextSibling,h=i.nextSibling;return e.parentNode&&e.parentNode.removeChild(e),i.parentNode&&i.parentNode.removeChild(i),e.style.height=this.props.height+"px",this._repaintLabels(),a?o.insertBefore(e,a):o.appendChild(e),h?this.body.dom.backgroundVertical.insertBefore(i,h):this.body.dom.backgroundVertical.appendChild(i),this._isResized()||n},o.prototype._repaintLabels=function(){var t=this.options.orientation.axis,e=s.convert(this.body.range.start,"Number"),i=s.convert(this.body.range.end,"Number"),o=this.body.util.toTime((this.props.minorCharWidth||10)*this.options.maxMinorChars).valueOf(),n=o-h.getHiddenDurationBefore(this.options.moment,this.body.hiddenDates,this.body.range,o);n-=this.body.util.toTime(0).valueOf();var r=new a(new Date(e),new Date(i),n,this.body.hiddenDates);r.setMoment(this.options.moment),this.options.format&&r.setFormat(this.options.format),this.options.timeAxis&&r.setScale(this.options.timeAxis),this.step=r;var d=this.dom;d.redundant.lines=d.lines,d.redundant.majorTexts=d.majorTexts,d.redundant.minorTexts=d.minorTexts,d.lines=[],d.majorTexts=[],d.minorTexts=[];var c,u,p,f,m,v,g,y,b,_,w=0,x=void 0,k=0,O=1e3;for(r.start(),u=r.getCurrent(),f=this.body.util.toScreen(u);r.hasNext()&&k=.4*g;if(this.options.showMinorLabels&&D){var S=this._repaintMinorText(p,b,t,_);S.style.width=w+"px"}m&&this.options.showMajorLabels?(p>0&&(void 0==x&&(x=p),S=this._repaintMajorText(p,r.getLabelMajor(),t,_)),y=this._repaintMajorLine(p,w,t,_)):D?y=this._repaintMinorLine(p,w,t,_):y&&(y.style.width=parseInt(y.style.width)+w+"px")}if(k!==O||l||(console.warn("Something is wrong with the Timeline scale. Limited drawing of grid lines to "+O+" lines."),l=!0),this.options.showMajorLabels){var C=this.body.util.toTime(0),T=r.getLabelMajor(C),E=T.length*(this.props.majorCharWidth||10)+10;(void 0==x||E1e3&&(o=1e3),e.redraw(),e.body.emitter.emit("currentTimeTick"),e.currentTimeTimer=setTimeout(t,o)}var e=this;t()},o.prototype.stop=function(){void 0!==this.currentTimeTimer&&(clearTimeout(this.currentTimeTimer),delete this.currentTimeTimer)},o.prototype.setCurrentTime=function(t){var e=n.convert(t,"Date").valueOf(),i=(new Date).valueOf();this.offset=e-i,this.redraw()},o.prototype.getCurrentTime=function(){return new Date((new Date).valueOf()+this.offset)},t.exports=o},function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var i="string",o="boolean",n="number",s="array",r="date",a="object",h="dom",d="moment",l="any",c={configure:{enabled:{boolean:o},filter:{boolean:o,function:"function"},container:{dom:h},__type__:{object:a,boolean:o,function:"function"}},align:{string:i},rtl:{boolean:o,undefined:"undefined"},verticalScroll:{boolean:o,undefined:"undefined"},horizontalScroll:{boolean:o,undefined:"undefined"},autoResize:{boolean:o},clickToUse:{boolean:o},dataAttributes:{string:i,array:s},editable:{add:{boolean:o,undefined:"undefined"},remove:{boolean:o,undefined:"undefined"},updateGroup:{boolean:o,undefined:"undefined"},updateTime:{boolean:o,undefined:"undefined"},__type__:{boolean:o,object:a}},end:{number:n,date:r,string:i,moment:d},format:{minorLabels:{millisecond:{string:i,undefined:"undefined"},second:{string:i,undefined:"undefined"},minute:{string:i,undefined:"undefined"},hour:{string:i,undefined:"undefined"},weekday:{string:i,undefined:"undefined"},day:{string:i,undefined:"undefined"},month:{string:i,undefined:"undefined"},year:{string:i,undefined:"undefined"},__type__:{object:a,function:"function"}},majorLabels:{millisecond:{string:i,undefined:"undefined"},second:{string:i,undefined:"undefined"},minute:{string:i,undefined:"undefined"},hour:{string:i,undefined:"undefined"},weekday:{string:i,undefined:"undefined"},day:{string:i,undefined:"undefined"},month:{string:i,undefined:"undefined"},year:{string:i,undefined:"undefined"},__type__:{object:a,function:"function"}},__type__:{object:a}},moment:{function:"function"},groupOrder:{string:i,function:"function"},groupEditable:{add:{boolean:o,undefined:"undefined"},remove:{boolean:o,undefined:"undefined"},order:{boolean:o,undefined:"undefined"},__type__:{boolean:o,object:a}},groupOrderSwap:{function:"function"},height:{string:i,number:n},hiddenDates:{start:{date:r,number:n,string:i,moment:d},end:{date:r,number:n,string:i,moment:d},repeat:{string:i},__type__:{object:a,array:s}},itemsAlwaysDraggable:{boolean:o},locale:{string:i},locales:{__any__:{any:l},__type__:{object:a}},margin:{axis:{number:n},item:{horizontal:{number:n,undefined:"undefined"},vertical:{number:n,undefined:"undefined"},__type__:{object:a,number:n}},__type__:{object:a,number:n}},max:{date:r,number:n,string:i,moment:d},maxHeight:{number:n,string:i},maxMinorChars:{number:n},min:{date:r,number:n,string:i,moment:d},minHeight:{number:n,string:i},moveable:{boolean:o},multiselect:{boolean:o},multiselectPerGroup:{boolean:o},onAdd:{function:"function"},onUpdate:{function:"function"},onMove:{function:"function"},onMoving:{function:"function"},onRemove:{function:"function"},onAddGroup:{function:"function"},onMoveGroup:{function:"function"},onRemoveGroup:{function:"function"},order:{function:"function"},orientation:{axis:{string:i,undefined:"undefined"},item:{string:i,undefined:"undefined"},__type__:{string:i,object:a}},selectable:{boolean:o},showCurrentTime:{boolean:o},showMajorLabels:{boolean:o},showMinorLabels:{boolean:o},stack:{boolean:o},snap:{function:"function",null:"null"},start:{date:r,number:n,string:i,moment:d},template:{function:"function"},groupTemplate:{function:"function"},tooltipOnItemUpdateTime:{template:{function:"function"},__type__:{boolean:o,object:a}},timeAxis:{scale:{string:i,undefined:"undefined"},step:{number:n,undefined:"undefined"},__type__:{object:a}},type:{string:i},width:{string:i,number:n},zoomable:{boolean:o},zoomKey:{string:["ctrlKey","altKey","metaKey",""]},zoomMax:{number:n},zoomMin:{number:n},__type__:{object:a}},u={global:{align:["center","left","right"],direction:!1,autoResize:!0,clickToUse:!1,editable:{add:!1,remove:!1,updateGroup:!1,updateTime:!1},end:"",format:{minorLabels:{millisecond:"SSS",second:"s",minute:"HH:mm",hour:"HH:mm",weekday:"ddd D",day:"D",month:"MMM",year:"YYYY"},majorLabels:{millisecond:"HH:mm:ss",second:"D MMMM HH:mm",minute:"ddd D MMMM",hour:"ddd D MMMM",weekday:"MMMM YYYY",day:"MMMM YYYY",month:"YYYY",year:""}},groupsDraggable:!1,height:"",locale:"",margin:{axis:[20,0,100,1],item:{horizontal:[10,0,100,1],vertical:[10,0,100,1]}},max:"",maxHeight:"",maxMinorChars:[7,0,20,1],min:"",minHeight:"",moveable:!1,multiselect:!1,multiselectPerGroup:!1,orientation:{axis:["both","bottom","top"],item:["bottom","top"]},selectable:!0,showCurrentTime:!1,showMajorLabels:!0,showMinorLabels:!0,stack:!0,start:"",tooltipOnItemUpdateTime:!1,type:["box","point","range","background"],width:"100%",zoomable:!0,zoomKey:["ctrlKey","altKey","metaKey",""],zoomMax:[31536e10,10,31536e10,1],zoomMin:[10,10,31536e10,1]}};e.allOptions=c,e.configureOptions=u},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e,i,o){if(!(Array.isArray(i)||i instanceof c||i instanceof u)&&i instanceof Object){var n=o;o=i,i=n}var s=this;this.defaultOptions={start:null,end:null,autoResize:!0,orientation:{axis:"bottom",item:"bottom"},moment:d,width:null,height:null,maxHeight:null,minHeight:null},this.options=l.deepExtend({},this.defaultOptions),this._create(t),this.components=[],this.body={dom:this.dom,domProps:this.props,emitter:{on:this.on.bind(this),off:this.off.bind(this),emit:this.emit.bind(this)},hiddenDates:[],util:{toScreen:s._toScreen.bind(s),toGlobalScreen:s._toGlobalScreen.bind(s),toTime:s._toTime.bind(s),toGlobalTime:s._toGlobalTime.bind(s)}},this.range=new p(this.body),this.components.push(this.range),this.body.range=this.range,this.timeAxis=new m(this.body),this.components.push(this.timeAxis),this.currentTime=new v(this.body),this.components.push(this.currentTime),this.linegraph=new y(this.body),this.components.push(this.linegraph),this.itemsData=null,this.groupsData=null,this.on("tap",function(t){s.emit("click",s.getEventProperties(t))}),this.on("doubletap",function(t){s.emit("doubleClick",s.getEventProperties(t))}),this.dom.root.oncontextmenu=function(t){s.emit("contextmenu",s.getEventProperties(t))},o&&this.setOptions(o),i&&this.setGroups(i),e&&this.setItems(e),this._redraw()}var s=i(28),r=o(s),a=i(31),h=o(a),d=(i(13),i(22),i(2)),l=i(1),c=i(9),u=i(11),p=i(32),f=i(35),m=i(46),v=i(50),g=i(48),y=i(53),b=i(31).printStyle,_=i(61).allOptions,w=i(61).configureOptions;n.prototype=new f,n.prototype.setOptions=function(t){var e=h.default.validate(t,_);e===!0&&console.log("%cErrors have been found in the supplied options object.",b),f.prototype.setOptions.call(this,t)},n.prototype.setItems=function(t){var e,i=null==this.itemsData;if(e=t?t instanceof c||t instanceof u?t:new c(t,{type:{start:"Date",end:"Date"}}):null,this.itemsData=e,this.linegraph&&this.linegraph.setItems(e),i)if(void 0!=this.options.start||void 0!=this.options.end){var o=void 0!=this.options.start?this.options.start:null,n=void 0!=this.options.end?this.options.end:null;this.setWindow(o,n,{animation:!1})}else this.fit({animation:!1})},n.prototype.setGroups=function(t){var e;e=t?t instanceof c||t instanceof u?t:new c(t):null,this.groupsData=e,this.linegraph.setGroups(e)},n.prototype.getLegend=function(t,e,i){return void 0===e&&(e=15),void 0===i&&(i=15),void 0!==this.linegraph.groups[t]?this.linegraph.groups[t].getLegend(e,i):"cannot find group:'"+t+"'"},n.prototype.isGroupVisible=function(t){return void 0!==this.linegraph.groups[t]&&(this.linegraph.groups[t].visible&&(void 0===this.linegraph.options.groups.visibility[t]||1==this.linegraph.options.groups.visibility[t]))},n.prototype.getDataRange=function(){var t=null,e=null;for(var i in this.linegraph.groups)if(this.linegraph.groups.hasOwnProperty(i)&&1==this.linegraph.groups[i].visible)for(var o=0;os?s:t,e=null==e?s:e0){var h={};for(this._getRelevantData(a,h,n,s),this._applySampling(a,h),e=0;e0)switch(t.options.style){case"line":l.hasOwnProperty(a[e])||(l[a[e]]=f.calcPath(h[a[e]],t)),f.draw(l[a[e]],t,this.framework);case"point":case"points":"point"!=t.options.style&&"points"!=t.options.style&&1!=t.options.drawPoints.enabled||m.draw(h[a[e]],t,this.framework);break;case"bar":}}}return r.cleanupElements(this.svgElements),!1},o.prototype._stack=function(t,e){var i,o,n,s,r;i=0;for(var a=0;at[a].x){r=e[h],s=0==h?r:e[h-1],i=h;break}}void 0===r&&(s=e[e.length-1],r=e[e.length-1]),o=r.x-s.x,n=r.y-s.y,0==o?t[a].y=t[a].orginalY+r.y:t[a].y=t[a].orginalY+n/o*(t[a].x-s.x)+s.y}},o.prototype._getRelevantData=function(t,e,i,o){var n,r,a,h;if(t.length>0)for(r=0;r0)for(var o=0;o0){var s=1,r=n.length,a=this.body.util.toGlobalScreen(n[n.length-1].x)-this.body.util.toGlobalScreen(n[0].x),h=r/a;s=Math.min(Math.ceil(.2*r),Math.max(1,Math.round(h)));for(var d=new Array(r),l=0;l0){for(s=0;s0&&(n=this.groups[t[s]],r.stack===!0&&"bar"===r.style?"left"===r.yAxisOrientation?a=a.concat(n.getItems()):h=h.concat(n.getItems()):i[t[s]]=n.getYRange(o,t[s]));p.getStackedYRange(a,i,t,"__barStackLeft","left"),p.getStackedYRange(h,i,t,"__barStackRight","right")}},o.prototype._updateYAxis=function(t,e){var i,o,n=!1,s=!1,r=!1,a=1e9,h=1e9,d=-1e9,l=-1e9;if(t.length>0){for(var c=0;ci?i:a,d=di?i:h,l=l=0&&t._redrawLabel(o-2,e.val,i,"vis-y-axis vis-major",t.props.majorCharHeight),t.master===!0&&(n?t._redrawLine(o,i,"vis-grid vis-horizontal vis-major",t.options.majorLinesOffset,t.props.majorLineWidth):t._redrawLine(o,i,"vis-grid vis-horizontal vis-minor",t.options.minorLinesOffset,t.props.minorLineWidth))});var d=0;void 0!==this.options[i].title&&void 0!==this.options[i].title.text&&(d=this.props.titleCharHeight);var l=this.options.icons===!0?Math.max(this.options.iconWidth,d)+this.options.labelOffsetX+15:d+this.options.labelOffsetX+15;return this.maxLabelSize>this.width-l&&this.options.visible===!0?(this.width=this.maxLabelSize+l,this.options.width=this.width+"px",s.cleanupElements(this.DOMelements.lines),s.cleanupElements(this.DOMelements.labels),this.redraw(),e=!0):this.maxLabelSizethis.minWidth?(this.width=Math.max(this.minWidth,this.maxLabelSize+l),this.options.width=this.width+"px",s.cleanupElements(this.DOMelements.lines),s.cleanupElements(this.DOMelements.labels),this.redraw(),e=!0):(s.cleanupElements(this.DOMelements.lines),s.cleanupElements(this.DOMelements.labels),e=!1),e},o.prototype.convertValue=function(t){return this.scale.convertValue(t)},o.prototype.screenToValue=function(t){return this.scale.screenToValue(t)},o.prototype._redrawLabel=function(t,e,i,o,n){var r=s.getDOMElement("div",this.DOMelements.labels,this.dom.frame);r.className=o,r.innerHTML=e,"left"===i?(r.style.left="-"+this.options.labelOffsetX+"px",r.style.textAlign="right"):(r.style.right="-"+this.options.labelOffsetX+"px",r.style.textAlign="left"),r.style.top=t-.5*n+this.options.labelOffsetY+"px",e+="";var a=Math.max(this.props.majorCharWidth,this.props.minorCharWidth);this.maxLabelSize6&&void 0!==arguments[6]&&arguments[6],a=arguments.length>7&&void 0!==arguments[7]&&arguments[7];if(this.majorSteps=[1,2,5,10],this.minorSteps=[.25,.5,1,2],this.customLines=null,this.containerHeight=n,this.majorCharHeight=s,this._start=t,this._end=e,this.scale=1,this.minorStepIdx=-1,this.magnitudefactor=1,this.determineScale(),this.zeroAlign=r,this.autoScaleStart=i,this.autoScaleEnd=o,this.formattingFunction=a,i||o){var h=this,d=function(t){var e=t-t%(h.magnitudefactor*h.minorSteps[h.minorStepIdx]);return t%(h.magnitudefactor*h.minorSteps[h.minorStepIdx])>.5*(h.magnitudefactor*h.minorSteps[h.minorStepIdx])?e+h.magnitudefactor*h.minorSteps[h.minorStepIdx]:e};i&&(this._start-=2*this.magnitudefactor*this.minorSteps[this.minorStepIdx],this._start=d(this._start)),o&&(this._end+=this.magnitudefactor*this.minorSteps[this.minorStepIdx],this._end=d(this._end)),this.determineScale()}}i.prototype.setCharHeight=function(t){this.majorCharHeight=t},i.prototype.setHeight=function(t){this.containerHeight=t},i.prototype.determineScale=function(){var t=this._end-this._start;this.scale=this.containerHeight/t;var e=this.majorCharHeight/this.scale,i=t>0?Math.round(Math.log(t)/Math.LN10):0;this.minorStepIdx=-1,this.magnitudefactor=Math.pow(10,i);var o=0;i<0&&(o=i);for(var n=!1,s=o;Math.abs(s)<=Math.abs(i);s++){this.magnitudefactor=Math.pow(10,s);for(var r=0;r=e){n=!0,this.minorStepIdx=r;break}}if(n===!0)break}},i.prototype.is_major=function(t){return t%(this.magnitudefactor*this.majorSteps[this.minorStepIdx])===0},i.prototype.getStep=function(){return this.magnitudefactor*this.minorSteps[this.minorStepIdx]},i.prototype.getFirstMajor=function(){var t=this.magnitudefactor*this.majorSteps[this.minorStepIdx];return this.convertValue(this._start+(t-this._start%t)%t)},i.prototype.formatValue=function(t){var e=t.toPrecision(5);return"function"==typeof this.formattingFunction&&(e=this.formattingFunction(t)),"number"==typeof e?""+e:"string"==typeof e?e:t.toPrecision(5)},i.prototype.getLines=function(){for(var t=[],e=this.getStep(),i=(e-this._start%e)%e,o=this._start+i;this._end-o>1e-5;o+=e)o!=this._start&&t.push({major:this.is_major(o),y:this.convertValue(o),val:this.formatValue(o)});return t},i.prototype.followScale=function(t){var e=this.minorStepIdx,i=this._start,o=this._end,n=this,s=function(){n.magnitudefactor*=2},r=function(){n.magnitudefactor/=2};t.minorStepIdx<=1&&this.minorStepIdx<=1||t.minorStepIdx>1&&this.minorStepIdx>1||(t.minorStepIdxo+1e-5)r(),d=!1;else{if(!this.autoScaleStart&&this._start=0)){r(),d=!1;continue}console.warn("Can't adhere to given 'min' range, due to zeroalign")}this.autoScaleStart&&this.autoScaleEnd&&ce.x?1:-1})):this.itemsData=[]},o.prototype.getItems=function(){return this.itemsData},o.prototype.setZeroPosition=function(t){this.zeroPosition=t},o.prototype.setOptions=function(t){if(void 0!==t){var e=["sampling","style","sort","yAxisOrientation","barChart","zIndex","excludeFromStacking","excludeFromLegend"];s.selectiveDeepExtend(e,this.options,t),"function"==typeof t.drawPoints&&(t.drawPoints={onRender:t.drawPoints}),s.mergeOptions(this.options,t,"interpolation"),s.mergeOptions(this.options,t,"drawPoints"),s.mergeOptions(this.options,t,"shaded"),t.interpolation&&"object"==n(t.interpolation)&&t.interpolation.parametrization&&("uniform"==t.interpolation.parametrization?this.options.interpolation.alpha=0:"chordal"==t.interpolation.parametrization?this.options.interpolation.alpha=1:(this.options.interpolation.parametrization="centripetal",this.options.interpolation.alpha=.5))}},o.prototype.update=function(t){this.group=t,this.content=t.content||"graph",this.className=t.className||this.className||"vis-graph-group"+this.groupsUsingDefaultStyles[0]%10,this.visible=void 0===t.visible||t.visible,this.style=t.style,this.setOptions(t.options)},o.prototype.getLegend=function(t,e,i,o,n){if(void 0==i||null==i){var s=document.createElementNS("http://www.w3.org/2000/svg","svg");i={svg:s,svgElements:{},options:this.options,groups:[this]}}switch(void 0!=o&&null!=o||(o=0),void 0!=n&&null!=n||(n=.5*e),this.options.style){case"line":a.drawIcon(this,o,n,t,e,i);break;case"points":case"point":h.drawIcon(this,o,n,t,e,i);break;case"bar":r.drawIcon(this,o,n,t,e,i)}return{icon:i.svg,label:this.content,orientation:this.options.yAxisOrientation}},o.prototype.getYRange=function(t){for(var e=t[0].y,i=t[0].y,o=0;ot[o].y?t[o].y:e,i=i0&&(i=Math.min(i,Math.abs(e[o-1].screen_x-e[o].screen_x))),0===i&&(void 0===t[e[o].screen_x]&&(t[e[o].screen_x]={amount:0,resolved:0,accumulatedPositive:0,accumulatedNegative:0}),t[e[o].screen_x].amount+=1)},o._getSafeDrawData=function(t,e,i){var o,n;return t0?(o=t0){t.sort(function(t,e){return t.screen_x===e.screen_x?t.groupIde[s].screen_y?e[s].screen_y:o,n=nt[r].accumulatedNegative?t[r].accumulatedNegative:o,o=o>t[r].accumulatedPositive?t[r].accumulatedPositive:o,n=n0){var i=[];return i=1==e.options.interpolation.enabled?o._catmullRom(t,e):o._linear(t)}},o.drawIcon=function(t,e,i,o,s,r){var a,h,d=.5*s,l=n.getSVGElement("rect",r.svgElements,r.svg);if(l.setAttributeNS(null,"x",e),l.setAttributeNS(null,"y",i-d),l.setAttributeNS(null,"width",o),l.setAttributeNS(null,"height",2*d),l.setAttributeNS(null,"class","vis-outline"),a=n.getSVGElement("path",r.svgElements,r.svg),a.setAttributeNS(null,"class",t.className),void 0!==t.style&&a.setAttributeNS(null,"style",t.style),a.setAttributeNS(null,"d","M"+e+","+i+" L"+(e+o)+","+i),1==t.options.shaded.enabled&&(h=n.getSVGElement("path",r.svgElements,r.svg),"top"==t.options.shaded.orientation?h.setAttributeNS(null,"d","M"+e+", "+(i-d)+"L"+e+","+i+" L"+(e+o)+","+i+" L"+(e+o)+","+(i-d)):h.setAttributeNS(null,"d","M"+e+","+i+" L"+e+","+(i+d)+" L"+(e+o)+","+(i+d)+"L"+(e+o)+","+i),h.setAttributeNS(null,"class",t.className+" vis-icon-fill"),void 0!==t.options.shaded.style&&""!==t.options.shaded.style&&h.setAttributeNS(null,"style",t.options.shaded.style)),1==t.options.drawPoints.enabled){var c={style:t.options.drawPoints.style,styles:t.options.drawPoints.styles,size:t.options.drawPoints.size,className:t.className};n.drawPoint(e+.5*o,i,c,r.svgElements,r.svg)}},o.drawShading=function(t,e,i,o){if(1==e.options.shaded.enabled){var s=Number(o.svg.style.height.replace("px","")),r=n.getSVGElement("path",o.svgElements,o.svg),a="L";1==e.options.interpolation.enabled&&(a="C");var h,d=0;d="top"==e.options.shaded.orientation?0:"bottom"==e.options.shaded.orientation?s:Math.min(Math.max(0,e.zeroPosition),s),h="group"==e.options.shaded.orientation&&null!=i&&void 0!=i?"M"+t[0][0]+","+t[0][1]+" "+this.serializePath(t,a,!1)+" L"+i[i.length-1][0]+","+i[i.length-1][1]+" "+this.serializePath(i,a,!0)+i[0][0]+","+i[0][1]+" Z":"M"+t[0][0]+","+t[0][1]+" "+this.serializePath(t,a,!1)+" V"+d+" H"+t[0][0]+" Z",r.setAttributeNS(null,"class",e.className+" vis-fill"),void 0!==e.options.shaded.style&&r.setAttributeNS(null,"style",e.options.shaded.style),r.setAttributeNS(null,"d",h)}},o.draw=function(t,e,i){if(null!=t&&void 0!=t){var o=n.getSVGElement("path",i.svgElements,i.svg);o.setAttributeNS(null,"class",e.className),void 0!==e.style&&o.setAttributeNS(null,"style",e.style);var s="L";1==e.options.interpolation.enabled&&(s="C"),o.setAttributeNS(null,"d","M"+t[0][0]+","+t[0][1]+" "+this.serializePath(t,s,!1))}},o.serializePath=function(t,e,i){if(t.length<2)return"";var o=e;if(i)for(var n=t.length-2;n>0;n--)o+=t[n][0]+","+t[n][1]+" ";else for(var n=1;n0&&(f=1/f),m=3*v*(v+g),m>0&&(m=1/m),a={screen_x:(-b*o.screen_x+u*n.screen_x+_*s.screen_x)*f,screen_y:(-b*o.screen_y+u*n.screen_y+_*s.screen_y)*f},h={screen_x:(y*n.screen_x+p*s.screen_x-b*r.screen_x)*m,screen_y:(y*n.screen_y+p*s.screen_y-b*r.screen_y)*m},0==a.screen_x&&0==a.screen_y&&(a=n),0==h.screen_x&&0==h.screen_y&&(h=s),x.push([a.screen_x,a.screen_y]),x.push([h.screen_x,h.screen_y]),x.push([s.screen_x,s.screen_y]);return x},o._linear=function(t){for(var e=[],i=0;i")}this.dom.textArea.innerHTML=s,this.dom.textArea.style.lineHeight=.75*this.options.iconSize+this.options.iconSpacing+"px"}},o.prototype.drawLegendIcons=function(){if(this.dom.frame.parentNode){var t=Object.keys(this.groups);t.sort(function(t,e){return t0){var i=this.groupIndex%this.groupsArray.length;this.groupIndex++,e={},e.color=this.groups[this.groupsArray[i]],this.groups[t]=e}else{var o=this.defaultIndex%this.defaultGroups.length;this.defaultIndex++,e={},e.color=this.defaultGroups[o],this.groups[t]=e}return e}},{key:"add",value:function(t,e){return this.groups[t]=e,this.groupsArray.push(t),e}}]),t}();e.default=r},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){for(var i=0;i1&&void 0!==arguments[1]&&arguments[1],o=this.body.data.nodes;if(t instanceof c||t instanceof u)this.body.data.nodes=t;else if(Array.isArray(t))this.body.data.nodes=new c,this.body.data.nodes.add(t);else{if(t)throw new TypeError("Array or DataSet expected");this.body.data.nodes=new c}o&&l.forEach(this.nodesListeners,function(t,e){o.off(e,t)}),this.body.nodes={},this.body.data.nodes&&!function(){var t=e;l.forEach(e.nodesListeners,function(e,i){t.body.data.nodes.on(i,e)});var i=e.body.data.nodes.getIds();e.add(i,!0)}(),i===!1&&this.body.emitter.emit("_dataChanged")}},{key:"add",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=void 0,o=[],n=0;n1&&void 0!==arguments[1]?arguments[1]:a.default;return new e(t,this.body,this.images,this.groups,this.options)}},{key:"refresh",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.body.nodes;for(var i in e){var o=void 0;e.hasOwnProperty(i)&&(o=e[i]);var n=this.body.data.nodes._data[i];void 0!==o&&void 0!==n&&(t===!0&&o.setOptions({x:null,y:null}),o.setOptions({fixed:!1}),o.setOptions(n))}}},{key:"getPositions",value:function(t){var e={};if(void 0!==t){if(Array.isArray(t)===!0){for(var i=0;it.left&&this.shape.topt.top}},{key:"isBoundingBoxOverlappingWith",value:function(t){return this.shape.boundingBox.leftt.left&&this.shape.boundingBox.topt.top}}],[{key:"parseOptions",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=["color","font","fixed","shadow"];if(A.selectiveNotDeepExtend(n,t,e,i),A.mergeOptions(t,e,"shadow",i,o),void 0!==e.color&&null!==e.color){var s=A.parseColor(e.color);A.fillIfDefined(t.color,s)}else i===!0&&null===e.color&&(t.color=A.bridgeObject(o.color));void 0!==e.fixed&&null!==e.fixed&&("boolean"==typeof e.fixed?(t.fixed.x=e.fixed,t.fixed.y=e.fixed):(void 0!==e.fixed.x&&"boolean"==typeof e.fixed.x&&(t.fixed.x=e.fixed.x),void 0!==e.fixed.y&&"boolean"==typeof e.fixed.y&&(t.fixed.y=e.fixed.y))),void 0!==e.font&&null!==e.font?a.default.parseOptions(t.font,e):i===!0&&null===e.font&&(t.font=A.bridgeObject(o.font)),void 0!==e.scaling&&A.mergeOptions(t.scaling,e.scaling,"label",i,o.scaling)}}]),t}();e.default=B},function(t,e,i){function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){var i=[],o=!0,n=!1,s=void 0;try{for(var r,a=t[Symbol.iterator]();!(o=(r=a.next()).done)&&(i.push(r.value),!e||i.length!==e);o=!0);}catch(t){n=!0,s=t}finally{try{!o&&a.return&&a.return()}finally{if(n)throw s}}return i}return function(e,i){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r=function(){function t(t,e){for(var i=0;i2&&void 0!==arguments[2]&&arguments[2];o(this,t),this.body=e,this.pointToSelf=!1,this.baseSize=void 0,this.fontOptions={},this.setOptions(i),this.size={top:0,left:0,width:0,height:0,yLine:0},this.isEdgeLabel=n}return r(t,[{key:"setOptions",value:function(e){var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.nodeOptions=e,this.fontOptions=a.deepExtend({},e.font,!0),void 0!==e.label&&(this.labelDirty=!0),void 0!==e.font&&(t.parseOptions(this.fontOptions,e,i),"string"==typeof e.font?this.baseSize=this.fontOptions.size:"object"===s(e.font)&&void 0!==e.font.size&&(this.baseSize=e.font.size))}},{key:"draw",value:function(t,e,i,o){var n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"middle";if(void 0!==this.nodeOptions.label){var s=this.fontOptions.size*this.body.view.scale;this.nodeOptions.label&&s4&&void 0!==arguments[4]?arguments[4]:"middle",r=this.fontOptions.size,a=r*this.body.view.scale;a>=this.nodeOptions.scaling.label.maxVisible&&(r=Number(this.nodeOptions.scaling.label.maxVisible)/this.body.view.scale);var h=this.size.yLine,d=this._getColor(a),l=n(d,2),c=l[0],u=l[1],p=this._setAlignment(t,i,h,s),f=n(p,2);i=f[0],h=f[1],t.font=(e&&this.nodeOptions.labelHighlightBold?"bold ":"")+r+"px "+this.fontOptions.face,t.fillStyle=c,this.isEdgeLabel||"left"!==this.fontOptions.align?t.textAlign="center":(t.textAlign=this.fontOptions.align,i-=.5*this.size.width),this.fontOptions.strokeWidth>0&&(t.lineWidth=this.fontOptions.strokeWidth,t.strokeStyle=u,t.lineJoin="round");for(var m=0;m0&&t.strokeText(this.lines[m],i,h),t.fillText(this.lines[m],i,h),h+=r}},{key:"_setAlignment",value:function(t,e,i,o){if(this.isEdgeLabel&&"horizontal"!==this.fontOptions.align&&this.pointToSelf===!1){e=0,i=0;var n=2;"top"===this.fontOptions.align?(t.textBaseline="alphabetic",i-=2*n):"bottom"===this.fontOptions.align?(t.textBaseline="hanging",i+=2*n):t.textBaseline="middle"}else t.textBaseline=o;return[e,i]}},{key:"_getColor",value:function(t){var e=this.fontOptions.color||"#000000",i=this.fontOptions.strokeColor||"#ffffff";if(t<=this.nodeOptions.scaling.label.drawThreshold){var o=Math.max(0,Math.min(1,1-(this.nodeOptions.scaling.label.drawThreshold-t)));e=a.overrideOpacity(e,o),i=a.overrideOpacity(i,o)}return[e,i]}},{key:"getTextSize",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i={width:this._processLabel(t,e),height:this.fontOptions.size*this.lineCount,lineCount:this.lineCount};return i}},{key:"calculateLabelSize",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"middle";this.labelDirty===!0&&(this.size.width=this._processLabel(t,e)),this.size.height=this.fontOptions.size*this.lineCount,this.size.left=i-.5*this.size.width,this.size.top=o-.5*this.size.height,this.size.yLine=o+.5*(1-this.lineCount)*this.fontOptions.size,"hanging"===n&&(this.size.top+=.5*this.fontOptions.size,this.size.top+=4,this.size.yLine+=4),this.labelDirty=!1}},{key:"_processLabel",value:function(t,e){var i=0,o=[""],n=0;if(void 0!==this.nodeOptions.label){o=String(this.nodeOptions.label).split("\n"),n=o.length,t.font=(e&&this.nodeOptions.labelHighlightBold?"bold ":"")+this.fontOptions.size+"px "+this.fontOptions.face,i=t.measureText(o[0]).width;for(var s=1;si?r:i}}return this.lines=o,this.lineCount=n,i}}],[{key:"parseOptions",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("string"==typeof e.font){var o=e.font.split(" ");t.size=o[0].replace("px",""),t.face=o[1],t.color=o[2]}else"object"===s(e.font)&&a.fillIfDefined(t,e.font,i);t.size=Number(t.size)}}]),t}();e.default=h},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var i=0;i0&&(this.enableBorderDashes(t),t.stroke(),this.disableBorderDashes(t)),t.restore(),this.updateBoundingBox(e,i,t,o),this.labelModule.draw(t,e,i,o)}},{key:"updateBoundingBox",value:function(t,e,i,o){this.resize(i,o),this.left=t-.5*this.width,this.top=e-.5*this.height;var n=this.options.shapeProperties.borderRadius;this.boundingBox.left=this.left-n,this.boundingBox.top=this.top-n,this.boundingBox.bottom=this.top+this.height+n,this.boundingBox.right=this.left+this.width+n}},{key:"distanceToBorder",value:function(t,e){this.resize(t);var i=this.options.borderWidth;return Math.min(Math.abs(this.width/2/Math.cos(e)),Math.abs(this.height/2/Math.sin(e)))+i}}]),e}(d.default);e.default=l},function(t,e){function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var i=0;ithis.imageObj.height?(o=this.imageObj.width/this.imageObj.height,e=2*this.options.size*o||this.imageObj.width,i=2*this.options.size||this.imageObj.height):(o=this.imageObj.width&&this.imageObj.height?this.imageObj.height/this.imageObj.width:1,e=2*this.options.size,i=2*this.options.size*o):(e=this.imageObj.width,i=this.imageObj.height),this.width=e,this.height=i,this.radius=.5*this.width}}},{key:"_drawRawCircle",value:function(t,e,i,o,n,s){var r=this.options.borderWidth,a=this.options.borderWidthSelected||2*this.options.borderWidth,h=(o?a:r)/this.body.view.scale;t.lineWidth=Math.min(this.width,h),t.strokeStyle=o?this.options.color.highlight.border:n?this.options.color.hover.border:this.options.color.border,t.fillStyle=o?this.options.color.highlight.background:n?this.options.color.hover.background:this.options.color.background,t.circle(e,i,s),this.enableShadow(t),t.fill(),this.disableShadow(t),t.save(),h>0&&(this.enableBorderDashes(t),t.stroke(),this.disableBorderDashes(t)),t.restore()}},{key:"_drawImageAtPosition",value:function(t){if(0!=this.imageObj.width){t.globalAlpha=1,this.enableShadow(t);var e=this.imageObj.width/this.width/this.body.view.scale;if(e>2&&this.options.shapeProperties.interpolation===!0){var i=this.imageObj.width,o=this.imageObj.height,n=document.createElement("canvas");n.width=i,n.height=i;var s=n.getContext("2d");e*=.5,i*=.5,o*=.5,s.drawImage(this.imageObj,0,0,i,o);for(var r=0,a=1;e>2&&a<4;)s.drawImage(n,r,0,i,o,r+i,0,i/2,o/2),r+=i,e*=.5,i*=.5,o*=.5,a+=1;t.drawImage(n,r,0,i,o,this.left,this.top,this.width,this.height)}else t.drawImage(this.imageObj,this.left,this.top,this.width,this.height);this.disableShadow(t)}}},{key:"_drawImageLabel",value:function(t,e,i,o){var n,s=0;if(void 0!==this.height){s=.5*this.height;var r=this.labelModule.getTextSize(t);r.lineCount>=1&&(s+=r.height/2)}n=i+s,this.options.label&&(this.labelOffset=s),this.labelModule.draw(t,e,n,o,"hanging")}}]),e}(d.default);e.default=l},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var i=0;i0&&(this.enableBorderDashes(t),t.stroke(),this.disableBorderDashes(t)),t.restore(),this.updateBoundingBox(e,i,t,o),this.labelModule.draw(t,e,i,o)}},{key:"updateBoundingBox",value:function(t,e,i,o){this.resize(i,o),this.left=t-.5*this.width,this.top=e-.5*this.height,this.boundingBox.left=this.left,this.boundingBox.top=this.top,this.boundingBox.bottom=this.top+this.height,this.boundingBox.right=this.left+this.width}},{key:"distanceToBorder",value:function(t,e){return this._distanceToBorder(t,e)}}]),e}(d.default);e.default=l},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var i=0;i0&&(this.enableBorderDashes(t), +t.stroke(),this.disableBorderDashes(t)),t.restore(),void 0!==this.options.label){var l=n+.5*this.height+3;this.labelModule.draw(t,o,l,s,"hanging")}this.updateBoundingBox(o,n)}},{key:"updateBoundingBox",value:function(t,e){this.boundingBox.top=e-this.options.size,this.boundingBox.left=t-this.options.size,this.boundingBox.right=t+this.options.size,this.boundingBox.bottom=e+this.options.size,void 0!==this.options.label&&this.labelModule.size.width>0&&(this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelModule.size.height+3))}}]),e}(d.default);e.default=l},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var i=0;i0&&(this.enableBorderDashes(t),t.stroke(),this.disableBorderDashes(t)),t.restore(),this.updateBoundingBox(e,i,t,o),this.labelModule.draw(t,e,i,o)}},{key:"updateBoundingBox",value:function(t,e,i,o){this.resize(i,o),this.left=t-.5*this.width,this.top=e-.5*this.height,this.boundingBox.left=this.left,this.boundingBox.top=this.top,this.boundingBox.bottom=this.top+this.height,this.boundingBox.right=this.left+this.width}},{key:"distanceToBorder",value:function(t,e){this.resize(t);var i=.5*this.width,o=.5*this.height,n=Math.sin(e)*i,s=Math.cos(e)*o;return i*o/Math.sqrt(n*n+s*s)}}]),e}(d.default);e.default=l},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var i=0;i0){var i=5;this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelModule.size.height+i)}}},{key:"_icon",value:function(t,e,i,o){var n=Number(this.options.icon.size);void 0!==this.options.icon.code?(t.font=(o?"bold ":"")+n+"px "+this.options.icon.face,t.fillStyle=this.options.icon.color||"black",t.textAlign="center",t.textBaseline="middle",this.enableShadow(t),t.fillText(this.options.icon.code,e,i),this.disableShadow(t)):console.error("When using the icon shape, you need to define the code in the icon options object. This can be done per node or globally.")}},{key:"distanceToBorder",value:function(t,e){return this._distanceToBorder(t,e)}}]),e}(d.default);e.default=l},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var i=0;i0&&(this.enableBorderDashes(t),t.stroke(),this.disableBorderDashes(t)),t.restore(),t.closePath()}this._drawImageAtPosition(t),this._drawImageLabel(t,e,i,o||n),this.updateBoundingBox(e,i)}},{key:"updateBoundingBox",value:function(t,e){this.resize(),this.left=t-this.width/2,this.top=e-this.height/2,this.boundingBox.top=this.top,this.boundingBox.left=this.left,this.boundingBox.right=this.left+this.width,this.boundingBox.bottom=this.top+this.height,void 0!==this.options.label&&this.labelModule.size.width>0&&(this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelOffset))}},{key:"distanceToBorder",value:function(t,e){return this._distanceToBorder(t,e)}}]),e}(d.default);e.default=l},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var i=0;i1&&void 0!==arguments[1]&&arguments[1],o=this.body.data.edges;if(t instanceof c||t instanceof u)this.body.data.edges=t;else if(Array.isArray(t))this.body.data.edges=new c,this.body.data.edges.add(t);else{if(t)throw new TypeError("Array or DataSet expected");this.body.data.edges=new c}if(o&&l.forEach(this.edgesListeners,function(t,e){o.off(e,t)}),this.body.edges={},this.body.data.edges){l.forEach(this.edgesListeners,function(t,i){e.body.data.edges.on(i,t)});var n=this.body.data.edges.getIds();this.add(n,!0)}i===!1&&this.body.emitter.emit("_dataChanged")}},{key:"add",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=this.body.edges,o=this.body.data.edges,n=0;ni.shape.height?(r=i.x+.5*i.shape.width,a=i.y-h):(r=i.x+h,a=i.y-.5*i.shape.height),s=this._pointOnCircle(r,a,h,.125),this.labelModule.draw(t,s.x,s.y,n)}}}},{key:"isOverlappingWith",value:function(t){if(this.connected){var e=10,i=this.from.x,o=this.from.y,n=this.to.x,s=this.to.y,r=t.left,a=t.top,h=this.edgeType.getDistanceToEdge(i,o,n,s,r,a);return h0&&i<0)&&(o+=Math.PI),t.rotate(o)}},{key:"_pointOnCircle",value:function(t,e,i,o){var n=2*o*Math.PI;return{x:t+i*Math.cos(n),y:e-i*Math.sin(n)}}},{key:"select",value:function(){this.selected=!0}},{key:"unselect",value:function(){this.selected=!1}},{key:"cleanup",value:function(){return this.edgeType.cleanup()}}],[{key:"parseOptions",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=["arrowStrikethrough","id","from","hidden","hoverWidth","label","labelHighlightBold","length","line","opacity","physics","scaling","selectionWidth","selfReferenceSize","to","title","value","width"];if(g.selectiveDeepExtend(n,t,e,i),g.mergeOptions(t,e,"smooth",i,o),g.mergeOptions(t,e,"shadow",i,o),void 0!==e.dashes&&null!==e.dashes?t.dashes=e.dashes:i===!0&&null===e.dashes&&(t.dashes=Object.create(o.dashes)),void 0!==e.scaling&&null!==e.scaling?(void 0!==e.scaling.min&&(t.scaling.min=e.scaling.min),void 0!==e.scaling.max&&(t.scaling.max=e.scaling.max),g.mergeOptions(t.scaling,e.scaling,"label",i,o.scaling)):i===!0&&null===e.scaling&&(t.scaling=Object.create(o.scaling)),void 0!==e.arrows&&null!==e.arrows)if("string"==typeof e.arrows){var r=e.arrows.toLowerCase();t.arrows.to.enabled=r.indexOf("to")!=-1,t.arrows.middle.enabled=r.indexOf("middle")!=-1,t.arrows.from.enabled=r.indexOf("from")!=-1}else{if("object"!==s(e.arrows))throw new Error("The arrow newOptions can only be an object or a string. Refer to the documentation. You used:"+JSON.stringify(e.arrows));g.mergeOptions(t.arrows,e.arrows,"to",i,o.arrows),g.mergeOptions(t.arrows,e.arrows,"middle",i,o.arrows),g.mergeOptions(t.arrows,e.arrows,"from",i,o.arrows)}else i===!0&&null===e.arrows&&(t.arrows=Object.create(o.arrows));if(void 0!==e.color&&null!==e.color)if(t.color=g.deepExtend({},t.color,!0),g.isString(e.color))t.color.color=e.color,t.color.highlight=e.color,t.color.hover=e.color,t.color.inherit=!1;else{var a=!1;void 0!==e.color.color&&(t.color.color=e.color.color,a=!0),void 0!==e.color.highlight&&(t.color.highlight=e.color.highlight,a=!0),void 0!==e.color.hover&&(t.color.hover=e.color.hover,a=!0),void 0!==e.color.inherit&&(t.color.inherit=e.color.inherit),void 0!==e.color.opacity&&(t.color.opacity=Math.min(1,Math.max(0,e.color.opacity))),void 0===e.color.inherit&&a===!0&&(t.color.inherit=!1)}else i===!0&&null===e.color&&(t.color=g.bridgeObject(o.color));void 0!==e.font&&null!==e.font?h.default.parseOptions(t.font,e):i===!0&&null===e.font&&(t.font=g.bridgeObject(o.font))}}]),t}();e.default=y},function(t,e,i){ +function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){var i=[],o=!0,n=!1,s=void 0;try{for(var r,a=t[Symbol.iterator]();!(o=(r=a.next()).done)&&(i.push(r.value),!e||i.length!==e);o=!0);}catch(t){n=!0,s=t}finally{try{!o&&a.return&&a.return()}finally{if(n)throw s}}return i}return function(e,i){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),h=function(){function t(t,e){for(var i=0;iMath.abs(e)||this.options.smooth.forceDirection===!0||"horizontal"===this.options.smooth.forceDirection)&&"vertical"!==this.options.smooth.forceDirection?(o=this.from.y,s=this.to.y,i=this.from.x-r*t,n=this.to.x+r*t):(o=this.from.y-r*e,s=this.to.y+r*e,i=this.from.x,n=this.to.x),[{x:i,y:o},{x:n,y:s}]}},{key:"getViaNode",value:function(){return this._getViaCoordinates()}},{key:"_findBorderPosition",value:function(t,e){return this._findBorderPositionBezier(t,e)}},{key:"_getDistanceToEdge",value:function(t,e,i,o,n,s){var r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:this._getViaCoordinates(),h=a(r,2),d=h[0],l=h[1];return this._getDistanceToBezierEdge(t,e,i,o,n,s,d,l)}},{key:"getPoint",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._getViaCoordinates(),i=a(e,2),o=i[0],n=i[1],s=t,r=[];r[0]=Math.pow(1-s,3),r[1]=3*s*Math.pow(1-s,2),r[2]=3*Math.pow(s,2)*(1-s),r[3]=Math.pow(s,3);var h=r[0]*this.fromPoint.x+r[1]*o.x+r[2]*n.x+r[3]*this.toPoint.x,d=r[0]*this.fromPoint.y+r[1]*o.y+r[2]*n.y+r[3]*this.toPoint.y;return{x:h,y:d}}}]),e}(l.default);e.default=c},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var i=0;i0&&(d=this._getDistanceToLine(f,m,u,p,n,s),h=d2&&void 0!==arguments[2]?arguments[2]:this._getViaCoordinates(),h=10,d=0,l=0,c=1,u=.2,p=this.to,f=!1;for(t.id===this.from.id&&(p=this.from,f=!0);l<=c&&d0&&(h=this._getDistanceToLine(p,f,c,u,n,s),a=ho.shape.height?(e=o.x+.5*o.shape.width,i=o.y-n):(e=o.x+n,i=o.y-.5*o.shape.height),[e,i,n]}},{key:"_pointOnCircle",value:function(t,e,i,o){var n=2*o*Math.PI;return{x:t+i*Math.cos(n),y:e-i*Math.sin(n)}}},{key:"_findBorderPositionCircle",value:function(t,e,i){for(var o=i.x,n=i.y,s=i.low,r=i.high,a=i.direction,h=10,d=0,l=this.options.selfReferenceSize,c=void 0,u=void 0,p=void 0,f=void 0,m=void 0,v=.05,g=.5*(s+r);s<=r&&d0?a>0?s=g:r=g:a>0?r=g:s=g,d++;return c.t=g,c}},{key:"getLineWidth",value:function(t,e){return t===!0?Math.max(this.selectionWidth,.3/this.body.view.scale):e===!0?Math.max(this.hoverWidth,.3/this.body.view.scale):Math.max(this.options.width,.3/this.body.view.scale)}},{key:"getColor",value:function(t,e,i){var o=this.options.color;if(o.inherit!==!1){if("both"===o.inherit&&this.from.id!==this.to.id){var n=t.createLinearGradient(this.from.x,this.from.y,this.to.x,this.to.y),s=void 0,a=void 0;return s=this.from.options.color.highlight.border,a=this.to.options.color.highlight.border,this.from.selected===!1&&this.to.selected===!1?(s=r.overrideOpacity(this.from.options.color.border,this.options.color.opacity),a=r.overrideOpacity(this.to.options.color.border,this.options.color.opacity)):this.from.selected===!0&&this.to.selected===!1?a=this.to.options.color.border:this.from.selected===!1&&this.to.selected===!0&&(s=this.from.options.color.border),n.addColorStop(0,s),n.addColorStop(1,a),n}this.colorDirty===!0&&("to"===o.inherit?(this.color.highlight=this.to.options.color.highlight.border,this.color.hover=this.to.options.color.hover.border,this.color.color=r.overrideOpacity(this.to.options.color.border,o.opacity)):(this.color.highlight=this.from.options.color.highlight.border,this.color.hover=this.from.options.color.hover.border,this.color.color=r.overrideOpacity(this.from.options.color.border,o.opacity)))}else this.colorDirty===!0&&(this.color.highlight=o.highlight,this.color.hover=o.hover,this.color.color=r.overrideOpacity(o.color,o.opacity));return this.colorDirty=!1,e===!0?this.color.highlight:i===!0?this.color.hover:this.color.color}},{key:"_circle",value:function(t,e,i,o){this.enableShadow(t),t.beginPath(),t.arc(e,i,o,0,2*Math.PI,!1),t.stroke(),this.disableShadow(t)}},{key:"getDistanceToEdge",value:function(t,e,i,o,s,r,a){var h=0;if(this.from!=this.to)h=this._getDistanceToEdge(t,e,i,o,s,r,a);else{var d=this._getCircleData(),l=n(d,3),c=l[0],u=l[1],p=l[2],f=c-s,m=u-r;h=Math.abs(Math.sqrt(f*f+m*m)-p)}return this.labelModule.size.lefts&&this.labelModule.size.topr?0:h}},{key:"_getDistanceToLine",value:function(t,e,i,o,n,s){var r=i-t,a=o-e,h=r*r+a*a,d=((n-t)*r+(s-e)*a)/h;d>1?d=1:d<0&&(d=0);var l=t+d*r,c=e+d*a,u=l-n,p=c-s;return Math.sqrt(u*u+p*p)}},{key:"getArrowData",value:function(t,e,i,o,s){var r=void 0,a=void 0,h=void 0,d=void 0,l=void 0,c=void 0,u=void 0,p=this.getLineWidth(o,s);if("from"===e?(h=this.from,d=this.to,l=.1,c=this.options.arrows.from.scaleFactor,u=this.options.arrows.from.type):"to"===e?(h=this.to,d=this.from,l=-.1,c=this.options.arrows.to.scaleFactor,u=this.options.arrows.to.type):(h=this.to,d=this.from,c=this.options.arrows.middle.scaleFactor,u=this.options.arrows.middle.type),h!=d)if("middle"!==e)if(this.options.smooth.enabled===!0){a=this.findBorderPosition(h,t,{via:i});var f=this.getPoint(Math.max(0,Math.min(1,a.t+l)),i);r=Math.atan2(a.y-f.y,a.x-f.x)}else r=Math.atan2(h.y-d.y,h.x-d.x),a=this.findBorderPosition(h,t);else r=Math.atan2(h.y-d.y,h.x-d.x),a=this.getPoint(.5,i);else{var m=this._getCircleData(t),v=n(m,3),g=v[0],y=v[1],b=v[2];"from"===e?(a=this.findBorderPosition(this.from,t,{x:g,y:y,low:.25,high:.6,direction:-1}),r=a.t*-2*Math.PI+1.5*Math.PI+.1*Math.PI):"to"===e?(a=this.findBorderPosition(this.from,t,{x:g,y:y,low:.6,high:1,direction:1}),r=a.t*-2*Math.PI+1.5*Math.PI-1.1*Math.PI):(a=this._pointOnCircle(g,y,b,.175),r=3.9269908169872414)}var _=15*c+3*p,w=a.x-.9*_*Math.cos(r),x=a.y-.9*_*Math.sin(r),k={x:w,y:x};return{point:a,core:k,angle:r,length:_,type:u}}},{key:"drawArrowHead",value:function(t,e,i,o){t.strokeStyle=this.getColor(t,e,i),t.fillStyle=t.strokeStyle,t.lineWidth=this.getLineWidth(e,i),o.type&&"circle"===o.type.toLowerCase()?t.circleEndpoint(o.point.x,o.point.y,o.angle,o.length):t.arrowEndpoint(o.point.x,o.point.y,o.angle,o.length),this.enableShadow(t),t.fill(),this.disableShadow(t)}},{key:"enableShadow",value:function(t){this.options.shadow.enabled===!0&&(t.shadowColor=this.options.shadow.color,t.shadowBlur=this.options.shadow.size,t.shadowOffsetX=this.options.shadow.x,t.shadowOffsetY=this.options.shadow.y)}},{key:"disableShadow",value:function(t){this.options.shadow.enabled===!0&&(t.shadowColor="rgba(0,0,0,0)",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0)}}]),t}();e.default=a},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){var i=[],o=!0,n=!1,s=void 0;try{for(var r,a=t[Symbol.iterator]();!(o=(r=a.next()).done)&&(i.push(r.value),!e||i.length!==e);o=!0);}catch(t){n=!0,s=t}finally{try{!o&&a.return&&a.return()}finally{if(n)throw s}}return i}return function(e,i){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),h=function(){function t(t,e){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:this.via,i=t,o=void 0,n=void 0;if(this.from===this.to){var s=this._getCircleData(this.from),r=a(s,3),h=r[0],d=r[1],l=r[2],c=2*Math.PI*(1-i);o=h+l*Math.sin(c),n=d+l-l*(1-Math.cos(c))}else o=Math.pow(1-i,2)*this.fromPoint.x+2*i*(1-i)*e.x+Math.pow(i,2)*this.toPoint.x,n=Math.pow(1-i,2)*this.fromPoint.y+2*i*(1-i)*e.y+Math.pow(i,2)*this.toPoint.y;return{x:o,y:n}}},{key:"_findBorderPosition",value:function(t,e){return this._findBorderPositionBezier(t,e,this.via)}},{key:"_getDistanceToEdge",value:function(t,e,i,o,n,s){return this._getDistanceToBezierEdge(t,e,i,o,n,s,this.via)}}]),e}(l.default);e.default=c},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var i=0;i=this.to.y?this.from.x<=this.to.x?(t=this.from.x+i*s,e=this.from.y-i*s):this.from.x>this.to.x&&(t=this.from.x-i*s,e=this.from.y-i*s):this.from.ythis.to.x&&(t=this.from.x-i*s,e=this.from.y+i*s)),"discrete"===o&&(t=nMath.abs(this.from.y-this.to.y)&&(this.from.y>=this.to.y?this.from.x<=this.to.x?(t=this.from.x+i*n,e=this.from.y-i*n):this.from.x>this.to.x&&(t=this.from.x-i*n,e=this.from.y-i*n):this.from.ythis.to.x&&(t=this.from.x-i*n,e=this.from.y+i*n)),"discrete"===o&&(e=sMath.abs(this.from.y-this.to.y)&&(t=this.from.x=this.to.y?this.from.x<=this.to.x?(t=this.from.x+i*s,e=this.from.y-i*s,t=this.to.xthis.to.x&&(t=this.from.x-i*s,e=this.from.y-i*s,t=this.to.x>t?this.to.x:t):this.from.ythis.to.x&&(t=this.from.x-i*s,e=this.from.y+i*s,t=this.to.x>t?this.to.x:t)):Math.abs(this.from.x-this.to.x)>Math.abs(this.from.y-this.to.y)&&(this.from.y>=this.to.y?this.from.x<=this.to.x?(t=this.from.x+i*n,e=this.from.y-i*n,e=this.to.y>e?this.to.y:e):this.from.x>this.to.x&&(t=this.from.x-i*n,e=this.from.y-i*n,e=this.to.y>e?this.to.y:e):this.from.ythis.to.x&&(t=this.from.x-i*n,e=this.from.y+i*n,e=this.to.y2&&void 0!==arguments[2]?arguments[2]:{};return this._findBorderPositionBezier(t,e,i.via)}},{key:"_getDistanceToEdge",value:function(t,e,i,o,n,s){var r=arguments.length>6&&void 0!==arguments[6]?arguments[6]:this._getViaCoordinates();return this._getDistanceToBezierEdge(t,e,i,o,n,s,r)}},{key:"getPoint",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._getViaCoordinates(),i=t,o=Math.pow(1-i,2)*this.fromPoint.x+2*i*(1-i)*e.x+Math.pow(i,2)*this.toPoint.x,n=Math.pow(1-i,2)*this.fromPoint.y+2*i*(1-i)*e.y+Math.pow(i,2)*this.toPoint.y;return{x:o,y:n}}}]),e}(d.default);e.default=l},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var i=0;i0&&void 0!==arguments[0])||arguments[0];this.stabilized=!0,t===!0&&this._emitStabilized(),void 0!==this.viewFunction&&(this.body.emitter.off("initRedraw",this.viewFunction),this.viewFunction=void 0,t===!0&&this.body.emitter.emit("_stopRendering"))}},{key:"simulationStep",value:function(){var t=Date.now();this.physicsTick();var e=Date.now()-t;(e<.4*this.simulationInterval||this.runDoubleSpeed===!0)&&this.stabilized===!1&&(this.physicsTick(),this.runDoubleSpeed=!0),this.stabilized===!0&&this.stopSimulation()}},{key:"_emitStabilized",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.stabilizationIterations;(this.stabilizationIterations>1||this.startedStabilization===!0)&&setTimeout(function(){t.body.emitter.emit("stabilized",{iterations:e}),t.startedStabilization=!1,t.stabilizationIterations=0},0)}},{key:"physicsTick",value:function(){if(this.startedStabilization===!1&&(this.body.emitter.emit("startStabilizing"),this.startedStabilization=!0),this.stabilized===!1){if(this.adaptiveTimestep===!0&&this.adaptiveTimestepEnabled===!0){var t=1.2;this.adaptiveCounter%this.adaptiveInterval===0?(this.timestep=2*this.timestep,this.calculateForces(),this.moveNodes(),this.revert(),this.timestep=.5*this.timestep,this.calculateForces(),this.moveNodes(),this.calculateForces(),this.moveNodes(),this._evaluateStepQuality()===!0?this.timestep=t*this.timestep:this.timestep/ts))return!1;return!0}},{key:"moveNodes",value:function(){for(var t=this.physicsBody.physicsNodeIndices,e=this.options.maxVelocity?this.options.maxVelocity:1e9,i=0,o=0,n=5,s=0;se?s[t].x>0?e:-e:s[t].x,i.x+=s[t].x*o}else n[t].x=0,s[t].x=0;if(i.options.fixed.y===!1){var h=this.modelOptions.damping*s[t].y,d=(n[t].y-h)/i.options.mass;s[t].y+=d*o,s[t].y=Math.abs(s[t].y)>e?s[t].y>0?e:-e:s[t].y,i.y+=s[t].y*o}else n[t].y=0,s[t].y=0;var l=Math.sqrt(Math.pow(s[t].x,2)+Math.pow(s[t].y,2));return l}},{key:"calculateForces",value:function(){this.gravitySolver.solve(),this.nodesSolver.solve(),this.edgesSolver.solve()}},{key:"_freezeNodes",value:function(){var t=this.body.nodes;for(var e in t)t.hasOwnProperty(e)&&t[e].x&&t[e].y&&(this.freezeCache[e]={x:t[e].options.fixed.x,y:t[e].options.fixed.y},t[e].options.fixed.x=!0,t[e].options.fixed.y=!0)}},{key:"_restoreFrozenNodes",value:function(){var t=this.body.nodes;for(var e in t)t.hasOwnProperty(e)&&void 0!==this.freezeCache[e]&&(t[e].options.fixed.x=this.freezeCache[e].x,t[e].options.fixed.y=this.freezeCache[e].y);this.freezeCache={}}},{key:"stabilize",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.stabilization.iterations;return"number"!=typeof e&&(console.log("The stabilize method needs a numeric amount of iterations. Switching to default: ",this.options.stabilization.iterations),e=this.options.stabilization.iterations),0===this.physicsBody.physicsNodeIndices.length?void(this.ready=!0):(this.adaptiveTimestep=this.options.adaptiveTimestep,this.body.emitter.emit("_resizeNodes"),this.stopSimulation(),this.stabilized=!1,this.body.emitter.emit("_blockRedraw"),this.targetIterations=e,this.options.stabilization.onlyDynamicEdges===!0&&this._freezeNodes(),this.stabilizationIterations=0,void setTimeout(function(){return t._stabilizationBatch()},0))}},{key:"_stabilizationBatch",value:function(){this.startedStabilization===!1&&(this.body.emitter.emit("startStabilizing"),this.startedStabilization=!0);for(var t=0;this.stabilized===!1&&t0){var t=void 0,e=this.body.nodes,i=this.physicsBody.physicsNodeIndices,o=i.length,n=this._formBarnesHutTree(e,i);this.barnesHutTree=n;for(var s=0;s0&&(this._getForceContribution(n.root.children.NW,t),this._getForceContribution(n.root.children.NE,t),this._getForceContribution(n.root.children.SW,t),this._getForceContribution(n.root.children.SE,t))}}},{key:"_getForceContribution",value:function(t,e){if(t.childrenCount>0){var i=void 0,o=void 0,n=void 0;i=t.centerOfMass.x-e.x,o=t.centerOfMass.y-e.y,n=Math.sqrt(i*i+o*o),n*t.calcSize>this.thetaInversed?this._calculateForces(n,i,o,e,t):4===t.childrenCount?(this._getForceContribution(t.children.NW,e),this._getForceContribution(t.children.NE,e),this._getForceContribution(t.children.SW,e),this._getForceContribution(t.children.SE,e)):t.children.data.id!=e.id&&this._calculateForces(n,i,o,e,t)}}},{key:"_calculateForces",value:function(t,e,i,o,n){0===t&&(t=.1,e=t),this.overlapAvoidanceFactor<1&&o.shape.radius&&(t=Math.max(.1+this.overlapAvoidanceFactor*o.shape.radius,t-o.shape.radius));var s=this.options.gravitationalConstant*n.mass*o.options.mass/Math.pow(t,3),r=e*s,a=i*s;this.physicsBody.forces[o.id].x+=r,this.physicsBody.forces[o.id].y+=a}},{key:"_formBarnesHutTree",value:function(t,e){for(var i=void 0,o=e.length,n=t[e[0]].x,s=t[e[0]].y,r=t[e[0]].x,a=t[e[0]].y,h=1;h0&&(dr&&(r=d),la&&(a=l))}var c=Math.abs(r-n)-Math.abs(a-s);c>0?(s-=.5*c,a+=.5*c):(n+=.5*c,r-=.5*c);var u=1e-5,p=Math.max(u,Math.abs(r-n)),f=.5*p,m=.5*(n+r),v=.5*(s+a),g={root:{centerOfMass:{x:0,y:0},mass:0,range:{minX:m-f,maxX:m+f,minY:v-f,maxY:v+f},size:p,calcSize:1/p,children:{data:null},maxWidth:0,level:0,childrenCount:4}};this._splitBranch(g.root);for(var y=0;y0&&this._placeInTree(g.root,i);return g}},{key:"_updateBranchMass",value:function(t,e){var i=t.mass+e.options.mass,o=1/i;t.centerOfMass.x=t.centerOfMass.x*t.mass+e.x*e.options.mass,t.centerOfMass.x*=o,t.centerOfMass.y=t.centerOfMass.y*t.mass+e.y*e.options.mass,t.centerOfMass.y*=o,t.mass=i;var n=Math.max(Math.max(e.height,e.radius),e.width);t.maxWidth=t.maxWidthe.x?t.children.NW.range.maxY>e.y?this._placeInRegion(t,e,"NW"):this._placeInRegion(t,e,"SW"):t.children.NW.range.maxY>e.y?this._placeInRegion(t,e,"NE"):this._placeInRegion(t,e,"SE")}},{key:"_placeInRegion",value:function(t,e,i){switch(t.children[i].childrenCount){case 0:t.children[i].children.data=e,t.children[i].childrenCount=1,this._updateBranchMass(t.children[i],e);break;case 1:t.children[i].children.data.x===e.x&&t.children[i].children.data.y===e.y?(e.x+=this.seededRandom(),e.y+=this.seededRandom()):(this._splitBranch(t.children[i]),this._placeInTree(t.children[i],e));break;case 4:this._placeInTree(t.children[i],e)}}},{key:"_splitBranch",value:function(t){var e=null;1===t.childrenCount&&(e=t.children.data,t.mass=0,t.centerOfMass.x=0,t.centerOfMass.y=0),t.childrenCount=4,t.children.data=null,this._insertRegion(t,"NW"),this._insertRegion(t,"NE"),this._insertRegion(t,"SW"),this._insertRegion(t,"SE"),null!=e&&this._placeInTree(t,e)}},{key:"_insertRegion",value:function(t,e){var i=void 0,o=void 0,n=void 0,s=void 0,r=.5*t.size;switch(e){case"NW":i=t.range.minX,o=t.range.minX+r,n=t.range.minY,s=t.range.minY+r;break;case"NE":i=t.range.minX+r,o=t.range.maxX,n=t.range.minY,s=t.range.minY+r;break;case"SW":i=t.range.minX,o=t.range.minX+r,n=t.range.minY+r,s=t.range.maxY;break;case"SE":i=t.range.minX+r,o=t.range.maxX,n=t.range.minY+r,s=t.range.maxY}t.children[e]={centerOfMass:{x:0,y:0},mass:0,range:{minX:i,maxX:o,minY:n,maxY:s},size:.5*t.size,calcSize:2*t.calcSize,children:{data:null},maxWidth:0,level:t.level+1,childrenCount:0}}},{key:"_debug",value:function(t,e){void 0!==this.barnesHutTree&&(t.lineWidth=1,this._drawBranch(this.barnesHutTree.root,t,e))}},{key:"_drawBranch",value:function(t,e,i){void 0===i&&(i="#FF0000"),4===t.childrenCount&&(this._drawBranch(t.children.NW,e),this._drawBranch(t.children.NE,e),this._drawBranch(t.children.SE,e),this._drawBranch(t.children.SW,e)),e.strokeStyle=i,e.beginPath(),e.moveTo(t.range.minX,t.range.minY),e.lineTo(t.range.maxX,t.range.minY),e.stroke(),e.beginPath(),e.moveTo(t.range.maxX,t.range.minY),e.lineTo(t.range.maxX,t.range.maxY),e.stroke(),e.beginPath(),e.moveTo(t.range.maxX,t.range.maxY),e.lineTo(t.range.minX,t.range.maxY),e.stroke(),e.beginPath(),e.moveTo(t.range.minX,t.range.maxY),e.lineTo(t.range.minX,t.range.minY),e.stroke()}}]),t}();e.default=n},function(t,e){function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var i=0;i0){var s=n.edges.length+1,r=this.options.centralGravity*s*n.options.mass;o[n.id].x=e*r,o[n.id].y=i*r}}}]),e}(d.default);e.default=l},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r=function(){function t(t,e){for(var i=0;i=t&&i.push(n.id)}for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{},e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(void 0===t.joinCondition)throw new Error("Cannot call clusterByNodeData without a joinCondition function in the options.");t=this._checkOptions(t);for(var i={},o={},n=0;n2&&void 0!==arguments[2])||arguments[2];e=this._checkOptions(e);for(var o=[],n={},s=void 0,r=void 0,a=void 0,d=void 0,l=void 0,c=0;c0&&Object.keys(p).length>0&&m===!0&&o.push({nodes:u,edges:p})}}}for(var b=0;b1&&void 0!==arguments[1])||arguments[1];this.clusterByEdgeCount(1,t,e)}},{key:"clusterBridges",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.clusterByEdgeCount(2,t,e)}},{key:"clusterByConnection",value:function(t,e){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(void 0===t)throw new Error("No nodeId supplied to clusterByConnection!");if(void 0===this.body.nodes[t])throw new Error("The nodeId given to clusterByConnection does not exist!");var o=this.body.nodes[t];e=this._checkOptions(e,o),void 0===e.clusterNodeProperties.x&&(e.clusterNodeProperties.x=o.x),void 0===e.clusterNodeProperties.y&&(e.clusterNodeProperties.y=o.y),void 0===e.clusterNodeProperties.fixed&&(e.clusterNodeProperties.fixed={},e.clusterNodeProperties.fixed.x=o.options.fixed.x,e.clusterNodeProperties.fixed.y=o.options.fixed.y);var n={},s={},r=o.id,a=h.default.cloneOptions(o);n[r]=o;for(var d=0;d-1&&(s[v.id]=v)}this._cluster(n,s,e,i)}},{key:"_createClusterEdges",value:function(t,e,i,o){for(var n=void 0,s=void 0,r=void 0,a=void 0,d=void 0,l=void 0,u=Object.keys(t),p=[],f=0;f0&&void 0!==arguments[0]?arguments[0]:{};return void 0===t.clusterEdgeProperties&&(t.clusterEdgeProperties={}),void 0===t.clusterNodeProperties&&(t.clusterNodeProperties={}),t}},{key:"_cluster",value:function(t,e,i){var o=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(0!=Object.keys(t).length&&(1!=Object.keys(t).length||1==i.clusterNodeProperties.allowSingleNodeCluster)){for(var n in t)if(t.hasOwnProperty(n)&&void 0!==this.clusteredNodes[n])return;var s=c.deepExtend({},i.clusterNodeProperties);if(void 0!==i.processProperties){var r=[];for(var a in t)if(t.hasOwnProperty(a)){var d=h.default.cloneOptions(t[a]);r.push(d)}var u=[];for(var p in e)if(e.hasOwnProperty(p)&&"clusterEdge:"!==p.substr(0,12)){var f=h.default.cloneOptions(e[p],"edge");u.push(f)}if(s=i.processProperties(s,r,u),!s)throw new Error("The processProperties function does not return properties!")}void 0===s.id&&(s.id="cluster:"+c.randomUUID());var m=s.id;void 0===s.label&&(s.label="cluster");var v=void 0;void 0===s.x&&(v=this._getClusterPosition(t),s.x=v.x),void 0===s.y&&(void 0===v&&(v=this._getClusterPosition(t)),s.y=v.y),s.id=m;var g=this.body.functions.createNode(s,l.default);g.isCluster=!0,g.containedNodes=t,g.containedEdges=e,g.clusterEdgeProperties=i.clusterEdgeProperties,this.body.nodes[s.id]=g,this._createClusterEdges(t,e,s,i.clusterEdgeProperties);for(var y in e)if(e.hasOwnProperty(y)&&void 0!==this.body.edges[y]){var b=this.body.edges[y];this._backupEdgeOptions(b),b.setOptions({physics:!1,hidden:!0})}for(var _ in t)t.hasOwnProperty(_)&&(this.clusteredNodes[_]={clusterId:s.id,node:this.body.nodes[_]},this.body.nodes[_].setOptions({hidden:!0,physics:!1}));s.id=void 0,o===!0&&this.body.emitter.emit("_dataChanged")}}},{key:"_backupEdgeOptions",value:function(t){void 0===this.clusteredEdges[t.id]&&(this.clusteredEdges[t.id]={physics:t.options.physics,hidden:t.options.hidden})}},{key:"_restoreEdge",value:function(t){var e=this.clusteredEdges[t.id];void 0!==e&&(t.setOptions({physics:e.physics,hidden:e.hidden}),delete this.clusteredEdges[t.id])}},{key:"isCluster",value:function(t){return void 0!==this.body.nodes[t]?this.body.nodes[t].isCluster===!0:(console.log("Node does not exist."),!1)}},{key:"_getClusterPosition",value:function(t){for(var e=Object.keys(t),i=t[e[0]].x,o=t[e[0]].x,n=t[e[0]].y,s=t[e[0]].y,r=void 0,a=1;ao?r.x:o,n=r.ys?r.y:s;return{x:.5*(i+o),y:.5*(n+s)}}},{key:"openCluster",value:function(t,e){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(void 0===t)throw new Error("No clusterNodeId supplied to openCluster.");if(void 0===this.body.nodes[t])throw new Error("The clusterNodeId supplied to openCluster does not exist.");if(void 0===this.body.nodes[t].containedNodes)return void console.log("The node:"+t+" is not a cluster.");var o=this.body.nodes[t],n=o.containedNodes,s=o.containedEdges;if(void 0!==e&&void 0!==e.releaseFunction&&"function"==typeof e.releaseFunction){var r={},a={x:o.x,y:o.y};for(var d in n)if(n.hasOwnProperty(d)){var l=this.body.nodes[d];r[d]={x:l.x,y:l.y}}var u=e.releaseFunction(a,r);for(var p in n)if(n.hasOwnProperty(p)){var f=this.body.nodes[p];void 0!==u[p]&&(f.x=void 0===u[p].x?o.x:u[p].x,f.y=void 0===u[p].y?o.y:u[p].y)}}else for(var m in n)if(n.hasOwnProperty(m)){var v=this.body.nodes[m];v=n[m],v.options.fixed.x===!1&&(v.x=o.x),v.options.fixed.y===!1&&(v.y=o.y)}for(var g in n)if(n.hasOwnProperty(g)){var y=this.body.nodes[g];y.vx=o.vx,y.vy=o.vy,y.setOptions({hidden:!1,physics:!0}),delete this.clusteredNodes[g]}for(var b=[],_=0;_o&&(o=s.edges.length),t+=s.edges.length, +e+=Math.pow(s.edges.length,2),i+=1}t/=i,e/=i;var r=e-Math.pow(t,2),a=Math.sqrt(r),h=Math.floor(t+2*a);return h>o&&(h=o),h}}]),t}();e.default=u},function(t,e,i){function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:[],o=1e9,n=-1e9,s=1e9,r=-1e9;if(i.length>0)for(var a=0;ae.shape.boundingBox.left&&(s=e.shape.boundingBox.left),re.shape.boundingBox.top&&(o=e.shape.boundingBox.top),n1&&void 0!==arguments[1]?arguments[1]:[],o=1e9,n=-1e9,s=1e9,r=-1e9;if(i.length>0)for(var a=0;ae.x&&(s=e.x),re.y&&(o=e.y),n0,t.renderTimer=void 0}),this.body.emitter.on("destroy",function(){t.renderRequests=0,t.allowRedraw=!1,t.renderingActive=!1,t.requiresTimeout===!0?clearTimeout(t.renderTimer):cancelAnimationFrame(t.renderTimer),t.body.emitter.off()})}},{key:"setOptions",value:function(t){if(void 0!==t){var e=["hideEdgesOnDrag","hideNodesOnDrag"];s.selectiveDeepExtend(e,this.options,t)}}},{key:"_startRendering",value:function(){this.renderingActive===!0&&void 0===this.renderTimer&&(this.requiresTimeout===!0?this.renderTimer=window.setTimeout(this._renderStep.bind(this),this.simulationInterval):this.renderTimer=window.requestAnimationFrame(this._renderStep.bind(this)))}},{key:"_renderStep",value:function(){this.renderingActive===!0&&(this.renderTimer=void 0,this.requiresTimeout===!0&&this._startRendering(),this._redraw(),this.requiresTimeout===!1&&this._startRendering())}},{key:"redraw",value:function(){this.body.emitter.emit("setSize"),this._redraw()}},{key:"_requestRedraw",value:function(){var t=this;this.redrawRequested!==!0&&this.renderingActive===!1&&this.allowRedraw===!0&&(this.redrawRequested=!0,this.requiresTimeout===!0?window.setTimeout(function(){t._redraw(!1)},0):window.requestAnimationFrame(function(){t._redraw(!1)}))}},{key:"_redraw",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.allowRedraw===!0){this.body.emitter.emit("initRedraw"),this.redrawRequested=!1;var e=this.canvas.frame.canvas.getContext("2d");0!==this.canvas.frame.canvas.width&&0!==this.canvas.frame.canvas.height||this.canvas.setSize(),this.pixelRatio=(window.devicePixelRatio||1)/(e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1),e.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0);var i=this.canvas.frame.canvas.clientWidth,o=this.canvas.frame.canvas.clientHeight;if(e.clearRect(0,0,i,o),0===this.canvas.frame.clientWidth)return;e.save(),e.translate(this.body.view.translation.x,this.body.view.translation.y),e.scale(this.body.view.scale,this.body.view.scale),e.beginPath(),this.body.emitter.emit("beforeDrawing",e),e.closePath(),t===!1&&(this.dragging===!1||this.dragging===!0&&this.options.hideEdgesOnDrag===!1)&&this._drawEdges(e),(this.dragging===!1||this.dragging===!0&&this.options.hideNodesOnDrag===!1)&&this._drawNodes(e,t),e.beginPath(),this.body.emitter.emit("afterDrawing",e),e.closePath(),e.restore(),t===!0&&e.clearRect(0,0,i,o)}}},{key:"_resizeNodes",value:function(){var t=this.canvas.frame.canvas.getContext("2d");void 0===this.pixelRatio&&(this.pixelRatio=(window.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)),t.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0),t.save(),t.translate(this.body.view.translation.x,this.body.view.translation.y),t.scale(this.body.view.scale,this.body.view.scale);var e=this.body.nodes,i=void 0;for(var o in e)e.hasOwnProperty(o)&&(i=e[o],i.resize(t),i.updateBoundingBox(t,i.selected));t.restore()}},{key:"_drawNodes",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=this.body.nodes,o=this.body.nodeIndices,n=void 0,s=[],r=20,a=this.canvas.DOMtoCanvas({x:-r,y:-r}),h=this.canvas.DOMtoCanvas({x:this.canvas.frame.canvas.clientWidth+r,y:this.canvas.frame.canvas.clientHeight+r}),d={top:a.y,left:a.x,bottom:h.y,right:h.x},l=0;l0&&void 0!==arguments[0]?arguments[0]:this.pixelRatio;this.initialized===!0&&(this.cameraState.previousWidth=this.frame.canvas.width/t,this.cameraState.previousHeight=this.frame.canvas.height/t,this.cameraState.scale=this.body.view.scale,this.cameraState.position=this.DOMtoCanvas({x:.5*this.frame.canvas.width/t,y:.5*this.frame.canvas.height/t}))}},{key:"_setCameraState",value:function(){if(void 0!==this.cameraState.scale&&0!==this.frame.canvas.clientWidth&&0!==this.frame.canvas.clientHeight&&0!==this.pixelRatio&&this.cameraState.previousWidth>0){var t=this.frame.canvas.width/this.pixelRatio/this.cameraState.previousWidth,e=this.frame.canvas.height/this.pixelRatio/this.cameraState.previousHeight,i=this.cameraState.scale;1!=t&&1!=e?i=.5*this.cameraState.scale*(t+e):1!=t?i=this.cameraState.scale*t:1!=e&&(i=this.cameraState.scale*e),this.body.view.scale=i;var o=this.DOMtoCanvas({x:.5*this.frame.canvas.clientWidth,y:.5*this.frame.canvas.clientHeight}),n={x:o.x-this.cameraState.position.x,y:o.y-this.cameraState.position.y};this.body.view.translation.x+=n.x*this.body.view.scale,this.body.view.translation.y+=n.y*this.body.view.scale}}},{key:"_prepareValue",value:function(t){if("number"==typeof t)return t+"px";if("string"==typeof t){if(t.indexOf("%")!==-1||t.indexOf("px")!==-1)return t;if(t.indexOf("%")===-1)return t+"px"}throw new Error("Could not use the value supplied for width or height:"+t)}},{key:"_create",value:function(){for(;this.body.container.hasChildNodes();)this.body.container.removeChild(this.body.container.firstChild);if(this.frame=document.createElement("div"),this.frame.className="vis-network",this.frame.style.position="relative",this.frame.style.overflow="hidden",this.frame.tabIndex=900,this.frame.canvas=document.createElement("canvas"),this.frame.canvas.style.position="relative",this.frame.appendChild(this.frame.canvas),this.frame.canvas.getContext){var t=this.frame.canvas.getContext("2d");this.pixelRatio=(window.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1),this.frame.canvas.getContext("2d").setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0)}else{var e=document.createElement("DIV");e.style.color="red",e.style.fontWeight="bold",e.style.padding="10px",e.innerHTML="Error: your browser does not support HTML canvas",this.frame.canvas.appendChild(e)}this.body.container.appendChild(this.frame),this.body.view.scale=1,this.body.view.translation={x:.5*this.frame.canvas.clientWidth,y:.5*this.frame.canvas.clientHeight},this._bindHammer()}},{key:"_bindHammer",value:function(){var t=this;void 0!==this.hammer&&this.hammer.destroy(),this.drag={},this.pinch={},this.hammer=new s(this.frame.canvas),this.hammer.get("pinch").set({enable:!0}),this.hammer.get("pan").set({threshold:5,direction:s.DIRECTION_ALL}),r.onTouch(this.hammer,function(e){t.body.eventListeners.onTouch(e)}),this.hammer.on("tap",function(e){t.body.eventListeners.onTap(e)}),this.hammer.on("doubletap",function(e){t.body.eventListeners.onDoubleTap(e)}),this.hammer.on("press",function(e){t.body.eventListeners.onHold(e)}),this.hammer.on("panstart",function(e){t.body.eventListeners.onDragStart(e)}),this.hammer.on("panmove",function(e){t.body.eventListeners.onDrag(e)}),this.hammer.on("panend",function(e){t.body.eventListeners.onDragEnd(e)}),this.hammer.on("pinch",function(e){t.body.eventListeners.onPinch(e)}),this.frame.canvas.addEventListener("mousewheel",function(e){t.body.eventListeners.onMouseWheel(e)}),this.frame.canvas.addEventListener("DOMMouseScroll",function(e){t.body.eventListeners.onMouseWheel(e)}),this.frame.canvas.addEventListener("mousemove",function(e){t.body.eventListeners.onMouseMove(e)}),this.frame.canvas.addEventListener("contextmenu",function(e){t.body.eventListeners.onContext(e)}),this.hammerFrame=new s(this.frame),r.onRelease(this.hammerFrame,function(e){t.body.eventListeners.onRelease(e)})}},{key:"setSize",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.width,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.options.height;t=this._prepareValue(t),e=this._prepareValue(e);var i=!1,o=this.frame.canvas.width,n=this.frame.canvas.height,s=this.frame.canvas.getContext("2d"),r=this.pixelRatio;return this.pixelRatio=(window.devicePixelRatio||1)/(s.webkitBackingStorePixelRatio||s.mozBackingStorePixelRatio||s.msBackingStorePixelRatio||s.oBackingStorePixelRatio||s.backingStorePixelRatio||1),t!=this.options.width||e!=this.options.height||this.frame.style.width!=t||this.frame.style.height!=e?(this._getCameraState(r),this.frame.style.width=t,this.frame.style.height=e,this.frame.canvas.style.width="100%",this.frame.canvas.style.height="100%",this.frame.canvas.width=Math.round(this.frame.canvas.clientWidth*this.pixelRatio),this.frame.canvas.height=Math.round(this.frame.canvas.clientHeight*this.pixelRatio),this.options.width=t,this.options.height=e,this.canvasViewCenter={x:.5*this.frame.clientWidth,y:.5*this.frame.clientHeight},i=!0):(this.frame.canvas.width==Math.round(this.frame.canvas.clientWidth*this.pixelRatio)&&this.frame.canvas.height==Math.round(this.frame.canvas.clientHeight*this.pixelRatio)||this._getCameraState(r),this.frame.canvas.width!=Math.round(this.frame.canvas.clientWidth*this.pixelRatio)&&(this.frame.canvas.width=Math.round(this.frame.canvas.clientWidth*this.pixelRatio),i=!0),this.frame.canvas.height!=Math.round(this.frame.canvas.clientHeight*this.pixelRatio)&&(this.frame.canvas.height=Math.round(this.frame.canvas.clientHeight*this.pixelRatio),i=!0)),i===!0&&(this.body.emitter.emit("resize",{width:Math.round(this.frame.canvas.width/this.pixelRatio),height:Math.round(this.frame.canvas.height/this.pixelRatio),oldWidth:Math.round(o/this.pixelRatio),oldHeight:Math.round(n/this.pixelRatio)}),this._setCameraState()),this.initialized=!0,i}},{key:"_XconvertDOMtoCanvas",value:function(t){return(t-this.body.view.translation.x)/this.body.view.scale}},{key:"_XconvertCanvasToDOM",value:function(t){return t*this.body.view.scale+this.body.view.translation.x}},{key:"_YconvertDOMtoCanvas",value:function(t){return(t-this.body.view.translation.y)/this.body.view.scale}},{key:"_YconvertCanvasToDOM",value:function(t){return t*this.body.view.scale+this.body.view.translation.y}},{key:"canvasToDOM",value:function(t){return{x:this._XconvertCanvasToDOM(t.x),y:this._YconvertCanvasToDOM(t.y)}}},{key:"DOMtoCanvas",value:function(t){return{x:this._XconvertDOMtoCanvas(t.x),y:this._YconvertDOMtoCanvas(t.y)}}}]),t}();e.default=h},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:{};this.options=t}},{key:"fit",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{nodes:[]},e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=void 0,o=void 0;if(void 0!==t.nodes&&0!==t.nodes.length||(t.nodes=this.body.nodeIndices),e===!0){var n=0;for(var s in this.body.nodes)if(this.body.nodes.hasOwnProperty(s)){var r=this.body.nodes[s];r.predefinedPosition===!0&&(n+=1)}if(n>.5*this.body.nodeIndices.length)return void this.fit(t,!1);i=a.default.getRange(this.body.nodes,t.nodes);var h=this.body.nodeIndices.length;o=12.662/(h+7.4147)+.0964822;var d=Math.min(this.canvas.frame.canvas.clientWidth/600,this.canvas.frame.canvas.clientHeight/600);o*=d}else{this.body.emitter.emit("_resizeNodes"),i=a.default.getRange(this.body.nodes,t.nodes);var l=1.1*Math.abs(i.maxX-i.minX),c=1.1*Math.abs(i.maxY-i.minY),u=this.canvas.frame.canvas.clientWidth/l,p=this.canvas.frame.canvas.clientHeight/c;o=u<=p?u:p}o>1?o=1:0===o&&(o=1);var f=a.default.findCenter(i),m={position:f,scale:o,animation:t.animation};this.moveTo(m)}},{key:"focus",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(void 0!==this.body.nodes[t]){var i={x:this.body.nodes[t].x,y:this.body.nodes[t].y};e.position=i,e.lockedOnNode=t,this.moveTo(e)}else console.log("Node: "+t+" cannot be found.")}},{key:"moveTo",value:function(t){return void 0===t?void(t={}):(void 0===t.offset&&(t.offset={x:0,y:0}),void 0===t.offset.x&&(t.offset.x=0),void 0===t.offset.y&&(t.offset.y=0),void 0===t.scale&&(t.scale=this.body.view.scale),void 0===t.position&&(t.position=this.getViewPosition()),void 0===t.animation&&(t.animation={duration:0}),t.animation===!1&&(t.animation={duration:0}),t.animation===!0&&(t.animation={}),void 0===t.animation.duration&&(t.animation.duration=1e3),void 0===t.animation.easingFunction&&(t.animation.easingFunction="easeInOutQuad"),void this.animateView(t))}},{key:"animateView",value:function(t){if(void 0!==t){this.animationEasingFunction=t.animation.easingFunction,this.releaseNode(),t.locked===!0&&(this.lockedOnNodeId=t.lockedOnNode,this.lockedOnNodeOffset=t.offset),0!=this.easingTime&&this._transitionRedraw(!0),this.sourceScale=this.body.view.scale,this.sourceTranslation=this.body.view.translation,this.targetScale=t.scale,this.body.view.scale=this.targetScale;var e=this.canvas.DOMtoCanvas({x:.5*this.canvas.frame.canvas.clientWidth,y:.5*this.canvas.frame.canvas.clientHeight}),i={x:e.x-t.position.x,y:e.y-t.position.y};this.targetTranslation={x:this.sourceTranslation.x+i.x*this.targetScale+t.offset.x,y:this.sourceTranslation.y+i.y*this.targetScale+t.offset.y},0===t.animation.duration?void 0!=this.lockedOnNodeId?(this.viewFunction=this._lockedRedraw.bind(this),this.body.emitter.on("initRedraw",this.viewFunction)):(this.body.view.scale=this.targetScale,this.body.view.translation=this.targetTranslation,this.body.emitter.emit("_requestRedraw")):(this.animationSpeed=1/(60*t.animation.duration*.001)||1/60,this.animationEasingFunction=t.animation.easingFunction,this.viewFunction=this._transitionRedraw.bind(this),this.body.emitter.on("initRedraw",this.viewFunction),this.body.emitter.emit("_startRendering"))}}},{key:"_lockedRedraw",value:function(){var t={x:this.body.nodes[this.lockedOnNodeId].x,y:this.body.nodes[this.lockedOnNodeId].y},e=this.canvas.DOMtoCanvas({x:.5*this.canvas.frame.canvas.clientWidth,y:.5*this.canvas.frame.canvas.clientHeight}),i={x:e.x-t.x,y:e.y-t.y},o=this.body.view.translation,n={x:o.x+i.x*this.body.view.scale+this.lockedOnNodeOffset.x,y:o.y+i.y*this.body.view.scale+this.lockedOnNodeOffset.y};this.body.view.translation=n}},{key:"releaseNode",value:function(){void 0!==this.lockedOnNodeId&&void 0!==this.viewFunction&&(this.body.emitter.off("initRedraw",this.viewFunction),this.lockedOnNodeId=void 0,this.lockedOnNodeOffset=void 0)}},{key:"_transitionRedraw",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.easingTime+=this.animationSpeed,this.easingTime=t===!0?1:this.easingTime;var e=h.easingFunctions[this.animationEasingFunction](this.easingTime);this.body.view.scale=this.sourceScale+(this.targetScale-this.sourceScale)*e,this.body.view.translation={x:this.sourceTranslation.x+(this.targetTranslation.x-this.sourceTranslation.x)*e,y:this.sourceTranslation.y+(this.targetTranslation.y-this.sourceTranslation.y)*e},this.easingTime>=1&&(this.body.emitter.off("initRedraw",this.viewFunction),this.easingTime=0,void 0!=this.lockedOnNodeId&&(this.viewFunction=this._lockedRedraw.bind(this),this.body.emitter.on("initRedraw",this.viewFunction)),this.body.emitter.emit("animationFinished"))}},{key:"getScale",value:function(){return this.body.view.scale}},{key:"getViewPosition",value:function(){return this.canvas.DOMtoCanvas({x:.5*this.canvas.frame.canvas.clientWidth,y:.5*this.canvas.frame.canvas.clientHeight})}}]),t}();e.default=d},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){for(var i=0;i50&&(this.drag.pointer=this.getPointer(t.center),this.drag.pinched=!1,this.pinch.scale=this.body.view.scale,this.touchTime=(new Date).valueOf())}},{key:"onTap",value:function(t){var e=this.getPointer(t.center),i=this.selectionHandler.options.multiselect&&(t.changedPointers[0].ctrlKey||t.changedPointers[0].metaKey);this.checkSelectionChanges(e,t,i),this.selectionHandler._generateClickEvent("click",t,e)}},{key:"onDoubleTap",value:function(t){var e=this.getPointer(t.center);this.selectionHandler._generateClickEvent("doubleClick",t,e)}},{key:"onHold",value:function(t){var e=this.getPointer(t.center),i=this.selectionHandler.options.multiselect;this.checkSelectionChanges(e,t,i),this.selectionHandler._generateClickEvent("click",t,e),this.selectionHandler._generateClickEvent("hold",t,e)}},{key:"onRelease",value:function(t){if((new Date).valueOf()-this.touchTime>10){var e=this.getPointer(t.center);this.selectionHandler._generateClickEvent("release",t,e),this.touchTime=(new Date).valueOf()}}},{key:"onContext",value:function(t){var e=this.getPointer({x:t.clientX,y:t.clientY});this.selectionHandler._generateClickEvent("oncontext",t,e)}},{key:"checkSelectionChanges",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=this.selectionHandler._getSelectedEdgeCount(),n=this.selectionHandler._getSelectedNodeCount(),s=this.selectionHandler.getSelection(),r=void 0;r=i===!0?this.selectionHandler.selectAdditionalOnPoint(t):this.selectionHandler.selectOnPoint(t);var a=this.selectionHandler._getSelectedEdgeCount(),h=this.selectionHandler._getSelectedNodeCount(),d=this.selectionHandler.getSelection(),l=this._determineIfDifferent(s,d),c=l.nodesChanged,u=l.edgesChanged,p=!1;h-n>0?(this.selectionHandler._generateClickEvent("selectNode",e,t),r=!0,p=!0):c===!0&&h>0?(this.selectionHandler._generateClickEvent("deselectNode",e,t,s),this.selectionHandler._generateClickEvent("selectNode",e,t),p=!0,r=!0):h-n<0&&(this.selectionHandler._generateClickEvent("deselectNode",e,t,s),r=!0),a-o>0&&p===!1?(this.selectionHandler._generateClickEvent("selectEdge",e,t),r=!0):a>0&&u===!0?(this.selectionHandler._generateClickEvent("deselectEdge",e,t,s),this.selectionHandler._generateClickEvent("selectEdge",e,t),r=!0):a-o<0&&(this.selectionHandler._generateClickEvent("deselectEdge",e,t,s),r=!0),r===!0&&this.selectionHandler._generateClickEvent("select",e,t)}},{key:"_determineIfDifferent",value:function(t,e){for(var i=!1,o=!1,n=0;n10&&(t=10);var o=void 0;void 0!==this.drag&&this.drag.dragging===!0&&(o=this.canvas.DOMtoCanvas(this.drag.pointer));var n=this.body.view.translation,s=t/i,r=(1-s)*e.x+n.x*s,a=(1-s)*e.y+n.y*s;if(this.body.view.scale=t,this.body.view.translation={x:r,y:a},void 0!=o){var h=this.canvas.canvasToDOM(o);this.drag.pointer.x=h.x,this.drag.pointer.y=h.y}this.body.emitter.emit("_requestRedraw"),i0&&(this.popupObj=h[c[c.length-1]],s=!0)}if(void 0===this.popupObj&&s===!1){for(var p=this.body.edgeIndices,f=this.body.edges,m=void 0,v=[],g=0;g0&&(this.popupObj=f[v[v.length-1]],r="edge")}void 0!==this.popupObj?this.popupObj.id!==n&&(void 0===this.popup&&(this.popup=new d.default(this.canvas.frame)),this.popup.popupTargetType=r,this.popup.popupTargetId=this.popupObj.id,this.popup.setPosition(t.x+3,t.y-5),this.popup.setText(this.popupObj.getTitle()),this.popup.show(),this.body.emitter.emit("showPopup",this.popupObj.id)):void 0!==this.popup&&(this.popup.hide(),this.body.emitter.emit("hidePopup"))}},{key:"_checkHidePopup",value:function(t){var e=this.selectionHandler._pointerToPositionObject(t),i=!1;if("node"===this.popup.popupTargetType){if(void 0!==this.body.nodes[this.popup.popupTargetId]&&(i=this.body.nodes[this.popup.popupTargetId].isOverlappingWith(e),i===!0)){var o=this.selectionHandler.getNodeAt(t);i=o.id===this.popup.popupTargetId}}else void 0===this.selectionHandler.getNodeAt(t)&&void 0!==this.body.edges[this.popup.popupTargetId]&&(i=this.body.edges[this.popup.popupTargetId].isOverlappingWith(e));i===!1&&(this.popupObj=void 0,this.popup.hide(),this.body.emitter.emit("hidePopup"))}}]),t}();e.default=c},function(t,e,i){function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){for(var i=0;i700&&(this.body.emitter.emit("fit",{duration:700}),this.touchTime=(new Date).valueOf())}},{key:"_stopMovement",value:function(){for(var t in this.boundFunctions)this.boundFunctions.hasOwnProperty(t)&&(this.body.emitter.off("initRedraw",this.boundFunctions[t]),this.body.emitter.emit("_stopRendering"));this.boundFunctions={}}},{key:"_moveUp",value:function(){this.body.view.translation.y+=this.options.keyboard.speed.y}},{key:"_moveDown",value:function(){this.body.view.translation.y-=this.options.keyboard.speed.y}},{key:"_moveLeft",value:function(){this.body.view.translation.x+=this.options.keyboard.speed.x}},{key:"_moveRight",value:function(){this.body.view.translation.x-=this.options.keyboard.speed.x}},{key:"_zoomIn",value:function(){var t=this.body.view.scale,e=this.body.view.scale*(1+this.options.keyboard.speed.zoom),i=this.body.view.translation,o=e/t,n=(1-o)*this.canvas.canvasViewCenter.x+i.x*o,s=(1-o)*this.canvas.canvasViewCenter.y+i.y*o;this.body.view.scale=e,this.body.view.translation={x:n,y:s},this.body.emitter.emit("zoom",{direction:"+",scale:this.body.view.scale})}},{key:"_zoomOut",value:function(){var t=this.body.view.scale,e=this.body.view.scale/(1+this.options.keyboard.speed.zoom),i=this.body.view.translation,o=e/t,n=(1-o)*this.canvas.canvasViewCenter.x+i.x*o,s=(1-o)*this.canvas.canvasViewCenter.y+i.y*o;this.body.view.scale=e,this.body.view.translation={x:n,y:s},this.body.emitter.emit("zoom",{direction:"-",scale:this.body.view.scale})}},{key:"configureKeyboardBindings",value:function(){var t=this;void 0!==this.keycharm&&this.keycharm.destroy(),this.options.keyboard.enabled===!0&&(this.options.keyboard.bindToWindow===!0?this.keycharm=a({container:window,preventDefault:!0}):this.keycharm=a({container:this.canvas.frame,preventDefault:!0}),this.keycharm.reset(),this.activated===!0&&(this.keycharm.bind("up",function(){t.bindToRedraw("_moveUp")},"keydown"),this.keycharm.bind("down",function(){t.bindToRedraw("_moveDown")},"keydown"),this.keycharm.bind("left",function(){t.bindToRedraw("_moveLeft")},"keydown"),this.keycharm.bind("right",function(){t.bindToRedraw("_moveRight")},"keydown"),this.keycharm.bind("=",function(){t.bindToRedraw("_zoomIn")},"keydown"),this.keycharm.bind("num+",function(){t.bindToRedraw("_zoomIn")},"keydown"),this.keycharm.bind("num-",function(){t.bindToRedraw("_zoomOut")},"keydown"),this.keycharm.bind("-",function(){t.bindToRedraw("_zoomOut")},"keydown"),this.keycharm.bind("[",function(){t.bindToRedraw("_zoomOut")},"keydown"),this.keycharm.bind("]",function(){t.bindToRedraw("_zoomIn")},"keydown"),this.keycharm.bind("pageup",function(){t.bindToRedraw("_zoomIn")},"keydown"),this.keycharm.bind("pagedown",function(){t.bindToRedraw("_zoomOut")},"keydown"),this.keycharm.bind("up",function(){t.unbindFromRedraw("_moveUp")},"keyup"),this.keycharm.bind("down",function(){t.unbindFromRedraw("_moveDown")},"keyup"),this.keycharm.bind("left",function(){t.unbindFromRedraw("_moveLeft")},"keyup"),this.keycharm.bind("right",function(){t.unbindFromRedraw("_moveRight")},"keyup"),this.keycharm.bind("=",function(){t.unbindFromRedraw("_zoomIn")},"keyup"),this.keycharm.bind("num+",function(){t.unbindFromRedraw("_zoomIn")},"keyup"),this.keycharm.bind("num-",function(){t.unbindFromRedraw("_zoomOut")},"keyup"),this.keycharm.bind("-",function(){t.unbindFromRedraw("_zoomOut")},"keyup"),this.keycharm.bind("[",function(){t.unbindFromRedraw("_zoomOut")},"keyup"),this.keycharm.bind("]",function(){t.unbindFromRedraw("_zoomIn")},"keyup"),this.keycharm.bind("pageup",function(){t.unbindFromRedraw("_zoomIn")},"keyup"),this.keycharm.bind("pagedown",function(){t.unbindFromRedraw("_zoomOut")},"keyup")))}}]),t}();e.default=h},function(t,e){function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var i=0;io&&(s=o-e-this.padding),sn&&(r=n-i-this.padding),r4&&void 0!==arguments[4]&&arguments[4],s=void 0;s=n===!0?{nodes:[],edges:[]}:this.getSelection(),s.pointer={DOM:{x:i.x,y:i.y},canvas:this.canvas.DOMtoCanvas(i)},s.event=e,void 0!==o&&(s.previousSelection=o),this.body.emitter.emit(t,s)}},{key:"selectObject",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.options.selectConnectedEdges;return void 0!==t&&(t instanceof a.default&&e===!0&&this._selectConnectedEdges(t),t.select(),this._addToSelection(t),!0)}},{key:"deselectObject",value:function(t){t.isSelected()===!0&&(t.selected=!1,this._removeFromSelection(t))}},{key:"_getAllNodesOverlappingWith",value:function(t){for(var e=[],i=this.body.nodes,o=0;o1&&void 0!==arguments[1])||arguments[1],i=this._pointerToPositionObject(t),o=this._getAllNodesOverlappingWith(i);return o.length>0?e===!0?this.body.nodes[o[o.length-1]]:o[o.length-1]:void 0}},{key:"_getEdgesOverlappingWith",value:function(t,e){for(var i=this.body.edges,o=0;o1&&void 0!==arguments[1])||arguments[1],i=this.canvas.DOMtoCanvas(t),o=10,n=null,s=this.body.edges,r=0;r1)return!0;return!1}},{key:"_selectConnectedEdges",value:function(t){for(var e=0;e1&&void 0!==arguments[1]?arguments[1]:{},i=void 0,o=void 0;if(!t||!t.nodes&&!t.edges)throw"Selection must be an object with nodes and/or edges properties";if((e.unselectAll||void 0===e.unselectAll)&&this.unselectAll(),t.nodes)for(i=0;i1&&void 0!==arguments[1])||arguments[1];if(!t||void 0===t.length)throw"Selection must be an array with ids";this.setSelection({nodes:t},{highlightEdges:e})}},{key:"selectEdges",value:function(t){if(!t||void 0===t.length)throw"Selection must be an array with ids";this.setSelection({edges:t})}},{key:"updateSelection",value:function(){for(var t in this.selectionObj.nodes)this.selectionObj.nodes.hasOwnProperty(t)&&(this.body.nodes.hasOwnProperty(t)||delete this.selectionObj.nodes[t]);for(var e in this.selectionObj.edges)this.selectionObj.edges.hasOwnProperty(e)&&(this.body.edges.hasOwnProperty(e)||delete this.selectionObj.edges[e])}}]),t}();e.default=c},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){var i=[],o=!0,n=!1,s=void 0;try{for(var r,a=t[Symbol.iterator]();!(o=(r=a.next()).done)&&(i.push(r.value),!e||i.length!==e);o=!0);}catch(t){n=!0,s=t}finally{try{!o&&a.return&&a.return()}finally{if(n)throw s}}return i}return function(e,i){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a=function(){function t(t,e){for(var i=0;i0&&(this.options.hierarchical.levelSeparation*=-1):this.options.hierarchical.levelSeparation<0&&(this.options.hierarchical.levelSeparation*=-1),this.body.emitter.emit("_resetHierarchicalLayout"),this.adaptAllOptionsForHierarchicalLayout(e);if(i===!0)return this.body.emitter.emit("refresh"),l.deepExtend(e,this.optionsBackup)}return e}},{key:"adaptAllOptionsForHierarchicalLayout",value:function(t){if(this.options.hierarchical.enabled===!0){void 0===t.physics||t.physics===!0?(t.physics={enabled:void 0===this.optionsBackup.physics.enabled||this.optionsBackup.physics.enabled,solver:"hierarchicalRepulsion"},this.optionsBackup.physics.enabled=void 0===this.optionsBackup.physics.enabled||this.optionsBackup.physics.enabled,this.optionsBackup.physics.solver=this.optionsBackup.physics.solver||"barnesHut"):"object"===r(t.physics)?(this.optionsBackup.physics.enabled=void 0===t.physics.enabled||t.physics.enabled,this.optionsBackup.physics.solver=t.physics.solver||"barnesHut",t.physics.solver="hierarchicalRepulsion"):t.physics!==!1&&(this.optionsBackup.physics.solver="barnesHut",t.physics={solver:"hierarchicalRepulsion"});var e="horizontal";"RL"!==this.options.hierarchical.direction&&"LR"!==this.options.hierarchical.direction||(e="vertical"),void 0===t.edges?(this.optionsBackup.edges={smooth:{enabled:!0,type:"dynamic"}},t.edges={smooth:!1}):void 0===t.edges.smooth?(this.optionsBackup.edges={smooth:{enabled:!0,type:"dynamic"}},t.edges.smooth=!1):"boolean"==typeof t.edges.smooth?(this.optionsBackup.edges={smooth:t.edges.smooth},t.edges.smooth={enabled:t.edges.smooth,type:e}):(void 0!==t.edges.smooth.type&&"dynamic"!==t.edges.smooth.type&&(e=t.edges.smooth.type),this.optionsBackup.edges={smooth:void 0===t.edges.smooth.enabled||t.edges.smooth.enabled,type:void 0===t.edges.smooth.type?"dynamic":t.edges.smooth.type,roundness:void 0===t.edges.smooth.roundness?.5:t.edges.smooth.roundness,forceDirection:void 0!==t.edges.smooth.forceDirection&&t.edges.smooth.forceDirection},t.edges.smooth={enabled:void 0===t.edges.smooth.enabled||t.edges.smooth.enabled,type:e,roundness:void 0===t.edges.smooth.roundness?.5:t.edges.smooth.roundness,forceDirection:void 0!==t.edges.smooth.forceDirection&&t.edges.smooth.forceDirection}),this.body.emitter.emit("_forceDisableDynamicCurves",e)}return t}},{key:"seededRandom",value:function(){var t=1e4*Math.sin(this.randomSeed++);return t-Math.floor(t)}},{key:"positionInitially",value:function(t){if(this.options.hierarchical.enabled!==!0){this.randomSeed=this.initialRandomSeed;for(var e=0;es){for(var r=this.body.nodeIndices.length;this.body.nodeIndices.length>s;){n+=1;var a=this.body.nodeIndices.length;n%3===0?this.body.modules.clustering.clusterBridges():this.body.modules.clustering.clusterOutliers();var h=this.body.nodeIndices.length;if(a==h&&n%3!==0||n>o)return this._declusterAll(),this.body.emitter.emit("_layoutFailed"),void console.info("This network could not be positioned by this version of the improved layout algorithm. Please disable improvedLayout for better performance.")}this.body.modules.kamadaKawai.setOptions({springLength:Math.max(150,2*r)})}this.body.modules.kamadaKawai.solve(this.body.nodeIndices,this.body.edgeIndices,!0),this._shiftToCenter();for(var d=70,l=0;l0){var t=void 0,e=void 0,i=!1,o=!0,n=!1;this.hierarchicalLevels={},this.lastNodeOnLevel={},this.hierarchicalChildrenReference={},this.hierarchicalParentReference={},this.hierarchicalTrees={},this.treeIndex=-1,this.distributionOrdering={},this.distributionIndex={},this.distributionOrderingPresence={};for(e in this.body.nodes)this.body.nodes.hasOwnProperty(e)&&(t=this.body.nodes[e],void 0===t.options.x&&void 0===t.options.y&&(o=!1),void 0!==t.options.level?(i=!0,this.hierarchicalLevels[e]=t.options.level):n=!0);if(n===!0&&i===!0)throw new Error("To use the hierarchical layout, nodes require either no predefined levels or levels have to be defined for all nodes.");n===!0&&("hubsize"===this.options.hierarchical.sortMethod?this._determineLevelsByHubsize():"directed"===this.options.hierarchical.sortMethod?this._determineLevelsDirected():"custom"===this.options.hierarchical.sortMethod&&this._determineLevelsCustomCallback());for(var s in this.body.nodes)this.body.nodes.hasOwnProperty(s)&&void 0===this.hierarchicalLevels[s]&&(this.hierarchicalLevels[s]=0);var r=this._getDistribution();this._generateMap(),this._placeNodesByHierarchy(r),this._condenseHierarchy(),this._shiftToCenter()}}},{key:"_condenseHierarchy",value:function(){var t=this,e=!1,i={},o=function(){for(var e=a(),i=0;i0)for(var s=0;s1&&void 0!==arguments[1]?arguments[1]:1e9,o=1e9,n=1e9,r=1e9,a=-1e9;for(var h in e)if(e.hasOwnProperty(h)){var d=t.body.nodes[h],l=t.hierarchicalLevels[d.id],c=t._getPositionForHierarchy(d),u=t._getSpaceAroundNode(d,e),p=s(u,2),f=p[0],m=p[1];o=Math.min(f,o),n=Math.min(m,n),l<=i&&(r=Math.min(c,r),a=Math.max(c,a))}return[r,a,o,n]},l=function e(i){var o=t.hierarchicalLevels[i];if(t.hierarchicalChildrenReference[i]){var n=t.hierarchicalChildrenReference[i];if(n.length>0)for(var s=0;s1)for(var a=0;a2&&void 0!==arguments[2]&&arguments[2],r=t._getPositionForHierarchy(i),a=t._getPositionForHierarchy(o),l=Math.abs(a-r);if(l>t.options.hierarchical.nodeSpacing){var u={};u[i.id]=!0;var p={};p[o.id]=!0,h(i,u),h(o,p);var f=c(i,o),m=d(u,f),v=s(m,4),g=(v[0],v[1]),y=(v[2],v[3],d(p,f)),b=s(y,4),_=b[0],w=(b[1],b[2]),x=(b[3],Math.abs(g-_));if(x>t.options.hierarchical.nodeSpacing){var k=g-_+t.options.hierarchical.nodeSpacing;k<-w+t.options.hierarchical.nodeSpacing&&(k=-w+t.options.hierarchical.nodeSpacing),k<0&&(t._shiftBlock(o.id,k),e=!0,n===!0&&t._centerParent(o))}}},m=function(o,n){for(var r=n.id,a=n.edges,l=t.hierarchicalLevels[n.id],c=t.options.hierarchical.levelSeparation*t.options.hierarchical.levelSeparation,u={},p=[],f=0;f0?m=Math.min(f,p-t.options.hierarchical.nodeSpacing):f<0&&(m=-Math.min(-f,u-t.options.hierarchical.nodeSpacing)),0!=m&&(t._shiftBlock(n.id,m),e=!0)},w=function(i){var o=t._getPositionForHierarchy(n),r=t._getSpaceAroundNode(n),a=s(r,2),h=a[0],d=a[1],l=i-o,c=o;l>0?c=Math.min(o+(d-t.options.hierarchical.nodeSpacing),i):l<0&&(c=Math.max(o-(h-t.options.hierarchical.nodeSpacing),i)),c!==o&&(t._setPositionForHierarchy(n,c,void 0,!0),e=!0)},x=b(o,p);_(x),x=b(o,a),w(x)},v=function(i){var o=Object.keys(t.distributionOrdering);o=o.reverse();for(var n=0;n0)for(var d=0;d0&&Math.abs(g)0&&(r=this._getPositionForHierarchy(i[n-1])+this.options.hierarchical.nodeSpacing),this._setPositionForHierarchy(s,r,e),this._validataPositionAndContinue(s,e,r),o++}}}}},{key:"_placeBranchNodes",value:function(t,e){if(void 0!==this.hierarchicalChildrenReference[t]){for(var i=[],o=0;oe&&void 0===this.positionedNodes[s.id]))return;var a=void 0;a=0===n?this._getPositionForHierarchy(this.body.nodes[t]):this._getPositionForHierarchy(i[n-1])+this.options.hierarchical.nodeSpacing,this._setPositionForHierarchy(s,a,r),this._validataPositionAndContinue(s,r,a)}for(var h=1e9,d=-1e9,l=0;l0&&(e=this._getHubSize(),0!==e);)for(var o in this.body.nodes)if(this.body.nodes.hasOwnProperty(o)){var n=this.body.nodes[o];n.edges.length===e&&this._crawlNetwork(i,o)}}},{key:"_determineLevelsCustomCallback",value:function(){var t=this,e=1e5,i=function(t,e,i){},o=function(o,n,s){var r=t.hierarchicalLevels[o.id];void 0===r&&(t.hierarchicalLevels[o.id]=e);var a=i(d.default.cloneOptions(o,"node"),d.default.cloneOptions(n,"node"),d.default.cloneOptions(s,"edge"));t.hierarchicalLevels[n.id]=t.hierarchicalLevels[o.id]+a};this._crawlNetwork(o),this._setMinLevelToZero()}},{key:"_determineLevelsDirected",value:function(){var t=this,e=1e4,i=function(i,o,n){var s=t.hierarchicalLevels[i.id];void 0===s&&(t.hierarchicalLevels[i.id]=e),n.toId==o.id?t.hierarchicalLevels[o.id]=t.hierarchicalLevels[i.id]+1:t.hierarchicalLevels[o.id]=t.hierarchicalLevels[i.id]-1};this._crawlNetwork(i),this._setMinLevelToZero()}},{key:"_setMinLevelToZero",value:function(){var t=1e9;for(var e in this.body.nodes)this.body.nodes.hasOwnProperty(e)&&void 0!==this.hierarchicalLevels[e]&&(t=Math.min(this.hierarchicalLevels[e],t));for(var i in this.body.nodes)this.body.nodes.hasOwnProperty(i)&&void 0!==this.hierarchicalLevels[i]&&(this.hierarchicalLevels[i]-=t)}},{key:"_generateMap",value:function(){var t=this,e=function(e,i){if(t.hierarchicalLevels[i.id]>t.hierarchicalLevels[e.id]){var o=e.id,n=i.id;void 0===t.hierarchicalChildrenReference[o]&&(t.hierarchicalChildrenReference[o]=[]),t.hierarchicalChildrenReference[o].push(n),void 0===t.hierarchicalParentReference[n]&&(t.hierarchicalParentReference[n]=[]),t.hierarchicalParentReference[n].push(o)}};this._crawlNetwork(e)}},{key:"_crawlNetwork",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){},i=arguments[1],o={},n=0,s=function i(n,s){if(void 0===o[n.id]){void 0===t.hierarchicalTrees[n.id]&&(t.hierarchicalTrees[n.id]=s,t.treeIndex=Math.max(s,t.treeIndex)),o[n.id]=!0;for(var r=void 0,a=0;a3&&void 0!==arguments[3]&&arguments[3];o!==!0&&(void 0===this.distributionOrdering[i]&&(this.distributionOrdering[i]=[],this.distributionOrderingPresence[i]={}),void 0===this.distributionOrderingPresence[i][t.id]&&(this.distributionOrdering[i].push(t),this.distributionIndex[t.id]=this.distributionOrdering[i].length-1),this.distributionOrderingPresence[i][t.id]=!0),"UD"===this.options.hierarchical.direction||"DU"===this.options.hierarchical.direction?t.x=e:t.y=e}},{key:"_getPositionForHierarchy",value:function(t){return"UD"===this.options.hierarchical.direction||"DU"===this.options.hierarchical.direction?t.x:t.y}},{key:"_sortNodeArray",value:function(t){t.length>1&&("UD"===this.options.hierarchical.direction||"DU"===this.options.hierarchical.direction?t.sort(function(t,e){return t.x-e.x}):t.sort(function(t,e){return t.y-e.y}))}}]),t}();e.default=c},function(t,e,i){function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){for(var i=0;i0&&this.options.deleteNode!==!1?(n===!0&&this._createSeperator(4),this._createDeleteButton(o)):0===t&&this.options.deleteEdge!==!1&&(n===!0&&this._createSeperator(4),this._createDeleteButton(o))),this._bindHammerToDiv(this.closeDiv,this.toggleEditMode.bind(this)),this._temporaryBindEvent("select",this.showManipulatorToolbar.bind(this))}this.body.emitter.emit("_redraw")}},{key:"addNodeMode",value:function(){if(this.editMode!==!0&&this.enableEditMode(),this._clean(),this.inMode="addNode",this.guiEnabled===!0){var t=this.options.locales[this.options.locale];this.manipulationDOM={},this._createBackButton(t),this._createSeperator(),this._createDescription(t.addDescription||this.options.locales.en.addDescription),this._bindHammerToDiv(this.closeDiv,this.toggleEditMode.bind(this))}this._temporaryBindEvent("click",this._performAddNode.bind(this))}},{key:"editNode",value:function(){var t=this;this.editMode!==!0&&this.enableEditMode(),this._clean();var e=this.selectionHandler._getSelectedNode();if(void 0!==e){if(this.inMode="editNode","function"!=typeof this.options.editNode)throw new Error("No function has been configured to handle the editing of nodes.");if(e.isCluster!==!0){var i=s.deepExtend({},e.options,!1);if(i.x=e.x,i.y=e.y,2!==this.options.editNode.length)throw new Error("The function for edit does not support two arguments (data, callback)");this.options.editNode(i,function(e){null!==e&&void 0!==e&&"editNode"===t.inMode&&t.body.data.nodes.getDataSet().update(e),t.showManipulatorToolbar()})}else alert(this.options.locales[this.options.locale].editClusterError||this.options.locales.en.editClusterError)}else this.showManipulatorToolbar()}},{key:"addEdgeMode",value:function(){if(this.editMode!==!0&&this.enableEditMode(),this._clean(),this.inMode="addEdge",this.guiEnabled===!0){var t=this.options.locales[this.options.locale];this.manipulationDOM={},this._createBackButton(t),this._createSeperator(),this._createDescription(t.edgeDescription||this.options.locales.en.edgeDescription),this._bindHammerToDiv(this.closeDiv,this.toggleEditMode.bind(this))}this._temporaryBindUI("onTouch",this._handleConnect.bind(this)),this._temporaryBindUI("onDragEnd",this._finishConnect.bind(this)),this._temporaryBindUI("onDrag",this._dragControlNode.bind(this)),this._temporaryBindUI("onRelease",this._finishConnect.bind(this)),this._temporaryBindUI("onDragStart",function(){}),this._temporaryBindUI("onHold",function(){})}},{key:"editEdgeMode",value:function(){var t=this;if(this.editMode!==!0&&this.enableEditMode(),this._clean(),this.inMode="editEdge",this.guiEnabled===!0){var e=this.options.locales[this.options.locale];this.manipulationDOM={},this._createBackButton(e),this._createSeperator(),this._createDescription(e.editEdgeDescription||this.options.locales.en.editEdgeDescription),this._bindHammerToDiv(this.closeDiv,this.toggleEditMode.bind(this))}this.edgeBeingEditedId=this.selectionHandler.getSelectedEdges()[0],void 0!==this.edgeBeingEditedId?!function(){var e=t.body.edges[t.edgeBeingEditedId],i=t._getNewTargetNode(e.from.x,e.from.y),o=t._getNewTargetNode(e.to.x,e.to.y);t.temporaryIds.nodes.push(i.id),t.temporaryIds.nodes.push(o.id),t.body.nodes[i.id]=i,t.body.nodeIndices.push(i.id),t.body.nodes[o.id]=o,t.body.nodeIndices.push(o.id),t._temporaryBindUI("onTouch",t._controlNodeTouch.bind(t)),t._temporaryBindUI("onTap",function(){}),t._temporaryBindUI("onHold",function(){}),t._temporaryBindUI("onDragStart",t._controlNodeDragStart.bind(t)),t._temporaryBindUI("onDrag",t._controlNodeDrag.bind(t)),t._temporaryBindUI("onDragEnd",t._controlNodeDragEnd.bind(t)),t._temporaryBindUI("onMouseMove",function(){}),t._temporaryBindEvent("beforeDrawing",function(t){var n=e.edgeType.findBorderPositions(t);i.selected===!1&&(i.x=n.from.x,i.y=n.from.y),o.selected===!1&&(o.x=n.to.x,o.y=n.to.y)}),t.body.emitter.emit("_redraw")}():this.showManipulatorToolbar()}},{key:"deleteSelected",value:function(){var t=this;this.editMode!==!0&&this.enableEditMode(),this._clean(),this.inMode="delete";var e=this.selectionHandler.getSelectedNodes(),i=this.selectionHandler.getSelectedEdges(),o=void 0;if(e.length>0){for(var n=0;n0&&"function"==typeof this.options.deleteEdge&&(o=this.options.deleteEdge);if("function"==typeof o){var s={nodes:e,edges:i};if(2!==o.length)throw new Error("The function for delete does not support two arguments (data, callback)");o(s,function(e){null!==e&&void 0!==e&&"delete"===t.inMode?(t.body.data.edges.getDataSet().remove(e.edges),t.body.data.nodes.getDataSet().remove(e.nodes),t.body.emitter.emit("startSimulation"),t.showManipulatorToolbar()):(t.body.emitter.emit("startSimulation"),t.showManipulatorToolbar())})}else this.body.data.edges.getDataSet().remove(i),this.body.data.nodes.getDataSet().remove(e),this.body.emitter.emit("startSimulation"),this.showManipulatorToolbar()}},{key:"_setup",value:function(){this.options.enabled===!0?(this.guiEnabled=!0,this._createWrappers(),this.editMode===!1?this._createEditButton():this.showManipulatorToolbar()):(this._removeManipulationDOM(),this.guiEnabled=!1)}},{key:"_createWrappers",value:function(){void 0===this.manipulationDiv&&(this.manipulationDiv=document.createElement("div"),this.manipulationDiv.className="vis-manipulation",this.editMode===!0?this.manipulationDiv.style.display="block":this.manipulationDiv.style.display="none",this.canvas.frame.appendChild(this.manipulationDiv)),void 0===this.editModeDiv&&(this.editModeDiv=document.createElement("div"),this.editModeDiv.className="vis-edit-mode",this.editMode===!0?this.editModeDiv.style.display="none":this.editModeDiv.style.display="block",this.canvas.frame.appendChild(this.editModeDiv)),void 0===this.closeDiv&&(this.closeDiv=document.createElement("div"),this.closeDiv.className="vis-close",this.closeDiv.style.display=this.manipulationDiv.style.display,this.canvas.frame.appendChild(this.closeDiv))}},{key:"_getNewTargetNode",value:function(t,e){var i=s.deepExtend({},this.options.controlNodeStyle);i.id="targetNode"+s.randomUUID(),i.hidden=!1,i.physics=!1,i.x=t,i.y=e;var o=this.body.functions.createNode(i);return o.shape.boundingBox={left:t,right:t,top:e,bottom:e},o}},{key:"_createEditButton",value:function(){this._clean(),this.manipulationDOM={},s.recursiveDOMDelete(this.editModeDiv);var t=this.options.locales[this.options.locale],e=this._createButton("editMode","vis-button vis-edit vis-edit-mode",t.edit||this.options.locales.en.edit);this.editModeDiv.appendChild(e),this._bindHammerToDiv(e,this.toggleEditMode.bind(this))}},{key:"_clean",value:function(){this.inMode=!1,this.guiEnabled===!0&&(s.recursiveDOMDelete(this.editModeDiv),s.recursiveDOMDelete(this.manipulationDiv),this._cleanManipulatorHammers()),this._cleanupTemporaryNodesAndEdges(),this._unbindTemporaryUIs(),this._unbindTemporaryEvents(),this.body.emitter.emit("restorePhysics")}},{key:"_cleanManipulatorHammers",value:function(){if(0!=this.manipulationHammers.length){for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:1;this.manipulationDOM["seperatorLineDiv"+t]=document.createElement("div"),this.manipulationDOM["seperatorLineDiv"+t].className="vis-separator-line",this.manipulationDiv.appendChild(this.manipulationDOM["seperatorLineDiv"+t])}},{key:"_createAddNodeButton",value:function(t){var e=this._createButton("addNode","vis-button vis-add",t.addNode||this.options.locales.en.addNode);this.manipulationDiv.appendChild(e),this._bindHammerToDiv(e,this.addNodeMode.bind(this))}},{key:"_createAddEdgeButton",value:function(t){var e=this._createButton("addEdge","vis-button vis-connect",t.addEdge||this.options.locales.en.addEdge);this.manipulationDiv.appendChild(e),this._bindHammerToDiv(e,this.addEdgeMode.bind(this))}},{key:"_createEditNodeButton",value:function(t){var e=this._createButton("editNode","vis-button vis-edit",t.editNode||this.options.locales.en.editNode);this.manipulationDiv.appendChild(e),this._bindHammerToDiv(e,this.editNode.bind(this))}},{key:"_createEditEdgeButton",value:function(t){var e=this._createButton("editEdge","vis-button vis-edit",t.editEdge||this.options.locales.en.editEdge);this.manipulationDiv.appendChild(e),this._bindHammerToDiv(e,this.editEdgeMode.bind(this))}},{key:"_createDeleteButton",value:function(t){if(this.options.rtl)var e="vis-button vis-delete-rtl";else var e="vis-button vis-delete";var i=this._createButton("delete",e,t.del||this.options.locales.en.del);this.manipulationDiv.appendChild(i),this._bindHammerToDiv(i,this.deleteSelected.bind(this))}},{key:"_createBackButton",value:function(t){var e=this._createButton("back","vis-button vis-back",t.back||this.options.locales.en.back);this.manipulationDiv.appendChild(e),this._bindHammerToDiv(e,this.showManipulatorToolbar.bind(this))}},{key:"_createButton",value:function(t,e,i){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"vis-label";return this.manipulationDOM[t+"Div"]=document.createElement("div"),this.manipulationDOM[t+"Div"].className=e,this.manipulationDOM[t+"Label"]=document.createElement("div"),this.manipulationDOM[t+"Label"].className=o,this.manipulationDOM[t+"Label"].innerHTML=i,this.manipulationDOM[t+"Div"].appendChild(this.manipulationDOM[t+"Label"]),this.manipulationDOM[t+"Div"]}},{key:"_createDescription",value:function(t){this.manipulationDiv.appendChild(this._createButton("description","vis-button vis-none",t))}},{key:"_temporaryBindEvent",value:function(t,e){this.temporaryEventFunctions.push({event:t,boundFunction:e}),this.body.emitter.on(t,e)}},{key:"_temporaryBindUI",value:function(t,e){if(void 0===this.body.eventListeners[t])throw new Error("This UI function does not exist. Typo? You tried: "+t+" possible are: "+JSON.stringify(Object.keys(this.body.eventListeners)));this.temporaryUIFunctions[t]=this.body.eventListeners[t],this.body.eventListeners[t]=e}},{key:"_unbindTemporaryUIs",value:function(){for(var t in this.temporaryUIFunctions)this.temporaryUIFunctions.hasOwnProperty(t)&&(this.body.eventListeners[t]=this.temporaryUIFunctions[t],delete this.temporaryUIFunctions[t]);this.temporaryUIFunctions={}}},{key:"_unbindTemporaryEvents",value:function(){for(var t=0;t=0;r--)if(n[r]!==this.selectedControlNode.id){s=this.body.nodes[n[r]];break}if(void 0!==s&&void 0!==this.selectedControlNode)if(s.isCluster===!0)alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError);else{var a=this.body.nodes[this.temporaryIds.nodes[0]];this.selectedControlNode.id===a.id?this._performEditEdge(s.id,o.to.id):this._performEditEdge(o.from.id,s.id)}else o.updateEdgeType(),this.body.emitter.emit("restorePhysics");this.body.emitter.emit("_redraw")}}},{key:"_handleConnect",value:function(t){if((new Date).valueOf()-this.touchTime>100){this.lastTouch=this.body.functions.getPointer(t.center),this.lastTouch.translation=s.extend({},this.body.view.translation);var e=this.lastTouch,i=this.selectionHandler.getNodeAt(e);if(void 0!==i)if(i.isCluster===!0)alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError);else{var o=this._getNewTargetNode(i.x,i.y);this.body.nodes[o.id]=o,this.body.nodeIndices.push(o.id);var n=this.body.functions.createEdge({id:"connectionEdge"+s.randomUUID(),from:i.id,to:o.id,physics:!1,smooth:{enabled:!0,type:"continuous",roundness:.5}});this.body.edges[n.id]=n,this.body.edgeIndices.push(n.id),this.temporaryIds.nodes.push(o.id),this.temporaryIds.edges.push(n.id)}this.touchTime=(new Date).valueOf()}}},{key:"_dragControlNode",value:function(t){var e=this.body.functions.getPointer(t.center);if(void 0!==this.temporaryIds.nodes[0]){var i=this.body.nodes[this.temporaryIds.nodes[0]];i.x=this.canvas._XconvertDOMtoCanvas(e.x),i.y=this.canvas._YconvertDOMtoCanvas(e.y),this.body.emitter.emit("_redraw")}else{var o=e.x-this.lastTouch.x,n=e.y-this.lastTouch.y;this.body.view.translation={x:this.lastTouch.translation.x+o,y:this.lastTouch.translation.y+n}}}},{key:"_finishConnect",value:function(t){var e=this.body.functions.getPointer(t.center),i=this.selectionHandler._pointerToPositionObject(e),o=void 0;void 0!==this.temporaryIds.edges[0]&&(o=this.body.edges[this.temporaryIds.edges[0]].fromId);for(var n=this.selectionHandler._getAllNodesOverlappingWith(i),s=void 0,r=n.length-1;r>=0;r--)if(this.temporaryIds.nodes.indexOf(n[r])===-1){s=this.body.nodes[n[r]];break}this._cleanupTemporaryNodesAndEdges(),void 0!==s&&(s.isCluster===!0?alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError):void 0!==this.body.nodes[o]&&void 0!==this.body.nodes[s.id]&&this._performAddEdge(o,s.id)),this.body.emitter.emit("_redraw")}},{key:"_performAddNode",value:function(t){var e=this,i={id:s.randomUUID(),x:t.pointer.canvas.x,y:t.pointer.canvas.y,label:"new"};if("function"==typeof this.options.addNode){if(2!==this.options.addNode.length)throw new Error("The function for add does not support two arguments (data,callback)");this.options.addNode(i,function(t){null!==t&&void 0!==t&&"addNode"===e.inMode&&(e.body.data.nodes.getDataSet().add(t),e.showManipulatorToolbar())})}else this.body.data.nodes.getDataSet().add(i),this.showManipulatorToolbar()}},{key:"_performAddEdge",value:function(t,e){var i=this,o={from:t,to:e};if("function"==typeof this.options.addEdge){if(2!==this.options.addEdge.length)throw new Error("The function for connect does not support two arguments (data,callback)");this.options.addEdge(o,function(t){null!==t&&void 0!==t&&"addEdge"===i.inMode&&(i.body.data.edges.getDataSet().add(t),i.selectionHandler.unselectAll(),i.showManipulatorToolbar())})}else this.body.data.edges.getDataSet().add(o),this.selectionHandler.unselectAll(),this.showManipulatorToolbar()}},{key:"_performEditEdge",value:function(t,e){var i=this,o={id:this.edgeBeingEditedId,from:t,to:e};if("function"==typeof this.options.editEdge){if(2!==this.options.editEdge.length)throw new Error("The function for edit does not support two arguments (data, callback)");this.options.editEdge(o,function(t){null===t||void 0===t||"editEdge"!==i.inMode?(i.body.edges[o.id].updateEdgeType(),i.body.emitter.emit("_redraw")):(i.body.data.edges.getDataSet().update(t),i.selectionHandler.unselectAll(),i.showManipulatorToolbar())})}else this.body.data.edges.getDataSet().update(o),this.selectionHandler.unselectAll(),this.showManipulatorToolbar()}}]),t}();e.default=h},function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var i="string",o="boolean",n="number",s="array",r="object",a="dom",h="any",d={configure:{enabled:{boolean:o},filter:{boolean:o,string:i,array:s,function:"function"},container:{dom:a},showButton:{boolean:o},__type__:{object:r,boolean:o,string:i,array:s,function:"function"}},edges:{arrows:{to:{enabled:{boolean:o},scaleFactor:{number:n},type:{string:["arrow","circle"]},__type__:{object:r,boolean:o}},middle:{enabled:{boolean:o},scaleFactor:{number:n},type:{string:["arrow","circle"]},__type__:{object:r,boolean:o}},from:{enabled:{boolean:o},scaleFactor:{number:n},type:{string:["arrow","circle"]},__type__:{object:r,boolean:o}},__type__:{string:["from","to","middle"],object:r}},arrowStrikethrough:{boolean:o},color:{color:{string:i},highlight:{string:i},hover:{string:i},inherit:{string:["from","to","both"],boolean:o},opacity:{number:n},__type__:{object:r,string:i}},dashes:{boolean:o,array:s},font:{color:{string:i},size:{number:n},face:{string:i},background:{string:i},strokeWidth:{number:n},strokeColor:{string:i},align:{string:["horizontal","top","middle","bottom"]},__type__:{object:r,string:i}},hidden:{boolean:o},hoverWidth:{function:"function",number:n},label:{string:i,undefined:"undefined"},labelHighlightBold:{boolean:o},length:{number:n,undefined:"undefined"},physics:{boolean:o},scaling:{min:{number:n},max:{number:n},label:{enabled:{boolean:o},min:{number:n},max:{number:n},maxVisible:{number:n},drawThreshold:{number:n},__type__:{object:r,boolean:o}},customScalingFunction:{function:"function"},__type__:{object:r}},selectionWidth:{function:"function",number:n},selfReferenceSize:{number:n},shadow:{enabled:{boolean:o},color:{string:i},size:{number:n},x:{number:n},y:{number:n},__type__:{object:r,boolean:o}},smooth:{enabled:{boolean:o},type:{string:["dynamic","continuous","discrete","diagonalCross","straightCross","horizontal","vertical","curvedCW","curvedCCW","cubicBezier"]},roundness:{number:n},forceDirection:{string:["horizontal","vertical","none"],boolean:o},__type__:{object:r,boolean:o}},title:{string:i,undefined:"undefined"},width:{number:n},value:{number:n,undefined:"undefined"},__type__:{object:r}},groups:{useDefaultGroups:{boolean:o},__any__:"get from nodes, will be overwritten below", +__type__:{object:r}},interaction:{dragNodes:{boolean:o},dragView:{boolean:o},hideEdgesOnDrag:{boolean:o},hideNodesOnDrag:{boolean:o},hover:{boolean:o},keyboard:{enabled:{boolean:o},speed:{x:{number:n},y:{number:n},zoom:{number:n},__type__:{object:r}},bindToWindow:{boolean:o},__type__:{object:r,boolean:o}},multiselect:{boolean:o},navigationButtons:{boolean:o},selectable:{boolean:o},selectConnectedEdges:{boolean:o},hoverConnectedEdges:{boolean:o},tooltipDelay:{number:n},zoomView:{boolean:o},__type__:{object:r}},layout:{randomSeed:{undefined:"undefined",number:n},improvedLayout:{boolean:o},hierarchical:{enabled:{boolean:o},levelSeparation:{number:n},nodeSpacing:{number:n},treeSpacing:{number:n},blockShifting:{boolean:o},edgeMinimization:{boolean:o},parentCentralization:{boolean:o},direction:{string:["UD","DU","LR","RL"]},sortMethod:{string:["hubsize","directed"]},__type__:{object:r,boolean:o}},__type__:{object:r}},manipulation:{enabled:{boolean:o},initiallyActive:{boolean:o},addNode:{boolean:o,function:"function"},addEdge:{boolean:o,function:"function"},editNode:{function:"function"},editEdge:{boolean:o,function:"function"},deleteNode:{boolean:o,function:"function"},deleteEdge:{boolean:o,function:"function"},controlNodeStyle:"get from nodes, will be overwritten below",__type__:{object:r,boolean:o}},nodes:{borderWidth:{number:n},borderWidthSelected:{number:n,undefined:"undefined"},brokenImage:{string:i,undefined:"undefined"},color:{border:{string:i},background:{string:i},highlight:{border:{string:i},background:{string:i},__type__:{object:r,string:i}},hover:{border:{string:i},background:{string:i},__type__:{object:r,string:i}},__type__:{object:r,string:i}},fixed:{x:{boolean:o},y:{boolean:o},__type__:{object:r,boolean:o}},font:{align:{string:i},color:{string:i},size:{number:n},face:{string:i},background:{string:i},strokeWidth:{number:n},strokeColor:{string:i},__type__:{object:r,string:i}},group:{string:i,number:n,undefined:"undefined"},hidden:{boolean:o},icon:{face:{string:i},code:{string:i},size:{number:n},color:{string:i},__type__:{object:r}},id:{string:i,number:n},image:{string:i,undefined:"undefined"},label:{string:i,undefined:"undefined"},labelHighlightBold:{boolean:o},level:{number:n,undefined:"undefined"},mass:{number:n},physics:{boolean:o},scaling:{min:{number:n},max:{number:n},label:{enabled:{boolean:o},min:{number:n},max:{number:n},maxVisible:{number:n},drawThreshold:{number:n},__type__:{object:r,boolean:o}},customScalingFunction:{function:"function"},__type__:{object:r}},shadow:{enabled:{boolean:o},color:{string:i},size:{number:n},x:{number:n},y:{number:n},__type__:{object:r,boolean:o}},shape:{string:["ellipse","circle","database","box","text","image","circularImage","diamond","dot","star","triangle","triangleDown","square","icon"]},shapeProperties:{borderDashes:{boolean:o,array:s},borderRadius:{number:n},interpolation:{boolean:o},useImageSize:{boolean:o},useBorderWithImage:{boolean:o},__type__:{object:r}},size:{number:n},title:{string:i,undefined:"undefined"},value:{number:n,undefined:"undefined"},x:{number:n},y:{number:n},__type__:{object:r}},physics:{enabled:{boolean:o},barnesHut:{gravitationalConstant:{number:n},centralGravity:{number:n},springLength:{number:n},springConstant:{number:n},damping:{number:n},avoidOverlap:{number:n},__type__:{object:r}},forceAtlas2Based:{gravitationalConstant:{number:n},centralGravity:{number:n},springLength:{number:n},springConstant:{number:n},damping:{number:n},avoidOverlap:{number:n},__type__:{object:r}},repulsion:{centralGravity:{number:n},springLength:{number:n},springConstant:{number:n},nodeDistance:{number:n},damping:{number:n},__type__:{object:r}},hierarchicalRepulsion:{centralGravity:{number:n},springLength:{number:n},springConstant:{number:n},nodeDistance:{number:n},damping:{number:n},__type__:{object:r}},maxVelocity:{number:n},minVelocity:{number:n},solver:{string:["barnesHut","repulsion","hierarchicalRepulsion","forceAtlas2Based"]},stabilization:{enabled:{boolean:o},iterations:{number:n},updateInterval:{number:n},onlyDynamicEdges:{boolean:o},fit:{boolean:o},__type__:{object:r,boolean:o}},timestep:{number:n},adaptiveTimestep:{boolean:o},__type__:{object:r,boolean:o}},autoResize:{boolean:o},clickToUse:{boolean:o},locale:{string:i},locales:{__any__:{any:h},__type__:{object:r}},height:{string:i},width:{string:i},__type__:{object:r}};d.groups.__any__=d.nodes,d.manipulation.controlNodeStyle=d.nodes;var l={nodes:{borderWidth:[1,0,10,1],borderWidthSelected:[2,0,10,1],color:{border:["color","#2B7CE9"],background:["color","#97C2FC"],highlight:{border:["color","#2B7CE9"],background:["color","#D2E5FF"]},hover:{border:["color","#2B7CE9"],background:["color","#D2E5FF"]}},fixed:{x:!1,y:!1},font:{color:["color","#343434"],size:[14,0,100,1],face:["arial","verdana","tahoma"],background:["color","none"],strokeWidth:[0,0,50,1],strokeColor:["color","#ffffff"]},hidden:!1,labelHighlightBold:!0,physics:!0,scaling:{min:[10,0,200,1],max:[30,0,200,1],label:{enabled:!1,min:[14,0,200,1],max:[30,0,200,1],maxVisible:[30,0,200,1],drawThreshold:[5,0,20,1]}},shadow:{enabled:!1,color:"rgba(0,0,0,0.5)",size:[10,0,20,1],x:[5,-30,30,1],y:[5,-30,30,1]},shape:["ellipse","box","circle","database","diamond","dot","square","star","text","triangle","triangleDown"],shapeProperties:{borderDashes:!1,borderRadius:[6,0,20,1],interpolation:!0,useImageSize:!1},size:[25,0,200,1]},edges:{arrows:{to:{enabled:!1,scaleFactor:[1,0,3,.05],type:"arrow"},middle:{enabled:!1,scaleFactor:[1,0,3,.05],type:"arrow"},from:{enabled:!1,scaleFactor:[1,0,3,.05],type:"arrow"}},arrowStrikethrough:!0,color:{color:["color","#848484"],highlight:["color","#848484"],hover:["color","#848484"],inherit:["from","to","both",!0,!1],opacity:[1,0,1,.05]},dashes:!1,font:{color:["color","#343434"],size:[14,0,100,1],face:["arial","verdana","tahoma"],background:["color","none"],strokeWidth:[2,0,50,1],strokeColor:["color","#ffffff"],align:["horizontal","top","middle","bottom"]},hidden:!1,hoverWidth:[1.5,0,5,.1],labelHighlightBold:!0,physics:!0,scaling:{min:[1,0,100,1],max:[15,0,100,1],label:{enabled:!0,min:[14,0,200,1],max:[30,0,200,1],maxVisible:[30,0,200,1],drawThreshold:[5,0,20,1]}},selectionWidth:[1.5,0,5,.1],selfReferenceSize:[20,0,200,1],shadow:{enabled:!1,color:"rgba(0,0,0,0.5)",size:[10,0,20,1],x:[5,-30,30,1],y:[5,-30,30,1]},smooth:{enabled:!0,type:["dynamic","continuous","discrete","diagonalCross","straightCross","horizontal","vertical","curvedCW","curvedCCW","cubicBezier"],forceDirection:["horizontal","vertical","none"],roundness:[.5,0,1,.05]},width:[1,0,30,1]},layout:{hierarchical:{enabled:!1,levelSeparation:[150,20,500,5],nodeSpacing:[100,20,500,5],treeSpacing:[200,20,500,5],blockShifting:!0,edgeMinimization:!0,parentCentralization:!0,direction:["UD","DU","LR","RL"],sortMethod:["hubsize","directed"]}},interaction:{dragNodes:!0,dragView:!0,hideEdgesOnDrag:!1,hideNodesOnDrag:!1,hover:!1,keyboard:{enabled:!1,speed:{x:[10,0,40,1],y:[10,0,40,1],zoom:[.02,0,.1,.005]},bindToWindow:!0},multiselect:!1,navigationButtons:!1,selectable:!0,selectConnectedEdges:!0,hoverConnectedEdges:!0,tooltipDelay:[300,0,1e3,25],zoomView:!0},manipulation:{enabled:!1,initiallyActive:!1},physics:{enabled:!0,barnesHut:{gravitationalConstant:[-2e3,-3e4,0,50],centralGravity:[.3,0,10,.05],springLength:[95,0,500,5],springConstant:[.04,0,1.2,.005],damping:[.09,0,1,.01],avoidOverlap:[0,0,1,.01]},forceAtlas2Based:{gravitationalConstant:[-50,-500,0,1],centralGravity:[.01,0,1,.005],springLength:[95,0,500,5],springConstant:[.08,0,1.2,.005],damping:[.4,0,1,.01],avoidOverlap:[0,0,1,.01]},repulsion:{centralGravity:[.2,0,10,.05],springLength:[200,0,500,5],springConstant:[.05,0,1.2,.005],nodeDistance:[100,0,500,5],damping:[.09,0,1,.01]},hierarchicalRepulsion:{centralGravity:[.2,0,10,.05],springLength:[100,0,500,5],springConstant:[.01,0,1.2,.005],nodeDistance:[120,0,500,5],damping:[.09,0,1,.01]},maxVelocity:[50,0,150,1],minVelocity:[.1,.01,.5,.01],solver:["barnesHut","forceAtlas2Based","repulsion","hierarchicalRepulsion"],timestep:[.5,.01,1,.01]}};e.allOptions=d,e.configureOptions=l},function(t,e,i){function o(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){var i=[],o=!0,n=!1,s=void 0;try{for(var r,a=t[Symbol.iterator]();!(o=(r=a.next()).done)&&(i.push(r.value),!e||i.length!==e);o=!0);}catch(t){n=!0,s=t}finally{try{!o&&a.return&&a.return()}finally{if(n)throw s}}return i}return function(e,i){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),r=function(){function t(t,e){for(var i=0;i2&&void 0!==arguments[2]&&arguments[2],o=this.distanceSolver.getDistances(this.body,t,e);this._createL_matrix(o),this._createK_matrix(o);for(var n=.01,r=1,a=0,h=Math.max(1e3,Math.min(10*this.body.nodeIndices.length,6e3)),d=5,l=1e9,c=0,u=0,p=0,f=0,m=0;l>n&&ar&&m=.1;)p=n[l++%s],p>d&&(p=d),u=Math.sqrt(p*p/(1+h*h)),u=r<0?-u:u,t+=u,e+=h*u,c===!0?this.lineTo(t,e):this.moveTo(t,e),d-=p,c=!c})},function(t,e){function i(t){return P=t,p()}function o(){I=0,N=P.charAt(0)}function n(){I++,N=P.charAt(I)}function s(){return P.charAt(I+1)}function r(t){return z.test(t)}function a(t,e){if(t||(t={}),e)for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t}function h(t,e,i){for(var o=e.split("."),n=t;o.length;){var s=o.shift();o.length?(n[s]||(n[s]={}),n=n[s]):n[s]=i}}function d(t,e){for(var i,o,n=null,s=[t],r=t;r.parent;)s.push(r.parent),r=r.parent;if(r.nodes)for(i=0,o=r.nodes.length;i=0;i--){var h=s[i];h.nodes||(h.nodes=[]),h.nodes.indexOf(n)===-1&&h.nodes.push(n)}e.attr&&(n.attr=a(n.attr,e.attr))}function l(t,e){if(t.edges||(t.edges=[]),t.edges.push(e),t.edge){var i=a({},t.edge);e.attr=a(i,e.attr)}}function c(t,e,i,o,n){var s={from:e,to:i,type:o};return t.edge&&(s.attr=a({},t.edge)),s.attr=a(s.attr||{},n),s}function u(){for(L=E.NULL,R="";" "===N||"\t"===N||"\n"===N||"\r"===N;)n();do{var t=!1;if("#"===N){for(var e=I-1;" "===P.charAt(e)||"\t"===P.charAt(e);)e--;if("\n"===P.charAt(e)||""===P.charAt(e)){for(;""!=N&&"\n"!=N;)n();t=!0}}if("/"===N&&"/"===s()){for(;""!=N&&"\n"!=N;)n();t=!0}if("/"===N&&"*"===s()){for(;""!=N;){if("*"===N&&"/"===s()){n(),n();break}n()}t=!0}for(;" "===N||"\t"===N||"\n"===N||"\r"===N;)n()}while(t);if(""===N)return void(L=E.DELIMITER);var i=N+s();if(M[i])return L=E.DELIMITER,R=i,n(),void n();if(M[N])return L=E.DELIMITER,R=N,void n();if(r(N)||"-"===N){for(R+=N,n();r(N);)R+=N,n();return"false"===R?R=!1:"true"===R?R=!0:isNaN(Number(R))||(R=Number(R)),void(L=E.IDENTIFIER)}if('"'===N){for(n();""!=N&&('"'!=N||'"'===N&&'"'===s());)R+=N,'"'===N&&n(),n();if('"'!=N)throw w('End of string " expected');return n(),void(L=E.IDENTIFIER)}for(L=E.UNKNOWN;""!=N;)R+=N,n();throw new SyntaxError('Syntax error in part "'+x(R,30)+'"')}function p(){var t={};if(o(),u(),"strict"===R&&(t.strict=!0,u()),"graph"!==R&&"digraph"!==R||(t.type=R,u()),L===E.IDENTIFIER&&(t.id=R,u()),"{"!=R)throw w("Angle bracket { expected");if(u(),f(t),"}"!=R)throw w("Angle bracket } expected");if(u(),""!==R)throw w("End of file expected");return u(),delete t.node,delete t.edge,delete t.graph,t}function f(t){for(;""!==R&&"}"!=R;)m(t),";"===R&&u()}function m(t){var e=v(t);if(e)return void b(t,e);var i=g(t);if(!i){if(L!=E.IDENTIFIER)throw w("Identifier expected");var o=R;if(u(),"="===R){if(u(),L!=E.IDENTIFIER)throw w("Identifier expected");t[o]=R,u()}else y(t,o)}}function v(t){var e=null;if("subgraph"===R&&(e={},e.type="subgraph",u(),L===E.IDENTIFIER&&(e.id=R,u())),"{"===R){if(u(),e||(e={}),e.parent=t,e.node=t.node,e.edge=t.edge,e.graph=t.graph,f(e),"}"!=R)throw w("Angle bracket } expected");u(),delete e.node,delete e.edge,delete e.graph,delete e.parent,t.subgraphs||(t.subgraphs=[]),t.subgraphs.push(e)}return e}function g(t){return"node"===R?(u(),t.node=_(),"node"):"edge"===R?(u(),t.edge=_(),"edge"):"graph"===R?(u(),t.graph=_(),"graph"):null}function y(t,e){var i={id:e},o=_();o&&(i.attr=o),d(t,i),b(t,e)}function b(t,e){for(;"->"===R||"--"===R;){var i,o=R;u();var n=v(t);if(n)i=n;else{if(L!=E.IDENTIFIER)throw w("Identifier or subgraph expected");i=R,d(t,{id:i}),u()}var s=_(),r=c(t,e,i,o,s);l(t,r),e=i}}function _(){for(var t=null;"["===R;){for(u(),t={};""!==R&&"]"!=R;){if(L!=E.IDENTIFIER)throw w("Attribute name expected");var e=R;if(u(),"="!=R)throw w("Equal sign = expected");if(u(),L!=E.IDENTIFIER)throw w("Attribute value expected");var i=R;h(t,e,i),u(),","==R&&u()}if("]"!=R)throw w("Bracket ] expected");u()}return t}function w(t){return new SyntaxError(t+', got "'+x(R,30)+'" (char '+I+")")}function x(t,e){return t.length<=e?t:t.substr(0,27)+"..."}function k(t,e,i){Array.isArray(t)?t.forEach(function(t){Array.isArray(e)?e.forEach(function(e){i(t,e)}):i(t,e)}):Array.isArray(e)?e.forEach(function(e){i(t,e)}):i(t,e)}function O(t,e,i){for(var o=e.split("."),n=o.pop(),s=t,r=0;r":!0,"--":!0},P="",I=0,N="",R="",L=E.NULL,z=/[a-zA-Z_0-9.:#]/;e.parseDOT=i,e.DOTToGraph=S},function(t,e){function i(t,e){var i=[],o=[],n={edges:{inheritColor:!1},nodes:{fixed:!1,parseColor:!1}};void 0!==e&&(void 0!==e.fixed&&(n.nodes.fixed=e.fixed),void 0!==e.parseColor&&(n.nodes.parseColor=e.parseColor),void 0!==e.inheritColor&&(n.edges.inheritColor=e.inheritColor));for(var s=t.edges,r=t.nodes,a=0;a= 0 && length <= MAX_ARRAY_INDEX; + }; + + // Collection Functions + // -------------------- + + // The cornerstone, an `each` implementation, aka `forEach`. + // Handles raw objects in addition to array-likes. Treats all + // sparse array-likes as if they were dense. + _.each = _.forEach = function (obj, iteratee, context) { + iteratee = optimizeCb(iteratee, context); + var i, length; + if (isArrayLike(obj)) { + for (i = 0, length = obj.length; i < length; i++) { + iteratee(obj[i], i, obj); + } + } else { + var keys = _.keys(obj); + for (i = 0, length = keys.length; i < length; i++) { + iteratee(obj[keys[i]], keys[i], obj); + } + } + return obj; + }; + + // Return the results of applying the iteratee to each element. + _.map = _.collect = function (obj, iteratee, context) { + iteratee = cb(iteratee, context); + var keys = !isArrayLike(obj) && _.keys(obj), + length = (keys || obj).length, + results = Array(length); + for (var index = 0; index < length; index++) { + var currentKey = keys ? keys[index] : index; + results[index] = iteratee(obj[currentKey], currentKey, obj); + } + return results; + }; + + // Create a reducing function iterating left or right. + function createReduce(dir) { + // Optimized iterator function as using arguments.length + // in the main function will deoptimize the, see #1991. + function iterator(obj, iteratee, memo, keys, index, length) { + for (; index >= 0 && index < length; index += dir) { + var currentKey = keys ? keys[index] : index; + memo = iteratee(memo, obj[currentKey], currentKey, obj); + } + return memo; + } + + return function (obj, iteratee, memo, context) { + iteratee = optimizeCb(iteratee, context, 4); + var keys = !isArrayLike(obj) && _.keys(obj), + length = (keys || obj).length, + index = dir > 0 ? 0 : length - 1; + // Determine the initial value if none is provided. + if (arguments.length < 3) { + memo = obj[keys ? keys[index] : index]; + index += dir; + } + return iterator(obj, iteratee, memo, keys, index, length); + }; + } + + // **Reduce** builds up a single result from a list of values, aka `inject`, + // or `foldl`. + _.reduce = _.foldl = _.inject = createReduce(1); + + // The right-associative version of reduce, also known as `foldr`. + _.reduceRight = _.foldr = createReduce(-1); + + // Return the first value which passes a truth test. Aliased as `detect`. + _.find = _.detect = function (obj, predicate, context) { + var key; + if (isArrayLike(obj)) { + key = _.findIndex(obj, predicate, context); + } else { + key = _.findKey(obj, predicate, context); + } + if (key !== void 0 && key !== -1) return obj[key]; + }; + + // Return all the elements that pass a truth test. + // Aliased as `select`. + _.filter = _.select = function (obj, predicate, context) { + var results = []; + predicate = cb(predicate, context); + _.each(obj, function (value, index, list) { + if (predicate(value, index, list)) results.push(value); + }); + return results; + }; + + // Return all the elements for which a truth test fails. + _.reject = function (obj, predicate, context) { + return _.filter(obj, _.negate(cb(predicate)), context); + }; + + // Determine whether all of the elements match a truth test. + // Aliased as `all`. + _.every = _.all = function (obj, predicate, context) { + predicate = cb(predicate, context); + var keys = !isArrayLike(obj) && _.keys(obj), + length = (keys || obj).length; + for (var index = 0; index < length; index++) { + var currentKey = keys ? keys[index] : index; + if (!predicate(obj[currentKey], currentKey, obj)) return false; + } + return true; + }; + + // Determine if at least one element in the object matches a truth test. + // Aliased as `any`. + _.some = _.any = function (obj, predicate, context) { + predicate = cb(predicate, context); + var keys = !isArrayLike(obj) && _.keys(obj), + length = (keys || obj).length; + for (var index = 0; index < length; index++) { + var currentKey = keys ? keys[index] : index; + if (predicate(obj[currentKey], currentKey, obj)) return true; + } + return false; + }; + + // Determine if the array or object contains a given item (using `===`). + // Aliased as `includes` and `include`. + _.contains = _.includes = _.include = function (obj, item, fromIndex, guard) { + if (!isArrayLike(obj)) obj = _.values(obj); + if (typeof fromIndex != 'number' || guard) fromIndex = 0; + return _.indexOf(obj, item, fromIndex) >= 0; + }; + + // Invoke a method (with arguments) on every item in a collection. + _.invoke = function (obj, method) { + var args = slice.call(arguments, 2); + var isFunc = _.isFunction(method); + return _.map(obj, function (value) { + var func = isFunc ? method : value[method]; + return func == null ? func : func.apply(value, args); + }); + }; + + // Convenience version of a common use case of `map`: fetching a property. + _.pluck = function (obj, key) { + return _.map(obj, _.property(key)); + }; + + // Convenience version of a common use case of `filter`: selecting only objects + // containing specific `key:value` pairs. + _.where = function (obj, attrs) { + return _.filter(obj, _.matcher(attrs)); + }; + + // Convenience version of a common use case of `find`: getting the first object + // containing specific `key:value` pairs. + _.findWhere = function (obj, attrs) { + return _.find(obj, _.matcher(attrs)); + }; + + // Return the maximum element (or element-based computation). + _.max = function (obj, iteratee, context) { + var result = -Infinity, + lastComputed = -Infinity, + value, + computed; + if (iteratee == null && obj != null) { + obj = isArrayLike(obj) ? obj : _.values(obj); + for (var i = 0, length = obj.length; i < length; i++) { + value = obj[i]; + if (value > result) { + result = value; + } + } + } else { + iteratee = cb(iteratee, context); + _.each(obj, function (value, index, list) { + computed = iteratee(value, index, list); + if (computed > lastComputed || computed === -Infinity && result === -Infinity) { + result = value; + lastComputed = computed; + } + }); + } + return result; + }; + + // Return the minimum element (or element-based computation). + _.min = function (obj, iteratee, context) { + var result = Infinity, + lastComputed = Infinity, + value, + computed; + if (iteratee == null && obj != null) { + obj = isArrayLike(obj) ? obj : _.values(obj); + for (var i = 0, length = obj.length; i < length; i++) { + value = obj[i]; + if (value < result) { + result = value; + } + } + } else { + iteratee = cb(iteratee, context); + _.each(obj, function (value, index, list) { + computed = iteratee(value, index, list); + if (computed < lastComputed || computed === Infinity && result === Infinity) { + result = value; + lastComputed = computed; + } + }); + } + return result; + }; + + // Shuffle a collection, using the modern version of the + // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle). + _.shuffle = function (obj) { + var set = isArrayLike(obj) ? obj : _.values(obj); + var length = set.length; + var shuffled = Array(length); + for (var index = 0, rand; index < length; index++) { + rand = _.random(0, index); + if (rand !== index) shuffled[index] = shuffled[rand]; + shuffled[rand] = set[index]; + } + return shuffled; + }; + + // Sample **n** random values from a collection. + // If **n** is not specified, returns a single random element. + // The internal `guard` argument allows it to work with `map`. + _.sample = function (obj, n, guard) { + if (n == null || guard) { + if (!isArrayLike(obj)) obj = _.values(obj); + return obj[_.random(obj.length - 1)]; + } + return _.shuffle(obj).slice(0, Math.max(0, n)); + }; + + // Sort the object's values by a criterion produced by an iteratee. + _.sortBy = function (obj, iteratee, context) { + iteratee = cb(iteratee, context); + return _.pluck(_.map(obj, function (value, index, list) { + return { + value: value, + index: index, + criteria: iteratee(value, index, list) + }; + }).sort(function (left, right) { + var a = left.criteria; + var b = right.criteria; + if (a !== b) { + if (a > b || a === void 0) return 1; + if (a < b || b === void 0) return -1; + } + return left.index - right.index; + }), 'value'); + }; + + // An internal function used for aggregate "group by" operations. + var group = function group(behavior) { + return function (obj, iteratee, context) { + var result = {}; + iteratee = cb(iteratee, context); + _.each(obj, function (value, index) { + var key = iteratee(value, index, obj); + behavior(result, value, key); + }); + return result; + }; + }; + + // Groups the object's values by a criterion. Pass either a string attribute + // to group by, or a function that returns the criterion. + _.groupBy = group(function (result, value, key) { + if (_.has(result, key)) result[key].push(value);else result[key] = [value]; + }); + + // Indexes the object's values by a criterion, similar to `groupBy`, but for + // when you know that your index values will be unique. + _.indexBy = group(function (result, value, key) { + result[key] = value; + }); + + // Counts instances of an object that group by a certain criterion. Pass + // either a string attribute to count by, or a function that returns the + // criterion. + _.countBy = group(function (result, value, key) { + if (_.has(result, key)) result[key]++;else result[key] = 1; + }); + + // Safely create a real, live array from anything iterable. + _.toArray = function (obj) { + if (!obj) return []; + if (_.isArray(obj)) return slice.call(obj); + if (isArrayLike(obj)) return _.map(obj, _.identity); + return _.values(obj); + }; + + // Return the number of elements in an object. + _.size = function (obj) { + if (obj == null) return 0; + return isArrayLike(obj) ? obj.length : _.keys(obj).length; + }; + + // Split a collection into two arrays: one whose elements all satisfy the given + // predicate, and one whose elements all do not satisfy the predicate. + _.partition = function (obj, predicate, context) { + predicate = cb(predicate, context); + var pass = [], + fail = []; + _.each(obj, function (value, key, obj) { + (predicate(value, key, obj) ? pass : fail).push(value); + }); + return [pass, fail]; + }; + + // Array Functions + // --------------- + + // Get the first element of an array. Passing **n** will return the first N + // values in the array. Aliased as `head` and `take`. The **guard** check + // allows it to work with `_.map`. + _.first = _.head = _.take = function (array, n, guard) { + if (array == null) return void 0; + if (n == null || guard) return array[0]; + return _.initial(array, array.length - n); + }; + + // Returns everything but the last entry of the array. Especially useful on + // the arguments object. Passing **n** will return all the values in + // the array, excluding the last N. + _.initial = function (array, n, guard) { + return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n))); + }; + + // Get the last element of an array. Passing **n** will return the last N + // values in the array. + _.last = function (array, n, guard) { + if (array == null) return void 0; + if (n == null || guard) return array[array.length - 1]; + return _.rest(array, Math.max(0, array.length - n)); + }; + + // Returns everything but the first entry of the array. Aliased as `tail` and `drop`. + // Especially useful on the arguments object. Passing an **n** will return + // the rest N values in the array. + _.rest = _.tail = _.drop = function (array, n, guard) { + return slice.call(array, n == null || guard ? 1 : n); + }; + + // Trim out all falsy values from an array. + _.compact = function (array) { + return _.filter(array, _.identity); + }; + + // Internal implementation of a recursive `flatten` function. + var flatten = function flatten(input, shallow, strict, startIndex) { + var output = [], + idx = 0; + for (var i = startIndex || 0, length = getLength(input); i < length; i++) { + var value = input[i]; + if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) { + //flatten current level of array or arguments object + if (!shallow) value = flatten(value, shallow, strict); + var j = 0, + len = value.length; + output.length += len; + while (j < len) { + output[idx++] = value[j++]; + } + } else if (!strict) { + output[idx++] = value; + } + } + return output; + }; + + // Flatten out an array, either recursively (by default), or just one level. + _.flatten = function (array, shallow) { + return flatten(array, shallow, false); + }; + + // Return a version of the array that does not contain the specified value(s). + _.without = function (array) { + return _.difference(array, slice.call(arguments, 1)); + }; + + // Produce a duplicate-free version of the array. If the array has already + // been sorted, you have the option of using a faster algorithm. + // Aliased as `unique`. + _.uniq = _.unique = function (array, isSorted, iteratee, context) { + if (!_.isBoolean(isSorted)) { + context = iteratee; + iteratee = isSorted; + isSorted = false; + } + if (iteratee != null) iteratee = cb(iteratee, context); + var result = []; + var seen = []; + for (var i = 0, length = getLength(array); i < length; i++) { + var value = array[i], + computed = iteratee ? iteratee(value, i, array) : value; + if (isSorted) { + if (!i || seen !== computed) result.push(value); + seen = computed; + } else if (iteratee) { + if (!_.contains(seen, computed)) { + seen.push(computed); + result.push(value); + } + } else if (!_.contains(result, value)) { + result.push(value); + } + } + return result; + }; + + // Produce an array that contains the union: each distinct element from all of + // the passed-in arrays. + _.union = function () { + return _.uniq(flatten(arguments, true, true)); + }; + + // Produce an array that contains every item shared between all the + // passed-in arrays. + _.intersection = function (array) { + var result = []; + var argsLength = arguments.length; + for (var i = 0, length = getLength(array); i < length; i++) { + var item = array[i]; + if (_.contains(result, item)) continue; + for (var j = 1; j < argsLength; j++) { + if (!_.contains(arguments[j], item)) break; + } + if (j === argsLength) result.push(item); + } + return result; + }; + + // Take the difference between one array and a number of other arrays. + // Only the elements present in just the first array will remain. + _.difference = function (array) { + var rest = flatten(arguments, true, true, 1); + return _.filter(array, function (value) { + return !_.contains(rest, value); + }); + }; + + // Zip together multiple lists into a single array -- elements that share + // an index go together. + _.zip = function () { + return _.unzip(arguments); + }; + + // Complement of _.zip. Unzip accepts an array of arrays and groups + // each array's elements on shared indices + _.unzip = function (array) { + var length = array && _.max(array, getLength).length || 0; + var result = Array(length); + + for (var index = 0; index < length; index++) { + result[index] = _.pluck(array, index); + } + return result; + }; + + // Converts lists into objects. Pass either a single array of `[key, value]` + // pairs, or two parallel arrays of the same length -- one of keys, and one of + // the corresponding values. + _.object = function (list, values) { + var result = {}; + for (var i = 0, length = getLength(list); i < length; i++) { + if (values) { + result[list[i]] = values[i]; + } else { + result[list[i][0]] = list[i][1]; + } + } + return result; + }; + + // Generator function to create the findIndex and findLastIndex functions + function createPredicateIndexFinder(dir) { + return function (array, predicate, context) { + predicate = cb(predicate, context); + var length = getLength(array); + var index = dir > 0 ? 0 : length - 1; + for (; index >= 0 && index < length; index += dir) { + if (predicate(array[index], index, array)) return index; + } + return -1; + }; + } + + // Returns the first index on an array-like that passes a predicate test + _.findIndex = createPredicateIndexFinder(1); + _.findLastIndex = createPredicateIndexFinder(-1); + + // Use a comparator function to figure out the smallest index at which + // an object should be inserted so as to maintain order. Uses binary search. + _.sortedIndex = function (array, obj, iteratee, context) { + iteratee = cb(iteratee, context, 1); + var value = iteratee(obj); + var low = 0, + high = getLength(array); + while (low < high) { + var mid = Math.floor((low + high) / 2); + if (iteratee(array[mid]) < value) low = mid + 1;else high = mid; + } + return low; + }; + + // Generator function to create the indexOf and lastIndexOf functions + function createIndexFinder(dir, predicateFind, sortedIndex) { + return function (array, item, idx) { + var i = 0, + length = getLength(array); + if (typeof idx == 'number') { + if (dir > 0) { + i = idx >= 0 ? idx : Math.max(idx + length, i); + } else { + length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1; + } + } else if (sortedIndex && idx && length) { + idx = sortedIndex(array, item); + return array[idx] === item ? idx : -1; + } + if (item !== item) { + idx = predicateFind(slice.call(array, i, length), _.isNaN); + return idx >= 0 ? idx + i : -1; + } + for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) { + if (array[idx] === item) return idx; + } + return -1; + }; + } + + // Return the position of the first occurrence of an item in an array, + // or -1 if the item is not included in the array. + // If the array is large and already in sort order, pass `true` + // for **isSorted** to use binary search. + _.indexOf = createIndexFinder(1, _.findIndex, _.sortedIndex); + _.lastIndexOf = createIndexFinder(-1, _.findLastIndex); + + // Generate an integer Array containing an arithmetic progression. A port of + // the native Python `range()` function. See + // [the Python documentation](http://docs.python.org/library/functions.html#range). + _.range = function (start, stop, step) { + if (stop == null) { + stop = start || 0; + start = 0; + } + step = step || 1; + + var length = Math.max(Math.ceil((stop - start) / step), 0); + var range = Array(length); + + for (var idx = 0; idx < length; idx++, start += step) { + range[idx] = start; + } + + return range; + }; + + // Function (ahem) Functions + // ------------------ + + // Determines whether to execute a function as a constructor + // or a normal function with the provided arguments + var executeBound = function executeBound(sourceFunc, boundFunc, context, callingContext, args) { + if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args); + var self = baseCreate(sourceFunc.prototype); + var result = sourceFunc.apply(self, args); + if (_.isObject(result)) return result; + return self; + }; + + // Create a function bound to a given object (assigning `this`, and arguments, + // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if + // available. + _.bind = function (func, context) { + if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); + if (!_.isFunction(func)) throw new TypeError('Bind must be called on a function'); + var args = slice.call(arguments, 2); + var bound = function bound() { + return executeBound(func, bound, context, this, args.concat(slice.call(arguments))); + }; + return bound; + }; + + // Partially apply a function by creating a version that has had some of its + // arguments pre-filled, without changing its dynamic `this` context. _ acts + // as a placeholder, allowing any combination of arguments to be pre-filled. + _.partial = function (func) { + var boundArgs = slice.call(arguments, 1); + var bound = function bound() { + var position = 0, + length = boundArgs.length; + var args = Array(length); + for (var i = 0; i < length; i++) { + args[i] = boundArgs[i] === _ ? arguments[position++] : boundArgs[i]; + } + while (position < arguments.length) { + args.push(arguments[position++]); + }return executeBound(func, bound, this, this, args); + }; + return bound; + }; + + // Bind a number of an object's methods to that object. Remaining arguments + // are the method names to be bound. Useful for ensuring that all callbacks + // defined on an object belong to it. + _.bindAll = function (obj) { + var i, + length = arguments.length, + key; + if (length <= 1) throw new Error('bindAll must be passed function names'); + for (i = 1; i < length; i++) { + key = arguments[i]; + obj[key] = _.bind(obj[key], obj); + } + return obj; + }; + + // Memoize an expensive function by storing its results. + _.memoize = function (func, hasher) { + var memoize = function memoize(key) { + var cache = memoize.cache; + var address = '' + (hasher ? hasher.apply(this, arguments) : key); + if (!_.has(cache, address)) cache[address] = func.apply(this, arguments); + return cache[address]; + }; + memoize.cache = {}; + return memoize; + }; + + // Delays a function for the given number of milliseconds, and then calls + // it with the arguments supplied. + _.delay = function (func, wait) { + var args = slice.call(arguments, 2); + return setTimeout(function () { + return func.apply(null, args); + }, wait); + }; + + // Defers a function, scheduling it to run after the current call stack has + // cleared. + _.defer = _.partial(_.delay, _, 1); + + // Returns a function, that, when invoked, will only be triggered at most once + // during a given window of time. Normally, the throttled function will run + // as much as it can, without ever going more than once per `wait` duration; + // but if you'd like to disable the execution on the leading edge, pass + // `{leading: false}`. To disable execution on the trailing edge, ditto. + _.throttle = function (func, wait, options) { + var context, args, result; + var timeout = null; + var previous = 0; + if (!options) options = {}; + var later = function later() { + previous = options.leading === false ? 0 : _.now(); + timeout = null; + result = func.apply(context, args); + if (!timeout) context = args = null; + }; + return function () { + var now = _.now(); + if (!previous && options.leading === false) previous = now; + var remaining = wait - (now - previous); + context = this; + args = arguments; + if (remaining <= 0 || remaining > wait) { + if (timeout) { + clearTimeout(timeout); + timeout = null; + } + previous = now; + result = func.apply(context, args); + if (!timeout) context = args = null; + } else if (!timeout && options.trailing !== false) { + timeout = setTimeout(later, remaining); + } + return result; + }; + }; + + // Returns a function, that, as long as it continues to be invoked, will not + // be triggered. The function will be called after it stops being called for + // N milliseconds. If `immediate` is passed, trigger the function on the + // leading edge, instead of the trailing. + _.debounce = function (func, wait, immediate) { + var timeout, args, context, timestamp, result; + + var later = function later() { + var last = _.now() - timestamp; + + if (last < wait && last >= 0) { + timeout = setTimeout(later, wait - last); + } else { + timeout = null; + if (!immediate) { + result = func.apply(context, args); + if (!timeout) context = args = null; + } + } + }; + + return function () { + context = this; + args = arguments; + timestamp = _.now(); + var callNow = immediate && !timeout; + if (!timeout) timeout = setTimeout(later, wait); + if (callNow) { + result = func.apply(context, args); + context = args = null; + } + + return result; + }; + }; + + // Returns the first function passed as an argument to the second, + // allowing you to adjust arguments, run code before and after, and + // conditionally execute the original function. + _.wrap = function (func, wrapper) { + return _.partial(wrapper, func); + }; + + // Returns a negated version of the passed-in predicate. + _.negate = function (predicate) { + return function () { + return !predicate.apply(this, arguments); + }; + }; + + // Returns a function that is the composition of a list of functions, each + // consuming the return value of the function that follows. + _.compose = function () { + var args = arguments; + var start = args.length - 1; + return function () { + var i = start; + var result = args[start].apply(this, arguments); + while (i--) { + result = args[i].call(this, result); + }return result; + }; + }; + + // Returns a function that will only be executed on and after the Nth call. + _.after = function (times, func) { + return function () { + if (--times < 1) { + return func.apply(this, arguments); + } + }; + }; + + // Returns a function that will only be executed up to (but not including) the Nth call. + _.before = function (times, func) { + var memo; + return function () { + if (--times > 0) { + memo = func.apply(this, arguments); + } + if (times <= 1) func = null; + return memo; + }; + }; + + // Returns a function that will be executed at most one time, no matter how + // often you call it. Useful for lazy initialization. + _.once = _.partial(_.before, 2); + + // Object Functions + // ---------------- + + // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed. + var hasEnumBug = !{ toString: null }.propertyIsEnumerable('toString'); + var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString', 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; + + function collectNonEnumProps(obj, keys) { + var nonEnumIdx = nonEnumerableProps.length; + var constructor = obj.constructor; + var proto = _.isFunction(constructor) && constructor.prototype || ObjProto; + + // Constructor is a special case. + var prop = 'constructor'; + if (_.has(obj, prop) && !_.contains(keys, prop)) keys.push(prop); + + while (nonEnumIdx--) { + prop = nonEnumerableProps[nonEnumIdx]; + if (prop in obj && obj[prop] !== proto[prop] && !_.contains(keys, prop)) { + keys.push(prop); + } + } + } + + // Retrieve the names of an object's own properties. + // Delegates to **ECMAScript 5**'s native `Object.keys` + _.keys = function (obj) { + if (!_.isObject(obj)) return []; + if (nativeKeys) return nativeKeys(obj); + var keys = []; + for (var key in obj) { + if (_.has(obj, key)) keys.push(key); + } // Ahem, IE < 9. + if (hasEnumBug) collectNonEnumProps(obj, keys); + return keys; + }; + + // Retrieve all the property names of an object. + _.allKeys = function (obj) { + if (!_.isObject(obj)) return []; + var keys = []; + for (var key in obj) { + keys.push(key); + } // Ahem, IE < 9. + if (hasEnumBug) collectNonEnumProps(obj, keys); + return keys; + }; + + // Retrieve the values of an object's properties. + _.values = function (obj) { + var keys = _.keys(obj); + var length = keys.length; + var values = Array(length); + for (var i = 0; i < length; i++) { + values[i] = obj[keys[i]]; + } + return values; + }; + + // Returns the results of applying the iteratee to each element of the object + // In contrast to _.map it returns an object + _.mapObject = function (obj, iteratee, context) { + iteratee = cb(iteratee, context); + var keys = _.keys(obj), + length = keys.length, + results = {}, + currentKey; + for (var index = 0; index < length; index++) { + currentKey = keys[index]; + results[currentKey] = iteratee(obj[currentKey], currentKey, obj); + } + return results; + }; + + // Convert an object into a list of `[key, value]` pairs. + _.pairs = function (obj) { + var keys = _.keys(obj); + var length = keys.length; + var pairs = Array(length); + for (var i = 0; i < length; i++) { + pairs[i] = [keys[i], obj[keys[i]]]; + } + return pairs; + }; + + // Invert the keys and values of an object. The values must be serializable. + _.invert = function (obj) { + var result = {}; + var keys = _.keys(obj); + for (var i = 0, length = keys.length; i < length; i++) { + result[obj[keys[i]]] = keys[i]; + } + return result; + }; + + // Return a sorted list of the function names available on the object. + // Aliased as `methods` + _.functions = _.methods = function (obj) { + var names = []; + for (var key in obj) { + if (_.isFunction(obj[key])) names.push(key); + } + return names.sort(); + }; + + // Extend a given object with all the properties in passed-in object(s). + _.extend = createAssigner(_.allKeys); + + // Assigns a given object with all the own properties in the passed-in object(s) + // (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) + _.extendOwn = _.assign = createAssigner(_.keys); + + // Returns the first key on an object that passes a predicate test + _.findKey = function (obj, predicate, context) { + predicate = cb(predicate, context); + var keys = _.keys(obj), + key; + for (var i = 0, length = keys.length; i < length; i++) { + key = keys[i]; + if (predicate(obj[key], key, obj)) return key; + } + }; + + // Return a copy of the object only containing the whitelisted properties. + _.pick = function (object, oiteratee, context) { + var result = {}, + obj = object, + iteratee, + keys; + if (obj == null) return result; + if (_.isFunction(oiteratee)) { + keys = _.allKeys(obj); + iteratee = optimizeCb(oiteratee, context); + } else { + keys = flatten(arguments, false, false, 1); + iteratee = function iteratee(value, key, obj) { + return key in obj; + }; + obj = Object(obj); + } + for (var i = 0, length = keys.length; i < length; i++) { + var key = keys[i]; + var value = obj[key]; + if (iteratee(value, key, obj)) result[key] = value; + } + return result; + }; + + // Return a copy of the object without the blacklisted properties. + _.omit = function (obj, iteratee, context) { + if (_.isFunction(iteratee)) { + iteratee = _.negate(iteratee); + } else { + var keys = _.map(flatten(arguments, false, false, 1), String); + iteratee = function iteratee(value, key) { + return !_.contains(keys, key); + }; + } + return _.pick(obj, iteratee, context); + }; + + // Fill in a given object with default properties. + _.defaults = createAssigner(_.allKeys, true); + + // Creates an object that inherits from the given prototype object. + // If additional properties are provided then they will be added to the + // created object. + _.create = function (prototype, props) { + var result = baseCreate(prototype); + if (props) _.extendOwn(result, props); + return result; + }; + + // Create a (shallow-cloned) duplicate of an object. + _.clone = function (obj) { + if (!_.isObject(obj)) return obj; + return _.isArray(obj) ? obj.slice() : _.extend({}, obj); + }; + + // Invokes interceptor with the obj, and then returns obj. + // The primary purpose of this method is to "tap into" a method chain, in + // order to perform operations on intermediate results within the chain. + _.tap = function (obj, interceptor) { + interceptor(obj); + return obj; + }; + + // Returns whether an object has a given set of `key:value` pairs. + _.isMatch = function (object, attrs) { + var keys = _.keys(attrs), + length = keys.length; + if (object == null) return !length; + var obj = Object(object); + for (var i = 0; i < length; i++) { + var key = keys[i]; + if (attrs[key] !== obj[key] || !(key in obj)) return false; + } + return true; + }; + + // Internal recursive comparison function for `isEqual`. + var eq = function eq(a, b, aStack, bStack) { + // Identical objects are equal. `0 === -0`, but they aren't identical. + // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal). + if (a === b) return a !== 0 || 1 / a === 1 / b; + // A strict comparison is necessary because `null == undefined`. + if (a == null || b == null) return a === b; + // Unwrap any wrapped objects. + if (a instanceof _) a = a._wrapped; + if (b instanceof _) b = b._wrapped; + // Compare `[[Class]]` names. + var className = toString.call(a); + if (className !== toString.call(b)) return false; + switch (className) { + // Strings, numbers, regular expressions, dates, and booleans are compared by value. + case '[object RegExp]': + // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i') + case '[object String]': + // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is + // equivalent to `new String("5")`. + return '' + a === '' + b; + case '[object Number]': + // `NaN`s are equivalent, but non-reflexive. + // Object(NaN) is equivalent to NaN + if (+a !== +a) return +b !== +b; + // An `egal` comparison is performed for other numeric values. + return +a === 0 ? 1 / +a === 1 / b : +a === +b; + case '[object Date]': + case '[object Boolean]': + // Coerce dates and booleans to numeric primitive values. Dates are compared by their + // millisecond representations. Note that invalid dates with millisecond representations + // of `NaN` are not equivalent. + return +a === +b; + } + + var areArrays = className === '[object Array]'; + if (!areArrays) { + if ((typeof a === 'undefined' ? 'undefined' : _typeof(a)) != 'object' || (typeof b === 'undefined' ? 'undefined' : _typeof(b)) != 'object') return false; + + // Objects with different constructors are not equivalent, but `Object`s or `Array`s + // from different frames are. + var aCtor = a.constructor, + bCtor = b.constructor; + if (aCtor !== bCtor && !(_.isFunction(aCtor) && aCtor instanceof aCtor && _.isFunction(bCtor) && bCtor instanceof bCtor) && 'constructor' in a && 'constructor' in b) { + return false; + } + } + // Assume equality for cyclic structures. The algorithm for detecting cyclic + // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. + + // Initializing stack of traversed objects. + // It's done here since we only need them for objects and arrays comparison. + aStack = aStack || []; + bStack = bStack || []; + var length = aStack.length; + while (length--) { + // Linear search. Performance is inversely proportional to the number of + // unique nested structures. + if (aStack[length] === a) return bStack[length] === b; + } + + // Add the first object to the stack of traversed objects. + aStack.push(a); + bStack.push(b); + + // Recursively compare objects and arrays. + if (areArrays) { + // Compare array lengths to determine if a deep comparison is necessary. + length = a.length; + if (length !== b.length) return false; + // Deep compare the contents, ignoring non-numeric properties. + while (length--) { + if (!eq(a[length], b[length], aStack, bStack)) return false; + } + } else { + // Deep compare objects. + var keys = _.keys(a), + key; + length = keys.length; + // Ensure that both objects contain the same number of properties before comparing deep equality. + if (_.keys(b).length !== length) return false; + while (length--) { + // Deep compare each member + key = keys[length]; + if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) return false; + } + } + // Remove the first object from the stack of traversed objects. + aStack.pop(); + bStack.pop(); + return true; + }; + + // Perform a deep comparison to check if two objects are equal. + _.isEqual = function (a, b) { + return eq(a, b); + }; + + // Is a given array, string, or object empty? + // An "empty" object has no enumerable own-properties. + _.isEmpty = function (obj) { + if (obj == null) return true; + if (isArrayLike(obj) && (_.isArray(obj) || _.isString(obj) || _.isArguments(obj))) return obj.length === 0; + return _.keys(obj).length === 0; + }; + + // Is a given value a DOM element? + _.isElement = function (obj) { + return !!(obj && obj.nodeType === 1); + }; + + // Is a given value an array? + // Delegates to ECMA5's native Array.isArray + _.isArray = nativeIsArray || function (obj) { + return toString.call(obj) === '[object Array]'; + }; + + // Is a given variable an object? + _.isObject = function (obj) { + var type = typeof obj === 'undefined' ? 'undefined' : _typeof(obj); + return type === 'function' || type === 'object' && !!obj; + }; + + // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError. + _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error'], function (name) { + _['is' + name] = function (obj) { + return toString.call(obj) === '[object ' + name + ']'; + }; + }); + + // Define a fallback version of the method in browsers (ahem, IE < 9), where + // there isn't any inspectable "Arguments" type. + if (!_.isArguments(arguments)) { + _.isArguments = function (obj) { + return _.has(obj, 'callee'); + }; + } + + // Optimize `isFunction` if appropriate. Work around some typeof bugs in old v8, + // IE 11 (#1621), and in Safari 8 (#1929). + if (typeof /./ != 'function' && (typeof Int8Array === 'undefined' ? 'undefined' : _typeof(Int8Array)) != 'object') { + _.isFunction = function (obj) { + return typeof obj == 'function' || false; + }; + } + + // Is a given object a finite number? + _.isFinite = function (obj) { + return isFinite(obj) && !isNaN(parseFloat(obj)); + }; + + // Is the given value `NaN`? (NaN is the only number which does not equal itself). + _.isNaN = function (obj) { + return _.isNumber(obj) && obj !== +obj; + }; + + // Is a given value a boolean? + _.isBoolean = function (obj) { + return obj === true || obj === false || toString.call(obj) === '[object Boolean]'; + }; + + // Is a given value equal to null? + _.isNull = function (obj) { + return obj === null; + }; + + // Is a given variable undefined? + _.isUndefined = function (obj) { + return obj === void 0; + }; + + // Shortcut function for checking if an object has a given property directly + // on itself (in other words, not on a prototype). + _.has = function (obj, key) { + return obj != null && hasOwnProperty.call(obj, key); + }; + + // Utility Functions + // ----------------- + + // Run Underscore.js in *noConflict* mode, returning the `_` variable to its + // previous owner. Returns a reference to the Underscore object. + _.noConflict = function () { + root._ = previousUnderscore; + return this; + }; + + // Keep the identity function around for default iteratees. + _.identity = function (value) { + return value; + }; + + // Predicate-generating functions. Often useful outside of Underscore. + _.constant = function (value) { + return function () { + return value; + }; + }; + + _.noop = function () {}; + + _.property = property; + + // Generates a function for a given object that returns a given property. + _.propertyOf = function (obj) { + return obj == null ? function () {} : function (key) { + return obj[key]; + }; + }; + + // Returns a predicate for checking whether an object has a given set of + // `key:value` pairs. + _.matcher = _.matches = function (attrs) { + attrs = _.extendOwn({}, attrs); + return function (obj) { + return _.isMatch(obj, attrs); + }; + }; + + // Run a function **n** times. + _.times = function (n, iteratee, context) { + var accum = Array(Math.max(0, n)); + iteratee = optimizeCb(iteratee, context, 1); + for (var i = 0; i < n; i++) { + accum[i] = iteratee(i); + }return accum; + }; + + // Return a random integer between min and max (inclusive). + _.random = function (min, max) { + if (max == null) { + max = min; + min = 0; + } + return min + Math.floor(Math.random() * (max - min + 1)); + }; + + // A (possibly faster) way to get the current timestamp as an integer. + _.now = Date.now || function () { + return new Date().getTime(); + }; + + // List of HTML entities for escaping. + var escapeMap = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''', + '`': '`' + }; + var unescapeMap = _.invert(escapeMap); + + // Functions for escaping and unescaping strings to/from HTML interpolation. + var createEscaper = function createEscaper(map) { + var escaper = function escaper(match) { + return map[match]; + }; + // Regexes for identifying a key that needs to be escaped + var source = '(?:' + _.keys(map).join('|') + ')'; + var testRegexp = RegExp(source); + var replaceRegexp = RegExp(source, 'g'); + return function (string) { + string = string == null ? '' : '' + string; + return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string; + }; + }; + _.escape = createEscaper(escapeMap); + _.unescape = createEscaper(unescapeMap); + + // If the value of the named `property` is a function then invoke it with the + // `object` as context; otherwise, return it. + _.result = function (object, property, fallback) { + var value = object == null ? void 0 : object[property]; + if (value === void 0) { + value = fallback; + } + return _.isFunction(value) ? value.call(object) : value; + }; + + // Generate a unique integer id (unique within the entire client session). + // Useful for temporary DOM ids. + var idCounter = 0; + _.uniqueId = function (prefix) { + var id = ++idCounter + ''; + return prefix ? prefix + id : id; + }; + + // By default, Underscore uses ERB-style template delimiters, change the + // following template settings to use alternative delimiters. + _.templateSettings = { + evaluate: /<%([\s\S]+?)%>/g, + interpolate: /<%=([\s\S]+?)%>/g, + escape: /<%-([\s\S]+?)%>/g + }; + + // When customizing `templateSettings`, if you don't want to define an + // interpolation, evaluation or escaping regex, we need one that is + // guaranteed not to match. + var noMatch = /(.)^/; + + // Certain characters need to be escaped so that they can be put into a + // string literal. + var escapes = { + "'": "'", + '\\': '\\', + '\r': 'r', + '\n': 'n', + '\u2028': 'u2028', + '\u2029': 'u2029' + }; + + var escaper = /\\|'|\r|\n|\u2028|\u2029/g; + + var escapeChar = function escapeChar(match) { + return '\\' + escapes[match]; + }; + + // JavaScript micro-templating, similar to John Resig's implementation. + // Underscore templating handles arbitrary delimiters, preserves whitespace, + // and correctly escapes quotes within interpolated code. + // NB: `oldSettings` only exists for backwards compatibility. + _.template = function (text, settings, oldSettings) { + if (!settings && oldSettings) settings = oldSettings; + settings = _.defaults({}, settings, _.templateSettings); + + // Combine delimiters into one regular expression via alternation. + var matcher = RegExp([(settings.escape || noMatch).source, (settings.interpolate || noMatch).source, (settings.evaluate || noMatch).source].join('|') + '|$', 'g'); + + // Compile the template source, escaping string literals appropriately. + var index = 0; + var source = "__p+='"; + text.replace(matcher, function (match, escape, interpolate, evaluate, offset) { + source += text.slice(index, offset).replace(escaper, escapeChar); + index = offset + match.length; + + if (escape) { + source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; + } else if (interpolate) { + source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; + } else if (evaluate) { + source += "';\n" + evaluate + "\n__p+='"; + } + + // Adobe VMs need the match returned to produce the correct offest. + return match; + }); + source += "';\n"; + + // If a variable is not specified, place data values in local scope. + if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; + + source = "var __t,__p='',__j=Array.prototype.join," + "print=function(){__p+=__j.call(arguments,'');};\n" + source + 'return __p;\n'; + + try { + var render = new Function(settings.variable || 'obj', '_', source); + } catch (e) { + e.source = source; + throw e; + } + + var template = function template(data) { + return render.call(this, data, _); + }; + + // Provide the compiled source as a convenience for precompilation. + var argument = settings.variable || 'obj'; + template.source = 'function(' + argument + '){\n' + source + '}'; + + return template; + }; + + // Add a "chain" function. Start chaining a wrapped Underscore object. + _.chain = function (obj) { + var instance = _(obj); + instance._chain = true; + return instance; + }; + + // OOP + // --------------- + // If Underscore is called as a function, it returns a wrapped object that + // can be used OO-style. This wrapper holds altered versions of all the + // underscore functions. Wrapped objects may be chained. + + // Helper function to continue chaining intermediate results. + var result = function result(instance, obj) { + return instance._chain ? _(obj).chain() : obj; + }; + + // Add your own custom functions to the Underscore object. + _.mixin = function (obj) { + _.each(_.functions(obj), function (name) { + var func = _[name] = obj[name]; + _.prototype[name] = function () { + var args = [this._wrapped]; + push.apply(args, arguments); + return result(this, func.apply(_, args)); + }; + }); + }; + + // Add all of the Underscore functions to the wrapper object. + _.mixin(_); + + // Add all mutator Array functions to the wrapper. + _.each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function (name) { + var method = ArrayProto[name]; + _.prototype[name] = function () { + var obj = this._wrapped; + method.apply(obj, arguments); + if ((name === 'shift' || name === 'splice') && obj.length === 0) delete obj[0]; + return result(this, obj); + }; + }); + + // Add all accessor Array functions to the wrapper. + _.each(['concat', 'join', 'slice'], function (name) { + var method = ArrayProto[name]; + _.prototype[name] = function () { + return result(this, method.apply(this._wrapped, arguments)); + }; + }); + + // Extracts the result from a wrapped and chained object. + _.prototype.value = function () { + return this._wrapped; + }; + + // Provide unwrapping proxy for some methods used in engine operations + // such as arithmetic and JSON stringification. + _.prototype.valueOf = _.prototype.toJSON = _.prototype.value; + + _.prototype.toString = function () { + return '' + this._wrapped; + }; + + // AMD registration happens at the end for compatibility with AMD loaders + // that may not enforce next-turn semantics on modules. Even though general + // practice for AMD registration is to be anonymous, underscore registers + // as a named module because, like jQuery, it is a base library that is + // popular enough to be bundled in a third party lib, but not be part of + // an AMD load request. Those cases could generate an error when an + // anonymous define() is called outside of a loader request. + if (true) { + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function () { + return _; + }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } +}).call(undefined); + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + +"use strict"; + + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var _ = __webpack_require__(0); +var nlp = __webpack_require__(2); +var wordwrap = __webpack_require__(5); +function capitalize(s) { + return s.charAt(0).toUpperCase() + s.slice(1); +} + +var Entity = function () { + function Entity() { + var _this = this; + + _classCallCheck(this, Entity); + + this.title = function () { + return Object.getPrototypeOf(_this).constructor.title; + }; + this.nouns = function () { + return Object.getPrototypeOf(_this).constructor.nouns; + }; + this.description = function (playerState) { + return Object.getPrototypeOf(_this).constructor.description; + }; + this.takeable = function () { + return Object.getPrototypeOf(_this).constructor.takeable; + }; + this.droppable = function () { + return Object.getPrototypeOf(_this).constructor.droppable; + }; + this.verbs = function () { + return Object.getPrototypeOf(_this).constructor.verbs; + }; + } + + _createClass(Entity, [{ + key: 'allCapsTitle', + value: function allCapsTitle() { + var words = this.title().split(' '); + for (var i = 0; i < words.length; i++) { + if (_.contains(this.nouns(), words[i])) { + words[i] = words[i].toUpperCase(); + } + } + return words.join(' '); + } + }, { + key: 'examine', + value: function examine(playerState, parsedSentence) { + return this.description(playerState); + } + }, { + key: 'take', + value: function take(playerState, parsedSentence) { + if (parsedSentence.secondaryEntity) { + return 'I didn\'t understand that.'; + } + if (playerState.inventory.containsEntity(this)) { + return 'You already have ' + this.title() + ' in your inventory.'; + } + if (!this.takeable() || !playerState.location.removeEntity(this)) { + return 'You can\'t ' + parsedSentence.verb.root() + ' ' + this.title() + '.'; + } + playerState.inventory.addEntity(this); + if (this.preTakeText) { + this.preTakeText = null; + } + return 'You ' + parsedSentence.verb.root() + ' ' + this.title() + '.'; + } + }, { + key: 'drop', + value: function drop(playerState, parsedSentence) { + if (parsedSentence.secondaryEntity) { + return 'I didn\'t understand that.'; + } + if (!playerState.inventory.containsEntity(this)) { + return 'You don\'t have ' + this.title() + ' in your inventory.'; + } + return 'You were raised not to litter, and decide against dropping ' + this.title() + ' on the ground.'; + } + }, { + key: 'use', + value: function use(playerState, parsedSentence) { + if (parsedSentence.secondaryEntity) { + return 'It\'s unclear how ' + this.title() + ' can be used with ' + parsedSentence.secondaryEntity.title() + '.'; + } else { + return 'It\'s unclear how ' + this.title() + ' can be used by itself.'; + } + } + }, { + key: 'give', + value: function give(playerState, parsedSentence) { + var otherEntity = parsedSentence.secondaryEntity; + if (!otherEntity) { + return capitalize(parsedSentence.verb.root()) + ' ' + this.title() + ' to whom?'; + } + if (otherEntity instanceof NpcEntity) { + return 'You ' + parsedSentence.verb.root() + ' ' + this.title() + ' to ' + otherEntity.title() + '.\n\n' + otherEntity.giveTo(playerState, this); + } + return 'You can\'t ' + parsedSentence.verb.root() + ' ' + this.title() + ' to ' + otherEntity.title() + '.'; + } + }]); + + return Entity; +}(); + +Entity.takeable = true; +Entity.droppable = true; +Entity.verbs = { + 'drop': 'drop', + 'give': 'give', + 'present': 'give', + 'show': 'give', + 'describe': 'examine', + 'examine': 'examine', + 'inspect': 'examine', + 'look at': 'examine', + 'x': 'examine', + 'get': 'take', + 'pick up': 'take', + 'take': 'take', + 'combine': 'use', + 'put': 'use', + 'use': 'use' +}; +exports.Entity = Entity; + +var NpcEntity = function (_Entity) { + _inherits(NpcEntity, _Entity); + + function NpcEntity() { + _classCallCheck(this, NpcEntity); + + return _possibleConstructorReturn(this, (NpcEntity.__proto__ || Object.getPrototypeOf(NpcEntity)).apply(this, arguments)); + } + + _createClass(NpcEntity, [{ + key: 'giveTo', + value: function giveTo(playerState, otherEntity) { + return '"That\'s very nice, but I\'m not sure what I\'d do with it. You should hold on to it."'; + } + }, { + key: 'talk', + value: function talk(playerState, parsedSentence) { + if (parsedSentence.secondaryEntity) { + return 'It\'s unclear how you can ' + parsedSentence.verb.root() + ' ' + this.title() + ' with ' + parsedSentence.secondaryEntity.title() + '.'; + } + return 'You approach ' + this.title() + ', but they have nothing to say.'; + } + }]); + + return NpcEntity; +}(Entity); + +NpcEntity.verbs = _.extend({}, Entity.verbs, { + 'talk to': 'talk', + 'talk with': 'talk', + 'speak to': 'talk', + 'speak with': 'talk' +}); +exports.NpcEntity = NpcEntity; + +var EntityContainerMixin = function () { + function EntityContainerMixin() { + _classCallCheck(this, EntityContainerMixin); + + this.entities = []; + } + + _createClass(EntityContainerMixin, [{ + key: 'getEntities', + value: function getEntities() { + return this.entities; + } + }, { + key: 'containsEntity', + value: function containsEntity(entity) { + return _.some(this.entities, function (arrayEntity) { + return _.isEqual(arrayEntity, entity); + }); + } + }, { + key: 'addEntity', + value: function addEntity(entity) { + this.entities.push(entity); + } + }, { + key: 'removeEntity', + value: function removeEntity(entity) { + var initialLength = this.entities.length; + this.entities = _.reject(this.entities, function (arrayEntity) { + return _.isEqual(arrayEntity, entity); + }); + return this.entities.length < initialLength; + } + }, { + key: 'findEntity', + value: function findEntity(terms) { + var fullText = _.pluck(terms, 'text').join(' '); + var nouns = []; + if (_.all(terms, function (term) { + return term.pos.Noun; + })) { + nouns = _.map(terms, function (term) { + return term.singularize(); + }); + } + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = this.entities[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var entity = _step.value; + + if (entity.title().indexOf(fullText) > -1) { + return entity; + } + if (nouns.length > 0 && _.intersection(nouns, entity.nouns()).length === nouns.length) { + return entity; + } + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + return null; + } + }]); + + return EntityContainerMixin; +}(); + +exports.EntityContainerMixin = EntityContainerMixin; +function formatCommaSeparatedList(list) { + if (list.length == 1) { + return list[0]; + } + return list.slice(0, list.length - 1).join(', ') + ' or ' + list[list.length - 1]; +} + +var PlayerState = function () { + function PlayerState() { + _classCallCheck(this, PlayerState); + + this.location = null; + this.inventory = new EntityContainerMixin(); + } + + _createClass(PlayerState, [{ + key: 'look', + value: function look() { + var _this3 = this; + + var description = this.location.getDescription() + '\n'; + var entities = this.location.getEntities(); + if (entities.length > 0) { + (function () { + var entityTitles = []; + _.each(entities, function (entity) { + if (entity.preTakeText) { + description += '\n' + entity.preTakeText + '\n'; + } else if (entity instanceof NpcEntity) { + description += '\n' + entity.description(_this3) + '\n'; + } else if (entity.takeable()) { + entityTitles.push(entity.allCapsTitle()); + } + }); + if (entityTitles.length > 0) { + description += '\nYou may pick up ' + formatCommaSeparatedList(entityTitles) + '.\n'; + } + })(); + } + var exitNames = _.keys(this.location.getExits()).map(function (exit) { + return exit.toUpperCase(); + }); + if (exitNames.length > 0) { + description += '\nYou may go ' + formatCommaSeparatedList(exitNames) + '.\n'; + } + return wordwrap.soft(80)(description); + } + }, { + key: 'inventoryDescription', + value: function inventoryDescription() { + var entities = this.inventory.getEntities(); + if (entities.length == 0) { + return 'You have nothing.\n'; + } + var output = ''; + _.each(entities, function (entity) { + output += 'You have ' + entity.allCapsTitle() + '.\n'; + }); + return output; + } + }, { + key: 'move', + value: function move(direction) { + if (direction in this.location.getExits()) { + this.location = this.location.getExits()[direction]; + return true; + } + return false; + } + }]); + + return PlayerState; +}(); + +exports.PlayerState = PlayerState; + +var Commander = function () { + function Commander(playerState, lexicon) { + _classCallCheck(this, Commander); + + this.playerState = playerState; + this.gameOver = false; + if (lexicon) { + this.lexicon = lexicon; + } else { + this.lexicon = nlp.lexicon(); + } + } + + _createClass(Commander, [{ + key: 'nlpParse', + value: function nlpParse(input) { + if (input.length === 0) { + return null; + } + var sentence = nlp.sentence(input, { lexicon: this.lexicon }); + if (sentence.terms.length === 0) { + return null; + } + var termIndex = 0; + var term = sentence.terms[termIndex]; + if (!term.pos.Verb) { + return null; + } + var verb = term; + termIndex++; + var entityTerms = []; + var primaryEntity = null; + while (termIndex < sentence.terms.length) { + term = sentence.terms[termIndex]; + if (entityTerms.length === 0 && term.pos.Determiner) { + termIndex++; + continue; + } + entityTerms.push(term); + var entity = this.playerState.location.findEntity(entityTerms); + if (!entity) { + entity = this.playerState.inventory.findEntity(entityTerms); + } + if (entity) { + primaryEntity = entity; + termIndex++; + continue; + } else if (primaryEntity) { + entityTerms = []; + break; + } else { + termIndex++; + continue; + } + } + if (termIndex === sentence.terms.length) { + return { + success: true, + verb: verb, + primaryEntity: primaryEntity, + secondaryEntity: null + }; + } + var secondaryEntity = null; + while (termIndex < sentence.terms.length) { + term = sentence.terms[termIndex]; + if (entityTerms.length === 0 && (term.pos.Determiner || term.pos.Preposition)) { + termIndex++; + continue; + } + entityTerms.push(term); + var _entity = this.playerState.location.findEntity(entityTerms); + if (!_entity) { + _entity = this.playerState.inventory.findEntity(entityTerms); + } + if (_entity) { + secondaryEntity = _entity; + termIndex++; + continue; + } else { + return { + success: false, + verb: verb, + primaryEntity: primaryEntity, + secondaryEntity: secondaryEntity + }; + } + } + return { + success: secondaryEntity != null, + verb: verb, + primaryEntity: primaryEntity, + secondaryEntity: secondaryEntity + }; + } + }, { + key: 'run', + value: function run(command) { + var trimmedCommand = command.trim().toLowerCase(); + if (trimmedCommand.length === 0) { + return this.playerState.look(); + } + var result = this.runTrimmedCommand(trimmedCommand); + if (result[result.length - 1] != '\n') { + result = result + '\n'; + } + return wordwrap.soft(80)(result); + } + }, { + key: 'runTrimmedCommand', + value: function runTrimmedCommand(trimmedCommand) { + if (trimmedCommand == 'help') { + return 'Here are a few examples of the kinds of commands you may use:\n\n look\n go left (or just \'left\' for short)\n look at sword\n take sword\n inventory\n talk to man\n use peanut butter with jelly\n give sandwich to man\n'; + } + if (this.playerState.location.runTrimmedCommand) { + var result = this.playerState.location.runTrimmedCommand(trimmedCommand); + if (result) { + return result; + } + } + if (trimmedCommand === 'look') { + return this.playerState.look(); + } + if ('inventory'.indexOf(trimmedCommand) === 0) { + return this.playerState.inventoryDescription(); + } + var direction = trimmedCommand; + direction = direction.replace(/^(move|go) /, ''); + for (var exit in this.playerState.location.getExits()) { + if (exit.indexOf(direction) === 0) { + var success = this.playerState.move(exit); + if (success) { + return 'You go ' + exit + '.\n\n' + this.playerState.look(); + } + } + } + var parsedSentence = this.nlpParse(trimmedCommand); + if (parsedSentence) { + if (!parsedSentence.success) { + if (parsedSentence.verb && parsedSentence.primaryEntity) { + return 'It may be possible to ' + parsedSentence.verb.root() + ' ' + parsedSentence.primaryEntity.title() + ', but I didn\'t completely understand that.'; + } + return 'I didn\'t understand that.'; + } + if (!parsedSentence.primaryEntity) { + return 'I didn\'t understand that.'; + } + var primaryEntityVerbs = parsedSentence.primaryEntity.verbs(); + var verbFuncName = primaryEntityVerbs[parsedSentence.verb.root()]; + if (!verbFuncName) { + return 'You can\'t ' + parsedSentence.verb.root() + ' ' + parsedSentence.primaryEntity.title() + '.'; + } + var verbFunc = parsedSentence.primaryEntity[verbFuncName].bind(parsedSentence.primaryEntity); + if (!verbFunc) { + return 'You can\'t ' + parsedSentence.verb.root() + ' ' + parsedSentence.primaryEntity.title() + '.'; + } + return verbFunc(this.playerState, parsedSentence); + } + return 'I didn\'t understand that.'; + } + }]); + + return Commander; +}(); + +exports.Commander = Commander; + +/***/ }, +/* 2 */ +/***/ function(module, exports, __webpack_require__) { + +"use strict"; +var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var require;var require; + +var _typeof2 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +(function (f) { + if (( false ? "undefined" : _typeof2(exports)) === "object" && typeof module !== "undefined") { + module.exports = f(); + } else if (true) { + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (f), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else { + var g;if (typeof window !== "undefined") { + g = window; + } else if (typeof global !== "undefined") { + g = global; + } else if (typeof self !== "undefined") { + g = self; + } else { + g = this; + }g.nlp_compromise = f(); + } +})(function () { + var define, module, exports;return function e(t, n, r) { + function s(o, u) { + if (!n[o]) { + if (!t[o]) { + var a = typeof require == "function" && require;if (!u && a) return require(o, !0);if (i) return i(o, !0);var f = new Error("Cannot find module '" + o + "'");throw f.code = "MODULE_NOT_FOUND", f; + }var l = n[o] = { exports: {} };t[o][0].call(l.exports, function (e) { + var n = t[o][1][e];return s(n ? n : e); + }, l, l.exports, e, t, n, r); + }return n[o].exports; + }var i = typeof require == "function" && require;for (var o = 0; o < r.length; o++) { + s(r[o]); + }return s; + }({ 1: [function (require, module, exports) { + 'use strict'; + + var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) { + return typeof obj === "undefined" ? "undefined" : _typeof2(obj); + } : function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof2(obj); + }; + + var fns = require('./fns.js'); + + var models = { + Term: require('./term/term.js'), + Text: require('./text/text.js'), + Sentence: require('./sentence/sentence.js'), + Statement: require('./sentence/statement/statement.js'), + Question: require('./sentence/question/question.js'), + Verb: require('./term/verb/verb.js'), + Adjective: require('./term/adjective/adjective.js'), + Adverb: require('./term/adverb/adverb.js'), + Noun: require('./term/noun/noun.js'), + Value: require('./term/noun/value/value.js'), + Person: require('./term/noun/person/person.js'), + Place: require('./term/noun/place/place.js'), + Date: require('./term/noun/date/date.js'), + Organization: require('./term/noun/organization/organization.js') + }; + + function NLP() { + + this.plugin = function (obj) { + obj = obj || {}; + // if obj is a function, pass it an instance of this nlp library + if (fns.isFunction(obj)) { + // run it in this current context + obj = obj.call(this, this); + } + //apply each plugin to the correct prototypes + Object.keys(obj).forEach(function (k) { + Object.keys(obj[k]).forEach(function (method) { + models[k].fn[method] = obj[k][method]; + }); + }); + }; + this.lexicon = function () { + return require('./lexicon.js'); + }; + + this.term = function (s) { + return new models.Term(s); + }; + this.noun = function (s) { + return new models.Noun(s); + }; + this.verb = function (s) { + return new models.Verb(s); + }; + this.adjective = function (s) { + return new models.Adjective(s); + }; + this.adverb = function (s) { + return new models.Adverb(s); + }; + + this.value = function (s) { + return new models.Value(s); + }; + this.person = function (s) { + return new models.Person(s); + }; + this.place = function (s) { + return new models.Place(s); + }; + this.date = function (s) { + return new models.Date(s); + }; + this.organization = function (s) { + return new models.Organization(s); + }; + + this.text = function (s, options) { + return new models.Text(s, options); + }; + this.sentence = function (s, options) { + return new models.Sentence(s, options); + }; + this.statement = function (s) { + return new models.Statement(s); + }; + this.question = function (s) { + return new models.Question(s); + }; + } + + var nlp = new NLP(); + //export to window or webworker + if ((typeof window === 'undefined' ? 'undefined' : _typeof(window)) === 'object' || typeof DedicatedWorkerGlobalScope === 'function') { + self.nlp_compromise = nlp; + } + //export to commonjs + if (typeof module !== 'undefined' && module.exports) { + module.exports = nlp; + } + //export to amd + if (typeof define === 'function' && define.amd) { + define(nlp); + } + + // console.log(nlp.sentence('first').terms); + // let r = nlp.sentence('The giraffe ate the apples.').terms.filter((t) => { + // return t.pos.Noun; + // }); + // console.log(r); + }, { "./fns.js": 23, "./lexicon.js": 24, "./sentence/question/question.js": 52, "./sentence/sentence.js": 55, "./sentence/statement/statement.js": 58, "./term/adjective/adjective.js": 60, "./term/adverb/adverb.js": 65, "./term/noun/date/date.js": 70, "./term/noun/noun.js": 76, "./term/noun/organization/organization.js": 78, "./term/noun/person/person.js": 82, "./term/noun/place/place.js": 84, "./term/noun/value/value.js": 94, "./term/term.js": 95, "./term/verb/verb.js": 104, "./text/text.js": 107 }], 2: [function (require, module, exports) { + //these are common word shortenings used in the lexicon and sentence segmentation methods + //there are all nouns, or at the least, belong beside one. + 'use strict'; + + var honourifics = require('./honourifics'); //stored seperately, for 'noun.is_person()' + + //common abbreviations + var main = ['arc', 'al', 'exp', 'rd', 'st', 'dist', 'mt', 'fy', 'pd', 'pl', 'plz', 'tce', 'llb', 'md', 'bl', 'ma', 'ba', 'lit', 'ex', 'eg', 'ie', 'circa', 'ca', 'cca', 'vs', 'etc', 'esp', 'ft', 'bc', 'ad']; + + //person titles like 'jr', (stored seperately) + main = main.concat(honourifics); + + //org main + var orgs = ['dept', 'univ', 'assn', 'bros', 'inc', 'ltd', 'co', 'corp', + //proper nouns with exclamation marks + 'yahoo', 'joomla', 'jeopardy']; + main = main.concat(orgs); + + //place main + var places = ['ariz', 'cal', 'calif', 'col', 'colo', 'conn', 'fla', 'fl', 'ga', 'ida', 'ia', 'kan', 'kans', 'md', 'minn', 'neb', 'nebr', 'okla', 'penna', 'penn', 'pa', 'dak', 'tenn', 'tex', 'ut', 'vt', 'va', 'wis', 'wisc', 'wy', 'wyo', 'usafa', 'alta', 'ont', 'que', 'sask', 'ave', 'blvd', 'cl', 'ct', 'cres', 'hwy']; + main = main.concat(places); + + //date abbrevs. + //these are added seperately because they are not nouns + var dates = ['jan', 'feb', 'mar', 'apr', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec', 'sept', 'sep']; + main = main.concat(dates); + + module.exports = { + abbreviations: main, + dates: dates, + orgs: orgs, + places: places + }; + }, { "./honourifics": 9 }], 3: [function (require, module, exports) { + //adjectives that either aren't covered by rules, or have superlative/comparative forms + //this list is the seed, from which various forms are conjugated + 'use strict'; + + var fns = require('../fns'); + + //suffix-index adjectives + // {cial:'cru,spe'} -> 'crucial', 'special' + var compressed = { + erate: 'degen,delib,desp,lit,mod', + icial: 'artif,benef,off,superf', + ntial: 'esse,influe,pote,substa', + teful: 'gra,ha,tas,was', + stant: 'con,di,in,resi', + going: 'easy,fore,on,out', + hing: 'astonis,das,far-reac,refres,scat,screec,self-loat,soot', + eful: 'car,grac,peac,sham,us,veng', + ming: 'alar,cal,glea,unassu,unbeco,upco', + cial: 'commer,cru,finan,ra,so,spe', + tful: 'deligh,doub,fre,righ,though,wis', + ight: 'overn,overwe,r,sl,upt', + ated: 'antiqu,intoxic,sophistic,unregul,unrel', + rant: 'aber,exube,flag,igno,vib', + uent: 'congr,fl,freq,subseq', + rate: 'accu,elabo,i,sepa', + ific: 'horr,scient,spec,terr', + rary: 'arbit,contempo,cont,tempo', + ntic: 'authe,fra,giga,roma', + wing: 'harro,kno,left-,right-', + nant: 'domi,malig,preg,reso', + nent: 'emi,immi,perma,promi', + iant: 'brill,def,g,luxur', + ging: 'dama,encoura,han,lon', + iate: 'appropr,immed,inappropr,intermed', + rect: 'cor,e,incor,indi', + zing: 'agoni,ama,appeti,free', + ant: 'abund,arrog,eleg,extravag,exult,hesit,irrelev,miscre,nonchal,obeis,observ,pl,pleas,redund,relev,reluct,signific,vac,verd', + ing: 'absorb,car,coo,liv,lov,ly,menac,perplex,shock,stand,surpris,tell,unappeal,unconvinc,unend,unsuspect,vex,want', + ate: 'adequ,delic,fortun,inadequ,inn,intim,legitim,priv,sed,ultim', + ted: 'expec,impor,limi,spiri,talen,tes,unexpec,unpreceden', + ish: 'dan,fool,hell,lout,self,snobb,squeam,styl', + ary: 'dre,legend,necess,prim,sc,second,w,we', + ite: 'el,favor,fin,oppos,pet,pol,recond,tr', + ely: 'hom,lik,liv,lon,lov,tim,unlik', + ure: 'fut,insec,miniat,obsc,premat,sec,s', + tly: 'cos,ghas,ghos,nigh,sain,sprigh,unsigh', + dly: 'cowar,cud,frien,frien,kin,ma', + ble: 'a,dou,hum,nim,no,proba', + rly: 'bu,disorde,elde,hou,neighbo,yea', + ine: 'div,femin,genu,mascul,prist,rout', + ute: 'absol,ac,c,m,resol', + ped: 'cram,pum,stereoty,stri,war', + sed: 'clo,disea,distres,unsupervi,u', + lly: 'chi,hi,jo,si,sme', + per: 'dap,impro,pro,su,up', + ile: 'fert,host,juven,mob,volat', + led: 'detai,disgrunt,fab,paralle,troub', + ern: 'east,north,south,st,west', + ast: 'e,l,p,steadf', + ent: 'abs,appar,b,pres', + ged: 'dama,deran,jag,rag', + ded: 'crow,guar,retar,undeci', + est: 'b,dishon,hon,quick', + ial: 'colon,impart,init,part', + ter: 'bet,lat,ou,ut', + ond: 'bey,bl,sec,vagab', + ady: 'he,re,sh,ste', + eal: 'ether,id,r,surr', + ard: 'abo,awkw,stand,straightforw', + ior: 'jun,pr,sen,super', + ale: 'fem,m,upsc,wholes', + ed: 'advanc,belov,craz,determin,hallow,hook,inbr,justifi,nak,nuanc,sacr,subdu,unauthoriz,unrecogniz,wick', + ly: 'dai,deep,earth,gris,heaven,low,meas,melancho,month,oi,on,prick,seem,s,ug,unru,week,wi,woman', + al: 'actu,coloss,glob,illeg,leg,leth,liter,loy,ov,riv,roy,univers,usu', + dy: 'baw,bloo,clou,gau,gid,han,mol,moo,stur,ti,tren,unti,unwiel', + se: 'adver,den,diver,fal,immen,inten,obe,perver,preci,profu', + er: 'clev,form,inn,oth,ov,she,slend,somb,togeth,und', + id: 'afra,hum,langu,plac,rab,sord,splend,stup,torp', + re: 'awa,bizar,di,enti,macab,me,seve,since,spa', + en: 'barr,brok,crav,op,sudd,unev,unwritt,wood', + ic: 'alcohol,didact,gener,hispan,organ,publ,symbol', + ny: 'ma,pho,pu,shi,skin,ti,za', + st: 'again,mo,populi,raci,robu,uttermo', + ne: 'do,go,insa,obsce,picayu,sere', + nd: 'behi,bla,bli,profou,undergrou,wou', + le: 'midd,multip,sing,so,subt,who', + pt: 'abru,ade,a,bankru,corru,nondescri', + ty: 'faul,hef,lof,mea,sal,uppi', + sy: 'bu,chee,lou,no,ro', + ct: 'abstra,exa,imperfe,inta,perfe', + in: 'certa,highfalut,ma,tw,va', + et: 'discre,secr,sovi,ups,viol', + me: 'part-ti,pri,sa,supre,welco', + cy: 'boun,fan,i,jui,spi', + ry: 'fur,sor,tawd,wi,w', + te: 'comple,concre,obsole,remo', + ld: 'ba,bo,go,mi', + an: 'deadp,republic,t,urb', + ll: 'a,i,overa,sti', + ay: 'everyd,g,gr,ok', + or: 'indo,maj,min,outdo', + my: 'foa,gloo,roo,sli', + ck: 'ba,qua,si,sli', + rt: 'cove,expe,hu,ove', + ul: 'fo,gainf,helpf,painf' + }; + + var arr = ['ablaze', 'above', 'adult', 'ahead', 'aloof', 'arab', 'asleep', 'average', 'awake', 'backwards', 'bad', 'blank', 'bogus', 'bottom', 'brisk', 'cagey', 'chief', 'civil', 'common', 'complex', 'cozy', 'crisp', 'deaf', 'devout', 'difficult', 'downtown', 'due', 'dumb', 'eerie', 'evil', 'excess', 'extra', 'fake', 'far', 'faux', 'fierce ', 'fit', 'foreign', 'fun', 'good', 'goofy', 'gratis', 'grey', 'groovy', 'gross', 'half', 'huge', 'humdrum', 'inside', 'kaput', 'lax', 'left', 'less', 'level', 'lewd', 'magenta', 'makeshift', 'mammoth', 'medium', 'moot', 'naive', 'nearby', 'next', 'nonstop', 'north', 'offbeat', 'ok', 'outside', 'overwrought', 'premium', 'pricey', 'pro', 'quaint', 'random', 'rear', 'rebel', 'ritzy', 'rough', 'savvy', 'sexy', 'shut', 'shy', 'sleek', 'smug', 'solemn', 'south', 'stark', 'superb', 'taboo', 'teenage', 'top', 'tranquil', 'ultra', 'understood', 'unfair', 'unknown', 'upbeat', 'upstairs', 'vanilla', 'various', 'widespread', 'woozy', 'wrong', 'final', 'true', 'modern', 'notable']; + + module.exports = fns.expand_suffixes(arr, compressed); + }, { "../fns": 23 }], 4: [function (require, module, exports) { + 'use strict'; + + //these are adjectives that can become comparative + superlative with out "most/more" + //its a whitelist for conjugation + //this data is shared between comparative/superlative methods + + module.exports = ['absurd', 'aggressive', 'alert', 'alive', 'awesome', 'beautiful', 'big', 'bitter', 'black', 'blue', 'bored', 'boring', 'brash', 'brave', 'brief', 'bright', 'broad', 'brown', 'calm', 'charming', 'cheap', 'clean', 'cold', 'cool', 'cruel', 'cute', 'damp', 'deep', 'dear', 'dead', 'dark', 'dirty', 'drunk', 'dull', 'eager', 'efficient', 'even', 'faint', 'fair', 'fanc', 'fast', 'fat', 'feeble', 'few', 'fierce', 'fine', 'flat', 'forgetful', 'frail', 'full', 'gentle', 'glib', 'great', 'green', 'gruesome', 'handsome', 'hard', 'harsh', 'high', 'hollow', 'hot', 'impolite', 'innocent', 'keen', 'kind', 'lame', 'lean', 'light', 'little', 'loose', 'long', 'loud', 'low', 'lush', 'macho', 'mean', 'meek', 'mellow', 'mundane', 'near', 'neat', 'new', 'nice', 'normal', 'odd', 'old', 'pale', 'pink', 'plain', 'poor', 'proud', 'purple', 'quick', 'rare', 'rapid', 'red', 'rich', 'ripe', 'rotten', 'round', 'rude', 'sad', 'safe', 'scarce', 'scared', 'shallow', 'sharp', 'short', 'shrill', 'simple', 'slim', 'slow', 'small', 'smart', 'smooth', 'soft', 'sore', 'sour', 'square', 'stale', 'steep', 'stiff', 'straight', 'strange', 'strong', 'sweet', 'swift', 'tall', 'tame', 'tart', 'tender', 'tense', 'thick', 'thin', 'tight', 'tough', 'vague', 'vast', 'vulgar', 'warm', 'weak', 'wet', 'white', 'wide', 'wild', 'wise', 'young', 'yellow', 'easy', 'narrow', 'late', 'early', 'soon', 'close', 'empty', 'dry', 'windy', 'noisy', 'thirsty', 'hungry', 'fresh', 'quiet', 'clear', 'heavy', 'happy', 'funny', 'lucky', 'pretty', 'important', 'interesting', 'attractive', 'dangerous', 'intellegent', 'pure', 'orange', 'large', 'firm', 'grand', 'formal', 'raw', 'weird', 'glad', 'mad', 'strict', 'tired', 'solid', 'extreme', 'mature', 'true', 'free', 'curly', 'angry'].reduce(function (h, s) { + h[s] = 'Adjective'; + return h; + }, {}); + }, {}], 5: [function (require, module, exports) { + 'use strict'; + //terms that are 'Date' term + + var months = ['january', 'february', + // "march", //ambig + 'april', + // "may", //ambig + 'june', 'july', 'august', 'september', 'october', 'november', 'december', 'jan', 'feb', 'mar', 'apr', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec', 'sept', 'sep']; + var days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'mon', 'tues', 'wed', 'thurs', 'fri', 'sat', 'sun']; + //add 'mondays' + for (var i = 0; i <= 6; i++) { + days.push(days[i] + 's'); + } + + var durations = ['millisecond', 'second', 'minute', 'hour', 'morning', 'afternoon', 'evening', 'night', 'day', 'week', 'month', 'year', 'decade']; + //add their plurals + var len = durations.length; + for (var i = 0; i < len; i++) { + durations.push(durations[i] + 's'); + } + durations.push('century'); + durations.push('centuries'); + + var relative = ['yesterday', 'today', 'tomorrow', 'week', 'weekend', 'tonight']; + + module.exports = { + days: days, + months: months, + durations: durations, + relative: relative + }; + }, {}], 6: [function (require, module, exports) { + 'use strict'; + + //adjectival forms of place names, as adjectives. + + module.exports = ['afghan', 'albanian', 'algerian', 'argentine', 'armenian', 'australian', 'aussie', 'austrian', 'bangladeshi', 'belgian', 'bolivian', 'bosnian', 'brazilian', 'bulgarian', 'cambodian', 'canadian', 'chilean', 'chinese', 'colombian', 'croat', 'cuban', 'czech', 'dominican', 'egyptian', 'british', 'estonian', 'ethiopian', 'finnish', 'french', 'gambian', 'georgian', 'german', 'greek', 'haitian', 'hungarian', 'indian', 'indonesian', 'iranian', 'iraqi', 'irish', 'israeli', 'italian', 'jamaican', 'japanese', 'jordanian', 'kenyan', 'korean', 'kuwaiti', 'latvian', 'lebanese', 'liberian', 'libyan', 'lithuanian', 'macedonian', 'malaysian', 'mexican', 'mongolian', 'moroccan', 'dutch', 'nicaraguan', 'nigerian', 'norwegian', 'omani', 'pakistani', 'palestinian', 'filipino', 'polish', 'portuguese', 'qatari', 'romanian', 'russian', 'rwandan', 'samoan', 'saudi', 'scottish', 'senegalese', 'serbian', 'singaporean', 'slovak', 'somali', 'sudanese', 'swedish', 'swiss', 'syrian', 'taiwanese', 'thai', 'tunisian', 'ugandan', 'ukrainian', 'american', 'hindi', 'spanish', 'venezuelan', 'vietnamese', 'welsh', 'african', 'european', 'asian', 'californian']; + }, {}], 7: [function (require, module, exports) { + // common first-names in compressed form. + // from http://www.ssa.gov/oact/babynames/limits.html and http://www.servicealberta.gov.ab.ca/pdf/vs/2001_Boys.pdf + // not sure what regional/cultural/demographic bias this has. Probably a lot. + // 73% of people are represented in the top 1000 names + + // used to reduce redundant named-entities in longer text. (don't spot the same person twice.) + // used to identify gender for coreference resolution + 'use strict'; + + var male = require('./names/male'); + var female = require('./names/female'); + var names = {}; + + //names commonly used in either gender + var ambiguous = ['casey', 'jamie', 'lee', 'jaime', 'jessie', 'morgan', 'rene', 'robin', 'devon', 'kerry', 'alexis', 'guadalupe', 'blair', 'kasey', 'jean', 'marion', 'aubrey', 'shelby', 'jan', 'shea', 'jade', 'kenyatta', 'kelsey', 'shay', 'lashawn', 'trinity', 'regan', 'jammie', 'cassidy', 'cheyenne', 'reagan', 'shiloh', 'marlo', 'andra', 'devan', 'rosario', 'lee']; + for (var i = 0; i < male.length; i++) { + names[male[i]] = 'm'; + } + for (var i = 0; i < female.length; i++) { + names[female[i]] = 'f'; + } + //ambiguous/unisex names + for (var i = 0; i < ambiguous.length; i += 1) { + names[ambiguous[i]] = 'a'; + } + // console.log(names['spencer']); + // console.log(names['jill']); + // console.log(names['sue']) + // console.log(names['jan']) + module.exports = names; + }, { "./names/female": 14, "./names/male": 15 }], 8: [function (require, module, exports) { + 'use strict'; + + var fns = require('../fns'); + //turns holiday-names into text-versions of their dates + //https://en.wikipedia.org/wiki/federal_holidays_in_the_united_states + + //some major, and unambiguous holidays with the same date each year + var annual = { + //general + 'new years eve': 'december 31', + 'new years': 'january 1', + 'new years day': 'january 1', + 'thanksgiving': 'fourth thursday in november', + 'christmas eve': 'december 24', + 'christmas': 'december 24', + 'christmas day': 'december 24', + 'saint patricks day': 'march 17', + 'st patricks day': 'march 17', + 'april fools': 'april 1', + 'halloween': 'october 31', + 'valentines': 'february 14', + 'valentines day': 'february 14', + + //american + 'martin luther king': 'third monday in january', + 'inauguration day': 'january 20', + 'washingtons birthday': 'third monday in february', + 'presidents day': 'third monday in february', + 'memorial day': 'last monday in may', + // 'independence': 'july 4', + 'labor day': 'first monday in september', + 'columbus day': 'second monday in october', + 'veterans day': 'november 11', + + //british + 'labour day': 'first monday in september', + 'commonwealth day': 'second monday in march', + 'st andrews day': 'november 30', + 'saint andrews day': 'november 30', + 'may day': 'may 1', + + //russian + 'russia day': 'june 12', + + //australian + 'australia day': 'january 26', + 'boxing day': 'december 26', + 'queens birthday': '2nd monday in june', + + //canadian + 'canada day': 'july 1', + 'victoria day': 'may 24', + 'canadian thanksgiving': 'second monday in october', + 'rememberance day': 'november 11', + 'august civic holiday': 'first monday in august', + 'natal day': 'first monday in august', + + //european + 'all saints day': 'november 1', + 'armistice day': 'november 11', + 'bastille day': 'july 14', + 'st stephens day': 'december 26', + 'saint stephens day': 'december 26' + }; + + // hardcoded dates for non-regular holidays + // ----change every few years(!)--- TODO :do more years + var astronomical = { + 2015: { + 'chinese new year': 'february 19', + 'easter': 'april 5', + 'easter sunday': 'april 5', + 'easter monday': 'april 6', + 'good friday': 'april 3', + 'ascension day': 'may 14', + 'eid': 'july 17', + 'eid al-fitr': 'july 17', + 'eid al-adha': 'september 24', + 'ramadan': 'june 6', //range + 'ashura': '23 october', + 'diwali': '11 november' + }, + 2016: { + 'chinese new year': 'february 8', + 'easter': 'march 27', + 'easter sunday': 'march 27', + 'easter monday': 'march 28', + 'good friday': 'march 25', + 'ascension day': 'may 5', + 'eid': 'july 6', + 'eid al-fitr': 'july 6', + 'eid al-adha': 'september 11', + 'ramadan': 'may 27', + 'diwali': 'october 30' + }, + 2017: { + 'chinese new year': '28 january', + 'easter': 'april 16', + 'easter sunday': 'april 16', + 'easter monday': 'april 17', + 'good friday': 'april 14', + 'ascension day': 'may 25', + 'eid': 'july 25', + 'eid al-fitr': 'july 25', + 'diwali': 'october 21', + 'ramadan': 'may 27' + } + }; + //select current year + var thisYear = new Date().getFullYear(); + var holidays = fns.extend(annual, astronomical[thisYear] || {}); + + module.exports = holidays; + }, { "../fns": 23 }], 9: [function (require, module, exports) { + 'use strict'; + + //these are common person titles used in the lexicon and sentence segmentation methods + //they are also used to identify that a noun is a person + + module.exports = [ + //honourifics + 'jr', 'mr', 'mrs', 'ms', 'dr', 'prof', 'sr', 'sen', 'corp', 'rep', 'gov', 'atty', 'supt', 'det', 'rev', 'col', 'gen', 'lt', 'cmdr', 'adm', 'capt', 'sgt', 'cpl', 'maj', + // 'miss', + // 'misses', + 'mister', 'sir', 'esq', 'mstr', 'phd', 'adj', 'adv', 'asst', 'bldg', 'brig', 'comdr', 'hon', 'messrs', 'mlle', 'mme', 'op', 'ord', 'pvt', 'reps', 'res', 'sens', 'sfc', 'surg']; + }, {}], 10: [function (require, module, exports) { + //nouns with irregular plural/singular forms + //used in noun.inflect, and also in the lexicon. + //compressed with '_' to reduce some redundancy. + 'use strict'; + + var main = [['child', '_ren'], ['person', 'people'], ['leaf', 'leaves'], ['database', '_s'], ['quiz', '_zes'], ['stomach', '_s'], ['sex', '_es'], ['move', '_s'], ['shoe', '_s'], ['goose', 'geese'], ['phenomenon', 'phenomena'], ['barracks', '_'], ['deer', '_'], ['syllabus', 'syllabi'], ['index', 'indices'], ['appendix', 'appendices'], ['criterion', 'criteria'], ['man', 'men'], ['sex', '_es'], ['rodeo', '_s'], ['epoch', '_s'], ['zero', '_s'], ['avocado', '_s'], ['halo', '_s'], ['tornado', '_s'], ['tuxedo', '_s'], ['sombrero', '_s'], ['addendum', 'addenda'], ['alga', '_e'], ['alumna', '_e'], ['alumnus', 'alumni'], ['bacillus', 'bacilli'], ['cactus', 'cacti'], ['beau', '_x'], ['château', '_x'], ['chateau', '_x'], ['tableau', '_x'], ['corpus', 'corpora'], ['curriculum', 'curricula'], ['echo', '_es'], ['embargo', '_es'], ['foot', 'feet'], ['genus', 'genera'], ['hippopotamus', 'hippopotami'], ['larva', '_e'], ['libretto', 'libretti'], ['loaf', 'loaves'], ['matrix', 'matrices'], ['memorandum', 'memoranda'], ['mosquito', '_es'], ['opus', 'opera'], ['ovum', 'ova'], ['ox', '_en'], ['radius', 'radii'], ['referendum', 'referenda'], ['thief', 'thieves'], ['tooth', 'teeth']]; + + main = main.map(function (a) { + a[1] = a[1].replace('_', a[0]); + return a; + }); + + module.exports = main; + }, {}], 11: [function (require, module, exports) { + 'use strict'; + + //a list of exceptions to the verb rules + + var irregular_verbs = { + take: { + perfect: 'have taken', + pluperfect: 'had taken', + future_perfect: 'will have taken' + }, + free: { + gerund: 'freeing', + actor: '' + }, + arise: { + past: 'arose', + participle: 'arisen' + }, + babysit: { + past: 'babysat', + actor: 'babysitter' + }, + be: { // this is crazy-hard and shouldn't be here + past: 'was', + present: 'is', + future: 'will be', + perfect: 'have been', + pluperfect: 'had been', + future_perfect: 'will have been', + actor: '', + gerund: 'am' + }, + is: { + past: 'was', + present: 'is', + future: 'will be', + perfect: 'have been', + pluperfect: 'had been', + future_perfect: 'will have been', + actor: '', + gerund: 'being' + }, + beat: { + gerund: 'beating', + actor: 'beater' + }, + begin: { + gerund: 'beginning', + past: 'began' + }, + bet: { + actor: 'better' + }, + bind: { + past: 'bound' + }, + bite: { + gerund: 'biting', + past: 'bit' + }, + bleed: { + past: 'bled' + }, + break: { + past: 'broke' + }, + breed: { + past: 'bred' + }, + bring: { + past: 'brought' + }, + broadcast: { + past: 'broadcast' + }, + build: { + past: 'built' + }, + buy: { + past: 'bought' + }, + catch: { + past: 'caught' + }, + choose: { + gerund: 'choosing', + past: 'chose' + }, + cost: { + past: 'cost' + }, + deal: { + past: 'dealt' + }, + die: { + past: 'died', + gerund: 'dying' + }, + dig: { + gerund: 'digging', + past: 'dug' + }, + do: { + past: 'did', + present: 'does' + }, + draw: { + past: 'drew' + }, + drink: { + past: 'drank' + }, + drive: { + gerund: 'driving', + past: 'drove' + }, + eat: { + gerund: 'eating', + past: 'ate', + actor: 'eater' + }, + fall: { + past: 'fell' + }, + feed: { + past: 'fed' + }, + feel: { + past: 'felt', + actor: 'feeler' + }, + fight: { + past: 'fought' + }, + find: { + past: 'found' + }, + fly: { + past: 'flew' + }, + forbid: { + past: 'forbade' + }, + forget: { + gerund: 'forgeting', + past: 'forgot' + }, + forgive: { + gerund: 'forgiving', + past: 'forgave' + }, + freeze: { + gerund: 'freezing', + past: 'froze' + }, + get: { + past: 'got' + }, + give: { + gerund: 'giving', + past: 'gave' + }, + go: { + past: 'went', + present: 'goes' + }, + hang: { + past: 'hung' + }, + have: { + gerund: 'having', + past: 'had', + present: 'has' + }, + hear: { + past: 'heard' + }, + hide: { + past: 'hid' + }, + hold: { + past: 'held' + }, + hurt: { + past: 'hurt' + }, + lay: { + past: 'laid' + }, + lead: { + past: 'led' + }, + leave: { + past: 'left' + }, + lie: { + gerund: 'lying', + past: 'lay' + }, + light: { + past: 'lit' + }, + lose: { + gerund: 'losing', + past: 'lost' + }, + make: { + past: 'made' + }, + mean: { + past: 'meant' + }, + meet: { + gerund: 'meeting', + past: 'met', + actor: 'meeter' + }, + pay: { + past: 'paid' + }, + read: { + past: 'read' + }, + ring: { + past: 'rang' + }, + rise: { + past: 'rose' + }, + run: { + gerund: 'running', + past: 'ran' + }, + say: { + past: 'said' + }, + see: { + past: 'saw' + }, + sell: { + past: 'sold' + }, + shine: { + past: 'shone' + }, + shoot: { + past: 'shot' + }, + show: { + past: 'showed' + }, + sing: { + past: 'sang' + }, + sink: { + past: 'sank', + pluperfect: 'had sunk' + }, + sit: { + past: 'sat' + }, + slide: { + past: 'slid' + }, + speak: { + past: 'spoke' + }, + spin: { + gerund: 'spinning', + past: 'spun' + }, + spread: { + past: 'spread' + }, + stand: { + past: 'stood' + }, + steal: { + past: 'stole', + actor: 'stealer' + }, + stick: { + past: 'stuck' + }, + sting: { + past: 'stung' + }, + strike: { + gerund: 'striking', + past: 'struck' + }, + swear: { + past: 'swore' + }, + swim: { + past: 'swam' + }, + swing: { + past: 'swung' + }, + teach: { + past: 'taught', + present: 'teaches' + }, + tear: { + past: 'tore' + }, + tell: { + past: 'told' + }, + think: { + past: 'thought' + }, + understand: { + past: 'understood' + }, + wake: { + past: 'woke' + }, + wear: { + past: 'wore' + }, + win: { + gerund: 'winning', + past: 'won' + }, + withdraw: { + past: 'withdrew' + }, + write: { + gerund: 'writing', + past: 'wrote' + }, + tie: { + gerund: 'tying', + past: 'tied' + }, + ski: { + past: 'skiied' + }, + boil: { + actor: 'boiler' + }, + miss: { + present: 'miss' + }, + act: { + actor: 'actor' + }, + compete: { + gerund: 'competing', + past: 'competed', + actor: 'competitor' + }, + being: { + gerund: 'are', + past: 'were', + present: 'are' + }, + imply: { + past: 'implied', + present: 'implies' + }, + ice: { + gerund: 'icing', + past: 'iced' + }, + develop: { + past: 'developed', + actor: 'developer' + }, + wait: { + gerund: 'waiting', + past: 'waited', + actor: 'waiter' + }, + aim: { + actor: 'aimer' + }, + spill: { + past: 'spilt' + }, + drop: { + gerund: 'dropping', + past: 'dropped' + }, + log: { + gerund: 'logging', + past: 'logged' + }, + rub: { + gerund: 'rubbing', + past: 'rubbed' + }, + smash: { + present: 'smashes' + }, + suit: { + gerund: 'suiting', + past: 'suited', + actor: 'suiter' + } + }; + module.exports = irregular_verbs; + }, {}], 12: [function (require, module, exports) { + 'use strict'; + + var misc = { + 'there': 'NN', + + 'better': 'JJR', + 'earlier': 'JJR', + + 'has': 'VB', + 'sounds': 'VBZ', + //special case for took/taken + 'taken': 'VBD', + 'msg': 'VB', //slang + //date + 'noon': 'DA', + 'midnight': 'DA', + //errr.... + 'now': 'DA', + 'morning': 'DA', + 'evening': 'DA', + 'afternoon': 'DA', + 'ago': 'DA', + //end of day, end of month + 'eod': 'DA', + 'eom': 'DA', + 'number': 'NN', + 'system': 'NN', + 'example': 'NN', + 'part': 'NN' + }; + + var compact = { + //conjunctions + 'CC': ['yet', 'therefore', 'or', 'while', 'nor', 'whether', 'though', 'because', 'cuz', 'but', 'for', 'and', 'however', 'before', 'although', 'how', 'plus', 'versus', 'not'], + 'CO': ['if', 'unless', 'otherwise', 'notwithstanding'], + + 'VBD': ['said', 'had', 'been', 'began', 'came', 'did', 'meant', 'went'], + + 'VBN': ['given', 'known', 'shown', 'seen', 'born'], + + 'VBG': ['going', 'being', 'according', 'resulting', 'developing', 'staining'], + + //copula + 'CP': ['is', 'will be', 'are', 'was', 'were', 'am', 'isn\'t', 'ain\'t', 'aren\'t'], + + //determiners + 'DT': ['this', 'any', 'enough', 'each', 'whatever', 'every', 'which', 'these', 'another', 'plenty', 'whichever', 'neither', 'an', 'a', 'least', 'own', 'few', 'both', 'those', 'the', 'that', 'various', 'what', 'either', 'much', 'some', 'else', 'no', + //some other languages (what could go wrong?) + 'la', 'le', 'les', 'des', 'de', 'du', 'el'], + + //prepositions + 'IN': ['until', 'onto', 'of', 'into', 'out', 'except', 'across', 'by', 'between', 'at', 'down', 'as', 'from', 'around', 'with', 'among', 'upon', 'amid', 'to', 'along', 'since', 'about', 'off', 'on', 'within', 'in', 'during', 'per', 'without', 'throughout', 'through', 'than', 'via', 'up', 'unlike', 'despite', 'below', 'unless', 'towards', 'besides', 'after', 'whereas', '\'o', 'amidst', 'amongst', 'apropos', 'atop', 'barring', 'chez', 'circa', 'mid', 'midst', 'notwithstanding', 'qua', 'sans', 'vis-a-vis', 'thru', 'till', 'versus', 'without', 'w/o', 'o\'', 'a\''], + + //modal verbs + 'MD': ['can', 'may', 'could', 'might', 'will', 'ought to', 'would', 'must', 'shall', 'should', 'ought', 'shant', 'lets'], + + //arguable + //Possessive pronouns + 'PP': ['mine', 'something', 'none', 'anything', 'anyone', 'theirs', 'himself', 'ours', 'his', 'my', 'their', 'yours', 'your', 'our', 'its', 'herself', 'hers', 'themselves', 'myself', 'itself', 'her', //this one is pretty ambiguous + 'who', 'whom', 'whose'], + + //personal pronouns (nouns) + 'PRP': ['it', 'they', 'i', 'them', 'you', 'she', 'me', 'he', 'him', 'ourselves', 'us', 'we', 'thou', 'il', 'elle', 'yourself', '\'em'], + + //some manual adverbs (the rest are generated) + 'RB': [ + // 'now', + 'again', 'already', 'soon', 'directly', 'toward', 'forever', 'apart', 'instead', 'yes', 'alone', 'indeed', 'ever', 'quite', 'perhaps', 'where', 'then', 'here', 'thus', 'very', 'often', 'once', 'never', 'why', 'when', 'away', 'always', 'sometimes', 'also', 'maybe', 'so', 'just', 'well', 'several', 'such', 'randomly', 'too', 'rather', 'abroad', 'almost', 'anyway', 'twice', 'aside', 'moreover', 'anymore', 'newly', 'damn', 'somewhat', 'somehow', 'meanwhile', 'hence', 'further', 'furthermore', 'more', 'way', 'kinda', 'totally'], + + // 'notably', + //interjections, expressions + 'EX': ['uh', 'uhh', 'uh huh', 'uh-oh', 'please', 'ugh', 'sheesh', 'eww', 'pff', 'voila', 'oy', 'hi', 'hello', 'bye', 'goodbye', 'hey', 'hai', 'eep', 'hurrah', 'yuck', 'ow', 'duh', 'oh', 'hmm', 'yeah', 'whoa', 'ooh', 'whee', 'ah', 'bah', 'gah', 'yaa', 'phew', 'gee', 'ahem', 'eek', 'meh', 'yahoo', 'oops', 'd\'oh', 'psst', 'argh', 'grr', 'nah', 'shhh', 'whew', 'mmm', 'ooo', 'yay', 'uh-huh', 'boo', 'wow', 'nope', 'haha', 'hahaha', 'lol', 'lols', 'ya', 'hee', 'ohh', 'eh', 'yup'], + + //special nouns that shouldnt be seen as a verb + 'NN': ['nothing', 'everything', 'god', 'dollar', 'student', 'patent', 'funding', 'banking', 'ceiling', 'energy', 'purpose', 'friend', 'event', 'room', 'door', 'thing', 'things', 'stuff', 'lunch', 'breakfast', 'dinner', 'home', 'problem', 'body', 'world', 'city', 'death', 'others'], + //family-terms are people + PN: ['father', 'mother', 'mom', 'dad', 'mommy', 'daddy', 'sister', 'brother', 'aunt', 'uncle', 'grandfather', 'grandmother', 'cousin', 'stepfather', 'stepmother', 'boy', 'girl', 'man', 'men', 'woman', 'women', 'guy', 'dude', 'bro', 'gentleman', 'someone'] + }; + //unpack the compact terms into the misc lexicon.. + var keys = Object.keys(compact); + for (var i = 0; i < keys.length; i++) { + var arr = compact[keys[i]]; + for (var i2 = 0; i2 < arr.length; i2++) { + misc[arr[i2]] = keys[i]; + } + } + // console.log(misc.a); + module.exports = misc; + }, {}], 13: [function (require, module, exports) { + 'use strict'; + + //common terms that are multi-word, but one part-of-speech + //these should not include phrasal verbs, like 'looked out'. These are handled elsewhere. + + module.exports = { + 'a few': 'CD', //different than 'few people' + 'of course': 'RB', + 'at least': 'RB', + 'no longer': 'RB', + 'sort of': 'RB', + // 'at first': 'RB', + 'once again': 'RB', + 'once more': 'RB', + 'up to': 'RB', + 'by now': 'RB', + 'all but': 'RB', + 'just about': 'RB', + 'so called': 'JJ', //? + 'on board': 'JJ', + 'a lot': 'RB', + 'by far': 'RB', + 'at best': 'RB', + 'at large': 'RB', + 'for good': 'RB', + 'for example': 'RB', + 'vice versa': 'JJ', + 'en route': 'JJ', + 'for sure': 'RB', + 'upside down': 'JJ', + 'at most': 'RB', + 'per se': 'RB', + 'at worst': 'RB', + 'upwards of': 'RB', + 'en masse': 'RB', + 'point blank': 'RB', + 'up front': 'JJ', + 'in front': 'JJ', + 'in situ': 'JJ', + 'in vitro': 'JJ', + 'ad hoc': 'JJ', + 'de facto': 'JJ', + 'ad infinitum': 'JJ', + 'ad nauseam': 'RB', + 'for keeps': 'JJ', + 'a priori': 'JJ', + 'et cetera': 'IN', + 'off guard': 'JJ', + 'spot on': 'JJ', + 'ipso facto': 'JJ', + 'not withstanding': 'RB', + 'de jure': 'RB', + 'a la': 'IN', + 'ad hominem': 'NN', + 'par excellence': 'RB', + 'de trop': 'RB', + 'a posteriori': 'RB', + 'fed up': 'JJ', + 'brand new': 'JJ', + 'old fashioned': 'JJ', + 'bona fide': 'JJ', + 'well off': 'JJ', + 'far off': 'JJ', + 'straight forward': 'JJ', + 'hard up': 'JJ', + 'sui generis': 'JJ', + 'en suite': 'JJ', + 'avant garde': 'JJ', + 'sans serif': 'JJ', + 'gung ho': 'JJ', + 'super duper': 'JJ', + 'new york': 'NN', + 'new england': 'NN', + 'new hampshire': 'NN', + 'new delhi': 'NN', + 'new jersey': 'NN', + 'new mexico': 'NN', + 'united states': 'NN', + 'united kingdom': 'NN', + 'great britain': 'NN', + 'head start': 'NN', + 'make sure': 'VB', + 'keep tabs': 'VB', + 'credit card': 'NN', + //timezones + 'standard time': 'DA', + 'daylight time': 'DA', + 'summer time': 'DA' + }; + }, {}], 14: [function (require, module, exports) { + 'use strict'; + + var fns = require('../../fns'); + + //the unique/uncompressed names.. + var arr = ['abby', 'amy', 'autumn', 'bobbi', 'brooke', 'carol', 'cheryl', 'claire', 'cleo', 'consuelo', + // 'dawn', + 'eleanor', 'eliza', 'erika', 'faye', 'fern', 'genevieve', 'gertrude', 'gladys', 'inez', 'ingrid', 'jenny', 'jo', 'joni', 'kathryn', 'kelli', 'kim', 'latoya', 'leigh', 'lupe', 'luz', 'lynn', 'mae', 'maude', 'mildred', 'miriam', 'naomi', 'nikki', 'olga', 'reba', 'robyn', 'rosalind', 'ruth', 'sheryl', 'socorro', 'sonja', 'staci', 'tanya', 'therese', 'toni', 'traci', 'vicki', 'vicky']; + + //compressed by frequent suffixes + var suffix_compressed = { + nette: 'an,antoi,ja,jea,jean,ly', + eline: 'ad,ang,jacqu,mad', + rlene: 'a,cha,da,ma', + stine: 'chri,erne,ju,kri', + tasha: 'la,na,', + andra: 'alex,cass,s', + helle: 'mic,rac,roc', + linda: 'be,,me', + stina: 'chri,cri,kri', + annie: ',f,je', + anne: ',di,je,jo,le,mari,rox,sus,suz', + elia: 'am,ang,cec,c,corn,d,of,sh', + llie: 'ca,ke,li,mi,mo,ne,o,sa', + anna: ',de,di,jo,joh,sh', + ette: 'bernad,b,bridg,claud,paul,yv', + ella: 'd,,est,lu,marc,st', + nnie: 'bo,co,je,mi,wi', + elle: 'dani,est,gabri,isab,jan', + icia: 'al,fel,let,patr,tr', + leen: 'ai,cath,col,ei,kath', + elma: ',s,th,v', + etta: ',henri,lor,ros', + anie: 'j,mel,stef,steph', + anda: 'am,mir,w,yol', + arla: 'c,d,k,m', + lena: 'e,he,,magda', + rina: 'kat,ma,sab,t', + isha: 'al,ke,lat,tr', + olly: 'd,m,p', + rice: 'beat,cla,pat', + ttie: 'be,ma,ne', + acie: 'gr,st,tr', + isty: 'chr,kr,m', + dith: 'e,ju,mere', + onya: 'lat,s,t', + onia: 'ant,s,t', + erri: 'k,sh,t', + lisa: 'a,e,', + rine: 'cathe,katha,kathe', + nita: 'a,bo,jua', + elyn: 'ev,jacqu,joc', + nine: 'ja,jea,jean', + nice: 'ber,eu,ja', + tney: 'brit,cour,whi', + ssie: 'be,ca,e', + beth: ',elisa,eliza', + ine: 'carol,ela,franc,gerald,jasm,joseph,lorra,max,nad,paul', + ana: 'adri,,d,de,di,j,ju,l,sh,sus', + rie: 'car,che,lau,lo,ma,marjo,rosema,sher,vale', + ina: 'angel,carol,d,georg,g,josef,mart,n,t', + ora: 'c,deb,d,fl,len,l,n,', + ara: 'barb,c,cl,k,l,s,tam,t', + ela: 'ang,carm,gabri,graci,l,manu,pam', + ica: 'angel,er,jess,mon,patr,veron', + nda: 'bre,gle,luci,ly,rho,ro', + ley: 'ash,kel,kimber,les,shel,shir', + eri: 'ch,j,k,sh,t', + ndy: 'ci,ma,mi,sa,we', + ene: 'hel,imog,ir,jol,lor', + ula: 'e,l,pa,urs', + ann: ',jo,le,mary', + ola: 'le,l,,vi', + nna: 'do,gle,je,lado', + nne: 'adrie,cori,ly,yvo', + lie: 'ju,les,nata,rosa', + ise: 'den,el,elo,lou', + die: 'ad,gol,jo,sa', + ena: 'd,lor,r,she', + ian: 'jill,lill,mar,viv', + lyn: 'caro,gwendo,jac,mari', + ssa: 'aly,mari,meli,vane', + thy: 'ca,doro,dor,ka', + tha: 'ber,mar,saman,tabi', + sie: 'el,jo,ro,su', + bel: 'isa,ma,mari', + via: 'oli,sil,syl', + tie: 'chris,ka,kris', + dra: 'au,ken,son', + ria: 'glo,ma,victo', + gie: 'an,mag,mar', + lly: 'ke,sa,she', + ila: 'le,l,she', + rna: 'lo,my,ve', + ole: 'car,nich,nic', + rma: 'e,i,no', + any: 'beth,britt,tiff', + ona: 'le,m,ram', + rta: 'albe,ma,robe', + en: 'carm,dore,ell,gretch,gw,hel,kar,kirst,krist,laur,maure', + ia: 'cecil,claud,cynth,eugen,georg,jul,luc,lyd,marc,soph,virgin', + le: 'ade,camil,ceci,ga,gay,luci,lucil,mab,miche,myrt', + ie: 'bobb,debb,dix,eff,jack,lizz,mam,soph,tamm,vick', + ra: 'barb,deb,elvi,lau,may,my,pet,ve', + er: 'amb,est,esth,heath,jenif,jennif,summ', + da: 'a,ai,fre,frie,hil,i,matil', + ce: 'ali,canda,candi,constan,floren,gra,joy', + ah: 'beul,debor,hann,le,rebek,sar', + sa: 'el,lui,mari,ro,tere,there', + ne: 'daph,dia,ja,jay,laver,simo', + el: 'eth,laur,muri,racha,rach,raqu', + is: 'delor,dor,jan,lo,mav,phyll', + et: 'bridg,harri,jan,margar,margr', + ta: 'al,chris,kris,margari,ri', + es: 'agn,delor,dolor,franc,merced', + an: 'jo,meag,meg,megh,sus', + cy: 'lu,mar,nan,sta,tra', + in: 'caitl,er,kar,krist', + ey: 'audr,linds,stac,trac', + ca: 'bian,blan,francis,rebec', + on: 'alis,allis,shann,shar', + il: 'abiga,apr,ga,syb', + ly: 'bever,emi,kimber,li', + ea: 'andr,chels,doroth,l', + ee: 'aim,d,desir,ren', + ma: 'al,em,wil', + di: 'bran,hei,jo', + va: 'el,e,i', + ue: 'dominiq,moniq,s', + ay: 'f,k,linds', + te: 'celes,ka,margueri', + ry: 'ma,rosema,sher', + na: 'ed,shau,shaw', + dy: 'jo,ju,tru', + ti: 'chris,kris,pat', + sy: 'bet,dai,pat', + ri: 'ka,lo,sha', + la: 'kay,priscil,wil', + al: 'cryst,kryst,op', + ll: 'jewe,ji,ne' + }; + arr = fns.expand_suffixes(arr, suffix_compressed); + + var prefix_compressed = { + mar: 'go,isol,itza,sha', + tam: 'i,ika,my', + be: 'atriz,cky,tty,ttye', + pe: 'arl,ggy,nny', + pa: 'ige,m,tty' + }; + arr = fns.expand_prefixes(arr, prefix_compressed); + + module.exports = arr; + }, { "../../fns": 23 }], 15: [function (require, module, exports) { + 'use strict'; + + var fns = require('../../fns'); + + //the unique/uncompressed names.. + var arr = ['adolfo', 'angelo', 'anthony', 'armand', 'arthur', 'bill', 'billy', 'bobby', 'bradford', 'bret', 'caleb', 'carroll', 'cliff', 'clifford', 'craig', 'curt', 'derek', 'doug', 'dwight', 'edmund', 'eli', 'elliot', 'enrique', 'erik', 'felipe', 'felix', 'francisco', 'frank', 'george', 'glenn', 'greg', 'gregg', 'hans', 'hugh', 'ira', 'irving', 'isaac', 'jim', 'kermit', 'kurt', 'leo', 'levi', 'lorenzo', 'lou', 'pablo', 'pat', 'percy', 'philip', 'phillip', 'rex', 'ricky', 'shaun', 'shawn', 'sterling', 'steve', 'tim', 'timothy', 'wilbur', 'williams', 'wm', 'woodrow']; + + //compressed by frequent suffixes + var suffix_compressed = { + rence: 'cla,lau,law,te,ter', + lbert: 'a,de,e,gi,wi', + ustin: 'ag,a,d,j', + berto: 'al,gil,hum,ro', + ester: 'ch,l,sylv', + onnie: 'd,l,r', + wayne: 'de,d,', + erick: ',fred,rod', + athan: 'john,jon,n', + elvin: ',k,m', + anuel: 'em,emm,m', + bert: ',her,hu,nor,ro', + rick: 'der,fred,kend,pat,', + land: 'cleve,gar,le,ro', + ando: 'arm,fern,orl,rol', + ardo: 'edu,ger,leon,ric', + lton: 'a,car,e,mi', + arry: 'b,g,h,l', + nton: 'a,cli,qui', + fred: 'al,,wil', + ance: 'l,terr,v', + mmie: 'ji,sa,to', + erry: 'j,p,t', + mond: 'des,ed,ray', + rman: 'he,no,she', + rvin: 'e,i,ma', + nald: 'do,regi,ro', + rett: 'b,eve,gar', + son: 'harri,jack,ja,ma,nel,ty,wil', + ell: 'darn,darr,low,mitch,russ,terr,wend', + ard: 'bern,edw,ger,how,leon,rich,will', + ian: 'adr,br,christ,dam,fab,,jul', + don: 'bran,,el,gor,shel', + ron: 'aa,by,came,my,', + ton: 'bur,clay,clif,pres,wins', + lan: 'a,al,dy,har,no', + rey: 'ca,co,geoff,jeff', + ent: 'br,k,tr,vinc', + ael: 'ism,mich,raf,raph', + mmy: 'ji,sa,ti,to', + mon: 'da,ra,si,solo', + las: 'dal,doug,nicho,nico', + vin: 'al,cal,de,ke', + nny: 'be,da,joh,ke', + ius: 'cornel,dar,demetr,jul', + ley: 'brad,har,stan,wes', + lio: 'emi,ju,roge', + ben: ',reu,ru', + ory: 'c,greg,r', + lie: 'bil,char,wil', + van: 'e,i,', + roy: 'le,,t', + all: 'kend,marsh,rand', + ary: 'c,g,zach', + ddy: 'bu,fre,te', + art: 'b,stew,stu', + iel: 'dan,gabr,nathan', + lin: 'co,frank,mar', + yle: 'do,k,l', + her: 'christop,kristop,lut', + oyd: 'b,fl,ll', + ren: 'dar,lo,war', + ter: 'dex,pe,wal', + arl: 'c,e,k', + ane: 'd,du,sh', + aul: 'p,r,s', + dan: 'bren,,jor', + nie: 'ben,er,john', + ine: 'anto,bla,jerma', + lph: 'ra,rando,rudo', + est: 'earn,ern,forr', + win: 'dar,ed,er', + is: 'chr,curt,den,denn,ell,franc,lew,lou,lu,morr,ot,trav,will', + er: 'alexand,elm,grov,hom,jasp,javi,oliv,rodg,rog,spenc,tyl,xavi', + an: 'bry,de,esteb,eth,ju,log,rom,ry,se,st,steph', + el: 'ab,darr,fid,jo,lion,marc,mich,migu,no,russ,samu', + in: 'benjam,bra,dar,darr,efra,joaqu,mart,quent', + ie: 'arch,edd,frank,fredd,lou,regg,robb', + en: 'all,dami,gl,k,ow,steph,stev', + ey: 'dew,harv,jo,mick,rick,rodn,sidn', + al: ',h,jam,miche,ne,rand', + on: 'bry,j,jonath,le,marl,vern', + or: 'hect,juni,salvad,tayl,trev,vict', + dy: 'an,bra,co,gra,ran,ru', + ce: 'bru,bry,hora,mauri,roy,walla', + il: 'cec,em,ne,ph,virg', + ar: 'ces,edg,lam,om,osc', + es: 'andr,charl,jam,mil,mos', + ro: 'alejand,alva,artu,ped,rami', + am: 'abrah,ad,grah,s,willi', + ck: 'chu,domini,ja,ma,ni', + io: 'anton,gregor,ignac,mar,serg', + ah: 'elij,jeremi,mic,no', + nt: 'brya,cli,gra,lamo', + re: 'and,pier,salvato,theodo', + ed: ',jar,n,t', + ld: 'arno,gera,haro,jera', + as: 'eli,luc,thom,tom', + os: 'am,carl,marc,sant', + ew: 'andr,dr,math,matth', + ke: 'bla,ja,lu,mi', + tt: 'ellio,emme,ma,sco', + ty: 'mar,mon,rus,scot', + th: 'hea,kei,kenne,se', + ay: 'cl,j,murr,r', + le: 'da,mer,orvil', + te: 'mon,pe,vicen', + us: 'jes,marc,ruf', + od: 'elwo,jarr,r', + ob: 'b,jac,r', + to: 'beni,ernes,ot', + ne: 'euge,ge,tyro', + go: 'domin,hu,santia', + de: 'clau,cly,wa', + do: 'alfre,reynal,wilfre', + rk: 'cla,ki,ma', + se: 'cha,jes,jo', + ry: 'hen,jeffe,jeff', + ic: 'cedr,domin,er', + ad: 'br,ch,conr' + }; + + arr = fns.expand_suffixes(arr, suffix_compressed); + + var prefix_compressed = { + jos: 'eph,h,hua', + ro: 'cky,dolfo,osevelt,scoe,ss', + je: 'ff,remy,rome,ss', + to: 'by,dd,m,ny', + da: 'rryl,ryl,ve,vid', + jo: 'e,esph,hn,rge', + ma: 'lcolm,rc,rco,x', + al: 'ex,fonso,i,onzo', + gu: 'illermo,stavo,y' + }; + arr = fns.expand_prefixes(arr, prefix_compressed); + + module.exports = arr; + }, { "../../fns": 23 }], 16: [function (require, module, exports) { + 'use strict'; + + var cardinal = { + ones: { + 'a': 1, + 'zero': 0, + 'one': 1, + 'two': 2, + 'three': 3, + 'four': 4, + 'five': 5, + 'six': 6, + 'seven': 7, + 'eight': 8, + 'nine': 9 + }, + teens: { + 'ten': 10, + 'eleven': 11, + 'twelve': 12, + 'thirteen': 13, + 'fourteen': 14, + 'fifteen': 15, + 'sixteen': 16, + 'seventeen': 17, + 'eighteen': 18, + 'nineteen': 19 + }, + tens: { + 'twenty': 20, + 'thirty': 30, + 'forty': 40, + 'fifty': 50, + 'sixty': 60, + 'seventy': 70, + 'eighty': 80, + 'ninety': 90 + }, + multiples: { + 'hundred': 100, + 'grand': 1000, + 'thousand': 1000, + 'million': 1000000, + 'billion': 1000000000, + 'trillion': 1000000000000, + 'quadrillion': 1000000000000000, + 'quintillion': 1000000000000000000, + 'sextillion': 1000000000000000000000, + 'septillion': 1000000000000000000000000 + } + }; + + var ordinal = { + ones: { + 'first': 1, + 'second': 2, + 'third': 3, + 'fourth': 4, + 'fifth': 5, + 'sixth': 6, + 'seventh': 7, + 'eighth': 8, + 'ninth': 9 + }, + teens: { + 'tenth': 10, + 'eleventh': 11, + 'twelfth': 12, + 'thirteenth': 13, + 'fourteenth': 14, + 'fifteenth': 15, + 'sixteenth': 16, + 'seventeenth': 17, + 'eighteenth': 18, + 'nineteenth': 19 + }, + tens: { + 'twentieth': 20, + 'thirtieth': 30, + 'fourtieth': 40, + 'fiftieth': 50, + 'sixtieth': 60, + 'seventieth': 70, + 'eightieth': 80, + 'ninetieth': 90 + }, + multiples: { + 'hundredth': 100, + 'thousandth': 1000, + 'millionth': 1000000, + 'billionth': 1000000000, + 'trillionth': 1000000000000, + 'quadrillionth': 1000000000000000, + 'quintillionth': 1000000000000000000, + 'sextillionth': 1000000000000000000000, + 'septillionth': 1000000000000000000000000 + } + }; + + //used for the units + var prefixes = { + 'yotta': 1, + 'zeta': 1, + 'peta': 1, + 'tera': 1, + 'giga': 1, + 'mega': 1, + 'kilo': 1, + 'hecto': 1, + 'deca': 1, + 'centi': 1, + 'centa': 1, + 'milli': 1, + 'micro': 1, + 'nano': 1, + 'pico': 1, + 'femto': 1, + 'atto': 1, + 'zepto': 1, + 'yokto': 1, + + 'square': 1, + 'cubic': 1, + 'quartic': 1 + }; + + module.exports = { + ones: cardinal.ones, + teens: cardinal.teens, + tens: cardinal.tens, + multiples: cardinal.multiples, + + ordinal_ones: ordinal.ones, + ordinal_teens: ordinal.teens, + ordinal_tens: ordinal.tens, + ordinal_multiples: ordinal.multiples, + + prefixes: prefixes + }; + }, {}], 17: [function (require, module, exports) { + 'use strict'; + //just a few named-organizations + //no acronyms needed. no product/brand pollution. + + var organizations = ['google', 'microsoft', 'walmart', 'exxonmobil', 'glencore', 'samsung', 'chevron', 'at&t', 'verizon', 'costco', 'nestlé', '7-eleven', 'adidas', 'nike', 'acer', 'mcdonalds', 'mcdonald\'s', 'comcast', 'compaq', 'craigslist', 'cisco', 'disney', 'coca cola', 'dupont', 'ebay', 'facebook', 'fedex', 'kmart', 'kkk', 'kodak', 'monsanto', 'myspace', 'netflix', 'sony', 'telus', 'twitter', 'usps', 'ubs', 'ups', 'walgreens', 'youtube', 'yahoo!', 'yamaha']; + + var suffixes = ['center', 'centre', 'memorial', 'school', 'government', 'faculty', 'society', 'union', 'ministry', 'collective', 'association', 'committee', 'university', 'bank', 'college', 'foundation', 'department', 'institute', 'club', 'co', 'sons']; + + module.exports = { + suffixes: suffixes, + organizations: organizations + }; + }, {}], 18: [function (require, module, exports) { + //phrasal verbs are two words that really mean one verb. + //'beef up' is one verb, and not some direction of beefing. + //by @spencermountain, 2015 mit + //many credits to http://www.allmyphrasalverbs.com/ + 'use strict'; + + var verb_conjugate = require('../term/verb/conjugate/conjugate.js'); + + //start the list with some randoms + var main = ['be onto', 'fall behind', 'fall through', 'fool with', 'get across', 'get along', 'get at', 'give way', 'hear from', 'hear of', 'lash into', 'make do', 'run across', 'set upon', 'take aback', 'keep from']; + + //if there's a phrasal verb "keep on", there's often a "keep off" + var opposites = { + 'away': 'back', + 'in': 'out', + 'on': 'off', + 'over': 'under', + 'together': 'apart', + 'up': 'down' + }; + + //forms that have in/out symmetry + var symmetric = { + 'away': 'blow,bounce,bring,call,come,cut,drop,fire,get,give,go,keep,pass,put,run,send,shoot,switch,take,tie,throw', + 'in': 'bang,barge,bash,beat,block,book,box,break,bring,burn,butt,carve,cash,check,come,cross,drop,fall,fence,fill,give,grow,hand,hang,head,jack,keep,leave,let,lock,log,move,opt,pack,peel,pull,put,rain,reach,ring,rub,send,set,settle,shut,sign,smash,snow,strike,take,try,turn,type,warm,wave,wean,wear,wheel', + 'on': 'add,call,carry,catch,count,feed,get,give,go,grind,head,hold,keep,lay,log,pass,pop,power,put,send,show,snap,switch,take,tell,try,turn,wait', + 'over': 'come,go,look,read,run,talk', + 'together': 'come,pull,put', + 'up': 'add,back,beat,bend,blow,boil,bottle,break,bring,buckle,bundle,call,carve,clean,cut,dress,fill,flag,fold,get,give,grind,grow,hang,hold,keep,let,load,lock,look,man,mark,melt,move,pack,pin,pipe,plump,pop,power,pull,put,rub,scale,scrape,send,set,settle,shake,show,sit,slow,smash,square,stand,strike,take,tear,tie,turn,use,wash,wind' + }; + Object.keys(symmetric).forEach(function (k) { + symmetric[k].split(',').forEach(function (s) { + //add the given form + main.push(s + ' ' + k); + //add its opposite form + main.push(s + ' ' + opposites[k]); + }); + }); + + //forms that don't have in/out symmetry + var asymmetric = { + 'about': 'bring,fool,gad,go,root,mess', + 'after': 'go,look,take', + 'ahead': 'get,go,press', + 'along': 'bring,move', + 'apart': 'fall,take', + 'around': 'ask,boss,bring,call,come,fool,get,horse,joke,lie,mess,play', + 'away': 'back,carry,file,frighten,hide,wash', + 'back': 'fall,fight,hit,hold,look,pay,stand,think', + 'by': 'come,drop,get,go,stop,swear,swing,tick,zip', + 'down': 'bog,calm,fall,hand,hunker,jot,knock,lie,narrow,note,pat,pour,run,tone,trickle,wear', + 'for': 'fend,file,gun,hanker,root,shoot', + 'forth': 'bring,come', + 'forward': 'come,look', + 'in': 'cave,chip,hone,jump,key,pencil,plug,rein,shade,sleep,stop,suck,tie,trade,tuck,usher,weigh,zero', + 'into': 'look,run', + 'it': 'go,have', + 'off': 'auction,be,beat,blast,block,brush,burn,buzz,cast,cool,drop,end,face,fall,fend,frighten,goof,jack,kick,knock,laugh,level,live,make,mouth,nod,pair,pay,peel,read,reel,ring,rip,round,sail,shave,shoot,sleep,slice,split,square,stave,stop,storm,strike,tear,tee,tick,tip,top,walk,work,write', + 'on': 'bank,bargain,frown,hit,latch,pile,prattle,press,spring,spur,tack,urge,yammer', + 'out': 'act,ask,back,bail,bear,black,blank,bleed,blow,blurt,branch,buy,cancel,cut,eat,edge,farm,figure,find,fill,find,fish,fizzle,flake,flame,flare,flesh,flip,geek,get,help,hide,hold,iron,knock,lash,level,listen,lose,luck,make,max,miss,nerd,pan,pass,pick,pig,point,print,psych,rat,read,rent,root,rule,run,scout,see,sell,shout,single,sit,smoke,sort,spell,splash,stamp,start,storm,straighten,suss,time,tire,top,trip,trot,wash,watch,weird,whip,wimp,wipe,work,zone,zonk', + 'over': 'bend,bubble,do,fall,get,gloss,hold,keel,mull,pore,sleep,spill,think,tide,tip', + 'round': 'get,go', + 'through': 'go,run', + 'to': 'keep,see', + 'up': 'act,beef,board,bone,boot,brighten,build,buy,catch,cheer,cook,end,eye,face,fatten,feel,fess,finish,fire,firm,flame,flare,free,freeze,freshen,fry,fuel,gang,gear,goof,hack,ham,heat,hit,hole,hush,jazz,juice,lap,light,lighten,line,link,listen,live,loosen,make,mash,measure,mess,mix,mock,mop,muddle,open,own,pair,patch,pick,prop,psych,read,rough,rustle,save,shack,sign,size,slice,slip,snap,sober,spark,split,spruce,stack,start,stay,stir,stitch,straighten,string,suck,suit,sum,team,tee,think,tidy,tighten,toss,trade,trip,type,vacuum,wait,wake,warm,weigh,whip,wire,wise,word,write,zip' + }; + Object.keys(asymmetric).forEach(function (k) { + asymmetric[k].split(',').forEach(function (s) { + main.push(s + ' ' + k); + }); + }); + + //at his point all verbs are infinitive. lets make this explicit. + main = main.reduce(function (h, s) { + h[s] = 'VBP'; + return h; + }, {}); + + //conjugate every phrasal verb. takes ~30ms + var tags = { + present: 'VB', + past: 'VBD', + future: 'VBF', + gerund: 'VBG', + infinitive: 'VBP' + }; + var cache = {}; //cache individual verbs to speed it up + var split = undefined, + verb = undefined, + particle = undefined, + phrasal = undefined; + Object.keys(main).forEach(function (s) { + split = s.split(' '); + verb = split[0]; + particle = split[1]; + if (cache[verb] === undefined) { + cache[verb] = verb_conjugate(verb); + } + Object.keys(cache[verb]).forEach(function (k) { + phrasal = cache[verb][k] + ' ' + particle; + if (tags[k]) { + main[phrasal] = tags[k]; + } + }); + }); + + // console.log(main); + // console.log(main['mess about']); + module.exports = main; + }, { "../term/verb/conjugate/conjugate.js": 96 }], 19: [function (require, module, exports) { + 'use strict'; + + var fns = require('../fns'); + + //uncompressed country names + var countries = ['usa', 'u.s.a.', 'ussr', 'brazil', 'bangladesh', 'mexico', 'vietnam', 'egypt', 'germany', 'turkey', 'france', 'united kingdom', 'italy', 'kenya', 'iraq', 'morocco', 'peru', 'yemen', 'mozambique', 'sri lanka', 'burkina faso', 'niger', 'netherlands', 'chile', 'malawi', 'ecuador', 'côte d\'ivoire', 'mali', 'zimbabwe', 'chad', 'belgium', 'cuba', 'greece', 'haiti', 'burundi', 'hungary', 'sweden', 'honduras', 'israel', 'laos', 'el salvador', 'libya', 'nicaragua', 'denmark', 'congo-brazzaville', 'kuwait', 'moldova', 'panama', 'jamaica', 'lesotho', 'guinea-bissau', 'timor-leste', 'djibouti', 'fiji', 'comoros', 'solomon islands', 'luxembourg', 'suriname', 'cape verde', 'malta', 'bahamas']; + var compressed_countries = { + istan: 'pak,uzbek,afghan,tajik,turkmen', + ublic: 'czech rep,dominican rep,central african rep', + uinea: 'g,papua new g,equatorial g', + land: 'thai,po,switzer,fin,republic of ire,new zea,swazi,ice', + ania: 'tanz,rom,maurit,lithu,alb', + rica: 'ame,united states of ame,south af,costa ', + mbia: 'colo,za,ga', + eria: 'nig,alg,lib', + nia: 'arme,macedo,slove,esto', + sia: 'indone,rus,malay,tuni', + ina: 'ch,argent,bosnia and herzegov', + tan: 'kazakhs,kyrgyzs,bhu', + ana: 'gh,botsw,guy', + bia: 'saudi ara,ser,nami', + lia: 'austra,soma,mongo', + rea: 'south ko,north ko,erit', + dan: 'su,south su,jor', + ria: 'sy,aust,bulga', + ia: 'ind,ethiop,cambod,boliv,slovak,georg,croat,latv', + an: 'jap,ir,taiw,azerbaij,om', + da: 'ugan,cana,rwan', + us: 'belar,mauriti,cypr', + al: 'nep,seneg,portug', + in: 'spa,ben,bahra', + go: 'dr con,to,trinidad-toba', + la: 'venezue,ango,guatema', + es: 'united stat,philippin,united arab emirat', + on: 'camero,leban,gab', + ar: 'myanm,madagasc,qat', + ay: 'paragu,norw,urugu', + ne: 'ukrai,sierra leo,palesti' + }; + countries = fns.expand_suffixes(countries, compressed_countries); + + /////uncomressed cities + var cities = ['guangzhou', 'ahmedabad', 'phoenix', 'jakarta', 'curitiba', 'moscow', 'tokyo', 'nagoya', 'kobe', 'mexico', 'cebu', 'ho chi minh', 'hanoi', 'giza', 'frankfurt', 'stuttgart', 'i̇zmir', 'paris', 'toulouse', 'nice', 'rome', 'palermo', 'genoa', 'cape town', 'port elizabeth', 'bogotá', 'medellín', 'seville', 'zaragoza', 'kiev', 'odessa', 'rosario', 'la plata', 'warsaw', 'kraków', 'łódź', 'wrocław', 'poznań', 'calgary', 'ottawa', 'sydney', 'perth', 'homs', 'iași', 'cluj-napoca', 'almaty', 'the hague', 'utrecht', 'phnom penh', 'antwerp', 'ghent', 'brussels', 'tunis', 'athens', 'thessaloniki', 'prague', 'brno', 'miskolc', 'stockholm', 'västerås', 'tegucigalpa', 'graz', 'innsbruck', 'abu dhabi', 'haifa', 'ashdod', 'dushanbe', 'niš', 'aqaba', 'aalborg', 'helsinki', 'espoo', 'vantaa', 'turku', 'košice', 'ashgabat', 'oslo', 'trondheim', 'auckland', 'tbilisi', 'zagreb', 'split', 'kuwait', 'montevideo', 'klaipėda', 'doha', 'skopje', 'riga', 'luxembourg', 'reykjavik', 'kingston']; + + var suffix_compressed_cities = { + burg: 'saint peters,yekaterin,ham,til,gothen,salz', + ton: 'hous,edmon,welling,hamil', + ion: 'hauts-bassins reg,nord reg,herakl', + ana: 'hav,tir,ljublj', + ara: 'guadalaj,ank,timișo', + an: 'tehr,mil,durb,bus,tain,abidj,amm,yerev', + ia: 'philadelph,brasíl,alexandr,pretor,valenc,sof,nicos', + on: 'ly,lond,yang,inche,daeje,lisb', + en: 'shenzh,eindhov,pils,copenhag,berg', + ng: 'beiji,chittago,pyongya,kaohsiu,taichu', + in: 'tianj,berl,tur,dubl,duned', + es: 'los angel,nant,napl,buenos air,f', + la: 'pueb,mani,barranquil,kampa,guatema', + or: 'salvad,san salvad,ulan bat,marib', + us: 'damasc,pirae,aarh,vilni', + as: 'carac,patr,burg,kaun', + va: 'craio,petah tik,gene,bratisla', + ai: 'shangh,mumb,chenn,chiang m', + ne: 'colog,melbour,brisba,lausan', + er: 'manchest,vancouv,tangi', + ka: 'dha,osa,banja lu', + ro: 'rio de janei,sappo,cai', + am: 'birmingh,amsterd,rotterd', + ur: 'kuala lump,winterth,kópavog', + ch: 'muni,züri,christchur', + na: 'barcelo,vien,var', + ma: 'yokoha,li,pana', + ul: 'istanb,seo,kab', + to: 'toron,qui,por', + iv: 'khark,lv,tel av', + sk: 'dnipropetrov,gdań,min' + }; + + cities = fns.expand_suffixes(cities, suffix_compressed_cities); + + var prefix_compressed_cities = { + 'new ': 'delhi,york,taipei', + san: 'a\'a,tiago, josé', + ta: 'ipei,mpere,llinn,rtu', + ba: 'ngalore,ngkok,ku,sel', + li: 'verpool,ège,nz,massol', + ma: 'rseille,ndalay,drid,lmö', + be: 'rn,lgrade,irut', + ka: 'rachi,raj,ndy', + da: 'egu,kar,ugavpils', + ch: 'icago,arleroi,ișinău', + co: 'lombo,nstanța,rk', + bu: 'rsa,charest,dapest' + }; + cities = fns.expand_prefixes(cities, prefix_compressed_cities); + + module.exports = { + countries: countries, + cities: cities + }; + // console.log(cities[99]); + // console.log(countries[99]); + }, { "../fns": 23 }], 20: [function (require, module, exports) { + 'use strict'; + + //professions 'lawyer' that aren't covered by verb.to_actor() + + module.exports = ['accountant', 'advisor', 'farmer', 'mechanic', 'technician', 'architect', 'clerk', 'therapist', 'bricklayer', 'butcher', 'carpenter', 'nurse', 'engineer', 'supervisor', 'attendant', 'operator', 'dietician', 'housekeeper', 'advisor', 'agent', 'firefighter', 'fireman', 'policeman', 'attendant', 'scientist', 'gardener', 'hairdresser', 'instructor', 'programmer', 'administrator', 'journalist', 'assistant', 'lawyer', 'officer', 'plumber', 'inspector', 'psychologist', 'receptionist', 'roofer', 'sailor', 'security guard', 'photographer', 'soldier', 'surgeon', 'researcher', 'practitioner', 'politician', 'musician', 'artist', 'secretary', 'minister', 'deputy', 'president']; + }, {}], 21: [function (require, module, exports) { + 'use strict'; + + //common nouns that have no plural form. These are suprisingly rare + //used in noun.inflect(), and added as nouns in lexicon + + module.exports = ['aircraft', 'bass', 'bison', 'fowl', 'halibut', 'moose', 'salmon', 'spacecraft', 'tuna', 'trout', 'advice', 'information', 'knowledge', 'trouble', 'enjoyment', 'fun', 'recreation', 'relaxation', 'meat', 'rice', 'bread', 'cake', 'coffee', 'ice', 'water', 'oil', 'grass', 'hair', 'fruit', 'wildlife', 'equipment', 'machinery', 'furniture', 'mail', 'luggage', 'jewelry', 'clothing', 'money', 'mathematics', 'economics', 'physics', 'civics', 'ethics', 'gymnastics', 'mumps', 'measles', 'news', 'tennis', 'baggage', 'currency', 'soap', 'toothpaste', 'food', 'sugar', 'butter', 'flour', 'research', 'leather', 'wool', 'wood', 'coal', 'weather', 'homework', 'cotton', 'silk', 'patience', 'impatience', 'vinegar', 'art', 'beef', 'blood', 'cash', 'chaos', 'cheese', 'chewing', 'conduct', 'confusion', 'education', 'electricity', 'entertainment', 'fiction', 'forgiveness', 'gold', 'gossip', 'ground', 'happiness', 'history', 'honey', 'hospitality', 'importance', 'justice', 'laughter', 'leisure', 'lightning', 'literature', 'luck', 'melancholy', 'milk', 'mist', 'music', 'noise', 'oxygen', 'paper', 'peace', 'peanut', 'pepper', 'petrol', 'plastic', 'pork', 'power', 'pressure', 'rain', 'recognition', 'sadness', 'safety', 'salt', 'sand', 'scenery', 'shopping', 'silver', 'snow', 'softness', 'space', 'speed', 'steam', 'sunshine', 'tea', 'thunder', 'time', 'traffic', 'trousers', 'violence', 'warmth', 'wine', 'steel', 'soccer', 'hockey', 'golf', 'fish', 'gum', 'liquid', 'series', 'sheep', 'species', 'fahrenheit', 'celcius', 'kelvin', 'hertz', 'everyone', 'everybody']; + }, {}], 22: [function (require, module, exports) { + //most-frequent non-irregular verbs, in infinitive form, to be conjugated for the lexicon + //this list is the seed, from which various forms are conjugated + 'use strict'; + + var fns = require('../fns'); + + //suffix-index adjectives + // {cial:'cru,spe'} -> 'crucial', 'special' + var compressed = { + prove: 'im,,ap,disap', + serve: ',de,ob,re', + ress: 'exp,p,prog,st,add,d', + lect: 'ref,se,neg,col,e', + sist: 'in,con,per,re,as', + tain: 'ob,con,main,s,re', + mble: 'rese,gru,asse,stu', + ture: 'frac,lec,tor,fea', + port: 're,sup,ex,im', + ate: 'rel,oper,indic,cre,h,activ,estim,particip,d,anticip,evalu', + use: 'ca,,over,ref,acc,am,pa,ho', + ive: 'l,rece,d,arr,str,surv,thr,rel', + are: 'prep,c,comp,sh,st,decl,d,sc', + ine: 'exam,imag,determ,comb,l,decl,underm,def', + nce: 'annou,da,experie,influe,bou,convi,enha', + ain: 'tr,rem,expl,dr,compl,g,str', + ent: 'prev,repres,r,res,rel,inv', + age: 'dam,mess,man,encour,eng,discour', + rge: 'su,cha,eme,u,me', + ise: 'ra,exerc,prom,surpr,pra', + ect: 'susp,dir,exp,def,rej', + ter: 'en,mat,cen,ca,al', + end: 't,dep,,ext,att', + est: 't,sugg,prot,requ,r', + ock: 'kn,l,sh,bl,unl', + nge: 'cha,excha,ra,challe,plu', + ase: 'incre,decre,purch,b,ce', + ish: 'establ,publ,w,fin,distingu', + mit: 'per,ad,sub,li', + ure: 'fig,ens,end,meas', + der: 'won,consi,mur,wan', + ave: 's,sh,w,cr', + ire: 'requ,des,h,ret', + tch: 'scra,swi,ma,stre', + ack: 'att,l,p,cr', + ion: 'ment,quest,funct,envis', + ump: 'j,l,p,d', + ide: 'dec,prov,gu,s', + ush: 'br,cr,p,r', + eat: 'def,h,tr,ch', + ash: 'sm,spl,w,fl', + rry: 'ca,ma,hu,wo', + ear: 'app,f,b,disapp', + er: 'answ,rememb,off,suff,cov,discov,diff,gath,deliv,both,empow,with', + le: 'fi,sett,hand,sca,whist,enab,smi,ming,ru,sprink,pi', + st: 'exi,foreca,ho,po,twi,tru,li,adju,boa,contra,boo', + it: 'vis,ed,depos,sp,awa,inhib,cred,benef,prohib,inhab', + nt: 'wa,hu,pri,poi,cou,accou,confro,warra,pai', + ch: 'laun,rea,approa,sear,tou,ar,enri,atta', + ss: 'discu,gue,ki,pa,proce,cro,glo,dismi', + ll: 'fi,pu,ki,ca,ro,sme,reca,insta', + rn: 'tu,lea,conce,retu,bu,ea,wa,gove', + ce: 'redu,produ,divor,fa,noti,pla,for,repla', + te: 'contribu,uni,tas,vo,no,constitu,ci', + rt: 'sta,comfo,exe,depa,asse,reso,conve', + ck: 'su,pi,che,ki,tri,wre', + ct: 'intera,restri,predi,attra,depi,condu', + ke: 'sta,li,bra,overta,smo,disli', + se: 'collap,suppo,clo,rever,po,sen', + nd: 'mi,surrou,dema,remi,expa,comma', + ve: 'achie,invol,remo,lo,belie,mo', + rm: 'fo,perfo,confi,confo,ha', + or: 'lab,mirr,fav,monit,hon', + ue: 'arg,contin,val,iss,purs', + ow: 'all,foll,sn,fl,borr', + ay: 'pl,st,betr,displ,portr', + ze: 'recogni,reali,snee,ga,emphasi', + ip: 'cl,d,gr,sl,sk', + re: 'igno,sto,interfe,sco', + ng: 'spri,ba,belo,cli', + ew: 'scr,vi,revi,ch', + gh: 'cou,lau,outwei,wei', + ly: 'app,supp,re,multip', + ge: 'jud,acknowled,dod,alle', + en: 'list,happ,threat,strength', + ee: 'fors,agr,disagr,guarant', + et: 'budg,regr,mark,targ', + rd: 'rega,gua,rewa,affo', + am: 'dre,j,sl,ro', + ry: 'va,t,c,bu' + }; + var arr = ['hope', 'thank', 'work', 'stop', 'control', 'join', 'enjoy', 'fail', 'aid', 'ask', 'talk', 'add', 'walk', 'describe', 'study', 'seem', 'occur', 'claim', 'fix', 'help', 'design', 'include', 'need', 'keep', 'assume', 'accept', 'do', 'look', 'die', 'seek', 'attempt', 'bomb', 'cook', 'copy', 'claw', 'doubt', 'drift', 'envy', 'fold', 'flood', 'focus', 'lift', 'link', 'load', 'loan', 'melt', 'overlap', 'rub', 'repair', 'sail', 'sleep', 'trade', 'trap', 'travel', 'tune', 'undergo', 'undo', 'uplift', 'yawn', 'plan', 'reveal', 'owe', 'sneak', 'drop', 'name', 'head', 'spoil', 'echo', 'deny', 'yield', 'reason', 'defy', 'applaud', 'risk', 'step', 'deem', 'embody', 'adopt', 'convey', 'pop', 'grab', 'revel', 'stem', 'mark', 'drag', 'pour', 'reckon', 'assign', 'rank', 'destroy', 'float', 'appeal', 'grasp', 'shout', 'overcome', 'relax', 'excel', 'plug', 'proclaim', 'ruin', 'abandon', 'overwhelm', 'wipe', 'added', 'took', 'goes', 'avoid', 'come', 'set', 'pay', 'grow', 'inspect', 'instruct', 'know', 'take', 'let', 'sort', 'put', 'take', 'cut', 'become', 'reply', 'happen', 'watch', 'associate', 'send', 'archive', 'cancel', 'learn']; + + module.exports = fns.expand_suffixes(arr, compressed); + }, { "../fns": 23 }], 23: [function (require, module, exports) { + 'use strict'; + + exports.pluck = function (arr, str) { + arr = arr || []; + return arr.map(function (o) { + return o[str]; + }); + }; + + //make an array of strings easier to lookup + exports.toObj = function (arr) { + return arr.reduce(function (h, a) { + h[a] = true; + return h; + }, {}); + }; + //turn key->value into value->key + exports.reverseObj = function (obj) { + return Object.keys(obj).reduce(function (h, k) { + h[obj[k]] = k; + return h; + }, {}); + }; + + exports.flatten = function (arr) { + var all = []; + arr.forEach(function (a) { + all = all.concat(a); + }); + return all; + }; + + //string utilities + exports.endsWith = function (str, suffix) { + if (str && suffix && str.indexOf(suffix, str.length - suffix.length) !== -1) { + return true; + } + return false; + }; + exports.startsWith = function (str, prefix) { + if (str && str.length && str.substr(0, 1) === prefix) { + return true; + } + return false; + }; + + exports.extend = function (a, b) { + var keys = Object.keys(b); + for (var i = 0; i < keys.length; i++) { + a[keys[i]] = b[keys[i]]; + } + return a; + }; + + exports.titlecase = function (str) { + if (!str) { + return ''; + } + str = str.toLowerCase(); + return str.charAt(0).toUpperCase() + str.slice(1); + }; + + // typeof obj == "function" also works + // but not in older browsers. :-/ + exports.isFunction = function (obj) { + return Object.prototype.toString.call(obj) === '[object Function]'; + }; + + //uncompress data in the adhoc compressed form {'ly':'kind,quick'} + exports.expand_suffixes = function (list, obj) { + var keys = Object.keys(obj); + var l = keys.length; + for (var i = 0; i < l; i++) { + var arr = obj[keys[i]].split(','); + for (var i2 = 0; i2 < arr.length; i2++) { + list.push(arr[i2] + keys[i]); + } + } + return list; + }; + //uncompress data in the adhoc compressed form {'over':'blown,kill'} + exports.expand_prefixes = function (list, obj) { + var keys = Object.keys(obj); + var l = keys.length; + for (var i = 0; i < l; i++) { + var arr = obj[keys[i]].split(','); + for (var i2 = 0; i2 < arr.length; i2++) { + list.push(keys[i] + arr[i2]); + } + } + return list; + }; + }, {}], 24: [function (require, module, exports) { + //the lexicon is a big hash of words to pos tags + //it's built by conjugating and inflecting a small seed of terms + 'use strict'; + + var fns = require('./fns.js'); + var verb_conjugate = require('./term/verb/conjugate/conjugate.js'); + var to_comparative = require('./term/adjective/to_comparative.js'); + var to_superlative = require('./term/adjective/to_superlative.js'); + var to_adverb = require('./term/adjective/to_adverb.js'); + var grand_mapping = require('./sentence/pos/parts_of_speech.js').tag_mapping; + + var lexicon = {}; + + var addObj = function addObj(obj) { + var keys = Object.keys(obj); + var l = keys.length; + for (var i = 0; i < l; i++) { + lexicon[keys[i]] = obj[keys[i]]; + } + }; + + var addArr = function addArr(arr, tag) { + var l = arr.length; + for (var i = 0; i < l; i++) { + lexicon[arr[i]] = tag; + } + }; + + //conjugate all verbs. + var verbMap = { + infinitive: 'Infinitive', + present: 'PresentTense', + past: 'PastTense', + gerund: 'Gerund', + actor: 'Actor', + future: 'FutureTense', + pluperfect: 'PluperfectTense', + perfect: 'PerfectTense', + + PerfectTense: 'PerfectTense', + PluperfectTense: 'PluperfectTense', + FutureTense: 'FutureTense', + PastTense: 'PastTense', + PresentTense: 'PresentTense' + }; + + var irregulars = require('./data/irregular_verbs.js'); + var verbs = require('./data/verbs.js').concat(Object.keys(irregulars)); + + var _loop = function _loop(i) { + var o = verb_conjugate(verbs[i]); + Object.keys(o).forEach(function (k) { + if (k && o[k] && verbMap[k]) { + lexicon[o[k]] = verbMap[k]; + } + }); + }; + + for (var i = 0; i < verbs.length; i++) { + _loop(i); + } + + var orgs = require('./data/organizations.js'); + addArr(orgs.organizations, 'Noun'); + addArr(orgs.suffixes, 'Noun'); + + var places = require('./data/places.js'); + addArr(places.countries, 'Place'); + addArr(places.cities, 'Place'); + + require('./data/adjectives.js').forEach(function (s) { + lexicon[s] = 'Adjective'; + lexicon[to_comparative(s)] = 'Comparative'; + lexicon[to_superlative(s)] = 'Superlative'; + lexicon[to_adverb(s)] = 'Adverb'; + }); + Object.keys(require('./data/convertables.js')).forEach(function (s) { + lexicon[s] = 'Adjective'; + lexicon[to_comparative(s)] = 'Comparative'; + lexicon[to_superlative(s)] = 'Superlative'; + lexicon[to_adverb(s)] = 'Adverb'; + }); + + addArr(require('./data/abbreviations.js').abbreviations, 'Abbreviation'); + addArr(require('./data/demonyms.js'), 'Adjective'); + addArr(require('./data/honourifics.js'), 'Honourific'); + addArr(require('./data/uncountables.js'), 'Noun'); + var dates = require('./data/dates.js'); + addArr(dates.days, 'Date'); + addArr(dates.months, 'Date'); + addArr(dates.durations, 'Date'); + addArr(dates.relative, 'Date'); + + //unpack the numbers + var nums = require('./data/numbers.js'); + var all_nums = Object.keys(nums).reduce(function (arr, k) { + arr = arr.concat(Object.keys(nums[k])); + return arr; + }, []); + addArr(all_nums, 'Value'); + + //a little fancy + addArr(Object.keys(require('./data/firstnames.js')), 'Person'); + //add irregular nouns + var irregNouns = require('./data/irregular_nouns.js'); + addArr(fns.pluck(irregNouns, 0), 'Noun'); + addArr(fns.pluck(irregNouns, 1), 'Plural'); + + addObj(require('./data/misc.js')); + addObj(require('./data/multiples.js')); + addObj(require('./data/phrasal_verbs.js')); + //add named holidays, like 'easter' + Object.keys(require('./data/holidays.js')).forEach(function (k) { + lexicon[k] = 'Date'; + }); + + //professions + addArr(require('./data/professions.js'), 'Actor'); + + //just in case + delete lexicon[false]; + delete lexicon[true]; + delete lexicon[undefined]; + delete lexicon[null]; + delete lexicon['']; + + //use 'Noun', not 'NN' + Object.keys(lexicon).forEach(function (k) { + lexicon[k] = grand_mapping[lexicon[k]] || lexicon[k]; + }); + + module.exports = lexicon; + }, { "./data/abbreviations.js": 2, "./data/adjectives.js": 3, "./data/convertables.js": 4, "./data/dates.js": 5, "./data/demonyms.js": 6, "./data/firstnames.js": 7, "./data/holidays.js": 8, "./data/honourifics.js": 9, "./data/irregular_nouns.js": 10, "./data/irregular_verbs.js": 11, "./data/misc.js": 12, "./data/multiples.js": 13, "./data/numbers.js": 16, "./data/organizations.js": 17, "./data/phrasal_verbs.js": 18, "./data/places.js": 19, "./data/professions.js": 20, "./data/uncountables.js": 21, "./data/verbs.js": 22, "./fns.js": 23, "./sentence/pos/parts_of_speech.js": 36, "./term/adjective/to_adverb.js": 61, "./term/adjective/to_comparative.js": 62, "./term/adjective/to_superlative.js": 64, "./term/verb/conjugate/conjugate.js": 96 }], 25: [function (require, module, exports) { + 'use strict'; + // a regex-like lookup for a list of terms. + // returns matches in a 'Terms' class + + var Result = require('./result'); + var syntax_parse = require('./syntax_parse'); + var match_term = require('./match_term'); + + // take a slice of our terms, and try a match starting here + var tryFromHere = function tryFromHere(terms, regs, options) { + var result = []; + var which_term = 0; + for (var i = 0; i < regs.length; i++) { + var term = terms[which_term]; + //if we hit the end of terms, prematurely + if (!term) { + return null; + } + //find a match with term, (..), [..], or ~..~ syntax + if (match_term(term, regs[i], options)) { + //handle '$' logic + if (regs[i].signals.trailing && terms[which_term + 1]) { + return null; + } + //handle '^' logic + if (regs[i].signals.leading && which_term !== 0) { + return null; + } + result.push(terms[which_term]); + which_term += 1; + continue; + } + //if it's a contraction, go to next term + if (term.normal === '') { + result.push(terms[which_term]); + which_term += 1; + term = terms[which_term]; + } + //support wildcards, some matching logic + // '.' means easy-pass + if (regs[i].signals.any_one) { + result.push(terms[which_term]); + which_term += 1; + continue; + } + //else, if term was optional, continue anyways + if (regs[i].signals.optional) { + continue; //(this increments i, but not which_term) + } + //attempt is dead. + return null; + } + //success, return terms subset + return result; + }; + + //find first match and return []Terms + var findAll = function findAll(terms, regs, options) { + var result = []; + regs = syntax_parse(regs || ''); + // one-off lookup for ^ + // '^' token is 'must start at 0' + if (regs[0].signals.leading) { + var match = tryFromHere(terms, regs, options) || []; + if (match) { + return [new Result(match)]; + } else { + return null; + } + } + + //repeating version starting from each term + var len = terms.length; // - regs.length + 1; + for (var i = 0; i < len; i++) { + var termSlice = terms.slice(i, terms.length); + var match = tryFromHere(termSlice, regs, options); + if (match) { + result.push(new Result(match)); + } + } + //if we have no results, return null + if (result.length === 0) { + return null; + } + return result; + }; + + //calls Terms.replace() on each found result + var replaceAll = function replaceAll(terms, regs, replacement, options) { + var list = findAll(terms, regs, options); + list.forEach(function (t) { + t.replace(replacement, options); + }); + }; + + module.exports = { + findAll: findAll, + replaceAll: replaceAll + }; + }, { "./match_term": 26, "./result": 27, "./syntax_parse": 28 }], 26: [function (require, module, exports) { + 'use strict'; + + var fns = require('../fns.js'); + + //a regex-like string search + // returns a boolean for match/not + var match_term = function match_term(term, reg) { + //fail-fast + if (!term || !reg || !reg.signals) { + return false; + } + var signals = reg.signals; + + //support optional (foo|bar) syntax + if (signals.one_of) { + var arr = reg.term.split('|'); + for (var i = 0; i < arr.length; i++) { + if (arr[i] === term.normal || arr[i] === term.text) { + return true; + } + } + return false; + } + //support [Pos] syntax + if (signals.pos) { + var pos = fns.titlecase(reg.term); + if (term.pos[pos]) { + return true; + } + return false; + } + //support ~alias~ syntax + if (signals.alias) { + if (reg.term === term.root()) { + return true; + } + return false; + } + //straight-up text match + if (reg.term === term.normal || reg.term === term.text || reg.term === term.expansion) { + return true; + } + + return false; + }; + + module.exports = match_term; + }, { "../fns.js": 23 }], 27: [function (require, module, exports) { + 'use strict'; + + var _createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); + } + }return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; + }; + }(); + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + var _match = require('./match.js'); + + // a slice of term objects returned from .match() + // ideally changes that happen here happen in the original object + + var Result = function () { + function Result(terms) { + _classCallCheck(this, Result); + + this.terms = terms; + } + //wha, this is possible eg. text.match().match() + + _createClass(Result, [{ + key: 'match', + value: function match(str, options) { + return _match(this.terms, str, options); + } + //a 1-1 replacement of strings + + }, { + key: 'replace', + value: function replace(words) { + for (var i = 0; i < this.terms.length; i++) { + //umm, this is like a capture-group in regexp.. + //so just leave it + if (words[i] === '$') { + continue; + } + //allow replacements with the capture group, like 'cyber-$1' + if (words[i].match(/\$1/)) { + var combined = words[1].replace(/\$1/, this.terms[i].text); + this.terms[i].changeTo(combined); + continue; + } + this.terms[i].changeTo(words[i] || ''); + } + return this; + } + }, { + key: 'text', + value: function text() { + return this.terms.reduce(function (s, t) { + //implicit contractions shouldn't be included + if (t.text) { + s += ' ' + t.text; + } + return s; + }, '').trim(); + } + }, { + key: 'normal', + value: function normal() { + return this.terms.reduce(function (s, t) { + //implicit contractions shouldn't be included + if (t.normal) { + s += ' ' + t.normal; + } + return s; + }, '').trim(); + } + }]); + + return Result; + }(); + //a slice of term objects + + module.exports = Result; + }, { "./match.js": 25 }], 28: [function (require, module, exports) { + 'use strict'; + // parse a search lookup term find the regex-like syntax in this term + + var fns = require('../fns.js'); + // flags: + // { + // pos: true, + // optional: true, + // one_of: true, + // alias: true, + // leading: true, + // trailing: true, + // any_one: true, + // any_many: true, + // } + + var parse_term = function parse_term(term, i) { + term = term || ''; + term = term.trim(); + var signals = {}; + //order matters! + + //leading ^ flag + if (fns.startsWith(term, '^')) { + term = term.substr(1, term.length); + signals.leading = true; + } + //trailing $ flag means ending + if (fns.endsWith(term, '$')) { + term = term.replace(/\$$/, ''); + signals.trailing = true; + } + //optional flag + if (fns.endsWith(term, '?')) { + term = term.replace(/\?$/, ''); + signals.optional = true; + } + + //pos flag + if (fns.startsWith(term, '[') && fns.endsWith(term, ']')) { + term = term.replace(/\]$/, ''); + term = term.replace(/^\[/, ''); + signals.pos = true; + } + //one_of options flag + if (fns.startsWith(term, '(') && fns.endsWith(term, ')')) { + term = term.replace(/\)$/, ''); + term = term.replace(/^\(/, ''); + signals.one_of = true; + } + //alias flag + if (fns.startsWith(term, '~')) { + term = term.replace(/^\~/, ''); + term = term.replace(/\~$/, ''); + signals.alias = true; + } + //addition flag + if (fns.startsWith(term, '+')) { + term = term.replace(/^\+/, ''); + term = term.replace(/\+$/, ''); + signals.extra = true; + } + + //a period means anything + if (term === '.') { + signals.any_one = true; + } + //a * means anything + if (term === '*') { + signals.any_many = true; + } + return { + term: term, + signals: signals, + i: i + }; + }; + // console.log(parse_term('~fun~?')); + + //turn a match string into an array of objects + var parse_all = function parse_all(regs) { + regs = regs || []; + return regs.map(parse_term); + }; + // console.log(parse_all('')); + + module.exports = parse_all; + }, { "../fns.js": 23 }], 29: [function (require, module, exports) { + 'use strict'; + //turns 'is not' into "isn't", and "he is" into "he's" + + var contractor = { + 'will': 'll', + 'would': 'd', + 'have': 've', + 'are': 're', + 'not': 't', + 'is': 's' + // 'was': 's' //this is too folksy + }; + + var contract = function contract(terms) { + for (var i = 1; i < terms.length; i++) { + if (contractor[terms[i].normal]) { + //remember expansion + terms[i - 1].expansion = terms[i - 1].text; + terms[i].expansion = terms[i].text; + //handle special `n't` case + if (terms[i].normal === 'not') { + terms[i - 1].text += 'n'; + } + terms[i - 1].text += '\'' + contractor[terms[i].normal]; + terms[i - 1].rebuild(); + terms[i].text = ''; + terms[i].rebuild(); + } + } + return terms; + }; + + module.exports = contract; + }, {}], 30: [function (require, module, exports) { + 'use strict'; + + var expand = function expand(terms) { + for (var i = 0; i < terms.length; i++) { + if (terms[i].expansion) { + terms[i].text = terms[i].expansion; + terms[i].rebuild(); + } + } + return terms; + }; + + module.exports = expand; + }, {}], 31: [function (require, module, exports) { + 'use strict'; + + var pos = require('../pos/parts_of_speech'); + //places a 'silent' term where a contraction, like "they're" exists + + //the formulaic contraction types: + var supported = { + 'll': 'will', + 'd': 'would', + 've': 'have', + 're': 'are', + 'm': 'am' //this is not the safest way to support i'm + //these ones are a bit tricksier: + // 't': 'not', + // 's': 'is' //or was + }; + + var irregulars = { + 'dunno': ['do not', 'know'], + 'wanna': ['want', 'to'], + 'gonna': ['going', 'to'], + 'im': ['i', 'am'], + 'alot': ['a', 'lot'], + + 'dont': ['do not'], + 'don\'t': ['do not'], + 'dun': ['do not'], + + 'won\'t': ['will not'], + 'wont': ['will not'], + + 'can\'t': ['can not'], + 'cannot': ['can not'], + + 'aint': ['is not'], //or 'are' + 'ain\'t': ['is not'], + 'shan\'t': ['should not'], + + 'where\'d': ['where', 'did'], + 'when\'d': ['when', 'did'], + 'how\'d': ['how', 'did'], + 'what\'d': ['what', 'did'], + 'brb': ['be', 'right', 'back'], + 'let\'s': ['let', 'us'] + }; + + //puts a 'implicit term' in this sentence, at 'i' + var handle_simple = function handle_simple(terms, i, particle) { + //fixup current term + terms[i].expansion = terms[i].text.replace(/'.*/, ''); + //make ghost-term + var second_word = new pos.Verb(''); + second_word.expansion = particle; + terms.splice(i + 1, 0, second_word); + return terms; + }; + + // `n't` contractions - negate doesn't have a second term + var handle_negate = function handle_negate(terms, i) { + //fixup current term + terms[i].expansion = terms[i].text.replace(/n'.*/, ''); + terms[i].expansion += ' not'; + return terms; + }; + + // expand manual contractions + var handle_irregulars = function handle_irregulars(terms, x, arr) { + terms[x].expansion = arr[0]; + for (var i = 1; i < arr.length; i++) { + var t = new pos.Term(''); + t.expansion = arr[i]; + terms.splice(x + i, 0, t); + } + return terms; + }; + + // `'s` contractions + var handle_copula = function handle_copula(terms, i) { + //fixup current term + terms[i].expansion = terms[i].text.replace(/'s$/, ''); + //make ghost-term + var second_word = new pos.Verb(''); + second_word.expansion = 'is'; + terms.splice(i + 1, 0, second_word); + return terms; + }; + + //turn all contraction-forms into 'silent' tokens + var interpret = function interpret(terms) { + for (var i = 0; i < terms.length; i++) { + //known-forms + if (irregulars[terms[i].normal]) { + terms = handle_irregulars(terms, i, irregulars[terms[i].normal]); + continue; + } + //words with an apostrophe + if (terms[i].has_abbreviation()) { + var split = terms[i].normal.split(/'/); + var pre = split[0]; + var post = split[1]; + // eg "they've" + if (supported[post]) { + terms = handle_simple(terms, i, supported[post]); + continue; + } + // eg "couldn't" + if (post === 't' && pre.match(/n$/)) { + terms = handle_negate(terms, i); + continue; + } + // eg "spencer's" + if (post === 's') { + terms = handle_copula(terms, i); + continue; + } + } + } + + return terms; + }; + + module.exports = interpret; + + // let t = new pos.Verb(`spencer's`); + // let terms = interpret([t]); + // console.log(terms); + }, { "../pos/parts_of_speech": 36 }], 32: [function (require, module, exports) { + 'use strict'; + + //boolean if sentence has + + // "[copula] [pastTense] by" + // "[pastParticiple] by" + + var passive_voice = function passive_voice(s) { + var terms = s.terms; + for (var i = 0; i < terms.length - 2; i++) { + if (terms[i].pos['Copula'] && terms[i + 1].pos['Verb'] && terms[i + 2].normal === 'by') { + //don't do 'june was approaching by then' + if (terms[i + 1].pos['Gerund']) { + continue; + } + return true; + } + } + return false; + }; + + module.exports = passive_voice; + }, {}], 33: [function (require, module, exports) { + 'use strict'; + + var pos = require('./parts_of_speech'); + + //set the part-of-speech of a particular term + var assign = function assign(t, tag, reason) { + var P = pos.classMapping[tag] || pos.Term; + var expansion = t.expansion; + var whitespace = t.whitespace; + t = new P(t.text, tag); + t.reason = reason; + t.whitespace = whitespace; + t.expansion = expansion; + return t; + }; + module.exports = assign; + }, { "./parts_of_speech": 36 }], 34: [function (require, module, exports) { + //fancy combining/chunking of terms + 'use strict'; + + var pos = require('./parts_of_speech'); + + var shouldLumpThree = function shouldLumpThree(a, b, c) { + if (!a || !b || !c) { + return false; + } + //some weak-pos + + var lump_rules = [{ + condition: a.pos.Noun && b.text === '&' && c.pos.Noun, //John & Joe's + result: 'Person' + }, { + condition: a.pos.Noun && b.text === 'N' && c.pos.Noun, //John N Joe's + result: 'Person' + }, { + condition: a.pos.Date && b.normal === 'the' && c.pos.Value, //June the 5th + result: 'Date' + }, { + condition: a.pos.Value && b.pos.Preposition && c.pos.Date, //June the 5th + result: 'Date' + }, { + condition: a.pos.Date && b.pos.Preposition && c.pos.Value, //June 5th to 7th + result: 'Date' + }, { + condition: a.is_capital() && b.normal === 'of' && c.is_capital(), //President of Mexico + result: 'Noun' + }, { + condition: a.text.match(/^["']/) && !b.text.match(/["']/) && c.text.match(/["']$/), //three-word quote + result: 'Noun' + }, { + condition: a.normal === 'will' && b.normal === 'have' && b.pos.Verb, //will have walk + result: 'FutureTense' + }, { + condition: a.pos.Date && (c.pos.Date || c.pos.Ordinal) && (b.pos.Preposition || b.pos.Determiner || b.pos.Conjunction || b.pos.Adjective), //3hrs after 5pm + result: 'Date' + }]; + for (var i = 0; i < lump_rules.length; i++) { + if (lump_rules[i].condition) { + return lump_rules[i].result; + } + } + return false; + }; + + var shouldLumpTwo = function shouldLumpTwo(a, b) { + if (!a || !b) { + return false; + } + //don't chunk non-word things with word-things + if (a.is_word() === false || b.is_word() === false) { + return false; + } + var lump_rules = [{ + condition: a.pos.Person && b.pos.Honourific || a.pos.Honourific && b.pos.Person, //"John sr." + result: 'Person' + }, { + condition: (a.pos.Value || a.pos.Date) && (b.normal === 'am' || b.normal === 'pm'), //6 am + result: 'Date' + }, { + condition: a.pos.Honourific && b.is_capital(), //'Dr. John + result: 'Person' + }, { + condition: a.pos.Person && b.is_capital(), //'Person, Capital -> Person' + result: 'Person' + }, { + condition: a.pos.Date && b.pos.Value, //June 4 + result: 'Date' + }, { + condition: a.pos.Value && b.pos.Date, //4 June + result: 'Date' + }, { + condition: (a.normal === 'last' || a.normal === 'next' || a.normal === 'this') && b.pos.Date, //last wednesday + result: 'Date' + }, { + condition: a.pos.Noun && b.pos.Actor, //Aircraft designer + result: 'Actor' + }, { + condition: a.pos.Value && b.pos.Noun && !a.pos.Ordinal, //5 books + result: 'Value' + }, { + condition: a.is_capital() && b.pos['Organization'] || b.is_capital() && a.pos['Organization'], //Canada Inc + result: 'Organization' + }, { + condition: a.text.match(/^["']/) && b.text.match(/["']$/), //two-word quote + result: 'Noun' + }, { + condition: a.normal === 'will' && b.pos.Verb, //will walk (perfect) + result: 'PerfectTense' + }, { + condition: a.normal.match(/^will ha(ve|d)$/) && b.pos.Verb, //will have walked (pluperfect) + result: 'PluperfectTense' + }, + //timezones + { + condition: b.normal.match(/(standard|daylight|summer) time/) && (a.pos['Adjective'] || a.pos['Place']), + result: 'Date' + }]; + for (var i = 0; i < lump_rules.length; i++) { + if (lump_rules[i].condition) { + return lump_rules[i].result; + } + } + return false; + }; + + var fancy_lumping = function fancy_lumping(terms) { + for (var i = 1; i < terms.length; i++) { + var a = terms[i - 1]; + var b = terms[i]; + var c = terms[i + 1]; + + // rules for lumping two terms + var tag = shouldLumpTwo(a, b); + if (tag) { + var Cl = pos.classMapping[tag] || pos.Term; + var space = a.whitespace.trailing + b.whitespace.preceding; + // console.log(terms[i - 1]); + // console.log(terms[i]); + terms[i] = new Cl(a.text + space + b.text, tag); + terms[i].reason = 'lumpedtwo(' + terms[i].reason + ')'; + terms[i].whitespace.preceding = a.whitespace.preceding; + terms[i].whitespace.trailing = b.whitespace.trailing; + terms[i - 1] = null; + continue; + } + + // rules for lumpting three terms + if (c) { + tag = shouldLumpThree(a, b, c); + if (tag) { + var Cl = pos.classMapping[tag] || pos.Term; + var space1 = a.whitespace.trailing + b.whitespace.preceding; + var space2 = b.whitespace.trailing + c.whitespace.preceding; + var text = a.text + space1 + b.text + space2 + c.text; + terms[i - 1] = new Cl(text, tag); + terms[i - 1].reason = 'lumpedThree(' + terms[i].reason + ')'; + //transfer unused-up whitespace + terms[i - 1].whitespace.preceding = a.whitespace.preceding; + terms[i - 1].whitespace.trailing = c.whitespace.trailing; + terms[i] = null; + terms[i + 1] = null; + continue; + } + } + } + //remove killed terms + terms = terms.filter(function (t) { + return t !== null; + }); + return terms; + }; + + module.exports = fancy_lumping; + }, { "./parts_of_speech": 36 }], 35: [function (require, module, exports) { + 'use strict'; + + var friendlies = [['Noun', 'Abbreviation'], ['Abbreviation', 'Noun']]; + + var should_chunk = function should_chunk(a, b) { + if (!a || !b) { + return false; + } + //if A has a comma, don't chunk it, (unless it's a date) + if (a.has_comma() && !a.pos.Date) { + return false; + } + //don't chunk non-word things with word-things + if (a.is_word() === false || b.is_word() === false) { + return false; + } + //dont chunk these pos + var dont_chunk = ['Expression', 'Phrasal']; + for (var i = 0; i < dont_chunk.length; i++) { + if (a.pos[dont_chunk[i]] || b.pos[dont_chunk[i]]) { + return false; + } + } + //dont chunk contractions (again) + if (a.expansion || b.expansion) { + return false; + } + if (a.tag === b.tag) { + return true; + } + for (var i = 0; i < friendlies.length; i++) { + var f = friendlies[i]; + if (a.pos[f[0]] && b.pos[f[1]]) { + return true; + } + } + //matching nouns + // if (a.pos['Noun'] && b.pos['Noun']) { + // return true; + // } + return false; + }; + + //turn [noun, noun..] into [noun..] + var chunk_neighbours = function chunk_neighbours(terms) { + var new_terms = []; + var last_one = null; + for (var i = 0; i < terms.length; i++) { + var t = terms[i]; + //if the tags match (but it's not a hidden contraction) + if (should_chunk(last_one, t)) { + var space = last_one.whitespace.trailing + t.whitespace.preceding; + new_terms[new_terms.length - 1].text += space + t.text; + new_terms[new_terms.length - 1].normalize(); + new_terms[new_terms.length - 1].whitespace.trailing = t.whitespace.trailing; + new_terms[new_terms.length - 1].whitespace.preceding = last_one.whitespace.preceding; + } else { + new_terms.push(t); + } + last_one = t; + } + return new_terms; + }; + + module.exports = chunk_neighbours; + }, {}], 36: [function (require, module, exports) { + 'use strict'; + + var Term = require('../../term/term.js'); + + var Verb = require('../../term/verb/verb.js'); + var Adverb = require('../../term/adverb/adverb.js'); + var Adjective = require('../../term/adjective/adjective.js'); + + var Noun = require('../../term/noun/noun.js'); + var Person = require('../../term/noun/person/person.js'); + var Place = require('../../term/noun/place/place.js'); + var Organization = require('../../term/noun/organization/organization.js'); + var Value = require('../../term/noun/value/value.js'); + var _Date = require('../../term/noun/date/date.js'); + + var tag_mapping = { + //nouns + 'NNA': 'Acronym', + 'NNS': 'Plural', + 'NN': 'Noun', + 'NNO': 'Possessive', + 'CD': 'Value', + // 'NNP': 'Noun', + // 'NNPA': 'Noun', + // 'NNAB': 'Noun', + // 'NNPS': 'Noun', + // 'NNG': 'Noun', + 'AC': 'Actor', + 'DA': 'Date', + 'CO': 'Condition', + 'PN': 'Person', + + //glue + 'PP': 'Possessive', + 'PRP': 'Pronoun', + 'EX': 'Expression', //interjection + 'DT': 'Determiner', + 'CC': 'Conjunction', + 'IN': 'Preposition', + + //verbs + 'VB': 'Verb', + 'VBD': 'PastTense', + 'VBF': 'FutureTense', + 'VBP': 'Infinitive', + 'VBZ': 'PresentTense', + 'VBG': 'Gerund', + 'VBN': 'Verb', + 'CP': 'Copula', + 'MD': 'Modal', + 'JJ': 'Adjective', + 'JJR': 'Comparative', + 'JJS': 'Superlative', + 'RB': 'Adverb' + }; + + var classMapping = { + 'Noun': Noun, + 'Honourific': Noun, + 'Acronym': Noun, + 'Plural': Noun, + 'Pronoun': Noun, + 'Actor': Noun, + 'Abbreviation': Noun, + + 'Verb': Verb, + 'PresentTense': Verb, + 'FutureTense': Verb, + 'PastTense': Verb, + 'Infinitive': Verb, + 'PerfectTense': Verb, + 'PluperfectTense': Verb, + 'Gerund': Verb, + 'Copula': Verb, + 'Modal': Verb, + + 'Comparative': Adjective, + 'Superlative': Adjective, + 'Adjective': Adjective, + + 'Determiner': Term, + 'Preposition': Term, + 'Expression': Term, + 'Conjunction': Term, + 'Possessive': Term, + + 'Adverb': Adverb, + 'Value': Value, + 'Place': Place, + 'Person': Person, + 'Organization': Organization, + 'Date': _Date + }; + + module.exports = { + tag_mapping: tag_mapping, + classMapping: classMapping, + Term: Term, + 'Date': _Date, + Value: Value, + Verb: Verb, + Person: Person, + Place: Place, + Organization: Organization, + Adjective: Adjective, + Adverb: Adverb, + Noun: Noun + }; + }, { "../../term/adjective/adjective.js": 60, "../../term/adverb/adverb.js": 65, "../../term/noun/date/date.js": 70, "../../term/noun/noun.js": 76, "../../term/noun/organization/organization.js": 78, "../../term/noun/person/person.js": 82, "../../term/noun/place/place.js": 84, "../../term/noun/value/value.js": 94, "../../term/term.js": 95, "../../term/verb/verb.js": 104 }], 37: [function (require, module, exports) { + 'use strict'; + + var assign = require('../assign'); + + //date words that are sometimes-not.. + var tough_dates = { + may: true, + april: true, + march: true, + june: true, + jan: true + }; + + //an integer that looks year-like + var maybe_year = function maybe_year(t) { + if (t.pos.Value) { + var num = t.number || 0; + if (num >= 1900 && num < 2030) { + return true; + } + } + return false; + }; + + //neighbouring words that indicate it is a date + var date_signals = { + between: true, + before: true, + after: true, + during: true, + from: true, + to: true, + in: true, + of: true, + the: true, + next: true + }; + + var ambiguous_dates = function ambiguous_dates(terms) { + for (var i = 0; i < terms.length; i++) { + var t = terms[i]; + if (tough_dates[t.normal] || maybe_year(t)) { + //'march' or '2015' + //if nearby another date or value + // console.log(terms[i + 1].pos.Verb); + if (terms[i + 1] && (terms[i + 1].pos['Value'] || terms[i + 1].pos['Date'])) { + terms[i] = assign(t, 'Date', 'date_signal'); + continue; + } + if (terms[i - 1] && (terms[i - 1].pos['Value'] || terms[i - 1].pos['Date'])) { + terms[i] = assign(t, 'Date', 'date_signal'); + continue; + } + + //if next term is date-like + if (terms[i + 1] && date_signals[terms[i + 1].normal]) { + terms[i] = assign(t, 'Date', 'date_signal'); + continue; + } + //if last term is date-like + if (terms[i - 1] && date_signals[terms[i - 1].normal]) { + terms[i] = assign(t, 'Date', 'date_signal'); + continue; + } + } + } + return terms; + }; + + module.exports = ambiguous_dates; + }, { "../assign": 33 }], 38: [function (require, module, exports) { + 'use strict'; + + var assign = require('../assign'); + //set POS for capitalised words + var capital_signals = function capital_signals(terms) { + //first words need careful rules + if (terms[0].is_acronym()) { + terms[0] = assign(terms[0], 'Noun', 'acronym'); + } + //non-first-word capitals are nouns + for (var i = 1; i < terms.length; i++) { + if (terms[i].is_capital() || terms[i].is_acronym()) { + terms[i] = assign(terms[i], 'Noun', 'capital_signal'); + } + } + return terms; + }; + module.exports = capital_signals; + }, { "../assign": 33 }], 39: [function (require, module, exports) { + 'use strict'; + + var starts = { + 'if': true, + 'in the event': true, + 'in order to': true, + 'so long as': true, + 'provided': true, + 'save that': true, + 'after': true, + 'once': true, + 'subject to': true, + 'without': true, + 'effective': true, + 'upon': true, + 'during': true, + 'unless': true, + 'according': true, + 'notwithstanding': true, + 'when': true, + 'before': true + }; + + // ensure there's a verb in a couple words + var verbSoon = function verbSoon(terms, x) { + for (var i = 0; i < 5; i++) { + if (terms[i + x] && terms[i + x].pos['Verb']) { + return true; + } + } + return false; + }; + + // find the next upcoming comma + var nextComma = function nextComma(terms, i) { + //don't be too aggressive + var max = terms.length - 1; + if (max > i + 7) { + max = i + 7; + } + for (var x = i; x < max; x++) { + //ensure there's a command and a verb coming up soon + if (terms[x].has_comma() && verbSoon(terms, x)) { + return x; + } + } + //allow trailing conditions too + if (i > 5 && terms.length - i < 5) { + return terms.length; + } + return null; + }; + + //set these terms as conditional + var tagCondition = function tagCondition(terms, start, stop) { + for (var i = start; i <= stop; i++) { + if (!terms[i]) { + break; + } + terms[i].pos['Condition'] = true; + } + }; + + var conditional_pass = function conditional_pass(terms) { + + //try leading condition + if (starts[terms[0].normal]) { + var until = nextComma(terms, 0); + if (until) { + tagCondition(terms, 0, until); + } + } + + //try trailing condition + for (var i = 3; i < terms.length; i++) { + if (starts[terms[i].normal] && terms[i - 1].has_comma()) { + var until = nextComma(terms, i); + if (until) { + tagCondition(terms, i, until); + i += until; + } + } + } + return terms; + }; + + module.exports = conditional_pass; + }, {}], 40: [function (require, module, exports) { + 'use strict'; + + var assign = require('../assign'); + var grammar_rules = require('./rules/grammar_rules'); + var fns = require('../../../fns'); + // const match = require('../../match/match'); + + //tests a subset of terms against a array of tags + var hasTags = function hasTags(terms, tags) { + if (terms.length !== tags.length) { + return false; + } + for (var i = 0; i < tags.length; i++) { + //do a [tag] match + if (fns.startsWith(tags[i], '[') && fns.endsWith(tags[i], ']')) { + var pos = tags[i].match(/^\[(.*?)\]$/)[1]; + if (!terms[i].pos[pos]) { + return false; + } + } else if (terms[i].normal !== tags[i]) { + //do a text-match + return false; + } + } + return true; + }; + + //hints from the sentence grammar + var grammar_rules_pass = function grammar_rules_pass(s) { + for (var i = 0; i < s.terms.length; i++) { + for (var o = 0; o < grammar_rules.length; o++) { + var rule = grammar_rules[o]; + //does this rule match + var terms = s.terms.slice(i, i + rule.before.length); + if (hasTags(terms, rule.before)) { + //change before/after for each term + for (var c = 0; c < rule.before.length; c++) { + if (rule.after[c]) { + var newPos = rule.after[c].match(/^\[(.*?)\]$/)[1]; + s.terms[i + c] = assign(s.terms[i + c], newPos, 'grammar_rule (' + rule.before.join(',') + ')'); + } + } + break; + } + } + } + return s.terms; + }; + module.exports = grammar_rules_pass; + }, { "../../../fns": 23, "../assign": 33, "./rules/grammar_rules": 47 }], 41: [function (require, module, exports) { + 'use strict'; + + var assign = require('../assign'); + + //clear-up ambiguous interjections "ok"[Int], "thats ok"[Adj] + var interjection_fixes = function interjection_fixes(terms) { + var interjections = { + ok: true, + so: true, + please: true, + alright: true, + well: true, + now: true + }; + for (var i = 0; i < terms.length; i++) { + if (i > 3) { + break; + } + if (interjections[terms[i].normal]) { + terms[i] = assign(terms[i], 'Expression', 'interjection_fixes'); + } else { + break; + } + } + return terms; + }; + + module.exports = interjection_fixes; + }, { "../assign": 33 }], 42: [function (require, module, exports) { + 'use strict'; + + var defaultLexicon = require('../../../lexicon.js'); + var assign = require('../assign'); + + //consult lexicon for this known-word + var lexicon_pass = function lexicon_pass(terms, options) { + var lexicon = options.lexicon || defaultLexicon; + return terms.map(function (t) { + //check lexicon straight-up + if (lexicon[t.normal] !== undefined) { + return assign(t, lexicon[t.normal], 'lexicon_pass'); + } + + if (lexicon[t.expansion] !== undefined) { + return assign(t, lexicon[t.expansion], 'lexicon_expansion'); + } + //try to match it without a prefix - eg. outworked -> worked + if (t.normal.match(/^(over|under|out|-|un|re|en).{3}/)) { + var attempt = t.normal.replace(/^(over|under|out|.*?-|un|re|en)/, ''); + return assign(t, lexicon[attempt], 'lexicon_prefix'); + } + //try to match without a contraction - "they've" -> "they" + if (t.has_abbreviation()) { + var attempt = t.normal.replace(/'(ll|re|ve|re|d|m)/, ''); + // attempt = t.normal.replace(/n't/, ''); + return assign(t, lexicon[attempt], 'lexicon_prefix'); + } + + //match 'twenty-eight' + if (t.normal.match(/-/)) { + var sides = t.normal.split('-'); + if (lexicon[sides[0]]) { + return assign(t, lexicon[sides[0]], 'lexicon_dash'); + } + if (lexicon[sides[1]]) { + return assign(t, lexicon[sides[1]], 'lexicon_dash'); + } + } + return t; + }); + }; + module.exports = lexicon_pass; + }, { "../../../lexicon.js": 24, "../assign": 33 }], 43: [function (require, module, exports) { + 'use strict'; + + var lexicon = require('../../../lexicon.js'); + var assign = require('../assign'); + + var should_merge = function should_merge(a, b) { + if (!a || !b) { + return false; + } + //if it's a known multiple-word term + if (lexicon[a.normal + ' ' + b.normal]) { + return true; + } + return false; + }; + + var multiples_pass = function multiples_pass(terms) { + var new_terms = []; + var last_one = null; + for (var i = 0; i < terms.length; i++) { + var t = terms[i]; + //if the tags match (but it's not a hidden contraction) + if (should_merge(last_one, t)) { + var last = new_terms[new_terms.length - 1]; + var space = t.whitespace.preceding + last.whitespace.trailing; + last.text += space + t.text; + last.rebuild(); + last.whitespace.trailing = t.whitespace.trailing; + var pos = lexicon[last.normal]; + new_terms[new_terms.length - 1] = assign(last, pos, 'multiples_pass_lexicon'); + new_terms[new_terms.length - 1].whitespace = last.whitespace; + } else { + new_terms.push(t); + } + last_one = t; + } + return new_terms; + }; + + module.exports = multiples_pass; + }, { "../../../lexicon.js": 24, "../assign": 33 }], 44: [function (require, module, exports) { + 'use strict'; + + //some prepositions are clumped onto the back of a verb "looked for", "looks at" + //they should be combined with the verb, sometimes. + //does not handle seperated phrasal verbs ('take the coat off' -> 'take off') + + var phrasals = require('../../../data/phrasal_verbs'); + + //combine ['blew','up'] -> 'blew up' + var phrasal_verbs = function phrasal_verbs(terms) { + for (var i = 0; i < terms.length - 1; i++) { + if (!terms[i] || !terms[i + 1]) { + break; + } + if (terms[i].pos['Verb'] && phrasals[terms[i].normal + terms[i + 1].normal]) { + //don't do 'is in' + if (terms[i].pos['Copula']) { + continue; + } + terms[i].pos['Phrasal'] = true; + terms[i].text = terms[i].text + ' ' + terms[i + 1].text; + terms[i].reason = 'phrasal(' + terms[i].reason + ')'; + terms[i + 1] = null; + terms[i].rebuild(); + // terms[i].conjugate(); + } + } + //remove killed-off ones + terms = terms.filter(function (t) { + return t !== null; + }); + return terms; + }; + + module.exports = phrasal_verbs; + }, { "../../../data/phrasal_verbs": 18 }], 45: [function (require, module, exports) { + 'use strict'; + // knowing if something is inside a quotation is important grammatically + //set all the words inside quotations marks as pos['Quotation']=true + // verbatim change of narration only, 'scare quotes' don't count. + + var startQuote = function startQuote(s) { + return s.match(/^["\u201C]./); + }; + var endQuote = function endQuote(s) { + return s.match(/.["\u201D]$/); + }; + + //find the next quotation terminator + var quotation_ending = function quotation_ending(terms, start) { + for (var i = start; i < terms.length; i++) { + if (endQuote(terms[i].text)) { + return i; + } + } + return null; + }; + + //set these terms as quotations + var tagQuotation = function tagQuotation(terms, start, stop) { + for (var i = start; i <= stop; i++) { + if (!terms[i]) { + break; + } + terms[i].pos['Quotation'] = true; + } + }; + + //hunt + var quotation_pass = function quotation_pass(terms) { + for (var i = 0; i < terms.length; i++) { + if (startQuote(terms[i].text)) { + var end = quotation_ending(terms, [i]); + if (end !== null) { + tagQuotation(terms, i, end); + return terms; + } + } + } + return terms; + }; + + module.exports = quotation_pass; + }, {}], 46: [function (require, module, exports) { + 'use strict'; + + var word_rules = require('./rules/word_rules'); + var assign = require('../assign'); + + //word-rules that run on '.text', not '.normal' + var punct_rules = [{ //2:54pm + reg: new RegExp('^[12]?[0-9]\:[0-9]{2}( am| pm)?$', 'i'), + pos: 'Date' + }, { //1999/12/25 + reg: new RegExp('^[0-9]{1,4}[-/][0-9]{1,2}[-/][0-9]{1,4}$', 'i'), + pos: 'Date' + }, { //3:32 + reg: new RegExp('^[0-9]{1,2}:[0-9]{2}(:[0-9]{2})?', 'i'), + pos: 'Date' + }]; + + var regex_pass = function regex_pass(terms) { + terms.forEach(function (t, i) { + if (terms[i].tag !== '?') { + return; + } + //regexes that involve punctuation + for (var o = 0; o < punct_rules.length; o++) { + if (terms[i].text.match(punct_rules[o].reg)) { + terms[i] = assign(terms[i], punct_rules[o].pos, 'rules_pass_' + o); + return; + } + } + //bigger list of regexes on normal + for (var o = 0; o < word_rules.length; o++) { + if (terms[i].normal.match(word_rules[o].reg)) { + terms[i] = assign(terms[i], word_rules[o].pos, 'rules_pass_' + o); + return; + } + } + }); + + return terms; + }; + + module.exports = regex_pass; + }, { "../assign": 33, "./rules/word_rules": 48 }], 47: [function (require, module, exports) { + 'use strict'; + + module.exports = [ + //determiner hints + { + 'before': ['[Determiner]', '[?]'], + 'after': ['[Determiner]', '[Noun]'] + }, { + 'before': ['the', '[Verb]'], + 'after': [null, '[Noun]'] + }, { + 'before': ['[Determiner]', '[Adjective]', '[Verb]'], + 'after': ['[Noun]', '[Noun]', '[Noun]'] + }, { + 'before': ['[Determiner]', '[Adverb]', '[Adjective]', '[?]'], + 'after': ['[Determiner]', '[Adverb]', '[Adjective]', '[Noun]'] + }, { + 'before': ['[?]', '[Determiner]', '[Noun]'], + 'after': ['[Verb]', '[Determiner]', '[Noun]'] + }, + //"peter the great" + { + 'before': ['[Person]', 'the', '[Noun]'], + 'after': ['[Person]', null, '[Noun]'] + }, + // //"book the flight" + { + 'before': ['[Noun]', 'the', '[Noun]'], + 'after': ['[Verb]', null, '[Noun]'] + }, + + //Possessive hints + { + 'before': ['[Possessive]', '[?]'], + 'after': ['[Possessive]', '[Noun]'] + }, { + 'before': ['[Possessive]', '[Verb]'], + 'after': ['[Possessive]', '[Noun]'] + }, { + 'before': ['[?]', '[Possessive]', '[Noun]'], + 'after': ['[Verb]', '[Possessive]', '[Noun]'] + }, + //copula hints + { + 'before': ['[Copula]', '[?]'], + 'after': ['[Copula]', '[Adjective]'] }, // not sure + { + 'before': ['[Copula]', '[Adverb]', '[?]'], + 'after': ['[Copula]', '[Adverb]', '[Adjective]'] }, // not sure + + //preposition hints + { + 'before': ['[?]', '[Preposition]'], + 'after': ['[Verb]', '[Preposition]'] + }, + //conjunction hints, like lists (a little sloppy) + { + 'before': ['[Adverb]', '[Conjunction]', '[Adverb]'], + 'after': ['[Adverb]', '[Adverb]', '[Adverb]'] + }, + //do not + { + 'before': ['[Verb]', 'not'], + 'after': ['[Verb]', '[Verb]'] + }, + // { + // 'before': ['[Noun]', '[Conjunction]', '[Noun]'], + // 'after': ['[Noun]', '[Noun]', '[Noun]'], + // }, + { + 'before': ['[Adjective]', '[Conjunction]', '[Adjective]'], + 'after': ['[Adjective]', '[Adjective]', '[Adjective]'] + }, { + 'before': ['[?]', '[Conjunction]', '[Verb]'], + 'after': ['[Verb]', '[Conjunction]', '[Verb]'] + }, { + 'before': ['[Verb]', '[Conjunction]', '[?]'], + 'after': ['[Verb]', '[Conjunction]', '[Verb]'] + }, + //adverb hints + { + 'before': ['[Noun]', '[Adverb]', '[Noun]'], + 'after': ['[Noun]', '[Adverb]', '[Verb]'] + }, + //pronoun hints + { + 'before': ['[?]', '[Pronoun]'], + 'after': ['[Verb]', '[Pronoun]'] + }, + //modal hints + { + 'before': ['[Modal]', '[?]'], + 'after': ['[Modal]', '[Verb]'] + }, { + 'before': ['[Modal]', '[Adverb]', '[?]'], + 'after': ['[Modal]', '[Adverb]', '[Verb]'] + }, + //ambiguous dates (march/may) + // { + // 'before': ['[Modal]', '[Value]'], + // 'after': ['[Modal]', '[Verb]'], + // }, + { + 'before': ['[Adverb]', '[Value]'], + 'after': ['[Adverb]', '[Verb]'] + }]; + }, {}], 48: [function (require, module, exports) { + 'use strict'; + + var tag_mapping = require('../../parts_of_speech.js').tag_mapping; + //regex patterns and parts of speech], + module.exports = [['^[0-9]+ ?(am|pm)$', 'DA'], ['^[0-9]+(st|nd|rd)?$', 'CD'], ['^[a-z]et$', 'VB'], ['cede$', 'VB'], ['.[cts]hy$', 'JJ'], ['.[st]ty$', 'JJ'], ['.[lnr]ize$', 'VB'], ['.[gk]y$', 'JJ'], ['.fies$', 'VB'], ['.some$', 'JJ'], ['.[nrtumcd]al$', 'JJ'], ['.que$', 'JJ'], ['.[tnl]ary$', 'JJ'], ['.[di]est$', 'JJS'], ['^(un|de|re)\\-[a-z]..', 'VB'], ['.lar$', 'JJ'], ['[bszmp]{2}y', 'JJ'], ['.zes$', 'VB'], ['.[icldtgrv]ent$', 'JJ'], ['.[rln]ates$', 'VBZ'], ['.[oe]ry$', 'JJ'], ['[rdntkdhs]ly$', 'RB'], ['.[lsrnpb]ian$', 'JJ'], ['.[^aeiou]ial$', 'JJ'], ['.[^aeiou]eal$', 'JJ'], ['.[vrl]id$', 'JJ'], ['.[ilk]er$', 'JJR'], ['.ike$', 'JJ'], ['.ends?$', 'VB'], ['.wards$', 'RB'], ['.rmy$', 'JJ'], ['.rol$', 'NN'], ['.tors$', 'NN'], ['.azy$', 'JJ'], ['.where$', 'RB'], ['.ify$', 'VB'], ['.bound$', 'JJ'], ['.ens$', 'VB'], ['.oid$', 'JJ'], ['.vice$', 'NN'], ['.rough$', 'JJ'], ['.mum$', 'JJ'], ['.teen(th)?$', 'CD'], ['.oses$', 'VB'], ['.ishes$', 'VB'], ['.ects$', 'VB'], ['.tieth$', 'CD'], ['.ices$', 'NN'], ['.bles$', 'VB'], ['.pose$', 'VB'], ['.ions$', 'NN'], ['.ean$', 'JJ'], ['.[ia]sed$', 'JJ'], ['.tized$', 'VB'], ['.llen$', 'JJ'], ['.fore$', 'RB'], ['.ances$', 'NN'], ['.gate$', 'VB'], ['.nes$', 'VB'], ['.less$', 'RB'], ['.ried$', 'JJ'], ['.gone$', 'JJ'], ['.made$', 'JJ'], ['.[pdltrkvyns]ing$', 'JJ'], ['.tions$', 'NN'], ['.tures$', 'NN'], ['.ous$', 'JJ'], ['.ports$', 'NN'], ['. so$', 'RB'], ['.ints$', 'NN'], ['.[gt]led$', 'JJ'], ['.lked$', 'VB'], ['.fully$', 'RB'], ['.*ould$', 'MD'], ['^-?[0-9]+(.[0-9]+)?$', 'CD'], ['[a-z]*\\-[a-z]*\\-', 'JJ'], ['[a-z]\'s$', 'NNO'], ['.\'n$', 'VB'], ['.\'re$', 'CP'], ['.\'ll$', 'MD'], ['.\'t$', 'VB'], ['.tches$', 'VB'], ['^https?\:?\/\/[a-z0-9]', 'NN'], //the colon is removed in normalisation + ['^www\.[a-z0-9]', 'NN'], ['.ize$', 'VB'], ['.[^aeiou]ise$', 'VB'], ['.[aeiou]te$', 'VB'], ['.ea$', 'NN'], ['[aeiou][pns]er$', 'NN'], ['.ia$', 'NN'], ['.sis$', 'NN'], ['.[aeiou]na$', 'NN'], ['.[^aeiou]ity$', 'NN'], ['.[^aeiou]ium$', 'NN'], ['.[^aeiou][ei]al$', 'JJ'], ['.ffy$', 'JJ'], ['.[^aeiou]ic$', 'JJ'], ['.(gg|bb|zz)ly$', 'JJ'], ['.[aeiou]my$', 'JJ'], ['.[aeiou]ble$', 'JJ'], ['.[^aeiou]ful$', 'JJ'], ['.[^aeiou]ish$', 'JJ'], ['.[^aeiou]ica$', 'NN'], ['[aeiou][^aeiou]is$', 'NN'], ['[^aeiou]ard$', 'NN'], ['[^aeiou]ism$', 'NN'], ['.[^aeiou]ity$', 'NN'], ['.[^aeiou]ium$', 'NN'], ['.[lstrn]us$', 'NN'], ['..ic$', 'JJ'], ['[aeiou][^aeiou]id$', 'JJ'], ['.[^aeiou]ish$', 'JJ'], ['.[^aeiou]ive$', 'JJ'], ['[ea]{2}zy$', 'JJ'], ['[^aeiou]ician$', 'AC'], ['.keeper$', 'AC'], ['.logist$', 'AC'], ['..ier$', 'AC'], ['.[^aeiou][ao]pher$', 'AC'], ['.tive$', 'AC'], ['[aeiou].*ist$', 'JJ'], + //slang things + ['^um+$', 'EX'], //ummmm + ['^([hyj]a)+$', 'EX'], //hahah + ['^(k)+$', 'EX'], //kkkk + ['^(yo)+$', 'EX'], //yoyo + ['^yes+$', 'EX'], //yessss + ['^no+$', 'EX'], //noooo + ['^lol[sz]$', 'EX'], //lol + ['^woo+[pt]?$', 'EX'], //woo + ['^ug?h+$', 'EX'], //uhh + ['^uh[ -]?oh$', 'EX']]. //uhoh + map(function (a) { + return { + reg: new RegExp(a[0], 'i'), + pos: tag_mapping[a[1]] + }; + }); + }, { "../../parts_of_speech.js": 36 }], 49: [function (require, module, exports) { + //part-of-speech tagging + 'use strict'; + + var lumper = require('./lumper'); + var fancy_lumping = require('./fancy_lumping'); + var pos = require('./parts_of_speech'); + var assign = require('./assign'); + + var grammar_pass = require('./passes/grammar_pass'); + var phrasal_verbs = require('./passes/phrasal_verbs'); + var interjection_fixes = require('./passes/interjection_fixes'); + var lexicon_pass = require('./passes/lexicon_pass'); + var capital_signals = require('./passes/capital_signals'); + var conditional_pass = require('./passes/conditional_pass'); + var ambiguous_dates = require('./passes/ambiguous_dates'); + var multiple_pass = require('./passes/multiples_pass'); + var regex_pass = require('./passes/regex_pass'); + var quotation_pass = require('./passes/quotation_pass'); + + var noun_fallback = function noun_fallback(terms) { + for (var i = 0; i < terms.length; i++) { + if (terms[i].tag === '?' && terms[i].normal.match(/[a-z]/)) { + terms[i] = assign(terms[i], 'Noun', 'fallback'); + } + } + return terms; + }; + + //turn nouns into person/place + var specific_noun = function specific_noun(terms) { + for (var i = 0; i < terms.length; i++) { + var t = terms[i]; + if (t instanceof pos.Noun) { + if (t.is_person()) { + terms[i] = assign(t, 'Person', 'is_person'); + } else if (t.is_place()) { + terms[i] = assign(t, 'Place', 'is_place'); + } else if (t.is_value()) { + terms[i] = assign(t, 'Value', 'is_value'); + } else if (t.is_date()) { + terms[i] = assign(t, 'Date', 'is_date'); + } else if (t.is_organization()) { + terms[i] = assign(t, 'Organization', 'is_organization'); + } + } + } + return terms; + }; + + var tagger = function tagger(s, options) { + //word-level rules + s.terms = capital_signals(s.terms); + s.terms = lexicon_pass(s.terms, options); + s.terms = multiple_pass(s.terms); + s.terms = regex_pass(s.terms); + s.terms = interjection_fixes(s.terms); + //repeat these steps a couple times, to wiggle-out the grammar + for (var i = 0; i < 2; i++) { + s.terms = grammar_pass(s); + s.terms = specific_noun(s.terms); + s.terms = ambiguous_dates(s.terms); + s.terms = lumper(s.terms); + s.terms = noun_fallback(s.terms); + s.terms = phrasal_verbs(s.terms); + s.terms = fancy_lumping(s.terms); + } + s.terms = conditional_pass(s.terms); + s.terms = quotation_pass(s.terms); + return s.terms; + }; + + module.exports = tagger; + }, { "./assign": 33, "./fancy_lumping": 34, "./lumper": 35, "./parts_of_speech": 36, "./passes/ambiguous_dates": 37, "./passes/capital_signals": 38, "./passes/conditional_pass": 39, "./passes/grammar_pass": 40, "./passes/interjection_fixes": 41, "./passes/lexicon_pass": 42, "./passes/multiples_pass": 43, "./passes/phrasal_verbs": 44, "./passes/quotation_pass": 45, "./passes/regex_pass": 46 }], 50: [function (require, module, exports) { + 'use strict'; + //build-out this mapping + + var interrogatives = { + 'who': 'who', + 'whose': 'who', + 'whom': 'who', + 'which person': 'who', + + 'where': 'where', + 'when': 'when', + + 'why': 'why', + 'how come': 'why' + }; + + var easyForm = function easyForm(s, i) { + var t = s.terms[i]; + var nextTerm = s.terms[i + 1]; + + //some interrogative forms are two-terms, try it. + if (nextTerm) { + var twoTerm = t.normal + ' ' + nextTerm.normal; + if (interrogatives[twoTerm]) { + return interrogatives[twoTerm]; + } + } + //try an interrogative first - 'who' + if (interrogatives[t.normal]) { + return interrogatives[t.normal]; + } + //an interrogative as a contraction - 'why'd' + if (interrogatives[t.expansion]) { + return interrogatives[t.expansion]; + } + return false; + }; + + module.exports = easyForm; + }, {}], 51: [function (require, module, exports) { + 'use strict'; + + var hardFormVerb = { + 'which': 'which', + 'what': 'what' + }; + + // "what time" -> 'when' + var knownForm = { + time: 'when', + day: 'when', + year: 'when', + + person: 'who', //more covered by pos["Actor"] + + amount: 'number', + number: 'number' + }; + + var hardForm = function hardForm(s, i) { + var t = s.terms[i]; + var nextTerm = s.terms[i + 1]; + // which, or what + var questionWord = hardFormVerb[t.normal] || hardFormVerb[t.expanded]; + // end early. + if (!nextTerm || !questionWord) { + return null; + } + + //"which is.." + if (nextTerm.pos['Copula']) { + return t.normal; + } + //"which politician.." + if (nextTerm.pos['Actor']) { + return 'who'; + } + //"what time.." + if (knownForm[nextTerm.normal]) { + return knownForm[nextTerm.normal]; + } + + return questionWord; + }; + + module.exports = hardForm; + }, {}], 52: [function (require, module, exports) { + 'use strict'; + + var _createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); + } + }return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; + }; + }(); + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + }return call && ((typeof call === "undefined" ? "undefined" : _typeof2(call)) === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : _typeof2(superClass))); + }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + } + + var Sentence = require('../sentence.js'); + var question_form = require('./question_form'); + + var Question = function (_Sentence) { + _inherits(Question, _Sentence); + + function Question(str, options) { + _classCallCheck(this, Question); + + return _possibleConstructorReturn(this, Object.getPrototypeOf(Question).call(this, str, options)); + } + + _createClass(Question, [{ + key: 'form', + value: function form() { + return question_form(this); + } + }]); + + return Question; + }(Sentence); + + Question.fn = Question.prototype; + + module.exports = Question; + + // let q = new Question(`accordingly, is he cool?`); + // let q = new Question(`what time did you show up?`); + // console.log(q.form()); + }, { "../sentence.js": 55, "./question_form": 53 }], 53: [function (require, module, exports) { + 'use strict'; + //classifies a question into: + + var yesNoTerm = require('./yesNo.js'); + var easyForm = require('./easyForm.js'); + var hardForm = require('./hardForm.js'); + + // how, when, where, who, why + // what, which + // number + // yesNo + + //exceptions: + // You bought what!? - Echo question + // Who bought what? - Multiple wh-expressions + // I wonder who Fred will ask to leave. - passive question + + // "Five Ws and one H" + 'which' + // let forms = { + // how: ['in what way'], + // what: ['what\'s'], + // which: ['what one'], + // number: ['how many', 'how much', 'how far', 'how long'], + // }; + + var question_form = function question_form(s) { + //loop through and find first signal + for (var i = 0; i < s.terms.length; i++) { + + //who is.. -> "who" + var form = easyForm(s, i); + if (form) { + return form; + } + //which politician.. -> "who" + form = hardForm(s, i); + if (form) { + return form; + } + //is he.. -> "yesNo" + if (yesNoTerm(s, i)) { + return 'yesNo'; + } + } + return null; + }; + + module.exports = question_form; + }, { "./easyForm.js": 50, "./hardForm.js": 51, "./yesNo.js": 54 }], 54: [function (require, module, exports) { + 'use strict'; + + // Yes/No questions take the form: + // he is -> is he? + + var yesNoVerb = { + is: true, + are: true, + was: true, + will: true, + do: true, + did: true + }; + + var yesNoTerm = function yesNoTerm(s, i) { + var t = s.terms[i]; + var lastTerm = s.terms[i - 1]; + var nextTerm = s.terms[i + 1]; + //try a yes/no question then + if (yesNoVerb[t.normal] || yesNoVerb[t.expansion]) { + //leading 'is x...' is a question + if (!lastTerm) { + return true; + } + //ending '... are.' is a not question + if (!lastTerm) { + return false; + } + // 'he is' is not a question.. + if (lastTerm.pos['Pronoun'] || lastTerm.pos['Person']) { + return false; + } + // 'is he' is a question.. + if (nextTerm.pos['Pronoun'] || nextTerm.pos['Person']) { + return true; + } + } + return false; + }; + + module.exports = yesNoTerm; + }, {}], 55: [function (require, module, exports) { + 'use strict'; + + var _createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); + } + }return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; + }; + }(); + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + var Term = require('../term/term'); + var tagger = require('./pos/tagger'); + var passive_voice = require('./passive_voice'); + var contractions = { + interpret: require('./contractions/interpret'), + contract: require('./contractions/contract'), + expand: require('./contractions/expand') + }; + var change_tense = require('./tense'); + var spot = require('./spot'); + var _match = require('../match/match'); + + //a sentence is an array of Term objects, along with their various methods + + var Sentence = function () { + function Sentence(str, options) { + _classCallCheck(this, Sentence); + + this.str = str || ''; + options = options || {}; + var the = this; + var words = str.split(/( +)/); + //build-up term-objects + this.terms = []; + if (words[0] === '') { + words.shift(); + } + for (var i = 0; i < words.length; i++) { + if (!words[i] || !words[i].match(/\S/i)) { + continue; + } + var whitespace = { + preceding: words[i - 1], + trailing: words[i + 1] + }; + //don't use them twice + words[i - 1] = null; + words[i + 1] = null; + this.terms.push(new Term(words[i], null, whitespace)); + } + // console.log(this.terms); + //part-of-speech tagging + this.terms = tagger(this, options); + // process contractions + this.terms = contractions.interpret(this.terms); + //now the hard part is already done, just flip them + this.contractions = { + // "he'd go" -> "he would go" + expand: function expand() { + the.terms = contractions.expand(the.terms); + return the; + }, + // "he would go" -> "he'd go" + contract: function contract() { + the.terms = contractions.contract(the.terms); + return the; + } + }; + } + + //Sentence methods: + + //insert a new word at this point + + _createClass(Sentence, [{ + key: 'addBefore', + value: function addBefore(i, str) { + var t = new Term(str); + this.terms.splice(i, 0, t); + } + }, { + key: 'addAfter', + value: function addAfter(i, str) { + var t = new Term(str); + this.terms.splice(i + 1, 0, t); + } + + //tokenize the match string, just like you'd tokenize the sentence. + //this avoids lumper/splitter problems between haystack and needle + + }, { + key: 'tokenize_match', + value: function tokenize_match(str) { + var regs = new Sentence(str).terms; //crazy! + regs = regs.map(function (t) { + return t.text; + }); + regs = regs.filter(function (t) { + return t !== ''; + }); + return regs; + } + + // a regex-like lookup for a list of terms. + // returns [] of matches in a 'Terms' class + + }, { + key: 'match', + value: function match(match_str, options) { + var regs = this.tokenize_match(match_str); + return _match.findAll(this.terms, regs, options); + } + //returns a transformed sentence + + }, { + key: 'replace', + value: function replace(match_str, replacement, options) { + var regs = this.tokenize_match(match_str); + replacement = this.tokenize_match(replacement); + _match.replaceAll(this.terms, regs, replacement, options); + return this; + } + + //the ending punctuation + + }, { + key: 'terminator', + value: function terminator() { + var allowed = ['.', '?', '!']; + var punct = this.str.slice(-1) || ''; + if (allowed.indexOf(punct) !== -1) { + return punct; + } + return '.'; + } + + //part-of-speech assign each term + + }, { + key: 'tag', + value: function tag() { + this.terms = tagger(this); + return this.terms; + } + + //is it a question/statement + + }, { + key: 'sentence_type', + value: function sentence_type() { + var char = this.terminator(); + var types = { + '?': 'interrogative', + '!': 'exclamative', + '.': 'declarative' + }; + return types[char] || 'declarative'; + } + + // A was verbed by B - B verbed A + + }, { + key: 'is_passive', + value: function is_passive() { + return passive_voice(this); + } + // Question doesn't have negate, this is a placeholder + + }, { + key: 'negate', + value: function negate() { + return this; + } + + //map over Term methods + + }, { + key: 'text', + value: function text() { + return this.terms.reduce(function (s, t) { + //implicit contractions shouldn't be included + if (t.text) { + s += (t.whitespace.preceding || '') + t.text + (t.whitespace.trailing || ''); + } + return s; + }, ''); + } + //like text but for cleaner text + + }, { + key: 'normalized', + value: function normalized() { + return this.terms.reduce(function (s, t) { + if (t.normal) { + s += ' ' + t.normal; + } + return s; + }, '').trim(); + } + + //further 'lemmatisation/inflection' + + }, { + key: 'root', + value: function root() { + return this.terms.reduce(function (s, t) { + s += ' ' + t.root(); + return s; + }, '').trim(); + } + //return only the main POS classnames/tags + + }, { + key: 'tags', + value: function tags() { + return this.terms.map(function (t) { + return t.tag || '?'; + }); + } + //mining for specific things + + }, { + key: 'people', + value: function people() { + return this.terms.filter(function (t) { + return t.pos['Person']; + }); + } + }, { + key: 'places', + value: function places() { + return this.terms.filter(function (t) { + return t.pos['Place']; + }); + } + }, { + key: 'dates', + value: function dates() { + return this.terms.filter(function (t) { + return t.pos['Date']; + }); + } + }, { + key: 'organizations', + value: function organizations() { + return this.terms.filter(function (t) { + return t.pos['Organization']; + }); + } + }, { + key: 'values', + value: function values() { + return this.terms.filter(function (t) { + return t.pos['Value']; + }); + } + + // john walks quickly -> john walked quickly + + }, { + key: 'to_past', + value: function to_past() { + change_tense(this, 'past'); + return this; + } + // john walked quickly -> john walks quickly + + }, { + key: 'to_present', + value: function to_present() { + change_tense(this, 'present'); + return this; + } + // john walked quickly -> john will walk quickly + + }, { + key: 'to_future', + value: function to_future() { + change_tense(this, 'future'); + return this; + } + }, { + key: 'strip_conditions', + value: function strip_conditions() { + var _this = this; + + this.terms = this.terms.filter(function (t, i) { + //remove preceding condition + if (i > 0 && t.pos['Condition'] && !_this.terms[i - 1].pos['Condition']) { + _this.terms[i - 1].text = _this.terms[i - 1].text.replace(/,$/, ''); + _this.terms[i - 1].whitespace.trailing = ''; + _this.terms[i - 1].rebuild(); + } + return !t.pos['Condition']; + }); + // + return this; + } + + //named-entity recognition + + }, { + key: 'topics', + value: function topics() { + return spot(this); + } + }]); + + return Sentence; + }(); + + Sentence.fn = Sentence.prototype; + + module.exports = Sentence; + + // let s = new Sentence(`don't go`); + // console.log(s.text()); + // s.contractions.expand(); + // console.log(s.text()); + // s.contractions.contract(); + // console.log(s.text()); + }, { "../match/match": 25, "../term/term": 95, "./contractions/contract": 29, "./contractions/expand": 30, "./contractions/interpret": 31, "./passive_voice": 32, "./pos/tagger": 49, "./spot": 56, "./tense": 59 }], 56: [function (require, module, exports) { + 'use strict'; + //generic named-entity-recognition + + var blacklist = { + man: true, + woman: true, + girl: true, + boy: true, + guy: true, + father: true, + mother: true, + sister: true, + brother: true + }; + + var consolidate = function consolidate(topics) { + var names = {}; + for (var i = 0; i < topics.length; i++) { + var normal = topics[i].root(); + if (normal) { + names[normal] = names[normal] || { + count: 0, + text: normal + }; + names[normal].count += 1; + } + } + //sort by freq + var arr = Object.keys(names).map(function (k) { + return names[k]; + }); + return arr.sort(function (a, b) { + if (a.count > b.count) { + return -1; + } else { + return 1; + } + }); + }; + + var spot = function spot(s) { + var topics = []; + for (var i = 0; i < s.terms.length; i++) { + var t = s.terms[i]; + //some stop-words + if (blacklist[t.normal]) { + continue; + } + //grab person, place, locations + if (t.pos['Place'] || t.pos['Organization']) { + topics.push(t); + continue; + } + if (t.pos['Person'] && !t.pos['Pronoun']) { + topics.push(t); + continue; + } + //add capitalized nouns... + if (i !== 0 && t.pos['Noun'] && t.is_capital()) { + //no dates, or values + if (t.pos['Value'] || t.pos['Date'] || t.pos['Pronoun']) { + continue; + } + topics.push(t); + } + } + return consolidate(topics); + }; + + module.exports = spot; + }, {}], 57: [function (require, module, exports) { + 'use strict'; + + var fns = require('../../../fns'); + + //these terms are nicer ways to negate a sentence + //ie. john always walks -> john always doesn't walk + var logical_negate = { + 'everyone': 'no one', + 'everybody': 'nobody', + 'someone': 'no one', + 'somebody': 'nobody', + // everything:"nothing", + 'always': 'never' + }; + //create corrollary + var logical_affirm = fns.reverseObj(logical_negate); + //these are not symmetic + logical_affirm['nobody'] = 'somebody'; + + var negate = function negate(s) { + for (var i = 0; i < s.terms.length; i++) { + var t = s.terms[i]; + //these verbs are red-herrings + if (t.pos['Condition'] || t.pos['Quotation']) { + continue; + } + //logical-negations are smoother than verb-negations + //ie. always -> never + if (logical_negate[t.normal]) { + t.changeTo(logical_negate[t.normal]); + break; + } + if (logical_affirm[t.normal]) { + t.changeTo(logical_affirm[t.normal]); + break; + } + //negate the first verb + if (t.pos['Verb']) { + t.negate(); + break; + } + } + return; + }; + + module.exports = negate; + }, { "../../../fns": 23 }], 58: [function (require, module, exports) { + 'use strict'; + + var _createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); + } + }return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; + }; + }(); + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + }return call && ((typeof call === "undefined" ? "undefined" : _typeof2(call)) === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : _typeof2(superClass))); + }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + } + + var Sentence = require('../sentence.js'); + var _negate = require('./negate/negate.js'); + + var Statement = function (_Sentence) { + _inherits(Statement, _Sentence); + + function Statement(str, options) { + _classCallCheck(this, Statement); + + return _possibleConstructorReturn(this, Object.getPrototypeOf(Statement).call(this, str, options)); + } + + _createClass(Statement, [{ + key: 'negate', + value: function negate() { + _negate(this); + return this; + } + }]); + + return Statement; + }(Sentence); + + Statement.fn = Statement.prototype; + + module.exports = Statement; + + // let s = new Statement('john is a person'); + // console.log(s); + }, { "../sentence.js": 55, "./negate/negate.js": 57 }], 59: [function (require, module, exports) { + 'use strict'; + //change a sentence to past, present, or future tense + + var pos = require('./pos/parts_of_speech.js'); + + //conjugate a specific verb + var flip_verb = function flip_verb(t, tense) { + if (tense === 'present') { + t.to_present(); + } else if (tense === 'past') { + t.to_past(); + } else if (tense === 'future') { + t.to_future(); + } + return t; + }; + + var change_tense = function change_tense(s, tense) { + //convert all verbs + s.terms.forEach(function (t) { + if (t instanceof pos.Verb) { + flip_verb(t, tense); + } + }); + return s; + }; + + // [ + // 'john walks to the church', + // 'john walks and feeds the birds', + // 'john always walks', + // 'will you walk?', + // ]; + + module.exports = change_tense; + }, { "./pos/parts_of_speech.js": 36 }], 60: [function (require, module, exports) { + 'use strict'; + + var _createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); + } + }return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; + }; + }(); + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + }return call && ((typeof call === "undefined" ? "undefined" : _typeof2(call)) === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : _typeof2(superClass))); + }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + } + + var Term = require('../term.js'); + + var _to_comparative = require('./to_comparative'); + var _to_superlative = require('./to_superlative'); + var adj_to_adv = require('./to_adverb'); + var adj_to_noun = require('./to_noun'); + + var Adjective = function (_Term) { + _inherits(Adjective, _Term); + + function Adjective(str, tag) { + _classCallCheck(this, Adjective); + + var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Adjective).call(this, str)); + + _this.tag = tag; + _this.pos['Adjective'] = true; + return _this; + } + + _createClass(Adjective, [{ + key: 'to_comparative', + value: function to_comparative() { + return _to_comparative(this.normal); + } + }, { + key: 'to_superlative', + value: function to_superlative() { + return _to_superlative(this.normal); + } + }, { + key: 'to_noun', + value: function to_noun() { + return adj_to_noun(this.normal); + } + }, { + key: 'to_adverb', + value: function to_adverb() { + return adj_to_adv(this.normal); + } + }, { + key: 'conjugate', + value: function conjugate() { + return { + comparative: _to_comparative(this.normal), + superlative: _to_superlative(this.normal), + adverb: adj_to_adv(this.normal), + noun: adj_to_noun(this.normal) + }; + } + }]); + + return Adjective; + }(Term); + + Adjective.fn = Adjective.prototype; + // let t = new Adjective("quick") + // console.log(t.conjugate()) + + module.exports = Adjective; + }, { "../term.js": 95, "./to_adverb": 61, "./to_comparative": 62, "./to_noun": 63, "./to_superlative": 64 }], 61: [function (require, module, exports) { + //turn 'quick' into 'quickly' + 'use strict'; + + var adj_to_adv = function adj_to_adv(str) { + var irregulars = { + 'idle': 'idly', + 'public': 'publicly', + 'vague': 'vaguely', + 'day': 'daily', + 'icy': 'icily', + 'single': 'singly', + 'female': 'womanly', + 'male': 'manly', + 'simple': 'simply', + 'whole': 'wholly', + 'special': 'especially', + 'straight': 'straight', + 'wrong': 'wrong', + 'fast': 'fast', + 'hard': 'hard', + 'late': 'late', + 'early': 'early', + 'well': 'well', + 'best': 'best', + 'latter': 'latter', + 'bad': 'badly' + }; + + var dont = { + 'foreign': 1, + 'black': 1, + 'modern': 1, + 'next': 1, + 'difficult': 1, + 'degenerate': 1, + 'young': 1, + 'awake': 1, + 'back': 1, + 'blue': 1, + 'brown': 1, + 'orange': 1, + 'complex': 1, + 'cool': 1, + 'dirty': 1, + 'done': 1, + 'empty': 1, + 'fat': 1, + 'fertile': 1, + 'frozen': 1, + 'gold': 1, + 'grey': 1, + 'gray': 1, + 'green': 1, + 'medium': 1, + 'parallel': 1, + 'outdoor': 1, + 'unknown': 1, + 'undersized': 1, + 'used': 1, + 'welcome': 1, + 'yellow': 1, + 'white': 1, + 'fixed': 1, + 'mixed': 1, + 'super': 1, + 'guilty': 1, + 'tiny': 1, + 'able': 1, + 'unable': 1, + 'same': 1, + 'adult': 1 + }; + + var transforms = [{ + reg: /al$/i, + repl: 'ally' + }, { + reg: /ly$/i, + repl: 'ly' + }, { + reg: /(.{3})y$/i, + repl: '$1ily' + }, { + reg: /que$/i, + repl: 'quely' + }, { + reg: /ue$/i, + repl: 'uly' + }, { + reg: /ic$/i, + repl: 'ically' + }, { + reg: /ble$/i, + repl: 'bly' + }, { + reg: /l$/i, + repl: 'ly' + }]; + + var not_matches = [/airs$/, /ll$/, /ee.$/, /ile$/]; + + if (dont[str]) { + return null; + } + if (irregulars[str]) { + return irregulars[str]; + } + if (str.length <= 3) { + return null; + } + for (var i = 0; i < not_matches.length; i++) { + if (str.match(not_matches[i])) { + return null; + } + } + for (var i = 0; i < transforms.length; i++) { + if (str.match(transforms[i].reg)) { + return str.replace(transforms[i].reg, transforms[i].repl); + } + } + return str + 'ly'; + }; + // console.log(adj_to_adv('direct')) + + module.exports = adj_to_adv; + }, {}], 62: [function (require, module, exports) { + //turn 'quick' into 'quickly' + 'use strict'; + + var convertables = require('../../data/convertables.js'); + + var to_comparative = function to_comparative(str) { + var irregulars = { + 'grey': 'greyer', + 'gray': 'grayer', + 'green': 'greener', + 'yellow': 'yellower', + 'red': 'redder', + 'good': 'better', + 'well': 'better', + 'bad': 'worse', + 'sad': 'sadder' + }; + + var dont = { + 'overweight': 1, + 'main': 1, + 'nearby': 1, + 'asleep': 1, + 'weekly': 1, + 'secret': 1, + 'certain': 1 + }; + + var transforms = [{ + reg: /y$/i, + repl: 'ier' + }, { + reg: /([aeiou])t$/i, + repl: '$1tter' + }, { + reg: /([aeou])de$/i, + repl: '$1der' + }, { + reg: /nge$/i, + repl: 'nger' + }]; + + var matches = [/ght$/, /nge$/, /ough$/, /ain$/, /uel$/, /[au]ll$/, /ow$/, /old$/, /oud$/, /e[ae]p$/]; + + var not_matches = [/ary$/, /ous$/]; + + if (dont.hasOwnProperty(str)) { + return null; + } + + for (var i = 0; i < transforms.length; i++) { + if (str.match(transforms[i].reg)) { + return str.replace(transforms[i].reg, transforms[i].repl); + } + } + + if (convertables.hasOwnProperty(str)) { + if (str.match(/e$/)) { + return str + 'r'; + } + return str + 'er'; + } + + if (irregulars.hasOwnProperty(str)) { + return irregulars[str]; + } + + for (var i = 0; i < not_matches.length; i++) { + if (str.match(not_matches[i])) { + return 'more ' + str; + } + } + + for (var i = 0; i < matches.length; i++) { + if (str.match(matches[i])) { + return str + 'er'; + } + } + return 'more ' + str; + }; + + // console.log(to_comparative("great")) + + module.exports = to_comparative; + }, { "../../data/convertables.js": 4 }], 63: [function (require, module, exports) { + //convert cute to cuteness + 'use strict'; + + var to_noun = function to_noun(w) { + var irregulars = { + 'clean': 'cleanliness', + 'naivety': 'naivety' + }; + if (!w) { + return ''; + } + if (irregulars.hasOwnProperty(w)) { + return irregulars[w]; + } + if (w.match(' ')) { + return w; + } + if (w.match(/w$/)) { + return w; + } + var transforms = [{ + 'reg': /y$/, + 'repl': 'iness' + }, { + 'reg': /le$/, + 'repl': 'ility' + }, { + 'reg': /ial$/, + 'repl': 'y' + }, { + 'reg': /al$/, + 'repl': 'ality' + }, { + 'reg': /ting$/, + 'repl': 'ting' + }, { + 'reg': /ring$/, + 'repl': 'ring' + }, { + 'reg': /bing$/, + 'repl': 'bingness' + }, { + 'reg': /sing$/, + 'repl': 'se' + }, { + 'reg': /ing$/, + 'repl': 'ment' + }, { + 'reg': /ess$/, + 'repl': 'essness' + }, { + 'reg': /ous$/, + 'repl': 'ousness' + }]; + + for (var i = 0; i < transforms.length; i++) { + if (w.match(transforms[i].reg)) { + return w.replace(transforms[i].reg, transforms[i].repl); + } + } + + if (w.match(/s$/)) { + return w; + } + return w + 'ness'; + }; + + // console.log(to_noun("great")) + + module.exports = to_noun; + }, {}], 64: [function (require, module, exports) { + //turn 'quick' into 'quickest' + 'use strict'; + + var convertables = require('../../data/convertables.js'); + + var to_superlative = function to_superlative(str) { + var irregulars = { + 'nice': 'nicest', + 'late': 'latest', + 'hard': 'hardest', + 'inner': 'innermost', + 'outer': 'outermost', + 'far': 'furthest', + 'worse': 'worst', + 'bad': 'worst', + 'good': 'best' + }; + + var dont = { + 'overweight': 1, + 'ready': 1 + }; + + var transforms = [{ + 'reg': /y$/i, + 'repl': 'iest' + }, { + 'reg': /([aeiou])t$/i, + 'repl': '$1ttest' + }, { + 'reg': /([aeou])de$/i, + 'repl': '$1dest' + }, { + 'reg': /nge$/i, + 'repl': 'ngest' + }]; + + var matches = [/ght$/, /nge$/, /ough$/, /ain$/, /uel$/, /[au]ll$/, /ow$/, /oud$/, /...p$/]; + + var not_matches = [/ary$/]; + + var generic_transformation = function generic_transformation(s) { + if (s.match(/e$/)) { + return s + 'st'; + } + return s + 'est'; + }; + + for (var i = 0; i < transforms.length; i++) { + if (str.match(transforms[i].reg)) { + return str.replace(transforms[i].reg, transforms[i].repl); + } + } + + if (convertables.hasOwnProperty(str)) { + return generic_transformation(str); + } + + if (dont.hasOwnProperty(str)) { + return 'most ' + str; + } + + if (irregulars.hasOwnProperty(str)) { + return irregulars[str]; + } + for (var i = 0; i < not_matches.length; i++) { + if (str.match(not_matches[i])) { + return 'most ' + str; + } + } + + for (var i = 0; i < matches.length; i++) { + if (str.match(matches[i])) { + return generic_transformation(str); + } + } + return 'most ' + str; + }; + + // console.log(to_superlative("great")) + + module.exports = to_superlative; + }, { "../../data/convertables.js": 4 }], 65: [function (require, module, exports) { + 'use strict'; + + var _createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); + } + }return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; + }; + }(); + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + }return call && ((typeof call === "undefined" ? "undefined" : _typeof2(call)) === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : _typeof2(superClass))); + }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + } + + var Term = require('../term.js'); + var _to_adjective = require('./to_adjective.js'); + + var Adverb = function (_Term) { + _inherits(Adverb, _Term); + + function Adverb(str, tag) { + _classCallCheck(this, Adverb); + + var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Adverb).call(this, str)); + + _this.tag = tag; + _this.pos['Adverb'] = true; + return _this; + } + + _createClass(Adverb, [{ + key: 'to_adjective', + value: function to_adjective() { + return _to_adjective(this.normal); + } + }]); + + return Adverb; + }(Term); + + Adverb.fn = Adverb.prototype; + // let t = new Adverb("quickly") + // console.log(t.to_adjective()) + + module.exports = Adverb; + }, { "../term.js": 95, "./to_adjective.js": 66 }], 66: [function (require, module, exports) { + //turns 'quickly' into 'quick' + 'use strict'; + + var to_adjective = function to_adjective(str) { + var irregulars = { + 'idly': 'idle', + 'sporadically': 'sporadic', + 'basically': 'basic', + 'grammatically': 'grammatical', + 'alphabetically': 'alphabetical', + 'economically': 'economical', + 'conically': 'conical', + 'politically': 'political', + 'vertically': 'vertical', + 'practically': 'practical', + 'theoretically': 'theoretical', + 'critically': 'critical', + 'fantastically': 'fantastic', + 'mystically': 'mystical', + 'pornographically': 'pornographic', + 'fully': 'full', + 'jolly': 'jolly', + 'wholly': 'whole' + }; + var transforms = [{ + 'reg': /bly$/i, + 'repl': 'ble' + }, { + 'reg': /gically$/i, + 'repl': 'gical' + }, { + 'reg': /([rsdh])ically$/i, + 'repl': '$1ical' + }, { + 'reg': /ically$/i, + 'repl': 'ic' + }, { + 'reg': /uly$/i, + 'repl': 'ue' + }, { + 'reg': /ily$/i, + 'repl': 'y' + }, { + 'reg': /(.{3})ly$/i, + 'repl': '$1' + }]; + if (irregulars.hasOwnProperty(str)) { + return irregulars[str]; + } + for (var i = 0; i < transforms.length; i++) { + if (str.match(transforms[i].reg)) { + return str.replace(transforms[i].reg, transforms[i].repl); + } + } + return str; + }; + + // console.log(to_adjective('quickly') === 'quick') + // console.log(to_adjective('marvelously') === 'marvelous') + module.exports = to_adjective; + }, {}], 67: [function (require, module, exports) { + 'use strict'; + //turn "plz" "please" + + var implications = { + 'plz': 'please', + 'tmrw': 'tomorrow', + 'wat': 'what', + 'r': 'are', + 'u': 'you' + }; + + var implied = function implied(str) { + if (implications[str]) { + return implications[str]; + } + return null; + }; + + module.exports = implied; + }, {}], 68: [function (require, module, exports) { + 'use strict'; + + var is_acronym = function is_acronym(str) { + //like N.D.A + if (str.match(/([A-Z]\.)+[A-Z]?$/)) { + return true; + } + //like NDA + if (str.match(/[A-Z]{3}$/)) { + return true; + } + return false; + }; + module.exports = is_acronym; + }, {}], 69: [function (require, module, exports) { + 'use strict'; + + var is_acronym = require('../is_acronym.js'); + + //chooses an indefinite aricle 'a/an' for a word + var irregulars = { + 'hour': 'an', + 'heir': 'an', + 'heirloom': 'an', + 'honest': 'an', + 'honour': 'an', + 'honor': 'an', + 'uber': 'an' //german u + }; + + var indefinite_article = function indefinite_article(str) { + if (!str) { + return null; + } + + //pronounced letters of acronyms that get a 'an' + var an_acronyms = { + A: true, + E: true, + F: true, + H: true, + I: true, + L: true, + M: true, + N: true, + O: true, + R: true, + S: true, + X: true + }; + //'a' regexes + var a_regexs = [/^onc?e/i, //'wu' sound of 'o' + /^u[bcfhjkqrstn][aeiou]/i, // 'yu' sound for hard 'u' + /^eul/i]; + + //begin business time + //////////////////// + //explicit irregular forms + if (irregulars.hasOwnProperty(str)) { + return irregulars[str]; + } + //spelled-out acronyms + if (is_acronym(str) && an_acronyms.hasOwnProperty(str.substr(0, 1))) { + return 'an'; + } + //'a' regexes + for (var i = 0; i < a_regexs.length; i++) { + if (str.match(a_regexs[i])) { + return 'a'; + } + } + //basic vowel-startings + if (str.match(/^[aeiou]/i)) { + return 'an'; + } + return 'a'; + }; + + module.exports = indefinite_article; + + // console.log(indefinite_article('N.D.A')); + }, { "../is_acronym.js": 68 }], 70: [function (require, module, exports) { + 'use strict'; + + var _createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); + } + }return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; + }; + }(); + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + }return call && ((typeof call === "undefined" ? "undefined" : _typeof2(call)) === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : _typeof2(superClass))); + }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + } + + var Noun = require('../noun.js'); + var parse_date = require('./parse_date.js'); + + var _Date = function (_Noun) { + _inherits(_Date, _Noun); + + function _Date(str, tag) { + _classCallCheck(this, _Date); + + var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(_Date).call(this, str)); + + _this.tag = tag; + _this.pos['Date'] = true; + _this.data = parse_date(_this.text) || {}; + return _this; + } + + //can we make it a js Date object? + + _createClass(_Date, [{ + key: 'is_date', + value: function is_date() { + var o = this.data; + if (o.month === null || o.day === null || o.year === null) { + return false; + } + return true; + } + }, { + key: 'date', + value: function date() { + if (this.is_date() === false) { + return null; + } + var d = new Date(); + if (this.data.year) { + d.setYear(this.data.year); + } + if (this.data.month !== null) { + d.setMonth(this.data.month); + } + if (this.data.day !== null) { + d.setDate(this.data.day); + } + return d; + } + }]); + + return _Date; + }(Noun); + + _Date.fn = _Date.prototype; + + module.exports = _Date; + + // let d = new _Date('June 4th 1993'); + // console.log(d.date()); + }, { "../noun.js": 76, "./parse_date.js": 73 }], 71: [function (require, module, exports) { + 'use strict'; + + var months = require('../../../data/dates').months.concat(['march', 'may']); //(march and may are ambiguous grammatically) + var month = '(' + months.join('|') + ')'; + var day = '([0-9]{1,2})'; + var year = '\'?([12][0-9]{3})'; + + var rules = [{ + reg: month + ' ' + day + ' ' + year, //'March 1st 1987' + order: ['month', 'day', 'year'] + }, { + reg: day + ' of ' + month + ' ' + year, //'3rd of March 1969', + order: ['day', 'month', 'year'] + }, + + //incomplete versions + { + reg: day + ' of ' + month, //'3rd of March', + order: ['day', 'month'] + }, { + reg: month + ' ' + year, //'March 1969', + order: ['month', 'year'] + }, { + reg: month + ' ' + day, //'March 18th', + order: ['month', 'day'] + }, { + reg: day + ' ' + month, //'18th of March', + order: ['day', 'month'] + }, { + reg: '' + month, //'january' + order: ['month'] + }, { + reg: '' + year, //'1998' + order: ['year'] + }].map(function (o) { + o.reg = new RegExp('\\b' + o.reg + '\\b', ''); + return o; + }); + module.exports = rules; + }, { "../../../data/dates": 5 }], 72: [function (require, module, exports) { + + 'use strict'; + + var dates = require('../../../data/dates'); + + //build date regex + var terms = dates.months.concat(dates.days); + var day_reg = '(\\b' + terms.join('\\b|\\b') + '\\b)'; + day_reg = new RegExp(day_reg, 'i'); + var times_reg = /1?[0-9]:[0-9]{2}/; + + var is_date = function is_date(str) { + if (str.match(day_reg) || str.match(times_reg)) { + return true; + } + return false; + }; + + module.exports = is_date; + + // console.log(is_date('january fifth, 2015')); + }, { "../../../data/dates": 5 }], 73: [function (require, module, exports) { + 'use strict'; + // #generates properly-formatted dates from free-text date forms + // #by spencer kelly 2015 + + var to_number = require('../value/parse/to_number.js'); + //regexes to top-parse + var rules = require('./date_rules.js'); + + //return integers from strings + var wrangle = { + + year: function year(s) { + var num = s.match(/[0-9]+/); + num = parseInt(num, 10); + if (!num || num > 2900 || num < 0) { + return null; + } + //honestly, prob not a year either + if (num > 100 && num < 1000) { + return null; + } + //'20BC' becomes -20 + if (s.match(/[0-9] ?bc/i)) { + return num *= -1; + } + // '98 becomes 1998 + if (num < 100 && num > 30) { + num += 1900; + } + return num; + }, + + month: function month(s) { + //0 based months, 1 based days... + var months_obj = { + january: 0, + february: 1, + march: 2, + april: 3, + may: 4, + june: 5, + july: 6, + august: 7, + september: 8, + october: 9, + november: 10, + december: 11, + jan: 0, + feb: 1, + mar: 2, + apr: 3, + aug: 7, + sept: 8, + oct: 9, + nov: 10, + dec: 11 + }; + return months_obj[s]; + }, + + day: function day(s) { + var n = to_number(s) || parseInt(s, 10); + if (n < 0 || n > 31) { + return null; + } + return n; + } + }; + + //cleanup string + var preprocess = function preprocess(str) { + str = str.toLowerCase(); + str = str.replace(/([0-9]+)(nd|rd|th|st)/i, '$1'); + var words = str.split(' ').map(function (w) { + if (!w.match(/[0-9]/)) { + return to_number(w) || w; + } + return w; + }); + return words.join(' '); + }; + + var date_parser = function date_parser(str) { + str = preprocess(str); + var result = { + year: null, + month: null, + day: null + }; + for (var i = 0; i < rules.length; i++) { + if (str.match(rules[i].reg)) { + var m = str.match(rules[i].reg); + for (var o = 0; o < rules[i].order.length; o++) { + var type = rules[i].order[o]; + result[type] = wrangle[type](m[o + 1]); + } + break; + } + } + return result; + }; + module.exports = date_parser; + // console.log(wrangle.year('1998')); + // console.log(date_parser('March 1st 1987')); + // console.log(date_extractor('june second 1999')); + }, { "../value/parse/to_number.js": 91, "./date_rules.js": 71 }], 74: [function (require, module, exports) { + 'use strict'; + + var irregulars = require('../../data/irregular_nouns'); + + //similar to plural/singularize rules, but not the same + var plural_indicators = [/(^v)ies$/i, /ises$/i, /ives$/i, /(antenn|formul|nebul|vertebr|vit)ae$/i, /(octop|vir|radi|nucle|fung|cact|stimul)i$/i, /(buffal|tomat|tornad)oes$/i, /(analy|ba|diagno|parenthe|progno|synop|the)ses$/i, /(vert|ind|cort)ices$/i, /(matr|append)ices$/i, /(x|ch|ss|sh|s|z|o)es$/i, /men$/i, /news$/i, /.tia$/i, /(^f)ves$/i, /(lr)ves$/i, /(^aeiouy|qu)ies$/i, /(m|l)ice$/i, /(cris|ax|test)es$/i, /(alias|status)es$/i, /ics$/i]; + + //similar to plural/singularize rules, but not the same + var singular_indicators = [/(ax|test)is$/i, /(octop|vir|radi|nucle|fung|cact|stimul)us$/i, /(octop|vir)i$/i, /(rl)f$/i, /(alias|status)$/i, /(bu)s$/i, /(al|ad|at|er|et|ed|ad)o$/i, /(ti)um$/i, /(ti)a$/i, /sis$/i, /(?:(^f)fe|(lr)f)$/i, /hive$/i, /(^aeiouy|qu)y$/i, /(x|ch|ss|sh|z)$/i, /(matr|vert|ind|cort)(ix|ex)$/i, /(m|l)ouse$/i, /(m|l)ice$/i, /(antenn|formul|nebul|vertebr|vit)a$/i, /.sis$/i, /^(?!talis|.*hu)(.*)man$/i]; + + var is_plural = function is_plural(str) { + str = (str || '').toLowerCase(); + //handle 'mayors of chicago' + var preposition = str.match(/([a-z]*) (of|in|by|for) [a-z]/); + if (preposition && preposition[1]) { + str = preposition[1]; + } + // if it's a known irregular case + for (var i = 0; i < irregulars.length; i++) { + if (irregulars[i][1] === str) { + return true; + } + if (irregulars[i][0] === str) { + return false; + } + } + for (var i = 0; i < plural_indicators.length; i++) { + if (str.match(plural_indicators[i])) { + return true; + } + } + for (var i = 0; i < singular_indicators.length; i++) { + if (str.match(singular_indicators[i])) { + return false; + } + } + // some 'looks pretty plural' rules + if (str.match(/s$/) && !str.match(/ss$/) && str.length > 3) { + //needs some lovin' + return true; + } + return false; + }; + + // console.log(is_plural('octopus') === false) + // console.log(is_plural('octopi') === true) + // console.log(is_plural('eyebrow') === false) + // console.log(is_plural('eyebrows') === true) + // console.log(is_plural('child') === false) + // console.log(is_plural('children') === true) + + module.exports = is_plural; + }, { "../../data/irregular_nouns": 10 }], 75: [function (require, module, exports) { + //uncountables are words that shouldn't ever inflect, for metaphysical reasons, like 'peace' + 'use strict'; + + var uncountable_arr = require('../../data/uncountables.js'); + + var uncountable = uncountable_arr.reduce(function (h, a) { + h[a] = true; + return h; + }, {}); + + var is_uncountable = function is_uncountable(str) { + if (uncountable[str]) { + return true; + } + return false; + }; + // console.log(is_uncountable("peace") === true) + // console.log(is_uncountable("dog") === false) + module.exports = is_uncountable; + }, { "../../data/uncountables.js": 21 }], 76: [function (require, module, exports) { + 'use strict'; + + var _createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); + } + }return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; + }; + }(); + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + }return call && ((typeof call === "undefined" ? "undefined" : _typeof2(call)) === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : _typeof2(superClass))); + }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + } + + var Term = require('../term.js'); + var _article = require('./article.js'); + var _is_plural = require('./is_plural.js'); + var _is_place = require('./place/is_place.js'); + var _is_person = require('./person/is_person.js'); + var _pronoun = require('./pronoun.js'); + var _is_value = require('./value/is_value.js'); + var _is_date = require('./date/is_date.js'); + var _is_organization = require('./organization/is_organization.js'); + var _singularize = require('./singularize.js'); + var _pluralize = require('./pluralize.js'); + var _is_uncountable = require('./is_uncountable.js'); + + var Noun = function (_Term) { + _inherits(Noun, _Term); + + function Noun(str, tag) { + _classCallCheck(this, Noun); + + var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Noun).call(this, str)); + + _this.tag = tag; + _this.pos['Noun'] = true; + if (tag) { + _this.pos[tag] = true; + } + if (_this.is_plural()) { + _this.pos['Plural'] = true; + } + return _this; + } + //noun methods + + _createClass(Noun, [{ + key: 'article', + value: function article() { + //if it's a person, it's he/she, not a/an + if (this.pos['Person']) { + return this.pronoun(); + } + //groups of people are 'they' + if (this.pos['Organization']) { + return 'they'; + } + return _article(this.text); + } + }, { + key: 'root', + value: function root() { + return this.singularize(); + } + }, { + key: 'pronoun', + value: function pronoun() { + if (this.is_organization() || this.is_place() || this.is_value()) { + return 'it'; + } + return _pronoun(this.normal); + } + }, { + key: 'is_plural', + value: function is_plural() { + var isPlural = _is_plural(this.normal); + if (this.pos['Date']) { + isPlural = false; + } + this.pos['Plural'] = isPlural; + return isPlural; + } + }, { + key: 'is_uncountable', + value: function is_uncountable() { + return _is_uncountable(this.normal); + } + }, { + key: 'pluralize', + value: function pluralize() { + return _pluralize(this.normal); + } + }, { + key: 'singularize', + value: function singularize() { + return _singularize(this.normal); + } + //sub-classes + + }, { + key: 'is_person', + value: function is_person() { + //don't overwrite dates, etc + if (this.tag === 'Date') { + return false; + } + return _is_person(this.normal); + } + }, { + key: 'is_organization', + value: function is_organization() { + return _is_organization(this.normal, this.text); + } + }, { + key: 'is_date', + value: function is_date() { + return _is_date(this.normal); + } + }, { + key: 'is_value', + value: function is_value() { + //don't overwrite dates, etc + if (this.tag === 'Date') { + return false; + } + return _is_value(this.normal); + } + }, { + key: 'is_place', + value: function is_place() { + return _is_place(this.normal); + } + }]); + + return Noun; + }(Term); + + Noun.fn = Noun.prototype; + + module.exports = Noun; + + // let t = new Noun('NDA'); + // console.log(t.article()); + }, { "../term.js": 95, "./article.js": 69, "./date/is_date.js": 72, "./is_plural.js": 74, "./is_uncountable.js": 75, "./organization/is_organization.js": 77, "./person/is_person.js": 80, "./place/is_place.js": 83, "./pluralize.js": 85, "./pronoun.js": 86, "./singularize.js": 87, "./value/is_value.js": 88 }], 77: [function (require, module, exports) { + 'use strict'; + + var abbreviations = require('../../../data/abbreviations'); + var org_data = require('../../../data/organizations'); + + //some boring capitalised acronyms you see frequently + var blacklist = { + url: true, + http: true, + wtf: true, + irl: true, + ie: true, + eg: true, + gps: true, + dna: true, + sms: true }; + + //words like 'co' and ltd + //these should maybe be somewhere else + var org_suffix = abbreviations.orgs.reduce(function (h, s) { + h[s] = true; + return h; + }, {}); + org_data.suffixes.forEach(function (s) { + //a few more + org_suffix[s] = true; + }); + + //named orgs like google and nestle + var org_names = org_data.organizations.reduce(function (h, s) { + h[s] = true; + return h; + }, {}); + + var is_organization = function is_organization(str, text) { + text = text || ''; + //blacklist some boring ones + if (blacklist[str]) { + return false; + } + //some known organizations, like microsoft + if (org_names[str]) { + return true; + } + //no period acronyms + if (text.length <= 5 && text.match(/^[A-Z][A-Z]+$/) !== null) { + return true; + } + //period acronyms + if (text.length >= 4 && text.match(/^([A-Z]\.)*$/) !== null) { + return true; + } + // eg 'Smith & Co' + if (str.match(/ & /)) { + return true; + } + // Girlscouts of Canada + if (str.match(/..s of /)) { + return true; + } + // eg pets.com + if (str.match(/[a-z]{3}\.(com|net|org|biz)/)) { + //not a perfect url regex, but a "org.com" + return true; + } + // "foobar inc." + var words = str.split(' '); + if (words.length > 1) { + var last = words[words.length - 1]; + if (org_suffix[last]) { + return true; + } + } + + return false; + }; + + module.exports = is_organization; + + // console.log(is_organization('Captain of Jamaica')); + }, { "../../../data/abbreviations": 2, "../../../data/organizations": 17 }], 78: [function (require, module, exports) { + 'use strict'; + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + }return call && ((typeof call === "undefined" ? "undefined" : _typeof2(call)) === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : _typeof2(superClass))); + }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + } + + var Noun = require('../noun.js'); + + var Organization = function (_Noun) { + _inherits(Organization, _Noun); + + function Organization(str, tag) { + _classCallCheck(this, Organization); + + var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Organization).call(this, str)); + + _this.tag = tag; + _this.pos['Organization'] = true; + + return _this; + } + + return Organization; + }(Noun); + + Organization.fn = Organization.prototype; + module.exports = Organization; + }, { "../noun.js": 76 }], 79: [function (require, module, exports) { + 'use strict'; + + var firstnames = require('../../../data/firstnames'); + var parse_name = require('./parse_name.js'); + + var gender = function gender(normal) { + if (normal === 'he') { + return 'Male'; + } + if (normal === 'she') { + return 'Female'; + } + var o = parse_name(normal); + var firstName = o.firstName; + if (!firstName) { + return null; + } + if (firstnames[firstName] === 'm') { + return 'Male'; + } + if (firstnames[firstName] === 'f') { + return 'Female'; + } + //male honourifics + if (normal.match(/\b(mr|mister|sr|jr)\b/i)) { + return 'Male'; + } + //female honourifics + if (normal.match(/^(mrs|miss|ms|misses|mme|mlle)\.? /i)) { + return 'Female'; + } + //statistical guesses + if (firstName.match(/.(i|ee|[a|e]y|a)$/i)) { + //this is almost-always true + return 'Female'; + } + if (firstName.match(/[ou]$/i)) { + //if it ends in a 'oh or uh', male + return 'Male'; + } + if (firstName.match(/(nn|ll|tt)/i)) { + //if it has double-consonants, female + return 'Female'; + } + return null; + }; + module.exports = gender; + + // console.log(gender('john', 'john') === 'Male'); + // console.log(gender('jane smith', 'jane') === 'Female'); + }, { "../../../data/firstnames": 7, "./parse_name.js": 81 }], 80: [function (require, module, exports) { + 'use strict'; + + var firstnames = require('../../../data/firstnames'); + var honourifics = require('../../../data/honourifics').reduce(function (h, s) { + h[s] = true; + return h; + }, {}); + + var whitelist = { + 'he': true, + 'she': true, + 'i': true, + 'you': true + }; + + var is_person = function is_person(str) { + if (whitelist[str] || firstnames[str]) { + return true; + } + var words = str.split(' '); + if (words.length > 1) { + var first = words[0]; + if (honourifics[first] || firstnames[first]) { + return true; + } + } + return false; + }; + + module.exports = is_person; + + // console.log(is_person('Illi Danza')); + }, { "../../../data/firstnames": 7, "../../../data/honourifics": 9 }], 81: [function (require, module, exports) { + 'use strict'; + + var firstnames = require('../../../data/firstnames'); + var honourifics = require('../../../data/honourifics').reduce(function (h, s) { + h[s] = true; + return h; + }, {}); + + var parse_name = function parse_name(str) { + + var words = str.split(' '); + var o = { + honourific: null, + firstName: null, + middleName: null, + lastName: null + }; + + //first-word honourific + if (honourifics[words[0]]) { + o.honourific = words[0]; + words = words.slice(1, words.length); + } + //last-word honourific + if (honourifics[words[words.length - 1]]) { + o.honourific = words[words.length - 1]; + words = words.slice(0, words.length - 1); + } + //see if the first word is now a known first-name + if (firstnames[words[0]]) { + o.firstName = words[0]; + words = words.slice(1, words.length); + } else { + //ambiguous one-word name + if (words.length === 1) { + return o; + } + //looks like an unknown first-name + o.firstName = words[0]; + words = words.slice(1, words.length); + } + //assume the remaining is '[middle..] [last]' + if (words[words.length - 1]) { + o.lastName = words[words.length - 1]; + words = words.slice(0, words.length - 1); + } + o.middleName = words.join(' '); + return o; + }; + + module.exports = parse_name; + + // console.log(parse_name('john smith')); + }, { "../../../data/firstnames": 7, "../../../data/honourifics": 9 }], 82: [function (require, module, exports) { + // not all cultures use the firstname-lastname practice. this does make some assumptions. + 'use strict'; + + var _createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); + } + }return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; + }; + }(); + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + }return call && ((typeof call === "undefined" ? "undefined" : _typeof2(call)) === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : _typeof2(superClass))); + }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + } + + var Noun = require('../noun.js'); + var guess_gender = require('./gender.js'); + var parse_name = require('./parse_name.js'); + + var Person = function (_Noun) { + _inherits(Person, _Noun); + + function Person(str, tag) { + _classCallCheck(this, Person); + + var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Person).call(this, str)); + + _this.tag = tag; + _this.pos['Person'] = true; + _this.honourific = null; + _this.firstName = null; + _this.middleName = null; + _this.lastName = null; + _this.parse(); + if (_this.isPronoun()) { + _this.pos['Pronoun'] = true; + } + return _this; + } + + _createClass(Person, [{ + key: 'isPronoun', + value: function isPronoun() { + var whitelist = { + 'he': true, + 'she': true, + 'i': true, + 'you': true + }; + return whitelist[this.normal]; + } + + //proper normalised name without the cruft + + }, { + key: 'root', + value: function root() { + if (this.isPronoun()) { + return this.normal; + } + var str = this.firstName || ''; + if (this.middleName) { + str += ' ' + this.middleName; + } + if (this.lastName) { + str += ' ' + this.lastName; + } + return str.trim() || this.normal; + } + + //turn a multi-word string into [first, middle, last, honourific] + + }, { + key: 'parse', + value: function parse() { + var o = parse_name(this.normal); + this.honourific = o.honourific; + this.firstName = o.firstName; + this.middleName = o.middleName; + this.lastName = o.lastName; + } + }, { + key: 'gender', + value: function gender() { + return guess_gender(this.normal); + } + }, { + key: 'pronoun', + value: function pronoun() { + var pronouns = { + Male: 'he', + Female: 'she' + }; + var gender = this.gender(); + //return 'singular they' if no gender is found + return pronouns[gender] || 'they'; + } + }]); + + return Person; + }(Noun); + + Person.fn = Person.prototype; + module.exports = Person; + + // let p = new Person('John Smith'); + // console.log(p.gender()); + }, { "../noun.js": 76, "./gender.js": 79, "./parse_name.js": 81 }], 83: [function (require, module, exports) { + 'use strict'; + + var places = require('../../../data/places'); + var abbreviations = require('../../../data/abbreviations'); + + //add Country names + var isPlace = places.countries.reduce(function (h, s) { + h[s] = true; + return h; + }, {}); + //add City names + places.cities.forEach(function (s) { + isPlace[s] = true; + }); + //add place abbreviations names + abbreviations.places.forEach(function (s) { + isPlace[s] = true; + }); + + //these are signals too + var firstwords = ['west', 'east', 'nort', 'south', 'western', 'eastern', 'nortern', 'southern', 'mount'].reduce(function (h, s) { + h[s] = true; + return h; + }, {}); + + var lastwords = ['city', 'town', 'county', 'village', 'province', 'country', 'state', 'province', 'mountain', 'river', 'valley', 'park', 'avenue', 'street', 'road']. //these should maybe be somewhere else + reduce(function (h, s) { + h[s] = true; + return h; + }, {}); + + var is_place = function is_place(str) { + var words = str.split(' '); + + if (words.length > 1) { + //first words, like 'eastern' + if (firstwords[words[0]]) { + return true; + } + //last words, like 'mountain' + if (lastwords[words[words.length - 1]]) { + return true; + } + } + for (var i = 0; i < words.length; i++) { + if (isPlace[words[i]]) { + return true; + } + } + + return false; + }; + + module.exports = is_place; + }, { "../../../data/abbreviations": 2, "../../../data/places": 19 }], 84: [function (require, module, exports) { + 'use strict'; + + var _createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); + } + }return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; + }; + }(); + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + }return call && ((typeof call === "undefined" ? "undefined" : _typeof2(call)) === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : _typeof2(superClass))); + }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + } + + var Noun = require('../noun.js'); + var places = require('../../../data/places.js'); + var fns = require('../../../fns.js'); + //make cities/countries easy to lookup + var countries = fns.toObj(places.countries); + var cities = fns.toObj(places.cities); + + var Place = function (_Noun) { + _inherits(Place, _Noun); + + function Place(str, tag) { + _classCallCheck(this, Place); + + var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Place).call(this, str)); + + _this.tag = tag; + _this.pos['Place'] = true; + + _this.title = null; + _this.city = null; + _this.region = null; //'2nd-tier' (state/province/county/whatever) + _this.country = null; + _this.parse(); + return _this; + } + + _createClass(Place, [{ + key: 'root', + value: function root() { + return this.title || this.normal; + } + }, { + key: 'parse', + value: function parse() { + //parse a comma-described place like "toronto, ontario" + var terms = this.normal.split(' '); + this.title = terms[0]; + for (var i = 0; i < terms.length; i++) { + var t = terms[i]; + if (cities[t]) { + this.city = fns.titlecase(t); + } else if (countries[t]) { + this.country = fns.titlecase(t); + } else if (this.city !== null) { + //if we already got the city.. + this.region = fns.titlecase(t); + } else { + //it's part of the title + this.title += ' ' + t; + } + } + } + }]); + + return Place; + }(Noun); + Place.fn = Place.prototype; + module.exports = Place; + + // console.log(new Place('Toronto, Ontario, Canada')); + }, { "../../../data/places.js": 19, "../../../fns.js": 23, "../noun.js": 76 }], 85: [function (require, module, exports) { + 'use strict'; + + var is_uncountable = require('./is_uncountable.js'); + var irregulars = require('../../data/irregular_nouns.js'); + var is_plural = require('./is_plural.js'); + var fns = require('../../fns.js'); + + var pluralize_rules = [[/(ax|test)is$/i, '$1es'], [/(octop|vir|radi|nucle|fung|cact|stimul)us$/i, '$1i'], [/(octop|vir)i$/i, '$1i'], [/([rl])f$/i, '$1ves'], [/(alias|status)$/i, '$1es'], [/(bu)s$/i, '$1ses'], [/(al|ad|at|er|et|ed|ad)o$/i, '$1oes'], [/([ti])um$/i, '$1a'], [/([ti])a$/i, '$1a'], [/sis$/i, 'ses'], [/(?:([^f])fe|([lr])f)$/i, '$1ves'], [/(hive)$/i, '$1s'], [/([^aeiouy]|qu)y$/i, '$1ies'], [/(x|ch|ss|sh|s|z)$/i, '$1es'], [/(matr|vert|ind|cort)(ix|ex)$/i, '$1ices'], [/([m|l])ouse$/i, '$1ice'], [/([m|l])ice$/i, '$1ice'], [/^(ox)$/i, '$1en'], [/^(oxen)$/i, '$1'], [/(quiz)$/i, '$1zes'], [/(antenn|formul|nebul|vertebr|vit)a$/i, '$1ae'], [/(sis)$/i, 'ses'], [/^(?!talis|.*hu)(.*)man$/i, '$1men'], [/(.*)/i, '$1s']].map(function (a) { + return { + reg: a[0], + repl: a[1] + }; + }); + + var pluralize = function pluralize(str) { + var low = str.toLowerCase(); + //uncountable + if (is_uncountable(low)) { + //uncountables shouldn't ever inflect + return str; + } + //is it already plural? + if (is_plural(low) === true) { + return str; + } + //irregular + var found = irregulars.filter(function (r) { + return r[0] === low; + }); + if (found[0]) { + if (fns.titlecase(low) === str) { + //handle capitalisation properly + return fns.titlecase(found[0][1]); + } + return found[0][1]; + } + //inflect first word of preposition-phrase + if (str.match(/([a-z]*) (of|in|by|for) [a-z]/)) { + var first = (str.match(/^([a-z]*) (of|in|by|for) [a-z]/) || [])[1]; + if (first) { + var better_first = pluralize(first); + return better_first + str.replace(first, ''); + } + } + //regular + for (var i = 0; i < pluralize_rules.length; i++) { + if (str.match(pluralize_rules[i].reg)) { + return str.replace(pluralize_rules[i].reg, pluralize_rules[i].repl); + } + } + return null; + }; + // console.log(pluralize('gas') === "gases") + // console.log(pluralize('narrative') === "narratives") + // console.log(pluralize('video') === "videos") + // console.log(pluralize('photo') === "photos") + // console.log(pluralize('stomach') === "stomachs") + // console.log(pluralize('database') === "databases") + // console.log(pluralize('kiss') === "kisses") + // console.log(pluralize('towns') === "towns") + // console.log(pluralize('peace') === "peace") + // console.log(pluralize('mayor of chicago') === "mayors of chicago") + module.exports = pluralize; + }, { "../../data/irregular_nouns.js": 10, "../../fns.js": 23, "./is_plural.js": 74, "./is_uncountable.js": 75 }], 86: [function (require, module, exports) { + 'use strict'; + + var is_person = require('./person/is_person.js'); + var is_plural = require('./is_plural.js'); + var gender = require('./person/gender.js'); + + var pronoun = function pronoun(str) { + if (is_person(str)) { + var g = gender(str); + if (g === 'Male') { + return 'he'; + } else if (g === 'Female') { + return 'she'; + } + return 'they'; //singular they + } + //non-person, like 'microwaves' + if (is_plural(str)) { + return 'they'; + } + return 'it'; + }; + + module.exports = pronoun; + + // console.log(pronoun('Illi Danza')); + }, { "./is_plural.js": 74, "./person/gender.js": 79, "./person/is_person.js": 80 }], 87: [function (require, module, exports) { + 'use strict'; + + var is_uncountable = require('./is_uncountable.js'); + var irregulars = require('../../data/irregular_nouns.js'); + var is_plural = require('./is_plural.js'); + var fns = require('../../fns.js'); + + var singularize_rules = [[/([^v])ies$/i, '$1y'], [/ises$/i, 'isis'], [/ives$/i, 'ife'], [/(antenn|formul|nebul|vertebr|vit)ae$/i, '$1a'], [/(octop|vir|radi|nucle|fung|cact|stimul)(i)$/i, '$1us'], [/(buffal|tomat|tornad)(oes)$/i, '$1o'], [/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i, '$1sis'], [/(vert|ind|cort)(ices)$/i, '$1ex'], [/(matr|append)(ices)$/i, '$1ix'], [/(x|ch|ss|sh|s|z|o)es$/i, '$1'], [/men$/i, 'man'], [/(n)ews$/i, '$1ews'], [/([ti])a$/i, '$1um'], [/([^f])ves$/i, '$1fe'], [/([lr])ves$/i, '$1f'], [/([^aeiouy]|qu)ies$/i, '$1y'], [/(s)eries$/i, '$1eries'], [/(m)ovies$/i, '$1ovie'], [/([m|l])ice$/i, '$1ouse'], [/(cris|ax|test)es$/i, '$1is'], [/(alias|status)es$/i, '$1'], [/(ss)$/i, '$1'], [/(ics)$/i, '$1'], [/s$/i, '']].map(function (a) { + return { + reg: a[0], + repl: a[1] + }; + }); + + var singularize = function singularize(str) { + var low = str.toLowerCase(); + //uncountable + if (is_uncountable(low)) { + return str; + } + //is it already singular? + if (is_plural(low) === false) { + return str; + } + //irregular + var found = irregulars.filter(function (r) { + return r[1] === low; + }); + if (found[0]) { + if (fns.titlecase(low) === str) { + //handle capitalisation properly + return fns.titlecase(found[0][0]); + } + return found[0][0]; + } + //inflect first word of preposition-phrase + if (str.match(/([a-z]*) (of|in|by|for) [a-z]/)) { + var first = str.match(/^([a-z]*) (of|in|by|for) [a-z]/); + if (first && first[1]) { + var better_first = singularize(first[1]); + return better_first + str.replace(first[1], ''); + } + } + //regular + for (var i = 0; i < singularize_rules.length; i++) { + if (str.match(singularize_rules[i].reg)) { + return str.replace(singularize_rules[i].reg, singularize_rules[i].repl); + } + } + return str; + }; + + // console.log(singularize('gases') === "gas") + // console.log(singularize('kisses') === "kiss") + // console.log(singularize('kiss') === "kiss") + // console.log(singularize('children') === "child") + // console.log(singularize('peace') === "peace") + // console.log(singularize('child') === "child") + // console.log(singularize('mayors of chicago') === "mayor of chicago") + + module.exports = singularize; + }, { "../../data/irregular_nouns.js": 10, "../../fns.js": 23, "./is_plural.js": 74, "./is_uncountable.js": 75 }], 88: [function (require, module, exports) { + 'use strict'; + + var nums = require('../../../data/numbers.js'); + var is_date = require('../date/is_date'); + + var is_value = function is_value(str) { + var words = str.split(' '); + //'january 5' is not a value + if (is_date(str)) { + return false; + } + for (var i = 0; i < words.length; i++) { + var w = words[i]; + if (nums.ones[w] || nums.teens[w] || nums.tens[w] || nums.multiples[w] || nums.prefixes[w]) { + return true; + } + if (parseFloat(w)) { + return true; + } + } + return false; + }; + + module.exports = is_value; + }, { "../../../data/numbers.js": 16, "../date/is_date": 72 }], 89: [function (require, module, exports) { + 'use strict'; + // handle 'nine point eight four' + + var nums = require('../../../../data/numbers.js'); + var fns = require('../../../../fns'); + var ones = {}; + ones = fns.extend(ones, nums.ones); + ones = fns.extend(ones, nums.teens); + ones = fns.extend(ones, nums.ordinal_ones); + ones = fns.extend(ones, nums.ordinal_teens); + + //concatenate into a string with leading '0.' + var decimals = function decimals(words) { + var str = '0.'; + for (var i = 0; i < words.length; i++) { + var w = words[i]; + if (ones[w]) { + str += ones[w]; + } else { + return 0; + } + } + return parseFloat(str); + }; + + module.exports = decimals; + }, { "../../../../data/numbers.js": 16, "../../../../fns": 23 }], 90: [function (require, module, exports) { + 'use strict'; + + //support global multipliers, like 'half-million' by doing 'million' then multiplying by 0.5 + + var find_modifiers = function find_modifiers(str) { + var mults = [{ + reg: /^(minus|negative)[\s\-]/i, + mult: -1 + }, { + reg: /^(a\s)?half[\s\-](of\s)?/i, + mult: 0.5 + }, { + reg: /^(a\s)?quarter[\s\-]/i, + mult: 0.25 + }]; + for (var i = 0; i < mults.length; i++) { + if (str.match(mults[i].reg)) { + return { + amount: mults[i].mult, + str: str.replace(mults[i].reg, '') + }; + } + } + return { + amount: 1, + str: str + }; + }; + + module.exports = find_modifiers; + }, {}], 91: [function (require, module, exports) { + 'use strict'; + // Spoken numbers take the following format + // [sixty five] (thousand) [sixty five] (hundred) [sixty five] + // aka: [one/teen/ten] (multiple) [one/teen/ten] (multiple) ... + + var nums = require('../../../../data/numbers.js'); + var fns = require('../../../../fns.js'); + var find_modifiers = require('./modifiers.js'); + var parse_decimals = require('./decimals.js'); + + var ones = {}; + var teens = {}; + var tens = {}; + var multiples = {}; + ones = fns.extend(ones, nums.ones); + ones = fns.extend(ones, nums.ordinal_ones); + + teens = fns.extend(teens, nums.teens); + teens = fns.extend(teens, nums.ordinal_teens); + + tens = fns.extend(tens, nums.tens); + tens = fns.extend(tens, nums.ordinal_tens); + + multiples = fns.extend(multiples, nums.multiples); + multiples = fns.extend(multiples, nums.ordinal_multiples); + + var normalize = function normalize(s) { + //pretty-printed numbers + s = s.replace(/, ?/g, ''); + s = s.replace(/([a-z])-([a-z])/gi, '$1 $2'); + //parse-out currency + s = s.replace(/[$£€]/, ''); + s = s.replace(/[\$%\(\)~,]/g, ''); + s = s.trim(); + return s; + }; + + var section_sum = function section_sum(obj) { + return Object.keys(obj).reduce(function (sum, k) { + sum += obj[k]; + return sum; + }, 0); + }; + + //prevent things like 'fifteen ten', and 'five sixty' + var appropriate = function appropriate(w, has) { + if (ones[w]) { + if (has.ones || has.teens) { + return false; + } + } else if (teens[w]) { + if (has.ones || has.teens || has.tens) { + return false; + } + } else if (tens[w]) { + if (has.ones || has.teens || has.tens) { + return false; + } + } + return true; + }; + + var to_number = function to_number(str) { + //try to fail-fast + if (!str || typeof str === 'number') { + return str; + } + str = normalize(str); + var modifier = find_modifiers(str); + str = modifier.str; + var biggest_yet = 0; + var has = {}; + var sum = 0; + + var words = str.split(' '); + for (var i = 0; i < words.length; i++) { + var w = words[i]; + if (!w || w === 'and') { + continue; + } + //decimal mode + if (w === 'point') { + sum += section_sum(has); + sum += parse_decimals(words.slice(i + 1, words.length)); + sum *= modifier.amount; + return sum; + } + //maybe it's just a number typed as a string + if (w.match(/^[0-9,\. ]+$/)) { + sum += parseFloat(w.replace(/[, ]/g, '')) || 0; + continue; + } + //prevent mismatched units, like 'seven eleven' + if (!appropriate(w, has)) { + return null; + } + //collect 'has' values + if (ones[w]) { + has['ones'] = ones[w]; + } else if (teens[w]) { + has['teens'] = teens[w]; + } else if (tens[w]) { + has['tens'] = tens[w]; + } else if (multiples[w]) { + //something has gone wrong : 'two hundred five hundred' + if (multiples[w] === biggest_yet) { + return null; + } + //if it's the biggest yet, multiply the whole sum - eg 'five hundred thousand' + if (multiples[w] > biggest_yet) { + biggest_yet = multiples[w]; + sum += section_sum(has); + sum = (sum || 1) * multiples[w]; + } else { + //it's smaller, so only multiply section_sum - eg 'five thousand one hundred' + sum += (section_sum(has) || 1) * multiples[w]; + } + //reset our section + has = {}; + } + } + //dump the remaining has values + sum += section_sum(has); + //post-process add modifier + sum *= modifier.amount; + return sum; + }; + + module.exports = to_number; + + // console.log(to_number('half a million')); + }, { "../../../../data/numbers.js": 16, "../../../../fns.js": 23, "./decimals.js": 89, "./modifiers.js": 90 }], 92: [function (require, module, exports) { + 'use strict'; + // const nums = require('../../../data/numbers.js'); + // const fns = require('../../../fns.js'); + + var ones_mapping = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']; + var tens_mapping = [['ninety', 90], ['eighty', 80], ['seventy', 70], ['sixty', 60], ['fifty', 50], ['forty', 40], ['thirty', 30], ['twenty', 20]]; + + var sequence = [[1000000000, 'million'], [100000000, 'hundred million'], [1000000, 'million'], [100000, 'hundred thousand'], [1000, 'thousand'], [100, 'hundred'], [1, 'one']]; + + //turn number into an array of magnitudes + var breakdown_magnitudes = function breakdown_magnitudes(num) { + var working = num; + var have = []; + sequence.forEach(function (a) { + if (num > a[0]) { + var howmany = Math.floor(working / a[0]); + working -= howmany * a[0]; + if (howmany) { + have.push({ + unit: a[1], + count: howmany + }); + } + } + }); + return have; + }; + + //turn numbers from 100-0 into their text + var breakdown_hundred = function breakdown_hundred(num) { + var str = ''; + for (var i = 0; i < tens_mapping.length; i++) { + if (num >= tens_mapping[i][1]) { + num -= tens_mapping[i][1]; + str += ' ' + tens_mapping[i][0]; + } + } + //(hopefully) we should only have 20-0 now + if (ones_mapping[num]) { + str += ' ' + ones_mapping[num]; + } + return str.trim(); + }; + + var to_text = function to_text(num) { + var isNegative = false; + if (num < 0) { + isNegative = true; + num = Math.abs(num); + } + //break-down into units, counts + var units = breakdown_magnitudes(num); + //build-up the string from its components + var str = ''; + for (var i = 0; i < units.length; i++) { + var unit_name = units[i].unit; + if (unit_name === 'one') { + unit_name = ''; + //put an 'and' in here + if (str.length > 1) { + str += ' and'; + } + } + str += ' ' + breakdown_hundred(units[i].count) + ' ' + unit_name; + } + str = str || 'zero'; + str = str.replace(/ +/g, ' '); + str = str.trim(); + if (isNegative) { + str = 'negative ' + str; + } + return str; + }; + + module.exports = to_text; + + // console.log(to_text(-5)); + }, {}], 93: [function (require, module, exports) { + 'use strict'; + + var units = { + 'Temperature': { + '°C': 'Celsius', + '°F': 'Fahrenheit', + 'K': 'Kelvin', + '°Ré': 'Reaumur', + '°N': 'Newton', + '°Ra': 'Rankine' + }, + 'Volume': { + 'm³': 'cubic meter', + 'dm³': 'cubic decimeter', + 'cm³': 'cubic centimeter', + 'l': 'liter', + 'dl': 'deciliter', + 'cl': 'centiliter', + 'ml': 'milliliter', + 'in³': 'cubic inch', + 'ft³': 'cubic foot', + 'yd³': 'cubic yard', + 'gal': 'gallon', + 'bbl': 'petroleum barrel', + 'pt': 'pint' + }, + 'Distance': { + 'km': 'kilometer', + 'm': 'meter', + 'dm': 'decimeter', + 'cm': 'centimeter', + 'mm': 'millimeter', + 'mi': 'mile', + 'in': 'inch', + 'ft': 'foot', + 'feet': 'foot', + 'yd': 'yard' + }, + 'Weight': { + 't': 'tonne', + 'kg': 'kilogram', + 'hg': 'hectogram', + 'g': 'gram', + 'dg': 'decigram', + 'cg': 'centigram', + 'mg': 'milligram', + 'µg': 'microgram', + 'carat': 'carat', + 'grain': 'grain', + 'oz': 'ounce', + 'lb': 'pound', + 'ton': 'tonne', + 'st': 'stone' + }, + 'Area': { + 'km²': 'square kilometer', + 'm²': 'square meter', + 'dm²': 'square decimeter', + 'cm²': 'square centimeter', + 'mm²': 'square millimeter', + 'ha': 'hectare', + 'ca': 'centiare', + 'mile²': 'square mile', + 'in²': 'square inch', + 'yd²': 'square yard', + 'ft²': 'square foot', + 'acre': 'acre' + }, + 'Frequency': { + 'Hz': 'hertz' + }, + 'Speed': { + 'km/h': 'kilometer per hour', + 'kmph': 'kilometer per hour', + 'mps': 'meter per second', + 'm/s': 'meter per second', + 'mph': 'mile per hour', + 'mi/h': 'mile per hour', + 'knot': 'knot' + }, + 'Data': { + 'b': 'bit', + 'B': 'byte', + 'KB': 'kilobyte', + 'Kb': 'kilobyte', + 'MB': 'megabyte', + 'Mb': 'megabyte', + 'GB': 'gigabyte', + 'Gb': 'gigabyte', + 'TB': 'terabyte', + 'Tb': 'terabyte', + 'PB': 'petabyte', + 'Pb': 'petabyte', + 'EB': 'exabyte', + 'Eb': 'exabyte', + 'ZB': 'zettabyte', + 'Zb': 'zettabyte', + 'YB': 'yottabyte', + 'Yb': 'yottabyte' + }, + 'Energy': { + 'J': 'joule', + 'Pa': 'pascal', + 'bar': 'bar', + 'W': 'watt', + 'N': 'newton', + 'Wb': 'weber', + 'T': 'tesla', + 'H': 'henry', + 'C': 'coulomb', + 'V': 'volt', + 'F': 'farad', + 'S': 'siemens', + 'O': 'ohm', + 'lx': 'lux', + 'lm': 'lumen' + }, + 'Time': { + 'year': 'year', + 'week': 'week', + 'day': 'day', + 'h': 'hour', + 'min': 'minute', + 's': 'second', + 'ms': 'millisecond', + 'µs': 'microsecond', + 'nanosecond': 'nanosecond', + 'picosecond': 'picosecond', + 'femtosecond': 'femtosecond', + 'attosecond': 'attosecond' + }, + 'Money': { + 'dollar': 'currency', + 'cent': 'currency', + 'penny': 'currency', + 'dime': 'currency', + 'dinar': 'currency', + 'euro': 'currency', + 'EU': 'currency', + 'lira': 'currency', + 'pound': 'currency', + 'GBP': 'currency', + 'pence': 'currency', + 'peso': 'currency', + 'sterling': 'currency', + 'rand': 'currency', + 'rouble': 'currency', + 'shekel': 'currency', + 'yen': 'currency', + 'yuan': 'currency', + 'franc': 'currency', + 'rupee': 'currency', + 'shilling': 'currency', + 'won': 'currency', + 'krona': 'currency', + 'dirham': 'currency', + '€': 'currency', + '$': 'currency', + '¥': 'currency', + '£': 'currency', + 'real': 'currency', + 'USD': 'currency', + 'AUD': 'currency', + 'CAD': 'currency', + 'BRL': 'currency', + 'EUR': 'currency', + 'CNY': 'currency', + 'EGP': 'currency', + 'MXN': 'currency' + } + }; + + module.exports = Object.keys(units).reduce(function (h, k) { + Object.keys(units[k]).forEach(function (u) { + h[u] = { + name: units[k][u], + category: k + }; + h[units[k][u]] = { + name: units[k][u], + category: k + }; + }); + return h; + }, {}); + }, {}], 94: [function (require, module, exports) { + 'use strict'; + + var _createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); + } + }return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; + }; + }(); + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + }return call && ((typeof call === "undefined" ? "undefined" : _typeof2(call)) === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : _typeof2(superClass))); + }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + } + + var Noun = require('../noun'); + var to_number = require('./parse/to_number'); + var to_text = require('./to_text'); + var units = require('./units'); + var nums = require('../../../data/numbers'); + var fns = require('../../../fns'); + //get an array of ordinal (first, second...) numbers + var ordinals = {}; + ordinals = fns.extend(ordinals, nums.ordinal_ones); + ordinals = fns.extend(ordinals, nums.ordinal_teens); + ordinals = fns.extend(ordinals, nums.ordinal_tens); + ordinals = fns.extend(ordinals, nums.ordinal_multiples); + ordinals = Object.keys(ordinals); + + var Value = function (_Noun) { + _inherits(Value, _Noun); + + function Value(str, tag) { + _classCallCheck(this, Value); + + var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Value).call(this, str)); + + _this.tag = tag; + _this.pos['Value'] = true; + _this.number = null; + _this.unit = null; + _this.unit_name = null; + _this.measurement = null; + // this.text = str; + // this.normal = str; + if (_this.is_ordinal()) { + _this.pos['Ordinal'] = true; + } + _this.parse(); + return _this; + } + + //test for nearly-numbers, like phonenumbers, or whatever + + _createClass(Value, [{ + key: 'is_number', + value: function is_number(s) { + //phone numbers, etc + if (s.match(/[:@]/)) { + return false; + } + //if there's a number, then something, then a number + if (s.match(/[0-9][^0-9,\.][0-9]/)) { + return false; + } + return true; + } + }, { + key: 'is_ordinal', + value: function is_ordinal() { + //todo: make this clever. + //1st + if (this.normal.match(/^[0-9]+(rd|st|nd|th)$/)) { + return true; + } + //first, second... + for (var i = 0; i < ordinals.length; i++) { + if (fns.endsWith(this.normal, ordinals[i])) { + return true; + } + } + return false; + } + + //turn an integer like 22 into '22nd' + + }, { + key: 'to_ordinal', + value: function to_ordinal(num) { + num = '' + num; + //fail safely + if (!num.match(/[0-9]$/)) { + return num; + } + if (fns.endsWith(num, '1')) { + return num + 'st'; + } + if (fns.endsWith(num, '2')) { + return num + 'nd'; + } + if (fns.endsWith(num, '3')) { + return num + 'rd'; + } + return num + 'th'; + } + + //overwrite term.normalize? + // normalize() { + // let str = '' + (this.number || ''); + // if (this.is_ordinal()) { + // str = this.to_ordinal(str); + // } + // if (this.unit) { + // str += ' ' + this.unit; + // } + // return str; + // } + + }, { + key: 'root', + value: function root() { + var str = this.number; + if (this.unit) { + str += ' ' + this.unit; + } + return str; + } + }, { + key: 'is_unit', + value: function is_unit(s) { + if (units[s]) { + return true; + } + s = s.toLowerCase(); + if (nums.prefixes[s]) { + return true; + } + //try singular version + s = s.replace(/s$/); //ew + if (units[s]) { + return true; + } + + return false; + } + }, { + key: 'parse', + value: function parse() { + if (!this.is_number(this.text)) { + return; + } + var words = this.text.toLowerCase().split(/[ -]/); + var number_words = { + minus: true, + negative: true, + point: true, + half: true, + quarter: true + }; + var numbers = ''; + //seperate number-words from unit-words + for (var i = 0; i < words.length; i++) { + var w = words[i]; + if (w.match(/[0-9]/) || number_words[w]) { + numbers += ' ' + w; + } else if (nums.ones[w] || nums.teens[w] || nums.tens[w] || nums.multiples[w]) { + numbers += ' ' + w; + } else if (nums.ordinal_ones[w] || nums.ordinal_teens[w] || nums.ordinal_tens[w] || nums.ordinal_multiples[w]) { + numbers += ' ' + w; + } else if (this.is_unit(w)) { + //optional units come after the number + this.unit = w; + if (units[w]) { + this.measurement = units[w].category; + this.unit_name = units[w].name; + } + } + } + numbers = numbers.trim(); + this.number = to_number(numbers); + } + }, { + key: 'textual', + value: function textual() { + return to_text(this.number || this.normal || this.text); + } + }]); + + return Value; + }(Noun); + + Value.fn = Value.prototype; + module.exports = Value; + + // console.log(new Value('first').normal); + // console.log(new Value('minus eighty eight point nine nine').number); + }, { "../../../data/numbers": 16, "../../../fns": 23, "../noun": 76, "./parse/to_number": 91, "./to_text": 92, "./units": 93 }], 95: [function (require, module, exports) { + 'use strict'; + + var _createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); + } + }return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; + }; + }(); + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + var _is_acronym = require('./is_acronym'); + var match_term = require('../match/match_term'); + var syntax_parse = require('../match/syntax_parse'); + var implied = require('./implied'); + + var Term = function () { + function Term(str, tag, whitespace) { + _classCallCheck(this, Term); + + //fail-safe + if (str === null || str === undefined) { + str = ''; + } + str = str.toString(); + //trailing & preceding whitespace + this.whitespace = whitespace || {}; + this.whitespace.preceding = this.whitespace.preceding || ''; + this.whitespace.trailing = this.whitespace.trailing || ''; + //set .text + this.text = str; + //the normalised working-version of the word + this.normal = ''; + //if it's a contraction or slang, the implication, or 'hidden word' + this.expansion = ''; + //set .normal + this.rebuild(); + //the reasoning behind it's part-of-speech + this.reason = ''; + //these are orphaned POS that have no methods + var types = { + Determiner: 'Determiner', + Conjunction: 'Conjunction', + Preposition: 'Preposition', + Possessive: 'Possessive', + Expression: 'Expression', + Condition: 'Condition' + }; + this.pos = {}; + this.tag = types[tag] || '?'; + //record them in pos{} + if (types[tag]) { + this.pos[types[tag]] = true; + } + } + + //when the text changes, rebuild derivative fields + + _createClass(Term, [{ + key: 'rebuild', + value: function rebuild() { + this.text = this.text || ''; + this.text = this.text.trim(); + + this.normal = ''; + this.normalize(); + this.expansion = implied(this.normal); + } + }, { + key: 'changeTo', + value: function changeTo(str) { + this.text = str; + this.rebuild(); + } + //a regex-like string search + + }, { + key: 'match', + value: function match(match_str, options) { + var reg = syntax_parse([match_str]); + return match_term(this, reg[0], options); + } + //the 'root' singular/infinitive/whatever. + // method is overloaded by each pos type + + }, { + key: 'root', + value: function root() { + return this.normal; + } + + //Term methods.. + + }, { + key: 'has_comma', + value: function has_comma() { + if (this.text.match(/,$/)) { + return true; + } + return false; + } + }, { + key: 'has_abbreviation', + value: function has_abbreviation() { + if (this.text.match(/[a-z]'[a-z][a-z]?$/)) { + return true; + } + return false; + } + }, { + key: 'is_capital', + value: function is_capital() { + if (this.text.match(/[A-Z][a-z]/)) { + return true; + } + return false; + } + //utility method to avoid lumping words with non-word stuff + + }, { + key: 'is_word', + value: function is_word() { + if (this.text.match(/^\[.*?\]\??$/)) { + return false; + } + if (!this.text.match(/[a-z|0-9]/i)) { + return false; + } + return true; + } + //FBI or F.B.I. + + }, { + key: 'is_acronym', + value: function is_acronym() { + return _is_acronym(this.text); + } + //working word + + }, { + key: 'normalize', + value: function normalize() { + var str = this.text || ''; + str = str.toLowerCase(); + //strip grammatical punctuation + str = str.replace(/[,\.!:;\?\(\)^$]/g, ''); + //convert hyphenations to a multiple-word term + str = str.replace(/([a-z])\-([a-z])/g, '$1 $2'); + // coerce single curly quotes + str = str.replace(/[\u2018\u2019\u201A\u201B\u2032\u2035]+/g, '\''); + // coerce double curly quotes + str = str.replace(/[\u201C\u201D\u201E\u201F\u2033\u2036]+/g, ''); + //remove quotations + scare-quotes + str = str.replace(/^'/g, ''); + str = str.replace(/'$/g, ''); + str = str.replace(/"/g, ''); + if (!str.match(/[a-z0-9]/i)) { + return ''; + } + this.normal = str; + return this.normal; + } + }]); + + return Term; + }(); + + Term.fn = Term.prototype; + // let t = new Term(`first`); + // console.log(t.normal); + + module.exports = Term; + }, { "../match/match_term": 26, "../match/syntax_parse": 28, "./implied": 67, "./is_acronym": 68 }], 96: [function (require, module, exports) { + //turn a verb into its other grammatical forms. + 'use strict'; + + var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) { + return typeof obj === "undefined" ? "undefined" : _typeof2(obj); + } : function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof2(obj); + }; + + var verb_to_actor = require('./to_actor'); + var to_infinitive = require('./to_infinitive'); + var from_infinitive = require('./from_infinitive'); + var irregular_verbs = require('../../../data/irregular_verbs'); + var predict = require('./predict_form.js'); + var generic = require('./generic.js'); + var strip_prefix = require('./strip_prefix.js'); + var fns = require('../../../fns.js'); + + //make sure object has all forms + var fufill = function fufill(obj, prefix) { + //we're toast if there's no infinitive + if (!obj.infinitive) { + return obj; + } + //apply generic methods to missing forms + if (!obj.gerund) { + obj.gerund = generic.gerund(obj); + } + if (!obj.present) { + obj.present = generic.present(obj); + } + if (!obj.past) { + obj.past = generic.past(obj); + } + if (obj.actor === undefined) { + obj.actor = verb_to_actor(obj.infinitive); + } + + //add the prefix to all forms, if it exists + if (prefix) { + Object.keys(obj).forEach(function (k) { + obj[k] = prefix + obj[k]; + }); + } + //future is 'will'+infinitive + if (!obj.future) { + obj.future = generic.future(obj); + } + //perfect is 'have'+past-tense + if (!obj.perfect) { + obj.perfect = generic.perfect(obj); + } + //pluperfect is 'had'+past-tense + if (!obj.pluperfect) { + obj.pluperfect = generic.pluperfect(obj); + } + //future perfect is 'will have'+past-tense + if (!obj.future_perfect) { + obj.future_perfect = generic.future_perfect(obj); + } + return obj; + }; + + var conjugate = function conjugate(w) { + if (w === undefined) { + return {}; + } + + //for phrasal verbs ('look out'), conjugate look, then append 'out' + var phrasal_reg = new RegExp('^(.*?) (in|out|on|off|behind|way|with|of|do|away|across|ahead|back|over|under|together|apart|up|upon|aback|down|about|before|after|around|to|forth|round|through|along|onto)$', 'i'); + if (w.match(phrasal_reg)) { + var _ret = function () { + var split = w.match(phrasal_reg, ''); + var phrasal_verb = split[1]; + var particle = split[2]; + var result = conjugate(phrasal_verb); //recursive + Object.keys(result).forEach(function (k) { + if (result[k]) { + result[k] += ' ' + particle; + } + }); + return { + v: result + }; + }(); + + if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; + } + + //for pluperfect ('had tried') remove 'had' and call it past-tense + w = w.replace(/^had /i, ''); + //for perfect ('have tried') remove 'have' and call it past-tense + w = w.replace(/^have /i, ''); + //for future perfect ('will have tried') remove 'will have' and call it past-tense + w = w.replace(/^will have /i, ''); + //chop it if it's future-tense + w = w.replace(/^will /i, ''); + + //un-prefix the verb, and add it in later + var prefix = strip_prefix(w); + w = w.replace(prefix, ''); + + //guess the tense, so we know which transormation to make + var predicted = predict(w) || 'infinitive'; + //check against suffix rules + var infinitive = to_infinitive(w, predicted) || ''; + //check irregulars + var obj = irregular_verbs[w] || irregular_verbs[infinitive] || {}; + obj = fns.extend({}, obj); + //apply regex-transformations + var conjugations = from_infinitive(infinitive); + Object.keys(conjugations).forEach(function (k) { + if (!obj[k]) { + obj[k] = conjugations[k]; + } + }); + return fufill(obj, prefix); + }; + module.exports = conjugate; + + // console.log(conjugate('learn')); + }, { "../../../data/irregular_verbs": 11, "../../../fns.js": 23, "./from_infinitive": 97, "./generic.js": 98, "./predict_form.js": 99, "./strip_prefix.js": 100, "./to_actor": 102, "./to_infinitive": 103 }], 97: [function (require, module, exports) { + 'use strict'; + + var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) { + return typeof obj === "undefined" ? "undefined" : _typeof2(obj); + } : function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof2(obj); + }; + + var rules = [{ + reg: /(eave)$/i, + repl: { + pr: '$1s', + pa: '$1d', + gr: 'eaving', + ar: '$1r' + } + }, { + reg: /(ink)$/i, + repl: { + pr: '$1s', + pa: 'unk', + gr: '$1ing', + ar: '$1er' + } + }, { + reg: /(end)$/i, + repl: { + pr: '$1s', + pa: 'ent', + gr: '$1ing', + ar: '$1er' + } + }, { + reg: /(ide)$/i, + repl: { + pr: '$1s', + pa: 'ode', + gr: 'iding', + ar: 'ider' + } + }, { + reg: /(ake)$/i, + repl: { + pr: '$1s', + pa: 'ook', + gr: 'aking', + ar: '$1r' + } + }, { + reg: /(eed)$/i, + repl: { + pr: '$1s', + pa: '$1ed', + gr: '$1ing', + ar: '$1er' + } + }, { + reg: /(e)(ep)$/i, + repl: { + pr: '$1$2s', + pa: '$1pt', + gr: '$1$2ing', + ar: '$1$2er' + } + }, { + reg: /(a[tg]|i[zn]|ur|nc|gl|is)e$/i, + repl: { + pr: '$1es', + pa: '$1ed', + gr: '$1ing', + prt: '$1en' + } + }, { + reg: /([i|f|rr])y$/i, + repl: { + pr: '$1ies', + pa: '$1ied', + gr: '$1ying' + } + }, { + reg: /([td]er)$/i, + repl: { + pr: '$1s', + pa: '$1ed', + gr: '$1ing' + } + }, { + reg: /([bd]l)e$/i, + repl: { + pr: '$1es', + pa: '$1ed', + gr: '$1ing' + } + }, { + reg: /(ish|tch|ess)$/i, + repl: { + pr: '$1es', + pa: '$1ed', + gr: '$1ing' + } + }, { + reg: /(ion|end|e[nc]t)$/i, + repl: { + pr: '$1s', + pa: '$1ed', + gr: '$1ing' + } + }, { + reg: /(om)e$/i, + repl: { + pr: '$1es', + pa: 'ame', + gr: '$1ing' + } + }, { + reg: /([aeiu])([pt])$/i, + repl: { + pr: '$1$2s', + pa: '$1$2', + gr: '$1$2$2ing' + } + }, { + reg: /(er)$/i, + repl: { + pr: '$1s', + pa: '$1ed', + gr: '$1ing' + } + }, { + reg: /(en)$/i, + repl: { + pr: '$1s', + pa: '$1ed', + gr: '$1ing' + } + }, { + reg: /(..)(ow)$/i, + repl: { + pr: '$1$2s', + pa: '$1ew', + gr: '$1$2ing', + prt: '$1$2n' + } + }, { + reg: /(..)([cs]h)$/i, + repl: { + pr: '$1$2es', + pa: '$1$2ed', + gr: '$1$2ing' + } + }, { + reg: /([^aeiou][ou])(g|d)$/i, + repl: { + pr: '$1$2s', + pa: '$1$2$2ed', + gr: '$1$2$2ing' + } + }, { + reg: /([^aeiou][aeiou])(b|t|p|m)$/i, + repl: { + pr: '$1$2s', + pa: '$1$2$2ed', + gr: '$1$2$2ing' + } + }]; + + var keys = { + pr: 'present', + pa: 'past', + gr: 'gerund', + prt: 'participle', + ar: 'actor' + }; + + var from_infinitive = function from_infinitive(str) { + var obj = { + infinitive: str + }; + if (!str || typeof str !== 'string') { + // console.log(str); + return obj; + } + + var _loop = function _loop(i) { + if (str.match(rules[i].reg)) { + // console.log(rules[i]); + Object.keys(rules[i].repl).forEach(function (k) { + obj[keys[k]] = str.replace(rules[i].reg, rules[i].repl[k]); + }); + return { + v: obj + }; + } + }; + + for (var i = 0; i < rules.length; i++) { + var _ret = _loop(i); + + if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; + } + return obj; + }; + // console.log(from_infinitive('watch')); + + module.exports = from_infinitive; + }, {}], 98: [function (require, module, exports) { + 'use strict'; + //non-specifc, 'hail-mary' transforms from infinitive, into other forms + + var fns = require('../../../fns'); + var generic = { + + gerund: function gerund(o) { + var inf = o.infinitive; + if (fns.endsWith(inf, 'e')) { + return inf.replace(/e$/, 'ing'); + } + return inf + 'ing'; + }, + + present: function present(o) { + var inf = o.infinitive; + if (fns.endsWith(inf, 's')) { + return inf + 'es'; + } + return inf + 's'; + }, + + past: function past(o) { + var inf = o.infinitive; + if (fns.endsWith(inf, 'e')) { + return inf + 'd'; + } + if (fns.endsWith(inf, 'ed')) { + return inf; + } + return inf + 'ed'; + }, + + future: function future(o) { + return 'will ' + o.infinitive; + }, + + perfect: function perfect(o) { + return 'have ' + (o.participle || o.past); + }, + + pluperfect: function pluperfect(o) { + return 'had ' + o.past; + }, + + future_perfect: function future_perfect(o) { + return 'will have ' + o.past; + } + + }; + + module.exports = generic; + }, { "../../../fns": 23 }], 99: [function (require, module, exports) { + 'use strict'; + //this method is used to predict which current conjugation a verb is + + //this method is the slowest in the whole library, + + var fns = require('../../../fns.js'); + var suffix_rules = require('./suffix_rules'); + var irregular_verbs = require('../../../data/irregular_verbs'); + var known_verbs = Object.keys(irregular_verbs).reduce(function (h, k) { + Object.keys(irregular_verbs[k]).forEach(function (k2) { + h[irregular_verbs[k][k2]] = k2; + }); + return h; + }, {}); + + var predict = function predict(w) { + + //check if known infinitive + if (irregular_verbs[w]) { + return 'infinitive'; + } + //check if known infinitive + if (known_verbs[w]) { + return known_verbs[w]; + } + + if (w.match(/will ha(ve|d) [a-z]{2}/)) { + return 'future_perfect'; + } + if (w.match(/will [a-z]{2}/)) { + return 'future'; + } + if (w.match(/had [a-z]{2}/)) { + return 'pluperfect'; + } + if (w.match(/have [a-z]{2}/)) { + return 'perfect'; + } + if (w.match(/..erer$/)) { + return 'actor'; + } + if (w.match(/[^aeiou]ing$/)) { + return 'gerund'; + } + + var arr = Object.keys(suffix_rules); + for (var i = 0; i < arr.length; i++) { + if (fns.endsWith(w, arr[i]) && arr[i].length < w.length) { + return suffix_rules[arr[i]]; + } + } + return 'infinitive'; + }; + + module.exports = predict; + }, { "../../../data/irregular_verbs": 11, "../../../fns.js": 23, "./suffix_rules": 101 }], 100: [function (require, module, exports) { + 'use strict'; + // 'over-kill' should use conjugation rules of 'kill', etc.. + + var strip_prefix = function strip_prefix(str) { + var prefix = ''; + var match = str.match(/^(over|under|re|anti|full|cross)([- ])?([^aeiou][a-z]*)/i); + if (match) { + prefix = match[1] + (match[2] || ''); + } + return prefix; + }; + + module.exports = strip_prefix; + }, {}], 101: [function (require, module, exports) { + 'use strict'; + //suffix signals for verb tense, generated from test data + + var compact = { + 'gerund': [], + 'infinitive': ['ate', 'ize', 'tion', 'rify', 'then', 'ress', 'ify', 'age', 'nce', 'ect', 'ise', 'ine', 'ish', 'ace', 'ash', 'ure', 'tch', 'end', 'ack', 'and', 'ute', 'ade', 'ock', 'ite', 'ase', 'ose', 'use', 'ive', 'int', 'nge', 'lay', 'est', 'ain', 'ant', 'eed', 'er', 'le'], + 'participle': ['own', 'unk', 'ung', 'en'], + 'past': ['ed', 'lt', 'nt', 'pt', 'ew', 'ld'], + 'present': ['rks', 'cks', 'nks', 'ngs', 'mps', 'tes', 'zes', 'ers', 'les', 'acks', 'ends', 'ands', 'ocks', 'lays', 'eads', 'lls', 'els', 'ils', 'ows', 'nds', 'ays', 'ams', 'ars', 'ops', 'ffs', 'als', 'urs', 'lds', 'ews', 'ips', 'es', 'ts', 'ns', 's'] + }; + var suffix_rules = {}; + var keys = Object.keys(compact); + var l = keys.length; + + for (var i = 0; i < l; i++) { + var l2 = compact[keys[i]].length; + for (var o = 0; o < l2; o++) { + suffix_rules[compact[keys[i]][o]] = keys[i]; + } + } + module.exports = suffix_rules; + }, {}], 102: [function (require, module, exports) { + //somone who does this present-tense verb + //turn 'walk' into 'walker' + 'use strict'; + + var actor = function actor(str) { + str = str || ''; + var irregulars = { + 'tie': 'tier', + 'dream': 'dreamer', + 'sail': 'sailer', + 'run': 'runner', + 'rub': 'rubber', + 'begin': 'beginner', + 'win': 'winner', + 'claim': 'claimant', + 'deal': 'dealer', + 'spin': 'spinner' + }; + var dont = { + 'aid': 1, + 'fail': 1, + 'appear': 1, + 'happen': 1, + 'seem': 1, + 'try': 1, + 'say': 1, + 'marry': 1, + 'be': 1, + 'forbid': 1, + 'understand': 1, + 'bet': 1 + }; + var transforms = [{ + 'reg': /e$/i, + 'repl': 'er' + }, { + 'reg': /([aeiou])([mlgp])$/i, + 'repl': '$1$2$2er' + }, { + 'reg': /([rlf])y$/i, + 'repl': '$1ier' + }, { + 'reg': /^(.?.[aeiou])t$/i, + 'repl': '$1tter' + }]; + + if (dont.hasOwnProperty(str)) { + return null; + } + if (irregulars.hasOwnProperty(str)) { + return irregulars[str]; + } + for (var i = 0; i < transforms.length; i++) { + if (str.match(transforms[i].reg)) { + return str.replace(transforms[i].reg, transforms[i].repl); + } + } + return str + 'er'; + }; + + // console.log(verb_to_actor('set')) + // console.log(verb_to_actor('sweep')) + // console.log(verb_to_actor('watch')) + module.exports = actor; + }, {}], 103: [function (require, module, exports) { + //turns a verb in any form, into it's infinitive version + // eg "walked" -> "walk" + 'use strict'; + + var irregular_verbs = require('../../../data/irregular_verbs'); + var known_verbs = Object.keys(irregular_verbs).reduce(function (h, k) { + Object.keys(irregular_verbs[k]).forEach(function (k2) { + h[irregular_verbs[k][k2]] = k; + }); + return h; + }, {}); + + var rules = { + participle: [{ + reg: /own$/i, + to: 'ow' + }, { + reg: /(.)un([g|k])$/i, + to: '$1in$2' + }], + + // { + // reg: /(..)en$/i, + // to: '$1e' + // }, + actor: [{ + reg: /(er)er$/i, + to: '$1' + }], + present: [{ + reg: /(ies)$/i, + to: 'y' + }, { + reg: /(tch|sh)es$/i, + to: '$1' + }, { + reg: /(ss)es$/i, + to: '$1' + }, { + reg: /([tzlshicgrvdnkmu])es$/i, + to: '$1e' + }, { + reg: /(n[dtk]|c[kt]|[eo]n|i[nl]|er|a[ytrl])s$/i, + to: '$1' + }, { + reg: /(ow)s$/i, + to: '$1' + }, { + reg: /(op)s$/i, + to: '$1' + }, { + reg: /([eirs])ts$/i, + to: '$1t' + }, { + reg: /(ll)s$/i, + to: '$1' + }, { + reg: /(el)s$/i, + to: '$1' + }, { + reg: /(ip)es$/i, + to: '$1e' + }, { + reg: /ss$/i, + to: 'ss' + }, { + reg: /s$/i, + to: '' + }], + gerund: [{ + reg: /pping$/i, + to: 'p' + }, { + reg: /lling$/i, + to: 'll' + }, { + reg: /tting$/i, + to: 't' + }, { + reg: /ssing$/i, + to: 'ss' + }, { + reg: /gging$/i, + to: 'g' + }, { + reg: /([^aeiou])ying$/i, + to: '$1y' + }, { + reg: /(i.)ing$/i, + to: '$1e' + }, { + reg: /(u[rtcb]|[bdtpkg]l|n[cg]|a[gdkvtc]|[ua]s|[dr]g|yz|o[rlsp]|cre)ing$/i, + to: '$1e' + }, { + reg: /(ch|sh)ing$/i, + to: '$1' + }, { + reg: /(..)ing$/i, + to: '$1' + }], + past: [{ + reg: /(ued)$/i, + to: 'ue' + }, { + reg: /(e|i)lled$/i, + to: '$1ll' + }, { + reg: /(sh|ch)ed$/i, + to: '$1' + }, { + reg: /(tl|gl)ed$/i, + to: '$1e' + }, { + reg: /(um?pt?)ed$/i, + to: '$1' + }, { + reg: /(ss)ed$/i, + to: '$1' + }, { + reg: /pped$/i, + to: 'p' + }, { + reg: /tted$/i, + to: 't' + }, { + reg: /gged$/i, + to: 'g' + }, { + reg: /(h|ion|n[dt]|ai.|[cs]t|pp|all|ss|tt|int|ail|ld|en|oo.|er|k|pp|w|ou.|rt|ght|rm)ed$/i, + to: '$1' + }, { + reg: /(.ut)ed$/i, + to: '$1e' + }, { + reg: /(us)ed$/i, + to: '$1e' + }, { + reg: /(..[^aeiou])ed$/i, + to: '$1e' + }, { + reg: /ied$/i, + to: 'y' + }, { + reg: /(.o)ed$/i, + to: '$1o' + }, { + reg: /(.i)ed$/i, + to: '$1' + }, { + reg: /([rl])ew$/i, + to: '$1ow' + }, { + reg: /([pl])t$/i, + to: '$1t' + }] + }; + + var to_infinitive = function to_infinitive(str, from_tense) { + if (known_verbs.hasOwnProperty(str)) { + return known_verbs[str]; + } + if (from_tense === 'infinitive') { + return str; + } + var regs = rules[from_tense] || []; + for (var i = 0; i < regs.length; i++) { + if (str.match(regs[i].reg)) { + return str.replace(regs[i].reg, regs[i].to); + } + } + return str; + }; + + // console.log(to_infinitive('watch', 'infinitive')); + + module.exports = to_infinitive; + }, { "../../../data/irregular_verbs": 11 }], 104: [function (require, module, exports) { + 'use strict'; + + var _createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); + } + }return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; + }; + }(); + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + }return call && ((typeof call === "undefined" ? "undefined" : _typeof2(call)) === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : _typeof2(superClass))); + }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + } + + var Term = require('../term.js'); + var _conjugate = require('./conjugate/conjugate.js'); + var _negate = require('./verb_negate.js'); + var predict_form = require('./conjugate/predict_form.js'); + + var verbTags = { + infinitive: 'Infinitive', + present: 'PresentTense', + past: 'PastTense', + gerund: 'Gerund', + actor: 'Actor', + future: 'FutureTense', + pluperfect: 'PluperfectTense', + perfect: 'PerfectTense' + }; + + var Verb = function (_Term) { + _inherits(Verb, _Term); + + function Verb(str, tag) { + _classCallCheck(this, Verb); + + var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Verb).call(this, str)); + + _this.tag = tag; + _this.pos['Verb'] = true; + //if we've been told which + if (tag) { + _this.pos[tag] = true; + } + return _this; + } + + //'root' for a verb means infinitive + + _createClass(Verb, [{ + key: 'root', + value: function root() { + return this.conjugate().infinitive; + } + + //retrieve a specific form + + }, { + key: 'conjugation', + value: function conjugation() { + //check cached conjugations + var conjugations = this.conjugate(); + var keys = Object.keys(conjugations); + for (var i = 0; i < keys.length; i++) { + if (conjugations[keys[i]] === this.normal) { + return verbTags[keys[i]]; + } + } + //try to guess + return verbTags[predict_form(this.normal)]; + } + }, { + key: 'tense', + value: function tense() { + //map conjugation onto past/present/future + var tenses = { + infinitive: 'present', + gerund: 'present', + actor: 'present', + present: 'present', + past: 'past', + future: 'future', + perfect: 'past', + pluperfect: 'past', + future_perfect: 'future' + }; + var c = this.conjugation(); + return tenses[c] || 'present'; + } + }, { + key: 'conjugate', + value: function conjugate() { + return _conjugate(this.normal); + } + }, { + key: 'to_past', + value: function to_past() { + var tense = 'past'; + var conjugations = this.conjugate(this.normal); + this.tag = verbTags[tense]; + this.changeTo(conjugations[tense]); + return conjugations[tense]; + } + }, { + key: 'to_present', + value: function to_present() { + var tense = 'present'; + var conjugations = this.conjugate(this.normal); + this.tag = verbTags[tense]; + this.changeTo(conjugations[tense]); + return conjugations[tense]; + } + }, { + key: 'to_future', + value: function to_future() { + var tense = 'future'; + var conjugations = this.conjugate(this.normal); + this.tag = verbTags[tense]; + this.changeTo(conjugations[tense]); + return conjugations[tense]; + } + + //is this verb negative already? + + }, { + key: 'isNegative', + value: function isNegative() { + var str = this.normal; + //yep, pretty simple + if (str.match(/(n't|\bnot\b)/)) { + return true; + } + return false; + } + + //turn 'walked' to "didn't walk" + + }, { + key: 'negate', + value: function negate() { + this.changeTo(_negate(this)); + return this; + } + }]); + + return Verb; + }(Term); + + Verb.fn = Verb.prototype; + + module.exports = Verb; + + // let v = new Verb('stunk up'); + // console.log(v.negate()); + }, { "../term.js": 95, "./conjugate/conjugate.js": 96, "./conjugate/predict_form.js": 99, "./verb_negate.js": 105 }], 105: [function (require, module, exports) { + 'use strict'; + //recieves a verb object, and returns a negated string + //sort out don't/didn't/doesn't/won't + + var fns = require('../../fns'); + + // logic: + // [past tense] - "sold" -> "didn't sell" + // [present] - "sells" -> "doesn't sell" + // [future] - "will sell" -> "won't sell" + + var negate = function negate(v) { + + var known_negation = { + 'is': 'isn\'t', + 'are': 'aren\'t', + 'was': 'wasn\'t', + 'will': 'won\'t', + 'had': 'hadn\'t', + //modals + 'did': 'didn\'t', + 'would': 'wouldn\'t', + 'could': 'couldn\'t', + 'should': 'shouldn\'t', + 'can': 'can\'t', + 'must': 'mustn\'t', + 'have': 'haven\'t', + 'has': 'hasn\'t', + 'does': 'doesn\'t' + }; + //hard-coded explicit forms + if (known_negation[v.normal]) { + return known_negation[v.normal]; + } + //try to un-negate? create corrollary + var known_affirmation = fns.reverseObj(known_negation); + if (known_affirmation[v.normal]) { + return known_affirmation[v.normal]; + } + + //multiple-word verbs, like 'have walked' + var words = v.normal.split(' '); + if (words.length > 1 && known_negation[words[0]]) { + return known_negation[words[0]] + ' ' + words.slice(1, words.length).join(' '); + } + var form = v.conjugation(); + //walked -> didn't walk + if (form === 'PastTense') { + return 'didn\'t ' + v.conjugate()['infinitive']; + } + //walks -> doesn't walk + if (form === 'PresentTense') { + return 'doesn\'t ' + v.conjugate()['infinitive']; + } + //walking -> not walking + if (form === 'Gerund') { + return 'not ' + v.text; + } + //walker -> non-walker ? + if (form === 'Actor') { + return 'non-' + v.text; + } + //walk -> not walk ? + if (form === 'Infinitive') { + return 'not ' + v.text; + } + + return v.text; + }; + + module.exports = negate; + }, { "../../fns": 23 }], 106: [function (require, module, exports) { + //(Rule-based sentence boundary segmentation) - chop given text into its proper sentences. + // Ignore periods/questions/exclamations used in acronyms/abbreviations/numbers, etc. + // @spencermountain 2015 MIT + 'use strict'; + + var abbreviations = require('../data/abbreviations').abbreviations; + + var sentence_parser = function sentence_parser(text) { + var sentences = []; + //first do a greedy-split.. + var chunks = []; + // This was the splitter regex updated to fix quoted punctuation marks. + // let splits = text.split(/(\S.+?[.\?!])(?=\s+|$|")/g); + // todo: look for side effects in this regex replacement: + var splits = text.split(/(\S.+?[.!?])(?=\s+|$)/g); + //filter-out the grap ones + for (var i = 0; i < splits.length; i++) { + var s = splits[i]; + if (!s || s === '') { + continue; + } + //this is meaningful whitespace + if (!s.match(/\S/)) { + //add it to the last one + if (chunks[chunks.length - 1]) { + chunks[chunks.length - 1] += s; + continue; + } else if (splits[i + 1]) { + //add it to the next one + splits[i + 1] = s + splits[i + 1]; + continue; + } + //else, only whitespace, no terms, no sentence + } + chunks.push(s); + } + + //detection of non-sentence chunks + var abbrev_reg = new RegExp('\\b(' + abbreviations.join('|') + ')[.!?] ?$', 'i'); + var acronym_reg = new RegExp('[ |\.][A-Z]\.? +?$', 'i'); + var elipses_reg = new RegExp('\\.\\.\\.* +?$'); + //loop through these chunks, and join the non-sentence chunks back together.. + for (var i = 0; i < chunks.length; i++) { + //should this chunk be combined with the next one? + if (chunks[i + 1] && (chunks[i].match(abbrev_reg) || chunks[i].match(acronym_reg) || chunks[i].match(elipses_reg))) { + chunks[i + 1] = chunks[i] + (chunks[i + 1] || ''); //.replace(/ +/g, ' '); + } else if (chunks[i] && chunks[i].length > 0) { + //this chunk is a proper sentence.. + sentences.push(chunks[i]); + chunks[i] = ''; + } + } + //if we never got a sentence, return the given text + if (sentences.length === 0) { + return [text]; + } + + return sentences; + }; + + module.exports = sentence_parser; + // console.log(sentence_parser(' Dr. Smith is nice? He lives in Spain? He does?? ')); + }, { "../data/abbreviations": 2 }], 107: [function (require, module, exports) { + 'use strict'; + + var _createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor); + } + }return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor; + }; + }(); + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + var sentence_parser = require('./sentence_parser.js'); + var Sentence = require('../sentence/sentence.js'); + var Question = require('../sentence/question/question.js'); + var Statement = require('../sentence/statement/statement.js'); + var fns = require('../fns.js'); + + //a text object is a series of sentences, along with the generic methods for transforming them + + var Text = function () { + function Text(str, options) { + _classCallCheck(this, Text); + + options = options || {}; + var the = this; + this.raw_text = str || ''; + //build-up sentence/statement methods + this.sentences = sentence_parser(str).map(function (s) { + var last_char = s.slice(-1); + if (last_char === '?') { + return new Question(s, options); + } else if (last_char === '.' || last_char === '!') { + return new Statement(s, options); + } + return new Sentence(s, options); + }); + + this.contractions = { + // he'd -> he would + expand: function expand() { + return the.sentences.map(function (s) { + return s.contractions.expand(); + }); + }, + // he would -> he'd + contract: function contract() { + return the.sentences.map(function (s) { + return s.contractions.contract(); + }); + } + }; + } + + //map over sentence methods + + _createClass(Text, [{ + key: 'text', + value: function text() { + var arr = this.sentences.map(function (s) { + return s.text(); + }); + return fns.flatten(arr).join(''); + } + }, { + key: 'normalized', + value: function normalized() { + var arr = this.sentences.map(function (s) { + return s.normalized(); + }); + return fns.flatten(arr).join(' '); + } + + //further 'lemmatisation/inflection' + + }, { + key: 'root', + value: function root() { + var arr = this.sentences.map(function (s) { + return s.root(); + }); + return fns.flatten(arr).join(' '); + } + }, { + key: 'terms', + value: function terms() { + var arr = this.sentences.map(function (s) { + return s.terms; + }); + return fns.flatten(arr); + } + }, { + key: 'tags', + value: function tags() { + return this.sentences.map(function (s) { + return s.tags(); + }); + } + + //a regex-like lookup for a sentence. + // returns an array of terms + + }, { + key: 'match', + value: function match(str, options) { + var arr = []; + for (var i = 0; i < this.sentences.length; i++) { + arr = arr.concat(this.sentences[i].match(str, options)); + } + return arr; + } + }, { + key: 'replace', + value: function replace(str, replacement, options) { + for (var i = 0; i < this.sentences.length; i++) { + this.sentences[i].replace(str, replacement, options); + } + return this; + } + + //transformations + + }, { + key: 'to_past', + value: function to_past() { + return this.sentences.map(function (s) { + return s.to_past(); + }); + } + }, { + key: 'to_present', + value: function to_present() { + return this.sentences.map(function (s) { + return s.to_present(); + }); + } + }, { + key: 'to_future', + value: function to_future() { + return this.sentences.map(function (s) { + return s.to_future(); + }); + } + }, { + key: 'negate', + value: function negate() { + return this.sentences.map(function (s) { + return s.negate(); + }); + } + //mining + + }, { + key: 'people', + value: function people() { + var arr = []; + for (var i = 0; i < this.sentences.length; i++) { + arr = arr.concat(this.sentences[i].people()); + } + return arr; + } + }, { + key: 'places', + value: function places() { + var arr = []; + for (var i = 0; i < this.sentences.length; i++) { + arr = arr.concat(this.sentences[i].places()); + } + return arr; + } + }, { + key: 'organizations', + value: function organizations() { + var arr = []; + for (var i = 0; i < this.sentences.length; i++) { + arr = arr.concat(this.sentences[i].organizations()); + } + return arr; + } + }, { + key: 'dates', + value: function dates() { + var arr = []; + for (var i = 0; i < this.sentences.length; i++) { + arr = arr.concat(this.sentences[i].dates()); + } + return arr; + } + }, { + key: 'values', + value: function values() { + var arr = []; + for (var i = 0; i < this.sentences.length; i++) { + arr = arr.concat(this.sentences[i].values()); + } + return arr; + } + //more generic named-entity recognition + + }, { + key: 'topics', + value: function topics() { + //consolodate topics across sentences + var obj = {}; + for (var i = 0; i < this.sentences.length; i++) { + var topics = this.sentences[i].topics(); + for (var o = 0; o < topics.length; o++) { + if (obj[topics[o].text]) { + obj[topics[o].text].count += topics[o].count; + } else { + obj[topics[o].text] = topics[o]; + } + } + } + //sort by frequency + var arr = Object.keys(obj).map(function (k) { + return obj[k]; + }); + return arr.sort(function (a, b) { + if (a.count > b.count) { + return -1; + } else { + return 1; + } + }); + } + }]); + + return Text; + }(); + + Text.fn = Text.prototype; + + module.exports = Text; + }, { "../fns.js": 23, "../sentence/question/question.js": 52, "../sentence/sentence.js": 55, "../sentence/statement/statement.js": 58, "./sentence_parser.js": 106 }] }, {}, [1])(1); +}); + +/***/ }, +/* 3 */ +/***/ function(module, exports, __webpack_require__) { + +"use strict"; + + +var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var _ = __webpack_require__(0); +var applyMixins = __webpack_require__(4); +var engine = __webpack_require__(1); +function directionName(direction) { + switch (direction) { + case 0: + return 'x'; + case 1: + return 'y'; + case 2: + return 'z'; + } +} + +var Orientation = function () { + function Orientation(direction) { + _classCallCheck(this, Orientation); + + this.direction = direction; + } + + _createClass(Orientation, [{ + key: 'getLeftTileDirection', + value: function getLeftTileDirection() { + switch (this.direction) { + case 0: + return 2; + case 1: + return 0; + case 2: + return 1; + } + } + }, { + key: 'getRightTileDirection', + value: function getRightTileDirection() { + switch (this.direction) { + case 0: + return 1; + case 1: + return 2; + case 2: + return 0; + } + } + }, { + key: 'getLeftEdgeDirection', + value: function getLeftEdgeDirection() { + return this.getRightTileDirection(); + } + }, { + key: 'getRightEdgeDirection', + value: function getRightEdgeDirection() { + return this.getLeftTileDirection(); + } + }]); + + return Orientation; +}(); + +exports.Orientation = Orientation; + +var TileRef = function () { + function TileRef(x, y, z) { + _classCallCheck(this, TileRef); + + this.x = x; + this.y = y; + this.z = z; + if (x + y + z != 0) { + throw new Error('Tile coordinates did not sum to zero'); + } + } + + _createClass(TileRef, [{ + key: 'key', + value: function key() { + return this.x + '|' + this.y + '|' + this.z; + } + }]); + + return TileRef; +}(); + +exports.TileRef = TileRef; + +var EdgeRef = function (_TileRef) { + _inherits(EdgeRef, _TileRef); + + function EdgeRef(x, y, z, pos) { + _classCallCheck(this, EdgeRef); + + var _this = _possibleConstructorReturn(this, (EdgeRef.__proto__ || Object.getPrototypeOf(EdgeRef)).call(this, x, y, z)); + + _this.pos = pos; + return _this; + } + + _createClass(EdgeRef, [{ + key: 'key', + value: function key() { + return _get(EdgeRef.prototype.__proto__ || Object.getPrototypeOf(EdgeRef.prototype), 'key', this).call(this) + '|' + this.pos; + } + }]); + + return EdgeRef; +}(TileRef); + +exports.EdgeRef = EdgeRef; + +var CornerRef = function (_TileRef2) { + _inherits(CornerRef, _TileRef2); + + function CornerRef(x, y, z, pos) { + _classCallCheck(this, CornerRef); + + var _this2 = _possibleConstructorReturn(this, (CornerRef.__proto__ || Object.getPrototypeOf(CornerRef)).call(this, x, y, z)); + + _this2.pos = pos; + return _this2; + } + + _createClass(CornerRef, [{ + key: 'key', + value: function key() { + return _get(CornerRef.prototype.__proto__ || Object.getPrototypeOf(CornerRef.prototype), 'key', this).call(this) + '|' + this.pos; + } + }, { + key: 'getAdjacentTileRef', + value: function getAdjacentTileRef(direction) { + if (this.pos == 0) { + switch (direction) { + case 0: + return new TileRef(this.x, this.y + 1, this.z - 1); + case 1: + return new TileRef(this.x + 1, this.y, this.z - 1); + case 2: + return new TileRef(this.x, this.y, this.z); + } + } else { + switch (direction) { + case 0: + return new TileRef(this.x, this.y - 1, this.z + 1); + case 1: + return new TileRef(this.x - 1, this.y, this.z + 1); + case 2: + return new TileRef(this.x, this.y, this.z); + } + } + } + }, { + key: 'getAdjacentCornerRef', + value: function getAdjacentCornerRef(direction) { + if (this.pos == 0) { + switch (direction) { + case 0: + return new CornerRef(this.x + 1, this.y, this.z - 1, 1); + case 1: + return new CornerRef(this.x, this.y + 1, this.z - 1, 1); + case 2: + return new CornerRef(this.x + 1, this.y + 1, this.z - 2, 1); + } + } else { + switch (direction) { + case 0: + return new CornerRef(this.x - 1, this.y, this.z + 1, 0); + case 1: + return new CornerRef(this.x, this.y - 1, this.z + 1, 0); + case 2: + return new CornerRef(this.x - 1, this.y - 1, this.z + 2, 0); + } + } + } + }, { + key: 'getAdjacentEdgeRef', + value: function getAdjacentEdgeRef(direction) { + if (this.pos == 0) { + switch (direction) { + case 0: + return new EdgeRef(this.x, this.y, this.z, 0); + case 1: + return new EdgeRef(this.x, this.y + 1, this.z - 1, 2); + case 2: + return new EdgeRef(this.x, this.y + 1, this.z - 1, 1); + } + } else { + switch (direction) { + case 0: + return new EdgeRef(this.x - 1, this.y, this.z + 1, 0); + case 1: + return new EdgeRef(this.x, this.y, this.z, 2); + case 2: + return new EdgeRef(this.x - 1, this.y, this.z + 1, 1); + } + } + } + }]); + + return CornerRef; +}(TileRef); + +exports.CornerRef = CornerRef; +function terrainName(terrain) { + switch (terrain) { + case 0: + return 'desert'; + case 1: + return 'fields'; + case 2: + return 'forest'; + case 3: + return 'hills'; + case 4: + return 'mountains'; + case 5: + return 'pasture'; + } +} + +var Tile = function Tile(ref) { + _classCallCheck(this, Tile); + + this.ref = ref; +}; + +exports.Tile = Tile; +function ownerName(owner) { + switch (owner) { + case 0: + return 'red'; + case 1: + return 'blue'; + case 2: + return 'orange'; + case 3: + return 'white'; + } +} +exports.ownerName = ownerName; + +var Edge = function Edge(ref) { + _classCallCheck(this, Edge); + + this.ref = ref; +}; + +exports.Edge = Edge; + +var DescriptionTemplate = function () { + function DescriptionTemplate(template) { + _classCallCheck(this, DescriptionTemplate); + + this.templateFunc = _.template(template); + } + + _createClass(DescriptionTemplate, [{ + key: 'render', + value: function render(orientation) { + var params = {}; + params['t' + directionName(orientation.direction)] = 'in front of you'; + params['t' + directionName(orientation.getLeftTileDirection())] = 'to your left'; + params['t' + directionName(orientation.getRightTileDirection())] = 'to your right'; + params['e' + directionName(orientation.direction)] = 'behind you'; + params['e' + directionName(orientation.getLeftEdgeDirection())] = 'ahead to your left'; + params['e' + directionName(orientation.getRightEdgeDirection())] = 'ahead to your right'; + var text = this.templateFunc(params); + text = text.replace(/[.?!] [a-z]/g, function (match) { + return match.toUpperCase(); + }); + return text; + } + }]); + + return DescriptionTemplate; +}(); + +exports.DescriptionTemplate = DescriptionTemplate; + +var Corner = function Corner(ref) { + _classCallCheck(this, Corner); + + this.ref = ref; + this.entities = []; +}; + +exports.Corner = Corner; +applyMixins(Corner, [engine.EntityContainerMixin]); + +var World = function () { + function World() { + _classCallCheck(this, World); + + this.tiles = {}; + this.edges = {}; + this.corners = {}; + this.createStructure(); + this.setProperties(); + } + + _createClass(World, [{ + key: 'createStructure', + value: function createStructure() { + var _this3 = this; + + for (var x = -3; x <= 3; x++) { + for (var y = -3; y <= 3; y++) { + var z = -(x + y); + var tileRef = new TileRef(x, y, z); + if (Math.abs(x) + Math.abs(y) + Math.abs(z) <= 4) { + this.tiles[tileRef.key()] = new Tile(tileRef); + _.each([0, 1, 2], function (edgePos) { + var edgeRef = new EdgeRef(x, y, z, edgePos); + _this3.edges[edgeRef.key()] = new Edge(edgeRef); + }); + _.each([0, 1], function (cornerPos) { + var cornerRef = new CornerRef(x, y, z, cornerPos); + _this3.corners[cornerRef.key()] = new Corner(cornerRef); + }); + } else { + if (z == -3 && x >= 0 && x < 3) { + var edgeRef = new EdgeRef(x, y, z, 2); + this.edges[edgeRef.key()] = new Edge(edgeRef); + var cornerRef = new CornerRef(x, y, z, 1); + this.corners[cornerRef.key()] = new Corner(cornerRef); + } + if (x == 3 && z >= -3 && z < 0) { + var cornerRef = new CornerRef(x, y, z, 1); + this.corners[cornerRef.key()] = new Corner(cornerRef); + } + if (y == -3 && x >= 0 && x < 3) { + var cornerRef = new CornerRef(x, y, z, 0); + this.corners[cornerRef.key()] = new Corner(cornerRef); + } + if (z == 3 && x >= -3 && x < 0) { + var edgeRef = new EdgeRef(x, y, z, 0); + this.edges[edgeRef.key()] = new Edge(edgeRef); + var cornerRef = new CornerRef(x, y, z, 0); + this.corners[cornerRef.key()] = new Corner(cornerRef); + } + if (x == -3 && y >= 1 && y < 3) { + var edgeRef = new EdgeRef(x, y, z, 0); + this.edges[edgeRef.key()] = new Edge(edgeRef); + edgeRef = new EdgeRef(x, y, z, 1); + this.edges[edgeRef.key()] = new Edge(edgeRef); + var cornerRef = new CornerRef(x, y, z, 0); + this.corners[cornerRef.key()] = new Corner(cornerRef); + } + if (x == -3 && y == 3) { + var edgeRef = new EdgeRef(x, y, z, 1); + this.edges[edgeRef.key()] = new Edge(edgeRef); + } + if (y == 3 && x >= -2 && x < 0) { + var edgeRef = new EdgeRef(x, y, z, 1); + this.edges[edgeRef.key()] = new Edge(edgeRef); + edgeRef = new EdgeRef(x, y, z, 2); + this.edges[edgeRef.key()] = new Edge(edgeRef); + var cornerRef = new CornerRef(x, y, z, 1); + this.corners[cornerRef.key()] = new Corner(cornerRef); + } + } + } + } + if (_.keys(this.tiles).length != 19) { + throw new Error('Wrong number of tiles generated: ' + _.keys(this.tiles).length); + } + if (_.keys(this.edges).length != 72) { + throw new Error('Wrong number of edges generated: ' + _.keys(this.edges).length); + } + if (_.keys(this.corners).length != 54) { + throw new Error('Wrong number of corners generated: ' + _.keys(this.corners).length); + } + } + }, { + key: 'setProperties', + value: function setProperties() { + this.tiles[new TileRef(0, 2, -2).key()].terrain = 5; + this.tiles[new TileRef(1, 1, -2).key()].terrain = 3; + this.tiles[new TileRef(2, 0, -2).key()].terrain = 4; + this.tiles[new TileRef(-1, 2, -1).key()].terrain = 1; + this.tiles[new TileRef(0, 1, -1).key()].terrain = 2; + this.tiles[new TileRef(1, 0, -1).key()].terrain = 5; + this.tiles[new TileRef(2, -1, -1).key()].terrain = 0; + this.tiles[new TileRef(-2, 2, 0).key()].terrain = 5; + this.tiles[new TileRef(-1, 1, 0).key()].terrain = 4; + this.tiles[new TileRef(0, 0, 0).key()].terrain = 1; + this.tiles[new TileRef(1, -1, 0).key()].terrain = 2; + this.tiles[new TileRef(2, -2, 0).key()].terrain = 4; + this.tiles[new TileRef(-2, 1, 1).key()].terrain = 3; + this.tiles[new TileRef(-1, 0, 1).key()].terrain = 2; + this.tiles[new TileRef(0, -1, 1).key()].terrain = 5; + this.tiles[new TileRef(1, -2, 1).key()].terrain = 1; + this.tiles[new TileRef(-2, 0, 2).key()].terrain = 1; + this.tiles[new TileRef(-1, -1, 2).key()].terrain = 3; + this.tiles[new TileRef(0, -2, 2).key()].terrain = 2; + } + }]); + + return World; +}(); + +exports.World = World; + +var Location = function () { + function Location(world, ref, orientation, playerState) { + _classCallCheck(this, Location); + + this.world = world; + this.ref = ref; + this.orientation = orientation; + this.playerState = playerState; + } + + _createClass(Location, [{ + key: 'allowEdgeExit', + value: function allowEdgeExit(edge) { + return true; + } + }, { + key: 'createLocation', + value: function createLocation(ref, orientation) { + return new Location(this.world, ref, orientation, this.playerState); + } + }, { + key: 'getExits', + value: function getExits() { + var _this4 = this; + + var exits = {}; + var processDirection = function processDirection(name, direction) { + var cornerRef = _this4.ref.getAdjacentCornerRef(direction); + var edgeRef = _this4.ref.getAdjacentEdgeRef(direction); + if (cornerRef.key() in _this4.world.corners) { + var edge = _this4.world.edges[edgeRef.key()]; + if (_this4.allowEdgeExit(edge)) { + exits[name] = _this4.createLocation(cornerRef, new Orientation(direction)); + } + } + }; + processDirection('left', this.orientation.getLeftEdgeDirection()); + processDirection('right', this.orientation.getRightEdgeDirection()); + processDirection('back', this.orientation.direction); + return exits; + } + }, { + key: 'getDescription', + value: function getDescription() { + var corner = this.world.corners[this.ref.key()]; + var description = ''; + if (corner.description) { + description += corner.description.render(this.orientation); + } else { + var frontTileRef = this.ref.getAdjacentTileRef(this.orientation.direction); + if (frontTileRef.key() in this.world.tiles) { + description += 'In front of you, you see ' + terrainName(this.world.tiles[frontTileRef.key()].terrain) + '.\n'; + } else { + description += 'The beach stretches out in front of you.\n'; + } + var leftTileRef = this.ref.getAdjacentTileRef(this.orientation.getLeftTileDirection()); + if (leftTileRef.key() in this.world.tiles) { + description += 'To your left, you see ' + terrainName(this.world.tiles[leftTileRef.key()].terrain) + '.\n'; + } else { + description += 'The beach stretches out to your left.\n'; + } + var rightTileRef = this.ref.getAdjacentTileRef(this.orientation.getRightTileDirection()); + if (rightTileRef.key() in this.world.tiles) { + description += 'To your right, you see ' + terrainName(this.world.tiles[rightTileRef.key()].terrain) + '.\n'; + } else { + description += 'The beach stretches out to your right.\n'; + } + var leftEdgeRef = this.ref.getAdjacentEdgeRef(this.orientation.getLeftEdgeDirection()); + if (leftEdgeRef.key() in this.world.edges) { + var owner = this.world.edges[leftEdgeRef.key()].owner; + if (owner !== undefined) { + description += 'There is a ' + ownerName(owner) + ' road ahead and to your left.\n'; + } + } + var rightEdgeRef = this.ref.getAdjacentEdgeRef(this.orientation.getRightEdgeDirection()); + if (rightEdgeRef.key() in this.world.edges) { + var owner = this.world.edges[rightEdgeRef.key()].owner; + if (owner !== undefined) { + description += 'There is a ' + ownerName(owner) + ' road ahead and to your right.\n'; + } + } + var backEdgeRef = this.ref.getAdjacentEdgeRef(this.orientation.direction); + if (backEdgeRef.key() in this.world.edges) { + var owner = this.world.edges[backEdgeRef.key()].owner; + if (owner !== undefined) { + description += 'There is a ' + ownerName(owner) + ' road behind you.\n'; + } + } + description = description.slice(0, description.length - 1); + } + return description; + } + }, { + key: 'getEntities', + value: function getEntities() { + return this.world.corners[this.ref.key()].getEntities(); + } + }, { + key: 'containsEntity', + value: function containsEntity(entity) { + return this.world.corners[this.ref.key()].containsEntity(entity); + } + }, { + key: 'addEntity', + value: function addEntity(entity) { + return this.world.corners[this.ref.key()].addEntity(entity); + } + }, { + key: 'removeEntity', + value: function removeEntity(entity) { + return this.world.corners[this.ref.key()].removeEntity(entity); + } + }, { + key: 'findEntity', + value: function findEntity(terms) { + return this.world.corners[this.ref.key()].findEntity(terms); + } + }]); + + return Location; +}(); + +exports.Location = Location; +function create() { + var playerState = new engine.PlayerState(); + var location = new Location(new World(), new CornerRef(3, -1, -2, 1), new Orientation(1), playerState); + playerState.location = location; + return playerState; +} +exports.create = create; + +/***/ }, +/* 4 */ +/***/ function(module, exports, __webpack_require__) { + +"use strict"; + + +module.exports = function (derivedCtor, baseCtors) { + baseCtors.forEach(function (baseCtor) { + Object.getOwnPropertyNames(baseCtor.prototype).forEach(function (name) { + derivedCtor.prototype[name] = baseCtor.prototype[name]; + }); + }); +}; + +/***/ }, +/* 5 */ +/***/ function(module, exports, __webpack_require__) { + +"use strict"; + + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +var wordwrap = module.exports = function (start, stop, params) { + if ((typeof start === 'undefined' ? 'undefined' : _typeof(start)) === 'object') { + params = start; + start = params.start; + stop = params.stop; + } + + if ((typeof stop === 'undefined' ? 'undefined' : _typeof(stop)) === 'object') { + params = stop; + start = start || params.start; + stop = undefined; + } + + if (!stop) { + stop = start; + start = 0; + } + + if (!params) params = {}; + var mode = params.mode || 'soft'; + var re = mode === 'hard' ? /\b/ : /(\S+\s+)/; + + return function (text) { + var chunks = text.toString().split(re).reduce(function (acc, x) { + if (mode === 'hard') { + for (var i = 0; i < x.length; i += stop - start) { + acc.push(x.slice(i, i + stop - start)); + } + } else acc.push(x); + return acc; + }, []); + + return chunks.reduce(function (lines, rawChunk) { + if (rawChunk === '') return lines; + + var chunk = rawChunk.replace(/\t/g, ' '); + + var i = lines.length - 1; + if (lines[i].length + chunk.length > stop) { + lines[i] = lines[i].replace(/\s+$/, ''); + + chunk.split(/\n/).forEach(function (c) { + lines.push(new Array(start + 1).join(' ') + c.replace(/^\s+/, '')); + }); + } else if (chunk.match(/\n/)) { + var xs = chunk.split(/\n/); + lines[i] += xs.shift(); + xs.forEach(function (c) { + lines.push(new Array(start + 1).join(' ') + c.replace(/^\s+/, '')); + }); + } else { + lines[i] += chunk; + } + + return lines; + }, [new Array(start + 1).join(' ')]).join('\n'); + }; +}; + +wordwrap.soft = wordwrap; + +wordwrap.hard = function (start, stop) { + return wordwrap(start, stop, { mode: 'hard' }); +}; + +/***/ }, +/* 6 */ +/***/ function(module, exports, __webpack_require__) { + +"use strict"; + + +var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _ = __webpack_require__(0); +var nlp = __webpack_require__(2); +var cw = __webpack_require__(3); +var engine = __webpack_require__(1); +var allEntityClasses = []; + +var PassportItem = function (_engine$Entity) { + _inherits(PassportItem, _engine$Entity); + + function PassportItem() { + var _ref; + + _classCallCheck(this, PassportItem); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var _this = _possibleConstructorReturn(this, (_ref = PassportItem.__proto__ || Object.getPrototypeOf(PassportItem)).call.apply(_ref, [this].concat(args))); + + _this.playerNightNums = [[17, 4, 27, 15], [26, 30, 26, 7], [11, 27, 8, 14], [13, 14, 1, 6], [3, 6, 14, 17], [15, 11, 26, 1], [20, 27, 12, 25], [12, 22, 5, 17], [16, 26, 17, 8], [21, 24, 9, 3], [19, 18, 16, 9], [10, 26, 9, 29], [26, 19, 12, 13], [18, 15, 11, 14], [21, 9, 26, 18], [2, 7, 22, 13], [17, 6, 19, 25], [22, 16, 13, 11], [26, 17, 8, 30], [10, 16, 29, 23], [25, 18, 12, 5], [16, 29, 27, 17], [1, 3, 10, 8], [27, 30, 29, 22], [20, 27, 25, 6], [12, 11, 5, 23], [26, 23, 15, 13], [21, 5, 19, 8], [5, 17, 16, 7], [16, 22, 10, 21], [29, 13, 7, 12], [12, 7, 6, 10], [17, 2, 17, 20], [26, 27, 10, 22], [7, 30, 9, 19], [16, 8, 1, 6], [21, 27, 19, 26], [13, 4, 3, 10], [19, 6, 20, 2], [30, 5, 1, 17], [18, 13, 10, 23], [17, 5, 7, 20], [26, 27, 10, 22], [4, 2, 5, 18], [4, 20, 13, 29], [17, 6, 25, 2], [10, 29, 29, 5], [30, 13, 15, 9], [22, 20, 23, 6], [21, 17, 1, 4], [26, 30, 26, 7], [13, 27, 14, 14], [15, 8, 13, 22], [4, 13, 16, 9], [30, 15, 23, 7], [5, 19, 12, 8], [21, 22, 18, 21], [29, 17, 14, 2]]; + _this.blue = true; + _this.orange = false; + _this.white = false; + _this.queen = false; + _this.description = function () { + var desc = 'It\'s a passport, granting you passage to other kingdoms.'; + desc += ' It\'s marked with the insignia of Crimsilon.'; + if (_this.blue) { + desc += ' It\'s marked with the insignia of Cerulia.'; + } + if (_this.orange) { + desc += ' It\'s marked with the insignia of Merrygold.'; + } + if (_this.white) { + desc += ' It\'s marked with the insignia of Blanc.'; + } + if (_this.queen) { + desc += ' The queen of Blanc added her own special markings.'; + } + if (_this.orange || _this.white || _this.queen) { + desc += ' On the back of the passport there\'s an interesting-looking grid, to which the characters you\'ve met have contributed:\n\n' + _this.renderGrid(_this.white, _this.queen); + } + return desc; + }; + return _this; + } + + _createClass(PassportItem, [{ + key: 'renderGrid', + value: function renderGrid(drawHeading, drawNightNumbers) { + var s = ''; + if (drawHeading) { + s += '| 1| 2| 3| 4|W|B|O|G|L|\n'; + } else { + s += '| | | | | | | | | |\n'; + } + s += '|--|--|--|--|-|-|-|-|-|\n'; + for (var i = 0; i < this.playerNightNums.length; i++) { + if (drawNightNumbers) { + var row = this.playerNightNums[i]; + s += '|' + (row[0] < 10 ? ' ' : '') + row[0] + '|' + (row[1] < 10 ? ' ' : '') + row[1] + '|' + (row[2] < 10 ? ' ' : '') + row[2] + '|' + (row[3] < 10 ? ' ' : '') + row[3] + '| | | | | |\n'; + } else { + s += '| | | | | | | | | |\n'; + } + } + return s; + } + }, { + key: 'renderHtml', + value: function renderHtml() { + var s = '
'; + s += 'CRIMSILON'; + if (this.blue) { + s += ' CERULIA'; + } + if (this.orange) { + s += ' MERRYGOLD'; + } + if (this.white) { + s += ' BLANC'; + } + if (this.orange || this.white || this.queen) { + s += ''; + s += ''; + if (this.white) { + s += ''; + s += ''; + s += ''; + s += ''; + s += ''; + s += ''; + s += ''; + s += ''; + s += ''; + } else { + s += ''; + s += ''; + s += ''; + s += ''; + s += ''; + s += ''; + s += ''; + s += ''; + s += ''; + } + s += ''; + for (var i = 0; i < this.playerNightNums.length; i++) { + s += ''; + if (this.queen) { + var row = this.playerNightNums[i]; + for (var j = 0; j < row.length; j++) { + s += ''; + } + } else { + s += ''; + } + for (var _j = 0; _j < 5; _j++) { + if (this.queen) { + s += ''; + } else { + s += ''; + } + } + s += ''; + } + s += '
1234WBOGL
' + row[j] + '
'; + } + s += '
'; + return s; + } + }]); + + return PassportItem; +}(engine.Entity); + +PassportItem.title = 'a passport'; +PassportItem.nouns = ['passport']; +PassportItem.description = ''; +PassportItem.droppable = false; +exports.PassportItem = PassportItem; +allEntityClasses.push(PassportItem); + +var StickerItem = function (_engine$Entity2) { + _inherits(StickerItem, _engine$Entity2); + + function StickerItem() { + _classCallCheck(this, StickerItem); + + return _possibleConstructorReturn(this, (StickerItem.__proto__ || Object.getPrototypeOf(StickerItem)).apply(this, arguments)); + } + + _createClass(StickerItem, [{ + key: 'use', + value: function use(playerState, parsedSentence) { + if (parsedSentence.secondaryEntity) { + return 'You\'re too afraid of affixation remorse to use the sticker with ' + parsedSentence.secondaryEntity.title() + '.'; + } + return 'You can\'t use a sticker by itself!'; + } + }]); + + return StickerItem; +}(engine.Entity); + +StickerItem.title = 'a sticker'; +StickerItem.nouns = ['sticker']; +StickerItem.description = 'It\'s shaped like a star, and says "LOOK UP!".'; +StickerItem.droppable = false; +StickerItem.verbs = _.extend({}, engine.Entity.verbs, { + 'apply': 'use', + 'stick': 'use', + 'use': 'use' +}); +allEntityClasses.push(StickerItem); + +var HexSign = function (_engine$Entity3) { + _inherits(HexSign, _engine$Entity3); + + function HexSign(text) { + _classCallCheck(this, HexSign); + + var _this3 = _possibleConstructorReturn(this, (HexSign.__proto__ || Object.getPrototypeOf(HexSign)).call(this)); + + _this3.description = function () { + return 'The sign reads: "' + _this3.text + '".'; + }; + _this3.text = text; + return _this3; + } + + return HexSign; +}(engine.Entity); + +HexSign.title = 'the sign'; +HexSign.nouns = ['sign']; +HexSign.description = ''; +HexSign.takeable = false; +HexSign.verbs = _.extend({}, engine.Entity.verbs, { + 'read': 'examine' +}); +allEntityClasses.push(HexSign); + +var NailsItem = function (_engine$Entity4) { + _inherits(NailsItem, _engine$Entity4); + + function NailsItem() { + _classCallCheck(this, NailsItem); + + var _this4 = _possibleConstructorReturn(this, (NailsItem.__proto__ || Object.getPrototypeOf(NailsItem)).call(this)); + + _this4.preTakeText = 'Some old rusty, sooty NAILS are scattered on the ground around the blacksmith\'s forge.'; + return _this4; + } + + return NailsItem; +}(engine.Entity); + +NailsItem.title = 'a bunch of rusty nails covered in soot'; +NailsItem.nouns = ['bunch', 'nails', 'soot']; +NailsItem.description = 'It\'s a handful of rusty iron nails that were discarded by the blacksmith. They\'re covered in soot from the blacksmith\'s forge.'; +allEntityClasses.push(NailsItem); + +var ButterItem = function (_engine$Entity5) { + _inherits(ButterItem, _engine$Entity5); + + function ButterItem() { + _classCallCheck(this, ButterItem); + + return _possibleConstructorReturn(this, (ButterItem.__proto__ || Object.getPrototypeOf(ButterItem)).apply(this, arguments)); + } + + _createClass(ButterItem, [{ + key: 'eat', + value: function eat(playerState, parsedSentence) { + return 'You taste the butter - it\'s delicious!'; + } + }, { + key: 'use', + value: function use(playerState, parsedSentence) { + var otherEntity = parsedSentence.secondaryEntity; + if (otherEntity instanceof CastleWindowEntity) { + otherEntity.squeaky = false; + playerState.inventory.removeEntity(this); + return 'You spread butter on the shutter\'s hinges.'; + } + return _get(ButterItem.prototype.__proto__ || Object.getPrototypeOf(ButterItem.prototype), 'use', this).call(this, playerState, parsedSentence); + } + }]); + + return ButterItem; +}(engine.Entity); + +ButterItem.title = 'a tub of butter'; +ButterItem.nouns = ['tub', 'butter']; +ButterItem.description = 'It\'s a small container of sheep\'s milk butter.'; +ButterItem.verbs = _.extend({}, engine.Entity.verbs, { + 'eat': 'eat', + 'taste': 'eat', + 'spread': 'use' +}); +allEntityClasses.push(ButterItem); + +var GryphonBeerItem = function (_engine$Entity6) { + _inherits(GryphonBeerItem, _engine$Entity6); + + function GryphonBeerItem() { + _classCallCheck(this, GryphonBeerItem); + + return _possibleConstructorReturn(this, (GryphonBeerItem.__proto__ || Object.getPrototypeOf(GryphonBeerItem)).apply(this, arguments)); + } + + _createClass(GryphonBeerItem, [{ + key: 'drink', + value: function drink(playerState, parsedSentence) { + return 'The liquid inside the bottle is bright green and looks pretty unfit for human consumption. You decide not to ' + parsedSentence.verb.root() + ' it.'; + } + }, { + key: 'use', + value: function use(playerState, parsedSentence) { + if (!parsedSentence.secondaryEntity) { + return this.drink(playerState, parsedSentence); + } + if (parsedSentence.secondaryEntity instanceof CastleChiffonierEntity) { + return this.pour(playerState, parsedSentence); + } + return _get(GryphonBeerItem.prototype.__proto__ || Object.getPrototypeOf(GryphonBeerItem.prototype), 'use', this).call(this, playerState, parsedSentence); + } + }, { + key: 'pour', + value: function pour(playerState, parsedSentence) { + var otherEntity = parsedSentence.secondaryEntity; + if (!otherEntity) { + return 'Where would you like to pour it?'; + } + if (otherEntity instanceof CastleChiffonierEntity) { + playerState.inventory.removeEntity(this); + otherEntity.locked = false; + return 'You pour the entire bottle of gryphon beer onto the dresser.\n\nThe metal and some of the wood start to dissolve, releasing acrid fumes.'; + } + return 'That would be a waste of perfectly good Gryphon Beer.'; + } + }]); + + return GryphonBeerItem; +}(engine.Entity); + +GryphonBeerItem.title = 'a bottle of gryphon beer'; +GryphonBeerItem.nouns = ['bottle', 'gryphon', 'beer']; +GryphonBeerItem.description = 'The label reads "Gryphon Beer: the only beer brewed by humans, for gryphons!". A toxic-looking green liquid is sloshing around inside.'; +GryphonBeerItem.verbs = _.extend({}, engine.Entity.verbs, { + 'drink': 'drink', + 'taste': 'drink', + 'pour': 'pour' +}); +allEntityClasses.push(GryphonBeerItem); + +var TiaraItem = function (_engine$Entity7) { + _inherits(TiaraItem, _engine$Entity7); + + function TiaraItem() { + _classCallCheck(this, TiaraItem); + + return _possibleConstructorReturn(this, (TiaraItem.__proto__ || Object.getPrototypeOf(TiaraItem)).apply(this, arguments)); + } + + _createClass(TiaraItem, [{ + key: 'wear', + value: function wear(playerState, parsedSentence) { + return 'You try on the tiara - very stylish!'; + } + }]); + + return TiaraItem; +}(engine.Entity); + +TiaraItem.title = 'a tiara'; +TiaraItem.nouns = ['tiara']; +TiaraItem.description = 'It\'s a serviceable plastic tiara.'; +TiaraItem.verbs = _.extend({}, engine.Entity.verbs, { + 'try on': 'wear', + 'wear': 'wear' +}); +allEntityClasses.push(TiaraItem); + +var CastleEntity = function (_engine$Entity8) { + _inherits(CastleEntity, _engine$Entity8); + + function CastleEntity() { + _classCallCheck(this, CastleEntity); + + return _possibleConstructorReturn(this, (CastleEntity.__proto__ || Object.getPrototypeOf(CastleEntity)).apply(this, arguments)); + } + + _createClass(CastleEntity, [{ + key: 'climb', + value: function climb(playerState, parsedSentence) { + if (playerState.nailBoots) { + playerState.returnLocation = playerState.location; + playerState.location = playerState.specialLocations[CastleWindowLocation.name]; + return 'The nails on your boots dig into the castle\'s stone walls, and you successfully climb up to a window.\n\n' + playerState.look(); + } + return 'You attempt to climb the castle wall, but your BOOTS slip on the stone and you slide back down.'; + } + }]); + + return CastleEntity; +}(engine.Entity); + +CastleEntity.title = 'the castle'; +CastleEntity.nouns = ['castle', 'wall']; +CastleEntity.description = 'The walls of the castle are made of large stones mortared together slightly irregularly. It looks like you could get ample fingerholds if you wanted to scale it, but there may not be enough purchase for your BOOTS.'; +CastleEntity.takeable = false; +CastleEntity.verbs = _.extend({}, engine.Entity.verbs, { + 'climb': 'climb', + 'climb up': 'climb', + 'scale': 'climb', + 'scale up': 'climb' +}); +allEntityClasses.push(CastleEntity); + +var CastleDoorEntity = function (_engine$Entity9) { + _inherits(CastleDoorEntity, _engine$Entity9); + + function CastleDoorEntity() { + _classCallCheck(this, CastleDoorEntity); + + return _possibleConstructorReturn(this, (CastleDoorEntity.__proto__ || Object.getPrototypeOf(CastleDoorEntity)).apply(this, arguments)); + } + + _createClass(CastleDoorEntity, [{ + key: 'open', + value: function open(playerState, parsedSentence) { + return 'Entering through the front door would not be particularly stealthy.'; + } + }]); + + return CastleDoorEntity; +}(engine.Entity); + +CastleDoorEntity.title = 'the castle door'; +CastleDoorEntity.nouns = ['door']; +CastleDoorEntity.description = 'The castle door is made of wood.'; +CastleDoorEntity.takeable = false; +CastleDoorEntity.verbs = _.extend({}, engine.Entity.verbs, { + 'open': 'open', + 'knock on': 'open', + 'use': 'open' +}); +allEntityClasses.push(CastleDoorEntity); + +var CastleWindowEntity = function (_engine$Entity10) { + _inherits(CastleWindowEntity, _engine$Entity10); + + function CastleWindowEntity() { + _classCallCheck(this, CastleWindowEntity); + + var _this10 = _possibleConstructorReturn(this, (CastleWindowEntity.__proto__ || Object.getPrototypeOf(CastleWindowEntity)).call(this)); + + _this10.squeaky = true; + return _this10; + } + + _createClass(CastleWindowEntity, [{ + key: 'open', + value: function open(playerState, parsedSentence) { + if (this.squeaky) { + playerState.location = playerState.returnLocation; + playerState.returnLocation = null; + return 'The hinges of the window shutters emit a loud squeal as you attempt to open them. You hear some rustling inside the castle, and quickly drop back down to the ground to avoid detection.\n\n' + playerState.look(); + } + playerState.location = playerState.specialLocations[CastleRoomLocation.name]; + return 'You open the shutters and climb inside through the window. The shutters swing shut behind you.\n\n' + playerState.look(); + } + }]); + + return CastleWindowEntity; +}(engine.Entity); + +CastleWindowEntity.title = 'the window shutters'; +CastleWindowEntity.nouns = ['window', 'shutter', 'hinge']; +CastleWindowEntity.description = 'The window has a heavy set of wooden shutters, which are closed tight.'; +CastleWindowEntity.takeable = false; +CastleWindowEntity.verbs = _.extend({}, engine.Entity.verbs, { + 'enter': 'open', + 'open': 'open' +}); +allEntityClasses.push(CastleWindowEntity); + +var InteriorCastleWindowEntity = function (_engine$Entity11) { + _inherits(InteriorCastleWindowEntity, _engine$Entity11); + + function InteriorCastleWindowEntity() { + _classCallCheck(this, InteriorCastleWindowEntity); + + return _possibleConstructorReturn(this, (InteriorCastleWindowEntity.__proto__ || Object.getPrototypeOf(InteriorCastleWindowEntity)).apply(this, arguments)); + } + + _createClass(InteriorCastleWindowEntity, [{ + key: 'open', + value: function open(playerState, parsedSentence) { + playerState.location = playerState.returnLocation; + playerState.returnLocation = null; + return 'You open the window shutters, and scramble back down the side of the castle.\n\n' + playerState.look(); + } + }]); + + return InteriorCastleWindowEntity; +}(engine.Entity); + +InteriorCastleWindowEntity.title = 'the window shutters'; +InteriorCastleWindowEntity.nouns = ['window', 'shutter']; +InteriorCastleWindowEntity.description = 'The window has a heavy set of wooden shutters, which are closed tight.'; +InteriorCastleWindowEntity.takeable = false; +InteriorCastleWindowEntity.verbs = _.extend({}, engine.Entity.verbs, { + 'open': 'open', + 'use': 'open' +}); +allEntityClasses.push(InteriorCastleWindowEntity); + +var CastleChiffonierEntity = function (_engine$Entity12) { + _inherits(CastleChiffonierEntity, _engine$Entity12); + + function CastleChiffonierEntity() { + _classCallCheck(this, CastleChiffonierEntity); + + var _this12 = _possibleConstructorReturn(this, (CastleChiffonierEntity.__proto__ || Object.getPrototypeOf(CastleChiffonierEntity)).call(this)); + + _this12.locked = true; + _this12.hasJewels = true; + _this12.description = function () { + if (_this12.locked) { + return 'The dresser is a tall, narrow and elegant chest of drawers.'; + } + return 'The dresser is a tall, narrow and formerly elegant chest of drawers that you\'ve partially melted with gryphon beer.'; + }; + _this12.locked = true; + _this12.hasJewels = true; + return _this12; + } + + _createClass(CastleChiffonierEntity, [{ + key: 'open', + value: function open(playerState, parsedSentence) { + if (this.locked) { + return 'You pull on the drawers of the dresser, but they seem to be locked.'; + } else if (this.hasJewels) { + this.hasJewels = false; + playerState.inventory.addEntity(new TiaraItem()); + return 'You pull open the top drawer of the dresser. Inside, there\'s a TIARA. You steal it.'; + } else { + return 'You look inside the top drawer of the dresser, but there\'s nothing of interest remaining in there.'; + } + } + }]); + + return CastleChiffonierEntity; +}(engine.Entity); + +CastleChiffonierEntity.title = 'the dresser'; +CastleChiffonierEntity.nouns = ['dresser', 'drawer']; +CastleChiffonierEntity.description = ''; +CastleChiffonierEntity.takeable = false; +CastleChiffonierEntity.verbs = _.extend({}, engine.Entity.verbs, { + 'open': 'open' +}); +allEntityClasses.push(CastleChiffonierEntity); + +var CastleWindowLocation = function () { + function CastleWindowLocation(playerState) { + _classCallCheck(this, CastleWindowLocation); + + this.playerState = playerState; + this.entityContainer = new engine.EntityContainerMixin(); + this.entityContainer.addEntity(new CastleWindowEntity()); + } + + _createClass(CastleWindowLocation, [{ + key: 'getDescription', + value: function getDescription() { + return 'You\'re up on the window sill. The wooden WINDOW SHUTTERS are closed, and you can\'t see inside.'; + } + }, { + key: 'getExits', + value: function getExits() { + return { 'down': this.playerState.returnLocation }; + } + }, { + key: 'getEntities', + value: function getEntities() { + return this.entityContainer.getEntities(); + } + }, { + key: 'containsEntity', + value: function containsEntity(entity) { + return this.entityContainer.containsEntity(entity); + } + }, { + key: 'addEntity', + value: function addEntity(entity) { + this.playerState.returnLocation.addEntity(entity); + } + }, { + key: 'removeEntity', + value: function removeEntity(entity) { + return false; + } + }, { + key: 'findEntity', + value: function findEntity(terms) { + return this.entityContainer.findEntity(terms); + } + }]); + + return CastleWindowLocation; +}(); + +var SlapItem = function (_engine$Entity13) { + _inherits(SlapItem, _engine$Entity13); + + function SlapItem() { + _classCallCheck(this, SlapItem); + + return _possibleConstructorReturn(this, (SlapItem.__proto__ || Object.getPrototypeOf(SlapItem)).apply(this, arguments)); + } + + _createClass(SlapItem, [{ + key: 'use', + value: function use(playerState, parsedSentence) { + if (!parsedSentence.secondaryEntity) { + return 'You slap at the air, but it offers unsatisfyingly little resistance.'; + } + if (parsedSentence.secondaryEntity instanceof Lumberjack) { + return parsedSentence.secondaryEntity.giveTo(playerState, this); + } + return _get(SlapItem.prototype.__proto__ || Object.getPrototypeOf(SlapItem.prototype), 'use', this).call(this, playerState, parsedSentence); + } + }]); + + return SlapItem; +}(engine.Entity); + +SlapItem.title = 'a slap technique'; +SlapItem.nouns = ['slap', 'technique']; +SlapItem.description = 'Slappity slap slap.'; +allEntityClasses.push(SlapItem); + +var Emma = function (_engine$NpcEntity) { + _inherits(Emma, _engine$NpcEntity); + + function Emma() { + var _ref2; + + _classCallCheck(this, Emma); + + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + var _this14 = _possibleConstructorReturn(this, (_ref2 = Emma.__proto__ || Object.getPrototypeOf(Emma)).call.apply(_ref2, [this].concat(args))); + + _this14.hasClap = false; + return _this14; + } + + _createClass(Emma, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + if (!this.hasClap) { + return '"Hi, who are you, and how did you get up to my window? You know what\'s weird? Someone climbed through my window just the other day, melted my dresser, and stole my tiara. Who does that?\n\nSorry, I\'m being rude. My name is Emma and I\'m a bioengineer first and princess second. I\'m in the market for a particularly virulent strain of an STI-causing bacterium for...reasons. And before you get any weird ideas, I\'m accepting in vitro samples only. Weirdo. Anyhow, if you can find that for me I\'ll give you what you deserve."'; + } + return '"You again? Get out of my room!"'; + } + }, { + key: 'giveTo', + value: function giveTo(playerState, item) { + if (item instanceof VialItem) { + this.hasClap = true; + playerState.location.removeEntity(item); + playerState.inventory.removeEntity(item); + playerState.inventory.addEntity(new SlapItem()); + playerState.location = playerState.returnLocation; + playerState.returnLocation = null; + return 'She pops the vial under a microscope and noodles around with it for a few minutes before nodding. Emma walks back over to you, and slaps you hard across the face. You fall back out of the window, but land uninjured in a convenient bale of hay.\n\nEmma sticks her head out of her window and shouts down to you, "That one\'s for melting my furniture! Don\'t come back here. Oh, and thanks for the Clap!" She slams her window. Some farmers who happen to be passing by at just that minute look at you and slowly shake their heads.\n\nYou\'ll remember that SLAP for a good long while. In fact, you now have a great SLAP technique you can use anytime.\n\nAs you recover from the SLAP, you re-orient yourself.\n\n' + playerState.look(); + } + return _get(Emma.prototype.__proto__ || Object.getPrototypeOf(Emma.prototype), 'giveTo', this).call(this, playerState, item); + } + }]); + + return Emma; +}(engine.NpcEntity); + +Emma.title = 'the beautiful princess'; +Emma.nouns = ['beautiful', 'princess', 'emma']; +Emma.description = 'Standing on the other side of the room is a beautiful PRINCESS. She\'s wearing a lab coat and goggles, and has beakers of bubbly liquids all over the place.'; +Emma.takeable = false; +allEntityClasses.push(Emma); + +var CastleRoomLocation = function (_engine$EntityContain) { + _inherits(CastleRoomLocation, _engine$EntityContain); + + function CastleRoomLocation(playerState) { + _classCallCheck(this, CastleRoomLocation); + + var _this15 = _possibleConstructorReturn(this, (CastleRoomLocation.__proto__ || Object.getPrototypeOf(CastleRoomLocation)).call(this)); + + _this15.playerState = playerState; + _this15.addEntity(new InteriorCastleWindowEntity()); + _this15.addEntity(new CastleChiffonierEntity()); + return _this15; + } + + _createClass(CastleRoomLocation, [{ + key: 'getDescription', + value: function getDescription() { + return 'You\'re inside of an upstairs bedroom of the castle. There\'s a DRESSER against the wall.'; + } + }, { + key: 'getExits', + value: function getExits() { + return { 'out the window': this.playerState.returnLocation }; + } + }, { + key: 'runTrimmedCommand', + value: function runTrimmedCommand(trimmedCommand) { + var match = trimmedCommand.match(/^((climb|go) out.*|exit.*|leave.*)/); + if (match) { + this.playerState.location = this.playerState.returnLocation; + this.playerState.returnLocation = null; + return 'You open the window shutters, and scramble back down the side of the castle. You re-orient yourself.\n\n' + this.playerState.look(); + } + return undefined; + } + }]); + + return CastleRoomLocation; +}(engine.EntityContainerMixin); + +var AutoShopEntity = function (_engine$Entity14) { + _inherits(AutoShopEntity, _engine$Entity14); + + function AutoShopEntity() { + _classCallCheck(this, AutoShopEntity); + + return _possibleConstructorReturn(this, (AutoShopEntity.__proto__ || Object.getPrototypeOf(AutoShopEntity)).apply(this, arguments)); + } + + _createClass(AutoShopEntity, [{ + key: 'enter', + value: function enter(playerState, parsedSentence) { + return 'No need to go inside - the garage door is open, you can see the contents of the shop from here.'; + } + }]); + + return AutoShopEntity; +}(engine.Entity); + +AutoShopEntity.title = 'the auto shop'; +AutoShopEntity.nouns = ['auto', 'shop']; +AutoShopEntity.description = 'The auto shop is oddly devoid of automobiles. The walls, however, are covered in accessories you never knew cars needed. Chains, spears, machine guns, skulls, and one pair of fuzzy dice. A few mechanic\'s tools are scattered around, including a welding torch, a HYDRAULIC LIFT, and a paint detailer. There\'s a HEAP of wood and plastic in the corner.'; +AutoShopEntity.takeable = false; +AutoShopEntity.verbs = _.extend({}, engine.Entity.verbs, { + 'enter': 'enter', + 'go in': 'enter', + 'go into': 'enter', + 'look in': 'examine', + 'look into': 'examine' +}); +allEntityClasses.push(AutoShopEntity); + +var HydraulicLiftEntity = function (_engine$Entity15) { + _inherits(HydraulicLiftEntity, _engine$Entity15); + + function HydraulicLiftEntity() { + var _ref3; + + _classCallCheck(this, HydraulicLiftEntity); + + for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } + + var _this17 = _possibleConstructorReturn(this, (_ref3 = HydraulicLiftEntity.__proto__ || Object.getPrototypeOf(HydraulicLiftEntity)).call.apply(_ref3, [this].concat(args))); + + _this17.entityOnLift = null; + _this17.title = function () { + var staticTitle = 'a hydraulic lift'; + if (_this17.entityOnLift) { + return staticTitle + ' holding ' + _this17.entityOnLift.title(); + } + return staticTitle; + }; + _this17.description = function () { + var staticDescription = 'It\'s a hydraulic lift, useful for working around and under vehicles.'; + if (!_this17.entityOnLift) { + return staticDescription + ' It\'s currently empty.'; + } + return staticDescription + (' It\'s currently holding ' + _this17.entityOnLift.allCapsTitle() + '.'); + }; + _this17.nouns = function () { + var liftNouns = Object.getPrototypeOf(_this17).constructor.nouns; + if (_this17.entityOnLift) { + return liftNouns.concat(_this17.entityOnLift.nouns()); + } + return liftNouns; + }; + return _this17; + } + + _createClass(HydraulicLiftEntity, [{ + key: 'take', + value: function take(playerState, parsedSentence) { + if (!this.entityOnLift) { + return 'There\'s nothing to take from the hydraulic lift.'; + } + var response = 'You take ' + this.entityOnLift.title() + ' down from the hydraulic lift.'; + playerState.inventory.addEntity(this.entityOnLift); + this.entityOnLift = null; + return response; + } + }, { + key: 'use', + value: function use(playerState, parsedSentence) { + if (this.entityOnLift) { + return this.take(playerState, parsedSentence); + } + return 'You better not use the hydraulic lift yourself, it looks like a complex piece of equipment. Maybe the mechanic can do it for you.'; + } + }]); + + return HydraulicLiftEntity; +}(engine.Entity); + +HydraulicLiftEntity.title = ''; +HydraulicLiftEntity.nouns = ['hydraulic', 'lift']; +HydraulicLiftEntity.description = ''; +HydraulicLiftEntity.takeable = false; +allEntityClasses.push(HydraulicLiftEntity); + +var HeapOfWoodAndPlasticEntity = function (_engine$Entity16) { + _inherits(HeapOfWoodAndPlasticEntity, _engine$Entity16); + + function HeapOfWoodAndPlasticEntity() { + var _ref4; + + _classCallCheck(this, HeapOfWoodAndPlasticEntity); + + for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { + args[_key4] = arguments[_key4]; + } + + var _this18 = _possibleConstructorReturn(this, (_ref4 = HeapOfWoodAndPlasticEntity.__proto__ || Object.getPrototypeOf(HeapOfWoodAndPlasticEntity)).call.apply(_ref4, [this].concat(args))); + + _this18.hasRudder = true; + _this18.description = function () { + if (_this18.hasRudder) { + return 'The heap of wood and plastic is barely recognizable as the remains of a sailboat. It\'s down to just a few isolated piece of wood, plastic, and the RUDDER.'; + } + return 'The heap of wood and plastic is barely recognizable as the remains of a sailboat. It\'s down to just a few isolated piece of wood and plastic.'; + }; + return _this18; + } + + _createClass(HeapOfWoodAndPlasticEntity, [{ + key: 'take', + value: function take(playerState, parsedSentence) { + return 'The mechanic pipes up, "Sorry, I\'d actually like to keep that particular bit of scrap."'; + } + }]); + + return HeapOfWoodAndPlasticEntity; +}(engine.Entity); + +HeapOfWoodAndPlasticEntity.title = 'a heap of wood and plastic'; +HeapOfWoodAndPlasticEntity.nouns = ['heap', 'wood', 'plastic', 'sailboat']; +HeapOfWoodAndPlasticEntity.description = ''; +HeapOfWoodAndPlasticEntity.takeable = false; +allEntityClasses.push(HeapOfWoodAndPlasticEntity); + +var RudderItem = function (_engine$Entity17) { + _inherits(RudderItem, _engine$Entity17); + + function RudderItem() { + var _ref5; + + _classCallCheck(this, RudderItem); + + for (var _len5 = arguments.length, args = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { + args[_key5] = arguments[_key5]; + } + + var _this19 = _possibleConstructorReturn(this, (_ref5 = RudderItem.__proto__ || Object.getPrototypeOf(RudderItem)).call.apply(_ref5, [this].concat(args))); + + _this19.inHeap = true; + _this19.takeable = function () { + return !_this19.inHeap; + }; + return _this19; + } + + _createClass(RudderItem, [{ + key: 'take', + value: function take(playerState, parsedSentence) { + if (this.inHeap) { + this.inHeap = false; + var heap = _.find(playerState.location.getEntities(), function (entity) { + return entity instanceof HeapOfWoodAndPlasticEntity; + }); + heap.hasRudder = false; + playerState.location.removeEntity(this); + playerState.inventory.addEntity(this); + return 'The mechanic pipes up, "Sure, you can have the rudder - I don\'t need it." He gives you the rudder.'; + } + return _get(RudderItem.prototype.__proto__ || Object.getPrototypeOf(RudderItem.prototype), 'take', this).call(this, playerState, parsedSentence); + } + }, { + key: 'use', + value: function use(playerState, parsedSentence) { + if (parsedSentence.secondaryEntity instanceof SurfboardItem) { + return 'You try to jam the rudder onto the surfboard, but you lack the expertise or equipment to make it stick. Perhaps a mechanic could help you with that.'; + } + return _get(RudderItem.prototype.__proto__ || Object.getPrototypeOf(RudderItem.prototype), 'use', this).call(this, playerState, parsedSentence); + } + }]); + + return RudderItem; +}(engine.Entity); + +RudderItem.title = 'a rudder'; +RudderItem.nouns = ['rudder']; +RudderItem.description = 'It\'s the rudder from the mechanic\'s wrecked sailboat.'; +allEntityClasses.push(RudderItem); + +var SeatItem = function (_engine$Entity18) { + _inherits(SeatItem, _engine$Entity18); + + function SeatItem() { + _classCallCheck(this, SeatItem); + + return _possibleConstructorReturn(this, (SeatItem.__proto__ || Object.getPrototypeOf(SeatItem)).apply(this, arguments)); + } + + return SeatItem; +}(engine.Entity); + +SeatItem.title = 'a car seat'; +SeatItem.nouns = ['car', 'seat']; +SeatItem.description = 'It\'s a car seat that was scavenged from a vehicle.'; +allEntityClasses.push(SeatItem); + +var AutoMechanic = function (_engine$NpcEntity2) { + _inherits(AutoMechanic, _engine$NpcEntity2); + + function AutoMechanic() { + var _ref6; + + _classCallCheck(this, AutoMechanic); + + for (var _len6 = arguments.length, args = Array(_len6), _key6 = 0; _key6 < _len6; _key6++) { + args[_key6] = arguments[_key6]; + } + + var _this21 = _possibleConstructorReturn(this, (_ref6 = AutoMechanic.__proto__ || Object.getPrototypeOf(AutoMechanic)).call.apply(_ref6, [this].concat(args))); + + _this21.hasSeat = true; + _this21.isClean = false; + _this21.description = function () { + if (_this21.isClean) { + return 'A squeaky clean MECHANIC works in front of the auto shop.'; + } else { + return 'A MECHANIC works in front of the auto shop, oozing so much grease that he leaves a trail wherever he goes.'; + } + }; + return _this21; + } + + _createClass(AutoMechanic, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + var passport = _.find(playerState.inventory.getEntities(), function (entity) { + return entity instanceof PassportItem; + }); + if (passport && passport.orange) { + if (this.hasSeat) { + return '"You again. What is it now? Hey, you still building that weird sailboat rocket thing? I just scavenged this neat car SEAT. I think it\'s from a schoolbus or something. Pretty cool, right? It\'s pretty great, but I\'ll give it to you if you can bring me some supplies. My latest to-scale ship-in-a-bottle\'s almost done. I need a spare strip of wood to fill in a gap. No more mooching off my good graces for you. It\'s strictly tit-for-tat from here on out."'; + } else { + return '"I haven\'t got any more fun parts for you right now, sorry."'; + } + } + return '"Hey, I\'m Desmond. So, I\'m guessing you\'re here like all of the others to look for the missing king. I\'m sorry to say that all of our search and rescue vehicles are currently out in the desert. All I\'ve got left are the remains of a sailboat that I\'m in the process of stripping for parts, over there in the corner. You can take anything I don\'t need for my lifesize ship-in-a-bottle hobby."'; + } + }, { + key: 'giveTo', + value: function giveTo(playerState, item) { + var hydraulicLift = _.find(playerState.location.getEntities(), function (entity) { + return entity instanceof HydraulicLiftEntity; + }); + if (item instanceof SteerableSurfboardItem) { + playerState.location.removeEntity(item); + playerState.inventory.removeEntity(item); + if (hydraulicLift.entityOnLift) { + playerState.location.addEntity(hydraulicLift.entityOnLift); + } + hydraulicLift.entityOnLift = item; + return '"Need some more modifications? I\'ll just throw that up here on the lift. Bring me anything else you\'d like to add to it."'; + } + if (item instanceof SurfboardItem) { + playerState.location.removeEntity(item); + playerState.inventory.removeEntity(item); + if (hydraulicLift.entityOnLift) { + playerState.location.addEntity(hydraulicLift.entityOnLift); + } + hydraulicLift.entityOnLift = item; + return '"Hmm, nice looking board. I like the fish decal. I\'ll just throw it up here on the lift. If you find anything you want to use to pimp your ride, bring it to me."'; + } + if (item instanceof RudderItem) { + if (hydraulicLift.entityOnLift instanceof SurfboardItem) { + playerState.location.removeEntity(item); + playerState.inventory.removeEntity(item); + hydraulicLift.entityOnLift = new SteerableSurfboardItem(); + return '"Ah, glad you found a use for this old thing. I\'ll just weld it onto your board. Welding works with all sorts of materials, you know."\n\nHe welds the rudder onto your surfboard. It\'s now a steerable board!'; + } + return '"That looks like a useful part for a vehicle, but I\'m not sure what you\'d like me to do with it right now. You should hold on to it for now."'; + } + if (item instanceof CedarLogItem) { + if (hydraulicLift.entityOnLift instanceof SteerableSurfboardItem) { + playerState.location.removeEntity(item); + playerState.inventory.removeEntity(item); + hydraulicLift.entityOnLift = new MastSurfboardItem(); + return '"Hmm, yeah, this\'ll work."\n\nHe welds it onto your surfboard. Like he said, his welding torch seems to work on all sorts of materials. Your board now has a mast!'; + } + return '"That looks like a useful part for a vehicle, but I\'m not sure what you\'d like me to do with it right now. You should hold on to it for now."'; + } + if (item instanceof TarpItem) { + return '"Yeah, I\'m not so sure I can work with this. The material\'s fine, but the shape is a bit unwieldy. If you can cut it down to size, I think I\'ll be able to work with it."'; + } + if (item instanceof TriangleTarpItem) { + if (hydraulicLift.entityOnLift instanceof MastSurfboardItem) { + playerState.location.removeEntity(item); + playerState.inventory.removeEntity(item); + hydraulicLift.entityOnLift = new SailSurfboardItem(); + return 'Nice. He welds it onto the mast. Your board now has a sail!'; + } + return '"That looks like a useful part for a vehicle, but I\'m not sure what you\'d like me to do with it right now. You should hold on to it for now."'; + } + if (item instanceof FabricScrapItem) { + this.isClean = true; + playerState.location.removeEntity(item); + playerState.inventory.removeEntity(item); + playerState.inventory.addEntity(new GreasyClothItem()); + return 'He sops grease off himself and hands the cloth back to you. He\'s now squeaky clean! And you have a grease-soaked cloth.'; + } + if (item instanceof MotorcycleEngineItem) { + if (!(item instanceof ConeMotorcycleEngineItem)) { + return '"This thing\'s no good. It\'ll never give you any meaningful amount of thrust looking like that. Bring me back something with a better nozzle, and I\'ll see what I can do."'; + } + var motorcycleEngineItem = item; + if (motorcycleEngineItem.hasAlcohol) { + return 'He looks it over, and peeks in the fuel tank. "Looks like it\'s full of high-proof alcohol, not engine fuel. Bring it back once it\'s properly fueled up."'; + } + if (!motorcycleEngineItem.hasFuel) { + return '"This looks good, but I think we should wait until you manage to get fuel in this thing."'; + } + if (hydraulicLift.entityOnLift instanceof SailSurfboardItem) { + playerState.location.removeEntity(item); + playerState.inventory.removeEntity(item); + hydraulicLift.entityOnLift = new RocketSurfboardItem(); + return '"This looks good."\n\nHe welds it onto the back of your board. Your board is now a rocket powered surfboard sailboat!'; + } + return '"That part looks ready to go, but we\'ll need to put something up on the lift first to weld it to."'; + } + if (item instanceof SlatItem) { + playerState.location.removeEntity(item); + playerState.inventory.removeEntity(item); + playerState.inventory.addEntity(new SeatItem()); + this.hasSeat = false; + return '"Is this cherry wood or something? I like it. You can grab the SEAT on your way out. And don\'t come back anymore unless you want me to do some work on something cool, like a tank or a motorbike or something."\n\nYou take the SEAT.'; + } + return _get(AutoMechanic.prototype.__proto__ || Object.getPrototypeOf(AutoMechanic.prototype), 'giveTo', this).call(this, playerState, item); + } + }]); + + return AutoMechanic; +}(engine.NpcEntity); + +AutoMechanic.title = 'the mechanic'; +AutoMechanic.nouns = ['mechanic', 'desmond']; +AutoMechanic.description = ''; +AutoMechanic.takeable = false; +allEntityClasses.push(AutoMechanic); + +var DesertTrailHeadEntity = function (_engine$Entity19) { + _inherits(DesertTrailHeadEntity, _engine$Entity19); + + function DesertTrailHeadEntity() { + _classCallCheck(this, DesertTrailHeadEntity); + + return _possibleConstructorReturn(this, (DesertTrailHeadEntity.__proto__ || Object.getPrototypeOf(DesertTrailHeadEntity)).apply(this, arguments)); + } + + _createClass(DesertTrailHeadEntity, [{ + key: 'enter', + value: function enter(playerState, parsedSentence) { + return 'Have you looked at this trail? Taking it would be suicide without some mode of conveyance, and a way to steer it.'; + } + }]); + + return DesertTrailHeadEntity; +}(engine.Entity); + +DesertTrailHeadEntity.title = 'the desert trail head'; +DesertTrailHeadEntity.nouns = ['desert', 'trail', 'trailhead', 'trail-head', 'head']; +DesertTrailHeadEntity.description = 'There\'s a trail that leads off into the desert. The trail goes about 15 feet before a near vertical plunge off the crest of the tallest SAND DUNE you\'ve ever seen. The dune is covered in barn-sized rocks. You can see something glinting at the bottom of the dune, far below you.'; +DesertTrailHeadEntity.takeable = false; +DesertTrailHeadEntity.verbs = _.extend({}, engine.Entity.verbs, { + 'enter': 'enter', + 'go to': 'enter', + 'take': 'enter', + 'use': 'enter' +}); +allEntityClasses.push(DesertTrailHeadEntity); + +var SandDuneEntity = function (_engine$Entity20) { + _inherits(SandDuneEntity, _engine$Entity20); + + function SandDuneEntity() { + _classCallCheck(this, SandDuneEntity); + + return _possibleConstructorReturn(this, (SandDuneEntity.__proto__ || Object.getPrototypeOf(SandDuneEntity)).apply(this, arguments)); + } + + _createClass(SandDuneEntity, [{ + key: 'slide', + value: function slide(playerState, parsedSentence) { + return 'Sliding down the sand dune would be suicide without some mode of conveyance, and a way to steer it. The sand here is very hard.'; + } + }]); + + return SandDuneEntity; +}(engine.Entity); + +SandDuneEntity.title = 'the sand dune'; +SandDuneEntity.nouns = ['sand', 'dune', 'boulders']; +SandDuneEntity.description = 'It\'s a giant sandy dune. At least 150 feet tall. It\'s covered in barn-sized rocks. You can see something glinting at the bottom of it.'; +SandDuneEntity.takeable = false; +SandDuneEntity.verbs = _.extend({}, engine.Entity.verbs, { + 'slide': 'slide', + 'slide down': 'slide', + 'go down': 'slide', + 'go to': 'slide' +}); +allEntityClasses.push(SandDuneEntity); + +var GlintEntity = function (_engine$Entity21) { + _inherits(GlintEntity, _engine$Entity21); + + function GlintEntity() { + _classCallCheck(this, GlintEntity); + + return _possibleConstructorReturn(this, (GlintEntity.__proto__ || Object.getPrototypeOf(GlintEntity)).apply(this, arguments)); + } + + return GlintEntity; +}(engine.Entity); + +GlintEntity.title = 'the glint at the bottom of the sand dune'; +GlintEntity.nouns = ['glint', 'glinting']; +GlintEntity.description = 'It\'s impossible to make out what it is from the top of the dune; you\'ll have to get closer.'; +GlintEntity.takeable = false; +allEntityClasses.push(GlintEntity); + +var BoulderEntity = function (_engine$Entity22) { + _inherits(BoulderEntity, _engine$Entity22); + + function BoulderEntity() { + _classCallCheck(this, BoulderEntity); + + return _possibleConstructorReturn(this, (BoulderEntity.__proto__ || Object.getPrototypeOf(BoulderEntity)).apply(this, arguments)); + } + + _createClass(BoulderEntity, [{ + key: 'push', + value: function push(playerState, parsedSentence) { + return 'It doesn\'t move.'; + } + }]); + + return BoulderEntity; +}(engine.Entity); + +BoulderEntity.title = 'a large boulder'; +BoulderEntity.nouns = ['boulder']; +BoulderEntity.description = 'It\'s a big rock. You don\'t notice anything special about it.'; +BoulderEntity.takeable = false; +BoulderEntity.verbs = _.extend({}, engine.Entity.verbs, { + 'lift': 'push', + 'move': 'push', + 'push': 'push', + 'shove': 'push' +}); +allEntityClasses.push(BoulderEntity); + +var FlowersItem = function (_engine$Entity23) { + _inherits(FlowersItem, _engine$Entity23); + + function FlowersItem() { + _classCallCheck(this, FlowersItem); + + var _this26 = _possibleConstructorReturn(this, (FlowersItem.__proto__ || Object.getPrototypeOf(FlowersItem)).call(this)); + + _this26.taken = false; + _this26.description = function () { + if (_this26.taken) { + return 'It\'s a handful of little purple flowers, picked from the desert.'; + } else { + return 'They\'re nice little purple desert flowers. The shade from a nearby rock must keep them from drying out in the sun.'; + } + }; + _this26.preTakeText = 'There\'s a patch of little purple FLOWERS growing in the shadow of a large rock.'; + return _this26; + } + + _createClass(FlowersItem, [{ + key: 'take', + value: function take(playerState, parsedSentence) { + this.taken = true; + return _get(FlowersItem.prototype.__proto__ || Object.getPrototypeOf(FlowersItem.prototype), 'take', this).call(this, playerState, parsedSentence); + } + }]); + + return FlowersItem; +}(engine.Entity); + +FlowersItem.title = 'a handful of little purple flowers'; +FlowersItem.nouns = ['purple', 'flowers']; +FlowersItem.description = ''; +FlowersItem.verbs = _.extend({}, engine.Entity.verbs, { + 'pick': 'take' +}); +allEntityClasses.push(FlowersItem); + +var BottomOfDuneHatchEntity = function (_engine$Entity24) { + _inherits(BottomOfDuneHatchEntity, _engine$Entity24); + + function BottomOfDuneHatchEntity() { + _classCallCheck(this, BottomOfDuneHatchEntity); + + return _possibleConstructorReturn(this, (BottomOfDuneHatchEntity.__proto__ || Object.getPrototypeOf(BottomOfDuneHatchEntity)).apply(this, arguments)); + } + + return BottomOfDuneHatchEntity; +}(engine.Entity); + +BottomOfDuneHatchEntity.title = 'a hatch'; +BottomOfDuneHatchEntity.nouns = ['hatch']; +BottomOfDuneHatchEntity.description = 'It\'s a small openable panel in the side of the sand dune.'; +BottomOfDuneHatchEntity.takeable = false; +allEntityClasses.push(BottomOfDuneHatchEntity); + +var BottomOfDuneVehiclesEntity = function (_engine$Entity25) { + _inherits(BottomOfDuneVehiclesEntity, _engine$Entity25); + + function BottomOfDuneVehiclesEntity() { + _classCallCheck(this, BottomOfDuneVehiclesEntity); + + var _this28 = _possibleConstructorReturn(this, (BottomOfDuneVehiclesEntity.__proto__ || Object.getPrototypeOf(BottomOfDuneVehiclesEntity)).call(this)); + + _this28.description = function () { + var text = 'These must be the remains of the search and rescue vehicles. There\'s a lot of scrap metal that doesn\'t interest you much - most of it is twisted and battered beyond repair. '; + if (_this28.hasHubcap && _this28.hasTarp) { + text += 'The only things that look salvageable are a HUBCAP and a TARP.'; + } else if (_this28.hasHubcap) { + text += 'The only thing that looks salvageable is a HUBCAP.'; + } else if (_this28.hasTarp) { + text += 'The only thing that looks salvageable is a TARP.'; + } else { + text += 'Nothing salvageable remains in the pile.'; + } + return text; + }; + _this28.hasHubcap = true; + _this28.hasTarp = true; + return _this28; + } + + return BottomOfDuneVehiclesEntity; +}(engine.Entity); + +BottomOfDuneVehiclesEntity.title = 'a pile of what looks like about 10 battered vehicles'; +BottomOfDuneVehiclesEntity.nouns = ['vehicles']; +BottomOfDuneVehiclesEntity.description = ''; +BottomOfDuneVehiclesEntity.takeable = false; +allEntityClasses.push(BottomOfDuneVehiclesEntity); + +var MetalEntity = function (_engine$Entity26) { + _inherits(MetalEntity, _engine$Entity26); + + function MetalEntity() { + _classCallCheck(this, MetalEntity); + + return _possibleConstructorReturn(this, (MetalEntity.__proto__ || Object.getPrototypeOf(MetalEntity)).apply(this, arguments)); + } + + return MetalEntity; +}(engine.Entity); + +var HubcapItem = function (_MetalEntity) { + _inherits(HubcapItem, _MetalEntity); + + function HubcapItem() { + _classCallCheck(this, HubcapItem); + + return _possibleConstructorReturn(this, (HubcapItem.__proto__ || Object.getPrototypeOf(HubcapItem)).apply(this, arguments)); + } + + return HubcapItem; +}(MetalEntity); + +var UnshapedHubcapItem = function (_HubcapItem) { + _inherits(UnshapedHubcapItem, _HubcapItem); + + function UnshapedHubcapItem() { + var _ref7; + + _classCallCheck(this, UnshapedHubcapItem); + + for (var _len7 = arguments.length, args = Array(_len7), _key7 = 0; _key7 < _len7; _key7++) { + args[_key7] = arguments[_key7]; + } + + var _this31 = _possibleConstructorReturn(this, (_ref7 = UnshapedHubcapItem.__proto__ || Object.getPrototypeOf(UnshapedHubcapItem)).call.apply(_ref7, [this].concat(args))); + + _this31.inPile = true; + _this31.takeable = function () { + return !_this31.inPile; + }; + return _this31; + } + + _createClass(UnshapedHubcapItem, [{ + key: 'take', + value: function take(playerState, parsedSentence) { + if (this.inPile) { + this.inPile = false; + var pile = _.find(playerState.location.getEntities(), function (entity) { + return entity instanceof BottomOfDuneVehiclesEntity; + }); + pile.hasHubcap = false; + } + return _get(UnshapedHubcapItem.prototype.__proto__ || Object.getPrototypeOf(UnshapedHubcapItem.prototype), 'take', this).call(this, playerState, parsedSentence); + } + }]); + + return UnshapedHubcapItem; +}(HubcapItem); + +UnshapedHubcapItem.title = 'a hubcap'; +UnshapedHubcapItem.nouns = ['hubcap']; +UnshapedHubcapItem.description = 'It\'s a thin, circular piece of metal, used to cap a hub.'; +allEntityClasses.push(UnshapedHubcapItem); + +var TriangleHubcapItem = function (_HubcapItem2) { + _inherits(TriangleHubcapItem, _HubcapItem2); + + function TriangleHubcapItem() { + _classCallCheck(this, TriangleHubcapItem); + + return _possibleConstructorReturn(this, (TriangleHubcapItem.__proto__ || Object.getPrototypeOf(TriangleHubcapItem)).apply(this, arguments)); + } + + return TriangleHubcapItem; +}(HubcapItem); + +TriangleHubcapItem.title = 'a hubcap hammered into a triangle shape'; +TriangleHubcapItem.nouns = ['hubcap', 'triangle']; +TriangleHubcapItem.description = 'It\'s a thin, flat piece of metal. It used to be a hubcap, but now it\'s been pounded into a triangle shape.'; +allEntityClasses.push(TriangleHubcapItem); + +var SquareHubcapItem = function (_HubcapItem3) { + _inherits(SquareHubcapItem, _HubcapItem3); + + function SquareHubcapItem() { + _classCallCheck(this, SquareHubcapItem); + + return _possibleConstructorReturn(this, (SquareHubcapItem.__proto__ || Object.getPrototypeOf(SquareHubcapItem)).apply(this, arguments)); + } + + return SquareHubcapItem; +}(HubcapItem); + +SquareHubcapItem.title = 'a hubcap hammered into a square shape'; +SquareHubcapItem.nouns = ['hubcap', 'square']; +SquareHubcapItem.description = 'It\'s a thin, flat piece of metal. It used to be a hubcap, but now it\'s been pounded into a square shape.'; +allEntityClasses.push(SquareHubcapItem); + +var StarburstHubcapItem = function (_HubcapItem4) { + _inherits(StarburstHubcapItem, _HubcapItem4); + + function StarburstHubcapItem() { + _classCallCheck(this, StarburstHubcapItem); + + return _possibleConstructorReturn(this, (StarburstHubcapItem.__proto__ || Object.getPrototypeOf(StarburstHubcapItem)).apply(this, arguments)); + } + + _createClass(StarburstHubcapItem, [{ + key: 'use', + value: function use(playerState, parsedSentence) { + if (parsedSentence.secondaryEntity instanceof SawmillEntity) { + return 'You\'d better get some help from the lumberjack with that.'; + } + _get(StarburstHubcapItem.prototype.__proto__ || Object.getPrototypeOf(StarburstHubcapItem.prototype), 'use', this).call(this, playerState, parsedSentence); + } + }]); + + return StarburstHubcapItem; +}(HubcapItem); + +StarburstHubcapItem.title = 'a hubcap hammered into a starburst shape'; +StarburstHubcapItem.nouns = ['hubcap', 'starburst']; +StarburstHubcapItem.description = 'It\'s a thin, circular piece of metal, once used to cap a hub. Now it\'s hammered into a starburst shape that looks like a child\'s drawing of a sawblade.'; +allEntityClasses.push(StarburstHubcapItem); + +var ConeHubcapItem = function (_HubcapItem5) { + _inherits(ConeHubcapItem, _HubcapItem5); + + function ConeHubcapItem() { + _classCallCheck(this, ConeHubcapItem); + + return _possibleConstructorReturn(this, (ConeHubcapItem.__proto__ || Object.getPrototypeOf(ConeHubcapItem)).apply(this, arguments)); + } + + return ConeHubcapItem; +}(HubcapItem); + +ConeHubcapItem.title = 'a hubcap hammered into a cone shape'; +ConeHubcapItem.nouns = ['hubcap', 'cone']; +ConeHubcapItem.description = 'It\'s a thin, hollow cone of metal. It used to be a hubcap, but now it\'s been pounded into a cone shape.'; +allEntityClasses.push(ConeHubcapItem); + +var CubeHubcapItem = function (_HubcapItem6) { + _inherits(CubeHubcapItem, _HubcapItem6); + + function CubeHubcapItem() { + _classCallCheck(this, CubeHubcapItem); + + return _possibleConstructorReturn(this, (CubeHubcapItem.__proto__ || Object.getPrototypeOf(CubeHubcapItem)).apply(this, arguments)); + } + + return CubeHubcapItem; +}(HubcapItem); + +CubeHubcapItem.title = 'a hubcap hammered into a cube shape'; +CubeHubcapItem.nouns = ['hubcap', 'cube']; +CubeHubcapItem.description = 'It\'s a thin, hollow cube made of metal. It used to be a hubcap, but now it\'s been pounded into a cube shape.'; +allEntityClasses.push(CubeHubcapItem); + +var TetrahedronHubcapItem = function (_HubcapItem7) { + _inherits(TetrahedronHubcapItem, _HubcapItem7); + + function TetrahedronHubcapItem() { + _classCallCheck(this, TetrahedronHubcapItem); + + return _possibleConstructorReturn(this, (TetrahedronHubcapItem.__proto__ || Object.getPrototypeOf(TetrahedronHubcapItem)).apply(this, arguments)); + } + + return TetrahedronHubcapItem; +}(HubcapItem); + +TetrahedronHubcapItem.title = 'a hubcap hammered into a tetrahedron shape'; +TetrahedronHubcapItem.nouns = ['hubcap', 'tetrahedron']; +TetrahedronHubcapItem.description = 'It\'s a thin, hollow pyramid made of metal. It used to be a hubcap, but now it\'s been pounded into a tetrahedron shape.'; +allEntityClasses.push(TetrahedronHubcapItem); + +var TarpItem = function (_engine$Entity27) { + _inherits(TarpItem, _engine$Entity27); + + function TarpItem() { + var _ref8; + + _classCallCheck(this, TarpItem); + + for (var _len8 = arguments.length, args = Array(_len8), _key8 = 0; _key8 < _len8; _key8++) { + args[_key8] = arguments[_key8]; + } + + var _this38 = _possibleConstructorReturn(this, (_ref8 = TarpItem.__proto__ || Object.getPrototypeOf(TarpItem)).call.apply(_ref8, [this].concat(args))); + + _this38.inPile = true; + _this38.takeable = function () { + return !_this38.inPile; + }; + return _this38; + } + + _createClass(TarpItem, [{ + key: 'take', + value: function take(playerState, parsedSentence) { + if (this.inPile) { + this.inPile = false; + var pile = _.find(playerState.location.getEntities(), function (entity) { + return entity instanceof BottomOfDuneVehiclesEntity; + }); + pile.hasTarp = false; + } + return _get(TarpItem.prototype.__proto__ || Object.getPrototypeOf(TarpItem.prototype), 'take', this).call(this, playerState, parsedSentence); + } + }, { + key: 'use', + value: function use(playerState, parsedSentence) { + if (parsedSentence.secondaryEntity instanceof SawmillEntity) { + return 'You\'d better get some help from the lumberjack with that.'; + } + return _get(TarpItem.prototype.__proto__ || Object.getPrototypeOf(TarpItem.prototype), 'use', this).call(this, playerState, parsedSentence); + } + }]); + + return TarpItem; +}(engine.Entity); + +TarpItem.title = 'a tarp'; +TarpItem.nouns = ['tarp']; +TarpItem.description = 'It\'s a green, woven piece of fabric, the kind you might see stretched over a truck in a military convoy. It\'s quite large - about 20 by 10 feet.'; +allEntityClasses.push(TarpItem); + +var TriangleTarpItem = function (_engine$Entity28) { + _inherits(TriangleTarpItem, _engine$Entity28); + + function TriangleTarpItem() { + _classCallCheck(this, TriangleTarpItem); + + return _possibleConstructorReturn(this, (TriangleTarpItem.__proto__ || Object.getPrototypeOf(TriangleTarpItem)).apply(this, arguments)); + } + + return TriangleTarpItem; +}(engine.Entity); + +TriangleTarpItem.title = 'a large triangle made of fabric'; +TriangleTarpItem.nouns = ['triangle', 'tarp']; +TriangleTarpItem.description = 'It\'s a green, woven piece of fabric, cut into the shape of a triangle. It\'s quite large - about 20 by 10 feet.'; +allEntityClasses.push(TriangleTarpItem); + +var FabricScrapItem = function (_engine$Entity29) { + _inherits(FabricScrapItem, _engine$Entity29); + + function FabricScrapItem() { + _classCallCheck(this, FabricScrapItem); + + return _possibleConstructorReturn(this, (FabricScrapItem.__proto__ || Object.getPrototypeOf(FabricScrapItem)).apply(this, arguments)); + } + + _createClass(FabricScrapItem, [{ + key: 'use', + value: function use(playerState, parsedSentence) { + if (parsedSentence.secondaryEntity instanceof AutoMechanic) { + parsedSentence.secondaryEntity.isClean = true; + playerState.location.removeEntity(this); + playerState.inventory.removeEntity(this); + playerState.inventory.addEntity(new GreasyClothItem()); + return 'You sop the grease off Desmond. He\'s now squeaky clean! And you have a grease-soaked cloth.'; + } + return _get(FabricScrapItem.prototype.__proto__ || Object.getPrototypeOf(FabricScrapItem.prototype), 'use', this).call(this, playerState, parsedSentence); + } + }]); + + return FabricScrapItem; +}(engine.Entity); + +FabricScrapItem.title = 'a small scrap of fabric'; +FabricScrapItem.nouns = ['scrap']; +FabricScrapItem.description = 'It\'s a small scrap of woven green fabric, about the size of a handkerchief.'; +allEntityClasses.push(FabricScrapItem); + +var GreasyClothItem = function (_engine$Entity30) { + _inherits(GreasyClothItem, _engine$Entity30); + + function GreasyClothItem() { + _classCallCheck(this, GreasyClothItem); + + return _possibleConstructorReturn(this, (GreasyClothItem.__proto__ || Object.getPrototypeOf(GreasyClothItem)).apply(this, arguments)); + } + + return GreasyClothItem; +}(engine.Entity); + +GreasyClothItem.title = 'a greasy cloth'; +GreasyClothItem.nouns = ['greasy', 'cloth', 'scrap']; +GreasyClothItem.description = 'It\'s a small scrap of fabric sopping with grease.'; +allEntityClasses.push(GreasyClothItem); + +var BottomOfDuneLocation = function (_engine$EntityContain2) { + _inherits(BottomOfDuneLocation, _engine$EntityContain2); + + function BottomOfDuneLocation(playerState) { + _classCallCheck(this, BottomOfDuneLocation); + + var _this42 = _possibleConstructorReturn(this, (BottomOfDuneLocation.__proto__ || Object.getPrototypeOf(BottomOfDuneLocation)).call(this)); + + _this42.playerState = playerState; + _this42.addEntity(new BottomOfDuneVehiclesEntity()); + _this42.addEntity(new UnshapedHubcapItem()); + _this42.addEntity(new TarpItem()); + return _this42; + } + + _createClass(BottomOfDuneLocation, [{ + key: 'getDescription', + value: function getDescription() { + return 'You\'re at the bottom of a massive sand dune, on the edge of a vast, flat desert. In the distance you see a flare drifting down from the sky. There\'s a pile of what looks like 10 battered VEHICLES.'; + } + }, { + key: 'getExits', + value: function getExits() { + return { 'back to the ranger station': this.playerState.returnLocation }; + } + }, { + key: 'runTrimmedCommand', + value: function runTrimmedCommand(trimmedCommand) { + var match = trimmedCommand.match(/^drop.*$/); + if (match) { + return 'You shouldn\'t drop anything here - you might lose it in the desert!'; + } + match = trimmedCommand.match(/^(((go |move )?back.*)|exit|leave)$/); + if (match) { + this.playerState.location = this.playerState.returnLocation; + this.playerState.returnLocation = null; + return 'You struggle back toward the ranger station. It\'s a pretty slow and arduous trek, the details of which aren\'t interesting enough to describe.\n\nFinally you\'re back on top of the sand dune, at the trailhead near the ranger station. You re-orient yourself.\n\n' + this.playerState.look(); + } + return undefined; + } + }]); + + return BottomOfDuneLocation; +}(engine.EntityContainerMixin); + +var RavineEntity = function (_engine$Entity31) { + _inherits(RavineEntity, _engine$Entity31); + + function RavineEntity() { + _classCallCheck(this, RavineEntity); + + return _possibleConstructorReturn(this, (RavineEntity.__proto__ || Object.getPrototypeOf(RavineEntity)).apply(this, arguments)); + } + + return RavineEntity; +}(engine.Entity); + +RavineEntity.title = 'the ravine'; +RavineEntity.nouns = ['ravine']; +RavineEntity.description = 'It\'s real deep, man.'; +RavineEntity.takeable = false; +allEntityClasses.push(RavineEntity); + +var RampEntity = function (_engine$Entity32) { + _inherits(RampEntity, _engine$Entity32); + + function RampEntity() { + _classCallCheck(this, RampEntity); + + return _possibleConstructorReturn(this, (RampEntity.__proto__ || Object.getPrototypeOf(RampEntity)).apply(this, arguments)); + } + + return RampEntity; +}(engine.Entity); + +RampEntity.title = 'the ramp'; +RampEntity.nouns = ['ramp']; +RampEntity.description = 'The ramp goes up about 40 feet.'; +RampEntity.takeable = false; +allEntityClasses.push(RampEntity); + +var EjectorVinesEntity = function (_engine$Entity33) { + _inherits(EjectorVinesEntity, _engine$Entity33); + + function EjectorVinesEntity() { + _classCallCheck(this, EjectorVinesEntity); + + return _possibleConstructorReturn(this, (EjectorVinesEntity.__proto__ || Object.getPrototypeOf(EjectorVinesEntity)).apply(this, arguments)); + } + + _createClass(EjectorVinesEntity, [{ + key: 'use', + value: function use(playerState, parsedSentence) { + playerState.location = playerState.specialLocations[RavineLocation.name]; + return 'You actually think the vines might hold your weight for a second. Then you realize they\'re actually crepe paper left over from a bar mitzvah someone held at this ravine, just last week. Go figure. They tear away with no resistance, and you tumble over the edge, never to be seen again.\n\nJust kidding. When all hope seems lost you feel talons dig into your shoulders, and a giant bird grabs you, and gently lowers you back onto the lip of the rift, on the same side you started out on. With flaps of mighty wings, something large flies away and bellows "Thanks for drinking gryphon beer!".'; + } + }]); + + return EjectorVinesEntity; +}(engine.Entity); + +EjectorVinesEntity.title = 'the vines'; +EjectorVinesEntity.nouns = ['vines']; +EjectorVinesEntity.description = 'There are some vines growing down from the edge of the ravine.'; +EjectorVinesEntity.takeable = false; +EjectorVinesEntity.verbs = _.extend({}, engine.Entity.verbs, { + 'grab': 'use', + 'take': 'use' +}); +allEntityClasses.push(EjectorVinesEntity); + +var EjectorRopeEntity = function (_engine$Entity34) { + _inherits(EjectorRopeEntity, _engine$Entity34); + + function EjectorRopeEntity() { + _classCallCheck(this, EjectorRopeEntity); + + return _possibleConstructorReturn(this, (EjectorRopeEntity.__proto__ || Object.getPrototypeOf(EjectorRopeEntity)).apply(this, arguments)); + } + + _createClass(EjectorRopeEntity, [{ + key: 'use', + value: function use(playerState, parsedSentence) { + playerState.location = playerState.specialLocations[RavineLocation.name]; + return 'You grab the rope. It goes taut, then you\'re horrified to see the rock it was tied to begin rolling towards you. You, the rope, and the rock tumble over the edge, never to be seen again.\n\nJust kidding. When all hope seems lost you feel talons dig into your shoulders, and a giant bird grabs you, and gently lowers you back onto the lip of the rift, on the same side you started out on. With flaps of mighty wings, something large flies away and bellows "Thanks for drinking gryphon beer!".'; + } + }]); + + return EjectorRopeEntity; +}(engine.Entity); + +EjectorRopeEntity.title = 'the rope'; +EjectorRopeEntity.nouns = ['rope']; +EjectorRopeEntity.description = 'There\'s a climber\'s rope anchored to a large rock.'; +EjectorRopeEntity.takeable = false; +EjectorRopeEntity.verbs = _.extend({}, engine.Entity.verbs, { + 'grab': 'use', + 'take': 'use' +}); +allEntityClasses.push(EjectorRopeEntity); + +var EjectorNetEntity = function (_engine$Entity35) { + _inherits(EjectorNetEntity, _engine$Entity35); + + function EjectorNetEntity() { + _classCallCheck(this, EjectorNetEntity); + + return _possibleConstructorReturn(this, (EjectorNetEntity.__proto__ || Object.getPrototypeOf(EjectorNetEntity)).apply(this, arguments)); + } + + _createClass(EjectorNetEntity, [{ + key: 'use', + value: function use(playerState, parsedSentence) { + playerState.location = playerState.specialLocations[RavineLocation.name]; + return 'What you thought was a net is actually a large spiderweb. The adrenaline pumping through your system made you gravely misjudge its structural integrity. You do manage to grab it, but the filaments shred in your hand, and you tumble over the edge, never to be seen again.\n\nJust kidding. When all hope seems lost you feel talons dig into your shoulders, and a giant bird grabs you, and gently lowers you back onto the lip of the rift, on the same side you started out on. With flaps of mighty wings, something large flies away and bellows "Thanks for drinking gryphon beer!"'; + } + }]); + + return EjectorNetEntity; +}(engine.Entity); + +EjectorNetEntity.title = 'the net'; +EjectorNetEntity.nouns = ['net']; +EjectorNetEntity.description = 'There\'s a giant net abutting out several feet over the drop.'; +EjectorNetEntity.takeable = false; +EjectorNetEntity.verbs = _.extend({}, engine.Entity.verbs, { + 'grab': 'use', + 'take': 'use' +}); +allEntityClasses.push(EjectorNetEntity); + +var EjectorSeatLocation = function (_engine$EntityContain3) { + _inherits(EjectorSeatLocation, _engine$EntityContain3); + + function EjectorSeatLocation(playerState) { + _classCallCheck(this, EjectorSeatLocation); + + var _this48 = _possibleConstructorReturn(this, (EjectorSeatLocation.__proto__ || Object.getPrototypeOf(EjectorSeatLocation)).call(this)); + + _this48.playerState = playerState; + _this48.addEntity(new EjectorVinesEntity()); + _this48.addEntity(new EjectorNetEntity()); + _this48.addEntity(new EjectorRopeEntity()); + return _this48; + } + + _createClass(EjectorSeatLocation, [{ + key: 'getDescription', + value: function getDescription() { + return 'You\'re slowly tumbling through the air, coming up on the lip of the ravine. Good news! You spot a few things that may be your salvation. There are VINES growing down from the edge of the rift. A climber\'s ROPE is anchored to a large rock. And what seems to be a giant NET abutting out several feet over the drop. You have time to grab one of them. Which will it be?'; + } + }, { + key: 'getExits', + value: function getExits() { + return {}; + } + }, { + key: 'runTrimmedCommand', + value: function runTrimmedCommand(trimmedCommand) { + var match = trimmedCommand.match(/^drop.*$/); + if (match) { + return 'It wouldn\'t be wise to start dropping your items into the ravine.'; + } + return undefined; + } + }]); + + return EjectorSeatLocation; +}(engine.EntityContainerMixin); + +var RedBusLeverEntity = function (_engine$Entity36) { + _inherits(RedBusLeverEntity, _engine$Entity36); + + function RedBusLeverEntity() { + var _ref9; + + _classCallCheck(this, RedBusLeverEntity); + + for (var _len9 = arguments.length, args = Array(_len9), _key9 = 0; _key9 < _len9; _key9++) { + args[_key9] = arguments[_key9]; + } + + var _this49 = _possibleConstructorReturn(this, (_ref9 = RedBusLeverEntity.__proto__ || Object.getPrototypeOf(RedBusLeverEntity)).call.apply(_ref9, [this].concat(args))); + + _this49.pulled = false; + return _this49; + } + + _createClass(RedBusLeverEntity, [{ + key: 'use', + value: function use(playerState, parsedSentence) { + if (!parsedSentence.secondaryEntity) { + if (this.pulled) { + return 'Nothing happens.'; + } + this.pulled = true; + var redBus = _.find(playerState.specialLocations[RavineLocation.name].getEntities(), function (entity) { + return entity instanceof SchoolBusEntity; + }); + redBus.hasRoof = false; + var roofMotorcycle = _.find(playerState.specialLocations[RavineLocation.name].getEntities(), function (entity) { + return entity instanceof RoofMotorcycleEntity; + }); + playerState.specialLocations[RavineLocation.name].removeEntity(roofMotorcycle); + playerState.specialLocations[RavineLocation.name].addEntity(new UnshapedMotorcycleEngineItem(null)); + playerState.location = playerState.specialLocations[RavineLocation.name]; + return 'There\'s a small explosion as the roof of the bus launches into the air. Then a sproingy noise, as you follow. To your dismay, the angle of the bus was such that you\'re heading right for the ravine. Your perception of time slows as you fly to your nearly certain doom.\n\nYou\'re slowly tumbling through the air, coming up on the lip of the ravine. Luckily, you notice what seems to be a giant net abutting out several feet over the drop!\n\nAs you try to grab it, though, you realize that what you thought was a net is actually a large spiderweb. The adrenaline pumping through your system made you gravely misjudge its structural integrity. You do manage to grab it, but the filaments shred in your hand, and you tumble over the edge, never to be seen again...\n\nBut as all hope seems lost, you suddenly feel talons dig into your shoulders. A giant bird grabs you, and gently lowers you back onto the lip of the rift, on the same side you started out on. With flaps of mighty wings, something large flies away and bellows "Thanks for drinking gryphon beer!"\n\n' + playerState.look(); + } + return _get(RedBusLeverEntity.prototype.__proto__ || Object.getPrototypeOf(RedBusLeverEntity.prototype), 'use', this).call(this, playerState, parsedSentence); + } + }]); + + return RedBusLeverEntity; +}(engine.Entity); + +RedBusLeverEntity.title = 'the lever'; +RedBusLeverEntity.nouns = ['lever']; +RedBusLeverEntity.description = 'It\'s a large lever labelled "ejector seat".'; +RedBusLeverEntity.takeable = false; +RedBusLeverEntity.verbs = _.extend({}, engine.Entity.verbs, { + 'pull': 'use' +}); +allEntityClasses.push(RedBusLeverEntity); + +var SchoolBusEntity = function (_engine$Entity37) { + _inherits(SchoolBusEntity, _engine$Entity37); + + function SchoolBusEntity() { + var _ref10; + + _classCallCheck(this, SchoolBusEntity); + + for (var _len10 = arguments.length, args = Array(_len10), _key10 = 0; _key10 < _len10; _key10++) { + args[_key10] = arguments[_key10]; + } + + var _this50 = _possibleConstructorReturn(this, (_ref10 = SchoolBusEntity.__proto__ || Object.getPrototypeOf(SchoolBusEntity)).call.apply(_ref10, [this].concat(args))); + + _this50.hasRoof = true; + _this50.description = function () { + if (_this50.hasRoof) { + return 'It\'s a school bus, and there\'s a motorcycle stuck on top of it. The driver\'s side door is hanging open.'; + } + return 'The bus is missing its roof.'; + }; + return _this50; + } + + _createClass(SchoolBusEntity, [{ + key: 'use', + value: function use(playerState, parsedSentence) { + if (!parsedSentence.secondaryEntity) { + playerState.location = playerState.specialLocations[RedBusLocation.name]; + return 'You climb into the school bus.\n\n' + playerState.look(); + } + return _get(SchoolBusEntity.prototype.__proto__ || Object.getPrototypeOf(SchoolBusEntity.prototype), 'use', this).call(this, playerState, parsedSentence); + } + }]); + + return SchoolBusEntity; +}(engine.Entity); + +SchoolBusEntity.title = 'the school bus'; +SchoolBusEntity.nouns = ['school', 'bus']; +SchoolBusEntity.description = ''; +SchoolBusEntity.takeable = false; +SchoolBusEntity.verbs = _.extend({}, engine.Entity.verbs, { + 'enter': 'use', + 'go in': 'use', + 'go into': 'use', + 'open': 'use' +}); +allEntityClasses.push(SchoolBusEntity); + +var RedBusLocation = function (_engine$EntityContain4) { + _inherits(RedBusLocation, _engine$EntityContain4); + + function RedBusLocation(playerState) { + _classCallCheck(this, RedBusLocation); + + var _this51 = _possibleConstructorReturn(this, (RedBusLocation.__proto__ || Object.getPrototypeOf(RedBusLocation)).call(this)); + + _this51.playerState = playerState; + _this51.addEntity(new RedBusLeverEntity()); + return _this51; + } + + _createClass(RedBusLocation, [{ + key: 'getDescription', + value: function getDescription() { + return 'You\'re sitting in the driver\'s seat of the school bus. There are lots of gauges, a LEVER marked "ejector seat," and no steering wheel.'; + } + }, { + key: 'getExits', + value: function getExits() { + return {}; + } + }, { + key: 'runTrimmedCommand', + value: function runTrimmedCommand(trimmedCommand) { + var match = trimmedCommand.match(/^(exit|back|go back|leave|get out).*$/); + if (match) { + this.playerState.location = this.playerState.specialLocations[RavineLocation.name]; + return 'You climb out of the school bus.\n\n' + this.playerState.look(); + } + return undefined; + } + }]); + + return RedBusLocation; +}(engine.EntityContainerMixin); + +var RoofMotorcycleEntity = function (_engine$Entity38) { + _inherits(RoofMotorcycleEntity, _engine$Entity38); + + function RoofMotorcycleEntity() { + _classCallCheck(this, RoofMotorcycleEntity); + + return _possibleConstructorReturn(this, (RoofMotorcycleEntity.__proto__ || Object.getPrototypeOf(RoofMotorcycleEntity)).apply(this, arguments)); + } + + _createClass(RoofMotorcycleEntity, [{ + key: 'take', + value: function take(playerState, parsedSentence) { + return 'The motorcycle is out of your reach on top of the school bus.'; + } + }]); + + return RoofMotorcycleEntity; +}(engine.Entity); + +RoofMotorcycleEntity.title = 'the motorcycle'; +RoofMotorcycleEntity.nouns = ['motorcycle']; +RoofMotorcycleEntity.description = 'The motorcycle is stuck on the roof of the bus. It has the biggest engine you\'ve ever seen on a motorcycle. Come to think of it, the bike seems to be a giant engine that someone haphazardly tacked wheels onto.'; +RoofMotorcycleEntity.takeable = false; +allEntityClasses.push(RoofMotorcycleEntity); + +var MotorcycleEngineItem = function (_MetalEntity2) { + _inherits(MotorcycleEngineItem, _MetalEntity2); + + function MotorcycleEngineItem(other) { + _classCallCheck(this, MotorcycleEngineItem); + + var _this53 = _possibleConstructorReturn(this, (MotorcycleEngineItem.__proto__ || Object.getPrototypeOf(MotorcycleEngineItem)).call(this)); + + _this53.description = function () { + return 'It\'s the engine from the motorcycle. This engine looks a lot more like the thing that pushes the space shuttle into orbit than anything you\'ve ever seen under the hood of a car. There\'s a lot of tubes and valves, and an opening at one end which seems to be the propelling nozzle. ' + _this53.shapeDescription() + ' ' + _this53.fuelDescription(); + }; + if (other) { + _this53.hasAlcohol = other.hasAlcohol; + _this53.hasFuel = other.hasFuel; + } + return _this53; + } + + _createClass(MotorcycleEngineItem, [{ + key: 'fuelDescription', + value: function fuelDescription() { + if (this.hasAlcohol || this.hasFuel) { + return 'There\'s a gas cap with a fuel indicator that shows the engine is full of liquid.'; + } else { + return 'There\'s a gas cap with a fuel indicator that shows the engine is empty.'; + } + } + }, { + key: 'shapeDescription', + value: function shapeDescription() { + return 'The steel around the opening is MANGLED, having been crushed by the fall.'; + } + }, { + key: 'use', + value: function use(playerState, parsedSentence) { + if (parsedSentence.secondaryEntity instanceof FuelBeakerEntity) { + return 'The men shake their heads. The larger one makes a hand gesture that looks like a nuclear explosion.'; + } + return _get(MotorcycleEngineItem.prototype.__proto__ || Object.getPrototypeOf(MotorcycleEngineItem.prototype), 'use', this).call(this, playerState, parsedSentence); + } + }]); + + return MotorcycleEngineItem; +}(MetalEntity); + +var UnshapedMotorcycleEngineItem = function (_MotorcycleEngineItem) { + _inherits(UnshapedMotorcycleEngineItem, _MotorcycleEngineItem); + + function UnshapedMotorcycleEngineItem(other) { + _classCallCheck(this, UnshapedMotorcycleEngineItem); + + var _this54 = _possibleConstructorReturn(this, (UnshapedMotorcycleEngineItem.__proto__ || Object.getPrototypeOf(UnshapedMotorcycleEngineItem)).call(this, other)); + + _this54.preTakeText = 'There\'s a crashed MOTORCYCLE ENGINE on the ground, teetering on the edge of the ravine.'; + return _this54; + } + + return UnshapedMotorcycleEngineItem; +}(MotorcycleEngineItem); + +UnshapedMotorcycleEngineItem.title = 'a mangled motorcycle engine'; +UnshapedMotorcycleEngineItem.nouns = ['mangled', 'motorcycle', 'engine']; +allEntityClasses.push(UnshapedMotorcycleEngineItem); + +var TriangleMotorcycleEngineItem = function (_MotorcycleEngineItem2) { + _inherits(TriangleMotorcycleEngineItem, _MotorcycleEngineItem2); + + function TriangleMotorcycleEngineItem() { + _classCallCheck(this, TriangleMotorcycleEngineItem); + + return _possibleConstructorReturn(this, (TriangleMotorcycleEngineItem.__proto__ || Object.getPrototypeOf(TriangleMotorcycleEngineItem)).apply(this, arguments)); + } + + _createClass(TriangleMotorcycleEngineItem, [{ + key: 'shapeDescription', + value: function shapeDescription() { + return 'The steel around the opening has been pounded into a triangular shape.'; + } + }]); + + return TriangleMotorcycleEngineItem; +}(MotorcycleEngineItem); + +TriangleMotorcycleEngineItem.title = 'a motorcycle engine with a triangular nozzle'; +TriangleMotorcycleEngineItem.nouns = ['motorcycle', 'engine', 'triangular']; +allEntityClasses.push(TriangleMotorcycleEngineItem); + +var SquareMotorcycleEngineItem = function (_MotorcycleEngineItem3) { + _inherits(SquareMotorcycleEngineItem, _MotorcycleEngineItem3); + + function SquareMotorcycleEngineItem() { + _classCallCheck(this, SquareMotorcycleEngineItem); + + return _possibleConstructorReturn(this, (SquareMotorcycleEngineItem.__proto__ || Object.getPrototypeOf(SquareMotorcycleEngineItem)).apply(this, arguments)); + } + + _createClass(SquareMotorcycleEngineItem, [{ + key: 'shapeDescription', + value: function shapeDescription() { + return 'The steel around the opening has been pounded into a square shape.'; + } + }]); + + return SquareMotorcycleEngineItem; +}(MotorcycleEngineItem); + +SquareMotorcycleEngineItem.title = 'a motorcycle engine with a square nozzle'; +SquareMotorcycleEngineItem.nouns = ['motorcycle', 'engine', 'square']; +allEntityClasses.push(SquareMotorcycleEngineItem); + +var StarburstMotorcycleEngineItem = function (_MotorcycleEngineItem4) { + _inherits(StarburstMotorcycleEngineItem, _MotorcycleEngineItem4); + + function StarburstMotorcycleEngineItem() { + _classCallCheck(this, StarburstMotorcycleEngineItem); + + return _possibleConstructorReturn(this, (StarburstMotorcycleEngineItem.__proto__ || Object.getPrototypeOf(StarburstMotorcycleEngineItem)).apply(this, arguments)); + } + + _createClass(StarburstMotorcycleEngineItem, [{ + key: 'shapeDescription', + value: function shapeDescription() { + return 'The steel around the opening has been pounded into a starburst shape.'; + } + }]); + + return StarburstMotorcycleEngineItem; +}(MotorcycleEngineItem); + +StarburstMotorcycleEngineItem.title = 'a motorcycle engine with a starburst shaped nozzle'; +StarburstMotorcycleEngineItem.nouns = ['motorcycle', 'engine', 'starburst']; +allEntityClasses.push(StarburstMotorcycleEngineItem); + +var ConeMotorcycleEngineItem = function (_MotorcycleEngineItem5) { + _inherits(ConeMotorcycleEngineItem, _MotorcycleEngineItem5); + + function ConeMotorcycleEngineItem() { + _classCallCheck(this, ConeMotorcycleEngineItem); + + return _possibleConstructorReturn(this, (ConeMotorcycleEngineItem.__proto__ || Object.getPrototypeOf(ConeMotorcycleEngineItem)).apply(this, arguments)); + } + + _createClass(ConeMotorcycleEngineItem, [{ + key: 'shapeDescription', + value: function shapeDescription() { + return 'The steel around the opening has been pounded into a conical shape.'; + } + }]); + + return ConeMotorcycleEngineItem; +}(MotorcycleEngineItem); + +ConeMotorcycleEngineItem.title = 'a motorcycle engine with a conical nozzle'; +ConeMotorcycleEngineItem.nouns = ['motorcycle', 'engine', 'conical']; +allEntityClasses.push(ConeMotorcycleEngineItem); + +var CubeMotorcycleEngineItem = function (_MotorcycleEngineItem6) { + _inherits(CubeMotorcycleEngineItem, _MotorcycleEngineItem6); + + function CubeMotorcycleEngineItem() { + _classCallCheck(this, CubeMotorcycleEngineItem); + + return _possibleConstructorReturn(this, (CubeMotorcycleEngineItem.__proto__ || Object.getPrototypeOf(CubeMotorcycleEngineItem)).apply(this, arguments)); + } + + _createClass(CubeMotorcycleEngineItem, [{ + key: 'shapeDescription', + value: function shapeDescription() { + return 'The steel around the opening has been pounded into a cubic shape.'; + } + }]); + + return CubeMotorcycleEngineItem; +}(MotorcycleEngineItem); + +CubeMotorcycleEngineItem.title = 'a motorcycle engine with a cubic nozzle'; +CubeMotorcycleEngineItem.nouns = ['motorcycle', 'engine', 'cubic']; +allEntityClasses.push(CubeMotorcycleEngineItem); + +var TetrahedronMotorcycleEngineItem = function (_MotorcycleEngineItem7) { + _inherits(TetrahedronMotorcycleEngineItem, _MotorcycleEngineItem7); + + function TetrahedronMotorcycleEngineItem() { + _classCallCheck(this, TetrahedronMotorcycleEngineItem); + + return _possibleConstructorReturn(this, (TetrahedronMotorcycleEngineItem.__proto__ || Object.getPrototypeOf(TetrahedronMotorcycleEngineItem)).apply(this, arguments)); + } + + _createClass(TetrahedronMotorcycleEngineItem, [{ + key: 'shapeDescription', + value: function shapeDescription() { + return 'The steel around the opening has been pounded into the shape of a tetrahedron.'; + } + }]); + + return TetrahedronMotorcycleEngineItem; +}(MotorcycleEngineItem); + +TetrahedronMotorcycleEngineItem.title = 'a motorcycle engine with a tetrahedronical nozzle'; +TetrahedronMotorcycleEngineItem.nouns = ['motorcycle', 'engine', 'tetrahedronical']; +allEntityClasses.push(TetrahedronMotorcycleEngineItem); + +var RavineLocation = function (_engine$EntityContain5) { + _inherits(RavineLocation, _engine$EntityContain5); + + function RavineLocation(playerState) { + _classCallCheck(this, RavineLocation); + + var _this61 = _possibleConstructorReturn(this, (RavineLocation.__proto__ || Object.getPrototypeOf(RavineLocation)).call(this)); + + _this61.playerState = playerState; + _this61.schoolBusEntity = new SchoolBusEntity(); + _this61.addEntity(new RampEntity()); + _this61.addEntity(new RavineEntity()); + _this61.addEntity(_this61.schoolBusEntity); + _this61.addEntity(new RoofMotorcycleEntity()); + _this61.addEntity(new FlowersItem()); + return _this61; + } + + _createClass(RavineLocation, [{ + key: 'getDescription', + value: function getDescription() { + if (this.schoolBusEntity.hasRoof) { + return 'You\'re at the edge of a RAVINE in the desert. It looks like a daredevil recently put on a show here; at the edge of the RAVINE there\'s a large RAMP, abutting a SCHOOL BUS. There\'s a crashed MOTORCYCLE on top of the bus.'; + } else { + return 'You\'re at the edge of a RAVINE in the desert. It looks like a daredevil recently put on a show here; at the edge of the RAVINE there\'s a large RAMP, abutting a SCHOOL BUS which is missing its roof.'; + } + } + }, { + key: 'getExits', + value: function getExits() { + return { 'back to the ranger station': this.playerState.returnLocation }; + } + }, { + key: 'runTrimmedCommand', + value: function runTrimmedCommand(trimmedCommand) { + var match = trimmedCommand.match(/^(exit|back|go back|leave)$/); + if (match) { + this.playerState.location = this.playerState.returnLocation; + this.playerState.returnLocation = null; + return 'You wait for the breeze to pick up again, then use your craft to sail back to the ranger station.\n\n' + this.playerState.look(); + } + return undefined; + } + }]); + + return RavineLocation; +}(engine.EntityContainerMixin); + +var TrapDoorEntity = function (_engine$Entity39) { + _inherits(TrapDoorEntity, _engine$Entity39); + + function TrapDoorEntity() { + _classCallCheck(this, TrapDoorEntity); + + var _this62 = _possibleConstructorReturn(this, (TrapDoorEntity.__proto__ || Object.getPrototypeOf(TrapDoorEntity)).call(this)); + + _this62.preTakeText = 'There\'s a TRAP DOOR underneath where the "rock" used to be.'; + return _this62; + } + + _createClass(TrapDoorEntity, [{ + key: 'take', + value: function take(playerState, parsedSentence) { + return 'You can\'t ' + parsedSentence.verb.root() + ' ' + this.title() + '.'; + } + }, { + key: 'use', + value: function use(playerState, parsedSentence) { + playerState.location = playerState.returnLocation; + playerState.returnLocation = null; + var passport = _.find(playerState.inventory.getEntities(), function (entity) { + return entity instanceof PassportItem; + }); + passport.orange = true; + return 'The trap door opens to a long ladder. You climb down the ladder, followed by the king, and stroll through a cool, breezy passage carved through solid rock. At the end there\'s another ladder leading up, followed by a trap door, which opens into the ranger station at the edge of the desert. The whole trip took about a half hour.\n\nThe king climbs up after you, shakes your hand, and says "Thanks for your help, adventurer. Allow me to mark your passport for passage to the next kingdom. I\'ll also draw you an aid for keeping track of activity on this island... well, what I can remember of it, anyway." You hand him your passport, he scribbles something in it, then hands it back to you and wanders off.'; + } + }]); + + return TrapDoorEntity; +}(engine.Entity); + +TrapDoorEntity.title = 'a trap door'; +TrapDoorEntity.nouns = ['trap', 'door']; +TrapDoorEntity.description = 'It\'s a trap door leading into the ground next to the pond.'; +TrapDoorEntity.verbs = _.extend({}, engine.Entity.verbs, { + 'open': 'use', + 'take': 'use' +}); +allEntityClasses.push(TrapDoorEntity); + +var BeanBagChairEntity = function (_engine$Entity40) { + _inherits(BeanBagChairEntity, _engine$Entity40); + + function BeanBagChairEntity() { + _classCallCheck(this, BeanBagChairEntity); + + return _possibleConstructorReturn(this, (BeanBagChairEntity.__proto__ || Object.getPrototypeOf(BeanBagChairEntity)).apply(this, arguments)); + } + + _createClass(BeanBagChairEntity, [{ + key: 'push', + value: function push(playerState, parsedSentence) { + playerState.location.removeEntity(this); + var craftingKing = _.find(playerState.location.getEntities(), function (entity) { + return entity instanceof CraftingKing; + }); + craftingKing.sitting = false; + playerState.location.addEntity(new TrapDoorEntity()); + return 'The king hops off the rock, and you put your back up against it, ready to shove with all of your might. You give it a mighty push, and fall on your ass as it rolls away with almost no effort. What you thought was a rock was actually a well camouflaged bean-bag chair. It rolls into the pond and disappears underneath the water. The king acts like nothing\'s out of the ordinary. Under the "rock" was a TRAP DOOR.'; + } + }]); + + return BeanBagChairEntity; +}(engine.Entity); + +BeanBagChairEntity.title = 'a rock'; +BeanBagChairEntity.nouns = ['rock']; +BeanBagChairEntity.description = 'It\'s a medium-sized rock, currently being used as a chair by the old man.'; +BeanBagChairEntity.verbs = _.extend({}, engine.Entity.verbs, { + 'lift': 'push', + 'move': 'push', + 'push': 'push', + 'shove': 'push' +}); +BeanBagChairEntity.takeable = false; +allEntityClasses.push(BeanBagChairEntity); + +var CraftingKing = function (_engine$NpcEntity3) { + _inherits(CraftingKing, _engine$NpcEntity3); + + function CraftingKing() { + var _ref11; + + _classCallCheck(this, CraftingKing); + + for (var _len11 = arguments.length, args = Array(_len11), _key11 = 0; _key11 < _len11; _key11++) { + args[_key11] = arguments[_key11]; + } + + var _this64 = _possibleConstructorReturn(this, (_ref11 = CraftingKing.__proto__ || Object.getPrototypeOf(CraftingKing)).call.apply(_ref11, [this].concat(args))); + + _this64.sitting = true; + _this64.description = function () { + if (_this64.sitting) { + return 'An OLD MAN is sitting on top of a ROCK at the side of the pond, fishing.'; + } + return 'An OLD MAN is standing by the side of the pond.'; + }; + return _this64; + } + + _createClass(CraftingKing, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + if (this.sitting) { + return '"Oh, hi! Have you come looking for me? I come here to fish when I get tired of all of my duties. But this rock I\'m sitting on rolled onto my trap door, and I couldn\'t get it to budge, so I\'ve just been living off of fish for the last several weeks. It\'s not so bad, really. Get me home and I\'ll give you a nice reward!"'; + } + return '"When we return home, I\'ll give you a nice reward!"'; + } + }]); + + return CraftingKing; +}(engine.NpcEntity); + +CraftingKing.title = 'the old man'; +CraftingKing.nouns = ['man']; +CraftingKing.description = ''; +CraftingKing.takeable = false; +allEntityClasses.push(CraftingKing); + +var PlateauLocation = function (_engine$EntityContain6) { + _inherits(PlateauLocation, _engine$EntityContain6); + + function PlateauLocation(playerState) { + _classCallCheck(this, PlateauLocation); + + var _this65 = _possibleConstructorReturn(this, (PlateauLocation.__proto__ || Object.getPrototypeOf(PlateauLocation)).call(this)); + + _this65.playerState = playerState; + _this65.addEntity(new CraftingKing()); + _this65.addEntity(new BeanBagChairEntity()); + return _this65; + } + + _createClass(PlateauLocation, [{ + key: 'getDescription', + value: function getDescription() { + return 'You\'re on top of a high plateau, surrounded by a ravine on all sides. In the middle of a plateau is a pleasant looking pond.'; + } + }, { + key: 'getExits', + value: function getExits() { + return {}; + } + }]); + + return PlateauLocation; +}(engine.EntityContainerMixin); + +var MessageBoardEntity = function (_engine$Entity41) { + _inherits(MessageBoardEntity, _engine$Entity41); + + function MessageBoardEntity() { + _classCallCheck(this, MessageBoardEntity); + + var _this66 = _possibleConstructorReturn(this, (MessageBoardEntity.__proto__ || Object.getPrototypeOf(MessageBoardEntity)).call(this)); + + _this66.description = function () { + if (_this66.hasRockFuPaper) { + return 'There are various notices and advertisements pinned to the message board. One piece of PAPER in particular stands out: it has some chunks taken out of it. The message board also has some chalked-on SURF CONDITIONS.'; + } + return 'There are various notices and advertisements pinned to the message board. It also has some chalked-on SURF CONDITIONS.'; + }; + _this66.hasRockFuPaper = true; + return _this66; + } + + return MessageBoardEntity; +}(engine.Entity); + +MessageBoardEntity.title = 'a message board'; +MessageBoardEntity.nouns = ['message', 'board']; +MessageBoardEntity.description = ''; +MessageBoardEntity.takeable = false; +MessageBoardEntity.verbs = _.extend({}, engine.Entity.verbs, { + 'read': 'examine' +}); +allEntityClasses.push(MessageBoardEntity); + +var SurfConditionsEntity = function (_engine$Entity42) { + _inherits(SurfConditionsEntity, _engine$Entity42); + + function SurfConditionsEntity() { + _classCallCheck(this, SurfConditionsEntity); + + return _possibleConstructorReturn(this, (SurfConditionsEntity.__proto__ || Object.getPrototypeOf(SurfConditionsEntity)).apply(this, arguments)); + } + + return SurfConditionsEntity; +}(engine.Entity); + +SurfConditionsEntity.title = 'the surf conditions'; +SurfConditionsEntity.nouns = ['surf', 'conditions']; +SurfConditionsEntity.description = 'Surf conditions: groovy\nWater is: pleasant\nSharks are: hungry\n\nThere\'s a chalked-on picture of a shark eating a gnarly wave.'; +SurfConditionsEntity.takeable = false; +SurfConditionsEntity.verbs = _.extend({}, engine.Entity.verbs, { + 'check': 'examine', + 'read': 'examine' +}); +allEntityClasses.push(SurfConditionsEntity); + +var RockFuPaperItem = function (_engine$Entity43) { + _inherits(RockFuPaperItem, _engine$Entity43); + + function RockFuPaperItem() { + var _ref12; + + _classCallCheck(this, RockFuPaperItem); + + for (var _len12 = arguments.length, args = Array(_len12), _key12 = 0; _key12 < _len12; _key12++) { + args[_key12] = arguments[_key12]; + } + + var _this68 = _possibleConstructorReturn(this, (_ref12 = RockFuPaperItem.__proto__ || Object.getPrototypeOf(RockFuPaperItem)).call.apply(_ref12, [this].concat(args))); + + _this68.onMessageBoard = true; + _this68.takeable = function () { + return !_this68.onMessageBoard; + }; + return _this68; + } + + _createClass(RockFuPaperItem, [{ + key: 'take', + value: function take(playerState, parsedSentence) { + if (this.onMessageBoard) { + this.onMessageBoard = false; + var messageBoard = _.find(playerState.location.getEntities(), function (entity) { + return entity instanceof MessageBoardEntity; + }); + messageBoard.hasRockFuPaper = false; + playerState.location.removeEntity(this); + playerState.inventory.addEntity(this); + return 'You grab the torn piece of paper off of the message board. It seems to be some kind of recipe.'; + } + return _get(RockFuPaperItem.prototype.__proto__ || Object.getPrototypeOf(RockFuPaperItem.prototype), 'take', this).call(this, playerState, parsedSentence); + } + }]); + + return RockFuPaperItem; +}(engine.Entity); + +RockFuPaperItem.title = 'a torn piece of paper containing a recipe'; +RockFuPaperItem.nouns = ['torn', 'paper', 'recipe']; +RockFuPaperItem.description = 'It\'s a recipe for something. It\'s a bit singed around the edges, and the top of the page has been torn off, so you can\'t tell what it\'s a recipe for. Here\'s what you can make out:\n\n25 mL Everclear\n5 g WD 40\nSand Verbena Extract to taste\nSTIR WELL BUT NOT TOO WELL'; +RockFuPaperItem.verbs = _.extend({}, engine.Entity.verbs, { + 'read': 'examine' +}); +allEntityClasses.push(RockFuPaperItem); + +var SurfboardItem = function (_engine$Entity44) { + _inherits(SurfboardItem, _engine$Entity44); + + function SurfboardItem() { + _classCallCheck(this, SurfboardItem); + + return _possibleConstructorReturn(this, (SurfboardItem.__proto__ || Object.getPrototypeOf(SurfboardItem)).apply(this, arguments)); + } + + _createClass(SurfboardItem, [{ + key: 'use', + value: function use(playerState, parsedSentence) { + if (parsedSentence.secondaryEntity) { + if (parsedSentence.secondaryEntity instanceof HydraulicLiftEntity) { + return 'You better not use the hydraulic lift yourself, it looks like a complex piece of equipment. Maybe the mechanic can do it for you.'; + } + if (parsedSentence.secondaryEntity instanceof DesertTrailHeadEntity || parsedSentence.secondaryEntity instanceof SandDuneEntity) { + return 'That\'s a good idea, but there are giant rocks on the dune. Without a precision way of steering you\'d almost definitely plow right into one and die a messy death.'; + } + return _get(SurfboardItem.prototype.__proto__ || Object.getPrototypeOf(SurfboardItem.prototype), 'use', this).call(this, playerState, parsedSentence); + } + if (playerState.location instanceof cw.Location && playerState.location.ref.key() == new cw.CornerRef(-2, 1, 1, 1).key()) { + return this.surf(); + } + return 'This isn\'t a great spot for surfing.'; + } + }, { + key: 'surf', + value: function surf() { + return 'You\'re not a bad surfer! You do some really cool looking tricks, but there\'s no one around to see you except for the beach bum, and he seems pretty spaced out. Too bad.'; + } + }]); + + return SurfboardItem; +}(engine.Entity); + +SurfboardItem.title = 'a surfboard'; +SurfboardItem.nouns = ['surfboard']; +SurfboardItem.description = 'It\'s the beach bum\'s surfboard. It\'s got a pretty sweet looking fish decal on the front.'; +allEntityClasses.push(SurfboardItem); + +var SteerableSurfboardItem = function (_SurfboardItem) { + _inherits(SteerableSurfboardItem, _SurfboardItem); + + function SteerableSurfboardItem() { + _classCallCheck(this, SteerableSurfboardItem); + + return _possibleConstructorReturn(this, (SteerableSurfboardItem.__proto__ || Object.getPrototypeOf(SteerableSurfboardItem)).apply(this, arguments)); + } + + _createClass(SteerableSurfboardItem, [{ + key: 'use', + value: function use(playerState, parsedSentence) { + if (parsedSentence.secondaryEntity) { + if (parsedSentence.secondaryEntity instanceof DesertTrailHeadEntity || parsedSentence.secondaryEntity instanceof SandDuneEntity) {} else { + return _get(SteerableSurfboardItem.prototype.__proto__ || Object.getPrototypeOf(SteerableSurfboardItem.prototype), 'use', this).call(this, playerState, parsedSentence); + } + } + if (playerState.location instanceof cw.Location && playerState.location.ref.key() == new cw.CornerRef(2, 0, -2, 1).key()) { + playerState.returnLocation = playerState.location; + playerState.location = playerState.specialLocations[BottomOfDuneLocation.name]; + return 'You take a deep breath, then push yourself over the lip of the dune. You gradually pick up speed until you\'re moving fast enough to think "Boy, brakes would have been a great idea." As you streak downwards, the giant boulders hurtle up to meet you. You\'re heading straight towards one, but you jerk your rudder left, and your craft angles right. Soon you\'re slaloming down the dune, and just as you\'re getting really good, you reach the bottom. The force of a strong headwind rapidly slows you down, and you glide to a halt at the bottom of the dune.\n\n' + playerState.look(); + } + return _get(SteerableSurfboardItem.prototype.__proto__ || Object.getPrototypeOf(SteerableSurfboardItem.prototype), 'use', this).call(this, playerState, parsedSentence); + } + }]); + + return SteerableSurfboardItem; +}(SurfboardItem); + +SteerableSurfboardItem.title = 'a steerable surfboard'; +SteerableSurfboardItem.nouns = ['steerable', 'surfboard']; +SteerableSurfboardItem.description = 'It\'s the beach bum\'s surfboard, now with a rudder awkwardly welded to the back of it. It\'s got a pretty sweet looking fish decal on the front.'; +SteerableSurfboardItem.droppable = false; +allEntityClasses.push(SteerableSurfboardItem); + +var MastSurfboardItem = function (_SteerableSurfboardIt) { + _inherits(MastSurfboardItem, _SteerableSurfboardIt); + + function MastSurfboardItem() { + _classCallCheck(this, MastSurfboardItem); + + return _possibleConstructorReturn(this, (MastSurfboardItem.__proto__ || Object.getPrototypeOf(MastSurfboardItem)).apply(this, arguments)); + } + + return MastSurfboardItem; +}(SteerableSurfboardItem); + +MastSurfboardItem.title = 'a steerable surfboard with a mast'; +MastSurfboardItem.nouns = ['steerable', 'surfboard', 'mast']; +MastSurfboardItem.description = 'It\'s the beach bum\'s surfboard, now with a rudder awkwardly welded to the bottom of it, and a large wooden mast sticking out of the center. It\'s still got a pretty sweet looking fish decal on the front.'; +MastSurfboardItem.droppable = false; +allEntityClasses.push(MastSurfboardItem); + +var SailSurfboardItem = function (_MastSurfboardItem) { + _inherits(SailSurfboardItem, _MastSurfboardItem); + + function SailSurfboardItem() { + _classCallCheck(this, SailSurfboardItem); + + return _possibleConstructorReturn(this, (SailSurfboardItem.__proto__ || Object.getPrototypeOf(SailSurfboardItem)).apply(this, arguments)); + } + + _createClass(SailSurfboardItem, [{ + key: 'use', + value: function use(playerState, parsedSentence) { + if (parsedSentence.secondaryEntity) { + if (parsedSentence.secondaryEntity instanceof DesertTrailHeadEntity || parsedSentence.secondaryEntity instanceof SandDuneEntity) {} else { + return _get(SailSurfboardItem.prototype.__proto__ || Object.getPrototypeOf(SailSurfboardItem.prototype), 'use', this).call(this, playerState, parsedSentence); + } + } + if (playerState.location instanceof cw.Location && playerState.location.ref.key() == new cw.CornerRef(2, 0, -2, 1).key()) { + playerState.returnLocation = playerState.location; + playerState.location = playerState.specialLocations[RavineLocation.name]; + return 'You push yourself over the lip of the dune, and slalom your way down - you\'re getting pretty good at this! At the bottom of the dune, you meet the force of a strong headwind. You tack into the wind, and diagonally make your way forward. After about 100 meters, you reach a ravine, and the wind suddenly dies.\n\n' + playerState.look(); + } + if (playerState.location instanceof RavineLocation) { + playerState.location = playerState.returnLocation; + playerState.returnLocation = null; + return 'You wait for the breeze to pick up again, then use your craft to sail back to the ranger station.\n\n' + playerState.look(); + } + return _get(SailSurfboardItem.prototype.__proto__ || Object.getPrototypeOf(SailSurfboardItem.prototype), 'use', this).call(this, playerState, parsedSentence); + } + }]); + + return SailSurfboardItem; +}(MastSurfboardItem); + +SailSurfboardItem.title = 'a steerable surfboard with a sail'; +SailSurfboardItem.nouns = ['steerable', 'surfboard', 'sail']; +SailSurfboardItem.description = 'It\'s the beach bum\'s surfboard, now with a rudder awkwardly welded to the bottom of it, and a large sail attached to a large wooden mast. It\'s still got a pretty sweet looking fish decal on the front.'; +SailSurfboardItem.droppable = false; +allEntityClasses.push(SailSurfboardItem); + +var RocketSurfboardItem = function (_SailSurfboardItem) { + _inherits(RocketSurfboardItem, _SailSurfboardItem); + + function RocketSurfboardItem() { + _classCallCheck(this, RocketSurfboardItem); + + return _possibleConstructorReturn(this, (RocketSurfboardItem.__proto__ || Object.getPrototypeOf(RocketSurfboardItem)).apply(this, arguments)); + } + + _createClass(RocketSurfboardItem, [{ + key: 'use', + value: function use(playerState, parsedSentence) { + if (parsedSentence.secondaryEntity) { + if (parsedSentence.secondaryEntity instanceof DesertTrailHeadEntity || parsedSentence.secondaryEntity instanceof SandDuneEntity) {} else if (parsedSentence.secondaryEntity instanceof RampEntity) { + playerState.inventory.removeEntity(this); + _.each(playerState.inventory.getEntities(), function (entity) { + if (entity instanceof PassportItem || entity instanceof StickerItem) { + return; + } + playerState.inventory.removeEntity(entity); + }); + playerState.location = playerState.specialLocations[PlateauLocation.name]; + return 'You fire up your surfboard about 20 feet from the base of the ramp, and do your best to hold the rudder on-course. You fly up the ramp, and before you know it, you\'re airborne. Oh ...oh wow this looks awesome. Oh holy crap! If only you could see this... it\'s SO COOL.\n\nYou crash down on the other side of the ravine. The impact is graceful enough to not kill you, but violent enough to destroy your vessel. The mast breaks off, the sail drifts down to the bottom of the ravine, the engine detaches and goes careening off on its own before exploding in the sky like a firework, the rudder is pulverized, and your surfboard breaks in half and bounces. Who breaks a surfboard??? Also, everything you were carrying except the passport and the sticker fell out of your pocket. Bummer.\n\n' + playerState.look(); + } else { + return _get(RocketSurfboardItem.prototype.__proto__ || Object.getPrototypeOf(RocketSurfboardItem.prototype), 'use', this).call(this, playerState, parsedSentence); + } + } + if (playerState.location instanceof cw.Location && playerState.location.ref.key() == new cw.CornerRef(2, 0, -2, 1).key()) { + playerState.inventory.removeEntity(this); + _.each(playerState.inventory.getEntities(), function (entity) { + if (entity instanceof PassportItem || entity instanceof StickerItem) { + return; + } + playerState.inventory.removeEntity(entity); + }); + playerState.returnLocation = playerState.location; + playerState.location = playerState.specialLocations[PlateauLocation.name]; + return 'You push yourself over the lip of the dune, and slalom your way down - you\'re a pro at this by now! At the bottom of the dune, you meet the force of a strong headwind. You tack into the wind, and diagonally make your way forward. As you approach the ravine, the wind starts to die down.\n\nYou fire up your surfboard about 20 feet from the base of the ramp near the ravine, and do your best to hold the rudder on-course. You fly up the ramp, and before you know it, you\'re airborne. Oh... oh wow this looks awesome. Oh holy crap! If only you could see this... it\'s SO COOL.\n\nYou crash down on the other side of the ravine. The impact is graceful enough to not kill you, but violent enough to destroy your vessel. The mast breaks off, the sail drifts down to the bottom of the ravine, the engine detaches and goes careening off on its own before exploding in the sky like a firework, the rudder is pulverized, and your surfboard breaks in half and bounces. Who breaks a surfboard??? Also, everything you were carrying except the passport and the sticker fell out of your pocket. Bummer.\n\n' + playerState.look(); + } + return _get(RocketSurfboardItem.prototype.__proto__ || Object.getPrototypeOf(RocketSurfboardItem.prototype), 'use', this).call(this, playerState, parsedSentence); + } + }]); + + return RocketSurfboardItem; +}(SailSurfboardItem); + +RocketSurfboardItem.title = 'a steerable surfboard with a sail and a rocket engine'; +RocketSurfboardItem.nouns = ['steerable', 'surfboard', 'sail', 'rocket', 'engine']; +RocketSurfboardItem.description = 'It\'s the beach bum\'s surfboard, now with a rudder awkwardly welded to the bottom of it, a rocket engine welded to the back, and a large sail attached to a large wooden mast. The fish decal is starting to get a bit worn.'; +RocketSurfboardItem.droppable = false; +allEntityClasses.push(RocketSurfboardItem); + +var BeachBum = function (_engine$NpcEntity4) { + _inherits(BeachBum, _engine$NpcEntity4); + + function BeachBum() { + _classCallCheck(this, BeachBum); + + var _this74 = _possibleConstructorReturn(this, (BeachBum.__proto__ || Object.getPrototypeOf(BeachBum)).call(this)); + + _this74.description = function () { + if (_this74.hasSurfboard) { + return 'A BEACH BUM is standing by the surf shop, waxing his board.'; + } + return 'A BEACH BUM leans against the wall of the surf shop, watching the waves.'; + }; + _this74.hasSurfboard = true; + return _this74; + } + + _createClass(BeachBum, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + if (this.hasSurfboard) { + this.hasSurfboard = false; + playerState.inventory.addEntity(new SurfboardItem()); + return '"Mahalo, brother. Do you, like, surf? No board? Here, why don\'t you take mine for a spin. Just bring it back in one piece. Ha, I\'m just kidding, no one breaks surfboards."\n\nYou now have a SURFBOARD.'; + } + return '"Surf\'s up!"'; + } + }]); + + return BeachBum; +}(engine.NpcEntity); + +BeachBum.title = 'the beach bum'; +BeachBum.nouns = ['beach', 'bum']; +BeachBum.description = ''; +BeachBum.takeable = false; +allEntityClasses.push(BeachBum); + +var StealingKing = function (_engine$NpcEntity5) { + _inherits(StealingKing, _engine$NpcEntity5); + + function StealingKing() { + var _ref13; + + _classCallCheck(this, StealingKing); + + for (var _len13 = arguments.length, args = Array(_len13), _key13 = 0; _key13 < _len13; _key13++) { + args[_key13] = arguments[_key13]; + } + + var _this75 = _possibleConstructorReturn(this, (_ref13 = StealingKing.__proto__ || Object.getPrototypeOf(StealingKing)).call.apply(_ref13, [this].concat(args))); + + _this75.questCompleted = false; + return _this75; + } + + _createClass(StealingKing, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + if (this.questCompleted) { + return '"Don\'t forget to LOOK UP, my friend!"'; + } else { + return '"Hi there! You must have a lot of questions. Who you are. Where you are. I\'d be very happy to help you out, but something very valuable has been stolen from me, and I need it back. If you can retrieve it, by any means necessary, I\'ll tell you what you need to know. You\'re looking for a tiara, and it\'s being kept in the castle that\'s near here. Probably in the upstairs bedroom, but what do I know? I\'m just an old woman!"'; + } + } + }, { + key: 'giveTo', + value: function giveTo(playerState, item) { + if (item instanceof TiaraItem) { + playerState.location.removeEntity(item); + playerState.inventory.removeEntity(item); + if (!_.find(playerState.inventory.getEntities(), function (entity) { + return entity instanceof PassportItem; + })) { + playerState.inventory.addEntity(new PassportItem()); + } + playerState.inventory.addEntity(new StickerItem()); + this.questCompleted = true; + return '"That\'s it, my TIARA! It may not look like much, but this thing gives me the authority I need to rule. You see I\'m not just an old woman. Brace yourself. I\'m the queen of Crimsilon! I know, right? I just like to hang out on the beach here, and look up at the stars. Oh, I promised you some answers. Who are you? Doesn\'t matter, no one cares. But where are you? That\'s the really important one.\n\nYou\'re in a land that\'s been divided into four kingdoms: Crimsilon, Cerulia, Merrygold, and Blanc. It used to be a pretty thriving place, lots of hustle and bustle, trade, construction, you name it. But things have turned stagnant, and no one\'s really sure why. Well, I have a theory. I think the gods are displeased with us. How do I know? Try to LOOK UP sometimes. The sky is so clear here, that you can see stars pretty much anytime. Study them long enough and you\'ll see what I mean.\n\nI have some things for you, then I\'ll send you on your merry way. This is a PASSPORT. You can use it to demonstrate that you\'re in my good graces. I\'ve filled it out with everything you need to get them to let you into Cerulia. And this is just a STICKER I like to give people."\n\nShe hands you a PASSPORT and a STICKER.'; + } + if (item instanceof GryphonBeerItem) { + return '"Oh, thanks but no thanks. You have to be careful with that stuff. It\'s known to eat holes through people\'s stomachs."'; + } + if (item instanceof PassportItem) { + return '"Show that to the guards to travel to other kingdoms. You don\'t need to show it to me."'; + } + return _get(StealingKing.prototype.__proto__ || Object.getPrototypeOf(StealingKing.prototype), 'giveTo', this).call(this, playerState, item); + } + }]); + + return StealingKing; +}(engine.NpcEntity); + +StealingKing.title = 'the old woman'; +StealingKing.nouns = ['woman', 'queen']; +StealingKing.description = 'An OLD WOMAN is huddled by a small fire.'; +StealingKing.takeable = false; +allEntityClasses.push(StealingKing); + +var MeldItem = function (_engine$Entity45) { + _inherits(MeldItem, _engine$Entity45); + + function MeldItem() { + _classCallCheck(this, MeldItem); + + return _possibleConstructorReturn(this, (MeldItem.__proto__ || Object.getPrototypeOf(MeldItem)).apply(this, arguments)); + } + + return MeldItem; +}(engine.Entity); + +MeldItem.title = 'some rods of a metal meld'; +MeldItem.nouns = ['rods', 'metal', 'meld']; +MeldItem.description = 'They\'re 15-foot-long rods of a special iron-carbon meld, made by the blacksmith.'; +allEntityClasses.push(MeldItem); + +var Blacksmith = function (_engine$NpcEntity6) { + _inherits(Blacksmith, _engine$NpcEntity6); + + function Blacksmith() { + var _ref14; + + _classCallCheck(this, Blacksmith); + + for (var _len14 = arguments.length, args = Array(_len14), _key14 = 0; _key14 < _len14; _key14++) { + args[_key14] = arguments[_key14]; + } + + var _this77 = _possibleConstructorReturn(this, (_ref14 = Blacksmith.__proto__ || Object.getPrototypeOf(Blacksmith)).call.apply(_ref14, [this].concat(args))); + + _this77.metalItem = null; + return _this77; + } + + _createClass(Blacksmith, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + if (this.metalItem != null) { + var metalItem = this.metalItem; + playerState.inventory.addEntity(metalItem); + this.metalItem = null; + return '"Couldn\'t decide on a shape? Here, you can have this back. Bring it back to me when you\'re feeling more decisive!"\n\nThe blacksmith hands you ' + metalItem.title() + '.'; + } + var passport = _.find(playerState.inventory.getEntities(), function (entity) { + return entity instanceof PassportItem; + }); + if (passport && passport.orange) { + return '"Hey buddy. Can you keep a secret? I\'m working on something special. It\'s a new type of metal I\'ve been inventing over in my back yard. It\'s a MELD of iron and carbon. Tell you what. I\'m pretty thirsty from all this time in front of the furnace. You bring me a big mug of beer, I\'ll give you a few long rods of my alloy to show off to all your friends. None of that caustic crap, mind you."'; + } + if (passport && passport.blue) { + return '"Oh, hey. Thanks for helping our queen. As a token of my appreciation, lemme know if you need any metal pounded out into specific shapes. I do triangles, squares, starbursts, cones, cubes, and tetrahedra."'; + } + return '"Hello there. You\'re not from around here, are you? I\'m the best blacksmith in all the land. Come back when you gain my queen\'s approval, and I may be able to help you out."'; + } + }, { + key: 'giveTo', + value: function giveTo(playerState, item) { + if (item instanceof NailsItem) { + return '"I don\'t need those nasty old nails anymore, you can keep them."'; + } + if (item instanceof GryphonBeerItem) { + return '"Yikes, no thank you. That stuff did in my cousin Carl. I\'m not talking about alcoholism. It melted him. I don\'t like to talk about it."'; + } + if (item instanceof MeadItem) { + playerState.location.removeEntity(item); + playerState.inventory.removeEntity(item); + playerState.inventory.addEntity(new MeldItem()); + return 'He downs it in one long go.\n\n"Ahhhh, that\'s the stuff. Here are some 15 foot rods of my special iron-carbon MELD. Any ideas what to call it? Nevermind, I\'ll think of something."'; + } + if (item instanceof MetalEntity) { + playerState.location.removeEntity(item); + playerState.inventory.removeEntity(item); + this.metalItem = item; + if (item instanceof MotorcycleEngineItem) { + return 'He whistles in appreciation. "Fine craftsmanship, this. I can hammer out the nozzle, any shape you want, that I can do. This doesn\'t have fuel in it, does it? Of course not, no one would be that stupid. What\'ll it be? I do triangles, squares, starbursts, cones, cubes, and tetrahedra."'; + } + return '"Nice chunk of metal. What shape do you want? I do triangles, squares, starbursts, cones, cubes, and tetrahedra."'; + } + return _get(Blacksmith.prototype.__proto__ || Object.getPrototypeOf(Blacksmith.prototype), 'giveTo', this).call(this, playerState, item); + } + }]); + + return Blacksmith; +}(engine.NpcEntity); + +Blacksmith.title = 'the blacksmith'; +Blacksmith.nouns = ['blacksmith']; +Blacksmith.description = 'The town BLACKSMITH sits nearby, hunched over his forge, working on some metal thingy.'; +Blacksmith.takeable = false; +allEntityClasses.push(Blacksmith); + +var HoleItem = function (_engine$Entity46) { + _inherits(HoleItem, _engine$Entity46); + + function HoleItem() { + _classCallCheck(this, HoleItem); + + return _possibleConstructorReturn(this, (HoleItem.__proto__ || Object.getPrototypeOf(HoleItem)).apply(this, arguments)); + } + + return HoleItem; +}(engine.Entity); + +HoleItem.title = 'a property deed for a hole'; +HoleItem.nouns = ['property', 'deed', 'hole']; +HoleItem.description = 'It\'s a property deed for a hole.'; +allEntityClasses.push(HoleItem); + +var PondEntity = function (_engine$Entity47) { + _inherits(PondEntity, _engine$Entity47); + + function PondEntity() { + var _ref15; + + _classCallCheck(this, PondEntity); + + for (var _len15 = arguments.length, args = Array(_len15), _key15 = 0; _key15 < _len15; _key15++) { + args[_key15] = arguments[_key15]; + } + + var _this79 = _possibleConstructorReturn(this, (_ref15 = PondEntity.__proto__ || Object.getPrototypeOf(PondEntity)).call.apply(_ref15, [this].concat(args))); + + _this79.description = function (playerState) { + var passport = _.find(playerState.inventory.getEntities(), function (entity) { + return entity instanceof PassportItem; + }); + if (passport && passport.orange) { + return 'It\'s actually now a sizable hole in the ground where there used to be a POND. You wonder what happened to all of the water.'; + } + if (playerState.nailBoots) { + return 'There\'s a sizable POND in which you can see your reflection. You\'re wearing nondescript, slightly weathered black clothing, and boots with rusty nails sticking out the front. They look surprisingly cool. When your adventure\'s over, you\'re considering mass producing them and opening a shoe store.'; + } + return 'There\'s a sizable POND in which you can see your reflection. You\'re wearing nondescript, slightly weathered black clothing, and a sturdy pair of BOOTS.'; + }; + return _this79; + } + + return PondEntity; +}(engine.Entity); + +PondEntity.title = 'a pond'; +PondEntity.nouns = ['pond']; +PondEntity.description = ''; +PondEntity.takeable = false; +allEntityClasses.push(PondEntity); + +var Farmer = function (_engine$NpcEntity7) { + _inherits(Farmer, _engine$NpcEntity7); + + function Farmer() { + var _ref16; + + _classCallCheck(this, Farmer); + + for (var _len16 = arguments.length, args = Array(_len16), _key16 = 0; _key16 < _len16; _key16++) { + args[_key16] = arguments[_key16]; + } + + var _this80 = _possibleConstructorReturn(this, (_ref16 = Farmer.__proto__ || Object.getPrototypeOf(Farmer)).call.apply(_ref16, [this].concat(args))); + + _this80.hasButter = true; + _this80.hasHole = true; + return _this80; + } + + _createClass(Farmer, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + var passport = _.find(playerState.inventory.getEntities(), function (entity) { + return entity instanceof PassportItem; + }); + if (passport && passport.orange) { + if (this.hasHole) { + return '"Heya. How goes it. Me? My soil\'s too dense. Nothing\'s growing. I need to aerate it out. I tried to dig a furrow but accidentally tapped into my pond. The water all drained out, and now I have a useless HOLE in the ground. Tell you what. I\'ll sell you the HOLE if you can find me something that\'ll add some air to my soil. Dunno what that would be. Clearly."'; + } else { + return '"Enjoy your new hole!"'; + } + } + if (this.hasButter) { + this.hasButter = false; + playerState.inventory.addEntity(new ButterItem()); + return '"I\'m a farmer! I milk sheep. Here, have some sheep\'s milk butter."\n\nThe farmer hands you a small tub of sheep\'s milk BUTTER.'; + } + return '"I\'m a farmer! I milk sheep."'; + } + }, { + key: 'giveTo', + value: function giveTo(playerState, item) { + if (item instanceof GryphonBeerItem) { + return '"Thanks, but I only drink sheep\'s milk. You have to be careful with that stuff; it could kill you. Read the warning label sometime."'; + } + if (item instanceof MoleItem) { + playerState.inventory.removeEntity(item); + playerState.location.removeEntity(item); + playerState.inventory.addEntity(new HoleItem()); + this.hasHole = false; + return '"What\'s this? Oh. He one of them... cats? No? Oh, these are the guys who burrow underground. Oh yeah. This\'ll do. Feisty little guy. Here\'s your hole."\n\nHe hands you a property deed to the HOLE.'; + } + return _get(Farmer.prototype.__proto__ || Object.getPrototypeOf(Farmer.prototype), 'giveTo', this).call(this, playerState, item); + } + }]); + + return Farmer; +}(engine.NpcEntity); + +Farmer.title = 'the farmer'; +Farmer.nouns = ['farmer']; +Farmer.description = 'A FARMER tends to a small group of sheep.'; +Farmer.takeable = false; +allEntityClasses.push(Farmer); + +var FuelBeakerEntity = function (_engine$Entity48) { + _inherits(FuelBeakerEntity, _engine$Entity48); + + function FuelBeakerEntity() { + _classCallCheck(this, FuelBeakerEntity); + + var _this81 = _possibleConstructorReturn(this, (FuelBeakerEntity.__proto__ || Object.getPrototypeOf(FuelBeakerEntity)).call(this)); + + _this81.preTakeText = 'The men carefully guard a BEAKER of green liquid.'; + return _this81; + } + + _createClass(FuelBeakerEntity, [{ + key: 'take', + value: function take(playerState, parsedSentence) { + return 'The men shake their heads. The larger one makes a hand gesture that looks like a nuclear explosion.'; + } + }, { + key: 'use', + value: function use(playerState, parsedSentence) { + if (parsedSentence.secondaryEntity instanceof MotorcycleEngineItem) { + return 'The men shake their heads. The larger one makes a hand gesture that looks like a nuclear explosion.'; + } + return _get(FuelBeakerEntity.prototype.__proto__ || Object.getPrototypeOf(FuelBeakerEntity.prototype), 'use', this).call(this, playerState, parsedSentence); + } + }]); + + return FuelBeakerEntity; +}(engine.Entity); + +FuelBeakerEntity.title = 'a beaker of green liquid'; +FuelBeakerEntity.nouns = ['beaker']; +FuelBeakerEntity.description = 'It\'s a beaker of green liquid.'; +allEntityClasses.push(FuelBeakerEntity); + +var MethCooks = function (_engine$NpcEntity8) { + _inherits(MethCooks, _engine$NpcEntity8); + + function MethCooks() { + var _ref17; + + _classCallCheck(this, MethCooks); + + for (var _len17 = arguments.length, args = Array(_len17), _key17 = 0; _key17 < _len17; _key17++) { + args[_key17] = arguments[_key17]; + } + + var _this82 = _possibleConstructorReturn(this, (_ref17 = MethCooks.__proto__ || Object.getPrototypeOf(MethCooks)).call.apply(_ref17, [this].concat(args))); + + _this82.hasFlowers = false; + _this82.hasAlcohol = false; + _this82.hasGrease = false; + _this82.fuelBeaker = null; + return _this82; + } + + _createClass(MethCooks, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + return 'The bigger man says something, but it comes out as a completely incomprehensible garble of syllables thanks to his gas mask.'; + } + }, { + key: 'giveTo', + value: function giveTo(playerState, item) { + if (item instanceof RockFuPaperItem) { + return 'They look at it, nod vigorously, and hand it back to you.'; + } + if (item instanceof FlowersItem) { + this.hasFlowers = true; + playerState.inventory.removeEntity(item); + playerState.location.removeEntity(item); + return 'The larger of the two men places the flowers in a mortar, vigorously grinds them with a pestle, and pours the contents through a fine sieve into a vial.' + this.checkForAllIngredients(playerState); + } + if (item instanceof GreasyClothItem) { + this.hasGrease = true; + playerState.inventory.removeEntity(item); + playerState.location.removeEntity(item); + return 'The larger man takes the greasy cloth and wrings it out over a large pan. It\'s now a greasy pan. He keeps the cloth.' + this.checkForAllIngredients(playerState); + } + if (item instanceof SteinItem) { + if (item.hasAlcohol) { + item.hasAlcohol = false; + return 'As you hand the stein to the men, you see that the alcohol it once contained has already evaporated. You take it back.'; + } + return 'They\'re not interested in an empty stein.'; + } + if (item instanceof MotorcycleEngineItem) { + if (item.hasAlcohol) { + item.hasAlcohol = false; + this.hasAlcohol = true; + return 'The smaller of the two men screws off the cap of the engine, pours its highly alcoholic contents into a narrow glass beaker, and quickly stoppers it. He hands the engine back to you.' + this.checkForAllIngredients(playerState); + } + if (this.fuelBeaker) { + playerState.location.removeEntity(this); + playerState.location.removeEntity(this.fuelBeaker); + this.fuelBeaker = null; + item.hasFuel = true; + return 'You open up the gas cap on the engine, and the smaller man pours in the green fluid. After you close the cap he gives you a thumbs up, they highfive, and go back into their trailer.'; + } + } + return 'The bigger man refuses your offer with an incomprehensible sequence of gasmask-muffled mumbles.'; + } + }, { + key: 'checkForAllIngredients', + value: function checkForAllIngredients(playerState) { + if (this.hasFlowers && this.hasAlcohol && this.hasGrease) { + this.fuelBeaker = new FuelBeakerEntity(); + playerState.location.addEntity(this.fuelBeaker); + return '\n\nThe two nearly naked men gather their glassware and cooking implements and disappear into the trailer. It shakes back and forth, and you\'re almost certain some sort of cool montage is happening inside. Variously colored puffs of smoke periodically erupt from the windows. Finally, about 15 minutes later, the door opens, and you see the two men, drenched in sweat, but looking pleased with themselves. They very, very gently carry a BEAKER of green liquid.'; + } + return ''; + } + }]); + + return MethCooks; +}(engine.NpcEntity); + +MethCooks.title = 'the two men'; +MethCooks.nouns = ['men']; +MethCooks.description = 'Two MEN wearing nothing but underwear and gasmasks are sunning themselves just outside of the scorched trailer. They\'re surrounded by assorted beakers and cooking apparatuses.'; +MethCooks.takeable = false; +allEntityClasses.push(MethCooks); + +var VialItem = function (_engine$Entity49) { + _inherits(VialItem, _engine$Entity49); + + function VialItem() { + _classCallCheck(this, VialItem); + + return _possibleConstructorReturn(this, (VialItem.__proto__ || Object.getPrototypeOf(VialItem)).apply(this, arguments)); + } + + return VialItem; +}(engine.Entity); + +VialItem.title = 'a small vial'; +VialItem.nouns = ['vial', 'clap']; +VialItem.description = 'It says "Contains live sample of Neisseria gonorrhoeae. Open at your risk." Congratulations. You have the clap.'; +allEntityClasses.push(VialItem); + +var ClipMethCooks = function (_engine$NpcEntity9) { + _inherits(ClipMethCooks, _engine$NpcEntity9); + + function ClipMethCooks() { + _classCallCheck(this, ClipMethCooks); + + return _possibleConstructorReturn(this, (ClipMethCooks.__proto__ || Object.getPrototypeOf(ClipMethCooks)).apply(this, arguments)); + } + + _createClass(ClipMethCooks, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + return '"Mmmmffsss mmm ummmhmmm papers frmmm urrm wind. Frrrma trrrm shwm. Frrrra gonorrhoea nmm frrrp smmmmovaaar."'; + } + }, { + key: 'giveTo', + value: function giveTo(playerState, item) { + if (item instanceof ClipItem) { + playerState.inventory.removeEntity(item); + playerState.location.removeEntity(item); + playerState.inventory.addEntity(new VialItem()); + playerState.location.removeEntity(this); + return 'They examine the paperclip, puzzled expressions apparent under their gas masks. You pick up two pieces of paper and use the clip to hold them together. The men make excited little noises, snatch the clip out of your hand, and start gathering a stack together. The smaller one takes a break to press a VIAL into your hand.\n\nAfter their papers are finally gathered and securely clipped, the men retreat back into their trailer.'; + } + return 'The bigger man refuses your offer with an incomprehensible sequence of gasmask-muffled mumbles, and returns to chasing doing his wind-strewn papers.'; + } + }]); + + return ClipMethCooks; +}(engine.NpcEntity); + +ClipMethCooks.title = 'the two men'; +ClipMethCooks.nouns = ['men']; +ClipMethCooks.description = 'Two MEN in their underwear and gas masks seem to be having trouble with a number of pieces of paper covered in diagrams and schematics. You watch them gather the pages off the ground into a stack, which moments later the wind obliterates, sending paper flying every which way. They then start the process over again.'; +ClipMethCooks.takeable = false; +allEntityClasses.push(ClipMethCooks); + +var RVEntity = function (_engine$Entity50) { + _inherits(RVEntity, _engine$Entity50); + + function RVEntity() { + _classCallCheck(this, RVEntity); + + return _possibleConstructorReturn(this, (RVEntity.__proto__ || Object.getPrototypeOf(RVEntity)).apply(this, arguments)); + } + + _createClass(RVEntity, [{ + key: 'open', + value: function open(playerState, parsedSentence) { + if (_.find(playerState.location.getEntities(), function (entity) { + return entity instanceof MethCooks; + })) { + return 'The bigger man blocks your way and shakes his head.'; + } else { + return 'It\'s locked.'; + } + } + }]); + + return RVEntity; +}(engine.Entity); + +RVEntity.title = 'a trailer with scorch marks'; +RVEntity.nouns = ['trailer']; +RVEntity.description = 'It\'s a rusty old trailer that\'s covered in scorch marks.'; +RVEntity.takeable = false; +RVEntity.verbs = _.extend({}, engine.Entity.verbs, { + 'enter': 'open', + 'go in': 'open', + 'go into': 'open', + 'open': 'open' +}); +allEntityClasses.push(RVEntity); + +var CedarLogItem = function (_engine$Entity51) { + _inherits(CedarLogItem, _engine$Entity51); + + function CedarLogItem() { + _classCallCheck(this, CedarLogItem); + + return _possibleConstructorReturn(this, (CedarLogItem.__proto__ || Object.getPrototypeOf(CedarLogItem)).apply(this, arguments)); + } + + return CedarLogItem; +}(engine.Entity); + +CedarLogItem.title = 'a cedar log'; +CedarLogItem.nouns = ['cedar', 'log']; +CedarLogItem.description = 'It\'s a cedar log, about 10 feet tall and 2 feet in diameter.'; +allEntityClasses.push(CedarLogItem); + +var SlatItem = function (_engine$Entity52) { + _inherits(SlatItem, _engine$Entity52); + + function SlatItem() { + _classCallCheck(this, SlatItem); + + return _possibleConstructorReturn(this, (SlatItem.__proto__ || Object.getPrototypeOf(SlatItem)).apply(this, arguments)); + } + + return SlatItem; +}(engine.Entity); + +SlatItem.title = 'a wooden slat'; +SlatItem.nouns = ['wooden', 'slat']; +SlatItem.description = 'It\'s a nice stick of wood.'; +allEntityClasses.push(SlatItem); + +var Lumberjack = function (_engine$NpcEntity10) { + _inherits(Lumberjack, _engine$NpcEntity10); + + function Lumberjack() { + var _ref18; + + _classCallCheck(this, Lumberjack); + + for (var _len18 = arguments.length, args = Array(_len18), _key18 = 0; _key18 < _len18; _key18++) { + args[_key18] = arguments[_key18]; + } + + var _this88 = _possibleConstructorReturn(this, (_ref18 = Lumberjack.__proto__ || Object.getPrototypeOf(Lumberjack)).call.apply(_ref18, [this].concat(args))); + + _this88.bladeFixed = false; + _this88.hasBass = false; + _this88.hasSlat = true; + _this88.description = function () { + if (_this88.hasBass) { + return 'The LUMBERJACK is still here, but now he\'s noodling away on an upright bass.'; + } + if (_this88.bladeFixed) { + return 'There\'s a single burly LUMBERJACK working at the sawmill.'; + } + return 'There\'s a single burly LUMBERJACK scratching his head and looking at what looks like a long backlog of uncut, felled TREES.'; + }; + return _this88; + } + + _createClass(Lumberjack, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + if (this.hasBass) { + if (this.hasSlat) { + return '"Saw\'s working great. I\'m takin\' a break. Practicing my scales. If you can teach me a new bass playing technique I\'ll give you some top shelf lumber. A great stick I\'ve been saving for a special day."'; + } else { + return 'The lumberjack is slappin\' dat bass so hard that he doesn\'t even notice you trying to get his attention.'; + } + } + if (this.bladeFixed) { + return '"Mill\'s fixed."'; + } + return '"Mill\'s broken. Sawblade snapped. Threw it out."'; + } + }, { + key: 'giveTo', + value: function giveTo(playerState, item) { + if (item instanceof SlapItem) { + playerState.inventory.addEntity(new SlatItem()); + this.hasSlat = false; + return 'You slap that bass. He slaps that bass. He gets into a deep groove and nods towards a SLAT of wood leaning against a log. It\'s about as nice as sticks of wood go. You take it.'; + } + var sawmill = _.find(playerState.location.getEntities(), function (entity) { + return entity instanceof SawmillEntity; + }); + if (item instanceof StarburstHubcapItem) { + playerState.location.removeEntity(item); + playerState.inventory.removeEntity(item); + sawmill.hasBlade = true; + this.bladeFixed = true; + playerState.inventory.addEntity(new CedarLogItem()); + return '"Looks good. Let\'s try it."\n\nHe installs the hubcap into the middle of the mill, flicks a switch, and it slices through a log with a bit of resistance, because let\'s be honest, that\'s a pretty crappy saw blade. But it does the job.\n\n"Have this log as a gesture of my appreciation." He gives you a nice looking log. Cedar, about 10 feet tall, 2 feet in diameter. You comically maneuver it into your pocket. The lumberjack winks at you. You choose to ignore it.'; + } else if (item instanceof HubcapItem) { + return '"Good material. Won\'t cut like that though."'; + } else if (item instanceof TarpItem) { + if (!sawmill.hasBlade) { + return '"Could cut this, but the mill\'s broken."'; + } + playerState.location.removeEntity(item); + playerState.inventory.removeEntity(item); + playerState.inventory.addEntity(new TriangleTarpItem()); + playerState.inventory.addEntity(new FabricScrapItem()); + return '"I can cut this."\n\nHe runs the tarp through his saw, cutting off a corner. It\'s now a large TRIANGLE of fabric. He gives it back to you. He also hands you a small SCRAP of fabric, about the size of a handkerchief.'; + } + return '"Don\'t want it."'; + } + }]); + + return Lumberjack; +}(engine.NpcEntity); + +Lumberjack.title = 'the lumberjack'; +Lumberjack.nouns = ['lumberjack']; +Lumberjack.description = ''; +Lumberjack.takeable = false; +allEntityClasses.push(Lumberjack); + +var SawmillEntity = function (_engine$Entity53) { + _inherits(SawmillEntity, _engine$Entity53); + + function SawmillEntity() { + _classCallCheck(this, SawmillEntity); + + var _this89 = _possibleConstructorReturn(this, (SawmillEntity.__proto__ || Object.getPrototypeOf(SawmillEntity)).call(this)); + + _this89.description = function () { + if (_this89.hasBlade) { + return 'It\'s a sawmill with a very crude, but functional, blade.'; + } + return 'It\'s a sawmill that\'s missing a blade.'; + }; + _this89.hasBlade = false; + return _this89; + } + + return SawmillEntity; +}(engine.Entity); + +SawmillEntity.title = 'the sawmill'; +SawmillEntity.nouns = ['sawmill']; +SawmillEntity.description = ''; +SawmillEntity.takeable = false; +allEntityClasses.push(SawmillEntity); + +var TreesEntity = function (_engine$Entity54) { + _inherits(TreesEntity, _engine$Entity54); + + function TreesEntity() { + _classCallCheck(this, TreesEntity); + + return _possibleConstructorReturn(this, (TreesEntity.__proto__ || Object.getPrototypeOf(TreesEntity)).apply(this, arguments)); + } + + return TreesEntity; +}(engine.Entity); + +TreesEntity.title = 'a pile of uncut, felled trees'; +TreesEntity.nouns = ['trees']; +TreesEntity.description = 'There\'s a pile of trees lined up at the end of the sawmill.'; +TreesEntity.takeable = false; +allEntityClasses.push(TreesEntity); + +var BlueKingdomGuard = function (_engine$NpcEntity11) { + _inherits(BlueKingdomGuard, _engine$NpcEntity11); + + function BlueKingdomGuard() { + var _ref19; + + _classCallCheck(this, BlueKingdomGuard); + + for (var _len19 = arguments.length, args = Array(_len19), _key19 = 0; _key19 < _len19; _key19++) { + args[_key19] = arguments[_key19]; + } + + var _this91 = _possibleConstructorReturn(this, (_ref19 = BlueKingdomGuard.__proto__ || Object.getPrototypeOf(BlueKingdomGuard)).call.apply(_ref19, [this].concat(args))); + + _this91.hasSeenPassport = false; + _this91.description = function (playerState) { + var passport = _.find(playerState.inventory.getEntities(), function (entity) { + return entity instanceof PassportItem; + }); + if (!_this91.hasSeenPassport) { + if (passport && passport.blue) { + _this91.hasSeenPassport = true; + return 'The GUARD recognizes the markings on your passport, and welcomes you with a grunt of acknowledgement. He seems to be crying.\n\n"Sorry, don\'t mind me. It\'s been a tough week. It\'s... it\'s our king. He\'s gone missing. He was last seen several days ago, hiking into the nearby desert. Can... can you help us find him? Your passport will allow you to travel freely within Cerulia."'; + } + return 'A GUARD blocks your way forward.'; + } + if (passport && passport.orange) { + return 'The GUARD whistles a happy tune.'; + } + return 'The GUARD paces nervously.'; + }; + return _this91; + } + + _createClass(BlueKingdomGuard, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + var passport = _.find(playerState.inventory.getEntities(), function (entity) { + return entity instanceof PassportItem; + }); + if (!passport || !passport.blue) { + return '"The land past here is part of Cerulia. No entry is permitted without a passport."'; + } + if (passport && passport.orange) { + return 'The GUARD welcomes you with a high five.'; + } + return '"Please help find our king. He was last seen hiking into the desert. The entrance is one day\'s walk from here."'; + } + }]); + + return BlueKingdomGuard; +}(engine.NpcEntity); + +BlueKingdomGuard.title = 'the guard'; +BlueKingdomGuard.nouns = ['guard']; +BlueKingdomGuard.description = ''; +BlueKingdomGuard.takeable = false; +allEntityClasses.push(BlueKingdomGuard); + +var DistillerySignEntity = function (_engine$Entity55) { + _inherits(DistillerySignEntity, _engine$Entity55); + + function DistillerySignEntity() { + _classCallCheck(this, DistillerySignEntity); + + return _possibleConstructorReturn(this, (DistillerySignEntity.__proto__ || Object.getPrototypeOf(DistillerySignEntity)).apply(this, arguments)); + } + + return DistillerySignEntity; +}(engine.Entity); + +DistillerySignEntity.title = 'the signboard'; +DistillerySignEntity.nouns = ['signboard']; +DistillerySignEntity.description = 'It says "Gryphon Distillery".'; +DistillerySignEntity.takeable = false; +DistillerySignEntity.verbs = _.extend({}, engine.Entity.verbs, { + 'read': 'examine' +}); +allEntityClasses.push(DistillerySignEntity); + +var DistilleryDoorEntity = function (_engine$Entity56) { + _inherits(DistilleryDoorEntity, _engine$Entity56); + + function DistilleryDoorEntity() { + _classCallCheck(this, DistilleryDoorEntity); + + return _possibleConstructorReturn(this, (DistilleryDoorEntity.__proto__ || Object.getPrototypeOf(DistilleryDoorEntity)).apply(this, arguments)); + } + + _createClass(DistilleryDoorEntity, [{ + key: 'knock', + value: function knock(playerState, parsedSentence) { + return 'There\'s a perfectly good bell.'; + } + }, { + key: 'use', + value: function use(playerState, parsedSentence) { + if (!parsedSentence.secondaryEntity) { + return 'It\'s locked.'; + } + return _get(DistilleryDoorEntity.prototype.__proto__ || Object.getPrototypeOf(DistilleryDoorEntity.prototype), 'use', this).call(this, playerState, parsedSentence); + } + }]); + + return DistilleryDoorEntity; +}(engine.Entity); + +DistilleryDoorEntity.title = 'the door'; +DistilleryDoorEntity.nouns = ['door']; +DistilleryDoorEntity.description = 'It\'s the door of the rectangular building.'; +DistilleryDoorEntity.takeable = false; +DistilleryDoorEntity.verbs = _.extend({}, engine.Entity.verbs, { + 'open': 'use', + 'knock': 'knock', + 'knock on': 'knock' +}); +allEntityClasses.push(DistilleryDoorEntity); + +var SteinItem = function (_engine$Entity57) { + _inherits(SteinItem, _engine$Entity57); + + function SteinItem() { + var _ref20; + + _classCallCheck(this, SteinItem); + + for (var _len20 = arguments.length, args = Array(_len20), _key20 = 0; _key20 < _len20; _key20++) { + args[_key20] = arguments[_key20]; + } + + var _this94 = _possibleConstructorReturn(this, (_ref20 = SteinItem.__proto__ || Object.getPrototypeOf(SteinItem)).call.apply(_ref20, [this].concat(args))); + + _this94.hasAlcohol = true; + _this94.description = function () { + if (_this94.hasAlcohol) { + return 'It\'s a tall glass full of extremely high proof alcohol.'; + } + return 'It\'s a tall, empty glass. All of the alcohol has evaporated or been used up.'; + }; + return _this94; + } + + _createClass(SteinItem, [{ + key: 'drink', + value: function drink(playerState, parsedSentence) { + this.hasAlcohol = false; + return 'You try to drink some alcohol, but before you can swallow it, it evaporates away. This is probably a lucky break; from the whiff you get of the stuff, it seems like you\'d probably explode if you managed to ingest any. The stein is now empty.'; + } + }, { + key: 'use', + value: function use(playerState, parsedSentence) { + if (this.hasAlcohol) { + if (!parsedSentence.secondaryEntity) { + return this.drink(playerState, parsedSentence); + } + if (parsedSentence.secondaryEntity instanceof MotorcycleEngineItem) { + var motorcycleEngine = parsedSentence.secondaryEntity; + motorcycleEngine.hasAlcohol = true; + this.hasAlcohol = false; + return 'You unscrew the gas cap, pour some alcohol in, and replace the cap before it can all evaporate away. You didn\'t get all of it, but that should be enough.'; + } + this.hasAlcohol = false; + return 'You try to pour the alcohol out of the stein, but it evaporates before it even touches ' + parsedSentence.secondaryEntity.title() + '.'; + } + return 'The stein is empty.'; + } + }]); + + return SteinItem; +}(engine.Entity); + +SteinItem.title = 'a stein'; +SteinItem.nouns = ['stein', 'alcohol']; +SteinItem.description = ''; +SteinItem.verbs = _.extend({}, engine.Entity.verbs, { + 'drink': 'drink', + 'pour': 'use' +}); +allEntityClasses.push(SteinItem); + +var MeadItem = function (_engine$Entity58) { + _inherits(MeadItem, _engine$Entity58); + + function MeadItem() { + _classCallCheck(this, MeadItem); + + return _possibleConstructorReturn(this, (MeadItem.__proto__ || Object.getPrototypeOf(MeadItem)).apply(this, arguments)); + } + + return MeadItem; +}(engine.Entity); + +MeadItem.title = 'a tankard of mead'; +MeadItem.nouns = ['tankard', 'mead']; +MeadItem.description = 'It\'s a tankard of mead.'; +allEntityClasses.push(MeadItem); + +var DistilleryWoman = function (_engine$NpcEntity12) { + _inherits(DistilleryWoman, _engine$NpcEntity12); + + function DistilleryWoman() { + var _ref21; + + _classCallCheck(this, DistilleryWoman); + + for (var _len21 = arguments.length, args = Array(_len21), _key21 = 0; _key21 < _len21; _key21++) { + args[_key21] = arguments[_key21]; + } + + var _this96 = _possibleConstructorReturn(this, (_ref21 = DistilleryWoman.__proto__ || Object.getPrototypeOf(DistilleryWoman)).call.apply(_ref21, [this].concat(args))); + + _this96.hasStein = true; + _this96.hasMead = true; + return _this96; + } + + _createClass(DistilleryWoman, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + var passport = _.find(playerState.inventory.getEntities(), function (entity) { + return entity instanceof PassportItem; + }); + if (passport && passport.orange) { + if (this.hasMead) { + return '"Hey, it\'s you. The tax man, wasn\'t it? Go away. Unless you have some dog food. My dog is hungry. He\'s inside. No taxes here."'; + } else { + return '"Thanks again for the meat. Now scram."'; + } + } + return '"Yer not one of them litigators, are you? There\'s some class-action lawsuit going on about our last batch. I dunno, something about melting furniture. Pah. We had to recall the whole shipment. We\'re currently brewing up a new batch now. 300 proof, this one. You can have some if you... wait, are those nails in your boots? You a safety inspector? Only safety inspectors walk around these parts with nails in their boots. You can\'t have any of my hooch until you can convince me you\'re not a fed. Come back when you can prove to me you\'re about to do something truly dangerous, and I\'ll let you try some."'; + } + }, { + key: 'giveTo', + value: function giveTo(playerState, item) { + if (item instanceof MeatItem) { + this.hasMead = false; + playerState.location.removeEntity(item); + playerState.inventory.removeEntity(item); + playerState.inventory.addEntity(new MeadItem()); + playerState.location.removeEntity(this); + return '"Meat! Here, have a drink."\n\nShe slams a tankard of MEAD into your chest, then runs inside, holding her steak high over her head.'; + } + if (item instanceof MotorcycleEngineItem) { + if (this.hasStein) { + this.hasStein = false; + playerState.inventory.addEntity(new SteinItem()); + return '"Wow. No way you\'re up to anything responsible with that. Here\'s a pint of our finest."\n\nShe hands you a stein of extremely high proof alcohol.'; + } + return '"You already showed me that. Give me back the stein and I\'ll pour you some more alcohol."'; + } + if (item instanceof SteinItem) { + if (item.hasAlcohol) { + return '"Your stein is still full! Feel free to bring it back for a refill later, though."'; + } + item.hasAlcohol = true; + return '"Back for more already? No problem, we\'ve got plenty." She refills your stein.'; + } + return '"That\'s pretty tame. I want to see evidence that you\'re going to do something really dumb and dangerous."'; + } + }]); + + return DistilleryWoman; +}(engine.NpcEntity); + +DistilleryWoman.title = 'the old woman'; +DistilleryWoman.nouns = ['old', 'woman']; +DistilleryWoman.description = 'A kindly OLD WOMAN stands by the door.'; +DistilleryWoman.takeable = false; +allEntityClasses.push(DistilleryWoman); + +var DistilleryBellEntity = function (_engine$Entity59) { + _inherits(DistilleryBellEntity, _engine$Entity59); + + function DistilleryBellEntity() { + var _ref22; + + _classCallCheck(this, DistilleryBellEntity); + + for (var _len22 = arguments.length, args = Array(_len22), _key22 = 0; _key22 < _len22; _key22++) { + args[_key22] = arguments[_key22]; + } + + var _this97 = _possibleConstructorReturn(this, (_ref22 = DistilleryBellEntity.__proto__ || Object.getPrototypeOf(DistilleryBellEntity)).call.apply(_ref22, [this].concat(args))); + + _this97.woman = new DistilleryWoman(); + return _this97; + } + + _createClass(DistilleryBellEntity, [{ + key: 'use', + value: function use(playerState, parsedSentence) { + if (!parsedSentence.secondaryEntity) { + if (_.find(playerState.location.getEntities(), function (entity) { + return entity instanceof DistilleryWoman; + })) { + return 'You ring the bell again. The old woman cries, "I\'m right here! Stop ringing that!".'; + } + playerState.location.addEntity(this.woman); + return 'The bell rings. After a moment you hear footsteps. A kindly OLD WOMAN opens the door.'; + } + return _get(DistilleryBellEntity.prototype.__proto__ || Object.getPrototypeOf(DistilleryBellEntity.prototype), 'use', this).call(this, playerState, parsedSentence); + } + }]); + + return DistilleryBellEntity; +}(engine.Entity); + +DistilleryBellEntity.title = 'the door bell'; +DistilleryBellEntity.nouns = ['bell']; +DistilleryBellEntity.description = 'It\'s a bell next to the door.'; +DistilleryBellEntity.takeable = false; +DistilleryBellEntity.verbs = _.extend({}, engine.Entity.verbs, { + 'ring': 'use' +}); +allEntityClasses.push(DistilleryBellEntity); + +var ClipItem = function (_engine$Entity60) { + _inherits(ClipItem, _engine$Entity60); + + function ClipItem() { + _classCallCheck(this, ClipItem); + + return _possibleConstructorReturn(this, (ClipItem.__proto__ || Object.getPrototypeOf(ClipItem)).apply(this, arguments)); + } + + _createClass(ClipItem, [{ + key: 'use', + value: function use(playerState, parsedSentence) { + return 'You don\'t have any paper that can be clipped.'; + } + }]); + + return ClipItem; +}(engine.Entity); + +ClipItem.title = 'a paper clip'; +ClipItem.nouns = ['paper', 'clip']; +ClipItem.description = 'It\'s one small red paperclip.'; +allEntityClasses.push(ClipItem); + +var TradingKing = function (_engine$NpcEntity13) { + _inherits(TradingKing, _engine$NpcEntity13); + + function TradingKing() { + var _ref23; + + _classCallCheck(this, TradingKing); + + for (var _len23 = arguments.length, args = Array(_len23), _key23 = 0; _key23 < _len23; _key23++) { + args[_key23] = arguments[_key23]; + } + + var _this99 = _possibleConstructorReturn(this, (_ref23 = TradingKing.__proto__ || Object.getPrototypeOf(TradingKing)).call.apply(_ref23, [this].concat(args))); + + _this99.hasClip = true; + return _this99; + } + + _createClass(TradingKing, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + if (this.hasClip) { + this.hasClip = false; + playerState.inventory.addEntity(new ClipItem()); + var corner = playerState.location.world.corners[new cw.CornerRef(0, -1, 1, 1).key()]; + var methCooks = _.find(corner.getEntities(), function (entity) { + return entity instanceof MethCooks; + }); + if (methCooks) { + corner.removeEntity(methCooks); + } + corner.addEntity(new ClipMethCooks()); + var castleRoom = playerState.specialLocations[CastleRoomLocation.name]; + castleRoom.addEntity(new Emma()); + corner = playerState.location.world.corners[new cw.CornerRef(0, 0, 0, 1).key()]; + _.find(corner.getEntities(), function (entity) { + return entity instanceof Lumberjack; + }).hasBass = true; + return '"Ah, you must be the traveler I\'ve heard so much about. Listen, I\'d love to just fill in your passport and send you on your merry way, but they have rules in Blanc, and they might declare war if I just let you in. Well, there\'s only one rule, really, and it\'s that you need to be a property owner to go there. Specifically, you have to own one of the condos in this neighborhood. Look, I don\'t make the rules, I just... sort of float here. But I\'m going to give you a freebie, ok? Take this paper CLIP, and if you can use your wit and trading acumen to scale the social ladder and become a member of the landed gentry, I\'ll do you a good turn."\n\nThe KING hands you a paper CLIP.'; + } else { + return '"Use your wit and trading acumen to scale the social ladder and become a member of the landed gentry, and I\'ll do you a good turn."'; + } + } + }, { + key: 'giveTo', + value: function giveTo(playerState, item) { + if (item instanceof HomeKeyItem) { + var passport = _.find(playerState.inventory.getEntities(), function (entity) { + return entity instanceof PassportItem; + }); + passport.white = true; + return '"Hey neighbor! Welcome to the community. I have to say I\'m impressed. I never thought you\'d actually be able to turn that paperclip into a home. I just couldn\'t be bothered to go find a trash can. A promise is a promise; let me see your passport."\n\nYou hand him your passport, and he studies the back of it intently.\n\n"Who drew this grid? It could be useful for keeping track of activity on this island, but someone left out the heading. I\'ll fix it for you."\n\nHe scribbles some markings on your passport, and hands it back to you.'; + } + return _get(TradingKing.prototype.__proto__ || Object.getPrototypeOf(TradingKing.prototype), 'giveTo', this).call(this, playerState, item); + } + }]); + + return TradingKing; +}(engine.NpcEntity); + +TradingKing.title = 'the king'; +TradingKing.nouns = ['king']; +TradingKing.description = 'A middle-aged bearded man wearing a crown - clearly a KING - floats on an inflated raft in a pool in front of the fanciest house on the block.'; +TradingKing.takeable = false; +allEntityClasses.push(TradingKing); + +var HomeKeyItem = function (_engine$Entity61) { + _inherits(HomeKeyItem, _engine$Entity61); + + function HomeKeyItem() { + _classCallCheck(this, HomeKeyItem); + + return _possibleConstructorReturn(this, (HomeKeyItem.__proto__ || Object.getPrototypeOf(HomeKeyItem)).apply(this, arguments)); + } + + _createClass(HomeKeyItem, [{ + key: 'use', + value: function use(playerState, parsedSentence) { + if (parsedSentence.secondaryEntity instanceof CondoEntity) { + return 'The key turns smoothly in the lock. The door swings open to reveal an unfurnished condo. It looks nice enough. There\'s nothing for you there right now though.'; + } + return _get(HomeKeyItem.prototype.__proto__ || Object.getPrototypeOf(HomeKeyItem.prototype), 'use', this).call(this, playerState, parsedSentence); + } + }]); + + return HomeKeyItem; +}(engine.Entity); + +HomeKeyItem.title = 'a house key'; +HomeKeyItem.nouns = ['house', 'key']; +HomeKeyItem.description = 'It\'s the key for your condo.'; +allEntityClasses.push(HomeKeyItem); + +var TallMan = function (_engine$NpcEntity14) { + _inherits(TallMan, _engine$NpcEntity14); + + function TallMan() { + var _ref24; + + _classCallCheck(this, TallMan); + + for (var _len24 = arguments.length, args = Array(_len24), _key24 = 0; _key24 < _len24; _key24++) { + args[_key24] = arguments[_key24]; + } + + var _this101 = _possibleConstructorReturn(this, (_ref24 = TallMan.__proto__ || Object.getPrototypeOf(TallMan)).call.apply(_ref24, [this].concat(args))); + + _this101.hasKey = true; + return _this101; + } + + _createClass(TallMan, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + if (this.hasKey) { + return '"Hi, hey, hi, howya doin\'? Stan\'s the name, real estate\'s the game. Shake! No? Fist bump? No? Ok. This HOME behind me is available, for the low low price of one parcel of land where I can build a new house and start a new condo association. Don\'t care where it is, just need some property. This place is just about tapped out; this condo is the last unit for sale, so act fast fast fast!"'; + } else { + return '"Leave me alone, I\'ve got a hole to flip!"'; + } + } + }, { + key: 'giveTo', + value: function giveTo(playerState, item) { + if (item instanceof HoleItem) { + playerState.location.removeEntity(item); + playerState.inventory.removeEntity(item); + playerState.inventory.addEntity(new HomeKeyItem()); + this.hasKey = false; + return '"Lemme see. Mmmhmm. Mmmhmm. Ah, yes! This is perfect. Can I hug you? I\'m going to hug you. No? High five? No? Ok. Well, this is exactly what I needed. I\'m off to flip this sucker into some prime real estate. The HOME behind me is all yours. Take this KEY. Ok, bye. I love you. Bye."'; + } + return _get(TallMan.prototype.__proto__ || Object.getPrototypeOf(TallMan.prototype), 'giveTo', this).call(this, playerState, item); + } + }]); + + return TallMan; +}(engine.NpcEntity); + +TallMan.title = 'the tall man'; +TallMan.nouns = ['tall', 'man']; +TallMan.description = 'In front of another, less lavish HOME, a TALL MAN animatedly alternates between pacing, sighing, and checking his watch. His arms are constantly flailing, and a trick of the light makes the pattern on his gaudy gingham shirt play tricks on your eyes.'; +TallMan.takeable = false; +allEntityClasses.push(TallMan); + +var CondoEntity = function (_engine$Entity62) { + _inherits(CondoEntity, _engine$Entity62); + + function CondoEntity() { + _classCallCheck(this, CondoEntity); + + return _possibleConstructorReturn(this, (CondoEntity.__proto__ || Object.getPrototypeOf(CondoEntity)).apply(this, arguments)); + } + + return CondoEntity; +}(engine.Entity); + +CondoEntity.title = 'a condo'; +CondoEntity.nouns = ['condo', 'home']; +CondoEntity.description = 'It\'s a reasonably-sized condo with a nice-looking lawn.'; +CondoEntity.takeable = false; +allEntityClasses.push(CondoEntity); + +var MeatItem = function (_engine$Entity63) { + _inherits(MeatItem, _engine$Entity63); + + function MeatItem() { + _classCallCheck(this, MeatItem); + + return _possibleConstructorReturn(this, (MeatItem.__proto__ || Object.getPrototypeOf(MeatItem)).apply(this, arguments)); + } + + return MeatItem; +}(engine.Entity); + +MeatItem.title = 'a slab of meat'; +MeatItem.nouns = ['slab', 'meat']; +MeatItem.description = 'It\'s a slab of unidentifiable meat.'; +allEntityClasses.push(MeatItem); + +var Butcher = function (_engine$NpcEntity15) { + _inherits(Butcher, _engine$NpcEntity15); + + function Butcher() { + var _ref25; + + _classCallCheck(this, Butcher); + + for (var _len25 = arguments.length, args = Array(_len25), _key25 = 0; _key25 < _len25; _key25++) { + args[_key25] = arguments[_key25]; + } + + var _this104 = _possibleConstructorReturn(this, (_ref25 = Butcher.__proto__ || Object.getPrototypeOf(Butcher)).call.apply(_ref25, [this].concat(args))); + + _this104.hasMeat = true; + return _this104; + } + + _createClass(Butcher, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + if (this.hasMeat) { + return '"Exotic MEAT sold here. Want to eat kangaroo? Cat, dog, elephant, giraffe, unicorn, narwhal, anything you need I\'ve got it. Don\'t ask me where it all comes from, I can\'t tell, but I promise it\'s the genuine article. No money? No problem. I\'m in the market for a new porch chair. Scratch my back and I\'ll scratch yours."'; + } else { + return '"Exotic MEAT sold here. Want to eat kangaroo? Cat, dog, elephant, giraffes, unicorn, narwhal, anything you need I\'ve got it. Don\'t ask me where it all comes from, I can\'t tell, but I promise it\'s the genuine article."'; + } + } + }, { + key: 'giveTo', + value: function giveTo(playerState, item) { + if (item instanceof SeatItem) { + playerState.location.removeEntity(item); + playerState.inventory.removeEntity(item); + playerState.inventory.addEntity(new MeatItem()); + this.hasMeat = false; + return '"Let me try this bad boy out. Oh yeah. That\'s the stuff. Have some MEAT. I don\'t remember what this one was from, but it\'s probably good. Ok, bye."'; + } + return _get(Butcher.prototype.__proto__ || Object.getPrototypeOf(Butcher.prototype), 'giveTo', this).call(this, playerState, item); + } + }]); + + return Butcher; +}(engine.NpcEntity); + +Butcher.title = 'the butcher in the bloody apron'; +Butcher.nouns = ['butcher', 'bloody', 'apron', 'butcher']; +Butcher.description = 'A BUTCHER in a bloody apron sits on a creaky rocking chair.'; +Butcher.takeable = false; +allEntityClasses.push(Butcher); + +var MoldItem = function (_engine$Entity64) { + _inherits(MoldItem, _engine$Entity64); + + function MoldItem() { + _classCallCheck(this, MoldItem); + + return _possibleConstructorReturn(this, (MoldItem.__proto__ || Object.getPrototypeOf(MoldItem)).apply(this, arguments)); + } + + return MoldItem; +}(engine.Entity); + +MoldItem.title = 'some mold'; +MoldItem.nouns = ['mold']; +MoldItem.description = 'It\'s a sample of mold scraped off the giant wheel of cheese.'; +allEntityClasses.push(MoldItem); + +var Cheesemonger = function (_engine$NpcEntity16) { + _inherits(Cheesemonger, _engine$NpcEntity16); + + function Cheesemonger() { + var _ref26; + + _classCallCheck(this, Cheesemonger); + + for (var _len26 = arguments.length, args = Array(_len26), _key26 = 0; _key26 < _len26; _key26++) { + args[_key26] = arguments[_key26]; + } + + var _this106 = _possibleConstructorReturn(this, (_ref26 = Cheesemonger.__proto__ || Object.getPrototypeOf(Cheesemonger)).call.apply(_ref26, [this].concat(args))); + + _this106.hasMold = true; + return _this106; + } + + _createClass(Cheesemonger, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + if (this.hasMold) { + return '"You goddamn cheese. God. Damn. Cheese.\n\nOh, hi. Get a load of this goddamn cheese. I got it into my head that I\'d put this cheese on top of my shop. Good for business, giant cheese. Twice I\'ve put it up there, and each time it\'s fallen through the goddamn roof. Do you know how much this cheese has cost me?\n\nI think what I need is a way of buttressing it up there. Like joists that\'ll go into the ground or something. But I can\'t find anything strong enough. I tried wood. Snapped. Iron. Crumpled. I need something stronger. If you can find something that could work, I\'ll give you a free sample."'; + } else { + return 'He just keeps mumbling "goddamn cheese" under his breath.'; + } + } + }, { + key: 'giveTo', + value: function giveTo(playerState, item) { + if (item instanceof SlatItem) { + return '"Nice idea, but that\'s not going to be strong enough. I already tried wood joists, and they just snapped under the strain. Come back when you find something stronger."'; + } + if (item instanceof MeldItem) { + playerState.location.removeEntity(item); + playerState.inventory.removeEntity(item); + playerState.inventory.addEntity(new MoldItem()); + this.hasMold = false; + return '"What is this? Seems pretty solid. Worth a try. Goddamn cheese. It\'ll take some time to get the equipment in place to hoist the goddamn cheese up and test this out. If it works I\'ll give you as much cheese as you want. In the meantime, have a sample."\n\nHe scrapes some MOLD off the giant goddamn cheese with a tiny knife and hands it to you.'; + } + return _get(Cheesemonger.prototype.__proto__ || Object.getPrototypeOf(Cheesemonger.prototype), 'giveTo', this).call(this, playerState, item); + } + }]); + + return Cheesemonger; +}(engine.NpcEntity); + +Cheesemonger.title = 'the cheesemonger'; +Cheesemonger.nouns = ['cheesemonger']; +Cheesemonger.description = 'A CHEESEMONGER is pummeling the cheese with his fists.'; +Cheesemonger.takeable = false; +allEntityClasses.push(Cheesemonger); + +var MoleItem = function (_engine$Entity65) { + _inherits(MoleItem, _engine$Entity65); + + function MoleItem() { + _classCallCheck(this, MoleItem); + + return _possibleConstructorReturn(this, (MoleItem.__proto__ || Object.getPrototypeOf(MoleItem)).apply(this, arguments)); + } + + return MoleItem; +}(engine.Entity); + +MoleItem.title = 'a baby mole'; +MoleItem.nouns = ['baby', 'mole']; +MoleItem.description = 'It\'s an adorable week-old mole wrapped in a baby bjorn.'; +allEntityClasses.push(MoleItem); + +var PetStoreWoman = function (_engine$NpcEntity17) { + _inherits(PetStoreWoman, _engine$NpcEntity17); + + function PetStoreWoman() { + var _ref27; + + _classCallCheck(this, PetStoreWoman); + + for (var _len27 = arguments.length, args = Array(_len27), _key27 = 0; _key27 < _len27; _key27++) { + args[_key27] = arguments[_key27]; + } + + var _this108 = _possibleConstructorReturn(this, (_ref27 = PetStoreWoman.__proto__ || Object.getPrototypeOf(PetStoreWoman)).call.apply(_ref27, [this].concat(args))); + + _this108.hasMole = true; + return _this108; + } + + _createClass(PetStoreWoman, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + if (this.hasMole) { + return '"Hello. Welcome to Rhonda\'s ark/petshop. I\'m Rhonda. Catastrophic flood? Maybe. Entrepreneurial opportunity? Definitely. I have all of these pairs of animals in there, but they keep having babies. So I sell them as pets. It\'s a living. If you don\'t have any money I do trades. I\'ve got the entire animal kingdom covered, but I\'m a bit deficient on some of the other kingdoms. Fungi in particular. Bring me one I don\'t have, and I\'ll give you some cute baby animal. Whatever I can find really."'; + } else { + return '"Thanks again for the fungus."'; + } + } + }, { + key: 'giveTo', + value: function giveTo(playerState, item) { + if (item instanceof VialItem) { + return '"Thanks, but no thanks. At any given time about 20% of my animals are in heat. Can you see how this could go bad?"'; + } + if (item instanceof MoldItem) { + playerState.location.removeEntity(item); + playerState.inventory.removeEntity(item); + playerState.inventory.addEntity(new MoleItem()); + this.hasMole = false; + return '"Is that a Penicillium? I\'ve been looking for one of these for years. Hold on for one second and I\'ll see what I can give you for it."\n\nShe disappears into the petshop. There are lots of animal noises. She finally emerges carrying a tiny adorable furry creature in a baby bjorn.\n\n"I found a baby MOLE, probably a week old. Here you go. Thanks again for the fungus."'; + } + return _get(PetStoreWoman.prototype.__proto__ || Object.getPrototypeOf(PetStoreWoman.prototype), 'giveTo', this).call(this, playerState, item); + } + }]); + + return PetStoreWoman; +}(engine.NpcEntity); + +PetStoreWoman.title = 'the woman'; +PetStoreWoman.nouns = ['woman', 'rhonda']; +PetStoreWoman.description = 'A WOMAN stands outside hammering some weatherproof panels onto the walls.'; +PetStoreWoman.takeable = false; +allEntityClasses.push(PetStoreWoman); + +var AmuletItem = function (_engine$Entity66) { + _inherits(AmuletItem, _engine$Entity66); + + function AmuletItem() { + _classCallCheck(this, AmuletItem); + + return _possibleConstructorReturn(this, (AmuletItem.__proto__ || Object.getPrototypeOf(AmuletItem)).apply(this, arguments)); + } + + return AmuletItem; +}(engine.Entity); + +AmuletItem.title = 'an amulet'; +AmuletItem.nouns = ['amulet']; +AmuletItem.description = 'It\'s an ornate amulet given to you by the queen of Blanc. It has the imprint of a rising sun. Or is it setting? Very difficult to tell.'; +allEntityClasses.push(AmuletItem); + +var FlowerSage = function (_engine$NpcEntity18) { + _inherits(FlowerSage, _engine$NpcEntity18); + + function FlowerSage() { + _classCallCheck(this, FlowerSage); + + return _possibleConstructorReturn(this, (FlowerSage.__proto__ || Object.getPrototypeOf(FlowerSage)).apply(this, arguments)); + } + + _createClass(FlowerSage, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + if (!_.find(playerState.inventory.getEntities(), function (entity) { + return entity instanceof AmuletItem; + })) { + return 'The guard menaces you with his halberd.\n\n"Halt! This is the Queen\'s garden. Only those who have earned her favor may remain."'; + } + return '"Hi! You seem nice.\n\nYou may have noticed that this is a bountiful, fertile land. Pretty much every acre of land - except in the desert - is devoted to producing something - and that\'s what the letters on your passport refer to. I\'ll leave it to you to figure out what\'s what. As for the question of what\'s when - not to be auspicious or anything, but try consulting the signs.\n\nSince you\'ve been here, the rulers haven\'t really been in touch with each other. That means that trade has been nonexistent. Furthermore, under normal circumstances, sometimes a ruler would get a double yield from their land. That\'s not happening these days. Some sort of union thing, I don\'t know. Don\'t worry about it. It doesn\'t matter. Point is: no double yield."'; + } + }]); + + return FlowerSage; +}(engine.NpcEntity); + +FlowerSage.title = 'the flower sage'; +FlowerSage.nouns = ['flower', 'sage']; +FlowerSage.description = 'The FLOWER SAGE is planting flowers in the garden.'; +FlowerSage.takeable = false; +allEntityClasses.push(FlowerSage); + +var HedgeSage = function (_engine$NpcEntity19) { + _inherits(HedgeSage, _engine$NpcEntity19); + + function HedgeSage() { + _classCallCheck(this, HedgeSage); + + return _possibleConstructorReturn(this, (HedgeSage.__proto__ || Object.getPrototypeOf(HedgeSage)).apply(this, arguments)); + } + + _createClass(HedgeSage, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + if (!_.find(playerState.inventory.getEntities(), function (entity) { + return entity instanceof AmuletItem; + })) { + return 'The guard menaces you with his halberd.\n\n"Halt! This is the Queen\'s garden. Only those who have earned her favor may remain."'; + } + return '"So you\'re the queen\'s champion. Here\'s what I have to tell you.\n\nThere are four kingdoms in this land, as you well know. Each has achieved a different degree of prosperity based on a peculiar wealth index that was invented on this island. The 1st, 2nd, 3rd, and 4th in your passport refer to these wealth index scores - where 1st refers to the richest ruler. I can\'t tell you everything about how that score is calculated, but I do know that only locations with buildings count towards it - and for our purposes, the portcullises that separate kingdoms don\'t count as buildings, but vehicles that are used as homes do. Locations with multiple buildings are worth exactly double those with only one. So, for example, this garden is worth just one point, thanks to our gazebo.\n\nFinally, no one\'s wealth index score has changed for the entire duration you\'ve been on the island. Things have been pretty stagnant."'; + } + }]); + + return HedgeSage; +}(engine.NpcEntity); + +HedgeSage.title = 'the hedge sage'; +HedgeSage.nouns = ['hedge', 'sage']; +HedgeSage.description = 'The HEDGE SAGE is clipping a tall row of hedges.'; +HedgeSage.takeable = false; +allEntityClasses.push(HedgeSage); + +var WeedSage = function (_engine$NpcEntity20) { + _inherits(WeedSage, _engine$NpcEntity20); + + function WeedSage() { + _classCallCheck(this, WeedSage); + + return _possibleConstructorReturn(this, (WeedSage.__proto__ || Object.getPrototypeOf(WeedSage)).apply(this, arguments)); + } + + _createClass(WeedSage, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + if (!_.find(playerState.inventory.getEntities(), function (entity) { + return entity instanceof AmuletItem; + })) { + return 'The guard menaces you with his halberd.\n\n"Halt! This is the Queen\'s garden. Only those who have earned her favor may remain."'; + } + return '"No, not that kind of weed. It\'s ok, I get that all the time. I\'m called that because my expertise is pretty in the weeds. And I like weeding. Say, could you hand me that pot? The ceramic thing. Ugh, nevermind.\n\nOk, first of all, you probably know this by now, but each month follows the same cycle of stars that appear in the sky during the day. Some astronomers think we\'re in a weird three body system, or twelve body system. I think they\'re full of crap - there\'s almost no way that would be physically stable, let alone cyclical in nature. Whatever. But all of those long lists of numbers in your passport - they have to do with days of the month. Doesn\'t matter what month it is, they\'re all effectively the same. Each listed day is in the column of a specific kingdom. In each row you\'ll want to mark what the first kingdom produced on the day in the the first column, the second kingdom produced on the day in the second column, and so on for all four kingdoms. The other sages can help you figure out which kingdom\'s which and what they\u2019re producing.\n\nOh, also, you got any marijuana? Medicinal, of course. Glaucoma blows, man."'; + } + }]); + + return WeedSage; +}(engine.NpcEntity); + +WeedSage.title = 'the weed sage'; +WeedSage.nouns = ['weed', 'sage']; +WeedSage.description = 'The WEED SAGE is pulling up weeds.'; +WeedSage.takeable = false; +allEntityClasses.push(WeedSage); + +var GardenGuard = function (_engine$NpcEntity21) { + _inherits(GardenGuard, _engine$NpcEntity21); + + function GardenGuard() { + _classCallCheck(this, GardenGuard); + + return _possibleConstructorReturn(this, (GardenGuard.__proto__ || Object.getPrototypeOf(GardenGuard)).apply(this, arguments)); + } + + _createClass(GardenGuard, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + if (!_.find(playerState.inventory.getEntities(), function (entity) { + return entity instanceof AmuletItem; + })) { + return 'The guard menaces you with his halberd.\n\n"Halt! This is the Queen\'s garden. Only those who have earned her favor may remain."'; + } + return '"You have earned the queen\'s favor, and may proceed."'; + } + }, { + key: 'giveTo', + value: function giveTo(playerState, item) { + if (item instanceof StickerItem) { + return '"Oh, sorry, I should have been more specific. I meant the favor of the queen of Blanc. That sticker looks like it\'s from the queen of Crimsilon, am I right? She loves giving those out. Check it out, I put one on the shaft of my halberd."\n\nHe shows you the sticker on his halberd.\n\n"A symbol of the queen of Blanc\'s favor would be something else entirely."'; + } + if (item instanceof AmuletItem) { + return '"Thank you. You may come and go as you please."'; + } + return _get(GardenGuard.prototype.__proto__ || Object.getPrototypeOf(GardenGuard.prototype), 'giveTo', this).call(this, playerState, item); + } + }]); + + return GardenGuard; +}(engine.NpcEntity); + +GardenGuard.title = 'the guard'; +GardenGuard.nouns = ['guard']; +GardenGuard.description = 'A single GUARD with a halberd eyes you suspiciously.'; +GardenGuard.takeable = false; +allEntityClasses.push(GardenGuard); + +var Queen = function (_engine$NpcEntity22) { + _inherits(Queen, _engine$NpcEntity22); + + function Queen() { + var _ref28; + + _classCallCheck(this, Queen); + + for (var _len28 = arguments.length, args = Array(_len28), _key28 = 0; _key28 < _len28; _key28++) { + args[_key28] = arguments[_key28]; + } + + var _this114 = _possibleConstructorReturn(this, (_ref28 = Queen.__proto__ || Object.getPrototypeOf(Queen)).call.apply(_ref28, [this].concat(args))); + + _this114.hasRing = true; + return _this114; + } + + _createClass(Queen, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + if (!this.hasRing) { + return '"The answer you seek is in your PASSPORT. Go see my advisors, and listen to what they have to say. They\'re in a garden nearby. The guard will let you in if you show them my amulet."'; + } + return '"So you\'re the wanderer I\'ve been hearing about. Please, allow me to see your PASSPORT."'; + } + }, { + key: 'giveTo', + value: function giveTo(playerState, item) { + if (item instanceof PassportItem && this.hasRing) { + item.queen = true; + playerState.inventory.addEntity(new AmuletItem()); + this.hasRing = false; + return '"Yes, this is very good. I will fill in my part now, but you are not done here."\n\nShe makes some marks in your PASSPORT and hands it back to you.\n\n"Do you know why I sit here? I have become disillusioned with reality. One of my wisest advisors tells me that God does not play dice with the universe and yet... Are you familiar with the theory that all that we know of as existence is a simulation, being run within another universe, being run within another universe, and so on?\n\nLook around you. Does this place seem... right to you? Also, do you get the impression that you\'re the only person who ever goes anywhere here? It\'s weird, right?\n\nI have my suspicions about reality, and I want you to confirm them. The answer\'s in your PASSPORT. I\'ve filled in a series of numbers that came to me in a dream. Go see my advisors, and listen to what they have to say. They\'re in a garden nearby. The guard will let you in if you show him this."\n\nShe hands you an AMULET.\n\n"I have one final gift for you. If you have friends who wish to travel freely throughout this land, but don\'t want to go through all of the trouble of solving other people\'s problems, tell them to speak the phrase I AM A WATER MELLON. I promise you, this is in no way related to the answer you seek.\n\nNow go, and come back and tell me when you have the answer."'; + } + if (item instanceof PassportItem) { + return '"My eyesight has grown poor. Please read me what you have found inside."'; + } + return _get(Queen.prototype.__proto__ || Object.getPrototypeOf(Queen.prototype), 'giveTo', this).call(this, playerState, item); + } + }]); + + return Queen; +}(engine.NpcEntity); + +Queen.title = 'the queen'; +Queen.nouns = ['queen']; +Queen.description = 'At the base of the tower, the QUEEN of this kingdom sits deep in thought.'; +Queen.takeable = false; +allEntityClasses.push(Queen); + +var CulDeSacSoldiers = function (_engine$NpcEntity23) { + _inherits(CulDeSacSoldiers, _engine$NpcEntity23); + + function CulDeSacSoldiers() { + _classCallCheck(this, CulDeSacSoldiers); + + return _possibleConstructorReturn(this, (CulDeSacSoldiers.__proto__ || Object.getPrototypeOf(CulDeSacSoldiers)).apply(this, arguments)); + } + + _createClass(CulDeSacSoldiers, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + return 'You\'d better just leave the soldiers to their patrolling.'; + } + }, { + key: 'giveTo', + value: function giveTo(playerState, item) { + return 'You\'d better just leave the soldiers to their patrolling.'; + } + }]); + + return CulDeSacSoldiers; +}(engine.NpcEntity); + +CulDeSacSoldiers.title = 'the soldiers'; +CulDeSacSoldiers.nouns = ['soldiers']; +CulDeSacSoldiers.description = 'There\'s a noticeable military presence here; three soldiers march in tight circles around the cul de sac, presumably patrolling.'; +CulDeSacSoldiers.takeable = false; +allEntityClasses.push(CulDeSacSoldiers); + +var CheeseSoldier = function (_engine$NpcEntity24) { + _inherits(CheeseSoldier, _engine$NpcEntity24); + + function CheeseSoldier() { + _classCallCheck(this, CheeseSoldier); + + return _possibleConstructorReturn(this, (CheeseSoldier.__proto__ || Object.getPrototypeOf(CheeseSoldier)).apply(this, arguments)); + } + + _createClass(CheeseSoldier, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + return 'You\'d better leave the soldier alone.'; + } + }, { + key: 'giveTo', + value: function giveTo(playerState, item) { + return 'You\'d better leave the soldier alone.'; + } + }]); + + return CheeseSoldier; +}(engine.NpcEntity); + +CheeseSoldier.title = 'the soldier'; +CheeseSoldier.nouns = ['soldier']; +CheeseSoldier.description = 'A soldier stands at attention, eyeing the cheese with suspicion.'; +CheeseSoldier.takeable = false; +allEntityClasses.push(CheeseSoldier); + +var PetStoreSoldiers = function (_engine$NpcEntity25) { + _inherits(PetStoreSoldiers, _engine$NpcEntity25); + + function PetStoreSoldiers() { + _classCallCheck(this, PetStoreSoldiers); + + return _possibleConstructorReturn(this, (PetStoreSoldiers.__proto__ || Object.getPrototypeOf(PetStoreSoldiers)).apply(this, arguments)); + } + + _createClass(PetStoreSoldiers, [{ + key: 'talk', + value: function talk(playerState, parsedSentence) { + return 'You\'d better leave the soldiers alone.'; + } + }, { + key: 'giveTo', + value: function giveTo(playerState, item) { + return 'You\'d better leave the soldiers alone.'; + } + }]); + + return PetStoreSoldiers; +}(engine.NpcEntity); + +PetStoreSoldiers.title = 'the soldiers'; +PetStoreSoldiers.nouns = ['soldiers']; +PetStoreSoldiers.description = 'Two soldiers stand guard outside the front door.'; +PetStoreSoldiers.takeable = false; +allEntityClasses.push(PetStoreSoldiers); + +var World = function (_cw$World) { + _inherits(World, _cw$World); + + function World() { + _classCallCheck(this, World); + + return _possibleConstructorReturn(this, (World.__proto__ || Object.getPrototypeOf(World)).call(this)); + } + + _createClass(World, [{ + key: 'setProperties', + value: function setProperties() { + var corner; + this.customCommandRunners = {}; + this.tiles[new cw.TileRef(0, 2, -2).key()].terrain = 5; + this.tiles[new cw.TileRef(1, 1, -2).key()].terrain = 3; + this.tiles[new cw.TileRef(2, 0, -2).key()].terrain = 4; + this.tiles[new cw.TileRef(-1, 2, -1).key()].terrain = 1; + this.tiles[new cw.TileRef(0, 1, -1).key()].terrain = 2; + this.tiles[new cw.TileRef(1, 0, -1).key()].terrain = 5; + this.tiles[new cw.TileRef(2, -1, -1).key()].terrain = 0; + this.tiles[new cw.TileRef(-2, 2, 0).key()].terrain = 5; + this.tiles[new cw.TileRef(-1, 1, 0).key()].terrain = 4; + this.tiles[new cw.TileRef(0, 0, 0).key()].terrain = 1; + this.tiles[new cw.TileRef(1, -1, 0).key()].terrain = 2; + this.tiles[new cw.TileRef(2, -2, 0).key()].terrain = 4; + this.tiles[new cw.TileRef(-2, 1, 1).key()].terrain = 3; + this.tiles[new cw.TileRef(-1, 0, 1).key()].terrain = 2; + this.tiles[new cw.TileRef(0, -1, 1).key()].terrain = 5; + this.tiles[new cw.TileRef(1, -2, 1).key()].terrain = 1; + this.tiles[new cw.TileRef(-2, 0, 2).key()].terrain = 1; + this.tiles[new cw.TileRef(-1, -1, 2).key()].terrain = 3; + this.tiles[new cw.TileRef(0, -2, 2).key()].terrain = 2; + this.edges[new cw.EdgeRef(1, 2, -3, 2).key()].owner = 0; + this.edges[new cw.EdgeRef(1, 1, -2, 0).key()].owner = 0; + this.edges[new cw.EdgeRef(2, 1, -3, 2).key()].owner = 0; + this.edges[new cw.EdgeRef(2, 0, -2, 0).key()].owner = 0; + this.edges[new cw.EdgeRef(2, 0, -2, 1).key()].owner = 0; + this.edges[new cw.EdgeRef(2, -1, -1, 0).key()].owner = 0; + this.edges[new cw.EdgeRef(2, -1, -1, 1).key()].owner = 0; + this.edges[new cw.EdgeRef(2, -1, -1, 2).key()].owner = 0; + this.edges[new cw.EdgeRef(2, -2, 0, 0).key()].owner = 0; + this.edges[new cw.EdgeRef(2, -2, 0, 1).key()].owner = 0; + this.edges[new cw.EdgeRef(1, -1, 0, 0).key()].owner = 0; + this.edges[new cw.EdgeRef(1, -1, 0, 1).key()].owner = 0; + this.edges[new cw.EdgeRef(1, -2, 1, 0).key()].owner = 0; + this.edges[new cw.EdgeRef(1, 0, -1, 1).key()].owner = 1; + this.edges[new cw.EdgeRef(1, 0, -1, 2).key()].owner = 1; + this.edges[new cw.EdgeRef(0, 0, 0, 1).key()].owner = 1; + this.edges[new cw.EdgeRef(0, 0, 0, 2).key()].owner = 1; + this.edges[new cw.EdgeRef(0, -1, 1, 0).key()].owner = 1; + this.edges[new cw.EdgeRef(0, -1, 1, 1).key()].owner = 1; + this.edges[new cw.EdgeRef(0, -1, 1, 2).key()].owner = 1; + this.edges[new cw.EdgeRef(-1, 0, 1, 1).key()].owner = 1; + this.edges[new cw.EdgeRef(-1, -1, 2, 0).key()].owner = 1; + this.edges[new cw.EdgeRef(-1, -1, 2, 1).key()].owner = 1; + this.edges[new cw.EdgeRef(-1, -1, 2, 2).key()].owner = 1; + this.edges[new cw.EdgeRef(-2, -1, 3, 0).key()].owner = 1; + this.edges[new cw.EdgeRef(-2, 0, 2, 2).key()].owner = 1; + this.edges[new cw.EdgeRef(-3, 0, 3, 0).key()].owner = 1; + this.edges[new cw.EdgeRef(-3, 1, 2, 1).key()].owner = 1; + this.edges[new cw.EdgeRef(-2, 0, 2, 0).key()].owner = 2; + this.edges[new cw.EdgeRef(-2, 0, 2, 1).key()].owner = 2; + this.edges[new cw.EdgeRef(-2, 1, 1, 0).key()].owner = 2; + this.edges[new cw.EdgeRef(-2, 1, 1, 1).key()].owner = 2; + this.edges[new cw.EdgeRef(-2, 2, 0, 0).key()].owner = 2; + this.edges[new cw.EdgeRef(-2, 2, 0, 1).key()].owner = 2; + this.edges[new cw.EdgeRef(-2, 2, 0, 2).key()].owner = 2; + this.edges[new cw.EdgeRef(-1, 2, -1, 2).key()].owner = 2; + this.edges[new cw.EdgeRef(-2, 3, -1, 1).key()].owner = 3; + this.edges[new cw.EdgeRef(-1, 3, -2, 2).key()].owner = 3; + this.edges[new cw.EdgeRef(-1, 2, -1, 0).key()].owner = 3; + this.edges[new cw.EdgeRef(0, 2, -2, 1).key()].owner = 3; + this.edges[new cw.EdgeRef(0, 2, -2, 2).key()].owner = 3; + this.edges[new cw.EdgeRef(0, 1, -1, 0).key()].owner = 3; + this.edges[new cw.EdgeRef(0, 1, -1, 1).key()].owner = 3; + this.edges[new cw.EdgeRef(0, 1, -1, 2).key()].owner = 3; + this.edges[new cw.EdgeRef(0, 0, 0, 0).key()].owner = 3; + this.edges[new cw.EdgeRef(-1, 1, 0, 0).key()].owner = 3; + this.edges[new cw.EdgeRef(-1, 1, 0, 1).key()].owner = 3; + this.edges[new cw.EdgeRef(-1, 0, 1, 0).key()].owner = 3; + corner = this.corners[new cw.CornerRef(3, -1, -2, 1).key()]; + corner.description = new cw.DescriptionTemplate('You find yourself standing on a beach. Directly <%= ty %> is a huge desert - it\'s just sand as far as the eye can see. There\'s a road that meanders along the edge of the beach, which you can follow <%= ez %> or <%= ex %>.'); + corner.addEntity(new StealingKing()); + corner.addEntity(new GryphonBeerItem()); + corner = this.corners[new cw.CornerRef(2, -2, 0, 1).key()]; + corner.description = new cw.DescriptionTemplate('You are standing in the center square of a small village. There\'s a blacksmith\'s shop here. <%= tz %>, the village ends at a sheer face of a mountain. <%= ty %>, there\'s fields of wheat as far as you can see. There\'s a road out of the village <%= ex %>.'); + corner.addEntity(new NailsItem()); + var blacksmith = new Blacksmith(); + corner.addEntity(blacksmith); + this.customCommandRunners[new cw.CornerRef(2, -2, 0, 1).key()] = function (location, trimmedCommand) { + var match = trimmedCommand.match(/^(triangle|square|starburst|cone|cube|tetrahedron|tetrahedra)s?$/); + if (match) { + if (blacksmith.metalItem == null) { + return '"Give me a metal object first. Then you can choose a shape."'; + } + switch (match[1]) { + case 'triangle': + if (blacksmith.metalItem instanceof HubcapItem) { + blacksmith.metalItem = null; + location.playerState.inventory.addEntity(new TriangleHubcapItem()); + return '"OK, I can pound that into a triangle for you."\n\nHe hammers for a few minutes in a blur of activity, then hands you a flat piece of metal shaped like a triangle.'; + } + if (blacksmith.metalItem instanceof MotorcycleEngineItem) { + var newItem = new TriangleMotorcycleEngineItem(blacksmith.metalItem); + location.playerState.inventory.addEntity(newItem); + blacksmith.metalItem = null; + return '"OK, I can pound that into a triangle for you."\n\nHe hammers for a few minutes in a blur of activity, then hands you an engine with a nozzle shaped like a triangle.'; + } + break; + case 'square': + if (blacksmith.metalItem instanceof HubcapItem) { + blacksmith.metalItem = null; + location.playerState.inventory.addEntity(new SquareHubcapItem()); + return '"Sqaure, you say? No problem!"\n\nHe hammers for a few minutes in a blur of activity, then hands you a flat piece of metal shaped like a square.'; + } + if (blacksmith.metalItem instanceof MotorcycleEngineItem) { + var _newItem = new SquareMotorcycleEngineItem(blacksmith.metalItem); + location.playerState.inventory.addEntity(_newItem); + blacksmith.metalItem = null; + return '"Sqaure, you say? No problem!"\n\nHe hammers for a few minutes in a blur of activity, then hands you an engine with a nozzle in the shape of a square.'; + } + break; + case 'starburst': + if (blacksmith.metalItem instanceof HubcapItem) { + blacksmith.metalItem = null; + location.playerState.inventory.addEntity(new StarburstHubcapItem()); + return '"One starburst, coming right up."\n\nHe hammers for a few minutes in a blur of activity, and hands you a flat piece of metal in a starburst shape, with an approximately 1 foot radius. It looks like a child\'s drawing of a sawblade.'; + } + if (blacksmith.metalItem instanceof MotorcycleEngineItem) { + var _newItem2 = new StarburstMotorcycleEngineItem(blacksmith.metalItem); + location.playerState.inventory.addEntity(_newItem2); + blacksmith.metalItem = null; + return '"One starburst, coming right up."\n\nHe hammers for a few minutes in a blur of activity, then hands you an engine with a nozzle in a starburst shape.'; + } + break; + case 'cone': + if (blacksmith.metalItem instanceof HubcapItem) { + blacksmith.metalItem = null; + location.playerState.inventory.addEntity(new ConeHubcapItem()); + return '"Where do you think you are, Cone-y Island? Ha! This isn\'t Dunshire, either."\n\nHe hammers for a few minutes in a blur of activity, then hands you a hollow cone made of thin metal.'; + } + if (blacksmith.metalItem instanceof MotorcycleEngineItem) { + var _newItem3 = new ConeMotorcycleEngineItem(blacksmith.metalItem); + location.playerState.inventory.addEntity(_newItem3); + blacksmith.metalItem = null; + return '"Yeah, good choice. Maximum thrust."\n\nHe hammers for a few minutes in a blur of activity, and hands back your engine, now with a smooth conic nozzle.'; + } + break; + case 'cube': + if (blacksmith.metalItem instanceof HubcapItem) { + blacksmith.metalItem = null; + location.playerState.inventory.addEntity(new CubeHubcapItem()); + return '"A cube? Like a six-sided die? Sure, why not."\n\nHe hammers for a few minutes in a blur of activity, then hands you a hollow cube made of thin metal.'; + } + if (blacksmith.metalItem instanceof MotorcycleEngineItem) { + var _newItem4 = new CubeMotorcycleEngineItem(blacksmith.metalItem); + location.playerState.inventory.addEntity(_newItem4); + blacksmith.metalItem = null; + return '"A cube? Like a six-sided die? Sure, why not."\n\nHe hammers for a few minutes in a blur of activity, then hands you an engine with a nozzle in a cube shape.'; + } + break; + case 'tetrahedron': + case 'tetrahedra': + if (blacksmith.metalItem instanceof HubcapItem) { + blacksmith.metalItem = null; + location.playerState.inventory.addEntity(new TetrahedronHubcapItem()); + return '"Well spelled."\n\nHe hammers for a few minutes in a blur of activity, then hands you a hollow pyramid made of thin metal.'; + } + if (blacksmith.metalItem instanceof MotorcycleEngineItem) { + var _newItem5 = new TetrahedronMotorcycleEngineItem(blacksmith.metalItem); + location.playerState.inventory.addEntity(_newItem5); + blacksmith.metalItem = null; + return '"Well spelled."\n\nHe hammers for a few minutes in a blur of activity, then hands you an engine with a nozzle shaped like a tetrahedron.'; + } + break; + } + return '"I don\'t feel like making that shape right now."'; + } + return undefined; + }; + corner = this.corners[new cw.CornerRef(1, 2, -3, 1).key()]; + corner.description = new cw.DescriptionTemplate('You\'re at a dairy farm adjacent to a sizable POND. The farm has several structures: a house, stables, and a silo. <%= ty %>, some sheep are grazing in the farm\'s pastures. Directly <%= tx %> the terrain becomes a bit more hilly. The road away from the farm is <%= ey %>, and there\'s a road <%= ez %> to the next kingdom guarded by a portcullis.'); + corner.addEntity(new PondEntity()); + corner.addEntity(new Farmer()); + corner = this.corners[new cw.CornerRef(3, 0, -3, 1).key()]; + corner.description = new cw.DescriptionTemplate('You are standing outside of a lone castle perched on the side of a mountain. It has a large wooden door, stone WALLS, and a few windows on the upper stories. There are roads leading away from the castle <%= ex %> and <%= ez %>.'); + corner.addEntity(new CastleEntity()); + corner.addEntity(new CastleDoorEntity()); + corner = this.corners[new cw.CornerRef(1, -1, 0, 0).key()]; + corner.description = new cw.DescriptionTemplate('You are standing at a border checkpoint, guarded by a portcullis. The main thoroughfare traversing Cerulia can be traveled <%= ey %> and <%= ez %>, and a road leading to Crimsilon is <%= ex %>.'); + corner.addEntity(new BlueKingdomGuard()); + corner = this.corners[new cw.CornerRef(2, 0, -2, 1).key()]; + corner.description = new cw.DescriptionTemplate('You\'re at a ranger station on the edge of the desert. The ranger station itself is a small wooden cabin, and next to it is an open garage that looks like some sort of AUTO SHOP. <%= tx %> there\'s a TRAIL HEAD marked with a sign that says "Desert trail". There\'s a road leading away <%= ez %>.'); + corner.addEntity(new AutoShopEntity()); + corner.addEntity(new AutoMechanic()); + corner.addEntity(new HydraulicLiftEntity()); + corner.addEntity(new HeapOfWoodAndPlasticEntity()); + corner.addEntity(new RudderItem()); + corner.addEntity(new DesertTrailHeadEntity()); + corner.addEntity(new SandDuneEntity()); + corner.addEntity(new GlintEntity()); + corner = this.corners[new cw.CornerRef(-2, 1, 1, 1).key()]; + corner.description = new cw.DescriptionTemplate('You\'re standing in an oceanside resort town. It seems to be the off-season. The beach is <%= ty %>, and on the beach there\'s a hut marked "surf shop." Near the shop, there\'s a MESSAGE BOARD that has various notices, including the current surf conditions. <%= tz %>, the town slopes upwards toward some hills. There\'s a road out of town <%= ez %>.'); + corner.addEntity(new BeachBum()); + corner.addEntity(new MessageBoardEntity()); + corner.addEntity(new SurfConditionsEntity()); + corner.addEntity(new RockFuPaperItem()); + this.customCommandRunners[new cw.CornerRef(-2, 1, 1, 1).key()] = function (location, trimmedCommand) { + var match = trimmedCommand.match(/^surf|go surfing$/); + if (match) { + var surfboard = _.find(location.playerState.inventory.getEntities(), function (entity) { + return entity instanceof SurfboardItem; + }); + if (!surfboard) { + return 'You can\'t go surfing without a surfboard.'; + } + return surfboard.surf(); + } + return undefined; + }; + corner = this.corners[new cw.CornerRef(0, -1, 1, 1).key()]; + corner.description = new cw.DescriptionTemplate('You\'re in a trailer park. Some of the trailers show signs of habitation; others are rusted husks. All have been here so long that they could be considered permanent structures. There are hundreds of "beware of dog" signs, and the ground is covered with the bones of the illiterate or foolhardy. The only place the ground is visible is a narrow path that leads to one of the trailers that seems to be currently inhabited. It\'s dotted with scorch marks.\n\nThere are roads leading out of the park <%= ex %>, <%= ey %> and <%= ez %>.'); + corner.addEntity(new MethCooks()); + corner.addEntity(new RVEntity()); + corner = this.corners[new cw.CornerRef(0, 0, 0, 1).key()]; + corner.description = new cw.DescriptionTemplate('You\'re standing in front of a SAWMILL. There are roads <%= ey %> and <%= ez %>, and a portcullis guards a road to another kingdom <%= ex %>.'); + corner.addEntity(new Lumberjack()); + corner.addEntity(new SawmillEntity()); + corner.addEntity(new TreesEntity()); + corner = this.corners[new cw.CornerRef(1, -1, 0, 1).key()]; + corner.description = new cw.DescriptionTemplate('You\'re in a clearing. There\'s a rectangular building with two large metal vats sticking out of its roof. A SIGNBOARD swings over the DOOR. There\'s a BELL next to the door. There are roads leading away from the clearing <%= ex %> and <%= ez %>.'); + corner.addEntity(new DistillerySignEntity()); + corner.addEntity(new DistilleryDoorEntity()); + corner.addEntity(new DistilleryBellEntity()); + corner = this.corners[new cw.CornerRef(-1, 0, 1, 1).key()]; + corner.description = new cw.DescriptionTemplate('You\'re standing on a cul de sac in a nice gated neighborhood. Everyone\'s lawns are immaculate. Two roads lead out of the neighborhood, one <%= ex %> and one <%= ez %>.'); + corner.addEntity(new TradingKing()); + corner.addEntity(new TallMan()); + corner.addEntity(new CondoEntity()); + corner.addEntity(new CulDeSacSoldiers()); + corner = this.corners[new cw.CornerRef(-1, 1, 0, 1).key()]; + corner.description = new cw.DescriptionTemplate('You\'re standing in front of a lone butcher shop on the side of the road. The road continues <%= ex %> and <%= ez %>.'); + corner.addEntity(new Butcher()); + corner = this.corners[new cw.CornerRef(-1, 1, 0, 0).key()]; + corner.description = new cw.DescriptionTemplate('There\'s only a single shop here, and boy does it stink. That could have something to do with the biggest wheel of cheese you\'ve ever seen, resting against the frame of the building. It\'s secured in place by multiple ropes connected to stakes that have been hammered into the ground and nearby trees. The cheese itself is about twice as tall as the house.\n\nThere\'s a road leading away from the shop <%= ey %>, and a portcullis guarding a road to another kingdom <%= ex %>.'); + corner.addEntity(new Cheesemonger()); + corner.addEntity(new CheeseSoldier()); + corner = this.corners[new cw.CornerRef(-2, 2, 0, 1).key()]; + corner.description = new cw.DescriptionTemplate('You\'re outside a massive pet store. You can see through the window all manner of creatures moving about. Cats, dogs, elephants, giraffes, unicorns... narwhals???... it\'s quite a menagerie.\n\nThere\'s a road leading away from the pet store <%= ey %>.'); + corner.addEntity(new PetStoreWoman()); + corner.addEntity(new PetStoreSoldiers()); + corner = this.corners[new cw.CornerRef(-1, 2, -1, 0).key()]; + corner.description = new cw.DescriptionTemplate('You\'re standing in a walled Victorian garden. <%= tx %> a gazebo sits on a ledge perched about 20 feet above the ocean. There are roads leading away from the garden <%= ex %> and <%= ey %>.\n\nThere are three women in long robes working in the garden.'); + corner.addEntity(new FlowerSage()); + corner.addEntity(new WeedSage()); + corner.addEntity(new HedgeSage()); + corner.addEntity(new GardenGuard()); + corner = this.corners[new cw.CornerRef(1, 1, -2, 1).key()]; + corner.description = new cw.DescriptionTemplate('You\'re standing at the base of a single, tall tower. There are roads leading away from the tower <%= ex %> and <%= ez %>.'); + corner.addEntity(new Queen()); + this.customCommandRunners[new cw.CornerRef(1, 1, -2, 1).key()] = function (location, trimmedCommand) { + var match = trimmedCommand.match(/^(tell|say|speak).*$/); + if (match) { + return '"No, I\'m sorry, but that\'s not the answer you seek."'; + } + return undefined; + }; + corner = this.corners[new cw.CornerRef(2, -3, 1, 0).key()]; + corner.description = new cw.DescriptionTemplate('You\'re standing at the dead end of a road at the base of a huge cliff. Someone\'s gone through the trouble to put up a SIGN by the cliff. The cliff and mountains rise up <%= tx %>, while there\'s oceanfront <%= ty %> and <%= tz %>. You can take the road <%= ez %>.'); + corner.addEntity(new HexSign('the steepest cliff I\'ve ever seen')); + corner = this.corners[new cw.CornerRef(3, -2, -1, 1).key()]; + corner.description = new cw.DescriptionTemplate('You\'re at a bend in the sandy beach road. A mountain range rises up directly <%= ty %>. You can take the road <%= ex %> or <%= ez %>.'); + corner = this.corners[new cw.CornerRef(2, -2, 0, 0).key()]; + corner.description = new cw.DescriptionTemplate('You\'ve traveled until you reached a fork in the road. The roads <%= ex %> and <%= ez %> seem to meander along the beach, while the road <%= ey %> leads further inland. Looking directly <%= tz %>, it looks like the terrain gets steeper, and there\'s sandy desert as far as you can see directly <%= tx %>. The ocean is directly <%= ty %>.'); + corner = this.corners[new cw.CornerRef(2, -1, -1, 0).key()]; + corner.description = new cw.DescriptionTemplate('You\'ve reached a bend in the road. <%= ez %> the road climbs up alongside a mountain range (which is directly <%= tx %>), while <%= ex %> the road follows alongside the beach. A seemingly endless amount of desert can be seen directly <%= tz %>.'); + corner = this.corners[new cw.CornerRef(2, 0, -2, 0).key()]; + corner.description = new cw.DescriptionTemplate('You\'ve reached a lookout point along a windy mountain road. There\'s a great view of the ocean up here. Someone\'s posted a SIGN by the lookout point. The mountain road continues <%= ex %> and <%= ey %>.'); + corner.addEntity(new HexSign('High elev. Enjoy view at own risk.')); + corner = this.corners[new cw.CornerRef(2, 1, -3, 1).key()]; + corner.description = new cw.DescriptionTemplate('You\'re at a bend in the road. The road rises further up into the mountains <%= ey %>, or descends along some gentle rolling hills <%= ex %>. The ocean is directly <%= tz %>.'); + corner = this.corners[new cw.CornerRef(1, 1, -2, 0).key()]; + corner.description = new cw.DescriptionTemplate('You\'re walking between some hills directly <%= tz %> and the ocean directly <%= tx %> and <%= ty %>. There\'s a SIGN marking this area of hilly terrain.'); + corner.addEntity(new HexSign('The "Semper Fi" Veldt')); + corner = this.corners[new cw.CornerRef(0, 0, 0, 0).key()]; + corner.description = new cw.DescriptionTemplate('You\'re at a crossroads - there are roads leading away from here <%= ex %>, <%= ey %> and <%= ez %>. <%= ty %>, you see some livestock grazing next to a SIGN. <%= tz %>, you see a field of crops. <%= tx %>, you see a dense forest.'); + corner.addEntity(new HexSign('Sheep networking function, last Saturday of the month')); + corner = this.corners[new cw.CornerRef(0, 1, -1, 1).key()]; + corner.description = new cw.DescriptionTemplate('The road splits here. <%= tx %>, you see a field of crops, marked with a SIGN. There are roads <%= ex %>, <%= ey %> and <%= ez %>.'); + corner.addEntity(new HexSign('posted: the commonwealth re-elects the Queen of Blanc')); + corner = this.corners[new cw.CornerRef(-1, -2, 3, 0).key()]; + corner.description = new cw.DescriptionTemplate('You stop at a bend in the road. <%= ty %>, you see a grove of trees marked with a SIGN. The road continues <%= ez %> and <%= ey %>.'); + corner.addEntity(new HexSign('Lots of gingkos here: path reeks. Fair warning.')); + corner = this.corners[new cw.CornerRef(-2, 2, 0, 0).key()]; + corner.description = new cw.DescriptionTemplate('You\'re at a portcullis guarding a road between kingdoms. The road to one kingdom is <%= ez %>, while the other is <%= ex %>. <%= ty %> you see some well-manicured wheat fields marked with a SIGN.'); + corner.addEntity(new HexSign('Field Of Our Holy Crops')); + corner = this.corners[new cw.CornerRef(-1, -1, 2, 1).key()]; + corner.description = new cw.DescriptionTemplate('You\'re at a bend in the road that winds along the shore. You may continue traveling <%= ex %> or <%= ey %>. In the hills <%= tz %> there\'s a clay pit with a SIGN nearby.'); + corner.addEntity(new HexSign('Info Urchins give tours on the hour')); + corner = this.corners[new cw.CornerRef(-2, 0, 2, 1).key()]; + corner.description = new cw.DescriptionTemplate('You\'re at a bend in the road that winds along the shore. You may continue traveling <%= ex %> or <%= ey %>. <%= tz %> there are crops planted as far as you can see, marked with a SIGN.'); + corner.addEntity(new HexSign('King\'s Fields IX - XIV')); + corner = this.corners[new cw.CornerRef(-2, 1, 1, 0).key()]; + corner.description = new cw.DescriptionTemplate('You\'re at a crossroads. There are roads leading away from here <%= ex %>, <%= ey %>, and <%= ez %>. <%= ty %>, there\'s evidence of a crude mining operation where someone\'s been chipping away at the side of a mountain. There\'s an advisory SIGN posted.'); + corner.addEntity(new HexSign('Remember: pounds of force = psi x square inches')); + corner = this.corners[new cw.CornerRef(0, -2, 2, 0).key()]; + corner.description = new cw.DescriptionTemplate('You\'re standing at a bend in the road. The road continues <%= ey %> and <%= ez %>. <%= ty %>, there\'s a huge farm growing crops, and running along the farm is a track marked with a SIGN.'); + corner.addEntity(new HexSign('Freight Passage')); + corner = this.corners[new cw.CornerRef(0, 2, -2, 1).key()]; + corner.description = new cw.DescriptionTemplate('You\'re standing at a bend in the road. The road continues <%= ex %> and <%= ey %>. <%= tz %> you see a bucolic scene: some livestock grazing in a grassy field, and a SIGN with a delightful message.'); + corner.addEntity(new HexSign('Winter sleigh turnoff ahead')); + corner = this.corners[new cw.CornerRef(-2, 0, 2, 0).key()]; + corner.description = new cw.DescriptionTemplate('You\'re standing at a bend in the road. The road continues <%= ex %> and <%= ez %>. <%= tx %> you see a SIGN by some hills.'); + corner.addEntity(new HexSign('Hey noob, gain your balance in inexperienced surfer training area! On the other side of the hills.')); + corner = this.corners[new cw.CornerRef(1, -2, 1, 0).key()]; + corner.description = new cw.DescriptionTemplate('You\'re standing at a bend in the road. The road continues <%= ex %> and <%= ez %>. <%= tx %> you see a wooded area marked with a SIGN.'); + corner.addEntity(new HexSign('Tannin Ecology Center')); + corner = this.corners[new cw.CornerRef(0, 1, -1, 0).key()]; + corner.description = new cw.DescriptionTemplate('You\'re standing at a crossroads. Roads lead away from here <%= ex %>, <%= ey %> and <%= ez %>. <%= tz %> you see a dense forest marked with a SIGN.'); + corner.addEntity(new HexSign('Halt! Endangered species habitat. No entry.')); + corner = this.corners[new cw.CornerRef(-1, 2, -1, 1).key()]; + corner.description = new cw.DescriptionTemplate('You\'re standing at a crossroads. Roads lead away from here <%= ex %>, <%= ey %> and <%= ez %>. <%= ty %> you see a pasture marked with a SIGN.'); + corner.addEntity(new HexSign('Sheep are tender animals. Please pet gently.')); + corner = this.corners[new cw.CornerRef(0, -1, 1, 0).key()]; + corner.description = new cw.DescriptionTemplate('You\'re standing at a crossroads. Roads lead away from here <%= ex %>, <%= ey %> and <%= ez %>. <%= tz %> you see a pasture marked with a SIGN.'); + corner.addEntity(new HexSign('When are squirrel evenings?')); + corner = this.corners[new cw.CornerRef(-1, -1, 2, 0).key()]; + corner.description = new cw.DescriptionTemplate('You\'re standing at a bend in the road. The road continues <%= ex %> and <%= ez %>. <%= tx %> is a thick forest, an area of which is marked with a SIGN.'); + corner.addEntity(new HexSign('George H. Atwel Vegetable Grove')); + corner = this.corners[new cw.CornerRef(-1, 3, -2, 1).key()]; + corner.description = new cw.DescriptionTemplate('You\'re at a bend in the road. You\'re next to a large field, and the road follows the beach both <%= ey %> and <%= ez %>. The ocean is <%= ty %>.'); + corner = this.corners[new cw.CornerRef(2, -1, -1, 1).key()]; + corner.description = new cw.DescriptionTemplate('You\'re standing at a crossroads, at the base of a mountain that\'s <%= tx %>. Looking <%= ty %> you see a dense forest, and <%= tz %> a desert. Roads lead away from here <%= ex %>, <%= ey %> and <%= ez %>.'); + corner = this.corners[new cw.CornerRef(1, 0, -1, 1).key()]; + corner.description = new cw.DescriptionTemplate('You\'re standing at a crossroads. <%= tx %> is a forest, and <%= tz %> you can see sheep grazing. Roads lead away from here <%= ex %>, <%= ey %> and <%= ez %>, and there\'s a portcullis guarding the road <%= ex %>.'); + corner = this.corners[new cw.CornerRef(-2, -1, 3, 0).key()]; + corner.description = new cw.DescriptionTemplate('You\'re standing at a crossroads. There\'s a portcullis here; on one side a road leads <%= ez %> into the interior of Merrygold. On the other side, a coastal road runs <%= ey %> and <%= ex %> within Cerulia.'); + corner = this.corners[new cw.CornerRef(-3, 0, 3, 0).key()]; + corner.description = new cw.DescriptionTemplate('You\'re at a bend in the road, alongside a large, thriving grain field <%= ty %>. You have magnificent views of the ocean on all other sides. The road leads away from here <%= ez %> and <%= ex %>.'); + corner = this.corners[new cw.CornerRef(-1, 0, 1, 0).key()]; + corner.description = new cw.DescriptionTemplate('You\'re at a bend in the road. A mountain rises up <%= tx %>, its peak lost in the clouds. <%= tz %> there\'s a forest where you can see evidence of an extensive logging operation. And <%= ty %> are stalks of grain, waving idly in the breeze. The road continues <%= ez %> and <%= ex %>.'); + } + }]); + + return World; +}(cw.World); + +var DAY_NAMES = ['first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth', 'eleventh', 'twelfth', 'thirteenth', 'fourteenth', 'fifteenth', 'sixteenth', 'seventeenth', 'eighteenth', 'nineteenth', 'twentieth', 'twenty-first', 'twenty-second', 'twenty-third', 'twenty-fourth', 'twenty-fifth', 'twenty-sixth', 'twenty-seventh', 'twenty-eighth', 'twenty-ninth', 'thirtieth']; +var DAY_STARS = [9, 10, 9, 10, 3, 6, 8, 8, 4, 7, 3, 5, 10, 8, 5, 5, 9, 10, 4, 8, 2, 7, 6, 3, 8, 11, 12, 8, 11, 10]; +var STAR_NUMBER_NAMES = { + 2: 'Two', + 3: 'Three', + 4: 'Four', + 5: 'Five', + 6: 'Six', + 7: 'Seven', + 8: 'Eight', + 9: 'Nine', + 10: 'Ten', + 11: 'Eleven', + 12: 'Twelve' +}; + +var PlayerState = function (_engine$PlayerState) { + _inherits(PlayerState, _engine$PlayerState); + + function PlayerState() { + _classCallCheck(this, PlayerState); + + var _this119 = _possibleConstructorReturn(this, (PlayerState.__proto__ || Object.getPrototypeOf(PlayerState)).call(this)); + + _this119.returnLocation = null; + _this119.specialLocations = {}; + _this119.specialLocations[CastleWindowLocation.name] = new CastleWindowLocation(_this119); + _this119.specialLocations[CastleRoomLocation.name] = new CastleRoomLocation(_this119); + _this119.specialLocations[BottomOfDuneLocation.name] = new BottomOfDuneLocation(_this119); + _this119.specialLocations[RavineLocation.name] = new RavineLocation(_this119); + _this119.specialLocations[RedBusLocation.name] = new RedBusLocation(_this119); + _this119.specialLocations[EjectorSeatLocation.name] = new EjectorSeatLocation(_this119); + _this119.specialLocations[PlateauLocation.name] = new PlateauLocation(_this119); + _this119.daysPassed = 0; + _this119.nailBoots = false; + return _this119; + } + + _createClass(PlayerState, [{ + key: 'lookUp', + value: function lookUp() { + var dayName = DAY_NAMES[this.daysPassed]; + var starNumberName = STAR_NUMBER_NAMES[DAY_STARS[this.daysPassed]]; + return starNumberName + ' stars are visible in the sky. It is the ' + dayName + ' day of the month.'; + } + }, { + key: 'lookAtMe', + value: function lookAtMe() { + if (this.nailBoots) { + return 'You\'re wearing nondescript, slightly weathered black clothing, and boots with some nails sticking out of their toes. Extra grippy!'; + } else { + return 'You\'re wearing nondescript, slightly weathered black clothing, and a sturdy pair of boots. The boots seem to be made of leather, and are solidly built. You could get a lot of mileage out of these.'; + } + } + }, { + key: 'useWithBoots', + value: function useWithBoots(entity) { + if (entity instanceof NailsItem) { + this.inventory.removeEntity(entity); + this.nailBoots = true; + return 'You punch the nails through the toes of your boots.\n\nYou\'ve fashioned a crude pair of crampons.'; + } else { + return 'It\'s unclear how ' + entity.title() + ' can be used with your boots.'; + } + } + }, { + key: 'move', + value: function move(direction) { + var moved = _get(PlayerState.prototype.__proto__ || Object.getPrototypeOf(PlayerState.prototype), 'move', this).call(this, direction); + if (moved && _.contains(['left', 'right', 'back'], direction)) { + this.daysPassed++; + if (this.daysPassed >= 30) { + this.daysPassed = 0; + } + } + return moved; + } + }, { + key: 'getPassportOwners', + value: function getPassportOwners() { + var passportOwners = [0]; + var passport = _.find(this.inventory.getEntities(), function (entity) { + return entity instanceof PassportItem; + }); + if (passport) { + if (passport.blue) { + passportOwners.push(1); + } + if (passport.orange) { + passportOwners.push(2); + } + if (passport.white) { + passportOwners.push(3); + } + } + return passportOwners; + } + }]); + + return PlayerState; +}(engine.PlayerState); + +exports.PlayerState = PlayerState; + +var Location = function (_cw$Location) { + _inherits(Location, _cw$Location); + + function Location(world, ref, orientation, playerState) { + _classCallCheck(this, Location); + + var _this120 = _possibleConstructorReturn(this, (Location.__proto__ || Object.getPrototypeOf(Location)).call(this, world, ref, orientation, playerState)); + + _this120.puzzleWorld = world; + _this120.puzzlePlayerState = playerState; + return _this120; + } + + _createClass(Location, [{ + key: 'createLocation', + value: function createLocation(ref, orientation) { + return new Location(this.puzzleWorld, ref, orientation, this.puzzlePlayerState); + } + }, { + key: 'allowEdgeExit', + value: function allowEdgeExit(edge) { + if (edge.owner === undefined) { + return false; + } + var passportOwners = this.puzzlePlayerState.getPassportOwners(); + return _.contains(passportOwners, edge.owner); + } + }, { + key: 'runTrimmedCommand', + value: function runTrimmedCommand(trimmedCommand) { + var customCommandRunner = this.puzzleWorld.customCommandRunners[this.ref.key()]; + if (customCommandRunner) { + return customCommandRunner(this, trimmedCommand); + } + return undefined; + } + }]); + + return Location; +}(cw.Location); + +exports.Location = Location; +var puzzleLexicon = {}; +var _iteratorNormalCompletion = true; +var _didIteratorError = false; +var _iteratorError = undefined; + +try { + for (var _iterator = allEntityClasses[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var entityClass = _step.value; + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; + + try { + for (var _iterator2 = entityClass.nouns[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var noun = _step2.value; + + puzzleLexicon[noun] = 'Noun'; + } + } catch (err) { + _didIteratorError2 = true; + _iteratorError2 = err; + } finally { + try { + if (!_iteratorNormalCompletion2 && _iterator2.return) { + _iterator2.return(); + } + } finally { + if (_didIteratorError2) { + throw _iteratorError2; + } + } + } + + var _iteratorNormalCompletion3 = true; + var _didIteratorError3 = false; + var _iteratorError3 = undefined; + + try { + for (var _iterator3 = _.keys(entityClass.verbs)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { + var verb = _step3.value; + + puzzleLexicon[verb] = 'Verb'; + } + } catch (err) { + _didIteratorError3 = true; + _iteratorError3 = err; + } finally { + try { + if (!_iteratorNormalCompletion3 && _iterator3.return) { + _iterator3.return(); + } + } finally { + if (_didIteratorError3) { + throw _iteratorError3; + } + } + } + } +} catch (err) { + _didIteratorError = true; + _iteratorError = err; +} finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } +} + +var lexicon = _.extend(nlp.lexicon(), puzzleLexicon); + +var Commander = function (_engine$Commander) { + _inherits(Commander, _engine$Commander); + + function Commander(puzzlePlayerState) { + _classCallCheck(this, Commander); + + var _this121 = _possibleConstructorReturn(this, (Commander.__proto__ || Object.getPrototypeOf(Commander)).call(this, puzzlePlayerState, lexicon)); + + _this121.puzzlePlayerState = puzzlePlayerState; + return _this121; + } + + _createClass(Commander, [{ + key: 'runTrimmedCommand', + value: function runTrimmedCommand(trimmedCommand) { + if (trimmedCommand.match(/.*nil sine numine.*/)) { + if (this.puzzlePlayerState.location.ref.key() == new cw.CornerRef(1, 1, -2, 1).key()) { + this.gameOver = true; + return 'Your words echo out and the ground begins shaking. The queen tells you that when everything is over you should call that in - whatever that means. She takes you by the hand and together you climb the tower. From this vantage you can see the sea in turmoil and great rifts appearing across the land. Buildings in the distance collapse one after another. Emma\'s castle crumbles. Elsewhere the giant wheel of cheese crashes down and crushes the shop. The roads you have travelled are disappearing as water rushes in on all sides and divides the land into many separate islands. These slowly sink beneath the waves, and soon only the tops of mountains are visible, then they too disappear. Now there is only the tower you\'re standing on, just a few feet above the roiling water.\n\nBut... off in the distance you spy a familiar shape, struggling to stay above the waves. It\'s Rhonda\'s ark! She anchors next to you, and Rhonda, Desmond, and Emma appear at the rail. Emma calls down, "Hey, need a lift? We have room for one more. We\'re going to find a new home and repopulate the earth." You glance back to offer the spot to the Queen of Blanc, but she\'s vanished, perhaps swept over by a wave. A rope lands at your feet, and you cling to it, as the crown of the tower sinks beneath the waves.\n\nYou climb up the hull and collapse on the deck. When you muster up the strength to rise, you notice a change in the air. Light seems to be slowly leaching out of the world. For the first time you can remember, there are no stars visible in the sky. The last of the light forms a thin line on the horizon, then winks out altogether.\n\nYou huddle with the other survivors, waiting for the sun to rise and a new world to begin.'; + } else { + return 'That sounds right, but you\'re in the wrong spot. The queen of Blanc told you to bring her the answer; try saying it by the tower.'; + } + } + if (trimmedCommand == 'look up') { + return this.puzzlePlayerState.lookUp() + '\n'; + } + var match = trimmedCommand.match(/^(describe|examine|inspect|look at|x) (me|myself|boot|boots)$/); + if (match) { + return this.puzzlePlayerState.lookAtMe() + '\n'; + } + match = trimmedCommand.match(/^(?:combine|put|use) (.*) (and|in|on|with) (my )?boot(s)?$/); + if (match) { + var item = this.puzzlePlayerState.inventory.findEntity(nlp.sentence(match[1]).terms); + if (item instanceof engine.Entity) { + return this.puzzlePlayerState.useWithBoots(item) + '\n'; + } else { + return 'I didn\'t understand that.\n'; + } + } + match = trimmedCommand.match(/^(?:combine|put|use) (?:my )?boot(?:s)? (?:and|in|on|with) (.*)$/); + if (match) { + var _item = this.puzzlePlayerState.inventory.findEntity(nlp.sentence(match[1]).terms); + if (_item instanceof engine.Entity) { + return this.puzzlePlayerState.useWithBoots(_item) + '\n'; + } else { + return 'I didn\'t understand that.\n'; + } + } + match = trimmedCommand.match(/^i am a water mellon$/); + if (match) { + var passport = _.find(this.puzzlePlayerState.inventory.getEntities(), function (item) { + return item instanceof PassportItem; + }); + if (!passport) { + passport = new PassportItem(); + this.puzzlePlayerState.inventory.addEntity(passport); + } + passport.blue = true; + passport.orange = true; + passport.white = true; + passport.queen = true; + return 'What a strange thing to say. You\'re a watermelon? That seems highly unlikely. Oh, wait, did you say WATER MELLON?\n\nA gryphon swoops down out of nowhere and drops a passport into your outstretched hand. It includes visas for all of the kingdoms of the realm, and a grid containing numbers and letters. You can travel freely throughout the land.'; + } + match = trimmedCommand.match(/^cheatitem (.*)$/); + if (match) { + var entityClass = _.find(allEntityClasses, function (entityClass) { + return entityClass.name.toLowerCase() === match[1]; + }); + if (!entityClass) { + return 'Unknown entity class: ' + match[1] + '. Try one of the following:\n' + allEntityClasses.map(function (c) { + return c.name; + }).filter(function (s) { + return s.endsWith('Item'); + }).join('\n'); + } + this.puzzlePlayerState.inventory.addEntity(new entityClass()); + return 'Added to inventory.'; + } + match = trimmedCommand.match(/^cheatdestroyitem (.*)$/); + if (match) { + var _item2 = this.puzzlePlayerState.inventory.findEntity(nlp.sentence(match[1]).terms); + if (_item2 instanceof engine.Entity) { + this.puzzlePlayerState.inventory.removeEntity(_item2); + return 'Removed from inventory.'; + } else { + return 'I didn\'t understand that.\n'; + } + } + match = trimmedCommand.match(/^cheatwarp (-?\d) (-?\d) (-?\d) ([ns])$/); + if (match) { + this.puzzlePlayerState.location.ref = new cw.CornerRef(Number(match[1]), Number(match[2]), Number(match[3]), match[4] === 'n' ? 0 : 1); + return 'Warped.'; + } + match = trimmedCommand.match(/^cheatpassport (blue|orange|white|queen)$/); + if (match) { + var _passport = _.find(this.puzzlePlayerState.inventory.getEntities(), function (item) { + return item instanceof PassportItem; + }); + if (!_passport) { + _passport = new PassportItem(); + this.puzzlePlayerState.inventory.addEntity(_passport); + } + if (match[1] == 'blue') { + _passport.blue = true; + } + if (match[1] == 'orange') { + _passport.orange = true; + } + if (match[1] == 'white') { + _passport.white = true; + } + if (match[1] == 'queen') { + _passport.queen = true; + } + return 'Passport updated.'; + } + return _get(Commander.prototype.__proto__ || Object.getPrototypeOf(Commander.prototype), 'runTrimmedCommand', this).call(this, trimmedCommand); + } + }]); + + return Commander; +}(engine.Commander); + +exports.Commander = Commander; +function create() { + var playerState = new PlayerState(); + var location = new Location(new World(), new cw.CornerRef(3, -1, -2, 1), new cw.Orientation(1), playerState); + playerState.location = location; + return playerState; +} +exports.create = create; + +/***/ } +/******/ ]); diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0801_MIT_Mystery_Hunt_2017_Arsenic/dungeon-background.png b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0801_MIT_Mystery_Hunt_2017_Arsenic/dungeon-background.png new file mode 100644 index 0000000000000000000000000000000000000000..bcb029a1c635db7cf3120420f84a3ca0969ea8a2 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0801_MIT_Mystery_Hunt_2017_Arsenic/dungeon-background.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:508512295f999bd7253d653a8ca7ce2090f9dfc404a4aa73a0c8c55ca533aa33 +size 587461 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0802_MIT_Mystery_Hunt_2017_A_Beauty_Cold_and_Austere/dungeon-background.png b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0802_MIT_Mystery_Hunt_2017_A_Beauty_Cold_and_Austere/dungeon-background.png new file mode 100644 index 0000000000000000000000000000000000000000..bcb029a1c635db7cf3120420f84a3ca0969ea8a2 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0802_MIT_Mystery_Hunt_2017_A_Beauty_Cold_and_Austere/dungeon-background.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:508512295f999bd7253d653a8ca7ce2090f9dfc404a4aa73a0c8c55ca533aa33 +size 587461 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0803_MIT_Mystery_Hunt_2017_Dancing_Girls/dungeon-background.png b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0803_MIT_Mystery_Hunt_2017_Dancing_Girls/dungeon-background.png new file mode 100644 index 0000000000000000000000000000000000000000..bcb029a1c635db7cf3120420f84a3ca0969ea8a2 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0803_MIT_Mystery_Hunt_2017_Dancing_Girls/dungeon-background.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:508512295f999bd7253d653a8ca7ce2090f9dfc404a4aa73a0c8c55ca533aa33 +size 587461 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0804_MIT_Mystery_Hunt_2017_Hamiltonian_Path/dungeon-background.png b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0804_MIT_Mystery_Hunt_2017_Hamiltonian_Path/dungeon-background.png new file mode 100644 index 0000000000000000000000000000000000000000..bcb029a1c635db7cf3120420f84a3ca0969ea8a2 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0804_MIT_Mystery_Hunt_2017_Hamiltonian_Path/dungeon-background.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:508512295f999bd7253d653a8ca7ce2090f9dfc404a4aa73a0c8c55ca533aa33 +size 587461 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0805_MIT_Mystery_Hunt_2017_How_I_Spent_My_Pre_Post-Apocalyptic_Vacation/dungeon-background.png b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0805_MIT_Mystery_Hunt_2017_How_I_Spent_My_Pre_Post-Apocalyptic_Vacation/dungeon-background.png new file mode 100644 index 0000000000000000000000000000000000000000..bcb029a1c635db7cf3120420f84a3ca0969ea8a2 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0805_MIT_Mystery_Hunt_2017_How_I_Spent_My_Pre_Post-Apocalyptic_Vacation/dungeon-background.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:508512295f999bd7253d653a8ca7ce2090f9dfc404a4aa73a0c8c55ca533aa33 +size 587461 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0806_MIT_Mystery_Hunt_2017_Hum_a_Few_More_Bars/dungeon-background.png b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0806_MIT_Mystery_Hunt_2017_Hum_a_Few_More_Bars/dungeon-background.png new file mode 100644 index 0000000000000000000000000000000000000000..bcb029a1c635db7cf3120420f84a3ca0969ea8a2 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0806_MIT_Mystery_Hunt_2017_Hum_a_Few_More_Bars/dungeon-background.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:508512295f999bd7253d653a8ca7ce2090f9dfc404a4aa73a0c8c55ca533aa33 +size 587461 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0807_MIT_Mystery_Hunt_2017_It_s_Only_a_Model/dungeon-background.png b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0807_MIT_Mystery_Hunt_2017_It_s_Only_a_Model/dungeon-background.png new file mode 100644 index 0000000000000000000000000000000000000000..bcb029a1c635db7cf3120420f84a3ca0969ea8a2 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0807_MIT_Mystery_Hunt_2017_It_s_Only_a_Model/dungeon-background.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:508512295f999bd7253d653a8ca7ce2090f9dfc404a4aa73a0c8c55ca533aa33 +size 587461 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0808_MIT_Mystery_Hunt_2017_Marvels_of_the_Ancient_World/dungeon-background.png b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0808_MIT_Mystery_Hunt_2017_Marvels_of_the_Ancient_World/dungeon-background.png new file mode 100644 index 0000000000000000000000000000000000000000..bcb029a1c635db7cf3120420f84a3ca0969ea8a2 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0808_MIT_Mystery_Hunt_2017_Marvels_of_the_Ancient_World/dungeon-background.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:508512295f999bd7253d653a8ca7ce2090f9dfc404a4aa73a0c8c55ca533aa33 +size 587461 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0809_MIT_Mystery_Hunt_2017_Missing_Links/Brochure_13.png b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0809_MIT_Mystery_Hunt_2017_Missing_Links/Brochure_13.png new file mode 100644 index 0000000000000000000000000000000000000000..675a7c9666f70ad627454f2041fc27ae4bff2d51 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0809_MIT_Mystery_Hunt_2017_Missing_Links/Brochure_13.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cda6354e27abfb9852eeca3d5efc6f71a4db8b0e51a11fe3cd0b33132a58430f +size 701814 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0809_MIT_Mystery_Hunt_2017_Missing_Links/dungeon-background.png b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0809_MIT_Mystery_Hunt_2017_Missing_Links/dungeon-background.png new file mode 100644 index 0000000000000000000000000000000000000000..bcb029a1c635db7cf3120420f84a3ca0969ea8a2 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0809_MIT_Mystery_Hunt_2017_Missing_Links/dungeon-background.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:508512295f999bd7253d653a8ca7ce2090f9dfc404a4aa73a0c8c55ca533aa33 +size 587461 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0810_MIT_Mystery_Hunt_2017_Repeated_Punishment/dungeon-background.png b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0810_MIT_Mystery_Hunt_2017_Repeated_Punishment/dungeon-background.png new file mode 100644 index 0000000000000000000000000000000000000000..bcb029a1c635db7cf3120420f84a3ca0969ea8a2 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0810_MIT_Mystery_Hunt_2017_Repeated_Punishment/dungeon-background.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:508512295f999bd7253d653a8ca7ce2090f9dfc404a4aa73a0c8c55ca533aa33 +size 587461 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0811_MIT_Mystery_Hunt_2017_Star_Tours/_solution_assets/dungeon-background.png b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0811_MIT_Mystery_Hunt_2017_Star_Tours/_solution_assets/dungeon-background.png new file mode 100644 index 0000000000000000000000000000000000000000..bcb029a1c635db7cf3120420f84a3ca0969ea8a2 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0811_MIT_Mystery_Hunt_2017_Star_Tours/_solution_assets/dungeon-background.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:508512295f999bd7253d653a8ca7ce2090f9dfc404a4aa73a0c8c55ca533aa33 +size 587461 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0811_MIT_Mystery_Hunt_2017_Star_Tours/dungeon-background.png b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0811_MIT_Mystery_Hunt_2017_Star_Tours/dungeon-background.png new file mode 100644 index 0000000000000000000000000000000000000000..bcb029a1c635db7cf3120420f84a3ca0969ea8a2 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0811_MIT_Mystery_Hunt_2017_Star_Tours/dungeon-background.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:508512295f999bd7253d653a8ca7ce2090f9dfc404a4aa73a0c8c55ca533aa33 +size 587461 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r08m_MIT_Mystery_Hunt_2017_The_Dismal_Dungeon/_solution_assets/dungeon-background.png b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r08m_MIT_Mystery_Hunt_2017_The_Dismal_Dungeon/_solution_assets/dungeon-background.png new file mode 100644 index 0000000000000000000000000000000000000000..bcb029a1c635db7cf3120420f84a3ca0969ea8a2 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r08m_MIT_Mystery_Hunt_2017_The_Dismal_Dungeon/_solution_assets/dungeon-background.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:508512295f999bd7253d653a8ca7ce2090f9dfc404a4aa73a0c8c55ca533aa33 +size 587461 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r08m_MIT_Mystery_Hunt_2017_The_Dismal_Dungeon/dungeon-background.png b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r08m_MIT_Mystery_Hunt_2017_The_Dismal_Dungeon/dungeon-background.png new file mode 100644 index 0000000000000000000000000000000000000000..bcb029a1c635db7cf3120420f84a3ca0969ea8a2 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r08m_MIT_Mystery_Hunt_2017_The_Dismal_Dungeon/dungeon-background.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:508512295f999bd7253d653a8ca7ce2090f9dfc404a4aa73a0c8c55ca533aa33 +size 587461 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0901_MIT_Mystery_Hunt_2017_Cabin_Fever/image01.png b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0901_MIT_Mystery_Hunt_2017_Cabin_Fever/image01.png new file mode 100644 index 0000000000000000000000000000000000000000..4d8842a66b514d363960c10fd2b577c393c576d6 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r0901_MIT_Mystery_Hunt_2017_Cabin_Fever/image01.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8833aaf23064b80f804e9d63c63f56cb4208dffffa5fa8531d3325ea64f09596 +size 717084 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/example_piece1.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/example_piece1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6f9af740f57656b6ae9ae52b30353892ed75bb27 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/example_piece1.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4eb29b7a2fbd9843f48a29e61543bcbcc23a15836d8a3db6289247fdc1deffaa +size 618488 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/example_piece2.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/example_piece2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0916aab0d40b9bf4f7cd9bd6fecd824dd713691f --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/example_piece2.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2e71e4525a78eb92cf8f9855725e2804ad09a92ebfd0ae6bd79f1033ff4c1e2b +size 604620 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/example_solved_lettered.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/example_solved_lettered.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c90deaa4d1ff69b74a3dca3b5538e2d20c064340 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/example_solved_lettered.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2e9f7e4a7f4d0ec288128d60044f2bb7f4a06502bd687c6b5a4e638c3144a70f +size 625810 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece1-1.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece1-1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c06eceac73504fdff27c77f29e65cbec50c4f6d2 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece1-1.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f8ea1c9037b1a1cd850e3d1489aa61a3b34d5640e32b65839af0ef34dc85a709 +size 663340 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece1-2.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece1-2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..415f733266815b6f99f6248fca65469ff3f0fb27 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece1-2.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6cc818535572ee6b82968b1e89059d09935064cd7eac0717ccbc5bc39a859333 +size 660384 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece1-3.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece1-3.jpg new file mode 100644 index 0000000000000000000000000000000000000000..474405b8e2594a72efb1fbf591b22e1e987ed4dc --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece1-3.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7364c345b7ca7d2b5870e7af43375a227a5b88d4724aade30e9efc5e20ed2403 +size 660188 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece2-1.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece2-1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..7e64a79e19a8d20833d949c11cbfc800ad8561a4 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece2-1.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:699f0b8af6c9f9acd327525e898615817efdf001340f8755d9c8d68622525b23 +size 652856 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece2-2.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece2-2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..2a52d0ae86e5ff86bac390bef44c57971e4b9b12 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece2-2.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b63d71325f26a5c1cd13b7995d9698bc09e63b7cc213760ed054aeb162556b2f +size 655589 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece2-3.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece2-3.jpg new file mode 100644 index 0000000000000000000000000000000000000000..696682e5fbb70092a8d47a76cb8c651b7a6a0b8f --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece2-3.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:334d0cbc313919a6248dd16fe24d60d9f4ef9f89b1dbc1f104e3ecf84923dc6a +size 653167 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece3-1.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece3-1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..cbfecc39f76747d83a760b758f236043779dfa26 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece3-1.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0cc6054b780593365bd39055166cb33996974a0a37fee51c4076e3b609414118 +size 657344 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece3-2.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece3-2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..aa535443636ca1ec8b160ad9a0119a304b79f94c --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece3-2.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5f723af27f24d4686bcda1f131ba4e1f37951894bdedd4ddf99e8c041ad198b8 +size 657664 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece3-3.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece3-3.jpg new file mode 100644 index 0000000000000000000000000000000000000000..4ce495ad640719daa1b6845f105d627cf3b1c40d --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece3-3.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:59044e3516c949b798293e9ac9a0ba0a110303906e793d2a15d48d369ca0c480 +size 659050 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece4-1.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece4-1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f69b7181b28fd66ffc7fd720a21c4e420351db52 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece4-1.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e60d7b3e6cf49c7869ffcad92a99727072db03b3492ae6af96e6dc5740c72166 +size 644464 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece4-2.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece4-2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c275991912a424de03725fd1866955e6a5576f96 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece4-2.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6579fbfa55187d00322ba6766ccf07499b57d08a272dc91ce474d77a2d6274c3 +size 642642 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece4-3.jpg b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece4-3.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ddcd83593c6a7783098f7327edc8b2e2c92277a9 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1004_MIT_Mystery_Hunt_2017_Attention_Span/piece4-3.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ef6054d43bc52812e246e4ff352e404c54759fd6c8165593afea95d0ac1be586 +size 642474 diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1012_MIT_Mystery_Hunt_2017_Patience_for_the_Bridge_Builder/phaser-2.3.0.min.js b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1012_MIT_Mystery_Hunt_2017_Patience_for_the_Bridge_Builder/phaser-2.3.0.min.js new file mode 100644 index 0000000000000000000000000000000000000000..3f0a8ade5ffe1ed7804175bbd70d0237bc864791 --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1012_MIT_Mystery_Hunt_2017_Patience_for_the_Bridge_Builder/phaser-2.3.0.min.js @@ -0,0 +1,25 @@ +/* Phaser v2.3.0 - http://phaser.io - @photonstorm - (c) 2015 Photon Storm Ltd. */ + +(function(){var a=this,b=b||{};b.WEBGL_RENDERER=0,b.CANVAS_RENDERER=1,b.VERSION="v2.2.8",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.defaultRenderOptions={view:null,transparent:!1,antialias:!1,preserveDrawingBuffer:!1,resolution:1,clearBeforeRender:!0,autoResize:!1},b.DisplayObject=function(){this.position=new b.Point(0,0),this.scale=new b.Point(1,1),this.transformCallback=null,this.transformCallbackContext=null,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._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.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.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 b=[],c=0;c=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;ga;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=ec?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;bi&&(i*=-1),0>l&&(l*=-1),q=i*e+m,o=i*d+m,r=l*g+n,p=l*f+n;else{var s=i*e+k*g+m,t=l*g+j*e+n,u=i*d+k*g+m,v=l*g+j*d+n,w=i*d+k*f+m,x=l*f+j*d+n,y=i*e+k*f+m,z=l*f+j*e+n;q=q>s?s:q,q=q>u?u:q,q=q>w?w:q,q=q>y?y:q,r=r>t?t:r,r=r>v?v:r,r=r>x?x:r,r=r>z?z:r,o=s>o?s:o,o=u>o?u:o,o=w>o?w:o,o=y>o?y:o,p=t>p?t:p,p=v>p?v:p,p=x>p?x:p,p=z>p?z:p}var A=this._bounds;return A.x=q,A.width=o-q,A.y=r,A.height=p-r,this._currentBounds=A,A},b.Sprite.prototype._renderWebGL=function(a){if(this.visible&&!(this.alpha<=0)&&this.renderable){var b;if(this._mask||this._filters){var c=a.spriteBatch;for(this._filters&&(c.flush(),a.filterManager.pushFilter(this._filterBlock)),this._mask&&(c.stop(),a.maskManager.pushMask(this.mask,a),c.start()),c.render(this),b=0;bi;i++){for(j=0;m>j;j+=4)if(255!==k[n+j]){o=!0;break}if(o)break;n+=m}for(c.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}c.descent=i-g,c.descent+=6,c.fontSize=c.ascent+c.descent,b.Text.fontPropertiesCache[a]=c}return c},b.Text.prototype.wordWrap=function(a){for(var b="",c=a.split("\n"),d=0;de?(g>0&&(b+="\n"),b+=f[g],e=this.style.wordWrapWidth-h):(e-=i,b+=" "+f[g])}d=2?parseInt(c[c.length-2],10):b.BitmapText.fonts[this.fontName].size,this.dirty=!0,this.tint=a.tint},b.BitmapText.prototype.updateText=function(){for(var a=b.BitmapText.fonts[this.fontName],c=new b.Point,d=null,e=[],f=0,g=[],h=0,i=this.fontSize/a.size,j=0,k=0;k0&&c.x*i>this.maxWidth)e.splice(j,k-j),k=j,j=-1,g.push(lastLineWidth),f=Math.max(f,lastLineWidth),h++,c.x=0,c.y+=a.lineHeight,d=null;else{var m=a.chars[l];m&&(d&&m.kerning[d]&&(c.x+=m.kerning[d]),e.push({texture:m.texture,line:h,charCode:l,position:new b.Point(c.x+m.xOffset,c.y+m.yOffset)}),c.x+=m.xAdvance,d=l)}}g.push(c.x),f=Math.max(f,c.x);var n=[];for(k=0;h>=k;k++){var o=0;"right"===this.style.align?o=f-g[k]:"center"===this.style.align&&(o=(f-g[k])/2),n.push(o)}var p=this.children.length,q=e.length,r=this.tint||16777215;this.textWidth=f*i,this.textHeight=(c.y+a.lineHeight)*i;var s=this.textWidth*this.anchor.x,t=this.textHeight*this.anchor.y;for(k=0;q>k;k++){var u=p>k?this.children[k]:this._pool.pop();u?u.setTexture(e[k].texture):u=new b.Sprite(e[k].texture),u.position.x=(e[k].position.x+n[e[k].line])*i-s,u.position.y=e[k].position.y*i-t,u.scale.x=u.scale.y=i,u.tint=r,u.parent||this.addChild(u)}for(;this.children.length>q;){var v=this.getChildAt(this.children.length-1);this._pool.push(v),this.removeChild(v)}},b.BitmapText.prototype.updateTransform=function(){(this.dirty||!this.anchor.equals(this._prevAnchor))&&(this.updateText(),this.dirty=!1,this._prevAnchor.copyFrom(this.anchor)),b.DisplayObjectContainer.prototype.updateTransform.call(this)},b.BitmapText.fonts={},b.Stage=function(a){b.DisplayObjectContainer.call(this),this.worldTransform=new b.Matrix,this.stage=this,this.setBackgroundColor(a)},b.Stage.prototype=Object.create(b.DisplayObjectContainer.prototype),b.Stage.prototype.constructor=b.Stage,b.Stage.prototype.updateTransform=function(){this.worldAlpha=1;for(var a=0;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("undefined"==typeof document)return!1;var a="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/",b="AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==",c=new Image;c.src=a+"AP804Oa6"+b;var d=new Image;d.src=a+"/wCKxvRF"+b;var e=document.createElement("canvas");e.width=6,e.height=1;var f=e.getContext("2d");f.globalCompositeOperation="multiply",f.drawImage(c,0,0),f.drawImage(d,2,0);var g=f.getImageData(2,0,1,1).data;return 255===g[0]&&0===g[1]&&0===g[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.PolyK={},b.PolyK.Triangulate=function(a){var c=!0,d=a.length>>1;if(3>d)return[];for(var e=[],f=[],g=0;d>g;g++)f.push(g);g=0;for(var h=d;h>3;){var i=f[(g+0)%h],j=f[(g+1)%h],k=f[(g+2)%h],l=a[2*i],m=a[2*i+1],n=a[2*j],o=a[2*j+1],p=a[2*k],q=a[2*k+1],r=!1;if(b.PolyK._convex(l,m,n,o,p,q,c)){r=!0;for(var s=0;h>s;s++){var t=f[s];if(t!==i&&t!==j&&t!==k&&b.PolyK._PointInTriangle(a[2*t],a[2*t+1],l,m,n,o,p,q)){r=!1;break}}}if(r)e.push(i,j,k),f.splice((g+1)%h,1),h--,g=0;else if(g++>3*h){if(!c)return null;for(e=[],f=[],g=0;d>g;g++)f.push(g);g=0,h=d,c=!1}}return e.push(f[0],f[1],f[2]),e},b.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},b.PolyK._convex=function(a,b,c,d,e,f,g){return(b-d)*(e-c)+(c-a)*(f-d)>=0===g},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.join("\n"),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],a.glValueLength="2f"===d||"2i"===d?2:"3f"===d||"3i"===d?3:"4f"===d||"4i"===d?4: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.WebGLGraphics=function(){},b.WebGLGraphics.renderGraphics=function(a,c){var d,e=c.gl,f=c.projection,g=c.offset,h=c.shaderManager.primitiveShader;a.dirty&&b.WebGLGraphics.updateGraphics(a,e);for(var i=a._webGL[e.id],j=0;j=6)if(h.points.length<12){g=b.WebGLGraphics.switchMode(d,0);var i=b.WebGLGraphics.buildPoly(h,g);i||(g=b.WebGLGraphics.switchMode(d,1),b.WebGLGraphics.buildComplexPoly(h,g))}else g=b.WebGLGraphics.switchMode(d,1),b.WebGLGraphics.buildComplexPoly(h,g);h.lineWidth>0&&(g=b.WebGLGraphics.switchMode(d,0),b.WebGLGraphics.buildLine(h,g))}else g=b.WebGLGraphics.switchMode(d,0),h.type===b.Graphics.RECT?b.WebGLGraphics.buildRectangle(h,g):h.type===b.Graphics.CIRC||h.type===b.Graphics.ELIP?b.WebGLGraphics.buildCircle(h,g):h.type===b.Graphics.RREC&&b.WebGLGraphics.buildRoundedRectangle(h,g);d.lastIndex++}for(e=0;e=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},b.WebGLGraphics.buildCircle=function(a,c){var d,e,f=a.shape,g=f.x,h=f.y;a.type===b.Graphics.CIRC?(d=f.radius,e=f.radius):(d=f.width,e=f.height);var i=40,j=2*Math.PI/i,k=0;if(a.fill){var l=b.hex2rgb(a.fillColor),m=a.fillAlpha,n=l[0]*m,o=l[1]*m,p=l[2]*m,q=c.points,r=c.indices,s=q.length/6;for(r.push(s),k=0;i+1>k;k++)q.push(g,h,n,o,p,m),q.push(g+Math.sin(j*k)*d,h+Math.cos(j*k)*e,n,o,p,m),r.push(s++,s++);r.push(s-1)}if(a.lineWidth){var t=a.points;for(a.points=[],k=0;i+1>k;k++)a.points.push(g+Math.sin(j*k)*d,h+Math.cos(j*k)*e);b.WebGLGraphics.buildLine(a,c),a.points=t}},b.WebGLGraphics.buildLine=function(a,c){var d=0,e=a.points;if(0!==e.length){if(a.lineWidth%2)for(d=0;dd;d++)l=e[2*(d-1)],m=e[2*(d-1)+1],n=e[2*d],o=e[2*d+1],p=e[2*(d+1)],q=e[2*(d+1)+1],r=-(m-o),s=l-n,F=Math.sqrt(r*r+s*s),r/=F,s/=F,r*=L,s*=L,t=-(o-q),u=n-p,F=Math.sqrt(t*t+u*u),t/=F,u/=F,t*=L,u*=L,x=-s+m-(-s+o),y=-r+n-(-r+l),z=(-r+l)*(-s+o)-(-r+n)*(-s+m),A=-u+q-(-u+o),B=-t+n-(-t+p),C=(-t+p)*(-u+o)-(-t+n)*(-u+q),D=x*B-A*y,Math.abs(D)<.1?(D+=10.1,G.push(n-r,o-s,O,P,Q,N),G.push(n+r,o+s,O,P,Q,N)):(j=(y*C-B*z)/D,k=(A*z-x*C)/D,E=(j-n)*(j-n)+(k-o)+(k-o),E>19600?(v=r-t,w=s-u,F=Math.sqrt(v*v+w*w),v/=F,w/=F,v*=L,w*=L,G.push(n-v,o-w),G.push(O,P,Q,N),G.push(n+v,o+w),G.push(O,P,Q,N),G.push(n-v,o-w),G.push(O,P,Q,N),J++):(G.push(j,k),G.push(O,P,Q,N),G.push(n-(j-n),o-(k-o)),G.push(O,P,Q,N)));for(l=e[2*(I-2)],m=e[2*(I-2)+1],n=e[2*(I-1)],o=e[2*(I-1)+1],r=-(m-o),s=l-n,F=Math.sqrt(r*r+s*s),r/=F,s/=F,r*=L,s*=L,G.push(n-r,o-s),G.push(O,P,Q,N),G.push(n+r,o+s),G.push(O,P,Q,N),H.push(K),d=0;J>d;d++)H.push(K++);H.push(K-1)}},b.WebGLGraphics.buildComplexPoly=function(a,c){var d=a.points.slice();if(!(d.length<6)){var e=c.indices;c.points=d,c.alpha=a.fillAlpha,c.color=b.hex2rgb(a.fillColor);for(var f,g,h=1/0,i=-1/0,j=1/0,k=-1/0,l=0;lf?f:h,i=f>i?f:i,j=j>g?g:j,k=g>k?g:k;d.push(h,j,i,j,i,k,h,k);var m=d.length/2;for(l=0;m>l;l++)e.push(l)}},b.WebGLGraphics.buildPoly=function(a,c){var d=a.points;if(!(d.length<6)){var e=c.points,f=c.indices,g=d.length/2,h=b.hex2rgb(a.fillColor),i=a.fillAlpha,j=h[0]*i,k=h[1]*i,l=h[2]*i,m=b.PolyK.Triangulate(d);if(!m)return!1;var n=e.length/6,o=0;for(o=0;oo;o++)e.push(d[2*o],d[2*o+1],j,k,l,i);return!0}},b.WebGLGraphics.graphicsDataPool=[],b.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},b.WebGLGraphicsData.prototype.reset=function(){this.points=[],this.indices=[]},b.WebGLGraphicsData.prototype.upload=function(){var a=this.gl;this.glPoints=new b.Float32Array(this.points),a.bindBuffer(a.ARRAY_BUFFER,this.buffer),a.bufferData(a.ARRAY_BUFFER,this.glPoints,a.STATIC_DRAW),this.glIndicies=new b.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},b.glContexts=[],b.instances=[],b.WebGLRenderer=function(a,c,d){if(d)for(var e in b.defaultRenderOptions)"undefined"==typeof d[e]&&(d[e]=b.defaultRenderOptions[e]);else d=b.defaultRenderOptions;b.defaultRenderer||(b.defaultRenderer=this),this.type=b.WEBGL_RENDERER,this.resolution=d.resolution,this.transparent=d.transparent,this.autoResize=d.autoResize||!1,this.preserveDrawingBuffer=d.preserveDrawingBuffer,this.clearBeforeRender=d.clearBeforeRender,this.width=a||800,this.height=c||600,this.view=d.view||document.createElement("canvas"),this.contextLostBound=this.handleContextLost.bind(this),this.contextRestoredBound=this.handleContextRestored.bind(this),this.view.addEventListener("webglcontextlost",this.contextLostBound,!1),this.view.addEventListener("webglcontextrestored",this.contextRestoredBound,!1),this._contextOptions={alpha:this.transparent,antialias:d.antialias,premultipliedAlpha:this.transparent&&"notMultiplied"!==this.transparent,stencil:!0,preserveDrawingBuffer:d.preserveDrawingBuffer},this.projection=new b.Point,this.offset=new b.Point(0,0),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.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){this.__stage!==a&&(this.__stage=a),a.updateTransform();var b=this.gl;b.viewport(0,0,this.width,this.height),b.bindFramebuffer(b.FRAMEBUFFER,null),this.clearBeforeRender&&(this.transparent?b.clearColor(0,0,0,0):b.clearColor(a.backgroundColorSplit[0],a.backgroundColorSplit[1],a.backgroundColorSplit[2],1),b.clear(b.COLOR_BUFFER_BIT)),this.renderDisplayObject(a,this.projection)}},b.WebGLRenderer.prototype.renderDisplayObject=function(a,c,d){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),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){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,a._glTextures[c.id]}},b.WebGLRenderer.prototype.handleContextLost=function(a){a.preventDefault(),this.contextLost=!0},b.WebGLRenderer.prototype.handleContextRestored=function(){this.initContext();for(var a in b.TextureCache){var c=b.TextureCache[a].baseTexture;c._glTextures=[]}this.contextLost=!1},b.WebGLRenderer.prototype.destroy=function(){this.view.removeEventListener("webglcontextlost",this.contextLostBound),this.view.removeEventListener("webglcontextrestored",this.contextRestoredBound),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.instances[this.glContextId]=null,b.WebGLRenderer.glContextId--},b.WebGLRenderer.prototype.mapBlendModes=function(){var a=this.gl;b.blendModesWebGL||(b.blendModesWebGL=[],b.blendModesWebGL[b.blendModes.NORMAL]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.ADD]=[a.SRC_ALPHA,a.DST_ALPHA],b.blendModesWebGL[b.blendModes.MULTIPLY]=[a.DST_COLOR,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.SCREEN]=[a.SRC_ALPHA,a.ONE],b.blendModesWebGL[b.blendModes.OVERLAY]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.DARKEN]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.LIGHTEN]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.COLOR_DODGE]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.COLOR_BURN]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.HARD_LIGHT]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.SOFT_LIGHT]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.DIFFERENCE]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.EXCLUSION]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.HUE]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.SATURATION]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.COLOR]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.LUMINOSITY]=[a.ONE,a.ONE_MINUS_SRC_ALPHA])},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 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;ad;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){var b=a.texture;this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=b.baseTexture);var c=b._uvs;if(c){var d,e,f,g,h=a.anchor.x,i=a.anchor.y;if(b.trim){var j=b.trim;e=j.x-h*j.width,d=e+b.crop.width,g=j.y-i*j.height,f=g+b.crop.height}else d=b.frame.width*(1-h),e=b.frame.width*-h,f=b.frame.height*(1-i),g=b.frame.height*-i;var k=4*this.currentBatchSize*this.vertSize,l=b.baseTexture.resolution,m=a.worldTransform,n=m.a/l,o=m.b/l,p=m.c/l,q=m.d/l,r=m.tx,s=m.ty,t=this.colors,u=this.positions;this.renderSession.roundPixels?(u[k]=n*e+p*g+r|0,u[k+1]=q*g+o*e+s|0,u[k+5]=n*d+p*g+r|0,u[k+6]=q*g+o*d+s|0,u[k+10]=n*d+p*f+r|0,u[k+11]=q*f+o*d+s|0,u[k+15]=n*e+p*f+r|0,u[k+16]=q*f+o*e+s|0):(u[k]=n*e+p*g+r,u[k+1]=q*g+o*e+s,u[k+5]=n*d+p*g+r,u[k+6]=q*g+o*d+s,u[k+10]=n*d+p*f+r,u[k+11]=q*f+o*d+s,u[k+15]=n*e+p*f+r,u[k+16]=q*f+o*e+s),u[k+2]=c.x0,u[k+3]=c.y0,u[k+7]=c.x1,u[k+8]=c.y1,u[k+12]=c.x2,u[k+13]=c.y2,u[k+17]=c.x3,u[k+18]=c.y3;var v=a.tint;t[k+4]=t[k+9]=t[k+14]=t[k+19]=(v>>16)+(65280&v)+((255&v)<<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;a.tilePosition.x%=c.baseTexture.width*a.tileScaleOffset.x,a.tilePosition.y%=c.baseTexture.height*a.tileScaleOffset.y;var e=a.tilePosition.x/(c.baseTexture.width*a.tileScaleOffset.x),f=a.tilePosition.y/(c.baseTexture.height*a.tileScaleOffset.y),g=a.width/c.baseTexture.width/(a.tileScale.x*a.tileScaleOffset.x),h=a.height/c.baseTexture.height/(a.tileScale.y*a.tileScaleOffset.y);d.x0=0-e,d.y0=0-f,d.x1=1*g-e,d.y1=0-f,d.x2=1*g-e,d.y2=1*h-f,d.x3=0-e,d.y3=1*h-f;var i=a.tint,j=(i>>16)+(65280&i)+((255&i)<<16)+(255*a.alpha<<24),k=this.positions,l=this.colors,m=a.width,n=a.height,o=a.anchor.x,p=a.anchor.y,q=m*(1-o),r=m*-o,s=n*(1-p),t=n*-p,u=4*this.currentBatchSize*this.vertSize,v=c.baseTexture.resolution,w=a.worldTransform,x=w.a/v,y=w.b/v,z=w.c/v,A=w.d/v,B=w.tx,C=w.ty;k[u++]=x*r+z*t+B,k[u++]=A*t+y*r+C,k[u++]=d.x0,k[u++]=d.y0,l[u++]=j,k[u++]=x*q+z*t+B,k[u++]=A*t+y*q+C,k[u++]=d.x1,k[u++]=d.y1,l[u++]=j,k[u++]=x*q+z*s+B,k[u++]=A*s+y*q+C,k[u++]=d.x2,k[u++]=d.y2,l[u++]=j,k[u++]=x*r+z*s+B,k[u++]=A*s+y*r+C,k[u++]=d.x3,k[u++]=d.y3,l[u++]=j,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.texture.baseTexture,g=i.blendMode,h=i.shader||this.defaultShader,o=m!==g,p=n!==h,(l!==f||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;a._dirty[d.id]?this.renderSession.renderer.updateTexture(a):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||(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;jB?B:A,c.beginPath(),c.moveTo(w,x+A),c.lineTo(w,x+z-A),c.quadraticCurveTo(w,x+z,w+A,x+z),c.lineTo(w+y-A,x+z),c.quadraticCurveTo(w+y,x+z,w+y,x+z-A),c.lineTo(w+y,x+A),c.quadraticCurveTo(w+y,x,w+y-A,x),c.lineTo(w+A,x),c.quadraticCurveTo(w,x,w,x+A),c.closePath(),(f.fillColor||0===f.fillColor)&&(c.globalAlpha=f.fillAlpha*d,c.fillStyle="#"+("00000"+(0|h).toString(16)).substr(-6),c.fill()),f.lineWidth&&(c.globalAlpha=f.lineAlpha*d,c.strokeStyle="#"+("00000"+(0|i).toString(16)).substr(-6),c.stroke())}}},b.CanvasGraphics.renderGraphicsMask=function(a,c){var d=a.graphicsData.length;if(0!==d){c.beginPath();for(var e=0;d>e;e++){var f=a.graphicsData[e],g=f.shape;if(f.type===b.Graphics.POLY){var h=g.points;c.moveTo(h[0],h[1]);for(var i=1;iz?z:y,c.moveTo(u,v+y),c.lineTo(u,v+x-y),c.quadraticCurveTo(u,v+x,u+y,v+x),c.lineTo(u+w-y,v+x),c.quadraticCurveTo(u+w,v+x,u+w,v+x-y),c.lineTo(u+w,v+y),c.quadraticCurveTo(u+w,v,u+w-y,v),c.lineTo(u+y,v),c.quadraticCurveTo(u,v,u,v+y),c.closePath()}}}},b.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>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}},b.Graphics=function(){b.DisplayObjectContainer.call(this),this.renderable=!0,this.fillAlpha=1,this.lineWidth=0,this.lineColor=0,this.graphicsData=[],this.tint=16777215,this.blendMode=b.blendModes.NORMAL,this.currentPath=null,this._webGL=[],this.isMask=!1,this.boundsPadding=0,this._localBounds=new b.Rectangle(0,0,1,1),this.dirty=!0,this.webGLDirty=!1,this.cachedSpriteDirty=!1},b.Graphics.prototype=Object.create(b.DisplayObjectContainer.prototype),b.Graphics.prototype.constructor=b.Graphics,b.Graphics.prototype.lineStyle=function(a,c,d){return this.lineWidth=a||0,this.lineColor=c||0,this.lineAlpha=void 0===d?1:d,this.currentPath&&(this.currentPath.shape.points.length?this.drawShape(new b.Polygon(this.currentPath.shape.points.slice(-2))):(this.currentPath.lineWidth=this.lineWidth,this.currentPath.lineColor=this.lineColor,this.currentPath.lineAlpha=this.lineAlpha)),this},b.Graphics.prototype.moveTo=function(a,c){return this.drawShape(new b.Polygon([a,c])),this},b.Graphics.prototype.lineTo=function(a,b){return this.currentPath||this.moveTo(0,0),this.currentPath.shape.points.push(a,b),this.dirty=!0,this},b.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},b.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},b.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},b.Graphics.prototype.arc=function(a,b,c,d,e,f){if(d===e)return this;"undefined"==typeof 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},b.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},b.Graphics.prototype.endFill=function(){return this.filling=!1,this.fillColor=null,this.fillAlpha=1,this},b.Graphics.prototype.drawRect=function(a,c,d,e){return this.drawShape(new b.Rectangle(a,c,d,e)),this},b.Graphics.prototype.drawRoundedRect=function(a,c,d,e,f){return this.drawShape(new b.RoundedRectangle(a,c,d,e,f)),this},b.Graphics.prototype.drawCircle=function(a,c,d){return this.drawShape(new b.Circle(a,c,d)),this},b.Graphics.prototype.drawEllipse=function(a,c,d,e){return this.drawShape(new b.Ellipse(a,c,d,e)),this},b.Graphics.prototype.drawPolygon=function(a){var b=a;if(!Array.isArray(b)){b=new Array(arguments.length);for(var c=0;cq?q:y,y=y>s?s:y,y=y>u?u:y,z=z>r?r:z,z=z>t?t:z,z=z>v?v:z,w=q>w?q:w,w=s>w?s:w,w=u>w?u:w,x=r>x?r:x,x=t>x?t:x,x=v>x?v:x,this._bounds.x=y,this._bounds.width=w-y,this._bounds.y=z,this._bounds.height=x-z,this._currentBounds=this._bounds +}return this._currentBounds},b.Graphics.prototype.containsPoint=function(a){this.worldTransform.applyInverse(a,tempPoint);for(var b=this.graphicsData,c=0;ch?h:a,c=h+j>c?h+j:c,d=d>i?i:d,e=i+k>e?i+k:e;else if(n===b.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,c=h+j>c?h+j:c,d=d>i-k?i-k:d,e=i+k>e?i+k:e;else if(n===b.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,c=h+j>c?h+j:c,d=d>i-k?i-k:d,e=i+k>e?i+k:e;else{g=f.points;for(var p=0;ph-o?h-o:a,c=h+o>c?h+o:c,d=d>i-o?i-o:d,e=i+o>e?i+o:e}}else a=0,c=0,d=0,e=0;var q=this.boundsPadding;this._localBounds.x=a-q,this._localBounds.width=c-a+2*q,this._localBounds.y=d-q,this._localBounds.height=e-d+2*q},b.Graphics.prototype._generateCachedSprite=function(){var a=this.getLocalBounds();if(this._cachedSprite)this._cachedSprite.buffer.resize(a.width,a.height);else{var c=new b.CanvasBuffer(a.width,a.height),d=b.Texture.fromCanvas(c.canvas);this._cachedSprite=new b.Sprite(d),this._cachedSprite.buffer=c,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,b.CanvasGraphics.renderGraphics(this,this._cachedSprite.buffer.context),this._cachedSprite.alpha=this.alpha},b.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()},b.Graphics.prototype.destroyCachedSprite=function(){this._cachedSprite.texture.destroy(!0),this._cachedSprite=null},b.Graphics.prototype.drawShape=function(a){this.currentPath&&this.currentPath.shape.points.length<=2&&this.graphicsData.pop(),this.currentPath=null,a instanceof b.Polygon&&a.flatten();var c=new b.GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.filling,a);return this.graphicsData.push(c),c.type===b.Graphics.POLY&&(c.shape.closed=this.filling,this.currentPath=c),this.dirty=!0,c},Object.defineProperty(b.Graphics.prototype,"cacheAsBitmap",{get:function(){return this._cacheAsBitmap},set:function(a){this._cacheAsBitmap=a,this._cacheAsBitmap?this._generateCachedSprite():(this.destroyCachedSprite(),this.dirty=!0)}}),b.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},b.GraphicsData.prototype.constructor=b.GraphicsData,b.GraphicsData.prototype.clone=function(){return new GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.fill,this.shape)},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||1/0===k)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=m1&&(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||100,this._height=d||100,this.tileScale=new b.Point(1,1),this.tileScaleOffset=new b.Point(1,1),this.tilePosition=new b.Point(0,0),this.renderable=!0,this.tint=16777215,this.blendMode=b.blendModes.NORMAL},b.TilingSprite.prototype=Object.create(b.Sprite.prototype),b.TilingSprite.prototype.constructor=b.TilingSprite,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}}),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){var b,c;for(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.tilingTexture||this.refreshTexture?(this.generateTilingTexture(!0),this.tilingTexture&&this.tilingTexture.needsUpdate&&(a.renderer.updateTexture(this.tilingTexture.baseTexture),this.tilingTexture.needsUpdate=!1)):a.spriteBatch.renderTilingSprite(this),b=0,c=this.children.length;c>b;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,e,f=this.worldTransform,g=a.resolution;if(c.setTransform(f.a*g,f.b*g,f.c*g,f.d*g,f.tx*g,f.ty*g),!this.__tilePattern||this.refreshTexture){if(this.generateTilingTexture(!1),!this.tilingTexture)return;this.__tilePattern=c.createPattern(this.tilingTexture.baseTexture.source,"repeat")}this.blendMode!==a.currentBlendMode&&(a.currentBlendMode=this.blendMode,c.globalCompositeOperation=b.blendModesCanvas[a.currentBlendMode]);var h=this.tilePosition,i=this.tileScale;for(h.x%=this.tilingTexture.baseTexture.width,h.y%=this.tilingTexture.baseTexture.height,c.scale(i.x,i.y),c.translate(h.x+this.anchor.x*-this._width,h.y+this.anchor.y*-this._height),c.fillStyle=this.__tilePattern,c.fillRect(-h.x,-h.y,this._width/i.x,this._height/i.y),c.scale(1/i.x,1/i.y),c.translate(-h.x+this.anchor.x*this._width,-h.y+this.anchor.y*this._height),this._mask&&a.maskManager.popMask(a),d=0,e=this.children.length;e>d;d++)this.children[d]._renderCanvas(a)}},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.onTextureUpdate=function(){},b.TilingSprite.prototype.generateTilingTexture=function(a){if(this.texture.baseTexture.hasLoaded){var c,d,e=this.originalTexture||this.texture,f=e.frame,g=f.width!==e.baseTexture.width||f.height!==e.baseTexture.height,h=!1;if(a?(e.crop?(c=b.getNextPowerOfTwo(e.crop.width),d=b.getNextPowerOfTwo(e.crop.height)):(c=b.getNextPowerOfTwo(f.width),d=b.getNextPowerOfTwo(f.height)),h=!0):g&&(e.crop?(c=e.crop.width,d=e.crop.height):(c=f.width,d=f.height),h=!0),h){var i;this.tilingTexture&&this.tilingTexture.isTiling?(i=this.tilingTexture.canvasBuffer,i.resize(c,d),this.tilingTexture.baseTexture.width=c,this.tilingTexture.baseTexture.height=d,this.tilingTexture.needsUpdate=!0):(i=new b.CanvasBuffer(c,d),this.tilingTexture=b.Texture.fromCanvas(i.canvas),this.tilingTexture.canvasBuffer=i,this.tilingTexture.isTiling=!0),i.context.drawImage(e.baseTexture.source,e.crop.x,e.crop.y,e.crop.width,e.crop.height,0,0,c,d),this.tileScaleOffset.x=f.width/c,this.tileScaleOffset.y=f.height/d}else this.tilingTexture&&this.tilingTexture.isTiling&&this.tilingTexture.destroy(!0),this.tileScaleOffset.x=1,this.tileScaleOffset.y=1,this.tilingTexture=e;this.refreshTexture=!1,this.originalTexture=this.texture,this.texture=this.tilingTexture,this.tilingTexture.baseTexture._powerOf2=!0}},b.TilingSprite.prototype.destroy=function(){b.Sprite.prototype.destroy.call(this),this.tileScale=null,this.tileScaleOffset=null,this.tilePosition=null,this.tilingTexture&&(this.tilingTexture.destroy(!0),this.tilingTexture=null)},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.imageUrl=null,this._powerOf2=!1)},b.BaseTexture.prototype.constructor=b.BaseTexture,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&&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=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++);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.requiresUpdate=!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._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){var d=a.worldTransform;d.identity(),d.translate(0,2*this.projection.y),b&&d.append(b),d.scale(1,-1),a.worldAlpha=1;for(var e=a.children,f=0,g=e.length;g>f;f++)e[f].updateTransform();var h=this.renderer.gl;h.viewport(0,0,this.width*this.resolution,this.height*this.resolution),h.bindFramebuffer(h.FRAMEBUFFER,this.textureBuffer.frameBuffer),c&&this.textureBuffer.clear(),this.renderer.spriteBatch.dirty=!0,this.renderer.renderDisplayObject(a,this.projection,this.textureBuffer.frameBuffer),this.renderer.spriteBatch.dirty=!0}},b.RenderTexture.prototype.renderCanvas=function(a,b,c){if(this.valid){var d=a.worldTransform;d.identity(),b&&d.append(b),a.worldAlpha=1;for(var e=a.children,f=0,g=e.length;g>f;f++)e[f].updateTransform();c&&this.textureBuffer.clear();var h=this.textureBuffer.context,i=this.renderer.resolution;this.renderer.resolution=this.resolution,this.renderer.renderDisplayObject(a,h),this.renderer.resolution=i}},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},"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}).call(this),function(){function a(a,b){this._scaleFactor=a,this._deltaMode=b,this.originalEvent=null}var b=this,c=c||{VERSION:"2.3.0",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,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}};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;bf&&(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"undefined"==typeof a&&(a=50),a>0&&100*Math.random()<=a},randomChoice:function(a,b){return Math.random()<.5?a:b},transposeArray:function(a){return c.ArrayUtils.transposeMatrix(a)},rotateArray:function(a,b){return c.ArrayUtils.rotateMatrix(a,b)},shuffle:function(a){return c.ArrayUtils.shuffle(a)},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("undefined"==typeof b)var b=0;if("undefined"==typeof c)var c=" ";if("undefined"==typeof 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){"undefined"==typeof c&&(c=!1);for(var d=Object.keys(b),e=0;e0&&(this._radius=.5*d),this.type=c.CIRCLE},c.Circle.prototype={circumference:function(){return 2*Math.PI*this._radius},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"undefined"==typeof 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){athis.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){a0?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"undefined"==typeof d&&(d=!1),"undefined"==typeof 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"undefined"==typeof 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)},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){this.width=ad+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"undefined"==typeof 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},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)},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},coordinatesOnLine:function(a,b){"undefined"==typeof a&&(a=1),"undefined"==typeof 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"undefined"==typeof 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){"undefined"==typeof f&&(f=!0),"undefined"==typeof 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(){this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this.type=c.MATRIX},c.Matrix.prototype.fromArray=function(a){this.a=a[0],this.b=a[1],this.c=a[3],this.d=a[4],this.tx=a[2],this.ty=a[5]},c.Matrix.prototype.toArray=function(a){this.array||(this.array=new PIXI.Float32Array(9));var b=this.array;return 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},c.Matrix.prototype.apply=function(a,b){b=b||new c.Point;var d=a.x,e=a.y;return b.x=this.a*d+this.c*e+this.tx,b.y=this.b*d+this.d*e+this.ty,b},c.Matrix.prototype.applyInverse=function(a,b){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},c.Matrix.prototype.translate=function(a,b){return this.tx+=a,this.ty+=b,this},c.Matrix.prototype.scale=function(a,b){return this.a*=a,this.d*=b,this.c*=a,this.b*=b,this.tx*=a,this.ty*=b,this},c.Matrix.prototype.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},c.Matrix.prototype.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},c.Matrix.prototype.identity=function(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this},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"undefined"==typeof 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"undefined"==typeof 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"undefined"==typeof 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"undefined"==typeof 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"undefined"==typeof 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"undefined"==typeof 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"undefined"==typeof b&&(b=new c.Point),b.setTo(-a.x,-a.y)},c.Point.multiplyAdd=function(a,b,d,e){return"undefined"==typeof 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"undefined"==typeof 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"undefined"==typeof b&&(b=new c.Point),b.setTo(-a.y,a.x)},c.Point.rperp=function(a,b){return"undefined"==typeof 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){"undefined"==typeof 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){"undefined"==typeof 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"undefined"==typeof b&&(b=new c.Point),b.setTo(-1*a.y,a.x)},c.Point.normalize=function(a,b){"undefined"==typeof 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){f=f||!1,g=g||null,f&&(e=c.Math.degToRad(e)),null===g&&(g=Math.sqrt((b-a.x)*(b-a.x)+(d-a.y)*(d-a.y)));var h=e+Math.atan2(a.y-d,a.x-b);return a.setTo(b+g*Math.cos(h),d+g*Math.sin(h))},c.Point.centroid=function(a,b){if("undefined"==typeof 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){"undefined"==typeof a&&(a=[]);for(var b=0;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.yf;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"undefined"==typeof 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)},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)},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)},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){this.height=a<=this.y?0:a-this.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){this.width=a>=this.right?0:this.right-a,this.x=a}}),Object.defineProperty(c.Rectangle.prototype,"right",{get:function(){return this.x+this.width},set:function(a){this.width=a<=this.x?0: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"undefined"==typeof 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"undefined"==typeof 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.y&&c=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.rightb.right||a.y>b.bottom)},c.Rectangle.intersectsRaw=function(a,b,c,d,e,f){return"undefined"==typeof f&&(f=0),!(b>a.right+f||ca.bottom+f||ed&&(d=a.x),a.xf&&(f=a.y),a.y=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.screenView=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){"undefined"==typeof 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._edgethis.deadzone.right&&(this.view.x=this._targetPosition.x-this.deadzone.right),this._edge=this._targetPosition.y-this.view.y,this._edgethis.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.setTo(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height)},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(){},render:function(){},resize:function(){},paused: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.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){"undefined"==typeof 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){"undefined"==typeof b&&(b=!0),"undefined"==typeof 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){"undefined"==typeof a&&(a=!0),"undefined"==typeof b&&(b=!1),this._pendingState=this.current,this._clearWorld=a,this._clearCache=b,arguments.length>2&&(this._args=Array.prototype.splice.call(arguments,2))},dummy:function(){},preUpdate:function(){if(this._pendingState&&this.game.isBooted){if(this.clearCurrentState(),this.setCurrentState(this._pendingState),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.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,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){var f,g=this._indexOfListener(a,d);if(-1!==g){if(f=this._bindings[g],f.isOnce()!==b)throw new Error("You cannot add"+(b?"":"Once")+"() then add"+(b?"Once":"")+"() the same listener without removing the relationship first.")}else f=new c.SignalBinding(this,a,b,d,e),this._addBinding(f); +return this.memorize&&this._prevParams&&f.execute(this._prevParams),f},_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;"undefined"==typeof 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){return this.validateListener(a,"add"),this._registerListener(a,!1,b,c)},addOnce:function(a,b,c){return this.validateListener(a,"addOnce"),this._registerListener(a,!0,b,c)},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("undefined"==typeof 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){this._listener=b,c&&(this._isOnce=!0),null!=d&&(this.context=d),this._signal=a,e&&(this._priority=e)},c.SignalBinding.prototype={context:null,_isOnce:!1,_priority:0,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,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()},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){"undefined"==typeof 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.splice.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.Stage.call(this,0),this.name="_stage_root",this.disableVisibilityChange=!1,this.exists=!0,this.currentRenderOrderID=0,this._hiddenVar="hidden",this._onChange=null,this._backgroundColor=0,a.config&&this.parseConfig(a.config)},c.Stage.prototype=Object.create(PIXI.Stage.prototype),c.Stage.prototype.constructor=c.Stage,c.Stage.prototype.parseConfig=function(a){a.disableVisibilityChange&&(this.disableVisibilityChange=a.disableVisibilityChange),a.backgroundColor&&(this.backgroundColor=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;aa||a>=this.children.length?-1:this.getChildAt(a)},c.Group.prototype.create=function(a,b,c,d,e){"undefined"==typeof e&&(e=!0);var f=new this.classType(this.game,a,b,c,d);return this.enableBody&&this.game.physics.enable(f,this.physicsBodyType,this.enableBodyDebug),f.exists=e,f.visible=e,f.alive=e,this.addChild(f),this._hash.push(f),f.z=this.children.length,f.events&&f.events.onAddedToGroup$dispatch(f,this),null===this.cursor&&(this.cursor=f),f},c.Group.prototype.createMultiple=function(a,b,c,d){"undefined"==typeof 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"undefined"==typeof 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)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)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("undefined"==typeof 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"undefined"==typeof 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"undefined"==typeof g&&(g=!1),b=b.split("."),"undefined"==typeof d&&(d=!1),"undefined"==typeof 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){"undefined"==typeof c&&(c=!1),"undefined"==typeof d&&(d=!1),"undefined"==typeof f&&(f=!1),a=a.split("."),e=e||0;for(var g=0;g2){c=[];for(var d=2;d2){e=[];for(var f=2;f2){d=[null];for(var e=2;e2){d=[null];for(var e=2;e2){d=[null];for(var e=2;eb[this._sortProperty]?1:a.zb[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;i0?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("undefined"==typeof b&&(b=!1),"undefined"==typeof 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),e=this._hash.indexOf(d);return-1!==e&&this._hash.splice(e,1),this.updateZ(),this.cursor===a&&this.next(),b&&d&&d.destroy(!0),!0},c.Group.prototype.removeAll=function(a,b){if("undefined"==typeof a&&(a=!1),"undefined"==typeof 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]),d=this._hash.indexOf(c);-1!==d&&this._hash.splice(d,1),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("undefined"==typeof b&&(b=this.children.length-1),"undefined"==typeof c&&(c=!1),"undefined"==typeof 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]),g=this._hash.indexOf(f);-1!==g&&this._hash.splice(g,1),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||("undefined"==typeof a&&(a=!0),"undefined"==typeof b&&(b=!1),this.onDestroy.dispatch(this,a,b),this.removeAll(a),this.cursor=null,this.filters=null,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},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.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&&(athis.bounds.right&&(a.x=this.bounds.left)),e&&(a.y+a._currentBounds.heightthis.bounds.bottom&&(a.y=this.bounds.top))):(d&&a.x+bthis.bounds.right&&(a.x=this.bounds.left-b),e&&a.y+bthis.bounds.bottom&&(a.y=this.bounds.top-b))},Object.defineProperty(c.World.prototype,"width",{get:function(){return this.bounds.width},set:function(a){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=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,c.ScaleManager.prototype.checkResize=c.ScaleManager.prototype.windowResize,c.ScaleManager.prototype.checkOrientation=c.ScaleManager.prototype.orientationChange,c.ScaleManager.prototype.setScreenSize=c.ScaleManager.prototype.updateLayout,c.ScaleManager.prototype.setSize=c.ScaleManager.prototype.reflowCanvas,c.ScaleManager.prototype.checkOrientationState=function(){var a=this.updateOrientationState();return a&&this.refresh(),a},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,"orientation",{get:function(){return"portrait"===this.classifyOrientation(this.screenOrientation)?0:90}}),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.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.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.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,"undefined"==typeof 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,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.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.raf=this.config&&this.config.forceSetTimeOut?new c.RequestAnimationFrame(this,this.config.forceSetTimeOut):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++)f.push(e>g?"color: #ff2424; background: #fff":"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=this.config.canvasID?c.Canvas.create(this.width,this.height,this.config.canvasID):c.Canvas.create(this.width,this.height),this.config.canvasStyle?this.canvas.style=this.config.canvasStyle:this.canvas.style["-webkit-full-screen"]="width: 100%; height: 100%",this.device.cocoonJS&&(this.canvas.screencanvas=this.renderType===c.CANVAS?!0:!1),this.renderType===c.HEADLESS||this.renderType===c.CANVAS||this.renderType===c.AUTO&&this.device.webGL===!1){if(!this.device.canvas)throw new Error("Phaser.Game - cannot create Canvas or WebGL context, aborting.");this.renderType===c.AUTO&&(this.renderType=c.CANVAS),this.renderer=new PIXI.CanvasRenderer(this.width,this.height,{view:this.canvas,transparent:this.transparent,resolution:this.resolution,clearBeforeRender:!0}),this.context=this.renderer.context}else this.renderType=c.WEBGL,this.renderer=new PIXI.WebGLRenderer(this.width,this.height,{view:this.canvas,transparent:this.transparent,resolution:this.resolution,antialias:this.antialias,preserveDrawingBuffer:this.preserveDrawingBuffer}),this.context=null;this.renderType!==c.HEADLESS&&(this.stage.smoothed=this.antialias,c.Canvas.addToDOM(this.canvas,this.parent,!1),c.Canvas.setTouchAction(this.canvas))},update:function(a){if(this.time.update(a),this._kickstart)return this.updateLogic(1/this.time.desiredFps),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(1/this.time.desiredFps),this.stage.updateTransform(),c++,!this.forceSingleUpdate||1!==c););c>this._lastCount?this._spiraling++:c=c.Input.MAX_POINTERS)return console.warn("Phaser.Input.addPointer: only "+c.Input.MAX_POINTERS+" pointer allowed"),null;var a=this.pointers.length+1,b=new c.Pointer(this.game,a);return this.pointers.push(b),this["pointer"+a]=b,b},update:function(){if(this.keyboard&&this.keyboard.update(),this.pollRate>0&&this._pollCounter=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;b0;c++){var d=this.pointers[c];d.active&&b--}return this.currentPointers=a-b,a-b +},getPointer:function(a){"undefined"==typeof a&&(a=!1);for(var b=0;b=g&&this._localPoint.x=h&&this._localPoint.y=g&&this._localPoint.x=h&&this._localPoint.yi;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._pollCounter0&&this.processInteractiveObjects(!1),this.dirty=!1),this._holdSent===!1&&this.duration>=this.game.input.holdRate&&((this.game.input.multiInputOverride==c.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==c.Input.MOUSE_TOUCH_COMBINE||this.game.input.multiInputOverride==c.Input.TOUCH_OVERRIDES_MOUSE&&0===this.game.input.currentPointers)&&this.game.input.onHold.dispatch(this),this._holdSent=!0),this.game.input.recordPointerHistory&&this.game.time.time>=this._nextDrop&&(this._nextDrop=this.game.time.time+this.game.input.recordRate,this._history.push({x:this.position.x,y:this.position.y}),this._history.length>this.game.input.recordLimit&&this._history.shift()))},move:function(a,b){if(!this.game.input.pollLocked){if("undefined"==typeof b&&(b=!1),"undefined"!=typeof a.button&&(this.button=a.button),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&&this.game.input.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)*this.game.input.scale.x,this.y=(this.pageY-this.game.scale.offset.y)*this.game.input.scale.y,this.position.setTo(this.x,this.y),this.circle.x=this.x,this.circle.y=this.y,(this.game.input.multiInputOverride===c.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride===c.Input.MOUSE_TOUCH_COMBINE||this.game.input.multiInputOverride===c.Input.TOUCH_OVERRIDES_MOUSE&&0===this.game.input.currentPointers)&&(this.game.input.activePointer=this,this.game.input.x=this.x,this.game.input.y=this.y,this.game.input.position.setTo(this.game.input.x,this.game.input.y),this.game.input.circle.x=this.game.input.x,this.game.input.circle.y=this.game.input.y),this.withinGame=this.game.scale.bounds.contains(this.pageX,this.pageY),this.game.paused)return this;for(var d=this.game.input.moveCallbacks.length;d--;)this.game.input.moveCallbacks[d].callback.call(this.game.input.moveCallbacks[d].context,this,this.x,this.y,b);return null!==this.targetObject&&this.targetObject.isDragged===!0?this.targetObject.update(this)===!1&&(this.targetObject=null):this.game.input.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){return this._stateReset&&this.withinGame?void a.preventDefault():(this.timeUp=this.game.time.time,(this.game.input.multiInputOverride===c.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride===c.Input.MOUSE_TOUCH_COMBINE||this.game.input.multiInputOverride===c.Input.TOUCH_OVERRIDES_MOUSE&&0===this.game.input.currentPointers)&&(this.game.input.onUp.dispatch(this,a),this.duration>=0&&this.duration<=this.game.input.tapRate&&(this.timeUp-this.previousTapTime0&&(this.active=!1),this.withinGame=!1,this.isDown=!1,this.isUp=!0,this.pointerId=null,this.identifier=null,this.positionUp.setTo(this.x,this.y),this.isMouse===!1&&this.game.input.currentPointers--,this.game.input.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===!0&&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;fd;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"undefined"==typeof c&&(c=!0),0===this.sprite.scale.x||0===this.sprite.scale.y||this.priorityIDa||this.priorityID===a&&this.sprite.renderOrderIDb;b++)if(this._pointerData[b].isOver)return!0}return!1},pointerOut:function(a){if(this.enabled){if("undefined"!=typeof a)return this._pointerData[a].isOut;for(var b=0;10>b;b++)if(this._pointerData[b].isOut)return!0}return!1},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)?("undefined"==typeof 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)?("undefined"==typeof 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,athis.sprite.texture.crop.right||bthis.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){null!==this.sprite&&(this._pointerData[a.id].isOver===!1||a.dirty)&&(this._pointerData[a.id].isOver=!0,this._pointerData[a.id].isOut=!1,this._pointerData[a.id].timeOver=this.game.time.time,this._pointerData[a.id].x=a.x-this.sprite.x,this._pointerData[a.id].y=a.y-this.sprite.y,this.useHandCursor&&this._pointerData[a.id].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){null!==this.sprite&&(this._pointerData[a.id].isOver=!1,this._pointerData[a.id].isOut=!0,this._pointerData[a.id].timeOut=this.game.time.time,this.useHandCursor&&this._pointerData[a.id].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){if(this._pointerData[a.id].isDown===!1&&this._pointerData[a.id].isOver===!0){if(this.pixelPerfectClick&&!this.checkPixel(null,null,a))return;this._pointerData[a.id].isDown=!0,this._pointerData[a.id].isUp=!1,this._pointerData[a.id].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){null!==this.sprite&&this._pointerData[a.id].isDown&&a.isUp&&(this._pointerData[a.id].isDown=!1,this._pointerData[a.id].isUp=!0,this._pointerData[a.id].timeUp=this.game.time.time,this._pointerData[a.id].downDuration=this._pointerData[a.id].timeUp-this._pointerData[a.id].timeDown,this.checkPointerOver(a)?this.sprite&&this.sprite.events&&this.sprite.events.onInputUp$dispatch(this.sprite,a,!0):(this.sprite&&this.sprite.events&&this.sprite.events.onInputUp$dispatch(this.sprite,a,!1),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.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)),!0},justOver:function(a,b){return a=a||0,b=b||500,this._pointerData[a].isOver&&this.overDuration(a)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){"undefined"==typeof a&&(a=!0),"undefined"==typeof b&&(b=!0),this.allowHorizontalDrag=a,this.allowVerticalDrag=b},enableSnap:function(a,b,c,d,e,f){"undefined"==typeof c&&(c=!0),"undefined"==typeof d&&(d=!1),"undefined"==typeof e&&(e=0),"undefined"==typeof 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.xthis.boundsRect.right&&(this.sprite.cameraOffset.x=this.boundsRect.right-this.sprite.width),this.sprite.cameraOffset.ythis.boundsRect.bottom&&(this.sprite.cameraOffset.y=this.boundsRect.bottom-this.sprite.height)):(this.sprite.leftthis.boundsRect.right&&(this.sprite.x=this.boundsRect.right-(this.sprite.width-this.sprite.offsetX)),this.sprite.topthis.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.xthis.boundsSprite.cameraOffset.x+this.boundsSprite.width&&(this.sprite.cameraOffset.x=this.boundsSprite.cameraOffset.x+this.boundsSprite.width-this.sprite.width),this.sprite.cameraOffset.ythis.boundsSprite.cameraOffset.y+this.boundsSprite.height&&(this.sprite.cameraOffset.y=this.boundsSprite.cameraOffset.y+this.boundsSprite.height-this.sprite.height)):(this.sprite.leftthis.boundsSprite.right&&(this.sprite.x=this.boundsSprite.right-(this.sprite.width-this.sprite.offsetX)),this.sprite.topthis.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;c0&&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;dthis.game.time.time},justReleased:function(a){return a=a||250,this.isUp===!0&&this.timeUp+a>this.game.time.time},reset:function(){this.isDown=!1,this.isUp=!0,this.timeDown=this.game.time.time,this.duration=0,this.repeats=0},destroy:function(){this.onDown.dispose(),this.onUp.dispose(),this.onFloat.dispose(),this.pad=null,this.game=null}},c.GamepadButton.prototype.constructor=c.GamepadButton,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){"undefined"==typeof 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"undefined"==typeof a&&(a=50),this.isDown&&this.duration0&&(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"undefined"==typeof a&&(a=1),this.alive=!0,this.exists=!0,this.visible=!0,"number"==typeof this.health&&(this.health=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={_frame:null,loadTexture:function(a,b,d){b=b||0,(d||"undefined"==typeof d)&&this.animations&&this.animations.stop(),this.key=a;var e=!0,f=!this.texture.baseTexture.scaleMode,g=!1;c.RenderTexture&&a instanceof c.RenderTexture?(this.key=a.key,this.setTexture(a),g=!0):c.BitmapData&&a instanceof c.BitmapData?(this.setTexture(a.texture),this.game.cache.getFrameData(a.key,c.Cache.BITMAPDATA)&&(e=!this.animations.loadFrameData(this.game.cache.getFrameData(a.key,c.Cache.BITMAPDATA),b))):a instanceof PIXI.Texture?this.setTexture(a):null===a||"undefined"==typeof a?(this.key="__default",this.setTexture(PIXI.TextureCache[this.key])):"string"!=typeof a||this.game.cache.checkImageKey(a)?(this.setTexture(new PIXI.Texture(PIXI.BaseTextureCache[a])),e=!this.animations.loadFrameData(this.game.cache.getFrameData(a),b)):(console.warn("Texture with key '"+a+"' not found."),this.key="__missing",this.setTexture(PIXI.TextureCache[this.key])),g||this.texture.baseTexture.dirty(),e&&(this._frame=c.Rectangle.clone(this.texture.frame)),f||(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(),16777215!==this.tint&&(this.cachedTint=-1),this.texture._updateUvs()},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"undefined"==typeof 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:this.checkTransform,transformCallbackContext:this,scaleMin:null,scaleMax:null,checkTransform:function(a){this.scaleMin&&(a.athis.scaleMax.x&&(a.a=this.scaleMax.x),a.d>this.scaleMax.y&&(a.d=this.scaleMax.y))},setScaleMinMax:function(a,b,d,e){"undefined"==typeof b?b=d=e=a:"undefined"==typeof 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)}},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"undefined"==typeof f&&(f=this.world),f.add(new c.Image(this.game,a,b,d,e))},sprite:function(a,b,c,d,e){return"undefined"==typeof e&&(e=this.world),e.create(a,b,c,d)},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"undefined"==typeof a&&(a=null),"undefined"==typeof b&&(b="group"),"undefined"==typeof 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"undefined"==typeof 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"undefined"==typeof g&&(g=this.world),g.add(new c.Rope(this.game,a,b,d,e,f))},text:function(a,b,d,e,f){return"undefined"==typeof 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"undefined"==typeof 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"undefined"==typeof 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"undefined"==typeof 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){("undefined"==typeof d||""===d)&&(d=this.game.rnd.uuid()),"undefined"==typeof 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){"undefined"==typeof e&&(e=!1),("undefined"==typeof 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.splice.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,null,b,d,e,f)},spriteBatch:function(a,b,d){return"undefined"==typeof b&&(b="group"),"undefined"==typeof 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){return 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){("undefined"==typeof d||""===d)&&(d=this.game.rnd.uuid()),"undefined"==typeof 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){"undefined"==typeof e&&(e=!1),("undefined"==typeof 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.splice.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","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.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._scroll=new c.Point,PIXI.TilingSprite.call(this,PIXI.TextureCache.__default,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","Destroy","FixedToCamera","InputEnabled","InWorld","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.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,this._scroll=new c.Point,PIXI.Rope.call(this,e,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","InputEnabled","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 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.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.tilePosition.x=0,this.tilePosition.y=0,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;km;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){"undefined"==typeof c&&(c=0),"undefined"==typeof d&&(d=0),"undefined"==typeof e&&(e=this.width),"undefined"==typeof 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(("undefined"==typeof a||null===a)&&(a=!1),("undefined"==typeof b||null===b)&&(b=!1),("undefined"==typeof d||null===d)&&(d=!1),a||b||d){"undefined"==typeof e&&(e=new c.Rectangle(0,0,this.width,this.height));for(var f=c.Color.createColor(),g=e.y;g=0&&a<=this.width&&b>=0&&b<=this.height&&(this.pixels[b*this.width+a]=c.Device.LITTLE_ENDIAN?g<<24|f<<16|e<<8|d: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){"undefined"==typeof 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"undefined"==typeof 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(("undefined"==typeof a||null===a)&&(a=this),this._image=a,a instanceof c.Sprite||a instanceof c.Image||a instanceof c.Text)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,("undefined"==typeof g||null===g)&&(g=a.x),("undefined"==typeof 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)}return("undefined"==typeof b||null===b)&&(b=0),("undefined"==typeof d||null===d)&&(d=0),e&&(this._size.x=e),f&&(this._size.y=f),("undefined"==typeof g||null===g)&&(g=b),("undefined"==typeof h||null===h)&&(h=d),("undefined"==typeof i||null===i)&&(i=this._size.x),("undefined"==typeof 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),"undefined"==typeof q&&(q=null),"undefined"==typeof r&&(r=!1),this._alpha.current<=0||0===this._scale.x||0===this._scale.y||0===this._size.x||0===this._size.y?void 0:(this._alpha.prev=this.context.globalAlpha,this.context.save(),this.context.globalAlpha=this._alpha.current,q&&(this.context.globalCompositeOperation=q),r&&(g|=0,h|=0),this.context.translate(g,h),this.context.scale(this._scale.x,this._scale.y),this.context.rotate(this._rotate),this.context.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),this.context.restore(),this.context.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},shadow:function(a,b,c,d){"undefined"==typeof a||null===a?this.context.shadowColor="rgba(0,0,0,0)":(this.context.shadowColor=a,this.context.shadowBlur=b||5,this.context.shadowOffsetX=c||10,this.context.shadowOffsetY=d||10)},alphaMask:function(a,b,c,d){return"undefined"==typeof d||null===d?this.draw(b).blendSourceAtop():this.draw(b,d.x,d.y,d.width,d.height).blendSourceAtop(),"undefined"==typeof 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"undefined"==typeof e&&(e=255),"undefined"==typeof f&&(f=!1),"undefined"==typeof g&&(g=b),"undefined"==typeof h&&(h=c),"undefined"==typeof 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){"undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=0),"undefined"==typeof d&&(d="14px Courier"),"undefined"==typeof e&&(e="rgb(255,255,255)"),"undefined"==typeof f&&(f=!0);var g=this.context.font;this.context.font=d,f&&(this.context.fillStyle="rgb(0,0,0)",this.context.fillText(a,b+1,c+1)),this.context.fillStyle=e,this.context.fillText(a,b,c),this.context.font=g},circle:function(a,b,c,d){return"undefined"!=typeof d&&(this.context.fillStyle=d),this.context.beginPath(),this.context.arc(a,b,c,0,2*Math.PI,!1),this.context.closePath(),this.context.fill(),this},textureLine:function(a,b,d){if("undefined"==typeof d&&(d="repeat-x"),"string"!=typeof b||(b=this.game.cache.getImage(b))){var e=a.length;return"no-repeat"===d&&e>b.width&&(e=b.width),this.context.fillStyle=this.context.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),this.context.save(),this.context.translate(this._pos.x,this._pos.y),this.context.rotate(a.angle),this.context.fillRect(0,0,e,b.height),this.context.restore(),this.dirty=!0,this}},render:function(){return!this.disableTextureUpload&&this.dirty&&(this.baseTexture.dirty(),this.dirty=!1),this},blendReset:function(){return this.context.globalCompositeOperation="source-over",this},blendSourceOver:function(){return this.context.globalCompositeOperation="source-over",this},blendSourceIn:function(){return this.context.globalCompositeOperation="source-in",this},blendSourceOut:function(){return this.context.globalCompositeOperation="source-out",this},blendSourceAtop:function(){return this.context.globalCompositeOperation="source-atop",this},blendDestinationOver:function(){return this.context.globalCompositeOperation="destination-over",this},blendDestinationIn:function(){return this.context.globalCompositeOperation="destination-in",this},blendDestinationOut:function(){return this.context.globalCompositeOperation="destination-out",this},blendDestinationAtop:function(){return this.context.globalCompositeOperation="destination-atop",this},blendXor:function(){return this.context.globalCompositeOperation="xor",this},blendAdd:function(){return this.context.globalCompositeOperation="lighter",this},blendMultiply:function(){return this.context.globalCompositeOperation="multiply",this},blendScreen:function(){return this.context.globalCompositeOperation="screen",this},blendOverlay:function(){return this.context.globalCompositeOperation="overlay",this},blendDarken:function(){return this.context.globalCompositeOperation="darken",this},blendLighten:function(){return this.context.globalCompositeOperation="lighten",this},blendColorDodge:function(){return this.context.globalCompositeOperation="color-dodge",this},blendColorBurn:function(){return this.context.globalCompositeOperation="color-burn",this},blendHardLight:function(){return this.context.globalCompositeOperation="hard-light",this},blendSoftLight:function(){return this.context.globalCompositeOperation="soft-light",this},blendDifference:function(){return this.context.globalCompositeOperation="difference",this},blendExclusion:function(){return this.context.globalCompositeOperation="exclusion",this},blendHue:function(){return this.context.globalCompositeOperation="hue",this},blendSaturation:function(){return this.context.globalCompositeOperation="saturation",this},blendColor:function(){return this.context.globalCompositeOperation="color",this},blendLuminosity:function(){return this.context.globalCompositeOperation="luminosity",this}},Object.defineProperty(c.BitmapData.prototype,"smoothed",{get:function(){c.Canvas.getSmoothingEnabled(this.context)},set:function(a){c.Canvas.setSmoothingEnabled(this.context,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,c.Graphics=function(a,b,d){b=b||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){"undefined"==typeof 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){"undefined"==typeof 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;ek&&Math.abs(k)>i&&(k=-i),0!==k){var l=k*(b.length-1);j+=l}this.canvas.height=j*this.resolution,this.context.scale(this.resolution,this.resolution),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.shadowOffsetX=this.style.shadowOffsetX,this.context.shadowOffsetY=this.style.shadowOffsetY,this.context.shadowColor=this.style.shadowColor,this.context.shadowBlur=this.style.shadowBlur,this.context.lineWidth=this.style.strokeThickness,this.context.lineCap="round",this.context.lineJoin="round";var m,n;for(this._charCount=0,f=0;f0&&(n+=k*f),"right"===this.style.align?m+=d-c[f]:"center"===this.style.align&&(m+=(d-c[f])/2),this.colors.length>0?this.updateLine(b[f],m,n):(this.style.stroke&&this.style.strokeThickness&&this.context.strokeText(b[f],m,n),this.style.fill&&this.context.fillText(b[f],m,n));this.updateTexture()},c.Text.prototype.updateLine=function(a,b,c){for(var d=0;de?(g>0&&(b+="\n"),b+=f[g]+" ",e=this.style.wordWrapWidth-h):(e-=i,b+=f[g]+" ")}d?@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){"undefined"==typeof 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",this.autoUpperCase=f?!1:!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;ea&&(a=0),this.pasteLine(d[e],a,b,this.customSpacingX),b+=this.characterHeight+this.customSpacingY}}else{switch(this.fixedWidth>0?this.resize(this.fixedWidth,this.characterHeight,!0):this.resize(this._text.length*(this.characterWidth+this.customSpacingX),this.characterHeight,!0),this.align){case c.RetroFont.ALIGN_LEFT:a=0;break;case c.RetroFont.ALIGN_RIGHT:a=this.width-this._text.length*(this.characterWidth+this.customSpacingX);break;case c.RetroFont.ALIGN_CENTER:a=this.width/2-this._text.length*(this.characterWidth+this.customSpacingX)/2,a+=this.customSpacingX/2}this.textureBuffer.clear(),this.pasteLine(this._text,a,0,this.customSpacingX)}},c.RetroFont.prototype.pasteLine=function(a,b,d,e){for(var f=new c.Point,g=0;g=0&&(this.stamp.frame=this.grabData[a.charCodeAt(g)],f.set(b,d),this.render(this.stamp,f,!1),b+=this.characterWidth+e,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;ca&&(a=b[c].length);return a},c.RetroFont.prototype.removeUnsupportedCharacters=function(a){for(var b="",c=0;c=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,PIXI.TextureCache[e[f].uuid].frame.x=e[f].x,PIXI.TextureCache[e[f].uuid].frame.y=e[f].y;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.Device=function(){this.deviceReadyAt=0,this.initialized=!1,this.desktop=!1,this.iOS=!1,this.cocoonJS=!1,this.cocoonJSApp=!1,this.cordova=!1,this.node=!1,this.nodeWebkit=!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=!1,this.quirksMode=!1,this.touch=!1,this.mspointer=!1,this.wheelEvent=null,this.arora=!1,this.chrome=!1,this.epiphany=!1,this.firefox=!1,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.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)?k.vita=!0:/Kindle/.test(a)||/\bKF[A-Z][A-Z]+/.test(a)||/Silk.*Mobile Safari/.test(a)?k.kindle=!0:/Android/.test(a)?k.android=!0:/CrOS/.test(a)?k.chromeOS=!0:/iP[ao]d|iPhone/i.test(a)?k.iOS=!0:/Linux/.test(a)?k.linux=!0:/Mac OS/.test(a)?k.macOS=!0:/Windows/.test(a)&&(k.windows=!0,/Windows Phone/i.test(a)&&(k.windowsPhone=!0));var b=/Silk/.test(a);(k.windows||k.macOS||k.linux&&!b||k.chromeOS)&&(k.desktop=!0),(k.windowsPhone||/Windows NT/i.test(a)&&/Touch/i.test(a))&&(k.desktop=!1)}function b(){k.canvas=!!window.CanvasRenderingContext2D||k.cocoonJS;try{k.localStorage=!!localStorage.getItem}catch(a){k.localStorage=!1}k.file=!!(window.File&&window.FileReader&&window.FileList&&window.Blob),k.fileSystem=!!window.requestFileSystem,k.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}}(),k.webGL=!!k.webGL,k.worker=!!window.Worker,k.pointerLock="pointerLockElement"in document||"mozPointerLockElement"in document||"webkitPointerLockElement"in document,k.quirksMode="CSS1Compat"===document.compatMode?!1:!0,k.getUserMedia=!!(navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia),!k.iOS&&(k.ie||k.firefox||k.chrome)&&(k.canvasBitBltShift=!0),(k.safari||k.mobileSafari)&&(k.canvasBitBltShift=!1)}function c(){("ontouchstart"in document.documentElement||window.navigator.maxTouchPoints&&window.navigator.maxTouchPoints>=1)&&(k.touch=!0),(window.navigator.msPointerEnabled||window.navigator.pointerEnabled)&&(k.mspointer=!0),k.cocoonJS||("onwheel"in window||k.ie&&"WheelEvent"in window?k.wheelEvent="wheel":"onmousewheel"in window?k.wheelEvent="mousewheel":k.firefox&&"MouseScrollEvent"in window&&(k.wheelEvent="DOMMouseScroll"))}function d(){for(var a=["requestFullscreen","requestFullScreen","webkitRequestFullscreen","webkitRequestFullScreen","msRequestFullscreen","msRequestFullScreen","mozRequestFullScreen","mozRequestFullscreen"],b=document.createElement("div"),c=0;c0&&"none"!==a}var k=this;a(),f(),e(),j(),g(),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.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.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"undefined"==typeof 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.Canvas={create:function(a,b,c){a=a||256,b=b||256;var d=document.createElement("canvas");return"string"==typeof c&&""!==c&&(d.id=c),d.width=a,d.height=b,d.style.display="block",d},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"undefined"==typeof 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){return a.imageSmoothingEnabled=b,a.mozImageSmoothingEnabled=b,a.oImageSmoothingEnabled=b,a.webkitImageSmoothingEnabled=b,a.msImageSmoothingEnabled=b,a},getSmoothingEnabled:function(a){return a.imageSmoothingEnabled||a.mozImageSmoothingEnabled||a.oImageSmoothingEnabled||a.webkitImageSmoothingEnabled||a.msImageSmoothingEnabled},setImageRenderingCrisp:function(a){return a.style["image-rendering"]="optimizeSpeed",a.style["image-rendering"]="crisp-edges",a.style["image-rendering"]="-moz-crisp-edges",a.style["image-rendering"]="-webkit-optimize-contrast",a.style["image-rendering"]="optimize-contrast",a.style["image-rendering"]="pixelated",a.style.msInterpolationMode="nearest-neighbor",a},setImageRenderingBicubic:function(a){return a.style["image-rendering"]="auto",a.style.msInterpolationMode="bicubic",a}},c.Canvas.getOffset=c.DOM.getOffset,c.Canvas.getAspectRatio=c.DOM.getAspectRatio,c.RequestAnimationFrame=function(a,b){"undefined"==typeof b&&(b=!1),this.game=a,this.isRunning=!1,this.forceSetTimeOut=b;for(var c=["ms","moz","webkit","o"],d=0;da},fuzzyGreaterThan:function(a,b,c){return"undefined"==typeof c&&(c=1e-4),a>b-c},fuzzyCeil:function(a,b){return"undefined"==typeof b&&(b=1e-4),Math.ceil(a-b)},fuzzyFloor:function(a,b){return"undefined"==typeof b&&(b=1e-4),Math.floor(a+b)},average:function(){for(var a=0,b=0;b=0?a:a+2*Math.PI},normalizeLatitude:function(a){return c.Math.clamp(a,-90,90)},normalizeLongitude:function(a){return c.Math.wrap(a,-180,180)},chanceRoll:function(a){return c.Utils.chanceRoll(a)},numberArray:function(a,b){return c.ArrayUtils.numberArray(a,b)},numberArrayStep:function(a,b,d){return c.ArrayUtils.numberArrayStep(a,b,d)},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},limitValue:function(a,b,d){return c.Math.clamp(a,b,d)},randomSign:function(){return c.Utils.randomChoice(-1,1)},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]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]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)},angleLimit:function(a,b,c){var d=a;return a>c?d=c:b>a&&(d=b),d},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)},getRandom:function(a,b,d){return c.ArrayUtils.getRandomItem(a,b,d)},removeRandom:function(a,b,d){return c.ArrayUtils.removeRandomItem(a,b,d)},floor:function(a){return Math.trunc(a)},ceil:function(a){return c.Math.roundAwayFromZero(a)},roundAwayFromZero:function(a){return a>0?Math.ceil(a):Math.floor(a)},sinCosGenerator:function(a,b,c,d){"undefined"==typeof b&&(b=1),"undefined"==typeof c&&(c=1),"undefined"==typeof 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}},shift:function(a){var b=a.shift();return a.push(b),b},shuffleArray:function(a){return c.ArrayUtils.shuffle(a)},distance:function(a,b,c,d){var e=a-c,f=b-d;return Math.sqrt(e*e+f*f)},distancePow:function(a,b,c,d,e){return"undefined"==typeof e&&(e=2),Math.sqrt(Math.pow(c-a,e)+Math.pow(d-b,e))},distanceRounded:function(a,b,d,e){return Math.round(c.Math.distance(a,b,d,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"undefined"==typeof c&&(c=0),a>b||c>b?1:c>a||c>a?0:(a-c)/b}};var j=Math.PI/180,k=180/Math.PI;c.Math.degToRad=function(a){return a*j},c.Math.radToDeg=function(a){return a*k},c.RandomDataGenerator=function(a){"undefined"==typeof a&&(a=[]),this.c=1,this.s0=0,this.s1=0,this.s2=0,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>>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))]},timestamp:function(a,b){return this.realInRange(a||9466848e5,b||1577862e6)},angle:function(){return this.integerInRange(-180,180)}},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.levelthis.bounds.bottom&&(b=2):a.x>this.bounds.right&&(a.ythis.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){"undefined"==typeof c&&(c=!1),("undefined"==typeof 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){"undefined"==typeof 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._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;ad;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._onUpdateCallback=null,this._onUpdateCallbackContext=null,this._pausedTime=0,this._codePaused=!1},c.Tween.prototype={to:function(a,b,d,e,f,g,h){return"undefined"==typeof b&&(b=1e3),"undefined"==typeof d&&(d=c.Easing.Default),"undefined"==typeof e&&(e=!1),"undefined"==typeof f&&(f=0),"undefined"==typeof g&&(g=0),"undefined"==typeof 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"undefined"==typeof b&&(b=1e3),"undefined"==typeof d&&(d=c.Easing.Default),"undefined"==typeof e&&(e=!1),"undefined"==typeof f&&(f=0),"undefined"==typeof g&&(g=0),"undefined"==typeof 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("undefined"==typeof a&&(a=0),null===this.game||null===this.target||0===this.timeline.length||this.isRunning)return this;for(var b=0;ba||a>this.timeline.length-1)&&(a=0),this.current=a,this.timeline[this.current].start(),this.onStart.dispatch(this.target,this),this},stop:function(a){return"undefined"==typeof 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("undefined"==typeof c&&(c=0),-1===c)for(var d=0;d0?arguments[a-1].chainedTween=arguments[a]:this.chainedTween=arguments[a];return this},loop:function(a){return"undefined"==typeof 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;a0?(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;"undefined"==typeof b&&(b=[]);for(var c=0;c0?!1:!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;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(){if(this.isRunning){if(this.game.time.time=this.startTime))return c.TweenData.PENDING;this.isRunning=!0}this.parent.reverse?(this.dt-=this.game.time.physicsElapsedMS*this.parent.timeScale,this.dt=Math.max(this.dt,0)):(this.dt+=this.game.time.physicsElapsedMS*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 a in this.vEnd){var b=this.vStart[a],d=this.vEnd[a]; +this.parent.target[a]=Array.isArray(d)?this.interpolationFunction.call(this.interpolationContext,d,this.value):b+(d-b)*this.value}return!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent?this.repeat():c.TweenData.RUNNING},generateData:function(a){this.dt=this.parent.reverse?this.duration: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];e[f]=Array.isArray(h)?this.interpolationFunction(h,this.value):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.dt=this.parent.reverse?this.duration: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(2*(a-b)*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(2*(a-b)*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(2*(a-b)*Math.PI/d):c*Math.pow(2,-10*(a-=1))*Math.sin(2*(a-b)*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=0,this.physicsElapsedMS=0,this.desiredFps=60,this.suggestedFps=null,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()},add:function(a){return this._timers.push(a),a},create:function(a){"undefined"==typeof a&&(a=!0);var b=new c.Timer(this.game,a);return this._timers.push(b),b},removeAll:function(){for(var a=0;a=2*this.desiredFps&&(this.suggestedFps=5*Math.floor(200/(this._elapsedAccumulator/this._frameCount)),this._frameCount=0,this._elapsedAccumulator=0),this.physicsElapsed=1/this.desiredFps,this.physicsElapsedMS=1e3*this.physicsElapsed,this.advancedTiming&&(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)),!this.game.paused){this.events.update(this.time);for(var c=0,d=this._timers.length;d>c;)this._timers[c].update(this.time)?c++:(this._timers.splice(c,1),d--)}},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()}},c.Time.prototype.constructor=c.Time,c.Timer=function(a,b){"undefined"==typeof 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.splice.call(arguments,3))},repeat:function(a,b,c,d){return this.create(a,!1,b,c,d,Array.prototype.splice.call(arguments,4))},loop:function(a,b,c){return this.create(a,!0,0,b,c,Array.prototype.splice.call(arguments,3))},start:function(a){if(!this.running){this._started=this.game.time.time+(a||0),this.running=!0;for(var b=0;b0&&(this.events.sort(this.sortHandler),this.nextTick=this.events[0].tick)},sortHandler:function(a,b){return a.tickb.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.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;bc&&(c=0),this.events[b].tick=this._now+c}var d=this.nextTick-a;this.nextTick=0>d?this._now: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("undefined"==typeof a)return!1;if(this.isLoaded)for(var c in this._anims)this._anims[c].updateFrameData(a);return this._frameData=a,"undefined"==typeof 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"undefined"==typeof 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,"undefined"==typeof e&&(e=!1),"undefined"==typeof f&&(f=b&&"number"==typeof b[0]?!0:!1),this._outputFrames.length=0,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.currentFrame=this.currentAnim.currentFrame,this.sprite.__tilePattern&&(this.sprite.__tilePattern=!1,this.tilingTexture=!1),this._anims[a]},validateFrames:function(a,b){"undefined"==typeof b&&(b=!0);for(var c=0;cthis._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){"undefined"==typeof 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]),this.sprite.__tilePattern&&(this.__tilePattern=!1,this.tilingTexture=!1)},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),this.sprite.__tilePattern&&(this.__tilePattern=!1,this.tilingTexture=!1)))}}),Object.defineProperty(c.AnimationManager.prototype,"frameName",{get:function(){return this.currentFrame?this.currentFrame.name:void 0},set:function(a){"string"==typeof a&&null!==this._frameData.getFrameByName(a)?(this.currentFrame=this._frameData.getFrameByName(a),this.currentFrame&&(this._frameIndex=this.currentFrame.index,this.sprite.setFrame(this.currentFrame),this.sprite.__tilePattern&&(this.__tilePattern=!1,this.tilingTexture=!1))):console.warn("Cannot set frameName: "+a)}}),c.Animation=function(a,b,d,e,f,g,h){"undefined"==typeof 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),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("undefined"==typeof b&&(b=!1),"string"==typeof a)for(var d=0;d=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.loopCount++,this._parent.events.onAnimationLoop$dispatch(this._parent,this),this.onLoop.dispatch(this._parent,this),this.updateCurrentFrame(!0)):(this.complete(),!1):this.updateCurrentFrame(!0)):!1},updateCurrentFrame:function(a){return this._frameData?(this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&(this._parent.setFrame(this.currentFrame),this._parent.__tilePattern&&(this._parent.__tilePattern=!1,this._parent.tilingTexture=!1)),this.onUpdate&&a?(this.onUpdate.dispatch(this,this.currentFrame),!!this._frameData):!0):!1},next:function(a){"undefined"==typeof 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){"undefined"==typeof 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){"undefined"==typeof 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,h){this.index=a,this.x=b,this.y=d,this.width=e,this.height=f,this.name=g,this.uuid=h,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={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,this.uuid);for(var b in this)this.hasOwnProperty(b)&&(a[b]=this[b]);return a},getRect:function(a){return"undefined"==typeof 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=d;d++)c.push(this._frames[d]);return c},getFrames:function(a,b,c){if("undefined"==typeof b&&(b=!0),"undefined"==typeof c&&(c=[]),"undefined"==typeof a||0===a.length)for(var d=0;dd;d++)c.push(b?this.getFrame(a[d]):this.getFrameByName(a[d]));return c},getFrameIndexes:function(a,b,c){if("undefined"==typeof b&&(b=!0),"undefined"==typeof c&&(c=[]),"undefined"==typeof a||0===a.length)for(var d=0,e=this._frames.length;e>d;d++)c.push(this._frames[d].index);else for(var d=0,e=a.length;e>d;d++)b?c.push(a[d]):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=a.cache.getImage(b);if(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++){var s=a.rnd.uuid();o.addFrame(new c.Frame(r,p,q,d,e,"",s)),PIXI.TextureCache[s]=new PIXI.Texture(PIXI.BaseTextureCache[b],{x:p,y:q,width:d,height:e}),p+=d+h,p+d>j&&(p=g,q+=e+h)}return o},JSONData:function(a,b,d){if(!b.frames)return console.warn("Phaser.AnimationParser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array"),void console.log(b);for(var e,f=new c.FrameData,g=b.frames,h=0;h tag");for(var e,f,g,h,i,j,k,l,m,n,o,p,q=new c.FrameData,r=b.getElementsByTagName("SubTexture"),s=0;s-1},getAssetIndex:function(a,b){for(var c=-1,d=0;d-1?{index:c,file:this._fileList[c]}:!1},reset:function(a,b){"undefined"==typeof 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){var f={type:a,key:b,url:c,syncPoint:this._withSyncPointDepth>0,data:null,loading:!1,loaded:!1,error:!1};if(d)for(var g in d)f[g]=d[g];var h=this.getAssetIndex(a,b);if(e&&h>-1){var i=this._fileList[h];i.loading||i.loaded?(this._fileList.push(f),this._totalFileCount++):this._fileList[h]=f}else-1===h&&(this._fileList.push(f),this._totalFileCount++)},replaceInFileList:function(a,b,c,d){return this.addToFileList(a,b,c,d,!0)},pack:function(a,b,c,d){if("undefined"==typeof b&&(b=null),"undefined"==typeof c&&(c=null),"undefined"==typeof 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,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=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){"undefined"==typeof 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=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)},getAudioURL:function(a){for(var b=0;b=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.game.cache.addImage(a.key,a.url,a.data);break;case"spritesheet":this.game.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.game.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)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.xmlURL?(d=!1,this.xhrLoad(a,this.transformUrl(a.xmlURL,a),"text",this.xmlLoadComplete)):this.game.cache.addBitmapFont(a.key,a.url,a.data,a.xmlData,a.xSpacing,a.ySpacing);break;case"audio":this.game.sound.usingWebAudio?(a.data=b.response,this.game.cache.addSound(a.key,a.url,a.data,!0,!1),a.autoDecode&&this.game.sound.decode(a.key)):this.game.cache.addSound(a.key,a.url,a.data,!1,!0);break;case"text":a.data=b.responseText,this.game.cache.addText(a.key,a.url,a.data);break;case"physics":var e=JSON.parse(b.responseText);this.game.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.data=a.callback?a.callback.call(a.callbackContext,a.key,b.response):b.response,this.game.cache.addBinary(a.key,a.data)}d&&this.asyncComplete(a)},jsonLoadComplete:function(a,b){var c=JSON.parse(b.responseText);"tilemap"===a.type?this.game.cache.addTilemap(a.key,a.url,c,a.format):"json"===a.type?this.game.cache.addJSON(a.key,a.url,c):this.game.cache.addTextureAtlas(a.key,a.url,a.data,c,a.format),this.asyncComplete(a)},csvLoadComplete:function(a,b){var c=b.responseText;this.game.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.game.cache.addBitmapFont(a.key,a.url,a.data,d,a.xSpacing,a.ySpacing):"textureatlas"===a.type?this.game.cache.addTextureAtlas(a.key,a.url,a.data,d,a.format):"xml"===a.type&&this.game.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,e){var f={},g=b.getElementsByTagName("info")[0],h=b.getElementsByTagName("common")[0];f.font=g.getAttribute("face"),f.size=parseInt(g.getAttribute("size"),10),f.lineHeight=parseInt(h.getAttribute("lineHeight"),10)+e,f.chars={};for(var i=b.getElementsByTagName("char"),j=0;j=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()))},loopFull:function(a){this.play(null,0,a,!0)},play:function(a,b,c,d,e){if(("undefined"==typeof a||a===!1||null===a)&&(a=""),"undefined"==typeof 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("undefined"==typeof 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,"undefined"==typeof c&&(c=this._volume),"undefined"==typeof 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)?(null===this._buffer&&(this._buffer=this.game.cache.getSoundData(this.key)),this._sound=this.context.createBufferSource(),this._sound.buffer=this._buffer,this._sound.connect(this.externalNode?this.externalNode:this.gainNode),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)),"undefined"==typeof this._sound.start?this._sound.noteGrainOn(0,this.position,this.duration):this.loop&&""===a?this._sound.start(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._sound.volume=this._muted?0: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,"undefined"==typeof 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._sound.connect(this.externalNode?this.externalNode: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;"undefined"==typeof this._sound.start?this._sound.noteGrainOn(0,a,b):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("undefined"==typeof 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){"undefined"==typeof b&&(b=!1),"undefined"==typeof 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("undefined"==typeof a&&(a=1e3),"undefined"==typeof 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){"undefined"==typeof 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||null,a?(this._muted=!0,this.usingWebAudio?(this._muteVolume=this.gainNode.gain.value,this.gainNode.gain.value=0):this.usingAudioTag&&this._sound&&(this._muteVolume=this._sound.volume,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){this.usingWebAudio?(this._volume=a,this.gainNode.gain.value=a):this.usingAudioTag&&this._sound&&a>=0&&1>=a&&(this._volume=a,this._sound.volume=a)}}),c.SoundManager=function(a){this.game=a,this.onSoundDecode=new c.Signal,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,this.context=null,this.usingWebAudio=!0,this.usingAudioTag=!1,this.noAudio=!1,this.connectToMaster=!0,this.touchLocked=!1,this.channels=32},c.SoundManager.prototype={boot:function(){if(this.game.device.iOS&&this.game.device.webAudio===!1&&(this.channels=1),!this.game.device.cocoonJS&&this.game.device.iOS||window.PhaserGlobal&&window.PhaserGlobal.fakeiOSTouchLock?(this.game.input.touch.callbackContext=this,this.game.input.touch.touchStartCallback=this.unlock,this.game.input.mouse.callbackContext=this,this.game.input.mouse.mouseDownCallback=this.unlock,this.touchLocked=!0):this.touchLocked=!1,window.PhaserGlobal){if(window.PhaserGlobal.disableAudio===!0)return this.usingWebAudio=!1,void(this.noAudio=!0);if(window.PhaserGlobal.disableWebAudio===!0)return this.usingWebAudio=!1,this.usingAudioTag=!0,void(this.noAudio=!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.noAudio=!0}else if(window.webkitAudioContext)try{this.context=new window.webkitAudioContext}catch(a){this.context=null,this.usingWebAudio=!1,this.noAudio=!0}window.Audio&&null===this.context&&(this.usingWebAudio=!1,this.usingAudioTag=!0,this.noAudio=!1),null!==this.context&&(this.masterGain="undefined"==typeof this.context.createGain?this.context.createGainNode():this.context.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this.context.destination))},unlock:function(){if(this.touchLocked!==!1)if(this.game.device.webAudio===!1||window.PhaserGlobal&&window.PhaserGlobal.disableWebAudio===!0)this.touchLocked=!1,this._unlockSource=null,this.game.input.touch.callbackContext=null,this.game.input.touch.touchStartCallback=null,this.game.input.mouse.callbackContext=null,this.game.input.mouse.mouseDownCallback=null;else{var a=this.context.createBuffer(1,1,22050);this._unlockSource=this.context.createBufferSource(),this._unlockSource.buffer=a,this._unlockSource.connect(this.context.destination),"undefined"==typeof this._unlockSource.start?this._unlockSource.noteOn(0):this._unlockSource.start(0)}},stopAll:function(){for(var a=0;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.splice.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){"undefined"==typeof 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.position0;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=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){a=+a||0;var e=typeof b;"number"!==e&&"string"!==e||!d||d[b]!==a||(b=d=null),d=null==d?1:+d||0,null===b?(b=a,a=0):b=+b||0;for(var f=-1,g=Math.max(c.Math.roundAwayFromZero((b-a)/(d||1)),0),h=new Array(g);++f>>0:(a<<24|b<<16|d<<8|e)>>>0},unpackPixel:function(a,b,d,e){return("undefined"==typeof b||null===b)&&(b=c.Color.createColor()),("undefined"==typeof d||null===d)&&(d=!1),("undefined"==typeof 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){"undefined"==typeof 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 j.color=c.Color.getColor(j.r,j.g,j.b),j.color32=c.Color.getColor32(j.a,j.r,j.g,j.b),c.Color.updateColor(j)},updateColor:function(a){return a.rgba="rgba("+a.r.toString()+","+a.g.toString()+","+a.b.toString()+","+a.a.toString()+")",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"undefined"==typeof e&&(e=255),"undefined"==typeof 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),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){"undefined"==typeof a&&(a=1),"undefined"==typeof 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){"undefined"==typeof a&&(a=.5),"undefined"==typeof 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){"undefined"==typeof 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("undefined"==typeof a&&(a=0),"undefined"==typeof b&&(b=255),"undefined"==typeof 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}},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.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.parseConfig()},c.Physics.ARCADE=0,c.Physics.P2JS=1,c.Physics.NINJA=2,c.Physics.BOX2D=3,c.Physics.CHIPMUNK=4,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.game.time.deltaCap=.2),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))},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())},enable:function(a,b,d){"undefined"==typeof b&&(b=c.Physics.ARCADE),"undefined"==typeof 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) +},preUpdate:function(){this.p2&&this.p2.preUpdate(),this.box2d&&this.box2d.preUpdate()},update:function(){this.p2&&this.p2.update(),this.box2d&&this.box2d.update()},setBoundsToWorld:function(){this.arcade&&this.arcade.setBoundsToWorld(),this.ninja&&this.ninja.setBoundsToWorld(),this.p2&&this.p2.setBoundsToWorld(),this.box2d&&this.box2d.setBoundsToWorld()},clear:function(){this.p2&&this.p2.clear(),this.box2d&&this.box2d.clear()},reset:function(){this.p2&&this.p2.reset(),this.box2d&&this.box2d.reset()},destroy:function(){this.p2&&this.p2.destroy(),this.box2d&&this.box2d.destroy(),this.arcade=null,this.ninja=null,this.p2=null,this.box2d=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.setTo(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height)},enable:function(a,b){"undefined"==typeof 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))},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"undefined"==typeof 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;f0},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;f0},sort:function(a){this.sortDirection===c.Physics.Arcade.LEFT_RIGHT?a._hash.sort(function(a,b){return a.body&&b.body?a.body.x-b.body.x:-1}):this.sortDirection===c.Physics.Arcade.RIGHT_LEFT?a._hash.sort(function(a,b){return a.body&&b.body?b.body.x-a.body.x:-1}):this.sortDirection===c.Physics.Arcade.TOP_BOTTOM?a._hash.sort(function(a,b){return a.body&&b.body?a.body.y-b.body.y:-1}):this.sortDirection===c.Physics.Arcade.BOTTOM_TOP&&a._hash.sort(function(a,b){return a.body&&b.body?b.body.y-a.body.y:-1})},collideHandler:function(a,b,d,e,f,g){return"undefined"==typeof 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):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)if(this.skipQuadTree||a.body.skipQuadTree){for(var h=0;hb._hash[h].body.right)break;if(b._hash[h].body.x>a.body.right)continue}else if(this.sortDirection===c.Physics.Arcade.TOP_BOTTOM){if(a.body.bottomb._hash[h].body.bottom)break;if(b._hash[h].body.y>a.body.bottom)continue}this.collideSpriteVsSprite(a,b._hash[h],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 i=this.quadTree.retrieve(a),h=0;hj.body.right)continue;if(j.body.x>h.body.right)break}else if(this.sortDirection===c.Physics.Arcade.TOP_BOTTOM){if(h.body.bottomj.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=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()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()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;k0&&(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){"undefined"==typeof b&&(b=60),c=c||this.game.input.activePointer,"undefined"==typeof 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){"undefined"==typeof d&&(d=60),"undefined"==typeof 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"undefined"==typeof 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"undefined"==typeof b&&(b=60),d=d||new c.Point,d.setTo(Math.cos(a)*b,Math.sin(a)*b)},accelerationFromRotation:function(a,b,d){return"undefined"==typeof 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){"undefined"==typeof c&&(c=60),"undefined"==typeof d&&(d=1e3),"undefined"==typeof 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){"undefined"==typeof c&&(c=60),"undefined"==typeof b&&(b=this.game.input.activePointer),"undefined"==typeof d&&(d=1e3),"undefined"==typeof 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){"undefined"==typeof d&&(d=60),"undefined"==typeof e&&(e=1e3),"undefined"==typeof 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._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(){var a=Math.abs(this.sprite.scale.x),b=Math.abs(this.sprite.scale.y);(a!==this._sx||b!==this._sy)&&(this.width=this.sourceWidth*a,this.height=this.sourceHeight*b,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this._sx=a,this._sy=b,this.center.setTo(this.position.x+this.halfWidth,this.position.y+this.halfHeight),this._reset=!0)},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.body=null,this.sprite=null},checkWorldBounds:function(){this.position.xthis.game.physics.arcade.bounds.right&&this.game.physics.arcade.checkCollision.right&&(this.position.x=this.game.physics.arcade.bounds.right-this.width,this.velocity.x*=-this.bounce.x,this.blocked.right=!0),this.position.ythis.game.physics.arcade.bounds.bottom&&this.game.physics.arcade.checkCollision.down&&(this.position.y=this.game.physics.arcade.bounds.bottom-this.height,this.velocity.y*=-this.bounce.y,this.blocked.down=!0)},setSize:function(a,b,c,d){"undefined"==typeof c&&(c=this.offset.x),"undefined"==typeof 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){"undefined"==typeof 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){if(a.body){var f=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!==f.length)for(var g=0;gb.deltaAbsY()?f=-1:b.deltaAbsX()f){if((c.faceLeft||c.faceRight)&&(d=this.tileCheckX(b,c),0!==d&&!c.intersects(b.position.x,b.position.y,b.right,b.bottom)))return!0;(c.faceTop||c.faceBottom)&&(e=this.tileCheckY(b,c))}else{if((c.faceTop||c.faceBottom)&&(e=this.tileCheckY(b,c),0!==e&&!c.intersects(b.position.x,b.position.y,b.right,b.bottom)))return!0;(c.faceLeft||c.faceRight)&&(d=this.tileCheckX(b,c))}return 0!==d||0!==e},tileCheckX:function(a,b){var c=0;return a.deltaX()<0&&!a.blocked.left&&b.collideRight&&a.checkCollision.left?b.faceRight&&a.x0&&!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.y0&&!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,a.velocity.x=0===a.bounce.x?0:-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,a.velocity.y=0===a.bounce.y?0:-a.velocity.y*a.bounce.y}},c.Utils.mixinPrototype(c.Physics.Arcade.prototype,c.Physics.Arcade.TilemapCollision.prototype),!function(a){"object"==typeof exports?module.exports=a():"function"==typeof define&&define.amd?define(a):"undefined"!=typeof window?window.p2=a():"undefined"!=typeof global?global.p2=a():"undefined"!=typeof self&&(self.p2=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=0&&1>=i&&j>=0&&1>=j}},{"./Scalar":4}],2:[function(a,b){function c(){}b.exports=c,c.area=function(a,b,c){return(b[0]-a[0])*(c[1]-a[1])-(c[0]-a[0])*(b[1]-a[1])},c.left=function(a,b,d){return c.area(a,b,d)>0},c.leftOn=function(a,b,d){return c.area(a,b,d)>=0},c.right=function(a,b,d){return c.area(a,b,d)<0},c.rightOn=function(a,b,d){return c.area(a,b,d)<=0};var d=[],e=[];c.collinear=function(a,b,f,g){if(g){var h=d,i=e;h[0]=b[0]-a[0],h[1]=b[1]-a[1],i[0]=f[0]-b[0],i[1]=f[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==c.area(a,b,f)},c.sqdist=function(a,b){var c=b[0]-a[0],d=b[1]-a[1];return c*c+d*d}},{}],3:[function(a,b){function c(){this.vertices=[]}function d(a,b,c,d,e){e=e||0;var f=b[1]-a[1],h=a[0]-b[0],i=f*a[0]+h*a[1],j=d[1]-c[1],k=c[0]-d[0],l=j*c[0]+k*c[1],m=f*k-j*h;return g.eq(m,0,e)?[0,0]:[(k*i-h*l)/m,(f*l-j*i)/m]}var e=a("./Line"),f=a("./Point"),g=a("./Scalar");b.exports=c,c.prototype.at=function(a){var b=this.vertices,c=b.length;return b[0>a?a%c+c:a%c]},c.prototype.first=function(){return this.vertices[0]},c.prototype.last=function(){return this.vertices[this.vertices.length-1]},c.prototype.clear=function(){this.vertices.length=0},c.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])},c.prototype.makeCCW=function(){for(var a=0,b=this.vertices,c=1;cb[a][0])&&(a=c);f.left(this.at(a-1),this.at(a),this.at(a+1))||this.reverse()},c.prototype.reverse=function(){for(var a=[],b=0,c=this.vertices.length;b!==c;b++)a.push(this.vertices.pop());this.vertices=a},c.prototype.isReflex=function(a){return f.right(this.at(a-1),this.at(a),this.at(a+1))};var h=[],i=[];c.prototype.canSee=function(a,b){var c,d,g=h,j=i;if(f.leftOn(this.at(a+1),this.at(a),this.at(b))&&f.rightOn(this.at(a-1),this.at(a),this.at(b)))return!1;d=f.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&&f.leftOn(this.at(a),this.at(b),this.at(k+1))&&f.rightOn(this.at(a),this.at(b),this.at(k))&&(g[0]=this.at(a),g[1]=this.at(b),j[0]=this.at(k),j[1]=this.at(k+1),c=e.lineInt(g,j),f.sqdist(this.at(a),c)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;f0?this.slice(a):[this]},c.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;cc;c++)if(e.segmentsIntersect(a[b],a[b+1],a[c],a[c+1]))return!1;for(var b=1;bh)return console.warn("quickDecomp: max level ("+h+") reached."),a;for(var x=0;xo&&(n=o,k=l,r=y))),f.left(v.at(x+1),v.at(x),v.at(y+1))&&f.rightOn(v.at(x+1),v.at(x),v.at(y))&&(l=d(v.at(x+1),v.at(x),v.at(y),v.at(y+1)),f.left(v.at(x-1),v.at(x),l)&&(o=f.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,e.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)f.leftOn(v.at(x-1),v.at(x),v.at(y))&&f.rightOn(v.at(x+1),v.at(x),v.at(y))&&(o=f.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.length3&&c>=0;--c)f.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){function c(){}b.exports=c,c.eq=function(a,b,c){return c=c||0,Math.abs(a-b) (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.0","grunt-contrib-jshint":"~0.9.2","grunt-contrib-nodeunit":"~0.1.2","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){function c(a){this.lowerBound=d.create(),a&&a.lowerBound&&d.copy(this.lowerBound,a.lowerBound),this.upperBound=d.create(),a&&a.upperBound&&d.copy(this.upperBound,a.upperBound)}{var d=a("../math/vec2");a("../utils/Utils")}b.exports=c;var e=d.create();c.prototype.setFromPoints=function(a,b,c,f){var g=this.lowerBound,h=this.upperBound;"number"!=typeof c&&(c=0),0!==c?d.rotate(g,a[0],c):d.copy(g,a[0]),d.copy(h,g);for(var i=Math.cos(c),j=Math.sin(c),k=1;ko;o++)l[o]>h[o]&&(h[o]=l[o]),l[o]c&&(this.lowerBound[b]=c);var d=a.upperBound[b];this.upperBound[b]=c},c.aabbCheck=function(a,b){return a.getAABB().overlaps(b.getAABB())},c.prototype.boundingVolumeCheck=function(a,b){var d;switch(this.boundingVolumeType){case c.BOUNDING_CIRCLE:d=c.boundingRadiusCheck(a,b);break;case c.AABB:d=c.aabbCheck(a,b);break;default:throw new Error("Bounding volume type not recognized: "+this.boundingVolumeType)}return d},c.canCollide=function(a,b){return a.type===e.STATIC&&b.type===e.STATIC?!1:a.type===e.KINEMATIC&&b.type===e.STATIC||a.type===e.STATIC&&b.type===e.KINEMATIC?!1:a.type===e.KINEMATIC&&b.type===e.KINEMATIC?!1:a.sleepState===e.SLEEPING&&b.sleepState===e.SLEEPING?!1:a.sleepState===e.SLEEPING&&b.type===e.STATIC||b.sleepState===e.SLEEPING&&a.type===e.STATIC?!1:!0},c.NAIVE=1,c.SAP=2},{"../math/vec2":31,"../objects/Body":32}],9:[function(a,b){function c(a){d.apply(this),a=e.defaults(a,{xmin:-100,xmax:100,ymin:-100,ymax:100,nx:10,ny:10}),this.xmin=a.xmin,this.ymin=a.ymin,this.xmax=a.xmax,this.ymax=a.ymax,this.nx=a.nx,this.ny=a.ny,this.binsizeX=(this.xmax-this.xmin)/this.nx,this.binsizeY=(this.ymax-this.ymin)/this.ny}var d=(a("../shapes/Circle"),a("../shapes/Plane"),a("../shapes/Particle"),a("../collision/Broadphase")),e=(a("../math/vec2"),a("../utils/Utils"));b.exports=c,c.prototype=new d,c.prototype.constructor=c,c.prototype.getCollisionPairs=function(a){for(var b=[],c=a.bodies,e=c.length,f=(this.binsizeX,this.binsizeY,this.nx),g=this.ny,h=this.xmin,i=this.ymin,j=this.xmax,k=this.ymax,l=[],m=f*g,n=0;m>n;n++)l.push([]);for(var o=f/(j-h),p=g/(k-i),n=0;n!==e;n++)for(var q=c[n],r=q.aabb,s=Math.max(r.lowerBound[0],h),t=Math.max(r.lowerBound[1],i),u=Math.min(r.upperBound[0],j),v=Math.min(r.upperBound[1],k),w=Math.floor(o*(s-h)),x=Math.floor(p*(t-i)),y=Math.floor(o*(u-h)),z=Math.floor(p*(v-i)),A=w;y>=A;A++)for(var B=x;z>=B;B++){var C=A,D=B,E=C*(g-1)+D;E>=0&&m>E&&l[E].push(q)}for(var n=0;n!==m;n++)for(var F=l[n],A=0,G=F.length;A!==G;A++)for(var q=F[A],B=0;B!==A;B++){var H=F[B];d.canCollide(q,H)&&this.boundingVolumeCheck(q,H)&&b.push(q,H)}return b}},{"../collision/Broadphase":8,"../math/vec2":31,"../shapes/Circle":38,"../shapes/Particle":42,"../shapes/Plane":43,"../utils/Utils":50}],10:[function(a,b){function c(){d.call(this,d.NAIVE)}{var d=(a("../shapes/Circle"),a("../shapes/Plane"),a("../shapes/Shape"),a("../shapes/Particle"),a("../collision/Broadphase"));a("../math/vec2")}b.exports=c,c.prototype=new d,c.prototype.constructor=c,c.prototype.getCollisionPairs=function(a){var b=a.bodies,c=this.result;c.length=0;for(var e=0,f=b.length;e!==f;e++)for(var g=b[e],h=0;e>h;h++){var i=b[h];d.canCollide(g,i)&&this.boundingVolumeCheck(g,i)&&c.push(g,i)}return c},c.prototype.aabbQuery=function(a,b,c){c=c||[];for(var d=a.bodies,e=0;e=r*n)return!1;n=r}return!0}var f=a("../math/vec2"),g=f.sub,h=f.add,i=f.dot,j=a("../utils/Utils"),k=a("../utils/TupleDictionary"),l=a("../equations/Equation"),m=a("../equations/ContactEquation"),n=a("../equations/FrictionEquation"),o=a("../shapes/Circle"),p=a("../shapes/Convex"),q=a("../shapes/Shape"),r=(a("../objects/Body"),a("../shapes/Rectangle"));b.exports=c;var s=f.fromValues(0,1),t=f.fromValues(0,0),u=f.fromValues(0,0),v=f.fromValues(0,0),w=f.fromValues(0,0),x=f.fromValues(0,0),y=f.fromValues(0,0),z=f.fromValues(0,0),A=f.fromValues(0,0),B=f.fromValues(0,0),C=f.fromValues(0,0),D=f.fromValues(0,0),E=f.fromValues(0,0),F=f.fromValues(0,0),G=f.fromValues(0,0),H=f.fromValues(0,0),I=f.fromValues(0,0),J=f.fromValues(0,0),K=f.fromValues(0,0),L=[],M=f.create(),N=f.create();c.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],h=a.shapeOffsets[e];a.shapeAngles[e]}a.toWorldFrame(c,h);for(var i=0,j=b.shapes.length;i!==j;i++){{var k=b.shapes[i],l=b.shapeOffsets[i];b.shapeAngles[i]}if(b.toWorldFrame(d,l),this[g.type|k.type](a,g,c,g.angle+a.angle,b,k,d,k.angle+b.angle,!0))return!0}}return!1},c.prototype.collidedLastStep=function(a,b){var c=0|a.id,d=0|b.id;return!!this.collidingBodiesLastStep.get(c,d)},c.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)}if(this.reuseObjects){var f=this.contactEquations,g=this.frictionEquations,h=this.reusableFrictionEquations,i=this.reusableContactEquations;j.appendArray(i,f),j.appendArray(h,g)}this.contactEquations.length=this.frictionEquations.length=0},c.prototype.createContactEquation=function(a,b,c,d){var e=this.reusableContactEquations.length?this.reusableContactEquations.pop():new m(a,b);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},c.prototype.createFrictionEquation=function(a,b,c,d){var e=this.reusableFrictionEquations.length?this.reusableFrictionEquations.pop():new n(a,b);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},c.prototype.createFrictionFromContact=function(a){var b=this.createFrictionEquation(a.bodyA,a.bodyB,a.shapeA,a.shapeB);return f.copy(b.contactPointA,a.contactPointA),f.copy(b.contactPointB,a.contactPointB),f.rotate90cw(b.t,a.normalA),b.contactEquations.push(a),b},c.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}f.set(c.contactPointA,0,0),f.set(c.contactPointB,0,0),f.set(c.t,0,0);for(var e=0;e!==a;e++)b=this.contactEquations[this.contactEquations.length-1-e],b.bodyA===d?(f.add(c.t,c.t,b.normalA),f.add(c.contactPointA,c.contactPointA,b.contactPointA),f.add(c.contactPointB,c.contactPointB,b.contactPointB)):(f.sub(c.t,c.t,b.normalA),f.add(c.contactPointA,c.contactPointA,b.contactPointB),f.add(c.contactPointB,c.contactPointB,b.contactPointA)),c.contactEquations.push(b);var g=1/a;return f.scale(c.contactPointA,c.contactPointA,g),f.scale(c.contactPointB,c.contactPointB,g),f.normalize(c.t,c.t),f.rotate90cw(c.t,c.t),c},c.prototype[q.LINE|q.CONVEX]=c.prototype.convexLine=function(a,b,c,d,e,f,g,h,i){return i?!1:0},c.prototype[q.LINE|q.RECTANGLE]=c.prototype.lineRectangle=function(a,b,c,d,e,f,g,h,i){return i?!1:0};var O=new r(1,1),P=f.create();c.prototype[q.CAPSULE|q.CONVEX]=c.prototype[q.CAPSULE|q.RECTANGLE]=c.prototype.convexCapsule=function(a,b,c,e,g,h,i,j,k){var l=P;f.set(l,h.length/2,0),f.rotate(l,l,j),f.add(l,l,i);var m=this.circleConvex(g,h,l,j,a,b,c,e,k,h.radius);f.set(l,-h.length/2,0),f.rotate(l,l,j),f.add(l,l,i);var n=this.circleConvex(g,h,l,j,a,b,c,e,k,h.radius);if(k&&(m||n))return!0;var o=O;d(o,h);var p=this.convexConvex(a,b,c,e,g,o,i,j,k);return p+m+n},c.prototype[q.CAPSULE|q.LINE]=c.prototype.lineCapsule=function(a,b,c,d,e,f,g,h,i){return i?!1:0};var Q=f.create(),R=f.create(),S=new r(1,1);c.prototype[q.CAPSULE|q.CAPSULE]=c.prototype.capsuleCapsule=function(a,b,c,e,g,h,i,j,k){for(var l,m=Q,n=R,o=0,p=0;2>p;p++){f.set(m,(0===p?-1:1)*b.length/2,0),f.rotate(m,m,e),f.add(m,m,c);for(var q=0;2>q;q++){f.set(n,(0===q?-1:1)*h.length/2,0),f.rotate(n,n,j),f.add(n,n,i),this.enableFrictionReduction&&(l=this.enableFriction,this.enableFriction=!1);var r=this.circleCircle(a,b,m,e,g,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;d(s,b);var t=this.convexCapsule(a,s,c,e,g,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}d(s,h);var u=this.convexCapsule(g,s,i,j,a,b,c,e,k);return this.enableFrictionReduction&&(this.enableFriction=l),k&&u?!0:(o+=u,this.enableFrictionReduction&&o&&this.enableFriction&&this.frictionEquations.push(this.createFrictionFromAverage(o)),o)},c.prototype[q.LINE|q.LINE]=c.prototype.lineLine=function(a,b,c,d,e,f,g,h,i){return i?!1:0},c.prototype[q.PLANE|q.LINE]=c.prototype.planeLine=function(a,b,c,d,e,j,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;f.set(n,-j.length/2,0),f.set(o,j.length/2,0),f.rotate(p,n,l),f.rotate(q,o,l),h(p,p,k),h(q,q,k),f.copy(n,p),f.copy(o,q),g(r,o,n),f.normalize(C,r),f.rotate90cw(F,C),f.rotate(E,s,d),G[0]=n,G[1]=o;for(var I=0;IK){if(m)return!0;var M=this.createContactEquation(a,e,b,j);H++,f.copy(M.normalA,E),f.normalize(M.normalA,M.normalA),f.scale(D,E,K),g(M.contactPointA,J,D),g(M.contactPointA,M.contactPointA,a.position),g(M.contactPointB,J,k),h(M.contactPointB,M.contactPointB,k),g(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)},c.prototype[q.PARTICLE|q.CAPSULE]=c.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)},c.prototype[q.CIRCLE|q.LINE]=c.prototype.circleLine=function(a,b,c,d,e,j,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;f.set(K,-j.length/2,0),f.set(M,j.length/2,0),f.rotate(N,K,l),f.rotate(O,M,l),h(N,N,k),h(O,O,k),f.copy(K,N),f.copy(M,O),g(I,M,K),f.normalize(J,I),f.rotate90cw(H,J),g(P,c,K);var T=i(P,H);g(s,K,k),g(Q,c,k);var U=o+n;if(Math.abs(T)W&&X>V){if(m)return!0;var Y=this.createContactEquation(a,e,b,j);return f.scale(Y.normalA,p,-1),f.normalize(Y.normalA,Y.normalA),f.scale(Y.contactPointA,Y.normalA,o),h(Y.contactPointA,Y.contactPointA,c),g(Y.contactPointA,Y.contactPointA,a.position),g(Y.contactPointB,r,k),h(Y.contactPointB,Y.contactPointB,k),g(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;ZQ&&(f.copy(J,B),L=Q,f.scale(A,s,Q),f.add(A,A,B),K=!0)}}if(K){if(m)return!0;var R=this.createContactEquation(a,i,b,j);return f.sub(R.normalA,J,c),f.normalize(R.normalA,R.normalA),f.scale(R.contactPointA,R.normalA,n),h(R.contactPointA,R.contactPointA,c),g(R.contactPointA,R.contactPointA,a.position),g(R.contactPointB,A,k),h(R.contactPointB,R.contactPointB,k),g(R.contactPointB,R.contactPointB,i.position),this.contactEquations.push(R),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(R)),1}if(n>0)for(var N=0;NQ&&(I=Q,f.scale(E,s,Q),f.add(E,E,c),f.copy(H,s),L=!0)}if(L){var R=this.createContactEquation(a,j,b,k);return f.scale(R.normalA,H,-1),f.normalize(R.normalA,R.normalA),f.set(R.contactPointA,0,0),h(R.contactPointA,R.contactPointA,c),g(R.contactPointA,R.contactPointA,a.position),g(R.contactPointB,E,l),h(R.contactPointB,R.contactPointB,l),g(R.contactPointB,R.contactPointB,j.position),this.contactEquations.push(R),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(R)),1}return 0},c.prototype[q.CIRCLE]=c.prototype.circleCircle=function(a,b,c,d,e,i,j,k,l,m,n){var o=t,m=m||b.radius,n=n||i.radius;g(o,c,j);var p=m+n;if(f.squaredLength(o)>Math.pow(p,2))return 0;if(l)return!0;var q=this.createContactEquation(a,e,b,i);return g(q.normalA,j,c),f.normalize(q.normalA,q.normalA),f.scale(q.contactPointA,q.normalA,m),f.scale(q.contactPointB,q.normalA,-n),h(q.contactPointA,q.contactPointA,c),g(q.contactPointA,q.contactPointA,a.position),h(q.contactPointB,q.contactPointB,j),g(q.contactPointB,q.contactPointB,e.position),this.contactEquations.push(q),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(q)),1},c.prototype[q.PLANE|q.CONVEX]=c.prototype[q.PLANE|q.RECTANGLE]=c.prototype.planeConvex=function(a,b,c,d,e,j,k,l,m){var n=t,o=u,p=v,q=0;f.rotate(o,s,d);for(var r=0;r!==j.vertices.length;r++){var w=j.vertices[r];if(f.rotate(n,w,l),h(n,n,k),g(p,n,c),i(p,o)<=0){if(m)return!0;q++;var x=this.createContactEquation(a,e,b,j);g(p,n,c),f.copy(x.normalA,o);var y=i(p,x.normalA);f.scale(p,x.normalA,y),g(x.contactPointB,n,e.position),g(x.contactPointA,n,p),g(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},c.prototype[q.PARTICLE|q.PLANE]=c.prototype.particlePlane=function(a,b,c,d,e,h,j,k,l){var m=t,n=u;k=k||0,g(m,c,j),f.rotate(n,s,k);var o=i(m,n);if(o>0)return 0;if(l)return!0;var p=this.createContactEquation(e,a,h,b);return f.copy(p.normalA,n),f.scale(m,p.normalA,o),g(p.contactPointA,c,m),g(p.contactPointA,p.contactPointA,e.position),g(p.contactPointB,c,a.position),this.contactEquations.push(p),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(p)),1},c.prototype[q.CIRCLE|q.PARTICLE]=c.prototype.circleParticle=function(a,b,c,d,e,i,j,k,l){var m=t;if(g(m,j,c),f.squaredLength(m)>Math.pow(b.radius,2))return 0;if(l)return!0;var n=this.createContactEquation(a,e,b,i);return f.copy(n.normalA,m),f.normalize(n.normalA,n.normalA),f.scale(n.contactPointA,n.normalA,b.radius),h(n.contactPointA,n.contactPointA,c),g(n.contactPointA,n.contactPointA,a.position),g(n.contactPointB,j,e.position),this.contactEquations.push(n),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(n)),1};{var X=new o(1),Y=f.create(),Z=f.create();f.create()}c.prototype[q.PLANE|q.CAPSULE]=c.prototype.planeCapsule=function(a,b,c,d,e,g,i,j,k){var l=Y,m=Z,n=X;f.set(l,-g.length/2,0),f.rotate(l,l,j),h(l,l,i),f.set(m,g.length/2,0),f.rotate(m,m,j),h(m,m,i),n.radius=g.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},c.prototype[q.CIRCLE|q.PLANE]=c.prototype.circlePlane=function(a,b,c,d,e,j,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;g(x,p,r),f.rotate(y,s,w);var A=i(y,x);if(A>o.radius)return 0;if(m)return!0;var B=this.createContactEquation(q,n,j,b);return f.copy(B.normalA,y),f.scale(B.contactPointB,B.normalA,-o.radius),h(B.contactPointB,B.contactPointB,p),g(B.contactPointB,B.contactPointB,n.position),f.scale(z,B.normalA,A),g(B.contactPointA,x,z),h(B.contactPointA,B.contactPointA,r),g(B.contactPointA,B.contactPointA,q.position),this.contactEquations.push(B),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(B)),1},c.prototype[q.CONVEX]=c.prototype[q.CONVEX|q.RECTANGLE]=c.prototype[q.RECTANGLE]=c.prototype.convexConvex=function(a,b,d,e,j,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=c.findSeparatingAxis(b,d,e,k,l,m,p);if(!G)return 0;g(D,l,d),i(p,D)>0&&f.scale(p,p,-1);var H=c.getClosestEdge(b,e,p,!0),I=c.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=d,P=l,Q=e,R=m,S=a,T=j;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];f.rotate(q,W,R),h(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];f.rotate(r,Z,Q),f.rotate(s,$,Q),h(r,r,O),h(s,s,O),g(y,s,r),f.rotate90cw(E,y),f.normalize(E,E),g(D,q,r);var _=i(E,D);(Y===K&&o>=_||Y!==K&&0>=_)&&X++}if(X>=3){if(n)return!0;var ab=this.createContactEquation(S,T,M,N);F++;var Z=M.vertices[K%M.vertices.length],$=M.vertices[(K+1)%M.vertices.length];f.rotate(r,Z,Q),f.rotate(s,$,Q),h(r,r,O),h(s,s,O),g(y,s,r),f.rotate90cw(ab.normalA,y),f.normalize(ab.normalA,ab.normalA),g(D,q,r);var _=i(ab.normalA,D);f.scale(C,ab.normalA,_),g(ab.contactPointA,q,O),g(ab.contactPointA,ab.contactPointA,C),h(ab.contactPointA,ab.contactPointA,O),g(ab.contactPointA,ab.contactPointA,S.position),g(ab.contactPointB,q,P),h(ab.contactPointB,ab.contactPointB,P),g(ab.contactPointB,ab.contactPointB,T.position),this.contactEquations.push(ab),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(ab))}}}return this.enableFrictionReduction&&this.enableFriction&&F&&this.frictionEquations.push(this.createFrictionFromAverage(F)),F};var $=f.fromValues(0,0);c.projectConvexOntoAxis=function(a,b,c,d,e){var g,h,j=null,k=null,l=$;f.rotate(l,d,-c);for(var m=0;mj)&&(j=h),(null===k||k>h)&&(k=h);if(k>j){var n=k;k=j,j=n}var o=i(b,d);f.set(e,k+o,j+o)};var _=f.fromValues(0,0),ab=f.fromValues(0,0),bb=f.fromValues(0,0),cb=f.fromValues(0,0),db=f.fromValues(0,0),eb=f.fromValues(0,0);c.findSeparatingAxis=function(a,b,d,e,h,i,j){var k=null,l=!1,m=!1,n=_,o=ab,p=bb,q=cb,s=db,t=eb;if(a instanceof r&&e instanceof r)for(var u=0;2!==u;u++){var v=a,w=d;1===u&&(v=e,w=i);for(var x=0;2!==x;x++){0===x?f.set(q,0,1):1===x&&f.set(q,1,0),0!==w&&f.rotate(q,q,w),c.projectConvexOntoAxis(a,b,d,q,s),c.projectConvexOntoAxis(e,h,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)&&(f.copy(j,q),k=B,m=l)}}else for(var u=0;2!==u;u++){var v=a,w=d;1===u&&(v=e,w=i);for(var x=0;x!==v.vertices.length;x++){f.rotate(o,v.vertices[x],w),f.rotate(p,v.vertices[(x+1)%v.vertices.length],w),g(n,p,o),f.rotate90cw(q,n),f.normalize(q,q),c.projectConvexOntoAxis(a,b,d,q,s),c.projectConvexOntoAxis(e,h,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)&&(f.copy(j,q),k=B,m=l)}}return m};var fb=f.fromValues(0,0),gb=f.fromValues(0,0),hb=f.fromValues(0,0);c.getClosestEdge=function(a,b,c,d){var e=fb,h=gb,j=hb;f.rotate(e,c,-b),d&&f.scale(e,e,-1);for(var k=-1,l=a.vertices.length,m=-1,n=0;n!==l;n++){g(h,a.vertices[(n+1)%l],a.vertices[n%l]),f.rotate90cw(j,h),f.normalize(j,j);var o=i(j,e);(-1===k||o>m)&&(k=n%l,m=o)}return k};var ib=f.create(),jb=f.create(),kb=f.create(),lb=f.create(),mb=f.create(),nb=f.create(),ob=f.create();c.prototype[q.CIRCLE|q.HEIGHTFIELD]=c.prototype.circleHeightfield=function(a,b,c,d,e,i,j,k,l,m){var n=i.data,m=m||b.radius,o=i.elementWidth,p=jb,q=ib,r=mb,s=ob,t=nb,u=kb,v=lb,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]y&&(y=n[A]);if(c[1]-m>y)return l?!1:0;for(var B=!1,A=w;x>A;A++){f.set(u,A*o,n[A]),f.set(v,(A+1)*o,n[A+1]),f.add(u,u,j),f.add(v,v,j),f.sub(t,v,u),f.rotate(t,t,Math.PI/2),f.normalize(t,t),f.scale(q,t,-m),f.add(q,q,c),f.sub(p,q,u);var C=f.dot(p,t);if(q[0]>=u[0]&&q[0]=C){if(l)return!0;B=!0,f.scale(p,t,-C),f.add(r,q,p),f.copy(s,t);var D=this.createContactEquation(e,a,i,b);f.copy(D.normalA,s),f.scale(D.contactPointB,D.normalA,-m),h(D.contactPointB,D.contactPointB,c),g(D.contactPointB,D.contactPointB,a.position),f.copy(D.contactPointA,r),f.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(f.set(u,A*o,n[A]),f.add(u,u,j),f.sub(p,c,u),f.squaredLength(p)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]s&&(s=k[u]);if(a.aabb.lowerBound[1]>s)return j?!1:0;for(var v=0,u=q;r>u;u++){f.set(m,u*l,k[u]),f.set(n,(u+1)*l,k[u+1]),f.add(m,m,h),f.add(n,n,h);var w=100;f.set(o,.5*(n[0]+m[0]),.5*(n[1]+m[1]-w)),f.sub(p.vertices[0],n,o),f.sub(p.vertices[1],m,o),f.copy(p.vertices[2],p.vertices[1]),f.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":22,"../equations/Equation":23,"../equations/FrictionEquation":24,"../math/vec2":31,"../objects/Body":32,"../shapes/Circle":38,"../shapes/Convex":39,"../shapes/Rectangle":44,"../shapes/Shape":45,"../utils/TupleDictionary":49,"../utils/Utils":50}],12:[function(a,b){function c(a){a=a||{},this.from=a.from?e.fromValues(a.from[0],a.from[1]):e.create(),this.to=a.to?e.fromValues(a.to[0],a.to[1]):e.create(),this._direction=e.create(),this.precision=1e-4,this.checkCollisionResponse=!0,this.skipBackfaces=!1,this.collisionMask=-1,this.collisionGroup=-1,this.mode=c.ANY,this.result=new f,this.hasHit=!1,this.callback=function(){}}function d(a,b,c){e.sub(z,c,a);var d=e.dot(z,b);e.scale(A,b,d),e.add(A,A,a);var f=e.distance(c,A);return f}b.exports=c;var e=a("../math/vec2"),f=a("../collision/RaycastResult"),g=a("../shapes/Shape"),h=a("../collision/AABB");c.prototype.constructor=c,c.CLOSEST=1,c.ANY=2,c.ALL=4;var i=new h,j=[];c.prototype.intersectWorld=function(a,b){return this.mode=b.mode||c.ANY,this.result=b.result||new f,this.skipBackfaces=!!b.skipBackfaces,this.collisionMask="undefined"!=typeof b.collisionMask?b.collisionMask:-1,this.collisionGroup="undefined"!=typeof b.collisionGroup?b.collisionGroup:-1,b.from&&e.copy(this.from,b.from),b.to&&e.copy(this.to,b.to),this.callback=b.callback||function(){},this.hasHit=!1,this.result.reset(),this._updateDirection(),this.getAABB(i),j.length=0,a.broadphase.aabbQuery(a,i,j),this.intersectBodies(j),this.hasHit};var k=(e.create(),e.create(),e.create());c.prototype.intersectBody=function(a,b){b&&(this.result=b,this._updateDirection());var c=this.checkCollisionResponse;if(!c||a.collisionResponse)for(var d=k,f=0,g=a.shapes.length;g>f;f++){var h=a.shapes[f];if(!c||h.collisionResponse){e.copy(d,a.shapeOffsets[f]),e.rotate(d,d,a.angle),e.add(d,d,a.position);var i=a.shapeAngles[f]+a.angle;if(this.intersectShape(h,i,d,a),this.result._shouldStop)break}}},c.prototype.intersectBodies=function(a,b){b&&(this.result=b,this._updateDirection());for(var c=0,d=a.length;!this.result._shouldStop&&d>c;c++)this.intersectBody(a[c])},c.prototype._updateDirection=function(){var a=this._direction;e.sub(a,this.to,this.from),e.normalize(a,a)},c.prototype.intersectShape=function(a,b,c,e){var f=this.from,g=d(f,this._direction,c);if(!(g>a.boundingSphereRadius)){var h=this[a.type];h&&h.call(this,a,b,c,e)}};var l=(e.create(),e.create(),e.create(),e.create(),e.create(),e.create(),e.create(),new f,e.create()),m=e.create(),n=e.create(),o=e.create(),p=e.create(),q=e.create(),r=e.create();c.prototype.intersectRectangle=function(a,b,c,d){var f=-Number.MAX_VALUE,g=Number.MAX_VALUE,h=l,i=m,j=n,k=o,s=p,t=q,u=r;if(e.set(t,.5*-a.width,.5*-a.height),e.set(u,.5*a.width,.5*a.height),e.rotate(h,this._direction,-b),d.toLocalFrame(i,this.from),0!==h[0]){var v=(t[0]-i[0])/h[0],w=(u[0]-i[0])/h[0],x=f;f=Math.max(f,Math.min(v,w)),f!==x&&e.set(j,v>w?1:-1,0);var y=g;g=Math.min(g,Math.max(v,w)),g!==y&&e.set(k,w>v?1:-1,0)}if(0!==h[1]){var z=(t[1]-i[1])/h[1],A=(u[1]-i[1])/h[1],x=f;f=Math.max(f,Math.min(z,A)),f!==x&&e.set(j,0,z>A?1:-1);var y=g;g=Math.min(g,Math.max(z,A)),g!==y&&e.set(k,0,A>z?1:-1)}if(g>=f){if(e.set(s,i[0]+h[0]*f,i[1]+h[1]*f),e.rotate(j,j,b),d.toWorldFrame(s,s),this.reportIntersection(j,s,a,d,-1),this._shouldStop)return;e.rotate(k,k,b),e.set(s,i[0]+h[0]*g,i[1]+h[1]*g),d.toWorldFrame(s,s),this.reportIntersection(k,s,a,d,-1)}},c.prototype[g.RECTANGLE]=c.prototype.intersectRectangle;var s=e.create(),t=e.create(),u=e.create(),v=e.create(),w=e.create();c.prototype.intersectPlane=function(a,b,c,d){var f=this.from,g=this.to,h=this._direction,i=s,j=t,k=u,l=v,m=w;e.set(l,0,1),e.rotate(l,l,b),e.sub(m,f,c);var n=e.dot(m,l);e.sub(m,g,c);var o=e.dot(m,l);if(!(n*o>0||e.distance(f,g)l))if(0===l)e.lerp(m,f,g,l),e.sub(n,m,c),e.normalize(n,n),this.reportIntersection(n,m,a,d,-1);else{var o=(-j-Math.sqrt(l))/(2*i),p=(-j+Math.sqrt(l))/(2*i);if(e.lerp(m,f,g,o),e.sub(n,m,c),e.normalize(n,n),this.reportIntersection(n,m,a,d,-1),this.result._shouldStop)return;e.lerp(m,f,g,p),e.sub(n,m,c),e.normalize(n,n),this.reportIntersection(n,m,a,d,-1)}},c.prototype[g.CIRCLE]=c.prototype.intersectCircle,c.prototype.getAABB=function(a){var b=this.to,c=this.from;a.lowerBound[0]=Math.min(b[0],c[0]),a.lowerBound[1]=Math.min(b[1],c[1]),a.upperBound[0]=Math.max(b[0],c[0]),a.upperBound[1]=Math.max(b[1],c[1]) +},c.prototype.reportIntersection=function(a,b,d,f,g){var h=this.from,i=this.to,j=e.distance(h,b),k=this.result;if(!(this.skipBackfaces&&e.dot(a,this._direction)>0))switch(k.hitFaceIndex="undefined"!=typeof g?g:-1,this.mode){case c.ALL:this.hasHit=!0,k.set(h,i,a,b,d,f,j),k.hasHit=!0,this.callback(k);break;case c.CLOSEST:(jc;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},c.prototype.sortList=function(){var a=this.axisList,b=this.axisIndex;c.sortAxisList(a,b)},c.prototype.getCollisionPairs=function(){var a=this.axisList,b=this.result,c=this.axisIndex;b.length=0;for(var d=a.length;d--;){var f=a[d];f.aabbNeedsUpdate&&f.updateAABB()}this.sortList();for(var g=0,h=0|a.length;g!==h;g++)for(var i=a[g],j=g+1;h>j;j++){var k=a[j],l=k.aabb.lowerBound[c]<=i.aabb.upperBound[c];if(!l)break;e.canCollide(i,k)&&this.boundingVolumeCheck(i,k)&&b.push(i,k)}return b},c.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);gthis.upperLimit&&(g.maxForce=0,g.minForce=-this.maxForce,this.distance=this.upperLimit,l=!0),this.lowerLimitEnabled&&this.positionc)g.scale(e.normalA,i,-1),g.sub(e.contactPointA,j,h.position),g.sub(e.contactPointB,k,o.position),g.scale(n,i,c),g.add(e.contactPointA,e.contactPointA,n),-1===a.indexOf(e)&&a.push(e);else{var u=a.indexOf(e);-1!==u&&a.splice(u,1)}if(this.lowerLimitEnabled&&d>s)g.scale(f.normalA,i,1),g.sub(f.contactPointA,j,h.position),g.sub(f.contactPointB,k,o.position),g.scale(n,i,d),g.sub(f.contactPointB,f.contactPointB,n),-1===a.indexOf(f)&&a.push(f);else{var u=a.indexOf(f);-1!==u&&a.splice(u,1)}},c.prototype.enableMotor=function(){this.motorEnabled||(this.equations.push(this.motorEquation),this.motorEnabled=!0)},c.prototype.disableMotor=function(){if(this.motorEnabled){var a=this.equations.indexOf(this.motorEquation);this.equations.splice(a,1),this.motorEnabled=!1}},c.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":22,"../equations/Equation":23,"../equations/RotationalLockEquation":25,"../math/vec2":31,"./Constraint":15}],20:[function(a,b){function c(a,b,c){c=c||{},d.call(this,a,b,d.REVOLUTE,c);var n=this.maxForce="undefined"!=typeof c.maxForce?c.maxForce:Number.MAX_VALUE;this.pivotA=h.create(),this.pivotB=h.create(),c.worldPivot?(h.sub(this.pivotA,c.worldPivot,a.position),h.sub(this.pivotB,c.worldPivot,b.position),h.rotate(this.pivotA,this.pivotA,-a.angle),h.rotate(this.pivotB,this.pivotB,-b.angle)):(h.copy(this.pivotA,c.localPivotA),h.copy(this.pivotB,c.localPivotB));var o=this.equations=[new e(a,b,-n,n),new e(a,b,-n,n)],p=o[0],q=o[1],r=this;p.computeGq=function(){return h.rotate(i,r.pivotA,a.angle),h.rotate(j,r.pivotB,b.angle),h.add(m,b.position,j),h.sub(m,m,a.position),h.sub(m,m,i),h.dot(m,k)},q.computeGq=function(){return h.rotate(i,r.pivotA,a.angle),h.rotate(j,r.pivotB,b.angle),h.add(m,b.position,j),h.sub(m,m,a.position),h.sub(m,m,i),h.dot(m,l)},q.minForce=p.minForce=-n,q.maxForce=p.maxForce=n,this.motorEquation=new f(a,b),this.motorEnabled=!1,this.angle=0,this.lowerLimitEnabled=!1,this.upperLimitEnabled=!1,this.lowerLimit=0,this.upperLimit=0,this.upperLimitEquation=new g(a,b),this.lowerLimitEquation=new g(a,b),this.upperLimitEquation.minForce=0,this.lowerLimitEquation.maxForce=0}var d=a("./Constraint"),e=a("../equations/Equation"),f=a("../equations/RotationalVelocityEquation"),g=a("../equations/RotationalLockEquation"),h=a("../math/vec2");b.exports=c;var i=h.create(),j=h.create(),k=h.fromValues(1,0),l=h.fromValues(0,1),m=h.create();c.prototype=new d,c.prototype.constructor=c,c.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)},c.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],m=this.upperLimit,n=this.lowerLimit,o=this.upperLimitEquation,p=this.lowerLimitEquation,q=this.angle=b.angle-a.angle;if(this.upperLimitEnabled&&q>m)o.angle=m,-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)}h.rotate(i,c,a.angle),h.rotate(j,d,b.angle),f.G[0]=-1,f.G[1]=0,f.G[2]=-h.crossLength(i,k),f.G[3]=1,f.G[4]=0,f.G[5]=h.crossLength(j,k),g.G[0]=0,g.G[1]=-1,g.G[2]=-h.crossLength(i,l),g.G[3]=0,g.G[4]=1,g.G[5]=h.crossLength(j,l)},c.prototype.enableMotor=function(){this.motorEnabled||(this.equations.push(this.motorEquation),this.motorEnabled=!0)},c.prototype.disableMotor=function(){if(this.motorEnabled){var a=this.equations.indexOf(this.motorEquation);this.equations.splice(a,1),this.motorEnabled=!1}},c.prototype.motorIsEnabled=function(){return!!this.motorEnabled},c.prototype.setMotorSpeed=function(a){if(this.motorEnabled){var b=this.equations.indexOf(this.motorEquation);this.equations[b].relativeVelocity=a}},c.prototype.getMotorSpeed=function(){return this.motorEnabled?this.motorEquation.relativeVelocity:!1}},{"../equations/Equation":23,"../equations/RotationalLockEquation":25,"../equations/RotationalVelocityEquation":26,"../math/vec2":31,"./Constraint":15}],21:[function(a,b){function c(a,b,c){c=c||{},d.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 d=a("./Equation");a("../math/vec2")}b.exports=c,c.prototype=new d,c.prototype.constructor=c,c.prototype.computeGq=function(){return this.ratio*this.bodyA.angle-this.bodyB.angle+this.angle},c.prototype.setRatio=function(a){var b=this.G;b[2]=a,b[5]=-1,this.ratio=a},c.prototype.setMaxTorque=function(a){this.maxForce=a,this.minForce=-a}},{"../math/vec2":31,"./Equation":23}],22:[function(a,b){function c(a,b){d.call(this,a,b,0,Number.MAX_VALUE),this.contactPointA=e.create(),this.penetrationVec=e.create(),this.contactPointB=e.create(),this.normalA=e.create(),this.restitution=0,this.firstImpact=!1,this.shapeA=null,this.shapeB=null}var d=a("./Equation"),e=a("../math/vec2");b.exports=c,c.prototype=new d,c.prototype.constructor=c,c.prototype.computeB=function(a,b,c){var d=this.bodyA,f=this.bodyB,g=this.contactPointA,h=this.contactPointB,i=d.position,j=f.position,k=this.penetrationVec,l=this.normalA,m=this.G,n=e.crossLength(g,l),o=e.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,e.add(k,j,h),e.sub(k,k,i),e.sub(k,k,g);var p,q;this.firstImpact&&0!==this.restitution?(q=0,p=1/b*(1+this.restitution)*this.computeGW()):(q=e.dot(l,k)+this.offset,p=this.computeGW());var r=this.computeGiMf(),s=-q*a-p*b-c*r;return s}},{"../math/vec2":31,"./Equation":23}],23:[function(a,b){function c(a,b,d,f){this.minForce="undefined"==typeof d?-Number.MAX_VALUE:d,this.maxForce="undefined"==typeof f?Number.MAX_VALUE:f,this.bodyA=a,this.bodyB=b,this.stiffness=c.DEFAULT_STIFFNESS,this.relaxation=c.DEFAULT_RELAXATION,this.G=new e.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=c;{var d=a("../math/vec2"),e=a("../utils/Utils");a("../objects/Body")}c.prototype.constructor=c,c.DEFAULT_STIFFNESS=1e6,c.DEFAULT_RELAXATION=4,c.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},c.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},c.prototype.computeB=function(a,b,c){var d=this.computeGW(),e=this.computeGq(),f=this.computeGiMf();return-e*a-d*b-f*c};var f=d.create(),g=d.create();c.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,f,d,g,e)+this.offset},c.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},c.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 h=d.create(),i=d.create();c.prototype.computeGiMf=function(){var a=this.bodyA,b=this.bodyB,c=a.force,e=a.angularForce,f=b.force,g=b.angularForce,j=a.invMassSolve,k=b.invMassSolve,l=a.invInertiaSolve,m=b.invInertiaSolve,n=this.G;return d.scale(h,c,j),d.scale(i,f,k),this.gmult(n,h,e*l,i,g*m)},c.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+g[1]*g[1]*c+g[2]*g[2]*e+g[3]*g[3]*d+g[4]*g[4]*d+g[5]*g[5]*f};{var j=d.create(),k=d.create(),l=d.create();d.create(),d.create(),d.create()}c.prototype.addToWlambda=function(a){var b=this.bodyA,c=this.bodyB,e=j,f=k,g=l,h=b.invMassSolve,i=c.invMassSolve,m=b.invInertiaSolve,n=c.invInertiaSolve,o=this.G;f[0]=o[0],f[1]=o[1],g[0]=o[3],g[1]=o[4],d.scale(e,f,h*a),d.add(b.vlambda,b.vlambda,e),b.wlambda+=m*o[2]*a,d.scale(e,g,i*a),d.add(c.vlambda,c.vlambda,e),c.wlambda+=n*o[5]*a},c.prototype.computeInvC=function(a){return 1/(this.computeGiMGt()+a)}},{"../math/vec2":31,"../objects/Body":32,"../utils/Utils":50}],24:[function(a,b){function c(a,b,c){e.call(this,a,b,-c,c),this.contactPointA=d.create(),this.contactPointB=d.create(),this.t=d.create(),this.contactEquations=[],this.shapeA=null,this.shapeB=null,this.frictionCoefficient=.3}{var d=a("../math/vec2"),e=a("./Equation");a("../utils/Utils")}b.exports=c,c.prototype=new e,c.prototype.constructor=c,c.prototype.setSlipForce=function(a){this.maxForce=a,this.minForce=-a},c.prototype.getSlipForce=function(){return this.maxForce},c.prototype.computeB=function(a,b,c){var e=(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]=-d.crossLength(e,g),h[3]=g[0],h[4]=g[1],h[5]=d.crossLength(f,g);var i=this.computeGW(),j=this.computeGiMf(),k=-i*b-c*j;return k}},{"../math/vec2":31,"../utils/Utils":50,"./Equation":23}],25:[function(a,b){function c(a,b,c){c=c||{},d.call(this,a,b,-Number.MAX_VALUE,Number.MAX_VALUE),this.angle=c.angle||0;var e=this.G;e[2]=1,e[5]=-1}var d=a("./Equation"),e=a("../math/vec2");b.exports=c,c.prototype=new d,c.prototype.constructor=c;var f=e.create(),g=e.create(),h=e.fromValues(1,0),i=e.fromValues(0,1);c.prototype.computeGq=function(){return e.rotate(f,h,this.bodyA.angle+this.angle),e.rotate(g,i,this.bodyB.angle),e.dot(f,g)}},{"../math/vec2":31,"./Equation":23}],26:[function(a,b){function c(a,b){d.call(this,a,b,-Number.MAX_VALUE,Number.MAX_VALUE),this.relativeVelocity=1,this.ratio=1}{var d=a("./Equation");a("../math/vec2")}b.exports=c,c.prototype=new d,c.prototype.constructor=c,c.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":31,"./Equation":23}],27:[function(a,b){var c=function(){};b.exports=c,c.prototype={constructor:c,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}}},{}],28:[function(a,b){function c(a,b,f){if(f=f||{},!(a instanceof d&&b instanceof d))throw new Error("First two arguments must be Material instances.");this.id=c.idCounter++,this.materialA=a,this.materialB=b,this.friction="undefined"!=typeof f.friction?Number(f.friction):.3,this.restitution="undefined"!=typeof f.restitution?Number(f.restitution):0,this.stiffness="undefined"!=typeof f.stiffness?Number(f.stiffness):e.DEFAULT_STIFFNESS,this.relaxation="undefined"!=typeof f.relaxation?Number(f.relaxation):e.DEFAULT_RELAXATION,this.frictionStiffness="undefined"!=typeof f.frictionStiffness?Number(f.frictionStiffness):e.DEFAULT_STIFFNESS,this.frictionRelaxation="undefined"!=typeof f.frictionRelaxation?Number(f.frictionRelaxation):e.DEFAULT_RELAXATION,this.surfaceVelocity="undefined"!=typeof f.surfaceVelocity?Number(f.surfaceVelocity):0,this.contactSkinSize=.005}var d=a("./Material"),e=a("../equations/Equation");b.exports=c,c.idCounter=0},{"../equations/Equation":23,"./Material":29}],29:[function(a,b){function c(a){this.id=a||c.idCounter++}b.exports=c,c.idCounter=0},{}],30:[function(a,b){var c={};c.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},c.Triangulate=function(a){var b=a.length>>1;if(3>b)return[];for(var d=[],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(c._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&&c._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)break}return d.push(e[0],e[1],e[2]),d},c._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},c._convex=function(a,b,c,d,e,f){return(b-d)*(e-c)+(c-a)*(f-d)>=0},b.exports=c},{}],31:[function(a,b){var c=b.exports={},d=a("../utils/Utils");c.crossLength=function(a,b){return a[0]*b[1]-a[1]*b[0]},c.crossVZ=function(a,b,d){return c.rotate(a,b,-Math.PI/2),c.scale(a,a,d),a},c.crossZV=function(a,b,d){return c.rotate(a,d,Math.PI/2),c.scale(a,a,b),a},c.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]},c.rotate90cw=function(a,b){var c=b[0],d=b[1];a[0]=d,a[1]=-c},c.toLocalFrame=function(a,b,d,e){c.copy(a,b),c.sub(a,a,d),c.rotate(a,a,-e)},c.toGlobalFrame=function(a,b,d,e){c.copy(a,b),c.rotate(a,a,e),c.add(a,a,d)},c.centroid=function(a,b,d,e){return c.add(a,b,d),c.add(a,a,e),c.scale(a,a,1/3),a},c.create=function(){var a=new d.ARRAY_TYPE(2);return a[0]=0,a[1]=0,a},c.clone=function(a){var b=new d.ARRAY_TYPE(2);return b[0]=a[0],b[1]=a[1],b},c.fromValues=function(a,b){var c=new d.ARRAY_TYPE(2);return c[0]=a,c[1]=b,c},c.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a},c.set=function(a,b,c){return a[0]=b,a[1]=c,a},c.add=function(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a},c.subtract=function(a,b,c){return a[0]=b[0]-c[0],a[1]=b[1]-c[1],a},c.sub=c.subtract,c.multiply=function(a,b,c){return a[0]=b[0]*c[0],a[1]=b[1]*c[1],a},c.mul=c.multiply,c.divide=function(a,b,c){return a[0]=b[0]/c[0],a[1]=b[1]/c[1],a},c.div=c.divide,c.scale=function(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a},c.distance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1];return Math.sqrt(c*c+d*d)},c.dist=c.distance,c.squaredDistance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1];return c*c+d*d},c.sqrDist=c.squaredDistance,c.length=function(a){var b=a[0],c=a[1];return Math.sqrt(b*b+c*c)},c.len=c.length,c.squaredLength=function(a){var b=a[0],c=a[1];return b*b+c*c},c.sqrLen=c.squaredLength,c.negate=function(a,b){return a[0]=-b[0],a[1]=-b[1],a},c.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},c.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]},c.str=function(a){return"vec2("+a[0]+", "+a[1]+")"},c.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}},{"../utils/Utils":50}],32:[function(a,b){function c(a){a=a||{},h.call(this),this.id=++c._idCounter,this.world=null,this.shapes=[],this.shapeOffsets=[],this.shapeAngles=[],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.position=d.fromValues(0,0),a.position&&d.copy(this.position,a.position),this.interpolatedPosition=d.fromValues(0,0),this.interpolatedAngle=0,this.previousPosition=d.fromValues(0,0),this.previousAngle=0,this.velocity=d.fromValues(0,0),a.velocity&&d.copy(this.velocity,a.velocity),this.vlambda=d.fromValues(0,0),this.wlambda=0,this.angle=a.angle||0,this.angularVelocity=a.angularVelocity||0,this.force=d.create(),a.force&&d.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=c.STATIC,this.type="undefined"!=typeof a.type?a.type:a.mass?c.DYNAMIC:c.STATIC,this.boundingRadius=0,this.aabb=new g,this.aabbNeedsUpdate=!0,this.allowSleep=!0,this.wantsToSleep=!1,this.sleepState=c.AWAKE,this.sleepSpeedLimit=.2,this.sleepTimeLimit=1,this.gravityScale=1,this.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 d=a("../math/vec2"),e=a("poly-decomp"),f=a("../shapes/Convex"),g=a("../collision/AABB"),h=a("../events/EventEmitter");b.exports=c,c.prototype=new h,c.prototype.constructor=c,c._idCounter=0,c.prototype.updateSolveMassProperties=function(){this.sleepState===c.SLEEPING||this.type===c.KINEMATIC?(this.invMassSolve=0,this.invInertiaSolve=0):(this.invMassSolve=this.invMass,this.invInertiaSolve=this.invInertia)},c.prototype.setDensity=function(a){var b=this.getArea();this.mass=b*a,this.updateMassProperties()},c.prototype.getArea=function(){for(var a=0,b=0;be&&(e=h+i)}this.boundingRadius=e},c.prototype.addShape=function(a,b,c){c=c||0,b=b?d.fromValues(b[0],b[1]):d.fromValues(0,0),this.shapes.push(a),this.shapeOffsets.push(b),this.shapeAngles.push(c),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0},c.prototype.removeShape=function(a){var b=this.shapes.indexOf(a);return-1!==b?(this.shapes.splice(b,1),this.shapeOffsets.splice(b,1),this.shapeAngles.splice(b,1),this.aabbNeedsUpdate=!0,!0):!1},c.prototype.updateMassProperties=function(){if(this.type===c.STATIC||this.type===c.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,e=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=d.squaredLength(this.shapeOffsets[g]),j=h.computeMomentOfInertia(e);f+=j+e*i}this.inertia=f,this.invInertia=f>0?1/f:0}this.invMass=1/this.mass}};var k=d.create();c.prototype.applyForce=function(a,b){var c=k;d.sub(c,b,this.position),d.add(this.force,this.force,a);var e=d.crossLength(c,a);this.angularForce+=e},c.prototype.toLocalFrame=function(a,b){d.toLocalFrame(a,b,this.position,this.angle)},c.prototype.toWorldFrame=function(a,b){d.toGlobalFrame(a,b,this.position,this.angle)},c.prototype.fromPolygon=function(a,b){b=b||{};for(var c=this.shapes.length;c>=0;--c)this.removeShape(this.shapes[c]);var g=new e.Polygon;if(g.vertices=a,g.makeCCW(),"number"==typeof b.removeCollinearPoints&&g.removeCollinearPoints(b.removeCollinearPoints),"undefined"==typeof b.skipSimpleCheck&&!g.isSimple())return!1;this.concavePath=g.vertices.slice(0);for(var c=0;c=g?(this.idleTime=0,this.sleepState=c.AWAKE):(this.idleTime+=e,this.sleepState=c.SLEEPY),this.idleTime>this.sleepTimeLimit&&(b?this.wantsToSleep=!0:this.sleep())}},c.prototype.getVelocityFromPosition=function(a,b){return a=a||d.create(),d.sub(a,this.position,this.previousPosition),d.scale(a,a,1/b),a},c.prototype.getAngularVelocityFromPosition=function(a){return(this.angle-this.previousAngle)/a},c.prototype.overlaps=function(a){return this.world.overlapKeeper.bodiesAreOverlapping(this,a)};var o=d.create(),p=d.create();c.prototype.integrate=function(a){var b=this.invMass,c=this.force,e=this.position,f=this.velocity;d.copy(this.previousPosition,this.position),this.previousAngle=this.angle,this.fixedRotation||(this.angularVelocity+=this.angularForce*this.invInertia*a),d.scale(o,c,a*b),d.add(f,o,f),this.integrateToTimeOfImpact(a)||(d.scale(p,f,a),d.add(e,e,p),this.fixedRotation||(this.angle+=this.angularVelocity*a)),this.aabbNeedsUpdate=!0};var q=d.create(),r=d.create(),s=d.create(),t=d.create();c.prototype.integrateToTimeOfImpact=function(a){if(this.ccdSpeedThreshold<0||d.squaredLength(this.velocity)=j&&if)&&(f=d),(null===h||h>d)&&(h=d);if(h>f){var j=h;h=f,f=j}e.set(b,h,f)},c.prototype.projectOntoWorldAxis=function(a,b,c,d){var f=h;this.projectOntoLocalAxis(a,d),0!==c?e.rotate(f,a,c):f=a;var g=e.dot(b,f);e.set(d,d[0]+g,d[1]+g)},c.prototype.updateTriangles=function(){this.triangles.length=0;for(var a=[],b=0;bg;f=g,g++){var h=this.vertices[f],i=this.vertices[g],j=Math.abs(e.crossLength(h,i)),k=e.dot(i,i)+e.dot(i,h)+e.dot(h,h);b+=j*k,c+=j}return a/6*(b/c)},c.prototype.updateBoundingRadius=function(){for(var a=this.vertices,b=0,c=0;c!==a.length;c++){var d=e.squaredLength(a[c]);d>b&&(b=d)}this.boundingRadius=Math.sqrt(b)},c.triangleArea=function(a,b,c){return.5*((b[0]-a[0])*(c[1]-a[1])-(c[0]-a[0])*(b[1]-a[1]))},c.prototype.updateArea=function(){this.updateTriangles(),this.area=0;for(var a=this.triangles,b=this.vertices,d=0;d!==a.length;d++){var e=a[d],f=b[e[0]],g=b[e[1]],h=b[e[2]],i=c.triangleArea(f,g,h);this.area+=i}},c.prototype.computeAABB=function(a,b,c){a.setFromPoints(this.vertices,b,c,0)}},{"../math/polyk":30,"../math/vec2":31,"./Shape":45,"poly-decomp":5}],40:[function(a,b){function c(a,b){if(b=e.defaults(b,{maxValue:null,minValue:null,elementWidth:.1}),null===b.minValue||null===b.maxValue){b.maxValue=a[0],b.minValue=a[0];for(var c=0;c!==a.length;c++){var f=a[c];f>b.maxValue&&(b.maxValue=f),f=w*w)break}for(c.updateMultipliers(k,q,1/a),x=0;x!==l;x++){var z=k[x];if(z instanceof h){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(f=0;f!==i;f++){for(w=0,x=0;x!==l;x++){v=k[x];var y=c.iterateEquation(x,v,v.epsilon,u,t,q,p,a,f);w+=Math.abs(y)}if(this.usedIterations++,m>=w*w)break}for(r=0;r!==o;r++)n[r].addConstraintVelocity();c.updateMultipliers(k,q,1/a)}},c.updateMultipliers=function(a,b,c){for(var d=a.length;d--;)a[d].multiplier=b[d]*c},c.iterateEquation=function(a,b,c,d,e,f,g,h){var i=d[a],j=e[a],k=f[a],l=b.computeGWlambda(),m=b.maxForce,n=b.minForce;g&&(i=0);var o=j*(i-l-c*k),p=k+o;return n*h>p?o=n*h-k:p>m*h&&(o=m*h-k),f[a]+=o,b.addToWlambda(o),o}},{"../equations/FrictionEquation":24,"../math/vec2":31,"../utils/Utils":50,"./Solver":47}],47:[function(a,b){function c(a,b){a=a||{},d.call(this),this.type=b,this.equations=[],this.equationSortFunction=a.equationSortFunction||!1}var d=(a("../utils/Utils"),a("../events/EventEmitter"));b.exports=c,c.prototype=new d,c.prototype.constructor=c,c.prototype.solve=function(){throw new Error("Solver.solve should be implemented by subclasses!")};var e={bodies:[]};c.prototype.solveIsland=function(a,b){this.removeAllEquations(),b.equations.length&&(this.addEquations(b.equations),e.bodies.length=0,b.getBodies(e.bodies),e.bodies.length&&this.solve(a,e))},c.prototype.sortEquations=function(){this.equationSortFunction&&this.equations.sort(this.equationSortFunction)},c.prototype.addEquation=function(a){a.enabled&&this.equations.push(a)},c.prototype.addEquations=function(a){for(var b=0,c=a.length;b!==c;b++){var d=a[b];d.enabled&&this.equations.push(d)}},c.prototype.removeEquation=function(a){var b=this.equations.indexOf(a);-1!==b&&this.equations.splice(b,1)},c.prototype.removeAllEquations=function(){this.equations.length=0},c.GS=1,c.ISLAND=2},{"../events/EventEmitter":27,"../utils/Utils":50}],48:[function(a,b){function c(){this.overlappingShapesLastState=new e,this.overlappingShapesCurrentState=new e,this.recordPool=[],this.tmpDict=new e,this.tmpArray1=[]}function d(a,b,c,d){this.shapeA=b,this.shapeB=d,this.bodyA=a,this.bodyB=c}{var e=a("./TupleDictionary");a("./Utils")}b.exports=c,c.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),f=b.getByKey(d);e&&!f&&this.recordPool.push(e)}a.reset(),a.copy(b),b.reset()},c.prototype.setOverlapping=function(a,b,c,e){var f=(this.overlappingShapesLastState,this.overlappingShapesCurrentState);if(!f.get(b.id,e.id)){var g;this.recordPool.length?(g=this.recordPool.pop(),g.set(a,b,c,e)):g=new d(a,b,c,e),f.set(b.id,e.id,g)}},c.prototype.getNewOverlaps=function(a){return this.getDiff(this.overlappingShapesLastState,this.overlappingShapesCurrentState,a)},c.prototype.getEndOverlaps=function(a){return this.getDiff(this.overlappingShapesCurrentState,this.overlappingShapesLastState,a)},c.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},c.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},c.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)},c.prototype.getNewBodyOverlaps=function(a){this.tmpArray1.length=0;var b=this.getNewOverlaps(this.tmpArray1);return this.getBodyDiff(b,a)},c.prototype.getEndBodyOverlaps=function(a){this.tmpArray1.length=0;var b=this.getEndOverlaps(this.tmpArray1);return this.getBodyDiff(b,a)},c.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},d.prototype.set=function(a,b,c,e){d.call(this,a,b,c,e)}},{"./TupleDictionary":49,"./Utils":50}],49:[function(a,b){function c(){this.data={},this.keys=[]}var d=a("./Utils");b.exports=c,c.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)},c.prototype.getByKey=function(a){return a=0|a,this.data[a]},c.prototype.get=function(a,b){return this.data[this.getKey(a,b)]},c.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},c.prototype.reset=function(){for(var a=this.data,b=this.keys,c=b.length;c--;)delete a[b[c]];b.length=0},c.prototype.copy=function(a){this.reset(),d.appendArray(this.keys,a.keys);for(var b=a.keys.length;b--;){var c=a.keys[b];this.data[c]=a.data[c]}}},{"./Utils":50}],50:[function(a,b){function c(){}b.exports=c,c.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])},c.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},c.ARRAY_TYPE=window.Float32Array||Array,c.extend=function(a,b){for(var c in b)a[c]=b[c]},c.defaults=function(a,b){a=a||{};for(var c in b)c in a||(a[c]=b[c]);return a}},{}],51:[function(a,b){function c(){this.equations=[],this.bodies=[]}var d=a("../objects/Body");b.exports=c,c.prototype.reset=function(){this.equations.length=this.bodies.length=0};var e=[];c.prototype.getBodies=function(a){var b=a||[],c=this.equations;e.length=0;for(var d=0;d!==c.length;d++){var f=c[d];-1===e.indexOf(f.bodyA.id)&&(b.push(f.bodyA),e.push(f.bodyA.id)),-1===e.indexOf(f.bodyB.id)&&(b.push(f.bodyB),e.push(f.bodyB.id))}return b},c.prototype.wantsToSleep=function(){for(var a=0;a1e3*a));g++);this.time+=b;for(var h=this.time%a,i=h/a,j=0;j!==this.bodies.length;j++){var k=this.bodies[j];k.type!==m.STATIC&&k.sleepState!==m.SLEEPING?(f.sub(y,k.position,k.previousPosition),f.scale(y,y,i),f.add(k.interpolatedPosition,k.position,y),k.interpolatedAngle=k.angle+(k.angle-k.previousAngle)*i):(f.copy(k.interpolatedPosition,k.position),k.interpolatedAngle=k.angle)}}};var z=[];c.prototype.internalStep=function(a){this.stepping=!0;var b,d,e=this,g=this.doProfiling,h=this.springs.length,i=this.springs,j=this.bodies,k=this.gravity,l=this.solver,n=this.bodies.length,o=this.broadphase,p=this.narrowphase,q=this.constraints,s=v,t=(f.scale,f.add),u=(f.rotate,this.islandManager);if(this.overlapKeeper.tick(),this.lastTimeStep=a,g&&(b=performance.now()),this.useWorldGravityAsFrictionGravity){var w=f.length(this.gravity);0===w&&this.useFrictionGravityOnZeroGravity||(this.frictionGravity=w)}if(this.applyGravity)for(var x=0;x!==n;x++){var y=j[x],A=y.force;y.type===m.DYNAMIC&&y.sleepState!==m.SLEEPING&&(f.scale(s,k,y.mass*y.gravityScale),t(A,A,s))}if(this.applySpringForces)for(var x=0;x!==h;x++){var B=i[x];B.applyForce()}if(this.applyDamping)for(var x=0;x!==n;x++){var y=j[x];y.type===m.DYNAMIC&&y.applyDamping(a)}for(var C=o.getCollisionPairs(this),D=this.disabledBodyCollisionPairs,x=D.length-2;x>=0;x-=2)for(var E=C.length-2;E>=0;E-=2)(D[x]===C[E]&&D[x+1]===C[E+1]||D[x+1]===C[E]&&D[x]===C[E+1])&&C.splice(E,2);var F=q.length;for(x=0;x!==F;x++){var G=q[x];if(!G.collideConnected)for(var E=C.length-2;E>=0;E-=2)(G.bodyA===C[E]&&G.bodyB===C[E+1]||G.bodyB===C[E]&&G.bodyA===C[E+1])&&C.splice(E,2) +}this.postBroadphaseEvent.pairs=C,this.emit(this.postBroadphaseEvent),p.reset(this);for(var x=0,H=C.length;x!==H;x+=2)for(var I=C[x],J=C[x+1],K=0,L=I.shapes.length;K!==L;K++)for(var M=I.shapes[K],N=I.shapeOffsets[K],O=I.shapeAngles[K],P=0,Q=J.shapes.length;P!==Q;P++){var R=J.shapes[P],S=J.shapeOffsets[P],T=J.shapeAngles[P],U=this.defaultContactMaterial;if(M.material&&R.material){var V=this.getContactMaterial(M.material,R.material);V&&(U=V)}this.runNarrowphase(p,I,M,N,O,J,R,S,T,U,this.frictionGravity)}for(var x=0;x!==n;x++){var W=j[x];W._wakeUpAfterNarrowphase&&(W.wakeUp(),W._wakeUpAfterNarrowphase=!1)}if(this.has("endContact")){this.overlapKeeper.getEndOverlaps(z);for(var X=this.endContactEvent,P=z.length;P--;){var Y=z[P];X.shapeA=Y.shapeA,X.shapeB=Y.shapeB,X.bodyA=Y.bodyA,X.bodyB=Y.bodyB,this.emit(X)}}var Z=this.preSolveEvent;Z.contactEquations=p.contactEquations,Z.frictionEquations=p.frictionEquations,this.emit(Z);var F=q.length;for(x=0;x!==F;x++)q[x].update();if(p.contactEquations.length||p.frictionEquations.length||q.length)if(this.islandSplit){for(u.equations.length=0,r.appendArray(u.equations,p.contactEquations),r.appendArray(u.equations,p.frictionEquations),x=0;x!==F;x++)r.appendArray(u.equations,q[x].equations);u.split(this);for(var x=0;x!==u.islands.length;x++){var $=u.islands[x];$.equations.length&&l.solveIsland(a,$)}}else{for(l.addEquations(p.contactEquations),l.addEquations(p.frictionEquations),x=0;x!==F;x++)l.addEquations(q[x].equations);this.solveConstraints&&l.solve(a,this),l.removeAllEquations()}for(var x=0;x!==n;x++){var W=j[x];W.sleepState!==m.SLEEPING&&W.type!==m.STATIC&&W.integrate(a)}for(var x=0;x!==n;x++)j[x].setZeroForce();if(g&&(d=performance.now(),e.lastStepTime=d-b),this.emitImpactEvent&&this.has("impact"))for(var _=this.impactEvent,x=0;x!==p.contactEquations.length;x++){var ab=p.contactEquations[x];ab.firstImpact&&(_.bodyA=ab.bodyA,_.bodyB=ab.bodyB,_.shapeA=ab.shapeA,_.shapeB=ab.shapeB,_.contactEquation=ab,this.emit(_))}if(this.sleepMode===c.BODY_SLEEPING)for(x=0;x!==n;x++)j[x].sleepTick(this.time,!1,a);else if(this.sleepMode===c.ISLAND_SLEEPING&&this.islandSplit){for(x=0;x!==n;x++)j[x].sleepTick(this.time,!0,a);for(var x=0;x0,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=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;C1)for(var C=a.frictionEquations.length-u;C=0;b--)this.removeConstraint(a[b]);for(var d=this.bodies,b=d.length-1;b>=0;b--)this.removeBody(d[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]);c.apply(this)},c.prototype.clone=function(){var a=new c;return a.fromJSON(this.toJSON()),a};var A=f.create(),B=f.fromValues(0,0),C=f.fromValues(0,0);c.prototype.hitTest=function(a,b,c){c=c||0;var d=new m({position:a}),e=new k,l=a,n=0,o=A,p=B,q=C;d.addShape(e);for(var r=this.narrowphase,s=[],t=0,u=b.length;t!==u;t++)for(var v=b[t],w=0,x=v.shapes.length;w!==x;w++){var y=v.shapes[w],z=v.shapeOffsets[w]||p,D=v.shapeAngles[w]||0;f.rotate(o,z,v.angle),f.add(o,o,v.position);var E=D+v.angle;(y instanceof g&&r.circleParticle(v,y,o,E,d,e,l,n,!0)||y instanceof h&&r.particleConvex(d,e,l,n,v,y,o,E,!0)||y instanceof i&&r.particlePlane(d,e,l,n,v,y,o,E,!0)||y instanceof j&&r.particleCapsule(d,e,l,n,v,y,o,E,!0)||y instanceof k&&f.squaredLength(f.sub(q,o,a))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,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){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.shapeA,a.shapeB,a.contactEquations),a.bodyB.parent&&a.bodyB.parent.onBeginContact.dispatch(a.bodyA.parent,a.shapeB,a.shapeA,a.contactEquations)},endContactHandler:function(a){this.onEndContact.dispatch(a.bodyA,a.bodyB,a.shapeA,a.shapeB),a.bodyA.parent&&a.bodyA.parent.onEndContact.dispatch(a.bodyB.parent,a.shapeA,a.shapeB),a.bodyB.parent&&a.bodyB.parent.onEndContact.dispatch(a.bodyA.parent,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){"undefined"==typeof b&&(b=!0),"undefined"==typeof c&&(c=!0),"undefined"==typeof d&&(d=!0),"undefined"==typeof 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;"undefined"==typeof 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){"undefined"==typeof e&&(e=this._boundsLeft),"undefined"==typeof f&&(f=this._boundsRight),"undefined"==typeof g&&(g=this._boundsTop),"undefined"==typeof h&&(h=this._boundsBottom),"undefined"==typeof 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.world.step(this.useElapsedTime?this.game.time.physicsElapsed: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 this.world.addSpring(a instanceof c.Physics.P2.Spring||a instanceof c.Physics.P2.RotationalSpring?a.data:a),this.onSpringAdded.dispatch(a),a},removeSpring:function(a){return this.world.removeSpring(a instanceof c.Physics.P2.Spring||a instanceof c.Physics.P2.RotationalSpring?a.data: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){"undefined"==typeof a&&(a=this.createMaterial()),"undefined"==typeof 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].parent);return a},hitTest:function(a,b,d,e){"undefined"==typeof b&&(b=this.world.bodies),"undefined"==typeof d&&(d=5),"undefined"==typeof 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;de;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),"undefined"==typeof c&&(c=!0),"undefined"==typeof 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,"undefined"==typeof 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._groupCallbacksContext[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=0;c--)this.data.shapes[c].collisionMask=b;else a.collisionMask=b},setCollisionGroup:function(a,b){var c=this.getCollisionMask();if("undefined"==typeof 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("undefined"==typeof a&&(a=!0),"undefined"==typeof b&&(b=!0),"undefined"==typeof 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)},collides:function(a,b,c,d){if(Array.isArray(a))for(var e=0;e=0;e--)this.data.shapes[e].collisionMask=f;else d.collisionMask=f},adjustCenterOfMass:function(){this.data.adjustCenterOfMass(),this.shapeChanged()},applyDamping:function(a){this.data.applyDamping(a)},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){"undefined"==typeof c&&(c=!1),"undefined"==typeof 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;ad;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=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=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){"undefined"==typeof i&&(i=1),"undefined"==typeof 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){"undefined"==typeof g&&(g=1),"undefined"==typeof 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){"undefined"==typeof d&&(d=1),"undefined"==typeof 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("undefined"==typeof f&&(f=1),"undefined"==typeof 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("undefined"==typeof e&&(e=1),"undefined"==typeof c&&(c=0),a.lineStyle(e,c,1),"number"==typeof d&&a.beginFill(d),h=null,i=null,g=0;g2&&"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;"undefined"==typeof f&&(f=1),"undefined"==typeof 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){"undefined"==typeof i&&(i=1),"undefined"==typeof 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,"undefined"==typeof d&&(d=1),"undefined"==typeof e&&(e=100),"undefined"==typeof 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,"undefined"==typeof d&&(d=null),"undefined"==typeof e&&(e=100),"undefined"==typeof 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){"undefined"==typeof d&&(d=100),"undefined"==typeof e&&(e=[0,0]),"undefined"==typeof f&&(f=[0,0]),"undefined"==typeof 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){"undefined"==typeof d&&(d=0),"undefined"==typeof 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){"undefined"==typeof d&&(d=[0,0]),"undefined"==typeof e&&(e=0),"undefined"==typeof 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){"undefined"==typeof d&&(d=!0),"undefined"==typeof e&&(e=[0,0]),"undefined"==typeof f&&(f=[0,0]),"undefined"==typeof g&&(g=[0,0]),"undefined"==typeof 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){"undefined"==typeof f&&(f=Number.MAX_VALUE),"undefined"==typeof 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.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!(athis.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.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"undefined"==typeof 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("undefined"==typeof d&&(d=this.tileWidth),"undefined"==typeof e&&(e=this.tileHeight),"undefined"==typeof f&&(f=0),"undefined"==typeof g&&(g=0),"undefined"==typeof h&&(h=0),0===d&&(d=32),0===e&&(e=32),"undefined"==typeof b){if("string"!=typeof a)return null;if(b=a,!this.game.cache.checkImageKey(b))return console.warn('Phaser.Tilemap.addTilesetImage: Invalid image key given: "'+b+'"'),null}if("string"==typeof a&&(a=this.getTilesetIndex(a),null===a&&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[a])return this.tilesets[a].setImage(this.game.cache.getImage(b)),this.tilesets[a];var i=new c.Tileset(b,h,d,e,f,g,{});i.setImage(this.game.cache.getImage(b)),this.tilesets.push(i);for(var j=this.tilesets.length-1,k=f,l=f,m=0,n=0,o=0,p=h;pl;l++)if(this.objects[a][l].gid===b){k=new i(this.game,this.objects[a][l].x,this.objects[a][l].y,d,e),k.name=this.objects[a][l].name,k.visible=this.objects[a][l].visible,k.autoCull=g,k.exists=f,this.objects[a][l].rotation&&(k.angle=this.objects[a][l].rotation),j&&(k.y-=k.height),h.add(k);for(var n in this.objects[a][l].properties)h.set(k,n,this.objects[a][l].properties[n],!1,!1,0,!0)}},createFromTiles:function(a,b,d,e,f,g){"number"==typeof a&&(a=[a]),"undefined"==typeof b||null===b?b=[]:"number"==typeof b&&(b=[b]),e=this.getLayer(e),"undefined"==typeof f&&(f=this.game.world),"undefined"==typeof 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;l1)for(l=0;lthis.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("undefined"==typeof 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;ce;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;hb)){for(var f=a;b>=f;f++)this.setCollisionByIndex(f,c,d,!1);e&&this.calculateFaces(d)}},setCollisionByExclusion:function(a,b,c,d){"undefined"==typeof b&&(b=!0),"undefined"==typeof 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("undefined"==typeof b&&(b=!0),"undefined"==typeof c&&(c=this.currentLayer),"undefined"==typeof 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;ff;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 c0?this.layers[a].data[c][b-1]:null},getTileRight:function(a,b,c){return b-1},removeTile:function(a,b,d){if(d=this.getLayer(d),a>=0&&a=0&&b=0&&b=0&&d-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){"undefined"==typeof b&&(b=0),"undefined"==typeof 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=0&&a=0&&ba&&(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("undefined"==typeof a&&(a=0),"undefined"==typeof 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;g1?this.debugMap[this.layers[this.currentLayer].data[c][d]]?"background: "+this.debugMap[this.layers[this.currentLayer].data[c][d]]:"background: #ffffff":"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,PIXI.Sprite.call(this,PIXI.TextureCache.__default),c.Component.Core.init.call(this,a,0,0,null,null),this.map=b,this.index=d,this.layer=b.layers[d],this.canvas=c.Canvas.create(e,f),this.context=this.canvas.getContext("2d"),this.baseTexture=new PIXI.BaseTexture(this.canvas),this.texture=new PIXI.Texture(this.baseTexture),this.textureFrame=new c.Frame(0,0,0,e,f,"tilemapLayer",a.rnd.uuid()),this.type=c.TILEMAPLAYER,this.physicsType=c.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: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(PIXI.Sprite.prototype),c.TilemapLayer.prototype.constructor=c.TilemapLayer;var l=["Bounds","Destroy","FixedToCamera","Reset","Smoothed"];c.Component.Core.install.call(c.TilemapLayer.prototype,l),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 c.Component.Core.preUpdate.call(this),!0},c.TilemapLayer.prototype.postUpdate=function(){c.Component.Core.prototype.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.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),"undefined"==typeof c&&(c=!1),"undefined"==typeof 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;hl;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()},Object.defineProperty(c.TilemapLayer.prototype,"tileColor",{get:function(){return this.debugSettings.missingImageFill},set:function(a){this.debugSettings.missingImageFill=a}}),Object.defineProperty(c.TilemapLayer.prototype,"wrap",{get:function(){return this._wrap},set:function(a){this._wrap=a,this.dirty=!0}}),c.TilemapLayer.prototype.resolveTileset=function(a){var b=this._mc.tilesets;if(2e3>a)for(;b.lengthb&&(g=-b,i=0),0>c&&(h=-c,j=0);var k=this.renderSettings.copyCanvas;if(k){(k.width=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.context.save(),(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 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)=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,"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={parse:function(a,b,d,e,f,g){if("undefined"==typeof d&&(d=32),"undefined"==typeof e&&(e=32),"undefined"==typeof f&&(f=10),"undefined"==typeof g&&(g=10),"undefined"==typeof 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;ko;o++){if(h=0,i=!1,k=a.layers[f].data[o],k>536870912)switch(j=0,k>2147483648&&(k-=2147483648,j+=4),k>1073741824&&(k-=1073741824,j+=2),k>536870912&&(k-=536870912,j+=1),j){case 5:h=Math.PI/2;break;case 6:h=Math.PI;break;case 3:h=3*Math.PI/2;break;case 4:h=0,i=!0;break;case 7:h=Math.PI/2,i=!0;break;case 2:h=Math.PI,i=!0;break;case 1:h=3*Math.PI/2,i=!0}k>0?(m.push(new c.Tile(g,k,l,n.length,a.tilewidth,a.tileheight)),m[m.length-1].rotation=h,m[m.length-1].flipped=i):m.push(new c.Tile(g,-1,l,n.length,a.tilewidth,a.tileheight)),l++,l===a.layers[f].width&&(n.push(m),l=0,m=[])}g.data=n,e.push(g)}d.layers=e;for(var q=[],f=0;fx;x++)if(a.layers[f].objects[x].gid){var y={gid:a.layers[f].objects[x].gid,name:a.layers[f].objects[x].name,type:a.layers[f].objects[x].hasOwnProperty("type")?a.layers[f].objects[x].type:"",x:a.layers[f].objects[x].x,y:a.layers[f].objects[x].y,visible:a.layers[f].objects[x].visible,properties:a.layers[f].objects[x].properties};a.layers[f].objects[x].rotation&&(y.rotation=a.layers[f].objects[x].rotation),v[a.layers[f].name].push(y)}else if(a.layers[f].objects[x].polyline){var y={name:a.layers[f].objects[x].name,type:a.layers[f].objects[x].type,x:a.layers[f].objects[x].x,y:a.layers[f].objects[x].y,width:a.layers[f].objects[x].width,height:a.layers[f].objects[x].height,visible:a.layers[f].objects[x].visible,properties:a.layers[f].objects[x].properties};a.layers[f].objects[x].rotation&&(y.rotation=a.layers[f].objects[x].rotation),y.polyline=[];for(var z=0;z=c)&&(c=32),("undefined"==typeof d||0>=d)&&(d=32),"undefined"==typeof e&&(e=0),"undefined"==typeof 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.firstgid&&a=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._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){"undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=this.maxParticles),"undefined"==typeof d&&(d=!1),"undefined"==typeof 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){("undefined"==typeof c||0===c)&&(c=1),"undefined"==typeof d&&(d=-1),"undefined"==typeof 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("undefined"==typeof a&&(a=!0),"undefined"==typeof b&&(b=0),("undefined"==typeof c||null===c)&&(c=250),"undefined"==typeof d&&(d=0),"undefined"==typeof 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(){var a=this.getFirstExists(!1);return null===a?!1:(this.width>1||this.height>1?a.reset(this.game.rnd.integerInRange(this.left,this.right),this.game.rnd.integerInRange(this.top,this.bottom)):a.reset(this.emitX,this.emitY),a.angle=0,a.lifespan=this.lifespan,this.particleBringToTop?this.bringToTop(a):this.particleSendToBack&&this.sendToBack(a),this.autoScale?a.setScaleData(this.scaleData):1!==this.minParticleScale||1!==this.maxParticleScale?a.scale.set(this.game.rnd.realInRange(this.minParticleScale,this.maxParticleScale)):(this._minParticleScale.x!==this._maxParticleScale.x||this._minParticleScale.y!==this._maxParticleScale.y)&&a.scale.set(this.game.rnd.realInRange(this._minParticleScale.x,this._maxParticleScale.x),this.game.rnd.realInRange(this._minParticleScale.y,this._maxParticleScale.y)),a.frame=Array.isArray("object"===this._frames)?this.game.rnd.pick(this._frames):this._frames,this.autoAlpha?a.setAlphaData(this.alphaData):a.alpha=this.game.rnd.realInRange(this.minParticleAlpha,this.maxParticleAlpha),a.blendMode=this.blendMode,a.body.updateBounds(),a.body.bounce.setTo(this.bounce.x,this.bounce.y),a.body.velocity.x=this.game.rnd.between(this.minParticleSpeed.x,this.maxParticleSpeed.x),a.body.velocity.y=this.game.rnd.between(this.minParticleSpeed.y,this.maxParticleSpeed.y),a.body.angularVelocity=this.game.rnd.between(this.minRotation,this.maxRotation),a.body.gravity.y=this.gravity,a.body.drag.x=this.particleDrag.x,a.body.drag.y=this.particleDrag.y,a.body.angularDrag=this.angularDrag,a.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("undefined"==typeof a&&(a=1),"undefined"==typeof b&&(b=1),"undefined"==typeof d&&(d=0),"undefined"==typeof e&&(e=c.Easing.Linear.None),"undefined"==typeof 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("undefined"==typeof a&&(a=1),"undefined"==typeof b&&(b=1),"undefined"==typeof d&&(d=1),"undefined"==typeof e&&(e=1),"undefined"==typeof f&&(f=0),"undefined"==typeof g&&(g=c.Easing.Linear.None),"undefined"==typeof 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)}}),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),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),"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}.call(this); +//# sourceMappingURL=phaser.map \ No newline at end of file diff --git a/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1104_MIT_Mystery_Hunt_2017_House_Arrest/HouseArrest8.mp3 b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1104_MIT_Mystery_Hunt_2017_House_Arrest/HouseArrest8.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..c41b04c409dfef95e232205965461884c199519d --- /dev/null +++ b/benchmark/MIT_Mystery_Hunt/puzzles/2017/mit2017r1104_MIT_Mystery_Hunt_2017_House_Arrest/HouseArrest8.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0a7dff6b33150b6911109f5dc13d398465b1e9b57752a7046da8c9ea3c9a9ca2 +size 596285