The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
Build.PL 15
Changes 096
MANIFEST 729
META.json 6770
META.yml 6669
Makefile.PL 17
lib/Dancer2/CLI/Command/gen.pm 22
lib/Dancer2/CLI/Command/version.pm 22
lib/Dancer2/CLI.pm 22
lib/Dancer2/Config.pod 216
lib/Dancer2/Cookbook.pod 616
lib/Dancer2/Core/App.pm 180493
lib/Dancer2/Core/Context.pm 3470
lib/Dancer2/Core/Cookie.pm 22
lib/Dancer2/Core/DSL.pm 2558
lib/Dancer2/Core/Dispatcher.pm 97134
lib/Dancer2/Core/Error.pm 4678
lib/Dancer2/Core/Factory.pm 22
lib/Dancer2/Core/HTTP.pm 33
lib/Dancer2/Core/Hook.pm 22
lib/Dancer2/Core/MIME.pm 22
lib/Dancer2/Core/Request/Upload.pm 22
lib/Dancer2/Core/Request.pm 7435
lib/Dancer2/Core/Response.pm 220
lib/Dancer2/Core/Role/ConfigReader.pm 3233
lib/Dancer2/Core/Role/DSL.pm 44
lib/Dancer2/Core/Role/Engine.pm 128
lib/Dancer2/Core/Role/Handler.pm 23
lib/Dancer2/Core/Role/HasLocation.pm 098
lib/Dancer2/Core/Role/Headers.pm 22
lib/Dancer2/Core/Role/Hookable.pm 33
lib/Dancer2/Core/Role/Logger.pm 22
lib/Dancer2/Core/Role/Serializer.pm 22
lib/Dancer2/Core/Role/SessionFactory/File.pm 22
lib/Dancer2/Core/Role/SessionFactory.pm 25
lib/Dancer2/Core/Role/StandardResponses.pm 1716
lib/Dancer2/Core/Role/Template.pm 1925
lib/Dancer2/Core/Route.pm 22
lib/Dancer2/Core/Runner.pm 9474
lib/Dancer2/Core/Session.pm 33
lib/Dancer2/Core/Time.pm 22
lib/Dancer2/Core/Types.pm 22
lib/Dancer2/Core.pm 22
lib/Dancer2/FileUtils.pm 22
lib/Dancer2/Handler/AutoPage.pm 1011
lib/Dancer2/Handler/File.pm 2730
lib/Dancer2/Logger/Capture/Trap.pm 22
lib/Dancer2/Logger/Capture.pm 22
lib/Dancer2/Logger/Console.pm 22
lib/Dancer2/Logger/Diag.pm 22
lib/Dancer2/Logger/File.pm 44
lib/Dancer2/Logger/Note.pm 22
lib/Dancer2/Logger/Null.pm 22
lib/Dancer2/Manual.pod 682
lib/Dancer2/Plugin/Ajax.pm 22
lib/Dancer2/Plugin.pm 1110
lib/Dancer2/Plugins.pod 22
lib/Dancer2/Serializer/Dumper.pm 22
lib/Dancer2/Serializer/JSON.pm 85
lib/Dancer2/Serializer/Mutable.pm 1212
lib/Dancer2/Serializer/YAML.pm 22
lib/Dancer2/Session/Simple.pm 22
lib/Dancer2/Session/YAML.pm 22
lib/Dancer2/Template/Implementation/ForkedTiny.pm 33
lib/Dancer2/Template/Simple.pm 22
lib/Dancer2/Template/TemplateToolkit.pm 22
lib/Dancer2/Template/Tiny.pm 22
lib/Dancer2/Test.pm 33
lib/Dancer2/Tutorial.pod 55
lib/Dancer2.pm 1935
script/dancer2 11
share/skel/environments/development.yml 02
share/skel/public/javascripts/jquery.js 64
share/skel/t/001_base.t 11
share/skel/t/002_index_route.t 512
share/skel/views/layouts/main.tt 33
t/00-compile.t 11
t/00-report-prereqs.t 03
t/ajax_plugin.t 11
t/any.t 21
t/app.t 212
t/auto_page.t 11
t/caller.t 025
t/config.t 1500
t/config_app1.t 160
t/config_app2.t 170
t/config_app3.t 160
t/config_multiapp.t 023
t/config_reader.t 0149
t/context-in-before.t 057
t/context.t 360
t/context_trigger.t 550
t/custom_dsl.t 11
t/deserialize.t 89
t/dispatcher.t 1718
t/dsl/extend.t 055
t/dsl/extend_config/config.yml 01
t/dsl/halt.t 65
t/dsl/pass.t 11
t/dsl.t 11
t/error.t 868
t/error_template.t 11
t/forward.t 11
t/forward_before_hook.t 54
t/handler_file.t 427
t/hooks.t 33
t/http_methods.t 21
t/log_die_before_hook.t 037
t/log_levels.t 086
t/logger/file.t 10
t/lwp-protocol-psgi.t 21
t/memory_cycles.t 027
t/multi_apps.t 048
t/multi_apps_forward.t 081
t/multiapp_template_hooks.t 0215
t/named_apps.t 041
t/plugin_import.t 22
t/plugin_multiple_apps.t 11
t/plugin_syntax.t 44
t/psgi_app.t 092
t/redirect.t 44
t/request.t 311
t/runner.t 53
t/serializer.t 21
t/serializer_json.t 1148
t/serializer_mutable.t 21
t/session_config.t 22
t/session_engines.t 11
t/session_forward.t 33156
t/session_hooks.t 11
t/session_lifecycle.t 22
t/sessions/U7g83AAAD40GMDKZZbYNAi9jRU6lJlmd.yml 02
t/sessions/U7hR3AAAME4JbYM_IBVWT5sQq-OlHt5v.yml 02
t/sessions/U8-0IAAAIo7quaDrMsrwW_vaalYuLN5G.yml 02
t/sessions/U8-x8wAAH8c5NFaIXyuTBQ1qaMYVXtms.yml 02
t/sessions/U8-yGQAAIIeUD3g5pCfu12mGyb9jdFpA.yml 02
t/sessions/U8EjygAAC9a8v1m7XkjynBlJ8JKWkXsr.yml 02
t/sessions/U8FTogAARfIT33ImUZSd5ffmiDvPjQ1k.yml 02
t/sessions/U8q6bgAAY5J_az3iLVXSgmzZBpzsGZdn.yml 02
t/sessions/U8qxAQAAVNrEmBCFpYG_oFJEBuv5Oo1T.yml 02
t/sessions/U8sClAAAQzB77au98B9OAeDZsoejrJ6L.yml 02
t/sessions/U9QiNAAATPWPqf4CsvJrPEfxpRGNdfDK.yml 02
t/sessions/U9UMBAAAWAmK4rV4Zld987OFzngYrzpQ.yml 02
t/sessions/U9URAgAAYlA49NVHsXQZcLgJzSdDKNDU.yml 02
t/splat.t 11
t/template.t 425
t/template_default_tokens.t 22
t/template_name.t 11
t/uri_for.t 11
t/vars.t 32
t/views/beforetemplate.tt 01
151 files changed (This is a version diff) 17433081
@@ -20,7 +20,7 @@ my %module_build_args = (
     "Dancer Core Developers"
   ],
   "dist_name" => "Dancer2",
-  "dist_version" => "0.141000",
+  "dist_version" => "0.150000",
   "license" => "perl",
   "module_name" => "Dancer2",
   "recommends" => {
@@ -78,7 +78,9 @@ my %module_build_args = (
     "Pod::Simple::SimpleTree" => 0,
     "Return::MultiLevel" => 0,
     "Role::Tiny" => "1.003000",
+    "Safe::Isa" => 0,
     "Scalar::Util" => 0,
+    "Sub::Quote" => 0,
     "Template" => 0,
     "Template::Tiny" => 0,
     "Test::Builder" => 0,
@@ -112,6 +114,7 @@ my %module_build_args = (
     "LWP::Protocol::PSGI" => "0.06",
     "Plack::Test" => 0,
     "Test::Fatal" => 0,
+    "Test::Memory::Cycle" => "1.04",
     "Test::MockTime" => 0,
     "Test::More" => "0.92",
     "Test::Script" => 0,
@@ -140,6 +143,7 @@ my %fallback_build_requires = (
   "Module::Build" => "0.3601",
   "Plack::Test" => 0,
   "Test::Fatal" => 0,
+  "Test::Memory::Cycle" => "1.04",
   "Test::MockTime" => 0,
   "Test::More" => "0.92",
   "Test::Script" => 0,
@@ -1,3 +1,99 @@
+0.150000  2014-08-17 01:35:16CEST+0200 Europe/Amsterdam
+
+    [ DOCUMENTATION ]
+    * GH #657: Update multi-app example in cookbook to include route
+      merging. (Bas Bloemsaat)
+    * GH #643: Improve session factory docs by mentioning Dancer2::Config.
+      (Andy Jack)
+
+    [ BUG FIXES ]
+    * Postponed hooks are no longer sent to all Apps.
+      (Sawyer X, Mickey Nasriachi)
+    * 404 File Not Found Application reworked to stay up to date with
+      postponed hooks merging in multiple apps. (Russell Jenkins)
+    * GH #610, #662: Removed two circular references memory leaks!
+      (Russell Jenkins)
+    * GH #633: Log an error when a hook dies. (DavsX)
+
+    [ ENHANCEMENT ]
+    * Allow settings apps in the psgi_app() call by name or regex.
+      (Sawyer X)
+    * GH #651: silly typo in clearer method name (DavsX).
+
+0.149000_02 2014-08-10 13:50:39CEST+0200 Europe/Amsterdam
+
+    [ ENHANCEMENT ]
+    * GH #641: Adding a shim layer to prevent available hooks (and
+      thus plugins) from breaking.
+    * Each App can now define its own configuration. The Runner's
+      application-specific configure has been untangled.
+      (Russell @veryrusty Jenkins, Sawyer X, Mickey Nasriachi)
+    * Multiple Dancer App support. You can now create a App-specific
+      PSGI application using MyApp->psgi_app.
+      (Russell @veryrusty Jenkins, Sawyer X, Mickey Nasriachi)
+    * Add routes and hooks to an existing app on import.
+      (Russell @veryrusty Jenkins, Stevan Humphrey, Stefan racke
+      Hornburg, Jean Stebens, Chunzi, Sawyer X, Mickey Nasriachi)
+    * Allow DSL class to be specified in configuration file.
+      (Stevan Humphrey)
+    * forward() now returns a new request which is then just runs
+      the dispatching loop again. (Sawyer X, Mickey Nasriachi)
+
+    [ BUG FIXES ]
+    * GH #336: Set log level correctly.
+      (Andrew Solomon, Pedro Bruno)
+    * GH #627, #607: Remove potential context issues with returning
+      undef explicitly. (Javier Rojas)
+    * GH #646: Fix whitespacing for tests. (DavsX)
+
+0.149000_01 2014-07-23 21:31:21CEST+0200 Europe/Amsterdam
+
+    *************************** NOTICE ***************************
+    * This very is a major upgrade                               *
+    * We untangled the context, DSL implementation a bit         *
+    * Please check your code, including your plugins, thoroughly *
+    * Thank you                                                  *
+
+    [ ENHANCEMENTS ]
+    * GH #589: Removing Dancer2::Core::Context global context variable.
+      Finally in.
+      (Sawyer X, Mickey Nasriachi, Russell @veryrusty Jenkins)
+
+    [ BUG FIXES ]
+    * GH #606, #605: Fix for setting public directory.
+      (Ivan Kocienski, Russell Jenkins, Stefan @racke Hornburg)
+    * GH #618, #620: Fix jQuery link generated by CLI skeleton.
+      (Michał Wojciechowski)
+    * GH #589: Major memory leak fix by removal of Dancer2::Core::Context.
+
+    [ ENHANCEMENTS ]
+    * GH #620: Bump jQuery to 1.11.1. (Michał Wojciechowski)
+
+0.143000  2014-07-05 21:39:28CEST+0200 Europe/Amsterdam
+
+    [ BUG FIXES ]
+    * GH #538, #539: Coerce propogated exceptions to strings within Error object.
+      (Steven Humphrey)
+    * GH #531: Generate valid HTML when show_errors is true from Error objects.
+      (Steven Humphrey)
+    * GH #603: Update skeleton test to use Plack::Test. (Sawyer X)
+
+    [ ENHANCEMENTS ]
+    * Provide psgi_app in top-level Dancer.pm to make it easier to change it.
+      (Sawyer X)
+
+0.142000  2014-06-24 15:16:42CEST+0200 Europe/Amsterdam
+
+    [ BUG FIXES ]
+    * GH #550, #555: Allow the content type to be set when using send_file
+      as per the documentation. (Russell Jenkins, Steven Humphrey)
+
+    [ ENHANCEMENTS ]
+    * GH #512, #520, #602: Pass all settings into JSON serializer engine.
+      (Jakob Voss, Russell Jenkins)
+    * GH #532: Serialize runtime errors such as those produced by die if a
+      serializer exists. (Steven Humphrey)
+
 0.141000  2014-06-08 22:27:03CEST+0200 Europe/Amsterdam
 
     * No functional changes.
@@ -17,7 +17,6 @@ lib/Dancer2/Config.pod
 lib/Dancer2/Cookbook.pod
 lib/Dancer2/Core.pm
 lib/Dancer2/Core/App.pm
-lib/Dancer2/Core/Context.pm
 lib/Dancer2/Core/Cookie.pm
 lib/Dancer2/Core/DSL.pm
 lib/Dancer2/Core/Dispatcher.pm
@@ -33,6 +32,7 @@ lib/Dancer2/Core/Role/ConfigReader.pm
 lib/Dancer2/Core/Role/DSL.pm
 lib/Dancer2/Core/Role/Engine.pm
 lib/Dancer2/Core/Role/Handler.pm
+lib/Dancer2/Core/Role/HasLocation.pm
 lib/Dancer2/Core/Role/Headers.pm
 lib/Dancer2/Core/Role/Hookable.pm
 lib/Dancer2/Core/Role/Logger.pm
@@ -107,20 +107,18 @@ t/app/t2/.dancer
 t/app/t2/config.yml
 t/app/t2/lib/App3.pm
 t/auto_page.t
+t/caller.t
 t/charset_server.t
-t/config.t
 t/config.yml
 t/config/config.yml
 t/config/environments/failure.yml
 t/config/environments/merging.yml
 t/config/environments/production.yml
 t/config/environments/staging.json
-t/config_app1.t
-t/config_app2.t
-t/config_app3.t
+t/config_multiapp.t
+t/config_reader.t
 t/config_settings.t
-t/context.t
-t/context_trigger.t
+t/context-in-before.t
 t/cookie.t
 t/corpus/pretty/505.tt
 t/corpus/pretty_public/404.html
@@ -133,6 +131,8 @@ t/dancer-test/config.yml
 t/deserialize.t
 t/dispatcher.t
 t/dsl.t
+t/dsl/extend.t
+t/dsl/extend_config/config.yml
 t/dsl/halt.t
 t/dsl/pass.t
 t/engine.t
@@ -159,15 +159,23 @@ t/lib/SubApp1.pm
 t/lib/SubApp2.pm
 t/lib/TestApp.pm
 t/lib/TestPod.pm
+t/log_die_before_hook.t
+t/log_levels.t
 t/logger.t
 t/logger/file.t
 t/logger_console.t
 t/lwp-protocol-psgi.t
+t/memory_cycles.t
 t/mime.t
+t/multi_apps.t
+t/multi_apps_forward.t
+t/multiapp_template_hooks.t
+t/named_apps.t
 t/plugin_import.t
 t/plugin_multiple_apps.t
 t/plugin_register.t
 t/plugin_syntax.t
+t/psgi_app.t
 t/public/file.txt
 t/redirect.t
 t/release-distmeta.t
@@ -231,6 +239,19 @@ t/sessions/U4dFuQAASvRTfhriav1JejXrIpcGPEZu.yml
 t/sessions/U4dHNwAAURLdtNi0IuajTgmkXFQfvjrA.yml
 t/sessions/U4dhegAAAw5gU_GDhdYOAgg7AtnGvHoB.yml
 t/sessions/U4uQKwAAc0S31MjwWDgsnGg-wkwCcUp-.yml
+t/sessions/U7g83AAAD40GMDKZZbYNAi9jRU6lJlmd.yml
+t/sessions/U7hR3AAAME4JbYM_IBVWT5sQq-OlHt5v.yml
+t/sessions/U8-0IAAAIo7quaDrMsrwW_vaalYuLN5G.yml
+t/sessions/U8-x8wAAH8c5NFaIXyuTBQ1qaMYVXtms.yml
+t/sessions/U8-yGQAAIIeUD3g5pCfu12mGyb9jdFpA.yml
+t/sessions/U8EjygAAC9a8v1m7XkjynBlJ8JKWkXsr.yml
+t/sessions/U8FTogAARfIT33ImUZSd5ffmiDvPjQ1k.yml
+t/sessions/U8q6bgAAY5J_az3iLVXSgmzZBpzsGZdn.yml
+t/sessions/U8qxAQAAVNrEmBCFpYG_oFJEBuv5Oo1T.yml
+t/sessions/U8sClAAAQzB77au98B9OAeDZsoejrJ6L.yml
+t/sessions/U9QiNAAATPWPqf4CsvJrPEfxpRGNdfDK.yml
+t/sessions/U9UMBAAAWAmK4rV4Zld987OFzngYrzpQ.yml
+t/sessions/U9URAgAAYlA49NVHsXQZcLgJzSdDKNDU.yml
 t/sessions/Uf-CrAAAdd2mP4pJAIBzc6YRqXnqeNUt.yml
 t/sessions/Uf-GsQAANz9OaEztWyuSfJKegUq3zD1V.yml
 t/sessions/Uf-HDgAAPPOeyDGX2_IgTLzBg6iBsFkk.yml
@@ -316,6 +337,7 @@ t/types.t
 t/uri_for.t
 t/vars.t
 t/views/auto_page.tt
+t/views/beforetemplate.tt
 t/views/folder/page.tt
 t/views/index.tt
 t/views/layouts/main.tt
@@ -87,7 +87,9 @@
             "Pod::Simple::SimpleTree" : "0",
             "Return::MultiLevel" : "0",
             "Role::Tiny" : "1.003000",
+            "Safe::Isa" : "0",
             "Scalar::Util" : "0",
+            "Sub::Quote" : "0",
             "Template" : "0",
             "Template::Tiny" : "0",
             "Test::Builder" : "0",
@@ -122,6 +124,7 @@
             "LWP::Protocol::PSGI" : "0.06",
             "Plack::Test" : "0",
             "Test::Fatal" : "0",
+            "Test::Memory::Cycle" : "1.04",
             "Test::MockTime" : "0",
             "Test::More" : "0.92",
             "Test::Script" : "0",
@@ -137,255 +140,255 @@
    "provides" : {
       "Dancer2" : {
          "file" : "lib/Dancer2.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::CLI" : {
          "file" : "lib/Dancer2/CLI.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::CLI::Command::gen" : {
          "file" : "lib/Dancer2/CLI/Command/gen.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::CLI::Command::version" : {
          "file" : "lib/Dancer2/CLI/Command/version.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Config" : {
          "file" : "lib/Dancer2/Config.pod",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Cookbook" : {
          "file" : "lib/Dancer2/Cookbook.pod",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core" : {
          "file" : "lib/Dancer2/Core.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::App" : {
          "file" : "lib/Dancer2/Core/App.pm",
-         "version" : "0.141000"
-      },
-      "Dancer2::Core::Context" : {
-         "file" : "lib/Dancer2/Core/Context.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::Cookie" : {
          "file" : "lib/Dancer2/Core/Cookie.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::DSL" : {
          "file" : "lib/Dancer2/Core/DSL.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::Dispatcher" : {
          "file" : "lib/Dancer2/Core/Dispatcher.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::Error" : {
          "file" : "lib/Dancer2/Core/Error.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::Factory" : {
          "file" : "lib/Dancer2/Core/Factory.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::HTTP" : {
          "file" : "lib/Dancer2/Core/HTTP.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::Hook" : {
          "file" : "lib/Dancer2/Core/Hook.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::MIME" : {
          "file" : "lib/Dancer2/Core/MIME.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::Request" : {
          "file" : "lib/Dancer2/Core/Request.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::Request::Upload" : {
          "file" : "lib/Dancer2/Core/Request/Upload.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::Response" : {
          "file" : "lib/Dancer2/Core/Response.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::Role::ConfigReader" : {
          "file" : "lib/Dancer2/Core/Role/ConfigReader.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::Role::DSL" : {
          "file" : "lib/Dancer2/Core/Role/DSL.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::Role::Engine" : {
          "file" : "lib/Dancer2/Core/Role/Engine.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::Role::Handler" : {
          "file" : "lib/Dancer2/Core/Role/Handler.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
+      },
+      "Dancer2::Core::Role::HasLocation" : {
+         "file" : "lib/Dancer2/Core/Role/HasLocation.pm",
+         "version" : "0.150000"
       },
       "Dancer2::Core::Role::Headers" : {
          "file" : "lib/Dancer2/Core/Role/Headers.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::Role::Hookable" : {
          "file" : "lib/Dancer2/Core/Role/Hookable.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::Role::Logger" : {
          "file" : "lib/Dancer2/Core/Role/Logger.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::Role::Serializer" : {
          "file" : "lib/Dancer2/Core/Role/Serializer.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::Role::SessionFactory" : {
          "file" : "lib/Dancer2/Core/Role/SessionFactory.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::Role::SessionFactory::File" : {
          "file" : "lib/Dancer2/Core/Role/SessionFactory/File.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::Role::StandardResponses" : {
          "file" : "lib/Dancer2/Core/Role/StandardResponses.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::Role::Template" : {
          "file" : "lib/Dancer2/Core/Role/Template.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::Route" : {
          "file" : "lib/Dancer2/Core/Route.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::Runner" : {
          "file" : "lib/Dancer2/Core/Runner.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::Session" : {
          "file" : "lib/Dancer2/Core/Session.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::Time" : {
          "file" : "lib/Dancer2/Core/Time.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Core::Types" : {
          "file" : "lib/Dancer2/Core/Types.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::FileUtils" : {
          "file" : "lib/Dancer2/FileUtils.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Handler::AutoPage" : {
          "file" : "lib/Dancer2/Handler/AutoPage.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Handler::File" : {
          "file" : "lib/Dancer2/Handler/File.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Logger::Capture" : {
          "file" : "lib/Dancer2/Logger/Capture.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Logger::Capture::Trap" : {
          "file" : "lib/Dancer2/Logger/Capture/Trap.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Logger::Console" : {
          "file" : "lib/Dancer2/Logger/Console.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Logger::Diag" : {
          "file" : "lib/Dancer2/Logger/Diag.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Logger::File" : {
          "file" : "lib/Dancer2/Logger/File.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Logger::Note" : {
          "file" : "lib/Dancer2/Logger/Note.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Logger::Null" : {
          "file" : "lib/Dancer2/Logger/Null.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Manual" : {
          "file" : "lib/Dancer2/Manual.pod",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Plugin" : {
          "file" : "lib/Dancer2/Plugin.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Plugin::Ajax" : {
          "file" : "lib/Dancer2/Plugin/Ajax.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Plugins" : {
          "file" : "lib/Dancer2/Plugins.pod",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Serializer::Dumper" : {
          "file" : "lib/Dancer2/Serializer/Dumper.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Serializer::JSON" : {
          "file" : "lib/Dancer2/Serializer/JSON.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Serializer::Mutable" : {
          "file" : "lib/Dancer2/Serializer/Mutable.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Serializer::YAML" : {
          "file" : "lib/Dancer2/Serializer/YAML.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Session::Simple" : {
          "file" : "lib/Dancer2/Session/Simple.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Session::YAML" : {
          "file" : "lib/Dancer2/Session/YAML.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Template::Implementation::ForkedTiny" : {
          "file" : "lib/Dancer2/Template/Implementation/ForkedTiny.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Template::Simple" : {
          "file" : "lib/Dancer2/Template/Simple.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Template::TemplateToolkit" : {
          "file" : "lib/Dancer2/Template/TemplateToolkit.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Template::Tiny" : {
          "file" : "lib/Dancer2/Template/Tiny.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Test" : {
          "file" : "lib/Dancer2/Test.pm",
-         "version" : "0.141000"
+         "version" : "0.150000"
       },
       "Dancer2::Tutorial" : {
          "file" : "lib/Dancer2/Tutorial.pod",
-         "version" : "0.141000"
+         "version" : "0.150000"
       }
    },
    "release_status" : "stable",
@@ -398,6 +401,6 @@
          "url" : "https://github.com/PerlDancer/Dancer2"
       }
    },
-   "version" : "0.141000"
+   "version" : "0.150000"
 }
 
@@ -17,6 +17,7 @@ build_requires:
   Module::Build: 0.3601
   Plack::Test: 0
   Test::Fatal: 0
+  Test::Memory::Cycle: 1.04
   Test::MockTime: 0
   Test::More: 0.92
   Test::Script: 0
@@ -40,193 +41,193 @@ name: Dancer2
 provides:
   Dancer2:
     file: lib/Dancer2.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::CLI:
     file: lib/Dancer2/CLI.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::CLI::Command::gen:
     file: lib/Dancer2/CLI/Command/gen.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::CLI::Command::version:
     file: lib/Dancer2/CLI/Command/version.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Config:
     file: lib/Dancer2/Config.pod
-    version: 0.141000
+    version: 0.150000
   Dancer2::Cookbook:
     file: lib/Dancer2/Cookbook.pod
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core:
     file: lib/Dancer2/Core.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::App:
     file: lib/Dancer2/Core/App.pm
-    version: 0.141000
-  Dancer2::Core::Context:
-    file: lib/Dancer2/Core/Context.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::Cookie:
     file: lib/Dancer2/Core/Cookie.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::DSL:
     file: lib/Dancer2/Core/DSL.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::Dispatcher:
     file: lib/Dancer2/Core/Dispatcher.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::Error:
     file: lib/Dancer2/Core/Error.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::Factory:
     file: lib/Dancer2/Core/Factory.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::HTTP:
     file: lib/Dancer2/Core/HTTP.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::Hook:
     file: lib/Dancer2/Core/Hook.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::MIME:
     file: lib/Dancer2/Core/MIME.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::Request:
     file: lib/Dancer2/Core/Request.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::Request::Upload:
     file: lib/Dancer2/Core/Request/Upload.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::Response:
     file: lib/Dancer2/Core/Response.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::Role::ConfigReader:
     file: lib/Dancer2/Core/Role/ConfigReader.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::Role::DSL:
     file: lib/Dancer2/Core/Role/DSL.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::Role::Engine:
     file: lib/Dancer2/Core/Role/Engine.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::Role::Handler:
     file: lib/Dancer2/Core/Role/Handler.pm
-    version: 0.141000
+    version: 0.150000
+  Dancer2::Core::Role::HasLocation:
+    file: lib/Dancer2/Core/Role/HasLocation.pm
+    version: 0.150000
   Dancer2::Core::Role::Headers:
     file: lib/Dancer2/Core/Role/Headers.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::Role::Hookable:
     file: lib/Dancer2/Core/Role/Hookable.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::Role::Logger:
     file: lib/Dancer2/Core/Role/Logger.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::Role::Serializer:
     file: lib/Dancer2/Core/Role/Serializer.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::Role::SessionFactory:
     file: lib/Dancer2/Core/Role/SessionFactory.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::Role::SessionFactory::File:
     file: lib/Dancer2/Core/Role/SessionFactory/File.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::Role::StandardResponses:
     file: lib/Dancer2/Core/Role/StandardResponses.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::Role::Template:
     file: lib/Dancer2/Core/Role/Template.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::Route:
     file: lib/Dancer2/Core/Route.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::Runner:
     file: lib/Dancer2/Core/Runner.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::Session:
     file: lib/Dancer2/Core/Session.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::Time:
     file: lib/Dancer2/Core/Time.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Core::Types:
     file: lib/Dancer2/Core/Types.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::FileUtils:
     file: lib/Dancer2/FileUtils.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Handler::AutoPage:
     file: lib/Dancer2/Handler/AutoPage.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Handler::File:
     file: lib/Dancer2/Handler/File.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Logger::Capture:
     file: lib/Dancer2/Logger/Capture.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Logger::Capture::Trap:
     file: lib/Dancer2/Logger/Capture/Trap.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Logger::Console:
     file: lib/Dancer2/Logger/Console.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Logger::Diag:
     file: lib/Dancer2/Logger/Diag.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Logger::File:
     file: lib/Dancer2/Logger/File.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Logger::Note:
     file: lib/Dancer2/Logger/Note.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Logger::Null:
     file: lib/Dancer2/Logger/Null.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Manual:
     file: lib/Dancer2/Manual.pod
-    version: 0.141000
+    version: 0.150000
   Dancer2::Plugin:
     file: lib/Dancer2/Plugin.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Plugin::Ajax:
     file: lib/Dancer2/Plugin/Ajax.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Plugins:
     file: lib/Dancer2/Plugins.pod
-    version: 0.141000
+    version: 0.150000
   Dancer2::Serializer::Dumper:
     file: lib/Dancer2/Serializer/Dumper.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Serializer::JSON:
     file: lib/Dancer2/Serializer/JSON.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Serializer::Mutable:
     file: lib/Dancer2/Serializer/Mutable.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Serializer::YAML:
     file: lib/Dancer2/Serializer/YAML.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Session::Simple:
     file: lib/Dancer2/Session/Simple.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Session::YAML:
     file: lib/Dancer2/Session/YAML.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Template::Implementation::ForkedTiny:
     file: lib/Dancer2/Template/Implementation/ForkedTiny.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Template::Simple:
     file: lib/Dancer2/Template/Simple.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Template::TemplateToolkit:
     file: lib/Dancer2/Template/TemplateToolkit.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Template::Tiny:
     file: lib/Dancer2/Template/Tiny.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Test:
     file: lib/Dancer2/Test.pm
-    version: 0.141000
+    version: 0.150000
   Dancer2::Tutorial:
     file: lib/Dancer2/Tutorial.pod
-    version: 0.141000
+    version: 0.150000
 recommends:
   CGI::Deurl::XS: 0
   Crypt::URandom: 0
@@ -280,7 +281,9 @@ requires:
   Pod::Simple::SimpleTree: 0
   Return::MultiLevel: 0
   Role::Tiny: 1.003000
+  Safe::Isa: 0
   Scalar::Util: 0
+  Sub::Quote: 0
   Template: 0
   Template::Tiny: 0
   Test::Builder: 0
@@ -297,4 +300,4 @@ resources:
   bugtracker: https://github.com/PerlDancer/Dancer2/issues
   homepage: http://perldancer.org/
   repository: https://github.com/PerlDancer/Dancer2
-version: 0.141000
+version: 0.150000
@@ -70,7 +70,9 @@ my %WriteMakefileArgs = (
     "Pod::Simple::SimpleTree" => 0,
     "Return::MultiLevel" => 0,
     "Role::Tiny" => "1.003000",
+    "Safe::Isa" => 0,
     "Scalar::Util" => 0,
+    "Sub::Quote" => 0,
     "Template" => 0,
     "Template::Tiny" => 0,
     "Test::Builder" => 0,
@@ -97,6 +99,7 @@ my %WriteMakefileArgs = (
     "LWP::Protocol::PSGI" => "0.06",
     "Plack::Test" => 0,
     "Test::Fatal" => 0,
+    "Test::Memory::Cycle" => "1.04",
     "Test::MockTime" => 0,
     "Test::More" => "0.92",
     "Test::Script" => 0,
@@ -106,7 +109,7 @@ my %WriteMakefileArgs = (
     "utf8" => 0,
     "vars" => 0
   },
-  "VERSION" => "0.141000",
+  "VERSION" => "0.150000",
   "test" => {
     "TESTS" => "t/*.t t/dsl/*.t t/logger/*.t t/roles/*.t t/route-pod-coverage/*.t t/template_tiny/*.t"
   }
@@ -165,11 +168,14 @@ my %FallbackPrereqs = (
   "Pod::Simple::SimpleTree" => 0,
   "Return::MultiLevel" => 0,
   "Role::Tiny" => "1.003000",
+  "Safe::Isa" => 0,
   "Scalar::Util" => 0,
+  "Sub::Quote" => 0,
   "Template" => 0,
   "Template::Tiny" => 0,
   "Test::Builder" => 0,
   "Test::Fatal" => 0,
+  "Test::Memory::Cycle" => "1.04",
   "Test::MockTime" => 0,
   "Test::More" => "0.92",
   "Test::Script" => 0,
@@ -1,6 +1,6 @@
 # ABSTRACT: create new Dancer2 application
 package Dancer2::CLI::Command::gen;
-$Dancer2::CLI::Command::gen::VERSION = '0.141000';
+$Dancer2::CLI::Command::gen::VERSION = '0.150000';
 use strict;
 use warnings;
 
@@ -277,7 +277,7 @@ Dancer2::CLI::Command::gen - create new Dancer2 application
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 AUTHOR
 
@@ -1,6 +1,6 @@
 package Dancer2::CLI::Command::version;
 # ABSTRACT: display version
-$Dancer2::CLI::Command::version::VERSION = '0.141000';
+$Dancer2::CLI::Command::version::VERSION = '0.150000';
 use App::Cmd::Setup -command;
 
 sub description { 'Display version of Dancer2' }
@@ -27,7 +27,7 @@ Dancer2::CLI::Command::version - display version
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 AUTHOR
 
@@ -1,6 +1,6 @@
 # ABSTRACT: Dancer2 cli application
 package Dancer2::CLI;
-$Dancer2::CLI::VERSION = '0.141000';
+$Dancer2::CLI::VERSION = '0.150000';
 use App::Cmd::Setup -app;
 
 1;
@@ -15,7 +15,7 @@ Dancer2::CLI - Dancer2 cli application
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 AUTHOR
 
@@ -1,6 +1,6 @@
 package Dancer2::Config;
 # ABSTRACT: Configure Dancer2 to suit your needs
-$Dancer2::Config::VERSION = '0.141000';
+$Dancer2::Config::VERSION = '0.150000';
 __END__
 
 =pod
@@ -11,7 +11,7 @@ Dancer2::Config - Configure Dancer2 to suit your needs
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -451,6 +451,20 @@ Dancer2 will honor your C<before_template_render> code, and all default
 variables. They will be accessible and interpolated on automatic
 served pages.
 
+=head2 dsl_class
+
+For complex applications that require extended DSL keywords or other
+functionality the DSL class used can be specified at import time or in the
+config settings.
+
+    dsl_class: 'My::DSL'
+
+This is the same as specifying
+
+    use Dancer2 dsl => 'My::DSL'
+
+in your module. dsl_class defaults to L<Dancer2::Core::DSL> if not specified
+
 =head2 DANCER_CONFDIR and DANCER_ENVDIR
 
 It's possible to set the configuration directory and environment directory using this two
@@ -1,6 +1,6 @@
 package Dancer2::Cookbook;
 # ABSTRACT: Example-driven quick-start to the Dancer2 web framework
-$Dancer2::Cookbook::VERSION = '0.141000';
+$Dancer2::Cookbook::VERSION = '0.150000';
 __END__
 
 =pod
@@ -11,7 +11,7 @@ Dancer2::Cookbook - Example-driven quick-start to the Dancer2 web framework
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -280,7 +280,7 @@ admin section, and want to maintain this in a different package:
     1;
 
     package myapp::admin;
-    use Dancer2;
+    use Dancer2 appname => 'myapp';
 
     prefix '/admin';
 
@@ -295,6 +295,16 @@ The following routes will be generated for us:
     - head /
     - head /admin/
 
+By default, a separate application is created for every package that uses
+Dancer2. The C<appname> tag is used to collect routes and hooks into a
+single Dancer2 application. In the above example, C<appname =E<gt> 'myapp'> adds
+the routes from C<myapp::admin> to the routes of the app C<myapp>.
+
+When using multiple applications please ensure that your path definitions
+do not overlap. Eg, if using a default route as described above, once a
+request is matched to the default route then no further routes
+(or applications) would be reached.
+
 =head1 MUSCLE MEMORY: STORING DATA
 
 =head2 Handling sessions
@@ -370,7 +380,7 @@ for you.
 
 When you're done with your session, you can destroy it:
 
-    context->destroy_session
+    app->destroy_session
 
 =head2 Sessions and logging in
 
@@ -1143,8 +1153,8 @@ Start by creating a simple app.psgi file:
     use Plack::Builder;
 
     builder {
-        mount '/wiki'  => OurWiki->dance;
-        mount '/forum' => OurForum->dance;
+        mount '/wiki'  => OurWiki->psgi_app;
+        mount '/forum' => OurForum->psgi_app;
     };
 
 and now use L<Starman>
@@ -1,15 +1,15 @@
 # ABSTRACT: encapsulation of Dancer2 packages
 package Dancer2::Core::App;
-$Dancer2::Core::App::VERSION = '0.141000';
+$Dancer2::Core::App::VERSION = '0.150000';
 use Moo;
 use Carp            'croak';
-use List::Util      'first';
 use Scalar::Util    'blessed';
 use Module::Runtime 'is_module_name';
 use File::Spec;
 
-use Dancer2::FileUtils 'path', 'read_file_content';
+use Dancer2::FileUtils 'path';
 use Dancer2::Core;
+use Dancer2::Core::Cookie;
 use Dancer2::Core::Types;
 use Dancer2::Core::Route;
 use Dancer2::Core::Hook;
@@ -58,21 +58,33 @@ has '+local_triggers' => (
         my $triggers = {
             # general triggers we want to allow, besides engines
             views => sub {
-                my ( $self, $value, $config ) = @_;
+                my $self  = shift;
+                my $value = shift;
                 $self->template_engine->views($value);
             },
 
             layout => sub {
-                my ( $self, $value, $config ) = @_;
+                my $self  = shift;
+                my $value = shift;
                 $self->template_engine->layout($value);
             },
+
+            log => sub {
+                my ( $self, $value, $config ) = @_;
+
+                # This will allow to set the log level
+                # using: set log => warning
+                $self->logger_engine->log_level($value);
+            },
         };
 
         foreach my $engine ( @{ $self->supported_engines } ) {
             $triggers->{$engine} = sub {
-                my ( $self, $value, $config ) = @_;
+                my $self   = shift;
+                my $value  = shift;
+                my $config = shift;
 
-                return $value if ref $value;
+                ref $value and return $value;
 
                 my $build_method    = "_build_${engine}_engine";
                 my $setter_method   = "set_${engine}_engine";
@@ -90,16 +102,18 @@ has '+local_triggers' => (
 );
 
 sub _build_logger_engine {
-    my ($self, $value, $config) = @_;
+    my $self   = shift;
+    my $value  = shift;
+    my $config = shift;
 
-    $config = $self->config     if !defined $config;
-    $value  = $config->{logger} if !defined $value;
+    defined $config or $config = $self->config;
+    defined $value  or $value  = $config->{logger};
 
-    return $value if ref($value);
+    ref $value and return $value;
 
     # XXX This is needed for the tests that create an app without
     # a runner.
-    $value = 'console' if !defined $value;
+    defined $value or $value = 'console';
 
     is_module_name($value)
         or croak "Cannot load logger engine '$value': illegal module name";
@@ -114,19 +128,20 @@ sub _build_logger_engine {
         postponed_hooks => $self->get_postponed_hooks
     );
 
-    $logger->log_level($config->{log}) if exists $config->{log};
+    exists $config->{log} and $logger->log_level($config->{log});
 
     return $logger;
 }
 
 sub _build_session_engine {
-    my ($self, $value, $config)  = @_;
+    my $self   = shift;
+    my $value  = shift;
+    my $config = shift;
 
-    $config = $self->config        if !defined $config;
-    $value  = $config->{'session'} if !defined $value;
+    defined $config or $config = $self->config;
+    defined $value  or $value  = $config->{'session'} || 'simple';
 
-    $value = 'simple' if !defined $value;
-    return $value     if ref($value);
+    ref $value and return $value;
 
     is_module_name($value)
         or croak "Cannot load session engine '$value': illegal module name";
@@ -142,13 +157,15 @@ sub _build_session_engine {
 }
 
 sub _build_template_engine {
-    my ($self, $value, $config)  = @_;
+    my $self   = shift;
+    my $value  = shift;
+    my $config = shift;
 
-    $config = $self->config         if !defined $config;
-    $value  = $config->{'template'} if !defined $value;
+    defined $config or $config = $self->config;
+    defined $value  or $value  = $config->{'template'};
 
-    return undef  if !defined $value;
-    return $value if ref($value);
+    defined $value or return;
+    ref $value    and return $value;
 
     is_module_name($value)
         or croak "Cannot load template engine '$value': illegal module name";
@@ -169,13 +186,15 @@ sub _build_template_engine {
 }
 
 sub _build_serializer_engine {
-    my ($self, $value, $config) = @_;
+    my $self   = shift;
+    my $value  = shift;
+    my $config = shift;
 
-    $config = $self->config         if !defined $config;
-    $value  = $config->{serializer} if !defined $value;
+    defined $config or $config = $self->config;
+    defined $value  or $value  = $config->{serializer};
 
-    return undef  if !defined $value;
-    return $value if ref($value);
+    defined $value or return;
+    ref $value    and return $value;
 
     my $engine_options =
         $self->_get_config_for_engine( serializer => $value, $config );
@@ -188,7 +207,10 @@ sub _build_serializer_engine {
 }
 
 sub _get_config_for_engine {
-    my ( $self, $engine, $name, $config ) = @_;
+    my $self   = shift;
+    my $engine = shift;
+    my $name   = shift;
+    my $config = shift;
 
     defined $config->{'engines'} && defined $config->{'engines'}{$engine}
         or return {};
@@ -205,8 +227,6 @@ sub _get_config_for_engine {
     return $engine_config;
 }
 
-
-
 has postponed_hooks => (
     is      => 'ro',
     isa     => HashRef,
@@ -219,12 +239,6 @@ has plugins => (
     default => sub { [] },
 );
 
-has runner_config => (
-    is      => 'ro',
-    isa     => HashRef,
-    default => sub { {} },
-);
-
 has route_handlers => (
     is      => 'rw',
     isa     => ArrayRef,
@@ -236,28 +250,139 @@ has name => (
     isa => Str,
 );
 
-# holds a context whenever a request is processed
-has context => (
-    is      => 'rw',
-    isa     => Maybe [ InstanceOf ['Dancer2::Core::Context'] ],
-    trigger => sub {
-        my ( $self, $ctx ) = @_;
-        $self->_init_for_context($ctx),;
-        for my $type ( @{ $self->supported_engines } ) {
-            my $attr   = "${type}_engine";
-            my $engine = $self->$attr or next;
-            defined($ctx) ? $engine->context($ctx) : $engine->clear_context;
+has request => (
+    is        => 'ro',
+    isa       => InstanceOf['Dancer2::Core::Request'],
+    writer    => 'set_request',
+    clearer   => 'clear_request',
+    predicate => 'has_request',
+);
+
+has response => (
+    is        => 'ro',
+    isa       => InstanceOf['Dancer2::Core::Response'],
+    lazy      => 1,
+    writer    => 'set_response',
+    clearer   => 'clear_response',
+    builder   => '_build_response',
+    predicate => 'has_response',
+);
+
+
+has with_return => (
+    is        => 'ro',
+    predicate => 1,
+    writer    => 'set_with_return',
+    clearer   => 'clear_with_return',
+);
+
+
+has session => (
+    is        => 'ro',
+    isa       => InstanceOf['Dancer2::Core::Session'],
+    lazy      => 1,
+    builder   => '_build_session',
+    writer    => 'set_session',
+    clearer   => 'clear_session',
+    predicate => '_has_session',
+);
+
+sub _build_response {
+    my $self   = shift;
+    my $engine = $self->engine('serializer');
+
+    return Dancer2::Core::Response->new(
+        ( serializer => $engine )x!! $engine
+    );
+}
+
+sub _build_session {
+    my $self = shift;
+    my $session;
+
+    # Find the session engine
+    my $engine = $self->engine('session');
+
+    # find the session cookie if any
+    if ( !$self->has_destroyed_session ) {
+        my $session_id;
+        my $session_cookie = $self->cookie( $engine->cookie_name );
+        defined $session_cookie and
+            $session_id = $session_cookie->value;
+
+        # if we have a session cookie, try to retrieve the session
+        if ( defined $session_id ) {
+            eval  { $session = $engine->retrieve( id => $session_id ); 1; }
+            or do { $@ and $@ !~ /Unable to retrieve session/
+                        and croak "Fail to retrieve session: $@" };
         }
-    },
+    }
+
+    # create the session if none retrieved
+    return $session ||= $engine->create();
+}
+
+
+sub has_session {
+    my $self = shift;
+
+    my $engine = $self->engine('session');
+
+    return $self->_has_session
+        || ( $self->cookie( $engine->cookie_name )
+             && !$self->has_destroyed_session );
+}
+
+
+has destroyed_session => (
+    is        => 'ro',
+    isa       => InstanceOf ['Dancer2::Core::Session'],
+    predicate => 1,
+    writer    => 'set_destroyed_session',
+    clearer   => 'clear_destroyed_session',
 );
 
+
+sub destroy_session {
+    my $self = shift;
+
+    # Find the session engine
+    my $engine = $self->engine('session');
+
+    # Expire session, set the expired cookie and destroy the session
+    # Setting the cookie ensures client gets an expired cookie unless
+    # a new session is created and supercedes it
+    my $session = $self->session;
+    $session->expires(-86400);    # yesterday
+    $engine->destroy( id => $session->id );
+
+    # Clear session and invalidate session cookie in request
+    $self->set_destroyed_session($session);
+    $self->clear_session;
+
+    return;
+}
+
+sub setup_session {
+    my $self = shift;
+
+    for my $type ( @{ $self->supported_engines } ) {
+        my $attr   = "${type}_engine";
+        my $engine = $self->$attr or next;
+
+        $self->has_session                         ?
+            $engine->set_session( $self->session ) :
+            $engine->clear_session;
+    }
+}
+
 has prefix => (
     is        => 'rw',
     isa       => Maybe [Dancer2Prefix],
     predicate => 1,
     coerce    => sub {
-        my ($prefix) = @_;
-        return undef if defined($prefix) and $prefix eq "/";
+        my $prefix = shift;
+        defined($prefix) and $prefix eq "/" and return;
         return $prefix;
     },
 );
@@ -280,7 +405,8 @@ has routes => (
 # add_hook will add the hook to the first "hook candidate" it finds that support
 # it. If none, then it will try to add the hook to the current application.
 around add_hook => sub {
-    my ( $orig, $self ) = ( shift, shift );
+    my $orig = shift;
+    my $self = shift;
 
     # saving caller information
     my ( $package, $file, $line ) = caller(4);    # deep to 4 : user's app code
@@ -291,27 +417,26 @@ around add_hook => sub {
     my $hook_aliases = $self->all_hook_aliases;
 
     # look for an alias
-    $name = $hook_aliases->{$name}
-      if defined $hook_aliases->{$name};
+    defined $hook_aliases->{$name} and $name = $hook_aliases->{$name};
     $hook->name($name);
 
     # if that hook belongs to the app, register it now and return
-    return $self->$orig(@_) if $self->has_hook($name);
+    $self->has_hook($name) and return $self->$orig(@_);
 
     # at this point the hook name must be formatted like:
     # '$type.$candidate.$name', eg: 'engine.template.before_render' or
     # 'plugin.database.before_dbi_connect'
     my ( $hookable_type, $hookable_name, $hook_name ) = split( /\./, $name );
 
-    croak "Invalid hook name `$name'"
-      unless defined $hookable_name && defined $hook_name;
+    ( defined $hookable_name && defined $hook_name )
+        or croak "Invalid hook name `$name'";
 
-    croak "Unknown hook type `$hookable_type'"
-      if !grep /^$hookable_type$/, qw(core engine handler plugin);
+    grep /^$hookable_type$/, qw(core engine handler plugin)
+        or croak "Unknown hook type `$hookable_type'";
 
     # register the hooks for existing hookable candidates
     foreach my $hookable ( $self->hook_candidates ) {
-        $hookable->add_hook(@_) if $hookable->has_hook($name);
+        $hookable->has_hook($name) and $hookable->add_hook(@_);
     }
 
     # we register the hook for upcoming objects;
@@ -331,11 +456,13 @@ around add_hook => sub {
 };
 
 around execute_hook => sub {
-    my ( $orig, $self ) = ( shift, shift );
+    my $orig = shift;
+    my $self = shift;
+
     my ( $hook, @args ) = @_;
     if ( !$self->has_hook($hook) ) {
         foreach my $cand ( $self->hook_candidates ) {
-            return $cand->execute_hook(@_) if $cand->has_hook($hook);
+            $cand->has_hook($hook) and return $cand->execute_hook(@_);
         }
     }
 
@@ -343,10 +470,15 @@ around execute_hook => sub {
 };
 
 sub _build_default_config {
-    my ($self) = @_;
+    my $self = shift;
 
     return {
-        %{ $self->runner_config },
+        content_type   => ( $ENV{DANCER_CONTENT_TYPE} || 'text/html' ),
+        charset        => ( $ENV{DANCER_CHARSET}      || '' ),
+        logger         => ( $ENV{DANCER_LOGGER}       || 'console' ),
+        views          => ( $ENV{DANCER_VIEWS}
+                            || path( $self->config_location, 'views' ) ),
+        appdir         => $self->location,
         template       => 'Tiny',
         route_handlers => [
             [
@@ -363,39 +495,39 @@ sub _build_default_config {
 }
 
 sub _init_hooks {
-    my ($self) = @_;
+    my $self = shift;
 
  # Hook to flush the session at the end of the request, this way, we're sure we
  # flush only once per request
+ #
+ # Note: we create a weakened copy $self before closing over the weakened copy
+ # to avoid circular memory refs.
+    Scalar::Util::weaken(my $app = $self);
     $self->add_hook(
         Dancer2::Core::Hook->new(
             name => 'core.app.after_request',
             code => sub {
-                my $response = shift;
+                my $response = $app->response;
 
                 # make sure an engine is defined, if not, nothing to do
-                my $engine = $self->session_engine;
-                return if !defined $engine;
-
-                # make sure we have a context to examine
-                return if !defined $self->context;
+                my $engine = $app->session_engine;
+                defined $engine or return;
 
                 # if a session has been instantiated or we already had a
                 # session, first flush the session so cookie-based sessions can
                 # update the session ID if needed, then set the session cookie
                 # in the response
 
-                if ( $self->context->has_session ) {
-                    my $session = $self->context->session;
-                    $engine->flush( session => $session )
-                      if $session->is_dirty;
+                if ( $app->has_session ) {
+                    my $session = $app->session;
+                    $session->is_dirty and $engine->flush( session => $session );
                     $engine->set_cookie_header(
                         response => $response,
                         session  => $session
                     );
                 }
-                elsif ( $self->context->has_destroyed_session ) {
-                    my $session = $self->context->destroyed_session;
+                elsif ( $app->has_destroyed_session ) {
+                    my $session = $app->destroyed_session;
                     $engine->set_cookie_header(
                         response  => $response,
                         session   => $session,
@@ -407,16 +539,6 @@ sub _init_hooks {
     );
 }
 
-sub _init_for_context {
-    my ($self) = @_;
-
-    return if !defined $self->context;
-    return if !defined $self->context->request;
-
-    $self->context->request->is_behind_proxy(1)
-      if $self->setting('behind_proxy');
-}
-
 sub supported_hooks {
     qw/
       core.app.before_request
@@ -432,66 +554,51 @@ sub supported_hooks {
 sub api_version {2}
 
 sub register_plugin {
-    my ( $self, $plugin ) = @_;
+    my $self   = shift;
+    my $plugin = shift;
+
     $self->log( core => "Registered $plugin");
+
     push @{ $self->plugins }, $plugin;
 }
 
 # This method overrides the default one from Role::ConfigReader
 sub settings {
-    my ($self) = @_;
+    my $self = shift;
     +{ %{ Dancer2->runner->config }, %{ $self->config } };
 }
 
+sub cleanup {
+    my $self = shift;
+    $self->clear_request;
+    $self->clear_response;
+    $self->clear_session;
+    $self->clear_destroyed_session;
+}
+
 sub engine {
-    my ( $self, $name ) = @_;
+    my $self = shift;
+    my $name = shift;
 
-    croak "Engine '$name' is not supported."
-        if !grep {$_ eq $name} @{ $self->supported_engines };
+    grep { $_ eq $name } @{ $self->supported_engines }
+        or croak "Engine '$name' is not supported.";
 
     my $attr_name = "${name}_engine";
     return $self->$attr_name;
 }
 
-sub session {
-    my ( $self, $key, $value ) = @_;
-
-    # shortcut reads if no session exists, so we don't
-    # instantiate sessions for no reason
-    if ( @_ == 2 ) {
-        return unless $self->context->has_session;
-    }
-
-    my $session = $self->context->session;
-    croak "No session available, a session engine needs to be set"
-      if !defined $session;
-
-    # return the session object if no key
-    return $session if @_ == 1;
-
-    # read if a key is provided
-    return $session->read($key) if @_ == 2;
-
-    # write to the session or delete if value is undef
-    if ( defined $value ) {
-        $session->write( $key => $value );
-    }
-    else {
-        $session->delete($key);
-    }
-}
-
 sub template {
-    my ($self) = shift;
-    my $template = $self->template_engine;
+    my $self = shift;
 
-    my $content = $template->process(@_);
+    my $template = $self->template_engine;
+    $template->set_settings( $self->config );
 
-    return $content;
+    # return content
+    return $template->process( $self->request, @_ );
 }
 
 sub hook_candidates {
-    my ($self) = @_;
+    my $self = shift;
 
     my @engines;
     for my $e ( @{ $self->supported_engines } ) {
@@ -503,8 +610,8 @@ sub hook_candidates {
     my @route_handlers;
     for my $handler ( @{ $self->route_handlers } ) {
         my $handler_code = $handler->{handler};
-        push @route_handlers, $handler_code
-          if blessed($handler_code) && $handler_code->can('supported_hooks');
+        blessed $handler_code and $handler_code->can('supported_hooks')
+            and push @route_handlers, $handler_code;
     }
 
     # TODO : get the list of all plugins registered
@@ -514,70 +621,64 @@ sub hook_candidates {
 }
 
 sub all_hook_aliases {
-    my ($self) = @_;
+    my $self = shift;
 
     my $aliases = $self->hook_aliases;
     for my $plugin ( @{ $self->plugins } ) {
-        $aliases = { %{$aliases}, %{ $plugin->hook_aliases }, };
+        $aliases = { %{$aliases}, %{ $plugin->hook_aliases } };
     }
 
     return $aliases;
 }
 
 sub mime_type {
-    my ($self) = @_;
+    my $self   = shift;
     my $runner = Dancer2->runner;
 
-    if ( exists( $self->config->{default_mime_type} ) ) {
-        $runner->mime_type->default( $self->config->{default_mime_type} );
-    }
-    else {
-        $runner->mime_type->reset_default;
-    }
+    exists $self->config->{default_mime_type}
+        ? $runner->mime_type->default( $self->config->{default_mime_type} )
+        : $runner->mime_type->reset_default;
+
     $runner->mime_type;
 }
 
 sub log {
-    my ($self, $level, @args)  = @_;
+    my $self  = shift;
+    my $level = shift;
 
     my $logger = $self->logger_engine
       or croak "No logger defined";
 
-    $logger->$level(@args);
+    $logger->$level(@_);
 }
 
-# XXX I think this should live on the context or response - but
-# we don't currently have backwards links - weak_ref should make
-# those completely doable.
-#   -- mst
-
 sub send_file {
-    my ( $self, $path, %options ) = @_;
-    my $env = $self->context->env;
+    my $self    = shift;
+    my $path    = shift;
+    my %options = @_;
+
+    my $env = $self->request->env;
 
     ( $options{'streaming'} && !$env->{'psgi.streaming'} )
       and croak "Streaming is not supported on this server.";
 
     ( exists $options{'content_type'} )
-      and $self->context->response->header(
+      and $self->response->header(
         'Content-Type' => $options{content_type} );
 
     ( exists $options{filename} )
-      and $self->context->response->header( 'Content-Disposition' =>
+      and $self->response->header( 'Content-Disposition' =>
           "attachment; filename=\"$options{filename}\"" );
 
     # if we're given a SCALAR reference, we're going to send the data
     # pretending it's a file (on-the-fly file sending)
-    ( ref($path) eq 'SCALAR' )
-      and return $$path;
+    ref $path eq 'SCALAR' and return $$path;
 
-    my $conf = {};
-    $conf->{app} = $self;
     my $file_handler = Dancer2::Core::Factory->create(
         Handler => 'File',
-        %$conf,
+        app     => $self,
         postponed_hooks => $self->postponed_hooks,
-        public_dir => ( $options{system_path} ? File::Spec->rootdir : undef ),
+        ( public_dir => File::Spec->rootdir )x!! $options{system_path},
     );
 
     # List shouldn't be too long, so we use 'grep' instead of 'first'
@@ -588,37 +689,37 @@ sub send_file {
         }
     }
 
-    $self->context->request->path_info($path);
-    $file_handler->code( $self->prefix )->( $self->context ); # slurp file
-    $self->context->with_return->( $self->context->response ) if $self->context->has_with_return;
+    $self->request->set_path_info($path);
+    $file_handler->code( $self->prefix )->( $self ); # slurp file
+    $self->has_with_return and $self->with_return->( $self->response );
 
     # TODO Streaming support
 }
 
 
 sub BUILD {
-    my ($self) = @_;
+    my $self = shift;
     $self->init_route_handlers();
     $self->_init_hooks();
 }
 
 sub finish {
-    my ($self) = @_;
+    my $self = shift;
     $self->register_route_handlers;
     $self->compile_hooks;
 }
 
 sub init_route_handlers {
-    my ($self) = @_;
+    my $self = shift;
 
     my $handlers_config = $self->config->{route_handlers};
     for my $handler_data ( @{$handlers_config} ) {
         my ($handler_name, $config) = @{$handler_data};
         $config = {} if !ref($config);
-        $config->{app} = $self;
 
         my $handler = Dancer2::Core::Factory->create(
             Handler => $handler_name,
+            app     => $self,
             %$config,
             postponed_hooks => $self->postponed_hooks,
         );
@@ -631,7 +732,7 @@ sub init_route_handlers {
 }
 
 sub register_route_handlers {
-    my ($self) = @_;
+    my $self = shift;
     for my $handler ( @{$self->route_handlers} ) {
         my $handler_code = $handler->{handler};
         $handler_code->register($self);
@@ -645,15 +746,15 @@ sub compile_hooks {
         my $compiled_hooks = [];
         for my $hook ( @{ $self->hooks->{$position} } ) {
             my $compiled = sub {
-
                 # don't run the filter if halt has been used
-                return
-                  if ( $self->context && $self->context->response->is_halted );
-
-                eval { $hook->(@_) };
-
-                # TODO : do something with exception there
-                croak "Exception caught in '$position' filter: $@" if $@;
+                $self->has_response && $self->response->is_halted
+                    and return;
+
+                eval  { $hook->(@_); 1; }
+                or do {
+                    $self->log('error', "Exception caught in '$position' filter: $@");
+                    croak "Exception caught in '$position' filter: $@";
+                };
             };
 
             push @{$compiled_hooks}, $compiled;
@@ -663,8 +764,11 @@ sub compile_hooks {
 }
 
 sub lexical_prefix {
-    my ( $self, $prefix, $cb ) = @_;
-    undef $prefix if $prefix eq '/';
+    my $self   = shift;
+    my $prefix = shift;
+    my $cb     = shift;
+
+    $prefix eq '/' and undef $prefix;
 
     # save the app prefix
     my $app_prefix = $self->prefix;
@@ -675,7 +779,7 @@ sub lexical_prefix {
       . ( defined $prefix     ? $prefix     : '' );
 
     # if the new prefix is empty, it's a meaningless prefix, just ignore it
-    $self->prefix($new_prefix) if length $new_prefix;
+    length $new_prefix and $self->prefix($new_prefix);
 
     eval { $cb->() };
     my $e = $@;
@@ -683,15 +787,15 @@ sub lexical_prefix {
     # restore app prefix
     $self->prefix($app_prefix);
 
-    croak "Unable to run the callback for prefix '$prefix': $e"
-      if $e;
+    $e and croak "Unable to run the callback for prefix '$prefix': $e";
 }
 
 sub add_route {
-    my ( $self, %route_attrs ) = @_;
+    my $self        = shift;
+    my %route_attrs = @_;
 
     my $route =
-      Dancer2::Core::Route->new( %route_attrs, prefix => $self->prefix, );
+      Dancer2::Core::Route->new( %route_attrs, prefix => $self->prefix );
 
     my $method = $route->method;
 
@@ -699,21 +803,150 @@ sub add_route {
 }
 
 sub route_exists {
-    my ( $self, $route ) = @_;
+    my $self  = shift;
+    my $route = shift;
 
     my $routes = $self->routes->{ $route->method };
 
     foreach my $existing_route (@$routes) {
-        return 1 if $existing_route->spec_route eq $route->spec_route;
+        $existing_route->spec_route eq $route->spec_route
+            and return 1;
     }
     return 0;
 }
 
 sub routes_regexps_for {
-    my ( $self, $method ) = @_;
+    my $self   = shift;
+    my $method = shift;
+
     return [ map { $_->regexp } @{ $self->routes->{$method} } ];
 }
 
+sub cookie {
+    my $self = shift;
+
+    @_ == 1 and return $self->request->cookies->{ $_[0] };
+
+    # writer
+    my ( $name, $value, %options ) = @_;
+    my $c =
+      Dancer2::Core::Cookie->new( name => $name, value => $value, %options );
+    $self->response->push_header( 'Set-Cookie' => $c->to_header );
+}
+
+
+sub redirect {
+    my $self        = shift;
+    my $destination = shift;
+    my $status      = shift;
+
+    # RFC 2616 requires an absolute URI with a scheme,
+    # turn the URI into that if it needs it
+
+    # Scheme grammar as defined in RFC 2396
+    #  scheme = alpha *( alpha | digit | "+" | "-" | "." )
+    my $scheme_re = qr{ [a-z][a-z0-9\+\-\.]* }ix;
+    if ( $destination !~ m{^ $scheme_re : }x ) {
+        $destination = $self->request->uri_for( $destination, {}, 1 );
+    }
+
+    $self->response->redirect( $destination, $status );
+
+    # Short circuit any remaining before hook / route code
+    # ('pass' and after hooks are still processed)
+    $self->has_with_return
+        and $self->with_return->($self->response);
+}
+
+
+sub halt {
+   my $self = shift;
+   $self->response->halt;
+
+   # Short citcuit any remaining hook/route code
+   $self->has_with_return
+       and $self->with_return->($self->response);
+}
+
+
+sub pass {
+   my $self = shift;
+   $self->response->pass;
+
+   # Short citcuit any remaining hook/route code
+   $self->has_with_return
+       and $self->with_return->($self->response);
+}
+
+
+sub forward {
+    my $self    = shift;
+    my $url     = shift;
+    my $params  = shift;
+    my $options = shift;
+
+    my $new_request = $self->make_forward_to( $url, $params, $options );
+
+    $self->has_with_return
+        and $self->with_return->($new_request);
+
+    # nothing else will run after this
+}
+
+# Create a new request which is a clone of the current one, apart
+# from the path location, which points instead to the new location
+# TODO this could be written in a more clean manner with a clone mechanism
+sub make_forward_to {
+    my $self    = shift;
+    my $url     = shift;
+    my $params  = shift;
+    my $options = shift;
+
+    my $request = $self->request;
+
+    # we clone the env to make sure we don't alter the existing one in $self
+    my $env = { %{ $request->env } };
+
+    $env->{PATH_INFO} = $url;
+
+    my $new_request = Dancer2::Core::Request->new( env => $env, body_is_parsed => 1 );
+    my $new_params = _merge_params( scalar( $request->params ), $params || {} );
+
+    exists $options->{method} and
+        $new_request->method( $options->{method} );
+
+    # Copy params (these are already decoded)
+    $new_request->{_params}       = $new_params;
+    $new_request->{_body_params}  = $request->{_body_params};
+    $new_request->{_query_params} = $request->{_query_params};
+    $new_request->{_route_params} = $request->{_route_params};
+    $new_request->{body}          = $request->body;
+    $new_request->{headers}       = $request->headers;
+
+    # If a session object was created during processing of the original request
+    # i.e. a session object exists but no cookie existed
+    # add a cookie so the dispatcher can assign the session to the appropriate app
+    my $engine = $self->engine('session');
+    $engine && $self->_has_session or return $new_request;
+    my $name = $engine->cookie_name;
+    exists $new_request->cookies->{$name} and return $new_request;
+    $new_request->cookies->{$name} =
+        Dancer2::Core::Cookie->new( name => $name, value => $self->session->id );
+    return $new_request;
+}
+
+sub _merge_params {
+    my $params = shift;
+    my $to_add = shift;
+
+    for my $key ( keys %$to_add ) {
+        $params->{$key} = $to_add->{$key};
+    }
+    return $params;
+}
+
+sub app { shift }
+
 1;
 
 __END__
@@ -726,7 +959,7 @@ Dancer2::Core::App - encapsulation of Dancer2 packages
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -742,6 +975,17 @@ that package, thanks to that encapsulation.
 
 =head1 ATTRIBUTES
 
+=head2 with_return
+
+Used to cache the coderef from L<Return::MultiLevel> within the dispatcher.
+
+=head2 destroyed_session
+
+We cache a destroyed session here; once this is set we must not attempt to
+retrieve the session from the cookie in the request.  If no new session is
+created, this is set (with expiration) as a cookie to force the browser to
+expire the cookie.
+
 =head2 plugins
 
 =head2 runner_config
@@ -750,6 +994,49 @@ that package, thanks to that encapsulation.
 
 =head1 METHODS
 
+=head2 has_session
+
+Returns true if session engine has been defined and if either a session
+object has been instantiated or if a session cookie was found and not
+subsequently invalidated.
+
+=head2 destroy_session
+
+Destroys the current session and ensures any subsequent session is created
+from scratch and not from the request session cookie
+
+=head2 redirect($destination, $status)
+
+Sets a redirect in the response object.  If $destination is not an absolute URI, then it will
+be made into an absolute URI, relative to the URI in the request.
+
+=head2 halt
+
+Flag the response object as 'halted'.
+
+If called during request dispatch, immediatly returns the response
+to the dispatcher and after hooks will not be run.
+
+=head2 pass
+
+Flag the response object as 'passed'.
+
+If called during request dispatch, immediatly returns the response
+to the dispatcher.
+
+=head2 forward
+
+Create a new request which is a clone of the current one, apart
+from the path location, which points instead to the new location.
+This is used internally to chain requests using the forward keyword.
+
+Note that the new location should be a hash reference. Only one key is
+required, the C<to_url>, that should point to the URL that forward
+will use. Optional values are the key C<params> to a hash of
+parameters to be added to the current request parameters, and the key
+C<options> that points to a hash of options about the redirect (for
+instance, C<method> pointing to a new request method).
+
 =head2 register_plugin
 
 =head2 lexical_prefix
@@ -791,6 +1078,32 @@ Sugar for getting the ordered list of all registered route regexps by method.
 
 Returns an ArrayRef with the results.
 
+=head2 app
+
+Returns itself. This is simply available as a shim to help transition from
+a previous version in which hooks were sent a context object (originally
+C<Dancer2::Core::Context>) which has since been removed.
+
+    # before
+    hook before => sub {
+        my $ctx = shift;
+        my $app = $ctx->app;
+    };
+
+    # after
+    hook before => sub {
+        my $app = shift;
+    };
+
+This meant that C<< $app->app >> would fail, so this method has been provided
+to make it work.
+
+    # now
+    hook before => sub {
+        my $WannaBeCtx = shift;
+        my $app        = $WannaBeContext->app; # works
+    };
+
 =head1 AUTHOR
 
 Dancer Core Developers
@@ -1,347 +0,0 @@
-package Dancer2::Core::Context;
-$Dancer2::Core::Context::VERSION = '0.141000';
-# ABSTRACT: handles everything proper to a request's context.
-
-use Moo;
-use URI::Escape;
-use Carp 'croak';
-
-use Dancer2::Core::Types;
-use Dancer2::Core::Request;
-use Dancer2::Core::Response;
-use Dancer2::Core::Cookie;
-
-
-
-has app => (
-    is        => 'rw',
-    isa       => InstanceOf ['Dancer2::Core::App'],
-    weak_ref  => 1,
-    predicate => 1,
-);
-
-
-# the PSGI-env to use for building the request to process
-# this is the only mandatory argument to a context
-has env => (
-    is       => 'ro',
-    required => 1,
-    isa      => HashRef,
-);
-
-
-# the incoming request
-has request => (
-    is      => 'rw',
-    lazy    => 1,
-    builder => '_build_request',
-    isa     => InstanceOf ['Dancer2::Core::Request'],
-);
-
-sub _build_request {
-    my ($self) = @_;
-
-    # If we have an app, get the serialization engine
-    my $engine = $self->app->engine('serializer')
-        if $self->has_app;
-
-    my $req = Dancer2::Core::Request->new( env => $self->env,
-        $engine ? ( serializer => $engine ) : (),
-    );
-
-    # Log deserialization errors
-    $self->app->log( core => "Failed to deserialize the request : "
-        . $engine->error ) if ( $engine && $engine->has_error );
-
-    return $req;
-}
-
-# a buffer for per-request variables
-has buffer => (
-    is      => 'rw',
-    isa     => HashRef,
-    default => sub { {} },
-);
-
-
-sub vars { shift->buffer }
-
-
-sub var {
-    my $self = shift;
-    @_ == 2
-      ? $self->buffer->{ $_[0] } = $_[1]
-      : $self->buffer->{ $_[0] };
-}
-
-
-# a set of changes to apply to the response
-# that HashRef will should be passed as attributes to a response object
-has response => (
-    is      => 'rw',
-    isa     => InstanceOf ['Dancer2::Core::Response'],
-    lazy    => 1,
-    default => sub {
-        my $self = shift;
-
-        my $engine = $self->has_app
-            ? $self->app->engine('serializer')
-            : undef;
-
-        return Dancer2::Core::Response->new(
-            $engine ? (serializer => $engine) : ()
-        );
-    },
-);
-
-
-sub cookies { shift->request->cookies(@_) }
-
-
-sub cookie {
-    my $self = shift;
-
-    return $self->request->cookies->{ $_[0] } if @_ == 1;
-
-    # writer
-    my ( $name, $value, %options ) = @_;
-    my $c =
-      Dancer2::Core::Cookie->new( name => $name, value => $value, %options );
-    $self->response->push_header( 'Set-Cookie' => $c->to_header );
-}
-
-
-sub redirect {
-    my ( $self, $destination, $status ) = @_;
-
-    # RFC 2616 requires an absolute URI with a scheme,
-    # turn the URI into that if it needs it
-
-    # Scheme grammar as defined in RFC 2396
-    #  scheme = alpha *( alpha | digit | "+" | "-" | "." )
-    my $scheme_re = qr{ [a-z][a-z0-9\+\-\.]* }ix;
-    if ( $destination !~ m{^ $scheme_re : }x ) {
-        $destination = $self->request->uri_for( $destination, {}, 1 );
-    }
-
-    $self->response->redirect( $destination, $status );
-    # Short circuit any remaining before hook / route code
-    # ('pass' and after hooks are still processed)
-    $self->with_return->($self->response) if $self->has_with_return;
-}
-
-
-sub halt {
-   my ($self) = @_;
-   $self->response->halt;
-   # Short citcuit any remaining hook/route code
-   $self->with_return->($self->response) if $self->has_with_return;
-}
-
-
-sub pass {
-   my ($self) = @_;
-   $self->response->pass;
-   # Short citcuit any remaining hook/route code
-   $self->with_return->($self->response) if $self->has_with_return;
-}
-
-
-has session => (
-    is        => 'rw',
-    isa       => Session,
-    lazy      => 1,
-    builder   => '_build_session',
-    predicate => '_has_session',
-    clearer   => 1,
-);
-
-sub _build_session {
-    my ($self) = @_;
-    my $session;
-
-    # Find the session engine
-    my $engine = $self->app->engine('session');
-
-    # find the session cookie if any
-    if ( !$self->destroyed_session ) {
-        my $session_id;
-        my $session_cookie = $self->cookie( $engine->cookie_name );
-        if ( defined $session_cookie ) {
-            $session_id = $session_cookie->value;
-        }
-
-        # if we have a session cookie, try to retrieve the session
-        if ( defined $session_id ) {
-            eval { $session = $engine->retrieve( id => $session_id ) };
-            croak "Fail to retrieve session: $@"
-              if $@ && $@ !~ /Unable to retrieve session/;
-        }
-    }
-
-    # create the session if none retrieved
-    return $session ||= $engine->create();
-}
-
-
-sub has_session {
-    my ($self) = @_;
-
-    my $engine = $self->app->engine('session');
-
-    return $self->_has_session
-      || ( $self->cookie( $engine->cookie_name )
-        && !$self->has_destroyed_session );
-}
-
-
-has destroyed_session => (
-    is        => 'rw',
-    isa       => InstanceOf ['Dancer2::Core::Session'],
-    predicate => 1,
-);
-
-
-sub destroy_session {
-    my ($self) = @_;
-
-    # Find the session engine
-    my $engine = $self->app->engine('session');
-
-    # Expire session, set the expired cookie and destroy the session
-    # Setting the cookie ensures client gets an expired cookie unless
-    # a new session is created and supercedes it
-    my $session = $self->session;
-    $session->expires(-86400);    # yesterday
-    $engine->destroy( id => $session->id );
-
-    # Clear session in context and invalidate session cookie in request
-    $self->destroyed_session($session);
-    $self->clear_session;
-
-    return;
-}
-
-
-
-has with_return => (
-    is        => 'rw',
-    predicate => 1,
-    clearer   => 'clear_with_response',
-);
-
-1;
-
-__END__
-
-=pod
-
-=head1 NAME
-
-Dancer2::Core::Context - handles everything proper to a request's context.
-
-=head1 VERSION
-
-version 0.141000
-
-=head1 ATTRIBUTES
-
-=head2 app
-
-Reference to the L<Dancer2::Core::App> object for the current application.
-
-=head2 env
-
-Read-only accessor to a PSGI environment hash.
-
-=head2 request
-
-A L<Dancer2::Core::Request> object, built from the PSGI environment variable for this request.
-
-=head2 response
-
-A L<Dancer2::Core::Response> object, used to set content, headers and HTTP status codes.
-
-=head2 session
-
-Handle for the current session object, if any
-
-=head2 destroyed_session
-
-We cache a destroyed session here; once this is set we must not attempt to
-retrieve the session from the cookie in the request.  If no new session is
-created, this is set (with expiration) as a cookie to force the browser to
-expire the cookie.
-
-=head2 with_return
-
-Used to cache the coderef from L<Return::MultiLevel> within the dispatcher.
-
-=head1 METHODS
-
-=head2 vars
-
-Returns a hashref of all per-request variables stored in this object.
-
-=head2 var
-
-By-name interface to variables stored in this context object.
-
-  my $stored = $context->var('some_variable');
-
-returns the value of 'some_variable', while
-
-  $context->var('some_variable' => 'value');
-
-will set it.
-
-=head2 cookies
-
-Shortcut that dispatches to L<Dancer2::Core::Request>'s cookies method.
-
-=head2 cookie
-
-Get a cookie from the L<request> object, or set one in the L<response> object.
-
-=head2 redirect($destination, $status)
-
-Sets a redirect in the response object.  If $destination is not an absolute URI, then it will
-be made into an absolute URI, relative to the URI in the request.
-
-=head2 halt
-
-Flag the response object as 'halted'.
-
-If called during request dispatch, immediatly returns the response
-to the dispatcher and after hooks will not be run.
-
-=head2 pass
-
-Flag the response object as 'passed'.
-
-If called during request dispatch, immediatly returns the response
-to the dispatcher.
-
-=head2 has_session
-
-Returns true if session engine has been defined and if either a session object
-has been instantiated in the context or if a session cookie was found and not
-subsequently invalidated.
-
-=head2 destroy_session
-
-Destroys the current session and ensures any subsequent session is created
-from scratch and not from the request session cookie
-
-=head1 AUTHOR
-
-Dancer Core Developers
-
-=head1 COPYRIGHT AND LICENSE
-
-This software is copyright (c) 2014 by Alexis Sukrieh.
-
-This is free software; you can redistribute it and/or modify it under
-the same terms as the Perl 5 programming language system itself.
-
-=cut
@@ -1,6 +1,6 @@
 package Dancer2::Core::Cookie;
 # ABSTRACT: A cookie representing class
-$Dancer2::Core::Cookie::VERSION = '0.141000';
+$Dancer2::Core::Cookie::VERSION = '0.150000';
 use Moo;
 use URI::Escape;
 use Dancer2::Core::Types;
@@ -116,7 +116,7 @@ Dancer2::Core::Cookie - A cookie representing class
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 SYNOPSIS
 
@@ -1,7 +1,7 @@
 # ABSTRACT: Dancer2's Domain Specific Language (DSL)
 
 package Dancer2::Core::DSL;
-$Dancer2::Core::DSL::VERSION = '0.141000';
+$Dancer2::Core::DSL::VERSION = '0.150000';
 use Moo;
 use Carp;
 use Class::Load 'load_class';
@@ -55,6 +55,7 @@ sub dsl_keywords {
         path                 => { is_global => 1 },
         post                 => { is_global => 1 },
         prefix               => { is_global => 1 },
+        psgi_app             => { is_global => 1 },
         push_header          => { is_global => 0 },
         put                  => { is_global => 1 },
         redirect             => { is_global => 0 },
@@ -100,7 +101,6 @@ sub false {0}
 sub dirname { shift and Dancer2::FileUtils::dirname(@_) }
 sub path    { shift and Dancer2::FileUtils::path(@_) }
 
-
 sub config { shift->app->settings }
 
 sub engine { shift->app->engine(@_) }
@@ -113,7 +113,35 @@ sub set { shift->setting(@_) }
 
 sub template { shift->app->template(@_) }
 
-sub session { shift->app->session(@_) }
+sub session {
+    my ( $self, $key, $value ) = @_;
+
+    # shortcut reads if no session exists, so we don't
+    # instantiate sessions for no reason
+    if ( @_ == 2 ) {
+        return unless $self->app->has_session;
+    }
+
+    my $session = $self->app->session
+        || croak "No session available, a session engine needs to be set";
+
+    $self->app->setup_session;
+
+    # return the session object if no key
+    @_ == 1 and return $session;
+
+    # read if a key is provided
+    @_ == 2 and return $session->read($key);
+
+
+    # write to the session or delete if value is undef
+    if ( defined $value ) {
+        $session->write( $key => $value );
+    }
+    else {
+        $session->delete($key);
+    }
+}
 
 sub send_file { shift->app->send_file(@_) }
 
@@ -134,7 +162,7 @@ sub prefix {
       : $app->lexical_prefix(@_);
 }
 
-sub halt { shift->context->halt }
+sub halt { shift->app->halt }
 
 sub _route_parameters {
     my ( $regexp, $code, $options );
@@ -248,6 +276,12 @@ sub start { shift->runner->start }
 
 sub dance { shift->start(@_) }
 
+sub psgi_app {
+    my $self = shift;
+
+    $self->runner->psgi_app( [ $self->app ] );
+}
+
 #
 # Response alterations
 #
@@ -257,17 +291,20 @@ sub push_header  { shift->response->push_header(@_) }
 sub header       { shift->response->header(@_) }
 sub headers      { shift->response->header(@_) }
 sub content_type { shift->response->content_type(@_) }
-sub pass         { shift->context->pass }
+sub pass         { shift->app->pass }
 
 #
 # Route handler helpers
 #
 
-sub context { shift->app->context }
+sub context {
+    carp "DEPRECATED: please use the 'app' keyword instead of 'context'";
+    shift->app;
+}
 
-sub request { shift->context->request }
+sub request { shift->app->request }
 
-sub response { shift->context->response }
+sub response { shift->app->response }
 
 sub upload { shift->request->upload(@_) }
 
@@ -281,17 +318,15 @@ sub params { shift->request->params(@_) }
 
 sub param { shift->request->param(@_) }
 
-sub redirect { shift->context->redirect(@_) }
+sub redirect { shift->app->redirect(@_) }
 
-sub forward {
-    my $self = shift;
-    $self->request->forward($self->context, @_);
-}
+sub forward { shift->app->forward(@_) }
 
-sub vars { shift->context->vars }
-sub var  { shift->context->var(@_) }
+sub vars { shift->request->vars }
+sub var  { shift->request->var(@_) }
 
-sub cookies { shift->context->cookies }
+sub cookies { shift->request->cookies }
+sub cookie { shift->app->cookie(@_) }
 
 sub mime {
     my $self = shift;
@@ -305,22 +340,20 @@ sub mime {
     }
 }
 
-sub cookie { shift->context->cookie(@_) }
-
 sub send_error {
     my ( $self, $message, $status ) = @_;
 
     my $serializer = $self->app->engine('serializer');
     my $x = Dancer2::Core::Error->new(
-        message => $message,
-        context => $self->context,
-        ( status => $status ) x !!$status,
-        ( serializer => $serializer ) x !!$serializer,
+          message    => $message,
+          app        => $self->app,
+        ( status     => $status     )x!! $status,
+        ( serializer => $serializer )x!! $serializer,
     )->throw;
 
     # return if there is a with_return coderef
-    $self->context->with_return->($x)
-      if $self->context->has_with_return;
+    $self->app->with_return->($x)
+      if $self->app->has_with_return;
 
     return $x;
 }
@@ -380,7 +413,7 @@ Dancer2::Core::DSL - Dancer2's Domain Specific Language (DSL)
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 FUNCTIONS
 
@@ -1,116 +1,167 @@
 package Dancer2::Core::Dispatcher;
 # ABSTRACT: Class for dispatching request to the appropriate route handler
-$Dancer2::Core::Dispatcher::VERSION = '0.141000';
+$Dancer2::Core::Dispatcher::VERSION = '0.150000';
 use Moo;
 use Encode;
+use Safe::Isa;
+use Return::MultiLevel qw(with_return);
 
 use Dancer2::Core::Types;
-use Dancer2::Core::Context;
+use Dancer2::Core::Request;
 use Dancer2::Core::Response;
 
-use Return::MultiLevel qw(with_return);
-
 has apps => (
     is      => 'rw',
     isa     => ArrayRef,
     default => sub { [] },
 );
 
-has default_content_type => (
-    is      => 'ro',
-    isa     => Str,
-    default => sub {'text/html'},
-);
-
 # take the list of applications and an $env hash, return a Response object.
 sub dispatch {
-    my ( $self, $env, $request, $curr_context ) = @_;
-
-#    warn "dispatching ".$env->{PATH_INFO}
-#       . " with ".join(", ", map { $_->name } @{$self->apps });
+    my ( $self, $env, $request ) = @_;
 
-    # Initialize a context for the current request
-    # Once per dispatching! We should not create one context for each app or
-    # we're going to parse the request body multiple times
-    my $context = Dancer2::Core::Context->new(
-        env => $env,
-        ( request => $request ) x !! $request,
-    );
+    my %preexisting_sessions;
 
-    if ( $curr_context && $curr_context->has_session ) {
-        $context->session( $curr_context->session );
-    }
+    # warn "dispatching ".$env->{PATH_INFO}
+    #    . " with ".join(", ", map { $_->name } @{$self->apps });
 
+DISPATCH:
+    while (1) {
     foreach my $app ( @{ $self->apps } ) {
-
         # warn "walking through routes of ".$app->name;
 
-        # set the current app in the context and context in the app..
-        $context->app($app);
-        $app->context($context);
+        # create request if we didn't get any
+        $request ||= $self->build_request( $env, $app );
 
-        my $http_method = lc $context->request->method;
-        my $path_info   = $context->request->path_info;
+        my $cname       = $app->engine('session')->cookie_name;
+        my $http_method = lc $request->method;
+        my $path_info   =    $request->path_info;
 
         $app->log( core => "looking for $http_method $path_info" );
 
       ROUTE:
         foreach my $route ( @{ $app->routes->{$http_method} } ) {
-
             # warn "testing route ".$route->regexp;
 
             # TODO store in route cache
 
             # go to the next route if no match
-            my $match = $route->match( $context->request )
-              or next ROUTE;
+            my $match = $route->match($request)
+                or next ROUTE;
+
+            $request->_set_route_params($match);
+            $app->set_request($request);
+            # Add session to app *if* we have a session and the request
+            # has the appropriate cookie header for _this_ app.
 
-            $context->request->_set_route_params($match);
+            $preexisting_sessions{$cname}
+                and $app->set_session( $preexisting_sessions{$cname} );
 
             my $response = with_return {
                 my ($return) = @_;
-                # stash the multilevel return coderef in the context
-                $context->with_return($return) if ! $context->has_with_return;
-                return $self->_dispatch_route($route, $context);
+
+                # stash the multilevel return coderef in the app
+                $app->has_with_return
+                    or $app->set_with_return($return);
+
+                return $self->_dispatch_route($route, $app);
             };
+
             # Ensure we clear the with_return handler
-            $context->clear_with_response;
+            $app->clear_with_return;
+
+            # handle forward requests
+            if ( ref $response eq 'Dancer2::Core::Request' ) {
+                # this is actually a request, not response
+                $request = $response;
+
+                # Get the session object from the app before we clean up
+                # the request context, so we can propogate this to the
+                # next dispatch cycle (if required).
+                $app->_has_session
+                    and $preexisting_sessions{$cname} = $app->session;
+
+                $app->cleanup;
+
+                next DISPATCH;
+            }
+
+            # from here we assume the response is a Dancer2::Core::Response
 
             # No further processing of this response if its halted
             if ( $response->is_halted ) {
-                $app->context(undef);
+                $app->cleanup;
                 return $response;
             }
 
             # pass the baton if the response says so...
             if ( $response->has_passed ) {
-
                 ## A previous route might have used splat, failed
                 ## this needs to be cleaned from the request.
-                if (exists $context->request->{_params}{splat}) {
-                    delete $context->request->{_params}{splat};
-                }
+                exists $request->{_params}{splat}
+                    and delete $request->{_params}{splat};
 
-                $response->has_passed(0);    # clear for the next round
+                $response->has_passed(0); # clear for the next round
                 next ROUTE;
             }
 
             $app->execute_hook( 'core.app.after_request', $response );
-            $app->context(undef);
+            $app->cleanup;
+
             return $response;
         }
+
+        # Get current session object to allow propogation to next app.
+        $app->_has_session
+            and $preexisting_sessions{$cname} = $app->session;
+        $app->cleanup;
     }
 
-    return $self->response_not_found($context);
+        last;
+    } # while
+
+    # Assume there was at least one app to the request object was instantiated..
+    return $self->response_not_found( $request );
+}
+
+# the dispatcher can build requests now :)
+sub build_request {
+    my ( $self, $env, $app ) = @_;
+
+    # If we have an app, send the serialization engine
+    my $engine  = $app->engine('serializer');
+    my $request = Dancer2::Core::Request->new(
+          env             => $env,
+          is_behind_proxy => Dancer2->runner->config->{'behind_proxy'} || 0,
+        ( serializer      => $engine )x!! $engine,
+    );
+
+    # if it's a mutable serializer, we add more headers
+    # so it can be set properly
+    # I don't like doing this... -- Sawyer
+    if ( $engine->$_isa('Dancer2::Serializer::Mutable') ) {
+        $engine->{'extra_headers'} = {
+            map +( $_ => $request->$_ ), qw<content_type accept accept_type>
+        }
+    }
+
+    # Log deserialization errors
+    if ($engine) {
+        $engine->has_error and $app->log(
+            core => "Failed to deserialize the request : " .
+                    $engine->error
+        );
+    }
+
+    return $request;
 }
 
 # Call any before hooks then the matched route.
 sub _dispatch_route {
-    my ($self, $route, $context) = @_;
-    my $app = $context->app;
+    my ($self, $route, $app) = @_;
 
-    $app->execute_hook( 'core.app.before_request', $context );
-    my $response = $context->response;
+    $app->execute_hook( 'core.app.before_request', $app );
+    my $response = $app->response;
 
     my $content;
     if ( $response->is_halted ) {
@@ -118,33 +169,28 @@ sub _dispatch_route {
         $content = $response->content;
     }
     else {
-        $content = eval { $route->execute($context) };
+        $content = eval { $route->execute($app) };
         my $error = $@;
         if ($error) {
             $app->log( error => "Route exception: $error" );
-            $app->execute_hook(
-                'core.app.route_exception', $context, $error);
-            return $self->response_internal_error( $context, $error );
+            $app->execute_hook( 'core.app.route_exception', $app, $error );
+            return $self->response_internal_error( $app, $error );
         }
     }
 
-    # routes should use 'content_type' as default, or 'text/html'
-    # (Content-Type header needs to be set to encode content below..)
-    if ( !$response->header('Content-type') ) {
-        if ( exists( $app->config->{content_type} ) ) {
-            $response->header(
-                'Content-Type' => $app->config->{content_type} );
-        }
-        else {
-            $response->header(
-                'Content-Type' => $self->default_content_type );
-        }
-    }
     if ( ref $content eq 'Dancer2::Core::Response' ) {
-        $response = $context->response($content);
+        $response = $app->set_response($content);
     }
-    else {
-        $response->content( defined $content ? $content : '' );
+    elsif ( defined $content ) {
+        # The response object has no back references to the content or app
+        # Update the default_content_type of the response if any value set in
+        # config so it can be applied when the response is encoded/returned.
+        if ( exists $app->config->{content_type}
+          && $app->config->{content_type} ) {
+            $response->default_content_type($app->config->{content_type});
+        }
+
+        $response->content($content);
         $response->encode_content;
     }
 
@@ -152,41 +198,32 @@ sub _dispatch_route {
 }
 
 sub response_internal_error {
-    my ( $self, $context, $error ) = @_;
+    my ( $self, $app, $error ) = @_;
 
     # warn "got error: $error";
 
     return Dancer2::Core::Error->new(
-        context      => $context,
-        status       => 500,
-        exception    => $error,
+        app       => $app,
+        status    => 500,
+        exception => $error,
     )->throw;
 }
 
-# if we support 5.10.0 and up, we can change that
-# for a 'state'
-my $not_found_app;
-
 sub response_not_found {
-    my ( $self, $context ) = @_;
-
-    $not_found_app ||= Dancer2::Core::App->new(
-        name            => 'file_not_found',
-        environment     => Dancer2->runner->environment,
-        location        => Dancer2->runner->location,
-        runner_config   => Dancer2->runner->config,
-        postponed_hooks => Dancer2->runner->postponed_hooks,
-        api_version     => 2,
-    );
+    my ( $self, $request ) = @_;
 
-    $context->app($not_found_app);
-    $not_found_app->context($context);
+    # Use first defined app (for now)
+    my $app = $self->apps->[0];
+    $app->set_request($request);
 
-    return Dancer2::Core::Error->new(
+    my $response = Dancer2::Core::Error->new(
+        app    => $app,
         status  => 404,
-        context => $context,
-        message => $context->request->path,
+        message => $request->path,
     )->throw;
+
+    $app->cleanup;
+    return $response;
 }
 
 1;
@@ -201,7 +238,7 @@ Dancer2::Core::Dispatcher - Class for dispatching request to the appropriate rou
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 SYNOPSIS
 
@@ -214,10 +251,10 @@ version 0.141000
     my $resp = $dispatcher->dispatch($env)->to_psgi;
 
     # Capture internal error of a response (if any) after a dispatch
-    $dispatcher->response_internal_error($context, $error);
+    $dispatcher->response_internal_error($app, $error);
 
     # Capture response not found for an application the after dispatch
-    $dispatcher->response_not_found($context);
+    $dispatcher->response_not_found($env);
 
 =head1 ATTRIBUTES
 
@@ -236,7 +273,7 @@ request. This attribute is read-only.
 
 The C<dispatch> method accepts the list of applications, hash reference for
 the B<env> attribute of L<Dancer2::Core::Request> and optionally the request
-object and a context object as input arguments.
+object and an env as input arguments.
 
 C<dispatch> returns a response object of L<Dancer2::Core::Response>.
 
@@ -253,7 +290,7 @@ a variable error and returns an object of L<Dancer2::Core::Error>.
 =head2 response_not_found
 
 The C<response_not_found> consumes as input the list of applications and an
-object of type L<Dancer2::Core::Context> and returns an object
+object of type L<Dancer2::Core::App> and returns an object
 L<Dancer2::Core::Error>.
 
 =head1 AUTHOR
@@ -1,21 +1,30 @@
 package Dancer2::Core::Error;
 # ABSTRACT: Class representing fatal errors
-$Dancer2::Core::Error::VERSION = '0.141000';
+$Dancer2::Core::Error::VERSION = '0.150000';
 use Moo;
 use Carp;
 use Dancer2::Core::Types;
 use Dancer2::Core::HTTP;
 use Data::Dumper;
-use Dancer2::FileUtils 'path';
+use Dancer2::FileUtils qw/path open_file/;
 
 
 
 
+has app => (
+    is        => 'ro',
+    isa       => InstanceOf['Dancer2::Core::App'],
+    predicate => 'has_app',
+);
+
 has show_errors => (
     is      => 'ro',
     isa     => Bool,
     default => sub {
-        $_[0]->context->app->setting('show_errors') if $_[0]->has_context;
+        my $self = shift;
+
+        $self->has_app
+            and return $self->app->setting('show_errors');
     },
 );
 
@@ -65,10 +74,10 @@ sub _build_error_template {
     # look for a template named after the status number.
     # E.g.: views/404.tt  for a TT template
     return $self->status
-      if -f $self->context->app->engine('template')
+      if -f $self->app->engine('template')
           ->view_pathname( $self->status );
 
-    return undef;
+    return;
 }
 
 has static_page => (
@@ -82,12 +91,12 @@ sub _build_static_page {
 
     # TODO there must be a better way to get it
     my $public_dir = $ENV{DANCER_PUBLIC}
-      || ( $self->has_context
-        && path( $self->context->app->config_location, 'public' ) );
+      || ( $self->has_app
+        && path( $self->app->config_location, 'public' ) );
 
     my $filename = sprintf "%s/%d.html", $public_dir, $self->status;
 
-    open my $fh, $filename or return undef;
+    open my $fh, $filename or return;
 
     local $/ = undef;    # slurp time
 
@@ -100,12 +109,18 @@ sub default_error_page {
 
     require Template::Tiny;
 
-    my $uri_base = $self->has_context ?
-        $self->context->request->uri_base : '';
+    my $uri_base = $self->has_app ?
+        $self->app->request->uri_base : '';
+
+    my $message = $self->message;
+    if ( $self->show_errors && $self->exception) {
+        $message .= "\n" . $self->exception;
+    }
+
     my $opts = {
         title    => $self->title,
         charset  => $self->charset,
-        content  => $self->message,
+        content  => $message,
         version  => Dancer2->VERSION,
         uri_base => $uri_base,
     };
@@ -143,8 +158,10 @@ has status => (
 
 
 has message => (
-    is  => 'ro',
-    isa => Str,
+    is      => 'ro',
+    isa     => Str,
+    lazy    => 1,
+    default => sub { '' },
 );
 
 sub full_message {
@@ -157,42 +174,49 @@ sub full_message {
 
 has serializer => (
     is        => 'ro',
-    isa       => ConsumerOf ['Dancer2::Core::Role::Serializer'],
-    predicate => 1,
+    isa       => Maybe[ConsumerOf ['Dancer2::Core::Role::Serializer']],
+    builder   => '_build_serializer',
 );
 
+sub _build_serializer {
+    my ($self) = @_;
+
+    $self->has_app
+        and return $self->app->engine('serializer');
+
+    return;
+}
+
 has session => (
     is  => 'ro',
     isa => ConsumerOf ['Dancer2::Core::Role::Session'],
 );
 
-has context => (
-    is        => 'ro',
-    isa       => InstanceOf ['Dancer2::Core::Context'],
-    predicate => 1,
-);
-
 sub BUILD {
     my ($self) = @_;
 
-    $self->has_context &&
-      $self->context->app->execute_hook( 'core.error.init', $self );
+    $self->has_app &&
+      $self->app->execute_hook( 'core.error.init', $self );
 }
 
 has exception => (
     is        => 'ro',
     isa       => Str,
     predicate => 1,
+    coerce    => sub {
+        # Until we properly support exception objects, we shouldn't barf on
+        # them because that hides the actual error, if object overloads "",
+        # which most exception objects do, this will result in a nicer string.
+        # other references will produce a meaningless error, but that is
+        # better than a meaningless stacktrace
+        return "$_[0]"
+    }
 );
 
 has response => (
     is      => 'rw',
     lazy    => 1,
-    default => sub {
-        $_[0]->has_context
-          ? $_[0]->context->response
-          : Dancer2::Core::Response->new;
-    },
+    default => sub { Dancer2::Core::Response->new }
 );
 
 has content_type => (
@@ -200,7 +224,7 @@ has content_type => (
     lazy    => 1,
     default => sub {
         my $self = shift;
-        $self->has_serializer
+        $self->serializer
             ? $self->serializer->content_type
             : 'text/html'
     },
@@ -213,7 +237,7 @@ has content => (
         my $self = shift;
 
         # Apply serializer
-        if ( $self->has_serializer ) {
+        if ( $self->serializer ) {
             my $content = {
                 message => $self->message,
                 title   => $self->title,
@@ -227,8 +251,8 @@ has content => (
         # Otherwise we check for a template, for a static file and,
         # if all else fail, the default error page
 
-        if ( $self->has_context and $self->template ) {
-            return $self->context->app->template(
+        if ( $self->has_app and $self->template ) {
+            return $self->app->template(
                 $self->template,
                 {   title     => $self->title,
                     content   => $self->message,
@@ -238,7 +262,8 @@ has content => (
             );
         }
 
-        if ( my $content = $self->static_page ) {
+        # It doesn't make sense to return a static page if show_errors is on
+        if ( !$self->show_errors && (my $content = $self->static_page) ) {
             return $content;
         }
 
@@ -249,23 +274,22 @@ has content => (
 
 sub throw {
     my $self = shift;
-    $self->response(shift) if @_;
+    $self->set_response(shift) if @_;
 
-    croak "error has no response to throw at" unless $self->response;
+    $self->response
+        or croak "error has no response to throw at";
 
-    $self->has_context &&
-        $self->context->app->execute_hook( 'core.error.before', $self );
+    $self->has_app &&
+        $self->app->execute_hook( 'core.error.before', $self );
 
     my $message = $self->content;
-    $message .= "\n\n" . $self->exception
-      if $self->show_errors && defined $self->exception;
 
     $self->response->status( $self->status );
     $self->response->content_type( $self->content_type );
     $self->response->content($message);
 
-    $self->has_context &&
-        $self->context->app->execute_hook('core.error.after', $self->response);
+    $self->has_app &&
+        $self->app->execute_hook('core.error.after', $self->response);
 
     $self->response->halt(1);
     return $self->response;
@@ -275,8 +299,14 @@ sub throw {
 sub backtrace {
     my ($self) = @_;
 
-    my $message =
-      qq|<pre class="error">| . _html_encode( $self->message ) . "</pre>";
+    my $message = $self->exception ? $self->exception : $self->message;
+    $message =
+      qq|<pre class="error">| . _html_encode( $message ) . "</pre>";
+
+    if ( $self->exception && !ref($self->exception) ) {
+        $message .= qq|<pre class="error">|
+                 . _html_encode($self->exception) . "</pre>";
+    }
 
     # the default perl warning/error pattern
     my ( $file, $line ) = ( $message =~ /at (\S+) line (\d+)/ );
@@ -364,7 +394,7 @@ sub dumper {
 sub environment {
     my ($self) = @_;
 
-    my $request = $self->has_context ? $self->context->request : 'TODO';
+    my $request = $self->has_app ? $self->app->request : 'TODO';
     my $r_env = {};
     $r_env = $request->env if defined $request;
 
@@ -437,6 +467,8 @@ sub _censor {
 sub _html_encode {
     my $value = shift;
 
+    return if !defined $value;
+
     $value =~ s/&/&amp;/g;
     $value =~ s/</&lt;/g;
     $value =~ s/>/&gt;/g;
@@ -476,7 +508,7 @@ Dancer2::Core::Error - Class representing fatal errors
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 SYNOPSIS
 
@@ -535,7 +567,7 @@ Create a new Dancer2::Core::Error object. For available arguments see ATTRIBUTES
 =head2 throw($response)
 
 Populates the content of the response with the error's information.
-If I<$response> is not given, acts on the I<context>
+If I<$response> is not given, acts on the I<app>
 attribute's response.
 
 =head2 backtrace
@@ -1,6 +1,6 @@
 package Dancer2::Core::Factory;
 # ABSTRACT: Instantiate components by type and name
-$Dancer2::Core::Factory::VERSION = '0.141000';
+$Dancer2::Core::Factory::VERSION = '0.150000';
 use strict;
 use warnings;
 
@@ -33,7 +33,7 @@ Dancer2::Core::Factory - Instantiate components by type and name
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 AUTHOR
 
@@ -1,7 +1,7 @@
 # ABSTRACT: helper for rendering HTTP status codes for Dancer2
 
 package Dancer2::Core::HTTP;
-$Dancer2::Core::HTTP::VERSION = '0.141000';
+$Dancer2::Core::HTTP::VERSION = '0.150000';
 use strict;
 use warnings;
 
@@ -110,7 +110,7 @@ sub status {
     if ( exists $HTTP_CODES->{$status} ) {
         return $HTTP_CODES->{$status};
     }
-    return undef;
+    return;
 }
 
 
@@ -134,7 +134,7 @@ Dancer2::Core::HTTP - helper for rendering HTTP status codes for Dancer2
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 FUNCTIONS
 
@@ -1,6 +1,6 @@
 package Dancer2::Core::Hook;
 # ABSTRACT: Manipulate hooks with Dancer2
-$Dancer2::Core::Hook::VERSION = '0.141000';
+$Dancer2::Core::Hook::VERSION = '0.150000';
 use Moo;
 use Dancer2::Core::Types;
 use Carp;
@@ -51,7 +51,7 @@ Dancer2::Core::Hook - Manipulate hooks with Dancer2
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 SYNOPSIS
 
@@ -1,7 +1,7 @@
 # ABSTRACT: Class to ease manipulation of MIME types
 
 package Dancer2::Core::MIME;
-$Dancer2::Core::MIME::VERSION = '0.141000';
+$Dancer2::Core::MIME::VERSION = '0.150000';
 use Moo;
 
 use MIME::Types;
@@ -88,7 +88,7 @@ Dancer2::Core::MIME - Class to ease manipulation of MIME types
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 SYNOPSIS
 
@@ -1,5 +1,5 @@
 package Dancer2::Core::Request::Upload;
-$Dancer2::Core::Request::Upload::VERSION = '0.141000';
+$Dancer2::Core::Request::Upload::VERSION = '0.150000';
 # ABSTRACT: Class representing file upload requests
 use Moo;
 
@@ -103,7 +103,7 @@ Dancer2::Core::Request::Upload - Class representing file upload requests
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -1,5 +1,5 @@
 package Dancer2::Core::Request;
-$Dancer2::Core::Request::VERSION = '0.141000';
+$Dancer2::Core::Request::VERSION = '0.150000';
 # ABSTRACT: Interface for accessing incoming requests
 
 use Moo;
@@ -59,6 +59,22 @@ has env => (
 );
 
 
+# a buffer for per-request variables
+has vars => (
+    is      => 'ro',
+    isa     => HashRef,
+    default => sub { {} },
+);
+
+
+sub var {
+    my $self = shift;
+    @_ == 2
+      ? $self->vars->{ $_[0] } = $_[1]
+      : $self->vars->{ $_[0] };
+}
+
+
 
 has path => (
     is      => 'ro',
@@ -90,9 +106,10 @@ sub _build_path {
 }
 
 has path_info => (
-    is      => 'rw',
+    is      => 'ro',
     isa     => Str,
     lazy    => 1,
+    writer  => 'set_path_info',
     builder => '_build_path_info',
 );
 
@@ -214,8 +231,9 @@ has body_is_parsed => (
 );
 
 has is_behind_proxy => (
-    is      => 'rw',
+    is      => 'ro',
     isa     => Bool,
+    lazy    => 1,
     default => sub {0},
 );
 
@@ -357,62 +375,6 @@ sub to_string {
     return "[#" . $self->id . "] " . $self->method . " " . $self->path;
 }
 
-# Create a new request which is a clone of the current one, apart
-# from the path location, which points instead to the new location
-# TODO this could be written in a more clean manner with a clone mechanism
-sub make_forward_to {
-    my ( $self, $url, $params, $options ) = @_;
-
-    # we clone the env to make sure we don't alter the existing one in $self
-    my $env = { %{ $self->env } };
-
-    $env->{PATH_INFO} = $url;
-
-    my $new_request = ( ref $self )->new( env => $env, body_is_parsed => 1 );
-    my $new_params = _merge_params( scalar( $self->params ), $params || {} );
-
-    if ( exists( $options->{method} ) ) {
-        $new_request->method( $options->{method} );
-    }
-
-    # Copy params (these are already decoded)
-    $new_request->{_params}       = $new_params;
-    $new_request->{_body_params}  = $self->{_body_params};
-    $new_request->{_query_params} = $self->{_query_params};
-    $new_request->{_route_params} = $self->{_route_params};
-    $new_request->{body}          = $self->body;
-    $new_request->{headers}       = $self->headers;
-
-    return $new_request;
-}
-
-
-sub forward {
-    my ( $self, $context, $url, $params, $options ) = @_;
-    my $new_request = $self->make_forward_to( $url, $params, $options );
-
-    my $new_response = Dancer2->runner->dispatcher->dispatch(
-        $new_request->env,
-        $new_request,
-        $context,
-    );
-    # halt the response, so no further processing is done on this request.
-    # (any after hooks will have already been run)
-    $new_response->halt;
-    $context->response($new_response);
-    $context->with_return->($new_response) if $context->has_with_return;
-    return $new_response; # Should never be called..
-}
-
-sub _merge_params {
-    my ( $params, $to_add ) = @_;
-
-    for my $key ( keys %$to_add ) {
-        $params->{$key} = $to_add->{$key};
-    }
-    return $params;
-}
-
 
 sub base {
     my $self = shift;
@@ -743,7 +705,7 @@ sub _build_uploads {
 
 
 has cookies => (
-    is      => 'rw',
+    is      => 'ro',
     isa     => HashRef,
     lazy    => 1,
     builder => '_build_cookies',
@@ -785,7 +747,7 @@ Dancer2::Core::Request - Interface for accessing incoming requests
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 SYNOPSIS
 
@@ -813,6 +775,18 @@ a Dancer2 application.
 
 Return the current PSGI environment hash reference.
 
+=head2 var
+
+By-name interface to variables stored in this request object.
+
+  my $stored = $request->var('some_variable');
+
+returns the value of 'some_variable', while
+
+  $request->var('some_variable' => 'value');
+
+will set it.
+
 =head2 path()
 
 Return the path requested by the client.
@@ -951,19 +925,6 @@ Alias to the PSGI input handle (C<< <request->env->{psgi.input}> >>)
 
 Return a string representing the request object (eg: C<"GET /some/path">)
 
-=head2 forward($request, $new_location)
-
-Create a new request which is a clone of the current one, apart
-from the path location, which points instead to the new location.
-This is used internally to chain requests using the forward keyword.
-
-Note that the new location should be a hash reference. Only one key is
-required, the C<to_url>, that should point to the URL that forward
-will use. Optional values are the key C<params> to a hash of
-parameters to be added to the current request parameters, and the key
-C<options> that points to a hash of options about the redirect (for
-instance, C<method> pointing to a new request method).
-
 =head2 base()
 
 Returns an absolute URI for the base of the application.  Returns a L<URI>
@@ -1,7 +1,7 @@
 # ABSTRACT: Response object for Dancer2
 
 package Dancer2::Core::Response;
-$Dancer2::Core::Response::VERSION = '0.141000';
+$Dancer2::Core::Response::VERSION = '0.150000';
 use Moo;
 
 use Encode;
@@ -105,9 +105,18 @@ before content => sub {
 };
 
 
+has default_content_type => (
+    is      => 'rw',
+    isa     => Str,
+    default => sub {'text/html'},
+);
+
+
 sub encode_content {
     my ($self) = @_;
     return if $self->is_encoded;
+    # Apply default content type if none set.
+    $self->content_type or $self->content_type($self->default_content_type);
     return if $self->content_type !~ /^text/;
 
     # we don't want to encode an empty string, it will break the output
@@ -127,6 +136,10 @@ sub encode_content {
 
 sub to_psgi {
     my ($self) = @_;
+    # It is possible to have no content and/or no content type set
+    # e.g. if all routes 'pass'. Apply defaults here..
+    $self->content_type or $self->content_type($self->default_content_type);
+    $self->content('') if ! defined $self->content;
     return [ $self->status, $self->headers_to_array, [ $self->content ], ];
 }
 
@@ -210,7 +223,7 @@ Dancer2::Core::Response - Response object for Dancer2
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 ATTRIBUTES
 
@@ -234,6 +247,11 @@ response will try coerce it to a string via double quote interpolation.
 Whenever the content changes, it recalculates and updates the Content-Length header,
 unless the response has_passed.
 
+=head2 default_content_type
+
+Default mime type to use for the response Content-Type header
+if nothing was specified
+
 =head1 METHODS
 
 =head2 pass
@@ -1,23 +1,19 @@
 # ABSTRACT: Config role for Dancer2 core objects
 package Dancer2::Core::Role::ConfigReader;
-$Dancer2::Core::Role::ConfigReader::VERSION = '0.141000';
+$Dancer2::Core::Role::ConfigReader::VERSION = '0.150000';
 use Moo::Role;
 
 use File::Spec;
 use Config::Any;
 use Hash::Merge::Simple;
-use Carp qw/croak carp/;
+use Carp 'croak';
 
 use Dancer2::Core::Factory;
 use Dancer2::Core;
 use Dancer2::Core::Types;
-use Dancer2::FileUtils qw/path/;
+use Dancer2::FileUtils 'path';
 
-has location => (
-    is      => 'ro',
-    lazy    => 1,
-    builder => '_build_location',
-);
+with 'Dancer2::Core::Role::HasLocation';
 
 has default_config => (
     is      => 'ro',
@@ -49,7 +45,7 @@ has environments_location => (
 );
 
 has config => (
-    is      => 'rw',
+    is      => 'ro',
     isa     => HashRef,
     lazy    => 1,
     builder => '_build_config',
@@ -63,7 +59,7 @@ has environment => (
 );
 
 has config_files => (
-    is      => 'rw',
+    is      => 'ro',
     lazy    => 1,
     isa     => ArrayRef,
     builder => '_build_config_files',
@@ -78,27 +74,34 @@ has local_triggers => (
 has global_triggers => (
     is      => 'ro',
     isa     => HashRef,
-    default => sub { +{
-        traces => sub {
-            my ( $self, $traces ) = @_;
-            require Carp;
-            $Carp::Verbose = $traces ? 1 : 0;
-        },
-
-        apphandler => sub {
-            my ( $self, $handler ) = @_;
-            Dancer2->runner->config->{'apphandler'} = $handler;
-        },
-    } },
+    default => sub {
+        my $triggers = {
+            traces => sub {
+                my ( $self, $traces ) = @_;
+                # Carp is already a dependency
+                $Carp::Verbose = $traces ? 1 : 0;
+            },
+        };
+
+        my $runner_config = defined $Dancer2::runner
+                            ? Dancer2->runner->config
+                            : {};
+
+        for my $global ( keys %$runner_config ) {
+            next if exists $triggers->{$global};
+            $triggers->{$global} = sub {
+                my ($self, $value) = @_;
+                Dancer2->runner->config->{$global} = $value;
+            }
+        }
+
+        return $triggers;
+    },
 );
 
 sub _build_default_config { +{} }
 
-sub _build_location { File::Spec->rel2abs('.') }
-
-sub _build_environment {
-    $ENV{DANCER_ENVIRONMENT} || $ENV{PLACK_ENV} || 'development';
-}
+sub _build_environment { 'development' }
 
 sub _build_config_files {
     my ($self) = @_;
@@ -127,11 +130,9 @@ sub _build_config_files {
 
 sub _build_config {
     my ($self) = @_;
-    my $location = $self->config_location;
 
-    my $default = {};
-    $default = $self->default_config
-      if $self->can('default_config');
+    my $location = $self->config_location;
+    my $default  = $self->default_config;
 
     my $config = Hash::Merge::Simple->merge(
         $default,
@@ -271,7 +272,7 @@ Dancer2::Core::Role::ConfigReader - Config role for Dancer2 core objects
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -1,6 +1,6 @@
 package Dancer2::Core::Role::DSL;
 # ABSTRACT: Role for DSL
-$Dancer2::Core::Role::DSL::VERSION = '0.141000';
+$Dancer2::Core::Role::DSL::VERSION = '0.150000';
 use Moo::Role;
 use Dancer2::Core::Types;
 use Carp 'croak';
@@ -71,8 +71,8 @@ sub _compile_keyword {
     if ( !$is_global ) {
         my $code = $compiled_code;
         $compiled_code = sub {
-            croak "Function '$keyword' must be called from a route handler"
-              unless defined $self->app->context;
+            $self->app->has_request or
+                croak "Function '$keyword' must be called from a route handler";
             $code->(@_);
         };
     }
@@ -104,7 +104,7 @@ Dancer2::Core::Role::DSL - Role for DSL
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 AUTHOR
 
@@ -1,18 +1,18 @@
 package Dancer2::Core::Role::Engine;
 # ABSTRACT: Role for engines
-$Dancer2::Core::Role::Engine::VERSION = '0.141000';
+$Dancer2::Core::Role::Engine::VERSION = '0.150000';
 use Moo::Role;
 use Dancer2::Core::Types;
 
 
 with 'Dancer2::Core::Role::Hookable';
 
-
-has context => (
-    is        => 'rw',
-    isa       => InstanceOf ['Dancer2::Core::Context'],
-    clearer   => 'clear_context',
-    predicate => 1,
+has session => (
+    is        => 'ro',
+    isa       => InstanceOf['Dancer2::Core::Session'],
+    writer    => 'set_session',
+    clearer   => 'clear_session',
+    predicate => 'has_session',
 );
 
 
@@ -34,7 +34,7 @@ Dancer2::Core::Role::Engine - Role for engines
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -45,10 +45,6 @@ This role consumes the L<Dancer2::Core::Role::Hookable> role.
 
 =head1 ATTRIBUTES
 
-=head2 context
-
-A L<Dancer2::Core::Context> object
-
 =head2 config
 
 An HashRef that hosts the configuration bits for the engine.
@@ -1,6 +1,6 @@
 package Dancer2::Core::Role::Handler;
 # ABSTRACT: Role for Handlers
-$Dancer2::Core::Role::Handler::VERSION = '0.141000';
+$Dancer2::Core::Role::Handler::VERSION = '0.150000';
 use Moo::Role;
 use Dancer2::Core::Types;
 
@@ -11,6 +11,7 @@ requires 'register';
 has app => (
     is  => 'ro',
     isa => InstanceOf ['Dancer2::Core::App'],
+    weak_ref => 1,
 );
 
 1;
@@ -25,7 +26,7 @@ Dancer2::Core::Role::Handler - Role for Handlers
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 ATTRIBUTES
 
@@ -0,0 +1,98 @@
+package Dancer2::Core::Role::HasLocation;
+# ABSTRACT: Role for application location "guessing"
+$Dancer2::Core::Role::HasLocation::VERSION = '0.150000';
+use Moo::Role;
+use Dancer2::Core::Types;
+use Dancer2::FileUtils;
+use File::Spec;
+use Sub::Quote 'quote_sub';
+
+# the path to the caller script/app
+# Note: to remove any ambiguity between the accessor for the
+# 'caller' attribute and the core function caller(), explictly
+# specify we want the function 'CORE::caller' as the default for
+# the attribute.
+has caller => (
+    is      => 'ro',
+    isa     => Str,
+    default => quote_sub( q{
+        my ( $caller, $script ) = CORE::caller;
+        $script;
+    } ),
+);
+
+has location => (
+    is      => 'ro',
+    builder => '_build_location',
+);
+
+# FIXME: i hate you most of all -- Sawyer X
+sub _build_location {
+    my $self   = shift;
+    my $script = $self->caller;
+
+    # default to the dir that contains the script...
+    my $location = Dancer2::FileUtils::dirname($script);
+
+    #we try to find bin and lib
+    my $subdir       = $location;
+    my $subdir_found = 0;
+
+    #maximum of 10 iterations, to prevent infinite loop
+    for ( 1 .. 10 ) {
+
+        #try to find libdir and bindir to determine the root of dancer app
+        my $libdir = Dancer2::FileUtils::path( $subdir, 'lib' );
+        my $bindir = Dancer2::FileUtils::path( $subdir, 'bin' );
+
+        #try to find .dancer_app file to determine the root of dancer app
+        my $dancerdir = Dancer2::FileUtils::path( $subdir, '.dancer' );
+
+        # if one of them is found, keep that; but skip ./blib since both lib and bin exist
+        # under it, but views and public do not.
+        if ( ( $subdir !~ m!/blib/?$! && -d $libdir && -d $bindir ) || ( -f $dancerdir ) ) {
+            $subdir_found = 1;
+            last;
+        }
+
+        $subdir = Dancer2::FileUtils::path( $subdir, '..' ) || '.';
+        last if File::Spec->rel2abs($subdir) eq File::Spec->rootdir;
+
+    }
+
+    my $path = $subdir_found ? $subdir : $location;
+
+    # return if absolute
+    File::Spec->file_name_is_absolute($path)
+        and return $path;
+
+    # convert relative to absolute
+    return File::Spec->rel2abs($path);
+}
+
+1;
+
+__END__
+
+=pod
+
+=head1 NAME
+
+Dancer2::Core::Role::HasLocation - Role for application location "guessing"
+
+=head1 VERSION
+
+version 0.150000
+
+=head1 AUTHOR
+
+Dancer Core Developers
+
+=head1 COPYRIGHT AND LICENSE
+
+This software is copyright (c) 2014 by Alexis Sukrieh.
+
+This is free software; you can redistribute it and/or modify it under
+the same terms as the Perl 5 programming language system itself.
+
+=cut
@@ -1,7 +1,7 @@
 # ABSTRACT: Role for handling headers
 
 package Dancer2::Core::Role::Headers;
-$Dancer2::Core::Role::Headers::VERSION = '0.141000';
+$Dancer2::Core::Role::Headers::VERSION = '0.150000';
 
 use Moo::Role;
 use Dancer2::Core::Types;
@@ -80,7 +80,7 @@ Dancer2::Core::Role::Headers - Role for handling headers
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -1,6 +1,6 @@
 package Dancer2::Core::Role::Hookable;
 # ABSTRACT: Role for hookable objects
-$Dancer2::Core::Role::Hookable::VERSION = '0.141000';
+$Dancer2::Core::Role::Hookable::VERSION = '0.150000';
 use Moo::Role;
 use Dancer2::Core;
 use Dancer2::Core::Types;
@@ -10,7 +10,7 @@ requires 'supported_hooks';
 
 # The hooks registry
 has hooks => (
-    is      => 'rw',
+    is      => 'ro',
     isa     => HashRef,
     builder => '_build_hooks',
     lazy    => 1,
@@ -154,7 +154,7 @@ Dancer2::Core::Role::Hookable - Role for hookable objects
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 AUTHOR
 
@@ -1,6 +1,6 @@
 package Dancer2::Core::Role::Logger;
 # ABSTRACT: Role for logger engines
-$Dancer2::Core::Role::Logger::VERSION = '0.141000';
+$Dancer2::Core::Role::Logger::VERSION = '0.150000';
 use Dancer2::Core::Types;
 
 use Moo::Role;
@@ -175,7 +175,7 @@ Dancer2::Core::Role::Logger - Role for logger engines
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -1,6 +1,6 @@
 package Dancer2::Core::Role::Serializer;
 # ABSTRACT: Role for Serializer engines
-$Dancer2::Core::Role::Serializer::VERSION = '0.141000';
+$Dancer2::Core::Role::Serializer::VERSION = '0.150000';
 use Dancer2::Core::Types;
 use Moo::Role;
 
@@ -76,7 +76,7 @@ Dancer2::Core::Role::Serializer - Role for Serializer engines
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -1,5 +1,5 @@
 package Dancer2::Core::Role::SessionFactory::File;
-$Dancer2::Core::Role::SessionFactory::File::VERSION = '0.141000';
+$Dancer2::Core::Role::SessionFactory::File::VERSION = '0.150000';
 #ABSTRACT: Role for file-based session factories
 
 
@@ -114,7 +114,7 @@ Dancer2::Core::Role::SessionFactory::File - Role for file-based session factorie
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -1,5 +1,5 @@
 package Dancer2::Core::Role::SessionFactory;
-$Dancer2::Core::Role::SessionFactory::VERSION = '0.141000';
+$Dancer2::Core::Role::SessionFactory::VERSION = '0.150000';
 #ABSTRACT: Role for session factories
 
 
@@ -272,13 +272,16 @@ Dancer2::Core::Role::SessionFactory - Role for session factories
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
 Any class that consumes this role will be able to store, create, retrieve and
 destroy session objects.
 
+The default values for attributes can be overridden in your Dancer2
+configuration. See L<Dancer2::Config/Session-engine>.
+
 =head1 ATTRIBUTES
 
 =head2 cookie_name
@@ -1,32 +1,32 @@
 package Dancer2::Core::Role::StandardResponses;
 # ABSTRACT: Role to provide commonly used responses
-$Dancer2::Core::Role::StandardResponses::VERSION = '0.141000';
+$Dancer2::Core::Role::StandardResponses::VERSION = '0.150000';
 use Moo::Role;
 
 
 sub response {
-    my ( $self, $ctx, $code, $message ) = @_;
-    $ctx->response->status($code);
-    $ctx->response->header( 'Content-Type', 'text/plain' );
+    my ( $self, $app, $code, $message ) = @_;
+    $app->response->status($code);
+    $app->response->header( 'Content-Type', 'text/plain' );
     return $message;
 }
 
 
 sub response_400 {
-    my ( $self, $ctx ) = @_;
-    $self->response( $ctx, 400, 'Bad Request' );
+    my ( $self, $app ) = @_;
+    $self->response( $app, 400, 'Bad Request' );
 }
 
 
 sub response_404 {
-    my ( $self, $ctx ) = @_;
-    $self->response( $ctx, 404, 'Not Found' );
+    my ( $self, $app ) = @_;
+    $self->response( $app, 404, 'Not Found' );
 }
 
 
 sub response_403 {
-    my ( $self, $ctx ) = @_;
-    $self->response( $ctx, 403, 'Unauthorized' );
+    my ( $self, $app ) = @_;
+    $self->response( $app, 403, 'Unauthorized' );
 }
 
 1;
@@ -41,28 +41,27 @@ Dancer2::Core::Role::StandardResponses - Role to provide commonly used responses
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 METHODS
 
 =head2 response
 
-Generic method that produces a response in the context given with a code and a
-message:
+Generic method that produces a response given with a code and a message:
 
-    $self->response( $ctx, 404, "not found" );
+    $self->response( $app, 404, "not found" );
 
 =head2 response_400
 
-Produces a 400 response in the context given.
+Produces a 400 response
 
 =head2 response_404
 
-Produces a 404 response in the context given.
+Produces a 404 response
 
 =head2 response_403
 
-Produces a 403 response in the context given.
+Produces a 403 response
 
 =head1 AUTHOR
 
@@ -1,7 +1,7 @@
 # ABSTRACT: Role for template engines
 
 package Dancer2::Core::Role::Template;
-$Dancer2::Core::Role::Template::VERSION = '0.141000';
+$Dancer2::Core::Role::Template::VERSION = '0.150000';
 use Dancer2::Core::Types;
 use Dancer2::FileUtils qw'path';
 use Carp 'croak';
@@ -63,6 +63,14 @@ has engine => (
     builder => 1,
 );
 
+has settings => (
+    is      => 'ro',
+    isa     => HashRef,
+    lazy    => 1,
+    default => sub { +{} },
+    writer  => 'set_settings',
+);
+
 sub _template_name {
     my ( $self, $view ) = @_;
     my $def_tmpl_ext = $self->default_tmpl_ext();
@@ -93,9 +101,9 @@ sub render_layout {
 }
 
 sub apply_renderer {
-    my ( $self, $view, $tokens ) = @_;
+    my ( $self, $request, $view, $tokens ) = @_;
     $view = $self->view_pathname($view) if !ref $view;
-    $tokens = $self->_prepare_tokens_options($tokens);
+    $tokens = $self->_prepare_tokens_options($request,$tokens);
 
     $self->execute_hook( 'engine.template.before_render', $tokens );
 
@@ -108,9 +116,9 @@ sub apply_renderer {
 }
 
 sub apply_layout {
-    my ( $self, $content, $tokens, $options ) = @_;
+    my ( $self, $request, $content, $tokens, $options ) = @_;
 
-    $tokens = $self->_prepare_tokens_options($tokens);
+    $tokens = $self->_prepare_tokens_options( $request, $tokens );
 
    # If 'layout' was given in the options hashref, use it if it's a true value,
    # or don't use a layout if it was false (0, or undef); if layout wasn't
@@ -119,7 +127,7 @@ sub apply_layout {
     my $layout =
       exists $options->{layout}
       ? ( $options->{layout} ? $options->{layout} : undef )
-      : ( $self->layout || $self->context->app->config->{layout} );
+      : ( $self->layout || $self->config->{layout} );
 
     # that should only be $self->config, but the layout ain't there ???
 
@@ -142,28 +150,26 @@ sub apply_layout {
 }
 
 sub _prepare_tokens_options {
-    my ( $self, $tokens ) = @_;
+    my ( $self, $request, $tokens ) = @_;
 
     # these are the default tokens provided for template processing
     $tokens ||= {};
     $tokens->{perl_version}   = $];
     $tokens->{dancer_version} = Dancer2->VERSION;
 
-    if ( defined $self->context ) {
-        $tokens->{settings} = $self->context->app->config;
-        $tokens->{request}  = $self->context->request;
-        $tokens->{params}   = $self->context->request->params;
-        $tokens->{vars}     = $self->context->buffer;
+    $tokens->{settings} = $self->settings;
+    $tokens->{request}  = $request;
+    $tokens->{params}   = $request->params;
+    $tokens->{vars}     = $request->vars;
 
-        $tokens->{session} = $self->context->session->data
-          if $self->context->has_session;
-    }
+    $tokens->{session} = $self->session->data
+      if $self->has_session;
 
     return $tokens;
 }
 
 sub process {
-    my ( $self, $view, $tokens, $options ) = @_;
+    my ( $self, $request, $view, $tokens, $options ) = @_;
     my ( $content, $full_content );
 
     # it's important that $tokens is not undef, so that things added to it via
@@ -175,11 +181,11 @@ sub process {
 
     $content =
         $view
-      ? $self->apply_renderer( $view, $tokens )
+      ? $self->apply_renderer( $request, $view, $tokens )
       : delete $options->{content};
 
     defined $content
-      and $full_content = $self->apply_layout( $content, $tokens, $options );
+      and $full_content = $self->apply_layout( $request, $content, $tokens, $options );
 
     defined $full_content
       and return $full_content;
@@ -199,7 +205,7 @@ Dancer2::Core::Role::Template - Role for template engines
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -1,7 +1,7 @@
 # ABSTRACT: Dancer2's route handler
 
 package Dancer2::Core::Route;
-$Dancer2::Core::Route::VERSION = '0.141000';
+$Dancer2::Core::Route::VERSION = '0.150000';
 use strict;
 use warnings;
 
@@ -233,7 +233,7 @@ Dancer2::Core::Route - Dancer2's route handler
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 ATTRIBUTES
 
@@ -1,21 +1,22 @@
 package Dancer2::Core::Runner;
 # ABSTRACT: Top-layer class to start a dancer app
-$Dancer2::Core::Runner::VERSION = '0.141000';
+$Dancer2::Core::Runner::VERSION = '0.150000';
 use Moo;
+use Carp 'croak';
 use Dancer2::Core::MIME;
 use Dancer2::Core::Types;
 use Dancer2::Core::Dispatcher;
 use HTTP::Server::PSGI;
 use Plack::Builder qw();
 
-with 'Dancer2::Core::Role::ConfigReader';
-
-# the path to the caller script that is starting the app
-# mandatory, because we use that to determine where the appdir is.
-has caller => (
-    is       => 'ro',
-    isa      => Str,
-    required => 1,
+# Hashref of configurable items for the runner.
+# Defaults come from ENV vars. Updated via global triggers
+# from app configs.
+has config => (
+    is      => 'ro',
+    isa     => HashRef,
+    lazy    => 1,
+    builder => '_build_config',
 );
 
 # FIXME: i hate this
@@ -39,26 +40,27 @@ has apps => (
     default => sub { [] },
 );
 
-has dispatcher => (
-    is      => 'rw',
-    isa     => InstanceOf ['Dancer2::Core::Dispatcher'],
-    lazy    => 1,
-    builder => '_build_dispatcher',
-);
-
 has postponed_hooks => (
     is      => 'ro',
     isa     => HashRef,
     default => sub { +{} },
 );
 
-# FIXME: this should be in the configuration
+has environment => (
+    is       => 'ro',
+    isa      => Str,
+    required => 1,
+    default  => sub {
+        $ENV{DANCER_ENVIRONMENT} || $ENV{PLACK_ENV} || 'development'
+    },
+);
+
 has host => (
     is      => 'ro',
     lazy    => 1,
     default => sub { $_[0]->config->{'host'} },
 );
-    
+
 has port => (
     is      => 'ro',
     lazy    => 1,
@@ -71,12 +73,6 @@ has timeout => (
     default => sub { $_[0]->config->{'timeout'} },
 );
 
-sub _build_dispatcher {
-    my $self = shift;
-    # FIXME: ::Dispatcher::apps attr is readwrite, why?
-    return Dancer2::Core::Dispatcher->new( apps => $self->apps );
-}
-
 sub _build_server {
     my $self = shift;
 
@@ -88,79 +84,36 @@ sub _build_server {
     );
 }
 
-# FIXME: i hate you most of all
-sub _build_location {
-    my $self   = shift;
-    my $script = $self->caller;
-
-    # default to the dir that contains the script...
-    my $location = Dancer2::FileUtils::dirname($script);
-
-    #we try to find bin and lib
-    my $subdir       = $location;
-    my $subdir_found = 0;
-
-    #maximum of 10 iterations, to prevent infinite loop
-    for ( 1 .. 10 ) {
-
-        #try to find libdir and bindir to determine the root of dancer app
-        my $libdir = Dancer2::FileUtils::path( $subdir, 'lib' );
-        my $bindir = Dancer2::FileUtils::path( $subdir, 'bin' );
-
-        #try to find .dancer_app file to determine the root of dancer app
-        my $dancerdir = Dancer2::FileUtils::path( $subdir, '.dancer' );
-
-        # if one of them is found, keep that; but skip ./blib since both lib and bin exist
-        # under it, but views and public do not.
-        if ( ( $subdir !~ m!/blib/?$! && -d $libdir && -d $bindir ) || ( -f $dancerdir ) ) {
-            $subdir_found = 1;
-            last;
-        }
-
-        $subdir = Dancer2::FileUtils::path( $subdir, '..' ) || '.';
-        last if File::Spec->rel2abs($subdir) eq File::Spec->rootdir;
-
-    }
-
-    my $path = $subdir_found ? $subdir : $location;
-
-    # return if absolute
-    File::Spec->file_name_is_absolute($path)
-        and return $path;
-
-    # convert relative to absolute
-    return File::Spec->rel2abs($path);
-}
-
-sub _build_default_config {
+sub _build_config {
     my $self = shift;
 
     $ENV{PLACK_ENV}
       and $ENV{DANCER_APPHANDLER} = 'PSGI';
 
     return {
-        apphandler   => ( $ENV{DANCER_APPHANDLER}   || 'Standalone' ),
-        content_type => ( $ENV{DANCER_CONTENT_TYPE} || 'text/html' ),
-        charset      => ( $ENV{DANCER_CHARSET}      || '' ),
-        warnings     => ( $ENV{DANCER_WARNINGS}     || 0 ),
-        startup_info => ( $ENV{DANCER_STARTUP_INFO} || 1 ),
-        traces       => ( $ENV{DANCER_TRACES}       || 0 ),
-        logger       => ( $ENV{DANCER_LOGGER}       || 'console' ),
-        host         => ( $ENV{DANCER_SERVER}       || '0.0.0.0' ),
-        port         => ( $ENV{DANCER_PORT}         || '3000' ),
-        views        => ( $ENV{DANCER_VIEWS}
-              || path( $self->config_location, 'views' ) ),
-        appdir        => $self->location,
+        behind_proxy  => 0,
+        apphandler    => ( $ENV{DANCER_APPHANDLER}   || 'Standalone' ),
+        warnings      => ( $ENV{DANCER_WARNINGS}     || 0 ),
+        traces        => ( $ENV{DANCER_TRACES}       || 0 ),
+        host          => ( $ENV{DANCER_SERVER}       || '0.0.0.0' ),
+        port          => ( $ENV{DANCER_PORT}         || '3000' ),
+        server_tokens => ( defined $ENV{DANCER_SERVER_TOKENS} ?
+                           $ENV{DANCER_SERVER_TOKENS}         :
+                           1 ),
+        startup_info  => ( defined $ENV{DANCER_STARTUP_INFO} ?
+                           $ENV{DANCER_STARTUP_INFO}         :
+                           1 ),
     };
 }
 
 sub BUILD {
     my $self = shift;
 
-    # this assures any failure in building the location
-    # will be encountered as soon as possible
-    # while making sure that 'caller' is already available
-    $self->location;
+    # Enable traces if set by ENV var.
+    if (my $traces = $self->config->{traces} ) {
+        require Carp;
+        $Carp::Verbose = $traces ? 1 : 0;
+    };
 
     # set the global runner object if one doesn't exist yet
     # this can happen if you create one without going through Dancer2
@@ -176,15 +129,16 @@ sub register_application {
     push @{ $self->apps }, $app;
 
     # add postponed hooks to our psgi app
-    $self->add_postponed_hooks( $app->postponed_hooks );
+    $self->add_postponed_hooks( $app->name, $app->postponed_hooks );
 }
 
 sub add_postponed_hooks {
     my $self  = shift;
+    my $name  = shift;
     my $hooks = shift;
 
     # merge postponed hooks
-    @{ $self->{'postponed_hooks'} }{ keys %{$hooks} } = values %{$hooks};
+    @{ $self->{'postponed_hooks'}{$name} }{ keys %{$hooks} } = values %{$hooks};
 }
 
 # decide what to start
@@ -214,13 +168,40 @@ sub start_server {
 }
 
 sub psgi_app {
-    my $self   = shift;
-    my $server = $self->server;
+    my ($self, $apps) = @_;
+
+    if ( $apps && @{$apps} ) {
+        my @found_apps = ();
+
+        foreach my $app_req ( @{$apps} ) {
+            if ( ref $app_req eq 'Regexp' ) {
+                # find it in the apps registry
+                push @found_apps,
+                    grep +( $_->name =~ $app_req ), @{ $self->apps };
+            } elsif ( ref $app_req eq 'Dancer2::Core::App' ) {
+                # use it directly
+                push @found_apps, $app_req;
+            } elsif ( ! ref $app_req ) {
+                # find it in the apps registry
+                push @found_apps,
+                    grep +( $_->name eq $app_req ), @{ $self->apps };
+            } else {
+                croak "Invalid input to psgi_app: $app_req";
+            }
+        }
+
+        $apps = \@found_apps;
+    } else {
+        # dispatch over all apps by default
+        $apps = $self->apps;
+    }
 
-    foreach my $app ( @{ $self->apps } ) {
+    foreach my $app ( @{$apps} ) {
         $app->finish;
     }
 
+    my $dispatcher = Dancer2::Core::Dispatcher->new( apps => $apps );
+
     # eval entire request to catch any internal errors
     my $psgi = sub {
         my $env = shift;
@@ -236,7 +217,7 @@ sub psgi_app {
             ];
 
         eval {
-            $response = $self->dispatcher->dispatch($env)->to_psgi;
+            $response = $dispatcher->dispatch($env)->to_psgi;
             1;
         } or do {
             return [
@@ -259,8 +240,7 @@ sub print_banner {
     my $pid  = $$;
 
     # we only print the info if we need to
-    # FIXME: go to the configuration
-    #Dancer2->runner->config->{'startup_info'} or return;
+    $self->config->{'startup_info'} or return;
 
     # bare minimum
     print STDERR ">> Dancer2 v$Dancer2::VERSION server $pid listening "
@@ -291,7 +271,7 @@ Dancer2::Core::Runner - Top-layer class to start a dancer app
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 AUTHOR
 
@@ -1,5 +1,5 @@
 package Dancer2::Core::Session;
-$Dancer2::Core::Session::VERSION = '0.141000';
+$Dancer2::Core::Session::VERSION = '0.150000';
 #ABSTRACT: class to represent any session object
 
 
@@ -77,7 +77,7 @@ Dancer2::Core::Session - class to represent any session object
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -90,7 +90,7 @@ a factory that consumes L<Dancer2::Core::Role::SessionFactory> to know about tha
 Generally, session objects should not be created directly.  The correct way to
 get a new session object is to call the C<create()> method on a session engine
 that implements the SessionFactory role.  This is done automatically by the
-context object if a session engine is defined.
+app object if a session engine is defined.
 
 =head1 ATTRIBUTES
 
@@ -1,5 +1,5 @@
 package Dancer2::Core::Time;
-$Dancer2::Core::Time::VERSION = '0.141000';
+$Dancer2::Core::Time::VERSION = '0.150000';
 #ABSTRACT: class to handle common helpers for time manipulations
 
 
@@ -141,7 +141,7 @@ Dancer2::Core::Time - class to handle common helpers for time manipulations
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 SYNOPSIS
 
@@ -1,5 +1,5 @@
 package Dancer2::Core::Types;
-$Dancer2::Core::Types::VERSION = '0.141000';
+$Dancer2::Core::Types::VERSION = '0.150000';
 # ABSTRACT: Moo types for Dancer2 core.
 
 use strict;
@@ -150,7 +150,7 @@ Dancer2::Core::Types - Moo types for Dancer2 core.
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -1,7 +1,7 @@
 # ABSTRACT: Core libraries for Dancer2 2.0
 
 package Dancer2::Core;
-$Dancer2::Core::VERSION = '0.141000';
+$Dancer2::Core::VERSION = '0.150000';
 use strict;
 use warnings;
 
@@ -29,7 +29,7 @@ Dancer2::Core - Core libraries for Dancer2 2.0
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 FUNCTIONS
 
@@ -1,7 +1,7 @@
 # ABSTRACT: File utility helpers
 
 package Dancer2::FileUtils;
-$Dancer2::FileUtils::VERSION = '0.141000';
+$Dancer2::FileUtils::VERSION = '0.150000';
 use strict;
 use warnings;
 
@@ -111,7 +111,7 @@ Dancer2::FileUtils - File utility helpers
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 SYNOPSIS
 
@@ -1,6 +1,6 @@
 package Dancer2::Handler::AutoPage;
 # ABSTRACT: Class for handling the AutoPage feature
-$Dancer2::Handler::AutoPage::VERSION = '0.141000';
+$Dancer2::Handler::AutoPage::VERSION = '0.150000';
 use Moo;
 use Carp 'croak';
 use Dancer2::Core::Types;
@@ -22,26 +22,27 @@ sub register {
 
 sub code {
     sub {
-        my $ctx = shift;
+        my $app    = shift;
+        my $prefix = shift;
 
-        my $page = $ctx->request->path_info;
+        my $page = $app->request->path_info;
 
-        my $template = $ctx->app->engine('template');
+        my $template = $app->engine('template');
         if ( !defined $template ) {
-            $ctx->response->has_passed(1);
+            $app->response->has_passed(1);
             return;
         }
 
         my $view_path = $template->view_pathname($page);
 
         if ( !-f $view_path ) {
-            $ctx->response->has_passed(1);
+            $app->response->has_passed(1);
             return;
         }
 
-        my $ct = $template->process($page);
-        $ctx->response->header( 'Content-Length', length($ct) );
-        return ( $ctx->request->method eq 'GET' ) ? $ct : '';
+        my $ct = $template->process( $app->request, $page );
+        $app->response->header( 'Content-Length', length($ct) );
+        return ( $app->request->method eq 'GET' ) ? $ct : '';
     };
 }
 
@@ -61,7 +62,7 @@ Dancer2::Handler::AutoPage - Class for handling the AutoPage feature
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -1,6 +1,6 @@
 package Dancer2::Handler::File;
 # ABSTRACT: class for handling file content rendering
-$Dancer2::Handler::File::VERSION = '0.141000';
+$Dancer2::Handler::File::VERSION = '0.150000';
 use Carp 'croak';
 use Moo;
 use HTTP::Date;
@@ -31,23 +31,22 @@ has encoding => (
     default => sub {'utf-8'},
 );
 
-has public_dir => ( is => 'rw', );
+has public_dir => (
+    is      => 'ro',
+    lazy    => 1,
+    builder => '_build_public_dir',
+);
 
 has regexp => (
     is      => 'ro',
     default => sub {'/**'},
 );
 
-sub BUILD {
-    my ($self) = @_;
-    if ( !defined $self->public_dir ) {
-        my $public =
-             $self->app->config->{public}
-          || $ENV{DANCER_PUBLIC}
-          || path( $self->app->location, 'public' );
-
-        $self->public_dir($public);
-    }
+sub _build_public_dir {
+    my $self = shift;
+    return $self->app->config->{public}
+        || $ENV{DANCER_PUBLIC}
+        || path( $self->app->location, 'public' );
 }
 
 sub register {
@@ -69,11 +68,12 @@ sub code {
     my ( $self, $prefix ) = @_;
 
     sub {
-        my $ctx  = shift;
-        my $path = $ctx->request->path_info;
+        my $app    = shift;
+        my $prefix = shift;
+        my $path   = $app->request->path_info;
 
         if ( $path =~ /\0/ ) {
-            return $self->response_400($ctx);
+            return $self->response_400($app);
         }
 
         if ( $prefix && $prefix ne '/' ) {
@@ -84,18 +84,18 @@ sub code {
           File::Spec->splitdir( join '',
             ( File::Spec->splitpath($path) )[ 1, 2 ] );
         if ( grep $_ eq '..', @tokens ) {
-            return $self->response_403($ctx);
+            return $self->response_403($app);
         }
 
         my $file_path = path( $self->public_dir, @tokens );
 
         if ( !-f $file_path ) {
-            $ctx->response->has_passed(1);
+            $app->response->has_passed(1);
             return;
         }
 
         if ( !-r $file_path ) {
-            return $self->response_403($ctx);
+            return $self->response_403($app);
         }
 
         # Now we are sure we can render the file...
@@ -114,19 +114,22 @@ sub code {
 
         my @stat = stat $file_path;
 
-        $ctx->response->header( 'Content-Type', $content_type );
+        $app->response->header('Content-Type')
+          or $app->response->header( 'Content-Type', $content_type );
 
-        $ctx->response->header( 'Content-Length', $stat[7] );
+        $app->response->header('Content-Length')
+          or $app->response->header( 'Content-Length', $stat[7] );
 
-        $ctx->response->header(
+        $app->response->header('Last-Modified')
+          or $app->response->header(
             'Last-Modified',
             HTTP::Date::time2str( $stat[9] )
-        );
+          );
 
-        $ctx->response->content($content);
-        $ctx->response->is_encoded(1);    # bytes are already encoded
-        $self->execute_hook( 'handler.file.after_render', $ctx->response );
-        return ( $ctx->request->method eq 'GET' ) ? $content : '';
+        $app->response->content($content);
+        $app->response->is_encoded(1);    # bytes are already encoded
+        $self->execute_hook( 'handler.file.after_render', $app->response );
+        return ( $app->request->method eq 'GET' ) ? $content : '';
     };
 }
 
@@ -142,7 +145,7 @@ Dancer2::Handler::File - class for handling file content rendering
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 AUTHOR
 
@@ -1,6 +1,6 @@
 package Dancer2::Logger::Capture::Trap;
 # ABSTRACT: a place to store captured Dancer2 logs
-$Dancer2::Logger::Capture::Trap::VERSION = '0.141000';
+$Dancer2::Logger::Capture::Trap::VERSION = '0.150000';
 use Moo;
 use Dancer2::Core::Types;
 
@@ -35,7 +35,7 @@ Dancer2::Logger::Capture::Trap - a place to store captured Dancer2 logs
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 SYNOPSIS
 
@@ -1,6 +1,6 @@
 package Dancer2::Logger::Capture;
 # ABSTRACT: Capture dancer logs
-$Dancer2::Logger::Capture::VERSION = '0.141000';
+$Dancer2::Logger::Capture::VERSION = '0.150000';
 use Moo;
 use Dancer2::Logger::Capture::Trap;
 
@@ -34,7 +34,7 @@ Dancer2::Logger::Capture - Capture dancer logs
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 SYNOPSIS
 
@@ -1,6 +1,6 @@
 package Dancer2::Logger::Console;
 # ABSTRACT: Console logger
-$Dancer2::Logger::Console::VERSION = '0.141000';
+$Dancer2::Logger::Console::VERSION = '0.150000';
 use Moo;
 
 with 'Dancer2::Core::Role::Logger';
@@ -22,7 +22,7 @@ Dancer2::Logger::Console - Console logger
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -1,6 +1,6 @@
 package Dancer2::Logger::Diag;
 # ABSTRACT: Test::More diag() logging engine for Dancer2
-$Dancer2::Logger::Diag::VERSION = '0.141000';
+$Dancer2::Logger::Diag::VERSION = '0.150000';
 use Moo;
 use Test::More;
 
@@ -26,7 +26,7 @@ Dancer2::Logger::Diag - Test::More diag() logging engine for Dancer2
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -1,6 +1,6 @@
 package Dancer2::Logger::File;
 # ABSTRACT: file-based logging engine for Dancer2
-$Dancer2::Logger::File::VERSION = '0.141000';
+$Dancer2::Logger::File::VERSION = '0.150000';
 use Carp 'carp';
 use Moo;
 use Dancer2::Core::Types;
@@ -16,14 +16,14 @@ use IO::File;
 has environment => (
     is      => 'ro',
     lazy    => 1,
-    default => sub { $_[0]->context->app->environment },
+    default => sub { $_[0]->app->environment },
 );
 
 # FIXME: this is not a good way to do this
 has location => (
     is      => 'ro',
     lazy    => 1,
-    default => sub { $_[0]->context->app->config_location },
+    default => sub { $_[0]->app->config_location },
 );
 
 has log_dir => (
@@ -112,7 +112,7 @@ Dancer2::Logger::File - file-based logging engine for Dancer2
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -1,6 +1,6 @@
 package Dancer2::Logger::Note;
 # ABSTRACT: Test::More note() logging engine for Dancer2
-$Dancer2::Logger::Note::VERSION = '0.141000';
+$Dancer2::Logger::Note::VERSION = '0.150000';
 use Moo;
 use Test::More;
 
@@ -25,7 +25,7 @@ Dancer2::Logger::Note - Test::More note() logging engine for Dancer2
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -1,6 +1,6 @@
 package Dancer2::Logger::Null;
 # ABSTRACT: Blackhole-like silent logging engine for Dancer2
-$Dancer2::Logger::Null::VERSION = '0.141000';
+$Dancer2::Logger::Null::VERSION = '0.150000';
 use Moo;
 with 'Dancer2::Core::Role::Logger';
 
@@ -19,7 +19,7 @@ Dancer2::Logger::Null - Blackhole-like silent logging engine for Dancer2
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -1,6 +1,6 @@
 # ABSTRACT: A gentle introduction to Dancer2
 package Dancer2::Manual;
-$Dancer2::Manual::VERSION = '0.141000';
+$Dancer2::Manual::VERSION = '0.150000';
 __END__
 
 =pod
@@ -11,7 +11,7 @@ Dancer2::Manual - A gentle introduction to Dancer2
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -275,7 +275,7 @@ define their own.
 =head2 Request workflow
 
 C<before> hooks are evaluated before each request within the context of the
-request and receives as argument the context (a L<Dancer2::Core::Context>
+request and receives as argument the app (a L<Dancer2::Core::App>
 object).
 
 It's possible to define variables which will be accessible in the action blocks
@@ -406,10 +406,10 @@ this hook.>
 
 C<on_route_exception> is called when an exception has been caught, at the
 route level, just before rethrowing it higher. This hook receives a
-L<Dancer2::Core::Context> and the error as arguments.
+L<Dancer2::Core::App> and the error as arguments.
 
   hook on_route_exception => sub {
-    my ($context, $error) = @_;
+    my ($app, $error) = @_;
   };
 
 =head2 File rendering
@@ -722,6 +722,74 @@ Or even if you want your index page to be a plain old index.html file, just do:
         send_file '/index.html'
     };
 
+=head1 EXPORTS
+
+By default, C<use Dancer2> exports all the DSL keywords and sets up the
+webapp under the name of the current package. The following tags control exports
+and webapp namespace.
+
+=over 4
+
+=item B<!keyword>
+
+If you want to prevent Dancer2 from exporting specific keywords; perhaps you
+plan to implement them yourself in a different way, or they clash with another
+module you're loading, you can simply exclude them:
+
+    use Test::More;
+    use Dancer2 qw(!pass);
+
+The above would import all keywords as normal, with the exception of C<pass>.
+
+=item B<appname>
+
+A larger application may split its source between several packages to aid
+maintainability. Dancer2 will create a separate application for each package,
+each having separate hooks, config and/or engines. You can force Dancer2 to
+collect the route and hooks into a single application with the C<appname>
+tag; e.g.
+
+    package MyApp;
+    use Dancer2;
+    get '/foo' => sub {...};
+
+    package MyApp::Private;
+    use Dancer2 appname => MyApp;
+    get '/bar' => sub {...};
+
+The above would add the C<bar> route to the MyApp application. Dancer2 will not
+create an application with the name C<MyApp::Private>.
+
+=back
+
+When you C<use Dancer2>, you get an C<import> method added into the current
+package. This B<will> override previously declared import methods from other
+sources, such as L<Exporter>. Dancer2 applications support the following tags
+on import:
+
+=over 4
+
+=item B<with>
+
+The C<with> tag allows an app to pass one or more config entries to another app,
+when it C<use>s it.
+
+    package MyApp;
+    use Dancer2;
+
+    set session => 'YAML';
+    use Blog with => { session => engine('session') };
+
+In this example, the session engine is passed to the C<Blog> app. That way,
+anything done in the session will be shared between both apps.
+
+Anything that is defined in the config entry can be passed that way. If we want
+to pass the whole config object, it can be done like so:
+
+    use SomeApp with => { %{config()} };
+
+=back
+
 =head1 DSL KEYWORDS
 
 Dancer2 provides you with a DSL (Domain-Specific Language) which makes
@@ -1426,7 +1494,7 @@ You may also need to clear a session:
     # destroy session
     get '/logout' => sub {
         ...
-        context->destroy_session;
+        app->destroy_session;
         ...
     };
 
@@ -1481,6 +1549,14 @@ choices).
 This keyword should be called at the very end of the script, once all routes
 are defined.  At this point, Dancer takes over control.
 
+=head2 psgi_app
+
+Returns the PSGI coderef for the current (and only the current) application
+
+This keyword will typically be used as a method to get the psgi coderef for
+testing, or building a larger application via L<Plack::Builder> from
+independent parts.
+
 =head2 status
 
 Changes the status code provided by an action.  By default, an action will
@@ -1,7 +1,7 @@
 # ABSTRACT: a plugin for adding Ajax route handlers
 
 package Dancer2::Plugin::Ajax;
-$Dancer2::Plugin::Ajax::VERSION = '0.141000';
+$Dancer2::Plugin::Ajax::VERSION = '0.150000';
 use strict;
 use warnings;
 
@@ -62,7 +62,7 @@ Dancer2::Plugin::Ajax - a plugin for adding Ajax route handlers
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 SYNOPSIS
 
@@ -1,5 +1,5 @@
 package Dancer2::Plugin;
-$Dancer2::Plugin::VERSION = '0.141000';
+$Dancer2::Plugin::VERSION = '0.150000';
 # ABSTRACT: Extending Dancer2's DSL with plugins
 
 
@@ -258,7 +258,7 @@ Dancer2::Plugin - Extending Dancer2's DSL with plugins
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -294,11 +294,10 @@ with them directly.
         my $dsl = shift;
         my @args = @_;
 
-        my $app = $dsl->app;
-        my $context = $app->context;
-        my $request = $context->request;
+        my $app     = $dsl->app;
+        my $request = $app->request;
 
-        if ( $app->session( "logged_in" ) ) {
+        if ( $app->session->read('logged_in') ) {
             ...
         }
     };
@@ -419,13 +418,13 @@ the config file as C<after_logout>.
   use Dancer2::Plugin;
 
   register logout => sub {
-    my $dsl     = shift;
-    my $context = $dsl->app->context;
-    my $conf    = plugin_setting();
+    my $dsl  = shift;
+    my $app  = $dsl->app;
+    my $conf = plugin_setting();
 
-    $context->destroy_session;
+    $app->destroy_session;
 
-    return $context->redirect( $conf->{after_logout} );
+    return $app->redirect( $conf->{after_logout} );
   };
 
   register_plugin for_versions => [ 2 ] ;
@@ -1,6 +1,6 @@
 package Dancer2::Plugins;
 # ABSTRACT: Recommended Dancer2 plugins
-$Dancer2::Plugins::VERSION = '0.141000';
+$Dancer2::Plugins::VERSION = '0.150000';
 __END__
 
 =pod
@@ -11,7 +11,7 @@ Dancer2::Plugins - Recommended Dancer2 plugins
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -1,7 +1,7 @@
 # ABSTRACT: Serializer for handling Dumper data
 
 package Dancer2::Serializer::Dumper;
-$Dancer2::Serializer::Dumper::VERSION = '0.141000';
+$Dancer2::Serializer::Dumper::VERSION = '0.150000';
 use Moo;
 use Carp 'croak';
 use Data::Dumper;
@@ -53,7 +53,7 @@ Dancer2::Serializer::Dumper - Serializer for handling Dumper data
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -1,6 +1,6 @@
 package Dancer2::Serializer::JSON;
 # ABSTRACT: Serializer for handling JSON data
-$Dancer2::Serializer::JSON::VERSION = '0.141000';
+$Dancer2::Serializer::JSON::VERSION = '0.150000';
 use Moo;
 use JSON ();
 
@@ -25,15 +25,12 @@ sub loaded {1}
 sub serialize {
     my ( $self, $entity, $options ) = @_;
 
-    # Why doesn't $self->config have this?
     my $config = $self->config;
 
-    if ( $config->{allow_blessed} && !defined $options->{allow_blessed} ) {
-        $options->{allow_blessed} = $config->{allow_blessed};
-    }
-    if ( $config->{convert_blessed} ) {
-        $options->{convert_blessed} = $config->{convert_blessed};
+    foreach (keys %$config) {
+        $options->{$_} = $config->{$_} unless exists $options->{$_};
     }
+
     $options->{utf8} = 1 if !defined $options->{utf8};
 
     JSON::to_json( $entity, $options );
@@ -58,7 +55,7 @@ Dancer2::Serializer::JSON - Serializer for handling JSON data
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -1,6 +1,6 @@
 package Dancer2::Serializer::Mutable;
 # ABSTRACT: Serialize and deserialize content based on HTTP header
-$Dancer2::Serializer::Mutable::VERSION = '0.141000';
+$Dancer2::Serializer::Mutable::VERSION = '0.150000';
 use Moo;
 use Carp 'croak';
 use Encode;
@@ -20,16 +20,16 @@ my $formats = {
 
 my $serializer = {
     'YAML'   => {
-        to      => sub { return Dancer2::Core::DSL::to_yaml(@_);   },
-        from    => sub { return Dancer2::Core::DSL::from_yaml(@_); },
+        to      => sub { Dancer2::Core::DSL::to_yaml(@_)   },
+        from    => sub { Dancer2::Core::DSL::from_yaml(@_) },
     },
     'Dumper' => {
-        to      => sub { return Dancer2::Core::DSL::to_dumper(@_);   },
-        from    => sub { return Dancer2::Core::DSL::from_dumper(@_); },
+        to      => sub { Dancer2::Core::DSL::to_dumper(@_)   },
+        from    => sub { Dancer2::Core::DSL::from_dumper(@_) },
     },
     'JSON'   => {
-        to      => sub { return Dancer2::Core::DSL::to_json(@_);   },
-        from    => sub { return Dancer2::Core::DSL::from_json(@_); },
+        to      => sub { Dancer2::Core::DSL::to_json(@_)   },
+        from    => sub { Dancer2::Core::DSL::from_json(@_) },
     },
 };
 
@@ -57,7 +57,7 @@ sub serialize {
 
     # Match format with a serializer and return
     $format and return $serializer->{$format}{'to'}->(
-        $self->context, $entity
+        $self, $entity
     );
 
     # If none is found then just return the entity without change
@@ -77,14 +77,14 @@ sub deserialize {
 
 sub _get_content_type {
     my $self    = shift;
-    my $request = $self->context->request
+    my $headers = $self->{'extra_headers'}
         or return;
 
     # Search for the first HTTP header variable which
     # specifies supported content.
     foreach my $method ( qw<content_type accept accept_type> ) {
-        if ( my $value = $request->$method ) {
-            if( exists $formats->{$value} ) {
+        if ( my $value = $headers->{$method} ) {
+            if ( exists $formats->{$value} ) {
                 $self->set_content_type($value);
                 return $formats->{$value};
             }
@@ -107,7 +107,7 @@ Dancer2::Serializer::Mutable - Serialize and deserialize content based on HTTP h
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 SYNOPSIS
 
@@ -1,6 +1,6 @@
 package Dancer2::Serializer::YAML;
 # ABSTRACT: Serializer for handling YAML data
-$Dancer2::Serializer::YAML::VERSION = '0.141000';
+$Dancer2::Serializer::YAML::VERSION = '0.150000';
 use Moo;
 use Carp 'croak';
 use Encode;
@@ -49,7 +49,7 @@ Dancer2::Serializer::YAML - Serializer for handling YAML data
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -1,6 +1,6 @@
 package Dancer2::Session::Simple;
 # ABSTRACT: in-memory session backend for Dancer2
-$Dancer2::Session::Simple::VERSION = '0.141000';
+$Dancer2::Session::Simple::VERSION = '0.150000';
 use Moo;
 use Dancer2::Core::Types;
 use Carp;
@@ -48,7 +48,7 @@ Dancer2::Session::Simple - in-memory session backend for Dancer2
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -1,5 +1,5 @@
 package Dancer2::Session::YAML;
-$Dancer2::Session::YAML::VERSION = '0.141000';
+$Dancer2::Session::YAML::VERSION = '0.150000';
 # ABSTRACT: YAML-file-based session backend for Dancer2
 
 use Moo;
@@ -37,7 +37,7 @@ Dancer2::Session::YAML - YAML-file-based session backend for Dancer2
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -1,5 +1,5 @@
 package Dancer2::Template::Implementation::ForkedTiny;
-$Dancer2::Template::Implementation::ForkedTiny::VERSION = '0.141000';
+$Dancer2::Template::Implementation::ForkedTiny::VERSION = '0.150000';
 # ABSTRACT: Dancer2 own implementation of Template::Tiny
 
 use 5.00503;
@@ -190,7 +190,7 @@ sub _expression {
     foreach (@path) {
 
         # Support for private keys
-        return undef if substr( $_, 0, 1 ) eq '_';
+        return if substr( $_, 0, 1 ) eq '_';
 
         # Split by data type
         my $type = ref $cursor;
@@ -227,7 +227,7 @@ Dancer2::Template::Implementation::ForkedTiny - Dancer2 own implementation of Te
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 SYNOPSIS
 
@@ -1,6 +1,6 @@
 package Dancer2::Template::Simple;
 # ABSTRACT: Pure Perl 5 template engine for Dancer2
-$Dancer2::Template::Simple::VERSION = '0.141000';
+$Dancer2::Template::Simple::VERSION = '0.150000';
 use strict;
 use warnings;
 use Moo;
@@ -154,7 +154,7 @@ Dancer2::Template::Simple - Pure Perl 5 template engine for Dancer2
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 SYNOPSIS
 
@@ -1,7 +1,7 @@
 # ABSTRACT: Template toolkit engine for Dancer2
 
 package Dancer2::Template::TemplateToolkit;
-$Dancer2::Template::TemplateToolkit::VERSION = '0.141000';
+$Dancer2::Template::TemplateToolkit::VERSION = '0.150000';
 use strict;
 use warnings;
 use Carp qw/croak/;
@@ -61,7 +61,7 @@ Dancer2::Template::TemplateToolkit - Template toolkit engine for Dancer2
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 SYNOPSIS
 
@@ -1,6 +1,6 @@
 package Dancer2::Template::Tiny;
 # ABSTRACT: Template::Tiny engine for Dancer2
-$Dancer2::Template::Tiny::VERSION = '0.141000';
+$Dancer2::Template::Tiny::VERSION = '0.150000';
 use Moo;
 use Carp qw/croak/;
 use Dancer2::Core::Types;
@@ -48,7 +48,7 @@ Dancer2::Template::Tiny - Template::Tiny engine for Dancer2
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 SYNOPSIS
 
@@ -1,6 +1,6 @@
 package Dancer2::Test;
 # ABSTRACT: Useful routines for testing Dancer2 apps
-$Dancer2::Test::VERSION = '0.141000';
+$Dancer2::Test::VERSION = '0.150000';
 use strict;
 use warnings;
 
@@ -619,7 +619,7 @@ Dancer2::Test - Useful routines for testing Dancer2 apps
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -633,7 +633,7 @@ If you need to remove the warnings, for now, you can set:
     $Dancer::Test::NO_WARN = 1;
 
 This module provides useful routines to test Dancer2 apps. They are, however,
-buggy and unnecessary. L<Plack:Test> is advised instead.
+buggy and unnecessary. L<Plack::Test> is advised instead.
 
 $test_name is always optional.
 
@@ -1,6 +1,6 @@
 package Dancer2::Tutorial;
 # ABSTRACT: An example to get you dancing
-$Dancer2::Tutorial::VERSION = '0.141000';
+$Dancer2::Tutorial::VERSION = '0.150000';
 __END__
 
 =pod
@@ -11,7 +11,7 @@ Dancer2::Tutorial - An example to get you dancing
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 What is Dancer2?
 
@@ -350,12 +350,12 @@ And finally, we need a way to clear our user's session with the customary
 logout procedure.
 
   get '/logout' => sub {
-     context->destroy_session;
+     app->destroy_session;
      set_flash('You are logged out.');
      redirect '/';
   };
 
-C<context-E<gt>destroy_session;> is Dancer2's way to remove a stored session.
+C<app-E<gt>destroy_session;> is Dancer2's way to remove a stored session.
 We notify the user she is logged out and route her back to the root URL
 once again.
 
@@ -563,7 +563,7 @@ Here's the complete dancr.pl script from start to finish.
  };
 
  get '/logout' => sub {
-    context->destroy_session;
+    app->destroy_session;
     set_flash('You are logged out.');
     redirect '/';
  };
@@ -1,8 +1,9 @@
 package Dancer2;
 # ABSTRACT: Lightweight yet powerful web application framework
-$Dancer2::VERSION = '0.141000';
+$Dancer2::VERSION = '0.150000';
 use strict;
 use warnings;
+use List::Util  'first';
 use Class::Load 'load_class';
 use Dancer2::Core;
 use Dancer2::Core::App;
@@ -14,11 +15,12 @@ our $AUTHORITY = 'SUKRIA';
 # set version in dist.ini now
 # but we still need a basic version for
 # the tests
-$Dancer2::VERSION ||= '0.140001'; # 2.14.1
+$Dancer2::VERSION ||= '0.143000'; # 2.14.3
 
 our $runner;
 
-sub runner {$runner}
+sub runner   {$runner}
+sub psgi_app { shift->runner->psgi_app(@_) }
 
 sub import {
     my ( $class,  @args   ) = @_;
@@ -45,27 +47,37 @@ sub import {
 
     my %final_args = @final_args;
 
-    $final_args{dsl} ||= 'Dancer2::Core::DSL';
+    my $appname = delete $final_args{appname};
+    $appname ||= $caller;
 
     # never instantiated the runner, should do it now
     if ( not defined $runner ) {
-        $runner = Dancer2::Core::Runner->new( caller => $script );
+        $runner = Dancer2::Core::Runner->new();
     }
 
-    # the app object
-    # populating with the server's postponed hooks in advance
-    my $app = Dancer2::Core::App->new(
-        name            => $caller,
-        environment     => $runner->environment,
-        location        => $runner->location,
-        runner_config   => $runner->config,
-        postponed_hooks => $runner->postponed_hooks,
-    );
+    # Search through registered apps, creating a new app object
+    # if we do not find one with the same name.
+    my $app;
+    ($app) = first { $_->name eq $appname } @{ $runner->apps };
+
+    if ( ! $app ) {
+        # populating with the server's postponed hooks in advance
+        $app = Dancer2::Core::App->new(
+            name            => $appname,
+            caller          => $script,
+            environment     => $runner->environment,
+            postponed_hooks => $runner->postponed_hooks->{$appname} || {},
+        );
+
+        # register the app within the runner instance
+        $runner->register_application($app);
+    }
 
     _set_import_method_to_caller($caller);
 
-    # register the app within the runner instance
-    $runner->register_application($app);
+    # use config dsl class, must extend Dancer2::Core::DSL
+    my $config_dsl = $app->setting('dsl_class') || 'Dancer2::Core::DSL';
+    $final_args{dsl} ||= $config_dsl;
 
     # load the DSL, defaulting to Dancer2::Core::DSL
     load_class( $final_args{dsl} );
@@ -104,7 +116,7 @@ Dancer2 - Lightweight yet powerful web application framework
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 DESCRIPTION
 
@@ -185,8 +197,9 @@ Import gets called when you use Dancer2. You can specify import options giving
 you control over the keywords that will be imported into your webapp and other
 things:
 
-    use Dancer2 ( foo => 'bar' ); # sets option foo to bar
     use Dancer2 '!quux'; # Don't import DSL keyword quux
+    use Dancer2 appname => 'MyAwesomeApp'; # Add routes and hooks to MyAwesomeApp
+    use Dancer2 ( foo => 'bar' ); # sets option foo to bar (currently not implemented)
 
 =head1 FUNCTIONS
 
@@ -219,7 +232,6 @@ Returns the current runner. It is of type L<Dancer2::Core::Runner>.
     Alex Beamish
     Alexander Karelas
     Alexandr Ciornii
-    ambs
     Andrew Grangaard
     Andrew Inishev
     andrewsolomon
@@ -227,6 +239,7 @@ Returns the current runner. It is of type L<Dancer2::Core::Runner>.
     B10m
     baynes
     Blabos de Blebe
+    Bas Bloemsaat
     Breno G. de Oliveira
     Celogeek
     Cesare Gargano
@@ -244,8 +257,10 @@ Returns the current runner. It is of type L<Dancer2::Core::Runner>.
     Grzegorz Rożniecki
     Hobbestigrou
     Ivan Bessarabov
+    Jakob Voss
     James Aitken
     Jason A. Crome
+    Javier Rojas
     Jean Stebens
     Jonathan Scott Duff
     Julio Fraire
@@ -255,6 +270,7 @@ Returns the current runner. It is of type L<Dancer2::Core::Runner>.
     Matt Phillips
     Matt S Trout
     Maurice
+    Michał Wojciechowski
     mokko
     Olivier Mengué
     Omar M. Othman
@@ -31,7 +31,7 @@ dancer2 - Dancer2 command line interface
 
 =head1 VERSION
 
-version 0.141000
+version 0.150000
 
 =head1 SYNOPSIS
 
@@ -15,6 +15,8 @@ log: "core"
 warnings: 1
 
 # should Dancer2 show a stacktrace when an error is caught?
+# if set to yes, public/500.html will be ignored and either
+# views/500.tt or a default error template will be used.
 show_errors: 1
 
 # print the banner
@@ -1,6 +1,4 @@
-/*! jQuery v1.10.2 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license
-//@ sourceMappingURL=jquery.min.map
-*/
-(function(e,t){var n,r,i=typeof t,o=e.location,a=e.document,s=a.documentElement,l=e.jQuery,u=e.$,c={},p=[],f="1.10.2",d=p.concat,h=p.push,g=p.slice,m=p.indexOf,y=c.toString,v=c.hasOwnProperty,b=f.trim,x=function(e,t){return new x.fn.init(e,t,r)},w=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=/\S+/g,C=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,N=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,k=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,E=/^[\],:{}\s]*$/,S=/(?:^|:|,)(?:\s*\[)+/g,A=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,j=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,D=/^-ms-/,L=/-([\da-z])/gi,H=function(e,t){return t.toUpperCase()},q=function(e){(a.addEventListener||"load"===e.type||"complete"===a.readyState)&&(_(),x.ready())},_=function(){a.addEventListener?(a.removeEventListener("DOMContentLoaded",q,!1),e.removeEventListener("load",q,!1)):(a.detachEvent("onreadystatechange",q),e.detachEvent("onload",q))};x.fn=x.prototype={jquery:f,constructor:x,init:function(e,n,r){var i,o;if(!e)return this;if("string"==typeof e){if(i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:N.exec(e),!i||!i[1]&&n)return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e);if(i[1]){if(n=n instanceof x?n[0]:n,x.merge(this,x.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:a,!0)),k.test(i[1])&&x.isPlainObject(n))for(i in n)x.isFunction(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}if(o=a.getElementById(i[2]),o&&o.parentNode){if(o.id!==i[2])return r.find(e);this.length=1,this[0]=o}return this.context=a,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):x.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),x.makeArray(e,this))},selector:"",length:0,toArray:function(){return g.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=x.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return x.each(this,e,t)},ready:function(e){return x.ready.promise().done(e),this},slice:function(){return this.pushStack(g.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(x.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:h,sort:[].sort,splice:[].splice},x.fn.init.prototype=x.fn,x.extend=x.fn.extend=function(){var e,n,r,i,o,a,s=arguments[0]||{},l=1,u=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[1]||{},l=2),"object"==typeof s||x.isFunction(s)||(s={}),u===l&&(s=this,--l);u>l;l++)if(null!=(o=arguments[l]))for(i in o)e=s[i],r=o[i],s!==r&&(c&&r&&(x.isPlainObject(r)||(n=x.isArray(r)))?(n?(n=!1,a=e&&x.isArray(e)?e:[]):a=e&&x.isPlainObject(e)?e:{},s[i]=x.extend(c,a,r)):r!==t&&(s[i]=r));return s},x.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),noConflict:function(t){return e.$===x&&(e.$=u),t&&e.jQuery===x&&(e.jQuery=l),x},isReady:!1,readyWait:1,holdReady:function(e){e?x.readyWait++:x.ready(!0)},ready:function(e){if(e===!0?!--x.readyWait:!x.isReady){if(!a.body)return setTimeout(x.ready);x.isReady=!0,e!==!0&&--x.readyWait>0||(n.resolveWith(a,[x]),x.fn.trigger&&x(a).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===x.type(e)},isArray:Array.isArray||function(e){return"array"===x.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?c[y.call(e)]||"object":typeof e},isPlainObject:function(e){var n;if(!e||"object"!==x.type(e)||e.nodeType||x.isWindow(e))return!1;try{if(e.constructor&&!v.call(e,"constructor")&&!v.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(r){return!1}if(x.support.ownLast)for(n in e)return v.call(e,n);for(n in e);return n===t||v.call(e,n)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||a;var r=k.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=x.buildFragment([e],t,i),i&&x(i).remove(),x.merge([],r.childNodes))},parseJSON:function(n){return e.JSON&&e.JSON.parse?e.JSON.parse(n):null===n?n:"string"==typeof n&&(n=x.trim(n),n&&E.test(n.replace(A,"@").replace(j,"]").replace(S,"")))?Function("return "+n)():(x.error("Invalid JSON: "+n),t)},parseXML:function(n){var r,i;if(!n||"string"!=typeof n)return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(o){r=t}return r&&r.documentElement&&!r.getElementsByTagName("parsererror").length||x.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&x.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(D,"ms-").replace(L,H)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,n){var r,i=0,o=e.length,a=M(e);if(n){if(a){for(;o>i;i++)if(r=t.apply(e[i],n),r===!1)break}else for(i in e)if(r=t.apply(e[i],n),r===!1)break}else if(a){for(;o>i;i++)if(r=t.call(e[i],i,e[i]),r===!1)break}else for(i in e)if(r=t.call(e[i],i,e[i]),r===!1)break;return e},trim:b&&!b.call("\ufeff\u00a0")?function(e){return null==e?"":b.call(e)}:function(e){return null==e?"":(e+"").replace(C,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(M(Object(e))?x.merge(n,"string"==typeof e?[e]:e):h.call(n,e)),n},inArray:function(e,t,n){var r;if(t){if(m)return m.call(t,e,n);for(r=t.length,n=n?0>n?Math.max(0,r+n):n:0;r>n;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,o=0;if("number"==typeof r)for(;r>o;o++)e[i++]=n[o];else while(n[o]!==t)e[i++]=n[o++];return e.length=i,e},grep:function(e,t,n){var r,i=[],o=0,a=e.length;for(n=!!n;a>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,n){var r,i=0,o=e.length,a=M(e),s=[];if(a)for(;o>i;i++)r=t(e[i],i,n),null!=r&&(s[s.length]=r);else for(i in e)r=t(e[i],i,n),null!=r&&(s[s.length]=r);return d.apply([],s)},guid:1,proxy:function(e,n){var r,i,o;return"string"==typeof n&&(o=e[n],n=e,e=o),x.isFunction(e)?(r=g.call(arguments,2),i=function(){return e.apply(n||this,r.concat(g.call(arguments)))},i.guid=e.guid=e.guid||x.guid++,i):t},access:function(e,n,r,i,o,a,s){var l=0,u=e.length,c=null==r;if("object"===x.type(r)){o=!0;for(l in r)x.access(e,n,l,r[l],!0,a,s)}else if(i!==t&&(o=!0,x.isFunction(i)||(s=!0),c&&(s?(n.call(e,i),n=null):(c=n,n=function(e,t,n){return c.call(x(e),n)})),n))for(;u>l;l++)n(e[l],r,s?i:i.call(e[l],l,n(e[l],r)));return o?e:c?n.call(e):u?n(e[0],r):a},now:function(){return(new Date).getTime()},swap:function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i}}),x.ready.promise=function(t){if(!n)if(n=x.Deferred(),"complete"===a.readyState)setTimeout(x.ready);else if(a.addEventListener)a.addEventListener("DOMContentLoaded",q,!1),e.addEventListener("load",q,!1);else{a.attachEvent("onreadystatechange",q),e.attachEvent("onload",q);var r=!1;try{r=null==e.frameElement&&a.documentElement}catch(i){}r&&r.doScroll&&function o(){if(!x.isReady){try{r.doScroll("left")}catch(e){return setTimeout(o,50)}_(),x.ready()}}()}return n.promise(t)},x.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){c["[object "+t+"]"]=t.toLowerCase()});function M(e){var t=e.length,n=x.type(e);return x.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}r=x(a),function(e,t){var n,r,i,o,a,s,l,u,c,p,f,d,h,g,m,y,v,b="sizzle"+-new Date,w=e.document,T=0,C=0,N=st(),k=st(),E=st(),S=!1,A=function(e,t){return e===t?(S=!0,0):0},j=typeof t,D=1<<31,L={}.hasOwnProperty,H=[],q=H.pop,_=H.push,M=H.push,O=H.slice,F=H.indexOf||function(e){var t=0,n=this.length;for(;n>t;t++)if(this[t]===e)return t;return-1},B="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",P="[\\x20\\t\\r\\n\\f]",R="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",W=R.replace("w","w#"),$="\\["+P+"*("+R+")"+P+"*(?:([*^$|!~]?=)"+P+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+W+")|)|)"+P+"*\\]",I=":("+R+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+$.replace(3,8)+")*)|.*)\\)|)",z=RegExp("^"+P+"+|((?:^|[^\\\\])(?:\\\\.)*)"+P+"+$","g"),X=RegExp("^"+P+"*,"+P+"*"),U=RegExp("^"+P+"*([>+~]|"+P+")"+P+"*"),V=RegExp(P+"*[+~]"),Y=RegExp("="+P+"*([^\\]'\"]*)"+P+"*\\]","g"),J=RegExp(I),G=RegExp("^"+W+"$"),Q={ID:RegExp("^#("+R+")"),CLASS:RegExp("^\\.("+R+")"),TAG:RegExp("^("+R.replace("w","w*")+")"),ATTR:RegExp("^"+$),PSEUDO:RegExp("^"+I),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+P+"*(even|odd|(([+-]|)(\\d*)n|)"+P+"*(?:([+-]|)"+P+"*(\\d+)|))"+P+"*\\)|)","i"),bool:RegExp("^(?:"+B+")$","i"),needsContext:RegExp("^"+P+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+P+"*((?:-\\d)?\\d*)"+P+"*\\)|)(?=[^-]|$)","i")},K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,et=/^(?:input|select|textarea|button)$/i,tt=/^h\d$/i,nt=/'|\\/g,rt=RegExp("\\\\([\\da-f]{1,6}"+P+"?|("+P+")|.)","ig"),it=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:0>r?String.fromCharCode(r+65536):String.fromCharCode(55296|r>>10,56320|1023&r)};try{M.apply(H=O.call(w.childNodes),w.childNodes),H[w.childNodes.length].nodeType}catch(ot){M={apply:H.length?function(e,t){_.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function at(e,t,n,i){var o,a,s,l,u,c,d,m,y,x;if((t?t.ownerDocument||t:w)!==f&&p(t),t=t||f,n=n||[],!e||"string"!=typeof e)return n;if(1!==(l=t.nodeType)&&9!==l)return[];if(h&&!i){if(o=Z.exec(e))if(s=o[1]){if(9===l){if(a=t.getElementById(s),!a||!a.parentNode)return n;if(a.id===s)return n.push(a),n}else if(t.ownerDocument&&(a=t.ownerDocument.getElementById(s))&&v(t,a)&&a.id===s)return n.push(a),n}else{if(o[2])return M.apply(n,t.getElementsByTagName(e)),n;if((s=o[3])&&r.getElementsByClassName&&t.getElementsByClassName)return M.apply(n,t.getElementsByClassName(s)),n}if(r.qsa&&(!g||!g.test(e))){if(m=d=b,y=t,x=9===l&&e,1===l&&"object"!==t.nodeName.toLowerCase()){c=mt(e),(d=t.getAttribute("id"))?m=d.replace(nt,"\\$&"):t.setAttribute("id",m),m="[id='"+m+"'] ",u=c.length;while(u--)c[u]=m+yt(c[u]);y=V.test(e)&&t.parentNode||t,x=c.join(",")}if(x)try{return M.apply(n,y.querySelectorAll(x)),n}catch(T){}finally{d||t.removeAttribute("id")}}}return kt(e.replace(z,"$1"),t,n,i)}function st(){var e=[];function t(n,r){return e.push(n+=" ")>o.cacheLength&&delete t[e.shift()],t[n]=r}return t}function lt(e){return e[b]=!0,e}function ut(e){var t=f.createElement("div");try{return!!e(t)}catch(n){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function ct(e,t){var n=e.split("|"),r=e.length;while(r--)o.attrHandle[n[r]]=t}function pt(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&(~t.sourceIndex||D)-(~e.sourceIndex||D);if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function ft(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function dt(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function ht(e){return lt(function(t){return t=+t,lt(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}s=at.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},r=at.support={},p=at.setDocument=function(e){var n=e?e.ownerDocument||e:w,i=n.defaultView;return n!==f&&9===n.nodeType&&n.documentElement?(f=n,d=n.documentElement,h=!s(n),i&&i.attachEvent&&i!==i.top&&i.attachEvent("onbeforeunload",function(){p()}),r.attributes=ut(function(e){return e.className="i",!e.getAttribute("className")}),r.getElementsByTagName=ut(function(e){return e.appendChild(n.createComment("")),!e.getElementsByTagName("*").length}),r.getElementsByClassName=ut(function(e){return e.innerHTML="<div class='a'></div><div class='a i'></div>",e.firstChild.className="i",2===e.getElementsByClassName("i").length}),r.getById=ut(function(e){return d.appendChild(e).id=b,!n.getElementsByName||!n.getElementsByName(b).length}),r.getById?(o.find.ID=function(e,t){if(typeof t.getElementById!==j&&h){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},o.filter.ID=function(e){var t=e.replace(rt,it);return function(e){return e.getAttribute("id")===t}}):(delete o.find.ID,o.filter.ID=function(e){var t=e.replace(rt,it);return function(e){var n=typeof e.getAttributeNode!==j&&e.getAttributeNode("id");return n&&n.value===t}}),o.find.TAG=r.getElementsByTagName?function(e,n){return typeof n.getElementsByTagName!==j?n.getElementsByTagName(e):t}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},o.find.CLASS=r.getElementsByClassName&&function(e,n){return typeof n.getElementsByClassName!==j&&h?n.getElementsByClassName(e):t},m=[],g=[],(r.qsa=K.test(n.querySelectorAll))&&(ut(function(e){e.innerHTML="<select><option selected=''></option></select>",e.querySelectorAll("[selected]").length||g.push("\\["+P+"*(?:value|"+B+")"),e.querySelectorAll(":checked").length||g.push(":checked")}),ut(function(e){var t=n.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("t",""),e.querySelectorAll("[t^='']").length&&g.push("[*^$]="+P+"*(?:''|\"\")"),e.querySelectorAll(":enabled").length||g.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),g.push(",.*:")})),(r.matchesSelector=K.test(y=d.webkitMatchesSelector||d.mozMatchesSelector||d.oMatchesSelector||d.msMatchesSelector))&&ut(function(e){r.disconnectedMatch=y.call(e,"div"),y.call(e,"[s!='']:x"),m.push("!=",I)}),g=g.length&&RegExp(g.join("|")),m=m.length&&RegExp(m.join("|")),v=K.test(d.contains)||d.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},A=d.compareDocumentPosition?function(e,t){if(e===t)return S=!0,0;var i=t.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(t);return i?1&i||!r.sortDetached&&t.compareDocumentPosition(e)===i?e===n||v(w,e)?-1:t===n||v(w,t)?1:c?F.call(c,e)-F.call(c,t):0:4&i?-1:1:e.compareDocumentPosition?-1:1}:function(e,t){var r,i=0,o=e.parentNode,a=t.parentNode,s=[e],l=[t];if(e===t)return S=!0,0;if(!o||!a)return e===n?-1:t===n?1:o?-1:a?1:c?F.call(c,e)-F.call(c,t):0;if(o===a)return pt(e,t);r=e;while(r=r.parentNode)s.unshift(r);r=t;while(r=r.parentNode)l.unshift(r);while(s[i]===l[i])i++;return i?pt(s[i],l[i]):s[i]===w?-1:l[i]===w?1:0},n):f},at.matches=function(e,t){return at(e,null,null,t)},at.matchesSelector=function(e,t){if((e.ownerDocument||e)!==f&&p(e),t=t.replace(Y,"='$1']"),!(!r.matchesSelector||!h||m&&m.test(t)||g&&g.test(t)))try{var n=y.call(e,t);if(n||r.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(i){}return at(t,f,null,[e]).length>0},at.contains=function(e,t){return(e.ownerDocument||e)!==f&&p(e),v(e,t)},at.attr=function(e,n){(e.ownerDocument||e)!==f&&p(e);var i=o.attrHandle[n.toLowerCase()],a=i&&L.call(o.attrHandle,n.toLowerCase())?i(e,n,!h):t;return a===t?r.attributes||!h?e.getAttribute(n):(a=e.getAttributeNode(n))&&a.specified?a.value:null:a},at.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},at.uniqueSort=function(e){var t,n=[],i=0,o=0;if(S=!r.detectDuplicates,c=!r.sortStable&&e.slice(0),e.sort(A),S){while(t=e[o++])t===e[o]&&(i=n.push(o));while(i--)e.splice(n[i],1)}return e},a=at.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=a(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r];r++)n+=a(t);return n},o=at.selectors={cacheLength:50,createPseudo:lt,match:Q,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(rt,it),e[3]=(e[4]||e[5]||"").replace(rt,it),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||at.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&at.error(e[0]),e},PSEUDO:function(e){var n,r=!e[5]&&e[2];return Q.CHILD.test(e[0])?null:(e[3]&&e[4]!==t?e[2]=e[4]:r&&J.test(r)&&(n=mt(r,!0))&&(n=r.indexOf(")",r.length-n)-r.length)&&(e[0]=e[0].slice(0,n),e[2]=r.slice(0,n)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(rt,it).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=N[e+" "];return t||(t=RegExp("(^|"+P+")"+e+"("+P+"|$)"))&&N(e,function(e){return t.test("string"==typeof e.className&&e.className||typeof e.getAttribute!==j&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=at.attr(r,e);return null==i?"!="===t:t?(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i+" ").indexOf(n)>-1:"|="===t?i===n||i.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,l){var u,c,p,f,d,h,g=o!==a?"nextSibling":"previousSibling",m=t.parentNode,y=s&&t.nodeName.toLowerCase(),v=!l&&!s;if(m){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===y:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?m.firstChild:m.lastChild],a&&v){c=m[b]||(m[b]={}),u=c[e]||[],d=u[0]===T&&u[1],f=u[0]===T&&u[2],p=d&&m.childNodes[d];while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if(1===p.nodeType&&++f&&p===t){c[e]=[T,d,f];break}}else if(v&&(u=(t[b]||(t[b]={}))[e])&&u[0]===T)f=u[1];else while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===y:1===p.nodeType)&&++f&&(v&&((p[b]||(p[b]={}))[e]=[T,f]),p===t))break;return f-=i,f===r||0===f%r&&f/r>=0}}},PSEUDO:function(e,t){var n,r=o.pseudos[e]||o.setFilters[e.toLowerCase()]||at.error("unsupported pseudo: "+e);return r[b]?r(t):r.length>1?(n=[e,e,"",t],o.setFilters.hasOwnProperty(e.toLowerCase())?lt(function(e,n){var i,o=r(e,t),a=o.length;while(a--)i=F.call(e,o[a]),e[i]=!(n[i]=o[a])}):function(e){return r(e,0,n)}):r}},pseudos:{not:lt(function(e){var t=[],n=[],r=l(e.replace(z,"$1"));return r[b]?lt(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:lt(function(e){return function(t){return at(e,t).length>0}}),contains:lt(function(e){return function(t){return(t.textContent||t.innerText||a(t)).indexOf(e)>-1}}),lang:lt(function(e){return G.test(e||"")||at.error("unsupported lang: "+e),e=e.replace(rt,it).toLowerCase(),function(t){var n;do if(n=h?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===d},focus:function(e){return e===f.activeElement&&(!f.hasFocus||f.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!o.pseudos.empty(e)},header:function(e){return tt.test(e.nodeName)},input:function(e){return et.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:ht(function(){return[0]}),last:ht(function(e,t){return[t-1]}),eq:ht(function(e,t,n){return[0>n?n+t:n]}),even:ht(function(e,t){var n=0;for(;t>n;n+=2)e.push(n);return e}),odd:ht(function(e,t){var n=1;for(;t>n;n+=2)e.push(n);return e}),lt:ht(function(e,t,n){var r=0>n?n+t:n;for(;--r>=0;)e.push(r);return e}),gt:ht(function(e,t,n){var r=0>n?n+t:n;for(;t>++r;)e.push(r);return e})}},o.pseudos.nth=o.pseudos.eq;for(n in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})o.pseudos[n]=ft(n);for(n in{submit:!0,reset:!0})o.pseudos[n]=dt(n);function gt(){}gt.prototype=o.filters=o.pseudos,o.setFilters=new gt;function mt(e,t){var n,r,i,a,s,l,u,c=k[e+" "];if(c)return t?0:c.slice(0);s=e,l=[],u=o.preFilter;while(s){(!n||(r=X.exec(s)))&&(r&&(s=s.slice(r[0].length)||s),l.push(i=[])),n=!1,(r=U.exec(s))&&(n=r.shift(),i.push({value:n,type:r[0].replace(z," ")}),s=s.slice(n.length));for(a in o.filter)!(r=Q[a].exec(s))||u[a]&&!(r=u[a](r))||(n=r.shift(),i.push({value:n,type:a,matches:r}),s=s.slice(n.length));if(!n)break}return t?s.length:s?at.error(e):k(e,l).slice(0)}function yt(e){var t=0,n=e.length,r="";for(;n>t;t++)r+=e[t].value;return r}function vt(e,t,n){var r=t.dir,o=n&&"parentNode"===r,a=C++;return t.first?function(t,n,i){while(t=t[r])if(1===t.nodeType||o)return e(t,n,i)}:function(t,n,s){var l,u,c,p=T+" "+a;if(s){while(t=t[r])if((1===t.nodeType||o)&&e(t,n,s))return!0}else while(t=t[r])if(1===t.nodeType||o)if(c=t[b]||(t[b]={}),(u=c[r])&&u[0]===p){if((l=u[1])===!0||l===i)return l===!0}else if(u=c[r]=[p],u[1]=e(t,n,s)||i,u[1]===!0)return!0}}function bt(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function xt(e,t,n,r,i){var o,a=[],s=0,l=e.length,u=null!=t;for(;l>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),u&&t.push(s));return a}function wt(e,t,n,r,i,o){return r&&!r[b]&&(r=wt(r)),i&&!i[b]&&(i=wt(i,o)),lt(function(o,a,s,l){var u,c,p,f=[],d=[],h=a.length,g=o||Nt(t||"*",s.nodeType?[s]:s,[]),m=!e||!o&&t?g:xt(g,f,e,s,l),y=n?i||(o?e:h||r)?[]:a:m;if(n&&n(m,y,s,l),r){u=xt(y,d),r(u,[],s,l),c=u.length;while(c--)(p=u[c])&&(y[d[c]]=!(m[d[c]]=p))}if(o){if(i||e){if(i){u=[],c=y.length;while(c--)(p=y[c])&&u.push(m[c]=p);i(null,y=[],u,l)}c=y.length;while(c--)(p=y[c])&&(u=i?F.call(o,p):f[c])>-1&&(o[u]=!(a[u]=p))}}else y=xt(y===a?y.splice(h,y.length):y),i?i(null,a,y,l):M.apply(a,y)})}function Tt(e){var t,n,r,i=e.length,a=o.relative[e[0].type],s=a||o.relative[" "],l=a?1:0,c=vt(function(e){return e===t},s,!0),p=vt(function(e){return F.call(t,e)>-1},s,!0),f=[function(e,n,r){return!a&&(r||n!==u)||((t=n).nodeType?c(e,n,r):p(e,n,r))}];for(;i>l;l++)if(n=o.relative[e[l].type])f=[vt(bt(f),n)];else{if(n=o.filter[e[l].type].apply(null,e[l].matches),n[b]){for(r=++l;i>r;r++)if(o.relative[e[r].type])break;return wt(l>1&&bt(f),l>1&&yt(e.slice(0,l-1).concat({value:" "===e[l-2].type?"*":""})).replace(z,"$1"),n,r>l&&Tt(e.slice(l,r)),i>r&&Tt(e=e.slice(r)),i>r&&yt(e))}f.push(n)}return bt(f)}function Ct(e,t){var n=0,r=t.length>0,a=e.length>0,s=function(s,l,c,p,d){var h,g,m,y=[],v=0,b="0",x=s&&[],w=null!=d,C=u,N=s||a&&o.find.TAG("*",d&&l.parentNode||l),k=T+=null==C?1:Math.random()||.1;for(w&&(u=l!==f&&l,i=n);null!=(h=N[b]);b++){if(a&&h){g=0;while(m=e[g++])if(m(h,l,c)){p.push(h);break}w&&(T=k,i=++n)}r&&((h=!m&&h)&&v--,s&&x.push(h))}if(v+=b,r&&b!==v){g=0;while(m=t[g++])m(x,y,l,c);if(s){if(v>0)while(b--)x[b]||y[b]||(y[b]=q.call(p));y=xt(y)}M.apply(p,y),w&&!s&&y.length>0&&v+t.length>1&&at.uniqueSort(p)}return w&&(T=k,u=C),x};return r?lt(s):s}l=at.compile=function(e,t){var n,r=[],i=[],o=E[e+" "];if(!o){t||(t=mt(e)),n=t.length;while(n--)o=Tt(t[n]),o[b]?r.push(o):i.push(o);o=E(e,Ct(i,r))}return o};function Nt(e,t,n){var r=0,i=t.length;for(;i>r;r++)at(e,t[r],n);return n}function kt(e,t,n,i){var a,s,u,c,p,f=mt(e);if(!i&&1===f.length){if(s=f[0]=f[0].slice(0),s.length>2&&"ID"===(u=s[0]).type&&r.getById&&9===t.nodeType&&h&&o.relative[s[1].type]){if(t=(o.find.ID(u.matches[0].replace(rt,it),t)||[])[0],!t)return n;e=e.slice(s.shift().value.length)}a=Q.needsContext.test(e)?0:s.length;while(a--){if(u=s[a],o.relative[c=u.type])break;if((p=o.find[c])&&(i=p(u.matches[0].replace(rt,it),V.test(s[0].type)&&t.parentNode||t))){if(s.splice(a,1),e=i.length&&yt(s),!e)return M.apply(n,i),n;break}}}return l(e,f)(i,t,!h,n,V.test(e)),n}r.sortStable=b.split("").sort(A).join("")===b,r.detectDuplicates=S,p(),r.sortDetached=ut(function(e){return 1&e.compareDocumentPosition(f.createElement("div"))}),ut(function(e){return e.innerHTML="<a href='#'></a>","#"===e.firstChild.getAttribute("href")})||ct("type|href|height|width",function(e,n,r){return r?t:e.getAttribute(n,"type"===n.toLowerCase()?1:2)}),r.attributes&&ut(function(e){return e.innerHTML="<input/>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||ct("value",function(e,n,r){return r||"input"!==e.nodeName.toLowerCase()?t:e.defaultValue}),ut(function(e){return null==e.getAttribute("disabled")})||ct(B,function(e,n,r){var i;return r?t:(i=e.getAttributeNode(n))&&i.specified?i.value:e[n]===!0?n.toLowerCase():null}),x.find=at,x.expr=at.selectors,x.expr[":"]=x.expr.pseudos,x.unique=at.uniqueSort,x.text=at.getText,x.isXMLDoc=at.isXML,x.contains=at.contains}(e);var O={};function F(e){var t=O[e]={};return x.each(e.match(T)||[],function(e,n){t[n]=!0}),t}x.Callbacks=function(e){e="string"==typeof e?O[e]||F(e):x.extend({},e);var n,r,i,o,a,s,l=[],u=!e.once&&[],c=function(t){for(r=e.memory&&t,i=!0,a=s||0,s=0,o=l.length,n=!0;l&&o>a;a++)if(l[a].apply(t[0],t[1])===!1&&e.stopOnFalse){r=!1;break}n=!1,l&&(u?u.length&&c(u.shift()):r?l=[]:p.disable())},p={add:function(){if(l){var t=l.length;(function i(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=l.length:r&&(s=t,c(r))}return this},remove:function(){return l&&x.each(arguments,function(e,t){var r;while((r=x.inArray(t,l,r))>-1)l.splice(r,1),n&&(o>=r&&o--,a>=r&&a--)}),this},has:function(e){return e?x.inArray(e,l)>-1:!(!l||!l.length)},empty:function(){return l=[],o=0,this},disable:function(){return l=u=r=t,this},disabled:function(){return!l},lock:function(){return u=t,r||p.disable(),this},locked:function(){return!u},fireWith:function(e,t){return!l||i&&!u||(t=t||[],t=[e,t.slice?t.slice():t],n?u.push(t):c(t)),this},fire:function(){return p.fireWith(this,arguments),this},fired:function(){return!!i}};return p},x.extend({Deferred:function(e){var t=[["resolve","done",x.Callbacks("once memory"),"resolved"],["reject","fail",x.Callbacks("once memory"),"rejected"],["notify","progress",x.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return x.Deferred(function(n){x.each(t,function(t,o){var a=o[0],s=x.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&x.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?x.extend(e,r):r}},i={};return r.pipe=r.then,x.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=g.call(arguments),r=n.length,i=1!==r||e&&x.isFunction(e.promise)?r:0,o=1===i?e:x.Deferred(),a=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?g.call(arguments):r,n===s?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},s,l,u;if(r>1)for(s=Array(r),l=Array(r),u=Array(r);r>t;t++)n[t]&&x.isFunction(n[t].promise)?n[t].promise().done(a(t,u,n)).fail(o.reject).progress(a(t,l,s)):--i;return i||o.resolveWith(u,n),o.promise()}}),x.support=function(t){var n,r,o,s,l,u,c,p,f,d=a.createElement("div");if(d.setAttribute("className","t"),d.innerHTML="  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",n=d.getElementsByTagName("*")||[],r=d.getElementsByTagName("a")[0],!r||!r.style||!n.length)return t;s=a.createElement("select"),u=s.appendChild(a.createElement("option")),o=d.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t.getSetAttribute="t"!==d.className,t.leadingWhitespace=3===d.firstChild.nodeType,t.tbody=!d.getElementsByTagName("tbody").length,t.htmlSerialize=!!d.getElementsByTagName("link").length,t.style=/top/.test(r.getAttribute("style")),t.hrefNormalized="/a"===r.getAttribute("href"),t.opacity=/^0.5/.test(r.style.opacity),t.cssFloat=!!r.style.cssFloat,t.checkOn=!!o.value,t.optSelected=u.selected,t.enctype=!!a.createElement("form").enctype,t.html5Clone="<:nav></:nav>"!==a.createElement("nav").cloneNode(!0).outerHTML,t.inlineBlockNeedsLayout=!1,t.shrinkWrapBlocks=!1,t.pixelPosition=!1,t.deleteExpando=!0,t.noCloneEvent=!0,t.reliableMarginRight=!0,t.boxSizingReliable=!0,o.checked=!0,t.noCloneChecked=o.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!u.disabled;try{delete d.test}catch(h){t.deleteExpando=!1}o=a.createElement("input"),o.setAttribute("value",""),t.input=""===o.getAttribute("value"),o.value="t",o.setAttribute("type","radio"),t.radioValue="t"===o.value,o.setAttribute("checked","t"),o.setAttribute("name","t"),l=a.createDocumentFragment(),l.appendChild(o),t.appendChecked=o.checked,t.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,d.attachEvent&&(d.attachEvent("onclick",function(){t.noCloneEvent=!1}),d.cloneNode(!0).click());for(f in{submit:!0,change:!0,focusin:!0})d.setAttribute(c="on"+f,"t"),t[f+"Bubbles"]=c in e||d.attributes[c].expando===!1;d.style.backgroundClip="content-box",d.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===d.style.backgroundClip;for(f in x(t))break;return t.ownLast="0"!==f,x(function(){var n,r,o,s="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",l=a.getElementsByTagName("body")[0];l&&(n=a.createElement("div"),n.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",l.appendChild(n).appendChild(d),d.innerHTML="<table><tr><td></td><td>t</td></tr></table>",o=d.getElementsByTagName("td"),o[0].style.cssText="padding:0;margin:0;border:0;display:none",p=0===o[0].offsetHeight,o[0].style.display="",o[1].style.display="none",t.reliableHiddenOffsets=p&&0===o[0].offsetHeight,d.innerHTML="",d.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",x.swap(l,null!=l.style.zoom?{zoom:1}:{},function(){t.boxSizing=4===d.offsetWidth}),e.getComputedStyle&&(t.pixelPosition="1%"!==(e.getComputedStyle(d,null)||{}).top,t.boxSizingReliable="4px"===(e.getComputedStyle(d,null)||{width:"4px"}).width,r=d.appendChild(a.createElement("div")),r.style.cssText=d.style.cssText=s,r.style.marginRight=r.style.width="0",d.style.width="1px",t.reliableMarginRight=!parseFloat((e.getComputedStyle(r,null)||{}).marginRight)),typeof d.style.zoom!==i&&(d.innerHTML="",d.style.cssText=s+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=3===d.offsetWidth,d.style.display="block",d.innerHTML="<div></div>",d.firstChild.style.width="5px",t.shrinkWrapBlocks=3!==d.offsetWidth,t.inlineBlockNeedsLayout&&(l.style.zoom=1)),l.removeChild(n),n=d=o=r=null)}),n=s=l=u=r=o=null,t
-}({});var B=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,P=/([A-Z])/g;function R(e,n,r,i){if(x.acceptData(e)){var o,a,s=x.expando,l=e.nodeType,u=l?x.cache:e,c=l?e[s]:e[s]&&s;if(c&&u[c]&&(i||u[c].data)||r!==t||"string"!=typeof n)return c||(c=l?e[s]=p.pop()||x.guid++:s),u[c]||(u[c]=l?{}:{toJSON:x.noop}),("object"==typeof n||"function"==typeof n)&&(i?u[c]=x.extend(u[c],n):u[c].data=x.extend(u[c].data,n)),a=u[c],i||(a.data||(a.data={}),a=a.data),r!==t&&(a[x.camelCase(n)]=r),"string"==typeof n?(o=a[n],null==o&&(o=a[x.camelCase(n)])):o=a,o}}function W(e,t,n){if(x.acceptData(e)){var r,i,o=e.nodeType,a=o?x.cache:e,s=o?e[x.expando]:x.expando;if(a[s]){if(t&&(r=n?a[s]:a[s].data)){x.isArray(t)?t=t.concat(x.map(t,x.camelCase)):t in r?t=[t]:(t=x.camelCase(t),t=t in r?[t]:t.split(" ")),i=t.length;while(i--)delete r[t[i]];if(n?!I(r):!x.isEmptyObject(r))return}(n||(delete a[s].data,I(a[s])))&&(o?x.cleanData([e],!0):x.support.deleteExpando||a!=a.window?delete a[s]:a[s]=null)}}}x.extend({cache:{},noData:{applet:!0,embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(e){return e=e.nodeType?x.cache[e[x.expando]]:e[x.expando],!!e&&!I(e)},data:function(e,t,n){return R(e,t,n)},removeData:function(e,t){return W(e,t)},_data:function(e,t,n){return R(e,t,n,!0)},_removeData:function(e,t){return W(e,t,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;var t=e.nodeName&&x.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),x.fn.extend({data:function(e,n){var r,i,o=null,a=0,s=this[0];if(e===t){if(this.length&&(o=x.data(s),1===s.nodeType&&!x._data(s,"parsedAttrs"))){for(r=s.attributes;r.length>a;a++)i=r[a].name,0===i.indexOf("data-")&&(i=x.camelCase(i.slice(5)),$(s,i,o[i]));x._data(s,"parsedAttrs",!0)}return o}return"object"==typeof e?this.each(function(){x.data(this,e)}):arguments.length>1?this.each(function(){x.data(this,e,n)}):s?$(s,e,x.data(s,e)):null},removeData:function(e){return this.each(function(){x.removeData(this,e)})}});function $(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(P,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:B.test(r)?x.parseJSON(r):r}catch(o){}x.data(e,n,r)}else r=t}return r}function I(e){var t;for(t in e)if(("data"!==t||!x.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}x.extend({queue:function(e,n,r){var i;return e?(n=(n||"fx")+"queue",i=x._data(e,n),r&&(!i||x.isArray(r)?i=x._data(e,n,x.makeArray(r)):i.push(r)),i||[]):t},dequeue:function(e,t){t=t||"fx";var n=x.queue(e,t),r=n.length,i=n.shift(),o=x._queueHooks(e,t),a=function(){x.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return x._data(e,n)||x._data(e,n,{empty:x.Callbacks("once memory").add(function(){x._removeData(e,t+"queue"),x._removeData(e,n)})})}}),x.fn.extend({queue:function(e,n){var r=2;return"string"!=typeof e&&(n=e,e="fx",r--),r>arguments.length?x.queue(this[0],e):n===t?this:this.each(function(){var t=x.queue(this,e,n);x._queueHooks(this,e),"fx"===e&&"inprogress"!==t[0]&&x.dequeue(this,e)})},dequeue:function(e){return this.each(function(){x.dequeue(this,e)})},delay:function(e,t){return e=x.fx?x.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,o=x.Deferred(),a=this,s=this.length,l=function(){--i||o.resolveWith(a,[a])};"string"!=typeof e&&(n=e,e=t),e=e||"fx";while(s--)r=x._data(a[s],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(l));return l(),o.promise(n)}});var z,X,U=/[\t\r\n\f]/g,V=/\r/g,Y=/^(?:input|select|textarea|button|object)$/i,J=/^(?:a|area)$/i,G=/^(?:checked|selected)$/i,Q=x.support.getSetAttribute,K=x.support.input;x.fn.extend({attr:function(e,t){return x.access(this,x.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){x.removeAttr(this,e)})},prop:function(e,t){return x.access(this,x.prop,e,t,arguments.length>1)},removeProp:function(e){return e=x.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,o,a=0,s=this.length,l="string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).addClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=x.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,a=0,s=this.length,l=0===arguments.length||"string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).removeClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):"")){o=0;while(i=t[o++])while(r.indexOf(" "+i+" ")>=0)r=r.replace(" "+i+" "," ");n.className=e?x.trim(r):""}return this},toggleClass:function(e,t){var n=typeof e;return"boolean"==typeof t&&"string"===n?t?this.addClass(e):this.removeClass(e):x.isFunction(e)?this.each(function(n){x(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if("string"===n){var t,r=0,o=x(this),a=e.match(T)||[];while(t=a[r++])o.hasClass(t)?o.removeClass(t):o.addClass(t)}else(n===i||"boolean"===n)&&(this.className&&x._data(this,"__className__",this.className),this.className=this.className||e===!1?"":x._data(this,"__className__")||"")})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(U," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,o=this[0];{if(arguments.length)return i=x.isFunction(e),this.each(function(n){var o;1===this.nodeType&&(o=i?e.call(this,n,x(this).val()):e,null==o?o="":"number"==typeof o?o+="":x.isArray(o)&&(o=x.map(o,function(e){return null==e?"":e+""})),r=x.valHooks[this.type]||x.valHooks[this.nodeName.toLowerCase()],r&&"set"in r&&r.set(this,o,"value")!==t||(this.value=o))});if(o)return r=x.valHooks[o.type]||x.valHooks[o.nodeName.toLowerCase()],r&&"get"in r&&(n=r.get(o,"value"))!==t?n:(n=o.value,"string"==typeof n?n.replace(V,""):null==n?"":n)}}}),x.extend({valHooks:{option:{get:function(e){var t=x.find.attr(e,"value");return null!=t?t:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,a=o?null:[],s=o?i+1:r.length,l=0>i?s:o?i:0;for(;s>l;l++)if(n=r[l],!(!n.selected&&l!==i||(x.support.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&x.nodeName(n.parentNode,"optgroup"))){if(t=x(n).val(),o)return t;a.push(t)}return a},set:function(e,t){var n,r,i=e.options,o=x.makeArray(t),a=i.length;while(a--)r=i[a],(r.selected=x.inArray(x(r).val(),o)>=0)&&(n=!0);return n||(e.selectedIndex=-1),o}}},attr:function(e,n,r){var o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return typeof e.getAttribute===i?x.prop(e,n,r):(1===s&&x.isXMLDoc(e)||(n=n.toLowerCase(),o=x.attrHooks[n]||(x.expr.match.bool.test(n)?X:z)),r===t?o&&"get"in o&&null!==(a=o.get(e,n))?a:(a=x.find.attr(e,n),null==a?t:a):null!==r?o&&"set"in o&&(a=o.set(e,r,n))!==t?a:(e.setAttribute(n,r+""),r):(x.removeAttr(e,n),t))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(T);if(o&&1===e.nodeType)while(n=o[i++])r=x.propFix[n]||n,x.expr.match.bool.test(n)?K&&Q||!G.test(n)?e[r]=!1:e[x.camelCase("default-"+n)]=e[r]=!1:x.attr(e,n,""),e.removeAttribute(Q?n:r)},attrHooks:{type:{set:function(e,t){if(!x.support.radioValue&&"radio"===t&&x.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},propFix:{"for":"htmlFor","class":"className"},prop:function(e,n,r){var i,o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return a=1!==s||!x.isXMLDoc(e),a&&(n=x.propFix[n]||n,o=x.propHooks[n]),r!==t?o&&"set"in o&&(i=o.set(e,r,n))!==t?i:e[n]=r:o&&"get"in o&&null!==(i=o.get(e,n))?i:e[n]},propHooks:{tabIndex:{get:function(e){var t=x.find.attr(e,"tabindex");return t?parseInt(t,10):Y.test(e.nodeName)||J.test(e.nodeName)&&e.href?0:-1}}}}),X={set:function(e,t,n){return t===!1?x.removeAttr(e,n):K&&Q||!G.test(n)?e.setAttribute(!Q&&x.propFix[n]||n,n):e[x.camelCase("default-"+n)]=e[n]=!0,n}},x.each(x.expr.match.bool.source.match(/\w+/g),function(e,n){var r=x.expr.attrHandle[n]||x.find.attr;x.expr.attrHandle[n]=K&&Q||!G.test(n)?function(e,n,i){var o=x.expr.attrHandle[n],a=i?t:(x.expr.attrHandle[n]=t)!=r(e,n,i)?n.toLowerCase():null;return x.expr.attrHandle[n]=o,a}:function(e,n,r){return r?t:e[x.camelCase("default-"+n)]?n.toLowerCase():null}}),K&&Q||(x.attrHooks.value={set:function(e,n,r){return x.nodeName(e,"input")?(e.defaultValue=n,t):z&&z.set(e,n,r)}}),Q||(z={set:function(e,n,r){var i=e.getAttributeNode(r);return i||e.setAttributeNode(i=e.ownerDocument.createAttribute(r)),i.value=n+="","value"===r||n===e.getAttribute(r)?n:t}},x.expr.attrHandle.id=x.expr.attrHandle.name=x.expr.attrHandle.coords=function(e,n,r){var i;return r?t:(i=e.getAttributeNode(n))&&""!==i.value?i.value:null},x.valHooks.button={get:function(e,n){var r=e.getAttributeNode(n);return r&&r.specified?r.value:t},set:z.set},x.attrHooks.contenteditable={set:function(e,t,n){z.set(e,""===t?!1:t,n)}},x.each(["width","height"],function(e,n){x.attrHooks[n]={set:function(e,r){return""===r?(e.setAttribute(n,"auto"),r):t}}})),x.support.hrefNormalized||x.each(["href","src"],function(e,t){x.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}}),x.support.style||(x.attrHooks.style={get:function(e){return e.style.cssText||t},set:function(e,t){return e.style.cssText=t+""}}),x.support.optSelected||(x.propHooks.selected={get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}}),x.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){x.propFix[this.toLowerCase()]=this}),x.support.enctype||(x.propFix.enctype="encoding"),x.each(["radio","checkbox"],function(){x.valHooks[this]={set:function(e,n){return x.isArray(n)?e.checked=x.inArray(x(e).val(),n)>=0:t}},x.support.checkOn||(x.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var Z=/^(?:input|select|textarea)$/i,et=/^key/,tt=/^(?:mouse|contextmenu)|click/,nt=/^(?:focusinfocus|focusoutblur)$/,rt=/^([^.]*)(?:\.(.+)|)$/;function it(){return!0}function ot(){return!1}function at(){try{return a.activeElement}catch(e){}}x.event={global:{},add:function(e,n,r,o,a){var s,l,u,c,p,f,d,h,g,m,y,v=x._data(e);if(v){r.handler&&(c=r,r=c.handler,a=c.selector),r.guid||(r.guid=x.guid++),(l=v.events)||(l=v.events={}),(f=v.handle)||(f=v.handle=function(e){return typeof x===i||e&&x.event.triggered===e.type?t:x.event.dispatch.apply(f.elem,arguments)},f.elem=e),n=(n||"").match(T)||[""],u=n.length;while(u--)s=rt.exec(n[u])||[],g=y=s[1],m=(s[2]||"").split(".").sort(),g&&(p=x.event.special[g]||{},g=(a?p.delegateType:p.bindType)||g,p=x.event.special[g]||{},d=x.extend({type:g,origType:y,data:o,handler:r,guid:r.guid,selector:a,needsContext:a&&x.expr.match.needsContext.test(a),namespace:m.join(".")},c),(h=l[g])||(h=l[g]=[],h.delegateCount=0,p.setup&&p.setup.call(e,o,m,f)!==!1||(e.addEventListener?e.addEventListener(g,f,!1):e.attachEvent&&e.attachEvent("on"+g,f))),p.add&&(p.add.call(e,d),d.handler.guid||(d.handler.guid=r.guid)),a?h.splice(h.delegateCount++,0,d):h.push(d),x.event.global[g]=!0);e=null}},remove:function(e,t,n,r,i){var o,a,s,l,u,c,p,f,d,h,g,m=x.hasData(e)&&x._data(e);if(m&&(c=m.events)){t=(t||"").match(T)||[""],u=t.length;while(u--)if(s=rt.exec(t[u])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){p=x.event.special[d]||{},d=(r?p.delegateType:p.bindType)||d,f=c[d]||[],s=s[2]&&RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),l=o=f.length;while(o--)a=f[o],!i&&g!==a.origType||n&&n.guid!==a.guid||s&&!s.test(a.namespace)||r&&r!==a.selector&&("**"!==r||!a.selector)||(f.splice(o,1),a.selector&&f.delegateCount--,p.remove&&p.remove.call(e,a));l&&!f.length&&(p.teardown&&p.teardown.call(e,h,m.handle)!==!1||x.removeEvent(e,d,m.handle),delete c[d])}else for(d in c)x.event.remove(e,d+t[u],n,r,!0);x.isEmptyObject(c)&&(delete m.handle,x._removeData(e,"events"))}},trigger:function(n,r,i,o){var s,l,u,c,p,f,d,h=[i||a],g=v.call(n,"type")?n.type:n,m=v.call(n,"namespace")?n.namespace.split("."):[];if(u=f=i=i||a,3!==i.nodeType&&8!==i.nodeType&&!nt.test(g+x.event.triggered)&&(g.indexOf(".")>=0&&(m=g.split("."),g=m.shift(),m.sort()),l=0>g.indexOf(":")&&"on"+g,n=n[x.expando]?n:new x.Event(g,"object"==typeof n&&n),n.isTrigger=o?2:3,n.namespace=m.join("."),n.namespace_re=n.namespace?RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,n.result=t,n.target||(n.target=i),r=null==r?[n]:x.makeArray(r,[n]),p=x.event.special[g]||{},o||!p.trigger||p.trigger.apply(i,r)!==!1)){if(!o&&!p.noBubble&&!x.isWindow(i)){for(c=p.delegateType||g,nt.test(c+g)||(u=u.parentNode);u;u=u.parentNode)h.push(u),f=u;f===(i.ownerDocument||a)&&h.push(f.defaultView||f.parentWindow||e)}d=0;while((u=h[d++])&&!n.isPropagationStopped())n.type=d>1?c:p.bindType||g,s=(x._data(u,"events")||{})[n.type]&&x._data(u,"handle"),s&&s.apply(u,r),s=l&&u[l],s&&x.acceptData(u)&&s.apply&&s.apply(u,r)===!1&&n.preventDefault();if(n.type=g,!o&&!n.isDefaultPrevented()&&(!p._default||p._default.apply(h.pop(),r)===!1)&&x.acceptData(i)&&l&&i[g]&&!x.isWindow(i)){f=i[l],f&&(i[l]=null),x.event.triggered=g;try{i[g]()}catch(y){}x.event.triggered=t,f&&(i[l]=f)}return n.result}},dispatch:function(e){e=x.event.fix(e);var n,r,i,o,a,s=[],l=g.call(arguments),u=(x._data(this,"events")||{})[e.type]||[],c=x.event.special[e.type]||{};if(l[0]=e,e.delegateTarget=this,!c.preDispatch||c.preDispatch.call(this,e)!==!1){s=x.event.handlers.call(this,e,u),n=0;while((o=s[n++])&&!e.isPropagationStopped()){e.currentTarget=o.elem,a=0;while((i=o.handlers[a++])&&!e.isImmediatePropagationStopped())(!e.namespace_re||e.namespace_re.test(i.namespace))&&(e.handleObj=i,e.data=i.data,r=((x.event.special[i.origType]||{}).handle||i.handler).apply(o.elem,l),r!==t&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,e),e.result}},handlers:function(e,n){var r,i,o,a,s=[],l=n.delegateCount,u=e.target;if(l&&u.nodeType&&(!e.button||"click"!==e.type))for(;u!=this;u=u.parentNode||this)if(1===u.nodeType&&(u.disabled!==!0||"click"!==e.type)){for(o=[],a=0;l>a;a++)i=n[a],r=i.selector+" ",o[r]===t&&(o[r]=i.needsContext?x(r,this).index(u)>=0:x.find(r,this,null,[u]).length),o[r]&&o.push(i);o.length&&s.push({elem:u,handlers:o})}return n.length>l&&s.push({elem:this,handlers:n.slice(l)}),s},fix:function(e){if(e[x.expando])return e;var t,n,r,i=e.type,o=e,s=this.fixHooks[i];s||(this.fixHooks[i]=s=tt.test(i)?this.mouseHooks:et.test(i)?this.keyHooks:{}),r=s.props?this.props.concat(s.props):this.props,e=new x.Event(o),t=r.length;while(t--)n=r[t],e[n]=o[n];return e.target||(e.target=o.srcElement||a),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,o):e},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,i,o,s=n.button,l=n.fromElement;return null==e.pageX&&null!=n.clientX&&(i=e.target.ownerDocument||a,o=i.documentElement,r=i.body,e.pageX=n.clientX+(o&&o.scrollLeft||r&&r.scrollLeft||0)-(o&&o.clientLeft||r&&r.clientLeft||0),e.pageY=n.clientY+(o&&o.scrollTop||r&&r.scrollTop||0)-(o&&o.clientTop||r&&r.clientTop||0)),!e.relatedTarget&&l&&(e.relatedTarget=l===e.target?n.toElement:l),e.which||s===t||(e.which=1&s?1:2&s?3:4&s?2:0),e}},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==at()&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:"focusin"},blur:{trigger:function(){return this===at()&&this.blur?(this.blur(),!1):t},delegateType:"focusout"},click:{trigger:function(){return x.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):t},_default:function(e){return x.nodeName(e.target,"a")}},beforeunload:{postDispatch:function(e){e.result!==t&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=x.extend(new x.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?x.event.trigger(i,null,t):x.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},x.removeEvent=a.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]===i&&(e[r]=null),e.detachEvent(r,n))},x.Event=function(e,n){return this instanceof x.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?it:ot):this.type=e,n&&x.extend(this,n),this.timeStamp=e&&e.timeStamp||x.now(),this[x.expando]=!0,t):new x.Event(e,n)},x.Event.prototype={isDefaultPrevented:ot,isPropagationStopped:ot,isImmediatePropagationStopped:ot,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=it,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=it,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=it,this.stopPropagation()}},x.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){x.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;return(!i||i!==r&&!x.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),x.support.submitBubbles||(x.event.special.submit={setup:function(){return x.nodeName(this,"form")?!1:(x.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=x.nodeName(n,"input")||x.nodeName(n,"button")?n.form:t;r&&!x._data(r,"submitBubbles")&&(x.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),x._data(r,"submitBubbles",!0))}),t)},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&x.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){return x.nodeName(this,"form")?!1:(x.event.remove(this,"._submit"),t)}}),x.support.changeBubbles||(x.event.special.change={setup:function(){return Z.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(x.event.add(this,"propertychange._change",function(e){"checked"===e.originalEvent.propertyName&&(this._just_changed=!0)}),x.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),x.event.simulate("change",this,e,!0)})),!1):(x.event.add(this,"beforeactivate._change",function(e){var t=e.target;Z.test(t.nodeName)&&!x._data(t,"changeBubbles")&&(x.event.add(t,"change._change",function(e){!this.parentNode||e.isSimulated||e.isTrigger||x.event.simulate("change",this.parentNode,e,!0)}),x._data(t,"changeBubbles",!0))}),t)},handle:function(e){var n=e.target;return this!==n||e.isSimulated||e.isTrigger||"radio"!==n.type&&"checkbox"!==n.type?e.handleObj.handler.apply(this,arguments):t},teardown:function(){return x.event.remove(this,"._change"),!Z.test(this.nodeName)}}),x.support.focusinBubbles||x.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){x.event.simulate(t,e.target,x.event.fix(e),!0)};x.event.special[t]={setup:function(){0===n++&&a.addEventListener(e,r,!0)},teardown:function(){0===--n&&a.removeEventListener(e,r,!0)}}}),x.fn.extend({on:function(e,n,r,i,o){var a,s;if("object"==typeof e){"string"!=typeof n&&(r=r||n,n=t);for(a in e)this.on(a,n,r,e[a],o);return this}if(null==r&&null==i?(i=n,r=n=t):null==i&&("string"==typeof n?(i=r,r=t):(i=r,r=n,n=t)),i===!1)i=ot;else if(!i)return this;return 1===o&&(s=i,i=function(e){return x().off(e),s.apply(this,arguments)},i.guid=s.guid||(s.guid=x.guid++)),this.each(function(){x.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,o;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,x(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if("object"==typeof e){for(o in e)this.off(o,n,e[o]);return this}return(n===!1||"function"==typeof n)&&(r=n,n=t),r===!1&&(r=ot),this.each(function(){x.event.remove(this,e,r,n)})},trigger:function(e,t){return this.each(function(){x.event.trigger(e,t,this)})},triggerHandler:function(e,n){var r=this[0];return r?x.event.trigger(e,n,r,!0):t}});var st=/^.[^:#\[\.,]*$/,lt=/^(?:parents|prev(?:Until|All))/,ut=x.expr.match.needsContext,ct={children:!0,contents:!0,next:!0,prev:!0};x.fn.extend({find:function(e){var t,n=[],r=this,i=r.length;if("string"!=typeof e)return this.pushStack(x(e).filter(function(){for(t=0;i>t;t++)if(x.contains(r[t],this))return!0}));for(t=0;i>t;t++)x.find(e,r[t],n);return n=this.pushStack(i>1?x.unique(n):n),n.selector=this.selector?this.selector+" "+e:e,n},has:function(e){var t,n=x(e,this),r=n.length;return this.filter(function(){for(t=0;r>t;t++)if(x.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(ft(this,e||[],!0))},filter:function(e){return this.pushStack(ft(this,e||[],!1))},is:function(e){return!!ft(this,"string"==typeof e&&ut.test(e)?x(e):e||[],!1).length},closest:function(e,t){var n,r=0,i=this.length,o=[],a=ut.test(e)||"string"!=typeof e?x(e,t||this.context):0;for(;i>r;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(11>n.nodeType&&(a?a.index(n)>-1:1===n.nodeType&&x.find.matchesSelector(n,e))){n=o.push(n);break}return this.pushStack(o.length>1?x.unique(o):o)},index:function(e){return e?"string"==typeof e?x.inArray(this[0],x(e)):x.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n="string"==typeof e?x(e,t):x.makeArray(e&&e.nodeType?[e]:e),r=x.merge(this.get(),n);return this.pushStack(x.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}});function pt(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}x.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return x.dir(e,"parentNode")},parentsUntil:function(e,t,n){return x.dir(e,"parentNode",n)},next:function(e){return pt(e,"nextSibling")},prev:function(e){return pt(e,"previousSibling")},nextAll:function(e){return x.dir(e,"nextSibling")},prevAll:function(e){return x.dir(e,"previousSibling")},nextUntil:function(e,t,n){return x.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return x.dir(e,"previousSibling",n)},siblings:function(e){return x.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return x.sibling(e.firstChild)},contents:function(e){return x.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:x.merge([],e.childNodes)}},function(e,t){x.fn[e]=function(n,r){var i=x.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=x.filter(r,i)),this.length>1&&(ct[e]||(i=x.unique(i)),lt.test(e)&&(i=i.reverse())),this.pushStack(i)}}),x.extend({filter:function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?x.find.matchesSelector(r,e)?[r]:[]:x.find.matches(e,x.grep(t,function(e){return 1===e.nodeType}))},dir:function(e,n,r){var i=[],o=e[n];while(o&&9!==o.nodeType&&(r===t||1!==o.nodeType||!x(o).is(r)))1===o.nodeType&&i.push(o),o=o[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});function ft(e,t,n){if(x.isFunction(t))return x.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return x.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(st.test(t))return x.filter(t,e,n);t=x.filter(t,e)}return x.grep(e,function(e){return x.inArray(e,t)>=0!==n})}function dt(e){var t=ht.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}var ht="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",gt=/ jQuery\d+="(?:null|\d+)"/g,mt=RegExp("<(?:"+ht+")[\\s/>]","i"),yt=/^\s+/,vt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bt=/<([\w:]+)/,xt=/<tbody/i,wt=/<|&#?\w+;/,Tt=/<(?:script|style|link)/i,Ct=/^(?:checkbox|radio)$/i,Nt=/checked\s*(?:[^=]|=\s*.checked.)/i,kt=/^$|\/(?:java|ecma)script/i,Et=/^true\/(.*)/,St=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,At={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:x.support.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},jt=dt(a),Dt=jt.appendChild(a.createElement("div"));At.optgroup=At.option,At.tbody=At.tfoot=At.colgroup=At.caption=At.thead,At.th=At.td,x.fn.extend({text:function(e){return x.access(this,function(e){return e===t?x.text(this):this.empty().append((this[0]&&this[0].ownerDocument||a).createTextNode(e))},null,e,arguments.length)},append:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Lt(this,e);t.appendChild(e)}})},prepend:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Lt(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=e?x.filter(e,this):this,i=0;for(;null!=(n=r[i]);i++)t||1!==n.nodeType||x.cleanData(Ft(n)),n.parentNode&&(t&&x.contains(n.ownerDocument,n)&&_t(Ft(n,"script")),n.parentNode.removeChild(n));return this},empty:function(){var e,t=0;for(;null!=(e=this[t]);t++){1===e.nodeType&&x.cleanData(Ft(e,!1));while(e.firstChild)e.removeChild(e.firstChild);e.options&&x.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return x.clone(this,e,t)})},html:function(e){return x.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return 1===n.nodeType?n.innerHTML.replace(gt,""):t;if(!("string"!=typeof e||Tt.test(e)||!x.support.htmlSerialize&&mt.test(e)||!x.support.leadingWhitespace&&yt.test(e)||At[(bt.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(vt,"<$1></$2>");try{for(;i>r;r++)n=this[r]||{},1===n.nodeType&&(x.cleanData(Ft(n,!1)),n.innerHTML=e);n=0}catch(o){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var e=x.map(this,function(e){return[e.nextSibling,e.parentNode]}),t=0;return this.domManip(arguments,function(n){var r=e[t++],i=e[t++];i&&(r&&r.parentNode!==i&&(r=this.nextSibling),x(this).remove(),i.insertBefore(n,r))},!0),t?this:this.remove()},detach:function(e){return this.remove(e,!0)},domManip:function(e,t,n){e=d.apply([],e);var r,i,o,a,s,l,u=0,c=this.length,p=this,f=c-1,h=e[0],g=x.isFunction(h);if(g||!(1>=c||"string"!=typeof h||x.support.checkClone)&&Nt.test(h))return this.each(function(r){var i=p.eq(r);g&&(e[0]=h.call(this,r,i.html())),i.domManip(e,t,n)});if(c&&(l=x.buildFragment(e,this[0].ownerDocument,!1,!n&&this),r=l.firstChild,1===l.childNodes.length&&(l=r),r)){for(a=x.map(Ft(l,"script"),Ht),o=a.length;c>u;u++)i=l,u!==f&&(i=x.clone(i,!0,!0),o&&x.merge(a,Ft(i,"script"))),t.call(this[u],i,u);if(o)for(s=a[a.length-1].ownerDocument,x.map(a,qt),u=0;o>u;u++)i=a[u],kt.test(i.type||"")&&!x._data(i,"globalEval")&&x.contains(s,i)&&(i.src?x._evalUrl(i.src):x.globalEval((i.text||i.textContent||i.innerHTML||"").replace(St,"")));l=r=null}return this}});function Lt(e,t){return x.nodeName(e,"table")&&x.nodeName(1===t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function Ht(e){return e.type=(null!==x.find.attr(e,"type"))+"/"+e.type,e}function qt(e){var t=Et.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function _t(e,t){var n,r=0;for(;null!=(n=e[r]);r++)x._data(n,"globalEval",!t||x._data(t[r],"globalEval"))}function Mt(e,t){if(1===t.nodeType&&x.hasData(e)){var n,r,i,o=x._data(e),a=x._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)x.event.add(t,n,s[n][r])}a.data&&(a.data=x.extend({},a.data))}}function Ot(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!x.support.noCloneEvent&&t[x.expando]){i=x._data(t);for(r in i.events)x.removeEvent(t,r,i.handle);t.removeAttribute(x.expando)}"script"===n&&t.text!==e.text?(Ht(t).text=e.text,qt(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),x.support.html5Clone&&e.innerHTML&&!x.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Ct.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}x.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){x.fn[e]=function(e){var n,r=0,i=[],o=x(e),a=o.length-1;for(;a>=r;r++)n=r===a?this:this.clone(!0),x(o[r])[t](n),h.apply(i,n.get());return this.pushStack(i)}});function Ft(e,n){var r,o,a=0,s=typeof e.getElementsByTagName!==i?e.getElementsByTagName(n||"*"):typeof e.querySelectorAll!==i?e.querySelectorAll(n||"*"):t;if(!s)for(s=[],r=e.childNodes||e;null!=(o=r[a]);a++)!n||x.nodeName(o,n)?s.push(o):x.merge(s,Ft(o,n));return n===t||n&&x.nodeName(e,n)?x.merge([e],s):s}function Bt(e){Ct.test(e.type)&&(e.defaultChecked=e.checked)}x.extend({clone:function(e,t,n){var r,i,o,a,s,l=x.contains(e.ownerDocument,e);if(x.support.html5Clone||x.isXMLDoc(e)||!mt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(Dt.innerHTML=e.outerHTML,Dt.removeChild(o=Dt.firstChild)),!(x.support.noCloneEvent&&x.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||x.isXMLDoc(e)))for(r=Ft(o),s=Ft(e),a=0;null!=(i=s[a]);++a)r[a]&&Ot(i,r[a]);if(t)if(n)for(s=s||Ft(e),r=r||Ft(o),a=0;null!=(i=s[a]);a++)Mt(i,r[a]);else Mt(e,o);return r=Ft(o,"script"),r.length>0&&_t(r,!l&&Ft(e,"script")),r=s=i=null,o},buildFragment:function(e,t,n,r){var i,o,a,s,l,u,c,p=e.length,f=dt(t),d=[],h=0;for(;p>h;h++)if(o=e[h],o||0===o)if("object"===x.type(o))x.merge(d,o.nodeType?[o]:o);else if(wt.test(o)){s=s||f.appendChild(t.createElement("div")),l=(bt.exec(o)||["",""])[1].toLowerCase(),c=At[l]||At._default,s.innerHTML=c[1]+o.replace(vt,"<$1></$2>")+c[2],i=c[0];while(i--)s=s.lastChild;if(!x.support.leadingWhitespace&&yt.test(o)&&d.push(t.createTextNode(yt.exec(o)[0])),!x.support.tbody){o="table"!==l||xt.test(o)?"<table>"!==c[1]||xt.test(o)?0:s:s.firstChild,i=o&&o.childNodes.length;while(i--)x.nodeName(u=o.childNodes[i],"tbody")&&!u.childNodes.length&&o.removeChild(u)}x.merge(d,s.childNodes),s.textContent="";while(s.firstChild)s.removeChild(s.firstChild);s=f.lastChild}else d.push(t.createTextNode(o));s&&f.removeChild(s),x.support.appendChecked||x.grep(Ft(d,"input"),Bt),h=0;while(o=d[h++])if((!r||-1===x.inArray(o,r))&&(a=x.contains(o.ownerDocument,o),s=Ft(f.appendChild(o),"script"),a&&_t(s),n)){i=0;while(o=s[i++])kt.test(o.type||"")&&n.push(o)}return s=null,f},cleanData:function(e,t){var n,r,o,a,s=0,l=x.expando,u=x.cache,c=x.support.deleteExpando,f=x.event.special;for(;null!=(n=e[s]);s++)if((t||x.acceptData(n))&&(o=n[l],a=o&&u[o])){if(a.events)for(r in a.events)f[r]?x.event.remove(n,r):x.removeEvent(n,r,a.handle);
-u[o]&&(delete u[o],c?delete n[l]:typeof n.removeAttribute!==i?n.removeAttribute(l):n[l]=null,p.push(o))}},_evalUrl:function(e){return x.ajax({url:e,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})}}),x.fn.extend({wrapAll:function(e){if(x.isFunction(e))return this.each(function(t){x(this).wrapAll(e.call(this,t))});if(this[0]){var t=x(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&1===e.firstChild.nodeType)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return x.isFunction(e)?this.each(function(t){x(this).wrapInner(e.call(this,t))}):this.each(function(){var t=x(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=x.isFunction(e);return this.each(function(n){x(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){x.nodeName(this,"body")||x(this).replaceWith(this.childNodes)}).end()}});var Pt,Rt,Wt,$t=/alpha\([^)]*\)/i,It=/opacity\s*=\s*([^)]*)/,zt=/^(top|right|bottom|left)$/,Xt=/^(none|table(?!-c[ea]).+)/,Ut=/^margin/,Vt=RegExp("^("+w+")(.*)$","i"),Yt=RegExp("^("+w+")(?!px)[a-z%]+$","i"),Jt=RegExp("^([+-])=("+w+")","i"),Gt={BODY:"block"},Qt={position:"absolute",visibility:"hidden",display:"block"},Kt={letterSpacing:0,fontWeight:400},Zt=["Top","Right","Bottom","Left"],en=["Webkit","O","Moz","ms"];function tn(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=en.length;while(i--)if(t=en[i]+n,t in e)return t;return r}function nn(e,t){return e=t||e,"none"===x.css(e,"display")||!x.contains(e.ownerDocument,e)}function rn(e,t){var n,r,i,o=[],a=0,s=e.length;for(;s>a;a++)r=e[a],r.style&&(o[a]=x._data(r,"olddisplay"),n=r.style.display,t?(o[a]||"none"!==n||(r.style.display=""),""===r.style.display&&nn(r)&&(o[a]=x._data(r,"olddisplay",ln(r.nodeName)))):o[a]||(i=nn(r),(n&&"none"!==n||!i)&&x._data(r,"olddisplay",i?n:x.css(r,"display"))));for(a=0;s>a;a++)r=e[a],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[a]||"":"none"));return e}x.fn.extend({css:function(e,n){return x.access(this,function(e,n,r){var i,o,a={},s=0;if(x.isArray(n)){for(o=Rt(e),i=n.length;i>s;s++)a[n[s]]=x.css(e,n[s],!1,o);return a}return r!==t?x.style(e,n,r):x.css(e,n)},e,n,arguments.length>1)},show:function(){return rn(this,!0)},hide:function(){return rn(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){nn(this)?x(this).show():x(this).hide()})}}),x.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Wt(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":x.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,l=x.camelCase(n),u=e.style;if(n=x.cssProps[l]||(x.cssProps[l]=tn(u,l)),s=x.cssHooks[n]||x.cssHooks[l],r===t)return s&&"get"in s&&(o=s.get(e,!1,i))!==t?o:u[n];if(a=typeof r,"string"===a&&(o=Jt.exec(r))&&(r=(o[1]+1)*o[2]+parseFloat(x.css(e,n)),a="number"),!(null==r||"number"===a&&isNaN(r)||("number"!==a||x.cssNumber[l]||(r+="px"),x.support.clearCloneStyle||""!==r||0!==n.indexOf("background")||(u[n]="inherit"),s&&"set"in s&&(r=s.set(e,r,i))===t)))try{u[n]=r}catch(c){}}},css:function(e,n,r,i){var o,a,s,l=x.camelCase(n);return n=x.cssProps[l]||(x.cssProps[l]=tn(e.style,l)),s=x.cssHooks[n]||x.cssHooks[l],s&&"get"in s&&(a=s.get(e,!0,r)),a===t&&(a=Wt(e,n,i)),"normal"===a&&n in Kt&&(a=Kt[n]),""===r||r?(o=parseFloat(a),r===!0||x.isNumeric(o)?o||0:a):a}}),e.getComputedStyle?(Rt=function(t){return e.getComputedStyle(t,null)},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s.getPropertyValue(n)||s[n]:t,u=e.style;return s&&(""!==l||x.contains(e.ownerDocument,e)||(l=x.style(e,n)),Yt.test(l)&&Ut.test(n)&&(i=u.width,o=u.minWidth,a=u.maxWidth,u.minWidth=u.maxWidth=u.width=l,l=s.width,u.width=i,u.minWidth=o,u.maxWidth=a)),l}):a.documentElement.currentStyle&&(Rt=function(e){return e.currentStyle},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s[n]:t,u=e.style;return null==l&&u&&u[n]&&(l=u[n]),Yt.test(l)&&!zt.test(n)&&(i=u.left,o=e.runtimeStyle,a=o&&o.left,a&&(o.left=e.currentStyle.left),u.left="fontSize"===n?"1em":l,l=u.pixelLeft+"px",u.left=i,a&&(o.left=a)),""===l?"auto":l});function on(e,t,n){var r=Vt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function an(e,t,n,r,i){var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;for(;4>o;o+=2)"margin"===n&&(a+=x.css(e,n+Zt[o],!0,i)),r?("content"===n&&(a-=x.css(e,"padding"+Zt[o],!0,i)),"margin"!==n&&(a-=x.css(e,"border"+Zt[o]+"Width",!0,i))):(a+=x.css(e,"padding"+Zt[o],!0,i),"padding"!==n&&(a+=x.css(e,"border"+Zt[o]+"Width",!0,i)));return a}function sn(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=Rt(e),a=x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=Wt(e,t,o),(0>i||null==i)&&(i=e.style[t]),Yt.test(i))return i;r=a&&(x.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+an(e,t,n||(a?"border":"content"),r,o)+"px"}function ln(e){var t=a,n=Gt[e];return n||(n=un(e,t),"none"!==n&&n||(Pt=(Pt||x("<iframe frameborder='0' width='0' height='0'/>").css("cssText","display:block !important")).appendTo(t.documentElement),t=(Pt[0].contentWindow||Pt[0].contentDocument).document,t.write("<!doctype html><html><body>"),t.close(),n=un(e,t),Pt.detach()),Gt[e]=n),n}function un(e,t){var n=x(t.createElement(e)).appendTo(t.body),r=x.css(n[0],"display");return n.remove(),r}x.each(["height","width"],function(e,n){x.cssHooks[n]={get:function(e,r,i){return r?0===e.offsetWidth&&Xt.test(x.css(e,"display"))?x.swap(e,Qt,function(){return sn(e,n,i)}):sn(e,n,i):t},set:function(e,t,r){var i=r&&Rt(e);return on(e,t,r?an(e,n,r,x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,i),i):0)}}}),x.support.opacity||(x.cssHooks.opacity={get:function(e,t){return It.test((t&&e.currentStyle?e.currentStyle.filter:e.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":t?"1":""},set:function(e,t){var n=e.style,r=e.currentStyle,i=x.isNumeric(t)?"alpha(opacity="+100*t+")":"",o=r&&r.filter||n.filter||"";n.zoom=1,(t>=1||""===t)&&""===x.trim(o.replace($t,""))&&n.removeAttribute&&(n.removeAttribute("filter"),""===t||r&&!r.filter)||(n.filter=$t.test(o)?o.replace($t,i):o+" "+i)}}),x(function(){x.support.reliableMarginRight||(x.cssHooks.marginRight={get:function(e,n){return n?x.swap(e,{display:"inline-block"},Wt,[e,"marginRight"]):t}}),!x.support.pixelPosition&&x.fn.position&&x.each(["top","left"],function(e,n){x.cssHooks[n]={get:function(e,r){return r?(r=Wt(e,n),Yt.test(r)?x(e).position()[n]+"px":r):t}}})}),x.expr&&x.expr.filters&&(x.expr.filters.hidden=function(e){return 0>=e.offsetWidth&&0>=e.offsetHeight||!x.support.reliableHiddenOffsets&&"none"===(e.style&&e.style.display||x.css(e,"display"))},x.expr.filters.visible=function(e){return!x.expr.filters.hidden(e)}),x.each({margin:"",padding:"",border:"Width"},function(e,t){x.cssHooks[e+t]={expand:function(n){var r=0,i={},o="string"==typeof n?n.split(" "):[n];for(;4>r;r++)i[e+Zt[r]+t]=o[r]||o[r-2]||o[0];return i}},Ut.test(e)||(x.cssHooks[e+t].set=on)});var cn=/%20/g,pn=/\[\]$/,fn=/\r?\n/g,dn=/^(?:submit|button|image|reset|file)$/i,hn=/^(?:input|select|textarea|keygen)/i;x.fn.extend({serialize:function(){return x.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=x.prop(this,"elements");return e?x.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!x(this).is(":disabled")&&hn.test(this.nodeName)&&!dn.test(e)&&(this.checked||!Ct.test(e))}).map(function(e,t){var n=x(this).val();return null==n?null:x.isArray(n)?x.map(n,function(e){return{name:t.name,value:e.replace(fn,"\r\n")}}):{name:t.name,value:n.replace(fn,"\r\n")}}).get()}}),x.param=function(e,n){var r,i=[],o=function(e,t){t=x.isFunction(t)?t():null==t?"":t,i[i.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};if(n===t&&(n=x.ajaxSettings&&x.ajaxSettings.traditional),x.isArray(e)||e.jquery&&!x.isPlainObject(e))x.each(e,function(){o(this.name,this.value)});else for(r in e)gn(r,e[r],n,o);return i.join("&").replace(cn,"+")};function gn(e,t,n,r){var i;if(x.isArray(t))x.each(t,function(t,i){n||pn.test(e)?r(e,i):gn(e+"["+("object"==typeof i?t:"")+"]",i,n,r)});else if(n||"object"!==x.type(t))r(e,t);else for(i in t)gn(e+"["+i+"]",t[i],n,r)}x.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(e,t){x.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),x.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)}});var mn,yn,vn=x.now(),bn=/\?/,xn=/#.*$/,wn=/([?&])_=[^&]*/,Tn=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Cn=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Nn=/^(?:GET|HEAD)$/,kn=/^\/\//,En=/^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,Sn=x.fn.load,An={},jn={},Dn="*/".concat("*");try{yn=o.href}catch(Ln){yn=a.createElement("a"),yn.href="",yn=yn.href}mn=En.exec(yn.toLowerCase())||[];function Hn(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(T)||[];if(x.isFunction(n))while(r=o[i++])"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function qn(e,n,r,i){var o={},a=e===jn;function s(l){var u;return o[l]=!0,x.each(e[l]||[],function(e,l){var c=l(n,r,i);return"string"!=typeof c||a||o[c]?a?!(u=c):t:(n.dataTypes.unshift(c),s(c),!1)}),u}return s(n.dataTypes[0])||!o["*"]&&s("*")}function _n(e,n){var r,i,o=x.ajaxSettings.flatOptions||{};for(i in n)n[i]!==t&&((o[i]?e:r||(r={}))[i]=n[i]);return r&&x.extend(!0,e,r),e}x.fn.load=function(e,n,r){if("string"!=typeof e&&Sn)return Sn.apply(this,arguments);var i,o,a,s=this,l=e.indexOf(" ");return l>=0&&(i=e.slice(l,e.length),e=e.slice(0,l)),x.isFunction(n)?(r=n,n=t):n&&"object"==typeof n&&(a="POST"),s.length>0&&x.ajax({url:e,type:a,dataType:"html",data:n}).done(function(e){o=arguments,s.html(i?x("<div>").append(x.parseHTML(e)).find(i):e)}).complete(r&&function(e,t){s.each(r,o||[e.responseText,t,e])}),this},x.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){x.fn[t]=function(e){return this.on(t,e)}}),x.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:yn,type:"GET",isLocal:Cn.test(mn[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Dn,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":x.parseJSON,"text xml":x.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?_n(_n(e,x.ajaxSettings),t):_n(x.ajaxSettings,e)},ajaxPrefilter:Hn(An),ajaxTransport:Hn(jn),ajax:function(e,n){"object"==typeof e&&(n=e,e=t),n=n||{};var r,i,o,a,s,l,u,c,p=x.ajaxSetup({},n),f=p.context||p,d=p.context&&(f.nodeType||f.jquery)?x(f):x.event,h=x.Deferred(),g=x.Callbacks("once memory"),m=p.statusCode||{},y={},v={},b=0,w="canceled",C={readyState:0,getResponseHeader:function(e){var t;if(2===b){if(!c){c={};while(t=Tn.exec(a))c[t[1].toLowerCase()]=t[2]}t=c[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===b?a:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return b||(e=v[n]=v[n]||e,y[e]=t),this},overrideMimeType:function(e){return b||(p.mimeType=e),this},statusCode:function(e){var t;if(e)if(2>b)for(t in e)m[t]=[m[t],e[t]];else C.always(e[C.status]);return this},abort:function(e){var t=e||w;return u&&u.abort(t),k(0,t),this}};if(h.promise(C).complete=g.add,C.success=C.done,C.error=C.fail,p.url=((e||p.url||yn)+"").replace(xn,"").replace(kn,mn[1]+"//"),p.type=n.method||n.type||p.method||p.type,p.dataTypes=x.trim(p.dataType||"*").toLowerCase().match(T)||[""],null==p.crossDomain&&(r=En.exec(p.url.toLowerCase()),p.crossDomain=!(!r||r[1]===mn[1]&&r[2]===mn[2]&&(r[3]||("http:"===r[1]?"80":"443"))===(mn[3]||("http:"===mn[1]?"80":"443")))),p.data&&p.processData&&"string"!=typeof p.data&&(p.data=x.param(p.data,p.traditional)),qn(An,p,n,C),2===b)return C;l=p.global,l&&0===x.active++&&x.event.trigger("ajaxStart"),p.type=p.type.toUpperCase(),p.hasContent=!Nn.test(p.type),o=p.url,p.hasContent||(p.data&&(o=p.url+=(bn.test(o)?"&":"?")+p.data,delete p.data),p.cache===!1&&(p.url=wn.test(o)?o.replace(wn,"$1_="+vn++):o+(bn.test(o)?"&":"?")+"_="+vn++)),p.ifModified&&(x.lastModified[o]&&C.setRequestHeader("If-Modified-Since",x.lastModified[o]),x.etag[o]&&C.setRequestHeader("If-None-Match",x.etag[o])),(p.data&&p.hasContent&&p.contentType!==!1||n.contentType)&&C.setRequestHeader("Content-Type",p.contentType),C.setRequestHeader("Accept",p.dataTypes[0]&&p.accepts[p.dataTypes[0]]?p.accepts[p.dataTypes[0]]+("*"!==p.dataTypes[0]?", "+Dn+"; q=0.01":""):p.accepts["*"]);for(i in p.headers)C.setRequestHeader(i,p.headers[i]);if(p.beforeSend&&(p.beforeSend.call(f,C,p)===!1||2===b))return C.abort();w="abort";for(i in{success:1,error:1,complete:1})C[i](p[i]);if(u=qn(jn,p,n,C)){C.readyState=1,l&&d.trigger("ajaxSend",[C,p]),p.async&&p.timeout>0&&(s=setTimeout(function(){C.abort("timeout")},p.timeout));try{b=1,u.send(y,k)}catch(N){if(!(2>b))throw N;k(-1,N)}}else k(-1,"No Transport");function k(e,n,r,i){var c,y,v,w,T,N=n;2!==b&&(b=2,s&&clearTimeout(s),u=t,a=i||"",C.readyState=e>0?4:0,c=e>=200&&300>e||304===e,r&&(w=Mn(p,C,r)),w=On(p,w,C,c),c?(p.ifModified&&(T=C.getResponseHeader("Last-Modified"),T&&(x.lastModified[o]=T),T=C.getResponseHeader("etag"),T&&(x.etag[o]=T)),204===e||"HEAD"===p.type?N="nocontent":304===e?N="notmodified":(N=w.state,y=w.data,v=w.error,c=!v)):(v=N,(e||!N)&&(N="error",0>e&&(e=0))),C.status=e,C.statusText=(n||N)+"",c?h.resolveWith(f,[y,N,C]):h.rejectWith(f,[C,N,v]),C.statusCode(m),m=t,l&&d.trigger(c?"ajaxSuccess":"ajaxError",[C,p,c?y:v]),g.fireWith(f,[C,N]),l&&(d.trigger("ajaxComplete",[C,p]),--x.active||x.event.trigger("ajaxStop")))}return C},getJSON:function(e,t,n){return x.get(e,t,n,"json")},getScript:function(e,n){return x.get(e,t,n,"script")}}),x.each(["get","post"],function(e,n){x[n]=function(e,r,i,o){return x.isFunction(r)&&(o=o||i,i=r,r=t),x.ajax({url:e,type:n,dataType:o,data:r,success:i})}});function Mn(e,n,r){var i,o,a,s,l=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),o===t&&(o=e.mimeType||n.getResponseHeader("Content-Type"));if(o)for(s in l)if(l[s]&&l[s].test(o)){u.unshift(s);break}if(u[0]in r)a=u[0];else{for(s in r){if(!u[0]||e.converters[s+" "+u[0]]){a=s;break}i||(i=s)}a=a||i}return a?(a!==u[0]&&u.unshift(a),r[a]):t}function On(e,t,n,r){var i,o,a,s,l,u={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)u[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!l&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),l=o,o=c.shift())if("*"===o)o=l;else if("*"!==l&&l!==o){if(a=u[l+" "+o]||u["* "+o],!a)for(i in u)if(s=i.split(" "),s[1]===o&&(a=u[l+" "+s[0]]||u["* "+s[0]])){a===!0?a=u[i]:u[i]!==!0&&(o=s[0],c.unshift(s[1]));break}if(a!==!0)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(p){return{state:"parsererror",error:a?p:"No conversion from "+l+" to "+o}}}return{state:"success",data:t}}x.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){return x.globalEval(e),e}}}),x.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),x.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=a.head||x("head")[0]||a.documentElement;return{send:function(t,i){n=a.createElement("script"),n.async=!0,e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,t){(t||!n.readyState||/loaded|complete/.test(n.readyState))&&(n.onload=n.onreadystatechange=null,n.parentNode&&n.parentNode.removeChild(n),n=null,t||i(200,"success"))},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(t,!0)}}}});var Fn=[],Bn=/(=)\?(?=&|$)|\?\?/;x.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Fn.pop()||x.expando+"_"+vn++;return this[e]=!0,e}}),x.ajaxPrefilter("json jsonp",function(n,r,i){var o,a,s,l=n.jsonp!==!1&&(Bn.test(n.url)?"url":"string"==typeof n.data&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Bn.test(n.data)&&"data");return l||"jsonp"===n.dataTypes[0]?(o=n.jsonpCallback=x.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,l?n[l]=n[l].replace(Bn,"$1"+o):n.jsonp!==!1&&(n.url+=(bn.test(n.url)?"&":"?")+n.jsonp+"="+o),n.converters["script json"]=function(){return s||x.error(o+" was not called"),s[0]},n.dataTypes[0]="json",a=e[o],e[o]=function(){s=arguments},i.always(function(){e[o]=a,n[o]&&(n.jsonpCallback=r.jsonpCallback,Fn.push(o)),s&&x.isFunction(a)&&a(s[0]),s=a=t}),"script"):t});var Pn,Rn,Wn=0,$n=e.ActiveXObject&&function(){var e;for(e in Pn)Pn[e](t,!0)};function In(){try{return new e.XMLHttpRequest}catch(t){}}function zn(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}x.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&In()||zn()}:In,Rn=x.ajaxSettings.xhr(),x.support.cors=!!Rn&&"withCredentials"in Rn,Rn=x.support.ajax=!!Rn,Rn&&x.ajaxTransport(function(n){if(!n.crossDomain||x.support.cors){var r;return{send:function(i,o){var a,s,l=n.xhr();if(n.username?l.open(n.type,n.url,n.async,n.username,n.password):l.open(n.type,n.url,n.async),n.xhrFields)for(s in n.xhrFields)l[s]=n.xhrFields[s];n.mimeType&&l.overrideMimeType&&l.overrideMimeType(n.mimeType),n.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");try{for(s in i)l.setRequestHeader(s,i[s])}catch(u){}l.send(n.hasContent&&n.data||null),r=function(e,i){var s,u,c,p;try{if(r&&(i||4===l.readyState))if(r=t,a&&(l.onreadystatechange=x.noop,$n&&delete Pn[a]),i)4!==l.readyState&&l.abort();else{p={},s=l.status,u=l.getAllResponseHeaders(),"string"==typeof l.responseText&&(p.text=l.responseText);try{c=l.statusText}catch(f){c=""}s||!n.isLocal||n.crossDomain?1223===s&&(s=204):s=p.text?200:404}}catch(d){i||o(-1,d)}p&&o(s,c,p,u)},n.async?4===l.readyState?setTimeout(r):(a=++Wn,$n&&(Pn||(Pn={},x(e).unload($n)),Pn[a]=r),l.onreadystatechange=r):r()},abort:function(){r&&r(t,!0)}}}});var Xn,Un,Vn=/^(?:toggle|show|hide)$/,Yn=RegExp("^(?:([+-])=|)("+w+")([a-z%]*)$","i"),Jn=/queueHooks$/,Gn=[nr],Qn={"*":[function(e,t){var n=this.createTween(e,t),r=n.cur(),i=Yn.exec(t),o=i&&i[3]||(x.cssNumber[e]?"":"px"),a=(x.cssNumber[e]||"px"!==o&&+r)&&Yn.exec(x.css(n.elem,e)),s=1,l=20;if(a&&a[3]!==o){o=o||a[3],i=i||[],a=+r||1;do s=s||".5",a/=s,x.style(n.elem,e,a+o);while(s!==(s=n.cur()/r)&&1!==s&&--l)}return i&&(a=n.start=+a||+r||0,n.unit=o,n.end=i[1]?a+(i[1]+1)*i[2]:+i[2]),n}]};function Kn(){return setTimeout(function(){Xn=t}),Xn=x.now()}function Zn(e,t,n){var r,i=(Qn[t]||[]).concat(Qn["*"]),o=0,a=i.length;for(;a>o;o++)if(r=i[o].call(n,t,e))return r}function er(e,t,n){var r,i,o=0,a=Gn.length,s=x.Deferred().always(function(){delete l.elem}),l=function(){if(i)return!1;var t=Xn||Kn(),n=Math.max(0,u.startTime+u.duration-t),r=n/u.duration||0,o=1-r,a=0,l=u.tweens.length;for(;l>a;a++)u.tweens[a].run(o);return s.notifyWith(e,[u,o,n]),1>o&&l?n:(s.resolveWith(e,[u]),!1)},u=s.promise({elem:e,props:x.extend({},t),opts:x.extend(!0,{specialEasing:{}},n),originalProperties:t,originalOptions:n,startTime:Xn||Kn(),duration:n.duration,tweens:[],createTween:function(t,n){var r=x.Tween(e,u.opts,t,n,u.opts.specialEasing[t]||u.opts.easing);return u.tweens.push(r),r},stop:function(t){var n=0,r=t?u.tweens.length:0;if(i)return this;for(i=!0;r>n;n++)u.tweens[n].run(1);return t?s.resolveWith(e,[u,t]):s.rejectWith(e,[u,t]),this}}),c=u.props;for(tr(c,u.opts.specialEasing);a>o;o++)if(r=Gn[o].call(u,e,c,u.opts))return r;return x.map(c,Zn,u),x.isFunction(u.opts.start)&&u.opts.start.call(e,u),x.fx.timer(x.extend(l,{elem:e,anim:u,queue:u.opts.queue})),u.progress(u.opts.progress).done(u.opts.done,u.opts.complete).fail(u.opts.fail).always(u.opts.always)}function tr(e,t){var n,r,i,o,a;for(n in e)if(r=x.camelCase(n),i=t[r],o=e[n],x.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),a=x.cssHooks[r],a&&"expand"in a){o=a.expand(o),delete e[r];for(n in o)n in e||(e[n]=o[n],t[n]=i)}else t[r]=i}x.Animation=x.extend(er,{tweener:function(e,t){x.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;i>r;r++)n=e[r],Qn[n]=Qn[n]||[],Qn[n].unshift(t)},prefilter:function(e,t){t?Gn.unshift(e):Gn.push(e)}});function nr(e,t,n){var r,i,o,a,s,l,u=this,c={},p=e.style,f=e.nodeType&&nn(e),d=x._data(e,"fxshow");n.queue||(s=x._queueHooks(e,"fx"),null==s.unqueued&&(s.unqueued=0,l=s.empty.fire,s.empty.fire=function(){s.unqueued||l()}),s.unqueued++,u.always(function(){u.always(function(){s.unqueued--,x.queue(e,"fx").length||s.empty.fire()})})),1===e.nodeType&&("height"in t||"width"in t)&&(n.overflow=[p.overflow,p.overflowX,p.overflowY],"inline"===x.css(e,"display")&&"none"===x.css(e,"float")&&(x.support.inlineBlockNeedsLayout&&"inline"!==ln(e.nodeName)?p.zoom=1:p.display="inline-block")),n.overflow&&(p.overflow="hidden",x.support.shrinkWrapBlocks||u.always(function(){p.overflow=n.overflow[0],p.overflowX=n.overflow[1],p.overflowY=n.overflow[2]}));for(r in t)if(i=t[r],Vn.exec(i)){if(delete t[r],o=o||"toggle"===i,i===(f?"hide":"show"))continue;c[r]=d&&d[r]||x.style(e,r)}if(!x.isEmptyObject(c)){d?"hidden"in d&&(f=d.hidden):d=x._data(e,"fxshow",{}),o&&(d.hidden=!f),f?x(e).show():u.done(function(){x(e).hide()}),u.done(function(){var t;x._removeData(e,"fxshow");for(t in c)x.style(e,t,c[t])});for(r in c)a=Zn(f?d[r]:0,r,u),r in d||(d[r]=a.start,f&&(a.end=a.start,a.start="width"===r||"height"===r?1:0))}}function rr(e,t,n,r,i){return new rr.prototype.init(e,t,n,r,i)}x.Tween=rr,rr.prototype={constructor:rr,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(x.cssNumber[n]?"":"px")},cur:function(){var e=rr.propHooks[this.prop];return e&&e.get?e.get(this):rr.propHooks._default.get(this)},run:function(e){var t,n=rr.propHooks[this.prop];return this.pos=t=this.options.duration?x.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):rr.propHooks._default.set(this),this}},rr.prototype.init.prototype=rr.prototype,rr.propHooks={_default:{get:function(e){var t;return null==e.elem[e.prop]||e.elem.style&&null!=e.elem.style[e.prop]?(t=x.css(e.elem,e.prop,""),t&&"auto"!==t?t:0):e.elem[e.prop]},set:function(e){x.fx.step[e.prop]?x.fx.step[e.prop](e):e.elem.style&&(null!=e.elem.style[x.cssProps[e.prop]]||x.cssHooks[e.prop])?x.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},rr.propHooks.scrollTop=rr.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},x.each(["toggle","show","hide"],function(e,t){var n=x.fn[t];x.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(ir(t,!0),e,r,i)}}),x.fn.extend({fadeTo:function(e,t,n,r){return this.filter(nn).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=x.isEmptyObject(e),o=x.speed(t,n,r),a=function(){var t=er(this,x.extend({},e),o);(i||x._data(this,"finish"))&&t.stop(!0)};return a.finish=a,i||o.queue===!1?this.each(a):this.queue(o.queue,a)},stop:function(e,n,r){var i=function(e){var t=e.stop;delete e.stop,t(r)};return"string"!=typeof e&&(r=n,n=e,e=t),n&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,n=null!=e&&e+"queueHooks",o=x.timers,a=x._data(this);if(n)a[n]&&a[n].stop&&i(a[n]);else for(n in a)a[n]&&a[n].stop&&Jn.test(n)&&i(a[n]);for(n=o.length;n--;)o[n].elem!==this||null!=e&&o[n].queue!==e||(o[n].anim.stop(r),t=!1,o.splice(n,1));(t||!r)&&x.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||"fx"),this.each(function(){var t,n=x._data(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=x.timers,a=r?r.length:0;for(n.finish=!0,x.queue(this,e,[]),i&&i.stop&&i.stop.call(this,!0),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;a>t;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}});function ir(e,t){var n,r={height:e},i=0;for(t=t?1:0;4>i;i+=2-t)n=Zt[i],r["margin"+n]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}x.each({slideDown:ir("show"),slideUp:ir("hide"),slideToggle:ir("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){x.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),x.speed=function(e,t,n){var r=e&&"object"==typeof e?x.extend({},e):{complete:n||!n&&t||x.isFunction(e)&&e,duration:e,easing:n&&t||t&&!x.isFunction(t)&&t};return r.duration=x.fx.off?0:"number"==typeof r.duration?r.duration:r.duration in x.fx.speeds?x.fx.speeds[r.duration]:x.fx.speeds._default,(null==r.queue||r.queue===!0)&&(r.queue="fx"),r.old=r.complete,r.complete=function(){x.isFunction(r.old)&&r.old.call(this),r.queue&&x.dequeue(this,r.queue)},r},x.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},x.timers=[],x.fx=rr.prototype.init,x.fx.tick=function(){var e,n=x.timers,r=0;for(Xn=x.now();n.length>r;r++)e=n[r],e()||n[r]!==e||n.splice(r--,1);n.length||x.fx.stop(),Xn=t},x.fx.timer=function(e){e()&&x.timers.push(e)&&x.fx.start()},x.fx.interval=13,x.fx.start=function(){Un||(Un=setInterval(x.fx.tick,x.fx.interval))},x.fx.stop=function(){clearInterval(Un),Un=null},x.fx.speeds={slow:600,fast:200,_default:400},x.fx.step={},x.expr&&x.expr.filters&&(x.expr.filters.animated=function(e){return x.grep(x.timers,function(t){return e===t.elem}).length}),x.fn.offset=function(e){if(arguments.length)return e===t?this:this.each(function(t){x.offset.setOffset(this,e,t)});var n,r,o={top:0,left:0},a=this[0],s=a&&a.ownerDocument;if(s)return n=s.documentElement,x.contains(n,a)?(typeof a.getBoundingClientRect!==i&&(o=a.getBoundingClientRect()),r=or(s),{top:o.top+(r.pageYOffset||n.scrollTop)-(n.clientTop||0),left:o.left+(r.pageXOffset||n.scrollLeft)-(n.clientLeft||0)}):o},x.offset={setOffset:function(e,t,n){var r=x.css(e,"position");"static"===r&&(e.style.position="relative");var i=x(e),o=i.offset(),a=x.css(e,"top"),s=x.css(e,"left"),l=("absolute"===r||"fixed"===r)&&x.inArray("auto",[a,s])>-1,u={},c={},p,f;l?(c=i.position(),p=c.top,f=c.left):(p=parseFloat(a)||0,f=parseFloat(s)||0),x.isFunction(t)&&(t=t.call(e,n,o)),null!=t.top&&(u.top=t.top-o.top+p),null!=t.left&&(u.left=t.left-o.left+f),"using"in t?t.using.call(e,u):i.css(u)}},x.fn.extend({position:function(){if(this[0]){var e,t,n={top:0,left:0},r=this[0];return"fixed"===x.css(r,"position")?t=r.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),x.nodeName(e[0],"html")||(n=e.offset()),n.top+=x.css(e[0],"borderTopWidth",!0),n.left+=x.css(e[0],"borderLeftWidth",!0)),{top:t.top-n.top-x.css(r,"marginTop",!0),left:t.left-n.left-x.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||s;while(e&&!x.nodeName(e,"html")&&"static"===x.css(e,"position"))e=e.offsetParent;return e||s})}}),x.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);x.fn[e]=function(i){return x.access(this,function(e,i,o){var a=or(e);return o===t?a?n in a?a[n]:a.document.documentElement[i]:e[i]:(a?a.scrollTo(r?x(a).scrollLeft():o,r?o:x(a).scrollTop()):e[i]=o,t)},e,i,arguments.length,null)}});function or(e){return x.isWindow(e)?e:9===e.nodeType?e.defaultView||e.parentWindow:!1}x.each({Height:"height",Width:"width"},function(e,n){x.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){x.fn[i]=function(i,o){var a=arguments.length&&(r||"boolean"!=typeof i),s=r||(i===!0||o===!0?"margin":"border");return x.access(this,function(n,r,i){var o;return x.isWindow(n)?n.document.documentElement["client"+e]:9===n.nodeType?(o=n.documentElement,Math.max(n.body["scroll"+e],o["scroll"+e],n.body["offset"+e],o["offset"+e],o["client"+e])):i===t?x.css(n,r,s):x.style(n,r,i,s)},n,a?i:t,a,null)}})}),x.fn.size=function(){return this.length},x.fn.andSelf=x.fn.addBack,"object"==typeof module&&module&&"object"==typeof module.exports?module.exports=x:(e.jQuery=e.$=x,"function"==typeof define&&define.amd&&define("jquery",[],function(){return x}))})(window);
+/*! jQuery v1.11.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
+!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.1",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function r(a){var b=a.length,c=m.type(a);return"function"===c||m.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var s=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+-new Date,v=a.document,w=0,x=0,y=gb(),z=gb(),A=gb(),B=function(a,b){return a===b&&(l=!0),0},C="undefined",D=1<<31,E={}.hasOwnProperty,F=[],G=F.pop,H=F.push,I=F.push,J=F.slice,K=F.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},L="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",N="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=N.replace("w","w#"),P="\\["+M+"*("+N+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+O+"))|)"+M+"*\\]",Q=":("+N+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+P+")*)|.*)\\)|)",R=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),S=new RegExp("^"+M+"*,"+M+"*"),T=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),V=new RegExp(Q),W=new RegExp("^"+O+"$"),X={ID:new RegExp("^#("+N+")"),CLASS:new RegExp("^\\.("+N+")"),TAG:new RegExp("^("+N.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+Q),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+L+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{I.apply(F=J.call(v.childNodes),v.childNodes),F[v.childNodes.length].nodeType}catch(eb){I={apply:F.length?function(a,b){H.apply(a,J.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function fb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],!a||"string"!=typeof a)return d;if(1!==(k=b.nodeType)&&9!==k)return[];if(p&&!e){if(f=_.exec(a))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return I.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return I.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=9===k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+qb(o[l]);w=ab.test(a)&&ob(b.parentNode)||b,x=o.join(",")}if(x)try{return I.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function gb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function hb(a){return a[u]=!0,a}function ib(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function jb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function kb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||D)-(~a.sourceIndex||D);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function lb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function nb(a){return hb(function(b){return b=+b,hb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function ob(a){return a&&typeof a.getElementsByTagName!==C&&a}c=fb.support={},f=fb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=fb.setDocument=function(a){var b,e=a?a.ownerDocument||a:v,g=e.defaultView;return e!==n&&9===e.nodeType&&e.documentElement?(n=e,o=e.documentElement,p=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){m()},!1):g.attachEvent&&g.attachEvent("onunload",function(){m()})),c.attributes=ib(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ib(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(e.getElementsByClassName)&&ib(function(a){return a.innerHTML="<div class='a'></div><div class='a i'></div>",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=ib(function(a){return o.appendChild(a).id=u,!e.getElementsByName||!e.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==C&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c=typeof a.getAttributeNode!==C&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==C?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==C&&p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(e.querySelectorAll))&&(ib(function(a){a.innerHTML="<select msallowclip=''><option selected=''></option></select>",a.querySelectorAll("[msallowclip^='']").length&&q.push("[*^$]="+M+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+M+"*(?:value|"+L+")"),a.querySelectorAll(":checked").length||q.push(":checked")}),ib(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+M+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ib(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",Q)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===v&&t(v,a)?-1:b===e||b.ownerDocument===v&&t(v,b)?1:k?K.call(k,a)-K.call(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],i=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:k?K.call(k,a)-K.call(k,b):0;if(f===g)return kb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?kb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},e):n},fb.matches=function(a,b){return fb(a,null,null,b)},fb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return fb(b,n,null,[a]).length>0},fb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},fb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&E.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},fb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},fb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=fb.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=fb.selectors={cacheLength:50,createPseudo:hb,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||fb.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&fb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+M+")"+a+"("+M+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==C&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=fb.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||fb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?hb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=K.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:hb(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?hb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:hb(function(a){return function(b){return fb(a,b).length>0}}),contains:hb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:hb(function(a){return W.test(a||"")||fb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:nb(function(){return[0]}),last:nb(function(a,b){return[b-1]}),eq:nb(function(a,b,c){return[0>c?c+b:c]}),even:nb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:nb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:nb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:nb(function(a,b,c){for(var d=0>c?c+b:c;++d<b;)a.push(d);return a})}},d.pseudos.nth=d.pseudos.eq;for(b in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})d.pseudos[b]=lb(b);for(b in{submit:!0,reset:!0})d.pseudos[b]=mb(b);function pb(){}pb.prototype=d.filters=d.pseudos,d.setFilters=new pb,g=fb.tokenize=function(a,b){var c,e,f,g,h,i,j,k=z[a+" "];if(k)return b?0:k.slice(0);h=a,i=[],j=d.preFilter;while(h){(!c||(e=S.exec(h)))&&(e&&(h=h.slice(e[0].length)||h),i.push(f=[])),c=!1,(e=T.exec(h))&&(c=e.shift(),f.push({value:c,type:e[0].replace(R," ")}),h=h.slice(c.length));for(g in d.filter)!(e=X[g].exec(h))||j[g]&&!(e=j[g](e))||(c=e.shift(),f.push({value:c,type:g,matches:e}),h=h.slice(c.length));if(!c)break}return b?h.length:h?fb.error(a):z(a,i).slice(0)};function qb(a){for(var b=0,c=a.length,d="";c>b;b++)d+=a[b].value;return d}function rb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function sb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function tb(a,b,c){for(var d=0,e=b.length;e>d;d++)fb(a,b[d],c);return c}function ub(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function vb(a,b,c,d,e,f){return d&&!d[u]&&(d=vb(d)),e&&!e[u]&&(e=vb(e,f)),hb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||tb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:ub(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=ub(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?K.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=ub(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):I.apply(g,r)})}function wb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=rb(function(a){return a===b},h,!0),l=rb(function(a){return K.call(b,a)>-1},h,!0),m=[function(a,c,d){return!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>i;i++)if(c=d.relative[a[i].type])m=[rb(sb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return vb(i>1&&sb(m),i>1&&qb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&wb(a.slice(i,e)),f>e&&wb(a=a.slice(e)),f>e&&qb(a))}m.push(c)}return sb(m)}function xb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=G.call(i));s=ub(s)}I.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&fb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?hb(f):f}return h=fb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=wb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,xb(e,d)),f.selector=a}return f},i=fb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&ob(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&qb(j),!a)return I.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&ob(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ib(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ib(function(a){return a.innerHTML="<a href='#'></a>","#"===a.firstChild.getAttribute("href")})||jb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ib(function(a){return a.innerHTML="<input/>",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||jb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ib(function(a){return null==a.getAttribute("disabled")})||jb(L,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),fb}(a);m.find=s,m.expr=s.selectors,m.expr[":"]=m.expr.pseudos,m.unique=s.uniqueSort,m.text=s.getText,m.isXMLDoc=s.isXML,m.contains=s.contains;var t=m.expr.match.needsContext,u=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,v=/^.[^:#\[\.,]*$/;function w(a,b,c){if(m.isFunction(b))return m.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return m.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(v.test(b))return m.filter(b,a,c);b=m.filter(b,a)}return m.grep(a,function(a){return m.inArray(a,b)>=0!==c})}m.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?m.find.matchesSelector(d,a)?[d]:[]:m.find.matches(a,m.grep(b,function(a){return 1===a.nodeType}))},m.fn.extend({find:function(a){var b,c=[],d=this,e=d.length;if("string"!=typeof a)return this.pushStack(m(a).filter(function(){for(b=0;e>b;b++)if(m.contains(d[b],this))return!0}));for(b=0;e>b;b++)m.find(a,d[b],c);return c=this.pushStack(e>1?m.unique(c):c),c.selector=this.selector?this.selector+" "+a:a,c},filter:function(a){return this.pushStack(w(this,a||[],!1))},not:function(a){return this.pushStack(w(this,a||[],!0))},is:function(a){return!!w(this,"string"==typeof a&&t.test(a)?m(a):a||[],!1).length}});var x,y=a.document,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=m.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||x).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof m?b[0]:b,m.merge(this,m.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:y,!0)),u.test(c[1])&&m.isPlainObject(b))for(c in b)m.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}if(d=y.getElementById(c[2]),d&&d.parentNode){if(d.id!==c[2])return x.find(a);this.length=1,this[0]=d}return this.context=y,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):m.isFunction(a)?"undefined"!=typeof x.ready?x.ready(a):a(m):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),m.makeArray(a,this))};A.prototype=m.fn,x=m(y);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};m.extend({dir:function(a,b,c){var d=[],e=a[b];while(e&&9!==e.nodeType&&(void 0===c||1!==e.nodeType||!m(e).is(c)))1===e.nodeType&&d.push(e),e=e[b];return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),m.fn.extend({has:function(a){var b,c=m(a,this),d=c.length;return this.filter(function(){for(b=0;d>b;b++)if(m.contains(this,c[b]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=t.test(a)||"string"!=typeof a?m(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&m.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?m.unique(f):f)},index:function(a){return a?"string"==typeof a?m.inArray(this[0],m(a)):m.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(m.unique(m.merge(this.get(),m(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}m.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return m.dir(a,"parentNode")},parentsUntil:function(a,b,c){return m.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return m.dir(a,"nextSibling")},prevAll:function(a){return m.dir(a,"previousSibling")},nextUntil:function(a,b,c){return m.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return m.dir(a,"previousSibling",c)},siblings:function(a){return m.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return m.sibling(a.firstChild)},contents:function(a){return m.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:m.merge([],a.childNodes)}},function(a,b){m.fn[a]=function(c,d){var e=m.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=m.filter(d,e)),this.length>1&&(C[a]||(e=m.unique(e)),B.test(a)&&(e=e.reverse())),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return m.each(a.match(E)||[],function(a,c){b[c]=!0}),b}m.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):m.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(c=a.memory&&l,d=!0,f=g||0,g=0,e=h.length,b=!0;h&&e>f;f++)if(h[f].apply(l[0],l[1])===!1&&a.stopOnFalse){c=!1;break}b=!1,h&&(i?i.length&&j(i.shift()):c?h=[]:k.disable())},k={add:function(){if(h){var d=h.length;!function f(b){m.each(b,function(b,c){var d=m.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&f(c)})}(arguments),b?e=h.length:c&&(g=d,j(c))}return this},remove:function(){return h&&m.each(arguments,function(a,c){var d;while((d=m.inArray(c,h,d))>-1)h.splice(d,1),b&&(e>=d&&e--,f>=d&&f--)}),this},has:function(a){return a?m.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],e=0,this},disable:function(){return h=i=c=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,c||k.disable(),this},locked:function(){return!i},fireWith:function(a,c){return!h||d&&!i||(c=c||[],c=[a,c.slice?c.slice():c],b?i.push(c):j(c)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!d}};return k},m.extend({Deferred:function(a){var b=[["resolve","done",m.Callbacks("once memory"),"resolved"],["reject","fail",m.Callbacks("once memory"),"rejected"],["notify","progress",m.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return m.Deferred(function(c){m.each(b,function(b,f){var g=m.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&m.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?m.extend(a,d):d}},e={};return d.pipe=d.then,m.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&m.isFunction(a.promise)?e:0,g=1===f?a:m.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&m.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;m.fn.ready=function(a){return m.ready.promise().done(a),this},m.extend({isReady:!1,readyWait:1,holdReady:function(a){a?m.readyWait++:m.ready(!0)},ready:function(a){if(a===!0?!--m.readyWait:!m.isReady){if(!y.body)return setTimeout(m.ready);m.isReady=!0,a!==!0&&--m.readyWait>0||(H.resolveWith(y,[m]),m.fn.triggerHandler&&(m(y).triggerHandler("ready"),m(y).off("ready")))}}});function I(){y.addEventListener?(y.removeEventListener("DOMContentLoaded",J,!1),a.removeEventListener("load",J,!1)):(y.detachEvent("onreadystatechange",J),a.detachEvent("onload",J))}function J(){(y.addEventListener||"load"===event.type||"complete"===y.readyState)&&(I(),m.ready())}m.ready.promise=function(b){if(!H)if(H=m.Deferred(),"complete"===y.readyState)setTimeout(m.ready);else if(y.addEventListener)y.addEventListener("DOMContentLoaded",J,!1),a.addEventListener("load",J,!1);else{y.attachEvent("onreadystatechange",J),a.attachEvent("onload",J);var c=!1;try{c=null==a.frameElement&&y.documentElement}catch(d){}c&&c.doScroll&&!function e(){if(!m.isReady){try{c.doScroll("left")}catch(a){return setTimeout(e,50)}I(),m.ready()}}()}return H.promise(b)};var K="undefined",L;for(L in m(k))break;k.ownLast="0"!==L,k.inlineBlockNeedsLayout=!1,m(function(){var a,b,c,d;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",k.inlineBlockNeedsLayout=a=3===b.offsetWidth,a&&(c.style.zoom=1)),c.removeChild(d))}),function(){var a=y.createElement("div");if(null==k.deleteExpando){k.deleteExpando=!0;try{delete a.test}catch(b){k.deleteExpando=!1}}a=null}(),m.acceptData=function(a){var b=m.noData[(a.nodeName+" ").toLowerCase()],c=+a.nodeType||1;return 1!==c&&9!==c?!1:!b||b!==!0&&a.getAttribute("classid")===b};var M=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,N=/([A-Z])/g;function O(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(N,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:M.test(c)?m.parseJSON(c):c}catch(e){}m.data(a,b,c)}else c=void 0}return c}function P(a){var b;for(b in a)if(("data"!==b||!m.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function Q(a,b,d,e){if(m.acceptData(a)){var f,g,h=m.expando,i=a.nodeType,j=i?m.cache:a,k=i?a[h]:a[h]&&h;
+if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?m.queue(this[0],a):void 0===b?this:this.each(function(){var c=m.queue(this,a,b);m._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&m.dequeue(this,a)})},dequeue:function(a){return this.each(function(){m.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=m.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=m._data(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var S=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=["Top","Right","Bottom","Left"],U=function(a,b){return a=b||a,"none"===m.css(a,"display")||!m.contains(a.ownerDocument,a)},V=m.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===m.type(c)){e=!0;for(h in c)m.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,m.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(m(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML="  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav></:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="<textarea>x</textarea>",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,c.appendChild(b),b.innerHTML="<input type='radio' checked='checked' name='t'/>",k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,k.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){k.noCloneEvent=!1}),b.cloneNode(!0).click()),null==k.deleteExpando){k.deleteExpando=!0;try{delete b.test}catch(d){k.deleteExpando=!1}}}(),function(){var b,c,d=y.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(k[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),k[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var X=/^(?:input|select|textarea)$/i,Y=/^key/,Z=/^(?:mouse|pointer|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=/^([^.]*)(?:\.(.+)|)$/;function ab(){return!0}function bb(){return!1}function cb(){try{return y.activeElement}catch(a){}}m.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=m.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return typeof m===K||a&&m.event.triggered===a.type?void 0:m.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(E)||[""],h=b.length;while(h--)f=_.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=m.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=m.event.special[o]||{},l=m.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&m.expr.match.needsContext.test(e),namespace:p.join(".")},i),(n=g[o])||(n=g[o]=[],n.delegateCount=0,j.setup&&j.setup.call(a,d,p,k)!==!1||(a.addEventListener?a.addEventListener(o,k,!1):a.attachEvent&&a.attachEvent("on"+o,k))),j.add&&(j.add.call(a,l),l.handler.guid||(l.handler.guid=c.guid)),e?n.splice(n.delegateCount++,0,l):n.push(l),m.event.global[o]=!0);a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m.hasData(a)&&m._data(a);if(r&&(k=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=_.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=m.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,n=k[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=n.length;while(f--)g=n[f],!e&&q!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(n.splice(f,1),g.selector&&n.delegateCount--,l.remove&&l.remove.call(a,g));i&&!n.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||m.removeEvent(a,o,r.handle),delete k[o])}else for(o in k)m.event.remove(a,o+b[j],c,d,!0);m.isEmptyObject(k)&&(delete r.handle,m._removeData(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,n,o=[d||y],p=j.call(b,"type")?b.type:b,q=j.call(b,"namespace")?b.namespace.split("."):[];if(h=l=d=d||y,3!==d.nodeType&&8!==d.nodeType&&!$.test(p+m.event.triggered)&&(p.indexOf(".")>=0&&(q=p.split("."),p=q.shift(),q.sort()),g=p.indexOf(":")<0&&"on"+p,b=b[m.expando]?b:new m.Event(p,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=q.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:m.makeArray(c,[b]),k=m.event.special[p]||{},e||!k.trigger||k.trigger.apply(d,c)!==!1)){if(!e&&!k.noBubble&&!m.isWindow(d)){for(i=k.delegateType||p,$.test(i+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),l=h;l===(d.ownerDocument||y)&&o.push(l.defaultView||l.parentWindow||a)}n=0;while((h=o[n++])&&!b.isPropagationStopped())b.type=n>1?i:k.bindType||p,f=(m._data(h,"events")||{})[b.type]&&m._data(h,"handle"),f&&f.apply(h,c),f=g&&h[g],f&&f.apply&&m.acceptData(h)&&(b.result=f.apply(h,c),b.result===!1&&b.preventDefault());if(b.type=p,!e&&!b.isDefaultPrevented()&&(!k._default||k._default.apply(o.pop(),c)===!1)&&m.acceptData(d)&&g&&d[p]&&!m.isWindow(d)){l=d[g],l&&(d[g]=null),m.event.triggered=p;try{d[p]()}catch(r){}m.event.triggered=void 0,l&&(d[g]=l)}return b.result}},dispatch:function(a){a=m.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(m._data(this,"events")||{})[a.type]||[],k=m.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=m.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,g=0;while((e=f.handlers[g++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,c=((m.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),void 0!==c&&(a.result=c)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!=this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(e=[],f=0;h>f;f++)d=b[f],c=d.selector+" ",void 0===e[c]&&(e[c]=d.needsContext?m(c,this).index(i)>=0:m.find(c,this,null,[i]).length),e[c]&&e.push(d);e.length&&g.push({elem:i,handlers:e})}return h<b.length&&g.push({elem:this,handlers:b.slice(h)}),g},fix:function(a){if(a[m.expando])return a;var b,c,d,e=a.type,f=a,g=this.fixHooks[e];g||(this.fixHooks[e]=g=Z.test(e)?this.mouseHooks:Y.test(e)?this.keyHooks:{}),d=g.props?this.props.concat(g.props):this.props,a=new m.Event(f),b=d.length;while(b--)c=d[b],a[c]=f[c];return a.target||(a.target=f.srcElement||y),3===a.target.nodeType&&(a.target=a.target.parentNode),a.metaKey=!!a.metaKey,g.filter?g.filter(a,f):a},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){return null==a.which&&(a.which=null!=b.charCode?b.charCode:b.keyCode),a}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,b){var c,d,e,f=b.button,g=b.fromElement;return null==a.pageX&&null!=b.clientX&&(d=a.target.ownerDocument||y,e=d.documentElement,c=d.body,a.pageX=b.clientX+(e&&e.scrollLeft||c&&c.scrollLeft||0)-(e&&e.clientLeft||c&&c.clientLeft||0),a.pageY=b.clientY+(e&&e.scrollTop||c&&c.scrollTop||0)-(e&&e.clientTop||c&&c.clientTop||0)),!a.relatedTarget&&g&&(a.relatedTarget=g===a.target?b.toElement:g),a.which||void 0===f||(a.which=1&f?1:2&f?3:4&f?2:0),a}},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==cb()&&this.focus)try{return this.focus(),!1}catch(a){}},delegateType:"focusin"},blur:{trigger:function(){return this===cb()&&this.blur?(this.blur(),!1):void 0},delegateType:"focusout"},click:{trigger:function(){return m.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):void 0},_default:function(a){return m.nodeName(a.target,"a")}},beforeunload:{postDispatch:function(a){void 0!==a.result&&a.originalEvent&&(a.originalEvent.returnValue=a.result)}}},simulate:function(a,b,c,d){var e=m.extend(new m.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?m.event.trigger(e,null,b):m.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},m.removeEvent=y.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){var d="on"+b;a.detachEvent&&(typeof a[d]===K&&(a[d]=null),a.detachEvent(d,c))},m.Event=function(a,b){return this instanceof m.Event?(a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||void 0===a.defaultPrevented&&a.returnValue===!1?ab:bb):this.type=a,b&&m.extend(this,b),this.timeStamp=a&&a.timeStamp||m.now(),void(this[m.expando]=!0)):new m.Event(a,b)},m.Event.prototype={isDefaultPrevented:bb,isPropagationStopped:bb,isImmediatePropagationStopped:bb,preventDefault:function(){var a=this.originalEvent;this.isDefaultPrevented=ab,a&&(a.preventDefault?a.preventDefault():a.returnValue=!1)},stopPropagation:function(){var a=this.originalEvent;this.isPropagationStopped=ab,a&&(a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)},stopImmediatePropagation:function(){var a=this.originalEvent;this.isImmediatePropagationStopped=ab,a&&a.stopImmediatePropagation&&a.stopImmediatePropagation(),this.stopPropagation()}},m.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(a,b){m.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj;return(!e||e!==d&&!m.contains(d,e))&&(a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b),c}}}),k.submitBubbles||(m.event.special.submit={setup:function(){return m.nodeName(this,"form")?!1:void m.event.add(this,"click._submit keypress._submit",function(a){var b=a.target,c=m.nodeName(b,"input")||m.nodeName(b,"button")?b.form:void 0;c&&!m._data(c,"submitBubbles")&&(m.event.add(c,"submit._submit",function(a){a._submit_bubble=!0}),m._data(c,"submitBubbles",!0))})},postDispatch:function(a){a._submit_bubble&&(delete a._submit_bubble,this.parentNode&&!a.isTrigger&&m.event.simulate("submit",this.parentNode,a,!0))},teardown:function(){return m.nodeName(this,"form")?!1:void m.event.remove(this,"._submit")}}),k.changeBubbles||(m.event.special.change={setup:function(){return X.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(m.event.add(this,"propertychange._change",function(a){"checked"===a.originalEvent.propertyName&&(this._just_changed=!0)}),m.event.add(this,"click._change",function(a){this._just_changed&&!a.isTrigger&&(this._just_changed=!1),m.event.simulate("change",this,a,!0)})),!1):void m.event.add(this,"beforeactivate._change",function(a){var b=a.target;X.test(b.nodeName)&&!m._data(b,"changeBubbles")&&(m.event.add(b,"change._change",function(a){!this.parentNode||a.isSimulated||a.isTrigger||m.event.simulate("change",this.parentNode,a,!0)}),m._data(b,"changeBubbles",!0))})},handle:function(a){var b=a.target;return this!==b||a.isSimulated||a.isTrigger||"radio"!==b.type&&"checkbox"!==b.type?a.handleObj.handler.apply(this,arguments):void 0},teardown:function(){return m.event.remove(this,"._change"),!X.test(this.nodeName)}}),k.focusinBubbles||m.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){m.event.simulate(b,a.target,m.event.fix(a),!0)};m.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=m._data(d,b);e||d.addEventListener(a,c,!0),m._data(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=m._data(d,b)-1;e?m._data(d,b,e):(d.removeEventListener(a,c,!0),m._removeData(d,b))}}}),m.fn.extend({on:function(a,b,c,d,e){var f,g;if("object"==typeof a){"string"!=typeof b&&(c=c||b,b=void 0);for(f in a)this.on(f,b,c,a[f],e);return this}if(null==c&&null==d?(d=b,c=b=void 0):null==d&&("string"==typeof b?(d=c,c=void 0):(d=c,c=b,b=void 0)),d===!1)d=bb;else if(!d)return this;return 1===e&&(g=d,d=function(a){return m().off(a),g.apply(this,arguments)},d.guid=g.guid||(g.guid=m.guid++)),this.each(function(){m.event.add(this,a,d,c,b)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,b,c){var d,e;if(a&&a.preventDefault&&a.handleObj)return d=a.handleObj,m(a.delegateTarget).off(d.namespace?d.origType+"."+d.namespace:d.origType,d.selector,d.handler),this;if("object"==typeof a){for(e in a)this.off(e,b,a[e]);return this}return(b===!1||"function"==typeof b)&&(c=b,b=void 0),c===!1&&(c=bb),this.each(function(){m.event.remove(this,a,c,b)})},trigger:function(a,b){return this.each(function(){m.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];return c?m.event.trigger(a,b,c,!0):void 0}});function db(a){var b=eb.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}var eb="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",fb=/ jQuery\d+="(?:null|\d+)"/g,gb=new RegExp("<(?:"+eb+")[\\s/>]","i"),hb=/^\s+/,ib=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,jb=/<([\w:]+)/,kb=/<tbody/i,lb=/<|&#?\w+;/,mb=/<(?:script|style|link)/i,nb=/checked\s*(?:[^=]|=\s*.checked.)/i,ob=/^$|\/(?:java|ecma)script/i,pb=/^true\/(.*)/,qb=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,rb={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:k.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},sb=db(y),tb=sb.appendChild(y.createElement("div"));rb.optgroup=rb.option,rb.tbody=rb.tfoot=rb.colgroup=rb.caption=rb.thead,rb.th=rb.td;function ub(a,b){var c,d,e=0,f=typeof a.getElementsByTagName!==K?a.getElementsByTagName(b||"*"):typeof a.querySelectorAll!==K?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||m.nodeName(d,b)?f.push(d):m.merge(f,ub(d,b));return void 0===b||b&&m.nodeName(a,b)?m.merge([a],f):f}function vb(a){W.test(a.type)&&(a.defaultChecked=a.checked)}function wb(a,b){return m.nodeName(a,"table")&&m.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function xb(a){return a.type=(null!==m.find.attr(a,"type"))+"/"+a.type,a}function yb(a){var b=pb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function zb(a,b){for(var c,d=0;null!=(c=a[d]);d++)m._data(c,"globalEval",!b||m._data(b[d],"globalEval"))}function Ab(a,b){if(1===b.nodeType&&m.hasData(a)){var c,d,e,f=m._data(a),g=m._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)m.event.add(b,c,h[c][d])}g.data&&(g.data=m.extend({},g.data))}}function Bb(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!k.noCloneEvent&&b[m.expando]){e=m._data(b);for(d in e.events)m.removeEvent(b,d,e.handle);b.removeAttribute(m.expando)}"script"===c&&b.text!==a.text?(xb(b).text=a.text,yb(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),k.html5Clone&&a.innerHTML&&!m.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&W.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}m.extend({clone:function(a,b,c){var d,e,f,g,h,i=m.contains(a.ownerDocument,a);if(k.html5Clone||m.isXMLDoc(a)||!gb.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(tb.innerHTML=a.outerHTML,tb.removeChild(f=tb.firstChild)),!(k.noCloneEvent&&k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||m.isXMLDoc(a)))for(d=ub(f),h=ub(a),g=0;null!=(e=h[g]);++g)d[g]&&Bb(e,d[g]);if(b)if(c)for(h=h||ub(a),d=d||ub(f),g=0;null!=(e=h[g]);g++)Ab(e,d[g]);else Ab(a,f);return d=ub(f,"script"),d.length>0&&zb(d,!i&&ub(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,l,n=a.length,o=db(b),p=[],q=0;n>q;q++)if(f=a[q],f||0===f)if("object"===m.type(f))m.merge(p,f.nodeType?[f]:f);else if(lb.test(f)){h=h||o.appendChild(b.createElement("div")),i=(jb.exec(f)||["",""])[1].toLowerCase(),l=rb[i]||rb._default,h.innerHTML=l[1]+f.replace(ib,"<$1></$2>")+l[2],e=l[0];while(e--)h=h.lastChild;if(!k.leadingWhitespace&&hb.test(f)&&p.push(b.createTextNode(hb.exec(f)[0])),!k.tbody){f="table"!==i||kb.test(f)?"<table>"!==l[1]||kb.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;while(e--)m.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j)}m.merge(p,h.childNodes),h.textContent="";while(h.firstChild)h.removeChild(h.firstChild);h=o.lastChild}else p.push(b.createTextNode(f));h&&o.removeChild(h),k.appendChecked||m.grep(ub(p,"input"),vb),q=0;while(f=p[q++])if((!d||-1===m.inArray(f,d))&&(g=m.contains(f.ownerDocument,f),h=ub(o.appendChild(f),"script"),g&&zb(h),c)){e=0;while(f=h[e++])ob.test(f.type||"")&&c.push(f)}return h=null,o},cleanData:function(a,b){for(var d,e,f,g,h=0,i=m.expando,j=m.cache,l=k.deleteExpando,n=m.event.special;null!=(d=a[h]);h++)if((b||m.acceptData(d))&&(f=d[i],g=f&&j[f])){if(g.events)for(e in g.events)n[e]?m.event.remove(d,e):m.removeEvent(d,e,g.handle);j[f]&&(delete j[f],l?delete d[i]:typeof d.removeAttribute!==K?d.removeAttribute(i):d[i]=null,c.push(f))}}}),m.fn.extend({text:function(a){return V(this,function(a){return void 0===a?m.text(this):this.empty().append((this[0]&&this[0].ownerDocument||y).createTextNode(a))},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?m.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||m.cleanData(ub(c)),c.parentNode&&(b&&m.contains(c.ownerDocument,c)&&zb(ub(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){1===a.nodeType&&m.cleanData(ub(a,!1));while(a.firstChild)a.removeChild(a.firstChild);a.options&&m.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return m.clone(this,a,b)})},html:function(a){return V(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a)return 1===b.nodeType?b.innerHTML.replace(fb,""):void 0;if(!("string"!=typeof a||mb.test(a)||!k.htmlSerialize&&gb.test(a)||!k.leadingWhitespace&&hb.test(a)||rb[(jb.exec(a)||["",""])[1].toLowerCase()])){a=a.replace(ib,"<$1></$2>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(m.cleanData(ub(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,m.cleanData(ub(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,n=this,o=l-1,p=a[0],q=m.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&nb.test(p))return this.each(function(c){var d=n.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(i=m.buildFragment(a,this[0].ownerDocument,!1,this),c=i.firstChild,1===i.childNodes.length&&(i=c),c)){for(g=m.map(ub(i,"script"),xb),f=g.length;l>j;j++)d=i,j!==o&&(d=m.clone(d,!0,!0),f&&m.merge(g,ub(d,"script"))),b.call(this[j],d,j);if(f)for(h=g[g.length-1].ownerDocument,m.map(g,yb),j=0;f>j;j++)d=g[j],ob.test(d.type||"")&&!m._data(d,"globalEval")&&m.contains(h,d)&&(d.src?m._evalUrl&&m._evalUrl(d.src):m.globalEval((d.text||d.textContent||d.innerHTML||"").replace(qb,"")));i=c=null}return this}}),m.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){m.fn[a]=function(a){for(var c,d=0,e=[],g=m(a),h=g.length-1;h>=d;d++)c=d===h?this:this.clone(!0),m(g[d])[b](c),f.apply(e,c.get());return this.pushStack(e)}});var Cb,Db={};function Eb(b,c){var d,e=m(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:m.css(e[0],"display");return e.detach(),f}function Fb(a){var b=y,c=Db[a];return c||(c=Eb(a,b),"none"!==c&&c||(Cb=(Cb||m("<iframe frameborder='0' width='0' height='0'/>")).appendTo(b.documentElement),b=(Cb[0].contentWindow||Cb[0].contentDocument).document,b.write(),b.close(),c=Eb(a,b),Cb.detach()),Db[a]=c),c}!function(){var a;k.shrinkWrapBlocks=function(){if(null!=a)return a;a=!1;var b,c,d;return c=y.getElementsByTagName("body")[0],c&&c.style?(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:1px;width:1px;zoom:1",b.appendChild(y.createElement("div")).style.width="5px",a=3!==b.offsetWidth),c.removeChild(d),a):void 0}}();var Gb=/^margin/,Hb=new RegExp("^("+S+")(?!px)[a-z%]+$","i"),Ib,Jb,Kb=/^(top|right|bottom|left)$/;a.getComputedStyle?(Ib=function(a){return a.ownerDocument.defaultView.getComputedStyle(a,null)},Jb=function(a,b,c){var d,e,f,g,h=a.style;return c=c||Ib(a),g=c?c.getPropertyValue(b)||c[b]:void 0,c&&(""!==g||m.contains(a.ownerDocument,a)||(g=m.style(a,b)),Hb.test(g)&&Gb.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0===g?g:g+""}):y.documentElement.currentStyle&&(Ib=function(a){return a.currentStyle},Jb=function(a,b,c){var d,e,f,g,h=a.style;return c=c||Ib(a),g=c?c[b]:void 0,null==g&&h&&h[b]&&(g=h[b]),Hb.test(g)&&!Kb.test(b)&&(d=h.left,e=a.runtimeStyle,f=e&&e.left,f&&(e.left=a.currentStyle.left),h.left="fontSize"===b?"1em":g,g=h.pixelLeft+"px",h.left=d,f&&(e.left=f)),void 0===g?g:g+""||"auto"});function Lb(a,b){return{get:function(){var c=a();if(null!=c)return c?void delete this.get:(this.get=b).apply(this,arguments)}}}!function(){var b,c,d,e,f,g,h;if(b=y.createElement("div"),b.innerHTML="  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",d=b.getElementsByTagName("a")[0],c=d&&d.style){c.cssText="float:left;opacity:.5",k.opacity="0.5"===c.opacity,k.cssFloat=!!c.cssFloat,b.style.backgroundClip="content-box",b.cloneNode(!0).style.backgroundClip="",k.clearCloneStyle="content-box"===b.style.backgroundClip,k.boxSizing=""===c.boxSizing||""===c.MozBoxSizing||""===c.WebkitBoxSizing,m.extend(k,{reliableHiddenOffsets:function(){return null==g&&i(),g},boxSizingReliable:function(){return null==f&&i(),f},pixelPosition:function(){return null==e&&i(),e},reliableMarginRight:function(){return null==h&&i(),h}});function i(){var b,c,d,i;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),b.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;margin-top:1%;top:1%;border:1px;padding:1px;width:4px;position:absolute",e=f=!1,h=!0,a.getComputedStyle&&(e="1%"!==(a.getComputedStyle(b,null)||{}).top,f="4px"===(a.getComputedStyle(b,null)||{width:"4px"}).width,i=b.appendChild(y.createElement("div")),i.style.cssText=b.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0",i.style.marginRight=i.style.width="0",b.style.width="1px",h=!parseFloat((a.getComputedStyle(i,null)||{}).marginRight)),b.innerHTML="<table><tr><td></td><td>t</td></tr></table>",i=b.getElementsByTagName("td"),i[0].style.cssText="margin:0;border:0;padding:0;display:none",g=0===i[0].offsetHeight,g&&(i[0].style.display="",i[1].style.display="none",g=0===i[0].offsetHeight),c.removeChild(d))}}}(),m.swap=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};var Mb=/alpha\([^)]*\)/i,Nb=/opacity\s*=\s*([^)]*)/,Ob=/^(none|table(?!-c[ea]).+)/,Pb=new RegExp("^("+S+")(.*)$","i"),Qb=new RegExp("^([+-])=("+S+")","i"),Rb={position:"absolute",visibility:"hidden",display:"block"},Sb={letterSpacing:"0",fontWeight:"400"},Tb=["Webkit","O","Moz","ms"];function Ub(a,b){if(b in a)return b;var c=b.charAt(0).toUpperCase()+b.slice(1),d=b,e=Tb.length;while(e--)if(b=Tb[e]+c,b in a)return b;return d}function Vb(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=m._data(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&U(d)&&(f[g]=m._data(d,"olddisplay",Fb(d.nodeName)))):(e=U(d),(c&&"none"!==c||!e)&&m._data(d,"olddisplay",e?c:m.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}function Wb(a,b,c){var d=Pb.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function Xb(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=m.css(a,c+T[f],!0,e)),d?("content"===c&&(g-=m.css(a,"padding"+T[f],!0,e)),"margin"!==c&&(g-=m.css(a,"border"+T[f]+"Width",!0,e))):(g+=m.css(a,"padding"+T[f],!0,e),"padding"!==c&&(g+=m.css(a,"border"+T[f]+"Width",!0,e)));return g}function Yb(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=Ib(a),g=k.boxSizing&&"border-box"===m.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=Jb(a,b,f),(0>e||null==e)&&(e=a.style[b]),Hb.test(e))return e;d=g&&(k.boxSizingReliable()||e===a.style[b]),e=parseFloat(e)||0}return e+Xb(a,b,c||(g?"border":"content"),d,f)+"px"}m.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=Jb(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":k.cssFloat?"cssFloat":"styleFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=m.camelCase(b),i=a.style;if(b=m.cssProps[h]||(m.cssProps[h]=Ub(i,h)),g=m.cssHooks[b]||m.cssHooks[h],void 0===c)return g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:i[b];if(f=typeof c,"string"===f&&(e=Qb.exec(c))&&(c=(e[1]+1)*e[2]+parseFloat(m.css(a,b)),f="number"),null!=c&&c===c&&("number"!==f||m.cssNumber[h]||(c+="px"),k.clearCloneStyle||""!==c||0!==b.indexOf("background")||(i[b]="inherit"),!(g&&"set"in g&&void 0===(c=g.set(a,c,d)))))try{i[b]=c}catch(j){}}},css:function(a,b,c,d){var e,f,g,h=m.camelCase(b);return b=m.cssProps[h]||(m.cssProps[h]=Ub(a.style,h)),g=m.cssHooks[b]||m.cssHooks[h],g&&"get"in g&&(f=g.get(a,!0,c)),void 0===f&&(f=Jb(a,b,d)),"normal"===f&&b in Sb&&(f=Sb[b]),""===c||c?(e=parseFloat(f),c===!0||m.isNumeric(e)?e||0:f):f}}),m.each(["height","width"],function(a,b){m.cssHooks[b]={get:function(a,c,d){return c?Ob.test(m.css(a,"display"))&&0===a.offsetWidth?m.swap(a,Rb,function(){return Yb(a,b,d)}):Yb(a,b,d):void 0},set:function(a,c,d){var e=d&&Ib(a);return Wb(a,c,d?Xb(a,b,d,k.boxSizing&&"border-box"===m.css(a,"boxSizing",!1,e),e):0)}}}),k.opacity||(m.cssHooks.opacity={get:function(a,b){return Nb.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=m.isNumeric(b)?"alpha(opacity="+100*b+")":"",f=d&&d.filter||c.filter||"";c.zoom=1,(b>=1||""===b)&&""===m.trim(f.replace(Mb,""))&&c.removeAttribute&&(c.removeAttribute("filter"),""===b||d&&!d.filter)||(c.filter=Mb.test(f)?f.replace(Mb,e):f+" "+e)}}),m.cssHooks.marginRight=Lb(k.reliableMarginRight,function(a,b){return b?m.swap(a,{display:"inline-block"},Jb,[a,"marginRight"]):void 0}),m.each({margin:"",padding:"",border:"Width"},function(a,b){m.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];4>d;d++)e[a+T[d]+b]=f[d]||f[d-2]||f[0];return e}},Gb.test(a)||(m.cssHooks[a+b].set=Wb)}),m.fn.extend({css:function(a,b){return V(this,function(a,b,c){var d,e,f={},g=0;if(m.isArray(b)){for(d=Ib(a),e=b.length;e>g;g++)f[b[g]]=m.css(a,b[g],!1,d);return f}return void 0!==c?m.style(a,b,c):m.css(a,b)},a,b,arguments.length>1)},show:function(){return Vb(this,!0)},hide:function(){return Vb(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){U(this)?m(this).show():m(this).hide()})}});function Zb(a,b,c,d,e){return new Zb.prototype.init(a,b,c,d,e)}m.Tween=Zb,Zb.prototype={constructor:Zb,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(m.cssNumber[c]?"":"px")
+},cur:function(){var a=Zb.propHooks[this.prop];return a&&a.get?a.get(this):Zb.propHooks._default.get(this)},run:function(a){var b,c=Zb.propHooks[this.prop];return this.pos=b=this.options.duration?m.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Zb.propHooks._default.set(this),this}},Zb.prototype.init.prototype=Zb.prototype,Zb.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=m.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){m.fx.step[a.prop]?m.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[m.cssProps[a.prop]]||m.cssHooks[a.prop])?m.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Zb.propHooks.scrollTop=Zb.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},m.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},m.fx=Zb.prototype.init,m.fx.step={};var $b,_b,ac=/^(?:toggle|show|hide)$/,bc=new RegExp("^(?:([+-])=|)("+S+")([a-z%]*)$","i"),cc=/queueHooks$/,dc=[ic],ec={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=bc.exec(b),f=e&&e[3]||(m.cssNumber[a]?"":"px"),g=(m.cssNumber[a]||"px"!==f&&+d)&&bc.exec(m.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,m.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function fc(){return setTimeout(function(){$b=void 0}),$b=m.now()}function gc(a,b){var c,d={height:a},e=0;for(b=b?1:0;4>e;e+=2-b)c=T[e],d["margin"+c]=d["padding"+c]=a;return b&&(d.opacity=d.width=a),d}function hc(a,b,c){for(var d,e=(ec[b]||[]).concat(ec["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function ic(a,b,c){var d,e,f,g,h,i,j,l,n=this,o={},p=a.style,q=a.nodeType&&U(a),r=m._data(a,"fxshow");c.queue||(h=m._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,n.always(function(){n.always(function(){h.unqueued--,m.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[p.overflow,p.overflowX,p.overflowY],j=m.css(a,"display"),l="none"===j?m._data(a,"olddisplay")||Fb(a.nodeName):j,"inline"===l&&"none"===m.css(a,"float")&&(k.inlineBlockNeedsLayout&&"inline"!==Fb(a.nodeName)?p.zoom=1:p.display="inline-block")),c.overflow&&(p.overflow="hidden",k.shrinkWrapBlocks()||n.always(function(){p.overflow=c.overflow[0],p.overflowX=c.overflow[1],p.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],ac.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(q?"hide":"show")){if("show"!==e||!r||void 0===r[d])continue;q=!0}o[d]=r&&r[d]||m.style(a,d)}else j=void 0;if(m.isEmptyObject(o))"inline"===("none"===j?Fb(a.nodeName):j)&&(p.display=j);else{r?"hidden"in r&&(q=r.hidden):r=m._data(a,"fxshow",{}),f&&(r.hidden=!q),q?m(a).show():n.done(function(){m(a).hide()}),n.done(function(){var b;m._removeData(a,"fxshow");for(b in o)m.style(a,b,o[b])});for(d in o)g=hc(q?r[d]:0,d,n),d in r||(r[d]=g.start,q&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function jc(a,b){var c,d,e,f,g;for(c in a)if(d=m.camelCase(c),e=b[d],f=a[c],m.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=m.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function kc(a,b,c){var d,e,f=0,g=dc.length,h=m.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=$b||fc(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:m.extend({},b),opts:m.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:$b||fc(),duration:c.duration,tweens:[],createTween:function(b,c){var d=m.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(jc(k,j.opts.specialEasing);g>f;f++)if(d=dc[f].call(j,a,k,j.opts))return d;return m.map(k,hc,j),m.isFunction(j.opts.start)&&j.opts.start.call(a,j),m.fx.timer(m.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}m.Animation=m.extend(kc,{tweener:function(a,b){m.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],ec[c]=ec[c]||[],ec[c].unshift(b)},prefilter:function(a,b){b?dc.unshift(a):dc.push(a)}}),m.speed=function(a,b,c){var d=a&&"object"==typeof a?m.extend({},a):{complete:c||!c&&b||m.isFunction(a)&&a,duration:a,easing:c&&b||b&&!m.isFunction(b)&&b};return d.duration=m.fx.off?0:"number"==typeof d.duration?d.duration:d.duration in m.fx.speeds?m.fx.speeds[d.duration]:m.fx.speeds._default,(null==d.queue||d.queue===!0)&&(d.queue="fx"),d.old=d.complete,d.complete=function(){m.isFunction(d.old)&&d.old.call(this),d.queue&&m.dequeue(this,d.queue)},d},m.fn.extend({fadeTo:function(a,b,c,d){return this.filter(U).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=m.isEmptyObject(a),f=m.speed(b,c,d),g=function(){var b=kc(this,m.extend({},a),f);(e||m._data(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=m.timers,g=m._data(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&cc.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));(b||!c)&&m.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=m._data(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=m.timers,g=d?d.length:0;for(c.finish=!0,m.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;g>b;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),m.each(["toggle","show","hide"],function(a,b){var c=m.fn[b];m.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(gc(b,!0),a,d,e)}}),m.each({slideDown:gc("show"),slideUp:gc("hide"),slideToggle:gc("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){m.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),m.timers=[],m.fx.tick=function(){var a,b=m.timers,c=0;for($b=m.now();c<b.length;c++)a=b[c],a()||b[c]!==a||b.splice(c--,1);b.length||m.fx.stop(),$b=void 0},m.fx.timer=function(a){m.timers.push(a),a()?m.fx.start():m.timers.pop()},m.fx.interval=13,m.fx.start=function(){_b||(_b=setInterval(m.fx.tick,m.fx.interval))},m.fx.stop=function(){clearInterval(_b),_b=null},m.fx.speeds={slow:600,fast:200,_default:400},m.fn.delay=function(a,b){return a=m.fx?m.fx.speeds[a]||a:a,b=b||"fx",this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},function(){var a,b,c,d,e;b=y.createElement("div"),b.setAttribute("className","t"),b.innerHTML="  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",d=b.getElementsByTagName("a")[0],c=y.createElement("select"),e=c.appendChild(y.createElement("option")),a=b.getElementsByTagName("input")[0],d.style.cssText="top:1px",k.getSetAttribute="t"!==b.className,k.style=/top/.test(d.getAttribute("style")),k.hrefNormalized="/a"===d.getAttribute("href"),k.checkOn=!!a.value,k.optSelected=e.selected,k.enctype=!!y.createElement("form").enctype,c.disabled=!0,k.optDisabled=!e.disabled,a=y.createElement("input"),a.setAttribute("value",""),k.input=""===a.getAttribute("value"),a.value="t",a.setAttribute("type","radio"),k.radioValue="t"===a.value}();var lc=/\r/g;m.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=m.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,m(this).val()):a,null==e?e="":"number"==typeof e?e+="":m.isArray(e)&&(e=m.map(e,function(a){return null==a?"":a+""})),b=m.valHooks[this.type]||m.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=m.valHooks[e.type]||m.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(lc,""):null==c?"":c)}}}),m.extend({valHooks:{option:{get:function(a){var b=m.find.attr(a,"value");return null!=b?b:m.trim(m.text(a))}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(k.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&m.nodeName(c.parentNode,"optgroup"))){if(b=m(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=m.makeArray(b),g=e.length;while(g--)if(d=e[g],m.inArray(m.valHooks.option.get(d),f)>=0)try{d.selected=c=!0}catch(h){d.scrollHeight}else d.selected=!1;return c||(a.selectedIndex=-1),e}}}}),m.each(["radio","checkbox"],function(){m.valHooks[this]={set:function(a,b){return m.isArray(b)?a.checked=m.inArray(m(a).val(),b)>=0:void 0}},k.checkOn||(m.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})});var mc,nc,oc=m.expr.attrHandle,pc=/^(?:checked|selected)$/i,qc=k.getSetAttribute,rc=k.input;m.fn.extend({attr:function(a,b){return V(this,m.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){m.removeAttr(this,a)})}}),m.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(a&&3!==f&&8!==f&&2!==f)return typeof a.getAttribute===K?m.prop(a,b,c):(1===f&&m.isXMLDoc(a)||(b=b.toLowerCase(),d=m.attrHooks[b]||(m.expr.match.bool.test(b)?nc:mc)),void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=m.find.attr(a,b),null==e?void 0:e):null!==c?d&&"set"in d&&void 0!==(e=d.set(a,c,b))?e:(a.setAttribute(b,c+""),c):void m.removeAttr(a,b))},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(E);if(f&&1===a.nodeType)while(c=f[e++])d=m.propFix[c]||c,m.expr.match.bool.test(c)?rc&&qc||!pc.test(c)?a[d]=!1:a[m.camelCase("default-"+c)]=a[d]=!1:m.attr(a,c,""),a.removeAttribute(qc?c:d)},attrHooks:{type:{set:function(a,b){if(!k.radioValue&&"radio"===b&&m.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}}}),nc={set:function(a,b,c){return b===!1?m.removeAttr(a,c):rc&&qc||!pc.test(c)?a.setAttribute(!qc&&m.propFix[c]||c,c):a[m.camelCase("default-"+c)]=a[c]=!0,c}},m.each(m.expr.match.bool.source.match(/\w+/g),function(a,b){var c=oc[b]||m.find.attr;oc[b]=rc&&qc||!pc.test(b)?function(a,b,d){var e,f;return d||(f=oc[b],oc[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,oc[b]=f),e}:function(a,b,c){return c?void 0:a[m.camelCase("default-"+b)]?b.toLowerCase():null}}),rc&&qc||(m.attrHooks.value={set:function(a,b,c){return m.nodeName(a,"input")?void(a.defaultValue=b):mc&&mc.set(a,b,c)}}),qc||(mc={set:function(a,b,c){var d=a.getAttributeNode(c);return d||a.setAttributeNode(d=a.ownerDocument.createAttribute(c)),d.value=b+="","value"===c||b===a.getAttribute(c)?b:void 0}},oc.id=oc.name=oc.coords=function(a,b,c){var d;return c?void 0:(d=a.getAttributeNode(b))&&""!==d.value?d.value:null},m.valHooks.button={get:function(a,b){var c=a.getAttributeNode(b);return c&&c.specified?c.value:void 0},set:mc.set},m.attrHooks.contenteditable={set:function(a,b,c){mc.set(a,""===b?!1:b,c)}},m.each(["width","height"],function(a,b){m.attrHooks[b]={set:function(a,c){return""===c?(a.setAttribute(b,"auto"),c):void 0}}})),k.style||(m.attrHooks.style={get:function(a){return a.style.cssText||void 0},set:function(a,b){return a.style.cssText=b+""}});var sc=/^(?:input|select|textarea|button|object)$/i,tc=/^(?:a|area)$/i;m.fn.extend({prop:function(a,b){return V(this,m.prop,a,b,arguments.length>1)},removeProp:function(a){return a=m.propFix[a]||a,this.each(function(){try{this[a]=void 0,delete this[a]}catch(b){}})}}),m.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(a,b,c){var d,e,f,g=a.nodeType;if(a&&3!==g&&8!==g&&2!==g)return f=1!==g||!m.isXMLDoc(a),f&&(b=m.propFix[b]||b,e=m.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){var b=m.find.attr(a,"tabindex");return b?parseInt(b,10):sc.test(a.nodeName)||tc.test(a.nodeName)&&a.href?0:-1}}}}),k.hrefNormalized||m.each(["href","src"],function(a,b){m.propHooks[b]={get:function(a){return a.getAttribute(b,4)}}}),k.optSelected||(m.propHooks.selected={get:function(a){var b=a.parentNode;return b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex),null}}),m.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){m.propFix[this.toLowerCase()]=this}),k.enctype||(m.propFix.enctype="encoding");var uc=/[\t\r\n\f]/g;m.fn.extend({addClass:function(a){var b,c,d,e,f,g,h=0,i=this.length,j="string"==typeof a&&a;if(m.isFunction(a))return this.each(function(b){m(this).addClass(a.call(this,b,this.className))});if(j)for(b=(a||"").match(E)||[];i>h;h++)if(c=this[h],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(uc," "):" ")){f=0;while(e=b[f++])d.indexOf(" "+e+" ")<0&&(d+=e+" ");g=m.trim(d),c.className!==g&&(c.className=g)}return this},removeClass:function(a){var b,c,d,e,f,g,h=0,i=this.length,j=0===arguments.length||"string"==typeof a&&a;if(m.isFunction(a))return this.each(function(b){m(this).removeClass(a.call(this,b,this.className))});if(j)for(b=(a||"").match(E)||[];i>h;h++)if(c=this[h],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(uc," "):"")){f=0;while(e=b[f++])while(d.indexOf(" "+e+" ")>=0)d=d.replace(" "+e+" "," ");g=a?m.trim(d):"",c.className!==g&&(c.className=g)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):this.each(m.isFunction(a)?function(c){m(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c){var b,d=0,e=m(this),f=a.match(E)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(c===K||"boolean"===c)&&(this.className&&m._data(this,"__className__",this.className),this.className=this.className||a===!1?"":m._data(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(uc," ").indexOf(b)>=0)return!0;return!1}}),m.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){m.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),m.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}});var vc=m.now(),wc=/\?/,xc=/(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;m.parseJSON=function(b){if(a.JSON&&a.JSON.parse)return a.JSON.parse(b+"");var c,d=null,e=m.trim(b+"");return e&&!m.trim(e.replace(xc,function(a,b,e,f){return c&&b&&(d=0),0===d?a:(c=e||b,d+=!f-!e,"")}))?Function("return "+e)():m.error("Invalid JSON: "+b)},m.parseXML=function(b){var c,d;if(!b||"string"!=typeof b)return null;try{a.DOMParser?(d=new DOMParser,c=d.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b))}catch(e){c=void 0}return c&&c.documentElement&&!c.getElementsByTagName("parsererror").length||m.error("Invalid XML: "+b),c};var yc,zc,Ac=/#.*$/,Bc=/([?&])_=[^&]*/,Cc=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Dc=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Ec=/^(?:GET|HEAD)$/,Fc=/^\/\//,Gc=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,Hc={},Ic={},Jc="*/".concat("*");try{zc=location.href}catch(Kc){zc=y.createElement("a"),zc.href="",zc=zc.href}yc=Gc.exec(zc.toLowerCase())||[];function Lc(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(E)||[];if(m.isFunction(c))while(d=f[e++])"+"===d.charAt(0)?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function Mc(a,b,c,d){var e={},f=a===Ic;function g(h){var i;return e[h]=!0,m.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function Nc(a,b){var c,d,e=m.ajaxSettings.flatOptions||{};for(d in b)void 0!==b[d]&&((e[d]?a:c||(c={}))[d]=b[d]);return c&&m.extend(!0,a,c),a}function Oc(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===e&&(e=a.mimeType||b.getResponseHeader("Content-Type"));if(e)for(g in h)if(h[g]&&h[g].test(e)){i.unshift(g);break}if(i[0]in c)f=i[0];else{for(g in c){if(!i[0]||a.converters[g+" "+i[0]]){f=g;break}d||(d=g)}f=f||d}return f?(f!==i[0]&&i.unshift(f),c[f]):void 0}function Pc(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}m.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:zc,type:"GET",isLocal:Dc.test(yc[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Jc,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":m.parseJSON,"text xml":m.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?Nc(Nc(a,m.ajaxSettings),b):Nc(m.ajaxSettings,a)},ajaxPrefilter:Lc(Hc),ajaxTransport:Lc(Ic),ajax:function(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c,d,e,f,g,h,i,j,k=m.ajaxSetup({},b),l=k.context||k,n=k.context&&(l.nodeType||l.jquery)?m(l):m.event,o=m.Deferred(),p=m.Callbacks("once memory"),q=k.statusCode||{},r={},s={},t=0,u="canceled",v={readyState:0,getResponseHeader:function(a){var b;if(2===t){if(!j){j={};while(b=Cc.exec(f))j[b[1].toLowerCase()]=b[2]}b=j[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===t?f:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return t||(a=s[c]=s[c]||a,r[a]=b),this},overrideMimeType:function(a){return t||(k.mimeType=a),this},statusCode:function(a){var b;if(a)if(2>t)for(b in a)q[b]=[q[b],a[b]];else v.always(a[v.status]);return this},abort:function(a){var b=a||u;return i&&i.abort(b),x(0,b),this}};if(o.promise(v).complete=p.add,v.success=v.done,v.error=v.fail,k.url=((a||k.url||zc)+"").replace(Ac,"").replace(Fc,yc[1]+"//"),k.type=b.method||b.type||k.method||k.type,k.dataTypes=m.trim(k.dataType||"*").toLowerCase().match(E)||[""],null==k.crossDomain&&(c=Gc.exec(k.url.toLowerCase()),k.crossDomain=!(!c||c[1]===yc[1]&&c[2]===yc[2]&&(c[3]||("http:"===c[1]?"80":"443"))===(yc[3]||("http:"===yc[1]?"80":"443")))),k.data&&k.processData&&"string"!=typeof k.data&&(k.data=m.param(k.data,k.traditional)),Mc(Hc,k,b,v),2===t)return v;h=k.global,h&&0===m.active++&&m.event.trigger("ajaxStart"),k.type=k.type.toUpperCase(),k.hasContent=!Ec.test(k.type),e=k.url,k.hasContent||(k.data&&(e=k.url+=(wc.test(e)?"&":"?")+k.data,delete k.data),k.cache===!1&&(k.url=Bc.test(e)?e.replace(Bc,"$1_="+vc++):e+(wc.test(e)?"&":"?")+"_="+vc++)),k.ifModified&&(m.lastModified[e]&&v.setRequestHeader("If-Modified-Since",m.lastModified[e]),m.etag[e]&&v.setRequestHeader("If-None-Match",m.etag[e])),(k.data&&k.hasContent&&k.contentType!==!1||b.contentType)&&v.setRequestHeader("Content-Type",k.contentType),v.setRequestHeader("Accept",k.dataTypes[0]&&k.accepts[k.dataTypes[0]]?k.accepts[k.dataTypes[0]]+("*"!==k.dataTypes[0]?", "+Jc+"; q=0.01":""):k.accepts["*"]);for(d in k.headers)v.setRequestHeader(d,k.headers[d]);if(k.beforeSend&&(k.beforeSend.call(l,v,k)===!1||2===t))return v.abort();u="abort";for(d in{success:1,error:1,complete:1})v[d](k[d]);if(i=Mc(Ic,k,b,v)){v.readyState=1,h&&n.trigger("ajaxSend",[v,k]),k.async&&k.timeout>0&&(g=setTimeout(function(){v.abort("timeout")},k.timeout));try{t=1,i.send(r,x)}catch(w){if(!(2>t))throw w;x(-1,w)}}else x(-1,"No Transport");function x(a,b,c,d){var j,r,s,u,w,x=b;2!==t&&(t=2,g&&clearTimeout(g),i=void 0,f=d||"",v.readyState=a>0?4:0,j=a>=200&&300>a||304===a,c&&(u=Oc(k,v,c)),u=Pc(k,u,v,j),j?(k.ifModified&&(w=v.getResponseHeader("Last-Modified"),w&&(m.lastModified[e]=w),w=v.getResponseHeader("etag"),w&&(m.etag[e]=w)),204===a||"HEAD"===k.type?x="nocontent":304===a?x="notmodified":(x=u.state,r=u.data,s=u.error,j=!s)):(s=x,(a||!x)&&(x="error",0>a&&(a=0))),v.status=a,v.statusText=(b||x)+"",j?o.resolveWith(l,[r,x,v]):o.rejectWith(l,[v,x,s]),v.statusCode(q),q=void 0,h&&n.trigger(j?"ajaxSuccess":"ajaxError",[v,k,j?r:s]),p.fireWith(l,[v,x]),h&&(n.trigger("ajaxComplete",[v,k]),--m.active||m.event.trigger("ajaxStop")))}return v},getJSON:function(a,b,c){return m.get(a,b,c,"json")},getScript:function(a,b){return m.get(a,void 0,b,"script")}}),m.each(["get","post"],function(a,b){m[b]=function(a,c,d,e){return m.isFunction(c)&&(e=e||d,d=c,c=void 0),m.ajax({url:a,type:b,dataType:e,data:c,success:d})}}),m.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){m.fn[b]=function(a){return this.on(b,a)}}),m._evalUrl=function(a){return m.ajax({url:a,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},m.fn.extend({wrapAll:function(a){if(m.isFunction(a))return this.each(function(b){m(this).wrapAll(a.call(this,b))});if(this[0]){var b=m(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&1===a.firstChild.nodeType)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){return this.each(m.isFunction(a)?function(b){m(this).wrapInner(a.call(this,b))}:function(){var b=m(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=m.isFunction(a);return this.each(function(c){m(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){m.nodeName(this,"body")||m(this).replaceWith(this.childNodes)}).end()}}),m.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0||!k.reliableHiddenOffsets()&&"none"===(a.style&&a.style.display||m.css(a,"display"))},m.expr.filters.visible=function(a){return!m.expr.filters.hidden(a)};var Qc=/%20/g,Rc=/\[\]$/,Sc=/\r?\n/g,Tc=/^(?:submit|button|image|reset|file)$/i,Uc=/^(?:input|select|textarea|keygen)/i;function Vc(a,b,c,d){var e;if(m.isArray(b))m.each(b,function(b,e){c||Rc.test(a)?d(a,e):Vc(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==m.type(b))d(a,b);else for(e in b)Vc(a+"["+e+"]",b[e],c,d)}m.param=function(a,b){var c,d=[],e=function(a,b){b=m.isFunction(b)?b():null==b?"":b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(void 0===b&&(b=m.ajaxSettings&&m.ajaxSettings.traditional),m.isArray(a)||a.jquery&&!m.isPlainObject(a))m.each(a,function(){e(this.name,this.value)});else for(c in a)Vc(c,a[c],b,e);return d.join("&").replace(Qc,"+")},m.fn.extend({serialize:function(){return m.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=m.prop(this,"elements");return a?m.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!m(this).is(":disabled")&&Uc.test(this.nodeName)&&!Tc.test(a)&&(this.checked||!W.test(a))}).map(function(a,b){var c=m(this).val();return null==c?null:m.isArray(c)?m.map(c,function(a){return{name:b.name,value:a.replace(Sc,"\r\n")}}):{name:b.name,value:c.replace(Sc,"\r\n")}}).get()}}),m.ajaxSettings.xhr=void 0!==a.ActiveXObject?function(){return!this.isLocal&&/^(get|post|head|put|delete|options)$/i.test(this.type)&&Zc()||$c()}:Zc;var Wc=0,Xc={},Yc=m.ajaxSettings.xhr();a.ActiveXObject&&m(a).on("unload",function(){for(var a in Xc)Xc[a](void 0,!0)}),k.cors=!!Yc&&"withCredentials"in Yc,Yc=k.ajax=!!Yc,Yc&&m.ajaxTransport(function(a){if(!a.crossDomain||k.cors){var b;return{send:function(c,d){var e,f=a.xhr(),g=++Wc;if(f.open(a.type,a.url,a.async,a.username,a.password),a.xhrFields)for(e in a.xhrFields)f[e]=a.xhrFields[e];a.mimeType&&f.overrideMimeType&&f.overrideMimeType(a.mimeType),a.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest");for(e in c)void 0!==c[e]&&f.setRequestHeader(e,c[e]+"");f.send(a.hasContent&&a.data||null),b=function(c,e){var h,i,j;if(b&&(e||4===f.readyState))if(delete Xc[g],b=void 0,f.onreadystatechange=m.noop,e)4!==f.readyState&&f.abort();else{j={},h=f.status,"string"==typeof f.responseText&&(j.text=f.responseText);try{i=f.statusText}catch(k){i=""}h||!a.isLocal||a.crossDomain?1223===h&&(h=204):h=j.text?200:404}j&&d(h,i,j,f.getAllResponseHeaders())},a.async?4===f.readyState?setTimeout(b):f.onreadystatechange=Xc[g]=b:b()},abort:function(){b&&b(void 0,!0)}}}});function Zc(){try{return new a.XMLHttpRequest}catch(b){}}function $c(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}m.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return m.globalEval(a),a}}}),m.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),m.ajaxTransport("script",function(a){if(a.crossDomain){var b,c=y.head||m("head")[0]||y.documentElement;return{send:function(d,e){b=y.createElement("script"),b.async=!0,a.scriptCharset&&(b.charset=a.scriptCharset),b.src=a.url,b.onload=b.onreadystatechange=function(a,c){(c||!b.readyState||/loaded|complete/.test(b.readyState))&&(b.onload=b.onreadystatechange=null,b.parentNode&&b.parentNode.removeChild(b),b=null,c||e(200,"success"))},c.insertBefore(b,c.firstChild)},abort:function(){b&&b.onload(void 0,!0)}}}});var _c=[],ad=/(=)\?(?=&|$)|\?\?/;m.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=_c.pop()||m.expando+"_"+vc++;return this[a]=!0,a}}),m.ajaxPrefilter("json jsonp",function(b,c,d){var e,f,g,h=b.jsonp!==!1&&(ad.test(b.url)?"url":"string"==typeof b.data&&!(b.contentType||"").indexOf("application/x-www-form-urlencoded")&&ad.test(b.data)&&"data");return h||"jsonp"===b.dataTypes[0]?(e=b.jsonpCallback=m.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h?b[h]=b[h].replace(ad,"$1"+e):b.jsonp!==!1&&(b.url+=(wc.test(b.url)?"&":"?")+b.jsonp+"="+e),b.converters["script json"]=function(){return g||m.error(e+" was not called"),g[0]},b.dataTypes[0]="json",f=a[e],a[e]=function(){g=arguments},d.always(function(){a[e]=f,b[e]&&(b.jsonpCallback=c.jsonpCallback,_c.push(e)),g&&m.isFunction(f)&&f(g[0]),g=f=void 0}),"script"):void 0}),m.parseHTML=function(a,b,c){if(!a||"string"!=typeof a)return null;"boolean"==typeof b&&(c=b,b=!1),b=b||y;var d=u.exec(a),e=!c&&[];return d?[b.createElement(d[1])]:(d=m.buildFragment([a],b,e),e&&e.length&&m(e).remove(),m.merge([],d.childNodes))};var bd=m.fn.load;m.fn.load=function(a,b,c){if("string"!=typeof a&&bd)return bd.apply(this,arguments);var d,e,f,g=this,h=a.indexOf(" ");return h>=0&&(d=m.trim(a.slice(h,a.length)),a=a.slice(0,h)),m.isFunction(b)?(c=b,b=void 0):b&&"object"==typeof b&&(f="POST"),g.length>0&&m.ajax({url:a,type:f,dataType:"html",data:b}).done(function(a){e=arguments,g.html(d?m("<div>").append(m.parseHTML(a)).find(d):a)}).complete(c&&function(a,b){g.each(c,e||[a.responseText,b,a])}),this},m.expr.filters.animated=function(a){return m.grep(m.timers,function(b){return a===b.elem}).length};var cd=a.document.documentElement;function dd(a){return m.isWindow(a)?a:9===a.nodeType?a.defaultView||a.parentWindow:!1}m.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=m.css(a,"position"),l=m(a),n={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=m.css(a,"top"),i=m.css(a,"left"),j=("absolute"===k||"fixed"===k)&&m.inArray("auto",[f,i])>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),m.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(n.top=b.top-h.top+g),null!=b.left&&(n.left=b.left-h.left+e),"using"in b?b.using.call(a,n):l.css(n)}},m.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){m.offset.setOffset(this,a,b)});var b,c,d={top:0,left:0},e=this[0],f=e&&e.ownerDocument;if(f)return b=f.documentElement,m.contains(b,e)?(typeof e.getBoundingClientRect!==K&&(d=e.getBoundingClientRect()),c=dd(f),{top:d.top+(c.pageYOffset||b.scrollTop)-(b.clientTop||0),left:d.left+(c.pageXOffset||b.scrollLeft)-(b.clientLeft||0)}):d},position:function(){if(this[0]){var a,b,c={top:0,left:0},d=this[0];return"fixed"===m.css(d,"position")?b=d.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),m.nodeName(a[0],"html")||(c=a.offset()),c.top+=m.css(a[0],"borderTopWidth",!0),c.left+=m.css(a[0],"borderLeftWidth",!0)),{top:b.top-c.top-m.css(d,"marginTop",!0),left:b.left-c.left-m.css(d,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||cd;while(a&&!m.nodeName(a,"html")&&"static"===m.css(a,"position"))a=a.offsetParent;return a||cd})}}),m.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,b){var c=/Y/.test(b);m.fn[a]=function(d){return V(this,function(a,d,e){var f=dd(a);return void 0===e?f?b in f?f[b]:f.document.documentElement[d]:a[d]:void(f?f.scrollTo(c?m(f).scrollLeft():e,c?e:m(f).scrollTop()):a[d]=e)},a,d,arguments.length,null)}}),m.each(["top","left"],function(a,b){m.cssHooks[b]=Lb(k.pixelPosition,function(a,c){return c?(c=Jb(a,b),Hb.test(c)?m(a).position()[b]+"px":c):void 0})}),m.each({Height:"height",Width:"width"},function(a,b){m.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){m.fn[d]=function(d,e){var f=arguments.length&&(c||"boolean"!=typeof d),g=c||(d===!0||e===!0?"margin":"border");return V(this,function(b,c,d){var e;return m.isWindow(b)?b.document.documentElement["client"+a]:9===b.nodeType?(e=b.documentElement,Math.max(b.body["scroll"+a],e["scroll"+a],b.body["offset"+a],e["offset"+a],e["client"+a])):void 0===d?m.css(b,c,g):m.style(b,c,d,g)},b,f?d:void 0,f,null)}})}),m.fn.size=function(){return this.length},m.fn.andSelf=m.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return m});var ed=a.jQuery,fd=a.$;return m.noConflict=function(b){return a.$===m&&(a.$=fd),b&&a.jQuery===m&&(a.jQuery=ed),m},typeof b===K&&(a.jQuery=a.$=m),m});
@@ -1,5 +1,5 @@
-use Test::More tests => 1;
 use strict;
 use warnings;
 
+use Test::More tests => 1;
 use_ok '[% appname %]';
@@ -1,10 +1,17 @@
-use Test::More tests => 2;
 use strict;
 use warnings;
 
-# the order is important
 use [% appname %];
-use Dancer2::Test apps => ['[% appname %]'];
+use Test::More tests => 2;
+use Plack::Test;
+use HTTP::Request::Common;
+
+my $app = Dancer2->psgi_app;
+is( ref $app, 'CODE', 'Got app' );
+
+test_psgi $app, sub {
+    my $cb = shift;
+
+    ok( $cb->( GET '/' )->is_success, '[GET /] successful' );
+};
 
-route_exists [GET => '/'], 'a route handler is defined for /';
-response_status_is ['GET' => '/'], 200, 'response status is 200 for /';
@@ -6,10 +6,10 @@
 <title>[% appname %]</title>
 <link rel="stylesheet" href="<% request.uri_base %>/css/style.css" />
 
-<!-- Grab Google CDN's jQuery. fall back to local if necessary -->
-<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
+<!-- Grab jQuery from a CDN, fall back to local if necessary -->
+<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
 <script type="text/javascript">/* <![CDATA[ */
-    !window.jQuery && document.write('<script type="text/javascript" src="<% request.uri_base %>/javascripts/jquery.min.js"><\/script>')
+    !window.jQuery && document.write('<script type="text/javascript" src="<% request.uri_base %>/javascripts/jquery.js"><\/script>')
 /* ]]> */</script>
 
 </head>
@@ -15,7 +15,6 @@ my @module_files = (
     'Dancer2/CLI/Command/version.pm',
     'Dancer2/Core.pm',
     'Dancer2/Core/App.pm',
-    'Dancer2/Core/Context.pm',
     'Dancer2/Core/Cookie.pm',
     'Dancer2/Core/DSL.pm',
     'Dancer2/Core/Dispatcher.pm',
@@ -31,6 +30,7 @@ my @module_files = (
     'Dancer2/Core/Role/DSL.pm',
     'Dancer2/Core/Role/Engine.pm',
     'Dancer2/Core/Role/Handler.pm',
+    'Dancer2/Core/Role/HasLocation.pm',
     'Dancer2/Core/Role/Headers.pm',
     'Dancer2/Core/Role/Hookable.pm',
     'Dancer2/Core/Role/Logger.pm',
@@ -67,12 +67,15 @@ my @modules = qw(
   Pod::Simple::SimpleTree
   Return::MultiLevel
   Role::Tiny
+  Safe::Isa
   Scalar::Util
   Scope::Upper
+  Sub::Quote
   Template
   Template::Tiny
   Test::Builder
   Test::Fatal
+  Test::Memory::Cycle
   Test::MockTime
   Test::More
   Test::Script
@@ -28,7 +28,7 @@ use HTTP::Request::Common qw(GET HEAD PUT POST DELETE);
     };
 }
 
-my $app = Dancer2->runner->psgi_app;
+my $app = Dancer2->psgi_app;
 is( ref $app, 'CODE', 'Got app' );
 
 test_psgi $app, sub {
@@ -18,7 +18,7 @@ use HTTP::Request::Common;
     };
 }
 
-my $app = Dancer2->runner->psgi_app;
+my $app = Dancer2->psgi_app;
 is( ref $app, 'CODE', 'Got app' );
 
 test_psgi $app, sub {
@@ -37,4 +37,3 @@ test_psgi $app, sub {
 };
 
 done_testing;
-
@@ -175,7 +175,7 @@ is( exception { my $resp = $dispatcher->dispatch($env)->to_psgi },
 );
 
 # test duplicate routes when the path is a regex
-$app = Dancer2::Core::App->new( name => 'main', );
+$app = Dancer2::Core::App->new( name => 'main' );
 my $regexp_route = {
     method => 'get', 'regexp' => qr!/(\d+)!, code => sub {1}
 };
@@ -183,7 +183,11 @@ $app->add_route(%$regexp_route);
 
 # try to get an invalid engine
 eval {$app->engine('foo')};
-ok $!, "Engine 'foo' does not exists";
+like(
+    $@,
+    qr/^Engine 'foo' is not supported/,
+    "Engine 'foo' does not exist",
+);
 
 my $tmpl_engine = $app->engine('template');
 ok $tmpl_engine, "Template engine is defined";
@@ -207,4 +211,10 @@ is_deeply(
     '_get_config_for_engine can find the right configuration',
 );
 
+is(
+    $app->caller,
+    't/app.t',
+    'Correct caller for app',
+);
+
 done_testing;
@@ -16,7 +16,7 @@ use HTTP::Request::Common;
     engine('template')->layout('main');
 }
 
-my $app = Dancer2->runner->psgi_app;
+my $app = Dancer2->psgi_app;
 is( ref $app, 'CODE', 'Got app' );
 
 test_psgi $app, sub {
@@ -0,0 +1,25 @@
+#!perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+use Plack::Test;
+use HTTP::Request::Common;
+
+{
+    package App;
+    use Dancer2;
+
+    get '/' => sub { app->caller };
+
+}
+
+my $app = Dancer2->psgi_app;
+test_psgi $app, sub {
+    my $cb  = shift;
+    my $res = $cb->( GET '/' );
+
+    is( $res->code, 200, '[GET /] Successful' );
+    is( $res->content, 't/caller.t', 'Correct App name from caller' );
+};
@@ -1,150 +0,0 @@
-use strict;
-use warnings;
-use Test::More;
-use Test::Fatal;
-use Carp 'croak';
-
-use Dancer2::Core::Runner;
-use Dancer2::FileUtils qw/dirname path/;
-use File::Spec;
-use File::Temp;
-
-my $runner = Dancer2::Core::Runner->new( caller => 'main' );
-my $location = File::Spec->rel2abs( path( dirname(__FILE__), 'config' ) );
-
-{
-
-    package Prod;
-    use Moo;
-    with 'Dancer2::Core::Role::ConfigReader';
-
-    sub name {'Prod'}
-
-    sub _build_environment {'production'}
-    sub location           {$location}
-    sub default_config     { $runner->default_config }
-
-    package Dev;
-    use Moo;
-    with 'Dancer2::Core::Role::ConfigReader';
-
-    sub _build_environment {'development'}
-    sub location           {$location}
-    sub default_config     { $runner->default_config }
-
-    package Failure;
-    use Moo;
-    with 'Dancer2::Core::Role::ConfigReader';
-
-    sub _build_environment {'failure'}
-    sub location           {$location}
-    sub default_config     { $runner->default_config }
-
-    package Staging;
-    use Moo;
-    with 'Dancer2::Core::Role::ConfigReader';
-
-    sub _build_environment {'staging'}
-    sub location           {$location}
-    sub default_config     { $runner->default_config }
-
-    package Merging;
-    use Moo;
-    with 'Dancer2::Core::Role::ConfigReader';
-
-    sub name {'Merging'}
-
-    sub _build_environment {'merging'}
-    sub location           {$location}
-    sub default_config     { $runner->default_config }
-
-}
-
-my $d = Dev->new;
-is_deeply $d->config_files,
-  [ path( $location, 'config.yml' ), ],
-  "config_files() only sees existing files";
-
-my $f = Prod->new;
-is $f->does('Dancer2::Core::Role::ConfigReader'), 1,
-  "role Dancer2::Core::Role::ConfigReader is consumed";
-
-is_deeply $f->config_files,
-  [ path( $location, 'config.yml' ),
-    path( $location, 'environments', 'production.yml' ),
-  ],
-  "config_files() works";
-
-my $j = Staging->new;
-is_deeply $j->config_files,
-  [ path( $location, 'config.yml' ),
-    path( $location, 'environments', 'staging.json' ),
-  ],
-  "config_files() does JSON too!";
-
-note "bad YAML file";
-my $fail = Failure->new;
-is $fail->environment, 'failure';
-
-is_deeply $fail->config_files,
-  [ path( $location, 'config.yml' ),
-    path( $location, 'environments', 'failure.yml' ),
-  ],
-  "config_files() works";
-
-like(
-    exception { $fail->config },
-    qr{YAML}, 'Configuration file parsing failure',
-);
-
-note "config merging";
-my $m = Merging->new;
-
-# Check the 'application' top-level key; its the only key that
-# is currently a HoH in the test configurations
-is_deeply $m->config->{application},
-  { some_feature    => 'bar',
-    another_setting => 'baz',
-  },
-  "full merging of configuration hashes";
-
-note "config parsing";
-
-is $f->config->{show_errors}, 0;
-is $f->config->{main},        1;
-is $f->config->{charset},     'utf-8', "normalized UTF-8 to utf-8";
-
-ok( $f->has_setting('charset') );
-ok( !$f->has_setting('foobarbaz') );
-
-note "default values";
-is $f->setting('apphandler'),   'Standalone';
-is $f->setting('content_type'), 'text/html';
-
-like(
-    exception { $f->_normalize_config( { charset => 'BOGUS' } ) },
-    qr{Charset defined in configuration is wrong : couldn't identify 'BOGUS'},
-    'Configuration file charset failure',
-);
-
-{
-
-    package Foo;
-    use Carp 'croak';
-    sub foo { croak "foo" }
-}
-
-is $f->setting('traces'), 0;
-unlike( exception { Foo->foo() }, qr{Foo::foo}, "traces are not enabled", );
-
-$f->setting( traces => 1 );
-like( exception { Foo->foo() }, qr{Foo::foo}, "traces are enabled", );
-
-{
-    my $tmpdir = File::Temp::tempdir( CLEANUP => 1, TMPDIR => 1 );
-    $ENV{DANCER_CONFDIR} = $tmpdir;
-    my $f = Prod->new;
-    is $f->config_location, $tmpdir;
-}
-
-done_testing;
@@ -1,16 +0,0 @@
-use strict;
-use warnings;
-
-use Test::More;
-use File::Spec;
-
-use t::app::t1::lib::App1;
-
-is( App1->runner->config->{app}->{config}, 'ok', 'config loaded properly' );
-is_deeply(
-    App1->runner->config_files,
-    [ File::Spec->rel2abs(File::Spec->catfile( 't', 'app', 't1', 'config.yml' )) ],
-    'config files found'
-);
-
-done_testing;
@@ -1,17 +0,0 @@
-use strict;
-use warnings;
-
-use Test::More;
-use File::Spec;
-
-use t::app::t1::lib::Sub::App2;
-
-is( Sub::App2->runner->config->{app}->{config}, 'ok',
-    'config loaded properly' );
-is_deeply(
-    Sub::App2->runner->config_files,
-    [ File::Spec->rel2abs(File::Spec->catfile( 't', 'app', 't1', 'config.yml' )) ],
-    'config files found'
-);
-
-done_testing;
@@ -1,16 +0,0 @@
-use strict;
-use warnings;
-
-use Test::More;
-use File::Spec;
-
-use t::app::t2::lib::App3;
-
-is( App3->runner->config->{app}->{config}, 'ok', 'config loaded properly' );
-is_deeply(
-    App3->runner->config_files,
-    [ File::Spec->rel2abs(File::Spec->catfile( 't', 'app', 't2', 'config.yml' )) ],
-    'config files found'
-);
-
-done_testing;
@@ -0,0 +1,23 @@
+use strict;
+use warnings;
+
+use Test::More;
+use File::Spec;
+
+use t::app::t1::lib::App1;
+use t::app::t1::lib::Sub::App2;
+use t::app::t2::lib::App3;
+
+for my $app ( @{ Dancer2->runner->apps } ) {
+    # Need to determine path to config; use apps' name for now..
+    my $path = $app->name eq 'App3' ? 't2' : 't1';
+
+    is_deeply $app->config_files,
+        [ File::Spec->rel2abs(File::Spec->catfile( 't', 'app', $path, 'config.yml' )) ],
+        $app->name . ": config files found";
+
+    is $app->config->{app}->{config}, 'ok',
+        $app->name . ": config loaded properly"
+}
+
+done_testing;
@@ -0,0 +1,149 @@
+use strict;
+use warnings;
+use Test::More;
+use Test::Fatal;
+use Carp 'croak';
+
+use Dancer2::Core::Runner;
+use Dancer2::FileUtils qw/dirname path/;
+use File::Spec;
+use File::Temp;
+
+my $runner = Dancer2::Core::Runner->new();
+my $location = File::Spec->rel2abs( path( dirname(__FILE__), 'config' ) );
+
+{
+
+    package Prod;
+    use Moo;
+    with 'Dancer2::Core::Role::ConfigReader';
+
+    sub name {'Prod'}
+
+    sub _build_environment    {'production'}
+    sub _build_location       {$location}
+    sub _build_default_config {$runner->config}
+
+    package Dev;
+    use Moo;
+    with 'Dancer2::Core::Role::ConfigReader';
+
+    sub _build_environment    {'development'}
+    sub _build_location       {$location};
+    sub _build_default_config {$runner->config}
+
+    package Failure;
+    use Moo;
+    with 'Dancer2::Core::Role::ConfigReader';
+
+    sub _build_environment    {'failure'}
+    sub _build_location       {$location}
+    sub _build_default_config {$runner->config}
+
+    package Staging;
+    use Moo;
+    with 'Dancer2::Core::Role::ConfigReader';
+
+    sub _build_environment    {'staging'}
+    sub _build_location       {$location}
+    sub _build_default_config {$runner->config}
+
+    package Merging;
+    use Moo;
+    with 'Dancer2::Core::Role::ConfigReader';
+
+    sub name {'Merging'}
+
+    sub _build_environment    {'merging'}
+    sub _build_location       {$location}
+    sub _build_default_config {$runner->config}
+
+}
+
+my $d = Dev->new();
+is_deeply $d->config_files,
+  [ path( $location, 'config.yml' ), ],
+  "config_files() only sees existing files";
+
+my $f = Prod->new;
+is $f->does('Dancer2::Core::Role::ConfigReader'), 1,
+  "role Dancer2::Core::Role::ConfigReader is consumed";
+
+is_deeply $f->config_files,
+  [ path( $location, 'config.yml' ),
+    path( $location, 'environments', 'production.yml' ),
+  ],
+  "config_files() works";
+
+my $j = Staging->new;
+is_deeply $j->config_files,
+  [ path( $location, 'config.yml' ),
+    path( $location, 'environments', 'staging.json' ),
+  ],
+  "config_files() does JSON too!";
+
+note "bad YAML file";
+my $fail = Failure->new;
+is $fail->environment, 'failure';
+
+is_deeply $fail->config_files,
+  [ path( $location, 'config.yml' ),
+    path( $location, 'environments', 'failure.yml' ),
+  ],
+  "config_files() works";
+
+like(
+    exception { $fail->config },
+    qr{YAML}, 'Configuration file parsing failure',
+);
+
+note "config merging";
+my $m = Merging->new;
+
+# Check the 'application' top-level key; its the only key that
+# is currently a HoH in the test configurations
+is_deeply $m->config->{application},
+  { some_feature    => 'bar',
+    another_setting => 'baz',
+  },
+  "full merging of configuration hashes";
+
+note "config parsing";
+
+is $f->config->{show_errors}, 0;
+is $f->config->{main},        1;
+is $f->config->{charset},     'utf-8', "normalized UTF-8 to utf-8";
+
+ok( $f->has_setting('charset') );
+ok( !$f->has_setting('foobarbaz') );
+
+note "default values";
+is $f->setting('apphandler'),   'Standalone';
+
+like(
+    exception { $f->_normalize_config( { charset => 'BOGUS' } ) },
+    qr{Charset defined in configuration is wrong : couldn't identify 'BOGUS'},
+    'Configuration file charset failure',
+);
+
+{
+
+    package Foo;
+    use Carp 'croak';
+    sub foo { croak "foo" }
+}
+
+is $f->setting('traces'), 0;
+unlike( exception { Foo->foo() }, qr{Foo::foo}, "traces are not enabled", );
+
+$f->setting( traces => 1 );
+like( exception { Foo->foo() }, qr{Foo::foo}, "traces are enabled", );
+
+{
+    my $tmpdir = File::Temp::tempdir( CLEANUP => 1, TMPDIR => 1 );
+    $ENV{DANCER_CONFDIR} = $tmpdir;
+    my $f = Prod->new;
+    is $f->config_location, $tmpdir;
+}
+
+done_testing;
@@ -0,0 +1,57 @@
+#!perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 10;
+use Plack::Test;
+use HTTP::Request::Common;
+
+my $before;
+{
+    package OurApp;
+    use Dancer2 '!pass';
+    use Test::More;
+
+    hook before => sub {
+        my $ctx = shift;
+
+        isa_ok(
+            $ctx,
+            'Dancer2::Core::App',
+            'Context is actually an app now',
+        );
+
+        is( $ctx->name, 'OurApp', 'It is the correct app' );
+        can_ok( $ctx, 'app' );
+
+        my $app = $ctx->app;
+        isa_ok(
+            $app,
+            'Dancer2::Core::App',
+            'When called ->app, we get te app again',
+        );
+
+        is( $app->name, 'OurApp', 'It is the correct app' );
+        is( $ctx, $app, 'Same exact application (by reference)' );
+
+        $before++;
+    };
+
+    get '/' => sub {'OK'};
+}
+
+my $app = Dancer2->psgi_app;
+isa_ok( $app, 'CODE', 'Got app' );
+
+test_psgi $app, sub {
+    my $cb  = shift;
+    my $res = $cb->( GET '/' );
+
+    is( $res->code,     200, '[GET /] status OK'  );
+    is( $res->content, 'OK', '[GET /] content OK' );
+
+    ok( $before == 1, 'before hook called' );
+};
+
+
@@ -1,36 +0,0 @@
-use strict;
-use warnings;
-
-use Test::More;
-use Dancer2::Core::Context;
-
-my $env = {
-    'psgi.url_scheme' => 'http',
-    REQUEST_METHOD    => 'GET',
-    SCRIPT_NAME       => '/foo',
-    PATH_INFO         => '/bar/baz',
-    REQUEST_URI       => '/foo/bar/baz',
-    QUERY_STRING      => 'foo=42&bar=12&bar=13&bar=14',
-    SERVER_NAME       => 'localhost',
-    SERVER_PORT       => 5000,
-    SERVER_PROTOCOL   => 'HTTP/1.1',
-    REMOTE_ADDR       => '127.0.0.1',
-    HTTP_COOKIE =>
-      'dancer.session=1234; fbs_102="access_token=xxxxxxxxxx%7Cffffff"',
-    HTTP_X_FORWARDED_FOR => '127.0.0.2',
-    REMOTE_HOST     => 'localhost',
-    HTTP_USER_AGENT => 'Mozilla',
-    REMOTE_USER     => 'sukria',
-};
-
-my $c = Dancer2::Core::Context->new( env => $env );
-
-isa_ok $c->request, 'Dancer2::Core::Request';
-is $c->request->method, 'GET';
-
-isa_ok $c->cookies->{'dancer.session'}, 'Dancer2::Core::Cookie';
-is $c->cookies->{'dancer.session'}->value,  1234;
-is $c->cookies->{'dancer.session'}->name,   'dancer.session';
-is $c->cookies->{'dancer.session'}->secure, 0;
-
-done_testing;
@@ -1,55 +0,0 @@
-use strict;
-use warnings;
-
-use File::Spec;
-use File::Temp 0.22;
-use LWP::UserAgent;
-use Test::More;
-use Test::TCP 1.13;
-use YAML;
-
-my $tempdir = File::Temp::tempdir( CLEANUP => 1, TMPDIR => 1 );
-
-Test::TCP::test_tcp(
-    client => sub {
-        my $port = shift;
-
-        my $ua = LWP::UserAgent->new;
-        $ua->cookie_jar( { file => "$tempdir/.cookies.txt" } );
-
-        my $res = $ua->get("http://127.0.0.1:$port/main");
-        for my $type (qw/session logger serializer template/) {
-            like $res->content, qr/^$type 1$/ms, "$type has context";
-        }
-
-        File::Temp::cleanup();
-    },
-    server => sub {
-        my $port = shift;
-
-        BEGIN {
-            use Dancer2;
-            set session    => 'Simple';
-            set logger     => 'Null';
-            set serializer => 'JSON';
-            set template   => 'Simple';
-        }
-
-        get '/main' => sub {
-            my $response = "";
-            for my $type (qw/session logger serializer template/) {
-                my $defined = defined( engine("$type")->context ) ? 1 : 0;
-                $response .= "$type $defined\n";
-            }
-            return $response;
-        };
-
-        setting appdir => $tempdir;
-
-        # we're overiding a RO attribute only for this test!
-        Dancer2->runner->{'port'} = $port;
-        start;
-    },
-);
-
-done_testing;
@@ -16,7 +16,7 @@ prend '/' => sub {
     request->method;
 };
 
-my $app = Dancer2->runner->psgi_app;
+my $app = Dancer2->psgi_app;
 is( ref $app, 'CODE', 'Got app' );
 
 test_psgi $app, sub {
@@ -35,7 +35,7 @@ use HTTP::Request::Common;
     };
 }
 
-my $app = Dancer2->runner->psgi_app;
+my $app = Dancer2->psgi_app;
 is( ref $app, 'CODE', 'Got app' );
 
 test_psgi $app, sub {
@@ -75,8 +75,9 @@ note "Verify Serializers decode into characters"; {
 
             # change the app serializer
             # we're overiding a RO attribute only for this test!
-            Dancer2->runner->apps->[0]->{'serializer_engine'} =
-                $serializer;
+            Dancer2->runner->apps->[0]->set_serializer_engine(
+                $serializer
+            );
 
             my $r = $cb->(
                 PUT '/from_params',
@@ -96,8 +97,9 @@ note "Verify Serializers decode into characters"; {
 
 # default back to JSON for the rest
 # we're overiding a RO attribute only for this test!
-Dancer2->runner->apps->[0]->{'serializer_engine'} =
-    Dancer2::Serializer::JSON->new;
+Dancer2->runner->apps->[0]->set_serializer_engine(
+    Dancer2::Serializer::JSON->new
+);
 
 note "Decoding of mixed route and deserialized body params"; {
     # Check integers from request body remain integers
@@ -168,12 +170,12 @@ note 'Check serialization errors'; {
         );
 
         ok(
-            Dancer2->runner->apps->[0]->{'serializer_engine'}->has_error,
+            Dancer2->runner->apps->[0]->serializer_engine->has_error,
             "Invalid JSON threw error in serializer",
         );
 
         like(
-            Dancer2->runner->apps->[0]->{'serializer_engine'}->error,
+            Dancer2->runner->apps->[0]->serializer_engine->error,
             qr/malformed number/,
             ".. of a 'malformed number'",
         );
@@ -181,4 +183,3 @@ note 'Check serialization errors'; {
 }
 
 done_testing();
-
@@ -29,7 +29,7 @@ $app->add_route(
 $app->add_route(
     method => 'get',
     regexp => '/error',
-    code   => sub { Fail->fail; },
+    code   => sub { Fail->fail },
 );
 
 # A chain of two route for /user/$foo
@@ -37,9 +37,9 @@ $app->add_route(
     method => 'get',
     regexp => '/user/:name',
     code   => sub {
-        my $ctx = shift;
-        $buffer->{user} = $ctx->request->params->{'name'};
-        $ctx->response->has_passed(1);
+        my $app = shift;
+        $buffer->{user} = $app->request->params->{'name'};
+        $app->response->has_passed(1);
     },
 );
 
@@ -47,8 +47,8 @@ $app->add_route(
     method => 'get',
     regexp => '/user/*?',
     code   => sub {
-        my $ctx = shift;
-        "Hello " . $ctx->request->params->{'name'};
+        my $app = shift;
+        "Hello " . $app->request->params->{'name'};
     },
 );
 
@@ -111,11 +111,11 @@ $app->add_hook(
     Dancer2::Core::Hook->new(
         name => 'before',
         code => sub {
-            my $ctx = shift;
-            if ( $ctx->request->path_info eq '/haltme' ) {
-                $ctx->response->header( Location => 'http://perldancer.org' );
-                $ctx->response->status(302);
-                $ctx->response->is_halted(1);
+            my $app = shift;
+            if ( $app->request->path_info eq '/haltme' ) {
+                $app->response->header( Location => 'http://perldancer.org' );
+                $app->response->status(302);
+                $app->response->is_halted(1);
             }
         },
     )
@@ -126,8 +126,8 @@ $app->add_hook(
     Dancer2::Core::Hook->new(
         name => 'before',
         code => sub {
-            my $ctx = shift;
-            if ( $ctx->request->path_info eq '/haltme' ) {
+            my $app = shift;
+            if ( $app->request->path_info eq '/haltme' ) {
                 $was_in_second_filter =
                   1;   # should not happen because first filter halted the flow
             }
@@ -149,20 +149,21 @@ my $counter = 0;
 foreach my $test (@tests) {
     my $env      = $test->{env};
     my $expected = $test->{expected};
+    my $path     = $env->{'PATH_INFO'};
 
     my $resp = $dispatcher->dispatch($env)->to_psgi;
 
-    is( $resp->[0], $expected->[0], 'Return code ok' );
+    is( $resp->[0], $expected->[0], "[$path] Return code ok" );
 
     my %got_headers = @{ $resp->[1] };
     my %exp_headers = @{ $expected->[1] };
-    is_deeply( \%got_headers, \%exp_headers, 'Correct headers' );
+    is_deeply( \%got_headers, \%exp_headers, "[$path] Correct headers" );
 
     if ( ref( $expected->[2] ) eq "Regexp" ) {
-        like $resp->[2][0] => $expected->[2], "Contents ok. (test $counter)";
+        like $resp->[2][0] => $expected->[2], "[$path] Contents ok. (test $counter)";
     }
     else {
-        is_deeply $resp->[2] => $expected->[2], "Contents ok. (test $counter)";
+        is_deeply $resp->[2] => $expected->[2], "[$path] Contents ok. (test $counter)";
     }
     $counter++;
 }
@@ -0,0 +1,55 @@
+#!/usr/bin/env perl
+
+# define a sample DSL extension that will be used in the rest of these test
+# This extends Dancer2::Core::DSL but provides an extra keyword
+#
+# Each test below creates a new package so it can load Dancer2
+BEGIN {
+
+    package Dancer2::Test::ExtendedDSL;
+
+    use Moo;
+    extends 'Dancer2::Core::DSL';
+
+    sub BUILD {
+        my ( $self ) = @_;
+        $self->register(foo => 1);
+    }
+
+    sub foo {
+        return $_[1];
+    }
+}
+
+package main;
+
+use Test::More tests => 5;
+
+package test1;
+use Test::More;
+
+use Dancer2 dsl => 'Dancer2::Test::ExtendedDSL';
+
+ok(defined &foo, 'use line dsl can foo');
+is(foo('bar'), 'bar', 'use line Foo returns bar');
+
+package test2;
+use Test::More;
+
+ok(!defined &foo, 'intermediate package has no polluted namespace');
+
+package test3;
+use Test::More;
+use FindBin;
+use File::Spec;
+
+BEGIN {
+    $ENV{DANCER_CONFDIR} = File::Spec->catdir($FindBin::Bin, 'extend_config');
+}
+
+use Dancer2;
+
+ok(defined &foo, 'config specified DSL can foo');
+is(foo('baz'), 'baz', 'config specified Foo returns baz');
+
+done_testing;
@@ -0,0 +1 @@
+dsl_class: 'Dancer2::Test::ExtendedDSL'
@@ -17,13 +17,13 @@ subtest 'halt within routes' => sub {
             halt;
         };
         get '/shortcircuit' => sub {
-            context->response->content('halted');
+            app->response->content('halted');
             halt;
             redirect '/'; # won't get executed as halt returns immediately.
         };
     }
 
-    my $app = Dancer2->runner->psgi_app;
+    my $app = Dancer2->psgi_app;
     is( ref $app, 'CODE', 'Got app' );
 
     test_psgi $app, sub {
@@ -61,14 +61,13 @@ subtest 'halt in before hook' => sub {
         use Dancer2;
 
         hook before => sub {
-            my $context = shift;
-            $context->response->content('I was halted');
-            halt if $context->request->dispatch_path eq '/shortcircuit';
+            response->content('I was halted');
+            halt if request->dispatch_path eq '/shortcircuit';
         };
 
     }
 
-    my $app = Dancer2->runner->psgi_app;
+    my $app = Dancer2->psgi_app;
     is( ref $app, 'CODE', 'Got app' );
 
     test_psgi $app, sub {
@@ -22,7 +22,7 @@ subtest 'pass within routes' => sub {
         };
     }
 
-    my $app = Dancer2->runner->psgi_app;
+    my $app = Dancer2->psgi_app;
     is( ref $app, 'CODE', 'Got app' );
 
     test_psgi $app, sub {
@@ -10,7 +10,7 @@ any [ 'get', 'post' ], '/' => sub {
     request->method;
 };
 
-my $app = Dancer2->runner->psgi_app;
+my $app = Dancer2->psgi_app;
 is( ref $app, 'CODE', 'Got app' );
 
 test_psgi $app, sub {
@@ -5,11 +5,12 @@ use Plack::Test;
 use HTTP::Request::Common;
 
 use Dancer2::Core::App;
-use Dancer2::Core::Context;
 use Dancer2::Core::Response;
 use Dancer2::Core::Request;
 use Dancer2::Core::Error;
 
+use JSON (); # Error serialization
+
 my $env = {
     'psgi.url_scheme' => 'http',
     REQUEST_METHOD    => 'GET',
@@ -30,13 +31,15 @@ my $env = {
 };
 
 my $a = Dancer2::Core::App->new( name => 'main' );
-my $c = Dancer2::Core::Context->new( env => $env, app => $a );
+my $request = Dancer2::Core::Dispatcher->build_request( $env, $a );
+
+$a->set_request($request);
 
 subtest 'basic defaults of Error object' => sub {
-    my $e = Dancer2::Core::Error->new( context => $c, );
+    my $e = Dancer2::Core::Error->new( app => $a );
     is $e->status,  500,                                 'code';
     is $e->title,   'Error 500 - Internal Server Error', 'title';
-    is $e->message, undef,                               'message';
+    is $e->message, '',                               'message';
     like $e->content, qr!http://localhost:5000/foo/css!,
         "error content contains css path relative to uri_base";
 };
@@ -55,7 +58,7 @@ subtest "send_error in route" => sub {
         };
     }
 
-    my $app = Dancer2->runner->psgi_app;
+    my $app = Dancer2->psgi_app;
     is( ref $app, 'CODE', 'Got app' );
 
     test_psgi $app, sub {
@@ -89,7 +92,7 @@ subtest "send_error with custom stuff" => sub {
         };
     }
 
-    my $app = Dancer2->runner->psgi_app;
+    my $app = Dancer2->psgi_app;
     is( ref $app, 'CODE', 'Got app' );
 
     test_psgi $app, sub {
@@ -115,7 +118,6 @@ subtest 'Response->error()' => sub {
 
 subtest 'Error with show_errors: 0' => sub {
     my $err = Dancer2::Core::Error->new(
-        context     => $c,
         exception   => 'our exception',
         show_errors => 0
     )->throw;
@@ -124,11 +126,69 @@ subtest 'Error with show_errors: 0' => sub {
 
 subtest 'Error with show_errors: 1' => sub {
     my $err = Dancer2::Core::Error->new(
-        context     => $c,
         exception   => 'our exception',
         show_errors => 1
     )->throw;
     like $err->content => qr/our exception/;
 };
 
+subtest 'App dies with serialized error' => sub {
+    {
+        package AppDies;
+        use Dancer2;
+        set serializer => 'JSON';
+
+        get '/die' => sub {
+            die "oh no\n"; # I should serialize
+        };
+    }
+
+    my $app = Dancer2->psgi_app;
+    isa_ok( $app, 'CODE', 'Got app' );
+
+    test_psgi $app, sub {
+        my $cb = shift;
+        my $r  = $cb->( GET '/die' );
+
+        is( $r->code, 500, '/die returns 500' );
+
+        my $out = eval { JSON->new->utf8(0)->decode($r->decoded_content) };
+        ok(!$@, 'JSON decoding serializer error produces no errors');
+        isa_ok($out, 'HASH', 'Error deserializes to a hash');
+        like($out->{exception}, qr/^oh no/, 'Get expected error message');
+    };
+};
+
+subtest 'Error with exception object' => sub {
+    local $@;
+    eval { MyTestException->throw('a test exception object') };
+    my $err = Dancer2::Core::Error->new(
+        exception   => $@,
+        show_errors => 1,
+    )->throw;
+
+    like $err->content, qr/a test exception object/, 'Error content contains exception message';
+};
+
 done_testing;
+
+
+{   # Simple test exception class
+    package MyTestException;
+
+    use overload '""' => \&as_str;
+
+    sub new {
+        return bless {};
+    }
+
+    sub throw {
+        my ( $class, $error ) = @_;
+        my $self = ref($class) ? $class : $class->new;
+        $self->{error} = $error;
+
+        die $self;
+    }
+
+    sub as_str { return $_[0]->{error} }
+}
@@ -30,7 +30,7 @@ use HTTP::Request::Common;
 
 }
 
-my $app = Dancer2->runner->psgi_app;
+my $app = Dancer2->psgi_app;
 is( ref $app, 'CODE', 'Got app' );
 
 test_psgi $app, sub {
@@ -33,7 +33,7 @@ get '/go_to_post/' => sub {
 # get '/b' => sub { vars->{test} = 1;  forward '/a'; };
 # get '/a' => sub { return "test is " . var('test'); };
 
-my $app = Dancer2->runner->psgi_app;
+my $app = Dancer2->psgi_app;
 is( ref $app, 'CODE', 'Got app' );
 
 test_psgi $app, sub {
@@ -18,21 +18,20 @@ get '/redirect' => sub {
 };
 
 hook before => sub {
-    my $context = shift;
-    return if $context->request->dispatch_path eq '/default';
+    return if request->dispatch_path eq '/default';
 
     # Add some content to the response
-    $context->response->content("SillyStringIsSilly");
+    response->content("SillyStringIsSilly");
 
     # redirect - response should include the above content
     return redirect '/default'
-        if $context->request->dispatch_path eq '/redirect';
+        if request->dispatch_path eq '/redirect';
 
     # The response object will get replaced by the result of the forward.
     forward '/default';
 };
 
-my $app = Dancer2->runner->psgi_app;
+my $app = Dancer2->psgi_app;
 is( ref $app, 'CODE', 'Got app' );
 
 test_psgi $app, sub {
@@ -4,14 +4,15 @@ use warnings;
 use Test::More;
 use Plack::Test;
 use HTTP::Request::Common;
+use File::Temp;
 
 {
     package StaticContent;
 
     use Dancer2;
 
-    engine('template')->views('t/corpus/static');
-    $ENV{DANCER_PUBLIC} = 't/corpus/static';
+    set views  => 't/corpus/static';
+    set public => 't/corpus/static';
 
     get '/' => sub {
         send_file 'index.html';
@@ -23,9 +24,17 @@ use HTTP::Request::Common;
             return "send_file returns; this content is ignored";
         };
     };
+
+    get '/check_content_type' => sub {
+        my $temp = File::Temp->new();
+        print $temp "hello";
+        close $temp;
+        send_file($temp->filename, content_type => 'image/png',
+                                   system_path  => 1);
+    };
 }
 
-my $app = Dancer2->runner->psgi_app;
+my $app = Dancer2->psgi_app;
 is( ref $app, 'CODE', 'Got app' );
 
 test_psgi $app, sub {
@@ -49,7 +58,21 @@ test_psgi $app, sub {
         my $r = $cb->( GET '/some/image' );
 
         is( $r->code, 200, 'send_file sets the status to 200' );
-        unlike( $r->content, qr/send_file returns/, "send_file returns immediately with content");
+        unlike( $r->content, qr/send_file returns/,
+            "send_file returns immediately with content");
+        is( $r->header( 'Content-Type' ), 'image/png',
+            'correct content_type in response' );
+    };
+};
+
+test_psgi $app, sub {
+    my $cb = shift;
+
+    subtest 'send_file returns correct content type' => sub {
+        my $r = $cb->( GET '/check_content_type' );
+
+        ok($r->is_success, 'send_file returns success');
+        is($r->content_type, 'image/png', 'send_file returns correct content_type');
     };
 };
 
@@ -92,8 +92,8 @@ my $tests_flags = {};
     };
 
     hook on_route_exception => sub {
-        my ($context, $error) = @_;
-        is ref($context), 'Dancer2::Core::Context';
+        my ($app, $error) = @_;
+        is ref($app), 'Dancer2::Core::App';
         like $error, qr/this is a route exception/;
     };
 
@@ -116,7 +116,7 @@ my $tests_flags = {};
 
 }
 
-my $app = Dancer2->runner->psgi_app;
+my $app = Dancer2->psgi_app;
 is( ref $app, 'CODE', 'Got app' );
 
 test_psgi $app, sub {
@@ -16,7 +16,7 @@ my %method = (
     options => 'OPTIONS',
 );
 
-my $app = Dancer2->runner->psgi_app;
+my $app = Dancer2->psgi_app;
 is( ref $app, 'CODE', 'Got app' );
 
 test_psgi $app, sub {
@@ -46,4 +46,3 @@ test_psgi $app, sub {
         like( $res->content, qr<Method Not Allowed>, q<Illegal method should have "Method Not Allowed" in the content> );
     }
 };
-
@@ -0,0 +1,37 @@
+use Test::More;
+use strict;
+use warnings;
+use Plack::Test;
+use HTTP::Request::Common;
+use Capture::Tiny 'capture_stderr';
+
+{
+    package App;
+    use Dancer2;
+
+    set logger => 'console';
+
+    hook 'before' => sub {
+        die 'test die inside a before hook';
+        print STDERR "error message not caught in the before hook\n";
+    };
+
+    get '/' => sub {
+        print STDERR "error message not caught in the route handler\n";
+    };
+}
+
+my $app = Dancer2->psgi_app;
+is( ref $app, 'CODE', 'Got app' );
+
+test_psgi $app, sub {
+    my $cb      = shift;
+    my $message = capture_stderr { $cb->( GET '/' ) };
+
+    like
+        $message,
+        qr/test die inside a before hook/,
+        'Got error message when a before hook dies';
+};
+
+done_testing;
@@ -0,0 +1,86 @@
+#!perl
+
+use strict;
+use warnings;
+use Test::More tests => 6;
+use Capture::Tiny 0.12 'capture_stderr';
+use Plack::Test;
+use HTTP::Request::Common;
+
+{
+    package App;
+    use Dancer2;
+
+    set logger => 'console';
+    set log    => 'debug';
+
+    get '/debug' => sub {
+        debug   "debug msg\n";
+        warning "warning msg\n";
+        error   "error msg\n";
+
+        set log => 'warning';
+
+        return 'debug';
+    };
+
+    get '/warning' => sub {
+        debug   "debug msg\n";
+        warning "warning msg\n";
+        error   "error msg\n";
+
+        return 'warning';
+    };
+}
+
+my $app = Dancer2->psgi_app;
+
+test_psgi $app, sub {
+    my $cb  = shift;
+    my $res;
+
+    {
+        my $stderr = capture_stderr { $res = $cb->( GET '/debug' ) };
+
+        is( $res->code,    200,     'Successful response' );
+        is( $res->content, 'debug', 'Correct content'     );
+
+        like(
+            $stderr,
+            qr/
+                ^
+                # a debug line
+                \[App:\d+\] \s debug [^\n]+ \n
+
+                # a warning line
+                \[App:\d+\] \s warning [^\n]+ \n
+
+                # followed by an error line
+                \[App:\d+\] \s error   [^\n]+ \n
+                $
+            /x,
+            'Log levels work',
+        );
+    }
+
+    {
+        my $stderr = capture_stderr { $res = $cb->( GET '/warning' ) };
+
+        is( $res->code,    200,       'Successful response' );
+        is( $res->content, 'warning', 'Correct content'     );
+
+        like(
+            $stderr,
+            qr/
+                ^
+                # a warning line
+                \[App:\d+\] \s warning [^\n]+ \n
+
+                # followed by an error line
+                \[App:\d+\] \s error   [^\n]+ \n
+                $
+            /x,
+            'Log levels work',
+        );
+    }
+};
@@ -8,4 +8,3 @@ use Dancer2::Logger::File;
 my $logger = Dancer2::Logger::File->new();
 isa_ok( $logger, 'Dancer2::Logger::File' );
 can_ok( $logger, qw<environment location log_dir file_name log_file fh> );
-
@@ -24,7 +24,7 @@ my $psgi_app = do {
 };
 
 # Register the $psgi_app to handle all LWP requests
-LWP::Protocol::PSGI->register($psgi_app); 
+LWP::Protocol::PSGI->register($psgi_app);
 my $ua  = LWP::UserAgent->new;
 isa_ok( $ua, 'LWP::UserAgent' );
 
@@ -33,4 +33,3 @@ isa_ok( $res, 'HTTP::Response' );
 
 ok( $res->is_success, 'Request is successful' );
 is( $res->content, 'bar', 'Correct response content' );
-
@@ -0,0 +1,27 @@
+use strict;
+use warnings;
+use Test::More;
+use Test::Fatal;
+use Test::Memory::Cycle;
+
+use Plack::Test;
+
+{
+
+    package MyApp::Cycles;
+    use Dancer2;
+
+    set auto_page => 1;
+    set serializer => 'JSON';
+
+    get '/**' => sub {
+        return { hello => 'world' };
+    };
+
+}
+
+my $runner = Dancer2->runner;
+memory_cycle_ok( $runner, "runner has no memory cycles" );
+memory_cycle_ok( $runner->apps->[0], "App has no memory cycles" );
+
+done_testing();
@@ -0,0 +1,48 @@
+use strict;
+use warnings;
+use Test::More;
+use Plack::Builder;
+use Plack::Test;
+use HTTP::Request::Common;
+
+{
+    package MyTestWiki;
+    use Dancer2;
+    get '/'     => sub { __PACKAGE__ };
+    get '/wiki' => sub {'WIKI'};
+
+    package MyTestForum;
+    use Dancer2;
+    get '/'      => sub { __PACKAGE__ };
+    get '/forum' => sub {'FORUM'};
+}
+
+{
+    my $app = builder {
+        mount '/wiki'  => MyTestWiki->psgi_app;
+        mount '/forum' => MyTestForum->psgi_app;
+    };
+
+    isa_ok( $app, 'CODE', 'Got app' );
+
+    test_psgi $app, sub {
+        my $cb = shift;
+
+        is( $cb->( GET '/wiki' )->content, 'MyTestWiki', "Got wiki root" );
+        is( $cb->( GET '/forum' )->content, 'MyTestForum', "Got forum root" );
+    };
+}
+
+{
+    my $app = Dancer2->psgi_app;
+    isa_ok( $app, 'CODE', 'Got app' );
+
+    test_psgi $app, sub {
+        my $cb = shift;
+
+        is( $cb->( GET '/wiki' )->content, 'WIKI', 'Got /wiki path' );
+        is( $cb->( GET '/forum' )->content, 'FORUM', 'Got /forum path' );
+    };
+}
+
+done_testing;
@@ -0,0 +1,81 @@
+#!perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 9;
+use Plack::Test;
+use HTTP::Request::Common;
+
+{
+    package App1;
+    use Dancer2;
+
+    get '/' => sub {'App1'};
+
+    get '/forward' => sub {
+        forward '/';
+        ::ok( 0, 'Foward not returning right away!' );
+    };
+
+    get '/forward_to_new' => sub {
+        forward '/new';
+        ::ok( 0, 'Foward not returning right away!' );
+    };
+}
+
+{
+    package App2;
+    use Dancer2;
+    get '/'    => sub {'App2'};
+    get '/new' => sub {'New'};
+}
+
+{
+    # test each single app
+    my $app1 = App1->psgi_app;
+    test_psgi $app1, sub {
+        my $cb = shift;
+        is( $cb->( GET '/' )->code, 200, '[GET /] OK' );
+        is( $cb->( GET '/' )->content, 'App1', '[GET /] OK content' );
+
+        is( $cb->( GET '/forward' )->code, 200, '[GET /forward] OK' );
+        is(
+            $cb->( GET '/forward' )->content,
+            'App1',
+            '[GET /forward] OK content'
+        );
+
+        is(
+            $cb->( GET '/forward_to_new' )->code,
+            404,
+            'Cannot find /new',
+        );
+    };
+
+    my $app2 = App2->psgi_app;
+    test_psgi $app2, sub {
+        my $cb = shift;
+        is( $cb->( GET '/' )->code, 200, '[GET /] OK' );
+        is( $cb->( GET '/' )->content, 'App2', '[GET /] OK content' );
+    };
+}
+
+{
+    # test global
+    my $app = Dancer2->psgi_app;
+    test_psgi $app, sub {
+        my $cb = shift;
+        is(
+            $cb->( GET '/forward_to_new' )->code,
+            200,
+            '[GET /forward_to_new] OK',
+        );
+
+        is(
+            $cb->( GET '/forward_to_new' )->content,
+            'New',
+            '[GET /forward_to_new] OK content',
+        );
+    };
+}
@@ -0,0 +1,215 @@
+#!perl
+
+use strict;
+use warnings;
+
+use File::Spec;
+use File::Basename 'dirname';
+use Test::More tests => 32;
+use Plack::Test;
+use HTTP::Request::Common;
+
+my $views = File::Spec->rel2abs(
+    File::Spec->catfile( dirname(__FILE__), 'views' )
+);
+
+my %called_hooks = ();
+my $hook_name    = 'engine.template.before_render';
+
+{
+    package App1;
+    use Dancer2;
+
+    set views => $views;
+
+    hook before => sub { $called_hooks{'App1'}{'before'}++ };
+
+    hook before_template => sub {
+        my $tokens = shift;
+        ::isa_ok( $tokens, 'HASH', '[App1] Tokens' );
+
+        my $app = app;
+
+        ::isa_ok( $app, 'Dancer2::Core::App', 'Got app object inside App1' );
+
+        # we accept anything that goes to App1, even if not only to App1
+        ::like(
+            $tokens->{'request'}->param('to'),
+            qr/^App1/,
+            'Request reached to correct App (App1)',
+        );
+
+        ::is(
+            scalar @{ $app->template_engine->hooks->{$hook_name} },
+            1,
+            'App1 has a single before_template hook defined',
+        );
+
+        $tokens->{'myname'} = 'App1';
+        $called_hooks{'App1'}{'before_template'}++;
+    };
+
+    get '/' => sub {
+        template beforetemplate => { it => 'App1' }, { layout => undef };
+    };
+}
+
+{
+    package App2;
+    use Dancer2;
+
+    set views => $views;
+
+    hook before => sub { $called_hooks{'App2'}{'before'}++ };
+
+    hook before_template => sub {
+        my $tokens = shift;
+        ::isa_ok( $tokens, 'HASH', '[App2] Tokens' );
+
+        my $app = app;
+        ::isa_ok( $app, 'Dancer2::Core::App', 'Got app object inside App2' );
+
+        ::is(
+            $tokens->{'request'}->param('to'),
+            'App2',
+            'Request reached to correct App (App2)',
+        );
+
+        ::is(
+            scalar @{ $app->template_engine->hooks->{$hook_name} },
+            1,
+            'App2 has a single before_template hook defined',
+        );
+
+        $tokens->{'myname'} = 'App2';
+        $called_hooks{'App2'}{'before_template'}++;
+    };
+
+    get '/' => sub {
+        template beforetemplate => { it => 'App2' }, { layout => undef };
+    };
+
+    get '/2' => sub {
+        template beforetemplate => { it => 'App2' }, { layout => undef };
+    };
+}
+
+note 'Check App1 only calls first hook, not both'; {
+    # clear
+    %called_hooks = ();
+
+    my $app = App1->psgi_app;
+    isa_ok( $app, 'CODE', 'Got app for test' );
+
+    test_psgi $app, sub {
+        my $cb  = shift;
+        my $res = $cb->( GET '/?to=App1' );
+
+        is( $res->code, 200, '[GET /] Successful' );
+
+        is(
+            $res->content,
+            "App is App1, again, it is App1\n",
+            '[GET /] Correct content',
+        );
+
+        is_deeply(
+            \%called_hooks,
+            { App1 => { before => 1, before_template => 1 } },
+            'Only App1\'s before_template hook was called',
+        );
+    };
+}
+
+note 'Check App2 only calls second hook, not both'; {
+    # clear
+    %called_hooks = ();
+
+    my $app = App2->psgi_app;
+    isa_ok( $app, 'CODE', 'Got app for test' );
+
+    test_psgi $app, sub {
+        my $cb  = shift;
+        my $res = $cb->( GET '/?to=App2' );
+
+        is( $res->code, 200, '[GET /] Successful' );
+
+        is(
+            $res->content,
+            "App is App2, again, it is App2\n",
+            '[GET /] Correct content',
+        );
+
+        is_deeply(
+            \%called_hooks,
+            { App2 => { before => 1, before_template => 1 } },
+            'Only App2\'s before_template hook was called',
+        );
+    };
+}
+
+note 'Check both apps only call the first hook (correct app), not both'; {
+    # clear
+    %called_hooks = ();
+
+    my $app = Dancer2->psgi_app;
+    isa_ok( $app, 'CODE', 'Got app for test' );
+
+    test_psgi $app, sub {
+        my $cb  = shift;
+        my $res = $cb->( GET '/?to=App1:App2' );
+
+        is( $res->code, 200, '[GET /] Successful' );
+
+        is(
+            $res->content,
+            "App is App1, again, it is App1\n",
+            '[GET /] Correct content',
+        );
+
+        is_deeply(
+            \%called_hooks,
+            { App1 => { before => 1, before_template => 1 } },
+            'Only App1\'s before_template hook was called (full PSGI app)',
+        );
+    };
+}
+
+note 'Check both apps only call the second hook (correct app), not both'; {
+    # clear
+    %called_hooks = ();
+
+    my $app = Dancer2->psgi_app;
+    isa_ok( $app, 'CODE', 'Got app for test' );
+
+    test_psgi $app, sub {
+        my $cb  = shift;
+        my $res = $cb->( GET '/2?to=App2' );
+
+        is( $res->code, 200, '[GET /2] Successful' );
+
+        is(
+            $res->content,
+            "App is App2, again, it is App2\n",
+            '[GET /2] Correct content',
+        );
+
+        # INFO: %called_hooks will contain the count '3' for App1
+        #       because we called ->psgi_app a few times beforehand
+        #       which called ->finish on App1, which added more and more
+        #       handlers to be added to its routes. Since they use
+        #       megasplats, they *always* match and *always* run, but
+        #       since they have no actual code (there are autopage
+        #       templates that match, or static files), they don't
+        #       actually serve anything.
+        is_deeply(
+            \%called_hooks,
+            {
+                App2 => { before => 1, before_template => 1 },
+                App1 => { before => 3 },
+            },
+            'Only App2\'s before_template hook was called (full PSGI app)',
+        );
+    };
+}
+
@@ -0,0 +1,41 @@
+use strict;
+use warnings;
+use Test::More import => ['!pass'];
+use Plack::Test;
+use HTTP::Request::Common;
+
+{
+
+    package Foo;
+    use Dancer2;
+
+    hook before => sub { vars->{foo} = 'foo' };
+
+    post '/foo' => sub {
+        return vars->{foo} . 'foo' . vars->{baz};
+    };
+}
+
+{
+    package Bar;
+    use Dancer2 appname => 'Foo'; # Add routes and hooks to Foo.
+
+    hook before => sub { vars->{baz} = 'baz' };
+
+    post '/bar' => sub {
+        return vars->{foo} . 'bar' . vars->{baz};
+    }
+}
+
+my $app = Dancer2->psgi_app;
+
+test_psgi $app, sub {
+    my $cb  = shift;
+    for my $path ( qw/foo bar/ ) {
+        my $res = $cb->( POST "/$path" );
+        is $res->content, "foo${path}baz",
+            "Got app content path $path";
+    }
+};
+
+done_testing;
@@ -15,7 +15,7 @@ use HTTP::Request::Common;
     };
 }
 
-my $app = Dancer2->runner->psgi_app;
+my $app = Dancer2->psgi_app;
 is( ref $app, 'CODE', 'Got app' );
 
 test_psgi $app, sub {
@@ -41,7 +41,7 @@ subtest 'import flags' => sub {
 
         register 'foo' => sub { request };
     ";
-    like $@, qr{Bareword "request" not allowed while "strict subs"}, 
+    like $@, qr{Bareword "request" not allowed while "strict subs"},
       "with :no_dsl, the Dancer's dsl is not imported.";
 
     eval "
@@ -20,7 +20,7 @@ use HTTP::Request::Common;
     use t::lib::SubApp2 with => { session => engine('session') };
 }
 
-my $app = Dancer2->runner->psgi_app;
+my $app = Dancer2->psgi_app;
 is( ref $app, 'CODE', 'Got app' );
 
 test_psgi $app, sub {
@@ -23,7 +23,7 @@ subtest 'global and route keywords' => sub {
         foo_route;
     }
 
-    my $app = Dancer2->runner->psgi_app;
+    my $app = Dancer2->psgi_app;
     is( ref $app, 'CODE', 'Got app' );
 
     test_psgi $app, sub {
@@ -63,7 +63,7 @@ subtest 'plugin old syntax' => sub {
         around_get;
     }
 
-    my $app = Dancer2->runner->psgi_app;
+    my $app = Dancer2->psgi_app;
     is( ref $app, 'CODE', 'Got app' );
 
     test_psgi $app, sub {
@@ -83,7 +83,7 @@ subtest caller_dsl => sub {
         use t::lib::DancerPlugin;
     }
 
-    my $app = Dancer2->runner->psgi_app;
+    my $app = Dancer2->psgi_app;
     is( ref $app, 'CODE', 'Got app' );
 
     test_psgi $app, sub {
@@ -129,7 +129,7 @@ subtest 'hooks in plugins' => sub {
 
     }
 
-    my $app = Dancer2->runner->psgi_app;
+    my $app = Dancer2->psgi_app;
     is( ref $app, 'CODE', 'Got app' );
 
     test_psgi $app, sub {
@@ -0,0 +1,92 @@
+#!perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 25;
+use Plack::Test;
+use HTTP::Request::Common;
+
+{ package App1; use Dancer2; get '/1' => sub {1}; }
+{ package App2; use Dancer2; get '/2' => sub {2}; }
+{ package App3; use Dancer2; get '/3' => sub {3}; }
+
+sub is_available {
+    my ( $cb, @apps ) = @_;
+    foreach my $app (@apps) {
+        is( $cb->( GET "/$app" )->content, $app, "App$app available" );
+    }
+}
+
+sub isnt_available {
+    my ( $cb, @apps ) = @_;
+    foreach my $app (@apps) {
+        is(
+            $cb->( GET "/$app" )->code,
+            404,
+            "App$app is not available",
+        );
+    }
+}
+
+note 'All Apps'; {
+    my $app = Dancer2->psgi_app;
+    isa_ok( $app, 'CODE', 'Got PSGI app' );
+    test_psgi $app, sub {
+        my $cb = shift;
+        is_available( $cb, 1, 2, 3 );
+    };
+}
+
+note 'Specific Apps by parameters'; {
+    my @apps = @{ Dancer2->runner->apps }[ 0, 2 ];
+    is( scalar @apps, 2, 'Took two apps from the Runner' );
+    my $app = Dancer2->psgi_app(\@apps);
+    isa_ok( $app, 'CODE', 'Got PSGI app' );
+    test_psgi $app, sub {
+        my $cb = shift;
+        is_available( $cb, 1, 3 );
+        isnt_available( $cb, 2 );
+    };
+}
+
+note 'Specific Apps via App objects'; {
+    my $app = App2->psgi_app;
+    isa_ok( $app, 'CODE', 'Got PSGI app' );
+    test_psgi $app, sub {
+        my $cb = shift;
+        is_available( $cb, 2 );
+        isnt_available( $cb, 1, 3 );
+    };
+};
+
+note 'Specific apps by App names'; {
+    my $app = Dancer2->psgi_app( [ 'App1', 'App3' ] );
+    isa_ok( $app, 'CODE', 'Got PSGI app' );
+    test_psgi $app, sub {
+        my $cb = shift;
+        isnt_available( $cb, 2 );
+        is_available( $cb, 1, 3 );
+    };
+}
+
+note 'Specific apps by App names with regular expression, v1'; {
+    my $app = Dancer2->psgi_app( [ qr/^App1$/, qr/^App3$/ ] );
+    isa_ok( $app, 'CODE', 'Got PSGI app' );
+    test_psgi $app, sub {
+        my $cb = shift;
+        isnt_available( $cb, 2 );
+        is_available( $cb, 1, 3 );
+    };
+}
+
+note 'Specific apps by App names with regular expression, v2'; {
+    my $app = Dancer2->psgi_app( [ qr/^App(2|3)$/ ] );
+    isa_ok( $app, 'CODE', 'Got PSGI app' );
+    test_psgi $app, sub {
+        my $cb = shift;
+        isnt_available( $cb, 1 );
+        is_available( $cb, 2, 3 );
+    };
+}
+
@@ -16,7 +16,7 @@ subtest 'basic redirects' => sub {
         get '/redirect_querystring' => sub { redirect '/login?failed=1' };
     }
 
-    my $app = Dancer2->runner->psgi_app;
+    my $app = Dancer2->psgi_app;
     is( ref $app, 'CODE', 'Got app' );
 
     test_psgi $app, sub {
@@ -86,7 +86,7 @@ subtest 'absolute and relative redirects' => sub {
         get '/relative' => sub { redirect "somewhere/else"; };
     }
 
-    my $app = Dancer2->runner->psgi_app;
+    my $app = Dancer2->psgi_app;
     is( ref $app, 'CODE', 'Got app' );
 
     test_psgi $app, sub {
@@ -133,7 +133,7 @@ subtest 'redirect behind a proxy' => sub {
         get '/bounce' => sub { redirect '/test2' };
     }
 
-    my $app = Dancer2->runner->psgi_app;
+    my $app = Dancer2->psgi_app;
     is( ref $app, 'CODE', 'Got app' );
 
     test_psgi $app, sub {
@@ -198,7 +198,7 @@ subtest 'redirect behind multiple proxies' => sub {
         get '/bounce' => sub { redirect '/test2' };
     }
 
-    my $app = Dancer2->runner->psgi_app;
+    my $app = Dancer2->psgi_app;
     is( ref $app, 'CODE', 'Got app' );
 
     test_psgi $app, sub {
@@ -2,6 +2,7 @@ use strict;
 use warnings;
 use Test::More;
 
+use Dancer2::Core::App;
 use Dancer2::Core::Request;
 
 diag "If you want extra speed, install URL::Encode::XS"
@@ -67,7 +68,8 @@ sub run_test {
     note "tests cookies";
     is( keys %{ $req->cookies }, 2, "multiple cookies extracted" );
 
-    my $forward = $req->make_forward_to('/somewhere');
+    my $forward = Dancer2::Core::App->new( request => $req )
+                                    ->make_forward_to('/somewhere');
     is $forward->path_info, '/somewhere';
     is $forward->method,    'GET';
     note "tests for uri_for";
@@ -200,13 +202,19 @@ sub run_test {
     is_deeply scalar( $req->params ), { foo => 'bar', number => 42 },
       'params are parsed';
 
-    $req = $req->make_forward_to("/new/path");
+    $req = Dancer2::Core::App->new( request => $req )
+                             ->make_forward_to('/new/path');
     is $req->path,   '/new/path', 'path is changed';
     is $req->method, 'GET',       'method is unchanged';
     is_deeply scalar( $req->params ), { foo => 'bar', number => 42 },
       'params are not touched';
 
-    $req = $req->make_forward_to( "/new/path", undef, { method => 'POST' } );
+    $req = Dancer2::Core::App->new( request => $req )
+                             ->make_forward_to(
+                                '/new/path',
+                                undef,
+                                { method => 'POST' },
+                             );
 
     is $req->path,   '/new/path', 'path is changed';
     is $req->method, 'POST',      'method is changed';
@@ -5,24 +5,22 @@ use Test::Fatal;
 use File::Basename 'dirname';
 
 use Dancer2::Core::Runner;
-my $runner = Dancer2::Core::Runner->new( caller => __FILE__ );
+my $runner = Dancer2::Core::Runner->new();
 
 isa_ok $runner, 'Dancer2::Core::Runner';
-is $runner->location, File::Spec->rel2abs( dirname(__FILE__) ),
-  "location is set correctly";
 
 note "testing environments";
 is $runner->environment, 'development';
 
 {
     local $ENV{DANCER_ENVIRONMENT} = 'production';
-    my $runner = Dancer2::Core::Runner->new( caller => __FILE__ );
+    my $runner = Dancer2::Core::Runner->new();
     is $runner->environment, 'production';
 }
 
 {
     local $ENV{PLACK_ENV} = 'foo';
-    my $runner = Dancer2::Core::Runner->new( caller => __FILE__ );
+    my $runner = Dancer2::Core::Runner->new();
     is $runner->environment, 'foo';
 }
 
@@ -18,7 +18,7 @@ use HTTP::Request::Common;
     get '/to_json' => sub { to_json({bar => 'baz'}, {pretty => 1}) };
 }
 
-my $app = Dancer2->runner->psgi_app;
+my $app = Dancer2->psgi_app;
 is( ref $app, 'CODE', 'Got app' );
 
 test_psgi $app, sub {
@@ -69,4 +69,3 @@ is(
     'text/x-data-dumper',
     'content-type is set correctly',
 );
-
@@ -2,32 +2,69 @@ use strict;
 use warnings;
 
 use Test::More;
+use Plack::Test;
+use HTTP::Request::Common;
 
-require Dancer2::Serializer::JSON;
+use Dancer2::Serializer::JSON;
+
+# config
+{
+    package MyApp;
+
+    use Dancer2;
+    our $entity;
+
+    set engines => {
+        serializer => {
+            JSON => {
+                pretty => 1,
+            }
+        }
+    };
+    set serializer => 'JSON';
+
+    get '/serialize'  => sub {
+        return $entity;
+    };
+}
 
 my @tests = (
     {   entity  => { a      => 1, b => 2, },
         options => { pretty => 1 },
+        name    => "basic hash",
     },
-    {   entity =>
+    {   entity  =>
           { c => [ { d => 3, e => { f => 4, g => 'word', } } ], h => 6 },
         options => { pretty => 1 },
+        name    => "nested",
     }
 );
 
+my $app = Dancer2->psgi_app;
+
 for my $test (@tests) {
+    my $expected = JSON::to_json( $test->{entity}, $test->{options} );
+
+    # Helpers pass options
     my $actual =
       Dancer2::Serializer::JSON::to_json( $test->{entity}, $test->{options} );
-    my $expected = JSON::to_json( $test->{entity}, $test->{options} );
-    is( $actual, $expected );
-}
+    is( $actual, $expected, "to_json: $test->{name}" );
 
-use Dancer2::Core::Response;
-my $resp = Dancer2::Core::Response->new(
-    content => '---',
-    serializer => Dancer2::Serializer::JSON->new(),
-);
+    # Options from config
+    my $serializer = Dancer2::Serializer::JSON->new(config => $test->{options});
+    my $output = $serializer->serialize( $test->{entity} );
+    is( $output, $expected, "serialize: $test->{name}" );
+
+    $MyApp::entity = $test->{entity};
+    test_psgi $app, sub {
+        my $cb = shift;
+
+        my $res = $cb->( GET '/serialize' );
+        is($res->content, $expected,
+          "serialized content in response: $test->{name}");
+    };
+
+}
 
-$resp->serialize();
 
 done_testing();
@@ -26,7 +26,7 @@ use YAML;
     };
 }
 
-my $app = Dancer2->runner->psgi_app;
+my $app = Dancer2->psgi_app;
 is( ref $app, 'CODE', 'Got app' );
 
 test_psgi $app, sub {
@@ -83,4 +83,3 @@ test_psgi $app, sub {
     }
 
 }
-
@@ -68,7 +68,7 @@ for my $session_expires ( 3600, '1h', '1 hour' ) {
             use Dancer2;
 
             get '/has_session' => sub {
-                return context->has_session;
+                return app->has_session;
             };
 
             get '/foo/set_session/*' => sub {
@@ -83,7 +83,7 @@ for my $session_expires ( 3600, '1h', '1 hour' ) {
 
             get '/foo/destroy_session' => sub {
                 my $name = session('name') || '';
-                context->destroy_session;
+                app->destroy_session;
                 return "destroyed='$name'";
             };
 
@@ -82,7 +82,7 @@ foreach my $engine (@engines) {
             };
 
             get '/cleanup' => sub {
-                context->destroy_session;
+                app->destroy_session;
                 return scalar(@to_destroy);
             };
 
@@ -2,61 +2,184 @@ use Test::More;
 use strict;
 use warnings;
 use LWP::UserAgent;
+use LWP::Protocol::PSGI;
 
-use Test::TCP 1.13;
 use File::Temp;
 
 my $tempdir = File::Temp::tempdir( CLEANUP => 1, TMPDIR => 1 );
 
-my $server = sub {
-    my $port = shift;
-
+{
+    package Test::Forward::Single;
     use Dancer2;
+
     set session => 'Simple';
 
-    get '/set_chained_session' => sub {
-        session 'zbr' => 'ugh';
-        forward '/set_session';
+    get '/main' => sub {
+        session foo => 'Single/main';
+        forward '/outer';
     };
 
-    get '/set_session' => sub {
-        session 'foo' => 'bar';
-        forward '/get_session';
+    get '/outer' => sub {
+        session bar => 'Single/outer';
+        forward '/inner';
     };
 
-    get '/get_session' => sub {
-        session 'more' => 'one';
-        sprintf("%s:%s:%s", session("more"), session('foo') , session('zbr')||"")
+    get '/inner' => sub {
+        session baz => 'Single/inner';
+        return join ':', map +( session($_) || '' ), qw<foo bar baz>;
     };
 
     get '/clear' => sub {
-        session "foo" => undef;
-        session "zbr" => undef;
-        session "more" => undef;
+        session foo => undef;
+        session bar => undef;
+        session baz => undef;
     };
+}
 
-    # we're overiding a RO attribute only for this test!
-    Dancer2->runner->{'port'} = $port;
-    start;
-};
+{
+    package Test::Forward::Multi::SameCookieName;
+    use Dancer2;
+    set session => 'Simple';
+    prefix '/same';
 
-my $client = sub {
-    my $port = shift;
-    my $ua = LWP::UserAgent->new;
-    $ua->cookie_jar( { file => "$tempdir/.cookies.txt" } );
+    get '/main' => sub {
+        session foo => 'SameCookieName/main';
+        forward '/outer';
+    };
 
-    my $res = $ua->get("http://127.0.0.1:$port/set_chained_session");
-    is $res->content, q{one:bar:ugh}, 'Session value preserved after chained forwards';
+    get '/bad_chain' => sub {
+        session foo => 'SameCookieName/bad_chain';
+        forward '/other/main';
+    };
+}
 
-    $res = $ua->get("http://127.0.0.1:$port/get_session");
-    is $res->content, q{one:bar:ugh}, 'Session values preserved between calls';
+{
+    package Test::Forward::Multi::OtherCookieName;
+    use Dancer2;
+    set engines => {
+        session => { Simple => { cookie_name => 'session.dancer' } }
+    };
 
-    $res = $ua->get("http://127.0.0.1:$port/clear");
+    set session => 'Simple';
+    prefix '/other';
 
-    $res = $ua->get("http://127.0.0.1:$port/set_session");
-    is $res->content, q{one:bar:}, 'Session value preserved after forward from route';
-};
+    get '/main' => sub {
+        session foo => 'OtherCookieName/main';
+		# Forwards to another app with different cookie name
+        forward '/outer';
+    };
+
+    get '/clear' => sub {
+        session foo => undef;
+        session bar => undef;
+        session baz => undef;
+    };
+}
+
+# base uri for all requests.
+my $base = "http://localhost:3000";
 
-Test::TCP::test_tcp( client => $client, server => $server);
+note "Forwards within a single app"; {
+    # Register single app as the handler for all LWP requests.
+    LWP::Protocol::PSGI->register( Test::Forward::Single->psgi_app );
+    my $ua = LWP::UserAgent->new;
+    my $cookies_store = "$tempdir/.cookies.txt";
+    $ua->cookie_jar( { file => $cookies_store } );
+
+    my $res = $ua->get("$base/main");
+    is(
+        $res->content,
+        q{Single/main:Single/outer:Single/inner},
+        'session value preserved after chained forwards',
+    );
+
+    $res = $ua->get("$base/inner");
+    is(
+        $res->content,
+        q{Single/main:Single/outer:Single/inner},
+        'session values preserved between calls',
+    );
+
+    $res = $ua->get("$base/clear");
+
+    $res = $ua->get("$base/outer");
+    is(
+        $res->content,
+        q{:Single/outer:Single/inner},
+        'session value preserved after forward from route',
+    );
+
+    # cleanup.
+    -e $cookies_store and unlink $cookies_store;
+}
+
+# Register all apps as the handler for all LWP requests.
+LWP::Protocol::PSGI->register( Dancer2->psgi_app );
+note "Forwards between multiple apps using the same cookie name"; {
+    my $ua = LWP::UserAgent->new;
+    my $cookies_store = "$tempdir/.cookies.txt";
+    $ua->cookie_jar( { file => $cookies_store } );
+
+    my $res = $ua->get("$base/same/main");
+    is(
+        $res->content,
+        q{SameCookieName/main:Single/outer:Single/inner},
+        'session value preserved after chained forwards between apps',
+    );
+
+    $res = $ua->get("$base/outer");
+    is(
+        $res->content,
+        q{SameCookieName/main:Single/outer:Single/inner},
+        'session value preserved after forward from route',
+    );
+
+    # cleanup.
+    -e $cookies_store and unlink $cookies_store;
+}
+
+note "Forwards between multiple apps using different cookie names"; {
+    my $ua = LWP::UserAgent->new;
+    my $cookies_store = "$tempdir/.cookies.txt";
+    $ua->cookie_jar( { file => $cookies_store } );
+
+    my $res = $ua->get("$base/other/main");
+    is(
+        $res->content,
+        q{:Single/outer:Single/inner},
+        'session value only from forwarded app',
+    );
+
+    # cleanup.
+    -e $cookies_store and unlink $cookies_store;
+}
+
+# we need to make sure B doesn't override A when forwarding to C
+# A -> B -> C
+# This means that A (cookie_name "Homer")
+#   forwarding to B (cookie_name "Marge")
+#   forwarding to C (cookie_name again "Homer")
+#   will cause a problem because we will lose "Homer" session data,
+#   because it will be overwritten by "Marge" session data.
+# Suddenly A and C cannot communicate because it was flogged.
+#
+# if A -> Single, B -> OtherCookieName, C -> SameCookieName
+# call A, create session, then forward to B, create session,
+# then forward to C, check has values as in A and C
+note "Forwards between multiple apps using multiple different cookie names"; {
+    my $ua = LWP::UserAgent->new;
+    my $cookies_store = "$tempdir/.cookies.txt";
+    $ua->cookie_jar( { file => $cookies_store } );
+
+    my $res = $ua->get("$base/same/bad_chain");
+    is(
+        $res->content,
+        q{SameCookieName/bad_chain:Single/outer:Single/inner},
+        'session value only from apps with same session cookie name',
+    );
+
+    # cleanup.
+    -e $cookies_store and unlink $cookies_store;
+}
 
 done_testing;
@@ -68,7 +68,7 @@ sub get_app_for_engine {
       return "ok";
     };
     get '/destroy_session' => sub {
-      context->destroy_session;
+      app->destroy_session;
       return "ok";
     };
 
@@ -147,12 +147,12 @@ foreach my $engine (@engines) {
 
             get '/destroy_session' => sub {
                 my $name = session('name') || '';
-                context->destroy_session;
+                app->destroy_session;
                 return "destroyed='$name'";
             };
 
             get '/churn_session' => sub {
-                context->destroy_session;
+                app->destroy_session;
                 session name => 'damian';
                 return "churned";
             };
@@ -0,0 +1,2 @@
+---
+name: damian
@@ -0,0 +1,2 @@
+---
+name: damian
@@ -0,0 +1,2 @@
+---
+name: damian
@@ -0,0 +1,2 @@
+---
+name: damian
@@ -0,0 +1,2 @@
+---
+name: damian
@@ -0,0 +1,2 @@
+---
+name: damian
@@ -0,0 +1,2 @@
+---
+name: damian
@@ -0,0 +1,2 @@
+---
+name: damian
@@ -0,0 +1,2 @@
+---
+name: damian
@@ -0,0 +1,2 @@
+---
+name: damian
@@ -0,0 +1,2 @@
+---
+name: damian
@@ -0,0 +1,2 @@
+---
+name: damian
@@ -0,0 +1,2 @@
+---
+name: damian
@@ -20,7 +20,7 @@ my @splat;
     };
 }
 
-my $app = Dancer2->runner->psgi_app;
+my $app = Dancer2->psgi_app;
 is( ref $app, 'CODE', 'Got app' );
 
 test_psgi $app, sub {
@@ -67,9 +67,19 @@ $tt->add_hook(
     )
 );
 
-my $space = " ";
-my $result = $tt->process( 'index.tt', { var => 42 } );
-is $result, "layout top
+{
+    package Bar;
+    use Dancer2;
+
+    # set template engine for first app
+    Dancer2->runner->apps->[0]->set_template_engine($tt);
+
+    get '/' => sub { template index => { var => 42 } };
+}
+
+my $app    = Dancer2->psgi_app;
+my $space  = " ";
+my $result = "layout top
 var = 42
 before_layout_render = 1
 ---
@@ -85,6 +95,17 @@ layout bottom
 
 content added in after_layout_render";
 
+test_psgi $app, sub {
+    my $cb = shift;
+
+    is(
+        $cb->( GET '/' )->content,
+        $result,
+        '[GET /] Correct content with template hooks',
+    );
+};
+
+
 {
 
     package Foo;
@@ -97,7 +118,7 @@ content added in after_layout_render";
     get '/get_views_via_settings' => sub { set 'views' };
 }
 
-my $app = Dancer2->runner->psgi_app;
+$app = Dancer2->psgi_app;
 is( ref $app, 'CODE', 'Got app' );
 
 test_psgi $app, sub {
@@ -24,7 +24,7 @@ my $views =
     set foo      => "in settings";
 
     get '/view/:foo' => sub {
-        var foo     => "in var";
+        var     foo => "in var";
         session foo => "in session";
         template "tokens";
     };
@@ -37,7 +37,7 @@ params.foo: 42
 session.foo in session
 vars.foo: in var";
 
-my $app = Dancer2->runner->psgi_app;
+my $app = Dancer2->psgi_app;
 is( ref $app, 'CODE', 'Got app' );
 
 test_psgi $app, sub {
@@ -17,7 +17,7 @@ use HTTP::Request::Common;
     };
 }
 
-my $app = Dancer2->runner->psgi_app;
+my $app = Dancer2->psgi_app;
 is( ref $app, 'CODE', 'Got app' );
 
 test_psgi $app, sub {
@@ -11,7 +11,7 @@ use HTTP::Request::Common;
     };
 }
 
-my $app = Dancer2->runner->psgi_app;
+my $app = Dancer2->psgi_app;
 is( ref $app, 'CODE', 'Got app' );
 
 test_psgi $app, sub {
@@ -23,13 +23,12 @@ plan tests => 3;
     };
 }
 
-my $app = Dancer2->runner->psgi_app;
+my $app = Dancer2->psgi_app;
 is( ref $app, 'CODE', 'Got app' );
- 
+
 test_psgi $app, sub {
     my $cb = shift;
 
     is( $cb->( GET '/bar' )->content, 'foo', 'foo' );
     is( $cb->( GET '/baz' )->content, 'ugh', 'ugh' );
 };
-
@@ -0,0 +1 @@
+App is [% myname %], again, it is [% it %]